1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2014 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/>.
30 (defvar w3m-minor-mode-map
)
46 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
47 (autoload 'gnus-button-mailto
"gnus-msg")
48 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
49 (autoload 'parse-time-string
"parse-time" nil nil
)
50 (autoload 'ansi-color-apply-on-region
"ansi-color")
51 (autoload 'mm-url-insert-file-contents-external
"mm-url")
52 (autoload 'mm-extern-cache-contents
"mm-extern")
54 (defgroup gnus-article nil
56 :link
'(custom-manual "(gnus)Article Buffer")
59 (defgroup gnus-article-treat nil
60 "Treating article parts."
61 :link
'(custom-manual "(gnus)Article Hiding")
64 (defgroup gnus-article-hiding nil
65 "Hiding article parts."
66 :link
'(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-highlight nil
70 "Article highlighting."
71 :link
'(custom-manual "(gnus)Article Highlighting")
75 (defgroup gnus-article-signature nil
77 :link
'(custom-manual "(gnus)Article Signature")
80 (defgroup gnus-article-headers nil
82 :link
'(custom-manual "(gnus)Hiding Headers")
85 (defgroup gnus-article-washing nil
86 "Special commands on articles."
87 :link
'(custom-manual "(gnus)Article Washing")
90 (defgroup gnus-article-emphasis nil
91 "Fontisizing articles."
92 :link
'(custom-manual "(gnus)Article Fontisizing")
95 (defgroup gnus-article-saving nil
97 :link
'(custom-manual "(gnus)Saving Articles")
100 (defgroup gnus-article-mime nil
101 "Worshiping the MIME wonder."
102 :link
'(custom-manual "(gnus)Using MIME")
103 :group
'gnus-article
)
105 (defgroup gnus-article-buttons nil
106 "Pushable buttons in the article buffer."
107 :link
'(custom-manual "(gnus)Article Buttons")
108 :group
'gnus-article
)
110 (defgroup gnus-article-various nil
111 "Other article options."
112 :link
'(custom-manual "(gnus)Misc Article")
113 :group
'gnus-article
)
115 (defcustom gnus-ignored-headers
118 (concat "^" header
":"))
119 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
120 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
121 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
122 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
123 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
124 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
125 "X-Attribution" "X-Originating-IP" "Delivered-To"
126 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
127 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
128 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
129 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
130 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
131 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
132 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
133 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
134 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
135 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
136 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
137 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
138 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
139 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
140 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
141 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
142 "List-[A-Za-z]+" "X-Listprocessor-Version"
143 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
144 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
145 "X-Received" "Content-length" "X-precedence"
146 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
147 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
148 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
149 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
150 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
151 "X-Content-length" "X-Posting-Agent" "Original-Received"
152 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
157 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
158 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
159 "Envelope-Sender" "Envelope-Recipients"))
160 "*All headers that start with this regexp will be hidden.
161 This variable can also be a list of regexps of headers to be ignored.
162 If `gnus-visible-headers' is non-nil, this variable will be ignored."
163 :type
'(choice regexp
165 :group
'gnus-article-hiding
)
167 (defcustom gnus-visible-headers
168 "^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:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
173 (repeat :value-to-internal
(lambda (widget value
)
174 (custom-split-regexp-maybe value
))
175 :match
(lambda (widget value
)
177 (widget-editable-list-match widget value
)))
179 (const :tag
"Use gnus-ignored-headers" nil
)
181 :group
'gnus-article-hiding
)
183 (defcustom gnus-sorted-header-list
184 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
185 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
186 "*This variable is a list of regular expressions.
187 If it is non-nil, headers that match the regular expressions will
188 be placed first in the article buffer in the sequence specified by
190 :type
'(repeat regexp
)
191 :group
'gnus-article-hiding
)
193 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
194 "Headers that are only to be displayed if they have interesting data.
195 Possible values in this list are:
197 'empty Headers with no content.
198 'newsgroups Newsgroup identical to Gnus group.
199 'to-address To identical to To-address.
200 'to-list To identical to To-list.
201 'cc-list CC identical to To-list.
202 'followup-to Followup-to identical to Newsgroups.
203 'reply-to Reply-to identical to From.
204 'date Date less than four days old.
205 'long-to To and/or Cc longer than 1024 characters.
206 'many-to Multiple To and/or Cc."
207 :type
'(set (const :tag
"Headers with no content." empty
)
208 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
209 (const :tag
"To identical to To-address." to-address
)
210 (const :tag
"To identical to To-list." to-list
)
211 (const :tag
"CC identical to To-list." cc-list
)
212 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
213 (const :tag
"Reply-to identical to From." reply-to
)
214 (const :tag
"Date less than four days old." date
)
215 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
216 (const :tag
"Multiple To and/or Cc headers." many-to
))
217 :group
'gnus-article-hiding
)
219 (defcustom gnus-article-skip-boring nil
220 "Skip over text that is not worth reading.
221 By default, if you set this t, then Gnus will display citations and
222 signatures, but will never scroll down to show you a page consisting
223 only of boring text. Boring text is controlled by
224 `gnus-article-boring-faces'."
227 :group
'gnus-article-hiding
)
229 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
230 "Regexp matching signature separator.
231 This can also be a list of regexps. In that case, it will be checked
232 from head to tail looking for a separator. Searches will be done from
233 the end of the buffer."
234 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
236 (repeat :tag
"List of regexp" regexp
))
237 :group
'gnus-article-signature
)
239 (defcustom gnus-signature-limit nil
240 "Provide a limit to what is considered a signature.
241 If it is a number, no signature may not be longer (in characters) than
242 that number. If it is a floating point number, no signature may be
243 longer (in lines) than that number. If it is a function, the function
244 will be called without any parameters, and if it returns nil, there is
245 no signature in the buffer. If it is a string, it will be used as a
246 regexp. If it matches, the text in question is not a signature.
248 This can also be a list of the above values."
249 :type
'(choice (const nil
)
253 (regexp :value
".*"))
254 :group
'gnus-article-signature
)
256 (defcustom gnus-hidden-properties
257 (if (featurep 'xemacs
)
258 ;; `intangible' is evil, but I keep it here in case it's useful.
259 '(invisible t intangible t
)
260 ;; Emacs's command loop moves point out of invisible text anyway, so
261 ;; `intangible' is clearly not needed there.
263 "Property list to use for hiding text."
265 :group
'gnus-article-hiding
)
267 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
268 ;; frames in a session.
269 (defcustom gnus-article-x-face-command
270 (if (featurep 'xemacs
)
271 (if (or (gnus-image-type-available-p 'xface
)
272 (gnus-image-type-available-p 'pbm
))
273 'gnus-display-x-face-in-from
275 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
276 ; uncompface; } | icontopbm | ee -")
277 (if (gnus-image-type-available-p 'pbm
)
278 'gnus-display-x-face-in-from
280 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
281 ; uncompface; } | icontopbm | display -"))
282 "*String or function to be executed to display an X-Face header.
283 If it is a string, the command will be executed in a sub-shell
284 asynchronously. The compressed face will be piped to this command."
285 :type
`(choice string
286 (function-item gnus-display-x-face-in-from
)
290 :group
'gnus-article-washing
)
292 (defcustom gnus-article-x-face-too-ugly nil
293 "Regexp matching posters whose face shouldn't be shown automatically."
294 :type
'(choice regexp
(const nil
))
295 :group
'gnus-article-washing
)
297 (defcustom gnus-article-banner-alist nil
298 "Banner alist for stripping.
300 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
302 :type
'(repeat (cons symbol regexp
))
303 :group
'gnus-article-washing
)
305 (gnus-define-group-parameter
308 "Alist of regexps (to match group names) and banner."
309 :variable-group gnus-article-washing
311 '(choice :tag
"Banner"
313 (const :tag
"Remove signature" signature
)
314 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
316 (const :tag
"None" nil
))
318 "If non-nil, specify how to remove `banners' from articles.
320 Symbol `signature' means to remove signatures delimited by
321 `gnus-signature-separator'. Any other symbol is used to look up a
322 regular expression to match the banner in `gnus-article-banner-alist'.
323 A string is used as a regular expression to match the banner
326 (defcustom gnus-article-address-banner-alist nil
327 "Alist of mail addresses and banners.
328 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
329 to match a mail address in the From: header, BANNER is one of a symbol
330 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
331 If ADDRESS matches author's mail address, it will remove things like
332 advertisements. For example:
334 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
338 (regexp :tag
"Address")
339 (choice :tag
"Banner" :value nil
340 (const :tag
"Remove signature" signature
)
341 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
343 (const :tag
"None" nil
))))
345 :group
'gnus-article-washing
)
347 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
349 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
350 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
353 (defun gnus-emphasis-custom-value-to-external (value)
354 (gnus-emphasis-custom-with-format
355 (if (consp (car value
))
356 (list (format format
(car (car value
)) (cdr (car value
)))
358 (if (nth 1 value
) 2 3)
362 (defun gnus-emphasis-custom-value-to-internal (value)
363 (gnus-emphasis-custom-with-format
364 (let ((regexp (concat "\\`"
365 (format (regexp-quote format
)
366 "\\([^()]+\\)" "\\([^()]+\\)")
369 (if (string-match regexp
(setq pattern
(car value
)))
370 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
375 (defcustom gnus-emphasis-alist
377 '(("\\*" "\\*" bold nil
2)
380 ("_/" "/_" underline-italic
)
381 ("_\\*" "\\*_" underline-bold
)
382 ("\\*/" "/\\*" bold-italic
)
383 ("_\\*/" "/\\*_" underline-bold-italic
))))
385 (gnus-emphasis-custom-with-format
386 (mapcar (lambda (spec)
387 (list (format format
(car spec
) (cadr spec
))
390 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
392 '(;; I've never seen anyone use this strikethru convention whereas I've
393 ;; several times seen it triggered by normal text. --Stef
394 ;; Miles suggests that this form is sometimes used but for italics,
395 ;; so maybe we should map it to `italic'.
396 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
397 ;; 2 3 gnus-emphasis-strikethru)
398 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
399 2 3 gnus-emphasis-underline
))))
400 "*Alist that says how to fontify certain phrases.
401 Each item looks like this:
403 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
405 The first element is a regular expression to be matched. The second
406 is a number that says what regular expression grouping used to find
407 the entire emphasized word. The third is a number that says what
408 regexp grouping should be displayed and highlighted. The fourth
409 is the face used for highlighting."
413 :format
"%[Customizing Style%]\n%v"
415 (group :tag
"Default"
416 :value
("" 0 0 default
)
419 (let ((value (widget-get
420 (cadr (widget-get (widget-get widget
:parent
)
423 (if (not (eq (nth 2 value
) 'default
))
427 (gnus-emphasis-custom-value-to-external value
))))
428 (widget-group-value-create widget
))
430 (integer :format
"Match group: %v")
431 (integer :format
"Emphasize group: %v")
434 :value
(("_" .
"_") nil default
)
436 (regexp :format
"Start regexp: %v")
437 (regexp :format
"End regexp: %v"))
438 (boolean :format
"Show start and end patterns: %[%v%]\n"
439 :on
" On " :off
" Off ")
441 :get
(lambda (symbol)
442 (mapcar 'gnus-emphasis-custom-value-to-internal
443 (default-value symbol
)))
444 :set
(lambda (symbol value
)
445 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
447 :group
'gnus-article-emphasis
)
449 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
450 "A regexp to describe whitespace which should not be emphasized.
451 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
452 The former avoids underlining of leading and trailing whitespace,
453 and the latter avoids underlining any whitespace at all."
455 :group
'gnus-article-emphasis
458 (defface gnus-emphasis-bold
'((t (:bold t
)))
459 "Face used for displaying strong emphasized text (*word*)."
460 :group
'gnus-article-emphasis
)
462 (defface gnus-emphasis-italic
'((t (:italic t
)))
463 "Face used for displaying italic emphasized text (/word/)."
464 :group
'gnus-article-emphasis
)
466 (defface gnus-emphasis-underline
'((t (:underline t
)))
467 "Face used for displaying underlined emphasized text (_word_)."
468 :group
'gnus-article-emphasis
)
470 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
471 "Face used for displaying underlined bold emphasized text (_*word*_)."
472 :group
'gnus-article-emphasis
)
474 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
475 "Face used for displaying underlined italic emphasized text (_/word/_)."
476 :group
'gnus-article-emphasis
)
478 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
479 "Face used for displaying bold italic emphasized text (/*word*/)."
480 :group
'gnus-article-emphasis
)
482 (defface gnus-emphasis-underline-bold-italic
483 '((t (:bold t
:italic t
:underline t
)))
484 "Face used for displaying underlined bold italic emphasized text.
485 Example: (_/*word*/_)."
486 :group
'gnus-article-emphasis
)
488 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
489 '((t (:strikethru t
)))
490 '((t (:strike-through t
))))
491 "Face used for displaying strike-through text (-word-)."
492 :group
'gnus-article-emphasis
)
494 (defface gnus-emphasis-highlight-words
495 '((t (:background
"black" :foreground
"yellow")))
496 "Face used for displaying highlighted words."
497 :group
'gnus-article-emphasis
)
499 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
500 "Format for display of Date headers in article bodies.
501 See `format-time-string' for the possible values.
503 The variable can also be function, which should return a complete Date
504 header. The function is called with one argument, the time, which can
505 be fed to `format-time-string'."
506 :type
'(choice string function
)
507 :link
'(custom-manual "(gnus)Article Date")
508 :group
'gnus-article-washing
)
510 (defcustom gnus-save-all-headers t
511 "*If non-nil, don't remove any headers before saving.
512 This will be overridden by the `:headers' property that the symbol of
513 the saver function, which is specified by `gnus-default-article-saver',
515 :group
'gnus-article-saving
518 (defcustom gnus-prompt-before-saving
'always
519 "*This variable says how much prompting is to be done when saving articles.
520 If it is nil, no prompting will be done, and the articles will be
521 saved to the default files. If this variable is `always', each and
522 every article that is saved will be preceded by a prompt, even when
523 saving large batches of articles. If this variable is neither nil not
524 `always', there the user will be prompted once for a file name for
525 each invocation of the saving commands."
526 :group
'gnus-article-saving
527 :type
'(choice (item always
)
528 (item :tag
"never" nil
)
529 (sexp :tag
"once" :format
"%t\n" :value t
)))
531 (defcustom gnus-saved-headers gnus-visible-headers
532 "Headers to keep if `gnus-save-all-headers' is nil.
533 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
534 If that variable is nil, however, all headers that match this regexp
535 will be kept while the rest will be deleted before saving. This and
536 `gnus-save-all-headers' will be overridden by the `:headers' property
537 that the symbol of the saver function, which is specified by
538 `gnus-default-article-saver', might have."
539 :group
'gnus-article-saving
542 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
543 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
544 "A function to save articles in your favorite format.
545 The function will be called by way of the `gnus-summary-save-article'
546 command, and friends such as `gnus-summary-save-article-rmail'.
548 Gnus provides the following functions:
550 * gnus-summary-save-in-rmail (Rmail format)
551 * gnus-summary-save-in-mail (Unix mail format)
552 * gnus-summary-save-in-folder (MH folder)
553 * gnus-summary-save-in-file (article format)
554 * gnus-summary-save-body-in-file (article body)
555 * gnus-summary-save-in-vm (use VM's folder format)
556 * gnus-summary-write-to-file (article format -- overwrite)
557 * gnus-summary-write-body-to-file (article body -- overwrite)
558 * gnus-summary-save-in-pipe (article format)
560 The symbol of each function may have the following properties:
563 The value non-nil means save decoded articles. This is meaningful
564 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
565 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
566 `gnus-summary-save-in-pipe'.
569 The value specifies an alternative function which appends, not
570 overwrites, articles to a file. This implies that when saving many
571 articles at a time, `gnus-prompt-before-saving' is bound to t and all
572 articles are saved in a single file. This is meaningful only with
573 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
576 The value specifies the symbol of a variable of which the value
577 specifies headers to be saved. If it is omitted,
578 `gnus-save-all-headers' and `gnus-saved-headers' control what
579 headers should be saved."
580 :group
'gnus-article-saving
581 :type
'(radio (function-item gnus-summary-save-in-rmail
)
582 (function-item gnus-summary-save-in-mail
)
583 (function-item gnus-summary-save-in-folder
)
584 (function-item gnus-summary-save-in-file
)
585 (function-item gnus-summary-save-body-in-file
)
586 (function-item gnus-summary-save-in-vm
)
587 (function-item gnus-summary-write-to-file
)
588 (function-item gnus-summary-write-body-to-file
)
589 (function-item gnus-summary-save-in-pipe
)
592 (defcustom gnus-article-save-coding-system
593 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
594 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
595 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
596 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
597 "Coding system used to save decoded articles to a file.
599 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
600 which can safely encode any characters in text. This is used by the
603 * gnus-summary-save-article-file
604 * gnus-summary-save-article-body-file
605 * gnus-summary-write-article-file
606 * gnus-summary-write-article-body-file
608 and the functions to which you may set `gnus-default-article-saver':
610 * gnus-summary-save-in-file
611 * gnus-summary-save-body-in-file
612 * gnus-summary-write-to-file
613 * gnus-summary-write-body-to-file
615 Those commands and functions save just text displayed in the article
616 buffer to a file if the value of this variable is non-nil. Note that
617 buttonized MIME parts will be lost in a saved file in that case.
618 Otherwise, raw articles will be saved."
619 :group
'gnus-article-saving
621 :format
"%{%t%}:\n %[Value Menu%] %v"
622 (const :tag
"Save raw articles" nil
)
625 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
626 '((const :tag
"UTF-8" utf-8
)
627 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
628 (const :tag
"Emacs internal" emacs-mule
)
629 (const :tag
"escape-quoted" escape-quoted
))))
630 (symbol :tag
"Coding system")))
632 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
633 "A function generating a file name to save articles in Rmail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group
'gnus-article-saving
638 (defcustom gnus-mail-save-name
'gnus-plain-save-name
639 "A function generating a file name to save articles in Unix mail format.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
641 :group
'gnus-article-saving
644 (defcustom gnus-folder-save-name
'gnus-folder-save-name
645 "A function generating a file name to save articles in MH folder.
646 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
647 :group
'gnus-article-saving
650 (defcustom gnus-file-save-name
'gnus-numeric-save-name
651 "A function generating a file name to save articles in article format.
652 The function is called with NEWSGROUP, HEADERS, and optional
654 :group
'gnus-article-saving
657 (defcustom gnus-split-methods
658 '((gnus-article-archive-name)
659 (gnus-article-nndoc-name))
660 "*Variable used to suggest where articles are to be saved.
661 For instance, if you would like to save articles related to Gnus in
662 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
663 you could set this variable to something like:
665 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
666 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
668 This variable is an alist where the key is the match and the
669 value is a list of possible files to save in if the match is
672 If the match is a string, it is used as a regexp match on the
673 article. If the match is a symbol, that symbol will be funcalled
674 from the buffer of the article to be saved with the newsgroup as the
675 parameter. If it is a list, it will be evalled in the same buffer.
677 If this form or function returns a string, this string will be used as a
678 possible file name; and if it returns a non-nil list, that list will be
679 used as possible file names."
680 :group
'gnus-article-saving
681 :type
'(repeat (choice (list :value
(fun) function
)
682 (cons :value
("" "") regexp
(repeat string
))
685 (defcustom gnus-page-delimiter
"^\^L"
686 "*Regexp describing what to use as article page delimiters.
687 The default value is \"^\^L\", which is a form linefeed at the
688 beginning of a line."
690 :group
'gnus-article-various
)
692 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
693 "*The format specification for the article mode line.
694 See `gnus-summary-mode-line-format' for a closer description.
696 The following additional specs are available:
698 %w The article washing status.
699 %m The number of MIME parts in the article."
702 :group
'gnus-article-various
)
704 (defcustom gnus-article-mode-hook nil
705 "*A hook for Gnus article mode."
707 :group
'gnus-article-various
)
709 (when (featurep 'xemacs
)
710 ;; Extracted from gnus-xmas-define in order to preserve user settings
711 (when (fboundp 'turn-off-scroll-in-place
)
712 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
713 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
714 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
716 (defcustom gnus-article-menu-hook nil
717 "*Hook run after the creation of the article mode menu."
719 :group
'gnus-article-various
)
721 (defcustom gnus-article-prepare-hook nil
722 "*A hook called after an article has been prepared in the article buffer."
724 :group
'gnus-article-various
)
726 (defcustom gnus-copy-article-ignored-headers nil
727 "List of headers to be removed when copying an article.
728 Each element is a regular expression."
729 :version
"23.1" ;; No Gnus
730 :type
'(repeat regexp
)
731 :group
'gnus-article-various
)
733 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
734 "Gnus 5.10 (Emacs 22.1)")
737 '((t (:weight bold
)))
738 "Face used for highlighting a button in the article buffer."
739 :group
'gnus-article-buttons
)
741 (defcustom gnus-article-button-face
'gnus-button
742 "Face used for highlighting buttons in the article buffer.
744 An article button is a piece of text that you can activate by pressing
745 `RET' or `mouse-2' above it."
747 :group
'gnus-article-buttons
)
749 (defcustom gnus-article-mouse-face
'highlight
750 "Face used for mouse highlighting in the article buffer.
752 Article buttons will be displayed in this face when the cursor is
755 :group
'gnus-article-buttons
)
757 (defcustom gnus-signature-face
'gnus-signature
758 "Face used for highlighting a signature in the article buffer.
759 Obsolete; use the face `gnus-signature' for customizations instead."
761 :group
'gnus-article-highlight
762 :group
'gnus-article-signature
)
764 (defface gnus-signature
767 "Face used for highlighting a signature in the article buffer."
768 :group
'gnus-article-highlight
769 :group
'gnus-article-signature
)
770 ;; backward-compatibility alias
771 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
772 (put 'gnus-signature-face
'obsolete-face
"22.1")
774 (defface gnus-header-from
777 (:foreground
"PaleGreen1"))
780 (:foreground
"red3"))
783 "Face used for displaying from headers."
784 :group
'gnus-article-headers
785 :group
'gnus-article-highlight
)
786 ;; backward-compatibility alias
787 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
788 (put 'gnus-header-from-face
'obsolete-face
"22.1")
790 (defface gnus-header-subject
793 (:foreground
"SeaGreen1"))
796 (:foreground
"red4"))
798 (:bold t
:italic t
)))
799 "Face used for displaying subject headers."
800 :group
'gnus-article-headers
801 :group
'gnus-article-highlight
)
802 ;; backward-compatibility alias
803 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
804 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
806 (defface gnus-header-newsgroups
809 (:foreground
"yellow" :italic t
))
812 (:foreground
"MidnightBlue" :italic t
))
815 "Face used for displaying newsgroups headers.
816 In the default setup this face is only used for crossposted
818 :group
'gnus-article-headers
819 :group
'gnus-article-highlight
)
820 ;; backward-compatibility alias
821 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
822 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
824 (defface gnus-header-name
827 (:foreground
"SpringGreen2"))
830 (:foreground
"maroon"))
833 "Face used for displaying header names."
834 :group
'gnus-article-headers
835 :group
'gnus-article-highlight
)
836 ;; backward-compatibility alias
837 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
838 (put 'gnus-header-name-face
'obsolete-face
"22.1")
840 (defface gnus-header-content
843 (:foreground
"SpringGreen1" :italic t
))
846 (:foreground
"indianred4" :italic t
))
848 (:italic t
))) "Face used for displaying header content."
849 :group
'gnus-article-headers
850 :group
'gnus-article-highlight
)
851 ;; backward-compatibility alias
852 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
853 (put 'gnus-header-content-face
'obsolete-face
"22.1")
855 (defcustom gnus-header-face-alist
856 '(("From" nil gnus-header-from
)
857 ("Subject" nil gnus-header-subject
)
858 ("Newsgroups:.*," nil gnus-header-newsgroups
)
859 ("" gnus-header-name gnus-header-content
))
860 "*Controls highlighting of article headers.
862 An alist of the form (HEADER NAME CONTENT).
864 HEADER is a regular expression which should match the name of a
865 header and NAME and CONTENT are either face names or nil.
867 The name of each header field will be displayed using the face
868 specified by the first element in the list where HEADER matches
869 the header name and NAME is non-nil. Similarly, the content will
870 be displayed by the first non-nil matching CONTENT face."
871 :group
'gnus-article-headers
872 :group
'gnus-article-highlight
873 :type
'(repeat (list (regexp :tag
"Header")
875 (item :tag
"skip" nil
)
876 (face :value default
))
877 (choice :tag
"Content"
878 (item :tag
"skip" nil
)
879 (face :value default
)))))
881 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
882 '((xface .
(:face gnus-x-face
)))
883 '((pbm .
(:face gnus-x-face
))
885 "Alist of image types and properties applied to Face and X-Face images.
888 ;; Specify the altitude of Face images in the From header.
889 \(setq gnus-face-properties-alist
890 '((pbm . (:face gnus-x-face :ascent 80))
891 (png . (:ascent 80))))
893 ;; Show Face images as pressed buttons.
894 \(setq gnus-face-properties-alist
895 '((pbm . (:face gnus-x-face :relief -2))
896 (png . (:relief -2))))
898 See the manual for the valid properties for various image types.
899 Currently, `pbm' is used for X-Face images and `png' is used for Face
900 images in Emacs. Only the `:face' property is effective on the `xface'
901 image type in XEmacs if it is built with the libcompface library."
902 :version
"23.1" ;; No Gnus
903 :group
'gnus-article-headers
904 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
906 (defcustom gnus-article-decode-hook
907 '(article-decode-charset article-decode-encoded-words
908 article-decode-group-name article-decode-idna-rhs
)
909 "*Hook run to decode charsets in articles."
910 :group
'gnus-article-headers
913 (defcustom gnus-display-mime-function
'gnus-display-mime
914 "Function to display MIME articles."
915 :group
'gnus-article-mime
918 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
919 "Function used to decode headers.")
921 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
922 "Function used to decode addresses.")
924 (defvar gnus-article-dumbquotes-map
944 "Table for MS-to-Latin1 translation.")
946 (defcustom gnus-ignored-mime-types nil
947 "List of MIME types that should be ignored by Gnus."
949 :group
'gnus-article-mime
950 :type
'(repeat regexp
))
952 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
953 "List of MIME types that should not be given buttons when rendered inline.
954 See also `gnus-buttonized-mime-types' which may override this variable.
955 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
957 :group
'gnus-article-mime
958 :type
'(repeat regexp
))
960 (defcustom gnus-buttonized-mime-types nil
961 "List of MIME types that should be given buttons when rendered inline.
962 If set, this variable overrides `gnus-unbuttonized-mime-types'.
963 To see e.g. security buttons you could set this to
964 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
965 this list to display radio buttons that allow you to choose one of two
966 media types those mails include. See also `mm-discouraged-alternatives'.
967 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
969 :group
'gnus-article-mime
970 :type
'(repeat regexp
))
972 (defcustom gnus-inhibit-mime-unbuttonizing nil
973 "If non-nil, all MIME parts get buttons.
974 When nil (the default value), then some MIME parts do not get buttons,
975 as described by the variables `gnus-buttonized-mime-types' and
976 `gnus-unbuttonized-mime-types'."
978 :group
'gnus-article-mime
981 (defcustom gnus-body-boundary-delimiter
"_"
982 "String used to delimit header and body.
983 This variable is used by `gnus-article-treat-body-boundary' which can
984 be controlled by `gnus-treat-body-boundary'."
986 :group
'gnus-article-various
987 :type
'(choice (item :tag
"None" :value nil
)
990 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
992 "Defines the location of the faces database.
993 For information on obtaining this database of pretty pictures, please
994 see http://www.cs.indiana.edu/picons/ftp/index.html"
996 :type
'(repeat directory
)
997 :link
'(url-link :tag
"download"
998 "http://www.cs.indiana.edu/picons/ftp/index.html")
999 :link
'(custom-manual "(gnus)Picons")
1002 (defun gnus-picons-installed-p ()
1003 "Say whether picons are installed on your machine."
1004 (let ((installed nil
))
1005 (dolist (database gnus-picon-databases
)
1006 (when (file-exists-p database
)
1007 (setq installed t
)))
1010 (defcustom gnus-article-mime-part-function nil
1011 "Function called with a MIME handle as the argument.
1012 This is meant for people who want to do something automatic based
1013 on parts -- for instance, adding Vcard info to a database."
1014 :group
'gnus-article-mime
1015 :type
'(choice (const nil
)
1018 (defcustom gnus-mime-multipart-functions nil
1019 "An alist of MIME types to functions to display them."
1021 :group
'gnus-article-mime
1022 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1024 (defcustom gnus-article-date-headers
'(combined-lapsed)
1025 "A list of Date header formats to display.
1026 Valid formats are `ut' (universal time), `local' (local time
1027 zone), `english' (readable English), `lapsed' (elapsed time),
1028 `combined-lapsed' (both the original date and the elapsed time),
1029 `original' (the original date header), `iso8601' (ISO8601
1030 format), and `user-defined' (a user-defined format defined by the
1031 `gnus-article-time-format' variable).
1033 You have as many date headers as you want in the article buffer.
1034 Some of these headers are updated automatically. See
1035 `gnus-article-update-date-headers' for details."
1037 :group
'gnus-article-headers
1039 (const :tag
"Universal time (UT)" ut
)
1040 (const :tag
"Local time zone" local
)
1041 (const :tag
"Readable English" english
)
1042 (const :tag
"Elapsed time" lapsed
)
1043 (const :tag
"Original and elapsed time" combined-lapsed
)
1044 (const :tag
"Original date header" original
)
1045 (const :tag
"ISO8601 format" iso8601
)
1046 (const :tag
"User-defined" user-defined
)))
1048 (defcustom gnus-article-update-date-headers nil
1049 "A number that says how often to update the date header (in seconds).
1050 If nil, don't update it at all."
1052 :group
'gnus-article-headers
1054 (item :tag
"Don't update" :value nil
)
1057 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1058 "Function called with a MIME handle as the argument.
1059 This is meant for people who want to view first matched part.
1060 For `undisplayed-alternative' (default), the first undisplayed
1061 part or alternative part is used. For `undisplayed', the first
1062 undisplayed part is used. For a function, the first part which
1063 the function return t is used. For nil, the first part is
1066 :group
'gnus-article-mime
1068 (item :tag
"first" :value nil
)
1069 (item :tag
"undisplayed" :value undisplayed
)
1070 (item :tag
"undisplayed or alternative"
1071 :value undisplayed-alternative
)
1074 (defcustom gnus-mime-action-alist
1075 '(("save to file" . gnus-mime-save-part
)
1076 ("save and strip" . gnus-mime-save-part-and-strip
)
1077 ("replace with file" . gnus-mime-replace-part
)
1078 ("delete part" . gnus-mime-delete-part
)
1079 ("display as text" . gnus-mime-inline-part
)
1080 ("view the part" . gnus-mime-view-part
)
1081 ("pipe to command" . gnus-mime-pipe-part
)
1082 ("toggle display" . gnus-article-press-button
)
1083 ("toggle display" . gnus-article-view-part-as-charset
)
1084 ("view as type" . gnus-mime-view-part-as-type
)
1085 ("view internally" . gnus-mime-view-part-internally
)
1086 ("view externally" . gnus-mime-view-part-externally
))
1087 "An alist of actions that run on the MIME attachment."
1088 :group
'gnus-article-mime
1089 :type
'(repeat (cons (string :tag
"name")
1092 (defcustom gnus-auto-select-part
1
1093 "Advance to next MIME part when deleting or stripping parts.
1095 When 0, point will be placed on the same part as before. When
1096 positive (negative), move point forward (backwards) this many
1097 parts. When nil, redisplay article."
1098 :version
"23.1" ;; No Gnus
1099 :group
'gnus-article-mime
1100 :type
'(choice (const nil
:tag
"Redisplay article.")
1101 (const 1 :tag
"Next part.")
1102 (const 0 :tag
"Current part.")
1106 ;;; The treatment variables
1109 (defvar gnus-part-display-hook nil
1110 "Hook called on parts that are to receive treatment.")
1112 (defvar gnus-article-treat-custom
1113 '(choice (const :tag
"Off" nil
)
1115 (const :tag
"Header" head
)
1116 (const :tag
"First" first
)
1117 (const :tag
"Last" last
)
1118 (integer :tag
"Less")
1119 (repeat :tag
"Groups" regexp
)
1120 (sexp :tag
"Predicate")))
1122 (defvar gnus-article-treat-head-custom
1123 '(choice (const :tag
"Off" nil
)
1124 (const :tag
"Header" head
)))
1126 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1127 "text/x-patch" "text/html")
1128 "Part types eligible for treatment.")
1130 (defvar gnus-inhibit-treatment nil
1131 "Whether to inhibit treatment.")
1133 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1134 "Highlight the signature.
1135 Valid values are nil, t, `head', `first', `last', an integer or a
1136 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group
'gnus-article-treat
1138 :link
'(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom
)
1140 (put 'gnus-treat-highlight-signature
'highlight t
)
1142 (defcustom gnus-treat-buttonize
100000
1144 Valid values are nil, t, `head', `first', `last', an integer or a
1145 predicate. See Info node `(gnus)Customizing Articles'."
1146 :group
'gnus-article-treat
1147 :link
'(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom
)
1149 (put 'gnus-treat-buttonize
'highlight t
)
1151 (defcustom gnus-treat-buttonize-head
'head
1152 "Add buttons to the head.
1153 Valid values are nil, t, `head', `first', `last', an integer or a
1154 predicate. See Info node `(gnus)Customizing Articles'."
1155 :group
'gnus-article-treat
1156 :link
'(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-head-custom
)
1158 (put 'gnus-treat-buttonize-head
'highlight t
)
1160 (defcustom gnus-treat-date
'head
1161 "Display dates according to the `gnus-article-date-headers' variable.
1162 Valid values are nil, t, `head', `first', `last', an integer or a
1163 predicate. See Info node `(gnus)Customizing Articles'."
1165 :group
'gnus-article-treat
1166 :link
'(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-head-custom
)
1169 (defcustom gnus-treat-emphasize
50000
1171 Valid values are nil, t, `head', `first', `last', an integer or a
1172 predicate. See Info node `(gnus)Customizing Articles'."
1173 :group
'gnus-article-treat
1174 :link
'(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-custom
)
1176 (put 'gnus-treat-emphasize
'highlight t
)
1178 (defcustom gnus-treat-strip-cr nil
1179 "Remove carriage returns.
1180 Valid values are nil, t, `head', `first', `last', an integer or a
1181 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group
'gnus-article-treat
1184 :link
'(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom
)
1187 (defcustom gnus-treat-unsplit-urls nil
1188 "Remove newlines from within URLs.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1192 :group
'gnus-article-treat
1193 :link
'(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-custom
)
1196 (defcustom gnus-treat-leading-whitespace nil
1197 "Remove leading whitespace in headers.
1198 Valid values are nil, t, `head', `first', `last', an integer or a
1199 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group
'gnus-article-treat
1202 :link
'(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom
)
1205 (defcustom gnus-treat-hide-headers
'head
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group
'gnus-article-treat
1210 :link
'(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom
)
1213 (defcustom gnus-treat-hide-boring-headers nil
1214 "Hide boring headers.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1217 :group
'gnus-article-treat
1218 :link
'(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-head-custom
)
1221 (defcustom gnus-treat-hide-signature nil
1222 "Hide the signature.
1223 Valid values are nil, t, `head', `first', `last', an integer or a
1224 predicate. See Info node `(gnus)Customizing Articles'."
1225 :group
'gnus-article-treat
1226 :link
'(custom-manual "(gnus)Customizing Articles")
1227 :type gnus-article-treat-custom
)
1229 (defcustom gnus-treat-fill-article nil
1231 Valid values are nil, t, `head', `first', `last', an integer or a
1232 predicate. See Info node `(gnus)Customizing Articles'."
1233 :group
'gnus-article-treat
1234 :link
'(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom
)
1237 (defcustom gnus-treat-hide-citation nil
1239 Valid values are nil, t, `head', `first', `last', an integer or a
1240 predicate. See Info node `(gnus)Customizing Articles'.
1242 See `gnus-article-highlight-citation' for variables used to
1243 control what it hides."
1244 :group
'gnus-article-treat
1245 :link
'(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom
)
1248 (defcustom gnus-treat-hide-citation-maybe nil
1249 "Hide cited text according to certain conditions.
1250 Valid values are nil, t, `head', `first', `last', an integer or a
1251 predicate. See Info node `(gnus)Customizing Articles'.
1253 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1254 how to control what it hides."
1255 :group
'gnus-article-treat
1256 :link
'(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom
)
1259 (defcustom gnus-treat-strip-list-identifiers
'head
1260 "Strip list identifiers from `gnus-list-identifiers`.
1261 Valid values are nil, t, `head', `first', `last', an integer or a
1262 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group
'gnus-article-treat
1265 :link
'(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom
)
1268 (gnus-define-group-parameter
1271 "Alist of regexps and correspondent identifiers."
1272 :variable-group gnus-article-washing
1274 '(choice :tag
"Identifier"
1276 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1278 (const :tag
"None" nil
))
1280 "If non-nil, specify how to remove `identifiers' from articles' subject.
1282 Any symbol is used to look up a regular expression to match the
1283 banner in `gnus-list-identifiers'. A string is used as a regular
1284 expression to match the identifier directly.")
1286 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1287 "Gnus 5.10 (Emacs 22.1)")
1289 (defcustom gnus-treat-strip-pem nil
1290 "Strip PEM signatures.
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1293 :group
'gnus-article-treat
1294 :link
'(custom-manual "(gnus)Customizing Articles")
1295 :type gnus-article-treat-custom
)
1297 (defcustom gnus-treat-strip-banner t
1298 "Strip banners from articles.
1299 The banner to be stripped is specified in the `banner' group parameter.
1300 Valid values are nil, t, `head', `first', `last', an integer or a
1301 predicate. See Info node `(gnus)Customizing Articles'."
1302 :group
'gnus-article-treat
1303 :link
'(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom
)
1306 (defcustom gnus-treat-highlight-headers
'head
1307 "Highlight the headers.
1308 Valid values are nil, t, `head', `first', `last', an integer or a
1309 predicate. See Info node `(gnus)Customizing Articles'."
1310 :group
'gnus-article-treat
1311 :link
'(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-head-custom
)
1313 (put 'gnus-treat-highlight-headers
'highlight t
)
1315 (defcustom gnus-treat-highlight-citation t
1316 "Highlight cited text.
1317 Valid values are nil, t, `head', `first', `last', an integer or a
1318 predicate. See Info node `(gnus)Customizing Articles'."
1319 :group
'gnus-article-treat
1320 :link
'(custom-manual "(gnus)Customizing Articles")
1321 :type gnus-article-treat-custom
)
1322 (put 'gnus-treat-highlight-citation
'highlight t
)
1324 (defcustom gnus-treat-strip-headers-in-body t
1325 "Strip the X-No-Archive header line from the beginning of the body.
1326 Valid values are nil, t, `head', `first', `last', an integer or a
1327 predicate. See Info node `(gnus)Customizing Articles'."
1329 :group
'gnus-article-treat
1330 :link
'(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom
)
1333 (defcustom gnus-treat-strip-trailing-blank-lines nil
1334 "Strip trailing 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 Consider to use `last' instead."
1340 :group
'gnus-article-treat
1341 :link
'(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom
)
1344 (defcustom gnus-treat-strip-leading-blank-lines nil
1345 "Strip leading blank lines.
1346 Valid values are nil, t, `head', `first', `last', an integer or a
1347 predicate. See Info node `(gnus)Customizing Articles'.
1349 When set to t, it also strips trailing blanks in all MIME parts."
1350 :group
'gnus-article-treat
1351 :link
'(custom-manual "(gnus)Customizing Articles")
1352 :type gnus-article-treat-custom
)
1354 (defcustom gnus-treat-strip-multiple-blank-lines nil
1355 "Strip multiple blank lines.
1356 Valid values are nil, t, `head', `first', `last', an integer or a
1357 predicate. See Info node `(gnus)Customizing Articles'."
1358 :group
'gnus-article-treat
1359 :link
'(custom-manual "(gnus)Customizing Articles")
1360 :type gnus-article-treat-custom
)
1362 (defcustom gnus-treat-unfold-headers
'head
1363 "Unfold folded header lines.
1364 Valid values are nil, t, `head', `first', `last', an integer or a
1365 predicate. See Info node `(gnus)Customizing Articles'."
1367 :group
'gnus-article-treat
1368 :link
'(custom-manual "(gnus)Customizing Articles")
1369 :type gnus-article-treat-custom
)
1371 (defcustom gnus-article-unfold-long-headers nil
1372 "If non-nil, allow unfolding headers even if the header is long.
1373 If it is a regexp, only long headers matching this regexp are unfolded.
1374 If it is t, all long headers are unfolded.
1376 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1377 :version
"23.1" ;; No Gnus
1378 :group
'gnus-article-treat
1379 :type
'(choice (const nil
)
1380 (const :tag
"all" t
)
1383 (defcustom gnus-treat-fold-headers nil
1385 Valid values are nil, t, `head', `first', `last', an integer or a
1386 predicate. See Info node `(gnus)Customizing Articles'."
1388 :group
'gnus-article-treat
1389 :link
'(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom
)
1392 (defcustom gnus-treat-fold-newsgroups
'head
1393 "Fold the Newsgroups and Followup-To headers.
1394 Valid values are nil, t, `head', `first', `last', an integer or a
1395 predicate. See Info node `(gnus)Customizing Articles'."
1397 :group
'gnus-article-treat
1398 :link
'(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom
)
1401 (defcustom gnus-treat-overstrike t
1402 "Treat overstrike highlighting.
1403 Valid values are nil, t, `head', `first', `last', an integer or a
1404 predicate. See Info node `(gnus)Customizing Articles'."
1405 :group
'gnus-article-treat
1406 :link
'(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom
)
1408 (put 'gnus-treat-overstrike
'highlight t
)
1410 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1411 "Treat ANSI SGR control sequences.
1412 Valid values are nil, t, `head', `first', `last', an integer or a
1413 predicate. See Info node `(gnus)Customizing Articles'."
1414 :group
'gnus-article-treat
1415 :link
'(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom
)
1418 (make-obsolete-variable 'gnus-treat-display-xface
1419 'gnus-treat-display-x-face
"Emacs 22.1")
1421 (defcustom gnus-treat-display-x-face
1422 (and (not noninteractive
)
1423 (gnus-image-type-available-p 'xbm
)
1424 (if (featurep 'xemacs
)
1427 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1428 (executable-find "icontopbm"))
1429 ;; shell-command-to-string may signal an error, e.g. if
1430 ;; shell-file-name is not found.
1433 "Display X-Face headers.
1434 Valid values are nil and `head'.
1435 See Info node `(gnus)Customizing Articles' and Info node
1436 `(gnus)X-Face' for details."
1437 :group
'gnus-article-treat
1439 :link
'(custom-manual "(gnus)Customizing Articles")
1440 :link
'(custom-manual "(gnus)X-Face")
1441 :type gnus-article-treat-head-custom
1442 :set
(lambda (symbol value
)
1445 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1447 ((boundp 'gnus-treat-display-xface
)
1449 ** gnus-treat-display-xface is an obsolete variable;\
1450 use gnus-treat-display-x-face instead")
1451 (default-value 'gnus-treat-display-xface
))
1452 ((get 'gnus-treat-display-xface
'saved-value
)
1454 ** gnus-treat-display-xface is an obsolete variable;\
1455 use gnus-treat-display-x-face instead")
1456 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1459 (put 'gnus-treat-display-x-face
'highlight t
)
1461 (defcustom gnus-treat-display-face
1462 (and (not noninteractive
)
1463 (gnus-image-type-available-p 'png
)
1465 "Display Face headers.
1466 Valid values are nil, t, `head', `first', `last', an integer or a
1467 predicate. See Info node `(gnus)Customizing Articles' and Info
1468 node `(gnus)Face' for details."
1469 :group
'gnus-article-treat
1471 :link
'(custom-manual "(gnus)Customizing Articles")
1472 :link
'(custom-manual "(gnus)X-Face")
1473 :type gnus-article-treat-head-custom
)
1474 (put 'gnus-treat-display-face
'highlight t
)
1476 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1478 Valid values are nil, t, `head', `first', `last', an integer or a
1479 predicate. See Info node `(gnus)Customizing Articles' and Info
1480 node `(gnus)Smileys' for details."
1481 :group
'gnus-article-treat
1483 :link
'(custom-manual "(gnus)Customizing Articles")
1484 :link
'(custom-manual "(gnus)Smileys")
1485 :type gnus-article-treat-custom
)
1486 (put 'gnus-treat-display-smileys
'highlight t
)
1488 (defcustom gnus-treat-from-picon
1489 (if (and (gnus-image-type-available-p 'xpm
)
1490 (gnus-picons-installed-p))
1492 "Display picons in the From header.
1493 Valid values are nil, t, `head', `first', `last', an integer or a
1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1495 node `(gnus)Picons' for details."
1497 :group
'gnus-article-treat
1499 :link
'(custom-manual "(gnus)Customizing Articles")
1500 :link
'(custom-manual "(gnus)Picons")
1501 :type gnus-article-treat-head-custom
)
1502 (put 'gnus-treat-from-picon
'highlight t
)
1504 (defcustom gnus-treat-mail-picon
1505 (if (and (gnus-image-type-available-p 'xpm
)
1506 (gnus-picons-installed-p))
1508 "Display picons in To and Cc headers.
1509 Valid values are nil, t, `head', `first', `last', an integer or a
1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1511 node `(gnus)Picons' for details."
1513 :group
'gnus-article-treat
1515 :link
'(custom-manual "(gnus)Customizing Articles")
1516 :link
'(custom-manual "(gnus)Picons")
1517 :type gnus-article-treat-head-custom
)
1518 (put 'gnus-treat-mail-picon
'highlight t
)
1520 (defcustom gnus-treat-newsgroups-picon
1521 (if (and (gnus-image-type-available-p 'xpm
)
1522 (gnus-picons-installed-p))
1524 "Display picons in the Newsgroups and Followup-To headers.
1525 Valid values are nil, t, `head', `first', `last', an integer or a
1526 predicate. See Info node `(gnus)Customizing Articles' and Info
1527 node `(gnus)Picons' for details."
1529 :group
'gnus-article-treat
1531 :link
'(custom-manual "(gnus)Customizing Articles")
1532 :link
'(custom-manual "(gnus)Picons")
1533 :type gnus-article-treat-head-custom
)
1534 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1536 (defcustom gnus-treat-from-gravatar nil
1537 "Display gravatars in the From header.
1538 Valid values are nil, t, `head', `first', `last', an integer or a
1539 predicate. See Info node `(gnus)Customizing Articles' and Info
1540 node `(gnus)Gravatars' for details."
1542 :group
'gnus-article-treat
1543 :group
'gnus-gravatar
1544 :link
'(custom-manual "(gnus)Customizing Articles")
1545 :link
'(custom-manual "(gnus)Gravatars")
1546 :type gnus-article-treat-head-custom
)
1547 (put 'gnus-treat-from-gravatar
'highlight t
)
1549 (defcustom gnus-treat-mail-gravatar nil
1550 "Display gravatars in To and Cc headers.
1551 Valid values are nil, t, `head', `first', `last', an integer or a
1552 predicate. See Info node `(gnus)Customizing Articles' and Info
1553 node `(gnus)Gravatars' for details."
1555 :group
'gnus-article-treat
1556 :group
'gnus-gravatar
1557 :link
'(custom-manual "(gnus)Customizing Articles")
1558 :link
'(custom-manual "(gnus)Gravatars")
1559 :type gnus-article-treat-head-custom
)
1560 (put 'gnus-treat-mail-gravatar
'highlight t
)
1562 (defcustom gnus-treat-body-boundary
1563 (if (or gnus-treat-newsgroups-picon
1564 gnus-treat-mail-picon
1565 gnus-treat-from-picon
1566 gnus-treat-from-gravatar
1567 gnus-treat-mail-gravatar
)
1568 ;; If there's much decoration, the user might prefer a boundary.
1571 "Draw a boundary at the end of the headers.
1572 Valid values are nil and `head'.
1573 See Info node `(gnus)Customizing Articles' for details."
1575 :group
'gnus-article-treat
1576 :link
'(custom-manual "(gnus)Customizing Articles")
1577 :type gnus-article-treat-head-custom
)
1579 (defcustom gnus-treat-capitalize-sentences nil
1580 "Capitalize sentence-starting words.
1581 Valid values are nil, t, `head', `first', `last', an integer or a
1582 predicate. See Info node `(gnus)Customizing Articles'."
1584 :group
'gnus-article-treat
1585 :link
'(custom-manual "(gnus)Customizing Articles")
1586 :type gnus-article-treat-custom
)
1588 (defcustom gnus-treat-wash-html nil
1590 Valid values are nil, t, `head', `first', `last', an integer or a
1591 predicate. See Info node `(gnus)Customizing Articles'."
1593 :group
'gnus-article-treat
1594 :link
'(custom-manual "(gnus)Customizing Articles")
1595 :type gnus-article-treat-custom
)
1597 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1599 Valid values are nil, t, `head', `first', `last', an integer or a
1600 predicate. See Info node `(gnus)Customizing Articles'."
1602 :group
'gnus-article-treat
1603 :link
'(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom
)
1606 (defcustom gnus-treat-x-pgp-sig nil
1608 To automatically treat X-PGP-Sig, set it to head.
1609 Valid values are nil, t, `head', `first', `last', an integer or a
1610 predicate. See Info node `(gnus)Customizing Articles'."
1612 :group
'gnus-article-treat
1613 :group
'mime-security
1614 :link
'(custom-manual "(gnus)Customizing Articles")
1615 :type gnus-article-treat-custom
)
1617 (defvar gnus-article-encrypt-protocol-alist
1618 '(("PGP" . mml2015-self-encrypt
)))
1620 ;; Set to nil if more than one protocol added to
1621 ;; gnus-article-encrypt-protocol-alist.
1622 (defcustom gnus-article-encrypt-protocol
"PGP"
1623 "The protocol used for encrypt articles.
1624 It is a string, such as \"PGP\". If nil, ask user."
1627 :group
'mime-security
)
1629 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1630 (mm-coding-system-p 'utf-8
)
1631 (executable-find idna-program
))
1632 "Whether IDNA decoding of headers is used when viewing messages.
1633 This requires GNU Libidn, and by default only enabled if it is found."
1635 :group
'gnus-article-headers
1638 (defcustom gnus-article-over-scroll nil
1639 "If non-nil, allow scrolling the article buffer even when there no more text."
1641 :group
'gnus-article
1644 (defcustom gnus-inhibit-images nil
1645 "Non-nil means inhibit displaying of images inline in the article body."
1647 :group
'gnus-article
1650 (defcustom gnus-blocked-images
'gnus-block-private-groups
1651 "Images that have URLs matching this regexp will be blocked.
1652 This can also be a function to be evaluated. If so, it will be
1653 called with the group name as the parameter, and should return a
1657 :type
'(choice regexp function
))
1659 ;;; Internal variables
1661 (defvar gnus-english-month-names
1662 '("January" "February" "March" "April" "May" "June" "July" "August"
1663 "September" "October" "November" "December"))
1665 (defvar article-goto-body-goes-to-point-min-p nil
)
1666 (defvar gnus-article-wash-types nil
)
1667 (defvar gnus-article-emphasis-alist nil
)
1668 (defvar gnus-article-image-alist nil
)
1670 (defvar gnus-article-mime-handle-alist-1 nil
)
1671 (defvar gnus-treatment-function-alist
1672 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1673 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1674 (gnus-treat-strip-banner gnus-article-strip-banner
)
1675 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1676 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1677 (gnus-treat-buttonize gnus-article-add-buttons
)
1678 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1679 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1680 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1681 (gnus-treat-display-x-face gnus-article-display-x-face
)
1682 (gnus-treat-display-face gnus-article-display-face
)
1683 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1684 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1685 (gnus-treat-hide-signature gnus-article-hide-signature
)
1686 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1687 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1688 (gnus-treat-from-picon gnus-treat-from-picon
)
1689 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1690 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1691 (gnus-treat-strip-pem gnus-article-hide-pem
)
1692 (gnus-treat-date gnus-article-treat-date
)
1693 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1694 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1695 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1696 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1697 (gnus-treat-strip-trailing-blank-lines
1698 gnus-article-remove-trailing-blank-lines
)
1699 (gnus-treat-strip-leading-blank-lines
1700 gnus-article-strip-leading-blank-lines
)
1701 (gnus-treat-strip-multiple-blank-lines
1702 gnus-article-strip-multiple-blank-lines
)
1703 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1704 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1705 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1706 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1707 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1708 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1709 (gnus-treat-display-smileys gnus-treat-smiley
)
1710 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1711 (gnus-treat-wash-html gnus-article-wash-html
)
1712 (gnus-treat-emphasize gnus-article-emphasize
)
1713 (gnus-treat-hide-citation gnus-article-hide-citation
)
1714 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1715 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1716 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1718 (defvar gnus-article-mime-handle-alist nil
)
1719 (defvar article-lapsed-timer nil
)
1720 (defvar gnus-article-current-summary nil
)
1722 (defvar gnus-article-mode-syntax-table
1723 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1724 ;; This causes the citation match run O(2^n).
1725 ;; (modify-syntax-entry ?- "w" table)
1726 (modify-syntax-entry ?
> ")<" table
)
1727 (modify-syntax-entry ?
< "(>" table
)
1728 ;; make M-. in article buffers work for `foo' strings
1729 (modify-syntax-entry ?
' " " table
)
1730 (modify-syntax-entry ?
` " " table
)
1732 "Syntax table used in article mode buffers.
1733 Initialized from `text-mode-syntax-table.")
1735 (defvar gnus-save-article-buffer nil
)
1737 (defvar gnus-number-of-articles-to-be-saved nil
)
1739 (defvar gnus-inhibit-hiding nil
)
1741 (defvar gnus-article-edit-mode nil
)
1743 ;;; Macros for dealing with the article buffer.
1745 (defmacro gnus-with-article-headers
(&rest forms
)
1746 `(with-current-buffer gnus-article-buffer
1748 (let ((inhibit-read-only t
)
1749 (inhibit-point-motion-hooks t
)
1750 (case-fold-search t
))
1751 (article-narrow-to-head)
1754 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1755 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1757 (defmacro gnus-with-article-buffer
(&rest forms
)
1758 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1759 (with-current-buffer gnus-article-buffer
1760 (let ((inhibit-read-only t
))
1763 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1764 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1766 (defun gnus-article-goto-header (header)
1767 "Go to HEADER, which is a regular expression."
1768 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1770 (defsubst gnus-article-hide-text
(b e props
)
1771 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1772 (gnus-add-text-properties-when 'article-type nil b e props
)
1773 (when (memq 'intangible props
)
1775 (max (1- b
) (point-min))
1776 b
'intangible
(cddr (memq 'intangible props
)))))
1778 (defsubst gnus-article-unhide-text
(b e
)
1779 "Remove hidden text properties from region between B and E."
1780 (remove-text-properties b e gnus-hidden-properties
)
1781 (when (memq 'intangible gnus-hidden-properties
)
1782 (put-text-property (max (1- b
) (point-min))
1783 b
'intangible nil
)))
1785 (defun gnus-article-hide-text-type (b e type
)
1786 "Hide text of TYPE between B and E."
1787 (gnus-add-wash-type type
)
1788 (gnus-article-hide-text
1789 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1791 (defun gnus-article-unhide-text-type (b e type
)
1792 "Unhide text of TYPE between B and E."
1793 (gnus-delete-wash-type type
)
1794 (remove-text-properties
1795 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1796 (when (memq 'intangible gnus-hidden-properties
)
1797 (put-text-property (max (1- b
) (point-min))
1798 b
'intangible nil
)))
1800 (defun gnus-article-delete-text-of-type (type)
1801 "Delete text of TYPE in the current buffer."
1803 (let ((b (point-min)))
1804 (if (eq type
'multipart
)
1805 ;; Remove MIME buttons associated with multipart/alternative parts.
1808 (while (if (get-text-property (point) 'gnus-part
)
1810 (when (setq b
(next-single-property-change (point)
1815 (skip-chars-forward "\n")
1816 (when (eq (get-text-property b
'article-type
) 'multipart
)
1817 (delete-region b
(point)))))
1818 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1820 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1823 (defun gnus-article-delete-invisible-text ()
1824 "Delete all invisible text in the current buffer."
1826 (let ((b (point-min)))
1827 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1829 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1832 (defsubst gnus-article-header-rank
()
1833 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1834 (let ((list gnus-sorted-header-list
)
1837 (if (looking-at (car list
))
1839 (setq list
(cdr list
))
1843 (defun article-hide-headers (&optional arg delete
)
1844 "Hide unwanted headers and possibly sort them as well."
1846 ;; This function might be inhibited.
1847 (unless gnus-inhibit-hiding
1848 (let ((inhibit-read-only t
)
1849 (case-fold-search t
)
1850 (max (1+ (length gnus-sorted-header-list
)))
1851 (inhibit-point-motion-hooks t
)
1852 (cur (current-buffer))
1853 ignored visible beg
)
1855 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1856 ;; group parameters, so we should go to the summary buffer.
1859 (progn (set-buffer gnus-summary-buffer
) t
)
1861 (setq ignored
(when (not gnus-visible-headers
)
1862 (cond ((stringp gnus-ignored-headers
)
1863 gnus-ignored-headers
)
1864 ((listp gnus-ignored-headers
)
1865 (mapconcat 'identity
1866 gnus-ignored-headers
1868 visible
(cond ((stringp gnus-visible-headers
)
1869 gnus-visible-headers
)
1870 ((and gnus-visible-headers
1871 (listp gnus-visible-headers
))
1872 (mapconcat 'identity
1873 gnus-visible-headers
1877 ;; First we narrow to just the headers.
1878 (article-narrow-to-head)
1879 ;; Hide any "From " lines at the beginning of (mail) articles.
1880 (while (looking-at "From ")
1883 (delete-region (point-min) (point)))
1884 ;; Then treat the rest of the header lines.
1885 ;; Then we use the two regular expressions
1886 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1887 ;; select which header lines is to remain visible in the
1889 (while (re-search-forward "^[^ \t:]*:" nil t
)
1891 ;; Mark the rank of the header.
1893 (point) (1+ (point)) 'message-rank
1894 (if (or (and visible
(looking-at visible
))
1896 (not (looking-at ignored
))))
1897 (gnus-article-header-rank)
1900 (message-sort-headers-1)
1901 (when (setq beg
(text-property-any
1902 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1903 ;; We delete the unwanted headers.
1904 (gnus-add-wash-type 'headers
)
1905 (add-text-properties (point-min) (+ 5 (point-min))
1906 '(article-type headers dummy-invisible t
))
1907 (delete-region beg
(point-max))))))))
1909 (defun article-hide-boring-headers (&optional arg
)
1910 "Toggle hiding of headers that aren't very interesting.
1911 If given a negative prefix, always show; if given a positive prefix,
1913 (interactive (gnus-article-hidden-arg))
1914 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1915 (not gnus-show-all-headers
))
1918 (let ((inhibit-read-only t
)
1919 (inhibit-point-motion-hooks t
))
1920 (article-narrow-to-head)
1921 (dolist (elem gnus-boring-article-headers
)
1922 (goto-char (point-min))
1924 ;; Hide empty headers.
1926 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1928 (gnus-article-hide-text-type
1932 (if (re-search-forward "^[^ \t]" nil t
)
1936 ;; Hide boring Newsgroups header.
1937 ((eq elem
'newsgroups
)
1938 (when (gnus-string-equal
1939 (gnus-fetch-field "newsgroups")
1940 (gnus-group-real-name
1941 (if (boundp 'gnus-newsgroup-name
)
1944 (gnus-article-hide-header "newsgroups")))
1945 ((eq elem
'to-address
)
1946 (let ((to (message-fetch-field "to"))
1948 (gnus-parameter-to-address
1949 (if (boundp 'gnus-newsgroup-name
)
1950 gnus-newsgroup-name
""))))
1951 (when (and to to-address
1954 ;; only one address in To
1955 (nth 1 (mail-extract-address-components to
))
1957 (gnus-article-hide-header "to"))))
1959 (let ((to (message-fetch-field "to"))
1961 (gnus-parameter-to-list
1962 (if (boundp 'gnus-newsgroup-name
)
1963 gnus-newsgroup-name
""))))
1964 (when (and to to-list
1967 ;; only one address in To
1968 (nth 1 (mail-extract-address-components to
))
1970 (gnus-article-hide-header "to"))))
1972 (let ((cc (message-fetch-field "cc"))
1974 (gnus-parameter-to-list
1975 (if (boundp 'gnus-newsgroup-name
)
1976 gnus-newsgroup-name
""))))
1977 (when (and cc to-list
1980 ;; only one address in CC
1981 (nth 1 (mail-extract-address-components cc
))
1983 (gnus-article-hide-header "cc"))))
1984 ((eq elem
'followup-to
)
1985 (when (gnus-string-equal
1986 (message-fetch-field "followup-to")
1987 (message-fetch-field "newsgroups"))
1988 (gnus-article-hide-header "followup-to")))
1989 ((eq elem
'reply-to
)
1990 (if (gnus-group-find-parameter
1991 gnus-newsgroup-name
'broken-reply-to
)
1992 (gnus-article-hide-header "reply-to")
1993 (let ((from (message-fetch-field "from"))
1994 (reply-to (message-fetch-field "reply-to")))
2001 (lambda (x) (downcase (cadr x
)))
2002 (mail-extract-address-components from t
))
2005 (lambda (x) (downcase (cadr x
)))
2006 (mail-extract-address-components reply-to t
))
2008 (gnus-article-hide-header "reply-to")))))
2010 (let ((date (with-current-buffer gnus-original-article-buffer
2011 ;; If date in `gnus-article-buffer' is localized
2012 ;; (`gnus-treat-date-user-defined'),
2013 ;; `days-between' might fail.
2014 (message-fetch-field "date"))))
2016 (< (days-between (current-time-string) date
)
2018 (gnus-article-hide-header "date"))))
2020 (let ((to (message-fetch-field "to"))
2021 (cc (message-fetch-field "cc")))
2022 (when (> (length to
) 1024)
2023 (gnus-article-hide-header "to"))
2024 (when (> (length cc
) 1024)
2025 (gnus-article-hide-header "cc"))))
2029 (goto-char (point-min))
2030 (while (re-search-forward "^to:" nil t
)
2031 (setq to-count
(1+ to-count
)))
2032 (when (> to-count
1)
2033 (while (> to-count
0)
2034 (goto-char (point-min))
2036 (re-search-forward "^to:" nil nil to-count
)
2038 (narrow-to-region (point) (point-max))
2039 (gnus-article-hide-header "to"))
2040 (setq to-count
(1- to-count
))))
2041 (goto-char (point-min))
2042 (while (re-search-forward "^cc:" nil t
)
2043 (setq cc-count
(1+ cc-count
)))
2044 (when (> cc-count
1)
2045 (while (> cc-count
0)
2046 (goto-char (point-min))
2048 (re-search-forward "^cc:" nil nil cc-count
)
2050 (narrow-to-region (point) (point-max))
2051 (gnus-article-hide-header "cc"))
2052 (setq cc-count
(1- cc-count
)))))))))))))
2054 (defun gnus-article-hide-header (header)
2056 (goto-char (point-min))
2057 (when (re-search-forward (concat "^" header
":") nil t
)
2058 (gnus-article-hide-text-type
2062 (if (re-search-forward "^[^ \t]" nil t
)
2067 (defvar gnus-article-normalized-header-length
40
2068 "Length of normalized headers.")
2070 (defun article-normalize-headers ()
2071 "Make all header lines 40 characters long."
2073 (let ((inhibit-read-only t
)
2077 (article-narrow-to-head)
2080 ((< (setq column
(- (point-at-eol) (point)))
2081 gnus-article-normalized-header-length
)
2083 (insert (make-string
2084 (- gnus-article-normalized-header-length column
)
2086 ((> column gnus-article-normalized-header-length
)
2087 (gnus-put-text-property
2089 (forward-char gnus-article-normalized-header-length
)
2096 (forward-line 1))))))
2098 (defun article-treat-dumbquotes ()
2099 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2100 Note that this function guesses whether a character is a sm*rtq**t* or
2101 not, so it should only be used interactively.
2103 Sm*rtq**t*s are M****s***'s unilateral extension to the
2104 iso-8859-1 character map in an attempt to provide more quoting
2105 characters. If you see something like \\222 or \\264 where
2106 you're expecting some kind of apostrophe or quotation mark, then
2109 (article-translate-strings gnus-article-dumbquotes-map
))
2111 (defvar org-entities
)
2113 (defun article-treat-non-ascii ()
2114 "Translate many Unicode characters into their ASCII equivalents."
2116 (require 'org-entities
)
2117 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2118 (dolist (elem org-entities
)
2119 (when (and (listp elem
)
2120 (= (length (nth 6 elem
)) 1))
2121 (if (featurep 'xemacs
)
2122 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2123 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2125 (when (article-goto-body)
2126 (let ((inhibit-read-only t
)
2129 (if (not (setq replace
(if (featurep 'xemacs
)
2130 (get-char-table (following-char) table
)
2131 (aref table
(following-char)))))
2134 (setq props
(text-properties-at (point)))
2136 (add-text-properties (point) (progn (insert replace
) (point))
2138 (insert replace
)))))))))
2140 (defun article-translate-strings (map)
2141 "Translate all string in the body of the article according to MAP.
2142 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2144 (when (article-goto-body)
2145 (let ((inhibit-read-only t
))
2147 (let ((from (car elem
))
2151 (while (search-forward from nil t
)
2154 (if (eq (following-char) from
)
2158 (forward-char 1)))))))))))
2160 (defun article-treat-overstrike ()
2161 "Translate overstrikes into bold text."
2164 (when (article-goto-body)
2165 (let ((inhibit-read-only t
))
2166 (while (search-forward "\b" nil t
)
2167 (let ((next (char-after))
2168 (previous (char-after (- (point) 2))))
2169 ;; We do the boldification/underlining by hiding the
2170 ;; overstrikes and putting the proper text property
2174 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2175 (put-text-property (point) (1+ (point)) 'face
'bold
))
2177 (gnus-article-hide-text-type
2178 (1- (point)) (1+ (point)) 'overstrike
)
2180 (- (point) 2) (1- (point)) 'face
'underline
))
2182 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2184 (point) (1+ (point)) 'face
'underline
)))))))))
2186 (defun article-treat-ansi-sequences ()
2187 "Translate ANSI SGR control sequences into overlays or extents."
2190 (when (article-goto-body)
2191 (let ((inhibit-read-only t
))
2192 (ansi-color-apply-on-region (point) (point-max))))))
2194 (defun gnus-article-treat-unfold-headers ()
2195 "Unfold folded message headers.
2196 Only the headers that fit into the current window width will be
2199 (gnus-with-article-headers
2203 (mail-header-narrow-to-field)
2204 (let* ((header (buffer-string))
2206 (or (equal gnus-article-unfold-long-headers t
)
2207 (and (stringp gnus-article-unfold-long-headers
)
2208 (string-match gnus-article-unfold-long-headers
2212 (goto-char (point-min))
2213 (while (re-search-forward "\n[\t ]" nil t
)
2214 (replace-match " " t t
)))
2215 (setq length
(- (point-max) (point-min) 1))
2216 (when (or unfoldable
2217 (< length
(window-width)))
2218 (while (re-search-forward "\n[\t ]" nil t
)
2219 (replace-match " " t t
))))
2220 (goto-char (point-max)))))))
2222 (defun gnus-article-treat-fold-headers ()
2223 "Fold message headers."
2225 (gnus-with-article-headers
2228 (mail-header-narrow-to-field)
2229 (mail-header-fold-field)
2230 (goto-char (point-max))))))
2232 (defun gnus-treat-smiley ()
2233 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2235 (gnus-with-article-buffer
2236 (if (memq 'smiley gnus-article-wash-types
)
2237 (gnus-delete-images 'smiley
)
2239 (let ((images (smiley-region (point) (point-max))))
2241 (gnus-add-wash-type 'smiley
)
2242 (dolist (image images
)
2243 (gnus-add-image 'smiley image
)))))))
2245 (defun gnus-article-remove-images ()
2246 "Remove all images from the article buffer."
2248 (gnus-with-article-buffer
2251 (dolist (elem gnus-article-image-alist
)
2252 (gnus-delete-images (car elem
))))))
2254 (autoload 'w3m-toggle-inline-images
"w3m")
2256 (defun gnus-article-show-images ()
2257 "Show any images that are in the HTML-rendered article buffer.
2258 This only works if the article in question is HTML."
2260 (gnus-with-article-buffer
2263 (if (eq mm-text-html-renderer
'w3m
)
2264 (let ((mm-inline-text-html-with-images nil
))
2265 (w3m-toggle-inline-images))
2266 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2268 (destructuring-bind (start end function
) region
2269 (funcall function
(get-text-property start
'image-url
)
2272 (defun gnus-article-treat-fold-newsgroups ()
2273 "Unfold folded message headers.
2274 Only the headers that fit into the current window width will be
2277 (gnus-with-article-headers
2278 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2280 (mail-header-narrow-to-field)
2281 (while (re-search-forward ", *" nil t
)
2282 (replace-match ", " t t
))
2283 (mail-header-fold-field)
2284 (goto-char (point-max))))))
2286 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2287 "Value of `truncate-lines' in Gnus Article buffer.
2288 Valid values are nil, t, `head', `first', `last', an integer or a
2289 predicate. See Info node `(gnus)Customizing Articles'."
2290 :version
"23.1" ;; No Gnus
2291 :group
'gnus-article
2292 ;; :link '(custom-manual "(gnus)Customizing Articles")
2295 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2296 "Toggle whether to fold or truncate long lines in article the buffer.
2297 If ARG is non-nil and not a number, toggle
2298 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2299 long lines if and only if arg is positive."
2302 ((and (numberp arg
) (> arg
0))
2303 (setq gnus-article-truncate-lines t
))
2305 (setq gnus-article-truncate-lines nil
))
2307 (setq gnus-article-truncate-lines
2308 (not gnus-article-truncate-lines
))))
2309 (gnus-with-article-buffer
2311 ((and (numberp arg
) (> arg
0))
2312 (setq truncate-lines nil
))
2314 (setq truncate-lines t
)))
2315 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2316 ;; `toggle-truncate-lines' needs an argument.
2317 (toggle-truncate-lines)))
2319 (defun gnus-article-treat-body-boundary ()
2320 "Place a boundary line at the end of the headers."
2322 (when (and gnus-body-boundary-delimiter
2323 (> (length gnus-body-boundary-delimiter
) 0))
2324 (gnus-with-article-headers
2325 (goto-char (point-max))
2326 (let ((start (point)))
2327 (insert "X-Boundary: ")
2328 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2329 (insert (let (str (max (window-width)))
2330 (if (featurep 'xemacs
)
2331 (setq max
(1- max
)))
2332 (while (>= max
(length str
))
2333 (setq str
(concat str gnus-body-boundary-delimiter
)))
2334 (substring str
0 max
))
2336 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2338 (defun article-fill-long-lines ()
2339 "Fill lines that are wider than the window width."
2342 (let ((inhibit-read-only t
)
2343 (width (window-width (get-buffer-window (current-buffer)))))
2346 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2349 (when (>= (current-column) (min fill-column width
))
2350 (narrow-to-region (min (1+ (point)) (point-max))
2352 (let ((goback (point-marker)))
2353 (fill-paragraph nil
)
2354 (goto-char (marker-position goback
)))
2356 (forward-line 1)))))))
2358 (defun article-capitalize-sentences ()
2359 "Capitalize the first word in each sentence."
2362 (let ((inhibit-read-only t
)
2363 (paragraph-start "^[\n\^L]"))
2367 (forward-sentence)))))
2369 (defun article-remove-cr ()
2370 "Remove trailing CRs and then translate remaining CRs into LFs."
2373 (let ((inhibit-read-only t
))
2374 (goto-char (point-min))
2375 (while (re-search-forward "\r+$" nil t
)
2376 (replace-match "" t t
))
2377 (goto-char (point-min))
2378 (while (search-forward "\r" nil t
)
2379 (replace-match "\n" t t
)))))
2381 (defun article-remove-trailing-blank-lines ()
2382 "Remove all trailing blank lines from the article."
2385 (let ((inhibit-read-only t
))
2386 (goto-char (point-max))
2390 (while (and (not (bobp))
2391 (looking-at "^[ \t]*$")
2392 (not (gnus-annotation-in-region-p
2393 (point) (point-at-eol))))
2398 (defvar gnus-face-properties-alist
)
2400 (defun article-display-face (&optional force
)
2401 "Display any Face headers in the header."
2402 (interactive (list 'force
))
2403 (let ((wash-face-p buffer-read-only
))
2404 (gnus-with-article-headers
2405 ;; When displaying parts, this function can be called several times on
2406 ;; the same article, without any intended toggle semantic (as typing `W
2407 ;; D d' would have). So face deletion must occur only when we come from
2408 ;; an interactive command, that is when the *Article* buffer is
2410 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2411 (gnus-delete-images 'face
)
2412 (let ((from (message-fetch-field "from"))
2414 (save-current-buffer
2415 (when (and wash-face-p
2416 (gnus-buffer-live-p gnus-original-article-buffer
)
2417 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2418 (set-buffer gnus-original-article-buffer
))
2420 (mail-narrow-to-head)
2422 ;; Check whether this face is censored.
2423 (not (and gnus-article-x-face-too-ugly
2425 (setq from
(message-fetch-field "from")))
2426 (string-match gnus-article-x-face-too-ugly
2428 (while (gnus-article-goto-header "Face")
2429 (push (mail-header-field-value) faces
)))))
2431 (goto-char (point-min))
2433 (unless (setq from
(gnus-article-goto-header "from"))
2436 (insert " [no `from' set]\n"))
2438 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2440 (apply 'gnus-create-image png
'png t
2441 (cdr (assq 'png gnus-face-properties-alist
))))
2444 (gnus-add-wash-type 'face
)
2445 (gnus-add-image 'face image
)
2446 (gnus-put-image image nil
'face
)))))))))))
2448 (defun article-display-x-face (&optional force
)
2449 "Look for an X-Face header and display it if present."
2450 (interactive (list 'force
))
2451 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2452 (gnus-with-article-headers
2453 ;; Delete the old process, if any.
2454 (when (process-status "article-x-face")
2455 (delete-process "article-x-face"))
2456 ;; See the comment in `article-display-face'.
2457 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2458 ;; We have already displayed X-Faces, so we remove them
2460 (gnus-delete-images 'xface
)
2462 (let ((from (message-fetch-field "from"))
2464 (save-current-buffer
2465 (when (and wash-face-p
2466 (gnus-buffer-live-p gnus-original-article-buffer
)
2467 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2468 ;; If type `W f', use gnus-original-article-buffer,
2469 ;; otherwise use the current buffer because displaying
2470 ;; RFC822 parts calls this function too.
2471 (set-buffer gnus-original-article-buffer
))
2473 (mail-narrow-to-head)
2474 (and gnus-article-x-face-command
2476 ;; Check whether this face is censored.
2477 (not (and gnus-article-x-face-too-ugly
2479 (setq from
(message-fetch-field "from")))
2480 (string-match gnus-article-x-face-too-ugly
2482 (while (gnus-article-goto-header "X-Face")
2483 (push (mail-header-field-value) x-faces
)))))
2485 ;; We display the face.
2486 (cond ((functionp gnus-article-x-face-command
)
2487 ;; The command is a lisp function, so we call it.
2488 (mapc gnus-article-x-face-command x-faces
))
2489 ((stringp gnus-article-x-face-command
)
2490 ;; The command is a string, so we interpret the command
2491 ;; as a, well, command, and fork it off.
2492 (let ((process-connection-type nil
))
2493 (gnus-set-process-query-on-exit-flag
2495 "article-x-face" nil shell-file-name
2496 shell-command-switch gnus-article-x-face-command
)
2498 ;; Sending multiple EOFs to xv doesn't work,
2499 ;; so we only do a single external face.
2501 (insert (car x-faces
))
2502 (process-send-region "article-x-face"
2503 (point-min) (point-max)))
2504 (process-send-eof "article-x-face")))
2506 (error "`%s' set to `%s' is not a function"
2507 gnus-article-x-face-command
2508 'gnus-article-x-face-command
)))))))))
2510 (defun article-decode-mime-words ()
2511 "Decode all MIME-encoded words in the article."
2513 (gnus-with-article-buffer
2514 (let ((inhibit-point-motion-hooks t
)
2515 (mail-parse-charset gnus-newsgroup-charset
)
2516 (mail-parse-ignored-charsets
2517 (with-current-buffer gnus-summary-buffer
2518 gnus-newsgroup-ignored-charsets
)))
2519 (mail-decode-encoded-word-region (point-min) (point-max)))))
2521 (defun article-decode-charset (&optional prompt
)
2522 "Decode charset-encoded text in the article.
2523 If PROMPT (the prefix), prompt for a coding system to use."
2525 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2526 (inhibit-read-only t
)
2527 (mail-parse-charset gnus-newsgroup-charset
)
2528 (mail-parse-ignored-charsets
2529 (save-excursion (condition-case nil
2530 (set-buffer gnus-summary-buffer
)
2532 gnus-newsgroup-ignored-charsets
))
2533 ct cte ctl charset format
)
2536 (article-narrow-to-head)
2537 (setq ct
(message-fetch-field "Content-Type" t
)
2538 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2539 ctl
(and ct
(mail-header-parse-content-type ct
))
2542 (mm-read-coding-system "Charset to decode: "))
2544 (mail-content-type-get ctl
'charset
)))
2545 format
(and ctl
(mail-content-type-get ctl
'format
)))
2547 (setq cte
(mail-header-strip cte
)))
2548 (if (and ctl
(not (string-match "/" (car ctl
))))
2550 (goto-char (point-max)))
2553 (narrow-to-region (point) (point-max))
2554 (when (and (eq mail-parse-charset
'gnus-decoded
)
2555 (eq (mm-body-7-or-8) '8bit
))
2556 ;; The text code could have been decoded.
2557 (setq charset mail-parse-charset
))
2558 (when (and (or (not ctl
)
2559 (equal (car ctl
) "text/plain"))
2560 (not format
)) ;; article with format will decode later.
2562 charset
(and cte
(intern (downcase
2563 (gnus-strip-whitespace cte
))))
2566 (defun article-decode-encoded-words ()
2567 "Remove encoded-word encoding from headers."
2568 (let ((inhibit-point-motion-hooks t
)
2569 (mail-parse-charset gnus-newsgroup-charset
)
2570 (mail-parse-ignored-charsets
2571 (save-excursion (condition-case nil
2572 (set-buffer gnus-summary-buffer
)
2574 gnus-newsgroup-ignored-charsets
))
2575 (inhibit-read-only t
)
2577 (goto-char (point-min))
2578 (when (search-forward "\n\n" nil
'move
)
2585 (memq (char-after) '(?
\t ?
)))))
2586 (setq start
(point))
2588 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2589 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2590 (funcall gnus-decode-address-function start end
)
2591 (funcall gnus-decode-header-function start end
))
2592 (goto-char (setq end start
)))))
2594 (defun article-decode-group-name ()
2595 "Decode group names in Newsgroups, Followup-To and Xref headers."
2596 (let ((inhibit-point-motion-hooks t
)
2597 (inhibit-read-only t
)
2598 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2600 (when (and (or gnus-group-name-charset-method-alist
2601 gnus-group-name-charset-group-alist
)
2602 (gnus-buffer-live-p gnus-original-article-buffer
))
2604 (article-narrow-to-head)
2605 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2606 (with-current-buffer gnus-original-article-buffer
2607 (goto-char (point-min)))
2608 (setq regexp
(concat "^" header
2609 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2610 (while (re-search-forward regexp nil t
)
2611 (replace-match (save-match-data
2612 (gnus-decode-newsgroups
2613 ;; XXX how to use data in article buffer?
2614 (with-current-buffer gnus-original-article-buffer
2615 (re-search-forward regexp nil t
)
2617 gnus-newsgroup-name method
))
2619 (goto-char (point-min)))))))
2621 (autoload 'idna-to-unicode
"idna")
2623 (defun article-decode-idna-rhs ()
2624 "Decode IDNA strings in RHS in various headers in current buffer.
2625 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2626 Mail-Reply-To: and Mail-Followup-To:."
2629 (let ((inhibit-point-motion-hooks t
)
2630 (inhibit-read-only t
))
2631 (article-narrow-to-head)
2632 (goto-char (point-min))
2633 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2635 (when (save-match-data
2636 (and (setq ace
(match-string 1))
2638 (and (re-search-backward "^[^ \t]" nil t
)
2639 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2640 (setq unicode
(idna-to-unicode ace
))))
2641 (unless (string= ace unicode
)
2642 (replace-match unicode nil nil nil
1)))))))))
2644 (defun article-de-quoted-unreadable (&optional force read-charset
)
2645 "Translate a quoted-printable-encoded article.
2646 If FORCE, decode the article whether it is marked as quoted-printable
2648 If READ-CHARSET, ask for a coding system."
2649 (interactive (list 'force current-prefix-arg
))
2651 (let ((inhibit-read-only t
) type charset
)
2652 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2653 (with-current-buffer gnus-original-article-buffer
2655 (gnus-fetch-field "content-transfer-encoding"))
2656 (let* ((ct (gnus-fetch-field "content-type"))
2657 (ctl (and ct
(mail-header-parse-content-type ct
))))
2658 (setq charset
(and ctl
2659 (mail-content-type-get ctl
'charset
)))
2660 (if (stringp charset
)
2661 (setq charset
(intern (downcase charset
)))))))
2663 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2665 (setq charset gnus-newsgroup-charset
))
2667 (and type
(let ((case-fold-search t
))
2668 (string-match "quoted-printable" type
))))
2670 (quoted-printable-decode-region
2671 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2673 (defun article-de-base64-unreadable (&optional force read-charset
)
2674 "Translate a base64 article.
2675 If FORCE, decode the article whether it is marked as base64 not.
2676 If READ-CHARSET, ask for a coding system."
2677 (interactive (list 'force current-prefix-arg
))
2679 (let ((inhibit-read-only t
) type charset
)
2680 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2681 (with-current-buffer gnus-original-article-buffer
2683 (gnus-fetch-field "content-transfer-encoding"))
2684 (let* ((ct (gnus-fetch-field "content-type"))
2685 (ctl (and ct
(mail-header-parse-content-type ct
))))
2686 (setq charset
(and ctl
2687 (mail-content-type-get ctl
'charset
)))
2688 (if (stringp charset
)
2689 (setq charset
(intern (downcase charset
)))))))
2691 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2693 (setq charset gnus-newsgroup-charset
))
2695 (and type
(let ((case-fold-search t
))
2696 (string-match "base64" type
))))
2699 (narrow-to-region (point) (point-max))
2700 (base64-decode-region (point-min) (point-max))
2701 (mm-decode-coding-region
2702 (point-min) (point-max)
2703 (mm-charset-to-coding-system charset nil t
)))))))
2708 (defun article-decode-HZ ()
2709 "Translate a HZ-encoded article."
2713 (let ((inhibit-read-only t
))
2714 (rfc1843-decode-region (point-min) (point-max)))))
2716 (defun article-unsplit-urls ()
2717 "Remove the newlines that some other mailers insert into URLs."
2720 (let ((inhibit-read-only t
))
2721 (goto-char (point-min))
2722 (while (re-search-forward
2723 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2724 (replace-match "\\1\\3" t
)))
2725 (when (gmm-called-interactively-p 'any
)
2726 (gnus-treat-article nil
))))
2728 (defun article-wash-html ()
2729 "Format an HTML article."
2732 (buffer-read-only nil
))
2733 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2734 (with-current-buffer gnus-original-article-buffer
2735 (setq handles
(mm-dissect-buffer t t
))))
2737 (delete-region (point) (point-max))
2738 (mm-enable-multibyte)
2739 (mm-inline-text-html handles
)))
2741 (defvar gnus-article-browse-html-temp-list nil
2742 "List of temporary files created by `gnus-article-browse-html-parts'.
2743 Internal variable.")
2745 (defcustom gnus-article-browse-delete-temp
'ask
2746 "What to do with temporary files from `gnus-article-browse-html-parts'.
2747 If nil, don't delete temporary files. If it is t, delete them on
2748 exit from the summary buffer. If it is the symbol `file', query
2749 on each file, if it is `ask' ask once when exiting from the
2751 :group
'gnus-article
2752 :version
"23.1" ;; No Gnus
2753 :type
'(choice (const :tag
"Don't delete" nil
)
2754 (const :tag
"Don't ask" t
)
2755 (const :tag
"Ask" ask
)
2756 (const :tag
"Ask for each file" file
)))
2758 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2760 (defun gnus-article-browse-delete-temp-files (&optional how
)
2761 "Delete temp-files created by `gnus-article-browse-html-parts'."
2762 (when (and gnus-article-browse-html-temp-list
2764 (or how
(setq how gnus-article-browse-delete-temp
))
2766 (let ((files (length gnus-article-browse-html-temp-list
)))
2769 "Delete the temporary HTML file? "
2770 (format "Delete all %s temporary HTML files? "
2772 (setq gnus-article-browse-html-temp-list nil
)))
2774 (dolist (file gnus-article-browse-html-temp-list
)
2775 (cond ((file-directory-p file
)
2776 (when (or (not (eq how
'file
))
2779 "Delete temporary HTML file(s) in directory `%s'? "
2780 (file-name-as-directory file
))))
2781 (gnus-delete-directory file
)))
2782 ((file-exists-p file
)
2783 (when (or (not (eq how
'file
))
2785 (format "Delete temporary HTML file `%s'? " file
)))
2786 (delete-file file
)))))
2787 ;; Also remove file from the list when not deleted or if file doesn't
2789 (setq gnus-article-browse-html-temp-list nil
))
2790 gnus-article-browse-html-temp-list
)
2792 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2793 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2798 (dolist (handle handles
)
2800 ((not (listp handle
)))
2801 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2803 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2804 ((equal (mm-handle-media-supertype handle
) "multipart")
2805 (when (setq file
(gnus-article-browse-html-save-cid-content
2806 cid handle directory
))
2807 (throw 'found file
)))
2808 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2811 (or (mm-handle-filename handle
)
2813 (make-temp-name "cid")
2814 (car (rassoc (car (mm-handle-type handle
))
2815 mailcap-mime-extensions
))))
2817 (mm-save-part-to-file handle file
)
2818 (throw 'found file
))))))))
2820 (defun gnus-article-browse-html-parts (list &optional header
)
2821 "View all \"text/html\" parts from LIST.
2822 Recurse into multiparts. The optional HEADER that should be a decoded
2823 message header will be added to the bodies of the \"text/html\" parts."
2824 ;; Internal function used by `gnus-article-browse-html-article'.
2825 (let (type file charset content cid-dir tmp-file showed
)
2826 ;; Find and show the html-parts.
2827 (dolist (handle list
)
2828 ;; If HTML, show it:
2829 (cond ((not (listp handle
)))
2830 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2831 (and (equal (car type
) "message/external-body")
2833 (setq file
(mm-handle-filename handle
)))
2834 (or (mm-handle-cache handle
)
2835 (condition-case code
2836 (progn (mm-extern-cache-contents handle
) t
)
2838 (gnus-message 3 "%s" (error-message-string code
))
2839 (when (>= gnus-verbose
3) (sit-for 2))
2842 (setq handle
(mm-handle-cache handle
)
2843 type
(mm-handle-type handle
))
2844 (equal (car type
) "text/html"))))
2845 (setq charset
(mail-content-type-get type
'charset
)
2846 content
(mm-get-part handle
))
2848 (if (eq charset
'gnus-decoded
)
2849 (mm-enable-multibyte)
2850 (mm-disable-multibyte))
2852 ;; resolve cid contents
2853 (let ((case-fold-search t
)
2855 (goto-char (point-min))
2856 (while (re-search-forward "\
2857 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2860 (setq cid-dir
(mm-make-temp-file "cid" t
))
2861 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2864 (when (setq cid-file
2865 (gnus-article-browse-html-save-cid-content
2867 (with-current-buffer gnus-article-buffer
2868 gnus-article-mime-handles
)
2870 (when (eq system-type
'cygwin
)
2872 (concat "/" (substring
2873 (with-output-to-string
2874 (call-process "cygpath" nil
2878 (replace-match (concat "file://" cid-file
)
2880 (unless content
(setq content
(buffer-string))))
2881 (when (or charset header
(not file
))
2882 (setq tmp-file
(mm-make-temp-file
2883 ;; Do we need to care for 8.3 filenames?
2884 "mm-" nil
".html")))
2885 ;; Add a meta html tag to specify charset and a header.
2888 (let (title eheader body hcharset coding
)
2890 (mm-enable-multibyte)
2891 (setq case-fold-search t
)
2892 (insert header
"\n")
2893 (setq title
(message-fetch-field "subject"))
2894 (goto-char (point-min))
2895 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2897 (replace-match (cond ((match-beginning 1) "<")
2898 ((match-beginning 2) ">")
2899 ((match-beginning 3) "&")
2901 (goto-char (point-min))
2902 (while (re-search-forward "^[\t ]+" nil t
)
2905 (delete-region (match-beginning 0)
2908 (goto-char (point-min))
2909 (insert "<div align=\"left\">\n")
2910 (goto-char (point-max))
2911 (insert "</div>\n<hr>\n")
2912 ;; We have to examine charset one by one since
2913 ;; charset specified in parts might be different.
2914 (if (eq charset
'gnus-decoded
)
2915 (setq charset
'utf-8
2916 eheader
(mm-encode-coding-string (buffer-string)
2919 (mm-encode-coding-string title charset
))
2920 body
(mm-encode-coding-string content charset
))
2921 (setq hcharset
(mm-find-mime-charset-region (point-min)
2923 (cond ((= (length hcharset
) 1)
2924 (setq hcharset
(car hcharset
)
2925 coding
(mm-charset-to-coding-system
2927 ((> (length hcharset
) 1)
2928 (setq hcharset
'utf-8
2934 (mm-charset-to-coding-system charset
2936 (if (eq coding body
)
2937 (setq eheader
(mm-encode-coding-string
2938 (buffer-string) coding
)
2940 (mm-encode-coding-string
2943 (setq charset
'utf-8
2944 eheader
(mm-encode-coding-string
2945 (buffer-string) charset
)
2947 (mm-encode-coding-string
2949 body
(mm-encode-coding-string
2950 (mm-decode-coding-string
2953 (setq charset hcharset
2954 eheader
(mm-encode-coding-string
2955 (buffer-string) coding
)
2957 (mm-encode-coding-string
2960 (setq eheader
(mm-string-as-unibyte (buffer-string))
2963 (mm-disable-multibyte)
2966 (mm-add-meta-html-tag handle charset t
))
2968 (goto-char (point-min))
2969 (unless (search-forward "<title>" nil t
)
2970 (re-search-forward "<head>\\s-*" nil t
)
2971 (insert "<title>" title
"</title>\n")))
2972 (goto-char (point-min))
2973 (or (re-search-forward
2974 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2976 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2978 (mm-write-region (point-min) (point-max)
2979 tmp-file nil nil nil
'binary t
))))
2981 (mm-with-unibyte-buffer
2982 (insert (if (eq charset
'gnus-decoded
)
2983 (mm-encode-coding-string content
2984 (setq charset
'utf-8
))
2986 (if (or (mm-add-meta-html-tag handle charset
)
2988 (mm-write-region (point-min) (point-max)
2989 tmp-file nil nil nil
'binary t
)
2990 (setq tmp-file nil
))))
2992 (mm-save-part-to-file handle tmp-file
)))
2994 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2995 (add-hook 'gnus-summary-prepare-exit-hook
2996 'gnus-article-browse-delete-temp-files
)
2997 (add-hook 'gnus-exit-gnus-hook
2999 (gnus-article-browse-delete-temp-files t
)))
3000 ;; FIXME: Warn if there's an <img> tag?
3001 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
3003 ;; If multipart, recurse
3004 ((equal (mm-handle-media-supertype handle
) "multipart")
3005 (when (gnus-article-browse-html-parts handle header
)
3007 ((equal (mm-handle-media-type handle
) "message/rfc822")
3008 (mm-with-multibyte-buffer
3009 (mm-insert-part handle
)
3010 (setq handle
(mm-dissect-buffer t t
))
3011 (when (and (bufferp (car handle
))
3012 (stringp (car (mm-handle-type handle
))))
3013 (setq handle
(list handle
)))
3015 (article-decode-encoded-words)
3016 (let ((gnus-visible-headers
3017 (or (get 'gnus-visible-headers
'standard-value
)
3018 gnus-visible-headers
)))
3019 (article-hide-headers))
3020 (goto-char (point-min))
3021 (search-forward "\n\n" nil
'move
)
3022 (skip-chars-backward "\t\n ")
3023 (setq header
(buffer-substring (point-min) (point)))))
3025 (gnus-article-browse-html-parts handle header
)
3026 (mm-destroy-parts handle
))
3030 (defun gnus-article-browse-html-article (&optional arg
)
3031 "View \"text/html\" parts of the current article with a WWW browser.
3032 Inline images embedded in a message using the cid scheme, as they are
3033 generally considered to be safe, will be processed properly.
3034 The message header is added to the beginning of every html part unless
3035 the prefix argument ARG is given.
3037 Warning: Spammers use links to images (using the http scheme) in HTML
3038 articles to verify whether you have read the message. As
3039 `gnus-article-browse-html-article' passes the HTML content to the
3040 browser without eliminating these \"web bugs\" you should only
3041 use it for mails from trusted senders.
3043 If you always want to display HTML parts in the browser, set
3044 `mm-text-html-renderer' to nil.
3046 This command creates temporary files to pass HTML contents including
3047 images if any to the browser, and deletes them when exiting the group
3049 ;; Cf. `mm-w3m-safe-url-regexp'
3052 (gnus-summary-show-article)
3053 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3054 gnus-visible-headers
))
3055 ;; As we insert a <hr>, there's no need for the body boundary.
3056 (gnus-treat-body-boundary nil
))
3057 (gnus-summary-show-article)))
3058 (with-current-buffer gnus-article-buffer
3059 (let ((header (unless arg
3062 (buffer-substring-no-properties
3063 (goto-char (point-min))
3064 (if (search-forward "\n\n" nil t
)
3066 (goto-char (point-max))
3067 (skip-chars-backward "\t\n ")
3070 (set-buffer gnus-original-article-buffer
)
3071 (setq parts
(mm-dissect-buffer t t
))
3072 ;; If singlepart, enforce a list.
3073 (when (and (bufferp (car parts
))
3074 (stringp (car (mm-handle-type parts
))))
3075 (setq parts
(list parts
)))
3077 (unless (gnus-article-browse-html-parts parts header
)
3078 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3079 (mm-destroy-parts parts
)
3081 (gnus-summary-show-article)))))
3083 (defun article-hide-list-identifiers ()
3084 "Remove list identifies from the Subject header.
3085 The `gnus-list-identifiers' variable specifies what to do."
3087 (let ((inhibit-point-motion-hooks t
)
3088 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3089 (inhibit-read-only t
))
3093 (article-narrow-to-head)
3094 (goto-char (point-min))
3095 (while (re-search-forward
3096 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3098 (delete-region (match-beginning 2) (match-end 0))
3099 (beginning-of-line))
3100 (when (re-search-forward
3101 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3102 (delete-region (match-beginning 1) (match-end 1))))))))
3104 (defun article-hide-pem (&optional arg
)
3105 "Toggle hiding of any PEM headers and signatures in the current article.
3106 If given a negative prefix, always show; if given a positive prefix,
3108 (interactive (gnus-article-hidden-arg))
3109 (unless (gnus-article-check-hidden-text 'pem arg
)
3111 (let ((inhibit-read-only t
) end
)
3112 (goto-char (point-min))
3113 ;; Hide the horrendously ugly "header".
3114 (when (and (search-forward
3115 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3117 (setq end
(1+ (match-beginning 0))))
3118 (gnus-add-wash-type 'pem
)
3119 (gnus-article-hide-text-type
3121 (if (search-forward "\n\n" nil t
)
3125 ;; Hide the trailer as well
3126 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3128 (gnus-article-hide-text-type
3129 (match-beginning 0) (match-end 0) 'pem
)))))))
3131 (defun article-strip-banner ()
3132 "Strip the banners specified by the `banner' group parameter and by
3133 `gnus-article-address-banner-alist'."
3137 (let ((inhibit-point-motion-hooks t
))
3138 (when (gnus-parameter-banner gnus-newsgroup-name
)
3139 (article-really-strip-banner
3140 (gnus-parameter-banner gnus-newsgroup-name
)))
3141 (when gnus-article-address-banner-alist
3142 ;; Note that the From header is decoded here, so it is
3143 ;; required that the *-extract-address-components function
3144 ;; supports non-ASCII text.
3145 (let ((from (save-restriction
3147 (article-narrow-to-head)
3148 (mail-fetch-field "from"))))
3151 (cadr (funcall gnus-extract-address-components
3154 (dolist (pair gnus-article-address-banner-alist
)
3155 (when (string-match (car pair
) from
)
3157 (article-really-strip-banner (cdr pair
)))))))))))))
3159 (defun article-really-strip-banner (banner)
3160 "Strip the banner specified by the argument."
3163 (let ((inhibit-point-motion-hooks t
)
3164 (gnus-signature-limit nil
)
3165 (inhibit-read-only t
))
3168 ((eq banner
'signature
)
3169 (when (gnus-article-narrow-to-signature)
3172 (delete-region (point) (point-max))))
3174 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3175 (while (re-search-forward banner nil t
)
3176 (delete-region (match-beginning 0) (match-end 0)))))
3178 (while (re-search-forward banner nil t
)
3179 (delete-region (match-beginning 0) (match-end 0)))))))))
3181 (defun article-babel ()
3182 "Translate article using an online translation service."
3185 (gnus-with-article-buffer
3186 (when (article-goto-body)
3187 (let* ((start (point))
3189 (orig (buffer-substring start end
))
3190 (trans (babel-as-string orig
)))
3192 (narrow-to-region start end
)
3193 (delete-region start end
)
3196 (defun article-hide-signature (&optional arg
)
3197 "Hide the signature in the current article.
3198 If given a negative prefix, always show; if given a positive prefix,
3200 (interactive (gnus-article-hidden-arg))
3201 (unless (gnus-article-check-hidden-text 'signature arg
)
3204 (let ((inhibit-read-only t
))
3205 (when (gnus-article-narrow-to-signature)
3206 (gnus-article-hide-text-type
3207 (point-min) (point-max) 'signature
))))))
3208 (gnus-set-mode-line 'article
))
3210 (defun article-strip-headers-in-body ()
3211 "Strip offensive headers from bodies."
3215 (let ((case-fold-search t
))
3216 (when (looking-at "x-no-archive:")
3217 (gnus-delete-line)))))
3219 (defun article-strip-leading-blank-lines ()
3220 "Remove all blank lines from the beginning of the article."
3223 (let ((inhibit-point-motion-hooks t
)
3224 (inhibit-read-only t
))
3225 (when (article-goto-body)
3226 (while (and (not (eobp))
3227 (looking-at "[ \t]*$"))
3228 (gnus-delete-line))))))
3230 (defun article-narrow-to-head ()
3231 "Narrow the buffer to the head of the message.
3232 Point is left at the beginning of the narrowed-to region."
3234 (goto-char (point-min))
3236 ;; Absolutely no headers displayed.
3240 ((search-forward "\n\n" nil
1)
3242 ;; Nothing but headers.
3245 (goto-char (point-min)))
3247 (defun article-goto-body ()
3248 "Place point at the start of the body."
3249 (goto-char (point-min))
3251 ;; This variable is only bound when dealing with separate
3253 (article-goto-body-goes-to-point-min-p
3255 ((search-forward "\n\n" nil t
)
3258 (goto-char (point-max))
3261 (defun article-strip-multiple-blank-lines ()
3262 "Replace consecutive blank lines with one empty line."
3265 (let ((inhibit-point-motion-hooks t
)
3266 (inhibit-read-only t
))
3267 ;; First make all blank lines empty.
3269 (while (re-search-forward "^[ \t]+$" nil t
)
3270 (unless (gnus-annotation-in-region-p
3271 (match-beginning 0) (match-end 0))
3272 (replace-match "" nil t
)))
3273 ;; Then replace multiple empty lines with a single empty line.
3275 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3276 (unless (gnus-annotation-in-region-p
3277 (match-beginning 0) (match-end 0))
3278 (delete-region (match-beginning 1) (match-end 1)))))))
3280 (defun article-strip-leading-space ()
3281 "Remove all white space from the beginning of the lines in the article."
3284 (let ((inhibit-point-motion-hooks t
)
3285 (inhibit-read-only t
))
3287 (while (re-search-forward "^[ \t]+" nil t
)
3288 (replace-match "" t t
)))))
3290 (defun article-strip-trailing-space ()
3291 "Remove all white space from the end of the lines in the article."
3294 (let ((inhibit-point-motion-hooks t
)
3295 (inhibit-read-only t
))
3297 (while (re-search-forward "[ \t]+$" nil t
)
3298 (replace-match "" t t
)))))
3300 (defun article-strip-blank-lines ()
3301 "Strip leading, trailing and multiple blank lines."
3303 (article-strip-leading-blank-lines)
3304 (article-remove-trailing-blank-lines)
3305 (article-strip-multiple-blank-lines))
3307 (defun article-strip-all-blank-lines ()
3308 "Strip all blank lines."
3311 (let ((inhibit-point-motion-hooks t
)
3312 (inhibit-read-only t
))
3314 (while (re-search-forward "^[ \t]*\n" nil t
)
3315 (replace-match "" t t
)))))
3317 (defun gnus-article-narrow-to-signature ()
3318 "Narrow to the signature; return t if a signature is found, else nil."
3319 (let ((inhibit-point-motion-hooks t
))
3320 (when (gnus-article-search-signature)
3322 ;; Check whether we have some limits to what we consider
3323 ;; to be a signature.
3324 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3325 (list gnus-signature-limit
)))
3327 (while (setq limit
(pop limits
))
3328 (if (or (and (integerp limit
)
3329 (< (- (point-max) (point)) limit
))
3331 (< (count-lines (point) (point-max)) limit
))
3332 (and (functionp limit
)
3334 (and (stringp limit
)
3335 (not (re-search-forward limit nil t
))))
3336 () ; This limit did not succeed.
3340 (narrow-to-region (point) (point-max))
3343 (defun gnus-article-search-signature ()
3344 "Search the current buffer for the signature separator.
3345 Put point at the beginning of the signature separator."
3346 (let ((cur (point)))
3347 (goto-char (point-max))
3348 (if (if (stringp gnus-signature-separator
)
3349 (re-search-backward gnus-signature-separator nil t
)
3350 (let ((seps gnus-signature-separator
))
3352 (not (re-search-backward (car seps
) nil t
)))
3359 (defun gnus-article-hidden-arg ()
3360 "Return the current prefix arg as a number, or 0 if no prefix."
3361 (list (if current-prefix-arg
3362 (prefix-numeric-value current-prefix-arg
)
3365 (defun gnus-article-check-hidden-text (type arg
)
3366 "Return nil if hiding is necessary.
3367 Arg can be nil or a number. nil and positive means hide, negative
3368 means show, 0 means toggle."
3371 (let ((hide (gnus-article-hidden-text-p type
)))
3377 (gnus-article-show-hidden-text type
)
3380 (if (eq hide
'hidden
)
3382 (gnus-article-show-hidden-text type
)
3386 (defun gnus-article-hidden-text-p (type)
3387 "Say whether the current buffer contains hidden text of type TYPE."
3388 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3390 (not (get-text-property pos
'invisible
))
3391 (not (get-text-property pos
'dummy-invisible
)))
3393 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3398 (defun gnus-article-show-hidden-text (type &optional dummy
)
3399 "Show all hidden text of type TYPE.
3400 Originally it is hide instead of DUMMY."
3401 (let ((inhibit-read-only t
)
3402 (inhibit-point-motion-hooks t
))
3403 (gnus-remove-text-properties-when
3405 (point-min) (point-max)
3406 (cons 'article-type
(cons type
3407 gnus-hidden-properties
)))
3408 (gnus-delete-wash-type type
)))
3410 (defconst article-time-units
3411 `((year .
,(* 365.25 24 60 60))
3412 (week .
,(* 7 24 60 60))
3413 (day .
,(* 24 60 60))
3417 "Mapping from time units to seconds.")
3419 (defun gnus-article-forward-header ()
3420 "Move point to the start of the next header.
3421 If the current header is a continuation header, this can be several
3426 (if (looking-at "[ \t]+[^ \t]")
3430 (defun article-treat-date ()
3431 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3432 (with-current-buffer gnus-summary-buffer
3433 gnus-article-date-headers
)
3434 gnus-article-date-headers
)
3437 (defun article-date-ut (&optional type highlight date-position
)
3438 "Convert DATE date to TYPE in the current article.
3439 The default type is `ut'. See `gnus-article-date-headers' for
3441 (interactive (list 'ut t
))
3442 (let* ((case-fold-search t
)
3443 (inhibit-read-only t
)
3444 (inhibit-point-motion-hooks t
)
3446 (visible-date (mail-fetch-field "Date"))
3447 pos date bface eface
)
3451 (goto-char date-position
)
3452 (setq date
(get-text-property (point) 'original-date
))
3453 (when (looking-at "[^:]+:[\t ]*")
3454 (setq bface
(get-text-property (match-beginning 0) 'face
)
3455 eface
(get-text-property (match-end 0) 'face
)))
3456 (delete-region (point)
3458 (gnus-article-forward-header)
3460 (article-transform-date date type bface eface
))
3463 (goto-char (point-min))
3464 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3465 (and (setq pos
(next-single-property-change
3466 (point) 'original-date
))
3468 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3469 (1+ (match-beginning 0))
3471 (while (setq pos
(text-property-not-all pos
(point-max)
3472 'gnus-date-type nil
))
3473 (setq date
(get-text-property pos
'original-date
))
3475 (when (looking-at "[^:]+:[\t ]*")
3476 (setq bface
(get-text-property (match-beginning 0) 'face
)
3477 eface
(get-text-property (match-end 0) 'face
)))
3478 (delete-region pos
(or (text-property-any pos
(point-max)
3479 'gnus-date-type nil
)
3481 (unless date
;; the 1st time
3482 (goto-char (point-min))
3483 (while (re-search-forward "^Date:[\t ]*" nil t
)
3484 (setq date
(get-text-property (match-beginning 0)
3486 bface
(get-text-property (match-beginning 0) 'face
)
3487 eface
(get-text-property (match-end 0) 'face
))
3488 (delete-region (point-at-bol) (progn
3489 (gnus-article-forward-header)
3491 (when (and (not date
)
3493 (setq date visible-date
))
3495 (article-transform-date date type bface eface
))
3496 (goto-char (point-max))
3499 (defun article-transform-date (date type bface eface
)
3500 (dolist (this-type (cond
3510 (add-text-properties
3513 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3515 (list 'original-date date
'gnus-date-type this-type
))))
3518 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3519 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3520 (when (match-beginning 2)
3521 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3522 (while (and (zerop (forward-line 1))
3523 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3524 (when (match-beginning 1)
3525 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3527 (defun article-make-date-line (date type
)
3528 "Return a DATE line of TYPE."
3529 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3531 (error "Unknown conversion type: %s" type
))
3533 (let ((time (ignore-errors (date-to-time date
))))
3535 ;; Convert to the local timezone.
3537 (concat "Date: " (message-make-date time
)))
3538 ;; Convert to Universal Time.
3543 (let* ((e (parse-time-string date
))
3544 (tm (apply 'encode-time e
))
3546 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3547 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3548 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3552 ;; Get the original date from the article.
3553 ((eq type
'original
)
3554 (concat "Date: " (if (string-match "\n+$" date
)
3555 (substring date
0 (match-beginning 0))
3557 ;; Let the user define the format.
3558 ((eq type
'user-defined
)
3559 (let ((format (or (condition-case nil
3560 (with-current-buffer gnus-summary-buffer
3561 gnus-article-time-format
)
3563 gnus-article-time-format
)))
3564 (if (functionp format
)
3565 (funcall format time
)
3566 (concat "Date: " (format-time-string format time
)))))
3569 (let ((tz (car (current-time-zone time
))))
3572 (format-time-string "%Y%m%dT%H%M%S" time
)
3573 (format "%s%02d%02d"
3574 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3575 (/ (%
(abs tz
) 3600) 60)))))
3576 ;; Do a lapsed format.
3578 (concat "Date: " (article-lapsed-string time
)))
3579 ;; A combined date/lapsed format.
3580 ((eq type
'combined-lapsed
)
3581 (let ((date-string (article-make-date-line date
'original
))
3587 (concat " (" (article-lapsed-string time segments
) ")"))
3588 (> (+ (length date-string
)
3589 (length lapsed-string
))
3592 (setq segments
(1- segments
)))
3594 (concat date-string lapsed-string
)
3596 ;; Display the date in proper English
3598 (let ((dtime (decode-time time
)))
3601 (number-to-string (nth 3 dtime
))
3602 (let ((digit (%
(nth 3 dtime
) 10)))
3604 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3610 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3612 (number-to-string (nth 5 dtime
))
3614 (format "%02d" (nth 2 dtime
))
3616 (format "%02d" (nth 1 dtime
)))))))
3618 (format "Date: %s (from Gnus)" date
))))
3620 (defun article-lapsed-string (time &optional max-segments
)
3621 ;; If the date is seriously mangled, the timezone functions are
3622 ;; liable to bug out, so we ignore all errors.
3623 (let* ((now (current-time))
3624 (real-time (subtract-time now time
))
3625 (real-sec (and real-time
3626 (+ (* (float (car real-time
)) 65536)
3628 (sec (and real-time
(abs real-sec
)))
3631 (unless max-segments
3632 (setq max-segments
(length article-time-units
)))
3640 ;; This is a bit convoluted, but basically we go
3641 ;; through the time units for years, weeks, etc,
3642 ;; and divide things to see whether that results
3643 ;; in positive answers.
3646 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3647 (>= segments max-segments
))
3648 ;; The (remaining) seconds are too few to
3649 ;; be divided into this time unit.
3651 ;; It's big enough, so we output it.
3652 (setq sec
(- sec
(* num
(cdr unit
))))
3654 (concat (if prev
", " "") (int-to-string
3656 " " (symbol-name (car unit
))
3657 (if (> num
1) "s" ""))
3659 segments
(1+ segments
)))))
3660 article-time-units
"")
3661 ;; If dates are odd, then it might appear like the
3662 ;; article was sent in the future.
3665 " in the future"))))))
3667 (defun article-date-local (&optional highlight
)
3668 "Convert the current article date to the local timezone."
3669 (interactive (list t
))
3670 (article-date-ut 'local highlight
))
3672 (defun article-date-english (&optional highlight
)
3673 "Convert the current article date to something that is proper English."
3674 (interactive (list t
))
3675 (article-date-ut 'english highlight
))
3677 (defun article-date-original (&optional highlight
)
3678 "Convert the current article date to what it was originally.
3679 This is only useful if you have used some other date conversion
3680 function and want to see what the date was before converting."
3681 (interactive (list t
))
3682 (article-date-ut 'original highlight
))
3684 (defun article-date-lapsed (&optional highlight
)
3685 "Convert the current article date to time lapsed since it was sent."
3686 (interactive (list t
))
3687 (article-date-ut 'lapsed highlight
))
3689 (defun article-date-combined-lapsed (&optional highlight
)
3690 "Convert the current article date to time lapsed since it was sent."
3691 (interactive (list t
))
3692 (article-date-ut 'combined-lapsed highlight
))
3694 (defun article-update-date-lapsed ()
3695 "Function to be run from a timer to update the lapsed time line."
3697 (let ((buffer (current-buffer)))
3701 (set-buffer (window-buffer w
))
3702 (when (derived-mode-p 'gnus-article-mode
)
3703 (let ((old-line (count-lines (point-min) (point)))
3704 (old-column (- (point) (line-beginning-position)))
3705 (window-start (window-start w
))
3708 (while (setq pos
(text-property-not-all pos
(point-max)
3709 'gnus-date-type nil
))
3710 (setq next
(or (next-single-property-change pos
3713 (setq type
(get-text-property pos
'gnus-date-type
))
3714 (when (memq type
'(lapsed combined-lapsed user-defined
))
3715 (article-date-ut type t pos
)
3716 (setq end
(or (next-single-property-change pos
3720 (if (/= window-start next
)
3721 (setq window-start nil
)
3722 (set-window-start w end
)))
3725 (goto-char (point-min))
3726 (when (> old-column
0)
3727 (setq old-line
(1- old-line
)))
3728 (forward-line old-line
)
3730 (when (> (current-column) old-column
)
3732 (forward-char old-column
)))))
3734 (set-buffer buffer
))))
3736 (defun gnus-start-date-timer (&optional n
)
3737 "Start a timer to update the Date headers in the article buffers.
3738 The numerical prefix says how frequently (in seconds) the function
3743 (gnus-stop-date-timer)
3744 (setq article-lapsed-timer
3745 (run-at-time 1 n
'article-update-date-lapsed
)))
3747 (defun gnus-stop-date-timer ()
3748 "Stop the Date timer."
3750 (when article-lapsed-timer
3751 (nnheader-cancel-timer article-lapsed-timer
)
3752 (setq article-lapsed-timer nil
)))
3754 (defun article-date-user (&optional highlight
)
3755 "Convert the current article date to the user-defined format.
3756 This format is defined by the `gnus-article-time-format' variable."
3757 (interactive (list t
))
3758 (article-date-ut 'user highlight
))
3760 (defun article-date-iso8601 (&optional highlight
)
3761 "Convert the current article date to ISO8601."
3762 (interactive (list t
))
3763 (article-date-ut 'iso8601 highlight
))
3765 (defmacro gnus-article-save-original-date
(&rest forms
)
3766 "Save the original date as a text property and evaluate FORMS."
3767 `(let* ((case-fold-search t
)
3769 (goto-char (point-min))
3770 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3773 (date (when (and start
3774 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3776 (buffer-substring-no-properties start
3777 (match-beginning 0)))))
3778 (goto-char (point-max))
3779 (skip-chars-backward "\n")
3780 (put-text-property (point-min) (point) 'original-date date
)
3782 (goto-char (point-max))
3783 (skip-chars-backward "\n")
3784 (put-text-property (point-min) (point) 'original-date date
)))
3786 ;; (defun article-show-all ()
3787 ;; "Show all hidden text in the article buffer."
3790 ;; (let ((inhibit-read-only t))
3791 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3793 (defun article-remove-leading-whitespace ()
3794 "Remove excessive whitespace from all headers."
3798 (let ((inhibit-read-only t
))
3799 (article-narrow-to-head)
3800 (goto-char (point-min))
3801 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3802 (delete-region (match-beginning 1) (match-end 1)))))))
3804 (defun article-emphasize (&optional arg
)
3805 "Emphasize text according to `gnus-emphasis-alist'."
3806 (interactive (gnus-article-hidden-arg))
3807 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3811 (with-current-buffer gnus-summary-buffer
3812 gnus-article-emphasis-alist
)
3814 gnus-emphasis-alist
))
3815 (inhibit-read-only t
)
3816 (props (append '(article-type emphasis
)
3817 gnus-hidden-properties
))
3818 regexp elem beg invisible visible face
)
3821 (while (setq elem
(pop alist
))
3823 (setq regexp
(car elem
)
3824 invisible
(nth 1 elem
)
3825 visible
(nth 2 elem
)
3827 (while (re-search-forward regexp nil t
)
3828 (when (and (match-beginning visible
) (match-beginning invisible
))
3829 (gnus-article-hide-text
3830 (match-beginning invisible
) (match-end invisible
) props
)
3831 (gnus-article-unhide-text-type
3832 (match-beginning visible
) (match-end visible
) 'emphasis
)
3833 (gnus-put-overlay-excluding-newlines
3834 (match-beginning visible
) (match-end visible
) 'face face
)
3835 (gnus-add-wash-type 'emphasis
)
3836 (goto-char (match-end invisible
)))))))))
3838 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3839 "Setup newsgroup emphasis alist."
3840 (unless gnus-article-emphasis-alist
3841 (let ((name (and gnus-newsgroup-name
3842 (gnus-group-real-name gnus-newsgroup-name
))))
3843 (make-local-variable 'gnus-article-emphasis-alist
)
3844 (setq gnus-article-emphasis-alist
3846 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3847 (while (setq elem
(pop alist
))
3848 (when (and name
(string-match (car elem
) name
))
3850 highlight
(copy-sequence (cdr elem
)))))
3852 (copy-sequence highlight-words
)
3853 (if gnus-newsgroup-name
3854 (copy-sequence (gnus-group-find-parameter
3855 gnus-newsgroup-name
'highlight-words t
)))
3856 gnus-emphasis-alist
)))))
3858 (defvar gnus-summary-article-menu
)
3859 (defvar gnus-summary-post-menu
)
3861 ;;; Saving functions.
3863 (defun gnus-article-save (save-buffer file
&optional num
)
3864 "Save the currently selected article."
3865 (when (or (get gnus-default-article-saver
:headers
)
3866 (not gnus-save-all-headers
))
3867 ;; Remove headers according to `gnus-saved-headers' or the value
3868 ;; of the `:headers' property that the saver function might have.
3869 (let ((gnus-visible-headers
3870 (or (symbol-value (get gnus-default-article-saver
:headers
))
3871 gnus-saved-headers gnus-visible-headers
))
3872 ;; Ignore group parameter. See `article-hide-headers'.
3873 (gnus-summary-buffer nil
))
3874 (with-current-buffer save-buffer
3875 (article-hide-headers 1 t
))))
3876 (save-window-excursion
3877 (if (not gnus-default-article-saver
)
3878 (error "No default saver is defined")
3879 ;; !!! Magic! The saving functions all save
3880 ;; `gnus-save-article-buffer' (or so they think), but we
3881 ;; bind that variable to our save-buffer.
3882 (set-buffer gnus-article-buffer
)
3883 (let* ((gnus-save-article-buffer save-buffer
)
3886 ((not gnus-prompt-before-saving
) 'default
)
3887 ((eq gnus-prompt-before-saving
'always
) nil
)
3889 (gnus-number-of-articles-to-be-saved
3890 (when (eq gnus-prompt-before-saving t
)
3892 (set-buffer gnus-article-current-summary
)
3893 (funcall gnus-default-article-saver filename
)))))
3895 (defun gnus-read-save-file-name (prompt &optional filename
3896 function group headers variable
3899 (funcall function group headers
(symbol-value variable
)))
3904 ((eq filename
'default
)
3910 (when (symbol-value dir-var
)
3911 (setq default-name
(expand-file-name
3912 (file-name-nondirectory default-name
)
3913 (symbol-value dir-var
))))
3914 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3917 (if (and gnus-number-of-articles-to-be-saved
3918 (> gnus-number-of-articles-to-be-saved
1))
3919 (format "these %d articles"
3920 gnus-number-of-articles-to-be-saved
)
3923 ;; Let the split methods have their say.
3925 ;; No split name was found.
3928 (concat prompt
" (default "
3929 (file-name-nondirectory default-name
) "): ")
3930 (file-name-directory default-name
)
3932 ;; A single group name is returned.
3933 ((stringp split-name
)
3935 (funcall function split-name headers
3936 (symbol-value variable
)))
3938 (concat prompt
" (default "
3939 (file-name-nondirectory default-name
) "): ")
3940 (file-name-directory default-name
)
3942 ;; A single split name was found
3943 ((= 1 (length split-name
))
3944 (let* ((name (expand-file-name
3946 gnus-article-save-directory
))
3947 (dir (cond ((file-directory-p name
)
3948 (file-name-as-directory name
))
3949 ((file-exists-p name
) name
)
3950 (t gnus-article-save-directory
))))
3952 (concat prompt
" (default " name
"): ")
3954 ;; A list of splits was found.
3956 (setq split-name
(nreverse split-name
))
3958 (let ((file-name-history
3959 (nconc split-name file-name-history
)))
3963 (concat prompt
" (`M-p' for defaults): ")
3964 gnus-article-save-directory
3966 gnus-article-save-directory
)))
3967 (car (push result file-name-history
)))))))
3968 ;; Create the directory.
3969 (gnus-make-directory (file-name-directory file
))
3970 ;; If we have read a directory, we append the default file name.
3971 (when (file-directory-p file
)
3972 (setq file
(expand-file-name (file-name-nondirectory
3974 (file-name-as-directory file
))))
3975 ;; Possibly translate some characters.
3976 (nnheader-translate-file-chars file
))))))
3977 (gnus-make-directory (file-name-directory result
))
3979 (set variable result
))
3981 (set dir-var
(file-name-directory result
)))
3984 (defun gnus-article-archive-name (group)
3985 "Return the first instance of an \"Archive-name\" in the current buffer."
3986 (let ((case-fold-search t
))
3987 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3988 (nnheader-concat gnus-article-save-directory
3989 (match-string 1)))))
3991 (defun gnus-article-nndoc-name (group)
3992 "If GROUP is an nndoc group, return the name of the parent group."
3993 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3994 (gnus-group-get-parameter group
'save-article-group
)))
3996 (defun gnus-summary-save-in-rmail (&optional filename
)
3997 "Append this article to Rmail file.
3998 Optional argument FILENAME specifies file name.
3999 Directory to save to is default to `gnus-article-save-directory'."
4000 (setq filename
(gnus-read-save-file-name
4001 "Save %s in rmail file" filename
4002 gnus-rmail-save-name gnus-newsgroup-name
4003 gnus-current-headers
'gnus-newsgroup-last-rmail
))
4004 (with-current-buffer gnus-save-article-buffer
4008 ;; Note that unlike gnus-summary-save-in-mail, there is no
4009 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4011 (gnus-output-to-rmail filename
))))
4014 (defun gnus-summary-save-in-mail (&optional filename
)
4015 "Append this article to Unix mail file.
4016 Optional argument FILENAME specifies file name.
4017 Directory to save to is default to `gnus-article-save-directory'."
4018 (setq filename
(gnus-read-save-file-name
4019 "Save %s in Unix mail file" filename
4020 gnus-mail-save-name gnus-newsgroup-name
4021 gnus-current-headers
'gnus-newsgroup-last-mail
))
4022 (with-current-buffer gnus-save-article-buffer
4026 (if (and (file-readable-p filename
)
4027 (file-regular-p filename
)
4028 (mail-file-babyl-p filename
))
4029 (gnus-output-to-rmail filename
)
4030 (gnus-output-to-mail filename
)))))
4033 (put 'gnus-summary-save-in-file
:decode t
)
4034 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4035 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4036 "Append this article to file.
4037 Optional argument FILENAME specifies file name.
4038 Directory to save to is default to `gnus-article-save-directory'."
4039 (setq filename
(gnus-read-save-file-name
4040 "Save %s in file" filename
4041 gnus-file-save-name gnus-newsgroup-name
4042 gnus-current-headers
'gnus-newsgroup-last-file
))
4043 (with-current-buffer gnus-save-article-buffer
4047 (when (and overwrite
4048 (file-exists-p filename
))
4049 (delete-file filename
))
4050 (gnus-output-to-file filename
))))
4053 (put 'gnus-summary-write-to-file
:decode t
)
4054 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4055 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4056 (defun gnus-summary-write-to-file (&optional filename
)
4057 "Write this article to a file, overwriting it if the file exists.
4058 Optional argument FILENAME specifies file name.
4059 The directory to save in defaults to `gnus-article-save-directory'."
4060 (setq filename
(gnus-read-save-file-name
4061 "Save %s in file" filename
4062 gnus-file-save-name gnus-newsgroup-name
4063 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4064 (gnus-summary-save-in-file filename t
))
4066 (put 'gnus-summary-save-body-in-file
:decode t
)
4067 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4068 "Append this article body to a file.
4069 Optional argument FILENAME specifies file name.
4070 The directory to save in defaults to `gnus-article-save-directory'."
4071 (setq filename
(gnus-read-save-file-name
4072 "Save %s body in file" filename
4073 gnus-file-save-name gnus-newsgroup-name
4074 gnus-current-headers
'gnus-newsgroup-last-file
))
4075 (with-current-buffer gnus-save-article-buffer
4079 (when (article-goto-body)
4080 (narrow-to-region (point) (point-max)))
4081 (when (and overwrite
4082 (file-exists-p filename
))
4083 (delete-file filename
))
4084 (gnus-output-to-file filename
))))
4087 (put 'gnus-summary-write-body-to-file
:decode t
)
4088 (put 'gnus-summary-write-body-to-file
4089 :function
'gnus-summary-save-body-in-file
)
4090 (defun gnus-summary-write-body-to-file (&optional filename
)
4091 "Write this article body to a file, overwriting it if the file exists.
4092 Optional argument FILENAME specifies file name.
4093 The directory to save in defaults to `gnus-article-save-directory'."
4094 (setq filename
(gnus-read-save-file-name
4095 "Save %s body in file" filename
4096 gnus-file-save-name gnus-newsgroup-name
4097 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4098 (gnus-summary-save-body-in-file filename t
))
4100 (put 'gnus-summary-save-in-pipe
:decode t
)
4101 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4102 (defun gnus-summary-save-in-pipe (&optional command raw
)
4103 "Pipe this article to subprocess COMMAND.
4104 Valid values for COMMAND include:
4106 The executable command name and possibly arguments.
4108 You will be prompted for the command in the minibuffer.
4109 the symbol `default'
4110 It will be replaced with the command which the variable
4111 `gnus-summary-pipe-output-default-command' holds or the command
4112 last used for saving.
4113 Non-nil value for RAW overrides `:decode' and `:headers' properties
4114 and the raw article including all headers will be piped."
4115 (let ((article (gnus-summary-article-number))
4117 (get 'gnus-summary-save-in-pipe
:decode
)))
4118 save-buffer default
)
4120 (if (vectorp (gnus-summary-article-header article
))
4121 (save-current-buffer
4122 (gnus-summary-select-article decode decode nil article
)
4123 (insert-buffer-substring
4127 gnus-original-article-buffer
)
4129 (nnheader-set-temp-buffer " *Gnus Save*"))))
4130 ;; Remove unwanted headers.
4131 (when (and (not raw
)
4132 (or (get 'gnus-summary-save-in-pipe
:headers
)
4133 (not gnus-save-all-headers
)))
4134 (let ((gnus-visible-headers
4135 (or (symbol-value (get 'gnus-summary-save-in-pipe
4137 gnus-saved-headers gnus-visible-headers
))
4138 (gnus-summary-buffer nil
))
4139 (article-hide-headers 1 t
))))
4140 (error "%d is not a real article" article
))
4141 (error "No article to pipe"))
4142 (setq default
(or gnus-summary-pipe-output-default-command
4143 gnus-last-shell-command
))
4144 (unless (stringp command
)
4146 (if (and (eq command
'default
) default
)
4148 (gnus-read-shell-command "Shell command on this article: "
4150 (when (string-equal command
"")
4152 (setq command default
)
4153 (error "A command is required")))
4154 (with-current-buffer save-buffer
4157 (shell-command-on-region (point-min) (point-max) command nil
)))
4158 (gnus-kill-buffer save-buffer
))
4159 (setq gnus-summary-pipe-output-default-command command
))
4161 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4162 "Pipe this article to muttprint."
4163 (unless (stringp command
)
4164 (setq command
(read-string
4165 "Print using command: " gnus-summary-muttprint-program
4166 nil gnus-summary-muttprint-program
)))
4167 (let ((gnus-summary-pipe-output-default-command
4168 gnus-summary-pipe-output-default-command
))
4169 (gnus-summary-save-in-pipe command
))
4170 (setq gnus-summary-muttprint-program command
))
4172 ;;; Article file names when saving.
4174 (defun gnus-capitalize-newsgroup (newsgroup)
4175 "Capitalize NEWSGROUP name."
4176 (when (not (zerop (length newsgroup
)))
4177 (concat (char-to-string (upcase (aref newsgroup
0)))
4178 (substring newsgroup
1))))
4180 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4181 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4182 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4183 Otherwise, it is like ~/News/news/group/num."
4186 (concat (if (gnus-use-long-file-name 'not-save
)
4187 (gnus-capitalize-newsgroup newsgroup
)
4188 (gnus-newsgroup-directory-form newsgroup
))
4189 "/" (int-to-string (mail-header-number headers
)))
4190 gnus-article-save-directory
)))
4192 (string-equal (file-name-directory default
)
4193 (file-name-directory last-file
))
4194 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4196 (or last-file default
))))
4198 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4199 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4200 If variable `gnus-use-long-file-name' is non-nil, it is
4201 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4204 (concat (if (gnus-use-long-file-name 'not-save
)
4206 (gnus-newsgroup-directory-form newsgroup
))
4207 "/" (int-to-string (mail-header-number headers
)))
4208 gnus-article-save-directory
)))
4210 (string-equal (file-name-directory default
)
4211 (file-name-directory last-file
))
4212 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4214 (or last-file default
))))
4216 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4217 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4218 If variable `gnus-use-long-file-name' is non-nil, it is
4219 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4222 (if (gnus-use-long-file-name 'not-save
)
4225 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4227 gnus-article-save-directory
)))
4229 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4230 "Generate file name from sender."
4231 (let ((from (mail-header-from headers
)))
4233 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4234 (match-string 1 from
)
4236 gnus-article-save-directory
)))
4238 (defun article-verify-x-pgp-sig ()
4240 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4242 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4243 (let ((sig (with-current-buffer gnus-original-article-buffer
4244 (gnus-fetch-field "X-PGP-Sig")))
4248 (mml2015-clear-verify-function))
4250 (insert-buffer-substring gnus-original-article-buffer
)
4251 (setq items
(split-string sig
))
4252 (message-narrow-to-head)
4253 (let ((inhibit-point-motion-hooks t
)
4254 (case-fold-search t
))
4255 ;; Don't verify multiple headers.
4256 (setq headers
(mapconcat (lambda (header)
4258 (mail-fetch-field header
)
4260 (split-string (nth 1 items
) ",") "")))
4261 (delete-region (point-min) (point-max))
4262 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4263 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4268 (if (looking-at "^-")
4271 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4272 (insert "Version: " (car items
) "\n\n")
4273 (insert (mapconcat 'identity
(cddr items
) "\n"))
4274 (insert "\n-----END PGP SIGNATURE-----\n")
4275 (let ((mm-security-handle (list (format "multipart/signed"))))
4276 (mml2015-clean-buffer)
4277 (let ((coding-system-for-write (or gnus-newsgroup-charset
4279 (funcall (mml2015-clear-verify-function)))
4281 (or (mm-handle-multipart-ctl-parameter
4282 mm-security-handle
'gnus-details
)
4283 (mm-handle-multipart-ctl-parameter
4284 mm-security-handle
'gnus-info
)))))
4286 (let ((inhibit-read-only t
) bface eface
)
4288 (message-narrow-to-head)
4289 (goto-char (point-max))
4291 (setq bface
(get-text-property (point-at-bol) 'face
)
4292 eface
(get-text-property (1- (point-at-eol)) 'face
))
4293 (message-remove-header "X-Gnus-PGP-Verify")
4294 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4296 (goto-char (point-max)))
4297 (narrow-to-region (point) (point))
4298 (insert "X-Gnus-PGP-Verify: " info
"\n")
4299 (goto-char (point-min))
4302 (if (not (looking-at "^[ \t]"))
4306 (goto-char (point-min))
4307 (when (looking-at "\\([^:]+\\): *")
4308 (put-text-property (match-beginning 1) (1+ (match-end 1))
4310 (put-text-property (match-end 0) (point-max)
4311 'face eface
)))))))))
4313 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4315 (defun article-verify-cancel-lock ()
4316 "Verify Cancel-Lock header."
4318 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4319 (canlock-verify gnus-original-article-buffer
)))
4326 (setq afunc
(car func
)
4329 gfunc
(intern (format "gnus-%s" func
))))
4331 (when (fboundp afunc
)
4332 `(lambda (&optional interactive
&rest args
)
4333 ,(documentation afunc t
)
4334 (interactive (list t
))
4335 (with-current-buffer gnus-article-buffer
4337 (call-interactively ',afunc
)
4338 (apply ',afunc args
))))))))
4339 '(article-hide-headers
4340 article-verify-x-pgp-sig
4341 article-verify-cancel-lock
4342 article-hide-boring-headers
4343 article-treat-overstrike
4344 article-treat-ansi-sequences
4345 article-fill-long-lines
4346 article-capitalize-sentences
4348 article-remove-leading-whitespace
4349 article-display-x-face
4350 article-display-face
4351 article-de-quoted-unreadable
4352 article-de-base64-unreadable
4355 article-unsplit-urls
4356 article-hide-list-identifiers
4357 article-strip-banner
4360 article-hide-signature
4361 article-strip-headers-in-body
4362 article-remove-trailing-blank-lines
4363 article-strip-leading-blank-lines
4364 article-strip-multiple-blank-lines
4365 article-strip-leading-space
4366 article-strip-trailing-space
4367 article-strip-blank-lines
4368 article-strip-all-blank-lines
4370 article-date-english
4371 article-date-iso8601
4372 article-date-original
4375 article-decode-mime-words
4376 article-decode-charset
4377 article-decode-encoded-words
4380 article-date-combined-lapsed
4382 article-treat-dumbquotes
4383 article-treat-non-ascii
4384 article-normalize-headers
4385 ;;(article-show-all . gnus-article-show-all-headers)
4389 ;;; Gnus article mode
4392 (put 'gnus-article-mode
'mode-class
'special
)
4394 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4396 (gnus-define-keys gnus-article-mode-map
4397 " " gnus-article-goto-next-page
4398 [?\S-\
] gnus-article-goto-prev-page
4399 "\177" gnus-article-goto-prev-page
4400 [delete] gnus-article-goto-prev-page
4401 "\C-c^" gnus-article-refer-article
4402 "h" gnus-article-show-summary
4403 "s" gnus-article-show-summary
4404 "\C-c\C-m" gnus-article-mail
4405 "?" gnus-article-describe-briefly
4406 "<" beginning-of-buffer
4408 "\C-c\C-i" gnus-info-find-node
4410 "R" gnus-article-reply-with-original
4411 "F" gnus-article-followup-with-original
4412 "\C-hk" gnus-article-describe-key
4413 "\C-hc" gnus-article-describe-key-briefly
4414 "\C-hb" gnus-article-describe-bindings
4416 "e" gnus-article-read-summary-keys
4417 "\C-d" gnus-article-read-summary-keys
4418 "\M-*" gnus-article-read-summary-keys
4419 "\M-#" gnus-article-read-summary-keys
4420 "\M-^" gnus-article-read-summary-keys
4421 "\M-g" gnus-article-read-summary-keys)
4423 (substitute-key-definition
4424 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4426 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4427 "W" gnus-article-wide-reply-with-original)
4428 (if (featurep 'xemacs)
4429 (set-keymap-default-binding gnus-article-send-map
4430 'gnus-article-read-summary-send-keys)
4431 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4433 (defun gnus-article-make-menu-bar ()
4434 (unless (boundp 'gnus-article-commands-menu)
4435 (gnus-summary-make-menu-bar))
4436 (unless (boundp 'gnus-article-article-menu)
4438 gnus-article-article-menu gnus-article-mode-map ""
4440 ["Scroll forwards" gnus-article-goto-next-page t]
4441 ["Scroll backwards" gnus-article-goto-prev-page t]
4442 ["Show summary" gnus-article-show-summary t]
4443 ["Fetch Message-ID at point" gnus-article-refer-article t]
4444 ["Mail to address at point" gnus-article-mail t]
4445 ["Send a bug report" gnus-bug t]))
4448 gnus-article-treatment-menu gnus-article-mode-map ""
4449 ;; Fixme: this should use :active (and maybe :visible).
4451 ["Hide headers" gnus-article-hide-headers t]
4452 ["Hide signature" gnus-article-hide-signature t]
4453 ["Hide citation" gnus-article-hide-citation t]
4454 ["Treat overstrike" gnus-article-treat-overstrike t]
4455 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4456 ["Remove carriage return" gnus-article-remove-cr t]
4457 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4458 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4459 ["Remove base64" gnus-article-de-base64-unreadable t]
4460 ["Treat html" gnus-article-wash-html t]
4461 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4462 ["Decode HZ" gnus-article-decode-HZ t]))
4464 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4466 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4468 (gnus-run-hooks 'gnus-article-menu-hook)))
4470 (defvar bookmark-make-record-function)
4471 (defvar shr-put-image-function)
4473 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4474 "Major mode for displaying an article.
4476 All normal editing commands are switched off.
4478 The following commands are available in addition to all summary mode
4480 \\<gnus-article-mode-map>
4481 \\[gnus-article-next-page]\t Scroll the article one page forwards
4482 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4483 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4484 \\[gnus-article-show-summary]\t Display the summary buffer
4485 \\[gnus-article-mail]\t Send a reply to the address near point
4486 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4487 \\[gnus-info-find-node]\t Go to the Gnus info node"
4488 (gnus-simplify-mode-line)
4489 (make-local-variable 'minor-mode-alist)
4490 (when (gnus-visual-p 'article-menu 'menu)
4491 (gnus-article-make-menu-bar)
4492 (when gnus-summary-tool-bar-map
4493 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4494 (gnus-update-format-specifications nil 'article-mode)
4495 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4496 (set (make-local-variable 'gnus-page-broken) nil)
4497 (make-local-variable 'gnus-article-current-summary)
4498 (make-local-variable 'gnus-article-mime-handles)
4499 (make-local-variable 'gnus-article-decoded-p)
4500 (make-local-variable 'gnus-article-mime-handle-alist)
4501 (make-local-variable 'gnus-article-wash-types)
4502 (make-local-variable 'gnus-article-image-alist)
4503 (make-local-variable 'gnus-article-charset)
4504 (make-local-variable 'gnus-article-ignored-charsets)
4505 (set (make-local-variable 'bookmark-make-record-function)
4506 'gnus-summary-bookmark-make-record)
4507 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4509 (set (make-local-variable 'nobreak-char-display) nil)
4510 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4511 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4512 (setq cursor-in-non-selected-windows nil)
4513 (gnus-set-default-directory)
4514 (buffer-disable-undo)
4515 (setq buffer-read-only t
4516 show-trailing-whitespace nil)
4517 (mm-enable-multibyte))
4519 (defun gnus-article-setup-buffer ()
4520 "Initialize the article buffer."
4521 (let* ((name (if gnus-single-article-buffer "*Article*"
4523 (gnus-group-decoded-name gnus-newsgroup-name)
4526 (progn (string-match "\\*Article" name)
4527 (concat " *Original Article"
4528 (substring name (match-end 0))))))
4529 (setq gnus-article-buffer name)
4530 (setq gnus-original-article-buffer original)
4531 (setq gnus-article-mime-handle-alist nil)
4532 (with-current-buffer gnus-summary-buffer
4533 ;; This might be a variable local to the summary buffer.
4534 (unless gnus-single-article-buffer
4535 (setq gnus-article-buffer name)
4536 (setq gnus-original-article-buffer original)
4537 (gnus-set-global-variables)))
4538 (gnus-article-setup-highlight-words)
4539 ;; Init original article buffer.
4540 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4541 (mm-enable-multibyte)
4542 (setq major-mode 'gnus-original-article-mode)
4543 (make-local-variable 'gnus-original-article))
4544 (if (and (get-buffer name)
4545 (with-current-buffer name
4546 (if gnus-article-edit-mode
4547 (if (y-or-n-p "Article mode edit in progress; discard? ")
4549 (set-buffer-modified-p nil)
4550 (gnus-kill-buffer name)
4553 (error "Action aborted"))
4555 (let ((summary gnus-summary-buffer))
4556 (with-current-buffer name
4557 (set (make-local-variable 'gnus-article-edit-mode) nil)
4558 (gnus-article-stop-animations)
4559 (when gnus-article-mime-handles
4560 (mm-destroy-parts gnus-article-mime-handles)
4561 (setq gnus-article-mime-handles nil))
4562 ;; Set it to nil in article-buffer!
4563 (setq gnus-article-mime-handle-alist nil)
4564 (buffer-disable-undo)
4565 (setq buffer-read-only t)
4566 (unless (derived-mode-p 'gnus-article-mode)
4567 (gnus-article-mode))
4568 (set (make-local-variable 'gnus-summary-buffer) summary)
4569 (setq truncate-lines gnus-article-truncate-lines)
4571 (let ((summary gnus-summary-buffer))
4572 (with-current-buffer (gnus-get-buffer-create name)
4574 (setq truncate-lines gnus-article-truncate-lines)
4575 (set (make-local-variable 'gnus-summary-buffer) summary)
4576 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4577 (when article-lapsed-timer
4578 (gnus-stop-date-timer))
4579 (when gnus-article-update-date-headers
4580 (gnus-start-date-timer gnus-article-update-date-headers))
4581 (current-buffer))))))
4583 (defun gnus-article-stop-animations ()
4584 (dolist (timer (and (boundp 'timer-list)
4586 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4587 (cancel-timer timer))))
4589 (defun gnus-stop-downloads ()
4590 (when (boundp 'url-queue)
4591 (set (intern "url-queue" obarray) nil)))
4593 ;; Set article window start at LINE, where LINE is the number of lines
4594 ;; from the head of the article.
4595 (defun gnus-article-set-window-start (&optional line)
4596 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4597 (when article-window
4600 (with-current-buffer gnus-article-buffer
4601 (goto-char (point-min))
4604 (gnus-message 6 "Moved to bookmark")
4605 (search-forward "\n\n" nil t)
4609 (defun gnus-article-prepare (article &optional all-headers header)
4610 "Prepare ARTICLE in article mode buffer.
4611 ARTICLE should either be an article number or a Message-ID.
4612 If ARTICLE is an id, HEADER should be the article headers.
4613 If ALL-HEADERS is non-nil, no headers are hidden."
4615 ;; Make sure we start in a summary buffer.
4616 (unless (derived-mode-p 'gnus-summary-mode)
4617 (set-buffer gnus-summary-buffer))
4618 (setq gnus-summary-buffer (current-buffer))
4619 (let* ((gnus-article (if header (mail-header-number header) article))
4620 (summary-buffer (current-buffer))
4621 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4622 (group gnus-newsgroup-name)
4625 (gnus-article-setup-buffer)
4626 (set-buffer gnus-article-buffer)
4627 ;; Deactivate active regions.
4628 (when (and (boundp 'transient-mark-mode)
4629 transient-mark-mode)
4630 (setq mark-active nil))
4631 (if (not (setq result (let ((inhibit-read-only t))
4632 (gnus-request-article-this-buffer
4634 ;; There is no such article.
4636 (when (and (numberp article)
4637 (not (memq article gnus-newsgroup-sparse)))
4638 (setq gnus-article-current
4639 (cons gnus-newsgroup-name article))
4640 (set-buffer gnus-summary-buffer)
4641 (setq gnus-current-article article)
4642 (if (and (memq article gnus-newsgroup-undownloaded)
4643 (not (gnus-online (gnus-find-method-for-group
4644 gnus-newsgroup-name))))
4646 (gnus-summary-set-agent-mark article)
4647 (message "Message marked for downloading"))
4648 (gnus-summary-mark-article article gnus-canceled-mark)
4649 (unless (memq article gnus-newsgroup-sparse)
4650 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4651 (if (or (eq result 'pseudo)
4652 (eq result 'nneething))
4654 (with-current-buffer summary-buffer
4655 (push article gnus-newsgroup-history)
4656 (setq gnus-last-article gnus-current-article
4657 gnus-current-article 0
4658 gnus-current-headers nil
4659 gnus-article-current nil)
4660 (if (eq result 'nneething)
4661 (gnus-configure-windows 'summary)
4662 (gnus-configure-windows 'article))
4663 (gnus-set-global-variables))
4664 (let ((gnus-article-mime-handle-alist-1
4665 gnus-article-mime-handle-alist))
4666 (gnus-set-mode-line 'article)))
4667 ;; The result from the `request' was an actual article -
4668 ;; or at least some text that is now displayed in the
4670 (when (and (numberp article)
4671 (not (eq article gnus-current-article)))
4672 ;; Seems like a new article has been selected.
4673 ;; `gnus-current-article' must be an article number.
4674 (with-current-buffer summary-buffer
4675 (push article gnus-newsgroup-history)
4676 (setq gnus-last-article gnus-current-article
4677 gnus-current-article article
4678 gnus-current-headers
4679 (gnus-summary-article-header gnus-current-article)
4680 gnus-article-current
4681 (cons gnus-newsgroup-name gnus-current-article))
4682 (unless (vectorp gnus-current-headers)
4683 (setq gnus-current-headers nil))
4684 (gnus-summary-goto-subject gnus-current-article)
4685 (when (gnus-summary-show-thread)
4686 ;; If the summary buffer really was folded, the
4687 ;; previous goto may not actually have gone to
4688 ;; the right article, but the thread root instead.
4690 (gnus-summary-goto-subject gnus-current-article))
4691 (gnus-run-hooks 'gnus-mark-article-hook)
4692 (gnus-set-mode-line 'summary)
4693 (when (gnus-visual-p 'article-highlight 'highlight)
4694 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4695 ;; Set the global newsgroup variables here.
4696 (gnus-set-global-variables)
4697 (setq gnus-have-all-headers
4698 (or all-headers gnus-show-all-headers))))
4700 (gnus-configure-windows 'article))
4701 (when (or (numberp article)
4703 (gnus-article-prepare-display)
4705 (goto-char (point-min))
4706 (when gnus-break-pages
4707 (gnus-narrow-to-page)))
4708 (let ((gnus-article-mime-handle-alist-1
4709 gnus-article-mime-handle-alist))
4710 (gnus-set-mode-line 'article))
4714 (set-window-point (get-buffer-window (current-buffer)) (point))
4715 (gnus-configure-windows 'article)
4716 (gnus-run-hooks 'gnus-article-prepare-hook)
4720 (defun gnus-article-prepare-display ()
4721 "Make the current buffer look like a nice article."
4722 ;; Hooks for getting information from the article.
4723 ;; This hook must be called before being narrowed.
4724 (let ((gnus-article-buffer (current-buffer))
4726 (inhibit-read-only t))
4727 (unless (derived-mode-p 'gnus-article-mode)
4728 (gnus-article-mode))
4729 (setq buffer-read-only nil
4730 gnus-article-wash-types nil
4731 gnus-article-image-alist nil)
4732 (gnus-run-hooks 'gnus-tmp-internal-hook)
4733 (when gnus-display-mime-function
4734 (funcall gnus-display-mime-function))
4735 ;; Add attachment buttons to the header.
4736 (when gnus-mime-display-attachment-buttons-in-header
4737 (gnus-mime-buttonize-attachments-in-header))))
4740 ;;; Gnus Sticky Article Mode
4743 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4744 "Mode for sticky articles."
4745 ;; Release bindings that won't work.
4746 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4747 gnus-sticky-article-mode-map)
4748 (substitute-key-definition 'gnus-article-refer-article 'undefined
4749 gnus-sticky-article-mode-map)
4750 (dolist (k '("e" "h" "s" "F" "R"))
4751 (define-key gnus-sticky-article-mode-map k nil))
4752 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4753 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4754 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4755 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4757 (defun gnus-sticky-article (arg)
4758 "Make the current article sticky.
4759 If a prefix ARG is given, ask for a name for this sticky article buffer."
4761 (gnus-summary-show-thread)
4762 (gnus-summary-select-article nil nil 'pseudo)
4763 (let (new-art-buf-name)
4764 (gnus-eval-in-buffer-window gnus-article-buffer
4765 (setq new-art-buf-name
4769 (read-from-minibuffer "Sticky article buffer name: ")
4770 (gnus-with-article-headers
4771 (gnus-article-goto-header "subject")
4772 (setq new-art-buf-name
4773 (buffer-substring-no-properties
4774 (line-beginning-position) (line-end-position)))
4775 (goto-char (point-min))
4776 (gnus-article-goto-header "from")
4777 (setq new-art-buf-name
4779 new-art-buf-name ", "
4780 (buffer-substring-no-properties
4781 (line-beginning-position) (line-end-position))))
4782 (goto-char (point-min))
4783 (gnus-article-goto-header "date")
4784 (setq new-art-buf-name
4786 new-art-buf-name ", "
4787 (buffer-substring-no-properties
4788 (line-beginning-position) (line-end-position))))))
4790 (if (and (gnus-buffer-live-p new-art-buf-name)
4791 (with-current-buffer new-art-buf-name
4792 (derived-mode-p 'gnus-sticky-article-mode)))
4793 (switch-to-buffer new-art-buf-name)
4794 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4795 (gnus-sticky-article-mode))
4796 (setq gnus-article-buffer new-art-buf-name))
4797 (gnus-summary-recenter)
4798 (gnus-summary-position-point))
4800 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4801 "Kill the given sticky article BUFFER.
4802 If none is given, assume the current buffer and kill it if it has
4803 `gnus-sticky-article-mode'."
4806 (setq buffer (current-buffer)))
4807 (with-current-buffer buffer
4808 (when (derived-mode-p 'gnus-sticky-article-mode)
4809 (gnus-kill-buffer buffer))))
4811 (defun gnus-kill-sticky-article-buffers (arg)
4812 "Kill all sticky article buffers.
4813 If a prefix ARG is given, ask for confirmation."
4815 (dolist (buf (gnus-buffers))
4816 (with-current-buffer buf
4817 (when (derived-mode-p 'gnus-sticky-article-mode)
4819 (gnus-kill-buffer buf)
4820 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4821 (gnus-kill-buffer buf)))))))
4824 ;;; Gnus MIME viewing functions
4827 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4828 "Format of the MIME buttons.
4830 Valid specifiers include:
4832 %T MIME type, along with additional info
4833 %n The `name' parameter
4834 %d The description, if any
4835 %l The length of the encoded part
4836 %p The part identifier number
4837 %e Dots if the part isn't displayed
4839 General format specifiers can also be used. See Info node
4840 `(gnus)Formatting Variables'.")
4842 (defvar gnus-mime-button-line-format-alist
4843 '((?t gnus-tmp-type ?s)
4844 (?T gnus-tmp-type-long ?s)
4845 (?n gnus-tmp-name ?s)
4846 (?d gnus-tmp-description ?s)
4848 (?l gnus-tmp-length ?d)
4849 (?e gnus-tmp-dots ?s)))
4851 (defvar gnus-mime-button-commands
4852 '((gnus-article-press-button "\r" "Toggle Display")
4853 (gnus-mime-view-part "v" "View Interactively...")
4854 (gnus-mime-view-part-as-type "t" "View As Type...")
4855 (gnus-mime-view-part-as-charset "C" "View As charset...")
4856 (gnus-mime-save-part "o" "Save...")
4857 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4858 (gnus-mime-replace-part "r" "Replace part")
4859 (gnus-mime-delete-part "d" "Delete part")
4860 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4861 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4862 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4863 (gnus-mime-view-part-externally "e" "View Externally")
4864 (gnus-mime-print-part "p" "Print")
4865 (gnus-mime-pipe-part "|" "Pipe To Command...")
4866 (gnus-mime-action-on-part "." "Take action on the part...")))
4868 (defun gnus-article-mime-part-status ()
4869 (if gnus-article-mime-handle-alist-1
4870 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4872 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4875 (defvar gnus-mime-button-map
4876 (let ((map (make-sparse-keymap)))
4877 (define-key map gnus-mouse-2 'gnus-article-push-button)
4878 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4879 (dolist (c gnus-mime-button-commands)
4880 (define-key map (cadr c) (car c)))
4884 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4886 ,@(mapcar (lambda (c)
4887 (vector (caddr c) (car c) :active t))
4888 gnus-mime-button-commands)))
4890 (defvar gnus-url-button-commands
4891 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4893 (defvar gnus-url-button-map
4894 (let ((map (make-sparse-keymap)))
4895 (dolist (c gnus-url-button-commands)
4896 (define-key map (cadr c) (car c)))
4900 gnus-url-button-menu gnus-url-button-map "URL button menu."
4902 ,@(mapcar (lambda (c)
4903 (vector (caddr c) (car c) :active t))
4904 gnus-url-button-commands)))
4906 (defmacro gnus-bind-safe-url-regexp (&rest body)
4907 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4908 `(let ((mm-w3m-safe-url-regexp
4909 (let ((group (if (and (derived-mode-p 'gnus-article-mode)
4911 gnus-article-current-summary))
4912 (with-current-buffer gnus-article-current-summary
4913 gnus-newsgroup-name)
4914 gnus-newsgroup-name)))
4915 (if (cond ((not group)
4916 ;; Maybe we're in a mml-preview buffer
4917 ;; and no group is selected.
4919 ((stringp gnus-safe-html-newsgroups)
4920 (string-match gnus-safe-html-newsgroups group))
4921 ((consp gnus-safe-html-newsgroups)
4922 (member group gnus-safe-html-newsgroups)))
4924 mm-w3m-safe-url-regexp))))
4927 (defun gnus-mime-button-menu (event prefix)
4928 "Construct a context-sensitive menu of MIME commands."
4929 (interactive "e\nP")
4930 (save-window-excursion
4931 (let ((pos (event-start event)))
4932 (select-window (posn-window pos))
4933 (goto-char (posn-point pos))
4934 (gnus-article-check-buffer)
4935 (popup-menu gnus-mime-button-menu nil prefix))))
4937 (defun gnus-mime-view-all-parts (&optional handles)
4938 "View all the MIME parts."
4940 (with-current-buffer gnus-article-buffer
4941 (let ((handles (or handles gnus-article-mime-handles))
4942 (mail-parse-charset gnus-newsgroup-charset)
4943 (mail-parse-ignored-charsets
4944 (with-current-buffer gnus-summary-buffer
4945 gnus-newsgroup-ignored-charsets)))
4947 (mm-remove-parts handles)
4948 (goto-char (point-min))
4949 (or (search-forward "\n\n") (goto-char (point-max)))
4950 (let ((inhibit-read-only t))
4951 (delete-region (point) (point-max))
4952 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4954 (defun gnus-article-jump-to-part (n)
4955 "Jump to MIME part N."
4957 (let ((parts (with-current-buffer gnus-article-buffer
4958 (length gnus-article-mime-handle-alist))))
4960 (error "No such part"))
4961 (pop-to-buffer gnus-article-buffer)
4963 (setq n (if (= parts 1)
4965 (read-number (format "Jump to part (1..%s): " parts)))))
4966 (unless (and (integerp n) (<= n parts) (>= n 1))
4969 (gnus-message 7 "Invalid part `%s', using %s instead."
4972 (gnus-message 9 "Jumping to part %s." n)
4973 (cond ((>= gnus-auto-select-part 1)
4974 (while (and (<= n parts)
4975 (not (gnus-article-goto-part n)))
4977 ((< gnus-auto-select-part 0)
4978 (while (and (>= n 1)
4979 (not (gnus-article-goto-part n)))
4982 (gnus-article-goto-part n)))))
4984 (defvar gnus-mime-buttonized-part-id nil
4985 "ID of a mime part that should be buttonized.
4986 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4989 (defsubst gnus-article-edit-part (handles &optional current-id)
4990 "Edit an article in order to delete a mime part.
4991 This function is exclusively used by `gnus-mime-save-part-and-strip'
4992 and `gnus-mime-delete-part', and not provided at run-time normally."
4993 (gnus-article-edit-article
4995 (buffer-disable-undo)
4996 (let ((mail-parse-charset (or gnus-article-charset
4997 ',gnus-newsgroup-charset))
4998 (mail-parse-ignored-charsets
4999 (or gnus-article-ignored-charsets
5000 ',gnus-newsgroup-ignored-charsets))
5001 (mbl mml-buffer-list))
5002 (setq mml-buffer-list nil)
5003 ;; A new text must be inserted before deleting existing ones
5004 ;; at the end so as not to move existing markers of which
5005 ;; the insertion type is t.
5009 (goto-char (point-max))
5010 (insert-buffer-substring gnus-original-article-buffer)))
5011 (mime-to-mml ',handles)
5012 (setq gnus-article-mime-handles nil)
5013 (let ((mbl1 mml-buffer-list))
5014 (setq mml-buffer-list mbl)
5015 (set (make-local-variable 'mml-buffer-list) mbl1))
5016 (gnus-make-local-hook 'kill-buffer-hook)
5017 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5018 `(lambda (no-highlight)
5019 (let ((mail-parse-charset (or gnus-article-charset
5020 ',gnus-newsgroup-charset))
5021 (message-options message-options)
5022 (message-options-set-recipient)
5023 (mail-parse-ignored-charsets
5024 (or gnus-article-ignored-charsets
5025 ',gnus-newsgroup-ignored-charsets)))
5027 (mml-destroy-buffers)
5028 (remove-hook 'kill-buffer-hook
5029 'mml-destroy-buffers t)
5030 (kill-local-variable 'mml-buffer-list))
5031 (gnus-summary-edit-article-done
5032 ,(or (mail-header-references gnus-current-headers) "")
5033 ,(gnus-group-read-only-p)
5034 ,gnus-summary-buffer no-highlight))
5036 ;; Force buttonizing this part.
5037 (let ((gnus-mime-buttonized-part-id current-id))
5038 (gnus-article-edit-done))
5039 (gnus-configure-windows 'article)
5040 (when (and current-id (integerp gnus-auto-select-part))
5041 (gnus-article-jump-to-part
5042 (min (max (+ current-id gnus-auto-select-part) 1)
5043 (with-current-buffer gnus-article-buffer
5044 (length gnus-article-mime-handle-alist)))))))
5046 (defun gnus-mime-replace-part (file)
5047 "Replace MIME part under point with an external body."
5048 ;; Useful if file has already been saved to disk
5051 (read-file-name "Replace MIME part with file: "
5052 (or mm-default-directory default-directory)
5054 (gnus-mime-save-part-and-strip file))
5056 (defun gnus-mime-save-part-and-strip (&optional file)
5057 "Save the MIME part under point then replace it with an external body.
5058 If FILE is given, use it for the external part."
5060 (gnus-article-check-buffer)
5061 (when (gnus-group-read-only-p)
5062 (error "The current group does not support deleting of parts"))
5063 (when (mm-complicated-handles gnus-article-mime-handles)
5065 The current article has a complicated MIME structure, giving up..."))
5066 (let* ((data (get-text-property (point) 'gnus-data))
5067 (id (get-text-property (point) 'gnus-part))
5069 (handles gnus-article-mime-handles))
5072 (and data (mm-save-part data "Delete MIME part and save to: "))))
5074 (with-current-buffer (mm-handle-buffer data)
5076 (insert "Content-Type: " (mm-handle-media-type data))
5077 (mml-insert-parameter-string (cdr (mm-handle-type data))
5079 ;; Add a filename for the sake of saving the part again.
5080 (mml-insert-parameter
5081 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5083 (insert "Content-ID: " (message-make-message-id) "\n")
5084 (insert "Content-Transfer-Encoding: binary\n")
5087 (cdr (mm-make-handle nil
5088 `("message/external-body"
5089 (access-type . "LOCAL-FILE")
5091 ;; (set-buffer gnus-summary-buffer)
5092 (gnus-article-edit-part handles id))))
5094 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5095 ;; parts...>') but with stripping would be nice.
5097 (defun gnus-mime-delete-part ()
5098 "Delete the MIME part under point.
5099 Replace it with some information about the removed part."
5101 (gnus-article-check-buffer)
5102 (when (gnus-group-read-only-p)
5103 (error "The current group does not support deleting of parts"))
5104 (when (mm-complicated-handles gnus-article-mime-handles)
5106 The current article has a complicated MIME structure, giving up..."))
5107 (when (or gnus-expert-user
5108 (gnus-yes-or-no-p "\
5109 Deleting parts may malfunction or destroy the article; continue? "))
5110 (let* ((data (get-text-property (point) 'gnus-data))
5111 (id (get-text-property (point) 'gnus-part))
5112 (handles gnus-article-mime-handles)
5114 (let ((desc (mm-handle-description data)))
5116 (mail-decode-encoded-word-string desc))))
5117 (filename (or (mm-handle-filename data) "(none)"))
5118 (type (mm-handle-media-type data)))
5120 (error "No MIME part under point"))
5121 (with-current-buffer (mm-handle-buffer data)
5122 (let ((bsize (buffer-size)))
5127 "| The following attachment has been deleted:\n"
5129 "| Type: " type "\n"
5130 "| Filename: " filename "\n"
5131 "| Size (encoded): " (format "%s byte%s\n"
5132 bsize (if (= bsize 1)
5136 (concat "| Description: " description "\n"))
5139 (cdr (mm-make-handle
5140 nil `("text/plain" (charset . gnus-decoded)) nil nil
5142 (format "Deleted attachment (%s bytes)" bsize))))))
5143 ;; (set-buffer gnus-summary-buffer)
5144 (gnus-article-edit-part handles id))))
5146 (defun gnus-mime-save-part ()
5147 "Save the MIME part under point."
5149 (gnus-article-check-buffer)
5150 (let ((data (get-text-property (point) 'gnus-data)))
5152 (mm-save-part data))))
5154 (defun gnus-mime-pipe-part (&optional cmd)
5155 "Pipe the MIME part under point to a process.
5156 Use CMD as the process."
5158 (gnus-article-check-buffer)
5159 (let ((data (get-text-property (point) 'gnus-data)))
5161 (mm-pipe-part data cmd))))
5163 (defun gnus-mime-view-part ()
5164 "Interactively choose a viewing method for the MIME part under point."
5166 (gnus-article-check-buffer)
5167 (let ((data (get-text-property (point) 'gnus-data)))
5169 (setq gnus-article-mime-handles
5171 gnus-article-mime-handles (setq data (copy-sequence data))))
5172 (mm-interactively-view-part data))))
5174 (defun gnus-mime-view-part-as-type-internal ()
5175 (gnus-article-check-buffer)
5176 (let* ((handle (get-text-property (point) 'gnus-data))
5178 ;; Content-Type: foo/bar; name=...
5179 (mail-content-type-get (mm-handle-type handle) 'name)
5180 ;; Content-Disposition: attachment; filename=...
5181 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5182 (def-type (and name (mm-default-file-encoding name))))
5183 (or (and def-type (cons def-type 0))
5185 (equal (mm-handle-media-supertype handle) "text")
5186 '("text/plain" . 0))
5187 '("application/octet-stream" . 0))))
5189 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5190 "Choose a MIME media type, and view the part as such.
5191 If non-nil, PRED is a predicate to use during completion to limit the
5192 available media-types."
5196 (let ((default (gnus-mime-view-part-as-type-internal)))
5197 (gnus-completing-read
5200 (gnus-remove-if-not pred (mailcap-mime-types))
5201 (mailcap-mime-types))
5204 (gnus-article-check-buffer)
5205 (let ((handle (get-text-property (point) 'gnus-data)))
5207 (when (equal (mm-handle-media-type handle) "message/external-body")
5208 (unless (mm-handle-cache handle)
5209 (mm-extern-cache-contents handle))
5210 (setq handle (mm-handle-cache handle)))
5212 (mm-make-handle (mm-handle-buffer handle)
5213 (cons mime-type (cdr (mm-handle-type handle)))
5214 (mm-handle-encoding handle)
5215 (mm-handle-undisplayer handle)
5216 (mm-handle-disposition handle)
5217 (mm-handle-description handle)
5219 (mm-handle-id handle)))
5220 (setq gnus-article-mime-handles
5221 (mm-merge-handles gnus-article-mime-handles handle))
5222 (when (mm-handle-displayed-p handle)
5223 (mm-remove-part handle))
5224 (gnus-mm-display-part handle))))
5226 (defun gnus-mime-copy-part (&optional handle arg)
5227 "Put the MIME part under point into a new buffer.
5228 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5230 (interactive (list nil current-prefix-arg))
5231 (gnus-article-check-buffer)
5233 (setq handle (get-text-property (point) 'gnus-data)))
5235 (let ((filename (mm-handle-filename handle))
5236 contents dont-decode charset coding-system)
5237 (mm-with-unibyte-buffer
5238 (mm-insert-part handle)
5239 (setq contents (or (condition-case nil
5240 (mm-decompress-buffer filename nil 'sig)
5242 (setq dont-decode t)
5245 (setq filename (cond (filename (file-name-nondirectory filename))
5246 (dont-decode "*raw data*")
5251 (unless (setq charset (mail-content-type-get
5252 (mm-handle-type handle) 'charset))
5253 (unless (setq coding-system (mm-with-unibyte-buffer
5255 (mm-find-buffer-file-coding-system)))
5256 (setq charset gnus-newsgroup-charset))))
5258 (setq charset (or (cdr (assq arg
5259 gnus-summary-show-article-charset-alist))
5260 (mm-read-coding-system "Charset: ")))))
5261 (switch-to-buffer (generate-new-buffer filename))
5262 (if (or coding-system
5264 (setq coding-system (mm-charset-to-coding-system
5266 (not (eq coding-system 'ascii))))
5268 (mm-enable-multibyte)
5269 (insert (mm-decode-coding-string contents coding-system))
5270 (setq buffer-file-coding-system
5271 (if (boundp 'last-coding-system-used)
5272 (symbol-value 'last-coding-system-used)
5274 (mm-disable-multibyte)
5276 (setq buffer-file-coding-system mm-binary-coding-system))
5277 ;; We do it this way to make `normal-mode' set the appropriate mode.
5280 (setq buffer-file-name (expand-file-name filename))
5282 (setq buffer-file-name nil))
5283 (goto-char (point-min)))))
5285 (defun gnus-mime-print-part (&optional handle filename)
5286 "Print the MIME part under point."
5287 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5288 (gnus-article-check-buffer)
5289 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5290 (contents (and handle (mm-get-part handle)))
5291 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5292 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5297 (mm-save-part-to-file handle file)
5298 (call-process shell-file-name nil
5299 (generate-new-buffer " *mm*")
5301 shell-command-switch
5303 printer file (mm-handle-type handle))))
5307 (gnus-print-buffer))
5308 (ps-despool filename)))))
5310 (defun gnus-mime-inline-part (&optional handle arg)
5311 "Insert the MIME part under point into the current buffer.
5312 Compressed files like .gz and .bz2 are decompressed."
5313 (interactive (list nil current-prefix-arg))
5314 (gnus-article-check-buffer)
5315 (let* ((inhibit-read-only t)
5317 (btn ;; position where the MIME button exists
5319 (if (eq handle (get-text-property b 'gnus-data))
5322 (or (text-property-any (point) (point-max) 'gnus-data handle)
5323 (text-property-any (point-min) (point) 'gnus-data handle)))
5324 (setq handle (get-text-property b 'gnus-data))
5326 start contents charset coding-system)
5330 (setq start (next-single-property-change btn 'gnus-data
5332 btn (previous-single-property-change start
5335 (if (and (not arg) (mm-handle-undisplayer handle))
5336 (mm-remove-part handle)
5337 (mm-with-unibyte-buffer
5338 (mm-insert-part handle)
5340 (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
5344 (unless (setq charset (mail-content-type-get
5345 (mm-handle-type handle) 'charset))
5346 (unless (setq coding-system
5347 (mm-with-unibyte-buffer
5349 (mm-find-buffer-file-coding-system)))
5350 (setq charset gnus-newsgroup-charset))))
5352 (if (mm-handle-undisplayer handle)
5353 (mm-remove-part handle))
5356 gnus-summary-show-article-charset-alist))
5357 (mm-read-coding-system "Charset: "))))
5358 ((mm-handle-undisplayer handle)
5359 (mm-remove-part handle)))
5362 ;; This is a header button.
5364 (mm-display-inline handle))
5365 ;; Toggle the button appearance between `[button]...' and `[button]'.
5367 (let ((displayed-p (mm-handle-displayed-p handle)))
5368 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5370 (if (featurep 'emacs)
5373 (next-single-property-change (point) 'gnus-data nil (point-max)))
5374 (let* ((end (next-single-property-change (point) 'gnus-data))
5375 (annots (annotations-at (or end (point-max)))))
5376 (delete-region (point)
5378 (if annots (1+ end) end)
5380 (dolist (annot annots)
5381 (set-extent-endpoints annot (point) (point)))))
5382 (setq start (point))
5383 (if (search-backward "\n\n" nil t)
5386 (unless (or displayed-p (eolp))
5387 ;; Add extra newline.
5388 (insert (propertize (buffer-substring (1- start) start)
5389 'gnus-undeletable t))))
5390 ;; We're in the article header.
5392 (dolist (ovl (gnus-overlays-in btn (point)))
5393 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5394 (gnus-overlay-put ovl 'face nil))
5396 (message-narrow-to-field)
5397 (let ((gnus-treatment-function-alist
5398 '((gnus-treat-highlight-headers
5399 gnus-article-highlight-headers))))
5400 (gnus-treat-article 'head)))))
5403 (defun gnus-mime-set-charset-parameters (handle charset)
5404 "Set CHARSET to parameters in HANDLE.
5405 CHARSET may either be a string or a symbol."
5406 (unless (stringp charset)
5407 (setq charset (symbol-name charset)))
5408 (if (stringp (car handle))
5409 (dolist (h (cdr handle))
5410 (gnus-mime-set-charset-parameters h charset))
5411 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5412 "message/external-body")
5414 (unless (mm-handle-cache handle)
5415 (mm-extern-cache-contents handle))
5416 (mm-handle-cache handle))
5418 (param (assq 'charset (cdr type))))
5420 (setcdr param charset)
5421 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5423 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5424 "Insert the MIME part under point into the current buffer using the
5426 (interactive (list nil current-prefix-arg))
5427 (gnus-article-check-buffer)
5428 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5429 (fun (get-text-property (point) 'gnus-callback))
5430 (gnus-newsgroup-ignored-charsets 'gnus-all)
5431 charset form preferred parts)
5438 gnus-summary-show-article-charset-alist))
5439 (mm-read-coding-system "Charset: "))))
5440 (if (mm-handle-undisplayer handle)
5441 (mm-remove-part handle)))
5442 (gnus-mime-set-charset-parameters handle charset)
5443 (when (and (consp (setq form (cdr-safe fun)))
5444 (setq form (ignore-errors
5445 (assq 'gnus-mime-display-alternative form)))
5446 (setq preferred (caddr form))
5448 (when (eq (car preferred) 'quote)
5449 (setq preferred (cadr preferred)))
5450 (not (equal preferred
5451 (get-text-property (point) 'gnus-data))))
5452 (setq parts (get-text-property (point) 'gnus-part))
5453 (setq parts (cdr (assq parts
5454 gnus-article-mime-handle-alist)))
5455 (equal (mm-handle-media-type parts) "multipart/alternative")
5456 (setq parts (reverse (cdr parts))))
5458 (list 'quote (or (cadr (member preferred parts))
5460 (funcall fun handle)))))
5462 (defun gnus-mime-view-part-externally (&optional handle)
5463 "View the MIME part under point with an external viewer."
5465 (gnus-article-check-buffer)
5466 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5467 (mm-user-display-methods nil)
5468 (mm-inlined-types nil)
5469 (mail-parse-charset gnus-newsgroup-charset)
5470 (mail-parse-ignored-charsets
5471 (with-current-buffer gnus-summary-buffer
5472 gnus-newsgroup-ignored-charsets))
5473 (type (mm-handle-media-type handle))
5474 (method (mailcap-mime-info type))
5475 (mm-enable-external t))
5476 (if (not (stringp method))
5477 (gnus-mime-view-part-as-type
5478 nil (lambda (type) (stringp (mailcap-mime-info type))))
5480 (mm-display-part handle nil t)))))
5482 (defun gnus-mime-view-part-internally (&optional handle)
5483 "View the MIME part under point with an internal viewer.
5484 If no internal viewer is available, use an external viewer."
5486 (gnus-article-check-buffer)
5487 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5488 (mm-inlined-types '(".*"))
5489 (mm-inline-large-images t)
5490 (mail-parse-charset gnus-newsgroup-charset)
5491 (mail-parse-ignored-charsets
5492 (with-current-buffer gnus-summary-buffer
5493 gnus-newsgroup-ignored-charsets))
5494 (inhibit-read-only t))
5495 (if (not (mm-inlinable-p handle))
5496 (gnus-mime-view-part-as-type
5497 nil (lambda (type) (mm-inlinable-p handle type)))
5499 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5501 (defun gnus-mime-action-on-part (&optional action)
5502 "Do something with the MIME attachment at \(point\)."
5504 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5505 (gnus-article-check-buffer)
5506 (let ((action-pair (assoc action gnus-mime-action-alist)))
5508 (funcall (cdr action-pair)))))
5510 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5511 "Call FUNCTION on MIME part N.
5512 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5513 If INTERACTIVE, call FUNCTION interactively."
5515 ;; Check whether the article is displayed.
5516 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5517 (setq window (get-buffer-window gnus-article-buffer t))
5518 (frame-visible-p (setq frame (window-frame window))))
5519 (error "No article is displayed"))
5520 (with-current-buffer gnus-article-buffer
5521 ;; Check whether the article displays the right contents.
5522 (unless (with-current-buffer gnus-summary-buffer
5523 (eq gnus-current-article (gnus-summary-article-number)))
5524 (error "You should select the right article first"))
5526 (setq n (prefix-numeric-value n))
5528 (setq n (or (get-text-property pt 'gnus-part)
5530 (get-text-property (1- pt) 'gnus-part))
5531 (get-text-property (prog2
5537 (or (and (setq pt (previous-single-property-change
5540 (next-single-property-change (point) 'gnus-part)
5544 ;; Check whether the specified part exists.
5545 (when (> n (length gnus-article-mime-handle-alist))
5546 (error "No such part")))
5549 ;; To select the window is needed so that the cursor
5550 ;; might be visible on the MIME button.
5551 (select-window (prog1
5553 (setq window (selected-window))
5554 ;; Article may be displayed in the other frame.
5555 (gnus-select-frame-set-input-focus
5558 (setq frame (selected-frame))))))
5559 (when (gnus-article-goto-part n)
5560 ;; We point the cursor and the arrow at the MIME button
5561 ;; when the `function' prompt the user for something.
5562 (unless (and (pos-visible-in-window-p)
5563 (> (count-lines (point) (window-end))
5564 (/ (1- (window-height)) 3)))
5565 (recenter (/ (1- (window-height)) 3)))
5566 (let ((cursor-in-non-selected-windows t)
5567 (overlay-arrow-string "=>")
5568 (overlay-arrow-position (point-marker)))
5571 ((and no-handle interactive)
5572 (call-interactively function))
5577 function (get-text-property (point) 'gnus-data)))
5580 (get-text-property (point) 'gnus-data))))
5581 (set-marker overlay-arrow-position nil)
5582 (unless gnus-auto-select-part
5583 (gnus-select-frame-set-input-focus frame)
5584 (select-window window))))
5586 (if gnus-inhibit-mime-unbuttonizing
5587 ;; This is the default though the program shouldn't reach here.
5588 (error "No such part")
5589 ;; The part which doesn't have the MIME button is selected.
5590 ;; So, we display all the buttons and redo it.
5591 (let ((gnus-inhibit-mime-unbuttonizing t))
5592 (gnus-summary-show-article)
5593 (gnus-article-part-wrapper n function no-handle))))))
5595 (defun gnus-article-pipe-part (n)
5596 "Pipe MIME part N, which is the numerical prefix."
5598 (gnus-article-part-wrapper n 'mm-pipe-part))
5600 (defun gnus-article-save-part (n)
5601 "Save MIME part N, which is the numerical prefix."
5603 (gnus-article-part-wrapper n 'mm-save-part))
5605 (defun gnus-article-interactively-view-part (n)
5606 "View MIME part N interactively, which is the numerical prefix."
5608 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5610 (defun gnus-article-copy-part (n)
5611 "Copy MIME part N, which is the numerical prefix."
5613 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5615 (defun gnus-article-view-part-as-charset (n)
5616 "View MIME part N using a specified charset.
5617 N is the numerical prefix."
5619 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5621 (defun gnus-article-view-part-externally (n)
5622 "View MIME part N externally, which is the numerical prefix."
5624 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5626 (defun gnus-article-inline-part (n)
5627 "Inline MIME part N, which is the numerical prefix."
5629 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5631 (defun gnus-article-save-part-and-strip (n)
5632 "Save MIME part N and replace it with an external body.
5633 N is the numerical prefix."
5635 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5637 (defun gnus-article-replace-part (n)
5638 "Replace MIME part N with an external body.
5639 N is the numerical prefix."
5641 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5643 (defun gnus-article-delete-part (n)
5644 "Delete MIME part N and add some information about the removed part.
5645 N is the numerical prefix."
5647 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5649 (defun gnus-article-view-part-as-type (n)
5650 "Choose a MIME media type, and view part N as such.
5651 N is the numerical prefix."
5653 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5655 (defun gnus-article-mime-match-handle-first (condition)
5658 (dolist (ihandle gnus-article-mime-handle-alist)
5660 ((functionp condition)
5661 (funcall condition (cdr ihandle)))
5662 ((eq condition 'undisplayed)
5663 (not (or (mm-handle-undisplayer (cdr ihandle))
5664 (equal (mm-handle-media-type (cdr ihandle))
5665 "multipart/alternative"))))
5666 ((eq condition 'undisplayed-alternative)
5667 (not (mm-handle-undisplayer (cdr ihandle))))
5669 (gnus-article-goto-part (car ihandle))
5670 (or (not n) (< (car ihandle) n)))
5671 (setq n (car ihandle))))
5675 (defun gnus-article-view-part (&optional n)
5676 "View MIME part N, which is the numerical prefix.
5677 If the part is already shown, hide the part. If N is nil, view
5680 (with-current-buffer gnus-article-buffer
5681 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5682 gnus-article-mime-match-handle-function)))
5683 (when (> n (length gnus-article-mime-handle-alist))
5684 (error "No such part"))
5685 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5686 (when (gnus-article-goto-part n)
5687 (if (equal (car handle) "multipart/alternative")
5689 (beginning-of-line) ;; Make it toggle subparts
5690 (gnus-article-press-button))
5691 (when (eq (gnus-mm-display-part handle) 'internal)
5692 (gnus-set-window-start)))))))
5694 (defsubst gnus-article-mime-total-parts ()
5695 (if (bufferp (car gnus-article-mime-handles))
5697 (1- (length gnus-article-mime-handles))))
5699 (defun gnus-mm-display-part (handle)
5700 "Display HANDLE and fix MIME button."
5701 (let ((id (get-text-property (point) 'gnus-part))
5703 (inhibit-read-only t)
5704 (window (selected-window))
5705 (mail-parse-charset gnus-newsgroup-charset)
5706 (mail-parse-ignored-charsets
5707 (if (gnus-buffer-live-p gnus-summary-buffer)
5708 (with-current-buffer gnus-summary-buffer
5709 gnus-newsgroup-ignored-charsets)
5714 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5718 (setq start (next-single-property-change point 'gnus-data
5720 point (previous-single-property-change start 'gnus-data))
5721 (if (mm-handle-displayed-p handle)
5722 ;; This will remove the part.
5723 (setq retval (mm-display-part handle))
5724 (let ((part (or (and (mm-inlinable-p handle)
5725 (mm-inlined-p handle)
5728 (gnus-bind-safe-url-regexp
5729 (setq retval (mm-display-part handle)))
5730 (unless (zerop (buffer-size))
5731 (buffer-string))))))
5734 ;; This is a header button.
5736 (cond ((stringp part)
5738 (narrow-to-region (point)
5741 (unless (bolp) (insert "\n"))
5743 (gnus-treat-article nil id
5744 (gnus-article-mime-total-parts)
5745 (mm-handle-media-type handle))
5746 (mm-handle-set-undisplayer
5749 (let ((inhibit-read-only t))
5750 (delete-region ,(copy-marker (point-min) t)
5751 ,(point-max-marker)))))))
5753 (mm-display-inline handle))))))
5755 ;; Toggle the button appearance between `[button]...' and `[button]'.
5756 (let ((displayed-p (mm-handle-displayed-p handle)))
5757 (gnus-insert-mime-button handle id (list displayed-p))
5758 (if (featurep 'emacs)
5761 (next-single-property-change (point) 'gnus-data nil (point-max)))
5762 (let* ((end (next-single-property-change (point) 'gnus-data))
5763 (annots (annotations-at (or end (point-max)))))
5764 (delete-region (point)
5766 (if annots (1+ end) end)
5768 (dolist (annot annots)
5769 (set-extent-endpoints annot (point) (point)))))
5770 (setq start (point))
5771 (if (search-backward "\n\n" nil t)
5774 (unless (or displayed-p (eolp))
5775 ;; Add extra newline.
5776 (insert (propertize (buffer-substring (1- start) start)
5777 'gnus-undeletable t))))
5778 ;; We're in the article header.
5780 (dolist (ovl (gnus-overlays-in point (point)))
5781 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5782 (gnus-overlay-put ovl 'face nil))
5784 (message-narrow-to-field)
5785 (let ((gnus-treatment-function-alist
5786 '((gnus-treat-highlight-headers
5787 gnus-article-highlight-headers))))
5788 (gnus-treat-article 'head)))))
5790 (if (window-live-p window)
5791 (select-window window)))
5794 (defun gnus-article-goto-part (n)
5795 "Go to MIME part N."
5796 (when gnus-break-pages
5800 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5801 ;; There may be header buttons.
5802 (text-property-any (point-min) (point) 'gnus-part n)))
5803 part handle end next handles)
5806 (if (setq handle (get-text-property start 'gnus-data))
5808 ;; Go to the displayed subpart, assuming this is
5809 ;; multipart/alternative.
5812 (while (and (not handle)
5815 (setq next (text-property-not-all part end
5818 handle (get-text-property part 'gnus-data))
5819 (push (cons handle part) handles)
5820 (unless (mm-handle-displayed-p handle)
5822 part (text-property-any part end 'gnus-data nil))))
5824 ;; No subpart is displayed, so we find preferred one.
5826 (cdr (assq (mm-preferred-alternative
5827 (nreverse (mapcar 'car handles)))
5830 (goto-char (1+ part))
5832 (when gnus-break-pages
5833 (gnus-narrow-to-page))))
5835 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5836 (let ((gnus-tmp-name
5837 (or (mm-handle-filename handle)
5838 (mail-content-type-get (mm-handle-type handle) 'url)
5840 (gnus-tmp-type (mm-handle-media-type handle))
5841 (gnus-tmp-description (or (mm-handle-description handle) ""))
5843 (if (if displayed (car displayed)
5844 (mm-handle-displayed-p handle))
5846 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5848 gnus-tmp-type-long b e)
5849 (when (string-match ".*/" gnus-tmp-name)
5850 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5851 (setq gnus-tmp-type-long (concat gnus-tmp-type
5852 (and (not (equal gnus-tmp-name ""))
5853 (concat "; " gnus-tmp-name))))
5854 (unless (equal gnus-tmp-description "")
5855 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5858 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5859 `(keymap ,gnus-mime-button-map
5860 gnus-callback gnus-mm-display-part
5861 gnus-part ,gnus-tmp-id
5862 article-type annotation
5866 ;; Exclude a newline.
5869 (when gnus-article-button-face
5870 (gnus-overlay-put (gnus-make-overlay b e nil t)
5871 'face gnus-article-button-face))
5872 (widget-convert-button
5875 :action 'gnus-widget-press-button
5876 :button-keymap gnus-mime-button-map
5879 ;; Needed to properly clear the message due to a bug in
5880 ;; wid-edit (XEmacs only).
5881 (if (boundp 'help-echo-owns-message)
5882 (setq help-echo-owns-message t))
5884 "%S: %s the MIME part; %S: more options"
5885 (aref gnus-mouse-2 0)
5886 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5888 (aref gnus-down-mouse-3 0))))))
5890 (defun gnus-widget-press-button (elems el)
5891 (goto-char (widget-get elems :from))
5892 (gnus-article-press-button))
5894 (defvar gnus-displaying-mime nil)
5896 (defun gnus-display-mime (&optional ihandles)
5897 "Display the MIME parts."
5899 (save-selected-window
5900 (let ((window (get-buffer-window gnus-article-buffer))
5903 (select-window window)
5904 ;; We have to do this since selecting the window
5905 ;; may change the point. So we set the window point.
5906 (set-window-point window point)))
5907 (let ((handles ihandles)
5908 (inhibit-read-only t)
5911 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5912 (when gnus-article-emulate-mime
5913 (mm-uu-dissect-text-parts handles)))
5914 (gnus-article-emulate-mime
5915 (setq handles (mm-uu-dissect))))
5916 (when (and (not ihandles)
5917 (not gnus-displaying-mime))
5918 ;; Top-level call; we clean up.
5919 (when gnus-article-mime-handles
5920 (mm-destroy-parts gnus-article-mime-handles)
5921 (setq gnus-article-mime-handle-alist nil));; A trick.
5922 (setq gnus-article-mime-handles handles)
5923 ;; We allow users to glean info from the handles.
5924 (when gnus-article-mime-part-function
5925 (gnus-mime-part-function handles)))
5927 (or (not (stringp (car handles)))
5930 (when (and (not ihandles)
5931 (not gnus-displaying-mime))
5932 ;; Clean up for mime parts.
5934 (delete-region (point) (point-max)))
5935 (let ((gnus-displaying-mime t))
5936 (gnus-mime-display-part handles)))
5939 (narrow-to-region (point) (point-max))
5940 (gnus-treat-article nil 1 1 "text/plain")
5943 ;; Highlight the headers.
5947 (narrow-to-region (point-min) (point))
5948 (gnus-article-save-original-date
5949 (gnus-treat-article 'head)))))))
5950 ;; Cope with broken MIME messages.
5951 (goto-char (point-max))
5955 (defcustom gnus-mime-display-multipart-as-mixed nil
5956 "Display \"multipart\" parts as \"multipart/mixed\".
5958 If t, it overrides nil values of
5959 `gnus-mime-display-multipart-alternative-as-mixed' and
5960 `gnus-mime-display-multipart-related-as-mixed'."
5961 :group 'gnus-article-mime
5964 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5965 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5967 :group 'gnus-article-mime
5970 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5971 "Display \"multipart/related\" parts as \"multipart/mixed\".
5973 If displaying \"text/html\" is discouraged \(see
5974 `mm-discouraged-alternatives'\) images or other material inside a
5975 \"multipart/related\" part might be overlooked when this variable is nil."
5977 :group 'gnus-article-mime
5980 (defcustom gnus-mime-display-attachment-buttons-in-header t
5981 "Add attachment buttons in the end of the header of an article.
5982 Since MIME attachments tend to be put at the end of an article, we may
5983 overlook them if there is a huge body. This option offers you a copy
5984 of all non-inlinable MIME parts as buttons shown in front of an article.
5985 If nil, don't show those extra buttons."
5987 :group 'gnus-article-mime
5990 (defun gnus-mime-display-part (handle)
5992 ;; Maybe a broken MIME message.
5995 ((not (stringp (car handle)))
5996 (gnus-mime-display-single handle))
5997 ;; User-defined multipart
5998 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5999 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
6001 ;; multipart/alternative
6002 ((and (equal (car handle) "multipart/alternative")
6003 (not (or gnus-mime-display-multipart-as-mixed
6004 gnus-mime-display-multipart-alternative-as-mixed)))
6005 (let ((id (1+ (length gnus-article-mime-handle-alist))))
6006 (push (cons id handle) gnus-article-mime-handle-alist)
6007 (gnus-mime-display-alternative (cdr handle) nil nil id)))
6008 ;; multipart/related
6009 ((and (equal (car handle) "multipart/related")
6010 (not (or gnus-mime-display-multipart-as-mixed
6011 gnus-mime-display-multipart-related-as-mixed)))
6012 (gnus-mime-display-part (cadr handle)))
6013 ((equal (car handle) "multipart/signed")
6014 (gnus-add-wash-type 'signed)
6015 (gnus-mime-display-security handle))
6016 ((equal (car handle) "multipart/encrypted")
6017 (gnus-add-wash-type 'encrypted)
6018 (gnus-mime-display-security handle))
6019 ;; Other multiparts are handled like multipart/mixed.
6021 (gnus-mime-display-mixed (cdr handle)))))
6023 (defun gnus-mime-part-function (handles)
6024 (if (stringp (car handles))
6025 (mapcar 'gnus-mime-part-function (cdr handles))
6026 (funcall gnus-article-mime-part-function handles)))
6028 (defun gnus-mime-display-mixed (handles)
6029 (mapcar 'gnus-mime-display-part handles))
6031 (defun gnus-mime-display-single (handle)
6032 (let ((type (mm-handle-media-type handle))
6033 (ignored gnus-ignored-mime-types)
6039 (when (string-match (pop ignored) type)
6040 (throw 'ignored nil)))
6041 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6042 (with-current-buffer gnus-summary-buffer
6043 gnus-inhibit-images)
6044 gnus-inhibit-images)
6045 (string-match "\\`image/" type)))
6046 (setq not-attachment
6047 (and (not (mm-inline-override-p handle))
6048 (or (not (mm-handle-disposition handle))
6049 (equal (car (mm-handle-disposition handle))
6051 (mm-attachment-override-p handle))))
6052 (mm-automatic-display-p handle)
6054 (mm-inlinable-p handle)
6055 (mm-inlined-p handle))
6056 (mm-automatic-external-display-p type)))
6058 (when (equal (mm-handle-media-supertype handle) "text")
6060 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6063 (setq id (1+ (length gnus-article-mime-handle-alist)))
6064 (push (cons id handle) gnus-article-mime-handle-alist))
6066 (equal (mm-handle-media-supertype handle) "message"))
6069 (cond ((not (bolp)) 2)
6070 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6072 (when (or (not display)
6073 (not (gnus-unbuttonized-mime-type-p type))
6074 (eq id gnus-mime-buttonized-part-id))
6075 (gnus-insert-mime-button
6076 handle id (list (or display (and not-attachment text)))))
6080 (let ((mail-parse-charset gnus-newsgroup-charset)
6081 (mail-parse-ignored-charsets
6082 (save-excursion (condition-case ()
6083 (set-buffer gnus-summary-buffer)
6085 gnus-newsgroup-ignored-charsets)))
6086 (gnus-bind-safe-url-regexp (mm-display-part handle t))))
6087 ((and text not-attachment)
6088 (mm-display-inline handle)))
6089 (goto-char (point-max))
6090 (if (string-match "\\`image/" type)
6091 (gnus-article-insert-newline)
6093 (= (skip-chars-backward "\n") -1)
6095 (gnus-article-insert-newline)
6096 (put-text-property (point) (point-max) 'gnus-undeletable t))
6097 (goto-char (point-max)))
6101 (narrow-to-region beg (point))
6102 (if (eq handle gnus-article-mime-handles)
6103 ;; The format=flowed case.
6104 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6105 ;; Don't count signature parts that are never displayed.
6106 ;; The part number should be re-calculated supposing this
6107 ;; might be a message/rfc822 part.
6109 (dolist (part gnus-article-mime-handles)
6110 (unless (or (stringp part)
6111 (equal (car (mm-handle-type part))
6112 "application/pgp-signature"))
6113 (push part handles)))
6115 nil (length (memq handle handles)) (length handles)
6116 (mm-handle-media-type handle)))))))))))
6118 (defun gnus-unbuttonized-mime-type-p (type)
6119 "Say whether TYPE is to be unbuttonized."
6120 (unless gnus-inhibit-mime-unbuttonizing
6122 (let ((types gnus-unbuttonized-mime-types))
6124 (when (string-match (pop types) type)
6125 (throw 'found t)))))
6127 (let ((types gnus-buttonized-mime-types))
6129 (when (string-match (pop types) type)
6130 (throw 'found t)))))))))
6132 (defun gnus-article-insert-newline ()
6133 "Insert a newline, but mark it as undeletable."
6134 (gnus-put-text-property
6135 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6137 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6138 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6141 handle (inhibit-read-only t) from props begend not-pref)
6142 (save-window-excursion
6145 (narrow-to-region (car ibegend)
6148 (goto-char (car ibegend))
6151 (delete-region (point-min) (point-max))
6152 (mm-remove-parts handles))
6153 (setq begend (list (point-marker)))
6155 (unless (setq not-pref (cadr (member preferred ihandles)))
6156 (setq not-pref (car ihandles)))
6159 (not (gnus-unbuttonized-mime-type-p
6160 "multipart/alternative")))
6161 (gnus-add-text-properties
6164 (insert (format "%d. " id))
6168 (unless ,(not ibegend)
6169 (setq gnus-article-mime-handle-alist
6170 ',gnus-article-mime-handle-alist))
6171 (gnus-mime-display-alternative
6172 ',ihandles ',not-pref ',begend ,id))
6173 keymap ,gnus-mime-button-map
6174 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6175 face ,gnus-article-button-face
6177 article-type multipart
6179 (widget-convert-button 'link from (point)
6180 :action 'gnus-widget-press-button
6181 :button-keymap gnus-widget-button-keymap)
6183 (while (setq handle (pop handles))
6184 (gnus-add-text-properties
6187 (insert (format "(%c) %-18s"
6188 (if (equal handle preferred) ?* ? )
6189 (mm-handle-media-type handle)))
6193 (unless ,(not ibegend)
6194 (setq gnus-article-mime-handle-alist
6195 ',gnus-article-mime-handle-alist))
6196 (gnus-mime-display-alternative
6197 ',ihandles ',handle ',begend ,id))
6198 keymap ,gnus-mime-button-map
6199 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6200 face ,gnus-article-button-face
6204 (widget-convert-button 'link from (point)
6205 :action 'gnus-widget-press-button
6206 :button-keymap gnus-widget-button-keymap)
6210 (if (stringp (car preferred))
6211 (gnus-display-mime preferred)
6212 (let ((mail-parse-charset gnus-newsgroup-charset)
6213 (mail-parse-ignored-charsets
6214 (with-current-buffer gnus-summary-buffer
6215 gnus-newsgroup-ignored-charsets)))
6216 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6220 (narrow-to-region (car begend) (point-max))
6222 nil (length gnus-article-mime-handle-alist)
6223 (gnus-article-mime-total-parts)
6224 (mm-handle-media-type preferred))))))
6225 (goto-char (point-max))
6226 (setcdr begend (point-marker)))))
6229 ;; Redraw attachment buttons in the header.
6230 (when gnus-mime-display-attachment-buttons-in-header
6231 (gnus-mime-buttonize-attachments-in-header)))
6233 (defconst gnus-article-wash-status-strings
6234 (let ((alist '((cite "c" "Possible hidden citation text"
6235 " " "All citation text visible")
6236 (headers "h" "Hidden headers"
6237 " " "All headers visible.")
6238 (pgp "p" "Encrypted or signed message status hidden"
6239 " " "No hidden encryption nor digital signature status")
6240 (signature "s" "Signature has been hidden"
6241 " " "Signature is visible")
6242 (overstrike "o" "Overstrike (^H) characters applied"
6243 " " "No overstrike characters applied")
6244 (emphasis "e" "/*_Emphasis_*/ characters applied"
6245 " " "No /*_emphasis_*/ characters applied")))
6247 (dolist (entry alist result)
6248 (let ((key (nth 0 entry))
6249 (on (copy-sequence (nth 1 entry)))
6250 (on-help (nth 2 entry))
6251 (off (copy-sequence (nth 3 entry)))
6252 (off-help (nth 4 entry)))
6253 (put-text-property 0 1 'help-echo on-help on)
6254 (put-text-property 0 1 'help-echo off-help off)
6255 (push (list key on off) result))))
6256 "Alist of strings describing wash status in the mode line.
6257 Each entry has the form (KEY ON OF), where the KEY is a symbol
6258 representing the particular washing function, ON is the string to use
6259 in the article mode line when the washing function is active, and OFF
6260 is the string to use when it is inactive.")
6262 (defun gnus-article-wash-status-entry (key value)
6263 (let ((entry (assoc key gnus-article-wash-status-strings)))
6264 (if value (nth 1 entry) (nth 2 entry))))
6266 (defun gnus-article-wash-status ()
6267 "Return a string which display status of article washing."
6268 (with-current-buffer gnus-article-buffer
6269 (let ((cite (memq 'cite gnus-article-wash-types))
6270 (headers (memq 'headers gnus-article-wash-types))
6271 (boring (memq 'boring-headers gnus-article-wash-types))
6272 (pgp (memq 'pgp gnus-article-wash-types))
6273 (pem (memq 'pem gnus-article-wash-types))
6274 (signed (memq 'signed gnus-article-wash-types))
6275 (encrypted (memq 'encrypted gnus-article-wash-types))
6276 (signature (memq 'signature gnus-article-wash-types))
6277 (overstrike (memq 'overstrike gnus-article-wash-types))
6278 (emphasis (memq 'emphasis gnus-article-wash-types)))
6280 (gnus-article-wash-status-entry 'cite cite)
6281 (gnus-article-wash-status-entry 'headers (or headers boring))
6282 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6283 (gnus-article-wash-status-entry 'signature signature)
6284 (gnus-article-wash-status-entry 'overstrike overstrike)
6285 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6287 (defun gnus-add-wash-type (type)
6288 "Add a washing of TYPE to the current status."
6289 (add-to-list 'gnus-article-wash-types type))
6291 (defun gnus-delete-wash-type (type)
6292 "Add a washing of TYPE to the current status."
6293 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6295 (defun gnus-add-image (category image)
6296 "Add IMAGE of CATEGORY to the list of displayed images."
6297 (let ((entry (assq category gnus-article-image-alist)))
6299 (setq entry (list category))
6300 (push entry gnus-article-image-alist))
6301 (nconc entry (list image))))
6303 (defun gnus-delete-images (category)
6304 "Delete all images in CATEGORY."
6305 (let ((entry (assq category gnus-article-image-alist)))
6306 (dolist (image (cdr entry))
6307 (gnus-remove-image image category))
6308 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6309 (gnus-delete-wash-type category)))
6311 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6313 (defun gnus-article-maybe-hide-headers ()
6314 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6315 Provided for backwards compatibility."
6316 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6317 (not (with-current-buffer gnus-summary-buffer
6318 gnus-have-all-headers)))
6319 (not gnus-inhibit-hiding))
6320 (gnus-article-hide-headers)))
6322 (declare-function shr-put-image "shr" (data alt &optional flags))
6324 (defun gnus-shr-put-image (data alt &optional flags)
6325 "Put image DATA with a string ALT. Enable image to be deleted."
6326 (let ((image (if flags
6327 (shr-put-image data (propertize (or alt "*")
6328 'gnus-image-category 'shr)
6330 ;; Old `shr-put-image' doesn't take the optional `flags'
6332 (shr-put-image data (propertize (or alt "*")
6333 'gnus-image-category 'shr)))))
6335 (gnus-add-image 'shr image))))
6337 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6338 "Show attachments as buttons in the end of the header of an article.
6339 This function toggles the display when called interactively. Note that
6340 buttons to be added to the header are only the ones that aren't inlined
6341 in the body. Use `gnus-header-face-alist' to highlight buttons."
6342 (interactive (list t))
6343 (gnus-with-article-buffer
6345 ;; Function that returns a flattened version of
6346 ;; `gnus-article-mime-handle-alist'.
6348 (&optional alist id all)
6350 (let ((i 1) newid flat)
6351 (dolist (handle alist flat)
6352 (setq newid (append id (list i))
6354 (if (stringp (car handle))
6355 (setq flat (nconc flat (flattened-alist (cdr handle)
6357 (delq (rassq handle all) all)
6358 (setq flat (nconc flat (list (cons newid handle)))))))
6359 (let ((flat (list nil)))
6360 ;; Assume that elements of `gnus-article-mime-handle-alist'
6361 ;; are in the decreasing order, but unnumbered subsidiaries
6362 ;; in each element are in the increasing order.
6363 (dolist (handle (reverse gnus-article-mime-handle-alist))
6364 (if (stringp (cadr handle))
6365 (setq flat (nconc flat (flattened-alist (cddr handle)
6368 (delq (rassq (cdr handle) flat) flat)
6369 (setq flat (nconc flat (list (cons (list (car handle))
6371 (setq flat (cdr flat))
6372 (mapc (lambda (handle)
6374 ;; This is a hidden (i.e. unnumbered) handle.
6377 (1+ (caar gnus-article-mime-handle-alist)))
6378 (push handle gnus-article-mime-handle-alist))
6379 (setcar handle (caar handle))))
6382 (let ((case-fold-search t) buttons handle type st)
6386 (article-narrow-to-head)
6387 ;; Header buttons exist?
6388 (while (and (not buttons)
6389 (re-search-forward "^attachments?:[\n ]+" nil t))
6390 (when (get-char-property (match-end 0)
6391 'gnus-button-attachment-extra)
6392 (setq buttons (match-beginning 0))))
6395 ;; Delete header buttons.
6396 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6399 (unless (and interactive buttons)
6402 (dolist (button (flattened-alist))
6403 (setq handle (cdr button)
6404 type (mm-handle-media-type handle))
6405 (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
6406 (with-current-buffer gnus-summary-buffer
6407 gnus-inhibit-images)
6408 gnus-inhibit-images)
6409 (string-match "\\`image/" type))
6410 (mm-inline-override-p handle)
6411 (and (mm-handle-disposition handle)
6412 (not (equal (car (mm-handle-disposition handle))
6414 (not (mm-attachment-override-p handle)))
6415 (not (mm-automatic-display-p handle))
6416 (not (or (and (mm-inlinable-p handle)
6417 (mm-inlined-p handle))
6418 (mm-automatic-external-display-p type))))
6419 (push button buttons)))
6421 ;; Add header buttons.
6424 (narrow-to-region (point) (point))
6425 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6426 (dolist (button (nreverse buttons))
6429 (mm-handle-set-undisplayer
6430 (setq handle (copy-sequence (cdr button))) nil)
6431 (gnus-insert-mime-button handle (car button))
6432 (skip-chars-backward "\t\n ")
6433 (delete-region (point) (point-max))
6434 (when (> (current-column) (window-width))
6439 (dolist (ovl (gnus-overlays-in (point-min) (point)))
6440 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
6441 (gnus-overlay-put ovl 'face nil))
6442 (let ((gnus-treatment-function-alist
6443 '((gnus-treat-highlight-headers
6444 gnus-article-highlight-headers))))
6445 (gnus-treat-article 'head))))))))))
6449 (defun gnus-output-to-file (file-name)
6450 "Append the current article to a file named FILE-NAME.
6451 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6452 text and used as the value of the coding cookie which is added to the
6453 top of a file. Otherwise, this function saves a raw article without
6455 (let* ((artbuf (current-buffer))
6456 (file-name-coding-system nnmail-pathname-coding-system)
6457 (coding gnus-article-save-coding-system)
6458 (coding-system-for-read (if coding
6459 nil ;; Rely on the coding cookie.
6460 mm-text-coding-system))
6461 (coding-system-for-write (or coding
6462 mm-text-coding-system-for-write
6463 mm-text-coding-system))
6464 (exists (file-exists-p file-name)))
6467 (insert-file-contents file-name)
6468 (goto-char (point-min))
6469 ;; Remove the existing coding cookie.
6470 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6471 (delete-region (match-beginning 0) (match-end 0))))
6472 (goto-char (point-max))
6473 (insert-buffer-substring artbuf)
6474 ;; Append newline at end of the buffer as separator, and then
6476 (goto-char (point-max))
6479 ;; If the coding system is not suitable to encode the text,
6480 ;; ask a user for a proper one.
6481 (when (fboundp 'select-safe-coding-system)
6482 (setq coding (coding-system-base
6483 (save-window-excursion
6484 (select-safe-coding-system (point-min) (point-max)
6486 (setq coding-system-for-write
6487 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6489 (goto-char (point-min))
6490 ;; Add the coding cookie.
6491 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6492 coding-system-for-write)))
6495 (write-region (point-min) (point-max) file-name nil 'no-message)
6496 (message "Appended to %s" file-name))
6497 (write-region (point-min) (point-max) file-name))))
6500 (defun gnus-narrow-to-page (&optional arg)
6501 "Narrow the article buffer to a page.
6502 If given a numerical ARG, move forward ARG pages."
6504 (setq arg (if arg (prefix-numeric-value arg) 0))
6505 (with-current-buffer gnus-article-buffer
6507 ;; Remove any old next/prev buttons.
6508 (when (gnus-visual-p 'page-marker)
6509 (let ((inhibit-read-only t))
6510 (gnus-remove-text-with-property 'gnus-prev)
6511 (gnus-remove-text-with-property 'gnus-next)))
6513 (when (save-excursion
6515 (if (re-search-backward page-delimiter nil 'move (abs arg))
6517 (setq nd (match-beginning 0)
6519 (when (re-search-backward page-delimiter nil t)
6520 (setq st (match-end 0))))
6521 (when (re-search-forward page-delimiter nil t)
6522 (setq nd (match-beginning 0)
6525 (if (re-search-forward page-delimiter nil 'move arg)
6527 (setq st (match-end 0)
6529 (when (re-search-forward page-delimiter nil t)
6530 (setq nd (match-beginning 0))))
6531 (when (re-search-backward page-delimiter nil t)
6532 (setq st (match-end 0)
6535 (when (re-search-backward page-delimiter nil t)
6536 (goto-char (setq st (match-end 0))))
6537 (when (re-search-forward page-delimiter nil t)
6538 (setq nd (match-beginning 0)))
6540 (setq gnus-page-broken t)
6541 (when pt (goto-char pt))
6542 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6543 (when (gnus-visual-p 'page-marker)
6547 (gnus-insert-next-page-button))
6550 (gnus-insert-prev-page-button))))))))
6552 ;; Article mode commands
6554 (defun gnus-article-goto-next-page ()
6555 "Show the next page of the article."
6557 (when (gnus-article-next-page)
6558 (goto-char (point-min))
6559 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6562 (defun gnus-article-goto-prev-page ()
6563 "Show the previous page of the article."
6565 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6566 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6567 (gnus-article-prev-page nil)))
6569 ;; This is cleaner but currently breaks `gnus-pick-mode':
6571 ;; (defun gnus-article-goto-next-page ()
6572 ;; "Show the next page of the article."
6574 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6575 ;; (gnus-summary-next-page)))
6577 ;; (defun gnus-article-goto-prev-page ()
6578 ;; "Show the next page of the article."
6580 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6581 ;; (gnus-summary-prev-page)))
6583 (defun gnus-article-next-page (&optional lines)
6584 "Show the next page of the current article.
6585 If end of article, return non-nil. Otherwise return nil.
6586 Argument LINES specifies lines to be scrolled up."
6588 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6589 (if (and (not (and gnus-article-over-scroll
6590 (> (count-lines (window-start) (point-max))
6591 (if (featurep 'xemacs)
6592 (or lines (1- (window-height)))
6593 (+ (or lines (1- (window-height))) scroll-margin)))))
6596 (and (pos-visible-in-window-p) ;Not continuation line.
6597 (>= (point) (point-max)))))
6598 ;; Nothing in this page.
6599 (if (or (not gnus-page-broken)
6604 (eobp)))) ;Real end-of-buffer?
6606 (when gnus-article-over-scroll
6607 (gnus-article-next-page-1 lines))
6609 (gnus-narrow-to-page 1) ;Go to next page.
6611 ;; More in this page.
6612 (gnus-article-next-page-1 lines)
6615 (defun gnus-article-beginning-of-window ()
6616 "Move point to the beginning of the window.
6617 In Emacs, the point is placed at the line number which `scroll-margin'
6619 (if (featurep 'xemacs)
6620 (move-to-window-line 0)
6621 ;; There is an obscure bug in Emacs that makes it impossible to
6622 ;; scroll past big pictures in the article buffer. Try to fix
6623 ;; this by adding a sanity check by counting the lines visible.
6624 (when (> (count-lines (window-start) (window-end)) 30)
6625 (move-to-window-line
6626 (min (max 0 scroll-margin)
6627 (max 1 (- (window-height)
6628 (if mode-line-format 1 0)
6629 (if header-line-format 1 0)
6632 (defun gnus-article-next-page-1 (lines)
6634 (let ((scroll-in-place nil)
6635 (auto-window-vscroll nil))
6638 ;; Long lines may cause an end-of-buffer error.
6639 (goto-char (point-max))))
6640 (gnus-article-beginning-of-window))
6642 (defun gnus-article-prev-page (&optional lines)
6643 "Show previous page of current article.
6644 Argument LINES specifies lines to be scrolled down."
6646 (move-to-window-line 0)
6647 (if (and gnus-page-broken
6649 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6651 (gnus-narrow-to-page -1) ;Go to previous page.
6652 (goto-char (point-max))
6653 (recenter (if gnus-article-over-scroll
6655 (max (if (featurep 'xemacs)
6657 (+ lines scroll-margin))
6659 (- (window-height) 2))
6663 (let ((scroll-in-place nil))
6664 (scroll-down lines))
6665 (beginning-of-buffer
6666 (goto-char (point-min))))
6667 (gnus-article-beginning-of-window))))
6669 (defun gnus-article-only-boring-p ()
6670 "Decide whether there is only boring text remaining in the article.
6671 Something \"interesting\" is a word of at least two letters that does
6672 not have a face in `gnus-article-boring-faces'."
6673 (when (and gnus-article-skip-boring
6674 (boundp 'gnus-article-boring-faces)
6675 (symbol-value 'gnus-article-boring-faces))
6677 (let ((inhibit-point-motion-hooks t))
6679 (while (re-search-forward "\\b\\w\\w" nil t)
6681 (when (not (gnus-intersection
6682 (gnus-faces-at (point))
6683 (symbol-value 'gnus-article-boring-faces)))
6684 (throw 'only-boring nil)))
6685 (throw 'only-boring t))))))
6687 (defun gnus-article-refer-article ()
6688 "Read article specified by message-id around point."
6691 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6692 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6693 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6694 (let ((msg-id (concat "<" (match-string 0) ">")))
6695 (set-buffer gnus-summary-buffer)
6696 (gnus-summary-refer-article msg-id))
6697 (error "No references around point"))))
6699 (defun gnus-article-show-summary ()
6700 "Reconfigure windows to show summary buffer."
6702 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6703 (error "There is no summary buffer for this article buffer")
6704 (gnus-article-set-globals)
6705 (gnus-configure-windows 'article)
6706 (gnus-summary-goto-subject gnus-current-article)
6707 (gnus-summary-position-point)))
6709 (defun gnus-article-describe-briefly ()
6710 "Describe article mode commands briefly."
6712 (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")))
6714 (defun gnus-article-check-buffer ()
6715 "Beep if not in an article buffer."
6716 (unless (derived-mode-p 'gnus-article-mode)
6717 (error "Command invoked outside of a Gnus article buffer")))
6719 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6720 "Read a summary buffer key sequence and execute it from the article buffer."
6722 (gnus-article-check-buffer)
6724 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6725 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6726 "=" "^" "\M-^" "|"))
6728 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6729 "An" "Ap" [?A (meta return)] [?A delete]))
6733 '("n" "Gn" "p" "Gp"))
6735 (with-current-buffer gnus-article-current-summary
6736 (let (gnus-pick-mode)
6737 (setq unread-command-events (nconc unread-command-events
6738 (list (or key last-command-event)))
6739 keys (if (featurep 'xemacs)
6740 (events-to-keys (read-key-sequence nil t))
6741 (read-key-sequence nil t)))))
6746 ((eq (aref keys (1- (length keys))) ?\C-h)
6747 (gnus-article-describe-bindings (substring keys 0 -1)))
6748 ((or (member keys nosaves)
6749 (member keys nosave-but-article)
6750 (member keys nosave-in-article))
6752 (save-window-excursion
6753 (pop-to-buffer gnus-article-current-summary)
6754 ;; We disable the pick minor mode commands.
6755 (let (gnus-pick-mode)
6756 (setq func (key-binding keys t))))
6760 (unless (member keys nosave-in-article)
6761 (set-buffer gnus-article-current-summary))
6762 (when (and (symbolp func)
6763 (get func 'disabled))
6764 (error "Function %s disabled" func))
6765 (call-interactively func)
6766 (setq new-sum-point (point)))
6767 (when (member keys nosave-but-article)
6768 (pop-to-buffer gnus-article-buffer))))
6770 ;; These commands should restore window configuration.
6771 (let ((obuf (current-buffer))
6772 (owin (current-window-configuration))
6773 win func in-buffer selected new-sum-start new-sum-hscroll err)
6774 (cond (not-restore-window
6775 (pop-to-buffer gnus-article-current-summary)
6776 (setq win (selected-window)))
6777 ((setq win (get-buffer-window gnus-article-current-summary))
6778 (select-window win))
6780 (let ((summary-buffer gnus-article-current-summary))
6781 (gnus-configure-windows 'article)
6782 (unless (setq win (get-buffer-window summary-buffer 'visible))
6783 (let ((gnus-buffer-configuration
6784 '((article ((vertical 1.0
6785 (summary 0.25 point)
6787 (gnus-configure-windows 'article))
6788 (setq win (get-buffer-window summary-buffer 'visible)))
6789 (gnus-select-frame-set-input-focus (window-frame win))
6790 (select-window win))))
6791 (setq in-buffer (current-buffer))
6792 ;; We disable the pick minor mode commands.
6793 (setq func (let (gnus-pick-mode)
6794 (key-binding keys t)))
6795 (when (get func 'disabled)
6796 (error "Function %s disabled" func))
6799 (condition-case code
6801 (call-interactively func)
6807 (when (eq win (selected-window))
6808 (setq new-sum-point (point)
6809 new-sum-start (window-start win)
6810 new-sum-hscroll (window-hscroll win)))
6811 (when (or (eq in-buffer (current-buffer))
6812 (when (eq obuf (current-buffer))
6813 (set-buffer in-buffer)
6815 (setq selected (ignore-errors (gnus-summary-select-article)))
6817 (unless not-restore-window
6818 (set-window-configuration owin))
6819 (when (and (eq selected 'old)
6821 (set-window-start (get-buffer-window (current-buffer))
6823 (set-window-point (get-buffer-window (current-buffer))
6824 (if (article-goto-body)
6827 (when (and (not not-restore-window)
6830 (with-current-buffer (window-buffer win)
6831 (derived-mode-p 'gnus-summary-mode)))
6832 (set-window-point win new-sum-point)
6833 (set-window-start win new-sum-start)
6834 (set-window-hscroll win new-sum-hscroll))))
6835 (set-window-configuration owin)
6837 (signal (car err) (cdr err))
6840 (defun gnus-article-read-summary-send-keys ()
6842 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6843 (gnus-article-read-summary-keys)))
6845 (defun gnus-article-describe-key (key)
6846 "Display documentation of the function invoked by KEY.
6847 KEY is a string or a vector."
6848 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6849 (read-key-sequence "Describe key: "))))
6850 (gnus-article-check-buffer)
6851 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6852 gnus-article-read-summary-send-keys))
6853 (with-current-buffer gnus-article-current-summary
6854 (setq unread-command-events
6855 (if (featurep 'xemacs)
6857 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6858 (list 'meta (- x 128))
6861 (let ((cursor-in-echo-area t)
6863 (describe-key (read-key-sequence nil t))))
6864 (describe-key key)))
6866 (defun gnus-article-describe-key-briefly (key &optional insert)
6867 "Display documentation of the function invoked by KEY.
6868 KEY is a string or a vector."
6869 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6870 (read-key-sequence "Describe key: "))
6871 current-prefix-arg))
6872 (gnus-article-check-buffer)
6873 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6874 gnus-article-read-summary-send-keys))
6875 (with-current-buffer gnus-article-current-summary
6876 (setq unread-command-events
6877 (if (featurep 'xemacs)
6879 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6880 (list 'meta (- x 128))
6883 (let ((cursor-in-echo-area t)
6885 (describe-key-briefly (read-key-sequence nil t) insert)))
6886 (describe-key-briefly key insert)))
6888 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6889 (defvar gnus-agent-summary-mode)
6890 (defvar gnus-draft-mode)
6891 (defvar help-xref-stack-item)
6893 (defun gnus-article-describe-bindings (&optional prefix)
6894 "Show a list of all defined keys, and their definitions.
6895 The optional argument PREFIX, if non-nil, should be a key sequence;
6896 then we display only bindings that start with that prefix."
6898 (gnus-article-check-buffer)
6899 (let ((keymap (copy-keymap gnus-article-mode-map))
6900 (map (copy-keymap gnus-article-send-map))
6901 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6903 (define-key keymap "S" map)
6904 (define-key map [t] nil)
6905 (with-current-buffer gnus-article-current-summary
6908 (if (setq parent (keymap-parent gnus-article-mode-map))
6910 (setq parent (copy-keymap parent))
6911 (set-keymap-parent parent (current-local-map)))
6912 (current-local-map)))
6913 (set-keymap-parent map (key-binding "S"))
6914 (let (key def gnus-pick-mode)
6916 (setq key (pop sumkeys))
6917 (cond ((and (vectorp key) (= (length key) 1)
6918 (consp (setq def (aref key 0)))
6919 (numberp (car def)) (numberp (cdr def)))
6920 (when (< (max (car def) (cdr def)) 128)
6924 (nreverse (gnus-uncompress-range def)))
6926 ((setq def (key-binding key))
6927 (unless (eq def 'undefined)
6928 (define-key keymap key def))))))
6929 (when (boundp 'gnus-agent-summary-mode)
6930 (setq agent gnus-agent-summary-mode))
6931 (when (boundp 'gnus-draft-mode)
6932 (setq draft gnus-draft-mode)))
6934 (use-local-map keymap)
6935 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6936 (set (make-local-variable 'gnus-draft-mode) draft)
6937 (describe-bindings prefix))
6938 (let ((item `((lambda (prefix)
6939 (with-current-buffer ,(current-buffer)
6940 (gnus-article-describe-bindings prefix)))
6942 ;; Loading `help-mode' here is necessary if `describe-bindings'
6943 ;; is replaced with something, e.g. `helm-descbinds'.
6944 (require 'help-mode)
6945 (with-current-buffer (let (help-xref-following) (help-buffer))
6946 (setq help-xref-stack-item item)))))
6948 (defun gnus-article-reply-with-original (&optional wide)
6949 "Start composing a reply mail to the current message.
6950 The text in the region will be yanked. If the region isn't active,
6951 the entire article will be yanked."
6953 (let ((article (cdr gnus-article-current))
6955 (if (not (gnus-region-active-p))
6956 (with-current-buffer gnus-summary-buffer
6957 (gnus-summary-reply (list (list article)) wide))
6958 (setq contents (buffer-substring (point) (mark t)))
6959 ;; Deactivate active regions.
6960 (when (and (boundp 'transient-mark-mode)
6961 transient-mark-mode)
6962 (setq mark-active nil))
6963 (with-current-buffer gnus-summary-buffer
6965 (list (list article contents)) wide)))))
6967 (defun gnus-article-wide-reply-with-original ()
6968 "Start composing a wide reply mail to the current message.
6969 The text in the region will be yanked. If the region isn't active,
6970 the entire article will be yanked."
6972 (gnus-article-reply-with-original t))
6974 (defun gnus-article-followup-with-original ()
6975 "Compose a followup to the current article.
6976 The text in the region will be yanked. If the region isn't active,
6977 the entire article will be yanked."
6979 (let ((article (cdr gnus-article-current))
6981 (if (not (gnus-region-active-p))
6982 (with-current-buffer gnus-summary-buffer
6983 (gnus-summary-followup (list (list article))))
6984 (setq contents (buffer-substring (point) (mark t)))
6985 ;; Deactivate active regions.
6986 (when (and (boundp 'transient-mark-mode)
6987 transient-mark-mode)
6988 (setq mark-active nil))
6989 (with-current-buffer gnus-summary-buffer
6990 (gnus-summary-followup
6991 (list (list article contents)))))))
6993 (defun gnus-article-hide (&optional arg force)
6994 "Hide all the gruft in the current article.
6995 This means that signatures, cited text and (some) headers will be
6997 If given a prefix, show the hidden text instead."
6998 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6999 (gnus-article-hide-headers arg)
7000 (gnus-article-hide-list-identifiers arg)
7001 (gnus-article-hide-citation-maybe arg force)
7002 (gnus-article-hide-signature arg))
7004 (defun gnus-check-group-server ()
7005 ;; Make sure the connection to the server is alive.
7006 (unless (gnus-server-opened
7007 (gnus-find-method-for-group gnus-newsgroup-name))
7008 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7009 (gnus-request-group gnus-newsgroup-name t)))
7012 (autoload 'nneething-get-file-name "nneething"))
7014 (defun gnus-request-article-this-buffer (article group)
7015 "Get an article and insert it into this buffer."
7016 (let (do-update-line sparse-header)
7020 (gnus-kill-all-overlays)
7021 (setq group (or group gnus-newsgroup-name))
7023 ;; Using `gnus-request-article' directly will insert the article into
7024 ;; `nntp-server-buffer' - so we'll save some time by not having to
7025 ;; copy it from the server buffer into the article buffer.
7027 ;; We only request an article by message-id when we do not have the
7028 ;; headers for it, so we'll have to get those.
7029 (when (stringp article)
7030 (gnus-read-header article))
7032 ;; If the article number is negative, that means that this article
7033 ;; doesn't belong in this newsgroup (possibly), so we find its
7034 ;; message-id and request it by id instead of number.
7035 (when (and (numberp article)
7037 (get-buffer gnus-summary-buffer)
7038 (gnus-buffer-exists-p gnus-summary-buffer))
7039 (with-current-buffer gnus-summary-buffer
7040 (let ((header (gnus-summary-article-header article)))
7043 ((memq article gnus-newsgroup-sparse)
7044 ;; This is a sparse gap article.
7045 (setq do-update-line article)
7046 (setq article (mail-header-id header))
7047 (setq sparse-header (gnus-read-header article))
7048 (setq gnus-newsgroup-sparse
7049 (delq article gnus-newsgroup-sparse)))
7051 ;; It's a real article.
7052 (setq article (mail-header-id header)))
7054 ;; It is an extracted pseudo-article.
7055 (setq article 'pseudo)
7056 (gnus-request-pseudo-article header))))
7058 (let ((method (gnus-find-method-for-group
7059 gnus-newsgroup-name)))
7060 (when (and (eq (car method) 'nneething)
7062 (let ((dir (nneething-get-file-name
7063 (mail-header-id header))))
7064 (when (and (stringp dir)
7065 (file-directory-p dir))
7066 (setq article 'nneething)
7067 (gnus-group-enter-directory dir))))))))
7070 ;; Refuse to select canceled articles.
7071 ((and (numberp article)
7073 (get-buffer gnus-summary-buffer)
7074 (gnus-buffer-exists-p gnus-summary-buffer)
7075 (eq (cdr (with-current-buffer gnus-summary-buffer
7076 (assq article gnus-newsgroup-reads)))
7077 gnus-canceled-mark))
7079 ;; We first check `gnus-original-article-buffer'.
7080 ((and (get-buffer gnus-original-article-buffer)
7082 (with-current-buffer gnus-original-article-buffer
7083 (and (equal (car gnus-original-article) group)
7084 (eq (cdr gnus-original-article) article))))
7085 ;; `insert-buffer-substring' would incorrectly use the
7086 ;; equivalent of string-make-multibyte which amount to decoding
7087 ;; with locale-coding-system, causing failure of
7088 ;; subsequent decoding.
7089 (insert (mm-string-to-multibyte
7090 (with-current-buffer gnus-original-article-buffer
7091 (buffer-substring (point-min) (point-max)))))
7093 ;; Check the backlog.
7094 ((and gnus-keep-backlog
7095 (gnus-backlog-request-article group article (current-buffer)))
7097 ;; Check asynchronous pre-fetch.
7098 ((gnus-async-request-fetched-article group article (current-buffer))
7099 (gnus-async-prefetch-next group article gnus-summary-buffer)
7100 (when (and (numberp article) gnus-keep-backlog)
7101 (gnus-backlog-enter-article group article (current-buffer)))
7104 ((and gnus-use-cache
7106 (gnus-cache-request-article article group))
7108 ;; Check the agent cache.
7109 ((gnus-agent-request-article article group)
7111 ;; Get the article and put into the article buffer.
7112 ((or (stringp article)
7114 (let ((gnus-override-method gnus-override-method)
7115 (methods (and (stringp article)
7116 (with-current-buffer gnus-summary-buffer
7117 (gnus-refer-article-methods))))
7118 (backend (car (gnus-find-method-for-group
7119 gnus-newsgroup-name)))
7121 (inhibit-read-only t))
7122 (when (and (null gnus-override-method)
7124 (setq gnus-override-method (pop methods)))
7127 (gnus-kill-all-overlays)
7128 (let ((gnus-newsgroup-name group))
7129 (gnus-check-group-server))
7131 ((gnus-request-article article group (current-buffer))
7132 (when (numberp article)
7133 (gnus-async-prefetch-next group article
7134 gnus-summary-buffer)
7135 (when gnus-keep-backlog
7136 (gnus-backlog-enter-article
7137 group article (current-buffer)))
7138 (when (and gnus-agent
7139 (gnus-agent-group-covered-p group))
7140 (gnus-agent-store-article article group)))
7141 (setq result 'article))
7143 (setq gnus-override-method (pop methods)))
7144 ((not (string-match "^400 "
7145 (nnheader-get-report backend)))
7146 ;; If we get 400 server disconnect, reconnect and
7147 ;; retry; otherwise, assume the article has expired.
7148 (setq result 'done))))
7149 (and (eq result 'article) 'article)))
7153 ;; Associate this article with the current summary buffer.
7154 (setq gnus-article-current-summary gnus-summary-buffer)
7156 ;; Take the article from the original article buffer
7157 ;; and place it in the buffer it's supposed to be in.
7158 (when (and (get-buffer gnus-article-buffer)
7159 (equal (buffer-name (current-buffer))
7160 (buffer-name (get-buffer gnus-article-buffer))))
7162 (if (get-buffer gnus-original-article-buffer)
7163 (set-buffer gnus-original-article-buffer)
7164 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7165 (buffer-disable-undo)
7166 (setq major-mode 'gnus-original-article-mode)
7167 (setq buffer-read-only t))
7168 (let ((inhibit-read-only t))
7170 (insert-buffer-substring gnus-article-buffer))
7171 (setq gnus-original-article (cons group article)))
7174 (run-hooks 'gnus-article-decode-hook)
7175 ;; Mark article as decoded or not.
7176 (setq gnus-article-decoded-p gnus-article-decode-hook))
7178 ;; Update sparse articles.
7179 (when (and do-update-line
7180 (or (numberp article)
7182 (let ((buf (current-buffer)))
7183 (set-buffer gnus-summary-buffer)
7184 (gnus-summary-update-article do-update-line sparse-header)
7185 (gnus-summary-goto-subject do-update-line nil t)
7186 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7188 (set-buffer buf))))))
7190 (defun gnus-block-private-groups (group)
7191 (if (or (gnus-news-group-p group)
7192 (gnus-member-of-valid 'global group))
7193 ;; Block nothing in news groups.
7195 ;; Block everything anywhere else.
7198 (defun gnus-blocked-images ()
7199 (if (functionp gnus-blocked-images)
7200 (funcall gnus-blocked-images gnus-newsgroup-name)
7201 gnus-blocked-images))
7207 (defcustom gnus-article-edit-mode-hook nil
7208 "Hook run in article edit mode buffers."
7209 :group 'gnus-article-various
7212 (defvar gnus-article-edit-done-function nil)
7214 (defvar gnus-article-edit-mode-map nil)
7216 ;; Should we be using derived.el for this?
7217 (unless gnus-article-edit-mode-map
7218 (setq gnus-article-edit-mode-map (make-keymap))
7219 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7221 (gnus-define-keys gnus-article-edit-mode-map
7222 "\C-c?" describe-mode
7223 "\C-c\C-c" gnus-article-edit-done
7224 "\C-c\C-k" gnus-article-edit-exit
7225 "\C-c\C-f\C-t" message-goto-to
7226 "\C-c\C-f\C-o" message-goto-from
7227 "\C-c\C-f\C-b" message-goto-bcc
7228 ;;"\C-c\C-f\C-w" message-goto-fcc
7229 "\C-c\C-f\C-c" message-goto-cc
7230 "\C-c\C-f\C-s" message-goto-subject
7231 "\C-c\C-f\C-r" message-goto-reply-to
7232 "\C-c\C-f\C-n" message-goto-newsgroups
7233 "\C-c\C-f\C-d" message-goto-distribution
7234 "\C-c\C-f\C-f" message-goto-followup-to
7235 "\C-c\C-f\C-m" message-goto-mail-followup-to
7236 "\C-c\C-f\C-k" message-goto-keywords
7237 "\C-c\C-f\C-u" message-goto-summary
7238 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7239 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7240 "\C-c\C-b" message-goto-body
7241 "\C-c\C-i" message-goto-signature
7243 "\C-c\C-t" message-insert-to
7244 "\C-c\C-n" message-insert-newsgroups
7245 "\C-c\C-o" message-sort-headers
7246 "\C-c\C-e" message-elide-region
7247 "\C-c\C-v" message-delete-not-region
7248 "\C-c\C-z" message-kill-to-signature
7249 "\M-\r" message-newline-and-reformat
7250 "\C-c\C-a" mml-attach-file
7251 "\C-a" message-beginning-of-line
7253 "\M-;" comment-region)
7255 (gnus-define-keys (gnus-article-edit-wash-map
7256 "\C-c\C-w" gnus-article-edit-mode-map)
7257 "f" gnus-article-edit-full-stops))
7260 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7262 ["Fetch To" message-insert-to t]
7263 ["Fetch Newsgroups" message-insert-newsgroups t]
7265 ["To" message-goto-to t]
7266 ["From" message-goto-from t]
7267 ["Subject" message-goto-subject t]
7268 ["Cc" message-goto-cc t]
7269 ["Reply-To" message-goto-reply-to t]
7270 ["Summary" message-goto-summary t]
7271 ["Keywords" message-goto-keywords t]
7272 ["Newsgroups" message-goto-newsgroups t]
7273 ["Followup-To" message-goto-followup-to t]
7274 ["Mail-Followup-To" message-goto-mail-followup-to t]
7275 ["Distribution" message-goto-distribution t]
7276 ["Body" message-goto-body t]
7277 ["Signature" message-goto-signature t]))
7279 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7280 "Major mode for editing articles.
7281 This is an extended text-mode.
7283 \\{gnus-article-edit-mode-map}"
7284 (make-local-variable 'gnus-article-edit-done-function)
7285 (make-local-variable 'gnus-prev-winconf)
7286 (set (make-local-variable 'font-lock-defaults)
7287 '(message-font-lock-keywords t))
7288 (set (make-local-variable 'mail-header-separator) "")
7289 (set (make-local-variable 'gnus-article-edit-mode) t)
7290 (easy-menu-add message-mode-field-menu message-mode-map)
7292 (setq buffer-read-only nil)
7293 (buffer-enable-undo)
7296 (defun gnus-article-edit (&optional force)
7297 "Edit the current article.
7298 This will have permanent effect only in mail groups.
7299 If FORCE is non-nil, allow editing of articles even in read-only
7302 (when (and (not force)
7303 (gnus-group-read-only-p))
7304 (error "The current newsgroup does not support article editing"))
7305 (gnus-article-date-original)
7306 (gnus-article-edit-article
7308 `(lambda (no-highlight)
7310 (gnus-summary-edit-article-done
7311 ,(or (mail-header-references gnus-current-headers) "")
7312 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7314 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7315 "Start editing the contents of the current article buffer."
7316 (let ((winconf (current-window-configuration)))
7317 (set-buffer gnus-article-buffer)
7318 (let ((message-auto-save-directory
7319 ;; Don't associate the article buffer with a draft file.
7321 (gnus-article-edit-mode))
7322 (funcall start-func)
7323 (set-buffer-modified-p nil)
7324 (gnus-configure-windows 'edit-article)
7325 (setq gnus-article-edit-done-function exit-func)
7326 (setq gnus-prev-winconf winconf)
7328 (gnus-message 6 "C-c C-c to end edits"))))
7330 (defun gnus-article-edit-done (&optional arg)
7331 "Update the article edits and exit."
7333 (let ((func gnus-article-edit-done-function)
7334 (buf (current-buffer))
7335 (start (window-start))
7337 (winconf gnus-prev-winconf))
7338 (widen) ;; Widen it in case that users narrowed the buffer.
7341 ;; The cache and backlog have to be flushed somewhat.
7342 (when gnus-keep-backlog
7343 (gnus-backlog-remove-article
7344 (car gnus-article-current) (cdr gnus-article-current)))
7345 ;; Flush original article as well.
7346 (gnus-flush-original-article-buffer)
7347 (when gnus-use-cache
7348 (gnus-cache-update-article
7349 (car gnus-article-current) (cdr gnus-article-current)))
7350 ;; We remove all text props from the article buffer.
7351 (kill-all-local-variables)
7352 (set-text-properties (point-min) (point-max) nil)
7354 (set-window-configuration winconf)
7356 (set-window-start (get-buffer-window buf) start)
7357 (set-window-point (get-buffer-window buf) (point)))
7358 (gnus-summary-show-article))
7360 (defun gnus-flush-original-article-buffer ()
7361 (when (get-buffer gnus-original-article-buffer)
7362 (with-current-buffer gnus-original-article-buffer
7363 (setq gnus-original-article nil))))
7365 (defun gnus-article-edit-exit ()
7366 "Exit the article editing without updating."
7368 (when (or (not (buffer-modified-p))
7369 (yes-or-no-p "Article modified; kill anyway? "))
7370 (let ((curbuf (current-buffer))
7372 (window-start (window-start)))
7374 (if (gnus-buffer-live-p gnus-original-article-buffer)
7375 (insert-buffer-substring gnus-original-article-buffer))
7376 (let ((winconf gnus-prev-winconf))
7377 (kill-all-local-variables)
7379 (set-window-configuration winconf)
7380 ;; Tippy-toe some to make sure that point remains where it was.
7381 (save-current-buffer
7383 (set-window-start (get-buffer-window (current-buffer)) window-start)
7385 (gnus-summary-show-article)))
7387 (defun gnus-article-edit-full-stops ()
7388 "Interactively repair spacing at end of sentences."
7391 (goto-char (point-min))
7392 (search-forward-regexp "^$" nil t)
7393 (let ((case-fold-search nil))
7394 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7397 ;;; Article highlights
7400 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7402 ;;; Internal Variables:
7404 (defcustom gnus-button-url-regexp
7406 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7407 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7408 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7409 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7410 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7414 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7415 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7416 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7417 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7419 "[" chars punct "]+" "[" chars "]"
7421 (concat ;; XEmacs 21.4 doesn't support POSIX.
7422 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7423 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7425 "Regular expression that matches URLs."
7427 :group 'gnus-article-buttons
7430 (defcustom gnus-button-valid-fqdn-regexp
7431 message-valid-fqdn-regexp
7432 "Regular expression that matches a valid FQDN."
7434 :group 'gnus-article-buttons
7437 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7438 (defcustom gnus-button-valid-localpart-regexp
7439 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7440 "Regular expression that matches a localpart of mail addresses or MIDs."
7442 :group 'gnus-article-buttons
7445 (defcustom gnus-button-man-handler 'manual-entry
7446 "Function to use for displaying man pages.
7447 The function must take at least one argument with a string naming the
7450 :type '(choice (function-item :tag "Man" manual-entry)
7451 (function-item :tag "Woman" woman)
7452 (function :tag "Other"))
7453 :group 'gnus-article-buttons)
7455 (defcustom gnus-button-mid-or-mail-regexp
7456 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7457 gnus-button-valid-fqdn-regexp
7459 "Regular expression that matches a message ID or a mail address."
7461 :group 'gnus-article-buttons
7464 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7465 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7466 Strings like this can be either a message ID or a mail address. If it is one
7467 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7468 message ID or a mail address, respectively. If this variable is set to the
7469 symbol `ask', always query the user what do do. If it is a function, this
7470 function will be called with the string as its only argument. The function
7471 must return `mid', `mail', `invalid' or `ask'."
7473 :group 'gnus-article-buttons
7474 :type '(choice (function-item :tag "Heuristic function"
7475 gnus-button-mid-or-mail-heuristic)
7480 (defcustom gnus-button-mid-or-mail-heuristic-alist
7481 '((-10.0 . ".+\\$.+@")
7484 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7485 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7486 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7487 (-1.0 . "^[^a-z]+@")
7489 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7490 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7491 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7492 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7495 (-1.0 . "^[0-9][0-9]")
7497 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7498 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7499 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7500 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7502 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7503 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7506 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7508 ;; compensation for TDMA dated mail addresses:
7509 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7511 (-20.0 . "\\.fsf@") ;; Gnus
7514 (-20.0 . "^alpine\\.")
7515 (-20.0 . "_-_") ;; Subject change in thread
7517 (-20.0 . "\\.ln@") ;; leafnode
7518 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7519 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7521 ;; (5.0 . "") ;; $local_part_len <= 7
7522 (10.0 . "^[^0-9]+@")
7523 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7524 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7527 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7529 (0.5 . "^[A-Z][a-z]")
7530 (0.5 . "^[A-Z][a-z][a-z]")
7531 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7532 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7533 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7535 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7536 address. The REGEXP is processed with `case-fold-search' set to nil."
7538 :group 'gnus-article-buttons
7539 :type '(repeat (cons (number :tag "Rate")
7540 (regexp :tag "Regexp"))))
7542 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7543 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7544 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7545 address, `ask' if unsure and `invalid' if the string is invalid."
7546 (let ((case-fold-search nil)
7547 (list gnus-button-mid-or-mail-heuristic-alist)
7548 (result 0) rate regexp lpartlen elem)
7550 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7551 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7552 ;; Certain special cases...
7555 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7556 "^[0-9]+\\.[0-9]+@compuserve\\|"
7557 "@public\\.gmane\\.org")
7559 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7560 (setq result 'mail))
7561 (when (string-match "@.*@\\| " mid-or-mail)
7562 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7563 (setq result 'invalid))
7564 ;; Nothing more to do, if result is not a number here...
7565 (when (numberp result)
7567 (setq elem (car list)
7571 (when (string-match regexp mid-or-mail)
7572 (setq result (+ result rate))
7574 9 "`%s' matched `%s', rate `%s', result `%s'."
7575 mid-or-mail regexp rate result)))
7576 (when (<= lpartlen 7)
7577 (setq result (+ result 5.0))
7578 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7579 mid-or-mail result))
7580 (when (>= lpartlen 12)
7581 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7583 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7584 ;; Long local part should contain realname if e-mail address,
7585 ;; too many digits: message-id.
7586 ;; $score -= 5.0 + 0.1 * $local_part_len;
7587 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7588 (setq result (+ result rate))
7590 9 "Many digits in `%s', rate `%s', result `%s'."
7591 mid-or-mail rate result))
7592 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7594 ;; Too few vowels [^aeiouy]{4,}.*\@
7595 (setq result (+ result -5.0))
7597 9 "Few vowels in `%s', rate `%s', result `%s'."
7598 mid-or-mail -5.0 result))
7600 (setq result (+ result 5.0))
7602 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7603 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7604 ;; Maybe we should make this a customizable alist: (condition . 'result)
7606 ((symbolp result) result)
7607 ;; Now convert number into proper results:
7608 ((< result -10.0) 'mid)
7609 ((> result 10.0) 'mail)
7612 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7613 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7614 (url-mid (concat "news" ":" mid-or-mail))
7615 (url-mailto (concat "mailto" ":" mid-or-mail)))
7616 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7617 (when (fboundp pref)
7619 ;; get rid of surrounding angles...
7621 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7622 (if (or (eq 'mid guessed) (eq 'mail guessed))
7626 (save-window-excursion
7627 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7630 (cond ((eq pref 'mid)
7631 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7632 (gnus-button-handle-news url-mid))
7634 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7635 (gnus-url-mailto url-mailto))
7636 (t (gnus-message 3 "Invalid string.")))))
7638 (defun gnus-button-handle-custom (fun arg)
7639 "Call function FUN on argument ARG.
7640 Both FUN and ARG are supposed to be strings. ARG will be passed
7641 as a symbol to FUN."
7642 (funcall (intern fun)
7643 (if (string-match "^customize-apropos" fun)
7647 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7649 (defun gnus-button-handle-describe-function (url)
7650 "Call `describe-function' when pushing the corresponding URL button."
7653 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7655 (defun gnus-button-handle-describe-variable (url)
7656 "Call `describe-variable' when pushing the corresponding URL button."
7659 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7661 (defun gnus-button-handle-symbol (url)
7662 "Display help on variable or function.
7663 Calls `describe-variable' or `describe-function'."
7664 (let ((sym (intern url)))
7666 ((fboundp sym) (describe-function sym))
7667 ((boundp sym) (describe-variable sym))
7668 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7670 (defun gnus-button-handle-describe-key (url)
7671 "Call `describe-key' when pushing the corresponding URL button."
7673 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7674 (keys (ignore-errors (eval `(kbd ,key-string)))))
7677 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7679 (defun gnus-button-handle-apropos (url)
7680 "Call `apropos' when pushing the corresponding URL button."
7681 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7683 (defun gnus-button-handle-apropos-command (url)
7684 "Call `apropos' when pushing the corresponding URL button."
7686 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7688 (defun gnus-button-handle-apropos-variable (url)
7689 "Call `apropos' when pushing the corresponding URL button."
7691 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7692 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7694 (defun gnus-button-handle-apropos-documentation (url)
7695 "Call `apropos' when pushing the corresponding URL button."
7697 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7698 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7700 (defun gnus-button-handle-library (url)
7701 "Call `locate-library' when pushing the corresponding URL button."
7702 (gnus-message 9 "url=`%s'" url)
7703 (let* ((lib (locate-library url))
7704 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7706 (gnus-message 1 "Cannot locale library `%s'." url)
7707 (find-file-read-only file))))
7709 (defcustom gnus-button-man-level 5
7710 "*Integer that says how many man-related buttons Gnus will show.
7711 The higher the number, the more buttons will appear and the more false
7712 positives are possible. Note that you can set this variable local to
7713 specific groups. Setting it higher in Unix groups is probably a good idea.
7714 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7715 how to set variables in specific groups."
7717 :group 'gnus-article-buttons
7718 :link '(custom-manual "(gnus)Group Parameters")
7721 (defcustom gnus-button-emacs-level 5
7722 "*Integer that says how many emacs-related buttons Gnus will show.
7723 The higher the number, the more buttons will appear and the more false
7724 positives are possible. Note that you can set this variable local to
7725 specific groups. Setting it higher in Emacs or Gnus related groups is
7726 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7727 `gnus-parameters' on how to set variables in specific groups."
7729 :group 'gnus-article-buttons
7730 :link '(custom-manual "(gnus)Group Parameters")
7733 (defcustom gnus-button-message-level 5
7734 "*Integer that says how many buttons for news or mail messages will appear.
7735 The higher the number, the more buttons will appear and the more false
7736 positives are possible."
7737 ;; mail addresses, MIDs, URLs for news, ...
7739 :group 'gnus-article-buttons
7742 (defcustom gnus-button-browse-level 5
7743 "*Integer that says how many buttons for browsing will appear.
7744 The higher the number, the more buttons will appear and the more false
7745 positives are possible."
7746 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7748 :group 'gnus-article-buttons
7751 (defcustom gnus-button-alist
7752 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7753 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7754 ((concat "\\b\\(nntp\\|news\\):\\("
7755 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7756 0 t gnus-button-handle-news 2)
7757 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7758 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7759 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7760 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7761 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7762 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7763 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7764 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7765 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7766 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7767 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7768 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7769 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7770 ;; RFC 2368 (The mailto URL scheme)
7771 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7772 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7773 ("\\bmailto:\\([^ \n\t]+\\)"
7774 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7775 ;; Info Konqueror style <info:/foo/bar baz>.
7776 ;; Must come before " Gnus home-grown style".
7777 ("\\binfo://?\\([^'\">\n\t]+\\)"
7778 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7779 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7780 ("\\binfo://\\([^'\">\n\t ]+\\)"
7781 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7782 ;; Info GNOME style <info:foo#bar_baz>
7783 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7784 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7785 ;; Info KDE style <info:(foo)bar baz>
7786 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7787 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7788 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7789 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7790 ("\\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,]*\\)\\)?"
7791 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7792 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7794 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7795 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7796 ;; Emacs help commands
7797 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7798 ;; regexp doesn't match arguments containing ` '.
7799 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7800 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7801 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7802 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7803 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7804 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7805 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7806 ;; The following entries may lead to many false positives so don't enable
7807 ;; them by default (use a high button level).
7808 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7809 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7810 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7811 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7812 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7813 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7814 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7815 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7816 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7817 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7818 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7819 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7820 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7821 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7822 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7823 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7824 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7825 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7826 ;; Unlike the other regexps we really have to require quoting
7827 ;; here to determine where it ends.
7828 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7829 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7830 ("<URL: *\\([^\n<>]*\\)>"
7831 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7832 ;; RFC 2396 (2.4.3., delims) ...
7833 ("\"URL: *\\([^\n\"]*\\)\""
7834 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7836 (gnus-button-url-regexp
7837 0 (>= gnus-button-browse-level 0) browse-url 0)
7839 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7840 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7841 gnus-button-handle-man 1)
7842 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7843 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7844 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7845 gnus-button-handle-man 1)
7846 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7847 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7848 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7849 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7850 ;; Recognizing patches to .el files. This is somewhat obscure,
7851 ;; but considering the percentage of Gnus users who hack Emacs
7853 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7854 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7855 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7856 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7857 ;; MID or mail: To avoid too many false positives we don't try to catch
7858 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7859 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7860 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7861 ;; so that non-ambiguous entries (see above) match first.
7862 (gnus-button-mid-or-mail-regexp
7863 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7864 "*Alist of regexps matching buttons in article bodies.
7866 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7867 REGEXP: is the string (case insensitive) matching text around the button (can
7868 also be Lisp expression evaluating to a string),
7869 BUTTON: is the number of the regexp grouping actually matching the button,
7870 FORM: is a Lisp expression which must eval to true for the button to
7872 CALLBACK: is the function to call when the user push this button, and each
7873 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7875 CALLBACK can also be a variable, in that case the value of that
7876 variable it the real callback function."
7877 :group 'gnus-article-buttons
7878 :type '(repeat (list (choice regexp variable sexp)
7879 (integer :tag "Button")
7881 (function :tag "Callback")
7884 (integer :tag "Regexp group")))))
7885 (put 'gnus-button-alist 'risky-local-variable t)
7887 (defcustom gnus-header-button-alist
7888 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7889 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7890 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7891 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7892 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7893 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7894 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7895 0 (>= gnus-button-browse-level 0) browse-url 0)
7896 ("^Subject:" gnus-button-url-regexp
7897 0 (>= gnus-button-browse-level 0) browse-url 0)
7898 ("^[^:]+:" gnus-button-url-regexp
7899 0 (>= gnus-button-browse-level 0) browse-url 0)
7900 ("^OpenPGP:.*url=" gnus-button-url-regexp
7901 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7902 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7903 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7904 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7905 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7906 "*Alist of headers and regexps to match buttons in article heads.
7908 This alist is very similar to `gnus-button-alist', except that each
7909 alist has an additional HEADER element first in each entry:
7911 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7913 HEADER is a regexp to match a header. For a fuller explanation, see
7914 `gnus-button-alist'."
7915 :group 'gnus-article-buttons
7916 :group 'gnus-article-headers
7917 :type '(repeat (list (regexp :tag "Header")
7918 (choice regexp variable)
7919 (integer :tag "Button")
7921 (function :tag "Callback")
7924 (integer :tag "Regexp group")))))
7925 (put 'gnus-header-button-alist 'risky-local-variable t)
7929 (defun gnus-article-push-button (event)
7930 "Check text under the mouse pointer for a callback function.
7931 If the text under the mouse pointer has a `gnus-callback' property,
7932 call it with the value of the `gnus-data' text property."
7934 (set-buffer (window-buffer (posn-window (event-start event))))
7935 (let* ((pos (posn-point (event-start event)))
7936 (data (get-text-property pos 'gnus-data))
7937 (fun (get-text-property pos 'gnus-callback)))
7940 (funcall fun data))))
7942 (defun gnus-article-press-button ()
7943 "Check text at point for a callback function.
7944 If the text at point has a `gnus-callback' property,
7945 call it with the value of the `gnus-data' text property."
7947 (let ((data (get-text-property (point) 'gnus-data))
7948 (fun (get-text-property (point) 'gnus-callback)))
7950 (funcall fun data))))
7952 (defun gnus-article-highlight (&optional force)
7953 "Highlight current article.
7954 This function calls `gnus-article-highlight-headers',
7955 `gnus-article-highlight-citation',
7956 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7957 do the highlighting. See the documentation for those functions."
7958 (interactive (list 'force))
7959 (gnus-article-highlight-headers)
7960 (gnus-article-highlight-citation force)
7961 (gnus-article-highlight-signature)
7962 (gnus-article-add-buttons)
7963 (gnus-article-add-buttons-to-head))
7965 (defun gnus-article-highlight-some (&optional force)
7966 "Highlight current article.
7967 This function calls `gnus-article-highlight-headers',
7968 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7969 do the highlighting. See the documentation for those functions."
7970 (interactive (list 'force))
7971 (gnus-article-highlight-headers)
7972 (gnus-article-highlight-signature)
7973 (gnus-article-add-buttons))
7975 (defun gnus-article-highlight-headers ()
7976 "Highlight article headers as specified by `gnus-header-face-alist'."
7978 (gnus-with-article-headers
7979 (let (regexp header-face field-face from hpoints fpoints)
7980 (dolist (entry gnus-header-face-alist)
7981 (goto-char (point-min))
7982 (setq regexp (concat "^\\("
7983 (if (string-equal "" (nth 0 entry))
7987 header-face (nth 1 entry)
7988 field-face (nth 2 entry))
7989 (while (and (re-search-forward regexp nil t)
7993 (unless (search-forward ":" nil t)
7995 (when (and header-face
7996 (not (memq (point) hpoints)))
7997 (push (point) hpoints)
7998 (gnus-put-text-property from (point) 'face header-face))
7999 (when (and field-face
8000 (not (memq (setq from (point)) fpoints)))
8002 (if (re-search-forward "^[^ \t]" nil t)
8004 (goto-char (point-max)))
8005 (gnus-put-text-property from (point) 'face field-face)))))))
8007 (defun gnus-article-highlight-signature ()
8008 "Highlight the signature in an article.
8009 It does this by highlighting everything after
8010 `gnus-signature-separator' using the face `gnus-signature'."
8012 (gnus-with-article-buffer
8013 (let ((inhibit-point-motion-hooks t))
8015 (when (and gnus-signature-face
8016 (gnus-article-narrow-to-signature))
8017 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
8018 'face gnus-signature-face)
8020 (gnus-article-search-signature)
8021 (let ((start (match-beginning 0))
8022 (end (set-marker (make-marker) (1+ (match-end 0)))))
8023 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
8026 (defun gnus-button-in-region-p (b e prop)
8027 "Say whether PROP exists in the region."
8028 (text-property-not-all b e prop nil))
8030 (defun gnus-article-add-buttons ()
8031 "Find external references in the article and make buttons of them.
8032 \"External references\" are things like Message-IDs and URLs, as
8033 specified by `gnus-button-alist'."
8035 (gnus-with-article-buffer
8036 (let ((inhibit-point-motion-hooks t)
8037 (case-fold-search t)
8038 (alist gnus-button-alist)
8040 ;; We skip the headers.
8043 (while (setq entry (pop alist))
8044 (setq regexp (eval (car entry)))
8046 (while (re-search-forward regexp nil t)
8047 (let ((start (match-beginning (nth 1 entry)))
8048 (end (match-end (nth 1 entry)))
8049 (from (match-beginning 0)))
8050 (when (and (eval (nth 2 entry))
8051 (not (gnus-button-in-region-p
8052 start end 'gnus-callback)))
8053 ;; That optional form returned non-nil, so we add the
8055 (setq from (set-marker (make-marker) from))
8056 (unless (and (eq (car entry) 'gnus-button-url-regexp)
8057 (gnus-article-extend-url-button from start end))
8058 (gnus-article-add-button start end
8059 'gnus-button-push (list from entry))
8060 (gnus-put-text-property
8062 'gnus-string (buffer-substring-no-properties
8065 (defun gnus-article-extend-url-button (beg start end)
8066 "Extend url button if url is folded into two or more lines.
8067 Return non-nil if button is extended. BEG is a marker that points to
8068 the beginning position of a text containing url. START and END are
8069 the endpoints of a url button before it is extended. The concatenated
8070 url is put as the `gnus-button-url' overlay property on the button."
8071 (let ((opoint (point))
8072 (points (list start end))
8077 (not (looking-at "[\t ]*[\">]")))
8081 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8082 (buffer-substring (point-at-bol) start)))
8084 (setq url (list (buffer-substring start end))
8085 delim (if (match-beginning 1) ">" "\""))
8087 (setq regexp (concat
8088 (when (and (looking-at
8089 message-cite-prefix-regexp)
8090 (< (match-end 0) start))
8091 (regexp-quote (match-string 0)))
8093 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8097 (and (looking-at regexp)
8100 (push (or (match-string 2)
8103 (push (setq end (or (match-end 2)
8106 (push (or (match-beginning 2)
8107 (match-beginning 1))
8109 (match-beginning 2)))
8110 (let (gnus-article-mouse-face widget-mouse-face)
8112 (gnus-article-add-button (pop points) (pop points)
8114 (list beg (assq 'gnus-button-url-regexp
8115 gnus-button-alist)))))
8116 (let ((overlay (gnus-make-overlay start end)))
8117 (gnus-overlay-put overlay 'evaporate t)
8118 (gnus-overlay-put overlay 'gnus-button-url
8119 (list (mapconcat 'identity (nreverse url) "")))
8120 (when gnus-article-mouse-face
8121 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8123 (goto-char opoint))))
8125 ;; Add buttons to the head of an article.
8126 (defun gnus-article-add-buttons-to-head ()
8127 "Add buttons to the head of the article."
8129 (gnus-with-article-headers
8131 (dolist (entry gnus-header-button-alist)
8132 ;; Each alist entry.
8133 (goto-char (point-min))
8134 (while (re-search-forward (car entry) nil t)
8135 ;; Each header matching the entry.
8136 (setq beg (match-beginning 0))
8137 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8138 (match-beginning 0))
8141 (while (re-search-forward (eval (nth 1 entry)) end t)
8142 ;; Each match within a header.
8143 (let* ((entry (cdr entry))
8144 (start (match-beginning (nth 1 entry)))
8145 (end (match-end (nth 1 entry)))
8146 (form (nth 2 entry)))
8147 (goto-char (match-end 0))
8149 (gnus-article-add-button
8150 start end (nth 3 entry)
8151 (buffer-substring (match-beginning (nth 4 entry))
8152 (match-end (nth 4 entry)))))))
8153 (goto-char end))))))
8155 ;;; External functions:
8157 (defun gnus-article-add-button (from to fun &optional data text)
8158 "Create a button between FROM and TO with callback FUN and data DATA."
8159 (when gnus-article-button-face
8160 (gnus-overlay-put (gnus-make-overlay from to nil t)
8161 'face gnus-article-button-face))
8162 (gnus-add-text-properties
8164 (nconc (and gnus-article-mouse-face
8165 (list gnus-mouse-face-prop gnus-article-mouse-face))
8166 (list 'gnus-callback fun)
8167 (and data (list 'gnus-data data))))
8168 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8169 :help-echo (or text "Follow the link")
8170 :keymap gnus-url-button-map
8171 :button-keymap gnus-widget-button-keymap))
8173 (defun gnus-article-copy-string ()
8174 "Copy the string in the button to the kill ring."
8176 (gnus-article-check-buffer)
8177 (let ((data (get-text-property (point) 'gnus-string)))
8181 (copy-region-as-kill (point-min) (point-max))
8182 (message "Copied %s" data)))))
8184 ;;; Internal functions:
8186 (defun gnus-article-set-globals ()
8187 (with-current-buffer gnus-summary-buffer
8188 (gnus-set-global-variables)))
8190 (defun gnus-signature-toggle (end)
8191 (gnus-with-article-buffer
8192 (let ((inhibit-point-motion-hooks t))
8193 (if (text-property-any end (point-max) 'article-type 'signature)
8195 (gnus-delete-wash-type 'signature)
8196 (gnus-remove-text-properties-when
8197 'article-type 'signature end (point-max)
8198 (cons 'article-type (cons 'signature
8199 gnus-hidden-properties))))
8200 (gnus-add-wash-type 'signature)
8201 (gnus-add-text-properties-when
8202 'article-type nil end (point-max)
8203 (cons 'article-type (cons 'signature
8204 gnus-hidden-properties)))))
8205 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8206 (gnus-set-mode-line 'article))))
8208 (defun gnus-button-push (marker-and-entry)
8209 ;; Push button starting at MARKER.
8211 (let* ((marker (car marker-and-entry))
8212 (entry (cadr marker-and-entry))
8213 (regexp (car entry))
8214 (inhibit-point-motion-hooks t))
8216 ;; This is obviously true, or something bad is happening :)
8217 ;; But we need it to have the match-data
8218 (when (looking-at (or (if (symbolp regexp)
8219 (symbol-value regexp)
8221 (let ((fun (nth 3 entry))
8222 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8223 (get-char-property marker 'gnus-button-url))
8224 (mapcar (lambda (group)
8225 (let ((string (match-string group)))
8226 (set-text-properties
8227 0 (length string) nil string)
8229 (nthcdr 4 entry)))))
8235 (fboundp (symbol-value fun)))
8236 (apply (symbol-value fun) args))
8238 (gnus-message 1 "You must define `%S' to use this button"
8239 (cons fun args)))))))))
8241 (defun gnus-parse-news-url (url)
8242 (let (scheme server port group message-id articles)
8245 (goto-char (point-min))
8246 (when (looking-at "\\([A-Za-z]+\\):")
8247 (setq scheme (match-string 1))
8248 (goto-char (match-end 0)))
8249 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8250 (setq server (match-string 1))
8251 (setq port (if (stringp (match-string 3))
8252 (string-to-number (match-string 3))
8254 (goto-char (match-end 0)))
8257 ((looking-at "\\(.*@.*\\)")
8258 (setq message-id (match-string 1)))
8259 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8260 (setq group (match-string 1)
8261 articles (split-string (match-string 2) "-")))
8262 ((looking-at "\\([^/]+\\)/?")
8263 (setq group (match-string 1)))
8265 (error "Unknown news URL syntax"))))
8266 (list scheme server port group message-id articles)))
8268 (defun gnus-button-handle-news (url)
8270 (destructuring-bind (scheme server port group message-id articles)
8271 (gnus-parse-news-url url)
8274 (with-current-buffer gnus-summary-buffer
8276 (let ((gnus-refer-article-method
8277 (nconc (list (list 'nntp server))
8278 gnus-refer-article-method))
8279 (nntp-port-number (or port "nntp")))
8280 (gnus-message 7 "Fetching %s with %s"
8281 message-id gnus-refer-article-method)
8282 (gnus-summary-refer-article message-id))
8283 (gnus-summary-refer-article message-id))))
8285 (gnus-button-fetch-group url)))))
8287 (defun gnus-button-patch (library line)
8288 "Visit an Emacs Lisp library LIBRARY on line LINE."
8290 (let ((file (locate-library (file-name-nondirectory library))))
8292 (error "Couldn't find library %s" library))
8294 (goto-char (point-min))
8295 (forward-line (1- (string-to-number line)))))
8297 (defun gnus-button-handle-man (url)
8299 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8300 (when (eq gnus-button-man-handler 'woman)
8301 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8302 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8303 (funcall gnus-button-man-handler url))
8305 (defun gnus-button-handle-info-url (url)
8306 "Fetch an info URL."
8307 (setq url (mm-subst-char-in-string ?+ ?\ url))
8309 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8310 (gnus-info-find-node
8311 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8313 ")" (gnus-url-unhex-string (match-string 2 url)))))
8314 ((string-match "([^)\"]+)[^\"]+" url)
8316 (gnus-replace-in-string
8317 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8318 (gnus-info-find-node url))
8319 (t (error "Can't parse %s" url))))
8321 (defun gnus-button-handle-info-url-gnome (url)
8322 "Fetch GNOME style info URL."
8323 (setq url (mm-subst-char-in-string ?_ ?\ url))
8324 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8325 (gnus-info-find-node
8327 (gnus-url-unhex-string
8328 (match-string 1 url))
8330 (or (gnus-url-unhex-string
8331 (match-string 2 url))
8333 (error "Can't parse %s" url)))
8335 (defun gnus-button-handle-info-url-kde (url)
8336 "Fetch KDE style info URL."
8337 (gnus-info-find-node (gnus-url-unhex-string url)))
8339 ;; (info) will autoload info.el
8340 (declare-function Info-menu "info" (menu-item &optional fork))
8341 (declare-function Info-index-next "info" (num))
8343 (defun gnus-button-handle-info-keystrokes (url)
8344 "Call `info' when pushing the corresponding URL button."
8345 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8346 (let (node indx comma)
8348 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8349 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8350 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8351 "\\(?:[ \t\n,]*\\)\\)?")
8353 (setq node (match-string 2 url)
8354 indx (match-string 3 url))
8355 (error "Can't parse %s" url))
8359 (when (> (length indx) 0)
8360 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8363 (setq comma (match-string 2 indx))
8364 (setq indx (match-string 1 indx))
8367 (dotimes (i (with-temp-buffer
8369 ;; Note: the XEmacs version of `how-many' takes
8370 ;; no optional argument.
8371 (goto-char (point-min))
8373 (Info-index-next 1)))
8376 (autoload 'pgg-snarf-keys-region "pgg")
8377 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8378 (declare-function pgg-display-output-buffer "pgg" (start end status))
8380 (defun gnus-button-openpgp (url)
8381 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8383 (mm-url-insert-file-contents-external url)
8384 (pgg-snarf-keys-region (point-min) (point-max))
8385 (pgg-display-output-buffer nil nil nil)))
8387 (defun gnus-button-message-id (message-id)
8389 (with-current-buffer gnus-summary-buffer
8390 (gnus-summary-refer-article message-id)))
8392 (defun gnus-button-fetch-group (address &rest ignore)
8393 "Fetch GROUP specified by ADDRESS."
8394 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8396 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8397 ;; for nntp:// and news://
8398 (setq address (match-string 3 address)))
8399 (if (not (string-match "[:/]" address))
8400 ;; This is just a simple group url.
8401 (gnus-group-read-ephemeral-group address gnus-select-method)
8404 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8406 (error "Can't parse %s" address)
8407 (gnus-group-read-ephemeral-group
8408 (match-string 4 address)
8409 `(nntp ,(match-string 1 address)
8410 (nntp-address ,(match-string 1 address))
8411 (nntp-port-number ,(if (match-end 3)
8412 (match-string 3 address)
8415 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8417 (defun gnus-url-parse-query-string (query &optional downcase)
8418 (let (retval pairs cur key val)
8419 (setq pairs (split-string query "&"))
8421 (setq cur (car pairs)
8423 (if (not (string-match "=" cur))
8425 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8426 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8428 (setq key (downcase key)))
8429 (setq cur (assoc key retval))
8431 (setcdr cur (cons val (cdr cur)))
8432 (setq retval (cons (list key val) retval)))))
8435 (defun gnus-url-mailto (url)
8436 ;; Send mail to someone
8437 (setq url (replace-regexp-in-string "\n" " " url))
8438 (when (string-match "mailto:/*\\(.*\\)" url)
8439 (setq url (substring url (match-beginning 1) nil)))
8440 (let (to args subject func)
8441 (setq args (gnus-url-parse-query-string
8442 (if (string-match "^\\?" url)
8444 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8445 (concat "to=" (match-string 1 url) "&"
8446 (match-string 2 url))
8447 (concat "to=" url))))
8448 subject (cdr-safe (assoc "subject" args)))
8451 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8454 (message-position-on-field (caar args)))
8455 (insert (gnus-replace-in-string
8456 (mapconcat 'identity (reverse (cdar args)) ", ")
8458 (setq args (cdr args)))
8461 (message-goto-subject))))
8463 (defun gnus-button-embedded-url (address)
8464 "Activate ADDRESS with `browse-url'."
8465 (browse-url (gnus-strip-whitespace address)))
8467 ;;; Next/prev buttons in the article buffer.
8469 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8470 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8472 (defvar gnus-prev-page-map
8473 (let ((map (make-sparse-keymap)))
8474 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8475 (define-key map "\r" 'gnus-button-prev-page)
8478 (defvar gnus-next-page-map
8479 (let ((map (make-sparse-keymap)))
8480 (define-key map gnus-mouse-2 'gnus-button-next-page)
8481 (define-key map "\r" 'gnus-button-next-page)
8484 (defun gnus-insert-prev-page-button ()
8486 (inhibit-read-only t))
8488 gnus-prev-page-line-format nil
8489 `(keymap ,gnus-prev-page-map
8491 gnus-callback gnus-article-button-prev-page
8492 article-type annotation))
8494 ;; Exclude a newline.
8497 (when gnus-article-button-face
8498 (gnus-overlay-put (gnus-make-overlay b e nil t)
8499 'face gnus-article-button-face))
8500 (widget-convert-button
8502 :action 'gnus-button-prev-page
8503 :button-keymap gnus-prev-page-map)))
8505 (defun gnus-button-next-page (&optional args more-args)
8506 "Go to the next page."
8508 (let ((win (selected-window)))
8509 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8510 (gnus-article-next-page)
8511 (select-window win)))
8513 (defun gnus-button-prev-page (&optional args more-args)
8514 "Go to the prev page."
8516 (let ((win (selected-window)))
8517 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8518 (gnus-article-prev-page)
8519 (select-window win)))
8521 (defun gnus-insert-next-page-button ()
8523 (inhibit-read-only t))
8524 (gnus-eval-format gnus-next-page-line-format nil
8525 `(keymap ,gnus-next-page-map
8527 gnus-callback gnus-article-button-next-page
8528 article-type annotation))
8530 ;; Exclude a newline.
8533 (when gnus-article-button-face
8534 (gnus-overlay-put (gnus-make-overlay b e nil t)
8535 'face gnus-article-button-face))
8536 (widget-convert-button
8538 :action 'gnus-button-next-page
8539 :button-keymap gnus-next-page-map)))
8541 (defun gnus-article-button-next-page (arg)
8542 "Go to the next page."
8544 (let ((win (selected-window)))
8545 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8546 (gnus-article-next-page)
8547 (select-window win)))
8549 (defun gnus-article-button-prev-page (arg)
8550 "Go to the prev page."
8552 (let ((win (selected-window)))
8553 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8554 (gnus-article-prev-page)
8555 (select-window win)))
8557 (defvar gnus-decode-header-methods
8558 '(mail-decode-encoded-word-region)
8559 "List of methods used to decode headers.
8561 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8562 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8563 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8564 whose names match REGEXP.
8567 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8568 mail-decode-encoded-word-region
8569 (\"chinese\" . rfc1843-decode-region))
8572 (defvar gnus-decode-header-methods-cache nil)
8574 (defun gnus-multi-decode-header (start end)
8575 "Apply the functions from `gnus-encoded-word-methods' that match."
8576 (unless (and gnus-decode-header-methods-cache
8577 (eq gnus-newsgroup-name
8578 (car gnus-decode-header-methods-cache)))
8579 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8580 (dolist (x gnus-decode-header-methods)
8582 (nconc gnus-decode-header-methods-cache (list x))
8583 (if (and gnus-newsgroup-name
8584 (string-match (car x) gnus-newsgroup-name))
8585 (nconc gnus-decode-header-methods-cache
8587 (let ((xlist gnus-decode-header-methods-cache))
8590 (narrow-to-region start end)
8592 (funcall (pop xlist) (point-min) (point-max))))))
8595 ;;; Treatment top-level handling.
8598 (defvar gnus-inhibit-article-treatments nil)
8600 (defun gnus-treat-article (gnus-treat-condition
8601 &optional part-number total-parts gnus-treat-type)
8602 (let ((gnus-treat-length (- (point-max) (point-min)))
8603 (alist gnus-treatment-function-alist)
8604 (article-goto-body-goes-to-point-min-p t)
8606 (or (not gnus-treat-type)
8608 (let ((list gnus-article-treat-types))
8610 (when (string-match (pop list) gnus-treat-type)
8611 (throw 'found t)))))))
8612 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8614 (gnus-run-hooks 'gnus-part-display-hook)
8615 (dolist (elem alist)
8618 (when (gnus-buffer-live-p gnus-summary-buffer)
8619 (set-buffer gnus-summary-buffer))
8620 (symbol-value (car elem))))
8621 (when (and (or (consp val)
8623 (or (not gnus-inhibit-article-treatments)
8624 (eq gnus-treat-condition 'head))
8625 (gnus-treat-predicate val)
8626 (or (not (get (car elem) 'highlight))
8629 (funcall (cadr elem)))))))
8631 ;; Dynamic variables.
8632 (defvar part-number)
8633 (defvar total-parts)
8634 (defvar gnus-treat-type)
8635 (defvar gnus-treat-condition)
8636 (defvar gnus-treat-length)
8638 (defun gnus-treat-predicate (val)
8642 (gnus-treat-condition
8643 (eq gnus-treat-condition val))
8645 (stringp (car val)))
8646 (apply 'gnus-or (mapcar `(lambda (s)
8647 (string-match s ,(or gnus-newsgroup-name "")))
8650 (let ((pred (pop val)))
8653 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8655 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8657 (not (gnus-treat-predicate (car val))))
8659 (equal (car val) gnus-treat-type))
8663 (error "%S is not a valid predicate" pred)))))
8671 (eq part-number total-parts))
8673 (< gnus-treat-length val))
8675 (error "%S is not a valid value" val))))
8677 (defun gnus-article-encrypt-body (protocol &optional n)
8678 "Encrypt the article body."
8681 (or gnus-article-encrypt-protocol
8682 (gnus-completing-read "Encrypt protocol"
8683 (mapcar 'car gnus-article-encrypt-protocol-alist)
8685 current-prefix-arg))
8686 ;; User might hit `K E' instead of `K e', so prompt once.
8687 (when (and gnus-article-encrypt-protocol
8689 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8690 (error "Encrypt aborted")))
8691 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8693 (error "Can't find the encrypt protocol %s" protocol))
8694 (if (member gnus-newsgroup-name '("nndraft:delayed"
8697 (error "Can't encrypt the article in group %s"
8698 gnus-newsgroup-name))
8699 (gnus-summary-iterate n
8700 (with-current-buffer gnus-summary-buffer
8701 (let ((mail-parse-charset gnus-newsgroup-charset)
8702 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8703 (summary-buffer gnus-summary-buffer)
8705 (gnus-set-global-variables)
8706 (when (gnus-group-read-only-p)
8707 (error "The current newsgroup does not support article encrypt"))
8708 (gnus-summary-show-article t)
8710 (or (mail-header-references gnus-current-headers) ""))
8711 (set-buffer gnus-article-buffer)
8712 (let* ((inhibit-read-only t)
8714 (mapcar (lambda (field)
8715 (and (save-restriction
8716 (message-narrow-to-head)
8717 (goto-char (point-min))
8718 (search-forward field nil t))
8720 (message-narrow-to-field)
8722 (delete-region (point-min) (point-max))
8724 '("Content-Type:" "Content-Transfer-Encoding:"
8725 "Content-Disposition:"))))
8726 (message-narrow-to-head)
8727 (message-remove-header "MIME-Version")
8728 (goto-char (point-max))
8729 (setq point (point))
8730 (insert (apply 'concat headers))
8732 (narrow-to-region point (point-max))
8733 (let ((message-options message-options))
8734 (message-options-set 'message-sender user-mail-address)
8735 (message-options-set 'message-recipients user-mail-address)
8736 (message-options-set 'message-sign-encrypt 'not)
8738 (goto-char (point-min))
8739 (insert "MIME-Version: 1.0\n")
8741 (gnus-summary-edit-article-done
8742 references nil summary-buffer t))
8743 (when gnus-keep-backlog
8744 (gnus-backlog-remove-article
8745 (car gnus-article-current) (cdr gnus-article-current)))
8746 (gnus-flush-original-article-buffer)
8747 (when gnus-use-cache
8748 (gnus-cache-update-article
8749 (car gnus-article-current) (cdr gnus-article-current))))))))
8751 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8752 "The following specs can be used:
8753 %t The security MIME type
8756 %D Details if button is pressed")
8758 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8759 "The following specs can be used:
8760 %t The security MIME type
8763 %D Details if button is pressed")
8765 (defvar gnus-mime-security-button-line-format-alist
8766 '((?t gnus-tmp-type ?s)
8767 (?i gnus-tmp-info ?s)
8768 (?d gnus-tmp-details ?s)
8769 (?D gnus-tmp-pressed-details ?s)))
8771 (defvar gnus-mime-security-button-commands
8772 '((gnus-article-press-button "\r" "Show Detail")
8776 (gnus-mime-security-save-part "o" "Save...")
8785 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8788 (defvar gnus-mime-security-button-map
8789 (let ((map (make-sparse-keymap)))
8790 (define-key map gnus-mouse-2 'gnus-article-push-button)
8791 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8792 (dolist (c gnus-mime-security-button-commands)
8793 (define-key map (cadr c) (car c)))
8797 gnus-mime-security-button-menu gnus-mime-security-button-map
8798 "Security button menu."
8802 (unless (eq (car c) 'undefined)
8803 (vector (caddr c) (car c) :active t)))
8804 gnus-mime-security-button-commands))))
8806 (defun gnus-mime-security-button-menu (event prefix)
8807 "Construct a context-sensitive menu of security commands."
8808 (interactive "e\nP")
8809 (save-window-excursion
8810 (let ((pos (event-start event)))
8811 (select-window (posn-window pos))
8812 (goto-char (posn-point pos))
8813 (gnus-article-check-buffer)
8814 (popup-menu gnus-mime-security-button-menu nil prefix))))
8816 (defvar gnus-mime-security-details-buffer nil)
8818 (defvar gnus-mime-security-button-pressed nil)
8820 (defvar gnus-mime-security-show-details-inline t
8821 "If non-nil, show details in the article buffer.")
8823 (defun gnus-mime-security-verify-or-decrypt (handle)
8824 (mm-remove-parts (cdr handle))
8825 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8826 point (inhibit-read-only t))
8828 (goto-char (car region)))
8829 (setq point (point))
8830 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8831 (let* ((mm-verify-option 'known)
8832 (mm-decrypt-option 'known)
8833 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8834 (unless (eq nparts (cdr handle))
8835 (mm-destroy-parts (cdr handle))
8836 (setcdr handle nparts))))
8837 (gnus-mime-display-security handle)
8839 (delete-region (point) (cdr region))
8840 (set-marker (car region) nil)
8841 (set-marker (cdr region) nil))
8844 (defun gnus-mime-security-show-details (handle)
8845 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8847 (gnus-message 5 "No details.")
8848 (if gnus-mime-security-show-details-inline
8849 (let ((gnus-mime-security-button-pressed
8850 (not (get-text-property (point) 'gnus-mime-details)))
8851 (gnus-mime-security-button-line-format
8852 (get-text-property (point) 'gnus-line-format))
8853 (inhibit-read-only t))
8855 (while (eq (get-text-property (point) 'gnus-line-format)
8856 gnus-mime-security-button-line-format)
8860 (narrow-to-region (point) (point))
8861 (gnus-insert-mime-security-button handle))
8862 (delete-region (point)
8863 (or (text-property-not-all
8866 gnus-mime-security-button-line-format)
8869 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8870 (with-current-buffer gnus-mime-security-details-buffer
8873 (setq gnus-mime-security-details-buffer
8874 (gnus-get-buffer-create "*MIME Security Details*")))
8875 (with-current-buffer gnus-mime-security-details-buffer
8877 (goto-char (point-min)))
8878 (pop-to-buffer gnus-mime-security-details-buffer)))))
8880 (defun gnus-mime-security-press-button (handle)
8882 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8883 (gnus-mime-security-show-details handle)
8884 (gnus-mime-security-verify-or-decrypt handle))))
8886 (defun gnus-insert-mime-security-button (handle &optional displayed)
8887 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8890 (or (nth 2 (assoc protocol mm-verify-function-alist))
8891 (nth 2 (assoc protocol mm-decrypt-function-alist))
8893 (if (equal (car handle) "multipart/signed")
8894 " Signed" " Encrypted")
8897 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8900 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8901 gnus-tmp-pressed-details
8903 (setq gnus-tmp-details
8904 (if gnus-tmp-details
8905 (concat "\n" gnus-tmp-details)
8907 (setq gnus-tmp-pressed-details
8908 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8913 gnus-mime-security-button-line-format
8914 gnus-mime-security-button-line-format-alist
8915 `(keymap ,gnus-mime-security-button-map
8916 gnus-callback gnus-mime-security-press-button
8917 gnus-line-format ,gnus-mime-security-button-line-format
8918 gnus-mime-details ,gnus-mime-security-button-pressed
8919 article-type annotation
8922 ;; Exclude a newline.
8925 (when gnus-article-button-face
8926 (gnus-overlay-put (gnus-make-overlay b e nil t)
8927 'face gnus-article-button-face))
8928 (widget-convert-button
8931 :action 'gnus-widget-press-button
8932 :button-keymap gnus-mime-security-button-map
8935 ;; Needed to properly clear the message due to a bug in
8936 ;; wid-edit (XEmacs only).
8937 (when (boundp 'help-echo-owns-message)
8938 (setq help-echo-owns-message t))
8940 "%S: show detail; %S: more options"
8941 (aref gnus-mouse-2 0)
8942 (aref gnus-down-mouse-3 0))))))
8944 (defun gnus-mime-display-security (handle)
8946 (narrow-to-region (point) (point))
8947 (unless (gnus-unbuttonized-mime-type-p (car handle))
8948 (gnus-insert-mime-security-button handle))
8949 (gnus-mime-display-part (cadr handle))
8952 (unless (gnus-unbuttonized-mime-type-p (car handle))
8953 (let ((gnus-mime-security-button-line-format
8954 gnus-mime-security-button-end-line-format))
8955 (gnus-insert-mime-security-button handle)))
8956 (mm-set-handle-multipart-parameter
8957 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8958 (goto-char (point-max))))
8960 (defun gnus-mime-security-run-function (function)
8961 "Run FUNCTION with the security part under point."
8962 (gnus-article-check-buffer)
8963 (let ((data (get-text-property (point) 'gnus-data))
8965 (when (and (stringp (car-safe data))
8966 (setq buffer (mm-handle-multipart-original-buffer data))
8967 (setq handle (cadr data)))
8968 (if (bufferp (mm-handle-buffer handle))
8970 (setq handle (cons buffer (copy-sequence (cdr handle))))
8971 (mm-handle-set-undisplayer handle nil))
8972 (setq handle (mm-make-handle
8974 (mm-handle-multipart-ctl-parameter handle 'protocol)
8975 nil nil nil nil nil nil)))
8976 (funcall function handle))))
8978 (defun gnus-mime-security-save-part ()
8979 "Save the security part under point."
8981 (gnus-mime-security-run-function 'mm-save-part))
8983 (defun gnus-mime-security-pipe-part ()
8984 "Pipe the security part under point to a process."
8986 (gnus-mime-security-run-function 'mm-pipe-part))
8992 (run-hooks 'gnus-art-load-hook)
8994 ;;; gnus-art.el ends here