1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
33 (defvar w3m-minor-mode-map
)
49 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
50 (autoload 'gnus-button-mailto
"gnus-msg")
51 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
52 (autoload 'parse-time-string
"parse-time" nil nil
)
53 (autoload 'ansi-color-apply-on-region
"ansi-color")
54 (autoload 'mm-url-insert-file-contents-external
"mm-url")
55 (autoload 'mm-extern-cache-contents
"mm-extern")
57 (defgroup gnus-article nil
59 :link
'(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link
'(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link
'(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link
'(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link
'(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link
'(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link
'(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link
'(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link
'(custom-manual "(gnus)Saving Articles")
101 :group
'gnus-article
)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link
'(custom-manual "(gnus)Using MIME")
106 :group
'gnus-article
)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link
'(custom-manual "(gnus)Article Buttons")
111 :group
'gnus-article
)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link
'(custom-manual "(gnus)Misc Article")
116 :group
'gnus-article
)
118 (defcustom gnus-ignored-headers
121 (concat "^" header
":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
160 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
161 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
162 "Envelope-Sender" "Envelope-Recipients"))
163 "*All headers that start with this regexp will be hidden.
164 This variable can also be a list of regexps of headers to be ignored.
165 If `gnus-visible-headers' is non-nil, this variable will be ignored."
166 :type
'(choice :custom-show nil
169 :group
'gnus-article-hiding
)
171 (defcustom gnus-visible-headers
172 "^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:"
173 "*All headers that do not match this regexp will be hidden.
174 This variable can also be a list of regexp of headers to remain visible.
175 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
177 (repeat :value-to-internal
(lambda (widget value
)
178 (custom-split-regexp-maybe value
))
179 :match
(lambda (widget value
)
181 (widget-editable-list-match widget value
)))
183 (const :tag
"Use gnus-ignored-headers" nil
)
185 :group
'gnus-article-hiding
)
187 (defcustom gnus-sorted-header-list
188 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
189 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
190 "*This variable is a list of regular expressions.
191 If it is non-nil, headers that match the regular expressions will
192 be placed first in the article buffer in the sequence specified by
194 :type
'(repeat regexp
)
195 :group
'gnus-article-hiding
)
197 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
198 "Headers that are only to be displayed if they have interesting data.
199 Possible values in this list are:
201 'empty Headers with no content.
202 'newsgroups Newsgroup identical to Gnus group.
203 'to-address To identical to To-address.
204 'to-list To identical to To-list.
205 'cc-list CC identical to To-list.
206 'followup-to Followup-to identical to Newsgroups.
207 'reply-to Reply-to identical to From.
208 'date Date less than four days old.
209 'long-to To and/or Cc longer than 1024 characters.
210 'many-to Multiple To and/or Cc."
211 :type
'(set (const :tag
"Headers with no content." empty
)
212 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
213 (const :tag
"To identical to To-address." to-address
)
214 (const :tag
"To identical to To-list." to-list
)
215 (const :tag
"CC identical to To-list." cc-list
)
216 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
217 (const :tag
"Reply-to identical to From." reply-to
)
218 (const :tag
"Date less than four days old." date
)
219 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
220 (const :tag
"Multiple To and/or Cc headers." many-to
))
221 :group
'gnus-article-hiding
)
223 (defcustom gnus-article-skip-boring nil
224 "Skip over text that is not worth reading.
225 By default, if you set this t, then Gnus will display citations and
226 signatures, but will never scroll down to show you a page consisting
227 only of boring text. Boring text is controlled by
228 `gnus-article-boring-faces'."
231 :group
'gnus-article-hiding
)
233 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
234 "Regexp matching signature separator.
235 This can also be a list of regexps. In that case, it will be checked
236 from head to tail looking for a separator. Searches will be done from
237 the end of the buffer."
238 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
240 (repeat :tag
"List of regexp" regexp
))
241 :group
'gnus-article-signature
)
243 (defcustom gnus-signature-limit nil
244 "Provide a limit to what is considered a signature.
245 If it is a number, no signature may not be longer (in characters) than
246 that number. If it is a floating point number, no signature may be
247 longer (in lines) than that number. If it is a function, the function
248 will be called without any parameters, and if it returns nil, there is
249 no signature in the buffer. If it is a string, it will be used as a
250 regexp. If it matches, the text in question is not a signature.
252 This can also be a list of the above values."
253 :type
'(choice (const nil
)
257 (regexp :value
".*"))
258 :group
'gnus-article-signature
)
260 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
261 "Property list to use for hiding text."
263 :group
'gnus-article-hiding
)
265 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
266 ;; frames in a session.
267 (defcustom gnus-article-x-face-command
268 (if (featurep 'xemacs
)
269 (if (or (gnus-image-type-available-p 'xface
)
270 (gnus-image-type-available-p 'pbm
))
271 'gnus-display-x-face-in-from
272 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
273 (if (gnus-image-type-available-p 'pbm
)
274 'gnus-display-x-face-in-from
275 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
277 "*String or function to be executed to display an X-Face header.
278 If it is a string, the command will be executed in a sub-shell
279 asynchronously. The compressed face will be piped to this command."
280 :type
`(choice string
281 (function-item gnus-display-x-face-in-from
)
285 :group
'gnus-article-washing
)
287 (defcustom gnus-article-x-face-too-ugly nil
288 "Regexp matching posters whose face shouldn't be shown automatically."
289 :type
'(choice regexp
(const nil
))
290 :group
'gnus-article-washing
)
292 (defcustom gnus-article-banner-alist nil
293 "Banner alist for stripping.
295 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
297 :type
'(repeat (cons symbol regexp
))
298 :group
'gnus-article-washing
)
300 (gnus-define-group-parameter
303 "Alist of regexps (to match group names) and banner."
304 :variable-group gnus-article-washing
306 '(choice :tag
"Banner"
308 (const :tag
"Remove signature" signature
)
309 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
311 (const :tag
"None" nil
))
313 "If non-nil, specify how to remove `banners' from articles.
315 Symbol `signature' means to remove signatures delimited by
316 `gnus-signature-separator'. Any other symbol is used to look up a
317 regular expression to match the banner in `gnus-article-banner-alist'.
318 A string is used as a regular expression to match the banner
321 (defcustom gnus-article-address-banner-alist nil
322 "Alist of mail addresses and banners.
323 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
324 to match a mail address in the From: header, BANNER is one of a symbol
325 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
326 If ADDRESS matches author's mail address, it will remove things like
327 advertisements. For example:
329 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
333 (regexp :tag
"Address")
334 (choice :tag
"Banner" :value nil
335 (const :tag
"Remove signature" signature
)
336 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
338 (const :tag
"None" nil
))))
340 :group
'gnus-article-washing
)
342 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
344 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
345 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
348 (defun gnus-emphasis-custom-value-to-external (value)
349 (gnus-emphasis-custom-with-format
350 (if (consp (car value
))
351 (list (format format
(car (car value
)) (cdr (car value
)))
353 (if (nth 1 value
) 2 3)
357 (defun gnus-emphasis-custom-value-to-internal (value)
358 (gnus-emphasis-custom-with-format
359 (let ((regexp (concat "\\`"
360 (format (regexp-quote format
)
361 "\\([^()]+\\)" "\\([^()]+\\)")
364 (if (string-match regexp
(setq pattern
(car value
)))
365 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
370 (defcustom gnus-emphasis-alist
372 '(("\\*" "\\*" bold nil
2)
375 ("_/" "/_" underline-italic
)
376 ("_\\*" "\\*_" underline-bold
)
377 ("\\*/" "/\\*" bold-italic
)
378 ("_\\*/" "/\\*_" underline-bold-italic
))))
380 (gnus-emphasis-custom-with-format
381 (mapcar (lambda (spec)
382 (list (format format
(car spec
) (cadr spec
))
385 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
387 '(;; I've never seen anyone use this strikethru convention whereas I've
388 ;; several times seen it triggered by normal text. --Stef
389 ;; Miles suggests that this form is sometimes used but for italics,
390 ;; so maybe we should map it to `italic'.
391 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
392 ;; 2 3 gnus-emphasis-strikethru)
393 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
394 2 3 gnus-emphasis-underline
))))
395 "*Alist that says how to fontify certain phrases.
396 Each item looks like this:
398 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
400 The first element is a regular expression to be matched. The second
401 is a number that says what regular expression grouping used to find
402 the entire emphasized word. The third is a number that says what
403 regexp grouping should be displayed and highlighted. The fourth
404 is the face used for highlighting."
408 :format
"%[Customizing Style%]\n%v"
410 (group :tag
"Default"
411 :value
("" 0 0 default
)
414 (let ((value (widget-get
415 (cadr (widget-get (widget-get widget
:parent
)
418 (if (not (eq (nth 2 value
) 'default
))
422 (gnus-emphasis-custom-value-to-external value
))))
423 (widget-group-value-create widget
))
425 (integer :format
"Match group: %v")
426 (integer :format
"Emphasize group: %v")
429 :value
(("_" .
"_") nil default
)
431 (regexp :format
"Start regexp: %v")
432 (regexp :format
"End regexp: %v"))
433 (boolean :format
"Show start and end patterns: %[%v%]\n"
434 :on
" On " :off
" Off ")
436 :get
(lambda (symbol)
437 (mapcar 'gnus-emphasis-custom-value-to-internal
438 (default-value symbol
)))
439 :set
(lambda (symbol value
)
440 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
442 :group
'gnus-article-emphasis
)
444 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
445 "A regexp to describe whitespace which should not be emphasized.
446 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
447 The former avoids underlining of leading and trailing whitespace,
448 and the latter avoids underlining any whitespace at all."
450 :group
'gnus-article-emphasis
453 (defface gnus-emphasis-bold
'((t (:bold t
)))
454 "Face used for displaying strong emphasized text (*word*)."
455 :group
'gnus-article-emphasis
)
457 (defface gnus-emphasis-italic
'((t (:italic t
)))
458 "Face used for displaying italic emphasized text (/word/)."
459 :group
'gnus-article-emphasis
)
461 (defface gnus-emphasis-underline
'((t (:underline t
)))
462 "Face used for displaying underlined emphasized text (_word_)."
463 :group
'gnus-article-emphasis
)
465 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
466 "Face used for displaying underlined bold emphasized text (_*word*_)."
467 :group
'gnus-article-emphasis
)
469 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
470 "Face used for displaying underlined italic emphasized text (_/word/_)."
471 :group
'gnus-article-emphasis
)
473 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
474 "Face used for displaying bold italic emphasized text (/*word*/)."
475 :group
'gnus-article-emphasis
)
477 (defface gnus-emphasis-underline-bold-italic
478 '((t (:bold t
:italic t
:underline t
)))
479 "Face used for displaying underlined bold italic emphasized text.
480 Example: (_/*word*/_)."
481 :group
'gnus-article-emphasis
)
483 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
484 '((t (:strikethru t
)))
485 '((t (:strike-through t
))))
486 "Face used for displaying strike-through text (-word-)."
487 :group
'gnus-article-emphasis
)
489 (defface gnus-emphasis-highlight-words
490 '((t (:background
"black" :foreground
"yellow")))
491 "Face used for displaying highlighted words."
492 :group
'gnus-article-emphasis
)
494 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
495 "Format for display of Date headers in article bodies.
496 See `format-time-string' for the possible values.
498 The variable can also be function, which should return a complete Date
499 header. The function is called with one argument, the time, which can
500 be fed to `format-time-string'."
501 :type
'(choice string function
)
502 :link
'(custom-manual "(gnus)Article Date")
503 :group
'gnus-article-washing
)
505 (defcustom gnus-save-all-headers t
506 "*If non-nil, don't remove any headers before saving.
507 This will be overridden by the `:headers' property that the symbol of
508 the saver function, which is specified by `gnus-default-article-saver',
510 :group
'gnus-article-saving
513 (defcustom gnus-prompt-before-saving
'always
514 "*This variable says how much prompting is to be done when saving articles.
515 If it is nil, no prompting will be done, and the articles will be
516 saved to the default files. If this variable is `always', each and
517 every article that is saved will be preceded by a prompt, even when
518 saving large batches of articles. If this variable is neither nil not
519 `always', there the user will be prompted once for a file name for
520 each invocation of the saving commands."
521 :group
'gnus-article-saving
522 :type
'(choice (item always
)
523 (item :tag
"never" nil
)
524 (sexp :tag
"once" :format
"%t\n" :value t
)))
526 (defcustom gnus-saved-headers gnus-visible-headers
527 "Headers to keep if `gnus-save-all-headers' is nil.
528 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
529 If that variable is nil, however, all headers that match this regexp
530 will be kept while the rest will be deleted before saving. This and
531 `gnus-save-all-headers' will be overridden by the `:headers' property
532 that the symbol of the saver function, which is specified by
533 `gnus-default-article-saver', might have."
534 :group
'gnus-article-saving
537 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
538 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
539 "A function to save articles in your favourite format.
540 The function will be called by way of the `gnus-summary-save-article'
541 command, and friends such as `gnus-summary-save-article-rmail'.
543 Gnus provides the following functions:
545 * gnus-summary-save-in-rmail (Rmail format)
546 * gnus-summary-save-in-mail (Unix mail format)
547 * gnus-summary-save-in-folder (MH folder)
548 * gnus-summary-save-in-file (article format)
549 * gnus-summary-save-body-in-file (article body)
550 * gnus-summary-save-in-vm (use VM's folder format)
551 * gnus-summary-write-to-file (article format -- overwrite)
552 * gnus-summary-write-body-to-file (article body -- overwrite)
553 * gnus-summary-save-in-pipe (article format)
555 The symbol of each function may have the following properties:
558 The value non-nil means save decoded articles. This is meaningful
559 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
560 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
561 `gnus-summary-save-in-pipe'.
564 The value specifies an alternative function which appends, not
565 overwrites, articles to a file. This implies that when saving many
566 articles at a time, `gnus-prompt-before-saving' is bound to t and all
567 articles are saved in a single file. This is meaningful only with
568 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
571 The value specifies the symbol of a variable of which the value
572 specifies headers to be saved. If it is omitted,
573 `gnus-save-all-headers' and `gnus-saved-headers' control what
574 headers should be saved."
575 :group
'gnus-article-saving
576 :type
'(radio (function-item gnus-summary-save-in-rmail
)
577 (function-item gnus-summary-save-in-mail
)
578 (function-item gnus-summary-save-in-folder
)
579 (function-item gnus-summary-save-in-file
)
580 (function-item gnus-summary-save-body-in-file
)
581 (function-item gnus-summary-save-in-vm
)
582 (function-item gnus-summary-write-to-file
)
583 (function-item gnus-summary-write-body-to-file
)
584 (function-item gnus-summary-save-in-pipe
)
587 (defcustom gnus-article-save-coding-system
588 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
589 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
590 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
591 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
592 "Coding system used to save decoded articles to a file.
594 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
595 which can safely encode any characters in text. This is used by the
598 * gnus-summary-save-article-file
599 * gnus-summary-save-article-body-file
600 * gnus-summary-write-article-file
601 * gnus-summary-write-article-body-file
603 and the functions to which you may set `gnus-default-article-saver':
605 * gnus-summary-save-in-file
606 * gnus-summary-save-body-in-file
607 * gnus-summary-write-to-file
608 * gnus-summary-write-body-to-file
610 Those commands and functions save just text displayed in the article
611 buffer to a file if the value of this variable is non-nil. Note that
612 buttonized MIME parts will be lost in a saved file in that case.
613 Otherwise, raw articles will be saved."
614 :group
'gnus-article-saving
616 :format
"%{%t%}:\n %[Value Menu%] %v"
617 (const :tag
"Save raw articles" nil
)
620 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
621 '((const :tag
"UTF-8" utf-8
)
622 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
623 (const :tag
"Emacs internal" emacs-mule
)
624 (const :tag
"escape-quoted" escape-quoted
))))
625 (symbol :tag
"Coding system")))
627 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
628 "A function generating a file name to save articles in Rmail format.
629 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
630 :group
'gnus-article-saving
633 (defcustom gnus-mail-save-name
'gnus-plain-save-name
634 "A function generating a file name to save articles in Unix mail format.
635 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
636 :group
'gnus-article-saving
639 (defcustom gnus-folder-save-name
'gnus-folder-save-name
640 "A function generating a file name to save articles in MH folder.
641 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
642 :group
'gnus-article-saving
645 (defcustom gnus-file-save-name
'gnus-numeric-save-name
646 "A function generating a file name to save articles in article format.
647 The function is called with NEWSGROUP, HEADERS, and optional
649 :group
'gnus-article-saving
652 (defcustom gnus-split-methods
653 '((gnus-article-archive-name)
654 (gnus-article-nndoc-name))
655 "*Variable used to suggest where articles are to be saved.
656 For instance, if you would like to save articles related to Gnus in
657 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
658 you could set this variable to something like:
660 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
661 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
663 This variable is an alist where the key is the match and the
664 value is a list of possible files to save in if the match is
667 If the match is a string, it is used as a regexp match on the
668 article. If the match is a symbol, that symbol will be funcalled
669 from the buffer of the article to be saved with the newsgroup as the
670 parameter. If it is a list, it will be evaled in the same buffer.
672 If this form or function returns a string, this string will be used as a
673 possible file name; and if it returns a non-nil list, that list will be
674 used as possible file names."
675 :group
'gnus-article-saving
676 :type
'(repeat (choice (list :value
(fun) function
)
677 (cons :value
("" "") regexp
(repeat string
))
680 (defcustom gnus-page-delimiter
"^\^L"
681 "*Regexp describing what to use as article page delimiters.
682 The default value is \"^\^L\", which is a form linefeed at the
683 beginning of a line."
685 :group
'gnus-article-various
)
687 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
688 "*The format specification for the article mode line.
689 See `gnus-summary-mode-line-format' for a closer description.
691 The following additional specs are available:
693 %w The article washing status.
694 %m The number of MIME parts in the article."
697 :group
'gnus-article-various
)
699 (defcustom gnus-article-mode-hook nil
700 "*A hook for Gnus article mode."
702 :group
'gnus-article-various
)
704 (when (featurep 'xemacs
)
705 ;; Extracted from gnus-xmas-define in order to preserve user settings
706 (when (fboundp 'turn-off-scroll-in-place
)
707 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
708 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
709 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
711 (defcustom gnus-article-menu-hook nil
712 "*Hook run after the creation of the article mode menu."
714 :group
'gnus-article-various
)
716 (defcustom gnus-article-prepare-hook nil
717 "*A hook called after an article has been prepared in the article buffer."
719 :group
'gnus-article-various
)
721 (defcustom gnus-copy-article-ignored-headers nil
722 "List of headers to be removed when copying an article.
723 Each element is a regular expression."
724 :version
"23.1" ;; No Gnus
725 :type
'(repeat regexp
)
726 :group
'gnus-article-various
)
728 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
729 "Gnus 5.10 (Emacs 22.1)")
732 '((t (:weight bold
)))
733 "Face used for highlighting a button in the article buffer."
734 :group
'gnus-article-buttons
)
736 (defcustom gnus-article-button-face
'gnus-button
737 "Face used for highlighting buttons in the article buffer.
739 An article button is a piece of text that you can activate by pressing
740 `RET' or `mouse-2' above it."
742 :group
'gnus-article-buttons
)
744 (defcustom gnus-article-mouse-face
'highlight
745 "Face used for mouse highlighting in the article buffer.
747 Article buttons will be displayed in this face when the cursor is
750 :group
'gnus-article-buttons
)
752 (defcustom gnus-signature-face
'gnus-signature
753 "Face used for highlighting a signature in the article buffer.
754 Obsolete; use the face `gnus-signature' for customizations instead."
756 :group
'gnus-article-highlight
757 :group
'gnus-article-signature
)
759 (defface gnus-signature
762 "Face used for highlighting a signature in the article buffer."
763 :group
'gnus-article-highlight
764 :group
'gnus-article-signature
)
765 ;; backward-compatibility alias
766 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
767 (put 'gnus-signature-face
'obsolete-face
"22.1")
769 (defface gnus-header-from
772 (:foreground
"PaleGreen1"))
775 (:foreground
"red3"))
778 "Face used for displaying from headers."
779 :group
'gnus-article-headers
780 :group
'gnus-article-highlight
)
781 ;; backward-compatibility alias
782 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
783 (put 'gnus-header-from-face
'obsolete-face
"22.1")
785 (defface gnus-header-subject
788 (:foreground
"SeaGreen1"))
791 (:foreground
"red4"))
793 (:bold t
:italic t
)))
794 "Face used for displaying subject headers."
795 :group
'gnus-article-headers
796 :group
'gnus-article-highlight
)
797 ;; backward-compatibility alias
798 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
799 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
801 (defface gnus-header-newsgroups
804 (:foreground
"yellow" :italic t
))
807 (:foreground
"MidnightBlue" :italic t
))
810 "Face used for displaying newsgroups headers.
811 In the default setup this face is only used for crossposted
813 :group
'gnus-article-headers
814 :group
'gnus-article-highlight
)
815 ;; backward-compatibility alias
816 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
817 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
819 (defface gnus-header-name
822 (:foreground
"SpringGreen2"))
825 (:foreground
"maroon"))
828 "Face used for displaying header names."
829 :group
'gnus-article-headers
830 :group
'gnus-article-highlight
)
831 ;; backward-compatibility alias
832 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
833 (put 'gnus-header-name-face
'obsolete-face
"22.1")
835 (defface gnus-header-content
838 (:foreground
"SpringGreen1" :italic t
))
841 (:foreground
"indianred4" :italic t
))
843 (:italic t
))) "Face used for displaying header content."
844 :group
'gnus-article-headers
845 :group
'gnus-article-highlight
)
846 ;; backward-compatibility alias
847 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
848 (put 'gnus-header-content-face
'obsolete-face
"22.1")
850 (defcustom gnus-header-face-alist
851 '(("From" nil gnus-header-from
)
852 ("Subject" nil gnus-header-subject
)
853 ("Newsgroups:.*," nil gnus-header-newsgroups
)
854 ("" gnus-header-name gnus-header-content
))
855 "*Controls highlighting of article headers.
857 An alist of the form (HEADER NAME CONTENT).
859 HEADER is a regular expression which should match the name of a
860 header and NAME and CONTENT are either face names or nil.
862 The name of each header field will be displayed using the face
863 specified by the first element in the list where HEADER matches
864 the header name and NAME is non-nil. Similarly, the content will
865 be displayed by the first non-nil matching CONTENT face."
866 :group
'gnus-article-headers
867 :group
'gnus-article-highlight
868 :type
'(repeat (list (regexp :tag
"Header")
870 (item :tag
"skip" nil
)
871 (face :value default
))
872 (choice :tag
"Content"
873 (item :tag
"skip" nil
)
874 (face :value default
)))))
876 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
877 '((xface .
(:face gnus-x-face
)))
878 '((pbm .
(:face gnus-x-face
))
880 "Alist of image types and properties applied to Face and X-Face images.
883 ;; Specify the altitude of Face images in the From header.
884 \(setq gnus-face-properties-alist
885 '((pbm . (:face gnus-x-face :ascent 80))
886 (png . (:ascent 80))))
888 ;; Show Face images as pressed buttons.
889 \(setq gnus-face-properties-alist
890 '((pbm . (:face gnus-x-face :relief -2))
891 (png . (:relief -2))))
893 See the manual for the valid properties for various image types.
894 Currently, `pbm' is used for X-Face images and `png' is used for Face
895 images in Emacs. Only the `:face' property is effective on the `xface'
896 image type in XEmacs if it is built with the libcompface library."
897 :version
"23.1" ;; No Gnus
898 :group
'gnus-article-headers
899 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
901 (defcustom gnus-article-decode-hook
902 '(article-decode-charset article-decode-encoded-words
903 article-decode-group-name article-decode-idna-rhs
)
904 "*Hook run to decode charsets in articles."
905 :group
'gnus-article-headers
908 (defcustom gnus-display-mime-function
'gnus-display-mime
909 "Function to display MIME articles."
910 :group
'gnus-article-mime
913 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
914 "Function used to decode headers.")
916 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
917 "Function used to decode addresses.")
919 (defvar gnus-article-dumbquotes-map
939 "Table for MS-to-Latin1 translation.")
941 (defcustom gnus-ignored-mime-types nil
942 "List of MIME types that should be ignored by Gnus."
944 :group
'gnus-article-mime
945 :type
'(repeat regexp
))
947 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
948 "List of MIME types that should not be given buttons when rendered inline.
949 See also `gnus-buttonized-mime-types' which may override this variable.
950 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
952 :group
'gnus-article-mime
953 :type
'(repeat regexp
))
955 (defcustom gnus-buttonized-mime-types nil
956 "List of MIME types that should be given buttons when rendered inline.
957 If set, this variable overrides `gnus-unbuttonized-mime-types'.
958 To see e.g. security buttons you could set this to
959 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
960 this list to display radio buttons that allow you to choose one of two
961 media types those mails include. See also `mm-discouraged-alternatives'.
962 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
964 :group
'gnus-article-mime
965 :type
'(repeat regexp
))
967 (defcustom gnus-inhibit-mime-unbuttonizing nil
968 "If non-nil, all MIME parts get buttons.
969 When nil (the default value), then some MIME parts do not get buttons,
970 as described by the variables `gnus-buttonized-mime-types' and
971 `gnus-unbuttonized-mime-types'."
973 :group
'gnus-article-mime
976 (defcustom gnus-body-boundary-delimiter
"_"
977 "String used to delimit header and body.
978 This variable is used by `gnus-article-treat-body-boundary' which can
979 be controlled by `gnus-treat-body-boundary'."
981 :group
'gnus-article-various
982 :type
'(choice (item :tag
"None" :value nil
)
985 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
987 "Defines the location of the faces database.
988 For information on obtaining this database of pretty pictures, please
989 see http://www.cs.indiana.edu/picons/ftp/index.html"
991 :type
'(repeat directory
)
992 :link
'(url-link :tag
"download"
993 "http://www.cs.indiana.edu/picons/ftp/index.html")
994 :link
'(custom-manual "(gnus)Picons")
997 (defun gnus-picons-installed-p ()
998 "Say whether picons are installed on your machine."
999 (let ((installed nil
))
1000 (dolist (database gnus-picon-databases
)
1001 (when (file-exists-p database
)
1002 (setq installed t
)))
1005 (defcustom gnus-article-mime-part-function nil
1006 "Function called with a MIME handle as the argument.
1007 This is meant for people who want to do something automatic based
1008 on parts -- for instance, adding Vcard info to a database."
1009 :group
'gnus-article-mime
1010 :type
'(choice (const nil
)
1013 (defcustom gnus-mime-multipart-functions nil
1014 "An alist of MIME types to functions to display them."
1016 :group
'gnus-article-mime
1017 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1019 (defcustom gnus-article-date-headers
'(combined-lapsed)
1020 "A list of Date header formats to display.
1021 Valid formats are `ut' (universal time), `local' (local time
1022 zone), `english' (readable English), `lapsed' (elapsed time),
1023 `combined-lapsed' (both the original date and the elapsed time),
1024 `original' (the original date header), `iso8601' (ISO8601
1025 format), and `user-defined' (a user-defined format defined by the
1026 `gnus-article-time-format' variable).
1028 You have as many date headers as you want in the article buffer.
1029 Some of these headers are updated automatically. See
1030 `gnus-article-update-date-headers' for details."
1032 :group
'gnus-article-headers
1034 (item :tag
"Universal time (UT)" :value
'ut
)
1035 (item :tag
"Local time zone" :value
'local
)
1036 (item :tag
"Readable English" :value
'english
)
1037 (item :tag
"Elapsed time" :value
'lapsed
)
1038 (item :tag
"Original and elapsed time" :value
'combined-lapsed
)
1039 (item :tag
"Original date header" :value
'original
)
1040 (item :tag
"ISO8601 format" :value
'iso8601
)
1041 (item :tag
"User-defined" :value
'user-defined
)))
1043 (defcustom gnus-article-update-date-headers
1
1044 "A number that says how often to update the date header (in seconds).
1045 If nil, don't update it at all."
1047 :group
'gnus-article-headers
1049 (item :tag
"Don't update" :value nil
)
1052 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1053 "Function called with a MIME handle as the argument.
1054 This is meant for people who want to view first matched part.
1055 For `undisplayed-alternative' (default), the first undisplayed
1056 part or alternative part is used. For `undisplayed', the first
1057 undisplayed part is used. For a function, the first part which
1058 the function return t is used. For nil, the first part is
1061 :group
'gnus-article-mime
1063 (item :tag
"first" :value nil
)
1064 (item :tag
"undisplayed" :value undisplayed
)
1065 (item :tag
"undisplayed or alternative"
1066 :value undisplayed-alternative
)
1069 (defcustom gnus-mime-action-alist
1070 '(("save to file" . gnus-mime-save-part
)
1071 ("save and strip" . gnus-mime-save-part-and-strip
)
1072 ("replace with file" . gnus-mime-replace-part
)
1073 ("delete part" . gnus-mime-delete-part
)
1074 ("display as text" . gnus-mime-inline-part
)
1075 ("view the part" . gnus-mime-view-part
)
1076 ("pipe to command" . gnus-mime-pipe-part
)
1077 ("toggle display" . gnus-article-press-button
)
1078 ("toggle display" . gnus-article-view-part-as-charset
)
1079 ("view as type" . gnus-mime-view-part-as-type
)
1080 ("view internally" . gnus-mime-view-part-internally
)
1081 ("view externally" . gnus-mime-view-part-externally
))
1082 "An alist of actions that run on the MIME attachment."
1083 :group
'gnus-article-mime
1084 :type
'(repeat (cons (string :tag
"name")
1087 (defcustom gnus-auto-select-part
1
1088 "Advance to next MIME part when deleting or stripping parts.
1090 When 0, point will be placed on the same part as before. When
1091 positive (negative), move point forward (backwards) this many
1092 parts. When nil, redisplay article."
1093 :version
"23.1" ;; No Gnus
1094 :group
'gnus-article-mime
1095 :type
'(choice (const nil
:tag
"Redisplay article.")
1096 (const 1 :tag
"Next part.")
1097 (const 0 :tag
"Current part.")
1101 ;;; The treatment variables
1104 (defvar gnus-part-display-hook nil
1105 "Hook called on parts that are to receive treatment.")
1107 (defvar gnus-article-treat-custom
1108 '(choice (const :tag
"Off" nil
)
1110 (const :tag
"Header" head
)
1111 (const :tag
"First" first
)
1112 (const :tag
"Last" last
)
1113 (integer :tag
"Less")
1114 (repeat :tag
"Groups" regexp
)
1115 (sexp :tag
"Predicate")))
1117 (defvar gnus-article-treat-head-custom
1118 '(choice (const :tag
"Off" nil
)
1119 (const :tag
"Header" head
)))
1121 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1125 (defvar gnus-inhibit-treatment nil
1126 "Whether to inhibit treatment.")
1128 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1129 "Highlight the signature.
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group
'gnus-article-treat
1133 :link
'(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom
)
1135 (put 'gnus-treat-highlight-signature
'highlight t
)
1137 (defcustom gnus-treat-buttonize
100000
1139 Valid values are nil, t, `head', `first', `last', an integer or a
1140 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group
'gnus-article-treat
1142 :link
'(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom
)
1144 (put 'gnus-treat-buttonize
'highlight t
)
1146 (defcustom gnus-treat-buttonize-head
'head
1147 "Add buttons to the head.
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1150 :group
'gnus-article-treat
1151 :link
'(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-head-custom
)
1153 (put 'gnus-treat-buttonize-head
'highlight t
)
1155 (defcustom gnus-treat-date
'head
1156 "Display dates according to the `gnus-article-date-headers' variable.
1157 Valid values are nil, t, `head', `first', `last', an integer or a
1158 predicate. See Info node `(gnus)Customizing Articles'."
1160 :group
'gnus-article-treat
1161 :link
'(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom
)
1164 (defcustom gnus-treat-emphasize
50000
1166 Valid values are nil, t, `head', `first', `last', an integer or a
1167 predicate. See Info node `(gnus)Customizing Articles'."
1168 :group
'gnus-article-treat
1169 :link
'(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom
)
1171 (put 'gnus-treat-emphasize
'highlight t
)
1173 (defcustom gnus-treat-strip-cr nil
1174 "Remove carriage returns.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group
'gnus-article-treat
1179 :link
'(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom
)
1182 (defcustom gnus-treat-unsplit-urls nil
1183 "Remove newlines from within URLs.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1187 :group
'gnus-article-treat
1188 :link
'(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom
)
1191 (defcustom gnus-treat-leading-whitespace nil
1192 "Remove leading whitespace in headers.
1193 Valid values are nil, t, `head', `first', `last', an integer or a
1194 predicate. See Info node `(gnus)Customizing Articles'."
1196 :group
'gnus-article-treat
1197 :link
'(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom
)
1200 (defcustom gnus-treat-hide-headers
'head
1202 Valid values are nil, t, `head', `first', `last', an integer or a
1203 predicate. See Info node `(gnus)Customizing Articles'."
1204 :group
'gnus-article-treat
1205 :link
'(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-head-custom
)
1208 (defcustom gnus-treat-hide-boring-headers nil
1209 "Hide boring headers.
1210 Valid values are nil, t, `head', `first', `last', an integer or a
1211 predicate. See Info node `(gnus)Customizing Articles'."
1212 :group
'gnus-article-treat
1213 :link
'(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-head-custom
)
1216 (defcustom gnus-treat-hide-signature nil
1217 "Hide the signature.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1220 :group
'gnus-article-treat
1221 :link
'(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom
)
1224 (defcustom gnus-treat-fill-article nil
1226 Valid values are nil, t, `head', `first', `last', an integer or a
1227 predicate. See Info node `(gnus)Customizing Articles'."
1228 :group
'gnus-article-treat
1229 :link
'(custom-manual "(gnus)Customizing Articles")
1230 :type gnus-article-treat-custom
)
1232 (defcustom gnus-treat-hide-citation nil
1234 Valid values are nil, t, `head', `first', `last', an integer or a
1235 predicate. See Info node `(gnus)Customizing Articles'."
1236 :group
'gnus-article-treat
1237 :link
'(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-custom
)
1240 (defcustom gnus-treat-hide-citation-maybe nil
1242 Valid values are nil, t, `head', `first', `last', an integer or a
1243 predicate. See Info node `(gnus)Customizing Articles'."
1244 :group
'gnus-article-treat
1245 :link
'(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom
)
1248 (defcustom gnus-treat-strip-list-identifiers
'head
1249 "Strip list identifiers from `gnus-list-identifiers`.
1250 Valid values are nil, t, `head', `first', `last', an integer or a
1251 predicate. See Info node `(gnus)Customizing Articles'."
1253 :group
'gnus-article-treat
1254 :link
'(custom-manual "(gnus)Customizing Articles")
1255 :type gnus-article-treat-custom
)
1257 (gnus-define-group-parameter
1260 "Alist of regexps and correspondent identifiers."
1261 :variable-group gnus-article-washing
1263 '(choice :tag
"Identifier"
1265 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1267 (const :tag
"None" nil
))
1269 "If non-nil, specify how to remove `identifiers' from articles' subject.
1271 Any symbol is used to look up a regular expression to match the
1272 banner in `gnus-list-identifiers'. A string is used as a regular
1273 expression to match the identifier directly.")
1275 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1276 "Gnus 5.10 (Emacs 22.1)")
1278 (defcustom gnus-treat-strip-pem nil
1279 "Strip PEM signatures.
1280 Valid values are nil, t, `head', `first', `last', an integer or a
1281 predicate. See Info node `(gnus)Customizing Articles'."
1282 :group
'gnus-article-treat
1283 :link
'(custom-manual "(gnus)Customizing Articles")
1284 :type gnus-article-treat-custom
)
1286 (defcustom gnus-treat-strip-banner t
1287 "Strip banners from articles.
1288 The banner to be stripped is specified in the `banner' group parameter.
1289 Valid values are nil, t, `head', `first', `last', an integer or a
1290 predicate. See Info node `(gnus)Customizing Articles'."
1291 :group
'gnus-article-treat
1292 :link
'(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom
)
1295 (defcustom gnus-treat-highlight-headers
'head
1296 "Highlight the headers.
1297 Valid values are nil, t, `head', `first', `last', an integer or a
1298 predicate. See Info node `(gnus)Customizing Articles'."
1299 :group
'gnus-article-treat
1300 :link
'(custom-manual "(gnus)Customizing Articles")
1301 :type gnus-article-treat-head-custom
)
1302 (put 'gnus-treat-highlight-headers
'highlight t
)
1304 (defcustom gnus-treat-highlight-citation t
1305 "Highlight cited text.
1306 Valid values are nil, t, `head', `first', `last', an integer or a
1307 predicate. See Info node `(gnus)Customizing Articles'."
1308 :group
'gnus-article-treat
1309 :link
'(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-custom
)
1311 (put 'gnus-treat-highlight-citation
'highlight t
)
1313 (defcustom gnus-treat-strip-headers-in-body t
1314 "Strip the X-No-Archive header line from the beginning of the body.
1315 Valid values are nil, t, `head', `first', `last', an integer or a
1316 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group
'gnus-article-treat
1319 :link
'(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom
)
1322 (defcustom gnus-treat-strip-trailing-blank-lines nil
1323 "Strip trailing blank lines.
1324 Valid values are nil, t, `head', `first', `last', an integer or a
1325 predicate. See Info node `(gnus)Customizing Articles'.
1327 When set to t, it also strips trailing blanks in all MIME parts.
1328 Consider to use `last' instead."
1329 :group
'gnus-article-treat
1330 :link
'(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom
)
1333 (defcustom gnus-treat-strip-leading-blank-lines nil
1334 "Strip leading blank lines.
1335 Valid values are nil, t, `head', `first', `last', an integer or a
1336 predicate. See Info node `(gnus)Customizing Articles'.
1338 When set to t, it also strips trailing blanks in all MIME parts."
1339 :group
'gnus-article-treat
1340 :link
'(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom
)
1343 (defcustom gnus-treat-strip-multiple-blank-lines nil
1344 "Strip multiple blank lines.
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'."
1347 :group
'gnus-article-treat
1348 :link
'(custom-manual "(gnus)Customizing Articles")
1349 :type gnus-article-treat-custom
)
1351 (defcustom gnus-treat-unfold-headers
'head
1352 "Unfold folded header lines.
1353 Valid values are nil, t, `head', `first', `last', an integer or a
1354 predicate. See Info node `(gnus)Customizing Articles'."
1356 :group
'gnus-article-treat
1357 :link
'(custom-manual "(gnus)Customizing Articles")
1358 :type gnus-article-treat-custom
)
1360 (defcustom gnus-article-unfold-long-headers nil
1361 "If non-nil, allow unfolding headers even if the header is long.
1362 If it is a regexp, only long headers matching this regexp are unfolded.
1363 If it is t, all long headers are unfolded.
1365 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1366 :version
"23.1" ;; No Gnus
1367 :group
'gnus-article-treat
1368 :type
'(choice (const nil
)
1369 (const :tag
"all" t
)
1372 (defcustom gnus-treat-fold-headers nil
1374 Valid values are nil, t, `head', `first', `last', an integer or a
1375 predicate. See Info node `(gnus)Customizing Articles'."
1377 :group
'gnus-article-treat
1378 :link
'(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom
)
1381 (defcustom gnus-treat-fold-newsgroups
'head
1382 "Fold the Newsgroups and Followup-To headers.
1383 Valid values are nil, t, `head', `first', `last', an integer or a
1384 predicate. See Info node `(gnus)Customizing Articles'."
1386 :group
'gnus-article-treat
1387 :link
'(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom
)
1390 (defcustom gnus-treat-overstrike t
1391 "Treat overstrike highlighting.
1392 Valid values are nil, t, `head', `first', `last', an integer or a
1393 predicate. See Info node `(gnus)Customizing Articles'."
1394 :group
'gnus-article-treat
1395 :link
'(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom
)
1397 (put 'gnus-treat-overstrike
'highlight t
)
1399 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1400 "Treat ANSI SGR control sequences.
1401 Valid values are nil, t, `head', `first', `last', an integer or a
1402 predicate. See Info node `(gnus)Customizing Articles'."
1403 :group
'gnus-article-treat
1404 :link
'(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom
)
1407 (make-obsolete-variable 'gnus-treat-display-xface
1408 'gnus-treat-display-x-face
"Emacs 22.1")
1410 (defcustom gnus-treat-display-x-face
1411 (and (not noninteractive
)
1412 (gnus-image-type-available-p 'xbm
)
1413 (if (featurep 'xemacs
)
1416 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1417 (executable-find "icontopbm"))
1418 ;; shell-command-to-string may signal an error, e.g. if
1419 ;; shell-file-name is not found.
1422 "Display X-Face headers.
1423 Valid values are nil and `head'.
1424 See Info node `(gnus)Customizing Articles' and Info node
1425 `(gnus)X-Face' for details."
1426 :group
'gnus-article-treat
1428 :link
'(custom-manual "(gnus)Customizing Articles")
1429 :link
'(custom-manual "(gnus)X-Face")
1430 :type gnus-article-treat-head-custom
1431 :set
(lambda (symbol value
)
1434 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1436 ((boundp 'gnus-treat-display-xface
)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (default-value 'gnus-treat-display-xface
))
1441 ((get 'gnus-treat-display-xface
'saved-value
)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1448 (put 'gnus-treat-display-x-face
'highlight t
)
1450 (defcustom gnus-treat-display-face
1451 (and (not noninteractive
)
1452 (gnus-image-type-available-p 'png
)
1454 "Display Face headers.
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles' and Info
1457 node `(gnus)Face' for details."
1458 :group
'gnus-article-treat
1460 :link
'(custom-manual "(gnus)Customizing Articles")
1461 :link
'(custom-manual "(gnus)X-Face")
1462 :type gnus-article-treat-head-custom
)
1463 (put 'gnus-treat-display-face
'highlight t
)
1465 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Smileys' for details."
1470 :group
'gnus-article-treat
1472 :link
'(custom-manual "(gnus)Customizing Articles")
1473 :link
'(custom-manual "(gnus)Smileys")
1474 :type gnus-article-treat-custom
)
1475 (put 'gnus-treat-display-smileys
'highlight t
)
1477 (defcustom gnus-treat-from-picon
1478 (if (and (gnus-image-type-available-p 'xpm
)
1479 (gnus-picons-installed-p))
1481 "Display picons in the From header.
1482 Valid values are nil, t, `head', `first', `last', an integer or a
1483 predicate. See Info node `(gnus)Customizing Articles' and Info
1484 node `(gnus)Picons' for details."
1486 :group
'gnus-article-treat
1488 :link
'(custom-manual "(gnus)Customizing Articles")
1489 :link
'(custom-manual "(gnus)Picons")
1490 :type gnus-article-treat-head-custom
)
1491 (put 'gnus-treat-from-picon
'highlight t
)
1493 (defcustom gnus-treat-mail-picon
1494 (if (and (gnus-image-type-available-p 'xpm
)
1495 (gnus-picons-installed-p))
1497 "Display picons in To and Cc headers.
1498 Valid values are nil, t, `head', `first', `last', an integer or a
1499 predicate. See Info node `(gnus)Customizing Articles' and Info
1500 node `(gnus)Picons' for details."
1502 :group
'gnus-article-treat
1504 :link
'(custom-manual "(gnus)Customizing Articles")
1505 :link
'(custom-manual "(gnus)Picons")
1506 :type gnus-article-treat-head-custom
)
1507 (put 'gnus-treat-mail-picon
'highlight t
)
1509 (defcustom gnus-treat-newsgroups-picon
1510 (if (and (gnus-image-type-available-p 'xpm
)
1511 (gnus-picons-installed-p))
1513 "Display picons in the Newsgroups and Followup-To headers.
1514 Valid values are nil, t, `head', `first', `last', an integer or a
1515 predicate. See Info node `(gnus)Customizing Articles' and Info
1516 node `(gnus)Picons' for details."
1518 :group
'gnus-article-treat
1520 :link
'(custom-manual "(gnus)Customizing Articles")
1521 :link
'(custom-manual "(gnus)Picons")
1522 :type gnus-article-treat-head-custom
)
1523 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1525 (defcustom gnus-treat-from-gravatar nil
1526 "Display gravatars in the From header.
1527 Valid values are nil, t, `head', `first', `last', an integer or a
1528 predicate. See Info node `(gnus)Customizing Articles' and Info
1529 node `(gnus)Gravatars' for details."
1531 :group
'gnus-article-treat
1532 :group
'gnus-gravatar
1533 :link
'(custom-manual "(gnus)Customizing Articles")
1534 :link
'(custom-manual "(gnus)Gravatars")
1535 :type gnus-article-treat-head-custom
)
1536 (put 'gnus-treat-from-gravatar
'highlight t
)
1538 (defcustom gnus-treat-mail-gravatar nil
1539 "Display gravatars in To and Cc headers.
1540 Valid values are nil, t, `head', `first', `last', an integer or a
1541 predicate. See Info node `(gnus)Customizing Articles' and Info
1542 node `(gnus)Gravatars' for details."
1544 :group
'gnus-article-treat
1545 :group
'gnus-gravatar
1546 :link
'(custom-manual "(gnus)Customizing Articles")
1547 :link
'(custom-manual "(gnus)Gravatars")
1548 :type gnus-article-treat-head-custom
)
1549 (put 'gnus-treat-mail-gravatar
'highlight t
)
1551 (defcustom gnus-treat-body-boundary
1552 (if (or gnus-treat-newsgroups-picon
1553 gnus-treat-mail-picon
1554 gnus-treat-from-picon
1555 gnus-treat-from-gravatar
1556 gnus-treat-mail-gravatar
)
1557 ;; If there's much decoration, the user might prefer a boundery.
1560 "Draw a boundary at the end of the headers.
1561 Valid values are nil and `head'.
1562 See Info node `(gnus)Customizing Articles' for details."
1564 :group
'gnus-article-treat
1565 :link
'(custom-manual "(gnus)Customizing Articles")
1566 :type gnus-article-treat-head-custom
)
1568 (defcustom gnus-treat-capitalize-sentences nil
1569 "Capitalize sentence-starting words.
1570 Valid values are nil, t, `head', `first', `last', an integer or a
1571 predicate. See Info node `(gnus)Customizing Articles'."
1573 :group
'gnus-article-treat
1574 :link
'(custom-manual "(gnus)Customizing Articles")
1575 :type gnus-article-treat-custom
)
1577 (defcustom gnus-treat-wash-html nil
1579 Valid values are nil, t, `head', `first', `last', an integer or a
1580 predicate. See Info node `(gnus)Customizing Articles'."
1582 :group
'gnus-article-treat
1583 :link
'(custom-manual "(gnus)Customizing Articles")
1584 :type gnus-article-treat-custom
)
1586 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1588 Valid values are nil, t, `head', `first', `last', an integer or a
1589 predicate. See Info node `(gnus)Customizing Articles'."
1591 :group
'gnus-article-treat
1592 :link
'(custom-manual "(gnus)Customizing Articles")
1593 :type gnus-article-treat-custom
)
1595 (defcustom gnus-treat-x-pgp-sig nil
1597 To automatically treat X-PGP-Sig, set it to head.
1598 Valid values are nil, t, `head', `first', `last', an integer or a
1599 predicate. See Info node `(gnus)Customizing Articles'."
1601 :group
'gnus-article-treat
1602 :group
'mime-security
1603 :link
'(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom
)
1606 (defvar gnus-article-encrypt-protocol-alist
1607 '(("PGP" . mml2015-self-encrypt
)))
1609 ;; Set to nil if more than one protocol added to
1610 ;; gnus-article-encrypt-protocol-alist.
1611 (defcustom gnus-article-encrypt-protocol
"PGP"
1612 "The protocol used for encrypt articles.
1613 It is a string, such as \"PGP\". If nil, ask user."
1616 :group
'mime-security
)
1618 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1619 (mm-coding-system-p 'utf-8
)
1620 (executable-find idna-program
))
1621 "Whether IDNA decoding of headers is used when viewing messages.
1622 This requires GNU Libidn, and by default only enabled if it is found."
1624 :group
'gnus-article-headers
1627 (defcustom gnus-article-over-scroll nil
1628 "If non-nil, allow scrolling the article buffer even when there no more text."
1630 :group
'gnus-article
1633 (defcustom gnus-inhibit-images nil
1634 "Non-nil means inhibit displaying of images inline in the article body."
1636 :group
'gnus-article
1639 (defcustom gnus-blocked-images
'gnus-block-private-groups
1640 "Images that have URLs matching this regexp will be blocked.
1641 This can also be a function to be evaluated. If so, it will be
1642 called with the group name as the parameter, and should return a
1648 ;;; Internal variables
1650 (defvar gnus-english-month-names
1651 '("January" "February" "March" "April" "May" "June" "July" "August"
1652 "September" "October" "November" "December"))
1654 (defvar article-goto-body-goes-to-point-min-p nil
)
1655 (defvar gnus-article-wash-types nil
)
1656 (defvar gnus-article-emphasis-alist nil
)
1657 (defvar gnus-article-image-alist nil
)
1659 (defvar gnus-article-mime-handle-alist-1 nil
)
1660 (defvar gnus-treatment-function-alist
1661 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1662 (gnus-treat-strip-banner gnus-article-strip-banner
)
1663 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1664 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1665 (gnus-treat-buttonize gnus-article-add-buttons
)
1666 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1667 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1668 (gnus-treat-strip-cr gnus-article-remove-cr
)
1669 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1670 (gnus-treat-display-x-face gnus-article-display-x-face
)
1671 (gnus-treat-display-face gnus-article-display-face
)
1672 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1673 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1674 (gnus-treat-hide-signature gnus-article-hide-signature
)
1675 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1676 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1677 (gnus-treat-from-picon gnus-treat-from-picon
)
1678 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1679 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1680 (gnus-treat-strip-pem gnus-article-hide-pem
)
1681 (gnus-treat-date gnus-article-treat-date
)
1682 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1683 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1684 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1685 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1686 (gnus-treat-strip-trailing-blank-lines
1687 gnus-article-remove-trailing-blank-lines
)
1688 (gnus-treat-strip-leading-blank-lines
1689 gnus-article-strip-leading-blank-lines
)
1690 (gnus-treat-strip-multiple-blank-lines
1691 gnus-article-strip-multiple-blank-lines
)
1692 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1693 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1694 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1695 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1696 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1697 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1698 (gnus-treat-display-smileys gnus-treat-smiley
)
1699 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1700 (gnus-treat-wash-html gnus-article-wash-html
)
1701 (gnus-treat-emphasize gnus-article-emphasize
)
1702 (gnus-treat-hide-citation gnus-article-hide-citation
)
1703 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1704 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1705 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1707 (defvar gnus-article-mime-handle-alist nil
)
1708 (defvar article-lapsed-timer nil
)
1709 (defvar gnus-article-current-summary nil
)
1711 (defvar gnus-article-mode-syntax-table
1712 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1713 ;; This causes the citation match run O(2^n).
1714 ;; (modify-syntax-entry ?- "w" table)
1715 (modify-syntax-entry ?
> ")<" table
)
1716 (modify-syntax-entry ?
< "(>" table
)
1717 ;; make M-. in article buffers work for `foo' strings
1718 (modify-syntax-entry ?
' " " table
)
1719 (modify-syntax-entry ?
` " " table
)
1721 "Syntax table used in article mode buffers.
1722 Initialized from `text-mode-syntax-table.")
1724 (defvar gnus-save-article-buffer nil
)
1726 (defvar gnus-number-of-articles-to-be-saved nil
)
1728 (defvar gnus-inhibit-hiding nil
)
1730 (defvar gnus-article-edit-mode nil
)
1732 ;;; Macros for dealing with the article buffer.
1734 (defmacro gnus-with-article-headers
(&rest forms
)
1735 `(with-current-buffer gnus-article-buffer
1737 (let ((inhibit-read-only t
)
1738 (inhibit-point-motion-hooks t
)
1739 (case-fold-search t
))
1740 (article-narrow-to-head)
1743 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1744 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1746 (defmacro gnus-with-article-buffer
(&rest forms
)
1747 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1748 (with-current-buffer gnus-article-buffer
1749 (let ((inhibit-read-only t
))
1752 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1753 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1755 (defun gnus-article-goto-header (header)
1756 "Go to HEADER, which is a regular expression."
1757 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1759 (defsubst gnus-article-hide-text
(b e props
)
1760 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1761 (gnus-add-text-properties-when 'article-type nil b e props
)
1762 (when (memq 'intangible props
)
1764 (max (1- b
) (point-min))
1765 b
'intangible
(cddr (memq 'intangible props
)))))
1767 (defsubst gnus-article-unhide-text
(b e
)
1768 "Remove hidden text properties from region between B and E."
1769 (remove-text-properties b e gnus-hidden-properties
)
1770 (when (memq 'intangible gnus-hidden-properties
)
1771 (put-text-property (max (1- b
) (point-min))
1772 b
'intangible nil
)))
1774 (defun gnus-article-hide-text-type (b e type
)
1775 "Hide text of TYPE between B and E."
1776 (gnus-add-wash-type type
)
1777 (gnus-article-hide-text
1778 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1780 (defun gnus-article-unhide-text-type (b e type
)
1781 "Unhide text of TYPE between B and E."
1782 (gnus-delete-wash-type type
)
1783 (remove-text-properties
1784 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1785 (when (memq 'intangible gnus-hidden-properties
)
1786 (put-text-property (max (1- b
) (point-min))
1787 b
'intangible nil
)))
1789 (defun gnus-article-hide-text-of-type (type)
1790 "Hide text of TYPE in the current buffer."
1792 (let ((b (point-min))
1794 (while (setq b
(text-property-any b e
'article-type type
))
1795 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1797 (defun gnus-article-delete-text-of-type (type)
1798 "Delete text of TYPE in the current buffer."
1800 (let ((b (point-min)))
1801 (if (eq type
'multipart
)
1802 ;; Remove MIME buttons associated with multipart/alternative parts.
1805 (while (if (get-text-property (point) 'gnus-part
)
1807 (when (setq b
(next-single-property-change (point)
1812 (skip-chars-forward "\n")
1813 (when (eq (get-text-property b
'article-type
) 'multipart
)
1814 (delete-region b
(point)))))
1815 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1817 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1820 (defun gnus-article-delete-invisible-text ()
1821 "Delete all invisible text in the current buffer."
1823 (let ((b (point-min)))
1824 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1826 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1829 (defun gnus-article-text-type-exists-p (type)
1830 "Say whether any text of type TYPE exists in the buffer."
1831 (text-property-any (point-min) (point-max) 'article-type type
))
1833 (defsubst gnus-article-header-rank
()
1834 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1835 (let ((list gnus-sorted-header-list
)
1838 (if (looking-at (car list
))
1840 (setq list
(cdr list
))
1844 (defun article-hide-headers (&optional arg delete
)
1845 "Hide unwanted headers and possibly sort them as well."
1847 ;; This function might be inhibited.
1848 (unless gnus-inhibit-hiding
1849 (let ((inhibit-read-only t
)
1850 (case-fold-search t
)
1851 (max (1+ (length gnus-sorted-header-list
)))
1852 (inhibit-point-motion-hooks t
)
1853 (cur (current-buffer))
1854 ignored visible beg
)
1856 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1857 ;; group parameters, so we should go to the summary buffer.
1860 (progn (set-buffer gnus-summary-buffer
) t
)
1862 (setq ignored
(when (not gnus-visible-headers
)
1863 (cond ((stringp gnus-ignored-headers
)
1864 gnus-ignored-headers
)
1865 ((listp gnus-ignored-headers
)
1866 (mapconcat 'identity
1867 gnus-ignored-headers
1869 visible
(cond ((stringp gnus-visible-headers
)
1870 gnus-visible-headers
)
1871 ((and gnus-visible-headers
1872 (listp gnus-visible-headers
))
1873 (mapconcat 'identity
1874 gnus-visible-headers
1878 ;; First we narrow to just the headers.
1879 (article-narrow-to-head)
1880 ;; Hide any "From " lines at the beginning of (mail) articles.
1881 (while (looking-at "From ")
1884 (delete-region (point-min) (point)))
1885 ;; Then treat the rest of the header lines.
1886 ;; Then we use the two regular expressions
1887 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1888 ;; select which header lines is to remain visible in the
1890 (while (re-search-forward "^[^ \t:]*:" nil t
)
1892 ;; Mark the rank of the header.
1894 (point) (1+ (point)) 'message-rank
1895 (if (or (and visible
(looking-at visible
))
1897 (not (looking-at ignored
))))
1898 (gnus-article-header-rank)
1901 (message-sort-headers-1)
1902 (when (setq beg
(text-property-any
1903 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1904 ;; We delete the unwanted headers.
1905 (gnus-add-wash-type 'headers
)
1906 (add-text-properties (point-min) (+ 5 (point-min))
1907 '(article-type headers dummy-invisible t
))
1908 (delete-region beg
(point-max))))))))
1910 (defun article-hide-boring-headers (&optional arg
)
1911 "Toggle hiding of headers that aren't very interesting.
1912 If given a negative prefix, always show; if given a positive prefix,
1914 (interactive (gnus-article-hidden-arg))
1915 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1916 (not gnus-show-all-headers
))
1919 (let ((inhibit-read-only t
)
1920 (inhibit-point-motion-hooks t
))
1921 (article-narrow-to-head)
1922 (dolist (elem gnus-boring-article-headers
)
1923 (goto-char (point-min))
1925 ;; Hide empty headers.
1927 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1929 (gnus-article-hide-text-type
1933 (if (re-search-forward "^[^ \t]" nil t
)
1937 ;; Hide boring Newsgroups header.
1938 ((eq elem
'newsgroups
)
1939 (when (gnus-string-equal
1940 (gnus-fetch-field "newsgroups")
1941 (gnus-group-real-name
1942 (if (boundp 'gnus-newsgroup-name
)
1945 (gnus-article-hide-header "newsgroups")))
1946 ((eq elem
'to-address
)
1947 (let ((to (message-fetch-field "to"))
1949 (gnus-parameter-to-address
1950 (if (boundp 'gnus-newsgroup-name
)
1951 gnus-newsgroup-name
""))))
1952 (when (and to to-address
1955 ;; only one address in To
1956 (nth 1 (mail-extract-address-components to
))
1958 (gnus-article-hide-header "to"))))
1960 (let ((to (message-fetch-field "to"))
1962 (gnus-parameter-to-list
1963 (if (boundp 'gnus-newsgroup-name
)
1964 gnus-newsgroup-name
""))))
1965 (when (and to to-list
1968 ;; only one address in To
1969 (nth 1 (mail-extract-address-components to
))
1971 (gnus-article-hide-header "to"))))
1973 (let ((cc (message-fetch-field "cc"))
1975 (gnus-parameter-to-list
1976 (if (boundp 'gnus-newsgroup-name
)
1977 gnus-newsgroup-name
""))))
1978 (when (and cc to-list
1981 ;; only one address in CC
1982 (nth 1 (mail-extract-address-components cc
))
1984 (gnus-article-hide-header "cc"))))
1985 ((eq elem
'followup-to
)
1986 (when (gnus-string-equal
1987 (message-fetch-field "followup-to")
1988 (message-fetch-field "newsgroups"))
1989 (gnus-article-hide-header "followup-to")))
1990 ((eq elem
'reply-to
)
1991 (if (gnus-group-find-parameter
1992 gnus-newsgroup-name
'broken-reply-to
)
1993 (gnus-article-hide-header "reply-to")
1994 (let ((from (message-fetch-field "from"))
1995 (reply-to (message-fetch-field "reply-to")))
2002 (lambda (x) (downcase (cadr x
)))
2003 (mail-extract-address-components from t
))
2006 (lambda (x) (downcase (cadr x
)))
2007 (mail-extract-address-components reply-to t
))
2009 (gnus-article-hide-header "reply-to")))))
2011 (let ((date (with-current-buffer gnus-original-article-buffer
2012 ;; If date in `gnus-article-buffer' is localized
2013 ;; (`gnus-treat-date-user-defined'),
2014 ;; `days-between' might fail.
2015 (message-fetch-field "date"))))
2017 (< (days-between (current-time-string) date
)
2019 (gnus-article-hide-header "date"))))
2021 (let ((to (message-fetch-field "to"))
2022 (cc (message-fetch-field "cc")))
2023 (when (> (length to
) 1024)
2024 (gnus-article-hide-header "to"))
2025 (when (> (length cc
) 1024)
2026 (gnus-article-hide-header "cc"))))
2030 (goto-char (point-min))
2031 (while (re-search-forward "^to:" nil t
)
2032 (setq to-count
(1+ to-count
)))
2033 (when (> to-count
1)
2034 (while (> to-count
0)
2035 (goto-char (point-min))
2037 (re-search-forward "^to:" nil nil to-count
)
2039 (narrow-to-region (point) (point-max))
2040 (gnus-article-hide-header "to"))
2041 (setq to-count
(1- to-count
))))
2042 (goto-char (point-min))
2043 (while (re-search-forward "^cc:" nil t
)
2044 (setq cc-count
(1+ cc-count
)))
2045 (when (> cc-count
1)
2046 (while (> cc-count
0)
2047 (goto-char (point-min))
2049 (re-search-forward "^cc:" nil nil cc-count
)
2051 (narrow-to-region (point) (point-max))
2052 (gnus-article-hide-header "cc"))
2053 (setq cc-count
(1- cc-count
)))))))))))))
2055 (defun gnus-article-hide-header (header)
2057 (goto-char (point-min))
2058 (when (re-search-forward (concat "^" header
":") nil t
)
2059 (gnus-article-hide-text-type
2063 (if (re-search-forward "^[^ \t]" nil t
)
2068 (defvar gnus-article-normalized-header-length
40
2069 "Length of normalized headers.")
2071 (defun article-normalize-headers ()
2072 "Make all header lines 40 characters long."
2074 (let ((inhibit-read-only t
)
2078 (article-narrow-to-head)
2081 ((< (setq column
(- (point-at-eol) (point)))
2082 gnus-article-normalized-header-length
)
2084 (insert (make-string
2085 (- gnus-article-normalized-header-length column
)
2087 ((> column gnus-article-normalized-header-length
)
2088 (gnus-put-text-property
2090 (forward-char gnus-article-normalized-header-length
)
2097 (forward-line 1))))))
2099 (defun article-treat-dumbquotes ()
2100 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2101 Note that this function guesses whether a character is a sm*rtq**t* or
2102 not, so it should only be used interactively.
2104 Sm*rtq**t*s are M****s***'s unilateral extension to the
2105 iso-8859-1 character map in an attempt to provide more quoting
2106 characters. If you see something like \\222 or \\264 where
2107 you're expecting some kind of apostrophe or quotation mark, then
2110 (article-translate-strings gnus-article-dumbquotes-map
))
2112 (defvar org-entities
)
2114 (defun article-treat-non-ascii ()
2115 "Translate many Unicode characters into their ASCII equivalents."
2117 (require 'org-entities
)
2118 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2119 (dolist (elem org-entities
)
2120 (when (and (listp elem
)
2121 (= (length (nth 6 elem
)) 1))
2122 (if (featurep 'xemacs
)
2123 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2124 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2126 (when (article-goto-body)
2127 (let ((inhibit-read-only t
)
2130 (if (not (setq replace
(if (featurep 'xemacs
)
2131 (get-char-table (following-char) table
)
2132 (aref table
(following-char)))))
2135 (setq props
(text-properties-at (point)))
2137 (add-text-properties (point) (progn (insert replace
) (point))
2139 (insert replace
)))))))))
2141 (defun article-translate-characters (from to
)
2142 "Translate all characters in the body of the article according to FROM and TO.
2143 FROM is a string of characters to translate from; to is a string of
2144 characters to translate to."
2146 (when (article-goto-body)
2147 (let ((inhibit-read-only t
)
2148 (x (make-string 225 ?x
))
2150 (while (< (incf i
) (length x
))
2153 (while (< i
(length from
))
2154 (aset x
(aref from i
) (aref to i
))
2156 (translate-region (point) (point-max) x
)))))
2158 (defun article-translate-strings (map)
2159 "Translate all string in the body of the article according to MAP.
2160 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2162 (when (article-goto-body)
2163 (let ((inhibit-read-only t
))
2165 (let ((from (car elem
))
2169 (while (search-forward from nil t
)
2172 (if (eq (following-char) from
)
2176 (forward-char 1)))))))))))
2178 (defun article-treat-overstrike ()
2179 "Translate overstrikes into bold text."
2182 (when (article-goto-body)
2183 (let ((inhibit-read-only t
))
2184 (while (search-forward "\b" nil t
)
2185 (let ((next (char-after))
2186 (previous (char-after (- (point) 2))))
2187 ;; We do the boldification/underlining by hiding the
2188 ;; overstrikes and putting the proper text property
2192 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2193 (put-text-property (point) (1+ (point)) 'face
'bold
))
2195 (gnus-article-hide-text-type
2196 (1- (point)) (1+ (point)) 'overstrike
)
2198 (- (point) 2) (1- (point)) 'face
'underline
))
2200 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2202 (point) (1+ (point)) 'face
'underline
)))))))))
2204 (defun article-treat-ansi-sequences ()
2205 "Translate ANSI SGR control sequences into overlays or extents."
2208 (when (article-goto-body)
2209 (let ((inhibit-read-only t
))
2210 (ansi-color-apply-on-region (point) (point-max))))))
2212 (defun gnus-article-treat-unfold-headers ()
2213 "Unfold folded message headers.
2214 Only the headers that fit into the current window width will be
2217 (gnus-with-article-headers
2221 (mail-header-narrow-to-field)
2222 (let* ((header (buffer-string))
2224 (or (equal gnus-article-unfold-long-headers t
)
2225 (and (stringp gnus-article-unfold-long-headers
)
2226 (string-match gnus-article-unfold-long-headers header
)))))
2229 (goto-char (point-min))
2230 (while (re-search-forward "\n[\t ]" nil t
)
2231 (replace-match " " t t
)))
2232 (setq length
(- (point-max) (point-min) 1))
2233 (when (or unfoldable
2234 (< length
(window-width)))
2235 (while (re-search-forward "\n[\t ]" nil t
)
2236 (replace-match " " t t
))))
2237 (goto-char (point-max)))))))
2239 (defun gnus-article-treat-fold-headers ()
2240 "Fold message headers."
2242 (gnus-with-article-headers
2245 (mail-header-narrow-to-field)
2246 (mail-header-fold-field)
2247 (goto-char (point-max))))))
2249 (defun gnus-treat-smiley ()
2250 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2252 (gnus-with-article-buffer
2253 (if (memq 'smiley gnus-article-wash-types
)
2254 (gnus-delete-images 'smiley
)
2256 (let ((images (smiley-region (point) (point-max))))
2258 (gnus-add-wash-type 'smiley
)
2259 (dolist (image images
)
2260 (gnus-add-image 'smiley image
)))))))
2262 (defun gnus-article-remove-images ()
2263 "Remove all images from the article buffer."
2265 (gnus-with-article-buffer
2268 (dolist (elem gnus-article-image-alist
)
2269 (gnus-delete-images (car elem
))))))
2271 (defun gnus-article-show-images ()
2272 "Show any images that are in the HTML-rendered article buffer.
2273 This only works if the article in question is HTML."
2275 (gnus-with-article-buffer
2278 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2280 (destructuring-bind (start end function
) region
2281 (funcall function
(get-text-property start
'image-url
)
2284 (defun gnus-article-treat-fold-newsgroups ()
2285 "Unfold folded message headers.
2286 Only the headers that fit into the current window width will be
2289 (gnus-with-article-headers
2290 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2292 (mail-header-narrow-to-field)
2293 (while (re-search-forward ", *" nil t
)
2294 (replace-match ", " t t
))
2295 (mail-header-fold-field)
2296 (goto-char (point-max))))))
2298 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2299 "Value of `truncate-lines' in Gnus Article buffer.
2300 Valid values are nil, t, `head', `first', `last', an integer or a
2301 predicate. See Info node `(gnus)Customizing Articles'."
2302 :version
"23.1" ;; No Gnus
2303 :group
'gnus-article
2304 ;; :link '(custom-manual "(gnus)Customizing Articles")
2307 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2308 "Toggle whether to fold or truncate long lines in article the buffer.
2309 If ARG is non-nil and not a number, toggle
2310 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2311 long lines if and only if arg is positive."
2314 ((and (numberp arg
) (> arg
0))
2315 (setq gnus-article-truncate-lines t
))
2317 (setq gnus-article-truncate-lines nil
))
2319 (setq gnus-article-truncate-lines
2320 (not gnus-article-truncate-lines
))))
2321 (gnus-with-article-buffer
2323 ((and (numberp arg
) (> arg
0))
2324 (setq truncate-lines nil
))
2326 (setq truncate-lines t
)))
2327 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2328 ;; `toggle-truncate-lines' needs an argument.
2329 (toggle-truncate-lines)))
2331 (defun gnus-article-treat-body-boundary ()
2332 "Place a boundary line at the end of the headers."
2334 (when (and gnus-body-boundary-delimiter
2335 (> (length gnus-body-boundary-delimiter
) 0))
2336 (gnus-with-article-headers
2337 (goto-char (point-max))
2338 (let ((start (point)))
2339 (insert "X-Boundary: ")
2340 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2341 (insert (let (str (max (window-width)))
2342 (if (featurep 'xemacs
)
2343 (setq max
(1- max
)))
2344 (while (>= max
(length str
))
2345 (setq str
(concat str gnus-body-boundary-delimiter
)))
2346 (substring str
0 max
))
2348 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2350 (defun article-fill-long-lines ()
2351 "Fill lines that are wider than the window width."
2354 (let ((inhibit-read-only t
)
2355 (width (window-width (get-buffer-window (current-buffer)))))
2358 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2361 (when (>= (current-column) (min fill-column width
))
2362 (narrow-to-region (min (1+ (point)) (point-max))
2364 (let ((goback (point-marker)))
2365 (fill-paragraph nil
)
2366 (goto-char (marker-position goback
)))
2368 (forward-line 1)))))))
2370 (defun article-capitalize-sentences ()
2371 "Capitalize the first word in each sentence."
2374 (let ((inhibit-read-only t
)
2375 (paragraph-start "^[\n\^L]"))
2379 (forward-sentence)))))
2381 (defun article-remove-cr ()
2382 "Remove trailing CRs and then translate remaining CRs into LFs."
2385 (let ((inhibit-read-only t
))
2386 (goto-char (point-min))
2387 (while (re-search-forward "\r+$" nil t
)
2388 (replace-match "" t t
))
2389 (goto-char (point-min))
2390 (while (search-forward "\r" nil t
)
2391 (replace-match "\n" t t
)))))
2393 (defun article-remove-trailing-blank-lines ()
2394 "Remove all trailing blank lines from the article."
2397 (let ((inhibit-read-only t
))
2398 (goto-char (point-max))
2402 (while (and (not (bobp))
2403 (looking-at "^[ \t]*$")
2404 (not (gnus-annotation-in-region-p
2405 (point) (point-at-eol))))
2410 (defvar gnus-face-properties-alist
)
2412 (defun article-display-face (&optional force
)
2413 "Display any Face headers in the header."
2414 (interactive (list 'force
))
2415 (let ((wash-face-p buffer-read-only
))
2416 (gnus-with-article-headers
2417 ;; When displaying parts, this function can be called several times on
2418 ;; the same article, without any intended toggle semantic (as typing `W
2419 ;; D d' would have). So face deletion must occur only when we come from
2420 ;; an interactive command, that is when the *Article* buffer is
2422 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2423 (gnus-delete-images 'face
)
2424 (let ((from (message-fetch-field "from"))
2426 (save-current-buffer
2427 (when (and wash-face-p
2428 (gnus-buffer-live-p gnus-original-article-buffer
)
2429 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2430 (set-buffer gnus-original-article-buffer
))
2432 (mail-narrow-to-head)
2434 ;; Check whether this face is censored.
2435 (not (and gnus-article-x-face-too-ugly
2437 (setq from
(message-fetch-field "from")))
2438 (string-match gnus-article-x-face-too-ugly
2440 (while (gnus-article-goto-header "Face")
2441 (push (mail-header-field-value) faces
)))))
2443 (goto-char (point-min))
2445 (unless (setq from
(gnus-article-goto-header "from"))
2448 (insert " [no `from' set]\n"))
2450 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2452 (apply 'gnus-create-image png
'png t
2453 (cdr (assq 'png gnus-face-properties-alist
))))
2455 (gnus-add-wash-type 'face
)
2456 (gnus-add-image 'face image
)
2457 (gnus-put-image image nil
'face
))))))))))
2459 (defun article-display-x-face (&optional force
)
2460 "Look for an X-Face header and display it if present."
2461 (interactive (list 'force
))
2462 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2463 (gnus-with-article-headers
2464 ;; Delete the old process, if any.
2465 (when (process-status "article-x-face")
2466 (delete-process "article-x-face"))
2467 ;; See the comment in `article-display-face'.
2468 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2469 ;; We have already displayed X-Faces, so we remove them
2471 (gnus-delete-images 'xface
)
2473 (let ((from (message-fetch-field "from"))
2475 (save-current-buffer
2476 (when (and wash-face-p
2477 (gnus-buffer-live-p gnus-original-article-buffer
)
2478 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2479 ;; If type `W f', use gnus-original-article-buffer,
2480 ;; otherwise use the current buffer because displaying
2481 ;; RFC822 parts calls this function too.
2482 (set-buffer gnus-original-article-buffer
))
2484 (mail-narrow-to-head)
2485 (and gnus-article-x-face-command
2487 ;; Check whether this face is censored.
2488 (not (and gnus-article-x-face-too-ugly
2490 (setq from
(message-fetch-field "from")))
2491 (string-match gnus-article-x-face-too-ugly
2493 (while (gnus-article-goto-header "X-Face")
2494 (push (mail-header-field-value) x-faces
)))))
2496 ;; We display the face.
2497 (cond ((functionp gnus-article-x-face-command
)
2498 ;; The command is a lisp function, so we call it.
2499 (mapc gnus-article-x-face-command x-faces
))
2500 ((stringp gnus-article-x-face-command
)
2501 ;; The command is a string, so we interpret the command
2502 ;; as a, well, command, and fork it off.
2503 (let ((process-connection-type nil
))
2504 (gnus-set-process-query-on-exit-flag
2506 "article-x-face" nil shell-file-name
2507 shell-command-switch gnus-article-x-face-command
)
2509 ;; Sending multiple EOFs to xv doesn't work,
2510 ;; so we only do a single external face.
2512 (insert (car x-faces
))
2513 (process-send-region "article-x-face"
2514 (point-min) (point-max)))
2515 (process-send-eof "article-x-face")))
2517 (error "`%s' set to `%s' is not a function"
2518 gnus-article-x-face-command
2519 'gnus-article-x-face-command
)))))))))
2521 (defun article-decode-mime-words ()
2522 "Decode all MIME-encoded words in the article."
2524 (gnus-with-article-buffer
2525 (let ((inhibit-point-motion-hooks t
)
2526 (mail-parse-charset gnus-newsgroup-charset
)
2527 (mail-parse-ignored-charsets
2528 (with-current-buffer gnus-summary-buffer
2529 gnus-newsgroup-ignored-charsets
)))
2530 (mail-decode-encoded-word-region (point-min) (point-max)))))
2532 (defun article-decode-charset (&optional prompt
)
2533 "Decode charset-encoded text in the article.
2534 If PROMPT (the prefix), prompt for a coding system to use."
2536 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2537 (inhibit-read-only t
)
2538 (mail-parse-charset gnus-newsgroup-charset
)
2539 (mail-parse-ignored-charsets
2540 (save-excursion (condition-case nil
2541 (set-buffer gnus-summary-buffer
)
2543 gnus-newsgroup-ignored-charsets
))
2544 ct cte ctl charset format
)
2547 (article-narrow-to-head)
2548 (setq ct
(message-fetch-field "Content-Type" t
)
2549 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2550 ctl
(and ct
(mail-header-parse-content-type ct
))
2553 (mm-read-coding-system "Charset to decode: "))
2555 (mail-content-type-get ctl
'charset
)))
2556 format
(and ctl
(mail-content-type-get ctl
'format
)))
2558 (setq cte
(mail-header-strip cte
)))
2559 (if (and ctl
(not (string-match "/" (car ctl
))))
2561 (goto-char (point-max)))
2564 (narrow-to-region (point) (point-max))
2565 (when (and (eq mail-parse-charset
'gnus-decoded
)
2566 (eq (mm-body-7-or-8) '8bit
))
2567 ;; The text code could have been decoded.
2568 (setq charset mail-parse-charset
))
2569 (when (and (or (not ctl
)
2570 (equal (car ctl
) "text/plain"))
2571 (not format
)) ;; article with format will decode later.
2573 charset
(and cte
(intern (downcase
2574 (gnus-strip-whitespace cte
))))
2577 (defun article-decode-encoded-words ()
2578 "Remove encoded-word encoding from headers."
2579 (let ((inhibit-point-motion-hooks t
)
2580 (mail-parse-charset gnus-newsgroup-charset
)
2581 (mail-parse-ignored-charsets
2582 (save-excursion (condition-case nil
2583 (set-buffer gnus-summary-buffer
)
2585 gnus-newsgroup-ignored-charsets
))
2586 (inhibit-read-only t
)
2588 (goto-char (point-min))
2589 (when (search-forward "\n\n" nil
'move
)
2596 (memq (char-after) '(?
\t ?
)))))
2597 (setq start
(point))
2599 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2600 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2601 (funcall gnus-decode-address-function start end
)
2602 (funcall gnus-decode-header-function start end
))
2603 (goto-char (setq end start
)))))
2605 (defun article-decode-group-name ()
2606 "Decode group names in Newsgroups, Followup-To and Xref headers."
2607 (let ((inhibit-point-motion-hooks t
)
2608 (inhibit-read-only t
)
2609 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2611 (when (and (or gnus-group-name-charset-method-alist
2612 gnus-group-name-charset-group-alist
)
2613 (gnus-buffer-live-p gnus-original-article-buffer
))
2615 (article-narrow-to-head)
2616 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2617 (with-current-buffer gnus-original-article-buffer
2618 (goto-char (point-min)))
2619 (setq regexp
(concat "^" header
2620 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2621 (while (re-search-forward regexp nil t
)
2622 (replace-match (save-match-data
2623 (gnus-decode-newsgroups
2624 ;; XXX how to use data in article buffer?
2625 (with-current-buffer gnus-original-article-buffer
2626 (re-search-forward regexp nil t
)
2628 gnus-newsgroup-name method
))
2630 (goto-char (point-min)))))))
2632 (autoload 'idna-to-unicode
"idna")
2634 (defun article-decode-idna-rhs ()
2635 "Decode IDNA strings in RHS in various headers in current buffer.
2636 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2637 Mail-Reply-To: and Mail-Followup-To:."
2640 (let ((inhibit-point-motion-hooks t
)
2641 (inhibit-read-only t
))
2642 (article-narrow-to-head)
2643 (goto-char (point-min))
2644 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2646 (when (save-match-data
2647 (and (setq ace
(match-string 1))
2649 (and (re-search-backward "^[^ \t]" nil t
)
2650 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2651 (setq unicode
(idna-to-unicode ace
))))
2652 (unless (string= ace unicode
)
2653 (replace-match unicode nil nil nil
1)))))))))
2655 (defun article-de-quoted-unreadable (&optional force read-charset
)
2656 "Translate a quoted-printable-encoded article.
2657 If FORCE, decode the article whether it is marked as quoted-printable
2659 If READ-CHARSET, ask for a coding system."
2660 (interactive (list 'force current-prefix-arg
))
2662 (let ((inhibit-read-only t
) type charset
)
2663 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2664 (with-current-buffer gnus-original-article-buffer
2666 (gnus-fetch-field "content-transfer-encoding"))
2667 (let* ((ct (gnus-fetch-field "content-type"))
2668 (ctl (and ct
(mail-header-parse-content-type ct
))))
2669 (setq charset
(and ctl
2670 (mail-content-type-get ctl
'charset
)))
2671 (if (stringp charset
)
2672 (setq charset
(intern (downcase charset
)))))))
2674 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2676 (setq charset gnus-newsgroup-charset
))
2678 (and type
(let ((case-fold-search t
))
2679 (string-match "quoted-printable" type
))))
2681 (quoted-printable-decode-region
2682 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2684 (defun article-de-base64-unreadable (&optional force read-charset
)
2685 "Translate a base64 article.
2686 If FORCE, decode the article whether it is marked as base64 not.
2687 If READ-CHARSET, ask for a coding system."
2688 (interactive (list 'force current-prefix-arg
))
2690 (let ((inhibit-read-only t
) type charset
)
2691 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2692 (with-current-buffer gnus-original-article-buffer
2694 (gnus-fetch-field "content-transfer-encoding"))
2695 (let* ((ct (gnus-fetch-field "content-type"))
2696 (ctl (and ct
(mail-header-parse-content-type ct
))))
2697 (setq charset
(and ctl
2698 (mail-content-type-get ctl
'charset
)))
2699 (if (stringp charset
)
2700 (setq charset
(intern (downcase charset
)))))))
2702 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2704 (setq charset gnus-newsgroup-charset
))
2706 (and type
(let ((case-fold-search t
))
2707 (string-match "base64" type
))))
2710 (narrow-to-region (point) (point-max))
2711 (base64-decode-region (point-min) (point-max))
2712 (mm-decode-coding-region
2713 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2718 (defun article-decode-HZ ()
2719 "Translate a HZ-encoded article."
2723 (let ((inhibit-read-only t
))
2724 (rfc1843-decode-region (point-min) (point-max)))))
2726 (defun article-unsplit-urls ()
2727 "Remove the newlines that some other mailers insert into URLs."
2730 (let ((inhibit-read-only t
))
2731 (goto-char (point-min))
2732 (while (re-search-forward
2733 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2734 (replace-match "\\1\\3" t
)))
2735 (when (interactive-p)
2736 (gnus-treat-article nil
))))
2738 (defun article-wash-html ()
2739 "Format an HTML article."
2742 (buffer-read-only nil
))
2743 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2744 (setq handles
(mm-dissect-buffer t t
)))
2746 (delete-region (point) (point-max))
2747 (mm-inline-text-html handles
)))
2749 (defvar gnus-article-browse-html-temp-list nil
2750 "List of temporary files created by `gnus-article-browse-html-parts'.
2751 Internal variable.")
2753 (defcustom gnus-article-browse-delete-temp
'ask
2754 "What to do with temporary files from `gnus-article-browse-html-parts'.
2755 If nil, don't delete temporary files. If it is t, delete them on
2756 exit from the summary buffer. If it is the symbol `file', query
2757 on each file, if it is `ask' ask once when exiting from the
2759 :group
'gnus-article
2760 :version
"23.1" ;; No Gnus
2761 :type
'(choice (const :tag
"Don't delete" nil
)
2762 (const :tag
"Don't ask" t
)
2763 (const :tag
"Ask" ask
)
2764 (const :tag
"Ask for each file" file
)))
2766 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2768 (defun gnus-article-browse-delete-temp-files (&optional how
)
2769 "Delete temp-files created by `gnus-article-browse-html-parts'."
2770 (when (and gnus-article-browse-html-temp-list
2772 (or how
(setq how gnus-article-browse-delete-temp
))
2774 (let ((files (length gnus-article-browse-html-temp-list
)))
2775 (gnus-y-or-n-p (format
2776 "Delete all %s temporary HTML file%s? "
2778 (if (> files
1) "s" ""))))
2780 (dolist (file gnus-article-browse-html-temp-list
)
2781 (cond ((file-directory-p file
)
2782 (when (or (not (eq how
'file
))
2785 "Delete temporary HTML file(s) in directory `%s'? "
2786 (file-name-as-directory file
))))
2787 (gnus-delete-directory file
)))
2788 ((file-exists-p file
)
2789 (when (or (not (eq how
'file
))
2791 (format "Delete temporary HTML file `%s'? " file
)))
2792 (delete-file file
)))))
2793 ;; Also remove file from the list when not deleted or if file doesn't
2795 (setq gnus-article-browse-html-temp-list nil
))
2796 gnus-article-browse-html-temp-list
)
2798 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2799 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2804 (dolist (handle handles
)
2806 ((not (listp handle
)))
2807 ((equal (mm-handle-media-supertype handle
) "multipart")
2808 (when (setq file
(gnus-article-browse-html-save-cid-content
2809 cid handle directory
))
2810 (throw 'found file
)))
2811 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2814 (or (mm-handle-filename handle
)
2816 (make-temp-name "cid")
2817 (car (rassoc (car (mm-handle-type handle
)) mailcap-mime-extensions
))))
2819 (mm-save-part-to-file handle file
)
2820 (throw 'found file
))))))))
2822 (defun gnus-article-browse-html-parts (list &optional header
)
2823 "View all \"text/html\" parts from LIST.
2824 Recurse into multiparts. The optional HEADER that should be a decoded
2825 message header will be added to the bodies of the \"text/html\" parts."
2826 ;; Internal function used by `gnus-article-browse-html-article'.
2827 (let (type file charset content cid-dir tmp-file showed
)
2828 ;; Find and show the html-parts.
2829 (dolist (handle list
)
2830 ;; If HTML, show it:
2831 (cond ((not (listp handle
)))
2832 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2833 (and (equal (car type
) "message/external-body")
2835 (setq file
(mm-handle-filename handle
)))
2836 (or (mm-handle-cache handle
)
2837 (condition-case code
2838 (progn (mm-extern-cache-contents handle
) t
)
2840 (gnus-message 3 "%s" (error-message-string code
))
2841 (when (>= gnus-verbose
3) (sit-for 2))
2844 (setq handle
(mm-handle-cache handle
)
2845 type
(mm-handle-type handle
))
2846 (equal (car type
) "text/html"))))
2847 (setq charset
(mail-content-type-get type
'charset
)
2848 content
(mm-get-part handle
))
2850 (if (eq charset
'gnus-decoded
)
2851 (mm-enable-multibyte)
2852 (mm-disable-multibyte))
2854 ;; resolve cid contents
2855 (let ((case-fold-search t
)
2857 (goto-char (point-min))
2858 (while (re-search-forward "\
2859 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2862 (setq cid-dir
(mm-make-temp-file "cid" t
))
2863 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2866 (when (setq cid-file
2867 (gnus-article-browse-html-save-cid-content
2869 (with-current-buffer gnus-article-buffer
2870 gnus-article-mime-handles
)
2872 (replace-match (concat "file://" cid-file
)
2874 (unless content
(setq content
(buffer-string))))
2875 (when (or charset header
(not file
))
2876 (setq tmp-file
(mm-make-temp-file
2877 ;; Do we need to care for 8.3 filenames?
2878 "mm-" nil
".html")))
2879 ;; Add a meta html tag to specify charset and a header.
2882 (let (title eheader body hcharset coding force-charset
)
2884 (mm-enable-multibyte)
2885 (setq case-fold-search t
)
2886 (insert header
"\n")
2887 (setq title
(message-fetch-field "subject"))
2888 (goto-char (point-min))
2889 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t
)
2890 (replace-match (cond ((match-beginning 1) "<")
2891 ((match-beginning 2) ">")
2893 (goto-char (point-min))
2895 (goto-char (point-max))
2896 (insert "</pre>\n<hr>\n")
2897 ;; We have to examine charset one by one since
2898 ;; charset specified in parts might be different.
2899 (if (eq charset
'gnus-decoded
)
2900 (setq charset
'utf-8
2901 eheader
(mm-encode-coding-string (buffer-string)
2904 (mm-encode-coding-string title charset
))
2905 body
(mm-encode-coding-string content charset
)
2907 (setq hcharset
(mm-find-mime-charset-region (point-min)
2909 (cond ((= (length hcharset
) 1)
2910 (setq hcharset
(car hcharset
)
2911 coding
(mm-charset-to-coding-system
2913 ((> (length hcharset
) 1)
2914 (setq hcharset
'utf-8
2920 (mm-charset-to-coding-system charset
))
2921 (if (eq coding body
)
2922 (setq eheader
(mm-encode-coding-string
2923 (buffer-string) coding
)
2925 (mm-encode-coding-string
2928 (setq charset
'utf-8
2929 eheader
(mm-encode-coding-string
2930 (buffer-string) charset
)
2932 (mm-encode-coding-string
2934 body
(mm-encode-coding-string
2935 (mm-decode-coding-string
2939 (setq charset hcharset
2940 eheader
(mm-encode-coding-string
2941 (buffer-string) coding
)
2943 (mm-encode-coding-string
2946 (setq eheader
(mm-string-as-unibyte (buffer-string))
2949 (mm-disable-multibyte)
2952 (mm-add-meta-html-tag handle charset force-charset
))
2954 (goto-char (point-min))
2955 (unless (search-forward "<title>" nil t
)
2956 (re-search-forward "<head>\\s-*" nil t
)
2957 (insert "<title>" title
"</title>\n")))
2958 (goto-char (point-min))
2959 (or (re-search-forward
2960 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2962 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2964 (mm-write-region (point-min) (point-max)
2965 tmp-file nil nil nil
'binary t
))))
2967 (mm-with-unibyte-buffer
2968 (insert (if (eq charset
'gnus-decoded
)
2969 (mm-encode-coding-string content
2970 (setq charset
'utf-8
))
2972 (if (or (mm-add-meta-html-tag handle charset
)
2974 (mm-write-region (point-min) (point-max)
2975 tmp-file nil nil nil
'binary t
)
2976 (setq tmp-file nil
))))
2978 (mm-save-part-to-file handle tmp-file
)))
2980 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2981 (add-hook 'gnus-summary-prepare-exit-hook
2982 'gnus-article-browse-delete-temp-files
)
2983 (add-hook 'gnus-exit-gnus-hook
2985 (gnus-article-browse-delete-temp-files t
)))
2986 ;; FIXME: Warn if there's an <img> tag?
2987 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2989 ;; If multipart, recurse
2990 ((equal (mm-handle-media-supertype handle
) "multipart")
2991 (when (gnus-article-browse-html-parts handle header
)
2993 ((equal (mm-handle-media-type handle
) "message/rfc822")
2994 (mm-with-multibyte-buffer
2995 (mm-insert-part handle
)
2996 (setq handle
(mm-dissect-buffer t t
))
2997 (when (and (bufferp (car handle
))
2998 (stringp (car (mm-handle-type handle
))))
2999 (setq handle
(list handle
)))
3001 (article-decode-encoded-words)
3002 (let ((gnus-visible-headers
3003 (or (get 'gnus-visible-headers
'standard-value
)
3004 gnus-visible-headers
)))
3005 (article-hide-headers))
3006 (goto-char (point-min))
3007 (search-forward "\n\n" nil
'move
)
3008 (skip-chars-backward "\t\n ")
3009 (setq header
(buffer-substring (point-min) (point)))))
3011 (gnus-article-browse-html-parts handle header
)
3012 (mm-destroy-parts handle
))
3016 (defun gnus-article-browse-html-article (&optional arg
)
3017 "View \"text/html\" parts of the current article with a WWW browser.
3018 Inline images embedded in a message using the cid scheme, as they are
3019 generally considered to be safe, will be processed properly.
3020 The message header is added to the beginning of every html part unless
3021 the prefix argument ARG is given.
3023 Warning: Spammers use links to images (using the http scheme) in HTML
3024 articles to verify whether you have read the message. As
3025 `gnus-article-browse-html-article' passes the HTML content to the
3026 browser without eliminating these \"web bugs\" you should only
3027 use it for mails from trusted senders.
3029 If you always want to display HTML parts in the browser, set
3030 `mm-text-html-renderer' to nil.
3032 This command creates temporary files to pass HTML contents including
3033 images if any to the browser, and deletes them when exiting the group
3035 ;; Cf. `mm-w3m-safe-url-regexp'
3038 (gnus-summary-show-article)
3039 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3040 gnus-visible-headers
))
3041 ;; As we insert a <hr>, there's no need for the body boundary.
3042 (gnus-treat-body-boundary nil
))
3043 (gnus-summary-show-article)))
3044 (with-current-buffer gnus-article-buffer
3045 (let ((header (unless arg
3048 (buffer-substring-no-properties
3049 (goto-char (point-min))
3050 (if (search-forward "\n\n" nil t
)
3052 (goto-char (point-max))
3053 (skip-chars-backward "\t\n ")
3056 (set-buffer gnus-original-article-buffer
)
3057 (setq parts
(mm-dissect-buffer t t
))
3058 ;; If singlepart, enforce a list.
3059 (when (and (bufferp (car parts
))
3060 (stringp (car (mm-handle-type parts
))))
3061 (setq parts
(list parts
)))
3063 (unless (gnus-article-browse-html-parts parts header
)
3064 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3065 (mm-destroy-parts parts
)
3067 (gnus-summary-show-article)))))
3069 (defun article-hide-list-identifiers ()
3070 "Remove list identifies from the Subject header.
3071 The `gnus-list-identifiers' variable specifies what to do."
3073 (let ((inhibit-point-motion-hooks t
)
3074 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3075 (inhibit-read-only t
))
3079 (article-narrow-to-head)
3080 (goto-char (point-min))
3081 (while (re-search-forward
3082 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3084 (delete-region (match-beginning 2) (match-end 0))
3085 (beginning-of-line))
3086 (when (re-search-forward
3087 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3088 (delete-region (match-beginning 1) (match-end 1))))))))
3090 (defun article-hide-pem (&optional arg
)
3091 "Toggle hiding of any PEM headers and signatures in the current article.
3092 If given a negative prefix, always show; if given a positive prefix,
3094 (interactive (gnus-article-hidden-arg))
3095 (unless (gnus-article-check-hidden-text 'pem arg
)
3097 (let ((inhibit-read-only t
) end
)
3098 (goto-char (point-min))
3099 ;; Hide the horrendously ugly "header".
3100 (when (and (search-forward
3101 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3103 (setq end
(1+ (match-beginning 0))))
3104 (gnus-add-wash-type 'pem
)
3105 (gnus-article-hide-text-type
3107 (if (search-forward "\n\n" nil t
)
3111 ;; Hide the trailer as well
3112 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3114 (gnus-article-hide-text-type
3115 (match-beginning 0) (match-end 0) 'pem
)))))))
3117 (defun article-strip-banner ()
3118 "Strip the banners specified by the `banner' group parameter and by
3119 `gnus-article-address-banner-alist'."
3123 (let ((inhibit-point-motion-hooks t
))
3124 (when (gnus-parameter-banner gnus-newsgroup-name
)
3125 (article-really-strip-banner
3126 (gnus-parameter-banner gnus-newsgroup-name
)))
3127 (when gnus-article-address-banner-alist
3128 ;; Note that the From header is decoded here, so it is
3129 ;; required that the *-extract-address-components function
3130 ;; supports non-ASCII text.
3131 (let ((from (save-restriction
3133 (article-narrow-to-head)
3134 (mail-fetch-field "from"))))
3137 (cadr (funcall gnus-extract-address-components
3140 (dolist (pair gnus-article-address-banner-alist
)
3141 (when (string-match (car pair
) from
)
3143 (article-really-strip-banner (cdr pair
)))))))))))))
3145 (defun article-really-strip-banner (banner)
3146 "Strip the banner specified by the argument."
3149 (let ((inhibit-point-motion-hooks t
)
3150 (gnus-signature-limit nil
)
3151 (inhibit-read-only t
))
3154 ((eq banner
'signature
)
3155 (when (gnus-article-narrow-to-signature)
3158 (delete-region (point) (point-max))))
3160 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3161 (while (re-search-forward banner nil t
)
3162 (delete-region (match-beginning 0) (match-end 0)))))
3164 (while (re-search-forward banner nil t
)
3165 (delete-region (match-beginning 0) (match-end 0)))))))))
3167 (defun article-babel ()
3168 "Translate article using an online translation service."
3171 (gnus-with-article-buffer
3172 (when (article-goto-body)
3173 (let* ((start (point))
3175 (orig (buffer-substring start end
))
3176 (trans (babel-as-string orig
)))
3178 (narrow-to-region start end
)
3179 (delete-region start end
)
3182 (defun article-hide-signature (&optional arg
)
3183 "Hide the signature in the current article.
3184 If given a negative prefix, always show; if given a positive prefix,
3186 (interactive (gnus-article-hidden-arg))
3187 (unless (gnus-article-check-hidden-text 'signature arg
)
3190 (let ((inhibit-read-only t
))
3191 (when (gnus-article-narrow-to-signature)
3192 (gnus-article-hide-text-type
3193 (point-min) (point-max) 'signature
))))))
3194 (gnus-set-mode-line 'article
))
3196 (defun article-strip-headers-in-body ()
3197 "Strip offensive headers from bodies."
3201 (let ((case-fold-search t
))
3202 (when (looking-at "x-no-archive:")
3203 (gnus-delete-line)))))
3205 (defun article-strip-leading-blank-lines ()
3206 "Remove all blank lines from the beginning of the article."
3209 (let ((inhibit-point-motion-hooks t
)
3210 (inhibit-read-only t
))
3211 (when (article-goto-body)
3212 (while (and (not (eobp))
3213 (looking-at "[ \t]*$"))
3214 (gnus-delete-line))))))
3216 (defun article-narrow-to-head ()
3217 "Narrow the buffer to the head of the message.
3218 Point is left at the beginning of the narrowed-to region."
3220 (goto-char (point-min))
3221 (if (search-forward "\n\n" nil
1)
3224 (goto-char (point-min)))
3226 (defun article-goto-body ()
3227 "Place point at the start of the body."
3228 (goto-char (point-min))
3230 ;; This variable is only bound when dealing with separate
3232 (article-goto-body-goes-to-point-min-p
3234 ((search-forward "\n\n" nil t
)
3237 (goto-char (point-max))
3240 (defun article-strip-multiple-blank-lines ()
3241 "Replace consecutive blank lines with one empty line."
3244 (let ((inhibit-point-motion-hooks t
)
3245 (inhibit-read-only t
))
3246 ;; First make all blank lines empty.
3248 (while (re-search-forward "^[ \t]+$" nil t
)
3249 (unless (gnus-annotation-in-region-p
3250 (match-beginning 0) (match-end 0))
3251 (replace-match "" nil t
)))
3252 ;; Then replace multiple empty lines with a single empty line.
3254 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3255 (unless (gnus-annotation-in-region-p
3256 (match-beginning 0) (match-end 0))
3257 (delete-region (match-beginning 1) (match-end 1)))))))
3259 (defun article-strip-leading-space ()
3260 "Remove all white space from the beginning of the lines in the article."
3263 (let ((inhibit-point-motion-hooks t
)
3264 (inhibit-read-only t
))
3266 (while (re-search-forward "^[ \t]+" nil t
)
3267 (replace-match "" t t
)))))
3269 (defun article-strip-trailing-space ()
3270 "Remove all white space from the end of the lines in the article."
3273 (let ((inhibit-point-motion-hooks t
)
3274 (inhibit-read-only t
))
3276 (while (re-search-forward "[ \t]+$" nil t
)
3277 (replace-match "" t t
)))))
3279 (defun article-strip-blank-lines ()
3280 "Strip leading, trailing and multiple blank lines."
3282 (article-strip-leading-blank-lines)
3283 (article-remove-trailing-blank-lines)
3284 (article-strip-multiple-blank-lines))
3286 (defun article-strip-all-blank-lines ()
3287 "Strip all blank lines."
3290 (let ((inhibit-point-motion-hooks t
)
3291 (inhibit-read-only t
))
3293 (while (re-search-forward "^[ \t]*\n" nil t
)
3294 (replace-match "" t t
)))))
3296 (defun gnus-article-narrow-to-signature ()
3297 "Narrow to the signature; return t if a signature is found, else nil."
3298 (let ((inhibit-point-motion-hooks t
))
3299 (when (gnus-article-search-signature)
3301 ;; Check whether we have some limits to what we consider
3302 ;; to be a signature.
3303 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3304 (list gnus-signature-limit
)))
3306 (while (setq limit
(pop limits
))
3307 (if (or (and (integerp limit
)
3308 (< (- (point-max) (point)) limit
))
3310 (< (count-lines (point) (point-max)) limit
))
3311 (and (functionp limit
)
3313 (and (stringp limit
)
3314 (not (re-search-forward limit nil t
))))
3315 () ; This limit did not succeed.
3319 (narrow-to-region (point) (point-max))
3322 (defun gnus-article-search-signature ()
3323 "Search the current buffer for the signature separator.
3324 Put point at the beginning of the signature separator."
3325 (let ((cur (point)))
3326 (goto-char (point-max))
3327 (if (if (stringp gnus-signature-separator
)
3328 (re-search-backward gnus-signature-separator nil t
)
3329 (let ((seps gnus-signature-separator
))
3331 (not (re-search-backward (car seps
) nil t
)))
3338 (defun gnus-article-hidden-arg ()
3339 "Return the current prefix arg as a number, or 0 if no prefix."
3340 (list (if current-prefix-arg
3341 (prefix-numeric-value current-prefix-arg
)
3344 (defun gnus-article-check-hidden-text (type arg
)
3345 "Return nil if hiding is necessary.
3346 Arg can be nil or a number. nil and positive means hide, negative
3347 means show, 0 means toggle."
3350 (let ((hide (gnus-article-hidden-text-p type
)))
3356 (gnus-article-show-hidden-text type
)
3359 (if (eq hide
'hidden
)
3361 (gnus-article-show-hidden-text type
)
3365 (defun gnus-article-hidden-text-p (type)
3366 "Say whether the current buffer contains hidden text of type TYPE."
3367 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3369 (not (get-text-property pos
'invisible
))
3370 (not (get-text-property pos
'dummy-invisible
)))
3372 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3377 (defun gnus-article-show-hidden-text (type &optional dummy
)
3378 "Show all hidden text of type TYPE.
3379 Originally it is hide instead of DUMMY."
3380 (let ((inhibit-read-only t
)
3381 (inhibit-point-motion-hooks t
))
3382 (gnus-remove-text-properties-when
3384 (point-min) (point-max)
3385 (cons 'article-type
(cons type
3386 gnus-hidden-properties
)))
3387 (gnus-delete-wash-type type
)))
3389 (defconst article-time-units
3390 `((year .
,(* 365.25 24 60 60))
3391 (week .
,(* 7 24 60 60))
3392 (day .
,(* 24 60 60))
3396 "Mapping from time units to seconds.")
3398 (defun gnus-article-forward-header ()
3399 "Move point to the start of the next header.
3400 If the current header is a continuation header, this can be several
3405 (if (looking-at "[ \t]+[^ \t]")
3409 (defun article-treat-date ()
3410 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3411 (with-current-buffer gnus-summary-buffer
3412 gnus-article-date-headers
)
3413 gnus-article-date-headers
)
3416 (defun article-date-ut (&optional type highlight date-position
)
3417 "Convert DATE date to TYPE in the current article.
3418 The default type is `ut'. See `gnus-article-date-headers' for
3420 (interactive (list 'ut t
))
3421 (let* ((case-fold-search t
)
3422 (inhibit-read-only t
)
3423 (inhibit-point-motion-hooks t
)
3425 (visible-date (mail-fetch-field "Date"))
3426 pos date bface eface
)
3429 (goto-char (point-min))
3430 (when (re-search-forward "^Date:" nil t
)
3431 (setq bface
(get-text-property (point-at-bol) 'face
)
3432 eface
(get-text-property (1- (point-at-eol)) 'face
)))
3433 (goto-char (point-min))
3434 ;; Delete any old Date headers.
3437 (goto-char date-position
)
3438 (setq date
(get-text-property (point) 'original-date
))
3439 (delete-region (point)
3441 (gnus-article-forward-header)
3443 (article-transform-date date type bface eface
))
3444 (while (re-search-forward "^Date:" nil t
)
3445 (setq date
(get-text-property (match-beginning 0) 'original-date
))
3446 (delete-region (point-at-bol) (progn
3447 (gnus-article-forward-header)
3449 (when (and (not date
)
3451 (setq date visible-date
))
3453 (article-transform-date date type bface eface
)))))))
3455 (defun article-transform-date (date type bface eface
)
3456 (dolist (this-type (cond
3463 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3466 (put-text-property (point) (1+ (point))
3467 'original-date date
)
3468 (put-text-property (point) (1+ (point))
3469 'gnus-date-type this-type
)
3471 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3472 (put-text-property (match-beginning 1) (1+ (match-end 1))
3474 (put-text-property (match-beginning 2) (match-end 2)
3478 (defun article-make-date-line (date type
)
3479 "Return a DATE line of TYPE."
3480 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3482 (error "Unknown conversion type: %s" type
))
3484 (let ((time (ignore-errors (date-to-time date
))))
3486 ;; Convert to the local timezone.
3488 (concat "Date: " (message-make-date time
)))
3489 ;; Convert to Universal Time.
3494 (let* ((e (parse-time-string date
))
3495 (tm (apply 'encode-time e
))
3497 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3498 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3499 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3503 ;; Get the original date from the article.
3504 ((eq type
'original
)
3505 (concat "Date: " (if (string-match "\n+$" date
)
3506 (substring date
0 (match-beginning 0))
3508 ;; Let the user define the format.
3509 ((eq type
'user-defined
)
3510 (let ((format (or (condition-case nil
3511 (with-current-buffer gnus-summary-buffer
3512 gnus-article-time-format
)
3514 gnus-article-time-format
)))
3515 (if (functionp format
)
3516 (funcall format time
)
3517 (concat "Date: " (format-time-string format time
)))))
3520 (let ((tz (car (current-time-zone time
))))
3523 (format-time-string "%Y%m%dT%H%M%S" time
)
3524 (format "%s%02d%02d"
3525 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3526 (/ (%
(abs tz
) 3600) 60)))))
3527 ;; Do a lapsed format.
3529 (concat "Date: " (article-lapsed-string time
)))
3530 ;; A combined date/lapsed format.
3531 ((eq type
'combined-lapsed
)
3532 (let ((date-string (article-make-date-line date
'original
))
3538 (concat " (" (article-lapsed-string time segments
) ")"))
3539 (> (+ (length date-string
)
3540 (length lapsed-string
))
3543 (setq segments
(1- segments
)))
3545 (concat date-string lapsed-string
)
3547 ;; Display the date in proper English
3549 (let ((dtime (decode-time time
)))
3552 (number-to-string (nth 3 dtime
))
3553 (let ((digit (%
(nth 3 dtime
) 10)))
3555 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3561 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3563 (number-to-string (nth 5 dtime
))
3565 (format "%02d" (nth 2 dtime
))
3567 (format "%02d" (nth 1 dtime
)))))))
3569 (format "Date: %s (from Gnus)" date
))))
3571 (defun article-lapsed-string (time &optional max-segments
)
3572 ;; If the date is seriously mangled, the timezone functions are
3573 ;; liable to bug out, so we ignore all errors.
3574 (let* ((now (current-time))
3575 (real-time (subtract-time now time
))
3576 (real-sec (and real-time
3577 (+ (* (float (car real-time
)) 65536)
3579 (sec (and real-time
(abs real-sec
)))
3582 (unless max-segments
3583 (setq max-segments
(length article-time-units
)))
3591 ;; This is a bit convoluted, but basically we go
3592 ;; through the time units for years, weeks, etc,
3593 ;; and divide things to see whether that results
3594 ;; in positive answers.
3597 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3598 (>= segments max-segments
))
3599 ;; The (remaining) seconds are too few to
3600 ;; be divided into this time unit.
3602 ;; It's big enough, so we output it.
3603 (setq sec
(- sec
(* num
(cdr unit
))))
3605 (concat (if prev
", " "") (int-to-string
3607 " " (symbol-name (car unit
))
3608 (if (> num
1) "s" ""))
3610 segments
(1+ segments
)))))
3611 article-time-units
"")
3612 ;; If dates are odd, then it might appear like the
3613 ;; article was sent in the future.
3616 " in the future"))))))
3618 (defun article-date-local (&optional highlight
)
3619 "Convert the current article date to the local timezone."
3620 (interactive (list t
))
3621 (article-date-ut 'local highlight
))
3623 (defun article-date-english (&optional highlight
)
3624 "Convert the current article date to something that is proper English."
3625 (interactive (list t
))
3626 (article-date-ut 'english highlight
))
3628 (defun article-date-original (&optional highlight
)
3629 "Convert the current article date to what it was originally.
3630 This is only useful if you have used some other date conversion
3631 function and want to see what the date was before converting."
3632 (interactive (list t
))
3633 (article-date-ut 'original highlight
))
3635 (defun article-date-lapsed (&optional highlight
)
3636 "Convert the current article date to time lapsed since it was sent."
3637 (interactive (list t
))
3638 (article-date-ut 'lapsed highlight
))
3640 (defun article-date-combined-lapsed (&optional highlight
)
3641 "Convert the current article date to time lapsed since it was sent."
3642 (interactive (list t
))
3643 (article-date-ut 'combined-lapsed highlight
))
3645 (defun article-update-date-lapsed ()
3646 "Function to be run from a timer to update the lapsed time line."
3648 (let ((buffer (current-buffer)))
3652 (set-buffer (window-buffer w
))
3653 (when (eq major-mode
'gnus-article-mode
)
3654 (let ((old-line (count-lines (point-min) (point)))
3655 (old-column (- (point) (line-beginning-position)))
3657 (window-start (get-buffer-window (current-buffer)))))
3658 (goto-char (point-min))
3659 (while (re-search-forward "^Date:" nil t
)
3660 (let ((type (get-text-property (match-beginning 0)
3662 (when (memq type
'(lapsed combined-lapsed user-format
))
3663 (when (and window-start
3664 (not (= window-start
3668 (setq window-start nil
))
3670 (article-date-ut type t
(match-beginning 0)))
3673 (set-window-start (get-buffer-window (current-buffer))
3675 (goto-char (point-min))
3676 (when (> old-column
0)
3677 (setq old-line
(1- old-line
)))
3678 (forward-line old-line
)
3680 (when (> (current-column) old-column
)
3682 (forward-char old-column
)))))
3684 (set-buffer buffer
))))
3686 (defun gnus-start-date-timer (&optional n
)
3687 "Start a timer to update the Date headers in the article buffers.
3688 The numerical prefix says how frequently (in seconds) the function
3693 (gnus-stop-date-timer)
3694 (setq article-lapsed-timer
3695 (run-at-time 1 n
'article-update-date-lapsed
)))
3697 (defun gnus-stop-date-timer ()
3698 "Stop the Date timer."
3700 (when article-lapsed-timer
3701 (nnheader-cancel-timer article-lapsed-timer
)
3702 (setq article-lapsed-timer nil
)))
3704 (defun article-date-user (&optional highlight
)
3705 "Convert the current article date to the user-defined format.
3706 This format is defined by the `gnus-article-time-format' variable."
3707 (interactive (list t
))
3708 (article-date-ut 'user highlight
))
3710 (defun article-date-iso8601 (&optional highlight
)
3711 "Convert the current article date to ISO8601."
3712 (interactive (list t
))
3713 (article-date-ut 'iso8601 highlight
))
3715 (defmacro gnus-article-save-original-date
(&rest forms
)
3716 "Save the original date as a text property and evaluate FORMS."
3717 `(let* ((case-fold-search t
)
3719 (goto-char (point-min))
3720 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3723 (date (when (and start
3724 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3726 (buffer-substring-no-properties start
3727 (match-beginning 0)))))
3728 (goto-char (point-max))
3729 (skip-chars-backward "\n")
3730 (put-text-property (point-min) (point) 'original-date date
)
3732 (goto-char (point-max))
3733 (skip-chars-backward "\n")
3734 (put-text-property (point-min) (point) 'original-date date
)))
3736 ;; (defun article-show-all ()
3737 ;; "Show all hidden text in the article buffer."
3740 ;; (let ((inhibit-read-only t))
3741 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3743 (defun article-remove-leading-whitespace ()
3744 "Remove excessive whitespace from all headers."
3748 (let ((inhibit-read-only t
))
3749 (article-narrow-to-head)
3750 (goto-char (point-min))
3751 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3752 (delete-region (match-beginning 1) (match-end 1)))))))
3754 (defun article-emphasize (&optional arg
)
3755 "Emphasize text according to `gnus-emphasis-alist'."
3756 (interactive (gnus-article-hidden-arg))
3757 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3761 (with-current-buffer gnus-summary-buffer
3762 gnus-article-emphasis-alist
)
3764 gnus-emphasis-alist
))
3765 (inhibit-read-only t
)
3766 (props (append '(article-type emphasis
)
3767 gnus-hidden-properties
))
3768 regexp elem beg invisible visible face
)
3771 (while (setq elem
(pop alist
))
3773 (setq regexp
(car elem
)
3774 invisible
(nth 1 elem
)
3775 visible
(nth 2 elem
)
3777 (while (re-search-forward regexp nil t
)
3778 (when (and (match-beginning visible
) (match-beginning invisible
))
3779 (gnus-article-hide-text
3780 (match-beginning invisible
) (match-end invisible
) props
)
3781 (gnus-article-unhide-text-type
3782 (match-beginning visible
) (match-end visible
) 'emphasis
)
3783 (gnus-put-overlay-excluding-newlines
3784 (match-beginning visible
) (match-end visible
) 'face face
)
3785 (gnus-add-wash-type 'emphasis
)
3786 (goto-char (match-end invisible
)))))))))
3788 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3789 "Setup newsgroup emphasis alist."
3790 (unless gnus-article-emphasis-alist
3791 (let ((name (and gnus-newsgroup-name
3792 (gnus-group-real-name gnus-newsgroup-name
))))
3793 (make-local-variable 'gnus-article-emphasis-alist
)
3794 (setq gnus-article-emphasis-alist
3796 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3797 (while (setq elem
(pop alist
))
3798 (when (and name
(string-match (car elem
) name
))
3800 highlight
(copy-sequence (cdr elem
)))))
3802 (copy-sequence highlight-words
)
3803 (if gnus-newsgroup-name
3804 (copy-sequence (gnus-group-find-parameter
3805 gnus-newsgroup-name
'highlight-words t
)))
3806 gnus-emphasis-alist
)))))
3808 (defvar gnus-summary-article-menu
)
3809 (defvar gnus-summary-post-menu
)
3811 ;;; Saving functions.
3813 (defun gnus-article-save (save-buffer file
&optional num
)
3814 "Save the currently selected article."
3815 (when (or (get gnus-default-article-saver
:headers
)
3816 (not gnus-save-all-headers
))
3817 ;; Remove headers according to `gnus-saved-headers' or the value
3818 ;; of the `:headers' property that the saver function might have.
3819 (let ((gnus-visible-headers
3820 (or (symbol-value (get gnus-default-article-saver
:headers
))
3821 gnus-saved-headers gnus-visible-headers
))
3822 ;; Ignore group parameter. See `article-hide-headers'.
3823 (gnus-summary-buffer nil
))
3824 (with-current-buffer save-buffer
3825 (article-hide-headers 1 t
))))
3826 (save-window-excursion
3827 (if (not gnus-default-article-saver
)
3828 (error "No default saver is defined")
3829 ;; !!! Magic! The saving functions all save
3830 ;; `gnus-save-article-buffer' (or so they think), but we
3831 ;; bind that variable to our save-buffer.
3832 (set-buffer gnus-article-buffer
)
3833 (let* ((gnus-save-article-buffer save-buffer
)
3836 ((not gnus-prompt-before-saving
) 'default
)
3837 ((eq gnus-prompt-before-saving
'always
) nil
)
3839 (gnus-number-of-articles-to-be-saved
3840 (when (eq gnus-prompt-before-saving t
)
3842 (set-buffer gnus-article-current-summary
)
3843 (funcall gnus-default-article-saver filename
)))))
3845 (defun gnus-read-save-file-name (prompt &optional filename
3846 function group headers variable
3849 (funcall function group headers
(symbol-value variable
)))
3854 ((eq filename
'default
)
3860 (when (symbol-value dir-var
)
3861 (setq default-name
(expand-file-name
3862 (file-name-nondirectory default-name
)
3863 (symbol-value dir-var
))))
3864 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3867 (if (and gnus-number-of-articles-to-be-saved
3868 (> gnus-number-of-articles-to-be-saved
1))
3869 (format "these %d articles"
3870 gnus-number-of-articles-to-be-saved
)
3873 ;; Let the split methods have their say.
3875 ;; No split name was found.
3878 (concat prompt
" (default "
3879 (file-name-nondirectory default-name
) "): ")
3880 (file-name-directory default-name
)
3882 ;; A single group name is returned.
3883 ((stringp split-name
)
3885 (funcall function split-name headers
3886 (symbol-value variable
)))
3888 (concat prompt
" (default "
3889 (file-name-nondirectory default-name
) "): ")
3890 (file-name-directory default-name
)
3892 ;; A single split name was found
3893 ((= 1 (length split-name
))
3894 (let* ((name (expand-file-name
3896 gnus-article-save-directory
))
3897 (dir (cond ((file-directory-p name
)
3898 (file-name-as-directory name
))
3899 ((file-exists-p name
) name
)
3900 (t gnus-article-save-directory
))))
3902 (concat prompt
" (default " name
"): ")
3904 ;; A list of splits was found.
3906 (setq split-name
(nreverse split-name
))
3908 (let ((file-name-history
3909 (nconc split-name file-name-history
)))
3913 (concat prompt
" (`M-p' for defaults): ")
3914 gnus-article-save-directory
3916 gnus-article-save-directory
)))
3917 (car (push result file-name-history
)))))))
3918 ;; Create the directory.
3919 (gnus-make-directory (file-name-directory file
))
3920 ;; If we have read a directory, we append the default file name.
3921 (when (file-directory-p file
)
3922 (setq file
(expand-file-name (file-name-nondirectory
3924 (file-name-as-directory file
))))
3925 ;; Possibly translate some characters.
3926 (nnheader-translate-file-chars file
))))))
3927 (gnus-make-directory (file-name-directory result
))
3929 (set variable result
))
3931 (set dir-var
(file-name-directory result
)))
3934 (defun gnus-article-archive-name (group)
3935 "Return the first instance of an \"Archive-name\" in the current buffer."
3936 (let ((case-fold-search t
))
3937 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3938 (nnheader-concat gnus-article-save-directory
3939 (match-string 1)))))
3941 (defun gnus-article-nndoc-name (group)
3942 "If GROUP is an nndoc group, return the name of the parent group."
3943 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3944 (gnus-group-get-parameter group
'save-article-group
)))
3946 (defun gnus-summary-save-in-rmail (&optional filename
)
3947 "Append this article to Rmail file.
3948 Optional argument FILENAME specifies file name.
3949 Directory to save to is default to `gnus-article-save-directory'."
3950 (setq filename
(gnus-read-save-file-name
3951 "Save %s in rmail file" filename
3952 gnus-rmail-save-name gnus-newsgroup-name
3953 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3954 (with-current-buffer gnus-save-article-buffer
3958 ;; Note that unlike gnus-summary-save-in-mail, there is no
3959 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3961 (gnus-output-to-rmail filename
))))
3964 (defun gnus-summary-save-in-mail (&optional filename
)
3965 "Append this article to Unix mail file.
3966 Optional argument FILENAME specifies file name.
3967 Directory to save to is default to `gnus-article-save-directory'."
3968 (setq filename
(gnus-read-save-file-name
3969 "Save %s in Unix mail file" filename
3970 gnus-mail-save-name gnus-newsgroup-name
3971 gnus-current-headers
'gnus-newsgroup-last-mail
))
3972 (with-current-buffer gnus-save-article-buffer
3976 (if (and (file-readable-p filename
)
3977 (file-regular-p filename
)
3978 (mail-file-babyl-p filename
))
3979 (gnus-output-to-rmail filename
)
3980 (gnus-output-to-mail filename
)))))
3983 (put 'gnus-summary-save-in-file
:decode t
)
3984 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
3985 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3986 "Append this article to file.
3987 Optional argument FILENAME specifies file name.
3988 Directory to save to is default to `gnus-article-save-directory'."
3989 (setq filename
(gnus-read-save-file-name
3990 "Save %s in file" filename
3991 gnus-file-save-name gnus-newsgroup-name
3992 gnus-current-headers
'gnus-newsgroup-last-file
))
3993 (with-current-buffer gnus-save-article-buffer
3997 (when (and overwrite
3998 (file-exists-p filename
))
3999 (delete-file filename
))
4000 (gnus-output-to-file filename
))))
4003 (put 'gnus-summary-write-to-file
:decode t
)
4004 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4005 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4006 (defun gnus-summary-write-to-file (&optional filename
)
4007 "Write this article to a file, overwriting it if the file exists.
4008 Optional argument FILENAME specifies file name.
4009 The directory to save in defaults to `gnus-article-save-directory'."
4010 (setq filename
(gnus-read-save-file-name
4011 "Save %s in file" filename
4012 gnus-file-save-name gnus-newsgroup-name
4013 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4014 (gnus-summary-save-in-file filename t
))
4016 (put 'gnus-summary-save-body-in-file
:decode t
)
4017 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4018 "Append this article body to a file.
4019 Optional argument FILENAME specifies file name.
4020 The directory to save in defaults to `gnus-article-save-directory'."
4021 (setq filename
(gnus-read-save-file-name
4022 "Save %s body in file" filename
4023 gnus-file-save-name gnus-newsgroup-name
4024 gnus-current-headers
'gnus-newsgroup-last-file
))
4025 (with-current-buffer gnus-save-article-buffer
4029 (when (article-goto-body)
4030 (narrow-to-region (point) (point-max)))
4031 (when (and overwrite
4032 (file-exists-p filename
))
4033 (delete-file filename
))
4034 (gnus-output-to-file filename
))))
4037 (put 'gnus-summary-write-body-to-file
:decode t
)
4038 (put 'gnus-summary-write-body-to-file
4039 :function
'gnus-summary-save-body-in-file
)
4040 (defun gnus-summary-write-body-to-file (&optional filename
)
4041 "Write this article body to a file, overwriting it if the file exists.
4042 Optional argument FILENAME specifies file name.
4043 The directory to save in defaults to `gnus-article-save-directory'."
4044 (setq filename
(gnus-read-save-file-name
4045 "Save %s body in file" filename
4046 gnus-file-save-name gnus-newsgroup-name
4047 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4048 (gnus-summary-save-body-in-file filename t
))
4050 (put 'gnus-summary-save-in-pipe
:decode t
)
4051 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4052 (defun gnus-summary-save-in-pipe (&optional command raw
)
4053 "Pipe this article to subprocess COMMAND.
4054 Valid values for COMMAND include:
4056 The executable command name and possibly arguments.
4058 You will be prompted for the command in the minibuffer.
4059 the symbol `default'
4060 It will be replaced with the command which the variable
4061 `gnus-summary-pipe-output-default-command' holds or the command
4062 last used for saving.
4063 Non-nil value for RAW overrides `:decode' and `:headers' properties
4064 and the raw article including all headers will be piped."
4065 (let ((article (gnus-summary-article-number))
4067 (get 'gnus-summary-save-in-pipe
:decode
)))
4068 save-buffer default
)
4070 (if (vectorp (gnus-summary-article-header article
))
4071 (save-current-buffer
4072 (gnus-summary-select-article decode decode nil article
)
4073 (insert-buffer-substring
4077 gnus-original-article-buffer
)
4079 (nnheader-set-temp-buffer " *Gnus Save*"))))
4080 ;; Remove unwanted headers.
4081 (when (and (not raw
)
4082 (or (get 'gnus-summary-save-in-pipe
:headers
)
4083 (not gnus-save-all-headers
)))
4084 (let ((gnus-visible-headers
4085 (or (symbol-value (get 'gnus-summary-save-in-pipe
4087 gnus-saved-headers gnus-visible-headers
))
4088 (gnus-summary-buffer nil
))
4089 (article-hide-headers 1 t
))))
4090 (error "%d is not a real article" article
))
4091 (error "No article to pipe"))
4092 (setq default
(or gnus-summary-pipe-output-default-command
4093 gnus-last-shell-command
))
4094 (unless (stringp command
)
4096 (if (and (eq command
'default
) default
)
4098 (gnus-read-shell-command "Shell command on this article: "
4100 (when (string-equal command
"")
4102 (setq command default
)
4103 (error "A command is required")))
4104 (with-current-buffer save-buffer
4107 (shell-command-on-region (point-min) (point-max) command nil
)))
4108 (gnus-kill-buffer save-buffer
))
4109 (setq gnus-summary-pipe-output-default-command command
))
4111 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4112 "Pipe this article to muttprint."
4113 (unless (stringp command
)
4114 (setq command
(read-string
4115 "Print using command: " gnus-summary-muttprint-program
4116 nil gnus-summary-muttprint-program
)))
4117 (let ((gnus-summary-pipe-output-default-command
4118 gnus-summary-pipe-output-default-command
))
4119 (gnus-summary-save-in-pipe command
))
4120 (setq gnus-summary-muttprint-program command
))
4122 ;;; Article file names when saving.
4124 (defun gnus-capitalize-newsgroup (newsgroup)
4125 "Capitalize NEWSGROUP name."
4126 (when (not (zerop (length newsgroup
)))
4127 (concat (char-to-string (upcase (aref newsgroup
0)))
4128 (substring newsgroup
1))))
4130 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4131 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4132 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4133 Otherwise, it is like ~/News/news/group/num."
4136 (concat (if (gnus-use-long-file-name 'not-save
)
4137 (gnus-capitalize-newsgroup newsgroup
)
4138 (gnus-newsgroup-directory-form newsgroup
))
4139 "/" (int-to-string (mail-header-number headers
)))
4140 gnus-article-save-directory
)))
4142 (string-equal (file-name-directory default
)
4143 (file-name-directory last-file
))
4144 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4146 (or last-file default
))))
4148 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4149 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4150 If variable `gnus-use-long-file-name' is non-nil, it is
4151 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4154 (concat (if (gnus-use-long-file-name 'not-save
)
4156 (gnus-newsgroup-directory-form newsgroup
))
4157 "/" (int-to-string (mail-header-number headers
)))
4158 gnus-article-save-directory
)))
4160 (string-equal (file-name-directory default
)
4161 (file-name-directory last-file
))
4162 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4164 (or last-file default
))))
4166 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4167 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4168 If variable `gnus-use-long-file-name' is non-nil, it is
4169 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4172 (if (gnus-use-long-file-name 'not-save
)
4175 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4177 gnus-article-save-directory
)))
4179 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4180 "Generate file name from sender."
4181 (let ((from (mail-header-from headers
)))
4183 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4184 (match-string 1 from
)
4186 gnus-article-save-directory
)))
4188 (defun article-verify-x-pgp-sig ()
4190 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4192 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4193 (let ((sig (with-current-buffer gnus-original-article-buffer
4194 (gnus-fetch-field "X-PGP-Sig")))
4198 (mml2015-clear-verify-function))
4200 (insert-buffer-substring gnus-original-article-buffer
)
4201 (setq items
(split-string sig
))
4202 (message-narrow-to-head)
4203 (let ((inhibit-point-motion-hooks t
)
4204 (case-fold-search t
))
4205 ;; Don't verify multiple headers.
4206 (setq headers
(mapconcat (lambda (header)
4208 (mail-fetch-field header
)
4210 (split-string (nth 1 items
) ",") "")))
4211 (delete-region (point-min) (point-max))
4212 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4213 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4218 (if (looking-at "^-")
4221 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4222 (insert "Version: " (car items
) "\n\n")
4223 (insert (mapconcat 'identity
(cddr items
) "\n"))
4224 (insert "\n-----END PGP SIGNATURE-----\n")
4225 (let ((mm-security-handle (list (format "multipart/signed"))))
4226 (mml2015-clean-buffer)
4227 (let ((coding-system-for-write (or gnus-newsgroup-charset
4229 (funcall (mml2015-clear-verify-function)))
4231 (or (mm-handle-multipart-ctl-parameter
4232 mm-security-handle
'gnus-details
)
4233 (mm-handle-multipart-ctl-parameter
4234 mm-security-handle
'gnus-info
)))))
4236 (let ((inhibit-read-only t
) bface eface
)
4238 (message-narrow-to-head)
4239 (goto-char (point-max))
4241 (setq bface
(get-text-property (point-at-bol) 'face
)
4242 eface
(get-text-property (1- (point-at-eol)) 'face
))
4243 (message-remove-header "X-Gnus-PGP-Verify")
4244 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4246 (goto-char (point-max)))
4247 (narrow-to-region (point) (point))
4248 (insert "X-Gnus-PGP-Verify: " info
"\n")
4249 (goto-char (point-min))
4252 (if (not (looking-at "^[ \t]"))
4256 (goto-char (point-min))
4257 (when (looking-at "\\([^:]+\\): *")
4258 (put-text-property (match-beginning 1) (1+ (match-end 1))
4260 (put-text-property (match-end 0) (point-max)
4261 'face eface
)))))))))
4263 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4265 (defun article-verify-cancel-lock ()
4266 "Verify Cancel-Lock header."
4268 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4269 (canlock-verify gnus-original-article-buffer
)))
4276 (setq afunc
(car func
)
4279 gfunc
(intern (format "gnus-%s" func
))))
4281 (when (fboundp afunc
)
4282 `(lambda (&optional interactive
&rest args
)
4283 ,(documentation afunc t
)
4284 (interactive (list t
))
4285 (with-current-buffer gnus-article-buffer
4287 (call-interactively ',afunc
)
4288 (apply ',afunc args
))))))))
4289 '(article-hide-headers
4290 article-verify-x-pgp-sig
4291 article-verify-cancel-lock
4292 article-hide-boring-headers
4293 article-treat-overstrike
4294 article-treat-ansi-sequences
4295 article-fill-long-lines
4296 article-capitalize-sentences
4298 article-remove-leading-whitespace
4299 article-display-x-face
4300 article-display-face
4301 article-de-quoted-unreadable
4302 article-de-base64-unreadable
4305 article-unsplit-urls
4306 article-hide-list-identifiers
4307 article-strip-banner
4310 article-hide-signature
4311 article-strip-headers-in-body
4312 article-remove-trailing-blank-lines
4313 article-strip-leading-blank-lines
4314 article-strip-multiple-blank-lines
4315 article-strip-leading-space
4316 article-strip-trailing-space
4317 article-strip-blank-lines
4318 article-strip-all-blank-lines
4320 article-date-english
4321 article-date-iso8601
4322 article-date-original
4325 article-decode-mime-words
4326 article-decode-charset
4327 article-decode-encoded-words
4330 article-date-combined-lapsed
4332 article-treat-dumbquotes
4333 article-treat-non-ascii
4334 article-normalize-headers
4335 ;;(article-show-all . gnus-article-show-all-headers)
4339 ;;; Gnus article mode
4342 (put 'gnus-article-mode
'mode-class
'special
)
4344 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4346 (gnus-define-keys gnus-article-mode-map
4347 " " gnus-article-goto-next-page
4348 "\177" gnus-article-goto-prev-page
4349 [delete] gnus-article-goto-prev-page
4350 [backspace] gnus-article-goto-prev-page
4351 "\C-c^" gnus-article-refer-article
4352 "h" gnus-article-show-summary
4353 "s" gnus-article-show-summary
4354 "\C-c\C-m" gnus-article-mail
4355 "?" gnus-article-describe-briefly
4356 "<" beginning-of-buffer
4358 "\C-c\C-i" gnus-info-find-node
4360 "R" gnus-article-reply-with-original
4361 "F" gnus-article-followup-with-original
4362 "\C-hk" gnus-article-describe-key
4363 "\C-hc" gnus-article-describe-key-briefly
4364 "\C-hb" gnus-article-describe-bindings
4366 "e" gnus-article-read-summary-keys
4367 "\C-d" gnus-article-read-summary-keys
4368 "\M-*" gnus-article-read-summary-keys
4369 "\M-#" gnus-article-read-summary-keys
4370 "\M-^" gnus-article-read-summary-keys
4371 "\M-g" gnus-article-read-summary-keys)
4373 (substitute-key-definition
4374 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4376 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4377 "W" gnus-article-wide-reply-with-original)
4378 (if (featurep 'xemacs)
4379 (set-keymap-default-binding gnus-article-send-map
4380 'gnus-article-read-summary-send-keys)
4381 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4383 (defun gnus-article-make-menu-bar ()
4384 (unless (boundp 'gnus-article-commands-menu)
4385 (gnus-summary-make-menu-bar))
4386 (unless (boundp 'gnus-article-article-menu)
4388 gnus-article-article-menu gnus-article-mode-map ""
4390 ["Scroll forwards" gnus-article-goto-next-page t]
4391 ["Scroll backwards" gnus-article-goto-prev-page t]
4392 ["Show summary" gnus-article-show-summary t]
4393 ["Fetch Message-ID at point" gnus-article-refer-article t]
4394 ["Mail to address at point" gnus-article-mail t]
4395 ["Send a bug report" gnus-bug t]))
4398 gnus-article-treatment-menu gnus-article-mode-map ""
4399 ;; Fixme: this should use :active (and maybe :visible).
4401 ["Hide headers" gnus-article-hide-headers t]
4402 ["Hide signature" gnus-article-hide-signature t]
4403 ["Hide citation" gnus-article-hide-citation t]
4404 ["Treat overstrike" gnus-article-treat-overstrike t]
4405 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4406 ["Remove carriage return" gnus-article-remove-cr t]
4407 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4408 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4409 ["Remove base64" gnus-article-de-base64-unreadable t]
4410 ["Treat html" gnus-article-wash-html t]
4411 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4412 ["Decode HZ" gnus-article-decode-HZ t]))
4414 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4416 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4418 (gnus-run-hooks 'gnus-article-menu-hook)))
4420 (defvar bookmark-make-record-function)
4421 (defvar shr-put-image-function)
4423 (defun gnus-article-mode ()
4424 "Major mode for displaying an article.
4426 All normal editing commands are switched off.
4428 The following commands are available in addition to all summary mode
4430 \\<gnus-article-mode-map>
4431 \\[gnus-article-next-page]\t Scroll the article one page forwards
4432 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4433 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4434 \\[gnus-article-show-summary]\t Display the summary buffer
4435 \\[gnus-article-mail]\t Send a reply to the address near point
4436 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4437 \\[gnus-info-find-node]\t Go to the Gnus info node"
4439 (kill-all-local-variables)
4440 (gnus-simplify-mode-line)
4441 (setq mode-name "Article")
4442 (setq major-mode 'gnus-article-mode)
4443 (make-local-variable 'minor-mode-alist)
4444 (use-local-map gnus-article-mode-map)
4445 (when (gnus-visual-p 'article-menu 'menu)
4446 (gnus-article-make-menu-bar)
4447 (when gnus-summary-tool-bar-map
4448 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4449 (gnus-update-format-specifications nil 'article-mode)
4450 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4451 (set (make-local-variable 'gnus-page-broken) nil)
4452 (make-local-variable 'gnus-article-current-summary)
4453 (make-local-variable 'gnus-article-mime-handles)
4454 (make-local-variable 'gnus-article-decoded-p)
4455 (make-local-variable 'gnus-article-mime-handle-alist)
4456 (make-local-variable 'gnus-article-wash-types)
4457 (make-local-variable 'gnus-article-image-alist)
4458 (make-local-variable 'gnus-article-charset)
4459 (make-local-variable 'gnus-article-ignored-charsets)
4460 (set (make-local-variable 'bookmark-make-record-function)
4461 'gnus-summary-bookmark-make-record)
4462 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4464 (set (make-local-variable 'nobreak-char-display) nil)
4465 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4466 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4467 (setq cursor-in-non-selected-windows nil)
4468 (gnus-set-default-directory)
4469 (buffer-disable-undo)
4470 (setq buffer-read-only t
4471 show-trailing-whitespace nil)
4472 (set-syntax-table gnus-article-mode-syntax-table)
4473 (mm-enable-multibyte)
4474 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4476 (defun gnus-article-setup-buffer ()
4477 "Initialize the article buffer."
4478 (let* ((name (if gnus-single-article-buffer "*Article*"
4479 (concat "*Article " gnus-newsgroup-name "*")))
4481 (progn (string-match "\\*Article" name)
4482 (concat " *Original Article"
4483 (substring name (match-end 0))))))
4484 (setq gnus-article-buffer name)
4485 (setq gnus-original-article-buffer original)
4486 (setq gnus-article-mime-handle-alist nil)
4487 (with-current-buffer gnus-summary-buffer
4488 ;; This might be a variable local to the summary buffer.
4489 (unless gnus-single-article-buffer
4490 (setq gnus-article-buffer name)
4491 (setq gnus-original-article-buffer original)
4492 (gnus-set-global-variables)))
4493 (gnus-article-setup-highlight-words)
4494 ;; Init original article buffer.
4495 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4496 (mm-enable-multibyte)
4497 (setq major-mode 'gnus-original-article-mode)
4498 (make-local-variable 'gnus-original-article))
4499 (if (and (get-buffer name)
4500 (with-current-buffer name
4501 (if gnus-article-edit-mode
4502 (if (y-or-n-p "Article mode edit in progress; discard? ")
4504 (set-buffer-modified-p nil)
4505 (gnus-kill-buffer name)
4508 (error "Action aborted"))
4510 (with-current-buffer name
4511 (set (make-local-variable 'gnus-article-edit-mode) nil)
4512 (when gnus-article-mime-handles
4513 (mm-destroy-parts gnus-article-mime-handles)
4514 (setq gnus-article-mime-handles nil))
4515 ;; Set it to nil in article-buffer!
4516 (setq gnus-article-mime-handle-alist nil)
4517 (buffer-disable-undo)
4518 (setq buffer-read-only t)
4519 (unless (eq major-mode 'gnus-article-mode)
4520 (gnus-article-mode))
4521 (setq truncate-lines gnus-article-truncate-lines)
4523 (with-current-buffer (gnus-get-buffer-create name)
4525 (setq truncate-lines gnus-article-truncate-lines)
4526 (make-local-variable 'gnus-summary-buffer)
4527 (setq gnus-summary-buffer
4528 (gnus-summary-buffer-name gnus-newsgroup-name))
4529 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4530 (when article-lapsed-timer
4531 (gnus-stop-date-timer))
4532 (when gnus-article-update-date-headers
4533 (gnus-start-date-timer gnus-article-update-date-headers))
4534 (current-buffer)))))
4536 ;; Set article window start at LINE, where LINE is the number of lines
4537 ;; from the head of the article.
4538 (defun gnus-article-set-window-start (&optional line)
4539 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4540 (when article-window
4543 (with-current-buffer gnus-article-buffer
4544 (goto-char (point-min))
4547 (gnus-message 6 "Moved to bookmark")
4548 (search-forward "\n\n" nil t)
4552 (defun gnus-article-prepare (article &optional all-headers header)
4553 "Prepare ARTICLE in article mode buffer.
4554 ARTICLE should either be an article number or a Message-ID.
4555 If ARTICLE is an id, HEADER should be the article headers.
4556 If ALL-HEADERS is non-nil, no headers are hidden."
4558 ;; Make sure we start in a summary buffer.
4559 (unless (eq major-mode 'gnus-summary-mode)
4560 (set-buffer gnus-summary-buffer))
4561 (setq gnus-summary-buffer (current-buffer))
4562 (let* ((gnus-article (if header (mail-header-number header) article))
4563 (summary-buffer (current-buffer))
4564 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4565 (group gnus-newsgroup-name)
4568 (gnus-article-setup-buffer)
4569 (set-buffer gnus-article-buffer)
4570 ;; Deactivate active regions.
4571 (when (and (boundp 'transient-mark-mode)
4572 transient-mark-mode)
4573 (setq mark-active nil))
4574 (if (not (setq result (let ((inhibit-read-only t))
4575 (gnus-request-article-this-buffer
4577 ;; There is no such article.
4579 (when (and (numberp article)
4580 (not (memq article gnus-newsgroup-sparse)))
4581 (setq gnus-article-current
4582 (cons gnus-newsgroup-name article))
4583 (set-buffer gnus-summary-buffer)
4584 (setq gnus-current-article article)
4585 (if (and (memq article gnus-newsgroup-undownloaded)
4586 (not (gnus-online (gnus-find-method-for-group
4587 gnus-newsgroup-name))))
4589 (gnus-summary-set-agent-mark article)
4590 (message "Message marked for downloading"))
4591 (gnus-summary-mark-article article gnus-canceled-mark)
4592 (unless (memq article gnus-newsgroup-sparse)
4593 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4594 (if (or (eq result 'pseudo)
4595 (eq result 'nneething))
4597 (with-current-buffer summary-buffer
4598 (push article gnus-newsgroup-history)
4599 (setq gnus-last-article gnus-current-article
4600 gnus-current-article 0
4601 gnus-current-headers nil
4602 gnus-article-current nil)
4603 (if (eq result 'nneething)
4604 (gnus-configure-windows 'summary)
4605 (gnus-configure-windows 'article))
4606 (gnus-set-global-variables))
4607 (let ((gnus-article-mime-handle-alist-1
4608 gnus-article-mime-handle-alist))
4609 (gnus-set-mode-line 'article)))
4610 ;; The result from the `request' was an actual article -
4611 ;; or at least some text that is now displayed in the
4613 (when (and (numberp article)
4614 (not (eq article gnus-current-article)))
4615 ;; Seems like a new article has been selected.
4616 ;; `gnus-current-article' must be an article number.
4617 (with-current-buffer summary-buffer
4618 (push article gnus-newsgroup-history)
4619 (setq gnus-last-article gnus-current-article
4620 gnus-current-article article
4621 gnus-current-headers
4622 (gnus-summary-article-header gnus-current-article)
4623 gnus-article-current
4624 (cons gnus-newsgroup-name gnus-current-article))
4625 (unless (vectorp gnus-current-headers)
4626 (setq gnus-current-headers nil))
4627 (gnus-summary-goto-subject gnus-current-article)
4628 (when (gnus-summary-show-thread)
4629 ;; If the summary buffer really was folded, the
4630 ;; previous goto may not actually have gone to
4631 ;; the right article, but the thread root instead.
4633 (gnus-summary-goto-subject gnus-current-article))
4634 (gnus-run-hooks 'gnus-mark-article-hook)
4635 (gnus-set-mode-line 'summary)
4636 (when (gnus-visual-p 'article-highlight 'highlight)
4637 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4638 ;; Set the global newsgroup variables here.
4639 (gnus-set-global-variables)
4640 (setq gnus-have-all-headers
4641 (or all-headers gnus-show-all-headers))))
4643 (gnus-configure-windows 'article))
4644 (when (or (numberp article)
4646 (gnus-article-prepare-display)
4648 (goto-char (point-min))
4649 (when gnus-break-pages
4650 (gnus-narrow-to-page)))
4651 (let ((gnus-article-mime-handle-alist-1
4652 gnus-article-mime-handle-alist))
4653 (gnus-set-mode-line 'article))
4657 (set-window-point (get-buffer-window (current-buffer)) (point))
4658 (gnus-configure-windows 'article)
4659 (gnus-run-hooks 'gnus-article-prepare-hook)
4663 (defun gnus-article-prepare-display ()
4664 "Make the current buffer look like a nice article."
4665 ;; Hooks for getting information from the article.
4666 ;; This hook must be called before being narrowed.
4667 (let ((gnus-article-buffer (current-buffer))
4669 (inhibit-read-only t))
4670 (unless (eq major-mode 'gnus-article-mode)
4671 (gnus-article-mode))
4672 (setq buffer-read-only nil
4673 gnus-article-wash-types nil
4674 gnus-article-image-alist nil)
4675 (gnus-run-hooks 'gnus-tmp-internal-hook)
4676 (when gnus-display-mime-function
4677 (funcall gnus-display-mime-function))))
4680 ;;; Gnus Sticky Article Mode
4683 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4684 "Mode for sticky articles."
4685 ;; Release bindings that won't work.
4686 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4687 gnus-sticky-article-mode-map)
4688 (substitute-key-definition 'gnus-article-refer-article 'undefined
4689 gnus-sticky-article-mode-map)
4690 (dolist (k '("e" "h" "s" "F" "R"))
4691 (define-key gnus-sticky-article-mode-map k nil))
4692 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4693 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4694 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4695 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4697 (defun gnus-sticky-article (arg)
4698 "Make the current article sticky.
4699 If a prefix ARG is given, ask for a name for this sticky article buffer."
4701 (gnus-summary-show-thread)
4702 (gnus-summary-select-article nil nil 'pseudo)
4703 (let (new-art-buf-name)
4704 (gnus-eval-in-buffer-window gnus-article-buffer
4705 (setq new-art-buf-name
4709 (read-from-minibuffer "Sticky article buffer name: ")
4710 (gnus-with-article-headers
4711 (gnus-article-goto-header "subject")
4712 (setq new-art-buf-name
4713 (buffer-substring-no-properties
4714 (line-beginning-position) (line-end-position)))
4715 (goto-char (point-min))
4716 (gnus-article-goto-header "from")
4717 (setq new-art-buf-name
4719 new-art-buf-name ", "
4720 (buffer-substring-no-properties
4721 (line-beginning-position) (line-end-position))))
4722 (goto-char (point-min))
4723 (gnus-article-goto-header "date")
4724 (setq new-art-buf-name
4726 new-art-buf-name ", "
4727 (buffer-substring-no-properties
4728 (line-beginning-position) (line-end-position))))))
4730 (if (and (gnus-buffer-live-p new-art-buf-name)
4731 (with-current-buffer new-art-buf-name
4732 (eq major-mode 'gnus-sticky-article-mode)))
4733 (switch-to-buffer new-art-buf-name)
4734 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4735 (gnus-sticky-article-mode))
4736 (setq gnus-article-buffer new-art-buf-name))
4737 (gnus-summary-recenter)
4738 (gnus-summary-position-point))
4740 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4741 "Kill the given sticky article BUFFER.
4742 If none is given, assume the current buffer and kill it if it has
4743 `gnus-sticky-article-mode'."
4746 (setq buffer (current-buffer)))
4747 (with-current-buffer buffer
4748 (when (eq major-mode 'gnus-sticky-article-mode)
4749 (gnus-kill-buffer buffer))))
4751 (defun gnus-kill-sticky-article-buffers (arg)
4752 "Kill all sticky article buffers.
4753 If a prefix ARG is given, ask for confirmation."
4755 (dolist (buf (gnus-buffers))
4756 (with-current-buffer buf
4757 (when (eq major-mode 'gnus-sticky-article-mode)
4759 (gnus-kill-buffer buf)
4760 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4761 (gnus-kill-buffer buf)))))))
4764 ;;; Gnus MIME viewing functions
4767 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4768 "Format of the MIME buttons.
4770 Valid specifiers include:
4772 %T MIME type, along with additional info
4773 %n The `name' parameter
4774 %d The description, if any
4775 %l The length of the encoded part
4776 %p The part identifier number
4777 %e Dots if the part isn't displayed
4779 General format specifiers can also be used. See Info node
4780 `(gnus)Formatting Variables'.")
4782 (defvar gnus-mime-button-line-format-alist
4783 '((?t gnus-tmp-type ?s)
4784 (?T gnus-tmp-type-long ?s)
4785 (?n gnus-tmp-name ?s)
4786 (?d gnus-tmp-description ?s)
4788 (?l gnus-tmp-length ?d)
4789 (?e gnus-tmp-dots ?s)))
4791 (defvar gnus-mime-button-commands
4792 '((gnus-article-press-button "\r" "Toggle Display")
4793 (gnus-mime-view-part "v" "View Interactively...")
4794 (gnus-mime-view-part-as-type "t" "View As Type...")
4795 (gnus-mime-view-part-as-charset "C" "View As charset...")
4796 (gnus-mime-save-part "o" "Save...")
4797 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4798 (gnus-mime-replace-part "r" "Replace part")
4799 (gnus-mime-delete-part "d" "Delete part")
4800 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4801 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4802 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4803 (gnus-mime-view-part-externally "e" "View Externally")
4804 (gnus-mime-print-part "p" "Print")
4805 (gnus-mime-pipe-part "|" "Pipe To Command...")
4806 (gnus-mime-action-on-part "." "Take action on the part...")))
4808 (defun gnus-article-mime-part-status ()
4809 (if gnus-article-mime-handle-alist-1
4810 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4812 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4815 (defvar gnus-mime-button-map
4816 (let ((map (make-sparse-keymap)))
4817 (define-key map gnus-mouse-2 'gnus-article-push-button)
4818 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4819 (dolist (c gnus-mime-button-commands)
4820 (define-key map (cadr c) (car c)))
4824 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4826 ,@(mapcar (lambda (c)
4827 (vector (caddr c) (car c) :active t))
4828 gnus-mime-button-commands)))
4830 (defvar gnus-url-button-commands
4831 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4833 (defvar gnus-url-button-map
4834 (let ((map (make-sparse-keymap)))
4835 (dolist (c gnus-url-button-commands)
4836 (define-key map (cadr c) (car c)))
4840 gnus-url-button-menu gnus-url-button-map "URL button menu."
4842 ,@(mapcar (lambda (c)
4843 (vector (caddr c) (car c) :active t))
4844 gnus-url-button-commands)))
4846 (defmacro gnus-bind-safe-url-regexp (&rest body)
4847 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4848 `(let ((mm-w3m-safe-url-regexp
4849 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4851 gnus-article-current-summary))
4852 (with-current-buffer gnus-article-current-summary
4853 gnus-newsgroup-name)
4854 gnus-newsgroup-name)))
4855 (if (cond ((not group)
4856 ;; Maybe we're in a mml-preview buffer
4857 ;; and no group is selected.
4859 ((stringp gnus-safe-html-newsgroups)
4860 (string-match gnus-safe-html-newsgroups group))
4861 ((consp gnus-safe-html-newsgroups)
4862 (member group gnus-safe-html-newsgroups)))
4864 mm-w3m-safe-url-regexp))))
4867 (defun gnus-mime-button-menu (event prefix)
4868 "Construct a context-sensitive menu of MIME commands."
4869 (interactive "e\nP")
4870 (save-window-excursion
4871 (let ((pos (event-start event)))
4872 (select-window (posn-window pos))
4873 (goto-char (posn-point pos))
4874 (gnus-article-check-buffer)
4875 (popup-menu gnus-mime-button-menu nil prefix))))
4877 (defun gnus-mime-view-all-parts (&optional handles)
4878 "View all the MIME parts."
4880 (with-current-buffer gnus-article-buffer
4881 (let ((handles (or handles gnus-article-mime-handles))
4882 (mail-parse-charset gnus-newsgroup-charset)
4883 (mail-parse-ignored-charsets
4884 (with-current-buffer gnus-summary-buffer
4885 gnus-newsgroup-ignored-charsets)))
4887 (mm-remove-parts handles)
4888 (goto-char (point-min))
4889 (or (search-forward "\n\n") (goto-char (point-max)))
4890 (let ((inhibit-read-only t))
4891 (delete-region (point) (point-max))
4892 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4894 (defun gnus-article-jump-to-part (n)
4895 "Jump to MIME part N."
4897 (let ((parts (with-current-buffer gnus-article-buffer
4898 (length gnus-article-mime-handle-alist))))
4900 (error "No such part"))
4901 (pop-to-buffer gnus-article-buffer)
4903 (setq n (if (= parts 1)
4905 (read-number (format "Jump to part (1..%s): " parts)))))
4906 (unless (and (integerp n) (<= n parts) (>= n 1))
4909 (gnus-message 7 "Invalid part `%s', using %s instead."
4912 (gnus-message 9 "Jumping to part %s." n)
4913 (cond ((>= gnus-auto-select-part 1)
4914 (while (and (<= n parts)
4915 (not (gnus-article-goto-part n)))
4917 ((< gnus-auto-select-part 0)
4918 (while (and (>= n 1)
4919 (not (gnus-article-goto-part n)))
4922 (gnus-article-goto-part n)))))
4924 (defvar gnus-mime-buttonized-part-id nil
4925 "ID of a mime part that should be buttonized.
4926 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4929 (defsubst gnus-article-edit-part (handles &optional current-id)
4930 "Edit an article in order to delete a mime part.
4931 This function is exclusively used by `gnus-mime-save-part-and-strip'
4932 and `gnus-mime-delete-part', and not provided at run-time normally."
4933 (gnus-article-edit-article
4935 (buffer-disable-undo)
4937 (let ((mail-parse-charset (or gnus-article-charset
4938 ',gnus-newsgroup-charset))
4939 (mail-parse-ignored-charsets
4940 (or gnus-article-ignored-charsets
4941 ',gnus-newsgroup-ignored-charsets))
4942 (mbl mml-buffer-list))
4943 (setq mml-buffer-list nil)
4944 (insert-buffer-substring gnus-original-article-buffer)
4945 (mime-to-mml ',handles)
4946 (setq gnus-article-mime-handles nil)
4947 (let ((mbl1 mml-buffer-list))
4948 (setq mml-buffer-list mbl)
4949 (set (make-local-variable 'mml-buffer-list) mbl1))
4950 (gnus-make-local-hook 'kill-buffer-hook)
4951 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4952 `(lambda (no-highlight)
4953 (let ((mail-parse-charset (or gnus-article-charset
4954 ',gnus-newsgroup-charset))
4955 (message-options message-options)
4956 (message-options-set-recipient)
4957 (mail-parse-ignored-charsets
4958 (or gnus-article-ignored-charsets
4959 ',gnus-newsgroup-ignored-charsets)))
4961 (mml-destroy-buffers)
4962 (remove-hook 'kill-buffer-hook
4963 'mml-destroy-buffers t)
4964 (kill-local-variable 'mml-buffer-list))
4965 (gnus-summary-edit-article-done
4966 ,(or (mail-header-references gnus-current-headers) "")
4967 ,(gnus-group-read-only-p)
4968 ,gnus-summary-buffer no-highlight))
4970 ;; Force buttonizing this part.
4971 (let ((gnus-mime-buttonized-part-id current-id))
4972 (gnus-article-edit-done))
4973 (gnus-configure-windows 'article)
4974 (when (and current-id (integerp gnus-auto-select-part))
4975 (gnus-article-jump-to-part
4976 (min (max (+ current-id gnus-auto-select-part) 1)
4977 (with-current-buffer gnus-article-buffer
4978 (length gnus-article-mime-handle-alist)))))))
4980 (defun gnus-mime-replace-part (file)
4981 "Replace MIME part under point with an external body."
4982 ;; Useful if file has already been saved to disk
4985 (read-file-name "Replace MIME part with file: "
4986 (or mm-default-directory default-directory)
4988 (gnus-mime-save-part-and-strip file))
4990 (defun gnus-mime-save-part-and-strip (&optional file)
4991 "Save the MIME part under point then replace it with an external body.
4992 If FILE is given, use it for the external part."
4994 (gnus-article-check-buffer)
4995 (when (gnus-group-read-only-p)
4996 (error "The current group does not support deleting of parts"))
4997 (when (mm-complicated-handles gnus-article-mime-handles)
4999 The current article has a complicated MIME structure, giving up..."))
5000 (let* ((data (get-text-property (point) 'gnus-data))
5001 (id (get-text-property (point) 'gnus-part))
5003 (handles gnus-article-mime-handles))
5006 (and data (mm-save-part data "Delete MIME part and save to: "))))
5008 (with-current-buffer (mm-handle-buffer data)
5010 (insert "Content-Type: " (mm-handle-media-type data))
5011 (mml-insert-parameter-string (cdr (mm-handle-type data))
5013 ;; Add a filename for the sake of saving the part again.
5014 (mml-insert-parameter
5015 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5017 (insert "Content-ID: " (message-make-message-id) "\n")
5018 (insert "Content-Transfer-Encoding: binary\n")
5021 (cdr (mm-make-handle nil
5022 `("message/external-body"
5023 (access-type . "LOCAL-FILE")
5025 ;; (set-buffer gnus-summary-buffer)
5026 (gnus-article-edit-part handles id))))
5028 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5029 ;; parts...>') but with stripping would be nice.
5031 (defun gnus-mime-delete-part ()
5032 "Delete the MIME part under point.
5033 Replace it with some information about the removed part."
5035 (gnus-article-check-buffer)
5036 (when (gnus-group-read-only-p)
5037 (error "The current group does not support deleting of parts"))
5038 (when (mm-complicated-handles gnus-article-mime-handles)
5040 The current article has a complicated MIME structure, giving up..."))
5041 (when (or gnus-expert-user
5042 (gnus-yes-or-no-p "\
5043 Deleting parts may malfunction or destroy the article; continue? "))
5044 (let* ((data (get-text-property (point) 'gnus-data))
5045 (id (get-text-property (point) 'gnus-part))
5046 (handles gnus-article-mime-handles)
5048 (let ((desc (mm-handle-description data)))
5050 (mail-decode-encoded-word-string desc))))
5051 (filename (or (mm-handle-filename data) "(none)"))
5052 (type (mm-handle-media-type data)))
5054 (error "No MIME part under point"))
5055 (with-current-buffer (mm-handle-buffer data)
5056 (let ((bsize (buffer-size)))
5061 "| The following attachment has been deleted:\n"
5063 "| Type: " type "\n"
5064 "| Filename: " filename "\n"
5065 "| Size (encoded): " (format "%s byte%s\n"
5066 bsize (if (= bsize 1)
5070 (concat "| Description: " description "\n"))
5073 (cdr (mm-make-handle
5074 nil `("text/plain" (charset . gnus-decoded)) nil nil
5076 (format "Deleted attachment (%s bytes)" bsize))))))
5077 ;; (set-buffer gnus-summary-buffer)
5078 (gnus-article-edit-part handles id))))
5080 (defun gnus-mime-save-part ()
5081 "Save the MIME part under point."
5083 (gnus-article-check-buffer)
5084 (let ((data (get-text-property (point) 'gnus-data)))
5086 (mm-save-part data))))
5088 (defun gnus-mime-pipe-part (&optional cmd)
5089 "Pipe the MIME part under point to a process.
5090 Use CMD as the process."
5092 (gnus-article-check-buffer)
5093 (let ((data (get-text-property (point) 'gnus-data)))
5095 (mm-pipe-part data cmd))))
5097 (defun gnus-mime-view-part ()
5098 "Interactively choose a viewing method for the MIME part under point."
5100 (gnus-article-check-buffer)
5101 (let ((data (get-text-property (point) 'gnus-data)))
5103 (setq gnus-article-mime-handles
5105 gnus-article-mime-handles (setq data (copy-sequence data))))
5106 (mm-interactively-view-part data))))
5108 (defun gnus-mime-view-part-as-type-internal ()
5109 (gnus-article-check-buffer)
5110 (let* ((handle (get-text-property (point) 'gnus-data))
5112 ;; Content-Type: foo/bar; name=...
5113 (mail-content-type-get (mm-handle-type handle) 'name)
5114 ;; Content-Disposition: attachment; filename=...
5115 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5116 (def-type (and name (mm-default-file-encoding name))))
5117 (or (and def-type (cons def-type 0))
5119 (equal (mm-handle-media-supertype handle) "text")
5120 '("text/plain" . 0))
5121 '("application/octet-stream" . 0))))
5123 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5124 "Choose a MIME media type, and view the part as such.
5125 If non-nil, PRED is a predicate to use during completion to limit the
5126 available media-types."
5130 (let ((default (gnus-mime-view-part-as-type-internal)))
5131 (gnus-completing-read
5134 (gnus-remove-if-not pred (mailcap-mime-types))
5135 (mailcap-mime-types))
5138 (gnus-article-check-buffer)
5139 (let ((handle (get-text-property (point) 'gnus-data)))
5141 (when (equal (mm-handle-media-type handle) "message/external-body")
5142 (unless (mm-handle-cache handle)
5143 (mm-extern-cache-contents handle))
5144 (setq handle (mm-handle-cache handle)))
5146 (mm-make-handle (mm-handle-buffer handle)
5147 (cons mime-type (cdr (mm-handle-type handle)))
5148 (mm-handle-encoding handle)
5149 (mm-handle-undisplayer handle)
5150 (mm-handle-disposition handle)
5151 (mm-handle-description handle)
5153 (mm-handle-id handle)))
5154 (setq gnus-article-mime-handles
5155 (mm-merge-handles gnus-article-mime-handles handle))
5156 (when (mm-handle-displayed-p handle)
5157 (mm-remove-part handle))
5158 (gnus-mm-display-part handle))))
5160 (defun gnus-mime-copy-part (&optional handle arg)
5161 "Put the MIME part under point into a new buffer.
5162 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5164 (interactive (list nil current-prefix-arg))
5165 (gnus-article-check-buffer)
5167 (setq handle (get-text-property (point) 'gnus-data)))
5169 (let ((filename (mm-handle-filename handle))
5170 contents dont-decode charset coding-system)
5171 (mm-with-unibyte-buffer
5172 (mm-insert-part handle)
5173 (setq contents (or (condition-case nil
5174 (mm-decompress-buffer filename nil 'sig)
5176 (setq dont-decode t)
5179 (setq filename (cond (filename (file-name-nondirectory filename))
5180 (dont-decode "*raw data*")
5185 (unless (setq charset (mail-content-type-get
5186 (mm-handle-type handle) 'charset))
5187 (unless (setq coding-system (mm-with-unibyte-buffer
5189 (mm-find-buffer-file-coding-system)))
5190 (setq charset gnus-newsgroup-charset))))
5192 (setq charset (or (cdr (assq arg
5193 gnus-summary-show-article-charset-alist))
5194 (mm-read-coding-system "Charset: ")))))
5195 (switch-to-buffer (generate-new-buffer filename))
5196 (if (or coding-system
5198 (setq coding-system (mm-charset-to-coding-system charset))
5199 (not (eq coding-system 'ascii))))
5201 (mm-enable-multibyte)
5202 (insert (mm-decode-coding-string contents coding-system))
5203 (setq buffer-file-coding-system
5204 (if (boundp 'last-coding-system-used)
5205 (symbol-value 'last-coding-system-used)
5207 (mm-disable-multibyte)
5209 (setq buffer-file-coding-system mm-binary-coding-system))
5210 ;; We do it this way to make `normal-mode' set the appropriate mode.
5213 (setq buffer-file-name (expand-file-name filename))
5215 (setq buffer-file-name nil))
5216 (goto-char (point-min)))))
5218 (defun gnus-mime-print-part (&optional handle filename)
5219 "Print the MIME part under point."
5220 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5221 (gnus-article-check-buffer)
5222 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5223 (contents (and handle (mm-get-part handle)))
5224 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5225 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5230 (mm-save-part-to-file handle file)
5231 (call-process shell-file-name nil
5232 (generate-new-buffer " *mm*")
5234 shell-command-switch
5236 printer file (mm-handle-type handle))))
5240 (gnus-print-buffer))
5241 (ps-despool filename)))))
5243 (defun gnus-mime-inline-part (&optional handle arg)
5244 "Insert the MIME part under point into the current buffer.
5245 Compressed files like .gz and .bz2 are decompressed."
5246 (interactive (list nil current-prefix-arg))
5247 (gnus-article-check-buffer)
5249 (setq handle (get-text-property (point) 'gnus-data)))
5252 (inhibit-read-only t)
5253 contents charset coding-system)
5254 (if (and (not arg) (mm-handle-undisplayer handle))
5255 (mm-remove-part handle)
5256 (mm-with-unibyte-buffer
5257 (mm-insert-part handle)
5259 (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
5263 (unless (setq charset (mail-content-type-get
5264 (mm-handle-type handle) 'charset))
5265 (unless (setq coding-system
5266 (mm-with-unibyte-buffer
5268 (mm-find-buffer-file-coding-system)))
5269 (setq charset gnus-newsgroup-charset))))
5271 (if (mm-handle-undisplayer handle)
5272 (mm-remove-part handle))
5275 gnus-summary-show-article-charset-alist))
5276 (mm-read-coding-system "Charset: "))))
5278 (if (mm-handle-undisplayer handle)
5279 (mm-remove-part handle))))
5281 (mm-display-inline handle)
5284 (defun gnus-mime-set-charset-parameters (handle charset)
5285 "Set CHARSET to parameters in HANDLE.
5286 CHARSET may either be a string or a symbol."
5287 (unless (stringp charset)
5288 (setq charset (symbol-name charset)))
5289 (if (stringp (car handle))
5290 (dolist (h (cdr handle))
5291 (gnus-mime-set-charset-parameters h charset))
5292 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5293 "message/external-body")
5295 (unless (mm-handle-cache handle)
5296 (mm-extern-cache-contents handle))
5297 (mm-handle-cache handle))
5299 (param (assq 'charset (cdr type))))
5301 (setcdr param charset)
5302 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5304 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5305 "Insert the MIME part under point into the current buffer using the
5307 (interactive (list nil current-prefix-arg))
5308 (gnus-article-check-buffer)
5309 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5310 (fun (get-text-property (point) 'gnus-callback))
5311 (gnus-newsgroup-ignored-charsets 'gnus-all)
5312 charset form preferred parts)
5319 gnus-summary-show-article-charset-alist))
5320 (mm-read-coding-system "Charset: "))))
5321 (if (mm-handle-undisplayer handle)
5322 (mm-remove-part handle)))
5323 (gnus-mime-set-charset-parameters handle charset)
5324 (when (and (consp (setq form (cdr-safe fun)))
5325 (setq form (ignore-errors
5326 (assq 'gnus-mime-display-alternative form)))
5327 (setq preferred (caddr form))
5329 (when (eq (car preferred) 'quote)
5330 (setq preferred (cadr preferred)))
5331 (not (equal preferred
5332 (get-text-property (point) 'gnus-data))))
5333 (setq parts (get-text-property (point) 'gnus-part))
5334 (setq parts (cdr (assq parts
5335 gnus-article-mime-handle-alist)))
5336 (equal (mm-handle-media-type parts) "multipart/alternative")
5337 (setq parts (reverse (cdr parts))))
5339 (list 'quote (or (cadr (member preferred parts))
5341 (funcall fun handle)))))
5343 (defun gnus-mime-view-part-externally (&optional handle)
5344 "View the MIME part under point with an external viewer."
5346 (gnus-article-check-buffer)
5347 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5348 (mm-user-display-methods nil)
5349 (mm-inlined-types nil)
5350 (mail-parse-charset gnus-newsgroup-charset)
5351 (mail-parse-ignored-charsets
5352 (with-current-buffer gnus-summary-buffer
5353 gnus-newsgroup-ignored-charsets))
5354 (type (mm-handle-media-type handle))
5355 (method (mailcap-mime-info type))
5356 (mm-enable-external t))
5357 (if (not (stringp method))
5358 (gnus-mime-view-part-as-type
5359 nil (lambda (type) (stringp (mailcap-mime-info type))))
5361 (mm-display-part handle nil t)))))
5363 (defun gnus-mime-view-part-internally (&optional handle)
5364 "View the MIME part under point with an internal viewer.
5365 If no internal viewer is available, use an external viewer."
5367 (gnus-article-check-buffer)
5368 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5369 (mm-inlined-types '(".*"))
5370 (mm-inline-large-images t)
5371 (mail-parse-charset gnus-newsgroup-charset)
5372 (mail-parse-ignored-charsets
5373 (with-current-buffer gnus-summary-buffer
5374 gnus-newsgroup-ignored-charsets))
5375 (inhibit-read-only t))
5376 (if (not (mm-inlinable-p handle))
5377 (gnus-mime-view-part-as-type
5378 nil (lambda (type) (mm-inlinable-p handle type)))
5380 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5382 (defun gnus-mime-action-on-part (&optional action)
5383 "Do something with the MIME attachment at \(point\)."
5385 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5386 (gnus-article-check-buffer)
5387 (let ((action-pair (assoc action gnus-mime-action-alist)))
5389 (funcall (cdr action-pair)))))
5391 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5392 "Call FUNCTION on MIME part N.
5393 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5394 If INTERACTIVE, call FUNCTION interactivly."
5396 ;; Check whether the article is displayed.
5397 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5398 (setq window (get-buffer-window gnus-article-buffer t))
5399 (frame-visible-p (setq frame (window-frame window))))
5400 (error "No article is displayed"))
5401 (with-current-buffer gnus-article-buffer
5402 ;; Check whether the article displays the right contents.
5403 (unless (with-current-buffer gnus-summary-buffer
5404 (eq gnus-current-article (gnus-summary-article-number)))
5405 (error "You should select the right article first"))
5407 (setq n (prefix-numeric-value n))
5409 (setq n (or (get-text-property pt 'gnus-part)
5411 (get-text-property (1- pt) 'gnus-part))
5412 (get-text-property (prog2
5418 (or (and (setq pt (previous-single-property-change
5421 (next-single-property-change (point) 'gnus-part)
5425 ;; Check whether the specified part exists.
5426 (when (> n (length gnus-article-mime-handle-alist))
5427 (error "No such part")))
5430 ;; To select the window is needed so that the cursor
5431 ;; might be visible on the MIME button.
5432 (select-window (prog1
5434 (setq window (selected-window))
5435 ;; Article may be displayed in the other frame.
5436 (gnus-select-frame-set-input-focus
5439 (setq frame (selected-frame))))))
5440 (when (gnus-article-goto-part n)
5441 ;; We point the cursor and the arrow at the MIME button
5442 ;; when the `function' prompt the user for something.
5443 (unless (and (pos-visible-in-window-p)
5444 (> (count-lines (point) (window-end))
5445 (/ (1- (window-height)) 3)))
5446 (recenter (/ (1- (window-height)) 3)))
5447 (let ((cursor-in-non-selected-windows t)
5448 (overlay-arrow-string "=>")
5449 (overlay-arrow-position (point-marker)))
5452 ((and no-handle interactive)
5453 (call-interactively function))
5458 function (get-text-property (point) 'gnus-data)))
5461 (get-text-property (point) 'gnus-data))))
5462 (set-marker overlay-arrow-position nil)
5463 (unless gnus-auto-select-part
5464 (gnus-select-frame-set-input-focus frame)
5465 (select-window window))))
5467 (if gnus-inhibit-mime-unbuttonizing
5468 ;; This is the default though the program shouldn't reach here.
5469 (error "No such part")
5470 ;; The part which doesn't have the MIME button is selected.
5471 ;; So, we display all the buttons and redo it.
5472 (let ((gnus-inhibit-mime-unbuttonizing t))
5473 (gnus-summary-show-article)
5474 (gnus-article-part-wrapper n function no-handle))))))
5476 (defun gnus-article-pipe-part (n)
5477 "Pipe MIME part N, which is the numerical prefix."
5479 (gnus-article-part-wrapper n 'mm-pipe-part))
5481 (defun gnus-article-save-part (n)
5482 "Save MIME part N, which is the numerical prefix."
5484 (gnus-article-part-wrapper n 'mm-save-part))
5486 (defun gnus-article-interactively-view-part (n)
5487 "View MIME part N interactively, which is the numerical prefix."
5489 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5491 (defun gnus-article-copy-part (n)
5492 "Copy MIME part N, which is the numerical prefix."
5494 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5496 (defun gnus-article-view-part-as-charset (n)
5497 "View MIME part N using a specified charset.
5498 N is the numerical prefix."
5500 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5502 (defun gnus-article-view-part-externally (n)
5503 "View MIME part N externally, which is the numerical prefix."
5505 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5507 (defun gnus-article-inline-part (n)
5508 "Inline MIME part N, which is the numerical prefix."
5510 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5512 (defun gnus-article-save-part-and-strip (n)
5513 "Save MIME part N and replace it with an external body.
5514 N is the numerical prefix."
5516 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5518 (defun gnus-article-replace-part (n)
5519 "Replace MIME part N with an external body.
5520 N is the numerical prefix."
5522 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5524 (defun gnus-article-delete-part (n)
5525 "Delete MIME part N and add some information about the removed part.
5526 N is the numerical prefix."
5528 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5530 (defun gnus-article-view-part-as-type (n)
5531 "Choose a MIME media type, and view part N as such.
5532 N is the numerical prefix."
5534 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5536 (defun gnus-article-mime-match-handle-first (condition)
5539 (dolist (ihandle gnus-article-mime-handle-alist)
5541 ((functionp condition)
5542 (funcall condition (cdr ihandle)))
5543 ((eq condition 'undisplayed)
5544 (not (or (mm-handle-undisplayer (cdr ihandle))
5545 (equal (mm-handle-media-type (cdr ihandle))
5546 "multipart/alternative"))))
5547 ((eq condition 'undisplayed-alternative)
5548 (not (mm-handle-undisplayer (cdr ihandle))))
5550 (gnus-article-goto-part (car ihandle))
5551 (or (not n) (< (car ihandle) n)))
5552 (setq n (car ihandle))))
5556 (defun gnus-article-view-part (&optional n)
5557 "View MIME part N, which is the numerical prefix.
5558 If the part is already shown, hide the part. If N is nil, view
5561 (with-current-buffer gnus-article-buffer
5562 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5563 gnus-article-mime-match-handle-function)))
5564 (when (> n (length gnus-article-mime-handle-alist))
5565 (error "No such part"))
5566 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5567 (when (gnus-article-goto-part n)
5568 (if (equal (car handle) "multipart/alternative")
5569 (gnus-article-press-button)
5570 (when (eq (gnus-mm-display-part handle) 'internal)
5571 (gnus-set-window-start)))))))
5573 (defsubst gnus-article-mime-total-parts ()
5574 (if (bufferp (car gnus-article-mime-handles))
5576 (1- (length gnus-article-mime-handles))))
5578 (defun gnus-mm-display-part (handle)
5579 "Display HANDLE and fix MIME button."
5580 (let ((id (get-text-property (point) 'gnus-part))
5582 (inhibit-read-only t))
5585 (let ((window (selected-window))
5586 (mail-parse-charset gnus-newsgroup-charset)
5587 (mail-parse-ignored-charsets
5588 (if (gnus-buffer-live-p gnus-summary-buffer)
5589 (with-current-buffer gnus-summary-buffer
5590 gnus-newsgroup-ignored-charsets)
5594 (let ((win (gnus-get-buffer-window (current-buffer) t))
5597 (select-window win))
5600 (if (mm-handle-displayed-p handle)
5601 ;; This will remove the part.
5602 (mm-display-part handle)
5604 (narrow-to-region (point)
5605 (if (eobp) (point) (1+ (point))))
5606 (gnus-bind-safe-url-regexp (mm-display-part handle))
5607 ;; We narrow to the part itself and
5608 ;; then call the treatment functions.
5609 (goto-char (point-min))
5611 (narrow-to-region (point) (point-max))
5614 (gnus-article-mime-total-parts)
5615 (mm-handle-media-type handle)))))
5616 (if (window-live-p window)
5617 (select-window window)))))
5620 (gnus-insert-mime-button
5621 handle id (list (mm-handle-displayed-p handle)))
5622 (goto-char point))))
5624 (defun gnus-article-goto-part (n)
5625 "Go to MIME part N."
5626 (when gnus-break-pages
5629 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5630 part handle end next handles)
5633 (if (setq handle (get-text-property start 'gnus-data))
5635 ;; Go to the displayed subpart, assuming this is
5636 ;; multipart/alternative.
5639 (while (and (not handle)
5642 (setq next (text-property-not-all part end
5645 handle (get-text-property part 'gnus-data))
5646 (push (cons handle part) handles)
5647 (unless (mm-handle-displayed-p handle)
5649 part (text-property-any part end 'gnus-data nil))))
5651 ;; No subpart is displayed, so we find preferred one.
5653 (cdr (assq (mm-preferred-alternative
5654 (nreverse (mapcar 'car handles)))
5657 (goto-char (1+ part))
5659 (when gnus-break-pages
5660 (gnus-narrow-to-page))))
5662 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5663 (let ((gnus-tmp-name
5664 (or (mm-handle-filename handle)
5665 (mail-content-type-get (mm-handle-type handle) 'url)
5667 (gnus-tmp-type (mm-handle-media-type handle))
5668 (gnus-tmp-description (or (mm-handle-description handle) ""))
5670 (if (if displayed (car displayed)
5671 (mm-handle-displayed-p handle))
5673 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5675 gnus-tmp-type-long b e)
5676 (when (string-match ".*/" gnus-tmp-name)
5677 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5678 (setq gnus-tmp-type-long (concat gnus-tmp-type
5679 (and (not (equal gnus-tmp-name ""))
5680 (concat "; " gnus-tmp-name))))
5681 (unless (equal gnus-tmp-description "")
5682 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5687 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5688 `(keymap ,gnus-mime-button-map
5689 gnus-callback gnus-mm-display-part
5690 gnus-part ,gnus-tmp-id
5691 article-type annotation
5694 ;; Exclude a newline.
5697 (when gnus-article-button-face
5698 (gnus-overlay-put (gnus-make-overlay b e nil t)
5699 'face gnus-article-button-face))
5700 (widget-convert-button
5703 :action 'gnus-widget-press-button
5704 :button-keymap gnus-mime-button-map
5707 ;; Needed to properly clear the message due to a bug in
5708 ;; wid-edit (XEmacs only).
5709 (if (boundp 'help-echo-owns-message)
5710 (setq help-echo-owns-message t))
5712 "%S: %s the MIME part; %S: more options"
5713 (aref gnus-mouse-2 0)
5714 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5716 (aref gnus-down-mouse-3 0))))))
5718 (defun gnus-widget-press-button (elems el)
5719 (goto-char (widget-get elems :from))
5720 (gnus-article-press-button))
5722 (defvar gnus-displaying-mime nil)
5724 (defun gnus-display-mime (&optional ihandles)
5725 "Display the MIME parts."
5727 (save-selected-window
5728 (let ((window (get-buffer-window gnus-article-buffer))
5731 (select-window window)
5732 ;; We have to do this since selecting the window
5733 ;; may change the point. So we set the window point.
5734 (set-window-point window point)))
5735 (let ((handles ihandles)
5736 (inhibit-read-only t)
5739 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5740 (when gnus-article-emulate-mime
5741 (mm-uu-dissect-text-parts handles)))
5742 (gnus-article-emulate-mime
5743 (setq handles (mm-uu-dissect))))
5744 (when (and (not ihandles)
5745 (not gnus-displaying-mime))
5746 ;; Top-level call; we clean up.
5747 (when gnus-article-mime-handles
5748 (mm-destroy-parts gnus-article-mime-handles)
5749 (setq gnus-article-mime-handle-alist nil));; A trick.
5750 (setq gnus-article-mime-handles handles)
5751 ;; We allow users to glean info from the handles.
5752 (when gnus-article-mime-part-function
5753 (gnus-mime-part-function handles)))
5755 (or (not (stringp (car handles)))
5758 (when (and (not ihandles)
5759 (not gnus-displaying-mime))
5760 ;; Clean up for mime parts.
5762 (delete-region (point) (point-max)))
5763 (let ((gnus-displaying-mime t))
5764 (gnus-mime-display-part handles)))
5767 (narrow-to-region (point) (point-max))
5768 (gnus-treat-article nil 1 1 "text/plain")
5771 ;; Highlight the headers.
5775 (narrow-to-region (point-min) (point))
5776 (gnus-article-save-original-date
5777 (gnus-treat-article 'head)))))))
5778 ;; Cope with broken MIME messages.
5779 (goto-char (point-max))
5783 (defcustom gnus-mime-display-multipart-as-mixed nil
5784 "Display \"multipart\" parts as \"multipart/mixed\".
5786 If t, it overrides nil values of
5787 `gnus-mime-display-multipart-alternative-as-mixed' and
5788 `gnus-mime-display-multipart-related-as-mixed'."
5789 :group 'gnus-article-mime
5792 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5793 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5795 :group 'gnus-article-mime
5798 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5799 "Display \"multipart/related\" parts as \"multipart/mixed\".
5801 If displaying \"text/html\" is discouraged \(see
5802 `mm-discouraged-alternatives'\) images or other material inside a
5803 \"multipart/related\" part might be overlooked when this variable is nil."
5805 :group 'gnus-article-mime
5808 (defun gnus-mime-display-part (handle)
5810 ;; Maybe a broken MIME message.
5813 ((not (stringp (car handle)))
5814 (gnus-mime-display-single handle))
5815 ;; User-defined multipart
5816 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5817 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5819 ;; multipart/alternative
5820 ((and (equal (car handle) "multipart/alternative")
5821 (not (or gnus-mime-display-multipart-as-mixed
5822 gnus-mime-display-multipart-alternative-as-mixed)))
5823 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5824 (push (cons id handle) gnus-article-mime-handle-alist)
5825 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5826 ;; multipart/related
5827 ((and (equal (car handle) "multipart/related")
5828 (not (or gnus-mime-display-multipart-as-mixed
5829 gnus-mime-display-multipart-related-as-mixed)))
5830 ;;;!!!We should find the start part, but we just default
5831 ;;;!!!to the first part.
5832 ;;(gnus-mime-display-part (cadr handle))
5833 ;;;!!! Most multipart/related is an HTML message plus images.
5834 ;;;!!! Unfortunately we are unable to let W3 display those
5835 ;;;!!! included images, so we just display it as a mixed multipart.
5836 ;;(gnus-mime-display-mixed (cdr handle))
5837 ;;;!!! No, w3 can display everything just fine.
5838 (gnus-mime-display-part (cadr handle)))
5839 ((equal (car handle) "multipart/signed")
5840 (gnus-add-wash-type 'signed)
5841 (gnus-mime-display-security handle))
5842 ((equal (car handle) "multipart/encrypted")
5843 (gnus-add-wash-type 'encrypted)
5844 (gnus-mime-display-security handle))
5845 ;; Other multiparts are handled like multipart/mixed.
5847 (gnus-mime-display-mixed (cdr handle)))))
5849 (defun gnus-mime-part-function (handles)
5850 (if (stringp (car handles))
5851 (mapcar 'gnus-mime-part-function (cdr handles))
5852 (funcall gnus-article-mime-part-function handles)))
5854 (defun gnus-mime-display-mixed (handles)
5855 (mapcar 'gnus-mime-display-part handles))
5857 (defun gnus-mime-display-single (handle)
5858 (let ((type (mm-handle-media-type handle))
5859 (ignored gnus-ignored-mime-types)
5866 (when (string-match (pop ignored) type)
5867 (throw 'ignored nil)))
5868 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5869 (with-current-buffer gnus-summary-buffer
5870 gnus-inhibit-images)
5871 gnus-inhibit-images)
5872 (string-match "\\`image/" type)))
5873 (setq not-attachment
5874 (and (not (mm-inline-override-p handle))
5875 (or (not (mm-handle-disposition handle))
5876 (equal (car (mm-handle-disposition handle))
5878 (mm-attachment-override-p handle))))
5879 (mm-automatic-display-p handle)
5881 (mm-inlinable-p handle)
5882 (mm-inlined-p handle))
5883 (mm-automatic-external-display-p type)))
5885 (when (equal (mm-handle-media-supertype handle) "text")
5887 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5889 (push (cons id handle) gnus-article-mime-handle-alist)
5891 (equal (mm-handle-media-supertype handle) "message"))
5894 (cond ((not (bolp)) 2)
5895 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5897 (when (or (not display)
5898 (not (gnus-unbuttonized-mime-type-p type))
5899 (eq id gnus-mime-buttonized-part-id))
5900 (gnus-insert-mime-button
5901 handle id (list (or display (and not-attachment text))))
5902 (gnus-article-insert-newline)
5903 ;; Remember modify the number of forward lines.
5911 (let ((mail-parse-charset gnus-newsgroup-charset)
5912 (mail-parse-ignored-charsets
5913 (save-excursion (condition-case ()
5914 (set-buffer gnus-summary-buffer)
5916 gnus-newsgroup-ignored-charsets)))
5917 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5918 (goto-char (point-max)))
5919 ((and text not-attachment)
5923 (gnus-article-insert-newline)
5924 (mm-display-inline handle)
5925 (goto-char (point-max))))
5929 (narrow-to-region beg (point))
5930 (if (eq handle gnus-article-mime-handles)
5931 ;; The format=flowed case.
5932 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5933 ;; Don't count signature parts that are never displayed.
5934 ;; The part number should be re-calculated supposing this
5935 ;; might be a message/rfc822 part.
5937 (dolist (part gnus-article-mime-handles)
5938 (unless (or (stringp part)
5939 (equal (car (mm-handle-type part))
5940 "application/pgp-signature"))
5941 (push part handles)))
5943 nil (length (memq handle handles)) (length handles)
5944 (mm-handle-media-type handle)))))))))))
5946 (defun gnus-unbuttonized-mime-type-p (type)
5947 "Say whether TYPE is to be unbuttonized."
5948 (unless gnus-inhibit-mime-unbuttonizing
5950 (let ((types gnus-unbuttonized-mime-types))
5952 (when (string-match (pop types) type)
5953 (throw 'found t)))))
5955 (let ((types gnus-buttonized-mime-types))
5957 (when (string-match (pop types) type)
5958 (throw 'found t)))))))))
5960 (defun gnus-article-insert-newline ()
5961 "Insert a newline, but mark it as undeletable."
5962 (gnus-put-text-property
5963 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5965 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5966 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5969 handle (inhibit-read-only t) from props begend not-pref)
5970 (save-window-excursion
5973 (narrow-to-region (car ibegend)
5976 (goto-char (car ibegend))
5979 (delete-region (point-min) (point-max))
5980 (mm-remove-parts handles))
5981 (setq begend (list (point-marker)))
5983 (unless (setq not-pref (cadr (member preferred ihandles)))
5984 (setq not-pref (car ihandles)))
5987 (not (gnus-unbuttonized-mime-type-p
5988 "multipart/alternative")))
5989 (gnus-add-text-properties
5992 (insert (format "%d. " id))
5996 (unless ,(not ibegend)
5997 (setq gnus-article-mime-handle-alist
5998 ',gnus-article-mime-handle-alist))
5999 (gnus-mime-display-alternative
6000 ',ihandles ',not-pref ',begend ,id))
6001 keymap ,gnus-mime-button-map
6002 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6003 face ,gnus-article-button-face
6005 article-type multipart))
6006 (widget-convert-button 'link from (point)
6007 :action 'gnus-widget-press-button
6008 :button-keymap gnus-widget-button-keymap)
6010 (while (setq handle (pop handles))
6011 (gnus-add-text-properties
6014 (insert (format "(%c) %-18s"
6015 (if (equal handle preferred) ?* ? )
6016 (mm-handle-media-type handle)))
6020 (unless ,(not ibegend)
6021 (setq gnus-article-mime-handle-alist
6022 ',gnus-article-mime-handle-alist))
6023 (gnus-mime-display-alternative
6024 ',ihandles ',handle ',begend ,id))
6025 keymap ,gnus-mime-button-map
6026 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6027 face ,gnus-article-button-face
6030 (widget-convert-button 'link from (point)
6031 :action 'gnus-widget-press-button
6032 :button-keymap gnus-widget-button-keymap)
6036 (if (stringp (car preferred))
6037 (gnus-display-mime preferred)
6038 (let ((mail-parse-charset gnus-newsgroup-charset)
6039 (mail-parse-ignored-charsets
6040 (with-current-buffer gnus-summary-buffer
6041 gnus-newsgroup-ignored-charsets)))
6042 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6046 (narrow-to-region (car begend) (point-max))
6048 nil (length gnus-article-mime-handle-alist)
6049 (gnus-article-mime-total-parts)
6050 (mm-handle-media-type preferred))))))
6051 (goto-char (point-max))
6052 (setcdr begend (point-marker)))))
6054 (goto-char point))))
6056 (defconst gnus-article-wash-status-strings
6057 (let ((alist '((cite "c" "Possible hidden citation text"
6058 " " "All citation text visible")
6059 (headers "h" "Hidden headers"
6060 " " "All headers visible.")
6061 (pgp "p" "Encrypted or signed message status hidden"
6062 " " "No hidden encryption nor digital signature status")
6063 (signature "s" "Signature has been hidden"
6064 " " "Signature is visible")
6065 (overstrike "o" "Overstrike (^H) characters applied"
6066 " " "No overstrike characters applied")
6067 (emphasis "e" "/*_Emphasis_*/ characters applied"
6068 " " "No /*_emphasis_*/ characters applied")))
6070 (dolist (entry alist result)
6071 (let ((key (nth 0 entry))
6072 (on (copy-sequence (nth 1 entry)))
6073 (on-help (nth 2 entry))
6074 (off (copy-sequence (nth 3 entry)))
6075 (off-help (nth 4 entry)))
6076 (put-text-property 0 1 'help-echo on-help on)
6077 (put-text-property 0 1 'help-echo off-help off)
6078 (push (list key on off) result))))
6079 "Alist of strings describing wash status in the mode line.
6080 Each entry has the form (KEY ON OF), where the KEY is a symbol
6081 representing the particular washing function, ON is the string to use
6082 in the article mode line when the washing function is active, and OFF
6083 is the string to use when it is inactive.")
6085 (defun gnus-article-wash-status-entry (key value)
6086 (let ((entry (assoc key gnus-article-wash-status-strings)))
6087 (if value (nth 1 entry) (nth 2 entry))))
6089 (defun gnus-article-wash-status ()
6090 "Return a string which display status of article washing."
6091 (with-current-buffer gnus-article-buffer
6092 (let ((cite (memq 'cite gnus-article-wash-types))
6093 (headers (memq 'headers gnus-article-wash-types))
6094 (boring (memq 'boring-headers gnus-article-wash-types))
6095 (pgp (memq 'pgp gnus-article-wash-types))
6096 (pem (memq 'pem gnus-article-wash-types))
6097 (signed (memq 'signed gnus-article-wash-types))
6098 (encrypted (memq 'encrypted gnus-article-wash-types))
6099 (signature (memq 'signature gnus-article-wash-types))
6100 (overstrike (memq 'overstrike gnus-article-wash-types))
6101 (emphasis (memq 'emphasis gnus-article-wash-types)))
6103 (gnus-article-wash-status-entry 'cite cite)
6104 (gnus-article-wash-status-entry 'headers (or headers boring))
6105 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6106 (gnus-article-wash-status-entry 'signature signature)
6107 (gnus-article-wash-status-entry 'overstrike overstrike)
6108 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6110 (defun gnus-add-wash-type (type)
6111 "Add a washing of TYPE to the current status."
6112 (add-to-list 'gnus-article-wash-types type))
6114 (defun gnus-delete-wash-type (type)
6115 "Add a washing of TYPE to the current status."
6116 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6118 (defun gnus-add-image (category image)
6119 "Add IMAGE of CATEGORY to the list of displayed images."
6120 (let ((entry (assq category gnus-article-image-alist)))
6122 (setq entry (list category))
6123 (push entry gnus-article-image-alist))
6124 (nconc entry (list image))))
6126 (defun gnus-delete-images (category)
6127 "Delete all images in CATEGORY."
6128 (let ((entry (assq category gnus-article-image-alist)))
6129 (dolist (image (cdr entry))
6130 (gnus-remove-image image category))
6131 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6132 (gnus-delete-wash-type category)))
6134 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6136 (defun gnus-article-maybe-hide-headers ()
6137 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6138 Provided for backwards compatibility."
6139 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6140 (not (with-current-buffer gnus-summary-buffer
6141 gnus-have-all-headers)))
6142 (not gnus-inhibit-hiding))
6143 (gnus-article-hide-headers)))
6145 (declare-function shr-put-image "shr" (data alt))
6147 (defun gnus-shr-put-image (data alt)
6148 "Put image DATA with a string ALT. Enable image to be deleted."
6149 (let ((image (shr-put-image data (propertize (or alt "*")
6150 'gnus-image-category 'shr))))
6152 (gnus-add-image 'shr image))))
6156 (defun gnus-output-to-file (file-name)
6157 "Append the current article to a file named FILE-NAME.
6158 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6159 text and used as the value of the coding cookie which is added to the
6160 top of a file. Otherwise, this function saves a raw article without
6162 (let* ((artbuf (current-buffer))
6163 (file-name-coding-system nnmail-pathname-coding-system)
6164 (coding gnus-article-save-coding-system)
6165 (coding-system-for-read (if coding
6166 nil ;; Rely on the coding cookie.
6167 mm-text-coding-system))
6168 (coding-system-for-write (or coding
6169 mm-text-coding-system-for-write
6170 mm-text-coding-system))
6171 (exists (file-exists-p file-name)))
6174 (insert-file-contents file-name)
6175 (goto-char (point-min))
6176 ;; Remove the existing coding cookie.
6177 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6178 (delete-region (match-beginning 0) (match-end 0))))
6179 (goto-char (point-max))
6180 (insert-buffer-substring artbuf)
6181 ;; Append newline at end of the buffer as separator, and then
6183 (goto-char (point-max))
6186 ;; If the coding system is not suitable to encode the text,
6187 ;; ask a user for a proper one.
6188 (when (fboundp 'select-safe-coding-system)
6189 (setq coding (coding-system-base
6190 (save-window-excursion
6191 (select-safe-coding-system (point-min) (point-max)
6193 (setq coding-system-for-write
6194 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6196 (goto-char (point-min))
6197 ;; Add the coding cookie.
6198 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6199 coding-system-for-write)))
6202 (write-region (point-min) (point-max) file-name nil 'no-message)
6203 (message "Appended to %s" file-name))
6204 (write-region (point-min) (point-max) file-name))))
6207 (defun gnus-narrow-to-page (&optional arg)
6208 "Narrow the article buffer to a page.
6209 If given a numerical ARG, move forward ARG pages."
6211 (setq arg (if arg (prefix-numeric-value arg) 0))
6212 (with-current-buffer gnus-article-buffer
6214 ;; Remove any old next/prev buttons.
6215 (when (gnus-visual-p 'page-marker)
6216 (let ((inhibit-read-only t))
6217 (gnus-remove-text-with-property 'gnus-prev)
6218 (gnus-remove-text-with-property 'gnus-next)))
6220 (when (save-excursion
6222 (if (re-search-backward page-delimiter nil 'move (abs arg))
6224 (setq nd (match-beginning 0)
6226 (when (re-search-backward page-delimiter nil t)
6227 (setq st (match-end 0))))
6228 (when (re-search-forward page-delimiter nil t)
6229 (setq nd (match-beginning 0)
6232 (if (re-search-forward page-delimiter nil 'move arg)
6234 (setq st (match-end 0)
6236 (when (re-search-forward page-delimiter nil t)
6237 (setq nd (match-beginning 0))))
6238 (when (re-search-backward page-delimiter nil t)
6239 (setq st (match-end 0)
6242 (when (re-search-backward page-delimiter nil t)
6243 (goto-char (setq st (match-end 0))))
6244 (when (re-search-forward page-delimiter nil t)
6245 (setq nd (match-beginning 0)))
6247 (setq gnus-page-broken t)
6248 (when pt (goto-char pt))
6249 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6250 (when (gnus-visual-p 'page-marker)
6254 (gnus-insert-next-page-button))
6257 (gnus-insert-prev-page-button))))))))
6259 ;; Article mode commands
6261 (defun gnus-article-goto-next-page ()
6262 "Show the next page of the article."
6264 (when (gnus-article-next-page)
6265 (goto-char (point-min))
6266 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6269 (defun gnus-article-goto-prev-page ()
6270 "Show the previous page of the article."
6272 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6273 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6274 (gnus-article-prev-page nil)))
6276 ;; This is cleaner but currently breaks `gnus-pick-mode':
6278 ;; (defun gnus-article-goto-next-page ()
6279 ;; "Show the next page of the article."
6281 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6282 ;; (gnus-summary-next-page)))
6284 ;; (defun gnus-article-goto-prev-page ()
6285 ;; "Show the next page of the article."
6287 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6288 ;; (gnus-summary-prev-page)))
6290 (defun gnus-article-next-page (&optional lines)
6291 "Show the next page of the current article.
6292 If end of article, return non-nil. Otherwise return nil.
6293 Argument LINES specifies lines to be scrolled up."
6295 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6296 (if (and (not (and gnus-article-over-scroll
6297 (> (count-lines (window-start) (point-max))
6298 (if (featurep 'xemacs)
6299 (or lines (1- (window-height)))
6300 (+ (or lines (1- (window-height))) scroll-margin)))))
6303 (and (pos-visible-in-window-p) ;Not continuation line.
6304 (>= (point) (point-max)))))
6305 ;; Nothing in this page.
6306 (if (or (not gnus-page-broken)
6311 (eobp)))) ;Real end-of-buffer?
6313 (when gnus-article-over-scroll
6314 (gnus-article-next-page-1 lines))
6316 (gnus-narrow-to-page 1) ;Go to next page.
6318 ;; More in this page.
6319 (gnus-article-next-page-1 lines)
6322 (defun gnus-article-beginning-of-window ()
6323 "Move point to the beginning of the window.
6324 In Emacs, the point is placed at the line number which `scroll-margin'
6326 (if (featurep 'xemacs)
6327 (move-to-window-line 0)
6328 ;; There is an obscure bug in Emacs that makes it impossible to
6329 ;; scroll past big pictures in the article buffer. Try to fix
6330 ;; this by adding a sanity check by counting the lines visible.
6331 (when (> (count-lines (window-start) (window-end)) 30)
6332 (move-to-window-line
6333 (min (max 0 scroll-margin)
6334 (max 1 (- (window-height)
6335 (if mode-line-format 1 0)
6336 (if header-line-format 1 0)
6339 (defun gnus-article-next-page-1 (lines)
6341 (let ((scroll-in-place nil)
6342 (auto-window-vscroll nil))
6345 ;; Long lines may cause an end-of-buffer error.
6346 (goto-char (point-max))))
6347 (gnus-article-beginning-of-window))
6349 (defun gnus-article-prev-page (&optional lines)
6350 "Show previous page of current article.
6351 Argument LINES specifies lines to be scrolled down."
6353 (move-to-window-line 0)
6354 (if (and gnus-page-broken
6356 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6358 (gnus-narrow-to-page -1) ;Go to previous page.
6359 (goto-char (point-max))
6360 (recenter (if gnus-article-over-scroll
6362 (max (if (featurep 'xemacs)
6364 (+ lines scroll-margin))
6366 (- (window-height) 2))
6370 (let ((scroll-in-place nil))
6371 (scroll-down lines))
6372 (beginning-of-buffer
6373 (goto-char (point-min))))
6374 (gnus-article-beginning-of-window))))
6376 (defun gnus-article-only-boring-p ()
6377 "Decide whether there is only boring text remaining in the article.
6378 Something \"interesting\" is a word of at least two letters that does
6379 not have a face in `gnus-article-boring-faces'."
6380 (when (and gnus-article-skip-boring
6381 (boundp 'gnus-article-boring-faces)
6382 (symbol-value 'gnus-article-boring-faces))
6384 (let ((inhibit-point-motion-hooks t))
6386 (while (re-search-forward "\\b\\w\\w" nil t)
6388 (when (not (gnus-intersection
6389 (gnus-faces-at (point))
6390 (symbol-value 'gnus-article-boring-faces)))
6391 (throw 'only-boring nil)))
6392 (throw 'only-boring t))))))
6394 (defun gnus-article-refer-article ()
6395 "Read article specified by message-id around point."
6398 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6399 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6400 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6401 (let ((msg-id (concat "<" (match-string 0) ">")))
6402 (set-buffer gnus-summary-buffer)
6403 (gnus-summary-refer-article msg-id))
6404 (error "No references around point"))))
6406 (defun gnus-article-show-summary ()
6407 "Reconfigure windows to show summary buffer."
6409 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6410 (error "There is no summary buffer for this article buffer")
6411 (gnus-article-set-globals)
6412 (gnus-configure-windows 'article)
6413 (gnus-summary-goto-subject gnus-current-article)
6414 (gnus-summary-position-point)))
6416 (defun gnus-article-describe-briefly ()
6417 "Describe article mode commands briefly."
6419 (gnus-message 6 "%s" (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")))
6421 (defun gnus-article-check-buffer ()
6422 "Beep if not in an article buffer."
6423 (unless (equal major-mode 'gnus-article-mode)
6424 (error "Command invoked outside of a Gnus article buffer")))
6426 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6427 "Read a summary buffer key sequence and execute it from the article buffer."
6429 (gnus-article-check-buffer)
6431 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6432 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6433 "=" "^" "\M-^" "|"))
6435 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6436 "An" "Ap" [?A (meta return)] [?A delete]))
6440 '("n" "Gn" "p" "Gp"))
6442 (with-current-buffer gnus-article-current-summary
6443 (let (gnus-pick-mode)
6444 (setq unread-command-events (nconc unread-command-events
6445 (list (or key last-command-event)))
6446 keys (if (featurep 'xemacs)
6447 (events-to-keys (read-key-sequence nil t))
6448 (read-key-sequence nil t)))))
6453 ((eq (aref keys (1- (length keys))) ?\C-h)
6454 (gnus-article-describe-bindings (substring keys 0 -1)))
6455 ((or (member keys nosaves)
6456 (member keys nosave-but-article)
6457 (member keys nosave-in-article))
6459 (save-window-excursion
6460 (pop-to-buffer gnus-article-current-summary)
6461 ;; We disable the pick minor mode commands.
6462 (let (gnus-pick-mode)
6463 (setq func (key-binding keys t))))
6467 (unless (member keys nosave-in-article)
6468 (set-buffer gnus-article-current-summary))
6469 (when (get func 'disabled)
6470 (error "Function %s disabled" func))
6471 (call-interactively func)
6472 (setq new-sum-point (point)))
6473 (when (member keys nosave-but-article)
6474 (pop-to-buffer gnus-article-buffer))))
6476 ;; These commands should restore window configuration.
6477 (let ((obuf (current-buffer))
6478 (owin (current-window-configuration))
6479 win func in-buffer selected new-sum-start new-sum-hscroll err)
6480 (cond (not-restore-window
6481 (pop-to-buffer gnus-article-current-summary)
6482 (setq win (selected-window)))
6483 ((setq win (get-buffer-window gnus-article-current-summary))
6484 (select-window win))
6486 (let ((summary-buffer gnus-article-current-summary))
6487 (gnus-configure-windows 'article)
6488 (unless (setq win (get-buffer-window summary-buffer 'visible))
6489 (let ((gnus-buffer-configuration
6490 '((article ((vertical 1.0
6491 (summary 0.25 point)
6493 (gnus-configure-windows 'article))
6494 (setq win (get-buffer-window summary-buffer 'visible)))
6495 (gnus-select-frame-set-input-focus (window-frame win))
6496 (select-window win))))
6497 (setq in-buffer (current-buffer))
6498 ;; We disable the pick minor mode commands.
6499 (setq func (let (gnus-pick-mode)
6500 (key-binding keys t)))
6501 (when (get func 'disabled)
6502 (error "Function %s disabled" func))
6505 (condition-case code
6507 (call-interactively func)
6513 (when (eq win (selected-window))
6514 (setq new-sum-point (point)
6515 new-sum-start (window-start win)
6516 new-sum-hscroll (window-hscroll win)))
6517 (when (or (eq in-buffer (current-buffer))
6518 (when (eq obuf (current-buffer))
6519 (set-buffer in-buffer)
6521 (setq selected (gnus-summary-select-article))
6523 (unless not-restore-window
6524 (set-window-configuration owin))
6525 (when (and (eq selected 'old)
6527 (set-window-start (get-buffer-window (current-buffer))
6529 (set-window-point (get-buffer-window (current-buffer))
6530 (if (article-goto-body)
6533 (when (and (not not-restore-window)
6536 (with-current-buffer (window-buffer win)
6537 (eq major-mode 'gnus-summary-mode)))
6538 (set-window-point win new-sum-point)
6539 (set-window-start win new-sum-start)
6540 (set-window-hscroll win new-sum-hscroll))))
6541 (set-window-configuration owin)
6543 (signal (car err) (cdr err))
6546 (defun gnus-article-read-summary-send-keys ()
6548 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6549 (gnus-article-read-summary-keys)))
6551 (defun gnus-article-describe-key (key)
6552 "Display documentation of the function invoked by KEY.
6553 KEY is a string or a vector."
6554 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6555 (read-key-sequence "Describe key: "))))
6556 (gnus-article-check-buffer)
6557 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6558 gnus-article-read-summary-send-keys))
6559 (with-current-buffer gnus-article-current-summary
6560 (setq unread-command-events
6561 (if (featurep 'xemacs)
6563 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6564 (list 'meta (- x 128))
6567 (let ((cursor-in-echo-area t)
6569 (describe-key (read-key-sequence nil t))))
6570 (describe-key key)))
6572 (defun gnus-article-describe-key-briefly (key &optional insert)
6573 "Display documentation of the function invoked by KEY.
6574 KEY is a string or a vector."
6575 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6576 (read-key-sequence "Describe key: "))
6577 current-prefix-arg))
6578 (gnus-article-check-buffer)
6579 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6580 gnus-article-read-summary-send-keys))
6581 (with-current-buffer gnus-article-current-summary
6582 (setq unread-command-events
6583 (if (featurep 'xemacs)
6585 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6586 (list 'meta (- x 128))
6589 (let ((cursor-in-echo-area t)
6591 (describe-key-briefly (read-key-sequence nil t) insert)))
6592 (describe-key-briefly key insert)))
6594 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6595 (defvar gnus-agent-summary-mode)
6596 (defvar gnus-draft-mode)
6597 ;; Calling help-buffer will autoload help-mode.
6598 (defvar help-xref-stack-item)
6599 ;; Emacs 22 doesn't load it in the batch mode.
6601 (autoload 'help-buffer "help-mode"))
6603 (defun gnus-article-describe-bindings (&optional prefix)
6604 "Show a list of all defined keys, and their definitions.
6605 The optional argument PREFIX, if non-nil, should be a key sequence;
6606 then we display only bindings that start with that prefix."
6608 (gnus-article-check-buffer)
6609 (let ((keymap (copy-keymap gnus-article-mode-map))
6610 (map (copy-keymap gnus-article-send-map))
6611 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6613 (define-key keymap "S" map)
6614 (define-key map [t] nil)
6615 (with-current-buffer gnus-article-current-summary
6618 (if (setq parent (keymap-parent gnus-article-mode-map))
6620 (setq parent (copy-keymap parent))
6621 (set-keymap-parent parent (current-local-map)))
6622 (current-local-map)))
6623 (set-keymap-parent map (key-binding "S"))
6624 (let (key def gnus-pick-mode)
6626 (setq key (pop sumkeys))
6627 (cond ((and (vectorp key) (= (length key) 1)
6628 (consp (setq def (aref key 0)))
6629 (numberp (car def)) (numberp (cdr def)))
6630 (when (< (max (car def) (cdr def)) 128)
6634 (nreverse (gnus-uncompress-range def)))
6636 ((setq def (key-binding key))
6637 (unless (eq def 'undefined)
6638 (define-key keymap key def))))))
6639 (when (boundp 'gnus-agent-summary-mode)
6640 (setq agent gnus-agent-summary-mode))
6641 (when (boundp 'gnus-draft-mode)
6642 (setq draft gnus-draft-mode)))
6644 (use-local-map keymap)
6645 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6646 (set (make-local-variable 'gnus-draft-mode) draft)
6647 (describe-bindings prefix))
6648 (let ((item `((lambda (prefix)
6649 (with-current-buffer ,(current-buffer)
6650 (gnus-article-describe-bindings prefix)))
6652 (with-current-buffer (let (help-xref-following) (help-buffer))
6653 (setq help-xref-stack-item item)))))
6655 (defun gnus-article-reply-with-original (&optional wide)
6656 "Start composing a reply mail to the current message.
6657 The text in the region will be yanked. If the region isn't active,
6658 the entire article will be yanked."
6660 (let ((article (cdr gnus-article-current))
6662 (if (not (gnus-region-active-p))
6663 (with-current-buffer gnus-summary-buffer
6664 (gnus-summary-reply (list (list article)) wide))
6665 (setq contents (buffer-substring (point) (mark t)))
6666 ;; Deactivate active regions.
6667 (when (and (boundp 'transient-mark-mode)
6668 transient-mark-mode)
6669 (setq mark-active nil))
6670 (with-current-buffer gnus-summary-buffer
6672 (list (list article contents)) wide)))))
6674 (defun gnus-article-wide-reply-with-original ()
6675 "Start composing a wide reply mail to the current message.
6676 The text in the region will be yanked. If the region isn't active,
6677 the entire article will be yanked."
6679 (gnus-article-reply-with-original t))
6681 (defun gnus-article-followup-with-original ()
6682 "Compose a followup to the current article.
6683 The text in the region will be yanked. If the region isn't active,
6684 the entire article will be yanked."
6686 (let ((article (cdr gnus-article-current))
6688 (if (not (gnus-region-active-p))
6689 (with-current-buffer gnus-summary-buffer
6690 (gnus-summary-followup (list (list article))))
6691 (setq contents (buffer-substring (point) (mark t)))
6692 ;; Deactivate active regions.
6693 (when (and (boundp 'transient-mark-mode)
6694 transient-mark-mode)
6695 (setq mark-active nil))
6696 (with-current-buffer gnus-summary-buffer
6697 (gnus-summary-followup
6698 (list (list article contents)))))))
6700 (defun gnus-article-hide (&optional arg force)
6701 "Hide all the gruft in the current article.
6702 This means that signatures, cited text and (some) headers will be
6704 If given a prefix, show the hidden text instead."
6705 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6706 (gnus-article-hide-headers arg)
6707 (gnus-article-hide-list-identifiers arg)
6708 (gnus-article-hide-citation-maybe arg force)
6709 (gnus-article-hide-signature arg))
6711 (defun gnus-article-maybe-highlight ()
6712 "Do some article highlighting if article highlighting is requested."
6713 (when (gnus-visual-p 'article-highlight 'highlight)
6714 (gnus-article-highlight-some)))
6716 (defun gnus-check-group-server ()
6717 ;; Make sure the connection to the server is alive.
6718 (unless (gnus-server-opened
6719 (gnus-find-method-for-group gnus-newsgroup-name))
6720 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6721 (gnus-request-group gnus-newsgroup-name t)))
6724 (autoload 'nneething-get-file-name "nneething"))
6726 (defun gnus-request-article-this-buffer (article group)
6727 "Get an article and insert it into this buffer."
6728 (let (do-update-line sparse-header)
6732 (gnus-kill-all-overlays)
6733 (setq group (or group gnus-newsgroup-name))
6735 ;; Using `gnus-request-article' directly will insert the article into
6736 ;; `nntp-server-buffer' - so we'll save some time by not having to
6737 ;; copy it from the server buffer into the article buffer.
6739 ;; We only request an article by message-id when we do not have the
6740 ;; headers for it, so we'll have to get those.
6741 (when (stringp article)
6742 (gnus-read-header article))
6744 ;; If the article number is negative, that means that this article
6745 ;; doesn't belong in this newsgroup (possibly), so we find its
6746 ;; message-id and request it by id instead of number.
6747 (when (and (numberp article)
6749 (get-buffer gnus-summary-buffer)
6750 (gnus-buffer-exists-p gnus-summary-buffer))
6751 (with-current-buffer gnus-summary-buffer
6752 (let ((header (gnus-summary-article-header article)))
6755 ((memq article gnus-newsgroup-sparse)
6756 ;; This is a sparse gap article.
6757 (setq do-update-line article)
6758 (setq article (mail-header-id header))
6759 (setq sparse-header (gnus-read-header article))
6760 (setq gnus-newsgroup-sparse
6761 (delq article gnus-newsgroup-sparse)))
6763 ;; It's a real article.
6764 (setq article (mail-header-id header)))
6766 ;; It is an extracted pseudo-article.
6767 (setq article 'pseudo)
6768 (gnus-request-pseudo-article header))))
6770 (let ((method (gnus-find-method-for-group
6771 gnus-newsgroup-name)))
6772 (when (and (eq (car method) 'nneething)
6774 (let ((dir (nneething-get-file-name
6775 (mail-header-id header))))
6776 (when (and (stringp dir)
6777 (file-directory-p dir))
6778 (setq article 'nneething)
6779 (gnus-group-enter-directory dir))))))))
6782 ;; Refuse to select canceled articles.
6783 ((and (numberp article)
6785 (get-buffer gnus-summary-buffer)
6786 (gnus-buffer-exists-p gnus-summary-buffer)
6787 (eq (cdr (with-current-buffer gnus-summary-buffer
6788 (assq article gnus-newsgroup-reads)))
6789 gnus-canceled-mark))
6791 ;; We first check `gnus-original-article-buffer'.
6792 ((and (get-buffer gnus-original-article-buffer)
6794 (with-current-buffer gnus-original-article-buffer
6795 (and (equal (car gnus-original-article) group)
6796 (eq (cdr gnus-original-article) article))))
6797 ;; `insert-buffer-substring' would incorrectly use the
6798 ;; equivalent of string-make-multibyte which amount to decoding
6799 ;; with locale-coding-system, causing failure of
6800 ;; subsequent decoding.
6801 (insert (mm-string-to-multibyte
6802 (with-current-buffer gnus-original-article-buffer
6803 (buffer-substring (point-min) (point-max)))))
6805 ;; Check the backlog.
6806 ((and gnus-keep-backlog
6807 (gnus-backlog-request-article group article (current-buffer)))
6809 ;; Check asynchronous pre-fetch.
6810 ((gnus-async-request-fetched-article group article (current-buffer))
6811 (gnus-async-prefetch-next group article gnus-summary-buffer)
6812 (when (and (numberp article) gnus-keep-backlog)
6813 (gnus-backlog-enter-article group article (current-buffer)))
6816 ((and gnus-use-cache
6818 (gnus-cache-request-article article group))
6820 ;; Check the agent cache.
6821 ((gnus-agent-request-article article group)
6823 ;; Get the article and put into the article buffer.
6824 ((or (stringp article)
6826 (let ((gnus-override-method gnus-override-method)
6827 (methods (and (stringp article)
6828 gnus-refer-article-method))
6829 (backend (car (gnus-find-method-for-group
6830 gnus-newsgroup-name)))
6832 (inhibit-read-only t))
6833 (if (or (not (listp methods))
6834 (and (symbolp (car methods))
6835 (assq (car methods) nnoo-definition-alist)))
6836 (setq methods (list methods)))
6837 (when (and (null gnus-override-method)
6839 (setq gnus-override-method (pop methods)))
6841 (when (eq gnus-override-method 'current)
6842 (setq gnus-override-method
6843 (with-current-buffer gnus-summary-buffer
6844 gnus-current-select-method)))
6846 (gnus-kill-all-overlays)
6847 (let ((gnus-newsgroup-name group))
6848 (gnus-check-group-server))
6850 ((gnus-request-article article group (current-buffer))
6851 (when (numberp article)
6852 (gnus-async-prefetch-next group article
6853 gnus-summary-buffer)
6854 (when gnus-keep-backlog
6855 (gnus-backlog-enter-article
6856 group article (current-buffer)))
6857 (when (and gnus-agent
6858 (gnus-agent-group-covered-p group))
6859 (gnus-agent-store-article article group)))
6860 (setq result 'article))
6862 (setq gnus-override-method (pop methods)))
6863 ((not (string-match "^400 "
6864 (nnheader-get-report backend)))
6865 ;; If we get 400 server disconnect, reconnect and
6866 ;; retry; otherwise, assume the article has expired.
6867 (setq result 'done))))
6868 (and (eq result 'article) 'article)))
6872 ;; Associate this article with the current summary buffer.
6873 (setq gnus-article-current-summary gnus-summary-buffer)
6875 ;; Take the article from the original article buffer
6876 ;; and place it in the buffer it's supposed to be in.
6877 (when (and (get-buffer gnus-article-buffer)
6878 (equal (buffer-name (current-buffer))
6879 (buffer-name (get-buffer gnus-article-buffer))))
6881 (if (get-buffer gnus-original-article-buffer)
6882 (set-buffer gnus-original-article-buffer)
6883 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6884 (buffer-disable-undo)
6885 (setq major-mode 'gnus-original-article-mode)
6886 (setq buffer-read-only t))
6887 (let ((inhibit-read-only t))
6889 (insert-buffer-substring gnus-article-buffer))
6890 (setq gnus-original-article (cons group article)))
6893 (run-hooks 'gnus-article-decode-hook)
6894 ;; Mark article as decoded or not.
6895 (setq gnus-article-decoded-p gnus-article-decode-hook))
6897 ;; Update sparse articles.
6898 (when (and do-update-line
6899 (or (numberp article)
6901 (let ((buf (current-buffer)))
6902 (set-buffer gnus-summary-buffer)
6903 (gnus-summary-update-article do-update-line sparse-header)
6904 (gnus-summary-goto-subject do-update-line nil t)
6905 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6907 (set-buffer buf))))))
6909 (defun gnus-block-private-groups (group)
6910 (if (gnus-news-group-p group)
6911 ;; Block nothing in news groups.
6913 ;; Block everything anywhere else.
6916 (defun gnus-blocked-images ()
6917 (if (functionp gnus-blocked-images)
6918 (funcall gnus-blocked-images gnus-newsgroup-name)
6919 gnus-blocked-images))
6925 (defcustom gnus-article-edit-mode-hook nil
6926 "Hook run in article edit mode buffers."
6927 :group 'gnus-article-various
6930 (defvar gnus-article-edit-done-function nil)
6932 (defvar gnus-article-edit-mode-map nil)
6934 ;; Should we be using derived.el for this?
6935 (unless gnus-article-edit-mode-map
6936 (setq gnus-article-edit-mode-map (make-keymap))
6937 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6939 (gnus-define-keys gnus-article-edit-mode-map
6940 "\C-c?" describe-mode
6941 "\C-c\C-c" gnus-article-edit-done
6942 "\C-c\C-k" gnus-article-edit-exit
6943 "\C-c\C-f\C-t" message-goto-to
6944 "\C-c\C-f\C-o" message-goto-from
6945 "\C-c\C-f\C-b" message-goto-bcc
6946 ;;"\C-c\C-f\C-w" message-goto-fcc
6947 "\C-c\C-f\C-c" message-goto-cc
6948 "\C-c\C-f\C-s" message-goto-subject
6949 "\C-c\C-f\C-r" message-goto-reply-to
6950 "\C-c\C-f\C-n" message-goto-newsgroups
6951 "\C-c\C-f\C-d" message-goto-distribution
6952 "\C-c\C-f\C-f" message-goto-followup-to
6953 "\C-c\C-f\C-m" message-goto-mail-followup-to
6954 "\C-c\C-f\C-k" message-goto-keywords
6955 "\C-c\C-f\C-u" message-goto-summary
6956 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6957 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6958 "\C-c\C-b" message-goto-body
6959 "\C-c\C-i" message-goto-signature
6961 "\C-c\C-t" message-insert-to
6962 "\C-c\C-n" message-insert-newsgroups
6963 "\C-c\C-o" message-sort-headers
6964 "\C-c\C-e" message-elide-region
6965 "\C-c\C-v" message-delete-not-region
6966 "\C-c\C-z" message-kill-to-signature
6967 "\M-\r" message-newline-and-reformat
6968 "\C-c\C-a" mml-attach-file
6969 "\C-a" message-beginning-of-line
6971 "\M-;" comment-region)
6973 (gnus-define-keys (gnus-article-edit-wash-map
6974 "\C-c\C-w" gnus-article-edit-mode-map)
6975 "f" gnus-article-edit-full-stops))
6978 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6980 ["Fetch To" message-insert-to t]
6981 ["Fetch Newsgroups" message-insert-newsgroups t]
6983 ["To" message-goto-to t]
6984 ["From" message-goto-from t]
6985 ["Subject" message-goto-subject t]
6986 ["Cc" message-goto-cc t]
6987 ["Reply-To" message-goto-reply-to t]
6988 ["Summary" message-goto-summary t]
6989 ["Keywords" message-goto-keywords t]
6990 ["Newsgroups" message-goto-newsgroups t]
6991 ["Followup-To" message-goto-followup-to t]
6992 ["Mail-Followup-To" message-goto-mail-followup-to t]
6993 ["Distribution" message-goto-distribution t]
6994 ["Body" message-goto-body t]
6995 ["Signature" message-goto-signature t]))
6997 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6998 "Major mode for editing articles.
6999 This is an extended text-mode.
7001 \\{gnus-article-edit-mode-map}"
7002 (make-local-variable 'gnus-article-edit-done-function)
7003 (make-local-variable 'gnus-prev-winconf)
7004 (set (make-local-variable 'font-lock-defaults)
7005 '(message-font-lock-keywords t))
7006 (set (make-local-variable 'mail-header-separator) "")
7007 (set (make-local-variable 'gnus-article-edit-mode) t)
7008 (easy-menu-add message-mode-field-menu message-mode-map)
7010 (setq buffer-read-only nil)
7011 (buffer-enable-undo)
7014 (defun gnus-article-edit (&optional force)
7015 "Edit the current article.
7016 This will have permanent effect only in mail groups.
7017 If FORCE is non-nil, allow editing of articles even in read-only
7020 (when (and (not force)
7021 (gnus-group-read-only-p))
7022 (error "The current newsgroup does not support article editing"))
7023 (gnus-article-date-original)
7024 (gnus-article-edit-article
7026 `(lambda (no-highlight)
7028 (gnus-summary-edit-article-done
7029 ,(or (mail-header-references gnus-current-headers) "")
7030 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7032 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7033 "Start editing the contents of the current article buffer."
7034 (let ((winconf (current-window-configuration)))
7035 (set-buffer gnus-article-buffer)
7036 (let ((message-auto-save-directory
7037 ;; Don't associate the article buffer with a draft file.
7039 (gnus-article-edit-mode))
7040 (funcall start-func)
7041 (set-buffer-modified-p nil)
7042 (gnus-configure-windows 'edit-article)
7043 (setq gnus-article-edit-done-function exit-func)
7044 (setq gnus-prev-winconf winconf)
7046 (gnus-message 6 "C-c C-c to end edits"))))
7048 (defun gnus-article-edit-done (&optional arg)
7049 "Update the article edits and exit."
7051 (let ((func gnus-article-edit-done-function)
7052 (buf (current-buffer))
7053 (start (window-start))
7055 (winconf gnus-prev-winconf))
7056 (widen) ;; Widen it in case that users narrowed the buffer.
7059 ;; The cache and backlog have to be flushed somewhat.
7060 (when gnus-keep-backlog
7061 (gnus-backlog-remove-article
7062 (car gnus-article-current) (cdr gnus-article-current)))
7063 ;; Flush original article as well.
7064 (gnus-flush-original-article-buffer)
7065 (when gnus-use-cache
7066 (gnus-cache-update-article
7067 (car gnus-article-current) (cdr gnus-article-current)))
7068 ;; We remove all text props from the article buffer.
7069 (kill-all-local-variables)
7070 (set-text-properties (point-min) (point-max) nil)
7072 (set-window-configuration winconf)
7074 (set-window-start (get-buffer-window buf) start)
7075 (set-window-point (get-buffer-window buf) (point)))
7076 (gnus-summary-show-article))
7078 (defun gnus-flush-original-article-buffer ()
7079 (when (get-buffer gnus-original-article-buffer)
7080 (with-current-buffer gnus-original-article-buffer
7081 (setq gnus-original-article nil))))
7083 (defun gnus-article-edit-exit ()
7084 "Exit the article editing without updating."
7086 (when (or (not (buffer-modified-p))
7087 (yes-or-no-p "Article modified; kill anyway? "))
7088 (let ((curbuf (current-buffer))
7090 (window-start (window-start)))
7092 (if (gnus-buffer-live-p gnus-original-article-buffer)
7093 (insert-buffer-substring gnus-original-article-buffer))
7094 (let ((winconf gnus-prev-winconf))
7095 (kill-all-local-variables)
7097 (set-window-configuration winconf)
7098 ;; Tippy-toe some to make sure that point remains where it was.
7099 (save-current-buffer
7101 (set-window-start (get-buffer-window (current-buffer)) window-start)
7103 (gnus-summary-show-article)))
7105 (defun gnus-article-edit-full-stops ()
7106 "Interactively repair spacing at end of sentences."
7109 (goto-char (point-min))
7110 (search-forward-regexp "^$" nil t)
7111 (let ((case-fold-search nil))
7112 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7115 ;;; Article highlights
7118 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7120 ;;; Internal Variables:
7122 (defcustom gnus-button-url-regexp
7124 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7125 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7126 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7127 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7128 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7132 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7133 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7134 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7136 "[" chars punct "]+" "[" chars "]"
7138 (concat ;; XEmacs 21.4 doesn't support POSIX.
7139 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7140 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7142 "Regular expression that matches URLs."
7143 :group 'gnus-article-buttons
7146 (defcustom gnus-button-valid-fqdn-regexp
7147 message-valid-fqdn-regexp
7148 "Regular expression that matches a valid FQDN."
7150 :group 'gnus-article-buttons
7153 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7154 (defcustom gnus-button-valid-localpart-regexp
7155 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7156 "Regular expression that matches a localpart of mail addresses or MIDs."
7158 :group 'gnus-article-buttons
7161 (defcustom gnus-button-man-handler 'manual-entry
7162 "Function to use for displaying man pages.
7163 The function must take at least one argument with a string naming the
7166 :type '(choice (function-item :tag "Man" manual-entry)
7167 (function-item :tag "Woman" woman)
7168 (function :tag "Other"))
7169 :group 'gnus-article-buttons)
7171 (defcustom gnus-button-mid-or-mail-regexp
7172 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7173 gnus-button-valid-fqdn-regexp
7175 "Regular expression that matches a message ID or a mail address."
7177 :group 'gnus-article-buttons
7180 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7181 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7182 Strings like this can be either a message ID or a mail address. If it is one
7183 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7184 message ID or a mail address, respectively. If this variable is set to the
7185 symbol `ask', always query the user what do do. If it is a function, this
7186 function will be called with the string as its only argument. The function
7187 must return `mid', `mail', `invalid' or `ask'."
7189 :group 'gnus-article-buttons
7190 :type '(choice (function-item :tag "Heuristic function"
7191 gnus-button-mid-or-mail-heuristic)
7196 (defcustom gnus-button-mid-or-mail-heuristic-alist
7197 '((-10.0 . ".+\\$.+@")
7200 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7201 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7202 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7203 (-1.0 . "^[^a-z]+@")
7205 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7206 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7207 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7208 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7211 (-1.0 . "^[0-9][0-9]")
7213 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7214 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7215 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7216 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7218 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7219 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7222 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7224 ;; compensation for TDMA dated mail addresses:
7225 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7227 (-20.0 . "\\.fsf@") ;; Gnus
7230 (-20.0 . "^alpine\\.")
7231 (-20.0 . "_-_") ;; Subject change in thread
7233 (-20.0 . "\\.ln@") ;; leafnode
7234 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7235 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7237 ;; (5.0 . "") ;; $local_part_len <= 7
7238 (10.0 . "^[^0-9]+@")
7239 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7240 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7243 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7245 (0.5 . "^[A-Z][a-z]")
7246 (0.5 . "^[A-Z][a-z][a-z]")
7247 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7248 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7249 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7251 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7252 address. The REGEXP is processed with `case-fold-search' set to nil."
7254 :group 'gnus-article-buttons
7255 :type '(repeat (cons (number :tag "Rate")
7256 (regexp :tag "Regexp"))))
7258 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7259 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7260 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7261 address, `ask' if unsure and `invalid' if the string is invalid."
7262 (let ((case-fold-search nil)
7263 (list gnus-button-mid-or-mail-heuristic-alist)
7264 (result 0) rate regexp lpartlen elem)
7266 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7267 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7268 ;; Certain special cases...
7271 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7272 "^[0-9]+\\.[0-9]+@compuserve\\|"
7273 "@public\\.gmane\\.org")
7275 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7276 (setq result 'mail))
7277 (when (string-match "@.*@\\| " mid-or-mail)
7278 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7279 (setq result 'invalid))
7280 ;; Nothing more to do, if result is not a number here...
7281 (when (numberp result)
7283 (setq elem (car list)
7287 (when (string-match regexp mid-or-mail)
7288 (setq result (+ result rate))
7290 9 "`%s' matched `%s', rate `%s', result `%s'."
7291 mid-or-mail regexp rate result)))
7292 (when (<= lpartlen 7)
7293 (setq result (+ result 5.0))
7294 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7295 mid-or-mail result))
7296 (when (>= lpartlen 12)
7297 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7299 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7300 ;; Long local part should contain realname if e-mail address,
7301 ;; too many digits: message-id.
7302 ;; $score -= 5.0 + 0.1 * $local_part_len;
7303 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7304 (setq result (+ result rate))
7306 9 "Many digits in `%s', rate `%s', result `%s'."
7307 mid-or-mail rate result))
7308 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7310 ;; Too few vowels [^aeiouy]{4,}.*\@
7311 (setq result (+ result -5.0))
7313 9 "Few vowels in `%s', rate `%s', result `%s'."
7314 mid-or-mail -5.0 result))
7316 (setq result (+ result 5.0))
7318 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7319 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7320 ;; Maybe we should make this a customizable alist: (condition . 'result)
7322 ((symbolp result) result)
7323 ;; Now convert number into proper results:
7324 ((< result -10.0) 'mid)
7325 ((> result 10.0) 'mail)
7328 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7329 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7330 (url-mid (concat "news" ":" mid-or-mail))
7331 (url-mailto (concat "mailto" ":" mid-or-mail)))
7332 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7333 (when (fboundp pref)
7335 ;; get rid of surrounding angles...
7337 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7338 (if (or (eq 'mid guessed) (eq 'mail guessed))
7342 (save-window-excursion
7343 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7346 (cond ((eq pref 'mid)
7347 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7348 (gnus-button-handle-news url-mid))
7350 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7351 (gnus-url-mailto url-mailto))
7352 (t (gnus-message 3 "Invalid string.")))))
7354 (defun gnus-button-handle-custom (fun arg)
7355 "Call function FUN on argument ARG.
7356 Both FUN and ARG are supposed to be strings. ARG will be passed
7357 as a symbol to FUN."
7358 (funcall (intern fun)
7359 (if (string-match "^customize-apropos" fun)
7363 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7365 (defun gnus-button-handle-describe-function (url)
7366 "Call `describe-function' when pushing the corresponding URL button."
7369 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7371 (defun gnus-button-handle-describe-variable (url)
7372 "Call `describe-variable' when pushing the corresponding URL button."
7375 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7377 (defun gnus-button-handle-symbol (url)
7378 "Display help on variable or function.
7379 Calls `describe-variable' or `describe-function'."
7380 (let ((sym (intern url)))
7382 ((fboundp sym) (describe-function sym))
7383 ((boundp sym) (describe-variable sym))
7384 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7386 (defun gnus-button-handle-describe-key (url)
7387 "Call `describe-key' when pushing the corresponding URL button."
7389 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7390 (keys (ignore-errors (eval `(kbd ,key-string)))))
7393 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7395 (defun gnus-button-handle-apropos (url)
7396 "Call `apropos' when pushing the corresponding URL button."
7397 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7399 (defun gnus-button-handle-apropos-command (url)
7400 "Call `apropos' when pushing the corresponding URL button."
7402 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7404 (defun gnus-button-handle-apropos-variable (url)
7405 "Call `apropos' when pushing the corresponding URL button."
7407 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7408 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7410 (defun gnus-button-handle-apropos-documentation (url)
7411 "Call `apropos' when pushing the corresponding URL button."
7413 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7414 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7416 (defun gnus-button-handle-library (url)
7417 "Call `locate-library' when pushing the corresponding URL button."
7418 (gnus-message 9 "url=`%s'" url)
7419 (let* ((lib (locate-library url))
7420 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7422 (gnus-message 1 "Cannot locale library `%s'." url)
7423 (find-file-read-only file))))
7425 (defcustom gnus-button-man-level 5
7426 "*Integer that says how many man-related buttons Gnus will show.
7427 The higher the number, the more buttons will appear and the more false
7428 positives are possible. Note that you can set this variable local to
7429 specific groups. Setting it higher in Unix groups is probably a good idea.
7430 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7431 how to set variables in specific groups."
7433 :group 'gnus-article-buttons
7434 :link '(custom-manual "(gnus)Group Parameters")
7437 (defcustom gnus-button-emacs-level 5
7438 "*Integer that says how many emacs-related buttons Gnus will show.
7439 The higher the number, the more buttons will appear and the more false
7440 positives are possible. Note that you can set this variable local to
7441 specific groups. Setting it higher in Emacs or Gnus related groups is
7442 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7443 `gnus-parameters' on how to set variables in specific groups."
7445 :group 'gnus-article-buttons
7446 :link '(custom-manual "(gnus)Group Parameters")
7449 (defcustom gnus-button-message-level 5
7450 "*Integer that says how many buttons for news or mail messages will appear.
7451 The higher the number, the more buttons will appear and the more false
7452 positives are possible."
7453 ;; mail addresses, MIDs, URLs for news, ...
7455 :group 'gnus-article-buttons
7458 (defcustom gnus-button-browse-level 5
7459 "*Integer that says how many buttons for browsing will appear.
7460 The higher the number, the more buttons will appear and the more false
7461 positives are possible."
7462 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7464 :group 'gnus-article-buttons
7467 (defcustom gnus-button-alist
7468 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7469 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7470 ((concat "\\b\\(nntp\\|news\\):\\("
7471 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7472 0 t gnus-button-handle-news 2)
7473 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7474 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7475 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7476 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7477 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7478 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7479 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7480 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7481 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7482 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7483 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7484 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7485 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7486 ;; RFC 2368 (The mailto URL scheme)
7487 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7488 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7489 ("\\bmailto:\\([^ \n\t]+\\)"
7490 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7491 ;; Info Konqueror style <info:/foo/bar baz>.
7492 ;; Must come before " Gnus home-grown style".
7493 ("\\binfo://?\\([^'\">\n\t]+\\)"
7494 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7495 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7496 ("\\binfo://\\([^'\">\n\t ]+\\)"
7497 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7498 ;; Info GNOME style <info:foo#bar_baz>
7499 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7500 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7501 ;; Info KDE style <info:(foo)bar baz>
7502 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7503 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7504 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7505 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7506 ("\\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,]*\\)\\)?"
7507 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7508 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7510 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7511 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7512 ;; Emacs help commands
7513 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7514 ;; regexp doesn't match arguments containing ` '.
7515 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7516 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7517 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7518 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7519 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7520 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7521 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7522 ;; The following entries may lead to many false positives so don't enable
7523 ;; them by default (use a high button level).
7524 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7525 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7526 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7527 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7528 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7529 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7530 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7531 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7532 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7533 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7534 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7535 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7536 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7537 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7538 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7539 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7540 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7541 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7542 ;; Unlike the other regexps we really have to require quoting
7543 ;; here to determine where it ends.
7544 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7545 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7546 ("<URL: *\\([^\n<>]*\\)>"
7547 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7548 ;; RFC 2396 (2.4.3., delims) ...
7549 ("\"URL: *\\([^\n\"]*\\)\""
7550 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7552 (gnus-button-url-regexp
7553 0 (>= gnus-button-browse-level 0) browse-url 0)
7555 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7556 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7557 gnus-button-handle-man 1)
7558 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7559 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7560 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7561 gnus-button-handle-man 1)
7562 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7563 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7564 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7565 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7566 ;; Recognizing patches to .el files. This is somewhat obscure,
7567 ;; but considering the percentage of Gnus users who hack Emacs
7569 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7570 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7571 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7572 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7573 ;; MID or mail: To avoid too many false positives we don't try to catch
7574 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7575 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7576 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7577 ;; so that non-ambiguous entries (see above) match first.
7578 (gnus-button-mid-or-mail-regexp
7579 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7580 "*Alist of regexps matching buttons in article bodies.
7582 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7583 REGEXP: is the string (case insensitive) matching text around the button (can
7584 also be Lisp expression evaluating to a string),
7585 BUTTON: is the number of the regexp grouping actually matching the button,
7586 FORM: is a Lisp expression which must eval to true for the button to
7588 CALLBACK: is the function to call when the user push this button, and each
7589 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7591 CALLBACK can also be a variable, in that case the value of that
7592 variable it the real callback function."
7593 :group 'gnus-article-buttons
7594 :type '(repeat (list (choice regexp variable sexp)
7595 (integer :tag "Button")
7597 (function :tag "Callback")
7600 (integer :tag "Regexp group")))))
7601 (put 'gnus-button-alist 'risky-local-variable t)
7603 (defcustom gnus-header-button-alist
7604 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7605 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7606 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7607 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7608 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7609 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7610 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7611 0 (>= gnus-button-browse-level 0) browse-url 0)
7612 ("^Subject:" gnus-button-url-regexp
7613 0 (>= gnus-button-browse-level 0) browse-url 0)
7614 ("^[^:]+:" gnus-button-url-regexp
7615 0 (>= gnus-button-browse-level 0) browse-url 0)
7616 ("^OpenPGP:.*url=" gnus-button-url-regexp
7617 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7618 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7619 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7620 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7621 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7622 "*Alist of headers and regexps to match buttons in article heads.
7624 This alist is very similar to `gnus-button-alist', except that each
7625 alist has an additional HEADER element first in each entry:
7627 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7629 HEADER is a regexp to match a header. For a fuller explanation, see
7630 `gnus-button-alist'."
7631 :group 'gnus-article-buttons
7632 :group 'gnus-article-headers
7633 :type '(repeat (list (regexp :tag "Header")
7634 (choice regexp variable)
7635 (integer :tag "Button")
7637 (function :tag "Callback")
7640 (integer :tag "Regexp group")))))
7641 (put 'gnus-header-button-alist 'risky-local-variable t)
7645 (defun gnus-article-push-button (event)
7646 "Check text under the mouse pointer for a callback function.
7647 If the text under the mouse pointer has a `gnus-callback' property,
7648 call it with the value of the `gnus-data' text property."
7650 (set-buffer (window-buffer (posn-window (event-start event))))
7651 (let* ((pos (posn-point (event-start event)))
7652 (data (get-text-property pos 'gnus-data))
7653 (fun (get-text-property pos 'gnus-callback)))
7656 (funcall fun data))))
7658 (defun gnus-article-press-button ()
7659 "Check text at point for a callback function.
7660 If the text at point has a `gnus-callback' property,
7661 call it with the value of the `gnus-data' text property."
7663 (let ((data (get-text-property (point) 'gnus-data))
7664 (fun (get-text-property (point) 'gnus-callback)))
7666 (funcall fun data))))
7668 (defun gnus-article-highlight (&optional force)
7669 "Highlight current article.
7670 This function calls `gnus-article-highlight-headers',
7671 `gnus-article-highlight-citation',
7672 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7673 do the highlighting. See the documentation for those functions."
7674 (interactive (list 'force))
7675 (gnus-article-highlight-headers)
7676 (gnus-article-highlight-citation force)
7677 (gnus-article-highlight-signature)
7678 (gnus-article-add-buttons)
7679 (gnus-article-add-buttons-to-head))
7681 (defun gnus-article-highlight-some (&optional force)
7682 "Highlight current article.
7683 This function calls `gnus-article-highlight-headers',
7684 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7685 do the highlighting. See the documentation for those functions."
7686 (interactive (list 'force))
7687 (gnus-article-highlight-headers)
7688 (gnus-article-highlight-signature)
7689 (gnus-article-add-buttons))
7691 (defun gnus-article-highlight-headers ()
7692 "Highlight article headers as specified by `gnus-header-face-alist'."
7694 (gnus-with-article-headers
7695 (let (regexp header-face field-face from hpoints fpoints)
7696 (dolist (entry gnus-header-face-alist)
7697 (goto-char (point-min))
7698 (setq regexp (concat "^\\("
7699 (if (string-equal "" (nth 0 entry))
7703 header-face (nth 1 entry)
7704 field-face (nth 2 entry))
7705 (while (and (re-search-forward regexp nil t)
7709 (unless (search-forward ":" nil t)
7711 (when (and header-face
7712 (not (memq (point) hpoints)))
7713 (push (point) hpoints)
7714 (gnus-put-text-property from (point) 'face header-face))
7715 (when (and field-face
7716 (not (memq (setq from (point)) fpoints)))
7718 (if (re-search-forward "^[^ \t]" nil t)
7720 (goto-char (point-max)))
7721 (gnus-put-text-property from (point) 'face field-face)))))))
7723 (defun gnus-article-highlight-signature ()
7724 "Highlight the signature in an article.
7725 It does this by highlighting everything after
7726 `gnus-signature-separator' using the face `gnus-signature'."
7728 (gnus-with-article-buffer
7729 (let ((inhibit-point-motion-hooks t))
7731 (when (and gnus-signature-face
7732 (gnus-article-narrow-to-signature))
7733 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7734 'face gnus-signature-face)
7736 (gnus-article-search-signature)
7737 (let ((start (match-beginning 0))
7738 (end (set-marker (make-marker) (1+ (match-end 0)))))
7739 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7742 (defun gnus-button-in-region-p (b e prop)
7743 "Say whether PROP exists in the region."
7744 (text-property-not-all b e prop nil))
7746 (defun gnus-article-add-buttons ()
7747 "Find external references in the article and make buttons of them.
7748 \"External references\" are things like Message-IDs and URLs, as
7749 specified by `gnus-button-alist'."
7751 (gnus-with-article-buffer
7752 (let ((inhibit-point-motion-hooks t)
7753 (case-fold-search t)
7754 (alist gnus-button-alist)
7756 ;; We skip the headers.
7759 (while (setq entry (pop alist))
7760 (setq regexp (eval (car entry)))
7762 (while (re-search-forward regexp nil t)
7763 (let ((start (match-beginning (nth 1 entry)))
7764 (end (match-end (nth 1 entry)))
7765 (from (match-beginning 0)))
7766 (when (and (eval (nth 2 entry))
7767 (not (gnus-button-in-region-p
7768 start end 'gnus-callback)))
7769 ;; That optional form returned non-nil, so we add the
7771 (setq from (set-marker (make-marker) from))
7772 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7773 (gnus-article-extend-url-button from start end))
7774 (gnus-article-add-button start end
7775 'gnus-button-push (list from entry))
7776 (gnus-put-text-property
7778 'gnus-string (buffer-substring-no-properties
7781 (defun gnus-article-extend-url-button (beg start end)
7782 "Extend url button if url is folded into two or more lines.
7783 Return non-nil if button is extended. BEG is a marker that points to
7784 the beginning position of a text containing url. START and END are
7785 the endpoints of a url button before it is extended. The concatenated
7786 url is put as the `gnus-button-url' overlay property on the button."
7787 (let ((opoint (point))
7788 (points (list start end))
7793 (not (looking-at "[\t ]*[\">]")))
7797 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7798 (buffer-substring (point-at-bol) start)))
7800 (setq url (list (buffer-substring start end))
7801 delim (if (match-beginning 1) ">" "\""))
7803 (setq regexp (concat
7804 (when (and (looking-at
7805 message-cite-prefix-regexp)
7806 (< (match-end 0) start))
7807 (regexp-quote (match-string 0)))
7809 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7813 (and (looking-at regexp)
7816 (push (or (match-string 2)
7819 (push (setq end (or (match-end 2)
7822 (push (or (match-beginning 2)
7823 (match-beginning 1))
7825 (match-beginning 2)))
7826 (let (gnus-article-mouse-face widget-mouse-face)
7828 (gnus-article-add-button (pop points) (pop points)
7829 'gnus-button-push beg)))
7830 (let ((overlay (gnus-make-overlay start end)))
7831 (gnus-overlay-put overlay 'evaporate t)
7832 (gnus-overlay-put overlay 'gnus-button-url
7833 (list (mapconcat 'identity (nreverse url) "")))
7834 (when gnus-article-mouse-face
7835 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7837 (goto-char opoint))))
7839 ;; Add buttons to the head of an article.
7840 (defun gnus-article-add-buttons-to-head ()
7841 "Add buttons to the head of the article."
7843 (gnus-with-article-headers
7845 (dolist (entry gnus-header-button-alist)
7846 ;; Each alist entry.
7847 (goto-char (point-min))
7848 (while (re-search-forward (car entry) nil t)
7849 ;; Each header matching the entry.
7850 (setq beg (match-beginning 0))
7851 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7852 (match-beginning 0))
7855 (while (re-search-forward (eval (nth 1 entry)) end t)
7856 ;; Each match within a header.
7857 (let* ((entry (cdr entry))
7858 (start (match-beginning (nth 1 entry)))
7859 (end (match-end (nth 1 entry)))
7860 (form (nth 2 entry)))
7861 (goto-char (match-end 0))
7863 (gnus-article-add-button
7864 start end (nth 3 entry)
7865 (buffer-substring (match-beginning (nth 4 entry))
7866 (match-end (nth 4 entry)))))))
7867 (goto-char end))))))
7869 ;;; External functions:
7871 (defun gnus-article-add-button (from to fun &optional data text)
7872 "Create a button between FROM and TO with callback FUN and data DATA."
7873 (when gnus-article-button-face
7874 (gnus-overlay-put (gnus-make-overlay from to nil t)
7875 'face gnus-article-button-face))
7876 (gnus-add-text-properties
7878 (nconc (and gnus-article-mouse-face
7879 (list gnus-mouse-face-prop gnus-article-mouse-face))
7880 (list 'gnus-callback fun)
7881 (and data (list 'gnus-data data))))
7882 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7883 :help-echo (or text "Follow the link")
7884 :keymap gnus-url-button-map
7885 :button-keymap gnus-widget-button-keymap))
7887 (defun gnus-article-copy-string ()
7888 "Copy the string in the button to the kill ring."
7890 (gnus-article-check-buffer)
7891 (let ((data (get-text-property (point) 'gnus-string)))
7895 (copy-region-as-kill (point-min) (point-max))
7896 (message "Copied %s" data)))))
7898 ;;; Internal functions:
7900 (defun gnus-article-set-globals ()
7901 (with-current-buffer gnus-summary-buffer
7902 (gnus-set-global-variables)))
7904 (defun gnus-signature-toggle (end)
7905 (gnus-with-article-buffer
7906 (let ((inhibit-point-motion-hooks t))
7907 (if (text-property-any end (point-max) 'article-type 'signature)
7909 (gnus-delete-wash-type 'signature)
7910 (gnus-remove-text-properties-when
7911 'article-type 'signature end (point-max)
7912 (cons 'article-type (cons 'signature
7913 gnus-hidden-properties))))
7914 (gnus-add-wash-type 'signature)
7915 (gnus-add-text-properties-when
7916 'article-type nil end (point-max)
7917 (cons 'article-type (cons 'signature
7918 gnus-hidden-properties)))))
7919 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7920 (gnus-set-mode-line 'article))))
7922 (defun gnus-button-push (marker-and-entry)
7923 ;; Push button starting at MARKER.
7925 (let* ((marker (car marker-and-entry))
7926 (entry (cadr marker-and-entry))
7927 (regexp (car entry))
7928 (inhibit-point-motion-hooks t))
7930 ;; This is obviously true, or something bad is happening :)
7931 ;; But we need it to have the match-data
7932 (when (looking-at (or (if (symbolp regexp)
7933 (symbol-value regexp)
7935 (let ((fun (nth 3 entry))
7936 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7937 (get-char-property marker 'gnus-button-url))
7938 (mapcar (lambda (group)
7939 (let ((string (match-string group)))
7940 (set-text-properties
7941 0 (length string) nil string)
7943 (nthcdr 4 entry)))))
7949 (fboundp (symbol-value fun)))
7950 (apply (symbol-value fun) args))
7952 (gnus-message 1 "You must define `%S' to use this button"
7953 (cons fun args)))))))))
7955 (defun gnus-parse-news-url (url)
7956 (let (scheme server port group message-id articles)
7959 (goto-char (point-min))
7960 (when (looking-at "\\([A-Za-z]+\\):")
7961 (setq scheme (match-string 1))
7962 (goto-char (match-end 0)))
7963 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7964 (setq server (match-string 1))
7965 (setq port (if (stringp (match-string 3))
7966 (string-to-number (match-string 3))
7968 (goto-char (match-end 0)))
7971 ((looking-at "\\(.*@.*\\)")
7972 (setq message-id (match-string 1)))
7973 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7974 (setq group (match-string 1)
7975 articles (split-string (match-string 2) "-")))
7976 ((looking-at "\\([^/]+\\)/?")
7977 (setq group (match-string 1)))
7979 (error "Unknown news URL syntax"))))
7980 (list scheme server port group message-id articles)))
7982 (defun gnus-button-handle-news (url)
7984 (destructuring-bind (scheme server port group message-id articles)
7985 (gnus-parse-news-url url)
7988 (with-current-buffer gnus-summary-buffer
7990 (let ((gnus-refer-article-method
7991 (nconc (list (list 'nntp server))
7992 gnus-refer-article-method))
7993 (nntp-port-number (or port "nntp")))
7994 (gnus-message 7 "Fetching %s with %s"
7995 message-id gnus-refer-article-method)
7996 (gnus-summary-refer-article message-id))
7997 (gnus-summary-refer-article message-id))))
7999 (gnus-button-fetch-group url)))))
8001 (defun gnus-button-patch (library line)
8002 "Visit an Emacs Lisp library LIBRARY on line LINE."
8004 (let ((file (locate-library (file-name-nondirectory library))))
8006 (error "Couldn't find library %s" library))
8008 (goto-char (point-min))
8009 (forward-line (1- (string-to-number line)))))
8011 (defun gnus-button-handle-man (url)
8013 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8014 (when (eq gnus-button-man-handler 'woman)
8015 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8016 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8017 (funcall gnus-button-man-handler url))
8019 (defun gnus-button-handle-info-url (url)
8020 "Fetch an info URL."
8021 (setq url (mm-subst-char-in-string ?+ ?\ url))
8023 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8024 (gnus-info-find-node
8025 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8027 ")" (gnus-url-unhex-string (match-string 2 url)))))
8028 ((string-match "([^)\"]+)[^\"]+" url)
8030 (gnus-replace-in-string
8031 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8032 (gnus-info-find-node url))
8033 (t (error "Can't parse %s" url))))
8035 (defun gnus-button-handle-info-url-gnome (url)
8036 "Fetch GNOME style info URL."
8037 (setq url (mm-subst-char-in-string ?_ ?\ url))
8038 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8039 (gnus-info-find-node
8041 (gnus-url-unhex-string
8042 (match-string 1 url))
8044 (or (gnus-url-unhex-string
8045 (match-string 2 url))
8047 (error "Can't parse %s" url)))
8049 (defun gnus-button-handle-info-url-kde (url)
8050 "Fetch KDE style info URL."
8051 (gnus-info-find-node (gnus-url-unhex-string url)))
8053 ;; (info) will autoload info.el
8054 (declare-function Info-menu "info" (menu-item &optional fork))
8055 (declare-function Info-index-next "info" (num))
8057 (defun gnus-button-handle-info-keystrokes (url)
8058 "Call `info' when pushing the corresponding URL button."
8059 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8060 (let (node indx comma)
8062 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8063 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8064 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8065 "\\(?:[ \t\n,]*\\)\\)?")
8067 (setq node (match-string 2 url)
8068 indx (match-string 3 url))
8069 (error "Can't parse %s" url))
8073 (when (> (length indx) 0)
8074 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8077 (setq comma (match-string 2 indx))
8078 (setq indx (match-string 1 indx))
8081 (dotimes (i (with-temp-buffer
8083 ;; Note: the XEmacs version of `how-many' takes
8084 ;; no optional argument.
8085 (goto-char (point-min))
8087 (Info-index-next 1)))
8090 (autoload 'pgg-snarf-keys-region "pgg")
8091 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8092 (declare-function pgg-display-output-buffer "pgg" (start end status))
8094 (defun gnus-button-openpgp (url)
8095 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8097 (mm-url-insert-file-contents-external url)
8098 (pgg-snarf-keys-region (point-min) (point-max))
8099 (pgg-display-output-buffer nil nil nil)))
8101 (defun gnus-button-message-id (message-id)
8103 (with-current-buffer gnus-summary-buffer
8104 (gnus-summary-refer-article message-id)))
8106 (defun gnus-button-fetch-group (address &rest ignore)
8107 "Fetch GROUP specified by ADDRESS."
8108 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8110 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8111 ;; for nntp:// and news://
8112 (setq address (match-string 3 address)))
8113 (if (not (string-match "[:/]" address))
8114 ;; This is just a simple group url.
8115 (gnus-group-read-ephemeral-group address gnus-select-method)
8118 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8120 (error "Can't parse %s" address)
8121 (gnus-group-read-ephemeral-group
8122 (match-string 4 address)
8123 `(nntp ,(match-string 1 address)
8124 (nntp-address ,(match-string 1 address))
8125 (nntp-port-number ,(if (match-end 3)
8126 (match-string 3 address)
8129 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8131 (defun gnus-url-parse-query-string (query &optional downcase)
8132 (let (retval pairs cur key val)
8133 (setq pairs (split-string query "&"))
8135 (setq cur (car pairs)
8137 (if (not (string-match "=" cur))
8139 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8140 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8142 (setq key (downcase key)))
8143 (setq cur (assoc key retval))
8145 (setcdr cur (cons val (cdr cur)))
8146 (setq retval (cons (list key val) retval)))))
8149 (defun gnus-url-mailto (url)
8150 ;; Send mail to someone
8151 (setq url (replace-regexp-in-string "\n" " " url))
8152 (when (string-match "mailto:/*\\(.*\\)" url)
8153 (setq url (substring url (match-beginning 1) nil)))
8154 (let (to args subject func)
8155 (setq args (gnus-url-parse-query-string
8156 (if (string-match "^\\?" url)
8158 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8159 (concat "to=" (match-string 1 url) "&"
8160 (match-string 2 url))
8161 (concat "to=" url))))
8162 subject (cdr-safe (assoc "subject" args)))
8165 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8168 (message-position-on-field (caar args)))
8169 (insert (gnus-replace-in-string
8170 (mapconcat 'identity (reverse (cdar args)) ", ")
8172 (setq args (cdr args)))
8175 (message-goto-subject))))
8177 (defun gnus-button-embedded-url (address)
8178 "Activate ADDRESS with `browse-url'."
8179 (browse-url (gnus-strip-whitespace address)))
8181 ;;; Next/prev buttons in the article buffer.
8183 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8184 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8186 (defvar gnus-prev-page-map
8187 (let ((map (make-sparse-keymap)))
8188 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8189 (define-key map "\r" 'gnus-button-prev-page)
8192 (defvar gnus-next-page-map
8193 (let ((map (make-sparse-keymap)))
8194 (define-key map gnus-mouse-2 'gnus-button-next-page)
8195 (define-key map "\r" 'gnus-button-next-page)
8198 (defun gnus-insert-prev-page-button ()
8200 (inhibit-read-only t))
8202 gnus-prev-page-line-format nil
8203 `(keymap ,gnus-prev-page-map
8205 gnus-callback gnus-article-button-prev-page
8206 article-type annotation))
8208 ;; Exclude a newline.
8211 (when gnus-article-button-face
8212 (gnus-overlay-put (gnus-make-overlay b e nil t)
8213 'face gnus-article-button-face))
8214 (widget-convert-button
8216 :action 'gnus-button-prev-page
8217 :button-keymap gnus-prev-page-map)))
8219 (defun gnus-button-next-page (&optional args more-args)
8220 "Go to the next page."
8222 (let ((win (selected-window)))
8223 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8224 (gnus-article-next-page)
8225 (select-window win)))
8227 (defun gnus-button-prev-page (&optional args more-args)
8228 "Go to the prev page."
8230 (let ((win (selected-window)))
8231 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8232 (gnus-article-prev-page)
8233 (select-window win)))
8235 (defun gnus-insert-next-page-button ()
8237 (inhibit-read-only t))
8238 (gnus-eval-format gnus-next-page-line-format nil
8239 `(keymap ,gnus-next-page-map
8241 gnus-callback gnus-article-button-next-page
8242 article-type annotation))
8244 ;; Exclude a newline.
8247 (when gnus-article-button-face
8248 (gnus-overlay-put (gnus-make-overlay b e nil t)
8249 'face gnus-article-button-face))
8250 (widget-convert-button
8252 :action 'gnus-button-next-page
8253 :button-keymap gnus-next-page-map)))
8255 (defun gnus-article-button-next-page (arg)
8256 "Go to the next page."
8258 (let ((win (selected-window)))
8259 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8260 (gnus-article-next-page)
8261 (select-window win)))
8263 (defun gnus-article-button-prev-page (arg)
8264 "Go to the prev page."
8266 (let ((win (selected-window)))
8267 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8268 (gnus-article-prev-page)
8269 (select-window win)))
8271 (defvar gnus-decode-header-methods
8272 '(mail-decode-encoded-word-region)
8273 "List of methods used to decode headers.
8275 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8276 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8277 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8278 whose names match REGEXP.
8281 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8282 mail-decode-encoded-word-region
8283 (\"chinese\" . rfc1843-decode-region))
8286 (defvar gnus-decode-header-methods-cache nil)
8288 (defun gnus-multi-decode-header (start end)
8289 "Apply the functions from `gnus-encoded-word-methods' that match."
8290 (unless (and gnus-decode-header-methods-cache
8291 (eq gnus-newsgroup-name
8292 (car gnus-decode-header-methods-cache)))
8293 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8294 (dolist (x gnus-decode-header-methods)
8296 (nconc gnus-decode-header-methods-cache (list x))
8297 (if (and gnus-newsgroup-name
8298 (string-match (car x) gnus-newsgroup-name))
8299 (nconc gnus-decode-header-methods-cache
8301 (let ((xlist gnus-decode-header-methods-cache))
8304 (narrow-to-region start end)
8306 (funcall (pop xlist) (point-min) (point-max))))))
8309 ;;; Treatment top-level handling.
8312 (defvar gnus-inhibit-article-treatments nil)
8314 (defun gnus-treat-article (gnus-treat-condition
8315 &optional part-number total-parts gnus-treat-type)
8316 (let ((gnus-treat-length (- (point-max) (point-min)))
8317 (alist gnus-treatment-function-alist)
8318 (article-goto-body-goes-to-point-min-p t)
8320 (or (not gnus-treat-type)
8322 (let ((list gnus-article-treat-types))
8324 (when (string-match (pop list) gnus-treat-type)
8325 (throw 'found t)))))))
8326 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8328 (gnus-run-hooks 'gnus-part-display-hook)
8329 (dolist (elem alist)
8332 (when (gnus-buffer-live-p gnus-summary-buffer)
8333 (set-buffer gnus-summary-buffer))
8334 (symbol-value (car elem))))
8335 (when (and (or (consp val)
8337 (or (not gnus-inhibit-article-treatments)
8338 (eq gnus-treat-condition 'head))
8339 (gnus-treat-predicate val)
8340 (or (not (get (car elem) 'highlight))
8343 (funcall (cadr elem)))))))
8345 ;; Dynamic variables.
8346 (defvar part-number)
8347 (defvar total-parts)
8348 (defvar gnus-treat-type)
8349 (defvar gnus-treat-condition)
8350 (defvar gnus-treat-length)
8352 (defun gnus-treat-predicate (val)
8356 (gnus-treat-condition
8357 (eq gnus-treat-condition val))
8359 (stringp (car val)))
8360 (apply 'gnus-or (mapcar `(lambda (s)
8361 (string-match s ,(or gnus-newsgroup-name "")))
8364 (let ((pred (pop val)))
8367 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8369 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8371 (not (gnus-treat-predicate (car val))))
8373 (equal (car val) gnus-treat-type))
8375 (error "%S is not a valid predicate" pred)))))
8383 (eq part-number total-parts))
8385 (< gnus-treat-length val))
8387 (error "%S is not a valid value" val))))
8389 (defun gnus-article-encrypt-body (protocol &optional n)
8390 "Encrypt the article body."
8393 (or gnus-article-encrypt-protocol
8394 (gnus-completing-read "Encrypt protocol"
8395 (mapcar 'car gnus-article-encrypt-protocol-alist)
8397 current-prefix-arg))
8398 ;; User might hit `K E' instead of `K e', so prompt once.
8399 (when (and gnus-article-encrypt-protocol
8401 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8402 (error "Encrypt aborted")))
8403 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8405 (error "Can't find the encrypt protocol %s" protocol))
8406 (if (member gnus-newsgroup-name '("nndraft:delayed"
8409 (error "Can't encrypt the article in group %s"
8410 gnus-newsgroup-name))
8411 (gnus-summary-iterate n
8412 (with-current-buffer gnus-summary-buffer
8413 (let ((mail-parse-charset gnus-newsgroup-charset)
8414 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8415 (summary-buffer gnus-summary-buffer)
8417 (gnus-set-global-variables)
8418 (when (gnus-group-read-only-p)
8419 (error "The current newsgroup does not support article encrypt"))
8420 (gnus-summary-show-article t)
8422 (or (mail-header-references gnus-current-headers) ""))
8423 (set-buffer gnus-article-buffer)
8424 (let* ((inhibit-read-only t)
8426 (mapcar (lambda (field)
8427 (and (save-restriction
8428 (message-narrow-to-head)
8429 (goto-char (point-min))
8430 (search-forward field nil t))
8432 (message-narrow-to-field)
8434 (delete-region (point-min) (point-max))
8436 '("Content-Type:" "Content-Transfer-Encoding:"
8437 "Content-Disposition:"))))
8438 (message-narrow-to-head)
8439 (message-remove-header "MIME-Version")
8440 (goto-char (point-max))
8441 (setq point (point))
8442 (insert (apply 'concat headers))
8444 (narrow-to-region point (point-max))
8445 (let ((message-options message-options))
8446 (message-options-set 'message-sender user-mail-address)
8447 (message-options-set 'message-recipients user-mail-address)
8448 (message-options-set 'message-sign-encrypt 'not)
8450 (goto-char (point-min))
8451 (insert "MIME-Version: 1.0\n")
8453 (gnus-summary-edit-article-done
8454 references nil summary-buffer t))
8455 (when gnus-keep-backlog
8456 (gnus-backlog-remove-article
8457 (car gnus-article-current) (cdr gnus-article-current)))
8458 (gnus-flush-original-article-buffer)
8459 (when gnus-use-cache
8460 (gnus-cache-update-article
8461 (car gnus-article-current) (cdr gnus-article-current))))))))
8463 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8464 "The following specs can be used:
8465 %t The security MIME type
8468 %D Details if button is pressed")
8470 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8471 "The following specs can be used:
8472 %t The security MIME type
8475 %D Details if button is pressed")
8477 (defvar gnus-mime-security-button-line-format-alist
8478 '((?t gnus-tmp-type ?s)
8479 (?i gnus-tmp-info ?s)
8480 (?d gnus-tmp-details ?s)
8481 (?D gnus-tmp-pressed-details ?s)))
8483 (defvar gnus-mime-security-button-commands
8484 '((gnus-article-press-button "\r" "Show Detail")
8488 (gnus-mime-security-save-part "o" "Save...")
8497 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8500 (defvar gnus-mime-security-button-map
8501 (let ((map (make-sparse-keymap)))
8502 (define-key map gnus-mouse-2 'gnus-article-push-button)
8503 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8504 (dolist (c gnus-mime-security-button-commands)
8505 (define-key map (cadr c) (car c)))
8509 gnus-mime-security-button-menu gnus-mime-security-button-map
8510 "Security button menu."
8514 (unless (eq (car c) 'undefined)
8515 (vector (caddr c) (car c) :active t)))
8516 gnus-mime-security-button-commands))))
8518 (defun gnus-mime-security-button-menu (event prefix)
8519 "Construct a context-sensitive menu of security commands."
8520 (interactive "e\nP")
8521 (save-window-excursion
8522 (let ((pos (event-start event)))
8523 (select-window (posn-window pos))
8524 (goto-char (posn-point pos))
8525 (gnus-article-check-buffer)
8526 (popup-menu gnus-mime-security-button-menu nil prefix))))
8528 (defvar gnus-mime-security-details-buffer nil)
8530 (defvar gnus-mime-security-button-pressed nil)
8532 (defvar gnus-mime-security-show-details-inline t
8533 "If non-nil, show details in the article buffer.")
8535 (defun gnus-mime-security-verify-or-decrypt (handle)
8536 (mm-remove-parts (cdr handle))
8537 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8538 point (inhibit-read-only t))
8540 (goto-char (car region)))
8541 (setq point (point))
8542 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8543 (let* ((mm-verify-option 'known)
8544 (mm-decrypt-option 'known)
8545 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8546 (unless (eq nparts (cdr handle))
8547 (mm-destroy-parts (cdr handle))
8548 (setcdr handle nparts))))
8549 (gnus-mime-display-security handle)
8551 (delete-region (point) (cdr region))
8552 (set-marker (car region) nil)
8553 (set-marker (cdr region) nil))
8556 (defun gnus-mime-security-show-details (handle)
8557 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8559 (gnus-message 5 "No details.")
8560 (if gnus-mime-security-show-details-inline
8561 (let ((gnus-mime-security-button-pressed
8562 (not (get-text-property (point) 'gnus-mime-details)))
8563 (gnus-mime-security-button-line-format
8564 (get-text-property (point) 'gnus-line-format))
8565 (inhibit-read-only t))
8567 (while (eq (get-text-property (point) 'gnus-line-format)
8568 gnus-mime-security-button-line-format)
8572 (narrow-to-region (point) (point))
8573 (gnus-insert-mime-security-button handle))
8574 (delete-region (point)
8575 (or (text-property-not-all
8578 gnus-mime-security-button-line-format)
8581 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8582 (with-current-buffer gnus-mime-security-details-buffer
8585 (setq gnus-mime-security-details-buffer
8586 (gnus-get-buffer-create "*MIME Security Details*")))
8587 (with-current-buffer gnus-mime-security-details-buffer
8589 (goto-char (point-min)))
8590 (pop-to-buffer gnus-mime-security-details-buffer)))))
8592 (defun gnus-mime-security-press-button (handle)
8594 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8595 (gnus-mime-security-show-details handle)
8596 (gnus-mime-security-verify-or-decrypt handle))))
8598 (defun gnus-insert-mime-security-button (handle &optional displayed)
8599 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8602 (or (nth 2 (assoc protocol mm-verify-function-alist))
8603 (nth 2 (assoc protocol mm-decrypt-function-alist))
8605 (if (equal (car handle) "multipart/signed")
8606 " Signed" " Encrypted")
8609 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8612 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8613 gnus-tmp-pressed-details
8615 (setq gnus-tmp-details
8616 (if gnus-tmp-details
8617 (concat "\n" gnus-tmp-details)
8619 (setq gnus-tmp-pressed-details
8620 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8625 gnus-mime-security-button-line-format
8626 gnus-mime-security-button-line-format-alist
8627 `(keymap ,gnus-mime-security-button-map
8628 gnus-callback gnus-mime-security-press-button
8629 gnus-line-format ,gnus-mime-security-button-line-format
8630 gnus-mime-details ,gnus-mime-security-button-pressed
8631 article-type annotation
8634 ;; Exclude a newline.
8637 (when gnus-article-button-face
8638 (gnus-overlay-put (gnus-make-overlay b e nil t)
8639 'face gnus-article-button-face))
8640 (widget-convert-button
8643 :action 'gnus-widget-press-button
8644 :button-keymap gnus-mime-security-button-map
8647 ;; Needed to properly clear the message due to a bug in
8648 ;; wid-edit (XEmacs only).
8649 (when (boundp 'help-echo-owns-message)
8650 (setq help-echo-owns-message t))
8652 "%S: show detail; %S: more options"
8653 (aref gnus-mouse-2 0)
8654 (aref gnus-down-mouse-3 0))))))
8656 (defun gnus-mime-display-security (handle)
8658 (narrow-to-region (point) (point))
8659 (unless (gnus-unbuttonized-mime-type-p (car handle))
8660 (gnus-insert-mime-security-button handle))
8661 (gnus-mime-display-part (cadr handle))
8664 (unless (gnus-unbuttonized-mime-type-p (car handle))
8665 (let ((gnus-mime-security-button-line-format
8666 gnus-mime-security-button-end-line-format))
8667 (gnus-insert-mime-security-button handle)))
8668 (mm-set-handle-multipart-parameter
8670 (cons (set-marker (make-marker) (point-min))
8671 (set-marker (make-marker) (point-max))))
8672 (goto-char (point-max))))
8674 (defun gnus-mime-security-run-function (function)
8675 "Run FUNCTION with the security part under point."
8676 (gnus-article-check-buffer)
8677 (let ((data (get-text-property (point) 'gnus-data))
8679 (when (and (stringp (car-safe data))
8680 (setq buffer (mm-handle-multipart-original-buffer data))
8681 (setq handle (cadr data)))
8682 (if (bufferp (mm-handle-buffer handle))
8684 (setq handle (cons buffer (copy-sequence (cdr handle))))
8685 (mm-handle-set-undisplayer handle nil))
8686 (setq handle (mm-make-handle
8688 (mm-handle-multipart-ctl-parameter handle 'protocol)
8689 nil nil nil nil nil nil)))
8690 (funcall function handle))))
8692 (defun gnus-mime-security-save-part ()
8693 "Save the security part under point."
8695 (gnus-mime-security-run-function 'mm-save-part))
8697 (defun gnus-mime-security-pipe-part ()
8698 "Pipe the security part under point to a process."
8700 (gnus-mime-security-run-function 'mm-pipe-part))
8706 (run-hooks 'gnus-art-load-hook)
8708 ;;; gnus-art.el ends here