1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008, 2009 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 3 of the License, or
14 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
30 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
34 (defvar w3m-minor-mode-map
)
37 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
39 (let ((recursive-load-depth-limit 100))
52 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
53 (autoload 'gnus-button-mailto
"gnus-msg")
54 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
55 (autoload 'parse-time-string
"parse-time" nil nil
)
56 (autoload 'ansi-color-apply-on-region
"ansi-color")
57 (autoload 'mm-url-insert-file-contents-external
"mm-url")
58 (autoload 'mm-extern-cache-contents
"mm-extern")
60 (defgroup gnus-article nil
62 :link
'(custom-manual "(gnus)Article Buffer")
65 (defgroup gnus-article-treat nil
66 "Treating article parts."
67 :link
'(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-hiding nil
71 "Hiding article parts."
72 :link
'(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-highlight nil
76 "Article highlighting."
77 :link
'(custom-manual "(gnus)Article Highlighting")
81 (defgroup gnus-article-signature nil
83 :link
'(custom-manual "(gnus)Article Signature")
86 (defgroup gnus-article-headers nil
88 :link
'(custom-manual "(gnus)Hiding Headers")
91 (defgroup gnus-article-washing nil
92 "Special commands on articles."
93 :link
'(custom-manual "(gnus)Article Washing")
96 (defgroup gnus-article-emphasis nil
97 "Fontisizing articles."
98 :link
'(custom-manual "(gnus)Article Fontisizing")
101 (defgroup gnus-article-saving nil
103 :link
'(custom-manual "(gnus)Saving Articles")
104 :group
'gnus-article
)
106 (defgroup gnus-article-mime nil
107 "Worshiping the MIME wonder."
108 :link
'(custom-manual "(gnus)Using MIME")
109 :group
'gnus-article
)
111 (defgroup gnus-article-buttons nil
112 "Pushable buttons in the article buffer."
113 :link
'(custom-manual "(gnus)Article Buttons")
114 :group
'gnus-article
)
116 (defgroup gnus-article-various nil
117 "Other article options."
118 :link
'(custom-manual "(gnus)Misc Article")
119 :group
'gnus-article
)
121 (defcustom gnus-ignored-headers
124 (concat "^" header
":"))
125 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
126 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
127 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
128 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
129 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
130 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
131 "X-Attribution" "X-Originating-IP" "Delivered-To"
132 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
133 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
134 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
135 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
136 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
137 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
138 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
139 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
140 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
141 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
142 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
143 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
144 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
145 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
146 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
147 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
148 "List-[A-Za-z]+" "X-Listprocessor-Version"
149 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
150 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
151 "X-Received" "Content-length" "X-precedence"
152 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
153 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
154 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
155 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
156 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
157 "X-Content-length" "X-Posting-Agent" "Original-Received"
158 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
159 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
160 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
161 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
162 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
163 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
164 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
165 "Envelope-Sender" "Envelope-Recipients"))
166 "*All headers that start with this regexp will be hidden.
167 This variable can also be a list of regexps of headers to be ignored.
168 If `gnus-visible-headers' is non-nil, this variable will be ignored."
169 :type
'(choice :custom-show nil
172 :group
'gnus-article-hiding
)
174 (defcustom gnus-visible-headers
175 "^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:"
176 "*All headers that do not match this regexp will be hidden.
177 This variable can also be a list of regexp of headers to remain visible.
178 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
180 (repeat :value-to-internal
(lambda (widget value
)
181 (custom-split-regexp-maybe value
))
182 :match
(lambda (widget value
)
184 (widget-editable-list-match widget value
)))
186 (const :tag
"Use gnus-ignored-headers" nil
)
188 :group
'gnus-article-hiding
)
190 (defcustom gnus-sorted-header-list
191 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
192 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
193 "*This variable is a list of regular expressions.
194 If it is non-nil, headers that match the regular expressions will
195 be placed first in the article buffer in the sequence specified by
197 :type
'(repeat regexp
)
198 :group
'gnus-article-hiding
)
200 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
201 "Headers that are only to be displayed if they have interesting data.
202 Possible values in this list are:
204 'empty Headers with no content.
205 'newsgroups Newsgroup identical to Gnus group.
206 'to-address To identical to To-address.
207 'to-list To identical to To-list.
208 'cc-list CC identical to To-list.
209 'followup-to Followup-to identical to Newsgroups.
210 'reply-to Reply-to identical to From.
211 'date Date less than four days old.
212 'long-to To and/or Cc longer than 1024 characters.
213 'many-to Multiple To and/or Cc."
214 :type
'(set (const :tag
"Headers with no content." empty
)
215 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
216 (const :tag
"To identical to To-address." to-address
)
217 (const :tag
"To identical to To-list." to-list
)
218 (const :tag
"CC identical to To-list." cc-list
)
219 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
220 (const :tag
"Reply-to identical to From." reply-to
)
221 (const :tag
"Date less than four days old." date
)
222 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
223 (const :tag
"Multiple To and/or Cc headers." many-to
))
224 :group
'gnus-article-hiding
)
226 (defcustom gnus-article-skip-boring nil
227 "Skip over text that is not worth reading.
228 By default, if you set this t, then Gnus will display citations and
229 signatures, but will never scroll down to show you a page consisting
230 only of boring text. Boring text is controlled by
231 `gnus-article-boring-faces'."
234 :group
'gnus-article-hiding
)
236 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
237 "Regexp matching signature separator.
238 This can also be a list of regexps. In that case, it will be checked
239 from head to tail looking for a separator. Searches will be done from
240 the end of the buffer."
241 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
243 (repeat :tag
"List of regexp" regexp
))
244 :group
'gnus-article-signature
)
246 (defcustom gnus-signature-limit nil
247 "Provide a limit to what is considered a signature.
248 If it is a number, no signature may not be longer (in characters) than
249 that number. If it is a floating point number, no signature may be
250 longer (in lines) than that number. If it is a function, the function
251 will be called without any parameters, and if it returns nil, there is
252 no signature in the buffer. If it is a string, it will be used as a
253 regexp. If it matches, the text in question is not a signature.
255 This can also be a list of the above values."
256 :type
'(choice (const nil
)
260 (regexp :value
".*"))
261 :group
'gnus-article-signature
)
263 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
264 "Property list to use for hiding text."
266 :group
'gnus-article-hiding
)
268 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
269 ;; frames in a session.
270 (defcustom gnus-article-x-face-command
271 (if (featurep 'xemacs
)
272 (if (or (gnus-image-type-available-p 'xface
)
273 (gnus-image-type-available-p 'pbm
))
274 'gnus-display-x-face-in-from
275 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
276 (if (gnus-image-type-available-p 'pbm
)
277 'gnus-display-x-face-in-from
278 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
280 "*String or function to be executed to display an X-Face header.
281 If it is a string, the command will be executed in a sub-shell
282 asynchronously. The compressed face will be piped to this command."
283 :type
`(choice string
284 (function-item gnus-display-x-face-in-from
)
288 :group
'gnus-article-washing
)
290 (defcustom gnus-article-x-face-too-ugly nil
291 "Regexp matching posters whose face shouldn't be shown automatically."
292 :type
'(choice regexp
(const nil
))
293 :group
'gnus-article-washing
)
295 (defcustom gnus-article-banner-alist nil
296 "Banner alist for stripping.
298 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
300 :type
'(repeat (cons symbol regexp
))
301 :group
'gnus-article-washing
)
303 (gnus-define-group-parameter
306 "Alist of regexps (to match group names) and banner."
307 :variable-group gnus-article-washing
309 '(choice :tag
"Banner"
311 (const :tag
"Remove signature" signature
)
312 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
314 (const :tag
"None" nil
))
316 "If non-nil, specify how to remove `banners' from articles.
318 Symbol `signature' means to remove signatures delimited by
319 `gnus-signature-separator'. Any other symbol is used to look up a
320 regular expression to match the banner in `gnus-article-banner-alist'.
321 A string is used as a regular expression to match the banner
324 (defcustom gnus-article-address-banner-alist nil
325 "Alist of mail addresses and banners.
326 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
327 to match a mail address in the From: header, BANNER is one of a symbol
328 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
329 If ADDRESS matches author's mail address, it will remove things like
330 advertisements. For example:
332 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
336 (regexp :tag
"Address")
337 (choice :tag
"Banner" :value nil
338 (const :tag
"Remove signature" signature
)
339 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
341 (const :tag
"None" nil
))))
343 :group
'gnus-article-washing
)
345 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
347 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
348 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
351 (defun gnus-emphasis-custom-value-to-external (value)
352 (gnus-emphasis-custom-with-format
353 (if (consp (car value
))
354 (list (format format
(car (car value
)) (cdr (car value
)))
356 (if (nth 1 value
) 2 3)
360 (defun gnus-emphasis-custom-value-to-internal (value)
361 (gnus-emphasis-custom-with-format
362 (let ((regexp (concat "\\`"
363 (format (regexp-quote format
)
364 "\\([^()]+\\)" "\\([^()]+\\)")
367 (if (string-match regexp
(setq pattern
(car value
)))
368 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
373 (defcustom gnus-emphasis-alist
375 '(("\\*" "\\*" bold nil
2)
378 ("_/" "/_" underline-italic
)
379 ("_\\*" "\\*_" underline-bold
)
380 ("\\*/" "/\\*" bold-italic
)
381 ("_\\*/" "/\\*_" underline-bold-italic
))))
383 (gnus-emphasis-custom-with-format
384 (mapcar (lambda (spec)
385 (list (format format
(car spec
) (cadr spec
))
388 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
390 '(;; I've never seen anyone use this strikethru convention whereas I've
391 ;; several times seen it triggered by normal text. --Stef
392 ;; Miles suggests that this form is sometimes used but for italics,
393 ;; so maybe we should map it to `italic'.
394 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
395 ;; 2 3 gnus-emphasis-strikethru)
396 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
397 2 3 gnus-emphasis-underline
))))
398 "*Alist that says how to fontify certain phrases.
399 Each item looks like this:
401 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
403 The first element is a regular expression to be matched. The second
404 is a number that says what regular expression grouping used to find
405 the entire emphasized word. The third is a number that says what
406 regexp grouping should be displayed and highlighted. The fourth
407 is the face used for highlighting."
411 :format
"%[Customizing Style%]\n%v"
413 (group :tag
"Default"
414 :value
("" 0 0 default
)
417 (let ((value (widget-get
418 (cadr (widget-get (widget-get widget
:parent
)
421 (if (not (eq (nth 2 value
) 'default
))
425 (gnus-emphasis-custom-value-to-external value
))))
426 (widget-group-value-create widget
))
428 (integer :format
"Match group: %v")
429 (integer :format
"Emphasize group: %v")
432 :value
(("_" .
"_") nil default
)
434 (regexp :format
"Start regexp: %v")
435 (regexp :format
"End regexp: %v"))
436 (boolean :format
"Show start and end patterns: %[%v%]\n"
437 :on
" On " :off
" Off ")
439 :get
(lambda (symbol)
440 (mapcar 'gnus-emphasis-custom-value-to-internal
441 (default-value symbol
)))
442 :set
(lambda (symbol value
)
443 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
445 :group
'gnus-article-emphasis
)
447 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
448 "A regexp to describe whitespace which should not be emphasized.
449 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
450 The former avoids underlining of leading and trailing whitespace,
451 and the latter avoids underlining any whitespace at all."
453 :group
'gnus-article-emphasis
456 (defface gnus-emphasis-bold
'((t (:bold t
)))
457 "Face used for displaying strong emphasized text (*word*)."
458 :group
'gnus-article-emphasis
)
460 (defface gnus-emphasis-italic
'((t (:italic t
)))
461 "Face used for displaying italic emphasized text (/word/)."
462 :group
'gnus-article-emphasis
)
464 (defface gnus-emphasis-underline
'((t (:underline t
)))
465 "Face used for displaying underlined emphasized text (_word_)."
466 :group
'gnus-article-emphasis
)
468 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
469 "Face used for displaying underlined bold emphasized text (_*word*_)."
470 :group
'gnus-article-emphasis
)
472 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
473 "Face used for displaying underlined italic emphasized text (_/word/_)."
474 :group
'gnus-article-emphasis
)
476 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
477 "Face used for displaying bold italic emphasized text (/*word*/)."
478 :group
'gnus-article-emphasis
)
480 (defface gnus-emphasis-underline-bold-italic
481 '((t (:bold t
:italic t
:underline t
)))
482 "Face used for displaying underlined bold italic emphasized text.
483 Example: (_/*word*/_)."
484 :group
'gnus-article-emphasis
)
486 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
487 '((t (:strikethru t
)))
488 '((t (:strike-through t
))))
489 "Face used for displaying strike-through text (-word-)."
490 :group
'gnus-article-emphasis
)
492 (defface gnus-emphasis-highlight-words
493 '((t (:background
"black" :foreground
"yellow")))
494 "Face used for displaying highlighted words."
495 :group
'gnus-article-emphasis
)
497 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
498 "Format for display of Date headers in article bodies.
499 See `format-time-string' for the possible values.
501 The variable can also be function, which should return a complete Date
502 header. The function is called with one argument, the time, which can
503 be fed to `format-time-string'."
504 :type
'(choice string function
)
505 :link
'(custom-manual "(gnus)Article Date")
506 :group
'gnus-article-washing
)
508 (defcustom gnus-save-all-headers t
509 "*If non-nil, don't remove any headers before saving.
510 This will be overridden by the `:headers' property that the symbol of
511 the saver function, which is specified by `gnus-default-article-saver',
513 :group
'gnus-article-saving
516 (defcustom gnus-prompt-before-saving
'always
517 "*This variable says how much prompting is to be done when saving articles.
518 If it is nil, no prompting will be done, and the articles will be
519 saved to the default files. If this variable is `always', each and
520 every article that is saved will be preceded by a prompt, even when
521 saving large batches of articles. If this variable is neither nil not
522 `always', there the user will be prompted once for a file name for
523 each invocation of the saving commands."
524 :group
'gnus-article-saving
525 :type
'(choice (item always
)
526 (item :tag
"never" nil
)
527 (sexp :tag
"once" :format
"%t\n" :value t
)))
529 (defcustom gnus-saved-headers gnus-visible-headers
530 "Headers to keep if `gnus-save-all-headers' is nil.
531 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
532 If that variable is nil, however, all headers that match this regexp
533 will be kept while the rest will be deleted before saving. This and
534 `gnus-save-all-headers' will be overridden by the `:headers' property
535 that the symbol of the saver function, which is specified by
536 `gnus-default-article-saver', might have."
537 :group
'gnus-article-saving
540 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
541 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
542 "A function to save articles in your favourite format.
543 The function will be called by way of the `gnus-summary-save-article'
544 command, and friends such as `gnus-summary-save-article-rmail'.
546 Gnus provides the following functions:
548 * gnus-summary-save-in-rmail (Rmail format)
549 * gnus-summary-save-in-mail (Unix mail format)
550 * gnus-summary-save-in-folder (MH folder)
551 * gnus-summary-save-in-file (article format)
552 * gnus-summary-save-body-in-file (article body)
553 * gnus-summary-save-in-vm (use VM's folder format)
554 * gnus-summary-write-to-file (article format -- overwrite)
555 * gnus-summary-write-body-to-file (article body -- overwrite)
556 * gnus-summary-save-in-pipe (article format)
558 The symbol of each function may have the following properties:
561 The value non-nil means save decoded articles. This is meaningful
562 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
563 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
564 `gnus-summary-save-in-pipe'.
567 The value specifies an alternative function which appends, not
568 overwrites, articles to a file. This implies that when saving many
569 articles at a time, `gnus-prompt-before-saving' is bound to t and all
570 articles are saved in a single file. This is meaningful only with
571 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
574 The value specifies the symbol of a variable of which the value
575 specifies headers to be saved. If it is omitted,
576 `gnus-save-all-headers' and `gnus-saved-headers' control what
577 headers should be saved."
578 :group
'gnus-article-saving
579 :type
'(radio (function-item gnus-summary-save-in-rmail
)
580 (function-item gnus-summary-save-in-mail
)
581 (function-item gnus-summary-save-in-folder
)
582 (function-item gnus-summary-save-in-file
)
583 (function-item gnus-summary-save-body-in-file
)
584 (function-item gnus-summary-save-in-vm
)
585 (function-item gnus-summary-write-to-file
)
586 (function-item gnus-summary-write-body-to-file
)
587 (function-item gnus-summary-save-in-pipe
)
590 (defcustom gnus-article-save-coding-system
591 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
592 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
593 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
594 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
595 "Coding system used to save decoded articles to a file.
597 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
598 which can safely encode any characters in text. This is used by the
601 * gnus-summary-save-article-file
602 * gnus-summary-save-article-body-file
603 * gnus-summary-write-article-file
604 * gnus-summary-write-article-body-file
606 and the functions to which you may set `gnus-default-article-saver':
608 * gnus-summary-save-in-file
609 * gnus-summary-save-body-in-file
610 * gnus-summary-write-to-file
611 * gnus-summary-write-body-to-file
613 Those commands and functions save just text displayed in the article
614 buffer to a file if the value of this variable is non-nil. Note that
615 buttonized MIME parts will be lost in a saved file in that case.
616 Otherwise, raw articles will be saved."
617 :group
'gnus-article-saving
619 :format
"%{%t%}:\n %[Value Menu%] %v"
620 (const :tag
"Save raw articles" nil
)
623 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
624 '((const :tag
"UTF-8" utf-8
)
625 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
626 (const :tag
"Emacs internal" emacs-mule
)
627 (const :tag
"escape-quoted" escape-quoted
))))
628 (symbol :tag
"Coding system")))
630 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
631 "A function generating a file name to save articles in Rmail format.
632 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
633 :group
'gnus-article-saving
636 (defcustom gnus-mail-save-name
'gnus-plain-save-name
637 "A function generating a file name to save articles in Unix mail format.
638 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
639 :group
'gnus-article-saving
642 (defcustom gnus-folder-save-name
'gnus-folder-save-name
643 "A function generating a file name to save articles in MH folder.
644 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
645 :group
'gnus-article-saving
648 (defcustom gnus-file-save-name
'gnus-numeric-save-name
649 "A function generating a file name to save articles in article format.
650 The function is called with NEWSGROUP, HEADERS, and optional
652 :group
'gnus-article-saving
655 (defcustom gnus-split-methods
656 '((gnus-article-archive-name)
657 (gnus-article-nndoc-name))
658 "*Variable used to suggest where articles are to be saved.
659 For instance, if you would like to save articles related to Gnus in
660 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
661 you could set this variable to something like:
663 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
664 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
666 This variable is an alist where the key is the match and the
667 value is a list of possible files to save in if the match is
670 If the match is a string, it is used as a regexp match on the
671 article. If the match is a symbol, that symbol will be funcalled
672 from the buffer of the article to be saved with the newsgroup as the
673 parameter. If it is a list, it will be evaled in the same buffer.
675 If this form or function returns a string, this string will be used as a
676 possible file name; and if it returns a non-nil list, that list will be
677 used as possible file names."
678 :group
'gnus-article-saving
679 :type
'(repeat (choice (list :value
(fun) function
)
680 (cons :value
("" "") regexp
(repeat string
))
683 (defcustom gnus-page-delimiter
"^\^L"
684 "*Regexp describing what to use as article page delimiters.
685 The default value is \"^\^L\", which is a form linefeed at the
686 beginning of a line."
688 :group
'gnus-article-various
)
690 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
691 "*The format specification for the article mode line.
692 See `gnus-summary-mode-line-format' for a closer description.
694 The following additional specs are available:
696 %w The article washing status.
697 %m The number of MIME parts in the article."
699 :group
'gnus-article-various
)
701 (defcustom gnus-article-mode-hook nil
702 "*A hook for Gnus article mode."
704 :group
'gnus-article-various
)
706 (when (featurep 'xemacs
)
707 ;; Extracted from gnus-xmas-define in order to preserve user settings
708 (when (fboundp 'turn-off-scroll-in-place
)
709 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
710 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
711 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
713 (defcustom gnus-article-menu-hook nil
714 "*Hook run after the creation of the article mode menu."
716 :group
'gnus-article-various
)
718 (defcustom gnus-article-prepare-hook nil
719 "*A hook called after an article has been prepared in the article buffer."
721 :group
'gnus-article-various
)
723 (defcustom gnus-copy-article-ignored-headers nil
724 "List of headers to be removed when copying an article.
725 Each element is a regular expression."
726 :version
"23.1" ;; No Gnus
727 :type
'(repeat regexp
)
728 :group
'gnus-article-various
)
730 (make-obsolete-variable 'gnus-article-hide-pgp-hook
731 "This variable is obsolete in Gnus 5.10.")
734 '((t (:weight bold
)))
735 "Face used for highlighting a button in the article buffer."
736 :group
'gnus-article-buttons
)
738 (defcustom gnus-article-button-face
'gnus-button
739 "Face used for highlighting buttons in the article buffer.
741 An article button is a piece of text that you can activate by pressing
742 `RET' or `mouse-2' above it."
744 :group
'gnus-article-buttons
)
746 (defcustom gnus-article-mouse-face
'highlight
747 "Face used for mouse highlighting in the article buffer.
749 Article buttons will be displayed in this face when the cursor is
752 :group
'gnus-article-buttons
)
754 (defcustom gnus-signature-face
'gnus-signature
755 "Face used for highlighting a signature in the article buffer.
756 Obsolete; use the face `gnus-signature' for customizations instead."
758 :group
'gnus-article-highlight
759 :group
'gnus-article-signature
)
761 (defface gnus-signature
764 "Face used for highlighting a signature in the article buffer."
765 :group
'gnus-article-highlight
766 :group
'gnus-article-signature
)
767 ;; backward-compatibility alias
768 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
770 (defface gnus-header-from
773 (:foreground
"PaleGreen1"))
776 (:foreground
"red3"))
779 "Face used for displaying from headers."
780 :group
'gnus-article-headers
781 :group
'gnus-article-highlight
)
782 ;; backward-compatibility alias
783 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
785 (defface gnus-header-subject
788 (:foreground
"SeaGreen1"))
791 (:foreground
"red4"))
793 (:bold t
:italic t
)))
794 "Face used for displaying subject headers."
795 :group
'gnus-article-headers
796 :group
'gnus-article-highlight
)
797 ;; backward-compatibility alias
798 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
800 (defface gnus-header-newsgroups
803 (:foreground
"yellow" :italic t
))
806 (:foreground
"MidnightBlue" :italic t
))
809 "Face used for displaying newsgroups headers.
810 In the default setup this face is only used for crossposted
812 :group
'gnus-article-headers
813 :group
'gnus-article-highlight
)
814 ;; backward-compatibility alias
815 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
817 (defface gnus-header-name
820 (:foreground
"SpringGreen2"))
823 (:foreground
"maroon"))
826 "Face used for displaying header names."
827 :group
'gnus-article-headers
828 :group
'gnus-article-highlight
)
829 ;; backward-compatibility alias
830 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
832 (defface gnus-header-content
835 (:foreground
"SpringGreen1" :italic t
))
838 (:foreground
"indianred4" :italic t
))
840 (:italic t
))) "Face used for displaying header content."
841 :group
'gnus-article-headers
842 :group
'gnus-article-highlight
)
843 ;; backward-compatibility alias
844 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
846 (defcustom gnus-header-face-alist
847 '(("From" nil gnus-header-from
)
848 ("Subject" nil gnus-header-subject
)
849 ("Newsgroups:.*," nil gnus-header-newsgroups
)
850 ("" gnus-header-name gnus-header-content
))
851 "*Controls highlighting of article headers.
853 An alist of the form (HEADER NAME CONTENT).
855 HEADER is a regular expression which should match the name of a
856 header and NAME and CONTENT are either face names or nil.
858 The name of each header field will be displayed using the face
859 specified by the first element in the list where HEADER matches
860 the header name and NAME is non-nil. Similarly, the content will
861 be displayed by the first non-nil matching CONTENT face."
862 :group
'gnus-article-headers
863 :group
'gnus-article-highlight
864 :type
'(repeat (list (regexp :tag
"Header")
866 (item :tag
"skip" nil
)
867 (face :value default
))
868 (choice :tag
"Content"
869 (item :tag
"skip" nil
)
870 (face :value default
)))))
872 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
873 '((xface .
(:face gnus-x-face
)))
874 '((pbm .
(:face gnus-x-face
))
876 "Alist of image types and properties applied to Face and X-Face images.
879 ;; Specify the altitude of Face images in the From header.
880 \(setq gnus-face-properties-alist
881 '((pbm . (:face gnus-x-face :ascent 80))
882 (png . (:ascent 80))))
884 ;; Show Face images as pressed buttons.
885 \(setq gnus-face-properties-alist
886 '((pbm . (:face gnus-x-face :relief -2))
887 (png . (:relief -2))))
889 See the manual for the valid properties for various image types.
890 Currently, `pbm' is used for X-Face images and `png' is used for Face
891 images in Emacs. Only the `:face' property is effective on the `xface'
892 image type in XEmacs if it is built with the libcompface library."
893 :version
"23.1" ;; No Gnus
894 :group
'gnus-article-headers
895 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
897 (defcustom gnus-article-decode-hook
898 '(article-decode-charset article-decode-encoded-words
899 article-decode-group-name article-decode-idna-rhs
)
900 "*Hook run to decode charsets in articles."
901 :group
'gnus-article-headers
904 (defcustom gnus-display-mime-function
'gnus-display-mime
905 "Function to display MIME articles."
906 :group
'gnus-article-mime
909 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
910 "Function used to decode headers.")
912 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
913 "Function used to decode addresses.")
915 (defvar gnus-article-dumbquotes-map
935 "Table for MS-to-Latin1 translation.")
937 (defcustom gnus-ignored-mime-types nil
938 "List of MIME types that should be ignored by Gnus."
940 :group
'gnus-article-mime
941 :type
'(repeat regexp
))
943 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
944 "List of MIME types that should not be given buttons when rendered inline.
945 See also `gnus-buttonized-mime-types' which may override this variable.
946 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
948 :group
'gnus-article-mime
949 :type
'(repeat regexp
))
951 (defcustom gnus-buttonized-mime-types nil
952 "List of MIME types that should be given buttons when rendered inline.
953 If set, this variable overrides `gnus-unbuttonized-mime-types'.
954 To see e.g. security buttons you could set this to
955 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
956 this list to display radio buttons that allow you to choose one of two
957 media types those mails include. See also `mm-discouraged-alternatives'.
958 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
960 :group
'gnus-article-mime
961 :type
'(repeat regexp
))
963 (defcustom gnus-inhibit-mime-unbuttonizing nil
964 "If non-nil, all MIME parts get buttons.
965 When nil (the default value), then some MIME parts do not get buttons,
966 as described by the variables `gnus-buttonized-mime-types' and
967 `gnus-unbuttonized-mime-types'."
969 :group
'gnus-article-mime
972 (defcustom gnus-body-boundary-delimiter
"_"
973 "String used to delimit header and body.
974 This variable is used by `gnus-article-treat-body-boundary' which can
975 be controlled by `gnus-treat-body-boundary'."
977 :group
'gnus-article-various
978 :type
'(choice (item :tag
"None" :value nil
)
981 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
983 "Defines the location of the faces database.
984 For information on obtaining this database of pretty pictures, please
985 see http://www.cs.indiana.edu/picons/ftp/index.html"
987 :type
'(repeat directory
)
988 :link
'(url-link :tag
"download"
989 "http://www.cs.indiana.edu/picons/ftp/index.html")
990 :link
'(custom-manual "(gnus)Picons")
993 (defun gnus-picons-installed-p ()
994 "Say whether picons are installed on your machine."
995 (let ((installed nil
))
996 (dolist (database gnus-picon-databases
)
997 (when (file-exists-p database
)
1001 (defcustom gnus-article-mime-part-function nil
1002 "Function called with a MIME handle as the argument.
1003 This is meant for people who want to do something automatic based
1004 on parts -- for instance, adding Vcard info to a database."
1005 :group
'gnus-article-mime
1006 :type
'(choice (const nil
)
1009 (defcustom gnus-mime-multipart-functions nil
1010 "An alist of MIME types to functions to display them."
1012 :group
'gnus-article-mime
1013 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1015 (defcustom gnus-article-date-lapsed-new-header nil
1016 "Whether the X-Sent and Date headers can coexist.
1017 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1018 either replace the old \"Date:\" header (if this variable is nil), or
1019 be added below it (otherwise)."
1021 :group
'gnus-article-headers
1024 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1025 "Function called with a MIME handle as the argument.
1026 This is meant for people who want to view first matched part.
1027 For `undisplayed-alternative' (default), the first undisplayed
1028 part or alternative part is used. For `undisplayed', the first
1029 undisplayed part is used. For a function, the first part which
1030 the function return t is used. For nil, the first part is
1033 :group
'gnus-article-mime
1035 (item :tag
"first" :value nil
)
1036 (item :tag
"undisplayed" :value undisplayed
)
1037 (item :tag
"undisplayed or alternative"
1038 :value undisplayed-alternative
)
1041 (defcustom gnus-mime-action-alist
1042 '(("save to file" . gnus-mime-save-part
)
1043 ("save and strip" . gnus-mime-save-part-and-strip
)
1044 ("replace with file" . gnus-mime-replace-part
)
1045 ("delete part" . gnus-mime-delete-part
)
1046 ("display as text" . gnus-mime-inline-part
)
1047 ("view the part" . gnus-mime-view-part
)
1048 ("pipe to command" . gnus-mime-pipe-part
)
1049 ("toggle display" . gnus-article-press-button
)
1050 ("toggle display" . gnus-article-view-part-as-charset
)
1051 ("view as type" . gnus-mime-view-part-as-type
)
1052 ("view internally" . gnus-mime-view-part-internally
)
1053 ("view externally" . gnus-mime-view-part-externally
))
1054 "An alist of actions that run on the MIME attachment."
1055 :group
'gnus-article-mime
1056 :type
'(repeat (cons (string :tag
"name")
1059 (defcustom gnus-auto-select-part
1
1060 "Advance to next MIME part when deleting or stripping parts.
1062 When 0, point will be placed on the same part as before. When
1063 positive (negative), move point forward (backwards) this many
1064 parts. When nil, redisplay article."
1065 :version
"23.1" ;; No Gnus
1066 :group
'gnus-article-mime
1067 :type
'(choice (const nil
:tag
"Redisplay article.")
1068 (const 1 :tag
"Next part.")
1069 (const 0 :tag
"Current part.")
1073 ;;; The treatment variables
1076 (defvar gnus-part-display-hook nil
1077 "Hook called on parts that are to receive treatment.")
1079 (defvar gnus-article-treat-custom
1080 '(choice (const :tag
"Off" nil
)
1082 (const :tag
"Header" head
)
1083 (const :tag
"First" first
)
1084 (const :tag
"Last" last
)
1085 (integer :tag
"Less")
1086 (repeat :tag
"Groups" regexp
)
1087 (sexp :tag
"Predicate")))
1089 (defvar gnus-article-treat-head-custom
1090 '(choice (const :tag
"Off" nil
)
1091 (const :tag
"Header" head
)))
1093 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1097 (defvar gnus-inhibit-treatment nil
1098 "Whether to inhibit treatment.")
1100 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1101 "Highlight the signature.
1102 Valid values are nil, t, `head', `first', `last', an integer or a
1103 predicate. See Info node `(gnus)Customizing Articles'."
1104 :group
'gnus-article-treat
1105 :link
'(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom
)
1107 (put 'gnus-treat-highlight-signature
'highlight t
)
1109 (defcustom gnus-treat-buttonize
100000
1111 Valid values are nil, t, `head', `first', `last', an integer or a
1112 predicate. See Info node `(gnus)Customizing Articles'."
1113 :group
'gnus-article-treat
1114 :link
'(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom
)
1116 (put 'gnus-treat-buttonize
'highlight t
)
1118 (defcustom gnus-treat-buttonize-head
'head
1119 "Add buttons to the head.
1120 Valid values are nil, t, `head', `first', `last', an integer or a
1121 predicate. See Info node `(gnus)Customizing Articles'."
1122 :group
'gnus-article-treat
1123 :link
'(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-head-custom
)
1125 (put 'gnus-treat-buttonize-head
'highlight t
)
1127 (defcustom gnus-treat-emphasize
50000
1129 Valid values are nil, t, `head', `first', `last', an integer or a
1130 predicate. See Info node `(gnus)Customizing Articles'."
1131 :group
'gnus-article-treat
1132 :link
'(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom
)
1134 (put 'gnus-treat-emphasize
'highlight t
)
1136 (defcustom gnus-treat-strip-cr nil
1137 "Remove carriage returns.
1138 Valid values are nil, t, `head', `first', `last', an integer or a
1139 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group
'gnus-article-treat
1142 :link
'(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom
)
1145 (defcustom gnus-treat-unsplit-urls nil
1146 "Remove newlines from within URLs.
1147 Valid values are nil, t, `head', `first', `last', an integer or a
1148 predicate. See Info node `(gnus)Customizing Articles'."
1150 :group
'gnus-article-treat
1151 :link
'(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom
)
1154 (defcustom gnus-treat-leading-whitespace nil
1155 "Remove leading whitespace in headers.
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1159 :group
'gnus-article-treat
1160 :link
'(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom
)
1163 (defcustom gnus-treat-hide-headers
'head
1165 Valid values are nil, t, `head', `first', `last', an integer or a
1166 predicate. See Info node `(gnus)Customizing Articles'."
1167 :group
'gnus-article-treat
1168 :link
'(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-head-custom
)
1171 (defcustom gnus-treat-hide-boring-headers nil
1172 "Hide boring headers.
1173 Valid values are nil, t, `head', `first', `last', an integer or a
1174 predicate. See Info node `(gnus)Customizing Articles'."
1175 :group
'gnus-article-treat
1176 :link
'(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom
)
1179 (defcustom gnus-treat-hide-signature nil
1180 "Hide the signature.
1181 Valid values are nil, t, `head', `first', `last', an integer or a
1182 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group
'gnus-article-treat
1184 :link
'(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom
)
1187 (defcustom gnus-treat-fill-article nil
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1191 :group
'gnus-article-treat
1192 :link
'(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-custom
)
1195 (defcustom gnus-treat-hide-citation nil
1197 Valid values are nil, t, `head', `first', `last', an integer or a
1198 predicate. See Info node `(gnus)Customizing Articles'."
1199 :group
'gnus-article-treat
1200 :link
'(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-custom
)
1203 (defcustom gnus-treat-hide-citation-maybe nil
1205 Valid values are nil, t, `head', `first', `last', an integer or a
1206 predicate. See Info node `(gnus)Customizing Articles'."
1207 :group
'gnus-article-treat
1208 :link
'(custom-manual "(gnus)Customizing Articles")
1209 :type gnus-article-treat-custom
)
1211 (defcustom gnus-treat-strip-list-identifiers
'head
1212 "Strip list identifiers from `gnus-list-identifiers`.
1213 Valid values are nil, t, `head', `first', `last', an integer or a
1214 predicate. See Info node `(gnus)Customizing Articles'."
1216 :group
'gnus-article-treat
1217 :link
'(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-custom
)
1220 (make-obsolete-variable 'gnus-treat-strip-pgp
1221 "This option is obsolete in Gnus 5.10.")
1223 (defcustom gnus-treat-strip-pem nil
1224 "Strip PEM signatures.
1225 Valid values are nil, t, `head', `first', `last', an integer or a
1226 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group
'gnus-article-treat
1228 :link
'(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom
)
1231 (defcustom gnus-treat-strip-banner t
1232 "Strip banners from articles.
1233 The banner to be stripped is specified in the `banner' group parameter.
1234 Valid values are nil, t, `head', `first', `last', an integer or a
1235 predicate. See Info node `(gnus)Customizing Articles'."
1236 :group
'gnus-article-treat
1237 :link
'(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-custom
)
1240 (defcustom gnus-treat-highlight-headers
'head
1241 "Highlight the headers.
1242 Valid values are nil, t, `head', `first', `last', an integer or a
1243 predicate. See Info node `(gnus)Customizing Articles'."
1244 :group
'gnus-article-treat
1245 :link
'(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-head-custom
)
1247 (put 'gnus-treat-highlight-headers
'highlight t
)
1249 (defcustom gnus-treat-highlight-citation t
1250 "Highlight cited text.
1251 Valid values are nil, t, `head', `first', `last', an integer or a
1252 predicate. See Info node `(gnus)Customizing Articles'."
1253 :group
'gnus-article-treat
1254 :link
'(custom-manual "(gnus)Customizing Articles")
1255 :type gnus-article-treat-custom
)
1256 (put 'gnus-treat-highlight-citation
'highlight t
)
1258 (defcustom gnus-treat-date-ut nil
1259 "Display the Date in UT (GMT).
1260 Valid values are nil, t, `head', `first', `last', an integer or a
1261 predicate. See Info node `(gnus)Customizing Articles'."
1262 :group
'gnus-article-treat
1263 :link
'(custom-manual "(gnus)Customizing Articles")
1264 :type gnus-article-treat-head-custom
)
1266 (defcustom gnus-treat-date-local nil
1267 "Display the Date in the local timezone.
1268 Valid values are nil, t, `head', `first', `last', an integer or a
1269 predicate. See Info node `(gnus)Customizing Articles'."
1270 :group
'gnus-article-treat
1271 :link
'(custom-manual "(gnus)Customizing Articles")
1272 :type gnus-article-treat-head-custom
)
1274 (defcustom gnus-treat-date-english nil
1275 "Display the Date in a format that can be read aloud in English.
1276 Valid values are nil, t, `head', `first', `last', an integer or a
1277 predicate. See Info node `(gnus)Customizing Articles'."
1279 :group
'gnus-article-treat
1280 :link
'(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-head-custom
)
1283 (defcustom gnus-treat-date-lapsed nil
1284 "Display the Date header in a way that says how much time has elapsed.
1285 Valid values are nil, t, `head', `first', `last', an integer or a
1286 predicate. See Info node `(gnus)Customizing Articles'."
1287 :group
'gnus-article-treat
1288 :link
'(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-head-custom
)
1291 (defcustom gnus-treat-date-original nil
1292 "Display the date in the original timezone.
1293 Valid values are nil, t, `head', `first', `last', an integer or a
1294 predicate. See Info node `(gnus)Customizing Articles'."
1295 :group
'gnus-article-treat
1296 :link
'(custom-manual "(gnus)Customizing Articles")
1297 :type gnus-article-treat-head-custom
)
1299 (defcustom gnus-treat-date-iso8601 nil
1300 "Display the date in the ISO8601 format.
1301 Valid values are nil, t, `head', `first', `last', an integer or a
1302 predicate. See Info node `(gnus)Customizing Articles'."
1304 :group
'gnus-article-treat
1305 :link
'(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-head-custom
)
1308 (defcustom gnus-treat-date-user-defined nil
1309 "Display the date in a user-defined format.
1310 The format is defined by the `gnus-article-time-format' variable.
1311 Valid values are nil, t, `head', `first', `last', an integer or a
1312 predicate. See Info node `(gnus)Customizing Articles'."
1313 :group
'gnus-article-treat
1314 :link
'(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-head-custom
)
1317 (defcustom gnus-treat-strip-headers-in-body t
1318 "Strip the X-No-Archive header line from the beginning of the body.
1319 Valid values are nil, t, `head', `first', `last', an integer or a
1320 predicate. See Info node `(gnus)Customizing Articles'."
1322 :group
'gnus-article-treat
1323 :link
'(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom
)
1326 (defcustom gnus-treat-strip-trailing-blank-lines nil
1327 "Strip trailing blank lines.
1328 Valid values are nil, t, `head', `first', `last', an integer or a
1329 predicate. See Info node `(gnus)Customizing Articles'.
1331 When set to t, it also strips trailing blanks in all MIME parts.
1332 Consider to use `last' instead."
1333 :group
'gnus-article-treat
1334 :link
'(custom-manual "(gnus)Customizing Articles")
1335 :type gnus-article-treat-custom
)
1337 (defcustom gnus-treat-strip-leading-blank-lines nil
1338 "Strip leading blank lines.
1339 Valid values are nil, t, `head', `first', `last', an integer or a
1340 predicate. See Info node `(gnus)Customizing Articles'.
1342 When set to t, it also strips trailing blanks in all MIME parts."
1343 :group
'gnus-article-treat
1344 :link
'(custom-manual "(gnus)Customizing Articles")
1345 :type gnus-article-treat-custom
)
1347 (defcustom gnus-treat-strip-multiple-blank-lines nil
1348 "Strip multiple blank lines.
1349 Valid values are nil, t, `head', `first', `last', an integer or a
1350 predicate. See Info node `(gnus)Customizing Articles'."
1351 :group
'gnus-article-treat
1352 :link
'(custom-manual "(gnus)Customizing Articles")
1353 :type gnus-article-treat-custom
)
1355 (defcustom gnus-treat-unfold-headers
'head
1356 "Unfold folded header lines.
1357 Valid values are nil, t, `head', `first', `last', an integer or a
1358 predicate. See Info node `(gnus)Customizing Articles'."
1360 :group
'gnus-article-treat
1361 :link
'(custom-manual "(gnus)Customizing Articles")
1362 :type gnus-article-treat-custom
)
1364 (defcustom gnus-article-unfold-long-headers nil
1365 "If non-nil, allow unfolding headers even if the header is long.
1366 If it is a regexp, only long headers matching this regexp are unfolded.
1367 If it is t, all long headers are unfolded.
1369 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1370 :version
"23.1" ;; No Gnus
1371 :group
'gnus-article-treat
1372 :type
'(choice (const nil
)
1373 (const :tag
"all" t
)
1376 (defcustom gnus-treat-fold-headers nil
1378 Valid values are nil, t, `head', `first', `last', an integer or a
1379 predicate. See Info node `(gnus)Customizing Articles'."
1381 :group
'gnus-article-treat
1382 :link
'(custom-manual "(gnus)Customizing Articles")
1383 :type gnus-article-treat-custom
)
1385 (defcustom gnus-treat-fold-newsgroups
'head
1386 "Fold the Newsgroups and Followup-To headers.
1387 Valid values are nil, t, `head', `first', `last', an integer or a
1388 predicate. See Info node `(gnus)Customizing Articles'."
1390 :group
'gnus-article-treat
1391 :link
'(custom-manual "(gnus)Customizing Articles")
1392 :type gnus-article-treat-custom
)
1394 (defcustom gnus-treat-overstrike t
1395 "Treat overstrike highlighting.
1396 Valid values are nil, t, `head', `first', `last', an integer or a
1397 predicate. See Info node `(gnus)Customizing Articles'."
1398 :group
'gnus-article-treat
1399 :link
'(custom-manual "(gnus)Customizing Articles")
1400 :type gnus-article-treat-custom
)
1401 (put 'gnus-treat-overstrike
'highlight t
)
1403 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1404 "Treat ANSI SGR control sequences.
1405 Valid values are nil, t, `head', `first', `last', an integer or a
1406 predicate. See Info node `(gnus)Customizing Articles'."
1407 :group
'gnus-article-treat
1408 :link
'(custom-manual "(gnus)Customizing Articles")
1409 :type gnus-article-treat-custom
)
1411 (make-obsolete-variable 'gnus-treat-display-xface
1412 'gnus-treat-display-x-face
)
1414 (defcustom gnus-treat-display-x-face
1415 (and (not noninteractive
)
1416 (gnus-image-type-available-p 'xbm
)
1417 (if (featurep 'xemacs
)
1419 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1420 (executable-find "icontopbm")))
1422 "Display X-Face headers.
1423 Valid values are nil and `head'.
1424 See Info node `(gnus)Customizing Articles' and Info node
1425 `(gnus)X-Face' for details."
1426 :group
'gnus-article-treat
1428 :link
'(custom-manual "(gnus)Customizing Articles")
1429 :link
'(custom-manual "(gnus)X-Face")
1430 :type gnus-article-treat-head-custom
1431 :set
(lambda (symbol value
)
1434 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1436 ((boundp 'gnus-treat-display-xface
)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (default-value 'gnus-treat-display-xface
))
1441 ((get 'gnus-treat-display-xface
'saved-value
)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1448 (put 'gnus-treat-display-x-face
'highlight t
)
1450 (defcustom gnus-treat-display-face
1451 (and (not noninteractive
)
1452 (gnus-image-type-available-p 'png
)
1454 "Display Face headers.
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles' and Info
1457 node `(gnus)Face' for details."
1458 :group
'gnus-article-treat
1460 :link
'(custom-manual "(gnus)Customizing Articles")
1461 :link
'(custom-manual "(gnus)X-Face")
1462 :type gnus-article-treat-head-custom
)
1463 (put 'gnus-treat-display-face
'highlight t
)
1465 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Smileys' for details."
1470 :group
'gnus-article-treat
1472 :link
'(custom-manual "(gnus)Customizing Articles")
1473 :link
'(custom-manual "(gnus)Smileys")
1474 :type gnus-article-treat-custom
)
1475 (put 'gnus-treat-display-smileys
'highlight t
)
1477 (defcustom gnus-treat-from-picon
1478 (if (and (gnus-image-type-available-p 'xpm
)
1479 (gnus-picons-installed-p))
1481 "Display picons in the From header.
1482 Valid values are nil, t, `head', `first', `last', an integer or a
1483 predicate. See Info node `(gnus)Customizing Articles' and Info
1484 node `(gnus)Picons' for details."
1486 :group
'gnus-article-treat
1488 :link
'(custom-manual "(gnus)Customizing Articles")
1489 :link
'(custom-manual "(gnus)Picons")
1490 :type gnus-article-treat-head-custom
)
1491 (put 'gnus-treat-from-picon
'highlight t
)
1493 (defcustom gnus-treat-mail-picon
1494 (if (and (gnus-image-type-available-p 'xpm
)
1495 (gnus-picons-installed-p))
1497 "Display picons in To and Cc headers.
1498 Valid values are nil, t, `head', `first', `last', an integer or a
1499 predicate. See Info node `(gnus)Customizing Articles' and Info
1500 node `(gnus)Picons' for details."
1502 :group
'gnus-article-treat
1504 :link
'(custom-manual "(gnus)Customizing Articles")
1505 :link
'(custom-manual "(gnus)Picons")
1506 :type gnus-article-treat-head-custom
)
1507 (put 'gnus-treat-mail-picon
'highlight t
)
1509 (defcustom gnus-treat-newsgroups-picon
1510 (if (and (gnus-image-type-available-p 'xpm
)
1511 (gnus-picons-installed-p))
1513 "Display picons in the Newsgroups and Followup-To headers.
1514 Valid values are nil, t, `head', `first', `last', an integer or a
1515 predicate. See Info node `(gnus)Customizing Articles' and Info
1516 node `(gnus)Picons' for details."
1518 :group
'gnus-article-treat
1520 :link
'(custom-manual "(gnus)Customizing Articles")
1521 :link
'(custom-manual "(gnus)Picons")
1522 :type gnus-article-treat-head-custom
)
1523 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1525 (defcustom gnus-treat-body-boundary
1526 (if (or gnus-treat-newsgroups-picon
1527 gnus-treat-mail-picon
1528 gnus-treat-from-picon
)
1529 ;; If there's much decoration, the user might prefer a boundery.
1532 "Draw a boundary at the end of the headers.
1533 Valid values are nil and `head'.
1534 See Info node `(gnus)Customizing Articles' for details."
1536 :group
'gnus-article-treat
1537 :link
'(custom-manual "(gnus)Customizing Articles")
1538 :type gnus-article-treat-head-custom
)
1540 (defcustom gnus-treat-capitalize-sentences nil
1541 "Capitalize sentence-starting words.
1542 Valid values are nil, t, `head', `first', `last', an integer or a
1543 predicate. See Info node `(gnus)Customizing Articles'."
1545 :group
'gnus-article-treat
1546 :link
'(custom-manual "(gnus)Customizing Articles")
1547 :type gnus-article-treat-custom
)
1549 (defcustom gnus-treat-wash-html nil
1551 Valid values are nil, t, `head', `first', `last', an integer or a
1552 predicate. See Info node `(gnus)Customizing Articles'."
1554 :group
'gnus-article-treat
1555 :link
'(custom-manual "(gnus)Customizing Articles")
1556 :type gnus-article-treat-custom
)
1558 (defcustom gnus-treat-fill-long-lines nil
1560 Valid values are nil, t, `head', `first', `last', an integer or a
1561 predicate. See Info node `(gnus)Customizing Articles'."
1562 :group
'gnus-article-treat
1563 :link
'(custom-manual "(gnus)Customizing Articles")
1564 :type gnus-article-treat-custom
)
1566 (defcustom gnus-treat-play-sounds nil
1568 Valid values are nil, t, `head', `first', `last', an integer or a
1569 predicate. See Info node `(gnus)Customizing Articles'."
1571 :group
'gnus-article-treat
1572 :link
'(custom-manual "(gnus)Customizing Articles")
1573 :type gnus-article-treat-custom
)
1575 (defcustom gnus-treat-translate nil
1576 "Translate articles from one language to another.
1577 Valid values are nil, t, `head', `first', `last', an integer or a
1578 predicate. See Info node `(gnus)Customizing Articles'."
1580 :group
'gnus-article-treat
1581 :link
'(custom-manual "(gnus)Customizing Articles")
1582 :type gnus-article-treat-custom
)
1584 (defcustom gnus-treat-x-pgp-sig nil
1586 To automatically treat X-PGP-Sig, set it to head.
1587 Valid values are nil, t, `head', `first', `last', an integer or a
1588 predicate. See Info node `(gnus)Customizing Articles'."
1590 :group
'gnus-article-treat
1591 :group
'mime-security
1592 :link
'(custom-manual "(gnus)Customizing Articles")
1593 :type gnus-article-treat-custom
)
1595 (defvar gnus-article-encrypt-protocol-alist
1596 '(("PGP" . mml2015-self-encrypt
)))
1598 ;; Set to nil if more than one protocol added to
1599 ;; gnus-article-encrypt-protocol-alist.
1600 (defcustom gnus-article-encrypt-protocol
"PGP"
1601 "The protocol used for encrypt articles.
1602 It is a string, such as \"PGP\". If nil, ask user."
1605 :group
'mime-security
)
1607 (defvar gnus-article-wash-function nil
1608 "Function used for converting HTML into text.")
1610 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1611 (mm-coding-system-p 'utf-8
)
1612 (executable-find idna-program
))
1613 "Whether IDNA decoding of headers is used when viewing messages.
1614 This requires GNU Libidn, and by default only enabled if it is found."
1616 :group
'gnus-article-headers
1619 (defcustom gnus-article-over-scroll nil
1620 "If non-nil, allow scrolling the article buffer even when there no more text."
1622 :group
'gnus-article
1625 ;;; Internal variables
1627 (defvar gnus-english-month-names
1628 '("January" "February" "March" "April" "May" "June" "July" "August"
1629 "September" "October" "November" "December"))
1631 (defvar article-goto-body-goes-to-point-min-p nil
)
1632 (defvar gnus-article-wash-types nil
)
1633 (defvar gnus-article-emphasis-alist nil
)
1634 (defvar gnus-article-image-alist nil
)
1636 (defvar gnus-article-mime-handle-alist-1 nil
)
1637 (defvar gnus-treatment-function-alist
1638 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1639 (gnus-treat-strip-banner gnus-article-strip-banner
)
1640 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1641 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1642 (gnus-treat-buttonize gnus-article-add-buttons
)
1643 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1644 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1645 (gnus-treat-strip-cr gnus-article-remove-cr
)
1646 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1647 (gnus-treat-date-ut gnus-article-date-ut
)
1648 (gnus-treat-date-local gnus-article-date-local
)
1649 (gnus-treat-date-english gnus-article-date-english
)
1650 (gnus-treat-date-original gnus-article-date-original
)
1651 (gnus-treat-date-user-defined gnus-article-date-user
)
1652 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1653 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1654 (gnus-treat-display-x-face gnus-article-display-x-face
)
1655 (gnus-treat-display-face gnus-article-display-face
)
1656 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1657 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1658 (gnus-treat-hide-signature gnus-article-hide-signature
)
1659 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1660 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1661 (gnus-treat-strip-pem gnus-article-hide-pem
)
1662 (gnus-treat-from-picon gnus-treat-from-picon
)
1663 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1664 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1665 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1666 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1667 (gnus-treat-strip-trailing-blank-lines
1668 gnus-article-remove-trailing-blank-lines
)
1669 (gnus-treat-strip-leading-blank-lines
1670 gnus-article-strip-leading-blank-lines
)
1671 (gnus-treat-strip-multiple-blank-lines
1672 gnus-article-strip-multiple-blank-lines
)
1673 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1674 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1675 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1676 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1677 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1678 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1679 (gnus-treat-display-smileys gnus-treat-smiley
)
1680 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1681 (gnus-treat-wash-html gnus-article-wash-html
)
1682 (gnus-treat-emphasize gnus-article-emphasize
)
1683 (gnus-treat-hide-citation gnus-article-hide-citation
)
1684 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1685 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1686 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)
1687 (gnus-treat-play-sounds gnus-earcon-display
)))
1689 (defvar gnus-article-mime-handle-alist nil
)
1690 (defvar article-lapsed-timer nil
)
1691 (defvar gnus-article-current-summary nil
)
1693 (defvar gnus-article-mode-syntax-table
1694 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1695 ;; This causes the citation match run O(2^n).
1696 ;; (modify-syntax-entry ?- "w" table)
1697 (modify-syntax-entry ?
> ")<" table
)
1698 (modify-syntax-entry ?
< "(>" table
)
1699 ;; make M-. in article buffers work for `foo' strings
1700 (modify-syntax-entry ?
' " " table
)
1701 (modify-syntax-entry ?
` " " table
)
1703 "Syntax table used in article mode buffers.
1704 Initialized from `text-mode-syntax-table.")
1706 (defvar gnus-save-article-buffer nil
)
1708 (defvar gnus-number-of-articles-to-be-saved nil
)
1710 (defvar gnus-inhibit-hiding nil
)
1712 (defvar gnus-article-edit-mode nil
)
1714 ;;; Macros for dealing with the article buffer.
1716 (defmacro gnus-with-article-headers
(&rest forms
)
1717 `(with-current-buffer gnus-article-buffer
1719 (let ((inhibit-read-only t
)
1720 (inhibit-point-motion-hooks t
)
1721 (case-fold-search t
))
1722 (article-narrow-to-head)
1725 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1726 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1728 (defmacro gnus-with-article-buffer
(&rest forms
)
1729 `(with-current-buffer gnus-article-buffer
1730 (let ((inhibit-read-only t
))
1733 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1734 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1736 (defun gnus-article-goto-header (header)
1737 "Go to HEADER, which is a regular expression."
1738 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1740 (defsubst gnus-article-hide-text
(b e props
)
1741 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1742 (gnus-add-text-properties-when 'article-type nil b e props
)
1743 (when (memq 'intangible props
)
1745 (max (1- b
) (point-min))
1746 b
'intangible
(cddr (memq 'intangible props
)))))
1748 (defsubst gnus-article-unhide-text
(b e
)
1749 "Remove hidden text properties from region between B and E."
1750 (remove-text-properties b e gnus-hidden-properties
)
1751 (when (memq 'intangible gnus-hidden-properties
)
1752 (put-text-property (max (1- b
) (point-min))
1753 b
'intangible nil
)))
1755 (defun gnus-article-hide-text-type (b e type
)
1756 "Hide text of TYPE between B and E."
1757 (gnus-add-wash-type type
)
1758 (gnus-article-hide-text
1759 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1761 (defun gnus-article-unhide-text-type (b e type
)
1762 "Unhide text of TYPE between B and E."
1763 (gnus-delete-wash-type type
)
1764 (remove-text-properties
1765 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1766 (when (memq 'intangible gnus-hidden-properties
)
1767 (put-text-property (max (1- b
) (point-min))
1768 b
'intangible nil
)))
1770 (defun gnus-article-hide-text-of-type (type)
1771 "Hide text of TYPE in the current buffer."
1773 (let ((b (point-min))
1775 (while (setq b
(text-property-any b e
'article-type type
))
1776 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1778 (defun gnus-article-delete-text-of-type (type)
1779 "Delete text of TYPE in the current buffer."
1781 (let ((b (point-min)))
1782 (if (eq type
'multipart
)
1783 ;; Remove MIME buttons associated with multipart/alternative parts.
1786 (while (if (get-text-property (point) 'gnus-part
)
1788 (when (setq b
(next-single-property-change (point)
1793 (skip-chars-forward "\n")
1794 (when (eq (get-text-property b
'article-type
) 'multipart
)
1795 (delete-region b
(point)))))
1796 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1798 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1801 (defun gnus-article-delete-invisible-text ()
1802 "Delete all invisible text in the current buffer."
1804 (let ((b (point-min)))
1805 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1807 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1810 (defun gnus-article-text-type-exists-p (type)
1811 "Say whether any text of type TYPE exists in the buffer."
1812 (text-property-any (point-min) (point-max) 'article-type type
))
1814 (defsubst gnus-article-header-rank
()
1815 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1816 (let ((list gnus-sorted-header-list
)
1819 (if (looking-at (car list
))
1821 (setq list
(cdr list
))
1825 (defun article-hide-headers (&optional arg delete
)
1826 "Hide unwanted headers and possibly sort them as well."
1828 ;; This function might be inhibited.
1829 (unless gnus-inhibit-hiding
1830 (let ((inhibit-read-only t
)
1831 (case-fold-search t
)
1832 (max (1+ (length gnus-sorted-header-list
)))
1833 (inhibit-point-motion-hooks t
)
1834 (cur (current-buffer))
1835 ignored visible beg
)
1837 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1838 ;; group parameters, so we should go to the summary buffer.
1841 (progn (set-buffer gnus-summary-buffer
) t
)
1843 (setq ignored
(when (not gnus-visible-headers
)
1844 (cond ((stringp gnus-ignored-headers
)
1845 gnus-ignored-headers
)
1846 ((listp gnus-ignored-headers
)
1847 (mapconcat 'identity
1848 gnus-ignored-headers
1850 visible
(cond ((stringp gnus-visible-headers
)
1851 gnus-visible-headers
)
1852 ((and gnus-visible-headers
1853 (listp gnus-visible-headers
))
1854 (mapconcat 'identity
1855 gnus-visible-headers
1859 ;; First we narrow to just the headers.
1860 (article-narrow-to-head)
1861 ;; Hide any "From " lines at the beginning of (mail) articles.
1862 (while (looking-at "From ")
1865 (delete-region (point-min) (point)))
1866 ;; Then treat the rest of the header lines.
1867 ;; Then we use the two regular expressions
1868 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1869 ;; select which header lines is to remain visible in the
1871 (while (re-search-forward "^[^ \t:]*:" nil t
)
1873 ;; Mark the rank of the header.
1875 (point) (1+ (point)) 'message-rank
1876 (if (or (and visible
(looking-at visible
))
1878 (not (looking-at ignored
))))
1879 (gnus-article-header-rank)
1882 (message-sort-headers-1)
1883 (when (setq beg
(text-property-any
1884 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1885 ;; We delete the unwanted headers.
1886 (gnus-add-wash-type 'headers
)
1887 (add-text-properties (point-min) (+ 5 (point-min))
1888 '(article-type headers dummy-invisible t
))
1889 (delete-region beg
(point-max))))))))
1891 (defun article-hide-boring-headers (&optional arg
)
1892 "Toggle hiding of headers that aren't very interesting.
1893 If given a negative prefix, always show; if given a positive prefix,
1895 (interactive (gnus-article-hidden-arg))
1896 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1897 (not gnus-show-all-headers
))
1900 (let ((inhibit-read-only t
)
1901 (inhibit-point-motion-hooks t
))
1902 (article-narrow-to-head)
1903 (dolist (elem gnus-boring-article-headers
)
1904 (goto-char (point-min))
1906 ;; Hide empty headers.
1908 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1910 (gnus-article-hide-text-type
1914 (if (re-search-forward "^[^ \t]" nil t
)
1918 ;; Hide boring Newsgroups header.
1919 ((eq elem
'newsgroups
)
1920 (when (gnus-string-equal
1921 (gnus-fetch-field "newsgroups")
1922 (gnus-group-real-name
1923 (if (boundp 'gnus-newsgroup-name
)
1926 (gnus-article-hide-header "newsgroups")))
1927 ((eq elem
'to-address
)
1928 (let ((to (message-fetch-field "to"))
1930 (gnus-parameter-to-address
1931 (if (boundp 'gnus-newsgroup-name
)
1932 gnus-newsgroup-name
""))))
1933 (when (and to to-address
1936 ;; only one address in To
1937 (nth 1 (mail-extract-address-components to
))
1939 (gnus-article-hide-header "to"))))
1941 (let ((to (message-fetch-field "to"))
1943 (gnus-parameter-to-list
1944 (if (boundp 'gnus-newsgroup-name
)
1945 gnus-newsgroup-name
""))))
1946 (when (and to to-list
1949 ;; only one address in To
1950 (nth 1 (mail-extract-address-components to
))
1952 (gnus-article-hide-header "to"))))
1954 (let ((cc (message-fetch-field "cc"))
1956 (gnus-parameter-to-list
1957 (if (boundp 'gnus-newsgroup-name
)
1958 gnus-newsgroup-name
""))))
1959 (when (and cc to-list
1962 ;; only one address in CC
1963 (nth 1 (mail-extract-address-components cc
))
1965 (gnus-article-hide-header "cc"))))
1966 ((eq elem
'followup-to
)
1967 (when (gnus-string-equal
1968 (message-fetch-field "followup-to")
1969 (message-fetch-field "newsgroups"))
1970 (gnus-article-hide-header "followup-to")))
1971 ((eq elem
'reply-to
)
1972 (if (gnus-group-find-parameter
1973 gnus-newsgroup-name
'broken-reply-to
)
1974 (gnus-article-hide-header "reply-to")
1975 (let ((from (message-fetch-field "from"))
1976 (reply-to (message-fetch-field "reply-to")))
1983 (lambda (x) (downcase (cadr x
)))
1984 (mail-extract-address-components from t
))
1987 (lambda (x) (downcase (cadr x
)))
1988 (mail-extract-address-components reply-to t
))
1990 (gnus-article-hide-header "reply-to")))))
1992 (let ((date (with-current-buffer gnus-original-article-buffer
1993 ;; If date in `gnus-article-buffer' is localized
1994 ;; (`gnus-treat-date-user-defined'),
1995 ;; `days-between' might fail.
1996 (message-fetch-field "date"))))
1998 (< (days-between (current-time-string) date
)
2000 (gnus-article-hide-header "date"))))
2002 (let ((to (message-fetch-field "to"))
2003 (cc (message-fetch-field "cc")))
2004 (when (> (length to
) 1024)
2005 (gnus-article-hide-header "to"))
2006 (when (> (length cc
) 1024)
2007 (gnus-article-hide-header "cc"))))
2011 (goto-char (point-min))
2012 (while (re-search-forward "^to:" nil t
)
2013 (setq to-count
(1+ to-count
)))
2014 (when (> to-count
1)
2015 (while (> to-count
0)
2016 (goto-char (point-min))
2018 (re-search-forward "^to:" nil nil to-count
)
2020 (narrow-to-region (point) (point-max))
2021 (gnus-article-hide-header "to"))
2022 (setq to-count
(1- to-count
))))
2023 (goto-char (point-min))
2024 (while (re-search-forward "^cc:" nil t
)
2025 (setq cc-count
(1+ cc-count
)))
2026 (when (> cc-count
1)
2027 (while (> cc-count
0)
2028 (goto-char (point-min))
2030 (re-search-forward "^cc:" nil nil cc-count
)
2032 (narrow-to-region (point) (point-max))
2033 (gnus-article-hide-header "cc"))
2034 (setq cc-count
(1- cc-count
)))))))))))))
2036 (defun gnus-article-hide-header (header)
2038 (goto-char (point-min))
2039 (when (re-search-forward (concat "^" header
":") nil t
)
2040 (gnus-article-hide-text-type
2044 (if (re-search-forward "^[^ \t]" nil t
)
2049 (defvar gnus-article-normalized-header-length
40
2050 "Length of normalized headers.")
2052 (defun article-normalize-headers ()
2053 "Make all header lines 40 characters long."
2055 (let ((inhibit-read-only t
)
2059 (article-narrow-to-head)
2062 ((< (setq column
(- (point-at-eol) (point)))
2063 gnus-article-normalized-header-length
)
2065 (insert (make-string
2066 (- gnus-article-normalized-header-length column
)
2068 ((> column gnus-article-normalized-header-length
)
2069 (gnus-put-text-property
2071 (forward-char gnus-article-normalized-header-length
)
2078 (forward-line 1))))))
2080 (defun article-treat-dumbquotes ()
2081 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2082 Note that this function guesses whether a character is a sm*rtq**t* or
2083 not, so it should only be used interactively.
2085 Sm*rtq**t*s are M****s***'s unilateral extension to the
2086 iso-8859-1 character map in an attempt to provide more quoting
2087 characters. If you see something like \\222 or \\264 where
2088 you're expecting some kind of apostrophe or quotation mark, then
2091 (article-translate-strings gnus-article-dumbquotes-map
))
2093 (defun article-translate-characters (from to
)
2094 "Translate all characters in the body of the article according to FROM and TO.
2095 FROM is a string of characters to translate from; to is a string of
2096 characters to translate to."
2098 (when (article-goto-body)
2099 (let ((inhibit-read-only t
)
2100 (x (make-string 225 ?x
))
2102 (while (< (incf i
) (length x
))
2105 (while (< i
(length from
))
2106 (aset x
(aref from i
) (aref to i
))
2108 (translate-region (point) (point-max) x
)))))
2110 (defun article-translate-strings (map)
2111 "Translate all string in the body of the article according to MAP.
2112 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2114 (when (article-goto-body)
2115 (let ((inhibit-read-only t
))
2118 (while (search-forward (car elem
) nil t
)
2119 (replace-match (cadr elem
)))))))))
2121 (defun article-treat-overstrike ()
2122 "Translate overstrikes into bold text."
2125 (when (article-goto-body)
2126 (let ((inhibit-read-only t
))
2127 (while (search-forward "\b" nil t
)
2128 (let ((next (char-after))
2129 (previous (char-after (- (point) 2))))
2130 ;; We do the boldification/underlining by hiding the
2131 ;; overstrikes and putting the proper text property
2135 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2136 (put-text-property (point) (1+ (point)) 'face
'bold
))
2138 (gnus-article-hide-text-type
2139 (1- (point)) (1+ (point)) 'overstrike
)
2141 (- (point) 2) (1- (point)) 'face
'underline
))
2143 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2145 (point) (1+ (point)) 'face
'underline
)))))))))
2147 (defun article-treat-ansi-sequences ()
2148 "Translate ANSI SGR control sequences into overlays or extents."
2151 (when (article-goto-body)
2152 (let ((inhibit-read-only t
))
2153 (ansi-color-apply-on-region (point) (point-max))))))
2155 (defun gnus-article-treat-unfold-headers ()
2156 "Unfold folded message headers.
2157 Only the headers that fit into the current window width will be
2160 (gnus-with-article-headers
2164 (mail-header-narrow-to-field)
2165 (let* ((header (buffer-string))
2167 (or (equal gnus-article-unfold-long-headers t
)
2168 (and (stringp gnus-article-unfold-long-headers
)
2169 (string-match gnus-article-unfold-long-headers header
)))))
2172 (goto-char (point-min))
2173 (while (re-search-forward "\n[\t ]" nil t
)
2174 (replace-match " " t t
)))
2175 (setq length
(- (point-max) (point-min) 1))
2176 (when (or unfoldable
2177 (< length
(window-width)))
2178 (while (re-search-forward "\n[\t ]" nil t
)
2179 (replace-match " " t t
))))
2180 (goto-char (point-max)))))))
2182 (defun gnus-article-treat-fold-headers ()
2183 "Fold message headers."
2185 (gnus-with-article-headers
2188 (mail-header-narrow-to-field)
2189 (mail-header-fold-field)
2190 (goto-char (point-max))))))
2192 (defun gnus-treat-smiley ()
2193 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2195 (gnus-with-article-buffer
2196 (if (memq 'smiley gnus-article-wash-types
)
2197 (gnus-delete-images 'smiley
)
2199 (let ((images (smiley-region (point) (point-max))))
2201 (gnus-add-wash-type 'smiley
)
2202 (dolist (image images
)
2203 (gnus-add-image 'smiley image
)))))))
2205 (defun gnus-article-remove-images ()
2206 "Remove all images from the article buffer."
2208 (gnus-with-article-buffer
2209 (dolist (elem gnus-article-image-alist
)
2210 (gnus-delete-images (car elem
)))))
2212 (defun gnus-article-treat-fold-newsgroups ()
2213 "Unfold folded message headers.
2214 Only the headers that fit into the current window width will be
2217 (gnus-with-article-headers
2218 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2220 (mail-header-narrow-to-field)
2221 (while (re-search-forward ", *" nil t
)
2222 (replace-match ", " t t
))
2223 (mail-header-fold-field)
2224 (goto-char (point-max))))))
2226 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2227 "Value of `truncate-lines' in Gnus Article buffer.
2228 Valid values are nil, t, `head', `first', `last', an integer or a
2229 predicate. See Info node `(gnus)Customizing Articles'."
2230 :version
"23.1" ;; No Gnus
2231 :group
'gnus-article
2232 ;; :link '(custom-manual "(gnus)Customizing Articles")
2235 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2236 "Toggle whether to fold or truncate long lines in article the buffer.
2237 If ARG is non-nil and not a number, toggle
2238 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2239 long lines if and only if arg is positive."
2242 ((and (numberp arg
) (> arg
0))
2243 (setq gnus-article-truncate-lines t
))
2245 (setq gnus-article-truncate-lines nil
))
2247 (setq gnus-article-truncate-lines
2248 (not gnus-article-truncate-lines
))))
2249 (gnus-with-article-buffer
2251 ((and (numberp arg
) (> arg
0))
2252 (setq truncate-lines nil
))
2254 (setq truncate-lines t
)))
2255 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2256 ;; `toggle-truncate-lines' needs an argument.
2257 (toggle-truncate-lines)))
2259 (defun gnus-article-treat-body-boundary ()
2260 "Place a boundary line at the end of the headers."
2262 (when (and gnus-body-boundary-delimiter
2263 (> (length gnus-body-boundary-delimiter
) 0))
2264 (gnus-with-article-headers
2265 (goto-char (point-max))
2266 (let ((start (point)))
2267 (insert "X-Boundary: ")
2268 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2270 (while (>= (1- (window-width)) (length str
))
2271 (setq str
(concat str gnus-body-boundary-delimiter
)))
2272 (substring str
0 (1- (window-width))))
2274 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2276 (defun article-fill-long-lines ()
2277 "Fill lines that are wider than the window width."
2280 (let ((inhibit-read-only t
)
2281 (width (window-width (get-buffer-window (current-buffer)))))
2284 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2287 (when (>= (current-column) (min fill-column width
))
2288 (narrow-to-region (min (1+ (point)) (point-max))
2290 (let ((goback (point-marker)))
2291 (fill-paragraph nil
)
2292 (goto-char (marker-position goback
)))
2294 (forward-line 1)))))))
2296 (defun article-capitalize-sentences ()
2297 "Capitalize the first word in each sentence."
2300 (let ((inhibit-read-only t
)
2301 (paragraph-start "^[\n\^L]"))
2305 (forward-sentence)))))
2307 (defun article-remove-cr ()
2308 "Remove trailing CRs and then translate remaining CRs into LFs."
2311 (let ((inhibit-read-only t
))
2312 (goto-char (point-min))
2313 (while (re-search-forward "\r+$" nil t
)
2314 (replace-match "" t t
))
2315 (goto-char (point-min))
2316 (while (search-forward "\r" nil t
)
2317 (replace-match "\n" t t
)))))
2319 (defun article-remove-trailing-blank-lines ()
2320 "Remove all trailing blank lines from the article."
2323 (let ((inhibit-read-only t
))
2324 (goto-char (point-max))
2328 (while (and (not (bobp))
2329 (looking-at "^[ \t]*$")
2330 (not (gnus-annotation-in-region-p
2331 (point) (point-at-eol))))
2336 (defvar gnus-face-properties-alist
)
2338 (defun article-display-face (&optional force
)
2339 "Display any Face headers in the header."
2340 (interactive (list 'force
))
2341 (let ((wash-face-p buffer-read-only
))
2342 (gnus-with-article-headers
2343 ;; When displaying parts, this function can be called several times on
2344 ;; the same article, without any intended toggle semantic (as typing `W
2345 ;; D d' would have). So face deletion must occur only when we come from
2346 ;; an interactive command, that is when the *Article* buffer is
2348 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2349 (gnus-delete-images 'face
)
2350 (let ((from (message-fetch-field "from"))
2352 (save-current-buffer
2353 (when (and wash-face-p
2354 (gnus-buffer-live-p gnus-original-article-buffer
)
2355 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2356 (set-buffer gnus-original-article-buffer
))
2358 (mail-narrow-to-head)
2360 ;; Check whether this face is censored.
2361 (not (and gnus-article-x-face-too-ugly
2363 (setq from
(message-fetch-field "from")))
2364 (string-match gnus-article-x-face-too-ugly
2366 (while (gnus-article-goto-header "Face")
2367 (push (mail-header-field-value) faces
)))))
2369 (goto-char (point-min))
2371 (unless (setq from
(gnus-article-goto-header "from"))
2374 (insert " [no `from' set]\n"))
2376 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2378 (apply 'gnus-create-image png
'png t
2379 (cdr (assq 'png gnus-face-properties-alist
))))
2381 (gnus-add-wash-type 'face
)
2382 (gnus-add-image 'face image
)
2383 (gnus-put-image image nil
'face
))))))))))
2385 (defun article-display-x-face (&optional force
)
2386 "Look for an X-Face header and display it if present."
2387 (interactive (list 'force
))
2388 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2389 (gnus-with-article-headers
2390 ;; Delete the old process, if any.
2391 (when (process-status "article-x-face")
2392 (delete-process "article-x-face"))
2393 ;; See the comment in `article-display-face'.
2394 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2395 ;; We have already displayed X-Faces, so we remove them
2397 (gnus-delete-images 'xface
)
2399 (let ((from (message-fetch-field "from"))
2401 (save-current-buffer
2402 (when (and wash-face-p
2403 (gnus-buffer-live-p gnus-original-article-buffer
)
2404 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2405 ;; If type `W f', use gnus-original-article-buffer,
2406 ;; otherwise use the current buffer because displaying
2407 ;; RFC822 parts calls this function too.
2408 (set-buffer gnus-original-article-buffer
))
2410 (mail-narrow-to-head)
2411 (and gnus-article-x-face-command
2413 ;; Check whether this face is censored.
2414 (not (and gnus-article-x-face-too-ugly
2416 (setq from
(message-fetch-field "from")))
2417 (string-match gnus-article-x-face-too-ugly
2419 (while (gnus-article-goto-header "X-Face")
2420 (push (mail-header-field-value) x-faces
)))))
2422 ;; We display the face.
2423 (cond ((functionp gnus-article-x-face-command
)
2424 ;; The command is a lisp function, so we call it.
2425 (mapc gnus-article-x-face-command x-faces
))
2426 ((stringp gnus-article-x-face-command
)
2427 ;; The command is a string, so we interpret the command
2428 ;; as a, well, command, and fork it off.
2429 (let ((process-connection-type nil
))
2430 (gnus-set-process-query-on-exit-flag
2432 "article-x-face" nil shell-file-name
2433 shell-command-switch gnus-article-x-face-command
)
2435 ;; Sending multiple EOFs to xv doesn't work,
2436 ;; so we only do a single external face.
2438 (insert (car x-faces
))
2439 (process-send-region "article-x-face"
2440 (point-min) (point-max)))
2441 (process-send-eof "article-x-face")))
2443 (error "`%s' set to `%s' is not a function"
2444 gnus-article-x-face-command
2445 'gnus-article-x-face-command
)))))))))
2447 (defun article-decode-mime-words ()
2448 "Decode all MIME-encoded words in the article."
2450 (gnus-with-article-buffer
2451 (let ((inhibit-point-motion-hooks t
)
2452 (mail-parse-charset gnus-newsgroup-charset
)
2453 (mail-parse-ignored-charsets
2454 (with-current-buffer gnus-summary-buffer
2455 gnus-newsgroup-ignored-charsets
)))
2456 (mail-decode-encoded-word-region (point-min) (point-max)))))
2458 (defun article-decode-charset (&optional prompt
)
2459 "Decode charset-encoded text in the article.
2460 If PROMPT (the prefix), prompt for a coding system to use."
2462 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2463 (inhibit-read-only t
)
2464 (mail-parse-charset gnus-newsgroup-charset
)
2465 (mail-parse-ignored-charsets
2466 (save-excursion (condition-case nil
2467 (set-buffer gnus-summary-buffer
)
2469 gnus-newsgroup-ignored-charsets
))
2470 ct cte ctl charset format
)
2473 (article-narrow-to-head)
2474 (setq ct
(message-fetch-field "Content-Type" t
)
2475 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2476 ctl
(and ct
(mail-header-parse-content-type ct
))
2479 (mm-read-coding-system "Charset to decode: "))
2481 (mail-content-type-get ctl
'charset
)))
2482 format
(and ctl
(mail-content-type-get ctl
'format
)))
2484 (setq cte
(mail-header-strip cte
)))
2485 (if (and ctl
(not (string-match "/" (car ctl
))))
2487 (goto-char (point-max)))
2490 (narrow-to-region (point) (point-max))
2491 (when (and (eq mail-parse-charset
'gnus-decoded
)
2492 (eq (mm-body-7-or-8) '8bit
))
2493 ;; The text code could have been decoded.
2494 (setq charset mail-parse-charset
))
2495 (when (and (or (not ctl
)
2496 (equal (car ctl
) "text/plain"))
2497 (not format
)) ;; article with format will decode later.
2499 charset
(and cte
(intern (downcase
2500 (gnus-strip-whitespace cte
))))
2503 (defun article-decode-encoded-words ()
2504 "Remove encoded-word encoding from headers."
2505 (let ((inhibit-point-motion-hooks t
)
2506 (mail-parse-charset gnus-newsgroup-charset
)
2507 (mail-parse-ignored-charsets
2508 (save-excursion (condition-case nil
2509 (set-buffer gnus-summary-buffer
)
2511 gnus-newsgroup-ignored-charsets
))
2512 (inhibit-read-only t
)
2514 (goto-char (point-min))
2515 (when (search-forward "\n\n" nil
'move
)
2522 (memq (char-after) '(?
\t ?
)))))
2523 (setq start
(point))
2525 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2526 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2527 (funcall gnus-decode-address-function start end
)
2528 (funcall gnus-decode-header-function start end
))
2529 (goto-char (setq end start
)))))
2531 (defun article-decode-group-name ()
2532 "Decode group names in Newsgroups, Followup-To and Xref headers."
2533 (let ((inhibit-point-motion-hooks t
)
2534 (inhibit-read-only t
)
2535 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2537 (when (and (or gnus-group-name-charset-method-alist
2538 gnus-group-name-charset-group-alist
)
2539 (gnus-buffer-live-p gnus-original-article-buffer
))
2541 (article-narrow-to-head)
2542 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2543 (with-current-buffer gnus-original-article-buffer
2544 (goto-char (point-min)))
2545 (setq regexp
(concat "^" header
2546 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2547 (while (re-search-forward regexp nil t
)
2548 (replace-match (save-match-data
2549 (gnus-decode-newsgroups
2550 ;; XXX how to use data in article buffer?
2551 (with-current-buffer gnus-original-article-buffer
2552 (re-search-forward regexp nil t
)
2554 gnus-newsgroup-name method
))
2556 (goto-char (point-min)))))))
2558 (autoload 'idna-to-unicode
"idna")
2560 (defun article-decode-idna-rhs ()
2561 "Decode IDNA strings in RHS in various headers in current buffer.
2562 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2563 Mail-Reply-To: and Mail-Followup-To:."
2566 (let ((inhibit-point-motion-hooks t
)
2567 (inhibit-read-only t
))
2568 (article-narrow-to-head)
2569 (goto-char (point-min))
2570 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2572 (when (save-match-data
2573 (and (setq ace
(match-string 1))
2575 (and (re-search-backward "^[^ \t]" nil t
)
2576 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2577 (setq unicode
(idna-to-unicode ace
))))
2578 (unless (string= ace unicode
)
2579 (replace-match unicode nil nil nil
1)))))))))
2581 (defun article-de-quoted-unreadable (&optional force read-charset
)
2582 "Translate a quoted-printable-encoded article.
2583 If FORCE, decode the article whether it is marked as quoted-printable
2585 If READ-CHARSET, ask for a coding system."
2586 (interactive (list 'force current-prefix-arg
))
2588 (let ((inhibit-read-only t
) type charset
)
2589 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2590 (with-current-buffer gnus-original-article-buffer
2592 (gnus-fetch-field "content-transfer-encoding"))
2593 (let* ((ct (gnus-fetch-field "content-type"))
2594 (ctl (and ct
(mail-header-parse-content-type ct
))))
2595 (setq charset
(and ctl
2596 (mail-content-type-get ctl
'charset
)))
2597 (if (stringp charset
)
2598 (setq charset
(intern (downcase charset
)))))))
2600 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2602 (setq charset gnus-newsgroup-charset
))
2604 (and type
(let ((case-fold-search t
))
2605 (string-match "quoted-printable" type
))))
2607 (quoted-printable-decode-region
2608 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2610 (defun article-de-base64-unreadable (&optional force read-charset
)
2611 "Translate a base64 article.
2612 If FORCE, decode the article whether it is marked as base64 not.
2613 If READ-CHARSET, ask for a coding system."
2614 (interactive (list 'force current-prefix-arg
))
2616 (let ((inhibit-read-only t
) type charset
)
2617 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2618 (with-current-buffer gnus-original-article-buffer
2620 (gnus-fetch-field "content-transfer-encoding"))
2621 (let* ((ct (gnus-fetch-field "content-type"))
2622 (ctl (and ct
(mail-header-parse-content-type ct
))))
2623 (setq charset
(and ctl
2624 (mail-content-type-get ctl
'charset
)))
2625 (if (stringp charset
)
2626 (setq charset
(intern (downcase charset
)))))))
2628 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2630 (setq charset gnus-newsgroup-charset
))
2632 (and type
(let ((case-fold-search t
))
2633 (string-match "base64" type
))))
2636 (narrow-to-region (point) (point-max))
2637 (base64-decode-region (point-min) (point-max))
2638 (mm-decode-coding-region
2639 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2644 (defun article-decode-HZ ()
2645 "Translate a HZ-encoded article."
2649 (let ((inhibit-read-only t
))
2650 (rfc1843-decode-region (point-min) (point-max)))))
2652 (defun article-unsplit-urls ()
2653 "Remove the newlines that some other mailers insert into URLs."
2656 (let ((inhibit-read-only t
))
2657 (goto-char (point-min))
2658 (while (re-search-forward
2659 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2660 (replace-match "\\1\\3" t
)))
2661 (when (interactive-p)
2662 (gnus-treat-article nil
))))
2665 (defun article-wash-html (&optional read-charset
)
2666 "Format an HTML article.
2667 If READ-CHARSET, ask for a coding system. If it is a number, the
2668 charset defined in `gnus-summary-show-article-charset-alist' is used."
2671 (let ((inhibit-read-only t
)
2674 (if (or (and (numberp read-charset
)
2678 gnus-summary-show-article-charset-alist
))))
2679 (setq charset
(mm-read-coding-system "Charset: ")))
2680 (let ((gnus-summary-show-article-charset-alist
2681 (list (cons 1 charset
))))
2682 (with-current-buffer gnus-summary-buffer
2683 (gnus-summary-show-article 1)))
2684 (error "No charset is given"))
2685 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2686 (with-current-buffer gnus-original-article-buffer
2687 (let* ((ct (gnus-fetch-field "content-type"))
2688 (ctl (and ct
(mail-header-parse-content-type ct
))))
2689 (setq charset
(and ctl
2690 (mail-content-type-get ctl
'charset
)))
2691 (when (stringp charset
)
2692 (setq charset
(intern (downcase charset
)))))))
2694 (setq charset gnus-newsgroup-charset
)))
2696 (save-window-excursion
2698 (narrow-to-region (point) (point-max))
2699 (let* ((func (or gnus-article-wash-function mm-text-html-renderer
))
2700 (entry (assq func mm-text-html-washer-alist
)))
2702 (setq func
(cdr entry
)))
2707 (apply (car func
) (cdr func
))))))))))
2710 (declare-function w3-region
"ext:w3-display" (st nd
))
2712 (defun gnus-article-wash-html-with-w3 ()
2713 "Wash the current buffer with w3."
2715 (let ((w3-strict-width (window-width))
2716 (url-standalone-mode t
)
2717 (url-gateway-unplugged t
)
2718 (w3-honor-stylesheets nil
))
2720 (w3-region (point-min) (point-max))
2724 (declare-function w3m-region
"ext:w3m" (start end
&optional url charset
))
2726 (defun gnus-article-wash-html-with-w3m ()
2727 "Wash the current buffer with emacs-w3m."
2729 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp
)
2730 w3m-force-redisplay
)
2731 (w3m-region (point-min) (point-max)))
2732 ;; Put the mark meaning this part was rendered by emacs-w3m.
2733 (put-text-property (point-min) (point-max) 'mm-inline-text-html-with-w3m t
)
2734 (when (and mm-inline-text-html-with-w3m-keymap
2735 (boundp 'w3m-minor-mode-map
)
2737 (if (and (boundp 'w3m-link-map
)
2739 (let* ((start (point-min))
2741 (on (get-text-property start
'w3m-href-anchor
))
2742 (map (copy-keymap w3m-link-map
))
2744 (set-keymap-parent map w3m-minor-mode-map
)
2745 (while (< start end
)
2748 (setq next
(or (text-property-any start end
2749 'w3m-href-anchor nil
)
2751 (put-text-property start next
'keymap map
))
2752 (setq next
(or (text-property-not-all start end
2753 'w3m-href-anchor nil
)
2755 (put-text-property start next
'keymap w3m-minor-mode-map
))
2758 (put-text-property (point-min) (point-max) 'keymap w3m-minor-mode-map
))))
2760 (defvar charset
) ;; Bound by `article-wash-html'.
2762 (defun gnus-article-wash-html-with-w3m-standalone ()
2763 "Wash the current buffer with w3m."
2764 (if (mm-w3m-standalone-supports-m17n-p)
2766 (unless (mm-coding-system-p charset
) ;; Bound by `article-wash-html'.
2768 (setq charset
'iso-8859-1
))
2769 (let ((coding-system-for-write charset
)
2770 (coding-system-for-read charset
))
2771 (call-process-region
2772 (point-min) (point-max)
2773 "w3m" t t nil
"-dump" "-T" "text/html"
2774 "-I" (symbol-name charset
) "-O" (symbol-name charset
))))
2775 (mm-inline-wash-with-stdin nil
"w3m" "-dump" "-T" "text/html")))
2777 (defvar gnus-article-browse-html-temp-list nil
2778 "List of temporary files created by `gnus-article-browse-html-parts'.
2779 Internal variable.")
2781 (defcustom gnus-article-browse-delete-temp
'ask
2782 "What to do with temporary files from `gnus-article-browse-html-parts'.
2783 If nil, don't delete temporary files. If it is t, delete them on
2784 exit from the summary buffer. If it is the symbol `file', query
2785 on each file, if it is `ask' ask once when exiting from the
2787 :group
'gnus-article
2788 :version
"23.1" ;; No Gnus
2789 :type
'(choice (const :tag
"Don't delete" nil
)
2790 (const :tag
"Don't ask" t
)
2791 (const :tag
"Ask" ask
)
2792 (const :tag
"Ask for each file" file
)))
2794 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2796 (defun gnus-article-browse-delete-temp-files (&optional how
)
2797 "Delete temp-files created by `gnus-article-browse-html-parts'."
2798 (when (and gnus-article-browse-html-temp-list
2800 (setq how gnus-article-browse-delete-temp
)))
2801 (when (and (eq how
'ask
)
2802 (gnus-y-or-n-p (format
2803 "Delete all %s temporary HTML file(s)? "
2804 (length gnus-article-browse-html-temp-list
)))
2806 (dolist (file gnus-article-browse-html-temp-list
)
2807 (when (and (file-exists-p file
)
2809 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2811 (format "Delete temporary HTML file `%s'? " file
))))
2812 (delete-file file
)))
2813 ;; Also remove file from the list when not deleted or if file doesn't
2815 (setq gnus-article-browse-html-temp-list nil
))
2816 gnus-article-browse-html-temp-list
)
2818 (defun gnus-article-browse-html-parts (list &optional header
)
2819 "View all \"text/html\" parts from LIST.
2820 Recurse into multiparts. The optional HEADER that should be a decoded
2821 message header will be added to the bodies of the \"text/html\" parts."
2822 ;; Internal function used by `gnus-article-browse-html-article'.
2823 (let (type file charset tmp-file showed
)
2824 ;; Find and show the html-parts.
2825 (dolist (handle list
)
2826 ;; If HTML, show it:
2827 (cond ((not (listp handle
)))
2828 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2829 (and (equal (car type
) "message/external-body")
2831 (setq file
(or (mail-content-type-get type
'name
)
2832 (mail-content-type-get
2833 (mm-handle-disposition handle
)
2835 (or (mm-handle-cache handle
)
2836 (condition-case code
2837 (progn (mm-extern-cache-contents handle
) t
)
2839 (gnus-message 3 "%s" (error-message-string code
))
2840 (when (>= gnus-verbose
3) (sit-for 2))
2843 (setq handle
(mm-handle-cache handle
)
2844 type
(mm-handle-type handle
))
2845 (equal (car type
) "text/html"))))
2846 (when (or (setq charset
(mail-content-type-get type
'charset
))
2849 (setq tmp-file
(mm-make-temp-file
2850 ;; Do we need to care for 8.3 filenames?
2851 "mm-" nil
".html")))
2852 ;; Add a meta html tag to specify charset and a header.
2855 (let (title eheader body hcharset coding
)
2857 (mm-enable-multibyte)
2858 (setq case-fold-search t
)
2859 (insert header
"\n")
2860 (setq title
(message-fetch-field "subject"))
2861 (goto-char (point-min))
2862 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t
)
2863 (replace-match (cond ((match-beginning 1) "<")
2864 ((match-beginning 2) ">")
2866 (goto-char (point-min))
2868 (goto-char (point-max))
2869 (insert "</pre>\n<hr>\n")
2870 ;; We have to examine charset one by one since
2871 ;; charset specified in parts might be different.
2872 (if (eq charset
'gnus-decoded
)
2873 (setq charset
'utf-8
2874 eheader
(mm-encode-coding-string (buffer-string)
2877 (mm-encode-coding-string title charset
))
2878 body
(mm-encode-coding-string (mm-get-part handle
)
2880 (setq hcharset
(mm-find-mime-charset-region (point-min)
2882 (cond ((= (length hcharset
) 1)
2883 (setq hcharset
(car hcharset
)
2884 coding
(mm-charset-to-coding-system
2886 ((> (length hcharset
) 1)
2887 (setq hcharset
'utf-8
2893 (mm-charset-to-coding-system charset
))
2894 (if (eq coding body
)
2895 (setq eheader
(mm-encode-coding-string
2896 (buffer-string) coding
)
2898 (mm-encode-coding-string
2900 body
(mm-get-part handle
))
2901 (setq charset
'utf-8
2902 eheader
(mm-encode-coding-string
2903 (buffer-string) charset
)
2905 (mm-encode-coding-string
2907 body
(mm-encode-coding-string
2908 (mm-decode-coding-string
2909 (mm-get-part handle
) body
)
2911 (setq charset hcharset
2912 eheader
(mm-encode-coding-string
2913 (buffer-string) coding
)
2915 (mm-encode-coding-string
2917 body
(mm-get-part handle
)))
2918 (setq eheader
(mm-string-as-unibyte (buffer-string))
2919 body
(mm-get-part handle
))))
2921 (mm-disable-multibyte)
2924 (mm-add-meta-html-tag handle charset
))
2926 (goto-char (point-min))
2927 (unless (search-forward "<title>" nil t
)
2928 (re-search-forward "<head>\\s-*" nil t
)
2929 (insert "<title>" title
"</title>\n")))
2930 (goto-char (point-min))
2931 (or (re-search-forward
2932 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2934 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2936 (mm-write-region (point-min) (point-max)
2937 tmp-file nil nil nil
'binary t
))))
2939 (mm-with-unibyte-buffer
2940 (insert (if (eq charset
'gnus-decoded
)
2941 (mm-encode-coding-string
2942 (mm-get-part handle
)
2943 (setq charset
'utf-8
))
2944 (mm-get-part handle
)))
2945 (if (or (mm-add-meta-html-tag handle charset
)
2947 (mm-write-region (point-min) (point-max)
2948 tmp-file nil nil nil
'binary t
)
2949 (setq tmp-file nil
))))
2951 (mm-save-part-to-file handle tmp-file
)))
2953 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2954 (add-hook 'gnus-summary-prepare-exit-hook
2955 'gnus-article-browse-delete-temp-files
)
2956 (add-hook 'gnus-exit-gnus-hook
2958 (gnus-article-browse-delete-temp-files t
)))
2959 ;; FIXME: Warn if there's an <img> tag?
2960 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2962 ;; If multipart, recurse
2963 ((equal (mm-handle-media-supertype handle
) "multipart")
2964 (when (gnus-article-browse-html-parts handle header
)
2966 ((equal (mm-handle-media-type handle
) "message/rfc822")
2967 (mm-with-multibyte-buffer
2968 (mm-insert-part handle
)
2969 (setq handle
(mm-dissect-buffer t t
))
2970 (when (and (bufferp (car handle
))
2971 (stringp (car (mm-handle-type handle
))))
2972 (setq handle
(list handle
)))
2974 (article-decode-encoded-words)
2975 (let ((gnus-visible-headers
2976 (or (get 'gnus-visible-headers
'standard-value
)
2977 gnus-visible-headers
)))
2978 (article-hide-headers))
2979 (goto-char (point-min))
2980 (search-forward "\n\n" nil
'move
)
2981 (skip-chars-backward "\t\n ")
2982 (setq header
(buffer-substring (point-min) (point)))))
2984 (gnus-article-browse-html-parts handle header
)
2985 (mm-destroy-parts handle
))
2989 (defun gnus-article-browse-html-article (&optional arg
)
2990 "View \"text/html\" parts of the current article with a WWW browser.
2991 The message header is added to the beginning of every html part unless
2992 the prefix argument ARG is given.
2994 Warning: Spammers use links to images in HTML articles to verify
2995 whether you have read the message. As
2996 `gnus-article-browse-html-article' passes the HTML content to the
2997 browser without eliminating these \"web bugs\" you should only
2998 use it for mails from trusted senders.
3000 If you always want to display HTML parts in the browser, set
3001 `mm-text-html-renderer' to nil."
3002 ;; Cf. `mm-w3m-safe-url-regexp'
3005 (gnus-summary-show-article)
3006 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3007 gnus-visible-headers
))
3008 ;; As we insert a <hr>, there's no need for the body boundary.
3009 (gnus-treat-body-boundary nil
))
3010 (gnus-summary-show-article)))
3011 (with-current-buffer gnus-article-buffer
3012 (let ((header (unless arg
3015 (buffer-substring-no-properties
3016 (goto-char (point-min))
3017 (if (search-forward "\n\n" nil t
)
3019 (goto-char (point-max))
3020 (skip-chars-backward "\t\n ")
3023 (set-buffer gnus-original-article-buffer
)
3024 (setq parts
(mm-dissect-buffer t t
))
3025 ;; If singlepart, enforce a list.
3026 (when (and (bufferp (car parts
))
3027 (stringp (car (mm-handle-type parts
))))
3028 (setq parts
(list parts
)))
3030 (unless (gnus-article-browse-html-parts parts header
)
3031 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3032 (mm-destroy-parts parts
)
3034 (gnus-summary-show-article)))))
3036 (defun article-hide-list-identifiers ()
3037 "Remove list identifies from the Subject header.
3038 The `gnus-list-identifiers' variable specifies what to do."
3040 (let ((inhibit-point-motion-hooks t
)
3041 (regexp (if (consp gnus-list-identifiers
)
3042 (mapconcat 'identity gnus-list-identifiers
" *\\|")
3043 gnus-list-identifiers
))
3044 (inhibit-read-only t
))
3048 (article-narrow-to-head)
3049 (goto-char (point-min))
3050 (while (re-search-forward
3051 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3053 (delete-region (match-beginning 2) (match-end 0))
3054 (beginning-of-line))
3055 (when (re-search-forward
3056 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3057 (delete-region (match-beginning 1) (match-end 1))))))))
3059 (defun article-hide-pem (&optional arg
)
3060 "Toggle hiding of any PEM headers and signatures in the current article.
3061 If given a negative prefix, always show; if given a positive prefix,
3063 (interactive (gnus-article-hidden-arg))
3064 (unless (gnus-article-check-hidden-text 'pem arg
)
3066 (let ((inhibit-read-only t
) end
)
3067 (goto-char (point-min))
3068 ;; Hide the horrendously ugly "header".
3069 (when (and (search-forward
3070 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3072 (setq end
(1+ (match-beginning 0))))
3073 (gnus-add-wash-type 'pem
)
3074 (gnus-article-hide-text-type
3076 (if (search-forward "\n\n" nil t
)
3080 ;; Hide the trailer as well
3081 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3083 (gnus-article-hide-text-type
3084 (match-beginning 0) (match-end 0) 'pem
)))))))
3086 (defun article-strip-banner ()
3087 "Strip the banners specified by the `banner' group parameter and by
3088 `gnus-article-address-banner-alist'."
3092 (let ((inhibit-point-motion-hooks t
))
3093 (when (gnus-parameter-banner gnus-newsgroup-name
)
3094 (article-really-strip-banner
3095 (gnus-parameter-banner gnus-newsgroup-name
)))
3096 (when gnus-article-address-banner-alist
3097 ;; Note that the From header is decoded here, so it is
3098 ;; required that the *-extract-address-components function
3099 ;; supports non-ASCII text.
3100 (let ((from (save-restriction
3102 (article-narrow-to-head)
3103 (mail-fetch-field "from"))))
3106 (cadr (funcall gnus-extract-address-components
3109 (dolist (pair gnus-article-address-banner-alist
)
3110 (when (string-match (car pair
) from
)
3112 (article-really-strip-banner (cdr pair
)))))))))))))
3114 (defun article-really-strip-banner (banner)
3115 "Strip the banner specified by the argument."
3118 (let ((inhibit-point-motion-hooks t
)
3119 (gnus-signature-limit nil
)
3120 (inhibit-read-only t
))
3123 ((eq banner
'signature
)
3124 (when (gnus-article-narrow-to-signature)
3127 (delete-region (point) (point-max))))
3129 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3130 (while (re-search-forward banner nil t
)
3131 (delete-region (match-beginning 0) (match-end 0)))))
3133 (while (re-search-forward banner nil t
)
3134 (delete-region (match-beginning 0) (match-end 0)))))))))
3136 (defun article-babel ()
3137 "Translate article using an online translation service."
3140 (gnus-with-article-buffer
3141 (when (article-goto-body)
3142 (let* ((start (point))
3144 (orig (buffer-substring start end
))
3145 (trans (babel-as-string orig
)))
3147 (narrow-to-region start end
)
3148 (delete-region start end
)
3151 (defun article-hide-signature (&optional arg
)
3152 "Hide the signature in the current article.
3153 If given a negative prefix, always show; if given a positive prefix,
3155 (interactive (gnus-article-hidden-arg))
3156 (unless (gnus-article-check-hidden-text 'signature arg
)
3159 (let ((inhibit-read-only t
))
3160 (when (gnus-article-narrow-to-signature)
3161 (gnus-article-hide-text-type
3162 (point-min) (point-max) 'signature
))))))
3163 (gnus-set-mode-line 'article
))
3165 (defun article-strip-headers-in-body ()
3166 "Strip offensive headers from bodies."
3170 (let ((case-fold-search t
))
3171 (when (looking-at "x-no-archive:")
3172 (gnus-delete-line)))))
3174 (defun article-strip-leading-blank-lines ()
3175 "Remove all blank lines from the beginning of the article."
3178 (let ((inhibit-point-motion-hooks t
)
3179 (inhibit-read-only t
))
3180 (when (article-goto-body)
3181 (while (and (not (eobp))
3182 (looking-at "[ \t]*$"))
3183 (gnus-delete-line))))))
3185 (defun article-narrow-to-head ()
3186 "Narrow the buffer to the head of the message.
3187 Point is left at the beginning of the narrowed-to region."
3189 (goto-char (point-min))
3190 (if (search-forward "\n\n" nil
1)
3193 (goto-char (point-min)))
3195 (defun article-goto-body ()
3196 "Place point at the start of the body."
3197 (goto-char (point-min))
3199 ;; This variable is only bound when dealing with separate
3201 (article-goto-body-goes-to-point-min-p
3203 ((search-forward "\n\n" nil t
)
3206 (goto-char (point-max))
3209 (defun article-strip-multiple-blank-lines ()
3210 "Replace consecutive blank lines with one empty line."
3213 (let ((inhibit-point-motion-hooks t
)
3214 (inhibit-read-only t
))
3215 ;; First make all blank lines empty.
3217 (while (re-search-forward "^[ \t]+$" nil t
)
3218 (unless (gnus-annotation-in-region-p
3219 (match-beginning 0) (match-end 0))
3220 (replace-match "" nil t
)))
3221 ;; Then replace multiple empty lines with a single empty line.
3223 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3224 (unless (gnus-annotation-in-region-p
3225 (match-beginning 0) (match-end 0))
3226 (delete-region (match-beginning 1) (match-end 1)))))))
3228 (defun article-strip-leading-space ()
3229 "Remove all white space from the beginning of the lines in the article."
3232 (let ((inhibit-point-motion-hooks t
)
3233 (inhibit-read-only t
))
3235 (while (re-search-forward "^[ \t]+" nil t
)
3236 (replace-match "" t t
)))))
3238 (defun article-strip-trailing-space ()
3239 "Remove all white space from the end of the lines in the article."
3242 (let ((inhibit-point-motion-hooks t
)
3243 (inhibit-read-only t
))
3245 (while (re-search-forward "[ \t]+$" nil t
)
3246 (replace-match "" t t
)))))
3248 (defun article-strip-blank-lines ()
3249 "Strip leading, trailing and multiple blank lines."
3251 (article-strip-leading-blank-lines)
3252 (article-remove-trailing-blank-lines)
3253 (article-strip-multiple-blank-lines))
3255 (defun article-strip-all-blank-lines ()
3256 "Strip all blank lines."
3259 (let ((inhibit-point-motion-hooks t
)
3260 (inhibit-read-only t
))
3262 (while (re-search-forward "^[ \t]*\n" nil t
)
3263 (replace-match "" t t
)))))
3265 (defun gnus-article-narrow-to-signature ()
3266 "Narrow to the signature; return t if a signature is found, else nil."
3267 (let ((inhibit-point-motion-hooks t
))
3268 (when (gnus-article-search-signature)
3270 ;; Check whether we have some limits to what we consider
3271 ;; to be a signature.
3272 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3273 (list gnus-signature-limit
)))
3275 (while (setq limit
(pop limits
))
3276 (if (or (and (integerp limit
)
3277 (< (- (point-max) (point)) limit
))
3279 (< (count-lines (point) (point-max)) limit
))
3280 (and (functionp limit
)
3282 (and (stringp limit
)
3283 (not (re-search-forward limit nil t
))))
3284 () ; This limit did not succeed.
3288 (narrow-to-region (point) (point-max))
3291 (defun gnus-article-search-signature ()
3292 "Search the current buffer for the signature separator.
3293 Put point at the beginning of the signature separator."
3294 (let ((cur (point)))
3295 (goto-char (point-max))
3296 (if (if (stringp gnus-signature-separator
)
3297 (re-search-backward gnus-signature-separator nil t
)
3298 (let ((seps gnus-signature-separator
))
3300 (not (re-search-backward (car seps
) nil t
)))
3307 (defun gnus-article-hidden-arg ()
3308 "Return the current prefix arg as a number, or 0 if no prefix."
3309 (list (if current-prefix-arg
3310 (prefix-numeric-value current-prefix-arg
)
3313 (defun gnus-article-check-hidden-text (type arg
)
3314 "Return nil if hiding is necessary.
3315 Arg can be nil or a number. nil and positive means hide, negative
3316 means show, 0 means toggle."
3319 (let ((hide (gnus-article-hidden-text-p type
)))
3325 (gnus-article-show-hidden-text type
)
3328 (if (eq hide
'hidden
)
3330 (gnus-article-show-hidden-text type
)
3334 (defun gnus-article-hidden-text-p (type)
3335 "Say whether the current buffer contains hidden text of type TYPE."
3336 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3338 (not (get-text-property pos
'invisible
))
3339 (not (get-text-property pos
'dummy-invisible
)))
3341 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3346 (defun gnus-article-show-hidden-text (type &optional dummy
)
3347 "Show all hidden text of type TYPE.
3348 Originally it is hide instead of DUMMY."
3349 (let ((inhibit-read-only t
)
3350 (inhibit-point-motion-hooks t
))
3351 (gnus-remove-text-properties-when
3353 (point-min) (point-max)
3354 (cons 'article-type
(cons type
3355 gnus-hidden-properties
)))
3356 (gnus-delete-wash-type type
)))
3358 (defconst article-time-units
3359 `((year .
,(* 365.25 24 60 60))
3360 (week .
,(* 7 24 60 60))
3361 (day .
,(* 24 60 60))
3365 "Mapping from time units to seconds.")
3367 (defun gnus-article-forward-header ()
3368 "Move point to the start of the next header.
3369 If the current header is a continuation header, this can be several
3374 (if (looking-at "[ \t]+[^ \t]")
3378 (defun article-date-ut (&optional type highlight
)
3379 "Convert DATE date to universal time in the current article.
3380 If TYPE is `local', convert to local time; if it is `lapsed', output
3381 how much time has lapsed since DATE. For `lapsed', the value of
3382 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3383 should replace the \"Date:\" one, or should be added below it."
3384 (interactive (list 'ut t
))
3385 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3386 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
3390 (article-lapsed-timer
3394 (case-fold-search t
)
3395 (inhibit-read-only t
)
3396 (inhibit-point-motion-hooks t
)
3397 pos date bface eface
)
3401 (goto-char (point-min))
3402 (while (or (setq date
(get-text-property (setq pos
(point))
3404 (when (setq pos
(next-single-property-change
3405 (point) 'original-date
))
3406 (setq date
(get-text-property pos
'original-date
))
3409 pos
(if (setq pos
(text-property-any pos
(point-max)
3410 'original-date nil
))
3413 (if (or (bolp) (eobp))
3417 (goto-char (point-min))
3418 (when (re-search-forward tdate-regexp nil t
)
3419 (setq bface
(get-text-property (point-at-bol) 'face
)
3420 eface
(get-text-property (1- (point-at-eol)) 'face
)))
3421 (goto-char (point-min))
3423 ;; Delete any old Date headers.
3424 (while (re-search-forward date-regexp nil t
)
3426 (delete-region (point-at-bol) (progn
3427 (gnus-article-forward-header)
3429 (delete-region (point-at-bol) (progn
3430 (gnus-article-forward-header)
3433 (setq pos
(point))))
3434 (when (and (not pos
)
3435 (re-search-forward tdate-regexp nil t
))
3437 (gnus-goto-char pos
)
3438 (insert (article-make-date-line date
(or type
'ut
)))
3444 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3445 (put-text-property (match-beginning 1) (1+ (match-end 1))
3447 (put-text-property (match-beginning 2) (match-end 2)
3449 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
3450 (goto-char (point-max))
3453 (defun article-make-date-line (date type
)
3454 "Return a DATE line of TYPE."
3455 (unless (memq type
'(local ut original user iso8601 lapsed english
))
3456 (error "Unknown conversion type: %s" type
))
3458 (let ((time (date-to-time date
)))
3460 ;; Convert to the local timezone.
3462 (concat "Date: " (message-make-date time
)))
3463 ;; Convert to Universal Time.
3468 (let* ((e (parse-time-string date
))
3469 (tm (apply 'encode-time e
))
3471 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3472 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3473 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3477 ;; Get the original date from the article.
3478 ((eq type
'original
)
3479 (concat "Date: " (if (string-match "\n+$" date
)
3480 (substring date
0 (match-beginning 0))
3482 ;; Let the user define the format.
3484 (let ((format (or (condition-case nil
3485 (with-current-buffer gnus-summary-buffer
3486 gnus-article-time-format
)
3488 gnus-article-time-format
)))
3489 (if (functionp format
)
3490 (funcall format time
)
3491 (concat "Date: " (format-time-string format time
)))))
3494 (let ((tz (car (current-time-zone time
))))
3497 (format-time-string "%Y%m%dT%H%M%S" time
)
3498 (format "%s%02d%02d"
3499 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3500 (/ (%
(abs tz
) 3600) 60)))))
3501 ;; Do an X-Sent lapsed format.
3503 ;; If the date is seriously mangled, the timezone functions are
3504 ;; liable to bug out, so we ignore all errors.
3505 (let* ((now (current-time))
3506 (real-time (subtract-time now time
))
3507 (real-sec (and real-time
3508 (+ (* (float (car real-time
)) 65536)
3510 (sec (and real-time
(abs real-sec
)))
3520 ;; This is a bit convoluted, but basically we go
3521 ;; through the time units for years, weeks, etc,
3522 ;; and divide things to see whether that results
3523 ;; in positive answers.
3526 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3527 ;; The (remaining) seconds are too few to
3528 ;; be divided into this time unit.
3530 ;; It's big enough, so we output it.
3531 (setq sec
(- sec
(* num
(cdr unit
))))
3533 (concat (if prev
", " "") (int-to-string
3535 " " (symbol-name (car unit
))
3536 (if (> num
1) "s" ""))
3538 article-time-units
"")
3539 ;; If dates are odd, then it might appear like the
3540 ;; article was sent in the future.
3543 " in the future"))))))
3544 ;; Display the date in proper English
3546 (let ((dtime (decode-time time
)))
3549 (number-to-string (nth 3 dtime
))
3550 (let ((digit (%
(nth 3 dtime
) 10)))
3552 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3558 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3560 (number-to-string (nth 5 dtime
))
3562 (format "%02d" (nth 2 dtime
))
3564 (format "%02d" (nth 1 dtime
)))))))
3566 (format "Date: %s (from Gnus)" date
))))
3568 (defun article-date-local (&optional highlight
)
3569 "Convert the current article date to the local timezone."
3570 (interactive (list t
))
3571 (article-date-ut 'local highlight
))
3573 (defun article-date-english (&optional highlight
)
3574 "Convert the current article date to something that is proper English."
3575 (interactive (list t
))
3576 (article-date-ut 'english highlight
))
3578 (defun article-date-original (&optional highlight
)
3579 "Convert the current article date to what it was originally.
3580 This is only useful if you have used some other date conversion
3581 function and want to see what the date was before converting."
3582 (interactive (list t
))
3583 (article-date-ut 'original highlight
))
3585 (defun article-date-lapsed (&optional highlight
)
3586 "Convert the current article date to time lapsed since it was sent."
3587 (interactive (list t
))
3588 (article-date-ut 'lapsed highlight
))
3590 (defun article-update-date-lapsed ()
3591 "Function to be run from a timer to update the lapsed time line."
3593 (let (deactivate-mark)
3598 (set-buffer (window-buffer w
))
3599 (when (eq major-mode
'gnus-article-mode
)
3600 (let ((mark (point-marker)))
3601 (goto-char (point-min))
3602 (when (re-search-forward "^X-Sent:" nil t
)
3603 (article-date-lapsed t
))
3604 (goto-char (marker-position mark
))
3605 (move-marker mark nil
))))
3608 (defun gnus-start-date-timer (&optional n
)
3609 "Start a timer to update the X-Sent header in the article buffers.
3610 The numerical prefix says how frequently (in seconds) the function
3615 (gnus-stop-date-timer)
3616 (setq article-lapsed-timer
3617 (run-at-time 1 n
'article-update-date-lapsed
)))
3619 (defun gnus-stop-date-timer ()
3620 "Stop the X-Sent timer."
3622 (when article-lapsed-timer
3623 (nnheader-cancel-timer article-lapsed-timer
)
3624 (setq article-lapsed-timer nil
)))
3626 (defun article-date-user (&optional highlight
)
3627 "Convert the current article date to the user-defined format.
3628 This format is defined by the `gnus-article-time-format' variable."
3629 (interactive (list t
))
3630 (article-date-ut 'user highlight
))
3632 (defun article-date-iso8601 (&optional highlight
)
3633 "Convert the current article date to ISO8601."
3634 (interactive (list t
))
3635 (article-date-ut 'iso8601 highlight
))
3637 (defmacro gnus-article-save-original-date
(&rest forms
)
3638 "Save the original date as a text property and evaluate FORMS."
3639 `(let* ((case-fold-search t
)
3641 (goto-char (point-min))
3642 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3645 (date (when (and start
3646 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3648 (buffer-substring-no-properties start
3649 (match-beginning 0)))))
3650 (goto-char (point-max))
3651 (skip-chars-backward "\n")
3652 (put-text-property (point-min) (point) 'original-date date
)
3654 (goto-char (point-max))
3655 (skip-chars-backward "\n")
3656 (put-text-property (point-min) (point) 'original-date date
)))
3658 ;; (defun article-show-all ()
3659 ;; "Show all hidden text in the article buffer."
3662 ;; (let ((inhibit-read-only t))
3663 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3665 (defun article-remove-leading-whitespace ()
3666 "Remove excessive whitespace from all headers."
3670 (let ((inhibit-read-only t
))
3671 (article-narrow-to-head)
3672 (goto-char (point-min))
3673 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3674 (delete-region (match-beginning 1) (match-end 1)))))))
3676 (defun article-emphasize (&optional arg
)
3677 "Emphasize text according to `gnus-emphasis-alist'."
3678 (interactive (gnus-article-hidden-arg))
3679 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3683 (with-current-buffer gnus-summary-buffer
3684 gnus-article-emphasis-alist
)
3686 gnus-emphasis-alist
))
3687 (inhibit-read-only t
)
3688 (props (append '(article-type emphasis
)
3689 gnus-hidden-properties
))
3690 regexp elem beg invisible visible face
)
3693 (while (setq elem
(pop alist
))
3695 (setq regexp
(car elem
)
3696 invisible
(nth 1 elem
)
3697 visible
(nth 2 elem
)
3699 (while (re-search-forward regexp nil t
)
3700 (when (and (match-beginning visible
) (match-beginning invisible
))
3701 (gnus-article-hide-text
3702 (match-beginning invisible
) (match-end invisible
) props
)
3703 (gnus-article-unhide-text-type
3704 (match-beginning visible
) (match-end visible
) 'emphasis
)
3705 (gnus-put-overlay-excluding-newlines
3706 (match-beginning visible
) (match-end visible
) 'face face
)
3707 (gnus-add-wash-type 'emphasis
)
3708 (goto-char (match-end invisible
)))))))))
3710 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3711 "Setup newsgroup emphasis alist."
3712 (unless gnus-article-emphasis-alist
3713 (let ((name (and gnus-newsgroup-name
3714 (gnus-group-real-name gnus-newsgroup-name
))))
3715 (make-local-variable 'gnus-article-emphasis-alist
)
3716 (setq gnus-article-emphasis-alist
3718 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3719 (while (setq elem
(pop alist
))
3720 (when (and name
(string-match (car elem
) name
))
3722 highlight
(copy-sequence (cdr elem
)))))
3724 (copy-sequence highlight-words
)
3725 (if gnus-newsgroup-name
3726 (copy-sequence (gnus-group-find-parameter
3727 gnus-newsgroup-name
'highlight-words t
)))
3728 gnus-emphasis-alist
)))))
3730 (defvar gnus-summary-article-menu
)
3731 (defvar gnus-summary-post-menu
)
3733 ;;; Saving functions.
3735 (defun gnus-article-save (save-buffer file
&optional num
)
3736 "Save the currently selected article."
3737 (when (or (get gnus-default-article-saver
:headers
)
3738 (not gnus-save-all-headers
))
3739 ;; Remove headers according to `gnus-saved-headers' or the value
3740 ;; of the `:headers' property that the saver function might have.
3741 (let ((gnus-visible-headers
3742 (or (symbol-value (get gnus-default-article-saver
:headers
))
3743 gnus-saved-headers gnus-visible-headers
))
3744 ;; Ignore group parameter. See `article-hide-headers'.
3745 (gnus-summary-buffer nil
))
3746 (with-current-buffer save-buffer
3747 (article-hide-headers 1 t
))))
3748 (save-window-excursion
3749 (if (not gnus-default-article-saver
)
3750 (error "No default saver is defined")
3751 ;; !!! Magic! The saving functions all save
3752 ;; `gnus-save-article-buffer' (or so they think), but we
3753 ;; bind that variable to our save-buffer.
3754 (set-buffer gnus-article-buffer
)
3755 (let* ((gnus-save-article-buffer save-buffer
)
3758 ((not gnus-prompt-before-saving
) 'default
)
3759 ((eq gnus-prompt-before-saving
'always
) nil
)
3761 (gnus-number-of-articles-to-be-saved
3762 (when (eq gnus-prompt-before-saving t
)
3764 (set-buffer gnus-article-current-summary
)
3765 (funcall gnus-default-article-saver filename
)))))
3767 (defun gnus-read-save-file-name (prompt &optional filename
3768 function group headers variable
3771 (funcall function group headers
(symbol-value variable
)))
3776 ((eq filename
'default
)
3782 (when (symbol-value dir-var
)
3783 (setq default-name
(expand-file-name
3784 (file-name-nondirectory default-name
)
3785 (symbol-value dir-var
))))
3786 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3789 (if (and gnus-number-of-articles-to-be-saved
3790 (> gnus-number-of-articles-to-be-saved
1))
3791 (format "these %d articles"
3792 gnus-number-of-articles-to-be-saved
)
3795 ;; Let the split methods have their say.
3797 ;; No split name was found.
3800 (concat prompt
" (default "
3801 (file-name-nondirectory default-name
) "): ")
3802 (file-name-directory default-name
)
3804 ;; A single group name is returned.
3805 ((stringp split-name
)
3807 (funcall function split-name headers
3808 (symbol-value variable
)))
3810 (concat prompt
" (default "
3811 (file-name-nondirectory default-name
) "): ")
3812 (file-name-directory default-name
)
3814 ;; A single split name was found
3815 ((= 1 (length split-name
))
3816 (let* ((name (expand-file-name
3818 gnus-article-save-directory
))
3819 (dir (cond ((file-directory-p name
)
3820 (file-name-as-directory name
))
3821 ((file-exists-p name
) name
)
3822 (t gnus-article-save-directory
))))
3824 (concat prompt
" (default " name
"): ")
3826 ;; A list of splits was found.
3828 (setq split-name
(nreverse split-name
))
3830 (let ((file-name-history
3831 (nconc split-name file-name-history
)))
3835 (concat prompt
" (`M-p' for defaults): ")
3836 gnus-article-save-directory
3838 gnus-article-save-directory
)))
3839 (car (push result file-name-history
)))))))
3840 ;; Create the directory.
3841 (gnus-make-directory (file-name-directory file
))
3842 ;; If we have read a directory, we append the default file name.
3843 (when (file-directory-p file
)
3844 (setq file
(expand-file-name (file-name-nondirectory
3846 (file-name-as-directory file
))))
3847 ;; Possibly translate some characters.
3848 (nnheader-translate-file-chars file
))))))
3849 (gnus-make-directory (file-name-directory result
))
3851 (set variable result
))
3853 (set dir-var
(file-name-directory result
)))
3856 (defun gnus-article-archive-name (group)
3857 "Return the first instance of an \"Archive-name\" in the current buffer."
3858 (let ((case-fold-search t
))
3859 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3860 (nnheader-concat gnus-article-save-directory
3861 (match-string 1)))))
3863 (defun gnus-article-nndoc-name (group)
3864 "If GROUP is an nndoc group, return the name of the parent group."
3865 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3866 (gnus-group-get-parameter group
'save-article-group
)))
3868 (defun gnus-summary-save-in-rmail (&optional filename
)
3869 "Append this article to Rmail file.
3870 Optional argument FILENAME specifies file name.
3871 Directory to save to is default to `gnus-article-save-directory'."
3872 (setq filename
(gnus-read-save-file-name
3873 "Save %s in rmail file" filename
3874 gnus-rmail-save-name gnus-newsgroup-name
3875 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3876 (gnus-eval-in-buffer-window gnus-save-article-buffer
3880 ;; Note that unlike gnus-summary-save-in-mail, there is no
3881 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3883 (gnus-output-to-rmail filename
))))
3886 (defun gnus-summary-save-in-mail (&optional filename
)
3887 "Append this article to Unix mail file.
3888 Optional argument FILENAME specifies file name.
3889 Directory to save to is default to `gnus-article-save-directory'."
3890 (setq filename
(gnus-read-save-file-name
3891 "Save %s in Unix mail file" filename
3892 gnus-mail-save-name gnus-newsgroup-name
3893 gnus-current-headers
'gnus-newsgroup-last-mail
))
3894 (gnus-eval-in-buffer-window gnus-save-article-buffer
3898 (if (and (file-readable-p filename
)
3899 (file-regular-p filename
)
3900 (mail-file-babyl-p filename
))
3901 (gnus-output-to-rmail filename
)
3902 (gnus-output-to-mail filename
)))))
3905 (put 'gnus-summary-save-in-file
:decode t
)
3906 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
3907 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3908 "Append this article to file.
3909 Optional argument FILENAME specifies file name.
3910 Directory to save to is default to `gnus-article-save-directory'."
3911 (setq filename
(gnus-read-save-file-name
3912 "Save %s in file" filename
3913 gnus-file-save-name gnus-newsgroup-name
3914 gnus-current-headers
'gnus-newsgroup-last-file
))
3915 (gnus-eval-in-buffer-window gnus-save-article-buffer
3919 (when (and overwrite
3920 (file-exists-p filename
))
3921 (delete-file filename
))
3922 (gnus-output-to-file filename
))))
3925 (put 'gnus-summary-write-to-file
:decode t
)
3926 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
3927 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
3928 (defun gnus-summary-write-to-file (&optional filename
)
3929 "Write this article to a file, overwriting it if the file exists.
3930 Optional argument FILENAME specifies file name.
3931 The directory to save in defaults to `gnus-article-save-directory'."
3932 (setq filename
(gnus-read-save-file-name
3933 "Save %s in file" filename
3934 gnus-file-save-name gnus-newsgroup-name
3935 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3936 (gnus-summary-save-in-file filename t
))
3938 (put 'gnus-summary-save-body-in-file
:decode t
)
3939 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
3940 "Append this article body to a file.
3941 Optional argument FILENAME specifies file name.
3942 The directory to save in defaults to `gnus-article-save-directory'."
3943 (setq filename
(gnus-read-save-file-name
3944 "Save %s body in file" filename
3945 gnus-file-save-name gnus-newsgroup-name
3946 gnus-current-headers
'gnus-newsgroup-last-file
))
3947 (gnus-eval-in-buffer-window gnus-save-article-buffer
3951 (when (article-goto-body)
3952 (narrow-to-region (point) (point-max)))
3953 (when (and overwrite
3954 (file-exists-p filename
))
3955 (delete-file filename
))
3956 (gnus-output-to-file filename
))))
3959 (put 'gnus-summary-write-body-to-file
:decode t
)
3960 (put 'gnus-summary-write-body-to-file
3961 :function
'gnus-summary-save-body-in-file
)
3962 (defun gnus-summary-write-body-to-file (&optional filename
)
3963 "Write this article body to a file, overwriting it if the file exists.
3964 Optional argument FILENAME specifies file name.
3965 The directory to save in defaults to `gnus-article-save-directory'."
3966 (setq filename
(gnus-read-save-file-name
3967 "Save %s body in file" filename
3968 gnus-file-save-name gnus-newsgroup-name
3969 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3970 (gnus-summary-save-body-in-file filename t
))
3972 (put 'gnus-summary-save-in-pipe
:decode t
)
3973 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
3974 (defun gnus-summary-save-in-pipe (&optional command raw
)
3975 "Pipe this article to subprocess COMMAND.
3976 Valid values for COMMAND include:
3978 The executable command name and possibly arguments.
3980 You will be prompted for the command in the minibuffer.
3981 the symbol `default'
3982 It will be replaced with the command which the variable
3983 `gnus-summary-pipe-output-default-command' holds or the command
3984 last used for saving.
3985 Non-nil value for RAW overrides `:decode' and `:headers' properties
3986 and the raw article including all headers will be piped."
3987 (let ((article (gnus-summary-article-number))
3989 (get 'gnus-summary-save-in-pipe
:decode
)))
3990 save-buffer default
)
3992 (if (vectorp (gnus-summary-article-header article
))
3993 (save-current-buffer
3994 (gnus-summary-select-article decode decode nil article
)
3995 (insert-buffer-substring
3999 gnus-original-article-buffer
)
4001 (nnheader-set-temp-buffer " *Gnus Save*"))))
4002 ;; Remove unwanted headers.
4003 (when (and (not raw
)
4004 (or (get 'gnus-summary-save-in-pipe
:headers
)
4005 (not gnus-save-all-headers
)))
4006 (let ((gnus-visible-headers
4007 (or (symbol-value (get 'gnus-summary-save-in-pipe
4009 gnus-saved-headers gnus-visible-headers
))
4010 (gnus-summary-buffer nil
))
4011 (article-hide-headers 1 t
))))
4012 (error "%d is not a real article" article
))
4013 (error "No article to pipe"))
4014 (setq default
(or gnus-summary-pipe-output-default-command
4015 gnus-last-shell-command
))
4016 (unless (stringp command
)
4018 (if (and (eq command
'default
) default
)
4020 (gnus-read-shell-command "Shell command on this article: "
4022 (when (string-equal command
"")
4024 (setq command default
)
4025 (error "A command is required")))
4026 (gnus-eval-in-buffer-window save-buffer
4029 (shell-command-on-region (point-min) (point-max) command nil
)))
4030 (gnus-kill-buffer save-buffer
))
4031 (setq gnus-summary-pipe-output-default-command command
))
4033 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4034 "Pipe this article to muttprint."
4035 (unless (stringp command
)
4036 (setq command
(read-string
4037 "Print using command: " gnus-summary-muttprint-program
4038 nil gnus-summary-muttprint-program
)))
4039 (let ((gnus-summary-pipe-output-default-command
4040 gnus-summary-pipe-output-default-command
))
4041 (gnus-summary-save-in-pipe command
))
4042 (setq gnus-summary-muttprint-program command
))
4044 ;;; Article file names when saving.
4046 (defun gnus-capitalize-newsgroup (newsgroup)
4047 "Capitalize NEWSGROUP name."
4048 (when (not (zerop (length newsgroup
)))
4049 (concat (char-to-string (upcase (aref newsgroup
0)))
4050 (substring newsgroup
1))))
4052 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4053 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4054 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4055 Otherwise, it is like ~/News/news/group/num."
4058 (concat (if (gnus-use-long-file-name 'not-save
)
4059 (gnus-capitalize-newsgroup newsgroup
)
4060 (gnus-newsgroup-directory-form newsgroup
))
4061 "/" (int-to-string (mail-header-number headers
)))
4062 gnus-article-save-directory
)))
4064 (string-equal (file-name-directory default
)
4065 (file-name-directory last-file
))
4066 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4068 (or last-file default
))))
4070 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4071 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4072 If variable `gnus-use-long-file-name' is non-nil, it is
4073 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4076 (concat (if (gnus-use-long-file-name 'not-save
)
4078 (gnus-newsgroup-directory-form newsgroup
))
4079 "/" (int-to-string (mail-header-number headers
)))
4080 gnus-article-save-directory
)))
4082 (string-equal (file-name-directory default
)
4083 (file-name-directory last-file
))
4084 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4086 (or last-file default
))))
4088 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4089 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4090 If variable `gnus-use-long-file-name' is non-nil, it is
4091 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4094 (if (gnus-use-long-file-name 'not-save
)
4097 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4099 gnus-article-save-directory
)))
4101 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4102 "Generate file name from sender."
4103 (let ((from (mail-header-from headers
)))
4105 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4106 (match-string 1 from
)
4108 gnus-article-save-directory
)))
4110 (defun article-verify-x-pgp-sig ()
4112 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4114 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4115 (let ((sig (with-current-buffer gnus-original-article-buffer
4116 (gnus-fetch-field "X-PGP-Sig")))
4120 (mml2015-clear-verify-function))
4122 (insert-buffer-substring gnus-original-article-buffer
)
4123 (setq items
(split-string sig
))
4124 (message-narrow-to-head)
4125 (let ((inhibit-point-motion-hooks t
)
4126 (case-fold-search t
))
4127 ;; Don't verify multiple headers.
4128 (setq headers
(mapconcat (lambda (header)
4130 (mail-fetch-field header
)
4132 (split-string (nth 1 items
) ",") "")))
4133 (delete-region (point-min) (point-max))
4134 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4135 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4140 (if (looking-at "^-")
4143 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4144 (insert "Version: " (car items
) "\n\n")
4145 (insert (mapconcat 'identity
(cddr items
) "\n"))
4146 (insert "\n-----END PGP SIGNATURE-----\n")
4147 (let ((mm-security-handle (list (format "multipart/signed"))))
4148 (mml2015-clean-buffer)
4149 (let ((coding-system-for-write (or gnus-newsgroup-charset
4151 (funcall (mml2015-clear-verify-function)))
4153 (or (mm-handle-multipart-ctl-parameter
4154 mm-security-handle
'gnus-details
)
4155 (mm-handle-multipart-ctl-parameter
4156 mm-security-handle
'gnus-info
)))))
4158 (let ((inhibit-read-only t
) bface eface
)
4160 (message-narrow-to-head)
4161 (goto-char (point-max))
4163 (setq bface
(get-text-property (point-at-bol) 'face
)
4164 eface
(get-text-property (1- (point-at-eol)) 'face
))
4165 (message-remove-header "X-Gnus-PGP-Verify")
4166 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4168 (goto-char (point-max)))
4169 (narrow-to-region (point) (point))
4170 (insert "X-Gnus-PGP-Verify: " info
"\n")
4171 (goto-char (point-min))
4174 (if (not (looking-at "^[ \t]"))
4178 (goto-char (point-min))
4179 (when (looking-at "\\([^:]+\\): *")
4180 (put-text-property (match-beginning 1) (1+ (match-end 1))
4182 (put-text-property (match-end 0) (point-max)
4183 'face eface
)))))))))
4185 (defun article-verify-cancel-lock ()
4186 "Verify Cancel-Lock header."
4188 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4189 (canlock-verify gnus-original-article-buffer
)))
4196 (setq afunc
(car func
)
4199 gfunc
(intern (format "gnus-%s" func
))))
4201 (when (fboundp afunc
)
4202 `(lambda (&optional interactive
&rest args
)
4203 ,(documentation afunc t
)
4204 (interactive (list t
))
4205 (with-current-buffer gnus-article-buffer
4207 (call-interactively ',afunc
)
4208 (apply ',afunc args
))))))))
4209 '(article-hide-headers
4210 article-verify-x-pgp-sig
4211 article-verify-cancel-lock
4212 article-hide-boring-headers
4213 article-treat-overstrike
4214 article-treat-ansi-sequences
4215 article-fill-long-lines
4216 article-capitalize-sentences
4218 article-remove-leading-whitespace
4219 article-display-x-face
4220 article-display-face
4221 article-de-quoted-unreadable
4222 article-de-base64-unreadable
4225 article-unsplit-urls
4226 article-hide-list-identifiers
4227 article-strip-banner
4230 article-hide-signature
4231 article-strip-headers-in-body
4232 article-remove-trailing-blank-lines
4233 article-strip-leading-blank-lines
4234 article-strip-multiple-blank-lines
4235 article-strip-leading-space
4236 article-strip-trailing-space
4237 article-strip-blank-lines
4238 article-strip-all-blank-lines
4240 article-date-english
4241 article-date-iso8601
4242 article-date-original
4244 article-decode-mime-words
4245 article-decode-charset
4246 article-decode-encoded-words
4250 article-treat-dumbquotes
4251 article-normalize-headers
4252 ;;(article-show-all . gnus-article-show-all-headers)
4256 ;;; Gnus article mode
4259 (put 'gnus-article-mode
'mode-class
'special
)
4261 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4263 (gnus-define-keys gnus-article-mode-map
4264 " " gnus-article-goto-next-page
4265 "\177" gnus-article-goto-prev-page
4266 [delete] gnus-article-goto-prev-page
4267 [backspace] gnus-article-goto-prev-page
4268 "\C-c^" gnus-article-refer-article
4269 "h" gnus-article-show-summary
4270 "s" gnus-article-show-summary
4271 "\C-c\C-m" gnus-article-mail
4272 "?" gnus-article-describe-briefly
4273 "e" gnus-summary-edit-article
4274 "<" beginning-of-buffer
4276 "\C-c\C-i" gnus-info-find-node
4278 "R" gnus-article-reply-with-original
4279 "F" gnus-article-followup-with-original
4280 "\C-hk" gnus-article-describe-key
4281 "\C-hc" gnus-article-describe-key-briefly
4282 "\C-hb" gnus-article-describe-bindings
4284 "\C-d" gnus-article-read-summary-keys
4285 "\M-*" gnus-article-read-summary-keys
4286 "\M-#" gnus-article-read-summary-keys
4287 "\M-^" gnus-article-read-summary-keys
4288 "\M-g" gnus-article-read-summary-keys)
4290 (substitute-key-definition
4291 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4293 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4294 "W" gnus-article-wide-reply-with-original)
4295 (if (featurep 'xemacs)
4296 (set-keymap-default-binding gnus-article-send-map
4297 'gnus-article-read-summary-send-keys)
4298 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4300 (defun gnus-article-make-menu-bar ()
4301 (unless (boundp 'gnus-article-commands-menu)
4302 (gnus-summary-make-menu-bar))
4303 (gnus-turn-off-edit-menu 'article)
4304 (unless (boundp 'gnus-article-article-menu)
4306 gnus-article-article-menu gnus-article-mode-map ""
4308 ["Scroll forwards" gnus-article-goto-next-page t]
4309 ["Scroll backwards" gnus-article-goto-prev-page t]
4310 ["Show summary" gnus-article-show-summary t]
4311 ["Fetch Message-ID at point" gnus-article-refer-article t]
4312 ["Mail to address at point" gnus-article-mail t]
4313 ["Send a bug report" gnus-bug t]))
4316 gnus-article-treatment-menu gnus-article-mode-map ""
4317 ;; Fixme: this should use :active (and maybe :visible).
4319 ["Hide headers" gnus-article-hide-headers t]
4320 ["Hide signature" gnus-article-hide-signature t]
4321 ["Hide citation" gnus-article-hide-citation t]
4322 ["Treat overstrike" gnus-article-treat-overstrike t]
4323 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4324 ["Remove carriage return" gnus-article-remove-cr t]
4325 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4326 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4327 ["Remove base64" gnus-article-de-base64-unreadable t]
4328 ["Treat html" gnus-article-wash-html t]
4329 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4330 ["Decode HZ" gnus-article-decode-HZ t]))
4332 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4334 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4336 (gnus-run-hooks 'gnus-article-menu-hook)))
4338 (defun gnus-article-mode ()
4339 "Major mode for displaying an article.
4341 All normal editing commands are switched off.
4343 The following commands are available in addition to all summary mode
4345 \\<gnus-article-mode-map>
4346 \\[gnus-article-next-page]\t Scroll the article one page forwards
4347 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4348 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4349 \\[gnus-article-show-summary]\t Display the summary buffer
4350 \\[gnus-article-mail]\t Send a reply to the address near point
4351 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4352 \\[gnus-info-find-node]\t Go to the Gnus info node"
4354 (kill-all-local-variables)
4355 (gnus-simplify-mode-line)
4356 (setq mode-name "Article")
4357 (setq major-mode 'gnus-article-mode)
4358 (make-local-variable 'minor-mode-alist)
4359 (use-local-map gnus-article-mode-map)
4360 (when (gnus-visual-p 'article-menu 'menu)
4361 (gnus-article-make-menu-bar)
4362 (when gnus-summary-tool-bar-map
4363 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4364 (gnus-update-format-specifications nil 'article-mode)
4365 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4366 (set (make-local-variable 'gnus-page-broken) nil)
4367 (make-local-variable 'gnus-button-marker-list)
4368 (make-local-variable 'gnus-article-current-summary)
4369 (make-local-variable 'gnus-article-mime-handles)
4370 (make-local-variable 'gnus-article-decoded-p)
4371 (make-local-variable 'gnus-article-mime-handle-alist)
4372 (make-local-variable 'gnus-article-wash-types)
4373 (make-local-variable 'gnus-article-image-alist)
4374 (make-local-variable 'gnus-article-charset)
4375 (make-local-variable 'gnus-article-ignored-charsets)
4376 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4378 (set (make-local-variable 'nobreak-char-display) nil)
4379 (setq cursor-in-non-selected-windows nil)
4380 (setq truncate-lines gnus-article-truncate-lines)
4381 (gnus-set-default-directory)
4382 (buffer-disable-undo)
4383 (setq buffer-read-only t
4384 show-trailing-whitespace nil)
4385 (set-syntax-table gnus-article-mode-syntax-table)
4386 (mm-enable-multibyte)
4387 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4389 (defvar gnus-button-marker-list nil
4390 "Regexp matching any of the regexps from `gnus-button-alist'.
4391 Internal variable.")
4393 (defun gnus-article-setup-buffer ()
4394 "Initialize the article buffer."
4395 (let* ((name (if gnus-single-article-buffer "*Article*"
4396 (concat "*Article " gnus-newsgroup-name "*")))
4398 (progn (string-match "\\*Article" name)
4399 (concat " *Original Article"
4400 (substring name (match-end 0))))))
4401 (setq gnus-article-buffer name)
4402 (setq gnus-original-article-buffer original)
4403 (setq gnus-article-mime-handle-alist nil)
4404 (with-current-buffer gnus-summary-buffer
4405 ;; This might be a variable local to the summary buffer.
4406 (unless gnus-single-article-buffer
4407 (setq gnus-article-buffer name)
4408 (setq gnus-original-article-buffer original)
4409 (gnus-set-global-variables)))
4410 (gnus-article-setup-highlight-words)
4411 ;; Init original article buffer.
4412 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4413 (mm-enable-multibyte)
4414 (setq major-mode 'gnus-original-article-mode)
4415 (make-local-variable 'gnus-original-article))
4416 (if (and (get-buffer name)
4417 (with-current-buffer name
4418 (if gnus-article-edit-mode
4419 (if (y-or-n-p "Article mode edit in progress; discard? ")
4421 (set-buffer-modified-p nil)
4422 (gnus-kill-buffer name)
4425 (error "Action aborted"))
4427 (with-current-buffer name
4428 (set (make-local-variable 'gnus-article-edit-mode) nil)
4429 (when gnus-article-mime-handles
4430 (mm-destroy-parts gnus-article-mime-handles)
4431 (setq gnus-article-mime-handles nil))
4432 ;; Set it to nil in article-buffer!
4433 (setq gnus-article-mime-handle-alist nil)
4434 (buffer-disable-undo)
4435 (setq buffer-read-only t)
4436 ;; This list just keeps growing if we don't reset it.
4437 (setq gnus-button-marker-list nil)
4438 (unless (eq major-mode 'gnus-article-mode)
4439 (gnus-article-mode))
4441 (with-current-buffer (gnus-get-buffer-create name)
4443 (make-local-variable 'gnus-summary-buffer)
4444 (setq gnus-summary-buffer
4445 (gnus-summary-buffer-name gnus-newsgroup-name))
4446 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4447 (current-buffer)))))
4449 ;; Set article window start at LINE, where LINE is the number of lines
4450 ;; from the head of the article.
4451 (defun gnus-article-set-window-start (&optional line)
4452 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4453 (when article-window
4456 (with-current-buffer gnus-article-buffer
4457 (goto-char (point-min))
4460 (gnus-message 6 "Moved to bookmark")
4461 (search-forward "\n\n" nil t)
4465 (defun gnus-article-prepare (article &optional all-headers header)
4466 "Prepare ARTICLE in article mode buffer.
4467 ARTICLE should either be an article number or a Message-ID.
4468 If ARTICLE is an id, HEADER should be the article headers.
4469 If ALL-HEADERS is non-nil, no headers are hidden."
4471 ;; Make sure we start in a summary buffer.
4472 (unless (eq major-mode 'gnus-summary-mode)
4473 (set-buffer gnus-summary-buffer))
4474 (setq gnus-summary-buffer (current-buffer))
4475 (let* ((gnus-article (if header (mail-header-number header) article))
4476 (summary-buffer (current-buffer))
4477 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4478 (group gnus-newsgroup-name)
4481 (gnus-article-setup-buffer)
4482 (set-buffer gnus-article-buffer)
4483 ;; Deactivate active regions.
4484 (when (and (boundp 'transient-mark-mode)
4485 transient-mark-mode)
4486 (setq mark-active nil))
4487 (if (not (setq result (let ((inhibit-read-only t))
4488 (gnus-request-article-this-buffer
4490 ;; There is no such article.
4492 (when (and (numberp article)
4493 (not (memq article gnus-newsgroup-sparse)))
4494 (setq gnus-article-current
4495 (cons gnus-newsgroup-name article))
4496 (set-buffer gnus-summary-buffer)
4497 (setq gnus-current-article article)
4498 (if (and (memq article gnus-newsgroup-undownloaded)
4499 (not (gnus-online (gnus-find-method-for-group
4500 gnus-newsgroup-name))))
4502 (gnus-summary-set-agent-mark article)
4503 (message "Message marked for downloading"))
4504 (gnus-summary-mark-article article gnus-canceled-mark)
4505 (unless (memq article gnus-newsgroup-sparse)
4506 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4507 (if (or (eq result 'pseudo)
4508 (eq result 'nneething))
4510 (with-current-buffer summary-buffer
4511 (push article gnus-newsgroup-history)
4512 (setq gnus-last-article gnus-current-article
4513 gnus-current-article 0
4514 gnus-current-headers nil
4515 gnus-article-current nil)
4516 (if (eq result 'nneething)
4517 (gnus-configure-windows 'summary)
4518 (gnus-configure-windows 'article))
4519 (gnus-set-global-variables))
4520 (let ((gnus-article-mime-handle-alist-1
4521 gnus-article-mime-handle-alist))
4522 (gnus-set-mode-line 'article)))
4523 ;; The result from the `request' was an actual article -
4524 ;; or at least some text that is now displayed in the
4526 (when (and (numberp article)
4527 (not (eq article gnus-current-article)))
4528 ;; Seems like a new article has been selected.
4529 ;; `gnus-current-article' must be an article number.
4530 (with-current-buffer summary-buffer
4531 (push article gnus-newsgroup-history)
4532 (setq gnus-last-article gnus-current-article
4533 gnus-current-article article
4534 gnus-current-headers
4535 (gnus-summary-article-header gnus-current-article)
4536 gnus-article-current
4537 (cons gnus-newsgroup-name gnus-current-article))
4538 (unless (vectorp gnus-current-headers)
4539 (setq gnus-current-headers nil))
4540 (gnus-summary-goto-subject gnus-current-article)
4541 (when (gnus-summary-show-thread)
4542 ;; If the summary buffer really was folded, the
4543 ;; previous goto may not actually have gone to
4544 ;; the right article, but the thread root instead.
4546 (gnus-summary-goto-subject gnus-current-article))
4547 (gnus-run-hooks 'gnus-mark-article-hook)
4548 (gnus-set-mode-line 'summary)
4549 (when (gnus-visual-p 'article-highlight 'highlight)
4550 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4551 ;; Set the global newsgroup variables here.
4552 (gnus-set-global-variables)
4553 (setq gnus-have-all-headers
4554 (or all-headers gnus-show-all-headers))))
4556 (gnus-configure-windows 'article))
4557 (when (or (numberp article)
4559 (gnus-article-prepare-display)
4561 (goto-char (point-min))
4562 (when gnus-break-pages
4563 (gnus-narrow-to-page)))
4564 (let ((gnus-article-mime-handle-alist-1
4565 gnus-article-mime-handle-alist))
4566 (gnus-set-mode-line 'article))
4570 (set-window-point (get-buffer-window (current-buffer)) (point))
4571 (gnus-configure-windows 'article)
4575 (defun gnus-article-prepare-display ()
4576 "Make the current buffer look like a nice article."
4577 ;; Hooks for getting information from the article.
4578 ;; This hook must be called before being narrowed.
4579 (let ((gnus-article-buffer (current-buffer))
4581 (inhibit-read-only t))
4582 (unless (eq major-mode 'gnus-article-mode)
4583 (gnus-article-mode))
4584 (setq buffer-read-only nil
4585 gnus-article-wash-types nil
4586 gnus-article-image-alist nil)
4587 (gnus-run-hooks 'gnus-tmp-internal-hook)
4588 (when gnus-display-mime-function
4589 (funcall gnus-display-mime-function))
4590 (gnus-run-hooks 'gnus-article-prepare-hook)))
4593 ;;; Gnus Sticky Article Mode
4596 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4597 "Mode for sticky articles."
4598 ;; Release bindings that won't work.
4599 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4600 gnus-sticky-article-mode-map)
4601 (substitute-key-definition 'gnus-article-refer-article 'undefined
4602 gnus-sticky-article-mode-map)
4603 (dolist (k '("e" "h" "s" "F" "R"))
4604 (define-key gnus-sticky-article-mode-map k nil))
4605 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4606 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4607 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4608 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4610 (defun gnus-sticky-article (arg)
4611 "Make the current article sticky.
4612 If a prefix ARG is given, ask for a name for this sticky article buffer."
4614 (gnus-summary-show-thread)
4615 (gnus-summary-select-article nil nil 'pseudo)
4616 (let (new-art-buf-name)
4617 (gnus-eval-in-buffer-window gnus-article-buffer
4618 (setq new-art-buf-name
4622 (read-from-minibuffer "Sticky article buffer name: ")
4623 (gnus-with-article-headers
4624 (gnus-article-goto-header "subject")
4625 (setq new-art-buf-name
4626 (buffer-substring-no-properties
4627 (line-beginning-position) (line-end-position)))
4628 (goto-char (point-min))
4629 (gnus-article-goto-header "from")
4630 (setq new-art-buf-name
4632 new-art-buf-name ", "
4633 (buffer-substring-no-properties
4634 (line-beginning-position) (line-end-position))))
4635 (goto-char (point-min))
4636 (gnus-article-goto-header "date")
4637 (setq new-art-buf-name
4639 new-art-buf-name ", "
4640 (buffer-substring-no-properties
4641 (line-beginning-position) (line-end-position))))))
4643 (if (and (gnus-buffer-live-p new-art-buf-name)
4644 (with-current-buffer new-art-buf-name
4645 (eq major-mode 'gnus-sticky-article-mode)))
4646 (switch-to-buffer new-art-buf-name)
4647 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4648 (gnus-sticky-article-mode))
4649 (setq gnus-article-buffer new-art-buf-name))
4650 (gnus-summary-recenter)
4651 (gnus-summary-position-point))
4653 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4654 "Kill the given sticky article BUFFER.
4655 If none is given, assume the current buffer and kill it if it has
4656 `gnus-sticky-article-mode'."
4659 (setq buffer (current-buffer)))
4660 (with-current-buffer buffer
4661 (when (eq major-mode 'gnus-sticky-article-mode)
4662 (gnus-kill-buffer buffer))))
4664 (defun gnus-kill-sticky-article-buffers (arg)
4665 "Kill all sticky article buffers.
4666 If a prefix ARG is given, ask for confirmation."
4668 (dolist (buf (gnus-buffers))
4669 (with-current-buffer buf
4670 (when (eq major-mode 'gnus-sticky-article-mode)
4672 (gnus-kill-buffer buf)
4673 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4674 (gnus-kill-buffer buf)))))))
4677 ;;; Gnus MIME viewing functions
4680 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4681 "Format of the MIME buttons.
4683 Valid specifiers include:
4685 %T MIME type, along with additional info
4686 %n The `name' parameter
4687 %d The description, if any
4688 %l The length of the encoded part
4689 %p The part identifier number
4690 %e Dots if the part isn't displayed
4692 General format specifiers can also be used. See Info node
4693 `(gnus)Formatting Variables'.")
4695 (defvar gnus-mime-button-line-format-alist
4696 '((?t gnus-tmp-type ?s)
4697 (?T gnus-tmp-type-long ?s)
4698 (?n gnus-tmp-name ?s)
4699 (?d gnus-tmp-description ?s)
4701 (?l gnus-tmp-length ?d)
4702 (?e gnus-tmp-dots ?s)))
4704 (defvar gnus-mime-button-commands
4705 '((gnus-article-press-button "\r" "Toggle Display")
4706 (gnus-mime-view-part "v" "View Interactively...")
4707 (gnus-mime-view-part-as-type "t" "View As Type...")
4708 (gnus-mime-view-part-as-charset "C" "View As charset...")
4709 (gnus-mime-save-part "o" "Save...")
4710 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4711 (gnus-mime-replace-part "r" "Replace part")
4712 (gnus-mime-delete-part "d" "Delete part")
4713 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4714 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4715 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4716 (gnus-mime-view-part-externally "e" "View Externally")
4717 (gnus-mime-print-part "p" "Print")
4718 (gnus-mime-pipe-part "|" "Pipe To Command...")
4719 (gnus-mime-action-on-part "." "Take action on the part...")))
4721 (defun gnus-article-mime-part-status ()
4722 (if gnus-article-mime-handle-alist-1
4723 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4725 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4728 (defvar gnus-mime-button-map
4729 (let ((map (make-sparse-keymap)))
4730 (define-key map gnus-mouse-2 'gnus-article-push-button)
4731 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4732 (dolist (c gnus-mime-button-commands)
4733 (define-key map (cadr c) (car c)))
4737 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4739 ,@(mapcar (lambda (c)
4740 (vector (caddr c) (car c) :active t))
4741 gnus-mime-button-commands)))
4743 (defun gnus-mime-button-menu (event prefix)
4744 "Construct a context-sensitive menu of MIME commands."
4745 (interactive "e\nP")
4746 (save-window-excursion
4747 (let ((pos (event-start event)))
4748 (select-window (posn-window pos))
4749 (goto-char (posn-point pos))
4750 (gnus-article-check-buffer)
4751 (popup-menu gnus-mime-button-menu nil prefix))))
4753 (defun gnus-mime-view-all-parts (&optional handles)
4754 "View all the MIME parts."
4756 (with-current-buffer gnus-article-buffer
4757 (let ((handles (or handles gnus-article-mime-handles))
4758 (mail-parse-charset gnus-newsgroup-charset)
4759 (mail-parse-ignored-charsets
4760 (with-current-buffer gnus-summary-buffer
4761 gnus-newsgroup-ignored-charsets)))
4763 (mm-remove-parts handles)
4764 (goto-char (point-min))
4765 (or (search-forward "\n\n") (goto-char (point-max)))
4766 (let ((inhibit-read-only t))
4767 (delete-region (point) (point-max))
4768 (mm-display-parts handles))))))
4770 (defun gnus-article-jump-to-part (n)
4771 "Jump to MIME part N."
4773 (pop-to-buffer gnus-article-buffer)
4774 ;; FIXME: why is it necessary?
4776 (let ((parts (length gnus-article-mime-handle-alist)))
4779 (read-string ;; Emacs 21 doesn't have `read-number'.
4780 (format "Jump to part (2..%s): " parts)))))
4781 (unless (and (integerp n) (<= n parts) (>= n 1))
4784 (gnus-message 7 "Invalid part `%s', using %s instead."
4787 (gnus-message 9 "Jumping to part %s." n)
4788 (cond ((>= gnus-auto-select-part 1)
4789 (while (and (<= n parts)
4790 (not (gnus-article-goto-part n)))
4792 ((< gnus-auto-select-part 0)
4793 (while (and (>= n 1)
4794 (not (gnus-article-goto-part n)))
4797 (gnus-article-goto-part n)))))
4800 (defsubst gnus-article-edit-part (handles &optional current-id)
4801 "Edit an article in order to delete a mime part.
4802 This function is exclusively used by `gnus-mime-save-part-and-strip'
4803 and `gnus-mime-delete-part', and not provided at run-time normally."
4804 (gnus-article-edit-article
4806 (buffer-disable-undo)
4808 (let ((mail-parse-charset (or gnus-article-charset
4809 ',gnus-newsgroup-charset))
4810 (mail-parse-ignored-charsets
4811 (or gnus-article-ignored-charsets
4812 ',gnus-newsgroup-ignored-charsets))
4813 (mbl mml-buffer-list))
4814 (setq mml-buffer-list nil)
4815 (insert-buffer-substring gnus-original-article-buffer)
4816 (mime-to-mml ',handles)
4817 (setq gnus-article-mime-handles nil)
4818 (let ((mbl1 mml-buffer-list))
4819 (setq mml-buffer-list mbl)
4820 (set (make-local-variable 'mml-buffer-list) mbl1))
4821 (gnus-make-local-hook 'kill-buffer-hook)
4822 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4823 `(lambda (no-highlight)
4824 (let ((mail-parse-charset (or gnus-article-charset
4825 ',gnus-newsgroup-charset))
4826 (message-options message-options)
4827 (message-options-set-recipient)
4828 (mail-parse-ignored-charsets
4829 (or gnus-article-ignored-charsets
4830 ',gnus-newsgroup-ignored-charsets)))
4832 (mml-destroy-buffers)
4833 (remove-hook 'kill-buffer-hook
4834 'mml-destroy-buffers t)
4835 (kill-local-variable 'mml-buffer-list))
4836 (gnus-summary-edit-article-done
4837 ,(or (mail-header-references gnus-current-headers) "")
4838 ,(gnus-group-read-only-p)
4839 ,gnus-summary-buffer no-highlight))
4841 (gnus-article-edit-done)
4842 (gnus-summary-expand-window)
4843 (gnus-summary-show-article)
4844 (when (and current-id (integerp gnus-auto-select-part))
4845 (gnus-article-jump-to-part
4846 (if (text-property-any (point-min) (point-max)
4847 'gnus-part (+ current-id gnus-auto-select-part))
4848 (+ current-id gnus-auto-select-part)
4849 (with-current-buffer gnus-article-buffer
4850 (length gnus-article-mime-handle-alist)))))))
4852 (defun gnus-mime-replace-part (file)
4853 "Replace MIME part under point with an external body."
4854 ;; Useful if file has already been saved to disk
4857 (read-file-name "Replace MIME part with file: "
4858 (or mm-default-directory default-directory)
4860 (gnus-mime-save-part-and-strip file))
4862 (defun gnus-mime-save-part-and-strip (&optional file)
4863 "Save the MIME part under point then replace it with an external body.
4864 If FILE is given, use it for the external part."
4866 (gnus-article-check-buffer)
4867 (when (gnus-group-read-only-p)
4868 (error "The current group does not support deleting of parts"))
4869 (when (mm-complicated-handles gnus-article-mime-handles)
4871 The current article has a complicated MIME structure, giving up..."))
4872 (let* ((data (get-text-property (point) 'gnus-data))
4873 (id (get-text-property (point) 'gnus-part))
4875 (handles gnus-article-mime-handles))
4878 (and data (mm-save-part data "Delete MIME part and save to: "))))
4880 (with-current-buffer (mm-handle-buffer data)
4882 (insert "Content-Type: " (mm-handle-media-type data))
4883 (mml-insert-parameter-string (cdr (mm-handle-type data))
4885 ;; Add a filename for the sake of saving the part again.
4886 (mml-insert-parameter
4887 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4889 (insert "Content-ID: " (message-make-message-id) "\n")
4890 (insert "Content-Transfer-Encoding: binary\n")
4893 (cdr (mm-make-handle nil
4894 `("message/external-body"
4895 (access-type . "LOCAL-FILE")
4897 ;; (set-buffer gnus-summary-buffer)
4898 (gnus-article-edit-part handles id))))
4900 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4901 ;; parts...>') but with stripping would be nice.
4903 (defun gnus-mime-delete-part ()
4904 "Delete the MIME part under point.
4905 Replace it with some information about the removed part."
4907 (gnus-article-check-buffer)
4908 (when (gnus-group-read-only-p)
4909 (error "The current group does not support deleting of parts"))
4910 (when (mm-complicated-handles gnus-article-mime-handles)
4912 The current article has a complicated MIME structure, giving up..."))
4913 (when (or gnus-expert-user
4914 (gnus-yes-or-no-p "\
4915 Deleting parts may malfunction or destroy the article; continue? "))
4916 (let* ((data (get-text-property (point) 'gnus-data))
4917 (id (get-text-property (point) 'gnus-part))
4918 (handles gnus-article-mime-handles)
4921 (let ((desc (mm-handle-description data)))
4923 (mail-decode-encoded-word-string desc))))
4925 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4927 (type (mm-handle-media-type data)))
4929 (error "No MIME part under point"))
4930 (with-current-buffer (mm-handle-buffer data)
4931 (let ((bsize (format "%s" (buffer-size))))
4936 "| The following attachment has been deleted:\n"
4938 "| Type: " type "\n"
4939 "| Filename: " filename "\n"
4940 "| Size (encoded): " bsize " Byte\n"
4942 (concat "| Description: " description "\n"))
4945 (cdr (mm-make-handle
4946 nil `("text/plain") nil nil
4948 (format "Deleted attachment (%s bytes)" bsize))))))
4949 ;; (set-buffer gnus-summary-buffer)
4950 (gnus-article-edit-part handles id))))
4952 (defun gnus-mime-save-part ()
4953 "Save the MIME part under point."
4955 (gnus-article-check-buffer)
4956 (let ((data (get-text-property (point) 'gnus-data)))
4958 (mm-save-part data))))
4960 (defun gnus-mime-pipe-part ()
4961 "Pipe the MIME part under point to a process."
4963 (gnus-article-check-buffer)
4964 (let ((data (get-text-property (point) 'gnus-data)))
4966 (mm-pipe-part data))))
4968 (defun gnus-mime-view-part ()
4969 "Interactively choose a viewing method for the MIME part under point."
4971 (gnus-article-check-buffer)
4972 (let ((data (get-text-property (point) 'gnus-data)))
4974 (setq gnus-article-mime-handles
4976 gnus-article-mime-handles (setq data (copy-sequence data))))
4977 (mm-interactively-view-part data))))
4979 (defun gnus-mime-view-part-as-type-internal ()
4980 (gnus-article-check-buffer)
4981 (let* ((handle (get-text-property (point) 'gnus-data))
4983 ;; Content-Type: foo/bar; name=...
4984 (mail-content-type-get (mm-handle-type handle) 'name)
4985 ;; Content-Disposition: attachment; filename=...
4986 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4987 (def-type (and name (mm-default-file-encoding name))))
4988 (or (and def-type (cons def-type 0))
4990 (equal (mm-handle-media-supertype handle) "text")
4991 '("text/plain" . 0))
4992 '("application/octet-stream" . 0))))
4994 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4995 "Choose a MIME media type, and view the part as such.
4996 If non-nil, PRED is a predicate to use during completion to limit the
4997 available media-types."
5001 (let ((default (gnus-mime-view-part-as-type-internal)))
5003 (format "View as MIME type (default %s): "
5005 (mapcar #'list (mailcap-mime-types))
5008 (gnus-article-check-buffer)
5009 (let ((handle (get-text-property (point) 'gnus-data)))
5011 (when (equal (mm-handle-media-type handle) "message/external-body")
5012 (unless (mm-handle-cache handle)
5013 (mm-extern-cache-contents handle))
5014 (setq handle (mm-handle-cache handle)))
5016 (mm-make-handle (mm-handle-buffer handle)
5017 (cons mime-type (cdr (mm-handle-type handle)))
5018 (mm-handle-encoding handle)
5019 (mm-handle-undisplayer handle)
5020 (mm-handle-disposition handle)
5021 (mm-handle-description handle)
5023 (mm-handle-id handle)))
5024 (setq gnus-article-mime-handles
5025 (mm-merge-handles gnus-article-mime-handles handle))
5026 (when (mm-handle-displayed-p handle)
5027 (mm-remove-part handle))
5028 (gnus-mm-display-part handle))))
5030 (defun gnus-mime-copy-part (&optional handle arg)
5031 "Put the MIME part under point into a new buffer.
5032 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5034 (interactive (list nil current-prefix-arg))
5035 (gnus-article-check-buffer)
5037 (setq handle (get-text-property (point) 'gnus-data)))
5039 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5041 (mail-content-type-get (mm-handle-disposition handle)
5043 contents dont-decode charset coding-system)
5044 (mm-with-unibyte-buffer
5045 (mm-insert-part handle)
5046 (setq contents (or (condition-case nil
5047 (mm-decompress-buffer filename nil 'sig)
5049 (setq dont-decode t)
5052 (setq filename (cond (filename (file-name-nondirectory filename))
5053 (dont-decode "*raw data*")
5058 (unless (setq charset (mail-content-type-get
5059 (mm-handle-type handle) 'charset))
5060 (unless (setq coding-system (mm-with-unibyte-buffer
5062 (mm-find-buffer-file-coding-system)))
5063 (setq charset gnus-newsgroup-charset))))
5065 (setq charset (or (cdr (assq arg
5066 gnus-summary-show-article-charset-alist))
5067 (mm-read-coding-system "Charset: ")))))
5068 (switch-to-buffer (generate-new-buffer filename))
5069 (if (or coding-system
5071 (setq coding-system (mm-charset-to-coding-system charset))
5072 (not (eq charset 'ascii))))
5074 (mm-enable-multibyte)
5075 (insert (mm-decode-coding-string contents coding-system))
5076 (setq buffer-file-coding-system
5077 (if (boundp 'last-coding-system-used)
5078 (symbol-value 'last-coding-system-used)
5080 (mm-disable-multibyte)
5082 (setq buffer-file-coding-system mm-binary-coding-system))
5083 ;; We do it this way to make `normal-mode' set the appropriate mode.
5086 (setq buffer-file-name (expand-file-name filename))
5088 (setq buffer-file-name nil))
5089 (goto-char (point-min)))))
5091 (defun gnus-mime-print-part (&optional handle filename)
5092 "Print the MIME part under point."
5093 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5094 (gnus-article-check-buffer)
5095 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5096 (contents (and handle (mm-get-part handle)))
5097 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5098 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5103 (mm-save-part-to-file handle file)
5104 (call-process shell-file-name nil
5105 (generate-new-buffer " *mm*")
5107 shell-command-switch
5109 printer file (mm-handle-type handle))))
5113 (gnus-print-buffer))
5114 (ps-despool filename)))))
5116 (defun gnus-mime-inline-part (&optional handle arg)
5117 "Insert the MIME part under point into the current buffer.
5118 Compressed files like .gz and .bz2 are decompressed."
5119 (interactive (list nil current-prefix-arg))
5120 (gnus-article-check-buffer)
5122 (setq handle (get-text-property (point) 'gnus-data)))
5125 (inhibit-read-only t)
5126 contents charset coding-system)
5127 (if (and (not arg) (mm-handle-undisplayer handle))
5128 (mm-remove-part handle)
5129 (mm-with-unibyte-buffer
5130 (mm-insert-part handle)
5132 (or (mm-decompress-buffer
5133 (or (mail-content-type-get (mm-handle-type handle)
5135 (mail-content-type-get (mm-handle-disposition handle)
5141 (unless (setq charset (mail-content-type-get
5142 (mm-handle-type handle) 'charset))
5143 (unless (setq coding-system
5144 (mm-with-unibyte-buffer
5146 (mm-find-buffer-file-coding-system)))
5147 (setq charset gnus-newsgroup-charset))))
5149 (if (mm-handle-undisplayer handle)
5150 (mm-remove-part handle))
5153 gnus-summary-show-article-charset-alist))
5154 (mm-read-coding-system "Charset: "))))
5156 (if (mm-handle-undisplayer handle)
5157 (mm-remove-part handle))))
5161 (if (or coding-system
5164 (mm-charset-to-coding-system charset))
5165 (not (eq coding-system 'ascii))))
5166 (mm-decode-coding-string contents coding-system)
5167 (mm-string-to-multibyte contents)))
5170 (defun gnus-mime-set-charset-parameters (handle charset)
5171 "Set CHARSET to parameters in HANDLE.
5172 CHARSET may either be a string or a symbol."
5173 (unless (stringp charset)
5174 (setq charset (symbol-name charset)))
5175 (if (stringp (car handle))
5176 (dolist (h (cdr handle))
5177 (gnus-mime-set-charset-parameters h charset))
5178 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5179 "message/external-body")
5181 (unless (mm-handle-cache handle)
5182 (mm-extern-cache-contents handle))
5183 (mm-handle-cache handle))
5185 (param (assq 'charset (cdr type))))
5187 (setcdr param charset)
5188 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5190 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5191 "Insert the MIME part under point into the current buffer using the
5193 (interactive (list nil current-prefix-arg))
5194 (gnus-article-check-buffer)
5195 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5196 (fun (get-text-property (point) 'gnus-callback))
5197 (gnus-newsgroup-ignored-charsets 'gnus-all)
5198 charset form preferred parts)
5205 gnus-summary-show-article-charset-alist))
5206 (mm-read-coding-system "Charset: "))))
5207 (if (mm-handle-undisplayer handle)
5208 (mm-remove-part handle)))
5209 (gnus-mime-set-charset-parameters handle charset)
5210 (when (and (consp (setq form (cdr-safe fun)))
5211 (setq form (ignore-errors
5212 (assq 'gnus-mime-display-alternative form)))
5213 (setq preferred (caddr form))
5215 (when (eq (car preferred) 'quote)
5216 (setq preferred (cadr preferred)))
5217 (not (equal preferred
5218 (get-text-property (point) 'gnus-data))))
5219 (setq parts (get-text-property (point) 'gnus-part))
5220 (setq parts (cdr (assq parts
5221 gnus-article-mime-handle-alist)))
5222 (equal (mm-handle-media-type parts) "multipart/alternative")
5223 (setq parts (reverse (cdr parts))))
5225 (list 'quote (or (cadr (member preferred parts))
5227 (funcall fun handle)))))
5229 (defun gnus-mime-view-part-externally (&optional handle)
5230 "View the MIME part under point with an external viewer."
5232 (gnus-article-check-buffer)
5233 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5234 (mm-user-display-methods nil)
5235 (mm-inlined-types nil)
5236 (mail-parse-charset gnus-newsgroup-charset)
5237 (mail-parse-ignored-charsets
5238 (with-current-buffer gnus-summary-buffer
5239 gnus-newsgroup-ignored-charsets))
5240 (type (mm-handle-media-type handle))
5241 (method (mailcap-mime-info type))
5242 (mm-enable-external t))
5243 (if (not (stringp method))
5244 (gnus-mime-view-part-as-type
5245 nil (lambda (types) (stringp (mailcap-mime-info (car types)))))
5247 (if (mm-handle-undisplayer handle)
5248 (mm-remove-part handle)
5249 (mm-display-part handle))))))
5251 (defun gnus-mime-view-part-internally (&optional handle)
5252 "View the MIME part under point with an internal viewer.
5253 If no internal viewer is available, use an external viewer."
5255 (gnus-article-check-buffer)
5256 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5257 (mm-inlined-types '(".*"))
5258 (mm-inline-large-images t)
5259 (mail-parse-charset gnus-newsgroup-charset)
5260 (mail-parse-ignored-charsets
5261 (with-current-buffer gnus-summary-buffer
5262 gnus-newsgroup-ignored-charsets))
5263 (inhibit-read-only t))
5264 (if (not (mm-inlinable-p handle))
5265 (gnus-mime-view-part-as-type
5266 nil (lambda (types) (mm-inlinable-p handle (car types))))
5268 (if (mm-handle-undisplayer handle)
5269 (mm-remove-part handle)
5270 (mm-display-part handle))))))
5272 (defun gnus-mime-action-on-part (&optional action)
5273 "Do something with the MIME attachment at \(point\)."
5275 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
5276 (gnus-article-check-buffer)
5277 (let ((action-pair (assoc action gnus-mime-action-alist)))
5279 (funcall (cdr action-pair)))))
5281 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5282 "Call FUNCTION on MIME part N.
5283 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5284 If INTERACTIVE, call FUNCTION interactivly."
5286 ;; Check whether the article is displayed.
5287 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5288 (setq window (get-buffer-window gnus-article-buffer t))
5289 (frame-visible-p (setq frame (window-frame window))))
5290 (error "No article is displayed"))
5291 (with-current-buffer gnus-article-buffer
5292 ;; Check whether the article displays the right contents.
5293 (unless (with-current-buffer gnus-summary-buffer
5294 (eq gnus-current-article (gnus-summary-article-number)))
5295 (error "You should select the right article first"))
5297 (setq n (prefix-numeric-value n))
5299 (setq n (or (get-text-property pt 'gnus-part)
5301 (get-text-property (1- pt) 'gnus-part))
5302 (get-text-property (prog2
5308 (or (and (setq pt (previous-single-property-change
5311 (next-single-property-change (point) 'gnus-part)
5315 ;; Check whether the specified part exists.
5316 (when (> n (length gnus-article-mime-handle-alist))
5317 (error "No such part")))
5320 ;; To select the window is needed so that the cursor
5321 ;; might be visible on the MIME button.
5322 (select-window (prog1
5324 (setq window (selected-window))
5325 ;; Article may be displayed in the other frame.
5326 (gnus-select-frame-set-input-focus
5329 (setq frame (selected-frame))))))
5330 (when (gnus-article-goto-part n)
5331 ;; We point the cursor and the arrow at the MIME button
5332 ;; when the `function' prompt the user for something.
5333 (let ((cursor-in-non-selected-windows t)
5334 (overlay-arrow-string "=>")
5335 (overlay-arrow-position (point-marker)))
5338 ((and no-handle interactive)
5339 (call-interactively function))
5345 (cdr (assq n gnus-article-mime-handle-alist))))
5348 (cdr (assq n gnus-article-mime-handle-alist)))))
5349 (set-marker overlay-arrow-position nil)
5350 (unless gnus-auto-select-part
5351 (gnus-select-frame-set-input-focus frame)
5352 (select-window window))))
5354 (if gnus-inhibit-mime-unbuttonizing
5355 ;; This is the default though the program shouldn't reach here.
5356 (error "No such part")
5357 ;; The part which doesn't have the MIME button is selected.
5358 ;; So, we display all the buttons and redo it.
5359 (let ((gnus-inhibit-mime-unbuttonizing t))
5360 (gnus-summary-show-article)
5361 (gnus-article-part-wrapper n function no-handle))))))
5363 (defun gnus-article-pipe-part (n)
5364 "Pipe MIME part N, which is the numerical prefix."
5366 (gnus-article-part-wrapper n 'mm-pipe-part))
5368 (defun gnus-article-save-part (n)
5369 "Save MIME part N, which is the numerical prefix."
5371 (gnus-article-part-wrapper n 'mm-save-part))
5373 (defun gnus-article-interactively-view-part (n)
5374 "View MIME part N interactively, which is the numerical prefix."
5376 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5378 (defun gnus-article-copy-part (n)
5379 "Copy MIME part N, which is the numerical prefix."
5381 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5383 (defun gnus-article-view-part-as-charset (n)
5384 "View MIME part N using a specified charset.
5385 N is the numerical prefix."
5387 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5389 (defun gnus-article-view-part-externally (n)
5390 "View MIME part N externally, which is the numerical prefix."
5392 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5394 (defun gnus-article-inline-part (n)
5395 "Inline MIME part N, which is the numerical prefix."
5397 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5399 (defun gnus-article-save-part-and-strip (n)
5400 "Save MIME part N and replace it with an external body.
5401 N is the numerical prefix."
5403 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5405 (defun gnus-article-replace-part (n)
5406 "Replace MIME part N with an external body.
5407 N is the numerical prefix."
5409 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5411 (defun gnus-article-delete-part (n)
5412 "Delete MIME part N and add some information about the removed part.
5413 N is the numerical prefix."
5415 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5417 (defun gnus-article-view-part-as-type (n)
5418 "Choose a MIME media type, and view part N as such.
5419 N is the numerical prefix."
5421 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5423 (defun gnus-article-mime-match-handle-first (condition)
5426 (dolist (ihandle gnus-article-mime-handle-alist)
5428 ((functionp condition)
5429 (funcall condition (cdr ihandle)))
5430 ((eq condition 'undisplayed)
5431 (not (or (mm-handle-undisplayer (cdr ihandle))
5432 (equal (mm-handle-media-type (cdr ihandle))
5433 "multipart/alternative"))))
5434 ((eq condition 'undisplayed-alternative)
5435 (not (mm-handle-undisplayer (cdr ihandle))))
5437 (gnus-article-goto-part (car ihandle))
5438 (or (not n) (< (car ihandle) n)))
5439 (setq n (car ihandle))))
5443 (defun gnus-article-view-part (&optional n)
5444 "View MIME part N, which is the numerical prefix."
5446 (with-current-buffer gnus-article-buffer
5447 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5448 gnus-article-mime-match-handle-function)))
5449 (when (> n (length gnus-article-mime-handle-alist))
5450 (error "No such part"))
5451 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5452 (when (gnus-article-goto-part n)
5453 (if (equal (car handle) "multipart/alternative")
5454 (gnus-article-press-button)
5455 (when (eq (gnus-mm-display-part handle) 'internal)
5456 (gnus-set-window-start)))))))
5458 (defsubst gnus-article-mime-total-parts ()
5459 (if (bufferp (car gnus-article-mime-handles))
5461 (1- (length gnus-article-mime-handles))))
5463 (defun gnus-mm-display-part (handle)
5464 "Display HANDLE and fix MIME button."
5465 (let ((id (get-text-property (point) 'gnus-part))
5467 (inhibit-read-only t))
5470 (let ((window (selected-window))
5471 (mail-parse-charset gnus-newsgroup-charset)
5472 (mail-parse-ignored-charsets
5473 (if (gnus-buffer-live-p gnus-summary-buffer)
5474 (with-current-buffer gnus-summary-buffer
5475 gnus-newsgroup-ignored-charsets)
5479 (let ((win (gnus-get-buffer-window (current-buffer) t))
5482 (select-window win))
5485 (if (mm-handle-displayed-p handle)
5486 ;; This will remove the part.
5487 (mm-display-part handle)
5489 (narrow-to-region (point)
5490 (if (eobp) (point) (1+ (point))))
5491 (mm-display-part handle)
5492 ;; We narrow to the part itself and
5493 ;; then call the treatment functions.
5494 (goto-char (point-min))
5496 (narrow-to-region (point) (point-max))
5499 (gnus-article-mime-total-parts)
5500 (mm-handle-media-type handle)))))
5501 (if (window-live-p window)
5502 (select-window window)))))
5505 (gnus-insert-mime-button
5506 handle id (list (mm-handle-displayed-p handle)))
5507 (goto-char point))))
5509 (defun gnus-article-goto-part (n)
5510 "Go to MIME part N."
5511 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5513 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5514 (let ((gnus-tmp-name
5515 (or (mail-content-type-get (mm-handle-type handle) 'name)
5516 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5517 (mail-content-type-get (mm-handle-type handle) 'url)
5519 (gnus-tmp-type (mm-handle-media-type handle))
5520 (gnus-tmp-description (or (mm-handle-description handle) ""))
5522 (if (if displayed (car displayed)
5523 (mm-handle-displayed-p handle))
5525 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5527 gnus-tmp-type-long b e)
5528 (when (string-match ".*/" gnus-tmp-name)
5529 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5530 (setq gnus-tmp-type-long (concat gnus-tmp-type
5531 (and (not (equal gnus-tmp-name ""))
5532 (concat "; " gnus-tmp-name))))
5533 (unless (equal gnus-tmp-description "")
5534 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5539 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5540 `(keymap ,gnus-mime-button-map
5541 gnus-callback gnus-mm-display-part
5542 gnus-part ,gnus-tmp-id
5543 article-type annotation
5546 ;; Exclude a newline.
5549 (when gnus-article-button-face
5550 (gnus-overlay-put (gnus-make-overlay b e nil t)
5551 'face gnus-article-button-face))
5552 (widget-convert-button
5555 :action 'gnus-widget-press-button
5556 :button-keymap gnus-mime-button-map
5558 (lambda (widget/window &optional overlay pos)
5559 ;; Needed to properly clear the message due to a bug in
5560 ;; wid-edit (XEmacs only).
5561 (if (boundp 'help-echo-owns-message)
5562 (setq help-echo-owns-message t))
5564 "%S: %s the MIME part; %S: more options"
5565 (aref gnus-mouse-2 0)
5566 ;; XEmacs will get a single widget arg; Emacs 21 will get
5567 ;; window, overlay, position.
5568 (if (mm-handle-displayed-p
5570 (with-current-buffer (gnus-overlay-buffer overlay)
5571 (widget-get (widget-at (gnus-overlay-start overlay))
5573 (widget-get widget/window :mime-handle)))
5575 (aref gnus-down-mouse-3 0))))))
5577 (defun gnus-widget-press-button (elems el)
5578 (goto-char (widget-get elems :from))
5579 (gnus-article-press-button))
5581 (defvar gnus-displaying-mime nil)
5583 (defun gnus-display-mime (&optional ihandles)
5584 "Display the MIME parts."
5586 (save-selected-window
5587 (let ((window (get-buffer-window gnus-article-buffer))
5590 (select-window window)
5591 ;; We have to do this since selecting the window
5592 ;; may change the point. So we set the window point.
5593 (set-window-point window point)))
5594 (let ((handles ihandles)
5595 (inhibit-read-only t)
5598 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5599 (when gnus-article-emulate-mime
5600 (mm-uu-dissect-text-parts handles)))
5601 (gnus-article-emulate-mime
5602 (setq handles (mm-uu-dissect))))
5603 (when (and (not ihandles)
5604 (not gnus-displaying-mime))
5605 ;; Top-level call; we clean up.
5606 (when gnus-article-mime-handles
5607 (mm-destroy-parts gnus-article-mime-handles)
5608 (setq gnus-article-mime-handle-alist nil));; A trick.
5609 (setq gnus-article-mime-handles handles)
5610 ;; We allow users to glean info from the handles.
5611 (when gnus-article-mime-part-function
5612 (gnus-mime-part-function handles)))
5614 (or (not (stringp (car handles)))
5617 (when (and (not ihandles)
5618 (not gnus-displaying-mime))
5619 ;; Clean up for mime parts.
5621 (delete-region (point) (point-max)))
5622 (let ((gnus-displaying-mime t))
5623 (gnus-mime-display-part handles)))
5626 (narrow-to-region (point) (point-max))
5627 (gnus-treat-article nil 1 1)
5630 ;; Highlight the headers.
5634 (narrow-to-region (point-min) (point))
5635 (gnus-article-save-original-date
5636 (gnus-treat-article 'head)))))))
5637 ;; Cope with broken MIME messages.
5638 (goto-char (point-max))
5642 (defcustom gnus-mime-display-multipart-as-mixed nil
5643 "Display \"multipart\" parts as \"multipart/mixed\".
5645 If t, it overrides nil values of
5646 `gnus-mime-display-multipart-alternative-as-mixed' and
5647 `gnus-mime-display-multipart-related-as-mixed'."
5648 :group 'gnus-article-mime
5651 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5652 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5654 :group 'gnus-article-mime
5657 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5658 "Display \"multipart/related\" parts as \"multipart/mixed\".
5660 If displaying \"text/html\" is discouraged \(see
5661 `mm-discouraged-alternatives'\) images or other material inside a
5662 \"multipart/related\" part might be overlooked when this variable is nil."
5664 :group 'gnus-article-mime
5667 (defun gnus-mime-display-part (handle)
5669 ;; Maybe a broken MIME message.
5672 ((not (stringp (car handle)))
5673 (gnus-mime-display-single handle))
5674 ;; User-defined multipart
5675 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5676 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5678 ;; multipart/alternative
5679 ((and (equal (car handle) "multipart/alternative")
5680 (not (or gnus-mime-display-multipart-as-mixed
5681 gnus-mime-display-multipart-alternative-as-mixed)))
5682 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5683 (push (cons id handle) gnus-article-mime-handle-alist)
5684 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5685 ;; multipart/related
5686 ((and (equal (car handle) "multipart/related")
5687 (not (or gnus-mime-display-multipart-as-mixed
5688 gnus-mime-display-multipart-related-as-mixed)))
5689 ;;;!!!We should find the start part, but we just default
5690 ;;;!!!to the first part.
5691 ;;(gnus-mime-display-part (cadr handle))
5692 ;;;!!! Most multipart/related is an HTML message plus images.
5693 ;;;!!! Unfortunately we are unable to let W3 display those
5694 ;;;!!! included images, so we just display it as a mixed multipart.
5695 ;;(gnus-mime-display-mixed (cdr handle))
5696 ;;;!!! No, w3 can display everything just fine.
5697 (gnus-mime-display-part (cadr handle)))
5698 ((equal (car handle) "multipart/signed")
5699 (gnus-add-wash-type 'signed)
5700 (gnus-mime-display-security handle))
5701 ((equal (car handle) "multipart/encrypted")
5702 (gnus-add-wash-type 'encrypted)
5703 (gnus-mime-display-security handle))
5704 ;; Other multiparts are handled like multipart/mixed.
5706 (gnus-mime-display-mixed (cdr handle)))))
5708 (defun gnus-mime-part-function (handles)
5709 (if (stringp (car handles))
5710 (mapcar 'gnus-mime-part-function (cdr handles))
5711 (funcall gnus-article-mime-part-function handles)))
5713 (defun gnus-mime-display-mixed (handles)
5714 (mapcar 'gnus-mime-display-part handles))
5716 (defun gnus-mime-display-single (handle)
5717 (let ((type (mm-handle-media-type handle))
5718 (ignored gnus-ignored-mime-types)
5725 (when (string-match (pop ignored) type)
5726 (throw 'ignored nil)))
5727 (if (and (setq not-attachment
5728 (and (not (mm-inline-override-p handle))
5729 (or (not (mm-handle-disposition handle))
5730 (equal (car (mm-handle-disposition handle))
5732 (mm-attachment-override-p handle))))
5733 (mm-automatic-display-p handle)
5735 (mm-inlinable-p handle)
5736 (mm-inlined-p handle))
5737 (mm-automatic-external-display-p type)))
5739 (when (equal (mm-handle-media-supertype handle) "text")
5741 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5743 (push (cons id handle) gnus-article-mime-handle-alist)
5745 (equal (mm-handle-media-supertype handle) "message"))
5748 (cond ((not (bolp)) 2)
5749 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5751 (when (or (not display)
5752 (not (gnus-unbuttonized-mime-type-p type)))
5753 (gnus-insert-mime-button
5754 handle id (list (or display (and not-attachment text))))
5755 (gnus-article-insert-newline)
5756 ;; Remember modify the number of forward lines.
5764 (let ((mail-parse-charset gnus-newsgroup-charset)
5765 (mail-parse-ignored-charsets
5766 (save-excursion (condition-case ()
5767 (set-buffer gnus-summary-buffer)
5769 gnus-newsgroup-ignored-charsets)))
5770 (mm-display-part handle t))
5771 (goto-char (point-max)))
5772 ((and text not-attachment)
5776 (gnus-article-insert-newline)
5779 (let ((charset (or (mail-content-type-get (mm-handle-type handle)
5781 (and (equal type "text/calendar") 'utf-8))))
5782 (cond ((not charset)
5783 (mm-string-as-multibyte (mm-get-part handle)))
5784 ((eq charset 'gnus-decoded)
5785 (with-current-buffer (mm-handle-buffer handle)
5788 (mm-decode-string (mm-get-part handle) charset)))))
5789 (goto-char (point-max))))
5793 (narrow-to-region beg (point))
5794 (if (eq handle gnus-article-mime-handles)
5795 ;; The format=flowed case.
5796 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5797 ;; Don't count signature parts that are never displayed.
5798 ;; The part number should be re-calculated supposing this
5799 ;; might be a message/rfc822 part.
5801 (dolist (part gnus-article-mime-handles)
5802 (unless (or (stringp part)
5803 (equal (car (mm-handle-type part))
5804 "application/pgp-signature"))
5805 (push part handles)))
5807 nil (length (memq handle handles)) (length handles)
5808 (mm-handle-media-type handle)))))))))))
5810 (defun gnus-unbuttonized-mime-type-p (type)
5811 "Say whether TYPE is to be unbuttonized."
5812 (unless gnus-inhibit-mime-unbuttonizing
5814 (let ((types gnus-unbuttonized-mime-types))
5816 (when (string-match (pop types) type)
5817 (throw 'found t)))))
5819 (let ((types gnus-buttonized-mime-types))
5821 (when (string-match (pop types) type)
5822 (throw 'found t)))))))))
5824 (defun gnus-article-insert-newline ()
5825 "Insert a newline, but mark it as undeletable."
5826 (gnus-put-text-property
5827 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5829 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5830 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5833 handle (inhibit-read-only t) from props begend not-pref)
5834 (save-window-excursion
5837 (narrow-to-region (car ibegend)
5840 (goto-char (car ibegend))
5843 (delete-region (point-min) (point-max))
5844 (mm-remove-parts handles))
5845 (setq begend (list (point-marker)))
5847 (unless (setq not-pref (cadr (member preferred ihandles)))
5848 (setq not-pref (car ihandles)))
5851 (not (gnus-unbuttonized-mime-type-p
5852 "multipart/alternative")))
5853 (gnus-add-text-properties
5856 (insert (format "%d. " id))
5860 (unless ,(not ibegend)
5861 (setq gnus-article-mime-handle-alist
5862 ',gnus-article-mime-handle-alist))
5863 (gnus-mime-display-alternative
5864 ',ihandles ',not-pref ',begend ,id))
5865 keymap ,gnus-mime-button-map
5866 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5867 face ,gnus-article-button-face
5869 article-type multipart))
5870 (widget-convert-button 'link from (point)
5871 :action 'gnus-widget-press-button
5872 :button-keymap gnus-widget-button-keymap)
5874 (while (setq handle (pop handles))
5875 (gnus-add-text-properties
5878 (insert (format "(%c) %-18s"
5879 (if (equal handle preferred) ?* ? )
5880 (mm-handle-media-type handle)))
5884 (unless ,(not ibegend)
5885 (setq gnus-article-mime-handle-alist
5886 ',gnus-article-mime-handle-alist))
5887 (gnus-mime-display-alternative
5888 ',ihandles ',handle ',begend ,id))
5889 keymap ,gnus-mime-button-map
5890 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5891 face ,gnus-article-button-face
5894 (widget-convert-button 'link from (point)
5895 :action 'gnus-widget-press-button
5896 :button-keymap gnus-widget-button-keymap)
5900 (if (stringp (car preferred))
5901 (gnus-display-mime preferred)
5902 (let ((mail-parse-charset gnus-newsgroup-charset)
5903 (mail-parse-ignored-charsets
5904 (with-current-buffer gnus-summary-buffer
5905 gnus-newsgroup-ignored-charsets)))
5906 (mm-display-part preferred)
5910 (narrow-to-region (car begend) (point-max))
5912 nil (length gnus-article-mime-handle-alist)
5913 (gnus-article-mime-total-parts)
5914 (mm-handle-media-type handle))))))
5915 (goto-char (point-max))
5916 (setcdr begend (point-marker)))))
5918 (goto-char point))))
5920 (defconst gnus-article-wash-status-strings
5921 (let ((alist '((cite "c" "Possible hidden citation text"
5922 " " "All citation text visible")
5923 (headers "h" "Hidden headers"
5924 " " "All headers visible.")
5925 (pgp "p" "Encrypted or signed message status hidden"
5926 " " "No hidden encryption nor digital signature status")
5927 (signature "s" "Signature has been hidden"
5928 " " "Signature is visible")
5929 (overstrike "o" "Overstrike (^H) characters applied"
5930 " " "No overstrike characters applied")
5931 (emphasis "e" "/*_Emphasis_*/ characters applied"
5932 " " "No /*_emphasis_*/ characters applied")))
5934 (dolist (entry alist result)
5935 (let ((key (nth 0 entry))
5936 (on (copy-sequence (nth 1 entry)))
5937 (on-help (nth 2 entry))
5938 (off (copy-sequence (nth 3 entry)))
5939 (off-help (nth 4 entry)))
5940 (put-text-property 0 1 'help-echo on-help on)
5941 (put-text-property 0 1 'help-echo off-help off)
5942 (push (list key on off) result))))
5943 "Alist of strings describing wash status in the mode line.
5944 Each entry has the form (KEY ON OF), where the KEY is a symbol
5945 representing the particular washing function, ON is the string to use
5946 in the article mode line when the washing function is active, and OFF
5947 is the string to use when it is inactive.")
5949 (defun gnus-article-wash-status-entry (key value)
5950 (let ((entry (assoc key gnus-article-wash-status-strings)))
5951 (if value (nth 1 entry) (nth 2 entry))))
5953 (defun gnus-article-wash-status ()
5954 "Return a string which display status of article washing."
5955 (with-current-buffer gnus-article-buffer
5956 (let ((cite (memq 'cite gnus-article-wash-types))
5957 (headers (memq 'headers gnus-article-wash-types))
5958 (boring (memq 'boring-headers gnus-article-wash-types))
5959 (pgp (memq 'pgp gnus-article-wash-types))
5960 (pem (memq 'pem gnus-article-wash-types))
5961 (signed (memq 'signed gnus-article-wash-types))
5962 (encrypted (memq 'encrypted gnus-article-wash-types))
5963 (signature (memq 'signature gnus-article-wash-types))
5964 (overstrike (memq 'overstrike gnus-article-wash-types))
5965 (emphasis (memq 'emphasis gnus-article-wash-types)))
5967 (gnus-article-wash-status-entry 'cite cite)
5968 (gnus-article-wash-status-entry 'headers (or headers boring))
5969 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5970 (gnus-article-wash-status-entry 'signature signature)
5971 (gnus-article-wash-status-entry 'overstrike overstrike)
5972 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5974 (defun gnus-add-wash-type (type)
5975 "Add a washing of TYPE to the current status."
5976 (add-to-list 'gnus-article-wash-types type))
5978 (defun gnus-delete-wash-type (type)
5979 "Add a washing of TYPE to the current status."
5980 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5982 (defun gnus-add-image (category image)
5983 "Add IMAGE of CATEGORY to the list of displayed images."
5984 (let ((entry (assq category gnus-article-image-alist)))
5986 (setq entry (list category))
5987 (push entry gnus-article-image-alist))
5988 (nconc entry (list image))))
5990 (defun gnus-delete-images (category)
5991 "Delete all images in CATEGORY."
5992 (let ((entry (assq category gnus-article-image-alist)))
5993 (dolist (image (cdr entry))
5994 (gnus-remove-image image category))
5995 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5996 (gnus-delete-wash-type category)))
5998 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6000 (defun gnus-article-maybe-hide-headers ()
6001 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6002 Provided for backwards compatibility."
6003 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6004 (not (with-current-buffer gnus-summary-buffer
6005 gnus-have-all-headers)))
6006 (not gnus-inhibit-hiding))
6007 (gnus-article-hide-headers)))
6011 (defun gnus-output-to-file (file-name)
6012 "Append the current article to a file named FILE-NAME.
6013 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6014 text and used as the value of the coding cookie which is added to the
6015 top of a file. Otherwise, this function saves a raw article without
6017 (let* ((artbuf (current-buffer))
6018 (file-name-coding-system nnmail-pathname-coding-system)
6019 (coding gnus-article-save-coding-system)
6020 (coding-system-for-read (if coding
6021 nil ;; Rely on the coding cookie.
6022 mm-text-coding-system))
6023 (coding-system-for-write (or coding
6024 mm-text-coding-system-for-write
6025 mm-text-coding-system))
6026 (exists (file-exists-p file-name)))
6029 (insert-file-contents file-name)
6030 (goto-char (point-min))
6031 ;; Remove the existing coding cookie.
6032 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6033 (delete-region (match-beginning 0) (match-end 0))))
6034 (goto-char (point-max))
6035 (insert-buffer-substring artbuf)
6036 ;; Append newline at end of the buffer as separator, and then
6038 (goto-char (point-max))
6041 ;; If the coding system is not suitable to encode the text,
6042 ;; ask a user for a proper one.
6043 (when (fboundp 'select-safe-coding-system)
6044 (setq coding (coding-system-base
6045 (save-window-excursion
6046 (select-safe-coding-system (point-min) (point-max)
6048 (setq coding-system-for-write
6049 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6051 (goto-char (point-min))
6052 ;; Add the coding cookie.
6053 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6054 coding-system-for-write)))
6057 (write-region (point-min) (point-max) file-name nil 'no-message)
6058 (message "Appended to %s" file-name))
6059 (write-region (point-min) (point-max) file-name))))
6062 (defun gnus-narrow-to-page (&optional arg)
6063 "Narrow the article buffer to a page.
6064 If given a numerical ARG, move forward ARG pages."
6066 (setq arg (if arg (prefix-numeric-value arg) 0))
6067 (with-current-buffer gnus-article-buffer
6069 ;; Remove any old next/prev buttons.
6070 (when (gnus-visual-p 'page-marker)
6071 (let ((inhibit-read-only t))
6072 (gnus-remove-text-with-property 'gnus-prev)
6073 (gnus-remove-text-with-property 'gnus-next)))
6075 (when (save-excursion
6077 (if (re-search-backward page-delimiter nil 'move (abs arg))
6079 (setq nd (match-beginning 0)
6081 (when (re-search-backward page-delimiter nil t)
6082 (setq st (match-end 0))))
6083 (when (re-search-forward page-delimiter nil t)
6084 (setq nd (match-beginning 0)
6087 (if (re-search-forward page-delimiter nil 'move arg)
6089 (setq st (match-end 0)
6091 (when (re-search-forward page-delimiter nil t)
6092 (setq nd (match-beginning 0))))
6093 (when (re-search-backward page-delimiter nil t)
6094 (setq st (match-end 0)
6097 (when (re-search-backward page-delimiter nil t)
6098 (goto-char (setq st (match-end 0))))
6099 (when (re-search-forward page-delimiter nil t)
6100 (setq nd (match-beginning 0)))
6102 (setq gnus-page-broken t)
6103 (when pt (goto-char pt))
6104 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6105 (when (gnus-visual-p 'page-marker)
6109 (gnus-insert-next-page-button))
6112 (gnus-insert-prev-page-button))))))))
6114 ;; Article mode commands
6116 (defun gnus-article-goto-next-page ()
6117 "Show the next page of the article."
6119 (when (gnus-article-next-page)
6120 (goto-char (point-min))
6121 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6124 (defun gnus-article-goto-prev-page ()
6125 "Show the previous page of the article."
6127 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6128 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6129 (gnus-article-prev-page nil)))
6131 ;; This is cleaner but currently breaks `gnus-pick-mode':
6133 ;; (defun gnus-article-goto-next-page ()
6134 ;; "Show the next page of the article."
6136 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6137 ;; (gnus-summary-next-page)))
6139 ;; (defun gnus-article-goto-prev-page ()
6140 ;; "Show the next page of the article."
6142 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6143 ;; (gnus-summary-prev-page)))
6145 (defun gnus-article-next-page (&optional lines)
6146 "Show the next page of the current article.
6147 If end of article, return non-nil. Otherwise return nil.
6148 Argument LINES specifies lines to be scrolled up."
6150 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6151 (if (and (not (and gnus-article-over-scroll
6152 (> (count-lines (window-start) (point-max))
6153 (if (featurep 'xemacs)
6154 (or lines (1- (window-height)))
6155 (+ (or lines (1- (window-height))) scroll-margin)))))
6158 (and (pos-visible-in-window-p) ;Not continuation line.
6159 (>= (1+ (point)) (point-max))))) ;Allow for trailing newline.
6160 ;; Nothing in this page.
6161 (if (or (not gnus-page-broken)
6166 (eobp)))) ;Real end-of-buffer?
6168 (when gnus-article-over-scroll
6169 (gnus-article-next-page-1 lines))
6171 (gnus-narrow-to-page 1) ;Go to next page.
6173 ;; More in this page.
6174 (gnus-article-next-page-1 lines)
6177 (defmacro gnus-article-beginning-of-window ()
6178 "Move point to the beginning of the window.
6179 In Emacs, the point is placed at the line number which `scroll-margin'
6181 (if (featurep 'xemacs)
6182 '(move-to-window-line 0)
6183 '(move-to-window-line
6184 (min (max 0 scroll-margin)
6185 (max 1 (- (window-height)
6186 (if mode-line-format 1 0)
6187 (if header-line-format 1 0)
6190 (defun gnus-article-next-page-1 (lines)
6191 (unless (featurep 'xemacs)
6192 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
6193 ;; too many number of lines if `scroll-margin' is set as two or greater.
6194 (when (and (numberp lines)
6196 (> scroll-margin 0))
6197 (setq lines (min lines
6198 (max 0 (- (count-lines (window-start) (point-max))
6201 (let ((scroll-in-place nil))
6204 ;; Long lines may cause an end-of-buffer error.
6205 (goto-char (point-max))))
6206 (gnus-article-beginning-of-window))
6208 (defun gnus-article-prev-page (&optional lines)
6209 "Show previous page of current article.
6210 Argument LINES specifies lines to be scrolled down."
6212 (move-to-window-line 0)
6213 (if (and gnus-page-broken
6215 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6217 (gnus-narrow-to-page -1) ;Go to previous page.
6218 (goto-char (point-max))
6219 (recenter (if gnus-article-over-scroll
6221 (max (if (featurep 'xemacs)
6223 (+ lines scroll-margin))
6225 (- (window-height) 2))
6229 (let ((scroll-in-place nil))
6230 (scroll-down lines))
6231 (beginning-of-buffer
6232 (goto-char (point-min))))
6233 (gnus-article-beginning-of-window))))
6235 (defun gnus-article-only-boring-p ()
6236 "Decide whether there is only boring text remaining in the article.
6237 Something \"interesting\" is a word of at least two letters that does
6238 not have a face in `gnus-article-boring-faces'."
6239 (when (and gnus-article-skip-boring
6240 (boundp 'gnus-article-boring-faces)
6241 (symbol-value 'gnus-article-boring-faces))
6243 (let ((inhibit-point-motion-hooks t))
6245 (while (re-search-forward "\\b\\w\\w" nil t)
6247 (when (not (gnus-intersection
6248 (gnus-faces-at (point))
6249 (symbol-value 'gnus-article-boring-faces)))
6250 (throw 'only-boring nil)))
6251 (throw 'only-boring t))))))
6253 (defun gnus-article-refer-article ()
6254 "Read article specified by message-id around point."
6257 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6258 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6259 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6260 (let ((msg-id (concat "<" (match-string 0) ">")))
6261 (set-buffer gnus-summary-buffer)
6262 (gnus-summary-refer-article msg-id))
6263 (error "No references around point"))))
6265 (defun gnus-article-show-summary ()
6266 "Reconfigure windows to show summary buffer."
6268 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6269 (error "There is no summary buffer for this article buffer")
6270 (gnus-article-set-globals)
6271 (gnus-configure-windows 'article)
6272 (gnus-summary-goto-subject gnus-current-article)
6273 (gnus-summary-position-point)))
6275 (defun gnus-article-describe-briefly ()
6276 "Describe article mode commands briefly."
6278 (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")))
6280 (defun gnus-article-summary-command ()
6281 "Execute the last keystroke in the summary buffer."
6283 (let ((obuf (current-buffer))
6284 (owin (current-window-configuration))
6286 (switch-to-buffer gnus-article-current-summary 'norecord)
6287 (setq func (lookup-key (current-local-map) (this-command-keys)))
6288 (call-interactively func)
6290 (set-window-configuration owin)
6291 (set-window-point (get-buffer-window (current-buffer)) (point))))
6293 (defun gnus-article-summary-command-nosave ()
6294 "Execute the last keystroke in the summary buffer."
6297 (pop-to-buffer gnus-article-current-summary)
6298 (setq func (lookup-key (current-local-map) (this-command-keys)))
6299 (call-interactively func)))
6301 (defun gnus-article-check-buffer ()
6302 "Beep if not in an article buffer."
6303 (unless (equal major-mode 'gnus-article-mode)
6304 (error "Command invoked outside of a Gnus article buffer")))
6306 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6307 "Read a summary buffer key sequence and execute it from the article buffer."
6309 (gnus-article-check-buffer)
6311 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6312 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6313 "=" "^" "\M-^" "|"))
6315 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6316 "An" "Ap" [?A (meta return)] [?A delete]))
6320 '("n" "Gn" "p" "Gp"))
6322 (with-current-buffer gnus-article-current-summary
6323 (let (gnus-pick-mode)
6324 (setq unread-command-events (nconc unread-command-events
6325 (list (or key last-command-event)))
6326 keys (if (featurep 'xemacs)
6327 (events-to-keys (read-key-sequence nil t))
6328 (read-key-sequence nil t)))))
6333 ((eq (aref keys (1- (length keys))) ?\C-h)
6334 (gnus-article-describe-bindings (substring keys 0 -1)))
6335 ((or (member keys nosaves)
6336 (member keys nosave-but-article)
6337 (member keys nosave-in-article))
6339 (save-window-excursion
6340 (pop-to-buffer gnus-article-current-summary)
6341 ;; We disable the pick minor mode commands.
6342 (let (gnus-pick-mode)
6343 (setq func (lookup-key (current-local-map) keys))))
6347 (unless (member keys nosave-in-article)
6348 (set-buffer gnus-article-current-summary))
6349 (call-interactively func)
6350 (setq new-sum-point (point)))
6351 (when (member keys nosave-but-article)
6352 (pop-to-buffer gnus-article-buffer))))
6354 ;; These commands should restore window configuration.
6355 (let ((obuf (current-buffer))
6356 (owin (current-window-configuration))
6357 win func in-buffer selected new-sum-start new-sum-hscroll err)
6358 (cond (not-restore-window
6359 (pop-to-buffer gnus-article-current-summary)
6360 (setq win (selected-window)))
6361 ((setq win (get-buffer-window gnus-article-current-summary))
6362 (select-window win))
6364 (let ((summary-buffer gnus-article-current-summary))
6365 (gnus-configure-windows 'article)
6366 (unless (setq win (get-buffer-window summary-buffer 'visible))
6367 (let ((gnus-buffer-configuration
6368 '(article ((vertical 1.0
6369 (summary 0.25 point)
6371 (gnus-configure-windows 'article))
6372 (setq win (get-buffer-window summary-buffer 'visible)))
6373 (gnus-select-frame-set-input-focus (window-frame win))
6374 (select-window win))))
6375 (setq in-buffer (current-buffer))
6376 ;; We disable the pick minor mode commands.
6377 (if (and (setq func (let (gnus-pick-mode)
6378 (lookup-key (current-local-map) keys)))
6380 (condition-case code
6382 (call-interactively func)
6388 (when (eq win (selected-window))
6389 (setq new-sum-point (point)
6390 new-sum-start (window-start win)
6391 new-sum-hscroll (window-hscroll win)))
6392 (when (or (eq in-buffer (current-buffer))
6393 (when (eq obuf (current-buffer))
6394 (set-buffer in-buffer)
6396 (setq selected (gnus-summary-select-article))
6398 (unless not-restore-window
6399 (set-window-configuration owin))
6400 (when (and (eq selected 'old)
6402 (set-window-start (get-buffer-window (current-buffer))
6404 (set-window-point (get-buffer-window (current-buffer))
6405 (if (article-goto-body)
6408 (when (and (not not-restore-window)
6411 (with-current-buffer (window-buffer win)
6412 (eq major-mode 'gnus-summary-mode)))
6413 (set-window-point win new-sum-point)
6414 (set-window-start win new-sum-start)
6415 (set-window-hscroll win new-sum-hscroll))))
6416 (set-window-configuration owin)
6418 (signal (car err) (cdr err))
6421 (defun gnus-article-read-summary-send-keys ()
6423 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6424 (gnus-article-read-summary-keys)))
6426 (defun gnus-article-describe-key (key)
6427 "Display documentation of the function invoked by KEY.
6428 KEY is a string or a vector."
6429 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6430 (read-key-sequence "Describe key: "))))
6431 (gnus-article-check-buffer)
6432 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6433 gnus-article-read-summary-send-keys))
6434 (with-current-buffer gnus-article-current-summary
6435 (setq unread-command-events
6436 (if (featurep 'xemacs)
6438 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6439 (list 'meta (- x 128))
6442 (let ((cursor-in-echo-area t)
6444 (describe-key (read-key-sequence nil t))))
6445 (describe-key key)))
6447 (defun gnus-article-describe-key-briefly (key &optional insert)
6448 "Display documentation of the function invoked by KEY.
6449 KEY is a string or a vector."
6450 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6451 (read-key-sequence "Describe key: "))
6452 current-prefix-arg))
6453 (gnus-article-check-buffer)
6454 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6455 gnus-article-read-summary-send-keys))
6456 (with-current-buffer gnus-article-current-summary
6457 (setq unread-command-events
6458 (if (featurep 'xemacs)
6460 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6461 (list 'meta (- x 128))
6464 (let ((cursor-in-echo-area t)
6466 (describe-key-briefly (read-key-sequence nil t) insert)))
6467 (describe-key-briefly key insert)))
6469 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6470 (defvar gnus-agent-summary-mode)
6471 (defvar gnus-draft-mode)
6473 (defun gnus-article-describe-bindings (&optional prefix)
6474 "Show a list of all defined keys, and their definitions.
6475 The optional argument PREFIX, if non-nil, should be a key sequence;
6476 then we display only bindings that start with that prefix."
6478 (gnus-article-check-buffer)
6479 (let ((keymap (copy-keymap gnus-article-mode-map))
6480 (map (copy-keymap gnus-article-send-map))
6481 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6483 (define-key keymap "S" map)
6484 (define-key map [t] nil)
6485 (with-current-buffer gnus-article-current-summary
6486 (set-keymap-parent map (key-binding "S"))
6487 (let (key def gnus-pick-mode)
6489 (setq key (pop sumkeys))
6490 (cond ((and (vectorp key) (= (length key) 1)
6491 (consp (setq def (aref key 0)))
6492 (numberp (car def)) (numberp (cdr def)))
6493 (when (< (max (car def) (cdr def)) 128)
6497 (nreverse (gnus-uncompress-range def)))
6499 ((setq def (key-binding key))
6500 (unless (eq def 'undefined)
6501 (define-key keymap key def))))))
6502 (when (boundp 'gnus-agent-summary-mode)
6503 (setq agent gnus-agent-summary-mode))
6504 (when (boundp 'gnus-draft-mode)
6505 (setq draft gnus-draft-mode)))
6507 (use-local-map keymap)
6508 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6509 (set (make-local-variable 'gnus-draft-mode) draft)
6510 (describe-bindings prefix))
6511 (let ((item `((lambda (prefix)
6512 (with-current-buffer ,(current-buffer)
6513 (gnus-article-describe-bindings prefix)))
6515 (with-current-buffer (if (fboundp 'help-buffer)
6516 (let (help-xref-following) (help-buffer))
6517 "*Help*") ;; Emacs 21
6518 (setq help-xref-stack-item item)))))
6520 (defun gnus-article-reply-with-original (&optional wide)
6521 "Start composing a reply mail to the current message.
6522 The text in the region will be yanked. If the region isn't active,
6523 the entire article will be yanked."
6525 (let ((article (cdr gnus-article-current))
6527 (if (not (gnus-region-active-p))
6528 (with-current-buffer gnus-summary-buffer
6529 (gnus-summary-reply (list (list article)) wide))
6530 (setq contents (buffer-substring (point) (mark t)))
6531 ;; Deactivate active regions.
6532 (when (and (boundp 'transient-mark-mode)
6533 transient-mark-mode)
6534 (setq mark-active nil))
6535 (with-current-buffer gnus-summary-buffer
6537 (list (list article contents)) wide)))))
6539 (defun gnus-article-wide-reply-with-original ()
6540 "Start composing a wide reply mail to the current message.
6541 The text in the region will be yanked. If the region isn't active,
6542 the entire article will be yanked."
6544 (gnus-article-reply-with-original t))
6546 (defun gnus-article-followup-with-original ()
6547 "Compose a followup to the current article.
6548 The text in the region will be yanked. If the region isn't active,
6549 the entire article will be yanked."
6551 (let ((article (cdr gnus-article-current))
6553 (if (not (gnus-region-active-p))
6554 (with-current-buffer gnus-summary-buffer
6555 (gnus-summary-followup (list (list article))))
6556 (setq contents (buffer-substring (point) (mark t)))
6557 ;; Deactivate active regions.
6558 (when (and (boundp 'transient-mark-mode)
6559 transient-mark-mode)
6560 (setq mark-active nil))
6561 (with-current-buffer gnus-summary-buffer
6562 (gnus-summary-followup
6563 (list (list article contents)))))))
6565 (defun gnus-article-hide (&optional arg force)
6566 "Hide all the gruft in the current article.
6567 This means that signatures, cited text and (some) headers will be
6569 If given a prefix, show the hidden text instead."
6570 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6571 (gnus-article-hide-headers arg)
6572 (gnus-article-hide-list-identifiers arg)
6573 (gnus-article-hide-citation-maybe arg force)
6574 (gnus-article-hide-signature arg))
6576 (defun gnus-article-maybe-highlight ()
6577 "Do some article highlighting if article highlighting is requested."
6578 (when (gnus-visual-p 'article-highlight 'highlight)
6579 (gnus-article-highlight-some)))
6581 (defun gnus-check-group-server ()
6582 ;; Make sure the connection to the server is alive.
6583 (unless (gnus-server-opened
6584 (gnus-find-method-for-group gnus-newsgroup-name))
6585 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6586 (gnus-request-group gnus-newsgroup-name t)))
6589 (autoload 'nneething-get-file-name "nneething"))
6591 (defun gnus-request-article-this-buffer (article group)
6592 "Get an article and insert it into this buffer."
6593 (let (do-update-line sparse-header)
6597 (gnus-kill-all-overlays)
6598 (setq group (or group gnus-newsgroup-name))
6600 ;; Using `gnus-request-article' directly will insert the article into
6601 ;; `nntp-server-buffer' - so we'll save some time by not having to
6602 ;; copy it from the server buffer into the article buffer.
6604 ;; We only request an article by message-id when we do not have the
6605 ;; headers for it, so we'll have to get those.
6606 (when (stringp article)
6607 (gnus-read-header article))
6609 ;; If the article number is negative, that means that this article
6610 ;; doesn't belong in this newsgroup (possibly), so we find its
6611 ;; message-id and request it by id instead of number.
6612 (when (and (numberp article)
6614 (get-buffer gnus-summary-buffer)
6615 (gnus-buffer-exists-p gnus-summary-buffer))
6616 (with-current-buffer gnus-summary-buffer
6617 (let ((header (gnus-summary-article-header article)))
6620 ((memq article gnus-newsgroup-sparse)
6621 ;; This is a sparse gap article.
6622 (setq do-update-line article)
6623 (setq article (mail-header-id header))
6624 (setq sparse-header (gnus-read-header article))
6625 (setq gnus-newsgroup-sparse
6626 (delq article gnus-newsgroup-sparse)))
6628 ;; It's a real article.
6629 (setq article (mail-header-id header)))
6631 ;; It is an extracted pseudo-article.
6632 (setq article 'pseudo)
6633 (gnus-request-pseudo-article header))))
6635 (let ((method (gnus-find-method-for-group
6636 gnus-newsgroup-name)))
6637 (when (and (eq (car method) 'nneething)
6639 (let ((dir (nneething-get-file-name
6640 (mail-header-id header))))
6641 (when (and (stringp dir)
6642 (file-directory-p dir))
6643 (setq article 'nneething)
6644 (gnus-group-enter-directory dir))))))))
6647 ;; Refuse to select canceled articles.
6648 ((and (numberp article)
6650 (get-buffer gnus-summary-buffer)
6651 (gnus-buffer-exists-p gnus-summary-buffer)
6652 (eq (cdr (with-current-buffer gnus-summary-buffer
6653 (assq article gnus-newsgroup-reads)))
6654 gnus-canceled-mark))
6656 ;; We first check `gnus-original-article-buffer'.
6657 ((and (get-buffer gnus-original-article-buffer)
6659 (with-current-buffer gnus-original-article-buffer
6660 (and (equal (car gnus-original-article) group)
6661 (eq (cdr gnus-original-article) article))))
6662 ;; `insert-buffer-substring' would incorrectly use the
6663 ;; equivalent of string-make-multibyte which amount to decoding
6664 ;; with locale-coding-system, causing failure of
6665 ;; subsequent decoding.
6666 (insert (mm-string-to-multibyte
6667 (with-current-buffer gnus-original-article-buffer
6668 (buffer-substring (point-min) (point-max)))))
6670 ;; Check the backlog.
6671 ((and gnus-keep-backlog
6672 (gnus-backlog-request-article group article (current-buffer)))
6674 ;; Check asynchronous pre-fetch.
6675 ((gnus-async-request-fetched-article group article (current-buffer))
6676 (gnus-async-prefetch-next group article gnus-summary-buffer)
6677 (when (and (numberp article) gnus-keep-backlog)
6678 (gnus-backlog-enter-article group article (current-buffer)))
6681 ((and gnus-use-cache
6683 (gnus-cache-request-article article group))
6685 ;; Check the agent cache.
6686 ((gnus-agent-request-article article group)
6688 ;; Get the article and put into the article buffer.
6689 ((or (stringp article)
6691 (let ((gnus-override-method gnus-override-method)
6692 (methods (and (stringp article)
6693 gnus-refer-article-method))
6694 (backend (car (gnus-find-method-for-group
6695 gnus-newsgroup-name)))
6697 (inhibit-read-only t))
6698 (if (or (not (listp methods))
6699 (and (symbolp (car methods))
6700 (assq (car methods) nnoo-definition-alist)))
6701 (setq methods (list methods)))
6702 (when (and (null gnus-override-method)
6704 (setq gnus-override-method (pop methods)))
6706 (when (eq gnus-override-method 'current)
6707 (setq gnus-override-method
6708 (with-current-buffer gnus-summary-buffer
6709 gnus-current-select-method)))
6711 (gnus-kill-all-overlays)
6712 (let ((gnus-newsgroup-name group))
6713 (gnus-check-group-server))
6715 ((gnus-request-article article group (current-buffer))
6716 (when (numberp article)
6717 (gnus-async-prefetch-next group article
6718 gnus-summary-buffer)
6719 (when gnus-keep-backlog
6720 (gnus-backlog-enter-article
6721 group article (current-buffer))))
6722 (setq result 'article))
6724 (setq gnus-override-method (pop methods)))
6725 ((not (string-match "^400 "
6726 (nnheader-get-report backend)))
6727 ;; If we get 400 server disconnect, reconnect and
6728 ;; retry; otherwise, assume the article has expired.
6729 (setq result 'done))))
6730 (and (eq result 'article) 'article)))
6734 ;; Associate this article with the current summary buffer.
6735 (setq gnus-article-current-summary gnus-summary-buffer)
6737 ;; Take the article from the original article buffer
6738 ;; and place it in the buffer it's supposed to be in.
6739 (when (and (get-buffer gnus-article-buffer)
6740 (equal (buffer-name (current-buffer))
6741 (buffer-name (get-buffer gnus-article-buffer))))
6743 (if (get-buffer gnus-original-article-buffer)
6744 (set-buffer gnus-original-article-buffer)
6745 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6746 (buffer-disable-undo)
6747 (setq major-mode 'gnus-original-article-mode)
6748 (setq buffer-read-only t))
6749 (let ((inhibit-read-only t))
6751 (insert-buffer-substring gnus-article-buffer))
6752 (setq gnus-original-article (cons group article)))
6755 (run-hooks 'gnus-article-decode-hook)
6756 ;; Mark article as decoded or not.
6757 (setq gnus-article-decoded-p gnus-article-decode-hook))
6759 ;; Update sparse articles.
6760 (when (and do-update-line
6761 (or (numberp article)
6763 (let ((buf (current-buffer)))
6764 (set-buffer gnus-summary-buffer)
6765 (gnus-summary-update-article do-update-line sparse-header)
6766 (gnus-summary-goto-subject do-update-line nil t)
6767 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6769 (set-buffer buf))))))
6775 (defcustom gnus-article-edit-mode-hook nil
6776 "Hook run in article edit mode buffers."
6777 :group 'gnus-article-various
6780 (defvar gnus-article-edit-done-function nil)
6782 (defvar gnus-article-edit-mode-map nil)
6784 ;; Should we be using derived.el for this?
6785 (unless gnus-article-edit-mode-map
6786 (setq gnus-article-edit-mode-map (make-keymap))
6787 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6789 (gnus-define-keys gnus-article-edit-mode-map
6790 "\C-c?" describe-mode
6791 "\C-c\C-c" gnus-article-edit-done
6792 "\C-c\C-k" gnus-article-edit-exit
6793 "\C-c\C-f\C-t" message-goto-to
6794 "\C-c\C-f\C-o" message-goto-from
6795 "\C-c\C-f\C-b" message-goto-bcc
6796 ;;"\C-c\C-f\C-w" message-goto-fcc
6797 "\C-c\C-f\C-c" message-goto-cc
6798 "\C-c\C-f\C-s" message-goto-subject
6799 "\C-c\C-f\C-r" message-goto-reply-to
6800 "\C-c\C-f\C-n" message-goto-newsgroups
6801 "\C-c\C-f\C-d" message-goto-distribution
6802 "\C-c\C-f\C-f" message-goto-followup-to
6803 "\C-c\C-f\C-m" message-goto-mail-followup-to
6804 "\C-c\C-f\C-k" message-goto-keywords
6805 "\C-c\C-f\C-u" message-goto-summary
6806 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6807 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6808 "\C-c\C-b" message-goto-body
6809 "\C-c\C-i" message-goto-signature
6811 "\C-c\C-t" message-insert-to
6812 "\C-c\C-n" message-insert-newsgroups
6813 "\C-c\C-o" message-sort-headers
6814 "\C-c\C-e" message-elide-region
6815 "\C-c\C-v" message-delete-not-region
6816 "\C-c\C-z" message-kill-to-signature
6817 "\M-\r" message-newline-and-reformat
6818 "\C-c\C-a" mml-attach-file
6819 "\C-a" message-beginning-of-line
6821 "\M-;" comment-region)
6823 (gnus-define-keys (gnus-article-edit-wash-map
6824 "\C-c\C-w" gnus-article-edit-mode-map)
6825 "f" gnus-article-edit-full-stops))
6828 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6830 ["Fetch To" message-insert-to t]
6831 ["Fetch Newsgroups" message-insert-newsgroups t]
6833 ["To" message-goto-to t]
6834 ["From" message-goto-from t]
6835 ["Subject" message-goto-subject t]
6836 ["Cc" message-goto-cc t]
6837 ["Reply-To" message-goto-reply-to t]
6838 ["Summary" message-goto-summary t]
6839 ["Keywords" message-goto-keywords t]
6840 ["Newsgroups" message-goto-newsgroups t]
6841 ["Followup-To" message-goto-followup-to t]
6842 ["Mail-Followup-To" message-goto-mail-followup-to t]
6843 ["Distribution" message-goto-distribution t]
6844 ["Body" message-goto-body t]
6845 ["Signature" message-goto-signature t]))
6847 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6848 "Major mode for editing articles.
6849 This is an extended text-mode.
6851 \\{gnus-article-edit-mode-map}"
6852 (make-local-variable 'gnus-article-edit-done-function)
6853 (make-local-variable 'gnus-prev-winconf)
6854 (set (make-local-variable 'font-lock-defaults)
6855 '(message-font-lock-keywords t))
6856 (set (make-local-variable 'mail-header-separator) "")
6857 (set (make-local-variable 'gnus-article-edit-mode) t)
6858 (easy-menu-add message-mode-field-menu message-mode-map)
6860 (setq buffer-read-only nil)
6861 (buffer-enable-undo)
6864 (defun gnus-article-edit (&optional force)
6865 "Edit the current article.
6866 This will have permanent effect only in mail groups.
6867 If FORCE is non-nil, allow editing of articles even in read-only
6870 (when (and (not force)
6871 (gnus-group-read-only-p))
6872 (error "The current newsgroup does not support article editing"))
6873 (gnus-article-date-original)
6874 (gnus-article-edit-article
6876 `(lambda (no-highlight)
6878 (gnus-summary-edit-article-done
6879 ,(or (mail-header-references gnus-current-headers) "")
6880 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6882 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6883 "Start editing the contents of the current article buffer."
6884 (let ((winconf (current-window-configuration)))
6885 (set-buffer gnus-article-buffer)
6886 (let ((message-auto-save-directory
6887 ;; Don't associate the article buffer with a draft file.
6889 (gnus-article-edit-mode))
6890 (funcall start-func)
6891 (set-buffer-modified-p nil)
6892 (gnus-configure-windows 'edit-article)
6893 (setq gnus-article-edit-done-function exit-func)
6894 (setq gnus-prev-winconf winconf)
6896 (gnus-message 6 "C-c C-c to end edits"))))
6898 (defun gnus-article-edit-done (&optional arg)
6899 "Update the article edits and exit."
6901 (let ((func gnus-article-edit-done-function)
6902 (buf (current-buffer))
6903 (start (window-start))
6905 (winconf gnus-prev-winconf))
6906 (widen) ;; Widen it in case that users narrowed the buffer.
6909 ;; The cache and backlog have to be flushed somewhat.
6910 (when gnus-keep-backlog
6911 (gnus-backlog-remove-article
6912 (car gnus-article-current) (cdr gnus-article-current)))
6913 ;; Flush original article as well.
6914 (when (get-buffer gnus-original-article-buffer)
6915 (with-current-buffer gnus-original-article-buffer
6916 (setq gnus-original-article nil)))
6917 (when gnus-use-cache
6918 (gnus-cache-update-article
6919 (car gnus-article-current) (cdr gnus-article-current)))
6920 ;; We remove all text props from the article buffer.
6921 (kill-all-local-variables)
6922 (set-text-properties (point-min) (point-max) nil)
6924 (set-window-configuration winconf)
6926 (set-window-start (get-buffer-window buf) start)
6927 (set-window-point (get-buffer-window buf) (point)))
6928 (gnus-summary-show-article))
6930 (defun gnus-article-edit-exit ()
6931 "Exit the article editing without updating."
6933 (when (or (not (buffer-modified-p))
6934 (yes-or-no-p "Article modified; kill anyway? "))
6935 (let ((curbuf (current-buffer))
6937 (window-start (window-start)))
6939 (if (gnus-buffer-live-p gnus-original-article-buffer)
6940 (insert-buffer-substring gnus-original-article-buffer))
6941 (let ((winconf gnus-prev-winconf))
6942 (kill-all-local-variables)
6944 (set-window-configuration winconf)
6945 ;; Tippy-toe some to make sure that point remains where it was.
6946 (save-current-buffer
6948 (set-window-start (get-buffer-window (current-buffer)) window-start)
6950 (gnus-summary-show-article)))
6952 (defun gnus-article-edit-full-stops ()
6953 "Interactively repair spacing at end of sentences."
6956 (goto-char (point-min))
6957 (search-forward-regexp "^$" nil t)
6958 (let ((case-fold-search nil))
6959 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6962 ;;; Article highlights
6965 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6967 ;;; Internal Variables:
6969 (defcustom gnus-button-url-regexp
6971 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
6972 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
6973 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
6974 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
6975 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
6979 ;; Match paired parentheses, e.g. in Wikipedia URLs:
6980 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
6981 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
6983 "[" chars punct "]+" "[" chars "]"
6985 (concat ;; XEmacs 21.4 doesn't support POSIX.
6986 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
6987 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
6989 "Regular expression that matches URLs."
6990 :group 'gnus-article-buttons
6993 (defcustom gnus-button-valid-fqdn-regexp
6994 message-valid-fqdn-regexp
6995 "Regular expression that matches a valid FQDN."
6997 :group 'gnus-article-buttons
7000 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7001 (defcustom gnus-button-valid-localpart-regexp
7002 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7003 "Regular expression that matches a localpart of mail addresses or MIDs."
7005 :group 'gnus-article-buttons
7008 (defcustom gnus-button-man-handler 'manual-entry
7009 "Function to use for displaying man pages.
7010 The function must take at least one argument with a string naming the
7013 :type '(choice (function-item :tag "Man" manual-entry)
7014 (function-item :tag "Woman" woman)
7015 (function :tag "Other"))
7016 :group 'gnus-article-buttons)
7018 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
7019 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
7020 If the default site is too slow, try to find a CTAN mirror, see
7021 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
7022 the variable `gnus-button-handle-ctan'."
7024 :group 'gnus-article-buttons
7025 :link '(custom-manual "(gnus)Group Parameters")
7026 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
7027 (const "http://tug.ctan.org/tex-archive/")
7028 (const "http://www.dante.de/CTAN/")
7029 (string :tag "Other")))
7031 (defcustom gnus-button-ctan-handler 'browse-url
7032 "Function to use for displaying CTAN links.
7033 The function must take one argument, the string naming the URL."
7035 :type '(choice (function-item :tag "Browse Url" browse-url)
7036 (function :tag "Other"))
7037 :group 'gnus-article-buttons)
7039 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
7040 "Bogus strings removed from CTAN URLs."
7042 :group 'gnus-article-buttons
7043 :type '(choice (const "^/?tex-archive/\\|/")
7044 (regexp :tag "Other")))
7046 (defcustom gnus-button-ctan-directory-regexp
7048 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
7049 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
7050 "languages" "macros" "nonfree" "obsolete" "support" "systems"
7051 "tds" "tools" "usergrps" "web") t)
7052 "Regular expression for ctan directories.
7053 It should match all directories in the top level of `gnus-ctan-url'."
7055 :group 'gnus-article-buttons
7058 (defcustom gnus-button-mid-or-mail-regexp
7059 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7060 gnus-button-valid-fqdn-regexp
7062 "Regular expression that matches a message ID or a mail address."
7064 :group 'gnus-article-buttons
7067 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7068 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7069 Strings like this can be either a message ID or a mail address. If it is one
7070 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7071 message ID or a mail address, respectively. If this variable is set to the
7072 symbol `ask', always query the user what do do. If it is a function, this
7073 function will be called with the string as its only argument. The function
7074 must return `mid', `mail', `invalid' or `ask'."
7076 :group 'gnus-article-buttons
7077 :type '(choice (function-item :tag "Heuristic function"
7078 gnus-button-mid-or-mail-heuristic)
7083 (defcustom gnus-button-mid-or-mail-heuristic-alist
7084 '((-10.0 . ".+\\$.+@")
7087 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7088 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7089 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7090 (-1.0 . "^[^a-z]+@")
7092 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7093 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7094 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7095 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7098 (-1.0 . "^[0-9][0-9]")
7100 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7101 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7102 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7103 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7105 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7106 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7109 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7111 ;; compensation for TDMA dated mail addresses:
7112 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7114 (-20.0 . "\\.fsf@") ;; Gnus
7117 (-20.0 . "^alpine\\.")
7118 (-20.0 . "_-_") ;; Subject change in thread
7120 (-20.0 . "\\.ln@") ;; leafnode
7121 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7122 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7124 ;; (5.0 . "") ;; $local_part_len <= 7
7125 (10.0 . "^[^0-9]+@")
7126 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7127 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7130 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7132 (0.5 . "^[A-Z][a-z]")
7133 (0.5 . "^[A-Z][a-z][a-z]")
7134 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7135 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7136 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7138 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7139 address. The REGEXP is processed with `case-fold-search' set to nil."
7141 :group 'gnus-article-buttons
7142 :type '(repeat (cons (number :tag "Rate")
7143 (regexp :tag "Regexp"))))
7145 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7146 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7147 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7148 address, `ask' if unsure and `invalid' if the string is invalid."
7149 (let ((case-fold-search nil)
7150 (list gnus-button-mid-or-mail-heuristic-alist)
7151 (result 0) rate regexp lpartlen elem)
7153 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7154 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7155 ;; Certain special cases...
7158 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7159 "^[0-9]+\\.[0-9]+@compuserve\\|"
7160 "@public\\.gmane\\.org")
7162 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7163 (setq result 'mail))
7164 (when (string-match "@.*@\\| " mid-or-mail)
7165 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7166 (setq result 'invalid))
7167 ;; Nothing more to do, if result is not a number here...
7168 (when (numberp result)
7170 (setq elem (car list)
7174 (when (string-match regexp mid-or-mail)
7175 (setq result (+ result rate))
7177 9 "`%s' matched `%s', rate `%s', result `%s'."
7178 mid-or-mail regexp rate result)))
7179 (when (<= lpartlen 7)
7180 (setq result (+ result 5.0))
7181 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7182 mid-or-mail result))
7183 (when (>= lpartlen 12)
7184 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7186 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7187 ;; Long local part should contain realname if e-mail address,
7188 ;; too many digits: message-id.
7189 ;; $score -= 5.0 + 0.1 * $local_part_len;
7190 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7191 (setq result (+ result rate))
7193 9 "Many digits in `%s', rate `%s', result `%s'."
7194 mid-or-mail rate result))
7195 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7197 ;; Too few vowels [^aeiouy]{4,}.*\@
7198 (setq result (+ result -5.0))
7200 9 "Few vowels in `%s', rate `%s', result `%s'."
7201 mid-or-mail -5.0 result))
7203 (setq result (+ result 5.0))
7205 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7206 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7207 ;; Maybe we should make this a customizable alist: (condition . 'result)
7209 ((symbolp result) result)
7210 ;; Now convert number into proper results:
7211 ((< result -10.0) 'mid)
7212 ((> result 10.0) 'mail)
7215 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7216 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7217 (url-mid (concat "news" ":" mid-or-mail))
7218 (url-mailto (concat "mailto" ":" mid-or-mail)))
7219 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7220 (when (fboundp pref)
7222 ;; get rid of surrounding angles...
7224 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7225 (if (or (eq 'mid guessed) (eq 'mail guessed))
7229 (save-window-excursion
7230 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7233 (cond ((eq pref 'mid)
7234 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7235 (gnus-button-handle-news url-mid))
7237 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7238 (gnus-url-mailto url-mailto))
7239 (t (gnus-message 3 "Invalid string.")))))
7241 (defun gnus-button-handle-custom (fun arg)
7242 "Call function FUN on argument ARG.
7243 Both FUN and ARG are supposed to be strings. ARG will be passed
7244 as a symbol to FUN."
7245 (funcall (intern fun)
7246 (if (string-match "^customize-apropos" fun)
7250 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7252 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7255 (defun gnus-button-handle-describe-function (url)
7256 "Call `describe-function' when pushing the corresponding URL button."
7259 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7261 (defun gnus-button-handle-describe-variable (url)
7262 "Call `describe-variable' when pushing the corresponding URL button."
7265 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7267 (defun gnus-button-handle-symbol (url)
7268 "Display help on variable or function.
7269 Calls `describe-variable' or `describe-function'."
7270 (let ((sym (intern url)))
7272 ((fboundp sym) (describe-function sym))
7273 ((boundp sym) (describe-variable sym))
7274 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7276 (defun gnus-button-handle-describe-key (url)
7277 "Call `describe-key' when pushing the corresponding URL button."
7279 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7280 (keys (ignore-errors (eval `(kbd ,key-string)))))
7283 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7285 (defun gnus-button-handle-apropos (url)
7286 "Call `apropos' when pushing the corresponding URL button."
7287 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7289 (defun gnus-button-handle-apropos-command (url)
7290 "Call `apropos' when pushing the corresponding URL button."
7292 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7294 (defun gnus-button-handle-apropos-variable (url)
7295 "Call `apropos' when pushing the corresponding URL button."
7297 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7298 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7300 (defun gnus-button-handle-apropos-documentation (url)
7301 "Call `apropos' when pushing the corresponding URL button."
7303 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7304 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7306 (defun gnus-button-handle-library (url)
7307 "Call `locate-library' when pushing the corresponding URL button."
7308 (gnus-message 9 "url=`%s'" url)
7309 (let* ((lib (locate-library url))
7310 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7312 (gnus-message 1 "Cannot locale library `%s'." url)
7313 (find-file-read-only file))))
7315 (defun gnus-button-handle-ctan (url)
7316 "Call `browse-url' when pushing a CTAN URL button."
7318 gnus-button-ctan-handler
7321 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
7323 (defcustom gnus-button-tex-level 5
7324 "*Integer that says how many TeX-related buttons Gnus will show.
7325 The higher the number, the more buttons will appear and the more false
7326 positives are possible. Note that you can set this variable local to
7327 specific groups. Setting it higher in TeX groups is probably a good idea.
7328 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7329 how to set variables in specific groups."
7331 :group 'gnus-article-buttons
7332 :link '(custom-manual "(gnus)Group Parameters")
7335 (defcustom gnus-button-man-level 5
7336 "*Integer that says how many man-related buttons Gnus will show.
7337 The higher the number, the more buttons will appear and the more false
7338 positives are possible. Note that you can set this variable local to
7339 specific groups. Setting it higher in Unix groups is probably a good idea.
7340 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7341 how to set variables in specific groups."
7343 :group 'gnus-article-buttons
7344 :link '(custom-manual "(gnus)Group Parameters")
7347 (defcustom gnus-button-emacs-level 5
7348 "*Integer that says how many emacs-related buttons Gnus will show.
7349 The higher the number, the more buttons will appear and the more false
7350 positives are possible. Note that you can set this variable local to
7351 specific groups. Setting it higher in Emacs or Gnus related groups is
7352 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7353 `gnus-parameters' on how to set variables in specific groups."
7355 :group 'gnus-article-buttons
7356 :link '(custom-manual "(gnus)Group Parameters")
7359 (defcustom gnus-button-message-level 5
7360 "*Integer that says how many buttons for news or mail messages will appear.
7361 The higher the number, the more buttons will appear and the more false
7362 positives are possible."
7363 ;; mail addresses, MIDs, URLs for news, ...
7365 :group 'gnus-article-buttons
7368 (defcustom gnus-button-browse-level 5
7369 "*Integer that says how many buttons for browsing will appear.
7370 The higher the number, the more buttons will appear and the more false
7371 positives are possible."
7372 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7374 :group 'gnus-article-buttons
7377 (defcustom gnus-button-alist
7378 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7379 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7380 ((concat "\\b\\(nntp\\|news\\):\\("
7381 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7382 0 t gnus-button-handle-news 2)
7383 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7384 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7385 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7386 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7387 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7388 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7389 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7390 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7391 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7392 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7393 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7394 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7395 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7396 ;; RFC 2368 (The mailto URL scheme)
7397 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7398 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7399 ("\\bmailto:\\([^ \n\t]+\\)"
7400 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7402 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
7403 gnus-button-ctan-directory-regexp
7404 "[^][>)!;:,'\n\t ]+\\)")
7405 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
7406 ((concat "\\btex-archive/\\("
7407 gnus-button-ctan-directory-regexp
7408 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
7409 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
7412 gnus-button-ctan-directory-regexp
7413 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
7414 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
7415 ;; Info Konqueror style <info:/foo/bar baz>.
7416 ;; Must come before " Gnus home-grown style".
7417 ("\\binfo://?\\([^'\">\n\t]+\\)"
7418 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7419 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7420 ("\\binfo://\\([^'\">\n\t ]+\\)"
7421 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7422 ;; Info GNOME style <info:foo#bar_baz>
7423 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7424 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7425 ;; Info KDE style <info:(foo)bar baz>
7426 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7427 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7428 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7429 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7430 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n,]*\\)\\)?"
7431 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7432 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7434 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
7435 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7436 ;; Emacs help commands
7437 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7438 ;; regexp doesn't match arguments containing ` '.
7439 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7440 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7441 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7442 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7443 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7444 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7445 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7446 ;; The following entries may lead to many false positives so don't enable
7447 ;; them by default (use a high button level).
7448 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7449 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7450 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7451 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7452 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7453 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7454 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7455 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7456 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7457 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7458 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7459 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7460 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7461 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7462 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7463 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7464 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7465 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7466 ;; Unlike the other regexps we really have to require quoting
7467 ;; here to determine where it ends.
7468 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7469 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7470 ("<URL: *\\([^\n<>]*\\)>"
7471 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7472 ;; RFC 2396 (2.4.3., delims) ...
7473 ("\"URL: *\\([^\n\"]*\\)\""
7474 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7476 (gnus-button-url-regexp
7477 0 (>= gnus-button-browse-level 0) browse-url 0)
7479 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7480 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7481 gnus-button-handle-man 1)
7482 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7483 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7484 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7485 gnus-button-handle-man 1)
7486 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7487 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7488 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7489 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7490 ;; Recognizing patches to .el files. This is somewhat obscure,
7491 ;; but considering the percentage of Gnus users who hack Emacs
7493 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7494 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7495 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7496 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7497 ;; MID or mail: To avoid too many false positives we don't try to catch
7498 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7499 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7500 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7501 ;; so that non-ambiguous entries (see above) match first.
7502 (gnus-button-mid-or-mail-regexp
7503 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7504 "*Alist of regexps matching buttons in article bodies.
7506 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7507 REGEXP: is the string (case insensitive) matching text around the button (can
7508 also be Lisp expression evaluating to a string),
7509 BUTTON: is the number of the regexp grouping actually matching the button,
7510 FORM: is a Lisp expression which must eval to true for the button to
7512 CALLBACK: is the function to call when the user push this button, and each
7513 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7515 CALLBACK can also be a variable, in that case the value of that
7516 variable it the real callback function."
7517 :group 'gnus-article-buttons
7518 :type '(repeat (list (choice regexp variable sexp)
7519 (integer :tag "Button")
7521 (function :tag "Callback")
7524 (integer :tag "Regexp group")))))
7525 (put 'gnus-button-alist 'risky-local-variable t)
7527 (defcustom gnus-header-button-alist
7528 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7529 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7530 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7531 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7532 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7533 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7534 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7535 0 (>= gnus-button-browse-level 0) browse-url 0)
7536 ("^Subject:" gnus-button-url-regexp
7537 0 (>= gnus-button-browse-level 0) browse-url 0)
7538 ("^[^:]+:" gnus-button-url-regexp
7539 0 (>= gnus-button-browse-level 0) browse-url 0)
7540 ("^OpenPGP:.*url=" gnus-button-url-regexp
7541 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7542 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7543 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7544 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7545 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7546 "*Alist of headers and regexps to match buttons in article heads.
7548 This alist is very similar to `gnus-button-alist', except that each
7549 alist has an additional HEADER element first in each entry:
7551 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7553 HEADER is a regexp to match a header. For a fuller explanation, see
7554 `gnus-button-alist'."
7555 :group 'gnus-article-buttons
7556 :group 'gnus-article-headers
7557 :type '(repeat (list (regexp :tag "Header")
7558 (choice regexp variable)
7559 (integer :tag "Button")
7561 (function :tag "Callback")
7564 (integer :tag "Regexp group")))))
7565 (put 'gnus-header-button-alist 'risky-local-variable t)
7569 (defun gnus-article-push-button (event)
7570 "Check text under the mouse pointer for a callback function.
7571 If the text under the mouse pointer has a `gnus-callback' property,
7572 call it with the value of the `gnus-data' text property."
7574 (set-buffer (window-buffer (posn-window (event-start event))))
7575 (let* ((pos (posn-point (event-start event)))
7576 (data (get-text-property pos 'gnus-data))
7577 (fun (get-text-property pos 'gnus-callback)))
7580 (funcall fun data))))
7582 (defun gnus-article-press-button ()
7583 "Check text at point for a callback function.
7584 If the text at point has a `gnus-callback' property,
7585 call it with the value of the `gnus-data' text property."
7587 (let ((data (get-text-property (point) 'gnus-data))
7588 (fun (get-text-property (point) 'gnus-callback)))
7590 (funcall fun data))))
7592 (defun gnus-article-highlight (&optional force)
7593 "Highlight current article.
7594 This function calls `gnus-article-highlight-headers',
7595 `gnus-article-highlight-citation',
7596 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7597 do the highlighting. See the documentation for those functions."
7598 (interactive (list 'force))
7599 (gnus-article-highlight-headers)
7600 (gnus-article-highlight-citation force)
7601 (gnus-article-highlight-signature)
7602 (gnus-article-add-buttons force)
7603 (gnus-article-add-buttons-to-head))
7605 (defun gnus-article-highlight-some (&optional force)
7606 "Highlight current article.
7607 This function calls `gnus-article-highlight-headers',
7608 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7609 do the highlighting. See the documentation for those functions."
7610 (interactive (list 'force))
7611 (gnus-article-highlight-headers)
7612 (gnus-article-highlight-signature)
7613 (gnus-article-add-buttons))
7615 (defun gnus-article-highlight-headers ()
7616 "Highlight article headers as specified by `gnus-header-face-alist'."
7618 (gnus-with-article-headers
7619 (let (regexp header-face field-face from hpoints fpoints)
7620 (dolist (entry gnus-header-face-alist)
7621 (goto-char (point-min))
7622 (setq regexp (concat "^\\("
7623 (if (string-equal "" (nth 0 entry))
7627 header-face (nth 1 entry)
7628 field-face (nth 2 entry))
7629 (while (and (re-search-forward regexp nil t)
7633 (unless (search-forward ":" nil t)
7635 (when (and header-face
7636 (not (memq (point) hpoints)))
7637 (push (point) hpoints)
7638 (gnus-put-text-property from (point) 'face header-face))
7639 (when (and field-face
7640 (not (memq (setq from (point)) fpoints)))
7642 (if (re-search-forward "^[^ \t]" nil t)
7644 (goto-char (point-max)))
7645 (gnus-put-text-property from (point) 'face field-face)))))))
7647 (defun gnus-article-highlight-signature ()
7648 "Highlight the signature in an article.
7649 It does this by highlighting everything after
7650 `gnus-signature-separator' using the face `gnus-signature'."
7652 (gnus-with-article-buffer
7653 (let ((inhibit-point-motion-hooks t))
7655 (when (and gnus-signature-face
7656 (gnus-article-narrow-to-signature))
7657 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7658 'face gnus-signature-face)
7660 (gnus-article-search-signature)
7661 (let ((start (match-beginning 0))
7662 (end (set-marker (make-marker) (1+ (match-end 0)))))
7663 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7666 (defun gnus-button-in-region-p (b e prop)
7667 "Say whether PROP exists in the region."
7668 (text-property-not-all b e prop nil))
7670 (defun gnus-article-add-buttons (&optional force)
7671 "Find external references in the article and make buttons of them.
7672 \"External references\" are things like Message-IDs and URLs, as
7673 specified by `gnus-button-alist'."
7674 (interactive (list 'force))
7675 (gnus-with-article-buffer
7676 (let ((inhibit-point-motion-hooks t)
7677 (case-fold-search t)
7678 (alist gnus-button-alist)
7680 ;; Remove all old markers.
7681 (let (marker entry new-list)
7682 (while (setq marker (pop gnus-button-marker-list))
7683 (if (or (< marker (point-min)) (>= marker (point-max)))
7684 (push marker new-list)
7686 (when (setq entry (gnus-button-entry))
7687 (put-text-property (match-beginning (nth 1 entry))
7688 (match-end (nth 1 entry))
7689 'gnus-callback nil))
7690 (set-marker marker nil)))
7691 (setq gnus-button-marker-list new-list))
7692 ;; We skip the headers.
7695 (while (setq entry (pop alist))
7696 (setq regexp (eval (car entry)))
7698 (while (re-search-forward regexp nil t)
7699 (let ((start (match-beginning (nth 1 entry)))
7700 (end (match-end (nth 1 entry)))
7701 (from (match-beginning 0)))
7702 (when (and (or (eq t (nth 2 entry))
7703 (eval (nth 2 entry)))
7704 (not (gnus-button-in-region-p
7705 start end 'gnus-callback)))
7706 ;; That optional form returned non-nil, so we add the
7708 (setq from (set-marker (make-marker) from))
7709 (push from gnus-button-marker-list)
7710 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7711 (gnus-article-extend-url-button from start end))
7712 (gnus-article-add-button start end
7713 'gnus-button-push from)))))))))
7715 (defun gnus-article-extend-url-button (beg start end)
7716 "Extend url button if url is folded into two or more lines.
7717 Return non-nil if button is extended. BEG is a marker that points to
7718 the beginning position of a text containing url. START and END are
7719 the endpoints of a url button before it is extended. The concatenated
7720 url is put as the `gnus-button-url' overlay property on the button."
7721 (let ((opoint (point))
7722 (points (list start end))
7727 (not (looking-at "[\t ]*[\">]")))
7731 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7732 (buffer-substring (point-at-bol) start)))
7734 (setq url (list (buffer-substring start end))
7735 delim (if (match-beginning 1) ">" "\""))
7737 (setq regexp (concat
7738 (when (and (looking-at
7739 message-cite-prefix-regexp)
7740 (< (match-end 0) start))
7741 (regexp-quote (match-string 0)))
7743 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7747 (and (looking-at regexp)
7750 (push (or (match-string 2)
7753 (push (setq end (or (match-end 2)
7756 (push (or (match-beginning 2)
7757 (match-beginning 1))
7759 (match-beginning 2)))
7760 (let (gnus-article-mouse-face widget-mouse-face)
7762 (gnus-article-add-button (pop points) (pop points)
7763 'gnus-button-push beg)))
7764 (let ((overlay (gnus-make-overlay start end)))
7765 (gnus-overlay-put overlay 'evaporate t)
7766 (gnus-overlay-put overlay 'gnus-button-url
7767 (list (mapconcat 'identity (nreverse url) "")))
7768 (when gnus-article-mouse-face
7769 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7771 (goto-char opoint))))
7773 ;; Add buttons to the head of an article.
7774 (defun gnus-article-add-buttons-to-head ()
7775 "Add buttons to the head of the article."
7777 (gnus-with-article-headers
7779 (dolist (entry gnus-header-button-alist)
7780 ;; Each alist entry.
7781 (goto-char (point-min))
7782 (while (re-search-forward (car entry) nil t)
7783 ;; Each header matching the entry.
7784 (setq beg (match-beginning 0))
7785 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7786 (match-beginning 0))
7789 (while (re-search-forward (eval (nth 1 entry)) end t)
7790 ;; Each match within a header.
7791 (let* ((entry (cdr entry))
7792 (start (match-beginning (nth 1 entry)))
7793 (end (match-end (nth 1 entry)))
7794 (form (nth 2 entry)))
7795 (goto-char (match-end 0))
7797 (gnus-article-add-button
7798 start end (nth 3 entry)
7799 (buffer-substring (match-beginning (nth 4 entry))
7800 (match-end (nth 4 entry)))))))
7801 (goto-char end))))))
7803 ;;; External functions:
7805 (defun gnus-article-add-button (from to fun &optional data)
7806 "Create a button between FROM and TO with callback FUN and data DATA."
7807 (when gnus-article-button-face
7808 (gnus-overlay-put (gnus-make-overlay from to nil t)
7809 'face gnus-article-button-face))
7810 (gnus-add-text-properties
7812 (nconc (and gnus-article-mouse-face
7813 (list gnus-mouse-face-prop gnus-article-mouse-face))
7814 (list 'gnus-callback fun)
7815 (and data (list 'gnus-data data))))
7816 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7817 :button-keymap gnus-widget-button-keymap))
7819 ;;; Internal functions:
7821 (defun gnus-article-set-globals ()
7822 (with-current-buffer gnus-summary-buffer
7823 (gnus-set-global-variables)))
7825 (defun gnus-signature-toggle (end)
7826 (gnus-with-article-buffer
7827 (let ((inhibit-point-motion-hooks t))
7828 (if (text-property-any end (point-max) 'article-type 'signature)
7830 (gnus-delete-wash-type 'signature)
7831 (gnus-remove-text-properties-when
7832 'article-type 'signature end (point-max)
7833 (cons 'article-type (cons 'signature
7834 gnus-hidden-properties))))
7835 (gnus-add-wash-type 'signature)
7836 (gnus-add-text-properties-when
7837 'article-type nil end (point-max)
7838 (cons 'article-type (cons 'signature
7839 gnus-hidden-properties)))))
7840 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7841 (gnus-set-mode-line 'article))))
7843 (defun gnus-button-entry ()
7844 ;; Return the first entry in `gnus-button-alist' matching this place.
7845 (let ((alist gnus-button-alist)
7848 (setq entry (pop alist))
7849 (if (looking-at (eval (car entry)))
7854 (defun gnus-button-push (marker)
7855 ;; Push button starting at MARKER.
7858 (let* ((entry (gnus-button-entry))
7859 (inhibit-point-motion-hooks t)
7861 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7862 (get-char-property marker 'gnus-button-url))
7863 (mapcar (lambda (group)
7864 (let ((string (match-string group)))
7865 (set-text-properties
7866 0 (length string) nil string)
7868 (nthcdr 4 entry)))))
7873 (fboundp (symbol-value fun)))
7874 (apply (symbol-value fun) args))
7876 (gnus-message 1 "You must define `%S' to use this button"
7877 (cons fun args)))))))
7879 (defun gnus-parse-news-url (url)
7880 (let (scheme server port group message-id articles)
7883 (goto-char (point-min))
7884 (when (looking-at "\\([A-Za-z]+\\):")
7885 (setq scheme (match-string 1))
7886 (goto-char (match-end 0)))
7887 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7888 (setq server (match-string 1))
7889 (setq port (if (stringp (match-string 3))
7890 (string-to-number (match-string 3))
7892 (goto-char (match-end 0)))
7895 ((looking-at "\\(.*@.*\\)")
7896 (setq message-id (match-string 1)))
7897 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7898 (setq group (match-string 1)
7899 articles (split-string (match-string 2) "-")))
7900 ((looking-at "\\([^/]+\\)/?")
7901 (setq group (match-string 1)))
7903 (error "Unknown news URL syntax"))))
7904 (list scheme server port group message-id articles)))
7906 (defun gnus-button-handle-news (url)
7908 (destructuring-bind (scheme server port group message-id articles)
7909 (gnus-parse-news-url url)
7912 (with-current-buffer gnus-summary-buffer
7914 (let ((gnus-refer-article-method
7915 (nconc (list (list 'nntp server))
7916 gnus-refer-article-method))
7917 (nntp-port-number (or port "nntp")))
7918 (gnus-message 7 "Fetching %s with %s"
7919 message-id gnus-refer-article-method)
7920 (gnus-summary-refer-article message-id))
7921 (gnus-summary-refer-article message-id))))
7923 (gnus-button-fetch-group url)))))
7925 (defun gnus-button-patch (library line)
7926 "Visit an Emacs Lisp library LIBRARY on line LINE."
7928 (let ((file (locate-library (file-name-nondirectory library))))
7930 (error "Couldn't find library %s" library))
7932 (goto-line (string-to-number line))))
7934 (defun gnus-button-handle-man (url)
7936 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7937 (when (eq gnus-button-man-handler 'woman)
7938 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7939 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7940 (funcall gnus-button-man-handler url))
7942 (defun gnus-button-handle-info-url (url)
7943 "Fetch an info URL."
7944 (setq url (mm-subst-char-in-string ?+ ?\ url))
7946 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7947 (gnus-info-find-node
7948 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7950 ")" (gnus-url-unhex-string (match-string 2 url)))))
7951 ((string-match "([^)\"]+)[^\"]+" url)
7953 (gnus-replace-in-string
7954 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7955 (gnus-info-find-node url))
7956 (t (error "Can't parse %s" url))))
7958 (defun gnus-button-handle-info-url-gnome (url)
7959 "Fetch GNOME style info URL."
7960 (setq url (mm-subst-char-in-string ?_ ?\ url))
7961 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7962 (gnus-info-find-node
7964 (gnus-url-unhex-string
7965 (match-string 1 url))
7967 (or (gnus-url-unhex-string
7968 (match-string 2 url))
7970 (error "Can't parse %s" url)))
7972 (defun gnus-button-handle-info-url-kde (url)
7973 "Fetch KDE style info URL."
7974 (gnus-info-find-node (gnus-url-unhex-string url)))
7976 ;; (info) will autoload info.el
7977 (declare-function Info-menu "info" (menu-item &optional fork))
7978 (declare-function Info-index-next "info" (num))
7980 (defun gnus-button-handle-info-keystrokes (url)
7981 "Call `info' when pushing the corresponding URL button."
7982 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
7983 (let (node indx comma)
7985 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
7986 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
7987 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET"
7988 "\\(?:[ \t\n,]*\\)\\)?")
7990 (setq node (match-string 2 url)
7991 indx (match-string 3 url))
7992 (error "Can't parse %s" url))
7996 (when (> (length indx) 0)
7997 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8000 (setq comma (match-string 2 indx))
8001 (setq indx (match-string 1 indx))
8004 (dotimes (i (with-temp-buffer
8006 ;; Note: the XEmacs version of `how-many' takes
8007 ;; no optional argument.
8008 (goto-char (point-min))
8010 (Info-index-next 1)))
8013 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8014 (declare-function pgg-display-output-buffer "pgg" (start end status))
8016 (defun gnus-button-openpgp (url)
8017 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8019 (mm-url-insert-file-contents-external url)
8020 (pgg-snarf-keys-region (point-min) (point-max))
8021 (pgg-display-output-buffer nil nil nil)))
8023 (defun gnus-button-message-id (message-id)
8025 (with-current-buffer gnus-summary-buffer
8026 (gnus-summary-refer-article message-id)))
8028 (defun gnus-button-fetch-group (address &rest ignore)
8029 "Fetch GROUP specified by ADDRESS."
8030 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8032 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8033 ;; for nntp:// and news://
8034 (setq address (match-string 3 address)))
8035 (if (not (string-match "[:/]" address))
8036 ;; This is just a simple group url.
8037 (gnus-group-read-ephemeral-group address gnus-select-method)
8040 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8042 (error "Can't parse %s" address)
8043 (gnus-group-read-ephemeral-group
8044 (match-string 4 address)
8045 `(nntp ,(match-string 1 address)
8046 (nntp-address ,(match-string 1 address))
8047 (nntp-port-number ,(if (match-end 3)
8048 (match-string 3 address)
8051 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8053 (defun gnus-url-parse-query-string (query &optional downcase)
8054 (let (retval pairs cur key val)
8055 (setq pairs (split-string query "&"))
8057 (setq cur (car pairs)
8059 (if (not (string-match "=" cur))
8061 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8062 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8064 (setq key (downcase key)))
8065 (setq cur (assoc key retval))
8067 (setcdr cur (cons val (cdr cur)))
8068 (setq retval (cons (list key val) retval)))))
8071 (defun gnus-url-mailto (url)
8072 ;; Send mail to someone
8073 (when (string-match "mailto:/*\\(.*\\)" url)
8074 (setq url (substring url (match-beginning 1) nil)))
8075 (let (to args subject func)
8076 (setq args (gnus-url-parse-query-string
8077 (if (string-match "^\\?" url)
8079 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8080 (concat "to=" (match-string 1 url) "&"
8081 (match-string 2 url))
8082 (concat "to=" url)))
8084 subject (cdr-safe (assoc "subject" args)))
8087 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8090 (message-position-on-field (caar args)))
8091 (insert (gnus-replace-in-string
8092 (mapconcat 'identity (reverse (cdar args)) ", ")
8094 (setq args (cdr args)))
8097 (message-goto-subject))))
8099 (defun gnus-button-embedded-url (address)
8100 "Activate ADDRESS with `browse-url'."
8101 (browse-url (gnus-strip-whitespace address)))
8103 ;;; Next/prev buttons in the article buffer.
8105 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8106 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8108 (defvar gnus-prev-page-map
8109 (let ((map (make-sparse-keymap)))
8110 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8111 (define-key map "\r" 'gnus-button-prev-page)
8114 (defvar gnus-next-page-map
8115 (let ((map (make-sparse-keymap)))
8116 (unless (>= emacs-major-version 21)
8117 ;; XEmacs doesn't care.
8118 (set-keymap-parent map gnus-article-mode-map))
8119 (define-key map gnus-mouse-2 'gnus-button-next-page)
8120 (define-key map "\r" 'gnus-button-next-page)
8123 (defun gnus-insert-prev-page-button ()
8125 (inhibit-read-only t))
8127 gnus-prev-page-line-format nil
8128 `(keymap ,gnus-prev-page-map
8130 gnus-callback gnus-article-button-prev-page
8131 article-type annotation))
8133 ;; Exclude a newline.
8136 (when gnus-article-button-face
8137 (gnus-overlay-put (gnus-make-overlay b e nil t)
8138 'face gnus-article-button-face))
8139 (widget-convert-button
8141 :action 'gnus-button-prev-page
8142 :button-keymap gnus-prev-page-map)))
8144 (defun gnus-button-next-page (&optional args more-args)
8145 "Go to the next page."
8147 (let ((win (selected-window)))
8148 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8149 (gnus-article-next-page)
8150 (select-window win)))
8152 (defun gnus-button-prev-page (&optional args more-args)
8153 "Go to the prev page."
8155 (let ((win (selected-window)))
8156 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8157 (gnus-article-prev-page)
8158 (select-window win)))
8160 (defun gnus-insert-next-page-button ()
8162 (inhibit-read-only t))
8163 (gnus-eval-format gnus-next-page-line-format nil
8164 `(keymap ,gnus-next-page-map
8166 gnus-callback gnus-article-button-next-page
8167 article-type annotation))
8169 ;; Exclude a newline.
8172 (when gnus-article-button-face
8173 (gnus-overlay-put (gnus-make-overlay b e nil t)
8174 'face gnus-article-button-face))
8175 (widget-convert-button
8177 :action 'gnus-button-next-page
8178 :button-keymap gnus-next-page-map)))
8180 (defun gnus-article-button-next-page (arg)
8181 "Go to the next page."
8183 (let ((win (selected-window)))
8184 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8185 (gnus-article-next-page)
8186 (select-window win)))
8188 (defun gnus-article-button-prev-page (arg)
8189 "Go to the prev page."
8191 (let ((win (selected-window)))
8192 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8193 (gnus-article-prev-page)
8194 (select-window win)))
8196 (defvar gnus-decode-header-methods
8197 '(mail-decode-encoded-word-region)
8198 "List of methods used to decode headers.
8200 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8201 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8202 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8203 whose names match REGEXP.
8206 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8207 mail-decode-encoded-word-region
8208 (\"chinese\" . rfc1843-decode-region))
8211 (defvar gnus-decode-header-methods-cache nil)
8213 (defun gnus-multi-decode-header (start end)
8214 "Apply the functions from `gnus-encoded-word-methods' that match."
8215 (unless (and gnus-decode-header-methods-cache
8216 (eq gnus-newsgroup-name
8217 (car gnus-decode-header-methods-cache)))
8218 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8219 (dolist (x gnus-decode-header-methods)
8221 (nconc gnus-decode-header-methods-cache (list x))
8222 (if (and gnus-newsgroup-name
8223 (string-match (car x) gnus-newsgroup-name))
8224 (nconc gnus-decode-header-methods-cache
8226 (let ((xlist gnus-decode-header-methods-cache))
8229 (narrow-to-region start end)
8231 (funcall (pop xlist) (point-min) (point-max))))))
8234 ;;; Treatment top-level handling.
8237 (defun gnus-treat-article (condition &optional part-number total-parts type)
8238 (let ((length (- (point-max) (point-min)))
8239 (alist gnus-treatment-function-alist)
8240 (article-goto-body-goes-to-point-min-p t)
8244 (let ((list gnus-article-treat-types))
8246 (when (string-match (pop list) type)
8247 (throw 'found t)))))))
8248 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8250 (gnus-run-hooks 'gnus-part-display-hook)
8251 (dolist (elem alist)
8254 (when (gnus-buffer-live-p gnus-summary-buffer)
8255 (set-buffer gnus-summary-buffer))
8256 (symbol-value (car elem))))
8257 (when (and (or (consp val)
8259 (gnus-treat-predicate val)
8260 (or (not (get (car elem) 'highlight))
8263 (funcall (cadr elem)))))))
8265 ;; Dynamic variables.
8266 (defvar part-number)
8267 (defvar total-parts)
8272 (defun gnus-treat-predicate (val)
8279 (stringp (car val)))
8280 (apply 'gnus-or (mapcar `(lambda (s)
8281 (string-match s ,(or gnus-newsgroup-name "")))
8284 (let ((pred (pop val)))
8287 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8289 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8291 (not (gnus-treat-predicate (car val))))
8293 (equal (car val) type))
8295 (error "%S is not a valid predicate" pred)))))
8303 (eq part-number total-parts))
8307 (error "%S is not a valid value" val))))
8309 (defun gnus-article-encrypt-body (protocol &optional n)
8310 "Encrypt the article body."
8313 (or gnus-article-encrypt-protocol
8314 (completing-read "Encrypt protocol: "
8315 gnus-article-encrypt-protocol-alist
8317 current-prefix-arg))
8318 ;; User might hit `K E' instead of `K e', so prompt once.
8319 (when (and gnus-article-encrypt-protocol
8321 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8322 (error "Encrypt aborted.")))
8323 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8325 (error "Can't find the encrypt protocol %s" protocol))
8326 (if (member gnus-newsgroup-name '("nndraft:delayed"
8329 (error "Can't encrypt the article in group %s"
8330 gnus-newsgroup-name))
8331 (gnus-summary-iterate n
8332 (with-current-buffer gnus-summary-buffer
8333 (let ((mail-parse-charset gnus-newsgroup-charset)
8334 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8335 (summary-buffer gnus-summary-buffer)
8337 (gnus-set-global-variables)
8338 (when (gnus-group-read-only-p)
8339 (error "The current newsgroup does not support article encrypt"))
8340 (gnus-summary-show-article t)
8342 (or (mail-header-references gnus-current-headers) ""))
8343 (set-buffer gnus-article-buffer)
8344 (let* ((inhibit-read-only t)
8346 (mapcar (lambda (field)
8347 (and (save-restriction
8348 (message-narrow-to-head)
8349 (goto-char (point-min))
8350 (search-forward field nil t))
8352 (message-narrow-to-field)
8354 (delete-region (point-min) (point-max))
8356 '("Content-Type:" "Content-Transfer-Encoding:"
8357 "Content-Disposition:"))))
8358 (message-narrow-to-head)
8359 (message-remove-header "MIME-Version")
8360 (goto-char (point-max))
8361 (setq point (point))
8362 (insert (apply 'concat headers))
8364 (narrow-to-region point (point-max))
8365 (let ((message-options message-options))
8366 (message-options-set 'message-sender user-mail-address)
8367 (message-options-set 'message-recipients user-mail-address)
8368 (message-options-set 'message-sign-encrypt 'not)
8370 (goto-char (point-min))
8371 (insert "MIME-Version: 1.0\n")
8373 (gnus-summary-edit-article-done
8374 references nil summary-buffer t))
8375 (when gnus-keep-backlog
8376 (gnus-backlog-remove-article
8377 (car gnus-article-current) (cdr gnus-article-current)))
8378 (when (get-buffer gnus-original-article-buffer)
8379 (with-current-buffer gnus-original-article-buffer
8380 (setq gnus-original-article nil)))
8381 (when gnus-use-cache
8382 (gnus-cache-update-article
8383 (car gnus-article-current) (cdr gnus-article-current))))))))
8385 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8386 "The following specs can be used:
8387 %t The security MIME type
8390 %D Details if button is pressed")
8392 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8393 "The following specs can be used:
8394 %t The security MIME type
8397 %D Details if button is pressed")
8399 (defvar gnus-mime-security-button-line-format-alist
8400 '((?t gnus-tmp-type ?s)
8401 (?i gnus-tmp-info ?s)
8402 (?d gnus-tmp-details ?s)
8403 (?D gnus-tmp-pressed-details ?s)))
8405 (defvar gnus-mime-security-button-commands
8406 '((gnus-article-press-button "\r" "Show Detail")
8410 (gnus-mime-security-save-part "o" "Save...")
8419 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8422 (defvar gnus-mime-security-button-map
8423 (let ((map (make-sparse-keymap)))
8424 (define-key map gnus-mouse-2 'gnus-article-push-button)
8425 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8426 (dolist (c gnus-mime-security-button-commands)
8427 (define-key map (cadr c) (car c)))
8431 gnus-mime-security-button-menu gnus-mime-security-button-map
8432 "Security button menu."
8436 (unless (eq (car c) 'undefined)
8437 (vector (caddr c) (car c) :active t)))
8438 gnus-mime-security-button-commands))))
8440 (defun gnus-mime-security-button-menu (event prefix)
8441 "Construct a context-sensitive menu of security commands."
8442 (interactive "e\nP")
8443 (save-window-excursion
8444 (let ((pos (event-start event)))
8445 (select-window (posn-window pos))
8446 (goto-char (posn-point pos))
8447 (gnus-article-check-buffer)
8448 (popup-menu gnus-mime-security-button-menu nil prefix))))
8450 (defvar gnus-mime-security-details-buffer nil)
8452 (defvar gnus-mime-security-button-pressed nil)
8454 (defvar gnus-mime-security-show-details-inline t
8455 "If non-nil, show details in the article buffer.")
8457 (defun gnus-mime-security-verify-or-decrypt (handle)
8458 (mm-remove-parts (cdr handle))
8459 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8460 point (inhibit-read-only t))
8462 (goto-char (car region)))
8463 (setq point (point))
8464 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8465 (let* ((mm-verify-option 'known)
8466 (mm-decrypt-option 'known)
8467 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8468 (unless (eq nparts (cdr handle))
8469 (mm-destroy-parts (cdr handle))
8470 (setcdr handle nparts))))
8471 (gnus-mime-display-security handle)
8473 (delete-region (point) (cdr region))
8474 (set-marker (car region) nil)
8475 (set-marker (cdr region) nil))
8478 (defun gnus-mime-security-show-details (handle)
8479 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8481 (gnus-message 5 "No details.")
8482 (if gnus-mime-security-show-details-inline
8483 (let ((gnus-mime-security-button-pressed
8484 (not (get-text-property (point) 'gnus-mime-details)))
8485 (gnus-mime-security-button-line-format
8486 (get-text-property (point) 'gnus-line-format))
8487 (inhibit-read-only t))
8489 (while (eq (get-text-property (point) 'gnus-line-format)
8490 gnus-mime-security-button-line-format)
8494 (narrow-to-region (point) (point))
8495 (gnus-insert-mime-security-button handle))
8496 (delete-region (point)
8497 (or (text-property-not-all
8500 gnus-mime-security-button-line-format)
8503 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8504 (with-current-buffer gnus-mime-security-details-buffer
8507 (setq gnus-mime-security-details-buffer
8508 (gnus-get-buffer-create "*MIME Security Details*")))
8509 (with-current-buffer gnus-mime-security-details-buffer
8511 (goto-char (point-min)))
8512 (pop-to-buffer gnus-mime-security-details-buffer)))))
8514 (defun gnus-mime-security-press-button (handle)
8516 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8517 (gnus-mime-security-show-details handle)
8518 (gnus-mime-security-verify-or-decrypt handle))))
8520 (defun gnus-insert-mime-security-button (handle &optional displayed)
8521 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8524 (or (nth 2 (assoc protocol mm-verify-function-alist))
8525 (nth 2 (assoc protocol mm-decrypt-function-alist))
8527 (if (equal (car handle) "multipart/signed")
8528 " Signed" " Encrypted")
8531 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8534 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8535 gnus-tmp-pressed-details
8537 (setq gnus-tmp-details
8538 (if gnus-tmp-details
8539 (concat "\n" gnus-tmp-details)
8541 (setq gnus-tmp-pressed-details
8542 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8547 gnus-mime-security-button-line-format
8548 gnus-mime-security-button-line-format-alist
8549 `(keymap ,gnus-mime-security-button-map
8550 gnus-callback gnus-mime-security-press-button
8551 gnus-line-format ,gnus-mime-security-button-line-format
8552 gnus-mime-details ,gnus-mime-security-button-pressed
8553 article-type annotation
8556 ;; Exclude a newline.
8559 (when gnus-article-button-face
8560 (gnus-overlay-put (gnus-make-overlay b e nil t)
8561 'face gnus-article-button-face))
8562 (widget-convert-button
8565 :action 'gnus-widget-press-button
8566 :button-keymap gnus-mime-security-button-map
8568 (lambda (widget/window &optional overlay pos)
8569 ;; Needed to properly clear the message due to a bug in
8570 ;; wid-edit (XEmacs only).
8571 (when (boundp 'help-echo-owns-message)
8572 (setq help-echo-owns-message t))
8574 "%S: show detail; %S: more options"
8575 (aref gnus-mouse-2 0)
8576 (aref gnus-down-mouse-3 0))))))
8578 (defun gnus-mime-display-security (handle)
8580 (narrow-to-region (point) (point))
8581 (unless (gnus-unbuttonized-mime-type-p (car handle))
8582 (gnus-insert-mime-security-button handle))
8583 (gnus-mime-display-part (cadr handle))
8586 (unless (gnus-unbuttonized-mime-type-p (car handle))
8587 (let ((gnus-mime-security-button-line-format
8588 gnus-mime-security-button-end-line-format))
8589 (gnus-insert-mime-security-button handle)))
8590 (mm-set-handle-multipart-parameter
8592 (cons (set-marker (make-marker) (point-min))
8593 (set-marker (make-marker) (point-max))))
8594 (goto-char (point-max))))
8596 (defun gnus-mime-security-run-function (function)
8597 "Run FUNCTION with the security part under point."
8598 (gnus-article-check-buffer)
8599 (let ((data (get-text-property (point) 'gnus-data))
8601 (when (and (stringp (car-safe data))
8602 (setq buffer (mm-handle-multipart-original-buffer data))
8603 (setq handle (cadr data)))
8604 (if (bufferp (mm-handle-buffer handle))
8606 (setq handle (cons buffer (copy-sequence (cdr handle))))
8607 (mm-handle-set-undisplayer handle nil))
8608 (setq handle (mm-make-handle
8610 (mm-handle-multipart-ctl-parameter handle 'protocol)
8611 nil nil nil nil nil nil)))
8612 (funcall function handle))))
8614 (defun gnus-mime-security-save-part ()
8615 "Save the security part under point."
8617 (gnus-mime-security-run-function 'mm-save-part))
8619 (defun gnus-mime-security-pipe-part ()
8620 "Pipe the security part under point to a process."
8622 (gnus-mime-security-run-function 'mm-pipe-part))
8628 (run-hooks 'gnus-art-load-hook)
8630 ;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
8631 ;;; gnus-art.el ends here