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, 2010, 2011 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 nil
731 "Gnus 5.10 (Emacs-22.1)")
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
)
769 (put 'gnus-signature-face
'obsolete-face
"22.1")
771 (defface gnus-header-from
774 (:foreground
"PaleGreen1"))
777 (:foreground
"red3"))
780 "Face used for displaying from headers."
781 :group
'gnus-article-headers
782 :group
'gnus-article-highlight
)
783 ;; backward-compatibility alias
784 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
785 (put 'gnus-header-from-face
'obsolete-face
"22.1")
787 (defface gnus-header-subject
790 (:foreground
"SeaGreen1"))
793 (:foreground
"red4"))
795 (:bold t
:italic t
)))
796 "Face used for displaying subject headers."
797 :group
'gnus-article-headers
798 :group
'gnus-article-highlight
)
799 ;; backward-compatibility alias
800 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
801 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
803 (defface gnus-header-newsgroups
806 (:foreground
"yellow" :italic t
))
809 (:foreground
"MidnightBlue" :italic t
))
812 "Face used for displaying newsgroups headers.
813 In the default setup this face is only used for crossposted
815 :group
'gnus-article-headers
816 :group
'gnus-article-highlight
)
817 ;; backward-compatibility alias
818 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
819 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
821 (defface gnus-header-name
824 (:foreground
"SpringGreen2"))
827 (:foreground
"maroon"))
830 "Face used for displaying header names."
831 :group
'gnus-article-headers
832 :group
'gnus-article-highlight
)
833 ;; backward-compatibility alias
834 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
835 (put 'gnus-header-name-face
'obsolete-face
"22.1")
837 (defface gnus-header-content
840 (:foreground
"SpringGreen1" :italic t
))
843 (:foreground
"indianred4" :italic t
))
845 (:italic t
))) "Face used for displaying header content."
846 :group
'gnus-article-headers
847 :group
'gnus-article-highlight
)
848 ;; backward-compatibility alias
849 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
850 (put 'gnus-header-content-face
'obsolete-face
"22.1")
852 (defcustom gnus-header-face-alist
853 '(("From" nil gnus-header-from
)
854 ("Subject" nil gnus-header-subject
)
855 ("Newsgroups:.*," nil gnus-header-newsgroups
)
856 ("" gnus-header-name gnus-header-content
))
857 "*Controls highlighting of article headers.
859 An alist of the form (HEADER NAME CONTENT).
861 HEADER is a regular expression which should match the name of a
862 header and NAME and CONTENT are either face names or nil.
864 The name of each header field will be displayed using the face
865 specified by the first element in the list where HEADER matches
866 the header name and NAME is non-nil. Similarly, the content will
867 be displayed by the first non-nil matching CONTENT face."
868 :group
'gnus-article-headers
869 :group
'gnus-article-highlight
870 :type
'(repeat (list (regexp :tag
"Header")
872 (item :tag
"skip" nil
)
873 (face :value default
))
874 (choice :tag
"Content"
875 (item :tag
"skip" nil
)
876 (face :value default
)))))
878 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
879 '((xface .
(:face gnus-x-face
)))
880 '((pbm .
(:face gnus-x-face
))
882 "Alist of image types and properties applied to Face and X-Face images.
885 ;; Specify the altitude of Face images in the From header.
886 \(setq gnus-face-properties-alist
887 '((pbm . (:face gnus-x-face :ascent 80))
888 (png . (:ascent 80))))
890 ;; Show Face images as pressed buttons.
891 \(setq gnus-face-properties-alist
892 '((pbm . (:face gnus-x-face :relief -2))
893 (png . (:relief -2))))
895 See the manual for the valid properties for various image types.
896 Currently, `pbm' is used for X-Face images and `png' is used for Face
897 images in Emacs. Only the `:face' property is effective on the `xface'
898 image type in XEmacs if it is built with the libcompface library."
899 :version
"23.1" ;; No Gnus
900 :group
'gnus-article-headers
901 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
903 (defcustom gnus-article-decode-hook
904 '(article-decode-charset article-decode-encoded-words
905 article-decode-group-name article-decode-idna-rhs
)
906 "*Hook run to decode charsets in articles."
907 :group
'gnus-article-headers
910 (defcustom gnus-display-mime-function
'gnus-display-mime
911 "Function to display MIME articles."
912 :group
'gnus-article-mime
915 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
916 "Function used to decode headers.")
918 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
919 "Function used to decode addresses.")
921 (defvar gnus-article-dumbquotes-map
941 "Table for MS-to-Latin1 translation.")
943 (defcustom gnus-ignored-mime-types nil
944 "List of MIME types that should be ignored by Gnus."
946 :group
'gnus-article-mime
947 :type
'(repeat regexp
))
949 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
950 "List of MIME types that should not be given buttons when rendered inline.
951 See also `gnus-buttonized-mime-types' which may override this variable.
952 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
954 :group
'gnus-article-mime
955 :type
'(repeat regexp
))
957 (defcustom gnus-buttonized-mime-types nil
958 "List of MIME types that should be given buttons when rendered inline.
959 If set, this variable overrides `gnus-unbuttonized-mime-types'.
960 To see e.g. security buttons you could set this to
961 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
962 this list to display radio buttons that allow you to choose one of two
963 media types those mails include. See also `mm-discouraged-alternatives'.
964 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
966 :group
'gnus-article-mime
967 :type
'(repeat regexp
))
969 (defcustom gnus-inhibit-mime-unbuttonizing nil
970 "If non-nil, all MIME parts get buttons.
971 When nil (the default value), then some MIME parts do not get buttons,
972 as described by the variables `gnus-buttonized-mime-types' and
973 `gnus-unbuttonized-mime-types'."
975 :group
'gnus-article-mime
978 (defcustom gnus-body-boundary-delimiter
"_"
979 "String used to delimit header and body.
980 This variable is used by `gnus-article-treat-body-boundary' which can
981 be controlled by `gnus-treat-body-boundary'."
983 :group
'gnus-article-various
984 :type
'(choice (item :tag
"None" :value nil
)
987 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
989 "Defines the location of the faces database.
990 For information on obtaining this database of pretty pictures, please
991 see http://www.cs.indiana.edu/picons/ftp/index.html"
993 :type
'(repeat directory
)
994 :link
'(url-link :tag
"download"
995 "http://www.cs.indiana.edu/picons/ftp/index.html")
996 :link
'(custom-manual "(gnus)Picons")
999 (defun gnus-picons-installed-p ()
1000 "Say whether picons are installed on your machine."
1001 (let ((installed nil
))
1002 (dolist (database gnus-picon-databases
)
1003 (when (file-exists-p database
)
1004 (setq installed t
)))
1007 (defcustom gnus-article-mime-part-function nil
1008 "Function called with a MIME handle as the argument.
1009 This is meant for people who want to do something automatic based
1010 on parts -- for instance, adding Vcard info to a database."
1011 :group
'gnus-article-mime
1012 :type
'(choice (const nil
)
1015 (defcustom gnus-mime-multipart-functions nil
1016 "An alist of MIME types to functions to display them."
1018 :group
'gnus-article-mime
1019 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1021 (defcustom gnus-article-date-lapsed-new-header nil
1022 "Whether the X-Sent and Date headers can coexist.
1023 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1024 either replace the old \"Date:\" header (if this variable is nil), or
1025 be added below it (otherwise)."
1027 :group
'gnus-article-headers
1030 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1031 "Function called with a MIME handle as the argument.
1032 This is meant for people who want to view first matched part.
1033 For `undisplayed-alternative' (default), the first undisplayed
1034 part or alternative part is used. For `undisplayed', the first
1035 undisplayed part is used. For a function, the first part which
1036 the function return t is used. For nil, the first part is
1039 :group
'gnus-article-mime
1041 (item :tag
"first" :value nil
)
1042 (item :tag
"undisplayed" :value undisplayed
)
1043 (item :tag
"undisplayed or alternative"
1044 :value undisplayed-alternative
)
1047 (defcustom gnus-mime-action-alist
1048 '(("save to file" . gnus-mime-save-part
)
1049 ("save and strip" . gnus-mime-save-part-and-strip
)
1050 ("replace with file" . gnus-mime-replace-part
)
1051 ("delete part" . gnus-mime-delete-part
)
1052 ("display as text" . gnus-mime-inline-part
)
1053 ("view the part" . gnus-mime-view-part
)
1054 ("pipe to command" . gnus-mime-pipe-part
)
1055 ("toggle display" . gnus-article-press-button
)
1056 ("toggle display" . gnus-article-view-part-as-charset
)
1057 ("view as type" . gnus-mime-view-part-as-type
)
1058 ("view internally" . gnus-mime-view-part-internally
)
1059 ("view externally" . gnus-mime-view-part-externally
))
1060 "An alist of actions that run on the MIME attachment."
1061 :group
'gnus-article-mime
1062 :type
'(repeat (cons (string :tag
"name")
1065 (defcustom gnus-auto-select-part
1
1066 "Advance to next MIME part when deleting or stripping parts.
1068 When 0, point will be placed on the same part as before. When
1069 positive (negative), move point forward (backwards) this many
1070 parts. When nil, redisplay article."
1071 :version
"23.1" ;; No Gnus
1072 :group
'gnus-article-mime
1073 :type
'(choice (const nil
:tag
"Redisplay article.")
1074 (const 1 :tag
"Next part.")
1075 (const 0 :tag
"Current part.")
1079 ;;; The treatment variables
1082 (defvar gnus-part-display-hook nil
1083 "Hook called on parts that are to receive treatment.")
1085 (defvar gnus-article-treat-custom
1086 '(choice (const :tag
"Off" nil
)
1088 (const :tag
"Header" head
)
1089 (const :tag
"First" first
)
1090 (const :tag
"Last" last
)
1091 (integer :tag
"Less")
1092 (repeat :tag
"Groups" regexp
)
1093 (sexp :tag
"Predicate")))
1095 (defvar gnus-article-treat-head-custom
1096 '(choice (const :tag
"Off" nil
)
1097 (const :tag
"Header" head
)))
1099 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1103 (defvar gnus-inhibit-treatment nil
1104 "Whether to inhibit treatment.")
1106 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1107 "Highlight the signature.
1108 Valid values are nil, t, `head', `first', `last', an integer or a
1109 predicate. See Info node `(gnus)Customizing Articles'."
1110 :group
'gnus-article-treat
1111 :link
'(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom
)
1113 (put 'gnus-treat-highlight-signature
'highlight t
)
1115 (defcustom gnus-treat-buttonize
100000
1117 Valid values are nil, t, `head', `first', `last', an integer or a
1118 predicate. See Info node `(gnus)Customizing Articles'."
1119 :group
'gnus-article-treat
1120 :link
'(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom
)
1122 (put 'gnus-treat-buttonize
'highlight t
)
1124 (defcustom gnus-treat-buttonize-head
'head
1125 "Add buttons to the head.
1126 Valid values are nil, t, `head', `first', `last', an integer or a
1127 predicate. See Info node `(gnus)Customizing Articles'."
1128 :group
'gnus-article-treat
1129 :link
'(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-head-custom
)
1131 (put 'gnus-treat-buttonize-head
'highlight t
)
1133 (defcustom gnus-treat-emphasize
50000
1135 Valid values are nil, t, `head', `first', `last', an integer or a
1136 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group
'gnus-article-treat
1138 :link
'(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom
)
1140 (put 'gnus-treat-emphasize
'highlight t
)
1142 (defcustom gnus-treat-strip-cr nil
1143 "Remove carriage returns.
1144 Valid values are nil, t, `head', `first', `last', an integer or a
1145 predicate. See Info node `(gnus)Customizing Articles'."
1147 :group
'gnus-article-treat
1148 :link
'(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom
)
1151 (defcustom gnus-treat-unsplit-urls nil
1152 "Remove newlines from within URLs.
1153 Valid values are nil, t, `head', `first', `last', an integer or a
1154 predicate. See Info node `(gnus)Customizing Articles'."
1156 :group
'gnus-article-treat
1157 :link
'(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom
)
1160 (defcustom gnus-treat-leading-whitespace nil
1161 "Remove leading whitespace in headers.
1162 Valid values are nil, t, `head', `first', `last', an integer or a
1163 predicate. See Info node `(gnus)Customizing Articles'."
1165 :group
'gnus-article-treat
1166 :link
'(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-custom
)
1169 (defcustom gnus-treat-hide-headers
'head
1171 Valid values are nil, t, `head', `first', `last', an integer or a
1172 predicate. See Info node `(gnus)Customizing Articles'."
1173 :group
'gnus-article-treat
1174 :link
'(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-head-custom
)
1177 (defcustom gnus-treat-hide-boring-headers nil
1178 "Hide boring headers.
1179 Valid values are nil, t, `head', `first', `last', an integer or a
1180 predicate. See Info node `(gnus)Customizing Articles'."
1181 :group
'gnus-article-treat
1182 :link
'(custom-manual "(gnus)Customizing Articles")
1183 :type gnus-article-treat-head-custom
)
1185 (defcustom gnus-treat-hide-signature nil
1186 "Hide the signature.
1187 Valid values are nil, t, `head', `first', `last', an integer or a
1188 predicate. See Info node `(gnus)Customizing Articles'."
1189 :group
'gnus-article-treat
1190 :link
'(custom-manual "(gnus)Customizing Articles")
1191 :type gnus-article-treat-custom
)
1193 (defcustom gnus-treat-fill-article nil
1195 Valid values are nil, t, `head', `first', `last', an integer or a
1196 predicate. See Info node `(gnus)Customizing Articles'."
1197 :group
'gnus-article-treat
1198 :link
'(custom-manual "(gnus)Customizing Articles")
1199 :type gnus-article-treat-custom
)
1201 (defcustom gnus-treat-hide-citation nil
1203 Valid values are nil, t, `head', `first', `last', an integer or a
1204 predicate. See Info node `(gnus)Customizing Articles'."
1205 :group
'gnus-article-treat
1206 :link
'(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-custom
)
1209 (defcustom gnus-treat-hide-citation-maybe nil
1211 Valid values are nil, t, `head', `first', `last', an integer or a
1212 predicate. See Info node `(gnus)Customizing Articles'."
1213 :group
'gnus-article-treat
1214 :link
'(custom-manual "(gnus)Customizing Articles")
1215 :type gnus-article-treat-custom
)
1217 (defcustom gnus-treat-strip-list-identifiers
'head
1218 "Strip list identifiers from `gnus-list-identifiers`.
1219 Valid values are nil, t, `head', `first', `last', an integer or a
1220 predicate. See Info node `(gnus)Customizing Articles'."
1222 :group
'gnus-article-treat
1223 :link
'(custom-manual "(gnus)Customizing Articles")
1224 :type gnus-article-treat-custom
)
1226 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1227 "Gnus 5.10 (Emacs 22.1)")
1229 (defcustom gnus-treat-strip-pem nil
1230 "Strip PEM signatures.
1231 Valid values are nil, t, `head', `first', `last', an integer or a
1232 predicate. See Info node `(gnus)Customizing Articles'."
1233 :group
'gnus-article-treat
1234 :link
'(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom
)
1237 (defcustom gnus-treat-strip-banner t
1238 "Strip banners from articles.
1239 The banner to be stripped is specified in the `banner' group parameter.
1240 Valid values are nil, t, `head', `first', `last', an integer or a
1241 predicate. See Info node `(gnus)Customizing Articles'."
1242 :group
'gnus-article-treat
1243 :link
'(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom
)
1246 (defcustom gnus-treat-highlight-headers
'head
1247 "Highlight the headers.
1248 Valid values are nil, t, `head', `first', `last', an integer or a
1249 predicate. See Info node `(gnus)Customizing Articles'."
1250 :group
'gnus-article-treat
1251 :link
'(custom-manual "(gnus)Customizing Articles")
1252 :type gnus-article-treat-head-custom
)
1253 (put 'gnus-treat-highlight-headers
'highlight t
)
1255 (defcustom gnus-treat-highlight-citation t
1256 "Highlight cited text.
1257 Valid values are nil, t, `head', `first', `last', an integer or a
1258 predicate. See Info node `(gnus)Customizing Articles'."
1259 :group
'gnus-article-treat
1260 :link
'(custom-manual "(gnus)Customizing Articles")
1261 :type gnus-article-treat-custom
)
1262 (put 'gnus-treat-highlight-citation
'highlight t
)
1264 (defcustom gnus-treat-date-ut nil
1265 "Display the Date in UT (GMT).
1266 Valid values are nil, t, `head', `first', `last', an integer or a
1267 predicate. See Info node `(gnus)Customizing Articles'."
1268 :group
'gnus-article-treat
1269 :link
'(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-head-custom
)
1272 (defcustom gnus-treat-date-local nil
1273 "Display the Date in the local timezone.
1274 Valid values are nil, t, `head', `first', `last', an integer or a
1275 predicate. See Info node `(gnus)Customizing Articles'."
1276 :group
'gnus-article-treat
1277 :link
'(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-head-custom
)
1280 (defcustom gnus-treat-date-english nil
1281 "Display the Date in a format that can be read aloud in English.
1282 Valid values are nil, t, `head', `first', `last', an integer or a
1283 predicate. See Info node `(gnus)Customizing Articles'."
1285 :group
'gnus-article-treat
1286 :link
'(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-head-custom
)
1289 (defcustom gnus-treat-date-lapsed nil
1290 "Display the Date header in a way that says how much time has elapsed.
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1293 :group
'gnus-article-treat
1294 :link
'(custom-manual "(gnus)Customizing Articles")
1295 :type gnus-article-treat-head-custom
)
1297 (defcustom gnus-treat-date-original nil
1298 "Display the date in the original timezone.
1299 Valid values are nil, t, `head', `first', `last', an integer or a
1300 predicate. See Info node `(gnus)Customizing Articles'."
1301 :group
'gnus-article-treat
1302 :link
'(custom-manual "(gnus)Customizing Articles")
1303 :type gnus-article-treat-head-custom
)
1305 (defcustom gnus-treat-date-iso8601 nil
1306 "Display the date in the ISO8601 format.
1307 Valid values are nil, t, `head', `first', `last', an integer or a
1308 predicate. See Info node `(gnus)Customizing Articles'."
1310 :group
'gnus-article-treat
1311 :link
'(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-head-custom
)
1314 (defcustom gnus-treat-date-user-defined nil
1315 "Display the date in a user-defined format.
1316 The format is defined by the `gnus-article-time-format' variable.
1317 Valid values are nil, t, `head', `first', `last', an integer or a
1318 predicate. See Info node `(gnus)Customizing Articles'."
1319 :group
'gnus-article-treat
1320 :link
'(custom-manual "(gnus)Customizing Articles")
1321 :type gnus-article-treat-head-custom
)
1323 (defcustom gnus-treat-strip-headers-in-body t
1324 "Strip the X-No-Archive header line from the beginning of the body.
1325 Valid values are nil, t, `head', `first', `last', an integer or a
1326 predicate. See Info node `(gnus)Customizing Articles'."
1328 :group
'gnus-article-treat
1329 :link
'(custom-manual "(gnus)Customizing Articles")
1330 :type gnus-article-treat-custom
)
1332 (defcustom gnus-treat-strip-trailing-blank-lines nil
1333 "Strip trailing blank lines.
1334 Valid values are nil, t, `head', `first', `last', an integer or a
1335 predicate. See Info node `(gnus)Customizing Articles'.
1337 When set to t, it also strips trailing blanks in all MIME parts.
1338 Consider to use `last' instead."
1339 :group
'gnus-article-treat
1340 :link
'(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom
)
1343 (defcustom gnus-treat-strip-leading-blank-lines nil
1344 "Strip leading blank lines.
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'.
1348 When set to t, it also strips trailing blanks in all MIME parts."
1349 :group
'gnus-article-treat
1350 :link
'(custom-manual "(gnus)Customizing Articles")
1351 :type gnus-article-treat-custom
)
1353 (defcustom gnus-treat-strip-multiple-blank-lines nil
1354 "Strip multiple blank lines.
1355 Valid values are nil, t, `head', `first', `last', an integer or a
1356 predicate. See Info node `(gnus)Customizing Articles'."
1357 :group
'gnus-article-treat
1358 :link
'(custom-manual "(gnus)Customizing Articles")
1359 :type gnus-article-treat-custom
)
1361 (defcustom gnus-treat-unfold-headers
'head
1362 "Unfold folded header lines.
1363 Valid values are nil, t, `head', `first', `last', an integer or a
1364 predicate. See Info node `(gnus)Customizing Articles'."
1366 :group
'gnus-article-treat
1367 :link
'(custom-manual "(gnus)Customizing Articles")
1368 :type gnus-article-treat-custom
)
1370 (defcustom gnus-article-unfold-long-headers nil
1371 "If non-nil, allow unfolding headers even if the header is long.
1372 If it is a regexp, only long headers matching this regexp are unfolded.
1373 If it is t, all long headers are unfolded.
1375 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1376 :version
"23.1" ;; No Gnus
1377 :group
'gnus-article-treat
1378 :type
'(choice (const nil
)
1379 (const :tag
"all" t
)
1382 (defcustom gnus-treat-fold-headers nil
1384 Valid values are nil, t, `head', `first', `last', an integer or a
1385 predicate. See Info node `(gnus)Customizing Articles'."
1387 :group
'gnus-article-treat
1388 :link
'(custom-manual "(gnus)Customizing Articles")
1389 :type gnus-article-treat-custom
)
1391 (defcustom gnus-treat-fold-newsgroups
'head
1392 "Fold the Newsgroups and Followup-To headers.
1393 Valid values are nil, t, `head', `first', `last', an integer or a
1394 predicate. See Info node `(gnus)Customizing Articles'."
1396 :group
'gnus-article-treat
1397 :link
'(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom
)
1400 (defcustom gnus-treat-overstrike t
1401 "Treat overstrike highlighting.
1402 Valid values are nil, t, `head', `first', `last', an integer or a
1403 predicate. See Info node `(gnus)Customizing Articles'."
1404 :group
'gnus-article-treat
1405 :link
'(custom-manual "(gnus)Customizing Articles")
1406 :type gnus-article-treat-custom
)
1407 (put 'gnus-treat-overstrike
'highlight t
)
1409 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1410 "Treat ANSI SGR control sequences.
1411 Valid values are nil, t, `head', `first', `last', an integer or a
1412 predicate. See Info node `(gnus)Customizing Articles'."
1413 :group
'gnus-article-treat
1414 :link
'(custom-manual "(gnus)Customizing Articles")
1415 :type gnus-article-treat-custom
)
1417 (make-obsolete-variable 'gnus-treat-display-xface
1418 'gnus-treat-display-x-face
"22.1")
1420 (defcustom gnus-treat-display-x-face
1421 (and (not noninteractive
)
1422 (gnus-image-type-available-p 'xbm
)
1423 (if (featurep 'xemacs
)
1426 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1427 (executable-find "icontopbm"))
1428 ;; shell-command-to-string may signal an error, e.g. if
1429 ;; shell-file-name is not found.
1432 "Display X-Face headers.
1433 Valid values are nil and `head'.
1434 See Info node `(gnus)Customizing Articles' and Info node
1435 `(gnus)X-Face' for details."
1436 :group
'gnus-article-treat
1438 :link
'(custom-manual "(gnus)Customizing Articles")
1439 :link
'(custom-manual "(gnus)X-Face")
1440 :type gnus-article-treat-head-custom
1441 :set
(lambda (symbol value
)
1444 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1446 ((boundp 'gnus-treat-display-xface
)
1448 ** gnus-treat-display-xface is an obsolete variable;\
1449 use gnus-treat-display-x-face instead")
1450 (default-value 'gnus-treat-display-xface
))
1451 ((get 'gnus-treat-display-xface
'saved-value
)
1453 ** gnus-treat-display-xface is an obsolete variable;\
1454 use gnus-treat-display-x-face instead")
1455 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1458 (put 'gnus-treat-display-x-face
'highlight t
)
1460 (defcustom gnus-treat-display-face
1461 (and (not noninteractive
)
1462 (gnus-image-type-available-p 'png
)
1464 "Display Face headers.
1465 Valid values are nil, t, `head', `first', `last', an integer or a
1466 predicate. See Info node `(gnus)Customizing Articles' and Info
1467 node `(gnus)Face' for details."
1468 :group
'gnus-article-treat
1470 :link
'(custom-manual "(gnus)Customizing Articles")
1471 :link
'(custom-manual "(gnus)X-Face")
1472 :type gnus-article-treat-head-custom
)
1473 (put 'gnus-treat-display-face
'highlight t
)
1475 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1477 Valid values are nil, t, `head', `first', `last', an integer or a
1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1479 node `(gnus)Smileys' for details."
1480 :group
'gnus-article-treat
1482 :link
'(custom-manual "(gnus)Customizing Articles")
1483 :link
'(custom-manual "(gnus)Smileys")
1484 :type gnus-article-treat-custom
)
1485 (put 'gnus-treat-display-smileys
'highlight t
)
1487 (defcustom gnus-treat-from-picon
1488 (if (and (gnus-image-type-available-p 'xpm
)
1489 (gnus-picons-installed-p))
1491 "Display picons in the From header.
1492 Valid values are nil, t, `head', `first', `last', an integer or a
1493 predicate. See Info node `(gnus)Customizing Articles' and Info
1494 node `(gnus)Picons' for details."
1496 :group
'gnus-article-treat
1498 :link
'(custom-manual "(gnus)Customizing Articles")
1499 :link
'(custom-manual "(gnus)Picons")
1500 :type gnus-article-treat-head-custom
)
1501 (put 'gnus-treat-from-picon
'highlight t
)
1503 (defcustom gnus-treat-mail-picon
1504 (if (and (gnus-image-type-available-p 'xpm
)
1505 (gnus-picons-installed-p))
1507 "Display picons in To and Cc headers.
1508 Valid values are nil, t, `head', `first', `last', an integer or a
1509 predicate. See Info node `(gnus)Customizing Articles' and Info
1510 node `(gnus)Picons' for details."
1512 :group
'gnus-article-treat
1514 :link
'(custom-manual "(gnus)Customizing Articles")
1515 :link
'(custom-manual "(gnus)Picons")
1516 :type gnus-article-treat-head-custom
)
1517 (put 'gnus-treat-mail-picon
'highlight t
)
1519 (defcustom gnus-treat-newsgroups-picon
1520 (if (and (gnus-image-type-available-p 'xpm
)
1521 (gnus-picons-installed-p))
1523 "Display picons in the Newsgroups and Followup-To headers.
1524 Valid values are nil, t, `head', `first', `last', an integer or a
1525 predicate. See Info node `(gnus)Customizing Articles' and Info
1526 node `(gnus)Picons' for details."
1528 :group
'gnus-article-treat
1530 :link
'(custom-manual "(gnus)Customizing Articles")
1531 :link
'(custom-manual "(gnus)Picons")
1532 :type gnus-article-treat-head-custom
)
1533 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1535 (defcustom gnus-treat-body-boundary
1536 (if (or gnus-treat-newsgroups-picon
1537 gnus-treat-mail-picon
1538 gnus-treat-from-picon
)
1539 ;; If there's much decoration, the user might prefer a boundery.
1542 "Draw a boundary at the end of the headers.
1543 Valid values are nil and `head'.
1544 See Info node `(gnus)Customizing Articles' for details."
1546 :group
'gnus-article-treat
1547 :link
'(custom-manual "(gnus)Customizing Articles")
1548 :type gnus-article-treat-head-custom
)
1550 (defcustom gnus-treat-capitalize-sentences nil
1551 "Capitalize sentence-starting words.
1552 Valid values are nil, t, `head', `first', `last', an integer or a
1553 predicate. See Info node `(gnus)Customizing Articles'."
1555 :group
'gnus-article-treat
1556 :link
'(custom-manual "(gnus)Customizing Articles")
1557 :type gnus-article-treat-custom
)
1559 (defcustom gnus-treat-wash-html nil
1561 Valid values are nil, t, `head', `first', `last', an integer or a
1562 predicate. See Info node `(gnus)Customizing Articles'."
1564 :group
'gnus-article-treat
1565 :link
'(custom-manual "(gnus)Customizing Articles")
1566 :type gnus-article-treat-custom
)
1568 (defcustom gnus-treat-fill-long-lines nil
1570 Valid values are nil, t, `head', `first', `last', an integer or a
1571 predicate. See Info node `(gnus)Customizing Articles'."
1572 :group
'gnus-article-treat
1573 :link
'(custom-manual "(gnus)Customizing Articles")
1574 :type gnus-article-treat-custom
)
1576 (defcustom gnus-treat-play-sounds nil
1578 Valid values are nil, t, `head', `first', `last', an integer or a
1579 predicate. See Info node `(gnus)Customizing Articles'."
1581 :group
'gnus-article-treat
1582 :link
'(custom-manual "(gnus)Customizing Articles")
1583 :type gnus-article-treat-custom
)
1585 (defcustom gnus-treat-translate nil
1586 "Translate articles from one language to another.
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 :link
'(custom-manual "(gnus)Customizing Articles")
1592 :type gnus-article-treat-custom
)
1594 (defcustom gnus-treat-x-pgp-sig nil
1596 To automatically treat X-PGP-Sig, set it to head.
1597 Valid values are nil, t, `head', `first', `last', an integer or a
1598 predicate. See Info node `(gnus)Customizing Articles'."
1600 :group
'gnus-article-treat
1601 :group
'mime-security
1602 :link
'(custom-manual "(gnus)Customizing Articles")
1603 :type gnus-article-treat-custom
)
1605 (defvar gnus-article-encrypt-protocol-alist
1606 '(("PGP" . mml2015-self-encrypt
)))
1608 ;; Set to nil if more than one protocol added to
1609 ;; gnus-article-encrypt-protocol-alist.
1610 (defcustom gnus-article-encrypt-protocol
"PGP"
1611 "The protocol used for encrypt articles.
1612 It is a string, such as \"PGP\". If nil, ask user."
1615 :group
'mime-security
)
1617 (defvar gnus-article-wash-function nil
1618 "Function used for converting HTML into text.")
1620 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1621 (mm-coding-system-p 'utf-8
)
1622 (executable-find idna-program
))
1623 "Whether IDNA decoding of headers is used when viewing messages.
1624 This requires GNU Libidn, and by default only enabled if it is found."
1626 :group
'gnus-article-headers
1629 (defcustom gnus-article-over-scroll nil
1630 "If non-nil, allow scrolling the article buffer even when there no more text."
1632 :group
'gnus-article
1635 ;;; Internal variables
1637 (defvar gnus-english-month-names
1638 '("January" "February" "March" "April" "May" "June" "July" "August"
1639 "September" "October" "November" "December"))
1641 (defvar article-goto-body-goes-to-point-min-p nil
)
1642 (defvar gnus-article-wash-types nil
)
1643 (defvar gnus-article-emphasis-alist nil
)
1644 (defvar gnus-article-image-alist nil
)
1646 (defvar gnus-article-mime-handle-alist-1 nil
)
1647 (defvar gnus-treatment-function-alist
1648 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1649 (gnus-treat-strip-banner gnus-article-strip-banner
)
1650 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1651 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1652 (gnus-treat-buttonize gnus-article-add-buttons
)
1653 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1654 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1655 (gnus-treat-strip-cr gnus-article-remove-cr
)
1656 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1657 (gnus-treat-date-ut gnus-article-date-ut
)
1658 (gnus-treat-date-local gnus-article-date-local
)
1659 (gnus-treat-date-english gnus-article-date-english
)
1660 (gnus-treat-date-original gnus-article-date-original
)
1661 (gnus-treat-date-user-defined gnus-article-date-user
)
1662 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1663 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1664 (gnus-treat-display-x-face gnus-article-display-x-face
)
1665 (gnus-treat-display-face gnus-article-display-face
)
1666 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1667 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1668 (gnus-treat-hide-signature gnus-article-hide-signature
)
1669 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1670 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1671 (gnus-treat-strip-pem gnus-article-hide-pem
)
1672 (gnus-treat-from-picon gnus-treat-from-picon
)
1673 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1674 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1675 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1676 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1677 (gnus-treat-strip-trailing-blank-lines
1678 gnus-article-remove-trailing-blank-lines
)
1679 (gnus-treat-strip-leading-blank-lines
1680 gnus-article-strip-leading-blank-lines
)
1681 (gnus-treat-strip-multiple-blank-lines
1682 gnus-article-strip-multiple-blank-lines
)
1683 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1684 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1685 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1686 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1687 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1688 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1689 (gnus-treat-display-smileys gnus-treat-smiley
)
1690 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1691 (gnus-treat-wash-html gnus-article-wash-html
)
1692 (gnus-treat-emphasize gnus-article-emphasize
)
1693 (gnus-treat-hide-citation gnus-article-hide-citation
)
1694 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1695 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1696 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)
1697 (gnus-treat-play-sounds gnus-earcon-display
)))
1699 (defvar gnus-article-mime-handle-alist nil
)
1700 (defvar article-lapsed-timer nil
)
1701 (defvar gnus-article-current-summary nil
)
1703 (defvar gnus-article-mode-syntax-table
1704 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1705 ;; This causes the citation match run O(2^n).
1706 ;; (modify-syntax-entry ?- "w" table)
1707 (modify-syntax-entry ?
> ")<" table
)
1708 (modify-syntax-entry ?
< "(>" table
)
1709 ;; make M-. in article buffers work for `foo' strings
1710 (modify-syntax-entry ?
' " " table
)
1711 (modify-syntax-entry ?
` " " table
)
1713 "Syntax table used in article mode buffers.
1714 Initialized from `text-mode-syntax-table.")
1716 (defvar gnus-save-article-buffer nil
)
1718 (defvar gnus-number-of-articles-to-be-saved nil
)
1720 (defvar gnus-inhibit-hiding nil
)
1722 (defvar gnus-article-edit-mode nil
)
1724 ;;; Macros for dealing with the article buffer.
1726 (defmacro gnus-with-article-headers
(&rest forms
)
1727 `(with-current-buffer gnus-article-buffer
1729 (let ((inhibit-read-only t
)
1730 (inhibit-point-motion-hooks t
)
1731 (case-fold-search t
))
1732 (article-narrow-to-head)
1735 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1736 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1738 (defmacro gnus-with-article-buffer
(&rest forms
)
1739 `(with-current-buffer gnus-article-buffer
1740 (let ((inhibit-read-only t
))
1743 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1744 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1746 (defun gnus-article-goto-header (header)
1747 "Go to HEADER, which is a regular expression."
1748 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1750 (defsubst gnus-article-hide-text
(b e props
)
1751 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1752 (gnus-add-text-properties-when 'article-type nil b e props
)
1753 (when (memq 'intangible props
)
1755 (max (1- b
) (point-min))
1756 b
'intangible
(cddr (memq 'intangible props
)))))
1758 (defsubst gnus-article-unhide-text
(b e
)
1759 "Remove hidden text properties from region between B and E."
1760 (remove-text-properties b e gnus-hidden-properties
)
1761 (when (memq 'intangible gnus-hidden-properties
)
1762 (put-text-property (max (1- b
) (point-min))
1763 b
'intangible nil
)))
1765 (defun gnus-article-hide-text-type (b e type
)
1766 "Hide text of TYPE between B and E."
1767 (gnus-add-wash-type type
)
1768 (gnus-article-hide-text
1769 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1771 (defun gnus-article-unhide-text-type (b e type
)
1772 "Unhide text of TYPE between B and E."
1773 (gnus-delete-wash-type type
)
1774 (remove-text-properties
1775 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1776 (when (memq 'intangible gnus-hidden-properties
)
1777 (put-text-property (max (1- b
) (point-min))
1778 b
'intangible nil
)))
1780 (defun gnus-article-hide-text-of-type (type)
1781 "Hide text of TYPE in the current buffer."
1783 (let ((b (point-min))
1785 (while (setq b
(text-property-any b e
'article-type type
))
1786 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1788 (defun gnus-article-delete-text-of-type (type)
1789 "Delete text of TYPE in the current buffer."
1791 (let ((b (point-min)))
1792 (if (eq type
'multipart
)
1793 ;; Remove MIME buttons associated with multipart/alternative parts.
1796 (while (if (get-text-property (point) 'gnus-part
)
1798 (when (setq b
(next-single-property-change (point)
1803 (skip-chars-forward "\n")
1804 (when (eq (get-text-property b
'article-type
) 'multipart
)
1805 (delete-region b
(point)))))
1806 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1808 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1811 (defun gnus-article-delete-invisible-text ()
1812 "Delete all invisible text in the current buffer."
1814 (let ((b (point-min)))
1815 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1817 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1820 (defun gnus-article-text-type-exists-p (type)
1821 "Say whether any text of type TYPE exists in the buffer."
1822 (text-property-any (point-min) (point-max) 'article-type type
))
1824 (defsubst gnus-article-header-rank
()
1825 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1826 (let ((list gnus-sorted-header-list
)
1829 (if (looking-at (car list
))
1831 (setq list
(cdr list
))
1835 (defun article-hide-headers (&optional arg delete
)
1836 "Hide unwanted headers and possibly sort them as well."
1838 ;; This function might be inhibited.
1839 (unless gnus-inhibit-hiding
1840 (let ((inhibit-read-only t
)
1841 (case-fold-search t
)
1842 (max (1+ (length gnus-sorted-header-list
)))
1843 (inhibit-point-motion-hooks t
)
1844 (cur (current-buffer))
1845 ignored visible beg
)
1847 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1848 ;; group parameters, so we should go to the summary buffer.
1851 (progn (set-buffer gnus-summary-buffer
) t
)
1853 (setq ignored
(when (not gnus-visible-headers
)
1854 (cond ((stringp gnus-ignored-headers
)
1855 gnus-ignored-headers
)
1856 ((listp gnus-ignored-headers
)
1857 (mapconcat 'identity
1858 gnus-ignored-headers
1860 visible
(cond ((stringp gnus-visible-headers
)
1861 gnus-visible-headers
)
1862 ((and gnus-visible-headers
1863 (listp gnus-visible-headers
))
1864 (mapconcat 'identity
1865 gnus-visible-headers
1869 ;; First we narrow to just the headers.
1870 (article-narrow-to-head)
1871 ;; Hide any "From " lines at the beginning of (mail) articles.
1872 (while (looking-at "From ")
1875 (delete-region (point-min) (point)))
1876 ;; Then treat the rest of the header lines.
1877 ;; Then we use the two regular expressions
1878 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1879 ;; select which header lines is to remain visible in the
1881 (while (re-search-forward "^[^ \t:]*:" nil t
)
1883 ;; Mark the rank of the header.
1885 (point) (1+ (point)) 'message-rank
1886 (if (or (and visible
(looking-at visible
))
1888 (not (looking-at ignored
))))
1889 (gnus-article-header-rank)
1892 (message-sort-headers-1)
1893 (when (setq beg
(text-property-any
1894 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1895 ;; We delete the unwanted headers.
1896 (gnus-add-wash-type 'headers
)
1897 (add-text-properties (point-min) (+ 5 (point-min))
1898 '(article-type headers dummy-invisible t
))
1899 (delete-region beg
(point-max))))))))
1901 (defun article-hide-boring-headers (&optional arg
)
1902 "Toggle hiding of headers that aren't very interesting.
1903 If given a negative prefix, always show; if given a positive prefix,
1905 (interactive (gnus-article-hidden-arg))
1906 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1907 (not gnus-show-all-headers
))
1910 (let ((inhibit-read-only t
)
1911 (inhibit-point-motion-hooks t
))
1912 (article-narrow-to-head)
1913 (dolist (elem gnus-boring-article-headers
)
1914 (goto-char (point-min))
1916 ;; Hide empty headers.
1918 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1920 (gnus-article-hide-text-type
1924 (if (re-search-forward "^[^ \t]" nil t
)
1928 ;; Hide boring Newsgroups header.
1929 ((eq elem
'newsgroups
)
1930 (when (gnus-string-equal
1931 (gnus-fetch-field "newsgroups")
1932 (gnus-group-real-name
1933 (if (boundp 'gnus-newsgroup-name
)
1936 (gnus-article-hide-header "newsgroups")))
1937 ((eq elem
'to-address
)
1938 (let ((to (message-fetch-field "to"))
1940 (gnus-parameter-to-address
1941 (if (boundp 'gnus-newsgroup-name
)
1942 gnus-newsgroup-name
""))))
1943 (when (and to to-address
1946 ;; only one address in To
1947 (nth 1 (mail-extract-address-components to
))
1949 (gnus-article-hide-header "to"))))
1951 (let ((to (message-fetch-field "to"))
1953 (gnus-parameter-to-list
1954 (if (boundp 'gnus-newsgroup-name
)
1955 gnus-newsgroup-name
""))))
1956 (when (and to to-list
1959 ;; only one address in To
1960 (nth 1 (mail-extract-address-components to
))
1962 (gnus-article-hide-header "to"))))
1964 (let ((cc (message-fetch-field "cc"))
1966 (gnus-parameter-to-list
1967 (if (boundp 'gnus-newsgroup-name
)
1968 gnus-newsgroup-name
""))))
1969 (when (and cc to-list
1972 ;; only one address in CC
1973 (nth 1 (mail-extract-address-components cc
))
1975 (gnus-article-hide-header "cc"))))
1976 ((eq elem
'followup-to
)
1977 (when (gnus-string-equal
1978 (message-fetch-field "followup-to")
1979 (message-fetch-field "newsgroups"))
1980 (gnus-article-hide-header "followup-to")))
1981 ((eq elem
'reply-to
)
1982 (if (gnus-group-find-parameter
1983 gnus-newsgroup-name
'broken-reply-to
)
1984 (gnus-article-hide-header "reply-to")
1985 (let ((from (message-fetch-field "from"))
1986 (reply-to (message-fetch-field "reply-to")))
1993 (lambda (x) (downcase (cadr x
)))
1994 (mail-extract-address-components from t
))
1997 (lambda (x) (downcase (cadr x
)))
1998 (mail-extract-address-components reply-to t
))
2000 (gnus-article-hide-header "reply-to")))))
2002 (let ((date (with-current-buffer gnus-original-article-buffer
2003 ;; If date in `gnus-article-buffer' is localized
2004 ;; (`gnus-treat-date-user-defined'),
2005 ;; `days-between' might fail.
2006 (message-fetch-field "date"))))
2008 (< (days-between (current-time-string) date
)
2010 (gnus-article-hide-header "date"))))
2012 (let ((to (message-fetch-field "to"))
2013 (cc (message-fetch-field "cc")))
2014 (when (> (length to
) 1024)
2015 (gnus-article-hide-header "to"))
2016 (when (> (length cc
) 1024)
2017 (gnus-article-hide-header "cc"))))
2021 (goto-char (point-min))
2022 (while (re-search-forward "^to:" nil t
)
2023 (setq to-count
(1+ to-count
)))
2024 (when (> to-count
1)
2025 (while (> to-count
0)
2026 (goto-char (point-min))
2028 (re-search-forward "^to:" nil nil to-count
)
2030 (narrow-to-region (point) (point-max))
2031 (gnus-article-hide-header "to"))
2032 (setq to-count
(1- to-count
))))
2033 (goto-char (point-min))
2034 (while (re-search-forward "^cc:" nil t
)
2035 (setq cc-count
(1+ cc-count
)))
2036 (when (> cc-count
1)
2037 (while (> cc-count
0)
2038 (goto-char (point-min))
2040 (re-search-forward "^cc:" nil nil cc-count
)
2042 (narrow-to-region (point) (point-max))
2043 (gnus-article-hide-header "cc"))
2044 (setq cc-count
(1- cc-count
)))))))))))))
2046 (defun gnus-article-hide-header (header)
2048 (goto-char (point-min))
2049 (when (re-search-forward (concat "^" header
":") nil t
)
2050 (gnus-article-hide-text-type
2054 (if (re-search-forward "^[^ \t]" nil t
)
2059 (defvar gnus-article-normalized-header-length
40
2060 "Length of normalized headers.")
2062 (defun article-normalize-headers ()
2063 "Make all header lines 40 characters long."
2065 (let ((inhibit-read-only t
)
2069 (article-narrow-to-head)
2072 ((< (setq column
(- (point-at-eol) (point)))
2073 gnus-article-normalized-header-length
)
2075 (insert (make-string
2076 (- gnus-article-normalized-header-length column
)
2078 ((> column gnus-article-normalized-header-length
)
2079 (gnus-put-text-property
2081 (forward-char gnus-article-normalized-header-length
)
2088 (forward-line 1))))))
2090 (defun article-treat-dumbquotes ()
2091 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2092 Note that this function guesses whether a character is a sm*rtq**t* or
2093 not, so it should only be used interactively.
2095 Sm*rtq**t*s are M****s***'s unilateral extension to the
2096 iso-8859-1 character map in an attempt to provide more quoting
2097 characters. If you see something like \\222 or \\264 where
2098 you're expecting some kind of apostrophe or quotation mark, then
2101 (article-translate-strings gnus-article-dumbquotes-map
))
2103 (defun article-translate-characters (from to
)
2104 "Translate all characters in the body of the article according to FROM and TO.
2105 FROM is a string of characters to translate from; to is a string of
2106 characters to translate to."
2108 (when (article-goto-body)
2109 (let ((inhibit-read-only t
)
2110 (x (make-string 225 ?x
))
2112 (while (< (incf i
) (length x
))
2115 (while (< i
(length from
))
2116 (aset x
(aref from i
) (aref to i
))
2118 (translate-region (point) (point-max) x
)))))
2120 (defun article-translate-strings (map)
2121 "Translate all string in the body of the article according to MAP.
2122 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2124 (when (article-goto-body)
2125 (let ((inhibit-read-only t
))
2128 (while (search-forward (car elem
) nil t
)
2129 (replace-match (cadr elem
)))))))))
2131 (defun article-treat-overstrike ()
2132 "Translate overstrikes into bold text."
2135 (when (article-goto-body)
2136 (let ((inhibit-read-only t
))
2137 (while (search-forward "\b" nil t
)
2138 (let ((next (char-after))
2139 (previous (char-after (- (point) 2))))
2140 ;; We do the boldification/underlining by hiding the
2141 ;; overstrikes and putting the proper text property
2145 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2146 (put-text-property (point) (1+ (point)) 'face
'bold
))
2148 (gnus-article-hide-text-type
2149 (1- (point)) (1+ (point)) 'overstrike
)
2151 (- (point) 2) (1- (point)) 'face
'underline
))
2153 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2155 (point) (1+ (point)) 'face
'underline
)))))))))
2157 (defun article-treat-ansi-sequences ()
2158 "Translate ANSI SGR control sequences into overlays or extents."
2161 (when (article-goto-body)
2162 (let ((inhibit-read-only t
))
2163 (ansi-color-apply-on-region (point) (point-max))))))
2165 (defun gnus-article-treat-unfold-headers ()
2166 "Unfold folded message headers.
2167 Only the headers that fit into the current window width will be
2170 (gnus-with-article-headers
2174 (mail-header-narrow-to-field)
2175 (let* ((header (buffer-string))
2177 (or (equal gnus-article-unfold-long-headers t
)
2178 (and (stringp gnus-article-unfold-long-headers
)
2179 (string-match gnus-article-unfold-long-headers header
)))))
2182 (goto-char (point-min))
2183 (while (re-search-forward "\n[\t ]" nil t
)
2184 (replace-match " " t t
)))
2185 (setq length
(- (point-max) (point-min) 1))
2186 (when (or unfoldable
2187 (< length
(window-width)))
2188 (while (re-search-forward "\n[\t ]" nil t
)
2189 (replace-match " " t t
))))
2190 (goto-char (point-max)))))))
2192 (defun gnus-article-treat-fold-headers ()
2193 "Fold message headers."
2195 (gnus-with-article-headers
2198 (mail-header-narrow-to-field)
2199 (mail-header-fold-field)
2200 (goto-char (point-max))))))
2202 (defun gnus-treat-smiley ()
2203 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2205 (gnus-with-article-buffer
2206 (if (memq 'smiley gnus-article-wash-types
)
2207 (gnus-delete-images 'smiley
)
2209 (let ((images (smiley-region (point) (point-max))))
2211 (gnus-add-wash-type 'smiley
)
2212 (dolist (image images
)
2213 (gnus-add-image 'smiley image
)))))))
2215 (defun gnus-article-remove-images ()
2216 "Remove all images from the article buffer."
2218 (gnus-with-article-buffer
2219 (dolist (elem gnus-article-image-alist
)
2220 (gnus-delete-images (car elem
)))))
2222 (defun gnus-article-treat-fold-newsgroups ()
2223 "Unfold folded message headers.
2224 Only the headers that fit into the current window width will be
2227 (gnus-with-article-headers
2228 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2230 (mail-header-narrow-to-field)
2231 (while (re-search-forward ", *" nil t
)
2232 (replace-match ", " t t
))
2233 (mail-header-fold-field)
2234 (goto-char (point-max))))))
2236 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2237 "Value of `truncate-lines' in Gnus Article buffer.
2238 Valid values are nil, t, `head', `first', `last', an integer or a
2239 predicate. See Info node `(gnus)Customizing Articles'."
2240 :version
"23.1" ;; No Gnus
2241 :group
'gnus-article
2242 ;; :link '(custom-manual "(gnus)Customizing Articles")
2245 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2246 "Toggle whether to fold or truncate long lines in article the buffer.
2247 If ARG is non-nil and not a number, toggle
2248 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2249 long lines if and only if arg is positive."
2252 ((and (numberp arg
) (> arg
0))
2253 (setq gnus-article-truncate-lines t
))
2255 (setq gnus-article-truncate-lines nil
))
2257 (setq gnus-article-truncate-lines
2258 (not gnus-article-truncate-lines
))))
2259 (gnus-with-article-buffer
2261 ((and (numberp arg
) (> arg
0))
2262 (setq truncate-lines nil
))
2264 (setq truncate-lines t
)))
2265 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2266 ;; `toggle-truncate-lines' needs an argument.
2267 (toggle-truncate-lines)))
2269 (defun gnus-article-treat-body-boundary ()
2270 "Place a boundary line at the end of the headers."
2272 (when (and gnus-body-boundary-delimiter
2273 (> (length gnus-body-boundary-delimiter
) 0))
2274 (gnus-with-article-headers
2275 (goto-char (point-max))
2276 (let ((start (point)))
2277 (insert "X-Boundary: ")
2278 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2280 (while (>= (1- (window-width)) (length str
))
2281 (setq str
(concat str gnus-body-boundary-delimiter
)))
2282 (substring str
0 (1- (window-width))))
2284 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2286 (defun article-fill-long-lines ()
2287 "Fill lines that are wider than the window width."
2290 (let ((inhibit-read-only t
)
2291 (width (window-width (get-buffer-window (current-buffer)))))
2294 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2297 (when (>= (current-column) (min fill-column width
))
2298 (narrow-to-region (min (1+ (point)) (point-max))
2300 (let ((goback (point-marker)))
2301 (fill-paragraph nil
)
2302 (goto-char (marker-position goback
)))
2304 (forward-line 1)))))))
2306 (defun article-capitalize-sentences ()
2307 "Capitalize the first word in each sentence."
2310 (let ((inhibit-read-only t
)
2311 (paragraph-start "^[\n\^L]"))
2315 (forward-sentence)))))
2317 (defun article-remove-cr ()
2318 "Remove trailing CRs and then translate remaining CRs into LFs."
2321 (let ((inhibit-read-only t
))
2322 (goto-char (point-min))
2323 (while (re-search-forward "\r+$" nil t
)
2324 (replace-match "" t t
))
2325 (goto-char (point-min))
2326 (while (search-forward "\r" nil t
)
2327 (replace-match "\n" t t
)))))
2329 (defun article-remove-trailing-blank-lines ()
2330 "Remove all trailing blank lines from the article."
2333 (let ((inhibit-read-only t
))
2334 (goto-char (point-max))
2338 (while (and (not (bobp))
2339 (looking-at "^[ \t]*$")
2340 (not (gnus-annotation-in-region-p
2341 (point) (point-at-eol))))
2346 (defvar gnus-face-properties-alist
)
2348 (defun article-display-face (&optional force
)
2349 "Display any Face headers in the header."
2350 (interactive (list 'force
))
2351 (let ((wash-face-p buffer-read-only
))
2352 (gnus-with-article-headers
2353 ;; When displaying parts, this function can be called several times on
2354 ;; the same article, without any intended toggle semantic (as typing `W
2355 ;; D d' would have). So face deletion must occur only when we come from
2356 ;; an interactive command, that is when the *Article* buffer is
2358 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2359 (gnus-delete-images 'face
)
2360 (let ((from (message-fetch-field "from"))
2362 (save-current-buffer
2363 (when (and wash-face-p
2364 (gnus-buffer-live-p gnus-original-article-buffer
)
2365 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2366 (set-buffer gnus-original-article-buffer
))
2368 (mail-narrow-to-head)
2370 ;; Check whether this face is censored.
2371 (not (and gnus-article-x-face-too-ugly
2373 (setq from
(message-fetch-field "from")))
2374 (string-match gnus-article-x-face-too-ugly
2376 (while (gnus-article-goto-header "Face")
2377 (push (mail-header-field-value) faces
)))))
2379 (goto-char (point-min))
2381 (unless (setq from
(gnus-article-goto-header "from"))
2384 (insert " [no `from' set]\n"))
2386 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2388 (apply 'gnus-create-image png
'png t
2389 (cdr (assq 'png gnus-face-properties-alist
))))
2391 (gnus-add-wash-type 'face
)
2392 (gnus-add-image 'face image
)
2393 (gnus-put-image image nil
'face
))))))))))
2395 (defun article-display-x-face (&optional force
)
2396 "Look for an X-Face header and display it if present."
2397 (interactive (list 'force
))
2398 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2399 (gnus-with-article-headers
2400 ;; Delete the old process, if any.
2401 (when (process-status "article-x-face")
2402 (delete-process "article-x-face"))
2403 ;; See the comment in `article-display-face'.
2404 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2405 ;; We have already displayed X-Faces, so we remove them
2407 (gnus-delete-images 'xface
)
2409 (let ((from (message-fetch-field "from"))
2411 (save-current-buffer
2412 (when (and wash-face-p
2413 (gnus-buffer-live-p gnus-original-article-buffer
)
2414 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2415 ;; If type `W f', use gnus-original-article-buffer,
2416 ;; otherwise use the current buffer because displaying
2417 ;; RFC822 parts calls this function too.
2418 (set-buffer gnus-original-article-buffer
))
2420 (mail-narrow-to-head)
2421 (and gnus-article-x-face-command
2423 ;; Check whether this face is censored.
2424 (not (and gnus-article-x-face-too-ugly
2426 (setq from
(message-fetch-field "from")))
2427 (string-match gnus-article-x-face-too-ugly
2429 (while (gnus-article-goto-header "X-Face")
2430 (push (mail-header-field-value) x-faces
)))))
2432 ;; We display the face.
2433 (cond ((functionp gnus-article-x-face-command
)
2434 ;; The command is a lisp function, so we call it.
2435 (mapc gnus-article-x-face-command x-faces
))
2436 ((stringp gnus-article-x-face-command
)
2437 ;; The command is a string, so we interpret the command
2438 ;; as a, well, command, and fork it off.
2439 (let ((process-connection-type nil
))
2440 (gnus-set-process-query-on-exit-flag
2442 "article-x-face" nil shell-file-name
2443 shell-command-switch gnus-article-x-face-command
)
2445 ;; Sending multiple EOFs to xv doesn't work,
2446 ;; so we only do a single external face.
2448 (insert (car x-faces
))
2449 (process-send-region "article-x-face"
2450 (point-min) (point-max)))
2451 (process-send-eof "article-x-face")))
2453 (error "`%s' set to `%s' is not a function"
2454 gnus-article-x-face-command
2455 'gnus-article-x-face-command
)))))))))
2457 (defun article-decode-mime-words ()
2458 "Decode all MIME-encoded words in the article."
2460 (gnus-with-article-buffer
2461 (let ((inhibit-point-motion-hooks t
)
2462 (mail-parse-charset gnus-newsgroup-charset
)
2463 (mail-parse-ignored-charsets
2464 (with-current-buffer gnus-summary-buffer
2465 gnus-newsgroup-ignored-charsets
)))
2466 (mail-decode-encoded-word-region (point-min) (point-max)))))
2468 (defun article-decode-charset (&optional prompt
)
2469 "Decode charset-encoded text in the article.
2470 If PROMPT (the prefix), prompt for a coding system to use."
2472 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2473 (inhibit-read-only t
)
2474 (mail-parse-charset gnus-newsgroup-charset
)
2475 (mail-parse-ignored-charsets
2476 (save-excursion (condition-case nil
2477 (set-buffer gnus-summary-buffer
)
2479 gnus-newsgroup-ignored-charsets
))
2480 ct cte ctl charset format
)
2483 (article-narrow-to-head)
2484 (setq ct
(message-fetch-field "Content-Type" t
)
2485 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2486 ctl
(and ct
(mail-header-parse-content-type ct
))
2489 (mm-read-coding-system "Charset to decode: "))
2491 (mail-content-type-get ctl
'charset
)))
2492 format
(and ctl
(mail-content-type-get ctl
'format
)))
2494 (setq cte
(mail-header-strip cte
)))
2495 (if (and ctl
(not (string-match "/" (car ctl
))))
2497 (goto-char (point-max)))
2500 (narrow-to-region (point) (point-max))
2501 (when (and (eq mail-parse-charset
'gnus-decoded
)
2502 (eq (mm-body-7-or-8) '8bit
))
2503 ;; The text code could have been decoded.
2504 (setq charset mail-parse-charset
))
2505 (when (and (or (not ctl
)
2506 (equal (car ctl
) "text/plain"))
2507 (not format
)) ;; article with format will decode later.
2509 charset
(and cte
(intern (downcase
2510 (gnus-strip-whitespace cte
))))
2513 (defun article-decode-encoded-words ()
2514 "Remove encoded-word encoding from headers."
2515 (let ((inhibit-point-motion-hooks t
)
2516 (mail-parse-charset gnus-newsgroup-charset
)
2517 (mail-parse-ignored-charsets
2518 (save-excursion (condition-case nil
2519 (set-buffer gnus-summary-buffer
)
2521 gnus-newsgroup-ignored-charsets
))
2522 (inhibit-read-only t
)
2524 (goto-char (point-min))
2525 (when (search-forward "\n\n" nil
'move
)
2532 (memq (char-after) '(?
\t ?
)))))
2533 (setq start
(point))
2535 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2536 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2537 (funcall gnus-decode-address-function start end
)
2538 (funcall gnus-decode-header-function start end
))
2539 (goto-char (setq end start
)))))
2541 (defun article-decode-group-name ()
2542 "Decode group names in Newsgroups, Followup-To and Xref headers."
2543 (let ((inhibit-point-motion-hooks t
)
2544 (inhibit-read-only t
)
2545 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2547 (when (and (or gnus-group-name-charset-method-alist
2548 gnus-group-name-charset-group-alist
)
2549 (gnus-buffer-live-p gnus-original-article-buffer
))
2551 (article-narrow-to-head)
2552 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2553 (with-current-buffer gnus-original-article-buffer
2554 (goto-char (point-min)))
2555 (setq regexp
(concat "^" header
2556 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2557 (while (re-search-forward regexp nil t
)
2558 (replace-match (save-match-data
2559 (gnus-decode-newsgroups
2560 ;; XXX how to use data in article buffer?
2561 (with-current-buffer gnus-original-article-buffer
2562 (re-search-forward regexp nil t
)
2564 gnus-newsgroup-name method
))
2566 (goto-char (point-min)))))))
2568 (autoload 'idna-to-unicode
"idna")
2570 (defun article-decode-idna-rhs ()
2571 "Decode IDNA strings in RHS in various headers in current buffer.
2572 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2573 Mail-Reply-To: and Mail-Followup-To:."
2576 (let ((inhibit-point-motion-hooks t
)
2577 (inhibit-read-only t
))
2578 (article-narrow-to-head)
2579 (goto-char (point-min))
2580 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2582 (when (save-match-data
2583 (and (setq ace
(match-string 1))
2585 (and (re-search-backward "^[^ \t]" nil t
)
2586 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2587 (setq unicode
(idna-to-unicode ace
))))
2588 (unless (string= ace unicode
)
2589 (replace-match unicode nil nil nil
1)))))))))
2591 (defun article-de-quoted-unreadable (&optional force read-charset
)
2592 "Translate a quoted-printable-encoded article.
2593 If FORCE, decode the article whether it is marked as quoted-printable
2595 If READ-CHARSET, ask for a coding system."
2596 (interactive (list 'force current-prefix-arg
))
2598 (let ((inhibit-read-only t
) type charset
)
2599 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2600 (with-current-buffer gnus-original-article-buffer
2602 (gnus-fetch-field "content-transfer-encoding"))
2603 (let* ((ct (gnus-fetch-field "content-type"))
2604 (ctl (and ct
(mail-header-parse-content-type ct
))))
2605 (setq charset
(and ctl
2606 (mail-content-type-get ctl
'charset
)))
2607 (if (stringp charset
)
2608 (setq charset
(intern (downcase charset
)))))))
2610 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2612 (setq charset gnus-newsgroup-charset
))
2614 (and type
(let ((case-fold-search t
))
2615 (string-match "quoted-printable" type
))))
2617 (quoted-printable-decode-region
2618 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2620 (defun article-de-base64-unreadable (&optional force read-charset
)
2621 "Translate a base64 article.
2622 If FORCE, decode the article whether it is marked as base64 not.
2623 If READ-CHARSET, ask for a coding system."
2624 (interactive (list 'force current-prefix-arg
))
2626 (let ((inhibit-read-only t
) type charset
)
2627 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2628 (with-current-buffer gnus-original-article-buffer
2630 (gnus-fetch-field "content-transfer-encoding"))
2631 (let* ((ct (gnus-fetch-field "content-type"))
2632 (ctl (and ct
(mail-header-parse-content-type ct
))))
2633 (setq charset
(and ctl
2634 (mail-content-type-get ctl
'charset
)))
2635 (if (stringp charset
)
2636 (setq charset
(intern (downcase charset
)))))))
2638 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2640 (setq charset gnus-newsgroup-charset
))
2642 (and type
(let ((case-fold-search t
))
2643 (string-match "base64" type
))))
2646 (narrow-to-region (point) (point-max))
2647 (base64-decode-region (point-min) (point-max))
2648 (mm-decode-coding-region
2649 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2654 (defun article-decode-HZ ()
2655 "Translate a HZ-encoded article."
2659 (let ((inhibit-read-only t
))
2660 (rfc1843-decode-region (point-min) (point-max)))))
2662 (defun article-unsplit-urls ()
2663 "Remove the newlines that some other mailers insert into URLs."
2666 (let ((inhibit-read-only t
))
2667 (goto-char (point-min))
2668 (while (re-search-forward
2669 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2670 (replace-match "\\1\\3" t
)))
2671 (when (interactive-p)
2672 (gnus-treat-article nil
))))
2675 (defun article-wash-html (&optional read-charset
)
2676 "Format an HTML article.
2677 If READ-CHARSET, ask for a coding system. If it is a number, the
2678 charset defined in `gnus-summary-show-article-charset-alist' is used."
2681 (let ((inhibit-read-only t
)
2684 (if (or (and (numberp read-charset
)
2688 gnus-summary-show-article-charset-alist
))))
2689 (setq charset
(mm-read-coding-system "Charset: ")))
2690 (let ((gnus-summary-show-article-charset-alist
2691 (list (cons 1 charset
))))
2692 (with-current-buffer gnus-summary-buffer
2693 (gnus-summary-show-article 1)))
2694 (error "No charset is given"))
2695 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2696 (with-current-buffer gnus-original-article-buffer
2697 (let* ((ct (gnus-fetch-field "content-type"))
2698 (ctl (and ct
(mail-header-parse-content-type ct
))))
2699 (setq charset
(and ctl
2700 (mail-content-type-get ctl
'charset
)))
2701 (when (stringp charset
)
2702 (setq charset
(intern (downcase charset
)))))))
2704 (setq charset gnus-newsgroup-charset
)))
2706 (save-window-excursion
2708 (narrow-to-region (point) (point-max))
2709 (let* ((func (or gnus-article-wash-function mm-text-html-renderer
))
2710 (entry (assq func mm-text-html-washer-alist
)))
2712 (setq func
(cdr entry
)))
2717 (apply (car func
) (cdr func
))))))))))
2720 (declare-function w3-region
"ext:w3-display" (st nd
))
2722 (defun gnus-article-wash-html-with-w3 ()
2723 "Wash the current buffer with w3."
2725 (let ((w3-strict-width (window-width))
2726 (url-standalone-mode t
)
2727 (url-gateway-unplugged t
)
2728 (w3-honor-stylesheets nil
))
2730 (w3-region (point-min) (point-max))
2734 (declare-function w3m-region
"ext:w3m" (start end
&optional url charset
))
2736 (defun gnus-article-wash-html-with-w3m ()
2737 "Wash the current buffer with emacs-w3m."
2739 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp
)
2740 w3m-force-redisplay
)
2741 (w3m-region (point-min) (point-max)))
2742 ;; Put the mark meaning this part was rendered by emacs-w3m.
2743 (put-text-property (point-min) (point-max) 'mm-inline-text-html-with-w3m t
)
2744 (when (and mm-inline-text-html-with-w3m-keymap
2745 (boundp 'w3m-minor-mode-map
)
2747 (if (and (boundp 'w3m-link-map
)
2749 (let* ((start (point-min))
2751 (on (get-text-property start
'w3m-href-anchor
))
2752 (map (copy-keymap w3m-link-map
))
2754 (set-keymap-parent map w3m-minor-mode-map
)
2755 (while (< start end
)
2758 (setq next
(or (text-property-any start end
2759 'w3m-href-anchor nil
)
2761 (put-text-property start next
'keymap map
))
2762 (setq next
(or (text-property-not-all start end
2763 'w3m-href-anchor nil
)
2765 (put-text-property start next
'keymap w3m-minor-mode-map
))
2768 (put-text-property (point-min) (point-max) 'keymap w3m-minor-mode-map
))))
2770 (defvar charset
) ;; Bound by `article-wash-html'.
2772 (defun gnus-article-wash-html-with-w3m-standalone ()
2773 "Wash the current buffer with w3m."
2774 (if (mm-w3m-standalone-supports-m17n-p)
2776 (unless (mm-coding-system-p charset
) ;; Bound by `article-wash-html'.
2778 (setq charset
'iso-8859-1
))
2779 (let ((coding-system-for-write charset
)
2780 (coding-system-for-read charset
))
2781 (call-process-region
2782 (point-min) (point-max)
2783 "w3m" t t nil
"-dump" "-T" "text/html"
2784 "-I" (symbol-name charset
) "-O" (symbol-name charset
))))
2785 (mm-inline-wash-with-stdin nil
"w3m" "-dump" "-T" "text/html")))
2787 (defvar gnus-article-browse-html-temp-list nil
2788 "List of temporary files created by `gnus-article-browse-html-parts'.
2789 Internal variable.")
2791 (defcustom gnus-article-browse-delete-temp
'ask
2792 "What to do with temporary files from `gnus-article-browse-html-parts'.
2793 If nil, don't delete temporary files. If it is t, delete them on
2794 exit from the summary buffer. If it is the symbol `file', query
2795 on each file, if it is `ask' ask once when exiting from the
2797 :group
'gnus-article
2798 :version
"23.1" ;; No Gnus
2799 :type
'(choice (const :tag
"Don't delete" nil
)
2800 (const :tag
"Don't ask" t
)
2801 (const :tag
"Ask" ask
)
2802 (const :tag
"Ask for each file" file
)))
2804 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2806 (defun gnus-article-browse-delete-temp-files (&optional how
)
2807 "Delete temp-files created by `gnus-article-browse-html-parts'."
2808 (when (and gnus-article-browse-html-temp-list
2810 (setq how gnus-article-browse-delete-temp
)))
2811 (when (and (eq how
'ask
)
2812 (gnus-y-or-n-p (format
2813 "Delete all %s temporary HTML file(s)? "
2814 (length gnus-article-browse-html-temp-list
)))
2816 (dolist (file gnus-article-browse-html-temp-list
)
2817 (when (and (file-exists-p file
)
2819 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2821 (format "Delete temporary HTML file `%s'? " file
))))
2822 (delete-file file
)))
2823 ;; Also remove file from the list when not deleted or if file doesn't
2825 (setq gnus-article-browse-html-temp-list nil
))
2826 gnus-article-browse-html-temp-list
)
2828 (defun gnus-article-browse-html-parts (list &optional header
)
2829 "View all \"text/html\" parts from LIST.
2830 Recurse into multiparts. The optional HEADER that should be a decoded
2831 message header will be added to the bodies of the \"text/html\" parts."
2832 ;; Internal function used by `gnus-article-browse-html-article'.
2833 (let (type file charset tmp-file showed
)
2834 ;; Find and show the html-parts.
2835 (dolist (handle list
)
2836 ;; If HTML, show it:
2837 (cond ((not (listp handle
)))
2838 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2839 (and (equal (car type
) "message/external-body")
2841 (setq file
(or (mail-content-type-get type
'name
)
2842 (mail-content-type-get
2843 (mm-handle-disposition handle
)
2845 (or (mm-handle-cache handle
)
2846 (condition-case code
2847 (progn (mm-extern-cache-contents handle
) t
)
2849 (gnus-message 3 "%s" (error-message-string code
))
2850 (when (>= gnus-verbose
3) (sit-for 2))
2853 (setq handle
(mm-handle-cache handle
)
2854 type
(mm-handle-type handle
))
2855 (equal (car type
) "text/html"))))
2856 (when (or (setq charset
(mail-content-type-get type
'charset
))
2859 (setq tmp-file
(mm-make-temp-file
2860 ;; Do we need to care for 8.3 filenames?
2861 "mm-" nil
".html")))
2862 ;; Add a meta html tag to specify charset and a header.
2865 (let (title eheader body hcharset coding
)
2867 (mm-enable-multibyte)
2868 (setq case-fold-search t
)
2869 (insert header
"\n")
2870 (setq title
(message-fetch-field "subject"))
2871 (goto-char (point-min))
2872 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t
)
2873 (replace-match (cond ((match-beginning 1) "<")
2874 ((match-beginning 2) ">")
2876 (goto-char (point-min))
2878 (goto-char (point-max))
2879 (insert "</pre>\n<hr>\n")
2880 ;; We have to examine charset one by one since
2881 ;; charset specified in parts might be different.
2882 (if (eq charset
'gnus-decoded
)
2883 (setq charset
'utf-8
2884 eheader
(mm-encode-coding-string (buffer-string)
2887 (mm-encode-coding-string title charset
))
2888 body
(mm-encode-coding-string (mm-get-part handle
)
2890 (setq hcharset
(mm-find-mime-charset-region (point-min)
2892 (cond ((= (length hcharset
) 1)
2893 (setq hcharset
(car hcharset
)
2894 coding
(mm-charset-to-coding-system
2896 ((> (length hcharset
) 1)
2897 (setq hcharset
'utf-8
2903 (mm-charset-to-coding-system charset
))
2904 (if (eq coding body
)
2905 (setq eheader
(mm-encode-coding-string
2906 (buffer-string) coding
)
2908 (mm-encode-coding-string
2910 body
(mm-get-part handle
))
2911 (setq charset
'utf-8
2912 eheader
(mm-encode-coding-string
2913 (buffer-string) charset
)
2915 (mm-encode-coding-string
2917 body
(mm-encode-coding-string
2918 (mm-decode-coding-string
2919 (mm-get-part handle
) body
)
2921 (setq charset hcharset
2922 eheader
(mm-encode-coding-string
2923 (buffer-string) coding
)
2925 (mm-encode-coding-string
2927 body
(mm-get-part handle
)))
2928 (setq eheader
(mm-string-as-unibyte (buffer-string))
2929 body
(mm-get-part handle
))))
2931 (mm-disable-multibyte)
2934 (mm-add-meta-html-tag handle charset
))
2936 (goto-char (point-min))
2937 (unless (search-forward "<title>" nil t
)
2938 (re-search-forward "<head>\\s-*" nil t
)
2939 (insert "<title>" title
"</title>\n")))
2940 (goto-char (point-min))
2941 (or (re-search-forward
2942 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2944 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2946 (mm-write-region (point-min) (point-max)
2947 tmp-file nil nil nil
'binary t
))))
2949 (mm-with-unibyte-buffer
2950 (insert (if (eq charset
'gnus-decoded
)
2951 (mm-encode-coding-string
2952 (mm-get-part handle
)
2953 (setq charset
'utf-8
))
2954 (mm-get-part handle
)))
2955 (if (or (mm-add-meta-html-tag handle charset
)
2957 (mm-write-region (point-min) (point-max)
2958 tmp-file nil nil nil
'binary t
)
2959 (setq tmp-file nil
))))
2961 (mm-save-part-to-file handle tmp-file
)))
2963 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2964 (add-hook 'gnus-summary-prepare-exit-hook
2965 'gnus-article-browse-delete-temp-files
)
2966 (add-hook 'gnus-exit-gnus-hook
2968 (gnus-article-browse-delete-temp-files t
)))
2969 ;; FIXME: Warn if there's an <img> tag?
2970 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2972 ;; If multipart, recurse
2973 ((equal (mm-handle-media-supertype handle
) "multipart")
2974 (when (gnus-article-browse-html-parts handle header
)
2976 ((equal (mm-handle-media-type handle
) "message/rfc822")
2977 (mm-with-multibyte-buffer
2978 (mm-insert-part handle
)
2979 (setq handle
(mm-dissect-buffer t t
))
2980 (when (and (bufferp (car handle
))
2981 (stringp (car (mm-handle-type handle
))))
2982 (setq handle
(list handle
)))
2984 (article-decode-encoded-words)
2985 (let ((gnus-visible-headers
2986 (or (get 'gnus-visible-headers
'standard-value
)
2987 gnus-visible-headers
)))
2988 (article-hide-headers))
2989 (goto-char (point-min))
2990 (search-forward "\n\n" nil
'move
)
2991 (skip-chars-backward "\t\n ")
2992 (setq header
(buffer-substring (point-min) (point)))))
2994 (gnus-article-browse-html-parts handle header
)
2995 (mm-destroy-parts handle
))
2999 (defun gnus-article-browse-html-article (&optional arg
)
3000 "View \"text/html\" parts of the current article with a WWW browser.
3001 The message header is added to the beginning of every html part unless
3002 the prefix argument ARG is given.
3004 Warning: Spammers use links to images in HTML articles to verify
3005 whether you have read the message. As
3006 `gnus-article-browse-html-article' passes the HTML content to the
3007 browser without eliminating these \"web bugs\" you should only
3008 use it for mails from trusted senders.
3010 If you always want to display HTML parts in the browser, set
3011 `mm-text-html-renderer' to nil."
3012 ;; Cf. `mm-w3m-safe-url-regexp'
3015 (gnus-summary-show-article)
3016 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3017 gnus-visible-headers
))
3018 ;; As we insert a <hr>, there's no need for the body boundary.
3019 (gnus-treat-body-boundary nil
))
3020 (gnus-summary-show-article)))
3021 (with-current-buffer gnus-article-buffer
3022 (let ((header (unless arg
3025 (buffer-substring-no-properties
3026 (goto-char (point-min))
3027 (if (search-forward "\n\n" nil t
)
3029 (goto-char (point-max))
3030 (skip-chars-backward "\t\n ")
3033 (set-buffer gnus-original-article-buffer
)
3034 (setq parts
(mm-dissect-buffer t t
))
3035 ;; If singlepart, enforce a list.
3036 (when (and (bufferp (car parts
))
3037 (stringp (car (mm-handle-type parts
))))
3038 (setq parts
(list parts
)))
3040 (unless (gnus-article-browse-html-parts parts header
)
3041 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3042 (mm-destroy-parts parts
)
3044 (gnus-summary-show-article)))))
3046 (defun article-hide-list-identifiers ()
3047 "Remove list identifies from the Subject header.
3048 The `gnus-list-identifiers' variable specifies what to do."
3050 (let ((inhibit-point-motion-hooks t
)
3051 (regexp (if (consp gnus-list-identifiers
)
3052 (mapconcat 'identity gnus-list-identifiers
" *\\|")
3053 gnus-list-identifiers
))
3054 (inhibit-read-only t
))
3058 (article-narrow-to-head)
3059 (goto-char (point-min))
3060 (while (re-search-forward
3061 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3063 (delete-region (match-beginning 2) (match-end 0))
3064 (beginning-of-line))
3065 (when (re-search-forward
3066 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3067 (delete-region (match-beginning 1) (match-end 1))))))))
3069 (defun article-hide-pem (&optional arg
)
3070 "Toggle hiding of any PEM headers and signatures in the current article.
3071 If given a negative prefix, always show; if given a positive prefix,
3073 (interactive (gnus-article-hidden-arg))
3074 (unless (gnus-article-check-hidden-text 'pem arg
)
3076 (let ((inhibit-read-only t
) end
)
3077 (goto-char (point-min))
3078 ;; Hide the horrendously ugly "header".
3079 (when (and (search-forward
3080 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3082 (setq end
(1+ (match-beginning 0))))
3083 (gnus-add-wash-type 'pem
)
3084 (gnus-article-hide-text-type
3086 (if (search-forward "\n\n" nil t
)
3090 ;; Hide the trailer as well
3091 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3093 (gnus-article-hide-text-type
3094 (match-beginning 0) (match-end 0) 'pem
)))))))
3096 (defun article-strip-banner ()
3097 "Strip the banners specified by the `banner' group parameter and by
3098 `gnus-article-address-banner-alist'."
3102 (let ((inhibit-point-motion-hooks t
))
3103 (when (gnus-parameter-banner gnus-newsgroup-name
)
3104 (article-really-strip-banner
3105 (gnus-parameter-banner gnus-newsgroup-name
)))
3106 (when gnus-article-address-banner-alist
3107 ;; Note that the From header is decoded here, so it is
3108 ;; required that the *-extract-address-components function
3109 ;; supports non-ASCII text.
3110 (let ((from (save-restriction
3112 (article-narrow-to-head)
3113 (mail-fetch-field "from"))))
3116 (cadr (funcall gnus-extract-address-components
3119 (dolist (pair gnus-article-address-banner-alist
)
3120 (when (string-match (car pair
) from
)
3122 (article-really-strip-banner (cdr pair
)))))))))))))
3124 (defun article-really-strip-banner (banner)
3125 "Strip the banner specified by the argument."
3128 (let ((inhibit-point-motion-hooks t
)
3129 (gnus-signature-limit nil
)
3130 (inhibit-read-only t
))
3133 ((eq banner
'signature
)
3134 (when (gnus-article-narrow-to-signature)
3137 (delete-region (point) (point-max))))
3139 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3140 (while (re-search-forward banner nil t
)
3141 (delete-region (match-beginning 0) (match-end 0)))))
3143 (while (re-search-forward banner nil t
)
3144 (delete-region (match-beginning 0) (match-end 0)))))))))
3146 (defun article-babel ()
3147 "Translate article using an online translation service."
3150 (gnus-with-article-buffer
3151 (when (article-goto-body)
3152 (let* ((start (point))
3154 (orig (buffer-substring start end
))
3155 (trans (babel-as-string orig
)))
3157 (narrow-to-region start end
)
3158 (delete-region start end
)
3161 (defun article-hide-signature (&optional arg
)
3162 "Hide the signature in the current article.
3163 If given a negative prefix, always show; if given a positive prefix,
3165 (interactive (gnus-article-hidden-arg))
3166 (unless (gnus-article-check-hidden-text 'signature arg
)
3169 (let ((inhibit-read-only t
))
3170 (when (gnus-article-narrow-to-signature)
3171 (gnus-article-hide-text-type
3172 (point-min) (point-max) 'signature
))))))
3173 (gnus-set-mode-line 'article
))
3175 (defun article-strip-headers-in-body ()
3176 "Strip offensive headers from bodies."
3180 (let ((case-fold-search t
))
3181 (when (looking-at "x-no-archive:")
3182 (gnus-delete-line)))))
3184 (defun article-strip-leading-blank-lines ()
3185 "Remove all blank lines from the beginning of the article."
3188 (let ((inhibit-point-motion-hooks t
)
3189 (inhibit-read-only t
))
3190 (when (article-goto-body)
3191 (while (and (not (eobp))
3192 (looking-at "[ \t]*$"))
3193 (gnus-delete-line))))))
3195 (defun article-narrow-to-head ()
3196 "Narrow the buffer to the head of the message.
3197 Point is left at the beginning of the narrowed-to region."
3199 (goto-char (point-min))
3200 (if (search-forward "\n\n" nil
1)
3203 (goto-char (point-min)))
3205 (defun article-goto-body ()
3206 "Place point at the start of the body."
3207 (goto-char (point-min))
3209 ;; This variable is only bound when dealing with separate
3211 (article-goto-body-goes-to-point-min-p
3213 ((search-forward "\n\n" nil t
)
3216 (goto-char (point-max))
3219 (defun article-strip-multiple-blank-lines ()
3220 "Replace consecutive blank lines with one empty line."
3223 (let ((inhibit-point-motion-hooks t
)
3224 (inhibit-read-only t
))
3225 ;; First make all blank lines empty.
3227 (while (re-search-forward "^[ \t]+$" nil t
)
3228 (unless (gnus-annotation-in-region-p
3229 (match-beginning 0) (match-end 0))
3230 (replace-match "" nil t
)))
3231 ;; Then replace multiple empty lines with a single empty line.
3233 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3234 (unless (gnus-annotation-in-region-p
3235 (match-beginning 0) (match-end 0))
3236 (delete-region (match-beginning 1) (match-end 1)))))))
3238 (defun article-strip-leading-space ()
3239 "Remove all white space from the beginning 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-trailing-space ()
3249 "Remove all white space from the end of the lines in the article."
3252 (let ((inhibit-point-motion-hooks t
)
3253 (inhibit-read-only t
))
3255 (while (re-search-forward "[ \t]+$" nil t
)
3256 (replace-match "" t t
)))))
3258 (defun article-strip-blank-lines ()
3259 "Strip leading, trailing and multiple blank lines."
3261 (article-strip-leading-blank-lines)
3262 (article-remove-trailing-blank-lines)
3263 (article-strip-multiple-blank-lines))
3265 (defun article-strip-all-blank-lines ()
3266 "Strip all blank lines."
3269 (let ((inhibit-point-motion-hooks t
)
3270 (inhibit-read-only t
))
3272 (while (re-search-forward "^[ \t]*\n" nil t
)
3273 (replace-match "" t t
)))))
3275 (defun gnus-article-narrow-to-signature ()
3276 "Narrow to the signature; return t if a signature is found, else nil."
3277 (let ((inhibit-point-motion-hooks t
))
3278 (when (gnus-article-search-signature)
3280 ;; Check whether we have some limits to what we consider
3281 ;; to be a signature.
3282 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3283 (list gnus-signature-limit
)))
3285 (while (setq limit
(pop limits
))
3286 (if (or (and (integerp limit
)
3287 (< (- (point-max) (point)) limit
))
3289 (< (count-lines (point) (point-max)) limit
))
3290 (and (functionp limit
)
3292 (and (stringp limit
)
3293 (not (re-search-forward limit nil t
))))
3294 () ; This limit did not succeed.
3298 (narrow-to-region (point) (point-max))
3301 (defun gnus-article-search-signature ()
3302 "Search the current buffer for the signature separator.
3303 Put point at the beginning of the signature separator."
3304 (let ((cur (point)))
3305 (goto-char (point-max))
3306 (if (if (stringp gnus-signature-separator
)
3307 (re-search-backward gnus-signature-separator nil t
)
3308 (let ((seps gnus-signature-separator
))
3310 (not (re-search-backward (car seps
) nil t
)))
3317 (defun gnus-article-hidden-arg ()
3318 "Return the current prefix arg as a number, or 0 if no prefix."
3319 (list (if current-prefix-arg
3320 (prefix-numeric-value current-prefix-arg
)
3323 (defun gnus-article-check-hidden-text (type arg
)
3324 "Return nil if hiding is necessary.
3325 Arg can be nil or a number. nil and positive means hide, negative
3326 means show, 0 means toggle."
3329 (let ((hide (gnus-article-hidden-text-p type
)))
3335 (gnus-article-show-hidden-text type
)
3338 (if (eq hide
'hidden
)
3340 (gnus-article-show-hidden-text type
)
3344 (defun gnus-article-hidden-text-p (type)
3345 "Say whether the current buffer contains hidden text of type TYPE."
3346 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3348 (not (get-text-property pos
'invisible
))
3349 (not (get-text-property pos
'dummy-invisible
)))
3351 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3356 (defun gnus-article-show-hidden-text (type &optional dummy
)
3357 "Show all hidden text of type TYPE.
3358 Originally it is hide instead of DUMMY."
3359 (let ((inhibit-read-only t
)
3360 (inhibit-point-motion-hooks t
))
3361 (gnus-remove-text-properties-when
3363 (point-min) (point-max)
3364 (cons 'article-type
(cons type
3365 gnus-hidden-properties
)))
3366 (gnus-delete-wash-type type
)))
3368 (defconst article-time-units
3369 `((year .
,(* 365.25 24 60 60))
3370 (week .
,(* 7 24 60 60))
3371 (day .
,(* 24 60 60))
3375 "Mapping from time units to seconds.")
3377 (defun gnus-article-forward-header ()
3378 "Move point to the start of the next header.
3379 If the current header is a continuation header, this can be several
3384 (if (looking-at "[ \t]+[^ \t]")
3388 (defun article-date-ut (&optional type highlight
)
3389 "Convert DATE date to universal time in the current article.
3390 If TYPE is `local', convert to local time; if it is `lapsed', output
3391 how much time has lapsed since DATE. For `lapsed', the value of
3392 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3393 should replace the \"Date:\" one, or should be added below it."
3394 (interactive (list 'ut t
))
3395 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3396 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
3400 (article-lapsed-timer
3404 (case-fold-search t
)
3405 (inhibit-read-only t
)
3406 (inhibit-point-motion-hooks t
)
3407 pos date bface eface
)
3411 (goto-char (point-min))
3412 (while (or (setq date
(get-text-property (setq pos
(point))
3414 (when (setq pos
(next-single-property-change
3415 (point) 'original-date
))
3416 (setq date
(get-text-property pos
'original-date
))
3419 pos
(if (setq pos
(text-property-any pos
(point-max)
3420 'original-date nil
))
3423 (if (or (bolp) (eobp))
3427 (goto-char (point-min))
3428 (when (re-search-forward tdate-regexp nil t
)
3429 (setq bface
(get-text-property (point-at-bol) 'face
)
3430 eface
(get-text-property (1- (point-at-eol)) 'face
)))
3431 (goto-char (point-min))
3433 ;; Delete any old Date headers.
3434 (while (re-search-forward date-regexp nil t
)
3436 (delete-region (point-at-bol) (progn
3437 (gnus-article-forward-header)
3439 (delete-region (point-at-bol) (progn
3440 (gnus-article-forward-header)
3443 (setq pos
(point))))
3444 (when (and (not pos
)
3445 (re-search-forward tdate-regexp nil t
))
3447 (gnus-goto-char pos
)
3448 (insert (article-make-date-line date
(or type
'ut
)))
3454 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3455 (put-text-property (match-beginning 1) (1+ (match-end 1))
3457 (put-text-property (match-beginning 2) (match-end 2)
3459 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
3460 (goto-char (point-max))
3463 (defun article-make-date-line (date type
)
3464 "Return a DATE line of TYPE."
3465 (unless (memq type
'(local ut original user iso8601 lapsed english
))
3466 (error "Unknown conversion type: %s" type
))
3468 (let ((time (date-to-time date
)))
3470 ;; Convert to the local timezone.
3472 (concat "Date: " (message-make-date time
)))
3473 ;; Convert to Universal Time.
3478 (let* ((e (parse-time-string date
))
3479 (tm (apply 'encode-time e
))
3481 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3482 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3483 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3487 ;; Get the original date from the article.
3488 ((eq type
'original
)
3489 (concat "Date: " (if (string-match "\n+$" date
)
3490 (substring date
0 (match-beginning 0))
3492 ;; Let the user define the format.
3494 (let ((format (or (condition-case nil
3495 (with-current-buffer gnus-summary-buffer
3496 gnus-article-time-format
)
3498 gnus-article-time-format
)))
3499 (if (functionp format
)
3500 (funcall format time
)
3501 (concat "Date: " (format-time-string format time
)))))
3504 (let ((tz (car (current-time-zone time
))))
3507 (format-time-string "%Y%m%dT%H%M%S" time
)
3508 (format "%s%02d%02d"
3509 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3510 (/ (%
(abs tz
) 3600) 60)))))
3511 ;; Do an X-Sent lapsed format.
3513 ;; If the date is seriously mangled, the timezone functions are
3514 ;; liable to bug out, so we ignore all errors.
3515 (let* ((now (current-time))
3516 (real-time (subtract-time now time
))
3517 (real-sec (and real-time
3518 (+ (* (float (car real-time
)) 65536)
3520 (sec (and real-time
(abs real-sec
)))
3530 ;; This is a bit convoluted, but basically we go
3531 ;; through the time units for years, weeks, etc,
3532 ;; and divide things to see whether that results
3533 ;; in positive answers.
3536 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3537 ;; The (remaining) seconds are too few to
3538 ;; be divided into this time unit.
3540 ;; It's big enough, so we output it.
3541 (setq sec
(- sec
(* num
(cdr unit
))))
3543 (concat (if prev
", " "") (int-to-string
3545 " " (symbol-name (car unit
))
3546 (if (> num
1) "s" ""))
3548 article-time-units
"")
3549 ;; If dates are odd, then it might appear like the
3550 ;; article was sent in the future.
3553 " in the future"))))))
3554 ;; Display the date in proper English
3556 (let ((dtime (decode-time time
)))
3559 (number-to-string (nth 3 dtime
))
3560 (let ((digit (%
(nth 3 dtime
) 10)))
3562 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3568 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3570 (number-to-string (nth 5 dtime
))
3572 (format "%02d" (nth 2 dtime
))
3574 (format "%02d" (nth 1 dtime
)))))))
3576 (format "Date: %s (from Gnus)" date
))))
3578 (defun article-date-local (&optional highlight
)
3579 "Convert the current article date to the local timezone."
3580 (interactive (list t
))
3581 (article-date-ut 'local highlight
))
3583 (defun article-date-english (&optional highlight
)
3584 "Convert the current article date to something that is proper English."
3585 (interactive (list t
))
3586 (article-date-ut 'english highlight
))
3588 (defun article-date-original (&optional highlight
)
3589 "Convert the current article date to what it was originally.
3590 This is only useful if you have used some other date conversion
3591 function and want to see what the date was before converting."
3592 (interactive (list t
))
3593 (article-date-ut 'original highlight
))
3595 (defun article-date-lapsed (&optional highlight
)
3596 "Convert the current article date to time lapsed since it was sent."
3597 (interactive (list t
))
3598 (article-date-ut 'lapsed highlight
))
3600 (defun article-update-date-lapsed ()
3601 "Function to be run from a timer to update the lapsed time line."
3603 (let (deactivate-mark)
3608 (set-buffer (window-buffer w
))
3609 (when (eq major-mode
'gnus-article-mode
)
3610 (let ((mark (point-marker)))
3611 (goto-char (point-min))
3612 (when (re-search-forward "^X-Sent:" nil t
)
3613 (article-date-lapsed t
))
3614 (goto-char (marker-position mark
))
3615 (move-marker mark nil
))))
3618 (defun gnus-start-date-timer (&optional n
)
3619 "Start a timer to update the X-Sent header in the article buffers.
3620 The numerical prefix says how frequently (in seconds) the function
3625 (gnus-stop-date-timer)
3626 (setq article-lapsed-timer
3627 (run-at-time 1 n
'article-update-date-lapsed
)))
3629 (defun gnus-stop-date-timer ()
3630 "Stop the X-Sent timer."
3632 (when article-lapsed-timer
3633 (nnheader-cancel-timer article-lapsed-timer
)
3634 (setq article-lapsed-timer nil
)))
3636 (defun article-date-user (&optional highlight
)
3637 "Convert the current article date to the user-defined format.
3638 This format is defined by the `gnus-article-time-format' variable."
3639 (interactive (list t
))
3640 (article-date-ut 'user highlight
))
3642 (defun article-date-iso8601 (&optional highlight
)
3643 "Convert the current article date to ISO8601."
3644 (interactive (list t
))
3645 (article-date-ut 'iso8601 highlight
))
3647 (defmacro gnus-article-save-original-date
(&rest forms
)
3648 "Save the original date as a text property and evaluate FORMS."
3649 `(let* ((case-fold-search t
)
3651 (goto-char (point-min))
3652 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3655 (date (when (and start
3656 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3658 (buffer-substring-no-properties start
3659 (match-beginning 0)))))
3660 (goto-char (point-max))
3661 (skip-chars-backward "\n")
3662 (put-text-property (point-min) (point) 'original-date date
)
3664 (goto-char (point-max))
3665 (skip-chars-backward "\n")
3666 (put-text-property (point-min) (point) 'original-date date
)))
3668 ;; (defun article-show-all ()
3669 ;; "Show all hidden text in the article buffer."
3672 ;; (let ((inhibit-read-only t))
3673 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3675 (defun article-remove-leading-whitespace ()
3676 "Remove excessive whitespace from all headers."
3680 (let ((inhibit-read-only t
))
3681 (article-narrow-to-head)
3682 (goto-char (point-min))
3683 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3684 (delete-region (match-beginning 1) (match-end 1)))))))
3686 (defun article-emphasize (&optional arg
)
3687 "Emphasize text according to `gnus-emphasis-alist'."
3688 (interactive (gnus-article-hidden-arg))
3689 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3693 (with-current-buffer gnus-summary-buffer
3694 gnus-article-emphasis-alist
)
3696 gnus-emphasis-alist
))
3697 (inhibit-read-only t
)
3698 (props (append '(article-type emphasis
)
3699 gnus-hidden-properties
))
3700 regexp elem beg invisible visible face
)
3703 (while (setq elem
(pop alist
))
3705 (setq regexp
(car elem
)
3706 invisible
(nth 1 elem
)
3707 visible
(nth 2 elem
)
3709 (while (re-search-forward regexp nil t
)
3710 (when (and (match-beginning visible
) (match-beginning invisible
))
3711 (gnus-article-hide-text
3712 (match-beginning invisible
) (match-end invisible
) props
)
3713 (gnus-article-unhide-text-type
3714 (match-beginning visible
) (match-end visible
) 'emphasis
)
3715 (gnus-put-overlay-excluding-newlines
3716 (match-beginning visible
) (match-end visible
) 'face face
)
3717 (gnus-add-wash-type 'emphasis
)
3718 (goto-char (match-end invisible
)))))))))
3720 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3721 "Setup newsgroup emphasis alist."
3722 (unless gnus-article-emphasis-alist
3723 (let ((name (and gnus-newsgroup-name
3724 (gnus-group-real-name gnus-newsgroup-name
))))
3725 (make-local-variable 'gnus-article-emphasis-alist
)
3726 (setq gnus-article-emphasis-alist
3728 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3729 (while (setq elem
(pop alist
))
3730 (when (and name
(string-match (car elem
) name
))
3732 highlight
(copy-sequence (cdr elem
)))))
3734 (copy-sequence highlight-words
)
3735 (if gnus-newsgroup-name
3736 (copy-sequence (gnus-group-find-parameter
3737 gnus-newsgroup-name
'highlight-words t
)))
3738 gnus-emphasis-alist
)))))
3740 (defvar gnus-summary-article-menu
)
3741 (defvar gnus-summary-post-menu
)
3743 ;;; Saving functions.
3745 (defun gnus-article-save (save-buffer file
&optional num
)
3746 "Save the currently selected article."
3747 (when (or (get gnus-default-article-saver
:headers
)
3748 (not gnus-save-all-headers
))
3749 ;; Remove headers according to `gnus-saved-headers' or the value
3750 ;; of the `:headers' property that the saver function might have.
3751 (let ((gnus-visible-headers
3752 (or (symbol-value (get gnus-default-article-saver
:headers
))
3753 gnus-saved-headers gnus-visible-headers
))
3754 ;; Ignore group parameter. See `article-hide-headers'.
3755 (gnus-summary-buffer nil
))
3756 (with-current-buffer save-buffer
3757 (article-hide-headers 1 t
))))
3758 (save-window-excursion
3759 (if (not gnus-default-article-saver
)
3760 (error "No default saver is defined")
3761 ;; !!! Magic! The saving functions all save
3762 ;; `gnus-save-article-buffer' (or so they think), but we
3763 ;; bind that variable to our save-buffer.
3764 (set-buffer gnus-article-buffer
)
3765 (let* ((gnus-save-article-buffer save-buffer
)
3768 ((not gnus-prompt-before-saving
) 'default
)
3769 ((eq gnus-prompt-before-saving
'always
) nil
)
3771 (gnus-number-of-articles-to-be-saved
3772 (when (eq gnus-prompt-before-saving t
)
3774 (set-buffer gnus-article-current-summary
)
3775 (funcall gnus-default-article-saver filename
)))))
3777 (defun gnus-read-save-file-name (prompt &optional filename
3778 function group headers variable
3781 (funcall function group headers
(symbol-value variable
)))
3786 ((eq filename
'default
)
3792 (when (symbol-value dir-var
)
3793 (setq default-name
(expand-file-name
3794 (file-name-nondirectory default-name
)
3795 (symbol-value dir-var
))))
3796 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3799 (if (and gnus-number-of-articles-to-be-saved
3800 (> gnus-number-of-articles-to-be-saved
1))
3801 (format "these %d articles"
3802 gnus-number-of-articles-to-be-saved
)
3805 ;; Let the split methods have their say.
3807 ;; No split name was found.
3810 (concat prompt
" (default "
3811 (file-name-nondirectory default-name
) "): ")
3812 (file-name-directory default-name
)
3814 ;; A single group name is returned.
3815 ((stringp split-name
)
3817 (funcall function split-name headers
3818 (symbol-value variable
)))
3820 (concat prompt
" (default "
3821 (file-name-nondirectory default-name
) "): ")
3822 (file-name-directory default-name
)
3824 ;; A single split name was found
3825 ((= 1 (length split-name
))
3826 (let* ((name (expand-file-name
3828 gnus-article-save-directory
))
3829 (dir (cond ((file-directory-p name
)
3830 (file-name-as-directory name
))
3831 ((file-exists-p name
) name
)
3832 (t gnus-article-save-directory
))))
3834 (concat prompt
" (default " name
"): ")
3836 ;; A list of splits was found.
3838 (setq split-name
(nreverse split-name
))
3840 (let ((file-name-history
3841 (nconc split-name file-name-history
)))
3845 (concat prompt
" (`M-p' for defaults): ")
3846 gnus-article-save-directory
3848 gnus-article-save-directory
)))
3849 (car (push result file-name-history
)))))))
3850 ;; Create the directory.
3851 (gnus-make-directory (file-name-directory file
))
3852 ;; If we have read a directory, we append the default file name.
3853 (when (file-directory-p file
)
3854 (setq file
(expand-file-name (file-name-nondirectory
3856 (file-name-as-directory file
))))
3857 ;; Possibly translate some characters.
3858 (nnheader-translate-file-chars file
))))))
3859 (gnus-make-directory (file-name-directory result
))
3861 (set variable result
))
3863 (set dir-var
(file-name-directory result
)))
3866 (defun gnus-article-archive-name (group)
3867 "Return the first instance of an \"Archive-name\" in the current buffer."
3868 (let ((case-fold-search t
))
3869 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3870 (nnheader-concat gnus-article-save-directory
3871 (match-string 1)))))
3873 (defun gnus-article-nndoc-name (group)
3874 "If GROUP is an nndoc group, return the name of the parent group."
3875 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3876 (gnus-group-get-parameter group
'save-article-group
)))
3878 (defun gnus-summary-save-in-rmail (&optional filename
)
3879 "Append this article to Rmail file.
3880 Optional argument FILENAME specifies file name.
3881 Directory to save to is default to `gnus-article-save-directory'."
3882 (setq filename
(gnus-read-save-file-name
3883 "Save %s in rmail file" filename
3884 gnus-rmail-save-name gnus-newsgroup-name
3885 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3886 (gnus-eval-in-buffer-window gnus-save-article-buffer
3890 ;; Note that unlike gnus-summary-save-in-mail, there is no
3891 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3893 (gnus-output-to-rmail filename
))))
3896 (defun gnus-summary-save-in-mail (&optional filename
)
3897 "Append this article to Unix mail file.
3898 Optional argument FILENAME specifies file name.
3899 Directory to save to is default to `gnus-article-save-directory'."
3900 (setq filename
(gnus-read-save-file-name
3901 "Save %s in Unix mail file" filename
3902 gnus-mail-save-name gnus-newsgroup-name
3903 gnus-current-headers
'gnus-newsgroup-last-mail
))
3904 (gnus-eval-in-buffer-window gnus-save-article-buffer
3908 (if (and (file-readable-p filename
)
3909 (file-regular-p filename
)
3910 (mail-file-babyl-p filename
))
3911 (gnus-output-to-rmail filename
)
3912 (gnus-output-to-mail filename
)))))
3915 (put 'gnus-summary-save-in-file
:decode t
)
3916 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
3917 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3918 "Append this article to file.
3919 Optional argument FILENAME specifies file name.
3920 Directory to save to is default to `gnus-article-save-directory'."
3921 (setq filename
(gnus-read-save-file-name
3922 "Save %s in file" filename
3923 gnus-file-save-name gnus-newsgroup-name
3924 gnus-current-headers
'gnus-newsgroup-last-file
))
3925 (gnus-eval-in-buffer-window gnus-save-article-buffer
3929 (when (and overwrite
3930 (file-exists-p filename
))
3931 (delete-file filename
))
3932 (gnus-output-to-file filename
))))
3935 (put 'gnus-summary-write-to-file
:decode t
)
3936 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
3937 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
3938 (defun gnus-summary-write-to-file (&optional filename
)
3939 "Write this article to a file, overwriting it if the file exists.
3940 Optional argument FILENAME specifies file name.
3941 The directory to save in defaults to `gnus-article-save-directory'."
3942 (setq filename
(gnus-read-save-file-name
3943 "Save %s in file" filename
3944 gnus-file-save-name gnus-newsgroup-name
3945 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3946 (gnus-summary-save-in-file filename t
))
3948 (put 'gnus-summary-save-body-in-file
:decode t
)
3949 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
3950 "Append this article body to a file.
3951 Optional argument FILENAME specifies file name.
3952 The directory to save in defaults to `gnus-article-save-directory'."
3953 (setq filename
(gnus-read-save-file-name
3954 "Save %s body in file" filename
3955 gnus-file-save-name gnus-newsgroup-name
3956 gnus-current-headers
'gnus-newsgroup-last-file
))
3957 (gnus-eval-in-buffer-window gnus-save-article-buffer
3961 (when (article-goto-body)
3962 (narrow-to-region (point) (point-max)))
3963 (when (and overwrite
3964 (file-exists-p filename
))
3965 (delete-file filename
))
3966 (gnus-output-to-file filename
))))
3969 (put 'gnus-summary-write-body-to-file
:decode t
)
3970 (put 'gnus-summary-write-body-to-file
3971 :function
'gnus-summary-save-body-in-file
)
3972 (defun gnus-summary-write-body-to-file (&optional filename
)
3973 "Write this article body to a file, overwriting it if the file exists.
3974 Optional argument FILENAME specifies file name.
3975 The directory to save in defaults to `gnus-article-save-directory'."
3976 (setq filename
(gnus-read-save-file-name
3977 "Save %s body in file" filename
3978 gnus-file-save-name gnus-newsgroup-name
3979 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3980 (gnus-summary-save-body-in-file filename t
))
3982 (put 'gnus-summary-save-in-pipe
:decode t
)
3983 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
3984 (defun gnus-summary-save-in-pipe (&optional command raw
)
3985 "Pipe this article to subprocess COMMAND.
3986 Valid values for COMMAND include:
3988 The executable command name and possibly arguments.
3990 You will be prompted for the command in the minibuffer.
3991 the symbol `default'
3992 It will be replaced with the command which the variable
3993 `gnus-summary-pipe-output-default-command' holds or the command
3994 last used for saving.
3995 Non-nil value for RAW overrides `:decode' and `:headers' properties
3996 and the raw article including all headers will be piped."
3997 (let ((article (gnus-summary-article-number))
3999 (get 'gnus-summary-save-in-pipe
:decode
)))
4000 save-buffer default
)
4002 (if (vectorp (gnus-summary-article-header article
))
4003 (save-current-buffer
4004 (gnus-summary-select-article decode decode nil article
)
4005 (insert-buffer-substring
4009 gnus-original-article-buffer
)
4011 (nnheader-set-temp-buffer " *Gnus Save*"))))
4012 ;; Remove unwanted headers.
4013 (when (and (not raw
)
4014 (or (get 'gnus-summary-save-in-pipe
:headers
)
4015 (not gnus-save-all-headers
)))
4016 (let ((gnus-visible-headers
4017 (or (symbol-value (get 'gnus-summary-save-in-pipe
4019 gnus-saved-headers gnus-visible-headers
))
4020 (gnus-summary-buffer nil
))
4021 (article-hide-headers 1 t
))))
4022 (error "%d is not a real article" article
))
4023 (error "No article to pipe"))
4024 (setq default
(or gnus-summary-pipe-output-default-command
4025 gnus-last-shell-command
))
4026 (unless (stringp command
)
4028 (if (and (eq command
'default
) default
)
4030 (gnus-read-shell-command "Shell command on this article: "
4032 (when (string-equal command
"")
4034 (setq command default
)
4035 (error "A command is required")))
4036 (gnus-eval-in-buffer-window save-buffer
4039 (shell-command-on-region (point-min) (point-max) command nil
)))
4040 (gnus-kill-buffer save-buffer
))
4041 (setq gnus-summary-pipe-output-default-command command
))
4043 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4044 "Pipe this article to muttprint."
4045 (unless (stringp command
)
4046 (setq command
(read-string
4047 "Print using command: " gnus-summary-muttprint-program
4048 nil gnus-summary-muttprint-program
)))
4049 (let ((gnus-summary-pipe-output-default-command
4050 gnus-summary-pipe-output-default-command
))
4051 (gnus-summary-save-in-pipe command
))
4052 (setq gnus-summary-muttprint-program command
))
4054 ;;; Article file names when saving.
4056 (defun gnus-capitalize-newsgroup (newsgroup)
4057 "Capitalize NEWSGROUP name."
4058 (when (not (zerop (length newsgroup
)))
4059 (concat (char-to-string (upcase (aref newsgroup
0)))
4060 (substring newsgroup
1))))
4062 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4063 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4064 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4065 Otherwise, it is like ~/News/news/group/num."
4068 (concat (if (gnus-use-long-file-name 'not-save
)
4069 (gnus-capitalize-newsgroup newsgroup
)
4070 (gnus-newsgroup-directory-form newsgroup
))
4071 "/" (int-to-string (mail-header-number headers
)))
4072 gnus-article-save-directory
)))
4074 (string-equal (file-name-directory default
)
4075 (file-name-directory last-file
))
4076 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4078 (or last-file default
))))
4080 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4081 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4082 If variable `gnus-use-long-file-name' is non-nil, it is
4083 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4086 (concat (if (gnus-use-long-file-name 'not-save
)
4088 (gnus-newsgroup-directory-form newsgroup
))
4089 "/" (int-to-string (mail-header-number headers
)))
4090 gnus-article-save-directory
)))
4092 (string-equal (file-name-directory default
)
4093 (file-name-directory last-file
))
4094 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4096 (or last-file default
))))
4098 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4099 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4100 If variable `gnus-use-long-file-name' is non-nil, it is
4101 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4104 (if (gnus-use-long-file-name 'not-save
)
4107 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4109 gnus-article-save-directory
)))
4111 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4112 "Generate file name from sender."
4113 (let ((from (mail-header-from headers
)))
4115 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4116 (match-string 1 from
)
4118 gnus-article-save-directory
)))
4120 (defun article-verify-x-pgp-sig ()
4122 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4124 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4125 (let ((sig (with-current-buffer gnus-original-article-buffer
4126 (gnus-fetch-field "X-PGP-Sig")))
4130 (mml2015-clear-verify-function))
4132 (insert-buffer-substring gnus-original-article-buffer
)
4133 (setq items
(split-string sig
))
4134 (message-narrow-to-head)
4135 (let ((inhibit-point-motion-hooks t
)
4136 (case-fold-search t
))
4137 ;; Don't verify multiple headers.
4138 (setq headers
(mapconcat (lambda (header)
4140 (mail-fetch-field header
)
4142 (split-string (nth 1 items
) ",") "")))
4143 (delete-region (point-min) (point-max))
4144 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4145 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4150 (if (looking-at "^-")
4153 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4154 (insert "Version: " (car items
) "\n\n")
4155 (insert (mapconcat 'identity
(cddr items
) "\n"))
4156 (insert "\n-----END PGP SIGNATURE-----\n")
4157 (let ((mm-security-handle (list (format "multipart/signed"))))
4158 (mml2015-clean-buffer)
4159 (let ((coding-system-for-write (or gnus-newsgroup-charset
4161 (funcall (mml2015-clear-verify-function)))
4163 (or (mm-handle-multipart-ctl-parameter
4164 mm-security-handle
'gnus-details
)
4165 (mm-handle-multipart-ctl-parameter
4166 mm-security-handle
'gnus-info
)))))
4168 (let ((inhibit-read-only t
) bface eface
)
4170 (message-narrow-to-head)
4171 (goto-char (point-max))
4173 (setq bface
(get-text-property (point-at-bol) 'face
)
4174 eface
(get-text-property (1- (point-at-eol)) 'face
))
4175 (message-remove-header "X-Gnus-PGP-Verify")
4176 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4178 (goto-char (point-max)))
4179 (narrow-to-region (point) (point))
4180 (insert "X-Gnus-PGP-Verify: " info
"\n")
4181 (goto-char (point-min))
4184 (if (not (looking-at "^[ \t]"))
4188 (goto-char (point-min))
4189 (when (looking-at "\\([^:]+\\): *")
4190 (put-text-property (match-beginning 1) (1+ (match-end 1))
4192 (put-text-property (match-end 0) (point-max)
4193 'face eface
)))))))))
4195 (defun article-verify-cancel-lock ()
4196 "Verify Cancel-Lock header."
4198 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4199 (canlock-verify gnus-original-article-buffer
)))
4206 (setq afunc
(car func
)
4209 gfunc
(intern (format "gnus-%s" func
))))
4211 (when (fboundp afunc
)
4212 `(lambda (&optional interactive
&rest args
)
4213 ,(documentation afunc t
)
4214 (interactive (list t
))
4215 (with-current-buffer gnus-article-buffer
4217 (call-interactively ',afunc
)
4218 (apply ',afunc args
))))))))
4219 '(article-hide-headers
4220 article-verify-x-pgp-sig
4221 article-verify-cancel-lock
4222 article-hide-boring-headers
4223 article-treat-overstrike
4224 article-treat-ansi-sequences
4225 article-fill-long-lines
4226 article-capitalize-sentences
4228 article-remove-leading-whitespace
4229 article-display-x-face
4230 article-display-face
4231 article-de-quoted-unreadable
4232 article-de-base64-unreadable
4235 article-unsplit-urls
4236 article-hide-list-identifiers
4237 article-strip-banner
4240 article-hide-signature
4241 article-strip-headers-in-body
4242 article-remove-trailing-blank-lines
4243 article-strip-leading-blank-lines
4244 article-strip-multiple-blank-lines
4245 article-strip-leading-space
4246 article-strip-trailing-space
4247 article-strip-blank-lines
4248 article-strip-all-blank-lines
4250 article-date-english
4251 article-date-iso8601
4252 article-date-original
4254 article-decode-mime-words
4255 article-decode-charset
4256 article-decode-encoded-words
4260 article-treat-dumbquotes
4261 article-normalize-headers
4262 ;;(article-show-all . gnus-article-show-all-headers)
4266 ;;; Gnus article mode
4269 (put 'gnus-article-mode
'mode-class
'special
)
4271 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4273 (gnus-define-keys gnus-article-mode-map
4274 " " gnus-article-goto-next-page
4275 "\177" gnus-article-goto-prev-page
4276 [delete] gnus-article-goto-prev-page
4277 [backspace] gnus-article-goto-prev-page
4278 "\C-c^" gnus-article-refer-article
4279 "h" gnus-article-show-summary
4280 "s" gnus-article-show-summary
4281 "\C-c\C-m" gnus-article-mail
4282 "?" gnus-article-describe-briefly
4283 "<" beginning-of-buffer
4285 "\C-c\C-i" gnus-info-find-node
4287 "R" gnus-article-reply-with-original
4288 "F" gnus-article-followup-with-original
4289 "\C-hk" gnus-article-describe-key
4290 "\C-hc" gnus-article-describe-key-briefly
4291 "\C-hb" gnus-article-describe-bindings
4293 "e" gnus-article-read-summary-keys
4294 "\C-d" gnus-article-read-summary-keys
4295 "\M-*" gnus-article-read-summary-keys
4296 "\M-#" gnus-article-read-summary-keys
4297 "\M-^" gnus-article-read-summary-keys
4298 "\M-g" gnus-article-read-summary-keys)
4300 (substitute-key-definition
4301 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4303 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4304 "W" gnus-article-wide-reply-with-original)
4305 (if (featurep 'xemacs)
4306 (set-keymap-default-binding gnus-article-send-map
4307 'gnus-article-read-summary-send-keys)
4308 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4310 (defun gnus-article-make-menu-bar ()
4311 (unless (boundp 'gnus-article-commands-menu)
4312 (gnus-summary-make-menu-bar))
4313 (gnus-turn-off-edit-menu 'article)
4314 (unless (boundp 'gnus-article-article-menu)
4316 gnus-article-article-menu gnus-article-mode-map ""
4318 ["Scroll forwards" gnus-article-goto-next-page t]
4319 ["Scroll backwards" gnus-article-goto-prev-page t]
4320 ["Show summary" gnus-article-show-summary t]
4321 ["Fetch Message-ID at point" gnus-article-refer-article t]
4322 ["Mail to address at point" gnus-article-mail t]
4323 ["Send a bug report" gnus-bug t]))
4326 gnus-article-treatment-menu gnus-article-mode-map ""
4327 ;; Fixme: this should use :active (and maybe :visible).
4329 ["Hide headers" gnus-article-hide-headers t]
4330 ["Hide signature" gnus-article-hide-signature t]
4331 ["Hide citation" gnus-article-hide-citation t]
4332 ["Treat overstrike" gnus-article-treat-overstrike t]
4333 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4334 ["Remove carriage return" gnus-article-remove-cr t]
4335 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4336 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4337 ["Remove base64" gnus-article-de-base64-unreadable t]
4338 ["Treat html" gnus-article-wash-html t]
4339 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4340 ["Decode HZ" gnus-article-decode-HZ t]))
4342 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4344 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4346 (gnus-run-hooks 'gnus-article-menu-hook)))
4348 (defun gnus-article-mode ()
4349 "Major mode for displaying an article.
4351 All normal editing commands are switched off.
4353 The following commands are available in addition to all summary mode
4355 \\<gnus-article-mode-map>
4356 \\[gnus-article-next-page]\t Scroll the article one page forwards
4357 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4358 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4359 \\[gnus-article-show-summary]\t Display the summary buffer
4360 \\[gnus-article-mail]\t Send a reply to the address near point
4361 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4362 \\[gnus-info-find-node]\t Go to the Gnus info node"
4364 (kill-all-local-variables)
4365 (gnus-simplify-mode-line)
4366 (setq mode-name "Article")
4367 (setq major-mode 'gnus-article-mode)
4368 (make-local-variable 'minor-mode-alist)
4369 (use-local-map gnus-article-mode-map)
4370 (when (gnus-visual-p 'article-menu 'menu)
4371 (gnus-article-make-menu-bar)
4372 (when gnus-summary-tool-bar-map
4373 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4374 (gnus-update-format-specifications nil 'article-mode)
4375 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4376 (set (make-local-variable 'gnus-page-broken) nil)
4377 (make-local-variable 'gnus-button-marker-list)
4378 (make-local-variable 'gnus-article-current-summary)
4379 (make-local-variable 'gnus-article-mime-handles)
4380 (make-local-variable 'gnus-article-decoded-p)
4381 (make-local-variable 'gnus-article-mime-handle-alist)
4382 (make-local-variable 'gnus-article-wash-types)
4383 (make-local-variable 'gnus-article-image-alist)
4384 (make-local-variable 'gnus-article-charset)
4385 (make-local-variable 'gnus-article-ignored-charsets)
4386 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4388 (set (make-local-variable 'nobreak-char-display) nil)
4389 (setq cursor-in-non-selected-windows nil)
4390 (setq truncate-lines gnus-article-truncate-lines)
4391 (gnus-set-default-directory)
4392 (buffer-disable-undo)
4393 (setq buffer-read-only t
4394 show-trailing-whitespace nil)
4395 (set-syntax-table gnus-article-mode-syntax-table)
4396 (mm-enable-multibyte)
4397 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4399 (defvar gnus-button-marker-list nil
4400 "Regexp matching any of the regexps from `gnus-button-alist'.
4401 Internal variable.")
4403 (defun gnus-article-setup-buffer ()
4404 "Initialize the article buffer."
4405 (let* ((name (if gnus-single-article-buffer "*Article*"
4406 (concat "*Article " gnus-newsgroup-name "*")))
4408 (progn (string-match "\\*Article" name)
4409 (concat " *Original Article"
4410 (substring name (match-end 0))))))
4411 (setq gnus-article-buffer name)
4412 (setq gnus-original-article-buffer original)
4413 (setq gnus-article-mime-handle-alist nil)
4414 (with-current-buffer gnus-summary-buffer
4415 ;; This might be a variable local to the summary buffer.
4416 (unless gnus-single-article-buffer
4417 (setq gnus-article-buffer name)
4418 (setq gnus-original-article-buffer original)
4419 (gnus-set-global-variables)))
4420 (gnus-article-setup-highlight-words)
4421 ;; Init original article buffer.
4422 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4423 (mm-enable-multibyte)
4424 (setq major-mode 'gnus-original-article-mode)
4425 (make-local-variable 'gnus-original-article))
4426 (if (and (get-buffer name)
4427 (with-current-buffer name
4428 (if gnus-article-edit-mode
4429 (if (y-or-n-p "Article mode edit in progress; discard? ")
4431 (set-buffer-modified-p nil)
4432 (gnus-kill-buffer name)
4435 (error "Action aborted"))
4437 (with-current-buffer name
4438 (set (make-local-variable 'gnus-article-edit-mode) nil)
4439 (when gnus-article-mime-handles
4440 (mm-destroy-parts gnus-article-mime-handles)
4441 (setq gnus-article-mime-handles nil))
4442 ;; Set it to nil in article-buffer!
4443 (setq gnus-article-mime-handle-alist nil)
4444 (buffer-disable-undo)
4445 (setq buffer-read-only t)
4446 ;; This list just keeps growing if we don't reset it.
4447 (setq gnus-button-marker-list nil)
4448 (unless (eq major-mode 'gnus-article-mode)
4449 (gnus-article-mode))
4451 (with-current-buffer (gnus-get-buffer-create name)
4453 (make-local-variable 'gnus-summary-buffer)
4454 (setq gnus-summary-buffer
4455 (gnus-summary-buffer-name gnus-newsgroup-name))
4456 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4457 (current-buffer)))))
4459 ;; Set article window start at LINE, where LINE is the number of lines
4460 ;; from the head of the article.
4461 (defun gnus-article-set-window-start (&optional line)
4462 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4463 (when article-window
4466 (with-current-buffer gnus-article-buffer
4467 (goto-char (point-min))
4470 (gnus-message 6 "Moved to bookmark")
4471 (search-forward "\n\n" nil t)
4475 (defun gnus-article-prepare (article &optional all-headers header)
4476 "Prepare ARTICLE in article mode buffer.
4477 ARTICLE should either be an article number or a Message-ID.
4478 If ARTICLE is an id, HEADER should be the article headers.
4479 If ALL-HEADERS is non-nil, no headers are hidden."
4481 ;; Make sure we start in a summary buffer.
4482 (unless (eq major-mode 'gnus-summary-mode)
4483 (set-buffer gnus-summary-buffer))
4484 (setq gnus-summary-buffer (current-buffer))
4485 (let* ((gnus-article (if header (mail-header-number header) article))
4486 (summary-buffer (current-buffer))
4487 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4488 (group gnus-newsgroup-name)
4491 (gnus-article-setup-buffer)
4492 (set-buffer gnus-article-buffer)
4493 ;; Deactivate active regions.
4494 (when (and (boundp 'transient-mark-mode)
4495 transient-mark-mode)
4496 (setq mark-active nil))
4497 (if (not (setq result (let ((inhibit-read-only t))
4498 (gnus-request-article-this-buffer
4500 ;; There is no such article.
4502 (when (and (numberp article)
4503 (not (memq article gnus-newsgroup-sparse)))
4504 (setq gnus-article-current
4505 (cons gnus-newsgroup-name article))
4506 (set-buffer gnus-summary-buffer)
4507 (setq gnus-current-article article)
4508 (if (and (memq article gnus-newsgroup-undownloaded)
4509 (not (gnus-online (gnus-find-method-for-group
4510 gnus-newsgroup-name))))
4512 (gnus-summary-set-agent-mark article)
4513 (message "Message marked for downloading"))
4514 (gnus-summary-mark-article article gnus-canceled-mark)
4515 (unless (memq article gnus-newsgroup-sparse)
4516 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4517 (if (or (eq result 'pseudo)
4518 (eq result 'nneething))
4520 (with-current-buffer summary-buffer
4521 (push article gnus-newsgroup-history)
4522 (setq gnus-last-article gnus-current-article
4523 gnus-current-article 0
4524 gnus-current-headers nil
4525 gnus-article-current nil)
4526 (if (eq result 'nneething)
4527 (gnus-configure-windows 'summary)
4528 (gnus-configure-windows 'article))
4529 (gnus-set-global-variables))
4530 (let ((gnus-article-mime-handle-alist-1
4531 gnus-article-mime-handle-alist))
4532 (gnus-set-mode-line 'article)))
4533 ;; The result from the `request' was an actual article -
4534 ;; or at least some text that is now displayed in the
4536 (when (and (numberp article)
4537 (not (eq article gnus-current-article)))
4538 ;; Seems like a new article has been selected.
4539 ;; `gnus-current-article' must be an article number.
4540 (with-current-buffer summary-buffer
4541 (push article gnus-newsgroup-history)
4542 (setq gnus-last-article gnus-current-article
4543 gnus-current-article article
4544 gnus-current-headers
4545 (gnus-summary-article-header gnus-current-article)
4546 gnus-article-current
4547 (cons gnus-newsgroup-name gnus-current-article))
4548 (unless (vectorp gnus-current-headers)
4549 (setq gnus-current-headers nil))
4550 (gnus-summary-goto-subject gnus-current-article)
4551 (when (gnus-summary-show-thread)
4552 ;; If the summary buffer really was folded, the
4553 ;; previous goto may not actually have gone to
4554 ;; the right article, but the thread root instead.
4556 (gnus-summary-goto-subject gnus-current-article))
4557 (gnus-run-hooks 'gnus-mark-article-hook)
4558 (gnus-set-mode-line 'summary)
4559 (when (gnus-visual-p 'article-highlight 'highlight)
4560 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4561 ;; Set the global newsgroup variables here.
4562 (gnus-set-global-variables)
4563 (setq gnus-have-all-headers
4564 (or all-headers gnus-show-all-headers))))
4566 (gnus-configure-windows 'article))
4567 (when (or (numberp article)
4569 (gnus-article-prepare-display)
4571 (goto-char (point-min))
4572 (when gnus-break-pages
4573 (gnus-narrow-to-page)))
4574 (let ((gnus-article-mime-handle-alist-1
4575 gnus-article-mime-handle-alist))
4576 (gnus-set-mode-line 'article))
4580 (set-window-point (get-buffer-window (current-buffer)) (point))
4581 (gnus-configure-windows 'article)
4585 (defun gnus-article-prepare-display ()
4586 "Make the current buffer look like a nice article."
4587 ;; Hooks for getting information from the article.
4588 ;; This hook must be called before being narrowed.
4589 (let ((gnus-article-buffer (current-buffer))
4591 (inhibit-read-only t))
4592 (unless (eq major-mode 'gnus-article-mode)
4593 (gnus-article-mode))
4594 (setq buffer-read-only nil
4595 gnus-article-wash-types nil
4596 gnus-article-image-alist nil)
4597 (gnus-run-hooks 'gnus-tmp-internal-hook)
4598 (when gnus-display-mime-function
4599 (funcall gnus-display-mime-function))
4600 (gnus-run-hooks 'gnus-article-prepare-hook)))
4603 ;;; Gnus Sticky Article Mode
4606 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4607 "Mode for sticky articles."
4608 ;; Release bindings that won't work.
4609 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4610 gnus-sticky-article-mode-map)
4611 (substitute-key-definition 'gnus-article-refer-article 'undefined
4612 gnus-sticky-article-mode-map)
4613 (dolist (k '("e" "h" "s" "F" "R"))
4614 (define-key gnus-sticky-article-mode-map k nil))
4615 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4616 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4617 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4618 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4620 (defun gnus-sticky-article (arg)
4621 "Make the current article sticky.
4622 If a prefix ARG is given, ask for a name for this sticky article buffer."
4624 (gnus-summary-show-thread)
4625 (gnus-summary-select-article nil nil 'pseudo)
4626 (let (new-art-buf-name)
4627 (gnus-eval-in-buffer-window gnus-article-buffer
4628 (setq new-art-buf-name
4632 (read-from-minibuffer "Sticky article buffer name: ")
4633 (gnus-with-article-headers
4634 (gnus-article-goto-header "subject")
4635 (setq new-art-buf-name
4636 (buffer-substring-no-properties
4637 (line-beginning-position) (line-end-position)))
4638 (goto-char (point-min))
4639 (gnus-article-goto-header "from")
4640 (setq new-art-buf-name
4642 new-art-buf-name ", "
4643 (buffer-substring-no-properties
4644 (line-beginning-position) (line-end-position))))
4645 (goto-char (point-min))
4646 (gnus-article-goto-header "date")
4647 (setq new-art-buf-name
4649 new-art-buf-name ", "
4650 (buffer-substring-no-properties
4651 (line-beginning-position) (line-end-position))))))
4653 (if (and (gnus-buffer-live-p new-art-buf-name)
4654 (with-current-buffer new-art-buf-name
4655 (eq major-mode 'gnus-sticky-article-mode)))
4656 (switch-to-buffer new-art-buf-name)
4657 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4658 (gnus-sticky-article-mode))
4659 (setq gnus-article-buffer new-art-buf-name))
4660 (gnus-summary-recenter)
4661 (gnus-summary-position-point))
4663 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4664 "Kill the given sticky article BUFFER.
4665 If none is given, assume the current buffer and kill it if it has
4666 `gnus-sticky-article-mode'."
4669 (setq buffer (current-buffer)))
4670 (with-current-buffer buffer
4671 (when (eq major-mode 'gnus-sticky-article-mode)
4672 (gnus-kill-buffer buffer))))
4674 (defun gnus-kill-sticky-article-buffers (arg)
4675 "Kill all sticky article buffers.
4676 If a prefix ARG is given, ask for confirmation."
4678 (dolist (buf (gnus-buffers))
4679 (with-current-buffer buf
4680 (when (eq major-mode 'gnus-sticky-article-mode)
4682 (gnus-kill-buffer buf)
4683 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4684 (gnus-kill-buffer buf)))))))
4687 ;;; Gnus MIME viewing functions
4690 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4691 "Format of the MIME buttons.
4693 Valid specifiers include:
4695 %T MIME type, along with additional info
4696 %n The `name' parameter
4697 %d The description, if any
4698 %l The length of the encoded part
4699 %p The part identifier number
4700 %e Dots if the part isn't displayed
4702 General format specifiers can also be used. See Info node
4703 `(gnus)Formatting Variables'.")
4705 (defvar gnus-mime-button-line-format-alist
4706 '((?t gnus-tmp-type ?s)
4707 (?T gnus-tmp-type-long ?s)
4708 (?n gnus-tmp-name ?s)
4709 (?d gnus-tmp-description ?s)
4711 (?l gnus-tmp-length ?d)
4712 (?e gnus-tmp-dots ?s)))
4714 (defvar gnus-mime-button-commands
4715 '((gnus-article-press-button "\r" "Toggle Display")
4716 (gnus-mime-view-part "v" "View Interactively...")
4717 (gnus-mime-view-part-as-type "t" "View As Type...")
4718 (gnus-mime-view-part-as-charset "C" "View As charset...")
4719 (gnus-mime-save-part "o" "Save...")
4720 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4721 (gnus-mime-replace-part "r" "Replace part")
4722 (gnus-mime-delete-part "d" "Delete part")
4723 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4724 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4725 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4726 (gnus-mime-view-part-externally "e" "View Externally")
4727 (gnus-mime-print-part "p" "Print")
4728 (gnus-mime-pipe-part "|" "Pipe To Command...")
4729 (gnus-mime-action-on-part "." "Take action on the part...")))
4731 (defun gnus-article-mime-part-status ()
4732 (if gnus-article-mime-handle-alist-1
4733 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4735 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4738 (defvar gnus-mime-button-map
4739 (let ((map (make-sparse-keymap)))
4740 (define-key map gnus-mouse-2 'gnus-article-push-button)
4741 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4742 (dolist (c gnus-mime-button-commands)
4743 (define-key map (cadr c) (car c)))
4747 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4749 ,@(mapcar (lambda (c)
4750 (vector (caddr c) (car c) :active t))
4751 gnus-mime-button-commands)))
4753 (defmacro gnus-bind-safe-url-regexp (&rest body)
4754 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4755 `(let ((mm-w3m-safe-url-regexp
4756 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4758 gnus-article-current-summary))
4759 (with-current-buffer gnus-article-current-summary
4760 gnus-newsgroup-name)
4761 gnus-newsgroup-name)))
4762 (if (cond ((stringp gnus-safe-html-newsgroups)
4763 (string-match gnus-safe-html-newsgroups group))
4764 ((consp gnus-safe-html-newsgroups)
4765 (member group gnus-safe-html-newsgroups)))
4767 mm-w3m-safe-url-regexp))))
4770 (defun gnus-mime-button-menu (event prefix)
4771 "Construct a context-sensitive menu of MIME commands."
4772 (interactive "e\nP")
4773 (save-window-excursion
4774 (let ((pos (event-start event)))
4775 (select-window (posn-window pos))
4776 (goto-char (posn-point pos))
4777 (gnus-article-check-buffer)
4778 (popup-menu gnus-mime-button-menu nil prefix))))
4780 (defun gnus-mime-view-all-parts (&optional handles)
4781 "View all the MIME parts."
4783 (with-current-buffer gnus-article-buffer
4784 (let ((handles (or handles gnus-article-mime-handles))
4785 (mail-parse-charset gnus-newsgroup-charset)
4786 (mail-parse-ignored-charsets
4787 (with-current-buffer gnus-summary-buffer
4788 gnus-newsgroup-ignored-charsets)))
4790 (mm-remove-parts handles)
4791 (goto-char (point-min))
4792 (or (search-forward "\n\n") (goto-char (point-max)))
4793 (let ((inhibit-read-only t))
4794 (delete-region (point) (point-max))
4795 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4797 (defun gnus-article-jump-to-part (n)
4798 "Jump to MIME part N."
4800 (pop-to-buffer gnus-article-buffer)
4801 ;; FIXME: why is it necessary?
4803 (let ((parts (length gnus-article-mime-handle-alist)))
4806 (read-string ;; Emacs 21 doesn't have `read-number'.
4807 (format "Jump to part (2..%s): " parts)))))
4808 (unless (and (integerp n) (<= n parts) (>= n 1))
4811 (gnus-message 7 "Invalid part `%s', using %s instead."
4814 (gnus-message 9 "Jumping to part %s." n)
4815 (cond ((>= gnus-auto-select-part 1)
4816 (while (and (<= n parts)
4817 (not (gnus-article-goto-part n)))
4819 ((< gnus-auto-select-part 0)
4820 (while (and (>= n 1)
4821 (not (gnus-article-goto-part n)))
4824 (gnus-article-goto-part n)))))
4827 (defsubst gnus-article-edit-part (handles &optional current-id)
4828 "Edit an article in order to delete a mime part.
4829 This function is exclusively used by `gnus-mime-save-part-and-strip'
4830 and `gnus-mime-delete-part', and not provided at run-time normally."
4831 (gnus-article-edit-article
4833 (buffer-disable-undo)
4835 (let ((mail-parse-charset (or gnus-article-charset
4836 ',gnus-newsgroup-charset))
4837 (mail-parse-ignored-charsets
4838 (or gnus-article-ignored-charsets
4839 ',gnus-newsgroup-ignored-charsets))
4840 (mbl mml-buffer-list))
4841 (setq mml-buffer-list nil)
4842 (insert-buffer-substring gnus-original-article-buffer)
4843 (mime-to-mml ',handles)
4844 (setq gnus-article-mime-handles nil)
4845 (let ((mbl1 mml-buffer-list))
4846 (setq mml-buffer-list mbl)
4847 (set (make-local-variable 'mml-buffer-list) mbl1))
4848 (gnus-make-local-hook 'kill-buffer-hook)
4849 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4850 `(lambda (no-highlight)
4851 (let ((mail-parse-charset (or gnus-article-charset
4852 ',gnus-newsgroup-charset))
4853 (message-options message-options)
4854 (message-options-set-recipient)
4855 (mail-parse-ignored-charsets
4856 (or gnus-article-ignored-charsets
4857 ',gnus-newsgroup-ignored-charsets)))
4859 (mml-destroy-buffers)
4860 (remove-hook 'kill-buffer-hook
4861 'mml-destroy-buffers t)
4862 (kill-local-variable 'mml-buffer-list))
4863 (gnus-summary-edit-article-done
4864 ,(or (mail-header-references gnus-current-headers) "")
4865 ,(gnus-group-read-only-p)
4866 ,gnus-summary-buffer no-highlight))
4868 (gnus-article-edit-done)
4869 (gnus-configure-windows 'article)
4870 (when (and current-id (integerp gnus-auto-select-part))
4871 (gnus-article-jump-to-part (+ current-id gnus-auto-select-part)))))
4873 (defun gnus-mime-replace-part (file)
4874 "Replace MIME part under point with an external body."
4875 ;; Useful if file has already been saved to disk
4878 (read-file-name "Replace MIME part with file: "
4879 (or mm-default-directory default-directory)
4881 (gnus-mime-save-part-and-strip file))
4883 (defun gnus-mime-save-part-and-strip (&optional file)
4884 "Save the MIME part under point then replace it with an external body.
4885 If FILE is given, use it for the external part."
4887 (gnus-article-check-buffer)
4888 (when (gnus-group-read-only-p)
4889 (error "The current group does not support deleting of parts"))
4890 (when (mm-complicated-handles gnus-article-mime-handles)
4892 The current article has a complicated MIME structure, giving up..."))
4893 (let* ((data (get-text-property (point) 'gnus-data))
4894 (id (get-text-property (point) 'gnus-part))
4896 (handles gnus-article-mime-handles))
4899 (and data (mm-save-part data "Delete MIME part and save to: "))))
4901 (with-current-buffer (mm-handle-buffer data)
4903 (insert "Content-Type: " (mm-handle-media-type data))
4904 (mml-insert-parameter-string (cdr (mm-handle-type data))
4906 ;; Add a filename for the sake of saving the part again.
4907 (mml-insert-parameter
4908 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4910 (insert "Content-ID: " (message-make-message-id) "\n")
4911 (insert "Content-Transfer-Encoding: binary\n")
4914 (cdr (mm-make-handle nil
4915 `("message/external-body"
4916 (access-type . "LOCAL-FILE")
4918 ;; (set-buffer gnus-summary-buffer)
4919 (gnus-article-edit-part handles id))))
4921 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4922 ;; parts...>') but with stripping would be nice.
4924 (defun gnus-mime-delete-part ()
4925 "Delete the MIME part under point.
4926 Replace it with some information about the removed part."
4928 (gnus-article-check-buffer)
4929 (when (gnus-group-read-only-p)
4930 (error "The current group does not support deleting of parts"))
4931 (when (mm-complicated-handles gnus-article-mime-handles)
4933 The current article has a complicated MIME structure, giving up..."))
4934 (when (or gnus-expert-user
4935 (gnus-yes-or-no-p "\
4936 Deleting parts may malfunction or destroy the article; continue? "))
4937 (let* ((data (get-text-property (point) 'gnus-data))
4938 (id (get-text-property (point) 'gnus-part))
4939 (handles gnus-article-mime-handles)
4942 (let ((desc (mm-handle-description data)))
4944 (mail-decode-encoded-word-string desc))))
4946 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4948 (type (mm-handle-media-type data)))
4950 (error "No MIME part under point"))
4951 (with-current-buffer (mm-handle-buffer data)
4952 (let ((bsize (format "%s" (buffer-size))))
4957 "| The following attachment has been deleted:\n"
4959 "| Type: " type "\n"
4960 "| Filename: " filename "\n"
4961 "| Size (encoded): " bsize " Byte\n"
4963 (concat "| Description: " description "\n"))
4966 (cdr (mm-make-handle
4967 nil `("text/plain" (charset . gnus-decoded)) nil nil
4969 (format "Deleted attachment (%s bytes)" bsize))))))
4970 ;; (set-buffer gnus-summary-buffer)
4971 (gnus-article-edit-part handles id))))
4973 (defun gnus-mime-save-part ()
4974 "Save the MIME part under point."
4976 (gnus-article-check-buffer)
4977 (let ((data (get-text-property (point) 'gnus-data)))
4979 (mm-save-part data))))
4981 (defun gnus-mime-pipe-part ()
4982 "Pipe the MIME part under point to a process."
4984 (gnus-article-check-buffer)
4985 (let ((data (get-text-property (point) 'gnus-data)))
4987 (mm-pipe-part data))))
4989 (defun gnus-mime-view-part ()
4990 "Interactively choose a viewing method for the MIME part under point."
4992 (gnus-article-check-buffer)
4993 (let ((data (get-text-property (point) 'gnus-data)))
4995 (setq gnus-article-mime-handles
4997 gnus-article-mime-handles (setq data (copy-sequence data))))
4998 (mm-interactively-view-part data))))
5000 (defun gnus-mime-view-part-as-type-internal ()
5001 (gnus-article-check-buffer)
5002 (let* ((handle (get-text-property (point) 'gnus-data))
5004 ;; Content-Type: foo/bar; name=...
5005 (mail-content-type-get (mm-handle-type handle) 'name)
5006 ;; Content-Disposition: attachment; filename=...
5007 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5008 (def-type (and name (mm-default-file-encoding name))))
5009 (or (and def-type (cons def-type 0))
5011 (equal (mm-handle-media-supertype handle) "text")
5012 '("text/plain" . 0))
5013 '("application/octet-stream" . 0))))
5015 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5016 "Choose a MIME media type, and view the part as such.
5017 If non-nil, PRED is a predicate to use during completion to limit the
5018 available media-types."
5022 (let ((default (gnus-mime-view-part-as-type-internal)))
5024 (format "View as MIME type (default %s): "
5026 (mapcar #'list (mailcap-mime-types))
5029 (gnus-article-check-buffer)
5030 (let ((handle (get-text-property (point) 'gnus-data)))
5032 (when (equal (mm-handle-media-type handle) "message/external-body")
5033 (unless (mm-handle-cache handle)
5034 (mm-extern-cache-contents handle))
5035 (setq handle (mm-handle-cache handle)))
5037 (mm-make-handle (mm-handle-buffer handle)
5038 (cons mime-type (cdr (mm-handle-type handle)))
5039 (mm-handle-encoding handle)
5040 (mm-handle-undisplayer handle)
5041 (mm-handle-disposition handle)
5042 (mm-handle-description handle)
5044 (mm-handle-id handle)))
5045 (setq gnus-article-mime-handles
5046 (mm-merge-handles gnus-article-mime-handles handle))
5047 (when (mm-handle-displayed-p handle)
5048 (mm-remove-part handle))
5049 (gnus-mm-display-part handle))))
5051 (defun gnus-mime-copy-part (&optional handle arg)
5052 "Put the MIME part under point into a new buffer.
5053 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5055 (interactive (list nil current-prefix-arg))
5056 (gnus-article-check-buffer)
5058 (setq handle (get-text-property (point) 'gnus-data)))
5060 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5062 (mail-content-type-get (mm-handle-disposition handle)
5064 contents dont-decode charset coding-system)
5065 (mm-with-unibyte-buffer
5066 (mm-insert-part handle)
5067 (setq contents (or (condition-case nil
5068 (mm-decompress-buffer filename nil 'sig)
5070 (setq dont-decode t)
5073 (setq filename (cond (filename (file-name-nondirectory filename))
5074 (dont-decode "*raw data*")
5079 (unless (setq charset (mail-content-type-get
5080 (mm-handle-type handle) 'charset))
5081 (unless (setq coding-system (mm-with-unibyte-buffer
5083 (mm-find-buffer-file-coding-system)))
5084 (setq charset gnus-newsgroup-charset))))
5086 (setq charset (or (cdr (assq arg
5087 gnus-summary-show-article-charset-alist))
5088 (mm-read-coding-system "Charset: ")))))
5089 (switch-to-buffer (generate-new-buffer filename))
5090 (if (or coding-system
5092 (setq coding-system (mm-charset-to-coding-system charset))
5093 (not (eq charset 'ascii))))
5095 (mm-enable-multibyte)
5096 (insert (mm-decode-coding-string contents coding-system))
5097 (setq buffer-file-coding-system
5098 (if (boundp 'last-coding-system-used)
5099 (symbol-value 'last-coding-system-used)
5101 (mm-disable-multibyte)
5103 (setq buffer-file-coding-system mm-binary-coding-system))
5104 ;; We do it this way to make `normal-mode' set the appropriate mode.
5107 (setq buffer-file-name (expand-file-name filename))
5109 (setq buffer-file-name nil))
5110 (goto-char (point-min)))))
5112 (defun gnus-mime-print-part (&optional handle filename)
5113 "Print the MIME part under point."
5114 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5115 (gnus-article-check-buffer)
5116 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5117 (contents (and handle (mm-get-part handle)))
5118 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5119 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5124 (mm-save-part-to-file handle file)
5125 (call-process shell-file-name nil
5126 (generate-new-buffer " *mm*")
5128 shell-command-switch
5130 printer file (mm-handle-type handle))))
5134 (gnus-print-buffer))
5135 (ps-despool filename)))))
5137 (defun gnus-mime-inline-part (&optional handle arg)
5138 "Insert the MIME part under point into the current buffer.
5139 Compressed files like .gz and .bz2 are decompressed."
5140 (interactive (list nil current-prefix-arg))
5141 (gnus-article-check-buffer)
5143 (setq handle (get-text-property (point) 'gnus-data)))
5146 (inhibit-read-only t)
5147 contents charset coding-system)
5148 (if (and (not arg) (mm-handle-undisplayer handle))
5149 (mm-remove-part handle)
5150 (mm-with-unibyte-buffer
5151 (mm-insert-part handle)
5153 (or (mm-decompress-buffer
5154 (or (mail-content-type-get (mm-handle-type handle)
5156 (mail-content-type-get (mm-handle-disposition handle)
5162 (unless (setq charset (mail-content-type-get
5163 (mm-handle-type handle) 'charset))
5164 (unless (setq coding-system
5165 (mm-with-unibyte-buffer
5167 (mm-find-buffer-file-coding-system)))
5168 (setq charset gnus-newsgroup-charset))))
5170 (if (mm-handle-undisplayer handle)
5171 (mm-remove-part handle))
5174 gnus-summary-show-article-charset-alist))
5175 (mm-read-coding-system "Charset: "))))
5177 (if (mm-handle-undisplayer handle)
5178 (mm-remove-part handle))))
5182 (if (or coding-system
5185 (mm-charset-to-coding-system charset))
5186 (not (eq coding-system 'ascii))))
5187 (mm-decode-coding-string contents coding-system)
5188 (mm-string-to-multibyte contents)))
5191 (defun gnus-mime-set-charset-parameters (handle charset)
5192 "Set CHARSET to parameters in HANDLE.
5193 CHARSET may either be a string or a symbol."
5194 (unless (stringp charset)
5195 (setq charset (symbol-name charset)))
5196 (if (stringp (car handle))
5197 (dolist (h (cdr handle))
5198 (gnus-mime-set-charset-parameters h charset))
5199 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5200 "message/external-body")
5202 (unless (mm-handle-cache handle)
5203 (mm-extern-cache-contents handle))
5204 (mm-handle-cache handle))
5206 (param (assq 'charset (cdr type))))
5208 (setcdr param charset)
5209 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5211 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5212 "Insert the MIME part under point into the current buffer using the
5214 (interactive (list nil current-prefix-arg))
5215 (gnus-article-check-buffer)
5216 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5217 (fun (get-text-property (point) 'gnus-callback))
5218 (gnus-newsgroup-ignored-charsets 'gnus-all)
5219 charset form preferred parts)
5226 gnus-summary-show-article-charset-alist))
5227 (mm-read-coding-system "Charset: "))))
5228 (if (mm-handle-undisplayer handle)
5229 (mm-remove-part handle)))
5230 (gnus-mime-set-charset-parameters handle charset)
5231 (when (and (consp (setq form (cdr-safe fun)))
5232 (setq form (ignore-errors
5233 (assq 'gnus-mime-display-alternative form)))
5234 (setq preferred (caddr form))
5236 (when (eq (car preferred) 'quote)
5237 (setq preferred (cadr preferred)))
5238 (not (equal preferred
5239 (get-text-property (point) 'gnus-data))))
5240 (setq parts (get-text-property (point) 'gnus-part))
5241 (setq parts (cdr (assq parts
5242 gnus-article-mime-handle-alist)))
5243 (equal (mm-handle-media-type parts) "multipart/alternative")
5244 (setq parts (reverse (cdr parts))))
5246 (list 'quote (or (cadr (member preferred parts))
5248 (funcall fun handle)))))
5250 (defun gnus-mime-view-part-externally (&optional handle)
5251 "View the MIME part under point with an external viewer."
5253 (gnus-article-check-buffer)
5254 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5255 (mm-user-display-methods nil)
5256 (mm-inlined-types nil)
5257 (mail-parse-charset gnus-newsgroup-charset)
5258 (mail-parse-ignored-charsets
5259 (with-current-buffer gnus-summary-buffer
5260 gnus-newsgroup-ignored-charsets))
5261 (type (mm-handle-media-type handle))
5262 (method (mailcap-mime-info type))
5263 (mm-enable-external t))
5264 (if (not (stringp method))
5265 (gnus-mime-view-part-as-type
5266 nil (lambda (types) (stringp (mailcap-mime-info (car types)))))
5268 (if (mm-handle-undisplayer handle)
5269 (mm-remove-part handle)
5270 (mm-display-part handle))))))
5272 (defun gnus-mime-view-part-internally (&optional handle)
5273 "View the MIME part under point with an internal viewer.
5274 If no internal viewer is available, use an external viewer."
5276 (gnus-article-check-buffer)
5277 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5278 (mm-inlined-types '(".*"))
5279 (mm-inline-large-images t)
5280 (mail-parse-charset gnus-newsgroup-charset)
5281 (mail-parse-ignored-charsets
5282 (with-current-buffer gnus-summary-buffer
5283 gnus-newsgroup-ignored-charsets))
5284 (inhibit-read-only t))
5285 (if (not (mm-inlinable-p handle))
5286 (gnus-mime-view-part-as-type
5287 nil (lambda (types) (mm-inlinable-p handle (car types))))
5289 (if (mm-handle-undisplayer handle)
5290 (mm-remove-part handle)
5291 (gnus-bind-safe-url-regexp (mm-display-part handle)))))))
5293 (defun gnus-mime-action-on-part (&optional action)
5294 "Do something with the MIME attachment at \(point\)."
5296 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
5297 (gnus-article-check-buffer)
5298 (let ((action-pair (assoc action gnus-mime-action-alist)))
5300 (funcall (cdr action-pair)))))
5302 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5303 "Call FUNCTION on MIME part N.
5304 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5305 If INTERACTIVE, call FUNCTION interactivly."
5307 ;; Check whether the article is displayed.
5308 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5309 (setq window (get-buffer-window gnus-article-buffer t))
5310 (frame-visible-p (setq frame (window-frame window))))
5311 (error "No article is displayed"))
5312 (with-current-buffer gnus-article-buffer
5313 ;; Check whether the article displays the right contents.
5314 (unless (with-current-buffer gnus-summary-buffer
5315 (eq gnus-current-article (gnus-summary-article-number)))
5316 (error "You should select the right article first"))
5318 (setq n (prefix-numeric-value n))
5320 (setq n (or (get-text-property pt 'gnus-part)
5322 (get-text-property (1- pt) 'gnus-part))
5323 (get-text-property (prog2
5329 (or (and (setq pt (previous-single-property-change
5332 (next-single-property-change (point) 'gnus-part)
5336 ;; Check whether the specified part exists.
5337 (when (> n (length gnus-article-mime-handle-alist))
5338 (error "No such part")))
5341 ;; To select the window is needed so that the cursor
5342 ;; might be visible on the MIME button.
5343 (select-window (prog1
5345 (setq window (selected-window))
5346 ;; Article may be displayed in the other frame.
5347 (gnus-select-frame-set-input-focus
5350 (setq frame (selected-frame))))))
5351 (when (gnus-article-goto-part n)
5352 ;; We point the cursor and the arrow at the MIME button
5353 ;; when the `function' prompt the user for something.
5354 (let ((cursor-in-non-selected-windows t)
5355 (overlay-arrow-string "=>")
5356 (overlay-arrow-position (point-marker)))
5359 ((and no-handle interactive)
5360 (call-interactively function))
5366 (cdr (assq n gnus-article-mime-handle-alist))))
5369 (cdr (assq n gnus-article-mime-handle-alist)))))
5370 (set-marker overlay-arrow-position nil)
5371 (unless gnus-auto-select-part
5372 (gnus-select-frame-set-input-focus frame)
5373 (select-window window))))
5375 (if gnus-inhibit-mime-unbuttonizing
5376 ;; This is the default though the program shouldn't reach here.
5377 (error "No such part")
5378 ;; The part which doesn't have the MIME button is selected.
5379 ;; So, we display all the buttons and redo it.
5380 (let ((gnus-inhibit-mime-unbuttonizing t))
5381 (gnus-summary-show-article)
5382 (gnus-article-part-wrapper n function no-handle))))))
5384 (defun gnus-article-pipe-part (n)
5385 "Pipe MIME part N, which is the numerical prefix."
5387 (gnus-article-part-wrapper n 'mm-pipe-part))
5389 (defun gnus-article-save-part (n)
5390 "Save MIME part N, which is the numerical prefix."
5392 (gnus-article-part-wrapper n 'mm-save-part))
5394 (defun gnus-article-interactively-view-part (n)
5395 "View MIME part N interactively, which is the numerical prefix."
5397 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5399 (defun gnus-article-copy-part (n)
5400 "Copy MIME part N, which is the numerical prefix."
5402 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5404 (defun gnus-article-view-part-as-charset (n)
5405 "View MIME part N using a specified charset.
5406 N is the numerical prefix."
5408 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5410 (defun gnus-article-view-part-externally (n)
5411 "View MIME part N externally, which is the numerical prefix."
5413 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5415 (defun gnus-article-inline-part (n)
5416 "Inline MIME part N, which is the numerical prefix."
5418 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5420 (defun gnus-article-save-part-and-strip (n)
5421 "Save MIME part N and replace it with an external body.
5422 N is the numerical prefix."
5424 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5426 (defun gnus-article-replace-part (n)
5427 "Replace MIME part N with an external body.
5428 N is the numerical prefix."
5430 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5432 (defun gnus-article-delete-part (n)
5433 "Delete MIME part N and add some information about the removed part.
5434 N is the numerical prefix."
5436 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5438 (defun gnus-article-view-part-as-type (n)
5439 "Choose a MIME media type, and view part N as such.
5440 N is the numerical prefix."
5442 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5444 (defun gnus-article-mime-match-handle-first (condition)
5447 (dolist (ihandle gnus-article-mime-handle-alist)
5449 ((functionp condition)
5450 (funcall condition (cdr ihandle)))
5451 ((eq condition 'undisplayed)
5452 (not (or (mm-handle-undisplayer (cdr ihandle))
5453 (equal (mm-handle-media-type (cdr ihandle))
5454 "multipart/alternative"))))
5455 ((eq condition 'undisplayed-alternative)
5456 (not (mm-handle-undisplayer (cdr ihandle))))
5458 (gnus-article-goto-part (car ihandle))
5459 (or (not n) (< (car ihandle) n)))
5460 (setq n (car ihandle))))
5464 (defun gnus-article-view-part (&optional n)
5465 "View MIME part N, which is the numerical prefix."
5467 (with-current-buffer gnus-article-buffer
5468 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5469 gnus-article-mime-match-handle-function)))
5470 (when (> n (length gnus-article-mime-handle-alist))
5471 (error "No such part"))
5472 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5473 (when (gnus-article-goto-part n)
5474 (if (equal (car handle) "multipart/alternative")
5475 (gnus-article-press-button)
5476 (when (eq (gnus-mm-display-part handle) 'internal)
5477 (gnus-set-window-start)))))))
5479 (defsubst gnus-article-mime-total-parts ()
5480 (if (bufferp (car gnus-article-mime-handles))
5482 (1- (length gnus-article-mime-handles))))
5484 (defun gnus-mm-display-part (handle)
5485 "Display HANDLE and fix MIME button."
5486 (let ((id (get-text-property (point) 'gnus-part))
5488 (inhibit-read-only t))
5491 (let ((window (selected-window))
5492 (mail-parse-charset gnus-newsgroup-charset)
5493 (mail-parse-ignored-charsets
5494 (if (gnus-buffer-live-p gnus-summary-buffer)
5495 (with-current-buffer gnus-summary-buffer
5496 gnus-newsgroup-ignored-charsets)
5500 (let ((win (gnus-get-buffer-window (current-buffer) t))
5503 (select-window win))
5506 (if (mm-handle-displayed-p handle)
5507 ;; This will remove the part.
5508 (mm-display-part handle)
5510 (narrow-to-region (point)
5511 (if (eobp) (point) (1+ (point))))
5512 (gnus-bind-safe-url-regexp (mm-display-part handle))
5513 ;; We narrow to the part itself and
5514 ;; then call the treatment functions.
5515 (goto-char (point-min))
5517 (narrow-to-region (point) (point-max))
5520 (gnus-article-mime-total-parts)
5521 (mm-handle-media-type handle)))))
5522 (if (window-live-p window)
5523 (select-window window)))))
5526 (gnus-insert-mime-button
5527 handle id (list (mm-handle-displayed-p handle)))
5528 (goto-char point))))
5530 (defun gnus-article-goto-part (n)
5531 "Go to MIME part N."
5532 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5534 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5535 (let ((gnus-tmp-name
5536 (or (mail-content-type-get (mm-handle-type handle) 'name)
5537 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5538 (mail-content-type-get (mm-handle-type handle) 'url)
5540 (gnus-tmp-type (mm-handle-media-type handle))
5541 (gnus-tmp-description (or (mm-handle-description handle) ""))
5543 (if (if displayed (car displayed)
5544 (mm-handle-displayed-p handle))
5546 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5548 gnus-tmp-type-long b e)
5549 (when (string-match ".*/" gnus-tmp-name)
5550 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5551 (setq gnus-tmp-type-long (concat gnus-tmp-type
5552 (and (not (equal gnus-tmp-name ""))
5553 (concat "; " gnus-tmp-name))))
5554 (unless (equal gnus-tmp-description "")
5555 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5560 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5561 `(keymap ,gnus-mime-button-map
5562 gnus-callback gnus-mm-display-part
5563 gnus-part ,gnus-tmp-id
5564 article-type annotation
5567 ;; Exclude a newline.
5570 (when gnus-article-button-face
5571 (gnus-overlay-put (gnus-make-overlay b e nil t)
5572 'face gnus-article-button-face))
5573 (widget-convert-button
5576 :action 'gnus-widget-press-button
5577 :button-keymap gnus-mime-button-map
5579 (lambda (widget/window &optional overlay pos)
5580 ;; Needed to properly clear the message due to a bug in
5581 ;; wid-edit (XEmacs only).
5582 (if (boundp 'help-echo-owns-message)
5583 (setq help-echo-owns-message t))
5585 "%S: %s the MIME part; %S: more options"
5586 (aref gnus-mouse-2 0)
5587 ;; XEmacs will get a single widget arg; Emacs 21 will get
5588 ;; window, overlay, position.
5589 (if (mm-handle-displayed-p
5591 (with-current-buffer (gnus-overlay-buffer overlay)
5592 (widget-get (widget-at (gnus-overlay-start overlay))
5594 (widget-get widget/window :mime-handle)))
5596 (aref gnus-down-mouse-3 0))))))
5598 (defun gnus-widget-press-button (elems el)
5599 (goto-char (widget-get elems :from))
5600 (gnus-article-press-button))
5602 (defvar gnus-displaying-mime nil)
5604 (defun gnus-display-mime (&optional ihandles)
5605 "Display the MIME parts."
5607 (save-selected-window
5608 (let ((window (get-buffer-window gnus-article-buffer))
5611 (select-window window)
5612 ;; We have to do this since selecting the window
5613 ;; may change the point. So we set the window point.
5614 (set-window-point window point)))
5615 (let ((handles ihandles)
5616 (inhibit-read-only t)
5619 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5620 (when gnus-article-emulate-mime
5621 (mm-uu-dissect-text-parts handles)))
5622 (gnus-article-emulate-mime
5623 (setq handles (mm-uu-dissect))))
5624 (when (and (not ihandles)
5625 (not gnus-displaying-mime))
5626 ;; Top-level call; we clean up.
5627 (when gnus-article-mime-handles
5628 (mm-destroy-parts gnus-article-mime-handles)
5629 (setq gnus-article-mime-handle-alist nil));; A trick.
5630 (setq gnus-article-mime-handles handles)
5631 ;; We allow users to glean info from the handles.
5632 (when gnus-article-mime-part-function
5633 (gnus-mime-part-function handles)))
5635 (or (not (stringp (car handles)))
5638 (when (and (not ihandles)
5639 (not gnus-displaying-mime))
5640 ;; Clean up for mime parts.
5642 (delete-region (point) (point-max)))
5643 (let ((gnus-displaying-mime t))
5644 (gnus-mime-display-part handles)))
5647 (narrow-to-region (point) (point-max))
5648 (gnus-treat-article nil 1 1)
5651 ;; Highlight the headers.
5655 (narrow-to-region (point-min) (point))
5656 (gnus-article-save-original-date
5657 (gnus-treat-article 'head)))))))
5658 ;; Cope with broken MIME messages.
5659 (goto-char (point-max))
5663 (defcustom gnus-mime-display-multipart-as-mixed nil
5664 "Display \"multipart\" parts as \"multipart/mixed\".
5666 If t, it overrides nil values of
5667 `gnus-mime-display-multipart-alternative-as-mixed' and
5668 `gnus-mime-display-multipart-related-as-mixed'."
5669 :group 'gnus-article-mime
5672 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5673 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5675 :group 'gnus-article-mime
5678 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5679 "Display \"multipart/related\" parts as \"multipart/mixed\".
5681 If displaying \"text/html\" is discouraged \(see
5682 `mm-discouraged-alternatives'\) images or other material inside a
5683 \"multipart/related\" part might be overlooked when this variable is nil."
5685 :group 'gnus-article-mime
5688 (defun gnus-mime-display-part (handle)
5690 ;; Maybe a broken MIME message.
5693 ((not (stringp (car handle)))
5694 (gnus-mime-display-single handle))
5695 ;; User-defined multipart
5696 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5697 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5699 ;; multipart/alternative
5700 ((and (equal (car handle) "multipart/alternative")
5701 (not (or gnus-mime-display-multipart-as-mixed
5702 gnus-mime-display-multipart-alternative-as-mixed)))
5703 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5704 (push (cons id handle) gnus-article-mime-handle-alist)
5705 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5706 ;; multipart/related
5707 ((and (equal (car handle) "multipart/related")
5708 (not (or gnus-mime-display-multipart-as-mixed
5709 gnus-mime-display-multipart-related-as-mixed)))
5710 ;;;!!!We should find the start part, but we just default
5711 ;;;!!!to the first part.
5712 ;;(gnus-mime-display-part (cadr handle))
5713 ;;;!!! Most multipart/related is an HTML message plus images.
5714 ;;;!!! Unfortunately we are unable to let W3 display those
5715 ;;;!!! included images, so we just display it as a mixed multipart.
5716 ;;(gnus-mime-display-mixed (cdr handle))
5717 ;;;!!! No, w3 can display everything just fine.
5718 (gnus-mime-display-part (cadr handle)))
5719 ((equal (car handle) "multipart/signed")
5720 (gnus-add-wash-type 'signed)
5721 (gnus-mime-display-security handle))
5722 ((equal (car handle) "multipart/encrypted")
5723 (gnus-add-wash-type 'encrypted)
5724 (gnus-mime-display-security handle))
5725 ;; Other multiparts are handled like multipart/mixed.
5727 (gnus-mime-display-mixed (cdr handle)))))
5729 (defun gnus-mime-part-function (handles)
5730 (if (stringp (car handles))
5731 (mapcar 'gnus-mime-part-function (cdr handles))
5732 (funcall gnus-article-mime-part-function handles)))
5734 (defun gnus-mime-display-mixed (handles)
5735 (mapcar 'gnus-mime-display-part handles))
5737 (defun gnus-mime-display-single (handle)
5738 (let ((type (mm-handle-media-type handle))
5739 (ignored gnus-ignored-mime-types)
5746 (when (string-match (pop ignored) type)
5747 (throw 'ignored nil)))
5748 (if (and (setq not-attachment
5749 (and (not (mm-inline-override-p handle))
5750 (or (not (mm-handle-disposition handle))
5751 (equal (car (mm-handle-disposition handle))
5753 (mm-attachment-override-p handle))))
5754 (mm-automatic-display-p handle)
5756 (mm-inlinable-p handle)
5757 (mm-inlined-p handle))
5758 (mm-automatic-external-display-p type)))
5760 (when (equal (mm-handle-media-supertype handle) "text")
5762 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5764 (push (cons id handle) gnus-article-mime-handle-alist)
5766 (equal (mm-handle-media-supertype handle) "message"))
5769 (cond ((not (bolp)) 2)
5770 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5772 (when (or (not display)
5773 (not (gnus-unbuttonized-mime-type-p type)))
5774 (gnus-insert-mime-button
5775 handle id (list (or display (and not-attachment text))))
5776 (gnus-article-insert-newline)
5777 ;; Remember modify the number of forward lines.
5785 (let ((mail-parse-charset gnus-newsgroup-charset)
5786 (mail-parse-ignored-charsets
5787 (save-excursion (condition-case ()
5788 (set-buffer gnus-summary-buffer)
5790 gnus-newsgroup-ignored-charsets)))
5791 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5792 (goto-char (point-max)))
5793 ((and text not-attachment)
5797 (gnus-article-insert-newline)
5800 (let ((charset (or (mail-content-type-get (mm-handle-type handle)
5802 (and (equal type "text/calendar") 'utf-8))))
5803 (cond ((not charset)
5804 (mm-string-as-multibyte (mm-get-part handle)))
5805 ((eq charset 'gnus-decoded)
5806 (with-current-buffer (mm-handle-buffer handle)
5809 (mm-decode-string (mm-get-part handle) charset)))))
5810 (goto-char (point-max))))
5814 (narrow-to-region beg (point))
5815 (if (eq handle gnus-article-mime-handles)
5816 ;; The format=flowed case.
5817 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5818 ;; Don't count signature parts that are never displayed.
5819 ;; The part number should be re-calculated supposing this
5820 ;; might be a message/rfc822 part.
5822 (dolist (part gnus-article-mime-handles)
5823 (unless (or (stringp part)
5824 (equal (car (mm-handle-type part))
5825 "application/pgp-signature"))
5826 (push part handles)))
5828 nil (length (memq handle handles)) (length handles)
5829 (mm-handle-media-type handle)))))))))))
5831 (defun gnus-unbuttonized-mime-type-p (type)
5832 "Say whether TYPE is to be unbuttonized."
5833 (unless gnus-inhibit-mime-unbuttonizing
5835 (let ((types gnus-unbuttonized-mime-types))
5837 (when (string-match (pop types) type)
5838 (throw 'found t)))))
5840 (let ((types gnus-buttonized-mime-types))
5842 (when (string-match (pop types) type)
5843 (throw 'found t)))))))))
5845 (defun gnus-article-insert-newline ()
5846 "Insert a newline, but mark it as undeletable."
5847 (gnus-put-text-property
5848 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5850 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5851 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5854 handle (inhibit-read-only t) from props begend not-pref)
5855 (save-window-excursion
5858 (narrow-to-region (car ibegend)
5861 (goto-char (car ibegend))
5864 (delete-region (point-min) (point-max))
5865 (mm-remove-parts handles))
5866 (setq begend (list (point-marker)))
5868 (unless (setq not-pref (cadr (member preferred ihandles)))
5869 (setq not-pref (car ihandles)))
5872 (not (gnus-unbuttonized-mime-type-p
5873 "multipart/alternative")))
5874 (gnus-add-text-properties
5877 (insert (format "%d. " id))
5881 (unless ,(not ibegend)
5882 (setq gnus-article-mime-handle-alist
5883 ',gnus-article-mime-handle-alist))
5884 (gnus-mime-display-alternative
5885 ',ihandles ',not-pref ',begend ,id))
5886 keymap ,gnus-mime-button-map
5887 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5888 face ,gnus-article-button-face
5890 article-type multipart))
5891 (widget-convert-button 'link from (point)
5892 :action 'gnus-widget-press-button
5893 :button-keymap gnus-widget-button-keymap)
5895 (while (setq handle (pop handles))
5896 (gnus-add-text-properties
5899 (insert (format "(%c) %-18s"
5900 (if (equal handle preferred) ?* ? )
5901 (mm-handle-media-type handle)))
5905 (unless ,(not ibegend)
5906 (setq gnus-article-mime-handle-alist
5907 ',gnus-article-mime-handle-alist))
5908 (gnus-mime-display-alternative
5909 ',ihandles ',handle ',begend ,id))
5910 keymap ,gnus-mime-button-map
5911 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5912 face ,gnus-article-button-face
5915 (widget-convert-button 'link from (point)
5916 :action 'gnus-widget-press-button
5917 :button-keymap gnus-widget-button-keymap)
5921 (if (stringp (car preferred))
5922 (gnus-display-mime preferred)
5923 (let ((mail-parse-charset gnus-newsgroup-charset)
5924 (mail-parse-ignored-charsets
5925 (with-current-buffer gnus-summary-buffer
5926 gnus-newsgroup-ignored-charsets)))
5927 (gnus-bind-safe-url-regexp (mm-display-part preferred))
5931 (narrow-to-region (car begend) (point-max))
5933 nil (length gnus-article-mime-handle-alist)
5934 (gnus-article-mime-total-parts)
5935 (mm-handle-media-type handle))))))
5936 (goto-char (point-max))
5937 (setcdr begend (point-marker)))))
5939 (goto-char point))))
5941 (defconst gnus-article-wash-status-strings
5942 (let ((alist '((cite "c" "Possible hidden citation text"
5943 " " "All citation text visible")
5944 (headers "h" "Hidden headers"
5945 " " "All headers visible.")
5946 (pgp "p" "Encrypted or signed message status hidden"
5947 " " "No hidden encryption nor digital signature status")
5948 (signature "s" "Signature has been hidden"
5949 " " "Signature is visible")
5950 (overstrike "o" "Overstrike (^H) characters applied"
5951 " " "No overstrike characters applied")
5952 (emphasis "e" "/*_Emphasis_*/ characters applied"
5953 " " "No /*_emphasis_*/ characters applied")))
5955 (dolist (entry alist result)
5956 (let ((key (nth 0 entry))
5957 (on (copy-sequence (nth 1 entry)))
5958 (on-help (nth 2 entry))
5959 (off (copy-sequence (nth 3 entry)))
5960 (off-help (nth 4 entry)))
5961 (put-text-property 0 1 'help-echo on-help on)
5962 (put-text-property 0 1 'help-echo off-help off)
5963 (push (list key on off) result))))
5964 "Alist of strings describing wash status in the mode line.
5965 Each entry has the form (KEY ON OF), where the KEY is a symbol
5966 representing the particular washing function, ON is the string to use
5967 in the article mode line when the washing function is active, and OFF
5968 is the string to use when it is inactive.")
5970 (defun gnus-article-wash-status-entry (key value)
5971 (let ((entry (assoc key gnus-article-wash-status-strings)))
5972 (if value (nth 1 entry) (nth 2 entry))))
5974 (defun gnus-article-wash-status ()
5975 "Return a string which display status of article washing."
5976 (with-current-buffer gnus-article-buffer
5977 (let ((cite (memq 'cite gnus-article-wash-types))
5978 (headers (memq 'headers gnus-article-wash-types))
5979 (boring (memq 'boring-headers gnus-article-wash-types))
5980 (pgp (memq 'pgp gnus-article-wash-types))
5981 (pem (memq 'pem gnus-article-wash-types))
5982 (signed (memq 'signed gnus-article-wash-types))
5983 (encrypted (memq 'encrypted gnus-article-wash-types))
5984 (signature (memq 'signature gnus-article-wash-types))
5985 (overstrike (memq 'overstrike gnus-article-wash-types))
5986 (emphasis (memq 'emphasis gnus-article-wash-types)))
5988 (gnus-article-wash-status-entry 'cite cite)
5989 (gnus-article-wash-status-entry 'headers (or headers boring))
5990 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5991 (gnus-article-wash-status-entry 'signature signature)
5992 (gnus-article-wash-status-entry 'overstrike overstrike)
5993 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5995 (defun gnus-add-wash-type (type)
5996 "Add a washing of TYPE to the current status."
5997 (add-to-list 'gnus-article-wash-types type))
5999 (defun gnus-delete-wash-type (type)
6000 "Add a washing of TYPE to the current status."
6001 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6003 (defun gnus-add-image (category image)
6004 "Add IMAGE of CATEGORY to the list of displayed images."
6005 (let ((entry (assq category gnus-article-image-alist)))
6007 (setq entry (list category))
6008 (push entry gnus-article-image-alist))
6009 (nconc entry (list image))))
6011 (defun gnus-delete-images (category)
6012 "Delete all images in CATEGORY."
6013 (let ((entry (assq category gnus-article-image-alist)))
6014 (dolist (image (cdr entry))
6015 (gnus-remove-image image category))
6016 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6017 (gnus-delete-wash-type category)))
6019 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6021 (defun gnus-article-maybe-hide-headers ()
6022 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6023 Provided for backwards compatibility."
6024 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6025 (not (with-current-buffer gnus-summary-buffer
6026 gnus-have-all-headers)))
6027 (not gnus-inhibit-hiding))
6028 (gnus-article-hide-headers)))
6032 (defun gnus-output-to-file (file-name)
6033 "Append the current article to a file named FILE-NAME.
6034 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6035 text and used as the value of the coding cookie which is added to the
6036 top of a file. Otherwise, this function saves a raw article without
6038 (let* ((artbuf (current-buffer))
6039 (file-name-coding-system nnmail-pathname-coding-system)
6040 (coding gnus-article-save-coding-system)
6041 (coding-system-for-read (if coding
6042 nil ;; Rely on the coding cookie.
6043 mm-text-coding-system))
6044 (coding-system-for-write (or coding
6045 mm-text-coding-system-for-write
6046 mm-text-coding-system))
6047 (exists (file-exists-p file-name)))
6050 (insert-file-contents file-name)
6051 (goto-char (point-min))
6052 ;; Remove the existing coding cookie.
6053 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6054 (delete-region (match-beginning 0) (match-end 0))))
6055 (goto-char (point-max))
6056 (insert-buffer-substring artbuf)
6057 ;; Append newline at end of the buffer as separator, and then
6059 (goto-char (point-max))
6062 ;; If the coding system is not suitable to encode the text,
6063 ;; ask a user for a proper one.
6064 (when (fboundp 'select-safe-coding-system)
6065 (setq coding (coding-system-base
6066 (save-window-excursion
6067 (select-safe-coding-system (point-min) (point-max)
6069 (setq coding-system-for-write
6070 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6072 (goto-char (point-min))
6073 ;; Add the coding cookie.
6074 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6075 coding-system-for-write)))
6078 (write-region (point-min) (point-max) file-name nil 'no-message)
6079 (message "Appended to %s" file-name))
6080 (write-region (point-min) (point-max) file-name))))
6083 (defun gnus-narrow-to-page (&optional arg)
6084 "Narrow the article buffer to a page.
6085 If given a numerical ARG, move forward ARG pages."
6087 (setq arg (if arg (prefix-numeric-value arg) 0))
6088 (with-current-buffer gnus-article-buffer
6090 ;; Remove any old next/prev buttons.
6091 (when (gnus-visual-p 'page-marker)
6092 (let ((inhibit-read-only t))
6093 (gnus-remove-text-with-property 'gnus-prev)
6094 (gnus-remove-text-with-property 'gnus-next)))
6096 (when (save-excursion
6098 (if (re-search-backward page-delimiter nil 'move (abs arg))
6100 (setq nd (match-beginning 0)
6102 (when (re-search-backward page-delimiter nil t)
6103 (setq st (match-end 0))))
6104 (when (re-search-forward page-delimiter nil t)
6105 (setq nd (match-beginning 0)
6108 (if (re-search-forward page-delimiter nil 'move arg)
6110 (setq st (match-end 0)
6112 (when (re-search-forward page-delimiter nil t)
6113 (setq nd (match-beginning 0))))
6114 (when (re-search-backward page-delimiter nil t)
6115 (setq st (match-end 0)
6118 (when (re-search-backward page-delimiter nil t)
6119 (goto-char (setq st (match-end 0))))
6120 (when (re-search-forward page-delimiter nil t)
6121 (setq nd (match-beginning 0)))
6123 (setq gnus-page-broken t)
6124 (when pt (goto-char pt))
6125 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6126 (when (gnus-visual-p 'page-marker)
6130 (gnus-insert-next-page-button))
6133 (gnus-insert-prev-page-button))))))))
6135 ;; Article mode commands
6137 (defun gnus-article-goto-next-page ()
6138 "Show the next page of the article."
6140 (when (gnus-article-next-page)
6141 (goto-char (point-min))
6142 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6145 (defun gnus-article-goto-prev-page ()
6146 "Show the previous page of the article."
6148 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6149 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6150 (gnus-article-prev-page nil)))
6152 ;; This is cleaner but currently breaks `gnus-pick-mode':
6154 ;; (defun gnus-article-goto-next-page ()
6155 ;; "Show the next page of the article."
6157 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6158 ;; (gnus-summary-next-page)))
6160 ;; (defun gnus-article-goto-prev-page ()
6161 ;; "Show the next page of the article."
6163 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6164 ;; (gnus-summary-prev-page)))
6166 (defun gnus-article-next-page (&optional lines)
6167 "Show the next page of the current article.
6168 If end of article, return non-nil. Otherwise return nil.
6169 Argument LINES specifies lines to be scrolled up."
6171 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6172 (if (and (not (and gnus-article-over-scroll
6173 (> (count-lines (window-start) (point-max))
6174 (if (featurep 'xemacs)
6175 (or lines (1- (window-height)))
6176 (+ (or lines (1- (window-height))) scroll-margin)))))
6179 (and (pos-visible-in-window-p) ;Not continuation line.
6180 (>= (1+ (point)) (point-max))))) ;Allow for trailing newline.
6181 ;; Nothing in this page.
6182 (if (or (not gnus-page-broken)
6187 (eobp)))) ;Real end-of-buffer?
6189 (when gnus-article-over-scroll
6190 (gnus-article-next-page-1 lines))
6192 (gnus-narrow-to-page 1) ;Go to next page.
6194 ;; More in this page.
6195 (gnus-article-next-page-1 lines)
6198 (defmacro gnus-article-beginning-of-window ()
6199 "Move point to the beginning of the window.
6200 In Emacs, the point is placed at the line number which `scroll-margin'
6202 (if (featurep 'xemacs)
6203 '(move-to-window-line 0)
6204 '(move-to-window-line
6205 (min (max 0 scroll-margin)
6206 (max 1 (- (window-height)
6207 (if mode-line-format 1 0)
6208 (if header-line-format 1 0)
6211 (defun gnus-article-next-page-1 (lines)
6212 (unless (featurep 'xemacs)
6213 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
6214 ;; too many number of lines if `scroll-margin' is set as two or greater.
6215 (when (and (numberp lines)
6217 (> scroll-margin 0))
6218 (setq lines (min lines
6219 (max 0 (- (count-lines (window-start) (point-max))
6222 (let ((scroll-in-place nil))
6225 ;; Long lines may cause an end-of-buffer error.
6226 (goto-char (point-max))))
6227 (gnus-article-beginning-of-window))
6229 (defun gnus-article-prev-page (&optional lines)
6230 "Show previous page of current article.
6231 Argument LINES specifies lines to be scrolled down."
6233 (move-to-window-line 0)
6234 (if (and gnus-page-broken
6236 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6238 (gnus-narrow-to-page -1) ;Go to previous page.
6239 (goto-char (point-max))
6240 (recenter (if gnus-article-over-scroll
6242 (max (if (featurep 'xemacs)
6244 (+ lines scroll-margin))
6246 (- (window-height) 2))
6250 (let ((scroll-in-place nil))
6251 (scroll-down lines))
6252 (beginning-of-buffer
6253 (goto-char (point-min))))
6254 (gnus-article-beginning-of-window))))
6256 (defun gnus-article-only-boring-p ()
6257 "Decide whether there is only boring text remaining in the article.
6258 Something \"interesting\" is a word of at least two letters that does
6259 not have a face in `gnus-article-boring-faces'."
6260 (when (and gnus-article-skip-boring
6261 (boundp 'gnus-article-boring-faces)
6262 (symbol-value 'gnus-article-boring-faces))
6264 (let ((inhibit-point-motion-hooks t))
6266 (while (re-search-forward "\\b\\w\\w" nil t)
6268 (when (not (gnus-intersection
6269 (gnus-faces-at (point))
6270 (symbol-value 'gnus-article-boring-faces)))
6271 (throw 'only-boring nil)))
6272 (throw 'only-boring t))))))
6274 (defun gnus-article-refer-article ()
6275 "Read article specified by message-id around point."
6278 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6279 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6280 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6281 (let ((msg-id (concat "<" (match-string 0) ">")))
6282 (set-buffer gnus-summary-buffer)
6283 (gnus-summary-refer-article msg-id))
6284 (error "No references around point"))))
6286 (defun gnus-article-show-summary ()
6287 "Reconfigure windows to show summary buffer."
6289 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6290 (error "There is no summary buffer for this article buffer")
6291 (gnus-article-set-globals)
6292 (gnus-configure-windows 'article)
6293 (gnus-summary-goto-subject gnus-current-article)
6294 (gnus-summary-position-point)))
6296 (defun gnus-article-describe-briefly ()
6297 "Describe article mode commands briefly."
6299 (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")))
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 (key-binding keys t))))
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 (key-binding keys t)))
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)
6472 ;; Calling help-buffer will autoload help-mode.
6473 (defvar help-xref-stack-item)
6475 (defun gnus-article-describe-bindings (&optional prefix)
6476 "Show a list of all defined keys, and their definitions.
6477 The optional argument PREFIX, if non-nil, should be a key sequence;
6478 then we display only bindings that start with that prefix."
6480 (gnus-article-check-buffer)
6481 (let ((keymap (copy-keymap gnus-article-mode-map))
6482 (map (copy-keymap gnus-article-send-map))
6483 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6485 (define-key keymap "S" map)
6486 (define-key map [t] nil)
6487 (with-current-buffer gnus-article-current-summary
6490 (if (setq parent (keymap-parent gnus-article-mode-map))
6492 (setq parent (copy-keymap parent))
6493 (set-keymap-parent parent (current-local-map)))
6494 (current-local-map)))
6495 (set-keymap-parent map (key-binding "S"))
6496 (let (key def gnus-pick-mode)
6498 (setq key (pop sumkeys))
6499 (cond ((and (vectorp key) (= (length key) 1)
6500 (consp (setq def (aref key 0)))
6501 (numberp (car def)) (numberp (cdr def)))
6502 (when (< (max (car def) (cdr def)) 128)
6506 (nreverse (gnus-uncompress-range def)))
6508 ((setq def (key-binding key))
6509 (unless (eq def 'undefined)
6510 (define-key keymap key def))))))
6511 (when (boundp 'gnus-agent-summary-mode)
6512 (setq agent gnus-agent-summary-mode))
6513 (when (boundp 'gnus-draft-mode)
6514 (setq draft gnus-draft-mode)))
6516 (use-local-map keymap)
6517 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6518 (set (make-local-variable 'gnus-draft-mode) draft)
6519 (describe-bindings prefix))
6520 (let ((item `((lambda (prefix)
6521 (with-current-buffer ,(current-buffer)
6522 (gnus-article-describe-bindings prefix)))
6524 (with-current-buffer (if (fboundp 'help-buffer)
6525 (let (help-xref-following) (help-buffer))
6526 "*Help*") ;; Emacs 21
6527 (setq help-xref-stack-item item)))))
6529 (defun gnus-article-reply-with-original (&optional wide)
6530 "Start composing a reply mail to the current message.
6531 The text in the region will be yanked. If the region isn't active,
6532 the entire article will be yanked."
6534 (let ((article (cdr gnus-article-current))
6536 (if (not (gnus-region-active-p))
6537 (with-current-buffer gnus-summary-buffer
6538 (gnus-summary-reply (list (list article)) wide))
6539 (setq contents (buffer-substring (point) (mark t)))
6540 ;; Deactivate active regions.
6541 (when (and (boundp 'transient-mark-mode)
6542 transient-mark-mode)
6543 (setq mark-active nil))
6544 (with-current-buffer gnus-summary-buffer
6546 (list (list article contents)) wide)))))
6548 (defun gnus-article-wide-reply-with-original ()
6549 "Start composing a wide reply mail to the current message.
6550 The text in the region will be yanked. If the region isn't active,
6551 the entire article will be yanked."
6553 (gnus-article-reply-with-original t))
6555 (defun gnus-article-followup-with-original ()
6556 "Compose a followup to the current article.
6557 The text in the region will be yanked. If the region isn't active,
6558 the entire article will be yanked."
6560 (let ((article (cdr gnus-article-current))
6562 (if (not (gnus-region-active-p))
6563 (with-current-buffer gnus-summary-buffer
6564 (gnus-summary-followup (list (list article))))
6565 (setq contents (buffer-substring (point) (mark t)))
6566 ;; Deactivate active regions.
6567 (when (and (boundp 'transient-mark-mode)
6568 transient-mark-mode)
6569 (setq mark-active nil))
6570 (with-current-buffer gnus-summary-buffer
6571 (gnus-summary-followup
6572 (list (list article contents)))))))
6574 (defun gnus-article-hide (&optional arg force)
6575 "Hide all the gruft in the current article.
6576 This means that signatures, cited text and (some) headers will be
6578 If given a prefix, show the hidden text instead."
6579 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6580 (gnus-article-hide-headers arg)
6581 (gnus-article-hide-list-identifiers arg)
6582 (gnus-article-hide-citation-maybe arg force)
6583 (gnus-article-hide-signature arg))
6585 (defun gnus-article-maybe-highlight ()
6586 "Do some article highlighting if article highlighting is requested."
6587 (when (gnus-visual-p 'article-highlight 'highlight)
6588 (gnus-article-highlight-some)))
6590 (defun gnus-check-group-server ()
6591 ;; Make sure the connection to the server is alive.
6592 (unless (gnus-server-opened
6593 (gnus-find-method-for-group gnus-newsgroup-name))
6594 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6595 (gnus-request-group gnus-newsgroup-name t)))
6598 (autoload 'nneething-get-file-name "nneething"))
6600 (defun gnus-request-article-this-buffer (article group)
6601 "Get an article and insert it into this buffer."
6602 (let (do-update-line sparse-header)
6606 (gnus-kill-all-overlays)
6607 (setq group (or group gnus-newsgroup-name))
6609 ;; Using `gnus-request-article' directly will insert the article into
6610 ;; `nntp-server-buffer' - so we'll save some time by not having to
6611 ;; copy it from the server buffer into the article buffer.
6613 ;; We only request an article by message-id when we do not have the
6614 ;; headers for it, so we'll have to get those.
6615 (when (stringp article)
6616 (gnus-read-header article))
6618 ;; If the article number is negative, that means that this article
6619 ;; doesn't belong in this newsgroup (possibly), so we find its
6620 ;; message-id and request it by id instead of number.
6621 (when (and (numberp article)
6623 (get-buffer gnus-summary-buffer)
6624 (gnus-buffer-exists-p gnus-summary-buffer))
6625 (with-current-buffer gnus-summary-buffer
6626 (let ((header (gnus-summary-article-header article)))
6629 ((memq article gnus-newsgroup-sparse)
6630 ;; This is a sparse gap article.
6631 (setq do-update-line article)
6632 (setq article (mail-header-id header))
6633 (setq sparse-header (gnus-read-header article))
6634 (setq gnus-newsgroup-sparse
6635 (delq article gnus-newsgroup-sparse)))
6637 ;; It's a real article.
6638 (setq article (mail-header-id header)))
6640 ;; It is an extracted pseudo-article.
6641 (setq article 'pseudo)
6642 (gnus-request-pseudo-article header))))
6644 (let ((method (gnus-find-method-for-group
6645 gnus-newsgroup-name)))
6646 (when (and (eq (car method) 'nneething)
6648 (let ((dir (nneething-get-file-name
6649 (mail-header-id header))))
6650 (when (and (stringp dir)
6651 (file-directory-p dir))
6652 (setq article 'nneething)
6653 (gnus-group-enter-directory dir))))))))
6656 ;; Refuse to select canceled articles.
6657 ((and (numberp article)
6659 (get-buffer gnus-summary-buffer)
6660 (gnus-buffer-exists-p gnus-summary-buffer)
6661 (eq (cdr (with-current-buffer gnus-summary-buffer
6662 (assq article gnus-newsgroup-reads)))
6663 gnus-canceled-mark))
6665 ;; We first check `gnus-original-article-buffer'.
6666 ((and (get-buffer gnus-original-article-buffer)
6668 (with-current-buffer gnus-original-article-buffer
6669 (and (equal (car gnus-original-article) group)
6670 (eq (cdr gnus-original-article) article))))
6671 ;; `insert-buffer-substring' would incorrectly use the
6672 ;; equivalent of string-make-multibyte which amount to decoding
6673 ;; with locale-coding-system, causing failure of
6674 ;; subsequent decoding.
6675 (insert (mm-string-to-multibyte
6676 (with-current-buffer gnus-original-article-buffer
6677 (buffer-substring (point-min) (point-max)))))
6679 ;; Check the backlog.
6680 ((and gnus-keep-backlog
6681 (gnus-backlog-request-article group article (current-buffer)))
6683 ;; Check asynchronous pre-fetch.
6684 ((gnus-async-request-fetched-article group article (current-buffer))
6685 (gnus-async-prefetch-next group article gnus-summary-buffer)
6686 (when (and (numberp article) gnus-keep-backlog)
6687 (gnus-backlog-enter-article group article (current-buffer)))
6690 ((and gnus-use-cache
6692 (gnus-cache-request-article article group))
6694 ;; Check the agent cache.
6695 ((gnus-agent-request-article article group)
6697 ;; Get the article and put into the article buffer.
6698 ((or (stringp article)
6700 (let ((gnus-override-method gnus-override-method)
6701 (methods (and (stringp article)
6702 gnus-refer-article-method))
6703 (backend (car (gnus-find-method-for-group
6704 gnus-newsgroup-name)))
6706 (inhibit-read-only t))
6707 (if (or (not (listp methods))
6708 (and (symbolp (car methods))
6709 (assq (car methods) nnoo-definition-alist)))
6710 (setq methods (list methods)))
6711 (when (and (null gnus-override-method)
6713 (setq gnus-override-method (pop methods)))
6715 (when (eq gnus-override-method 'current)
6716 (setq gnus-override-method
6717 (with-current-buffer gnus-summary-buffer
6718 gnus-current-select-method)))
6720 (gnus-kill-all-overlays)
6721 (let ((gnus-newsgroup-name group))
6722 (gnus-check-group-server))
6724 ((gnus-request-article article group (current-buffer))
6725 (when (numberp article)
6726 (gnus-async-prefetch-next group article
6727 gnus-summary-buffer)
6728 (when gnus-keep-backlog
6729 (gnus-backlog-enter-article
6730 group article (current-buffer))))
6731 (setq result 'article))
6733 (setq gnus-override-method (pop methods)))
6734 ((not (string-match "^400 "
6735 (nnheader-get-report backend)))
6736 ;; If we get 400 server disconnect, reconnect and
6737 ;; retry; otherwise, assume the article has expired.
6738 (setq result 'done))))
6739 (and (eq result 'article) 'article)))
6743 ;; Associate this article with the current summary buffer.
6744 (setq gnus-article-current-summary gnus-summary-buffer)
6746 ;; Take the article from the original article buffer
6747 ;; and place it in the buffer it's supposed to be in.
6748 (when (and (get-buffer gnus-article-buffer)
6749 (equal (buffer-name (current-buffer))
6750 (buffer-name (get-buffer gnus-article-buffer))))
6752 (if (get-buffer gnus-original-article-buffer)
6753 (set-buffer gnus-original-article-buffer)
6754 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6755 (buffer-disable-undo)
6756 (setq major-mode 'gnus-original-article-mode)
6757 (setq buffer-read-only t))
6758 (let ((inhibit-read-only t))
6760 (insert-buffer-substring gnus-article-buffer))
6761 (setq gnus-original-article (cons group article)))
6764 (run-hooks 'gnus-article-decode-hook)
6765 ;; Mark article as decoded or not.
6766 (setq gnus-article-decoded-p gnus-article-decode-hook))
6768 ;; Update sparse articles.
6769 (when (and do-update-line
6770 (or (numberp article)
6772 (let ((buf (current-buffer)))
6773 (set-buffer gnus-summary-buffer)
6774 (gnus-summary-update-article do-update-line sparse-header)
6775 (gnus-summary-goto-subject do-update-line nil t)
6776 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6778 (set-buffer buf))))))
6784 (defcustom gnus-article-edit-mode-hook nil
6785 "Hook run in article edit mode buffers."
6786 :group 'gnus-article-various
6789 (defvar gnus-article-edit-done-function nil)
6791 (defvar gnus-article-edit-mode-map nil)
6793 ;; Should we be using derived.el for this?
6794 (unless gnus-article-edit-mode-map
6795 (setq gnus-article-edit-mode-map (make-keymap))
6796 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6798 (gnus-define-keys gnus-article-edit-mode-map
6799 "\C-c?" describe-mode
6800 "\C-c\C-c" gnus-article-edit-done
6801 "\C-c\C-k" gnus-article-edit-exit
6802 "\C-c\C-f\C-t" message-goto-to
6803 "\C-c\C-f\C-o" message-goto-from
6804 "\C-c\C-f\C-b" message-goto-bcc
6805 ;;"\C-c\C-f\C-w" message-goto-fcc
6806 "\C-c\C-f\C-c" message-goto-cc
6807 "\C-c\C-f\C-s" message-goto-subject
6808 "\C-c\C-f\C-r" message-goto-reply-to
6809 "\C-c\C-f\C-n" message-goto-newsgroups
6810 "\C-c\C-f\C-d" message-goto-distribution
6811 "\C-c\C-f\C-f" message-goto-followup-to
6812 "\C-c\C-f\C-m" message-goto-mail-followup-to
6813 "\C-c\C-f\C-k" message-goto-keywords
6814 "\C-c\C-f\C-u" message-goto-summary
6815 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6816 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6817 "\C-c\C-b" message-goto-body
6818 "\C-c\C-i" message-goto-signature
6820 "\C-c\C-t" message-insert-to
6821 "\C-c\C-n" message-insert-newsgroups
6822 "\C-c\C-o" message-sort-headers
6823 "\C-c\C-e" message-elide-region
6824 "\C-c\C-v" message-delete-not-region
6825 "\C-c\C-z" message-kill-to-signature
6826 "\M-\r" message-newline-and-reformat
6827 "\C-c\C-a" mml-attach-file
6828 "\C-a" message-beginning-of-line
6830 "\M-;" comment-region)
6832 (gnus-define-keys (gnus-article-edit-wash-map
6833 "\C-c\C-w" gnus-article-edit-mode-map)
6834 "f" gnus-article-edit-full-stops))
6837 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6839 ["Fetch To" message-insert-to t]
6840 ["Fetch Newsgroups" message-insert-newsgroups t]
6842 ["To" message-goto-to t]
6843 ["From" message-goto-from t]
6844 ["Subject" message-goto-subject t]
6845 ["Cc" message-goto-cc t]
6846 ["Reply-To" message-goto-reply-to t]
6847 ["Summary" message-goto-summary t]
6848 ["Keywords" message-goto-keywords t]
6849 ["Newsgroups" message-goto-newsgroups t]
6850 ["Followup-To" message-goto-followup-to t]
6851 ["Mail-Followup-To" message-goto-mail-followup-to t]
6852 ["Distribution" message-goto-distribution t]
6853 ["Body" message-goto-body t]
6854 ["Signature" message-goto-signature t]))
6856 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6857 "Major mode for editing articles.
6858 This is an extended text-mode.
6860 \\{gnus-article-edit-mode-map}"
6861 (make-local-variable 'gnus-article-edit-done-function)
6862 (make-local-variable 'gnus-prev-winconf)
6863 (set (make-local-variable 'font-lock-defaults)
6864 '(message-font-lock-keywords t))
6865 (set (make-local-variable 'mail-header-separator) "")
6866 (set (make-local-variable 'gnus-article-edit-mode) t)
6867 (easy-menu-add message-mode-field-menu message-mode-map)
6869 (setq buffer-read-only nil)
6870 (buffer-enable-undo)
6873 (defun gnus-article-edit (&optional force)
6874 "Edit the current article.
6875 This will have permanent effect only in mail groups.
6876 If FORCE is non-nil, allow editing of articles even in read-only
6879 (when (and (not force)
6880 (gnus-group-read-only-p))
6881 (error "The current newsgroup does not support article editing"))
6882 (gnus-article-date-original)
6883 (gnus-article-edit-article
6885 `(lambda (no-highlight)
6887 (gnus-summary-edit-article-done
6888 ,(or (mail-header-references gnus-current-headers) "")
6889 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6891 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6892 "Start editing the contents of the current article buffer."
6893 (let ((winconf (current-window-configuration)))
6894 (set-buffer gnus-article-buffer)
6895 (let ((message-auto-save-directory
6896 ;; Don't associate the article buffer with a draft file.
6898 (gnus-article-edit-mode))
6899 (funcall start-func)
6900 (set-buffer-modified-p nil)
6901 (gnus-configure-windows 'edit-article)
6902 (setq gnus-article-edit-done-function exit-func)
6903 (setq gnus-prev-winconf winconf)
6905 (gnus-message 6 "C-c C-c to end edits"))))
6907 (defun gnus-article-edit-done (&optional arg)
6908 "Update the article edits and exit."
6910 (let ((func gnus-article-edit-done-function)
6911 (buf (current-buffer))
6912 (start (window-start))
6914 (winconf gnus-prev-winconf))
6915 (widen) ;; Widen it in case that users narrowed the buffer.
6918 ;; The cache and backlog have to be flushed somewhat.
6919 (when gnus-keep-backlog
6920 (gnus-backlog-remove-article
6921 (car gnus-article-current) (cdr gnus-article-current)))
6922 ;; Flush original article as well.
6923 (when (get-buffer gnus-original-article-buffer)
6924 (with-current-buffer gnus-original-article-buffer
6925 (setq gnus-original-article nil)))
6926 (when gnus-use-cache
6927 (gnus-cache-update-article
6928 (car gnus-article-current) (cdr gnus-article-current)))
6929 ;; We remove all text props from the article buffer.
6930 (kill-all-local-variables)
6931 (set-text-properties (point-min) (point-max) nil)
6933 (set-window-configuration winconf)
6935 (set-window-start (get-buffer-window buf) start)
6936 (set-window-point (get-buffer-window buf) (point)))
6937 (gnus-summary-show-article))
6939 (defun gnus-article-edit-exit ()
6940 "Exit the article editing without updating."
6942 (when (or (not (buffer-modified-p))
6943 (yes-or-no-p "Article modified; kill anyway? "))
6944 (let ((curbuf (current-buffer))
6946 (window-start (window-start)))
6948 (if (gnus-buffer-live-p gnus-original-article-buffer)
6949 (insert-buffer-substring gnus-original-article-buffer))
6950 (let ((winconf gnus-prev-winconf))
6951 (kill-all-local-variables)
6953 (set-window-configuration winconf)
6954 ;; Tippy-toe some to make sure that point remains where it was.
6955 (save-current-buffer
6957 (set-window-start (get-buffer-window (current-buffer)) window-start)
6959 (gnus-summary-show-article)))
6961 (defun gnus-article-edit-full-stops ()
6962 "Interactively repair spacing at end of sentences."
6965 (goto-char (point-min))
6966 (search-forward-regexp "^$" nil t)
6967 (let ((case-fold-search nil))
6968 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6971 ;;; Article highlights
6974 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6976 ;;; Internal Variables:
6978 (defcustom gnus-button-url-regexp
6980 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
6981 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
6982 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
6983 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
6984 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
6988 ;; Match paired parentheses, e.g. in Wikipedia URLs:
6989 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
6990 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
6992 "[" chars punct "]+" "[" chars "]"
6994 (concat ;; XEmacs 21.4 doesn't support POSIX.
6995 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
6996 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
6998 "Regular expression that matches URLs."
6999 :group 'gnus-article-buttons
7002 (defcustom gnus-button-valid-fqdn-regexp
7003 message-valid-fqdn-regexp
7004 "Regular expression that matches a valid FQDN."
7006 :group 'gnus-article-buttons
7009 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7010 (defcustom gnus-button-valid-localpart-regexp
7011 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7012 "Regular expression that matches a localpart of mail addresses or MIDs."
7014 :group 'gnus-article-buttons
7017 (defcustom gnus-button-man-handler 'manual-entry
7018 "Function to use for displaying man pages.
7019 The function must take at least one argument with a string naming the
7022 :type '(choice (function-item :tag "Man" manual-entry)
7023 (function-item :tag "Woman" woman)
7024 (function :tag "Other"))
7025 :group 'gnus-article-buttons)
7027 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
7028 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
7029 If the default site is too slow, try to find a CTAN mirror, see
7030 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
7031 the variable `gnus-button-handle-ctan'."
7033 :group 'gnus-article-buttons
7034 :link '(custom-manual "(gnus)Group Parameters")
7035 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
7036 (const "http://tug.ctan.org/tex-archive/")
7037 (const "http://www.dante.de/CTAN/")
7038 (string :tag "Other")))
7040 (defcustom gnus-button-ctan-handler 'browse-url
7041 "Function to use for displaying CTAN links.
7042 The function must take one argument, the string naming the URL."
7044 :type '(choice (function-item :tag "Browse Url" browse-url)
7045 (function :tag "Other"))
7046 :group 'gnus-article-buttons)
7048 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
7049 "Bogus strings removed from CTAN URLs."
7051 :group 'gnus-article-buttons
7052 :type '(choice (const "^/?tex-archive/\\|/")
7053 (regexp :tag "Other")))
7055 (defcustom gnus-button-ctan-directory-regexp
7057 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
7058 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
7059 "languages" "macros" "nonfree" "obsolete" "support" "systems"
7060 "tds" "tools" "usergrps" "web") t)
7061 "Regular expression for ctan directories.
7062 It should match all directories in the top level of `gnus-ctan-url'."
7064 :group 'gnus-article-buttons
7067 (defcustom gnus-button-mid-or-mail-regexp
7068 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7069 gnus-button-valid-fqdn-regexp
7071 "Regular expression that matches a message ID or a mail address."
7073 :group 'gnus-article-buttons
7076 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7077 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7078 Strings like this can be either a message ID or a mail address. If it is one
7079 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7080 message ID or a mail address, respectively. If this variable is set to the
7081 symbol `ask', always query the user what do do. If it is a function, this
7082 function will be called with the string as its only argument. The function
7083 must return `mid', `mail', `invalid' or `ask'."
7085 :group 'gnus-article-buttons
7086 :type '(choice (function-item :tag "Heuristic function"
7087 gnus-button-mid-or-mail-heuristic)
7092 (defcustom gnus-button-mid-or-mail-heuristic-alist
7093 '((-10.0 . ".+\\$.+@")
7096 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7097 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7098 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7099 (-1.0 . "^[^a-z]+@")
7101 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7102 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7103 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7104 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7107 (-1.0 . "^[0-9][0-9]")
7109 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7110 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7111 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7112 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7114 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7115 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7118 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7120 ;; compensation for TDMA dated mail addresses:
7121 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7123 (-20.0 . "\\.fsf@") ;; Gnus
7126 (-20.0 . "^alpine\\.")
7127 (-20.0 . "_-_") ;; Subject change in thread
7129 (-20.0 . "\\.ln@") ;; leafnode
7130 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7131 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7133 ;; (5.0 . "") ;; $local_part_len <= 7
7134 (10.0 . "^[^0-9]+@")
7135 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7136 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7139 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7141 (0.5 . "^[A-Z][a-z]")
7142 (0.5 . "^[A-Z][a-z][a-z]")
7143 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7144 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7145 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7147 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7148 address. The REGEXP is processed with `case-fold-search' set to nil."
7150 :group 'gnus-article-buttons
7151 :type '(repeat (cons (number :tag "Rate")
7152 (regexp :tag "Regexp"))))
7154 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7155 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7156 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7157 address, `ask' if unsure and `invalid' if the string is invalid."
7158 (let ((case-fold-search nil)
7159 (list gnus-button-mid-or-mail-heuristic-alist)
7160 (result 0) rate regexp lpartlen elem)
7162 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7163 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7164 ;; Certain special cases...
7167 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7168 "^[0-9]+\\.[0-9]+@compuserve\\|"
7169 "@public\\.gmane\\.org")
7171 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7172 (setq result 'mail))
7173 (when (string-match "@.*@\\| " mid-or-mail)
7174 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7175 (setq result 'invalid))
7176 ;; Nothing more to do, if result is not a number here...
7177 (when (numberp result)
7179 (setq elem (car list)
7183 (when (string-match regexp mid-or-mail)
7184 (setq result (+ result rate))
7186 9 "`%s' matched `%s', rate `%s', result `%s'."
7187 mid-or-mail regexp rate result)))
7188 (when (<= lpartlen 7)
7189 (setq result (+ result 5.0))
7190 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7191 mid-or-mail result))
7192 (when (>= lpartlen 12)
7193 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7195 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7196 ;; Long local part should contain realname if e-mail address,
7197 ;; too many digits: message-id.
7198 ;; $score -= 5.0 + 0.1 * $local_part_len;
7199 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7200 (setq result (+ result rate))
7202 9 "Many digits in `%s', rate `%s', result `%s'."
7203 mid-or-mail rate result))
7204 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7206 ;; Too few vowels [^aeiouy]{4,}.*\@
7207 (setq result (+ result -5.0))
7209 9 "Few vowels in `%s', rate `%s', result `%s'."
7210 mid-or-mail -5.0 result))
7212 (setq result (+ result 5.0))
7214 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7215 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7216 ;; Maybe we should make this a customizable alist: (condition . 'result)
7218 ((symbolp result) result)
7219 ;; Now convert number into proper results:
7220 ((< result -10.0) 'mid)
7221 ((> result 10.0) 'mail)
7224 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7225 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7226 (url-mid (concat "news" ":" mid-or-mail))
7227 (url-mailto (concat "mailto" ":" mid-or-mail)))
7228 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7229 (when (fboundp pref)
7231 ;; get rid of surrounding angles...
7233 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7234 (if (or (eq 'mid guessed) (eq 'mail guessed))
7238 (save-window-excursion
7239 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7242 (cond ((eq pref 'mid)
7243 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7244 (gnus-button-handle-news url-mid))
7246 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7247 (gnus-url-mailto url-mailto))
7248 (t (gnus-message 3 "Invalid string.")))))
7250 (defun gnus-button-handle-custom (fun arg)
7251 "Call function FUN on argument ARG.
7252 Both FUN and ARG are supposed to be strings. ARG will be passed
7253 as a symbol to FUN."
7254 (funcall (intern fun)
7255 (if (string-match "^customize-apropos" fun)
7259 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7261 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7264 (defun gnus-button-handle-describe-function (url)
7265 "Call `describe-function' when pushing the corresponding URL button."
7268 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7270 (defun gnus-button-handle-describe-variable (url)
7271 "Call `describe-variable' when pushing the corresponding URL button."
7274 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7276 (defun gnus-button-handle-symbol (url)
7277 "Display help on variable or function.
7278 Calls `describe-variable' or `describe-function'."
7279 (let ((sym (intern url)))
7281 ((fboundp sym) (describe-function sym))
7282 ((boundp sym) (describe-variable sym))
7283 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7285 (defun gnus-button-handle-describe-key (url)
7286 "Call `describe-key' when pushing the corresponding URL button."
7288 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7289 (keys (ignore-errors (eval `(kbd ,key-string)))))
7292 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7294 (defun gnus-button-handle-apropos (url)
7295 "Call `apropos' when pushing the corresponding URL button."
7296 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7298 (defun gnus-button-handle-apropos-command (url)
7299 "Call `apropos' when pushing the corresponding URL button."
7301 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7303 (defun gnus-button-handle-apropos-variable (url)
7304 "Call `apropos' when pushing the corresponding URL button."
7306 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7307 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7309 (defun gnus-button-handle-apropos-documentation (url)
7310 "Call `apropos' when pushing the corresponding URL button."
7312 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7313 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7315 (defun gnus-button-handle-library (url)
7316 "Call `locate-library' when pushing the corresponding URL button."
7317 (gnus-message 9 "url=`%s'" url)
7318 (let* ((lib (locate-library url))
7319 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7321 (gnus-message 1 "Cannot locale library `%s'." url)
7322 (find-file-read-only file))))
7324 (defun gnus-button-handle-ctan (url)
7325 "Call `browse-url' when pushing a CTAN URL button."
7327 gnus-button-ctan-handler
7330 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
7332 (defcustom gnus-button-tex-level 5
7333 "*Integer that says how many TeX-related buttons Gnus will show.
7334 The higher the number, the more buttons will appear and the more false
7335 positives are possible. Note that you can set this variable local to
7336 specific groups. Setting it higher in TeX groups is probably a good idea.
7337 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7338 how to set variables in specific groups."
7340 :group 'gnus-article-buttons
7341 :link '(custom-manual "(gnus)Group Parameters")
7344 (defcustom gnus-button-man-level 5
7345 "*Integer that says how many man-related buttons Gnus will show.
7346 The higher the number, the more buttons will appear and the more false
7347 positives are possible. Note that you can set this variable local to
7348 specific groups. Setting it higher in Unix groups is probably a good idea.
7349 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7350 how to set variables in specific groups."
7352 :group 'gnus-article-buttons
7353 :link '(custom-manual "(gnus)Group Parameters")
7356 (defcustom gnus-button-emacs-level 5
7357 "*Integer that says how many emacs-related buttons Gnus will show.
7358 The higher the number, the more buttons will appear and the more false
7359 positives are possible. Note that you can set this variable local to
7360 specific groups. Setting it higher in Emacs or Gnus related groups is
7361 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7362 `gnus-parameters' on how to set variables in specific groups."
7364 :group 'gnus-article-buttons
7365 :link '(custom-manual "(gnus)Group Parameters")
7368 (defcustom gnus-button-message-level 5
7369 "*Integer that says how many buttons for news or mail messages will appear.
7370 The higher the number, the more buttons will appear and the more false
7371 positives are possible."
7372 ;; mail addresses, MIDs, URLs for news, ...
7374 :group 'gnus-article-buttons
7377 (defcustom gnus-button-browse-level 5
7378 "*Integer that says how many buttons for browsing will appear.
7379 The higher the number, the more buttons will appear and the more false
7380 positives are possible."
7381 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7383 :group 'gnus-article-buttons
7386 (defcustom gnus-button-alist
7387 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7388 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7389 ((concat "\\b\\(nntp\\|news\\):\\("
7390 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7391 0 t gnus-button-handle-news 2)
7392 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7393 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7394 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7395 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7396 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7397 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7398 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7399 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7400 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7401 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7402 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7403 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7404 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7405 ;; RFC 2368 (The mailto URL scheme)
7406 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7407 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7408 ("\\bmailto:\\([^ \n\t]+\\)"
7409 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7411 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
7412 gnus-button-ctan-directory-regexp
7413 "[^][>)!;:,'\n\t ]+\\)")
7414 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
7415 ((concat "\\btex-archive/\\("
7416 gnus-button-ctan-directory-regexp
7417 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
7418 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
7421 gnus-button-ctan-directory-regexp
7422 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
7423 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
7424 ;; Info Konqueror style <info:/foo/bar baz>.
7425 ;; Must come before " Gnus home-grown style".
7426 ("\\binfo://?\\([^'\">\n\t]+\\)"
7427 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7428 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7429 ("\\binfo://\\([^'\">\n\t ]+\\)"
7430 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7431 ;; Info GNOME style <info:foo#bar_baz>
7432 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7433 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7434 ;; Info KDE style <info:(foo)bar baz>
7435 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7436 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7437 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7438 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7439 ("\\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,]*\\)\\)?"
7440 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7441 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7443 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
7444 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7445 ;; Emacs help commands
7446 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7447 ;; regexp doesn't match arguments containing ` '.
7448 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7449 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7450 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7451 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7452 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7453 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7454 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7455 ;; The following entries may lead to many false positives so don't enable
7456 ;; them by default (use a high button level).
7457 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7458 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7459 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7460 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7461 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7462 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7463 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7464 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7465 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7466 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7467 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7468 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7469 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7470 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7471 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7472 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7473 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7474 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7475 ;; Unlike the other regexps we really have to require quoting
7476 ;; here to determine where it ends.
7477 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7478 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7479 ("<URL: *\\([^\n<>]*\\)>"
7480 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7481 ;; RFC 2396 (2.4.3., delims) ...
7482 ("\"URL: *\\([^\n\"]*\\)\""
7483 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7485 (gnus-button-url-regexp
7486 0 (>= gnus-button-browse-level 0) browse-url 0)
7488 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7489 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7490 gnus-button-handle-man 1)
7491 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7492 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7493 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7494 gnus-button-handle-man 1)
7495 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7496 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7497 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7498 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7499 ;; Recognizing patches to .el files. This is somewhat obscure,
7500 ;; but considering the percentage of Gnus users who hack Emacs
7502 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7503 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7504 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7505 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7506 ;; MID or mail: To avoid too many false positives we don't try to catch
7507 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7508 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7509 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7510 ;; so that non-ambiguous entries (see above) match first.
7511 (gnus-button-mid-or-mail-regexp
7512 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7513 "*Alist of regexps matching buttons in article bodies.
7515 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7516 REGEXP: is the string (case insensitive) matching text around the button (can
7517 also be Lisp expression evaluating to a string),
7518 BUTTON: is the number of the regexp grouping actually matching the button,
7519 FORM: is a Lisp expression which must eval to true for the button to
7521 CALLBACK: is the function to call when the user push this button, and each
7522 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7524 CALLBACK can also be a variable, in that case the value of that
7525 variable it the real callback function."
7526 :group 'gnus-article-buttons
7527 :type '(repeat (list (choice regexp variable sexp)
7528 (integer :tag "Button")
7530 (function :tag "Callback")
7533 (integer :tag "Regexp group")))))
7534 (put 'gnus-button-alist 'risky-local-variable t)
7536 (defcustom gnus-header-button-alist
7537 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7538 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7539 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7540 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7541 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7542 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7543 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7544 0 (>= gnus-button-browse-level 0) browse-url 0)
7545 ("^Subject:" gnus-button-url-regexp
7546 0 (>= gnus-button-browse-level 0) browse-url 0)
7547 ("^[^:]+:" gnus-button-url-regexp
7548 0 (>= gnus-button-browse-level 0) browse-url 0)
7549 ("^OpenPGP:.*url=" gnus-button-url-regexp
7550 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7551 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7552 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7553 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7554 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7555 "*Alist of headers and regexps to match buttons in article heads.
7557 This alist is very similar to `gnus-button-alist', except that each
7558 alist has an additional HEADER element first in each entry:
7560 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7562 HEADER is a regexp to match a header. For a fuller explanation, see
7563 `gnus-button-alist'."
7564 :group 'gnus-article-buttons
7565 :group 'gnus-article-headers
7566 :type '(repeat (list (regexp :tag "Header")
7567 (choice regexp variable)
7568 (integer :tag "Button")
7570 (function :tag "Callback")
7573 (integer :tag "Regexp group")))))
7574 (put 'gnus-header-button-alist 'risky-local-variable t)
7578 (defun gnus-article-push-button (event)
7579 "Check text under the mouse pointer for a callback function.
7580 If the text under the mouse pointer has a `gnus-callback' property,
7581 call it with the value of the `gnus-data' text property."
7583 (set-buffer (window-buffer (posn-window (event-start event))))
7584 (let* ((pos (posn-point (event-start event)))
7585 (data (get-text-property pos 'gnus-data))
7586 (fun (get-text-property pos 'gnus-callback)))
7589 (funcall fun data))))
7591 (defun gnus-article-press-button ()
7592 "Check text at point for a callback function.
7593 If the text at point has a `gnus-callback' property,
7594 call it with the value of the `gnus-data' text property."
7596 (let ((data (get-text-property (point) 'gnus-data))
7597 (fun (get-text-property (point) 'gnus-callback)))
7599 (funcall fun data))))
7601 (defun gnus-article-highlight (&optional force)
7602 "Highlight current article.
7603 This function calls `gnus-article-highlight-headers',
7604 `gnus-article-highlight-citation',
7605 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7606 do the highlighting. See the documentation for those functions."
7607 (interactive (list 'force))
7608 (gnus-article-highlight-headers)
7609 (gnus-article-highlight-citation force)
7610 (gnus-article-highlight-signature)
7611 (gnus-article-add-buttons force)
7612 (gnus-article-add-buttons-to-head))
7614 (defun gnus-article-highlight-some (&optional force)
7615 "Highlight current article.
7616 This function calls `gnus-article-highlight-headers',
7617 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7618 do the highlighting. See the documentation for those functions."
7619 (interactive (list 'force))
7620 (gnus-article-highlight-headers)
7621 (gnus-article-highlight-signature)
7622 (gnus-article-add-buttons))
7624 (defun gnus-article-highlight-headers ()
7625 "Highlight article headers as specified by `gnus-header-face-alist'."
7627 (gnus-with-article-headers
7628 (let (regexp header-face field-face from hpoints fpoints)
7629 (dolist (entry gnus-header-face-alist)
7630 (goto-char (point-min))
7631 (setq regexp (concat "^\\("
7632 (if (string-equal "" (nth 0 entry))
7636 header-face (nth 1 entry)
7637 field-face (nth 2 entry))
7638 (while (and (re-search-forward regexp nil t)
7642 (unless (search-forward ":" nil t)
7644 (when (and header-face
7645 (not (memq (point) hpoints)))
7646 (push (point) hpoints)
7647 (gnus-put-text-property from (point) 'face header-face))
7648 (when (and field-face
7649 (not (memq (setq from (point)) fpoints)))
7651 (if (re-search-forward "^[^ \t]" nil t)
7653 (goto-char (point-max)))
7654 (gnus-put-text-property from (point) 'face field-face)))))))
7656 (defun gnus-article-highlight-signature ()
7657 "Highlight the signature in an article.
7658 It does this by highlighting everything after
7659 `gnus-signature-separator' using the face `gnus-signature'."
7661 (gnus-with-article-buffer
7662 (let ((inhibit-point-motion-hooks t))
7664 (when (and gnus-signature-face
7665 (gnus-article-narrow-to-signature))
7666 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7667 'face gnus-signature-face)
7669 (gnus-article-search-signature)
7670 (let ((start (match-beginning 0))
7671 (end (set-marker (make-marker) (1+ (match-end 0)))))
7672 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7675 (defun gnus-button-in-region-p (b e prop)
7676 "Say whether PROP exists in the region."
7677 (text-property-not-all b e prop nil))
7679 (defun gnus-article-add-buttons (&optional force)
7680 "Find external references in the article and make buttons of them.
7681 \"External references\" are things like Message-IDs and URLs, as
7682 specified by `gnus-button-alist'."
7683 (interactive (list 'force))
7684 (gnus-with-article-buffer
7685 (let ((inhibit-point-motion-hooks t)
7686 (case-fold-search t)
7687 (alist gnus-button-alist)
7689 ;; Remove all old markers.
7690 (let (marker entry new-list)
7691 (while (setq marker (pop gnus-button-marker-list))
7692 (if (or (< marker (point-min)) (>= marker (point-max)))
7693 (push marker new-list)
7695 (when (setq entry (gnus-button-entry))
7696 (put-text-property (match-beginning (nth 1 entry))
7697 (match-end (nth 1 entry))
7698 'gnus-callback nil))
7699 (set-marker marker nil)))
7700 (setq gnus-button-marker-list new-list))
7701 ;; We skip the headers.
7704 (while (setq entry (pop alist))
7705 (setq regexp (eval (car entry)))
7707 (while (re-search-forward regexp nil t)
7708 (let ((start (match-beginning (nth 1 entry)))
7709 (end (match-end (nth 1 entry)))
7710 (from (match-beginning 0)))
7711 (when (and (or (eq t (nth 2 entry))
7712 (eval (nth 2 entry)))
7713 (not (gnus-button-in-region-p
7714 start end 'gnus-callback)))
7715 ;; That optional form returned non-nil, so we add the
7717 (setq from (set-marker (make-marker) from))
7718 (push from gnus-button-marker-list)
7719 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7720 (gnus-article-extend-url-button from start end))
7721 (gnus-article-add-button start end
7722 'gnus-button-push from)))))))))
7724 (defun gnus-article-extend-url-button (beg start end)
7725 "Extend url button if url is folded into two or more lines.
7726 Return non-nil if button is extended. BEG is a marker that points to
7727 the beginning position of a text containing url. START and END are
7728 the endpoints of a url button before it is extended. The concatenated
7729 url is put as the `gnus-button-url' overlay property on the button."
7730 (let ((opoint (point))
7731 (points (list start end))
7736 (not (looking-at "[\t ]*[\">]")))
7740 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7741 (buffer-substring (point-at-bol) start)))
7743 (setq url (list (buffer-substring start end))
7744 delim (if (match-beginning 1) ">" "\""))
7746 (setq regexp (concat
7747 (when (and (looking-at
7748 message-cite-prefix-regexp)
7749 (< (match-end 0) start))
7750 (regexp-quote (match-string 0)))
7752 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7756 (and (looking-at regexp)
7759 (push (or (match-string 2)
7762 (push (setq end (or (match-end 2)
7765 (push (or (match-beginning 2)
7766 (match-beginning 1))
7768 (match-beginning 2)))
7769 (let (gnus-article-mouse-face widget-mouse-face)
7771 (gnus-article-add-button (pop points) (pop points)
7772 'gnus-button-push beg)))
7773 (let ((overlay (gnus-make-overlay start end)))
7774 (gnus-overlay-put overlay 'evaporate t)
7775 (gnus-overlay-put overlay 'gnus-button-url
7776 (list (mapconcat 'identity (nreverse url) "")))
7777 (when gnus-article-mouse-face
7778 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7780 (goto-char opoint))))
7782 ;; Add buttons to the head of an article.
7783 (defun gnus-article-add-buttons-to-head ()
7784 "Add buttons to the head of the article."
7786 (gnus-with-article-headers
7788 (dolist (entry gnus-header-button-alist)
7789 ;; Each alist entry.
7790 (goto-char (point-min))
7791 (while (re-search-forward (car entry) nil t)
7792 ;; Each header matching the entry.
7793 (setq beg (match-beginning 0))
7794 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7795 (match-beginning 0))
7798 (while (re-search-forward (eval (nth 1 entry)) end t)
7799 ;; Each match within a header.
7800 (let* ((entry (cdr entry))
7801 (start (match-beginning (nth 1 entry)))
7802 (end (match-end (nth 1 entry)))
7803 (form (nth 2 entry)))
7804 (goto-char (match-end 0))
7806 (gnus-article-add-button
7807 start end (nth 3 entry)
7808 (buffer-substring (match-beginning (nth 4 entry))
7809 (match-end (nth 4 entry)))))))
7810 (goto-char end))))))
7812 ;;; External functions:
7814 (defun gnus-article-add-button (from to fun &optional data)
7815 "Create a button between FROM and TO with callback FUN and data DATA."
7816 (when gnus-article-button-face
7817 (gnus-overlay-put (gnus-make-overlay from to nil t)
7818 'face gnus-article-button-face))
7819 (gnus-add-text-properties
7821 (nconc (and gnus-article-mouse-face
7822 (list gnus-mouse-face-prop gnus-article-mouse-face))
7823 (list 'gnus-callback fun)
7824 (and data (list 'gnus-data data))))
7825 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7826 :button-keymap gnus-widget-button-keymap))
7828 ;;; Internal functions:
7830 (defun gnus-article-set-globals ()
7831 (with-current-buffer gnus-summary-buffer
7832 (gnus-set-global-variables)))
7834 (defun gnus-signature-toggle (end)
7835 (gnus-with-article-buffer
7836 (let ((inhibit-point-motion-hooks t))
7837 (if (text-property-any end (point-max) 'article-type 'signature)
7839 (gnus-delete-wash-type 'signature)
7840 (gnus-remove-text-properties-when
7841 'article-type 'signature end (point-max)
7842 (cons 'article-type (cons 'signature
7843 gnus-hidden-properties))))
7844 (gnus-add-wash-type 'signature)
7845 (gnus-add-text-properties-when
7846 'article-type nil end (point-max)
7847 (cons 'article-type (cons 'signature
7848 gnus-hidden-properties)))))
7849 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7850 (gnus-set-mode-line 'article))))
7852 (defun gnus-button-entry ()
7853 ;; Return the first entry in `gnus-button-alist' matching this place.
7854 (let ((alist gnus-button-alist)
7857 (setq entry (pop alist))
7858 (if (looking-at (eval (car entry)))
7863 (defun gnus-button-push (marker)
7864 ;; Push button starting at MARKER.
7867 (let* ((entry (gnus-button-entry))
7868 (inhibit-point-motion-hooks t)
7870 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7871 (get-char-property marker 'gnus-button-url))
7872 (mapcar (lambda (group)
7873 (let ((string (match-string group)))
7874 (set-text-properties
7875 0 (length string) nil string)
7877 (nthcdr 4 entry)))))
7882 (fboundp (symbol-value fun)))
7883 (apply (symbol-value fun) args))
7885 (gnus-message 1 "You must define `%S' to use this button"
7886 (cons fun args)))))))
7888 (defun gnus-parse-news-url (url)
7889 (let (scheme server port group message-id articles)
7892 (goto-char (point-min))
7893 (when (looking-at "\\([A-Za-z]+\\):")
7894 (setq scheme (match-string 1))
7895 (goto-char (match-end 0)))
7896 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7897 (setq server (match-string 1))
7898 (setq port (if (stringp (match-string 3))
7899 (string-to-number (match-string 3))
7901 (goto-char (match-end 0)))
7904 ((looking-at "\\(.*@.*\\)")
7905 (setq message-id (match-string 1)))
7906 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7907 (setq group (match-string 1)
7908 articles (split-string (match-string 2) "-")))
7909 ((looking-at "\\([^/]+\\)/?")
7910 (setq group (match-string 1)))
7912 (error "Unknown news URL syntax"))))
7913 (list scheme server port group message-id articles)))
7915 (defun gnus-button-handle-news (url)
7917 (destructuring-bind (scheme server port group message-id articles)
7918 (gnus-parse-news-url url)
7921 (with-current-buffer gnus-summary-buffer
7923 (let ((gnus-refer-article-method
7924 (nconc (list (list 'nntp server))
7925 gnus-refer-article-method))
7926 (nntp-port-number (or port "nntp")))
7927 (gnus-message 7 "Fetching %s with %s"
7928 message-id gnus-refer-article-method)
7929 (gnus-summary-refer-article message-id))
7930 (gnus-summary-refer-article message-id))))
7932 (gnus-button-fetch-group url)))))
7934 (defun gnus-button-patch (library line)
7935 "Visit an Emacs Lisp library LIBRARY on line LINE."
7937 (let ((file (locate-library (file-name-nondirectory library))))
7939 (error "Couldn't find library %s" library))
7941 (goto-char (point-min))
7942 (forward-line (1- (string-to-number line)))))
7944 (defun gnus-button-handle-man (url)
7946 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7947 (when (eq gnus-button-man-handler 'woman)
7948 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7949 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7950 (funcall gnus-button-man-handler url))
7952 (defun gnus-button-handle-info-url (url)
7953 "Fetch an info URL."
7954 (setq url (mm-subst-char-in-string ?+ ?\ url))
7956 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7957 (gnus-info-find-node
7958 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7960 ")" (gnus-url-unhex-string (match-string 2 url)))))
7961 ((string-match "([^)\"]+)[^\"]+" url)
7963 (gnus-replace-in-string
7964 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7965 (gnus-info-find-node url))
7966 (t (error "Can't parse %s" url))))
7968 (defun gnus-button-handle-info-url-gnome (url)
7969 "Fetch GNOME style info URL."
7970 (setq url (mm-subst-char-in-string ?_ ?\ url))
7971 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7972 (gnus-info-find-node
7974 (gnus-url-unhex-string
7975 (match-string 1 url))
7977 (or (gnus-url-unhex-string
7978 (match-string 2 url))
7980 (error "Can't parse %s" url)))
7982 (defun gnus-button-handle-info-url-kde (url)
7983 "Fetch KDE style info URL."
7984 (gnus-info-find-node (gnus-url-unhex-string url)))
7986 ;; (info) will autoload info.el
7987 (declare-function Info-menu "info" (menu-item &optional fork))
7988 (declare-function Info-index-next "info" (num))
7990 (defun gnus-button-handle-info-keystrokes (url)
7991 "Call `info' when pushing the corresponding URL button."
7992 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
7993 (let (node indx comma)
7995 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
7996 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
7997 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET"
7998 "\\(?:[ \t\n,]*\\)\\)?")
8000 (setq node (match-string 2 url)
8001 indx (match-string 3 url))
8002 (error "Can't parse %s" url))
8006 (when (> (length indx) 0)
8007 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8010 (setq comma (match-string 2 indx))
8011 (setq indx (match-string 1 indx))
8014 (dotimes (i (with-temp-buffer
8016 ;; Note: the XEmacs version of `how-many' takes
8017 ;; no optional argument.
8018 (goto-char (point-min))
8020 (Info-index-next 1)))
8023 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8024 (declare-function pgg-display-output-buffer "pgg" (start end status))
8026 (defun gnus-button-openpgp (url)
8027 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8029 (mm-url-insert-file-contents-external url)
8030 (pgg-snarf-keys-region (point-min) (point-max))
8031 (pgg-display-output-buffer nil nil nil)))
8033 (defun gnus-button-message-id (message-id)
8035 (with-current-buffer gnus-summary-buffer
8036 (gnus-summary-refer-article message-id)))
8038 (defun gnus-button-fetch-group (address &rest ignore)
8039 "Fetch GROUP specified by ADDRESS."
8040 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8042 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8043 ;; for nntp:// and news://
8044 (setq address (match-string 3 address)))
8045 (if (not (string-match "[:/]" address))
8046 ;; This is just a simple group url.
8047 (gnus-group-read-ephemeral-group address gnus-select-method)
8050 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8052 (error "Can't parse %s" address)
8053 (gnus-group-read-ephemeral-group
8054 (match-string 4 address)
8055 `(nntp ,(match-string 1 address)
8056 (nntp-address ,(match-string 1 address))
8057 (nntp-port-number ,(if (match-end 3)
8058 (match-string 3 address)
8061 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8063 (defun gnus-url-parse-query-string (query &optional downcase)
8064 (let (retval pairs cur key val)
8065 (setq pairs (split-string query "&"))
8067 (setq cur (car pairs)
8069 (if (not (string-match "=" cur))
8071 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8072 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8074 (setq key (downcase key)))
8075 (setq cur (assoc key retval))
8077 (setcdr cur (cons val (cdr cur)))
8078 (setq retval (cons (list key val) retval)))))
8081 (defun gnus-url-mailto (url)
8082 ;; Send mail to someone
8083 (when (string-match "mailto:/*\\(.*\\)" url)
8084 (setq url (substring url (match-beginning 1) nil)))
8085 (let (to args subject func)
8086 (setq args (gnus-url-parse-query-string
8087 (if (string-match "^\\?" url)
8089 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8090 (concat "to=" (match-string 1 url) "&"
8091 (match-string 2 url))
8092 (concat "to=" url)))
8094 subject (cdr-safe (assoc "subject" args)))
8097 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8100 (message-position-on-field (caar args)))
8101 (insert (gnus-replace-in-string
8102 (mapconcat 'identity (reverse (cdar args)) ", ")
8104 (setq args (cdr args)))
8107 (message-goto-subject))))
8109 (defun gnus-button-embedded-url (address)
8110 "Activate ADDRESS with `browse-url'."
8111 (browse-url (gnus-strip-whitespace address)))
8113 ;;; Next/prev buttons in the article buffer.
8115 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8116 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8118 (defvar gnus-prev-page-map
8119 (let ((map (make-sparse-keymap)))
8120 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8121 (define-key map "\r" 'gnus-button-prev-page)
8124 (defvar gnus-next-page-map
8125 (let ((map (make-sparse-keymap)))
8126 (unless (>= emacs-major-version 21)
8127 ;; XEmacs doesn't care.
8128 (set-keymap-parent map gnus-article-mode-map))
8129 (define-key map gnus-mouse-2 'gnus-button-next-page)
8130 (define-key map "\r" 'gnus-button-next-page)
8133 (defun gnus-insert-prev-page-button ()
8135 (inhibit-read-only t))
8137 gnus-prev-page-line-format nil
8138 `(keymap ,gnus-prev-page-map
8140 gnus-callback gnus-article-button-prev-page
8141 article-type annotation))
8143 ;; Exclude a newline.
8146 (when gnus-article-button-face
8147 (gnus-overlay-put (gnus-make-overlay b e nil t)
8148 'face gnus-article-button-face))
8149 (widget-convert-button
8151 :action 'gnus-button-prev-page
8152 :button-keymap gnus-prev-page-map)))
8154 (defun gnus-button-next-page (&optional args more-args)
8155 "Go to the next page."
8157 (let ((win (selected-window)))
8158 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8159 (gnus-article-next-page)
8160 (select-window win)))
8162 (defun gnus-button-prev-page (&optional args more-args)
8163 "Go to the prev page."
8165 (let ((win (selected-window)))
8166 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8167 (gnus-article-prev-page)
8168 (select-window win)))
8170 (defun gnus-insert-next-page-button ()
8172 (inhibit-read-only t))
8173 (gnus-eval-format gnus-next-page-line-format nil
8174 `(keymap ,gnus-next-page-map
8176 gnus-callback gnus-article-button-next-page
8177 article-type annotation))
8179 ;; Exclude a newline.
8182 (when gnus-article-button-face
8183 (gnus-overlay-put (gnus-make-overlay b e nil t)
8184 'face gnus-article-button-face))
8185 (widget-convert-button
8187 :action 'gnus-button-next-page
8188 :button-keymap gnus-next-page-map)))
8190 (defun gnus-article-button-next-page (arg)
8191 "Go to the next page."
8193 (let ((win (selected-window)))
8194 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8195 (gnus-article-next-page)
8196 (select-window win)))
8198 (defun gnus-article-button-prev-page (arg)
8199 "Go to the prev page."
8201 (let ((win (selected-window)))
8202 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8203 (gnus-article-prev-page)
8204 (select-window win)))
8206 (defvar gnus-decode-header-methods
8207 '(mail-decode-encoded-word-region)
8208 "List of methods used to decode headers.
8210 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8211 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8212 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8213 whose names match REGEXP.
8216 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8217 mail-decode-encoded-word-region
8218 (\"chinese\" . rfc1843-decode-region))
8221 (defvar gnus-decode-header-methods-cache nil)
8223 (defun gnus-multi-decode-header (start end)
8224 "Apply the functions from `gnus-encoded-word-methods' that match."
8225 (unless (and gnus-decode-header-methods-cache
8226 (eq gnus-newsgroup-name
8227 (car gnus-decode-header-methods-cache)))
8228 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8229 (dolist (x gnus-decode-header-methods)
8231 (nconc gnus-decode-header-methods-cache (list x))
8232 (if (and gnus-newsgroup-name
8233 (string-match (car x) gnus-newsgroup-name))
8234 (nconc gnus-decode-header-methods-cache
8236 (let ((xlist gnus-decode-header-methods-cache))
8239 (narrow-to-region start end)
8241 (funcall (pop xlist) (point-min) (point-max))))))
8244 ;;; Treatment top-level handling.
8247 (defun gnus-treat-article (condition &optional part-number total-parts type)
8248 (let ((length (- (point-max) (point-min)))
8249 (alist gnus-treatment-function-alist)
8250 (article-goto-body-goes-to-point-min-p t)
8254 (let ((list gnus-article-treat-types))
8256 (when (string-match (pop list) type)
8257 (throw 'found t)))))))
8258 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8260 (gnus-run-hooks 'gnus-part-display-hook)
8261 (dolist (elem alist)
8264 (when (gnus-buffer-live-p gnus-summary-buffer)
8265 (set-buffer gnus-summary-buffer))
8266 (symbol-value (car elem))))
8267 (when (and (or (consp val)
8269 (gnus-treat-predicate val)
8270 (or (not (get (car elem) 'highlight))
8273 (funcall (cadr elem)))))))
8275 ;; Dynamic variables.
8276 (defvar part-number)
8277 (defvar total-parts)
8282 (defun gnus-treat-predicate (val)
8289 (stringp (car val)))
8290 (apply 'gnus-or (mapcar `(lambda (s)
8291 (string-match s ,(or gnus-newsgroup-name "")))
8294 (let ((pred (pop val)))
8297 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8299 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8301 (not (gnus-treat-predicate (car val))))
8303 (equal (car val) type))
8305 (error "%S is not a valid predicate" pred)))))
8313 (eq part-number total-parts))
8317 (error "%S is not a valid value" val))))
8319 (defun gnus-article-encrypt-body (protocol &optional n)
8320 "Encrypt the article body."
8323 (or gnus-article-encrypt-protocol
8324 (completing-read "Encrypt protocol: "
8325 gnus-article-encrypt-protocol-alist
8327 current-prefix-arg))
8328 ;; User might hit `K E' instead of `K e', so prompt once.
8329 (when (and gnus-article-encrypt-protocol
8331 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8332 (error "Encrypt aborted")))
8333 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8335 (error "Can't find the encrypt protocol %s" protocol))
8336 (if (member gnus-newsgroup-name '("nndraft:delayed"
8339 (error "Can't encrypt the article in group %s"
8340 gnus-newsgroup-name))
8341 (gnus-summary-iterate n
8342 (with-current-buffer gnus-summary-buffer
8343 (let ((mail-parse-charset gnus-newsgroup-charset)
8344 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8345 (summary-buffer gnus-summary-buffer)
8347 (gnus-set-global-variables)
8348 (when (gnus-group-read-only-p)
8349 (error "The current newsgroup does not support article encrypt"))
8350 (gnus-summary-show-article t)
8352 (or (mail-header-references gnus-current-headers) ""))
8353 (set-buffer gnus-article-buffer)
8354 (let* ((inhibit-read-only t)
8356 (mapcar (lambda (field)
8357 (and (save-restriction
8358 (message-narrow-to-head)
8359 (goto-char (point-min))
8360 (search-forward field nil t))
8362 (message-narrow-to-field)
8364 (delete-region (point-min) (point-max))
8366 '("Content-Type:" "Content-Transfer-Encoding:"
8367 "Content-Disposition:"))))
8368 (message-narrow-to-head)
8369 (message-remove-header "MIME-Version")
8370 (goto-char (point-max))
8371 (setq point (point))
8372 (insert (apply 'concat headers))
8374 (narrow-to-region point (point-max))
8375 (let ((message-options message-options))
8376 (message-options-set 'message-sender user-mail-address)
8377 (message-options-set 'message-recipients user-mail-address)
8378 (message-options-set 'message-sign-encrypt 'not)
8380 (goto-char (point-min))
8381 (insert "MIME-Version: 1.0\n")
8383 (gnus-summary-edit-article-done
8384 references nil summary-buffer t))
8385 (when gnus-keep-backlog
8386 (gnus-backlog-remove-article
8387 (car gnus-article-current) (cdr gnus-article-current)))
8388 (when (get-buffer gnus-original-article-buffer)
8389 (with-current-buffer gnus-original-article-buffer
8390 (setq gnus-original-article nil)))
8391 (when gnus-use-cache
8392 (gnus-cache-update-article
8393 (car gnus-article-current) (cdr gnus-article-current))))))))
8395 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8396 "The following specs can be used:
8397 %t The security MIME type
8400 %D Details if button is pressed")
8402 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8403 "The following specs can be used:
8404 %t The security MIME type
8407 %D Details if button is pressed")
8409 (defvar gnus-mime-security-button-line-format-alist
8410 '((?t gnus-tmp-type ?s)
8411 (?i gnus-tmp-info ?s)
8412 (?d gnus-tmp-details ?s)
8413 (?D gnus-tmp-pressed-details ?s)))
8415 (defvar gnus-mime-security-button-commands
8416 '((gnus-article-press-button "\r" "Show Detail")
8420 (gnus-mime-security-save-part "o" "Save...")
8429 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8432 (defvar gnus-mime-security-button-map
8433 (let ((map (make-sparse-keymap)))
8434 (define-key map gnus-mouse-2 'gnus-article-push-button)
8435 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8436 (dolist (c gnus-mime-security-button-commands)
8437 (define-key map (cadr c) (car c)))
8441 gnus-mime-security-button-menu gnus-mime-security-button-map
8442 "Security button menu."
8446 (unless (eq (car c) 'undefined)
8447 (vector (caddr c) (car c) :active t)))
8448 gnus-mime-security-button-commands))))
8450 (defun gnus-mime-security-button-menu (event prefix)
8451 "Construct a context-sensitive menu of security commands."
8452 (interactive "e\nP")
8453 (save-window-excursion
8454 (let ((pos (event-start event)))
8455 (select-window (posn-window pos))
8456 (goto-char (posn-point pos))
8457 (gnus-article-check-buffer)
8458 (popup-menu gnus-mime-security-button-menu nil prefix))))
8460 (defvar gnus-mime-security-details-buffer nil)
8462 (defvar gnus-mime-security-button-pressed nil)
8464 (defvar gnus-mime-security-show-details-inline t
8465 "If non-nil, show details in the article buffer.")
8467 (defun gnus-mime-security-verify-or-decrypt (handle)
8468 (mm-remove-parts (cdr handle))
8469 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8470 point (inhibit-read-only t))
8472 (goto-char (car region)))
8473 (setq point (point))
8474 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8475 (let* ((mm-verify-option 'known)
8476 (mm-decrypt-option 'known)
8477 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8478 (unless (eq nparts (cdr handle))
8479 (mm-destroy-parts (cdr handle))
8480 (setcdr handle nparts))))
8481 (gnus-mime-display-security handle)
8483 (delete-region (point) (cdr region))
8484 (set-marker (car region) nil)
8485 (set-marker (cdr region) nil))
8488 (defun gnus-mime-security-show-details (handle)
8489 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8491 (gnus-message 5 "No details.")
8492 (if gnus-mime-security-show-details-inline
8493 (let ((gnus-mime-security-button-pressed
8494 (not (get-text-property (point) 'gnus-mime-details)))
8495 (gnus-mime-security-button-line-format
8496 (get-text-property (point) 'gnus-line-format))
8497 (inhibit-read-only t))
8499 (while (eq (get-text-property (point) 'gnus-line-format)
8500 gnus-mime-security-button-line-format)
8504 (narrow-to-region (point) (point))
8505 (gnus-insert-mime-security-button handle))
8506 (delete-region (point)
8507 (or (text-property-not-all
8510 gnus-mime-security-button-line-format)
8513 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8514 (with-current-buffer gnus-mime-security-details-buffer
8517 (setq gnus-mime-security-details-buffer
8518 (gnus-get-buffer-create "*MIME Security Details*")))
8519 (with-current-buffer gnus-mime-security-details-buffer
8521 (goto-char (point-min)))
8522 (pop-to-buffer gnus-mime-security-details-buffer)))))
8524 (defun gnus-mime-security-press-button (handle)
8526 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8527 (gnus-mime-security-show-details handle)
8528 (gnus-mime-security-verify-or-decrypt handle))))
8530 (defun gnus-insert-mime-security-button (handle &optional displayed)
8531 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8534 (or (nth 2 (assoc protocol mm-verify-function-alist))
8535 (nth 2 (assoc protocol mm-decrypt-function-alist))
8537 (if (equal (car handle) "multipart/signed")
8538 " Signed" " Encrypted")
8541 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8544 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8545 gnus-tmp-pressed-details
8547 (setq gnus-tmp-details
8548 (if gnus-tmp-details
8549 (concat "\n" gnus-tmp-details)
8551 (setq gnus-tmp-pressed-details
8552 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8557 gnus-mime-security-button-line-format
8558 gnus-mime-security-button-line-format-alist
8559 `(keymap ,gnus-mime-security-button-map
8560 gnus-callback gnus-mime-security-press-button
8561 gnus-line-format ,gnus-mime-security-button-line-format
8562 gnus-mime-details ,gnus-mime-security-button-pressed
8563 article-type annotation
8566 ;; Exclude a newline.
8569 (when gnus-article-button-face
8570 (gnus-overlay-put (gnus-make-overlay b e nil t)
8571 'face gnus-article-button-face))
8572 (widget-convert-button
8575 :action 'gnus-widget-press-button
8576 :button-keymap gnus-mime-security-button-map
8578 (lambda (widget/window &optional overlay pos)
8579 ;; Needed to properly clear the message due to a bug in
8580 ;; wid-edit (XEmacs only).
8581 (when (boundp 'help-echo-owns-message)
8582 (setq help-echo-owns-message t))
8584 "%S: show detail; %S: more options"
8585 (aref gnus-mouse-2 0)
8586 (aref gnus-down-mouse-3 0))))))
8588 (defun gnus-mime-display-security (handle)
8590 (narrow-to-region (point) (point))
8591 (unless (gnus-unbuttonized-mime-type-p (car handle))
8592 (gnus-insert-mime-security-button handle))
8593 (gnus-mime-display-part (cadr handle))
8596 (unless (gnus-unbuttonized-mime-type-p (car handle))
8597 (let ((gnus-mime-security-button-line-format
8598 gnus-mime-security-button-end-line-format))
8599 (gnus-insert-mime-security-button handle)))
8600 (mm-set-handle-multipart-parameter
8602 (cons (set-marker (make-marker) (point-min))
8603 (set-marker (make-marker) (point-max))))
8604 (goto-char (point-max))))
8606 (defun gnus-mime-security-run-function (function)
8607 "Run FUNCTION with the security part under point."
8608 (gnus-article-check-buffer)
8609 (let ((data (get-text-property (point) 'gnus-data))
8611 (when (and (stringp (car-safe data))
8612 (setq buffer (mm-handle-multipart-original-buffer data))
8613 (setq handle (cadr data)))
8614 (if (bufferp (mm-handle-buffer handle))
8616 (setq handle (cons buffer (copy-sequence (cdr handle))))
8617 (mm-handle-set-undisplayer handle nil))
8618 (setq handle (mm-make-handle
8620 (mm-handle-multipart-ctl-parameter handle 'protocol)
8621 nil nil nil nil nil nil)))
8622 (funcall function handle))))
8624 (defun gnus-mime-security-save-part ()
8625 "Save the security part under point."
8627 (gnus-mime-security-run-function 'mm-save-part))
8629 (defun gnus-mime-security-pipe-part ()
8630 "Pipe the security part under point to a process."
8632 (gnus-mime-security-run-function 'mm-pipe-part))
8638 (run-hooks 'gnus-art-load-hook)
8640 ;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
8641 ;;; gnus-art.el ends here