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
'(invisible t intangible t
)
257 "Property list to use for hiding text."
259 :group
'gnus-article-hiding
)
261 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
262 ;; frames in a session.
263 (defcustom gnus-article-x-face-command
264 (if (featurep 'xemacs
)
265 (if (or (gnus-image-type-available-p 'xface
)
266 (gnus-image-type-available-p 'pbm
))
267 'gnus-display-x-face-in-from
269 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
270 ; uncompface; } | icontopbm | ee -")
271 (if (gnus-image-type-available-p 'pbm
)
272 'gnus-display-x-face-in-from
274 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
275 ; uncompface; } | icontopbm | display -"))
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type
`(choice string
280 (function-item gnus-display-x-face-in-from
)
284 :group
'gnus-article-washing
)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type
'(choice regexp
(const nil
))
289 :group
'gnus-article-washing
)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type
'(repeat (cons symbol regexp
))
297 :group
'gnus-article-washing
)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag
"Banner"
307 (const :tag
"Remove signature" signature
)
308 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
310 (const :tag
"None" nil
))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag
"Address")
333 (choice :tag
"Banner" :value nil
334 (const :tag
"Remove signature" signature
)
335 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
337 (const :tag
"None" nil
))))
339 :group
'gnus-article-washing
)
341 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value
))
350 (list (format format
(car (car value
)) (cdr (car value
)))
352 (if (nth 1 value
) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format
)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp
(setq pattern
(car value
)))
364 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil
2)
374 ("_/" "/_" underline-italic
)
375 ("_\\*" "\\*_" underline-bold
)
376 ("\\*/" "/\\*" bold-italic
)
377 ("_\\*/" "/\\*_" underline-bold-italic
))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format
(car spec
) (cadr spec
))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline
))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format
"%[Customizing Style%]\n%v"
409 (group :tag
"Default"
410 :value
("" 0 0 default
)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget
:parent
)
417 (if (not (eq (nth 2 value
) 'default
))
421 (gnus-emphasis-custom-value-to-external value
))))
422 (widget-group-value-create widget
))
424 (integer :format
"Match group: %v")
425 (integer :format
"Emphasize group: %v")
428 :value
(("_" .
"_") nil default
)
430 (regexp :format
"Start regexp: %v")
431 (regexp :format
"End regexp: %v"))
432 (boolean :format
"Show start and end patterns: %[%v%]\n"
433 :on
" On " :off
" Off ")
435 :get
(lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol
)))
438 :set
(lambda (symbol value
)
439 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
441 :group
'gnus-article-emphasis
)
443 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group
'gnus-article-emphasis
452 (defface gnus-emphasis-bold
'((t (:bold t
)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group
'gnus-article-emphasis
)
456 (defface gnus-emphasis-italic
'((t (:italic t
)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group
'gnus-article-emphasis
)
460 (defface gnus-emphasis-underline
'((t (:underline t
)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group
'gnus-article-emphasis
)
464 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group
'gnus-article-emphasis
)
468 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group
'gnus-article-emphasis
)
472 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group
'gnus-article-emphasis
)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t
:italic t
:underline t
)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group
'gnus-article-emphasis
)
482 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
483 '((t (:strikethru t
)))
484 '((t (:strike-through t
))))
485 "Face used for displaying strike-through text (-word-)."
486 :group
'gnus-article-emphasis
)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background
"black" :foreground
"yellow")))
490 "Face used for displaying highlighted words."
491 :group
'gnus-article-emphasis
)
493 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type
'(choice string function
)
501 :link
'(custom-manual "(gnus)Article Date")
502 :group
'gnus-article-washing
)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group
'gnus-article-saving
512 (defcustom gnus-prompt-before-saving
'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group
'gnus-article-saving
521 :type
'(choice (item always
)
522 (item :tag
"never" nil
)
523 (sexp :tag
"once" :format
"%t\n" :value t
)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group
'gnus-article-saving
536 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
537 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
538 "A function to save articles in your favorite format.
539 The function will be called by way of the `gnus-summary-save-article'
540 command, and friends such as `gnus-summary-save-article-rmail'.
542 Gnus provides the following functions:
544 * gnus-summary-save-in-rmail (Rmail format)
545 * gnus-summary-save-in-mail (Unix mail format)
546 * gnus-summary-save-in-folder (MH folder)
547 * gnus-summary-save-in-file (article format)
548 * gnus-summary-save-body-in-file (article body)
549 * gnus-summary-save-in-vm (use VM's folder format)
550 * gnus-summary-write-to-file (article format -- overwrite)
551 * gnus-summary-write-body-to-file (article body -- overwrite)
552 * gnus-summary-save-in-pipe (article format)
554 The symbol of each function may have the following properties:
557 The value non-nil means save decoded articles. This is meaningful
558 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
559 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
560 `gnus-summary-save-in-pipe'.
563 The value specifies an alternative function which appends, not
564 overwrites, articles to a file. This implies that when saving many
565 articles at a time, `gnus-prompt-before-saving' is bound to t and all
566 articles are saved in a single file. This is meaningful only with
567 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
570 The value specifies the symbol of a variable of which the value
571 specifies headers to be saved. If it is omitted,
572 `gnus-save-all-headers' and `gnus-saved-headers' control what
573 headers should be saved."
574 :group
'gnus-article-saving
575 :type
'(radio (function-item gnus-summary-save-in-rmail
)
576 (function-item gnus-summary-save-in-mail
)
577 (function-item gnus-summary-save-in-folder
)
578 (function-item gnus-summary-save-in-file
)
579 (function-item gnus-summary-save-body-in-file
)
580 (function-item gnus-summary-save-in-vm
)
581 (function-item gnus-summary-write-to-file
)
582 (function-item gnus-summary-write-body-to-file
)
583 (function-item gnus-summary-save-in-pipe
)
586 (defcustom gnus-article-save-coding-system
587 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
588 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
589 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
590 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
591 "Coding system used to save decoded articles to a file.
593 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
594 which can safely encode any characters in text. This is used by the
597 * gnus-summary-save-article-file
598 * gnus-summary-save-article-body-file
599 * gnus-summary-write-article-file
600 * gnus-summary-write-article-body-file
602 and the functions to which you may set `gnus-default-article-saver':
604 * gnus-summary-save-in-file
605 * gnus-summary-save-body-in-file
606 * gnus-summary-write-to-file
607 * gnus-summary-write-body-to-file
609 Those commands and functions save just text displayed in the article
610 buffer to a file if the value of this variable is non-nil. Note that
611 buttonized MIME parts will be lost in a saved file in that case.
612 Otherwise, raw articles will be saved."
613 :group
'gnus-article-saving
615 :format
"%{%t%}:\n %[Value Menu%] %v"
616 (const :tag
"Save raw articles" nil
)
619 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
620 '((const :tag
"UTF-8" utf-8
)
621 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
622 (const :tag
"Emacs internal" emacs-mule
)
623 (const :tag
"escape-quoted" escape-quoted
))))
624 (symbol :tag
"Coding system")))
626 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
627 "A function generating a file name to save articles in Rmail format.
628 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
629 :group
'gnus-article-saving
632 (defcustom gnus-mail-save-name
'gnus-plain-save-name
633 "A function generating a file name to save articles in Unix mail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group
'gnus-article-saving
638 (defcustom gnus-folder-save-name
'gnus-folder-save-name
639 "A function generating a file name to save articles in MH folder.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
641 :group
'gnus-article-saving
644 (defcustom gnus-file-save-name
'gnus-numeric-save-name
645 "A function generating a file name to save articles in article format.
646 The function is called with NEWSGROUP, HEADERS, and optional
648 :group
'gnus-article-saving
651 (defcustom gnus-split-methods
652 '((gnus-article-archive-name)
653 (gnus-article-nndoc-name))
654 "*Variable used to suggest where articles are to be saved.
655 For instance, if you would like to save articles related to Gnus in
656 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
657 you could set this variable to something like:
659 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
660 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
662 This variable is an alist where the key is the match and the
663 value is a list of possible files to save in if the match is
666 If the match is a string, it is used as a regexp match on the
667 article. If the match is a symbol, that symbol will be funcalled
668 from the buffer of the article to be saved with the newsgroup as the
669 parameter. If it is a list, it will be evalled in the same buffer.
671 If this form or function returns a string, this string will be used as a
672 possible file name; and if it returns a non-nil list, that list will be
673 used as possible file names."
674 :group
'gnus-article-saving
675 :type
'(repeat (choice (list :value
(fun) function
)
676 (cons :value
("" "") regexp
(repeat string
))
679 (defcustom gnus-page-delimiter
"^\^L"
680 "*Regexp describing what to use as article page delimiters.
681 The default value is \"^\^L\", which is a form linefeed at the
682 beginning of a line."
684 :group
'gnus-article-various
)
686 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
687 "*The format specification for the article mode line.
688 See `gnus-summary-mode-line-format' for a closer description.
690 The following additional specs are available:
692 %w The article washing status.
693 %m The number of MIME parts in the article."
696 :group
'gnus-article-various
)
698 (defcustom gnus-article-mode-hook nil
699 "*A hook for Gnus article mode."
701 :group
'gnus-article-various
)
703 (when (featurep 'xemacs
)
704 ;; Extracted from gnus-xmas-define in order to preserve user settings
705 (when (fboundp 'turn-off-scroll-in-place
)
706 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
707 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
708 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
710 (defcustom gnus-article-menu-hook nil
711 "*Hook run after the creation of the article mode menu."
713 :group
'gnus-article-various
)
715 (defcustom gnus-article-prepare-hook nil
716 "*A hook called after an article has been prepared in the article buffer."
718 :group
'gnus-article-various
)
720 (defcustom gnus-copy-article-ignored-headers nil
721 "List of headers to be removed when copying an article.
722 Each element is a regular expression."
723 :version
"23.1" ;; No Gnus
724 :type
'(repeat regexp
)
725 :group
'gnus-article-various
)
727 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
728 "Gnus 5.10 (Emacs 22.1)")
731 '((t (:weight bold
)))
732 "Face used for highlighting a button in the article buffer."
733 :group
'gnus-article-buttons
)
735 (defcustom gnus-article-button-face
'gnus-button
736 "Face used for highlighting buttons in the article buffer.
738 An article button is a piece of text that you can activate by pressing
739 `RET' or `mouse-2' above it."
741 :group
'gnus-article-buttons
)
743 (defcustom gnus-article-mouse-face
'highlight
744 "Face used for mouse highlighting in the article buffer.
746 Article buttons will be displayed in this face when the cursor is
749 :group
'gnus-article-buttons
)
751 (defcustom gnus-signature-face
'gnus-signature
752 "Face used for highlighting a signature in the article buffer.
753 Obsolete; use the face `gnus-signature' for customizations instead."
755 :group
'gnus-article-highlight
756 :group
'gnus-article-signature
)
758 (defface gnus-signature
761 "Face used for highlighting a signature in the article buffer."
762 :group
'gnus-article-highlight
763 :group
'gnus-article-signature
)
764 ;; backward-compatibility alias
765 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
766 (put 'gnus-signature-face
'obsolete-face
"22.1")
768 (defface gnus-header-from
771 (:foreground
"PaleGreen1"))
774 (:foreground
"red3"))
777 "Face used for displaying from headers."
778 :group
'gnus-article-headers
779 :group
'gnus-article-highlight
)
780 ;; backward-compatibility alias
781 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
782 (put 'gnus-header-from-face
'obsolete-face
"22.1")
784 (defface gnus-header-subject
787 (:foreground
"SeaGreen1"))
790 (:foreground
"red4"))
792 (:bold t
:italic t
)))
793 "Face used for displaying subject headers."
794 :group
'gnus-article-headers
795 :group
'gnus-article-highlight
)
796 ;; backward-compatibility alias
797 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
798 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
800 (defface gnus-header-newsgroups
803 (:foreground
"yellow" :italic t
))
806 (:foreground
"MidnightBlue" :italic t
))
809 "Face used for displaying newsgroups headers.
810 In the default setup this face is only used for crossposted
812 :group
'gnus-article-headers
813 :group
'gnus-article-highlight
)
814 ;; backward-compatibility alias
815 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
816 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
818 (defface gnus-header-name
821 (:foreground
"SpringGreen2"))
824 (:foreground
"maroon"))
827 "Face used for displaying header names."
828 :group
'gnus-article-headers
829 :group
'gnus-article-highlight
)
830 ;; backward-compatibility alias
831 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
832 (put 'gnus-header-name-face
'obsolete-face
"22.1")
834 (defface gnus-header-content
837 (:foreground
"SpringGreen1" :italic t
))
840 (:foreground
"indianred4" :italic t
))
842 (:italic t
))) "Face used for displaying header content."
843 :group
'gnus-article-headers
844 :group
'gnus-article-highlight
)
845 ;; backward-compatibility alias
846 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
847 (put 'gnus-header-content-face
'obsolete-face
"22.1")
849 (defcustom gnus-header-face-alist
850 '(("From" nil gnus-header-from
)
851 ("Subject" nil gnus-header-subject
)
852 ("Newsgroups:.*," nil gnus-header-newsgroups
)
853 ("" gnus-header-name gnus-header-content
))
854 "*Controls highlighting of article headers.
856 An alist of the form (HEADER NAME CONTENT).
858 HEADER is a regular expression which should match the name of a
859 header and NAME and CONTENT are either face names or nil.
861 The name of each header field will be displayed using the face
862 specified by the first element in the list where HEADER matches
863 the header name and NAME is non-nil. Similarly, the content will
864 be displayed by the first non-nil matching CONTENT face."
865 :group
'gnus-article-headers
866 :group
'gnus-article-highlight
867 :type
'(repeat (list (regexp :tag
"Header")
869 (item :tag
"skip" nil
)
870 (face :value default
))
871 (choice :tag
"Content"
872 (item :tag
"skip" nil
)
873 (face :value default
)))))
875 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
876 '((xface .
(:face gnus-x-face
)))
877 '((pbm .
(:face gnus-x-face
))
879 "Alist of image types and properties applied to Face and X-Face images.
882 ;; Specify the altitude of Face images in the From header.
883 \(setq gnus-face-properties-alist
884 '((pbm . (:face gnus-x-face :ascent 80))
885 (png . (:ascent 80))))
887 ;; Show Face images as pressed buttons.
888 \(setq gnus-face-properties-alist
889 '((pbm . (:face gnus-x-face :relief -2))
890 (png . (:relief -2))))
892 See the manual for the valid properties for various image types.
893 Currently, `pbm' is used for X-Face images and `png' is used for Face
894 images in Emacs. Only the `:face' property is effective on the `xface'
895 image type in XEmacs if it is built with the libcompface library."
896 :version
"23.1" ;; No Gnus
897 :group
'gnus-article-headers
898 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
900 (defcustom gnus-article-decode-hook
901 '(article-decode-charset article-decode-encoded-words
902 article-decode-group-name article-decode-idna-rhs
)
903 "*Hook run to decode charsets in articles."
904 :group
'gnus-article-headers
907 (defcustom gnus-display-mime-function
'gnus-display-mime
908 "Function to display MIME articles."
909 :group
'gnus-article-mime
912 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
913 "Function used to decode headers.")
915 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
916 "Function used to decode addresses.")
918 (defvar gnus-article-dumbquotes-map
938 "Table for MS-to-Latin1 translation.")
940 (defcustom gnus-ignored-mime-types nil
941 "List of MIME types that should be ignored by Gnus."
943 :group
'gnus-article-mime
944 :type
'(repeat regexp
))
946 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
947 "List of MIME types that should not be given buttons when rendered inline.
948 See also `gnus-buttonized-mime-types' which may override this variable.
949 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
951 :group
'gnus-article-mime
952 :type
'(repeat regexp
))
954 (defcustom gnus-buttonized-mime-types nil
955 "List of MIME types that should be given buttons when rendered inline.
956 If set, this variable overrides `gnus-unbuttonized-mime-types'.
957 To see e.g. security buttons you could set this to
958 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
959 this list to display radio buttons that allow you to choose one of two
960 media types those mails include. See also `mm-discouraged-alternatives'.
961 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
963 :group
'gnus-article-mime
964 :type
'(repeat regexp
))
966 (defcustom gnus-inhibit-mime-unbuttonizing nil
967 "If non-nil, all MIME parts get buttons.
968 When nil (the default value), then some MIME parts do not get buttons,
969 as described by the variables `gnus-buttonized-mime-types' and
970 `gnus-unbuttonized-mime-types'."
972 :group
'gnus-article-mime
975 (defcustom gnus-body-boundary-delimiter
"_"
976 "String used to delimit header and body.
977 This variable is used by `gnus-article-treat-body-boundary' which can
978 be controlled by `gnus-treat-body-boundary'."
980 :group
'gnus-article-various
981 :type
'(choice (item :tag
"None" :value nil
)
984 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
986 "Defines the location of the faces database.
987 For information on obtaining this database of pretty pictures, please
988 see http://www.cs.indiana.edu/picons/ftp/index.html"
990 :type
'(repeat directory
)
991 :link
'(url-link :tag
"download"
992 "http://www.cs.indiana.edu/picons/ftp/index.html")
993 :link
'(custom-manual "(gnus)Picons")
996 (defun gnus-picons-installed-p ()
997 "Say whether picons are installed on your machine."
998 (let ((installed nil
))
999 (dolist (database gnus-picon-databases
)
1000 (when (file-exists-p database
)
1001 (setq installed t
)))
1004 (defcustom gnus-article-mime-part-function nil
1005 "Function called with a MIME handle as the argument.
1006 This is meant for people who want to do something automatic based
1007 on parts -- for instance, adding Vcard info to a database."
1008 :group
'gnus-article-mime
1009 :type
'(choice (const nil
)
1012 (defcustom gnus-mime-multipart-functions nil
1013 "An alist of MIME types to functions to display them."
1015 :group
'gnus-article-mime
1016 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1018 (defcustom gnus-article-date-headers
'(combined-lapsed)
1019 "A list of Date header formats to display.
1020 Valid formats are `ut' (universal time), `local' (local time
1021 zone), `english' (readable English), `lapsed' (elapsed time),
1022 `combined-lapsed' (both the original date and the elapsed time),
1023 `original' (the original date header), `iso8601' (ISO8601
1024 format), and `user-defined' (a user-defined format defined by the
1025 `gnus-article-time-format' variable).
1027 You have as many date headers as you want in the article buffer.
1028 Some of these headers are updated automatically. See
1029 `gnus-article-update-date-headers' for details."
1031 :group
'gnus-article-headers
1033 (const :tag
"Universal time (UT)" ut
)
1034 (const :tag
"Local time zone" local
)
1035 (const :tag
"Readable English" english
)
1036 (const :tag
"Elapsed time" lapsed
)
1037 (const :tag
"Original and elapsed time" combined-lapsed
)
1038 (const :tag
"Original date header" original
)
1039 (const :tag
"ISO8601 format" iso8601
)
1040 (const :tag
"User-defined" user-defined
)))
1042 (defcustom gnus-article-update-date-headers nil
1043 "A number that says how often to update the date header (in seconds).
1044 If nil, don't update it at all."
1046 :group
'gnus-article-headers
1048 (item :tag
"Don't update" :value nil
)
1051 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1052 "Function called with a MIME handle as the argument.
1053 This is meant for people who want to view first matched part.
1054 For `undisplayed-alternative' (default), the first undisplayed
1055 part or alternative part is used. For `undisplayed', the first
1056 undisplayed part is used. For a function, the first part which
1057 the function return t is used. For nil, the first part is
1060 :group
'gnus-article-mime
1062 (item :tag
"first" :value nil
)
1063 (item :tag
"undisplayed" :value undisplayed
)
1064 (item :tag
"undisplayed or alternative"
1065 :value undisplayed-alternative
)
1068 (defcustom gnus-mime-action-alist
1069 '(("save to file" . gnus-mime-save-part
)
1070 ("save and strip" . gnus-mime-save-part-and-strip
)
1071 ("replace with file" . gnus-mime-replace-part
)
1072 ("delete part" . gnus-mime-delete-part
)
1073 ("display as text" . gnus-mime-inline-part
)
1074 ("view the part" . gnus-mime-view-part
)
1075 ("pipe to command" . gnus-mime-pipe-part
)
1076 ("toggle display" . gnus-article-press-button
)
1077 ("toggle display" . gnus-article-view-part-as-charset
)
1078 ("view as type" . gnus-mime-view-part-as-type
)
1079 ("view internally" . gnus-mime-view-part-internally
)
1080 ("view externally" . gnus-mime-view-part-externally
))
1081 "An alist of actions that run on the MIME attachment."
1082 :group
'gnus-article-mime
1083 :type
'(repeat (cons (string :tag
"name")
1086 (defcustom gnus-auto-select-part
1
1087 "Advance to next MIME part when deleting or stripping parts.
1089 When 0, point will be placed on the same part as before. When
1090 positive (negative), move point forward (backwards) this many
1091 parts. When nil, redisplay article."
1092 :version
"23.1" ;; No Gnus
1093 :group
'gnus-article-mime
1094 :type
'(choice (const nil
:tag
"Redisplay article.")
1095 (const 1 :tag
"Next part.")
1096 (const 0 :tag
"Current part.")
1100 ;;; The treatment variables
1103 (defvar gnus-part-display-hook nil
1104 "Hook called on parts that are to receive treatment.")
1106 (defvar gnus-article-treat-custom
1107 '(choice (const :tag
"Off" nil
)
1109 (const :tag
"Header" head
)
1110 (const :tag
"First" first
)
1111 (const :tag
"Last" last
)
1112 (integer :tag
"Less")
1113 (repeat :tag
"Groups" regexp
)
1114 (sexp :tag
"Predicate")))
1116 (defvar gnus-article-treat-head-custom
1117 '(choice (const :tag
"Off" nil
)
1118 (const :tag
"Header" head
)))
1120 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1121 "text/x-patch" "text/html")
1122 "Part types eligible for treatment.")
1124 (defvar gnus-inhibit-treatment nil
1125 "Whether to inhibit treatment.")
1127 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1128 "Highlight the signature.
1129 Valid values are nil, t, `head', `first', `last', an integer or a
1130 predicate. See Info node `(gnus)Customizing Articles'."
1131 :group
'gnus-article-treat
1132 :link
'(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom
)
1134 (put 'gnus-treat-highlight-signature
'highlight t
)
1136 (defcustom gnus-treat-buttonize
100000
1138 Valid values are nil, t, `head', `first', `last', an integer or a
1139 predicate. See Info node `(gnus)Customizing Articles'."
1140 :group
'gnus-article-treat
1141 :link
'(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-custom
)
1143 (put 'gnus-treat-buttonize
'highlight t
)
1145 (defcustom gnus-treat-buttonize-head
'head
1146 "Add buttons to the head.
1147 Valid values are nil, t, `head', `first', `last', an integer or a
1148 predicate. See Info node `(gnus)Customizing Articles'."
1149 :group
'gnus-article-treat
1150 :link
'(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-head-custom
)
1152 (put 'gnus-treat-buttonize-head
'highlight t
)
1154 (defcustom gnus-treat-date
'head
1155 "Display dates according to the `gnus-article-date-headers' variable.
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1159 :group
'gnus-article-treat
1160 :link
'(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-head-custom
)
1163 (defcustom gnus-treat-emphasize
50000
1165 Valid values are nil, t, `head', `first', `last', an integer or a
1166 predicate. See Info node `(gnus)Customizing Articles'."
1167 :group
'gnus-article-treat
1168 :link
'(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-custom
)
1170 (put 'gnus-treat-emphasize
'highlight t
)
1172 (defcustom gnus-treat-strip-cr nil
1173 "Remove carriage returns.
1174 Valid values are nil, t, `head', `first', `last', an integer or a
1175 predicate. See Info node `(gnus)Customizing Articles'."
1177 :group
'gnus-article-treat
1178 :link
'(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom
)
1181 (defcustom gnus-treat-unsplit-urls nil
1182 "Remove newlines from within URLs.
1183 Valid values are nil, t, `head', `first', `last', an integer or a
1184 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group
'gnus-article-treat
1187 :link
'(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom
)
1190 (defcustom gnus-treat-leading-whitespace nil
1191 "Remove leading whitespace in headers.
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1195 :group
'gnus-article-treat
1196 :link
'(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-custom
)
1199 (defcustom gnus-treat-hide-headers
'head
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group
'gnus-article-treat
1204 :link
'(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-head-custom
)
1207 (defcustom gnus-treat-hide-boring-headers nil
1208 "Hide boring headers.
1209 Valid values are nil, t, `head', `first', `last', an integer or a
1210 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group
'gnus-article-treat
1212 :link
'(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-head-custom
)
1215 (defcustom gnus-treat-hide-signature nil
1216 "Hide the signature.
1217 Valid values are nil, t, `head', `first', `last', an integer or a
1218 predicate. See Info node `(gnus)Customizing Articles'."
1219 :group
'gnus-article-treat
1220 :link
'(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-custom
)
1223 (defcustom gnus-treat-fill-article nil
1225 Valid values are nil, t, `head', `first', `last', an integer or a
1226 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group
'gnus-article-treat
1228 :link
'(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom
)
1231 (defcustom gnus-treat-hide-citation nil
1233 Valid values are nil, t, `head', `first', `last', an integer or a
1234 predicate. See Info node `(gnus)Customizing Articles'.
1236 See `gnus-article-highlight-citation' for variables used to
1237 control what it hides."
1238 :group
'gnus-article-treat
1239 :link
'(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom
)
1242 (defcustom gnus-treat-hide-citation-maybe nil
1243 "Hide cited text according to certain conditions.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'.
1247 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1248 how to control what it hides."
1249 :group
'gnus-article-treat
1250 :link
'(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom
)
1253 (defcustom gnus-treat-strip-list-identifiers
'head
1254 "Strip list identifiers from `gnus-list-identifiers`.
1255 Valid values are nil, t, `head', `first', `last', an integer or a
1256 predicate. See Info node `(gnus)Customizing Articles'."
1258 :group
'gnus-article-treat
1259 :link
'(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom
)
1262 (gnus-define-group-parameter
1265 "Alist of regexps and correspondent identifiers."
1266 :variable-group gnus-article-washing
1268 '(choice :tag
"Identifier"
1270 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1272 (const :tag
"None" nil
))
1274 "If non-nil, specify how to remove `identifiers' from articles' subject.
1276 Any symbol is used to look up a regular expression to match the
1277 banner in `gnus-list-identifiers'. A string is used as a regular
1278 expression to match the identifier directly.")
1280 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1281 "Gnus 5.10 (Emacs 22.1)")
1283 (defcustom gnus-treat-strip-pem nil
1284 "Strip PEM signatures.
1285 Valid values are nil, t, `head', `first', `last', an integer or a
1286 predicate. See Info node `(gnus)Customizing Articles'."
1287 :group
'gnus-article-treat
1288 :link
'(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-custom
)
1291 (defcustom gnus-treat-strip-banner t
1292 "Strip banners from articles.
1293 The banner to be stripped is specified in the `banner' group parameter.
1294 Valid values are nil, t, `head', `first', `last', an integer or a
1295 predicate. See Info node `(gnus)Customizing Articles'."
1296 :group
'gnus-article-treat
1297 :link
'(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom
)
1300 (defcustom gnus-treat-highlight-headers
'head
1301 "Highlight the headers.
1302 Valid values are nil, t, `head', `first', `last', an integer or a
1303 predicate. See Info node `(gnus)Customizing Articles'."
1304 :group
'gnus-article-treat
1305 :link
'(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-head-custom
)
1307 (put 'gnus-treat-highlight-headers
'highlight t
)
1309 (defcustom gnus-treat-highlight-citation t
1310 "Highlight cited text.
1311 Valid values are nil, t, `head', `first', `last', an integer or a
1312 predicate. See Info node `(gnus)Customizing Articles'."
1313 :group
'gnus-article-treat
1314 :link
'(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom
)
1316 (put 'gnus-treat-highlight-citation
'highlight t
)
1318 (defcustom gnus-treat-strip-headers-in-body t
1319 "Strip the X-No-Archive header line from the beginning of the body.
1320 Valid values are nil, t, `head', `first', `last', an integer or a
1321 predicate. See Info node `(gnus)Customizing Articles'."
1323 :group
'gnus-article-treat
1324 :link
'(custom-manual "(gnus)Customizing Articles")
1325 :type gnus-article-treat-custom
)
1327 (defcustom gnus-treat-strip-trailing-blank-lines nil
1328 "Strip trailing blank lines.
1329 Valid values are nil, t, `head', `first', `last', an integer or a
1330 predicate. See Info node `(gnus)Customizing Articles'.
1332 When set to t, it also strips trailing blanks in all MIME parts.
1333 Consider to use `last' instead."
1334 :group
'gnus-article-treat
1335 :link
'(custom-manual "(gnus)Customizing Articles")
1336 :type gnus-article-treat-custom
)
1338 (defcustom gnus-treat-strip-leading-blank-lines nil
1339 "Strip leading blank lines.
1340 Valid values are nil, t, `head', `first', `last', an integer or a
1341 predicate. See Info node `(gnus)Customizing Articles'.
1343 When set to t, it also strips trailing blanks in all MIME parts."
1344 :group
'gnus-article-treat
1345 :link
'(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom
)
1348 (defcustom gnus-treat-strip-multiple-blank-lines nil
1349 "Strip multiple blank lines.
1350 Valid values are nil, t, `head', `first', `last', an integer or a
1351 predicate. See Info node `(gnus)Customizing Articles'."
1352 :group
'gnus-article-treat
1353 :link
'(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom
)
1356 (defcustom gnus-treat-unfold-headers
'head
1357 "Unfold folded header lines.
1358 Valid values are nil, t, `head', `first', `last', an integer or a
1359 predicate. See Info node `(gnus)Customizing Articles'."
1361 :group
'gnus-article-treat
1362 :link
'(custom-manual "(gnus)Customizing Articles")
1363 :type gnus-article-treat-custom
)
1365 (defcustom gnus-article-unfold-long-headers nil
1366 "If non-nil, allow unfolding headers even if the header is long.
1367 If it is a regexp, only long headers matching this regexp are unfolded.
1368 If it is t, all long headers are unfolded.
1370 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1371 :version
"23.1" ;; No Gnus
1372 :group
'gnus-article-treat
1373 :type
'(choice (const nil
)
1374 (const :tag
"all" t
)
1377 (defcustom gnus-treat-fold-headers nil
1379 Valid values are nil, t, `head', `first', `last', an integer or a
1380 predicate. See Info node `(gnus)Customizing Articles'."
1382 :group
'gnus-article-treat
1383 :link
'(custom-manual "(gnus)Customizing Articles")
1384 :type gnus-article-treat-custom
)
1386 (defcustom gnus-treat-fold-newsgroups
'head
1387 "Fold the Newsgroups and Followup-To headers.
1388 Valid values are nil, t, `head', `first', `last', an integer or a
1389 predicate. See Info node `(gnus)Customizing Articles'."
1391 :group
'gnus-article-treat
1392 :link
'(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom
)
1395 (defcustom gnus-treat-overstrike t
1396 "Treat overstrike highlighting.
1397 Valid values are nil, t, `head', `first', `last', an integer or a
1398 predicate. See Info node `(gnus)Customizing Articles'."
1399 :group
'gnus-article-treat
1400 :link
'(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom
)
1402 (put 'gnus-treat-overstrike
'highlight t
)
1404 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1405 "Treat ANSI SGR control sequences.
1406 Valid values are nil, t, `head', `first', `last', an integer or a
1407 predicate. See Info node `(gnus)Customizing Articles'."
1408 :group
'gnus-article-treat
1409 :link
'(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom
)
1412 (make-obsolete-variable 'gnus-treat-display-xface
1413 'gnus-treat-display-x-face
"Emacs 22.1")
1415 (defcustom gnus-treat-display-x-face
1416 (and (not noninteractive
)
1417 (gnus-image-type-available-p 'xbm
)
1418 (if (featurep 'xemacs
)
1421 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1422 (executable-find "icontopbm"))
1423 ;; shell-command-to-string may signal an error, e.g. if
1424 ;; shell-file-name is not found.
1427 "Display X-Face headers.
1428 Valid values are nil and `head'.
1429 See Info node `(gnus)Customizing Articles' and Info node
1430 `(gnus)X-Face' for details."
1431 :group
'gnus-article-treat
1433 :link
'(custom-manual "(gnus)Customizing Articles")
1434 :link
'(custom-manual "(gnus)X-Face")
1435 :type gnus-article-treat-head-custom
1436 :set
(lambda (symbol value
)
1439 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1441 ((boundp 'gnus-treat-display-xface
)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (default-value 'gnus-treat-display-xface
))
1446 ((get 'gnus-treat-display-xface
'saved-value
)
1448 ** gnus-treat-display-xface is an obsolete variable;\
1449 use gnus-treat-display-x-face instead")
1450 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1453 (put 'gnus-treat-display-x-face
'highlight t
)
1455 (defcustom gnus-treat-display-face
1456 (and (not noninteractive
)
1457 (gnus-image-type-available-p 'png
)
1459 "Display Face headers.
1460 Valid values are nil, t, `head', `first', `last', an integer or a
1461 predicate. See Info node `(gnus)Customizing Articles' and Info
1462 node `(gnus)Face' for details."
1463 :group
'gnus-article-treat
1465 :link
'(custom-manual "(gnus)Customizing Articles")
1466 :link
'(custom-manual "(gnus)X-Face")
1467 :type gnus-article-treat-head-custom
)
1468 (put 'gnus-treat-display-face
'highlight t
)
1470 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1472 Valid values are nil, t, `head', `first', `last', an integer or a
1473 predicate. See Info node `(gnus)Customizing Articles' and Info
1474 node `(gnus)Smileys' for details."
1475 :group
'gnus-article-treat
1477 :link
'(custom-manual "(gnus)Customizing Articles")
1478 :link
'(custom-manual "(gnus)Smileys")
1479 :type gnus-article-treat-custom
)
1480 (put 'gnus-treat-display-smileys
'highlight t
)
1482 (defcustom gnus-treat-from-picon
1483 (if (and (gnus-image-type-available-p 'xpm
)
1484 (gnus-picons-installed-p))
1486 "Display picons in the From header.
1487 Valid values are nil, t, `head', `first', `last', an integer or a
1488 predicate. See Info node `(gnus)Customizing Articles' and Info
1489 node `(gnus)Picons' for details."
1491 :group
'gnus-article-treat
1493 :link
'(custom-manual "(gnus)Customizing Articles")
1494 :link
'(custom-manual "(gnus)Picons")
1495 :type gnus-article-treat-head-custom
)
1496 (put 'gnus-treat-from-picon
'highlight t
)
1498 (defcustom gnus-treat-mail-picon
1499 (if (and (gnus-image-type-available-p 'xpm
)
1500 (gnus-picons-installed-p))
1502 "Display picons in To and Cc headers.
1503 Valid values are nil, t, `head', `first', `last', an integer or a
1504 predicate. See Info node `(gnus)Customizing Articles' and Info
1505 node `(gnus)Picons' for details."
1507 :group
'gnus-article-treat
1509 :link
'(custom-manual "(gnus)Customizing Articles")
1510 :link
'(custom-manual "(gnus)Picons")
1511 :type gnus-article-treat-head-custom
)
1512 (put 'gnus-treat-mail-picon
'highlight t
)
1514 (defcustom gnus-treat-newsgroups-picon
1515 (if (and (gnus-image-type-available-p 'xpm
)
1516 (gnus-picons-installed-p))
1518 "Display picons in the Newsgroups and Followup-To headers.
1519 Valid values are nil, t, `head', `first', `last', an integer or a
1520 predicate. See Info node `(gnus)Customizing Articles' and Info
1521 node `(gnus)Picons' for details."
1523 :group
'gnus-article-treat
1525 :link
'(custom-manual "(gnus)Customizing Articles")
1526 :link
'(custom-manual "(gnus)Picons")
1527 :type gnus-article-treat-head-custom
)
1528 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1530 (defcustom gnus-treat-from-gravatar nil
1531 "Display gravatars in the From header.
1532 Valid values are nil, t, `head', `first', `last', an integer or a
1533 predicate. See Info node `(gnus)Customizing Articles' and Info
1534 node `(gnus)Gravatars' for details."
1536 :group
'gnus-article-treat
1537 :group
'gnus-gravatar
1538 :link
'(custom-manual "(gnus)Customizing Articles")
1539 :link
'(custom-manual "(gnus)Gravatars")
1540 :type gnus-article-treat-head-custom
)
1541 (put 'gnus-treat-from-gravatar
'highlight t
)
1543 (defcustom gnus-treat-mail-gravatar nil
1544 "Display gravatars in To and Cc headers.
1545 Valid values are nil, t, `head', `first', `last', an integer or a
1546 predicate. See Info node `(gnus)Customizing Articles' and Info
1547 node `(gnus)Gravatars' for details."
1549 :group
'gnus-article-treat
1550 :group
'gnus-gravatar
1551 :link
'(custom-manual "(gnus)Customizing Articles")
1552 :link
'(custom-manual "(gnus)Gravatars")
1553 :type gnus-article-treat-head-custom
)
1554 (put 'gnus-treat-mail-gravatar
'highlight t
)
1556 (defcustom gnus-treat-body-boundary
1557 (if (or gnus-treat-newsgroups-picon
1558 gnus-treat-mail-picon
1559 gnus-treat-from-picon
1560 gnus-treat-from-gravatar
1561 gnus-treat-mail-gravatar
)
1562 ;; If there's much decoration, the user might prefer a boundary.
1565 "Draw a boundary at the end of the headers.
1566 Valid values are nil and `head'.
1567 See Info node `(gnus)Customizing Articles' for details."
1569 :group
'gnus-article-treat
1570 :link
'(custom-manual "(gnus)Customizing Articles")
1571 :type gnus-article-treat-head-custom
)
1573 (defcustom gnus-treat-capitalize-sentences nil
1574 "Capitalize sentence-starting words.
1575 Valid values are nil, t, `head', `first', `last', an integer or a
1576 predicate. See Info node `(gnus)Customizing Articles'."
1578 :group
'gnus-article-treat
1579 :link
'(custom-manual "(gnus)Customizing Articles")
1580 :type gnus-article-treat-custom
)
1582 (defcustom gnus-treat-wash-html nil
1584 Valid values are nil, t, `head', `first', `last', an integer or a
1585 predicate. See Info node `(gnus)Customizing Articles'."
1587 :group
'gnus-article-treat
1588 :link
'(custom-manual "(gnus)Customizing Articles")
1589 :type gnus-article-treat-custom
)
1591 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1593 Valid values are nil, t, `head', `first', `last', an integer or a
1594 predicate. See Info node `(gnus)Customizing Articles'."
1596 :group
'gnus-article-treat
1597 :link
'(custom-manual "(gnus)Customizing Articles")
1598 :type gnus-article-treat-custom
)
1600 (defcustom gnus-treat-x-pgp-sig nil
1602 To automatically treat X-PGP-Sig, set it to head.
1603 Valid values are nil, t, `head', `first', `last', an integer or a
1604 predicate. See Info node `(gnus)Customizing Articles'."
1606 :group
'gnus-article-treat
1607 :group
'mime-security
1608 :link
'(custom-manual "(gnus)Customizing Articles")
1609 :type gnus-article-treat-custom
)
1611 (defvar gnus-article-encrypt-protocol-alist
1612 '(("PGP" . mml2015-self-encrypt
)))
1614 ;; Set to nil if more than one protocol added to
1615 ;; gnus-article-encrypt-protocol-alist.
1616 (defcustom gnus-article-encrypt-protocol
"PGP"
1617 "The protocol used for encrypt articles.
1618 It is a string, such as \"PGP\". If nil, ask user."
1621 :group
'mime-security
)
1623 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1624 (mm-coding-system-p 'utf-8
)
1625 (executable-find idna-program
))
1626 "Whether IDNA decoding of headers is used when viewing messages.
1627 This requires GNU Libidn, and by default only enabled if it is found."
1629 :group
'gnus-article-headers
1632 (defcustom gnus-article-over-scroll nil
1633 "If non-nil, allow scrolling the article buffer even when there no more text."
1635 :group
'gnus-article
1638 (defcustom gnus-inhibit-images nil
1639 "Non-nil means inhibit displaying of images inline in the article body."
1641 :group
'gnus-article
1644 (defcustom gnus-blocked-images
'gnus-block-private-groups
1645 "Images that have URLs matching this regexp will be blocked.
1646 This can also be a function to be evaluated. If so, it will be
1647 called with the group name as the parameter, and should return a
1651 :type
'(choice regexp function
))
1653 ;;; Internal variables
1655 (defvar gnus-english-month-names
1656 '("January" "February" "March" "April" "May" "June" "July" "August"
1657 "September" "October" "November" "December"))
1659 (defvar article-goto-body-goes-to-point-min-p nil
)
1660 (defvar gnus-article-wash-types nil
)
1661 (defvar gnus-article-emphasis-alist nil
)
1662 (defvar gnus-article-image-alist nil
)
1664 (defvar gnus-article-mime-handle-alist-1 nil
)
1665 (defvar gnus-treatment-function-alist
1666 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1667 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1668 (gnus-treat-strip-banner gnus-article-strip-banner
)
1669 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1670 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1671 (gnus-treat-buttonize gnus-article-add-buttons
)
1672 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1673 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1674 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1675 (gnus-treat-display-x-face gnus-article-display-x-face
)
1676 (gnus-treat-display-face gnus-article-display-face
)
1677 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1678 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1679 (gnus-treat-hide-signature gnus-article-hide-signature
)
1680 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1681 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1682 (gnus-treat-from-picon gnus-treat-from-picon
)
1683 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1684 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1685 (gnus-treat-strip-pem gnus-article-hide-pem
)
1686 (gnus-treat-date gnus-article-treat-date
)
1687 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1688 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1689 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1690 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1691 (gnus-treat-strip-trailing-blank-lines
1692 gnus-article-remove-trailing-blank-lines
)
1693 (gnus-treat-strip-leading-blank-lines
1694 gnus-article-strip-leading-blank-lines
)
1695 (gnus-treat-strip-multiple-blank-lines
1696 gnus-article-strip-multiple-blank-lines
)
1697 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1698 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1699 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1700 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1701 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1702 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1703 (gnus-treat-display-smileys gnus-treat-smiley
)
1704 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1705 (gnus-treat-wash-html gnus-article-wash-html
)
1706 (gnus-treat-emphasize gnus-article-emphasize
)
1707 (gnus-treat-hide-citation gnus-article-hide-citation
)
1708 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1709 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1710 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1712 (defvar gnus-article-mime-handle-alist nil
)
1713 (defvar article-lapsed-timer nil
)
1714 (defvar gnus-article-current-summary nil
)
1716 (defvar gnus-article-mode-syntax-table
1717 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1718 ;; This causes the citation match run O(2^n).
1719 ;; (modify-syntax-entry ?- "w" table)
1720 (modify-syntax-entry ?
> ")<" table
)
1721 (modify-syntax-entry ?
< "(>" table
)
1722 ;; make M-. in article buffers work for `foo' strings
1723 (modify-syntax-entry ?
' " " table
)
1724 (modify-syntax-entry ?
` " " table
)
1726 "Syntax table used in article mode buffers.
1727 Initialized from `text-mode-syntax-table.")
1729 (defvar gnus-save-article-buffer nil
)
1731 (defvar gnus-number-of-articles-to-be-saved nil
)
1733 (defvar gnus-inhibit-hiding nil
)
1735 (defvar gnus-article-edit-mode nil
)
1737 ;;; Macros for dealing with the article buffer.
1739 (defmacro gnus-with-article-headers
(&rest forms
)
1740 `(with-current-buffer gnus-article-buffer
1742 (let ((inhibit-read-only t
)
1743 (inhibit-point-motion-hooks t
)
1744 (case-fold-search t
))
1745 (article-narrow-to-head)
1748 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1749 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1751 (defmacro gnus-with-article-buffer
(&rest forms
)
1752 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1753 (with-current-buffer gnus-article-buffer
1754 (let ((inhibit-read-only t
))
1757 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1758 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1760 (defun gnus-article-goto-header (header)
1761 "Go to HEADER, which is a regular expression."
1762 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1764 (defsubst gnus-article-hide-text
(b e props
)
1765 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1766 (gnus-add-text-properties-when 'article-type nil b e props
)
1767 (when (memq 'intangible props
)
1769 (max (1- b
) (point-min))
1770 b
'intangible
(cddr (memq 'intangible props
)))))
1772 (defsubst gnus-article-unhide-text
(b e
)
1773 "Remove hidden text properties from region between B and E."
1774 (remove-text-properties b e gnus-hidden-properties
)
1775 (when (memq 'intangible gnus-hidden-properties
)
1776 (put-text-property (max (1- b
) (point-min))
1777 b
'intangible nil
)))
1779 (defun gnus-article-hide-text-type (b e type
)
1780 "Hide text of TYPE between B and E."
1781 (gnus-add-wash-type type
)
1782 (gnus-article-hide-text
1783 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1785 (defun gnus-article-unhide-text-type (b e type
)
1786 "Unhide text of TYPE between B and E."
1787 (gnus-delete-wash-type type
)
1788 (remove-text-properties
1789 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1790 (when (memq 'intangible gnus-hidden-properties
)
1791 (put-text-property (max (1- b
) (point-min))
1792 b
'intangible nil
)))
1794 (defun gnus-article-delete-text-of-type (type)
1795 "Delete text of TYPE in the current buffer."
1797 (let ((b (point-min)))
1798 (if (eq type
'multipart
)
1799 ;; Remove MIME buttons associated with multipart/alternative parts.
1802 (while (if (get-text-property (point) 'gnus-part
)
1804 (when (setq b
(next-single-property-change (point)
1809 (skip-chars-forward "\n")
1810 (when (eq (get-text-property b
'article-type
) 'multipart
)
1811 (delete-region b
(point)))))
1812 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1814 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1817 (defun gnus-article-delete-invisible-text ()
1818 "Delete all invisible text in the current buffer."
1820 (let ((b (point-min)))
1821 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1823 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1826 (defsubst gnus-article-header-rank
()
1827 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1828 (let ((list gnus-sorted-header-list
)
1831 (if (looking-at (car list
))
1833 (setq list
(cdr list
))
1837 (defun article-hide-headers (&optional arg delete
)
1838 "Hide unwanted headers and possibly sort them as well."
1840 ;; This function might be inhibited.
1841 (unless gnus-inhibit-hiding
1842 (let ((inhibit-read-only t
)
1843 (case-fold-search t
)
1844 (max (1+ (length gnus-sorted-header-list
)))
1845 (inhibit-point-motion-hooks t
)
1846 (cur (current-buffer))
1847 ignored visible beg
)
1849 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1850 ;; group parameters, so we should go to the summary buffer.
1853 (progn (set-buffer gnus-summary-buffer
) t
)
1855 (setq ignored
(when (not gnus-visible-headers
)
1856 (cond ((stringp gnus-ignored-headers
)
1857 gnus-ignored-headers
)
1858 ((listp gnus-ignored-headers
)
1859 (mapconcat 'identity
1860 gnus-ignored-headers
1862 visible
(cond ((stringp gnus-visible-headers
)
1863 gnus-visible-headers
)
1864 ((and gnus-visible-headers
1865 (listp gnus-visible-headers
))
1866 (mapconcat 'identity
1867 gnus-visible-headers
1871 ;; First we narrow to just the headers.
1872 (article-narrow-to-head)
1873 ;; Hide any "From " lines at the beginning of (mail) articles.
1874 (while (looking-at "From ")
1877 (delete-region (point-min) (point)))
1878 ;; Then treat the rest of the header lines.
1879 ;; Then we use the two regular expressions
1880 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1881 ;; select which header lines is to remain visible in the
1883 (while (re-search-forward "^[^ \t:]*:" nil t
)
1885 ;; Mark the rank of the header.
1887 (point) (1+ (point)) 'message-rank
1888 (if (or (and visible
(looking-at visible
))
1890 (not (looking-at ignored
))))
1891 (gnus-article-header-rank)
1894 (message-sort-headers-1)
1895 (when (setq beg
(text-property-any
1896 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1897 ;; We delete the unwanted headers.
1898 (gnus-add-wash-type 'headers
)
1899 (add-text-properties (point-min) (+ 5 (point-min))
1900 '(article-type headers dummy-invisible t
))
1901 (delete-region beg
(point-max))))))))
1903 (defun article-hide-boring-headers (&optional arg
)
1904 "Toggle hiding of headers that aren't very interesting.
1905 If given a negative prefix, always show; if given a positive prefix,
1907 (interactive (gnus-article-hidden-arg))
1908 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1909 (not gnus-show-all-headers
))
1912 (let ((inhibit-read-only t
)
1913 (inhibit-point-motion-hooks t
))
1914 (article-narrow-to-head)
1915 (dolist (elem gnus-boring-article-headers
)
1916 (goto-char (point-min))
1918 ;; Hide empty headers.
1920 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1922 (gnus-article-hide-text-type
1926 (if (re-search-forward "^[^ \t]" nil t
)
1930 ;; Hide boring Newsgroups header.
1931 ((eq elem
'newsgroups
)
1932 (when (gnus-string-equal
1933 (gnus-fetch-field "newsgroups")
1934 (gnus-group-real-name
1935 (if (boundp 'gnus-newsgroup-name
)
1938 (gnus-article-hide-header "newsgroups")))
1939 ((eq elem
'to-address
)
1940 (let ((to (message-fetch-field "to"))
1942 (gnus-parameter-to-address
1943 (if (boundp 'gnus-newsgroup-name
)
1944 gnus-newsgroup-name
""))))
1945 (when (and to to-address
1948 ;; only one address in To
1949 (nth 1 (mail-extract-address-components to
))
1951 (gnus-article-hide-header "to"))))
1953 (let ((to (message-fetch-field "to"))
1955 (gnus-parameter-to-list
1956 (if (boundp 'gnus-newsgroup-name
)
1957 gnus-newsgroup-name
""))))
1958 (when (and to to-list
1961 ;; only one address in To
1962 (nth 1 (mail-extract-address-components to
))
1964 (gnus-article-hide-header "to"))))
1966 (let ((cc (message-fetch-field "cc"))
1968 (gnus-parameter-to-list
1969 (if (boundp 'gnus-newsgroup-name
)
1970 gnus-newsgroup-name
""))))
1971 (when (and cc to-list
1974 ;; only one address in CC
1975 (nth 1 (mail-extract-address-components cc
))
1977 (gnus-article-hide-header "cc"))))
1978 ((eq elem
'followup-to
)
1979 (when (gnus-string-equal
1980 (message-fetch-field "followup-to")
1981 (message-fetch-field "newsgroups"))
1982 (gnus-article-hide-header "followup-to")))
1983 ((eq elem
'reply-to
)
1984 (if (gnus-group-find-parameter
1985 gnus-newsgroup-name
'broken-reply-to
)
1986 (gnus-article-hide-header "reply-to")
1987 (let ((from (message-fetch-field "from"))
1988 (reply-to (message-fetch-field "reply-to")))
1995 (lambda (x) (downcase (cadr x
)))
1996 (mail-extract-address-components from t
))
1999 (lambda (x) (downcase (cadr x
)))
2000 (mail-extract-address-components reply-to t
))
2002 (gnus-article-hide-header "reply-to")))))
2004 (let ((date (with-current-buffer gnus-original-article-buffer
2005 ;; If date in `gnus-article-buffer' is localized
2006 ;; (`gnus-treat-date-user-defined'),
2007 ;; `days-between' might fail.
2008 (message-fetch-field "date"))))
2010 (< (days-between (current-time-string) date
)
2012 (gnus-article-hide-header "date"))))
2014 (let ((to (message-fetch-field "to"))
2015 (cc (message-fetch-field "cc")))
2016 (when (> (length to
) 1024)
2017 (gnus-article-hide-header "to"))
2018 (when (> (length cc
) 1024)
2019 (gnus-article-hide-header "cc"))))
2023 (goto-char (point-min))
2024 (while (re-search-forward "^to:" nil t
)
2025 (setq to-count
(1+ to-count
)))
2026 (when (> to-count
1)
2027 (while (> to-count
0)
2028 (goto-char (point-min))
2030 (re-search-forward "^to:" nil nil to-count
)
2032 (narrow-to-region (point) (point-max))
2033 (gnus-article-hide-header "to"))
2034 (setq to-count
(1- to-count
))))
2035 (goto-char (point-min))
2036 (while (re-search-forward "^cc:" nil t
)
2037 (setq cc-count
(1+ cc-count
)))
2038 (when (> cc-count
1)
2039 (while (> cc-count
0)
2040 (goto-char (point-min))
2042 (re-search-forward "^cc:" nil nil cc-count
)
2044 (narrow-to-region (point) (point-max))
2045 (gnus-article-hide-header "cc"))
2046 (setq cc-count
(1- cc-count
)))))))))))))
2048 (defun gnus-article-hide-header (header)
2050 (goto-char (point-min))
2051 (when (re-search-forward (concat "^" header
":") nil t
)
2052 (gnus-article-hide-text-type
2056 (if (re-search-forward "^[^ \t]" nil t
)
2061 (defvar gnus-article-normalized-header-length
40
2062 "Length of normalized headers.")
2064 (defun article-normalize-headers ()
2065 "Make all header lines 40 characters long."
2067 (let ((inhibit-read-only t
)
2071 (article-narrow-to-head)
2074 ((< (setq column
(- (point-at-eol) (point)))
2075 gnus-article-normalized-header-length
)
2077 (insert (make-string
2078 (- gnus-article-normalized-header-length column
)
2080 ((> column gnus-article-normalized-header-length
)
2081 (gnus-put-text-property
2083 (forward-char gnus-article-normalized-header-length
)
2090 (forward-line 1))))))
2092 (defun article-treat-dumbquotes ()
2093 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2094 Note that this function guesses whether a character is a sm*rtq**t* or
2095 not, so it should only be used interactively.
2097 Sm*rtq**t*s are M****s***'s unilateral extension to the
2098 iso-8859-1 character map in an attempt to provide more quoting
2099 characters. If you see something like \\222 or \\264 where
2100 you're expecting some kind of apostrophe or quotation mark, then
2103 (article-translate-strings gnus-article-dumbquotes-map
))
2105 (defvar org-entities
)
2107 (defun article-treat-non-ascii ()
2108 "Translate many Unicode characters into their ASCII equivalents."
2110 (require 'org-entities
)
2111 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2112 (dolist (elem org-entities
)
2113 (when (and (listp elem
)
2114 (= (length (nth 6 elem
)) 1))
2115 (if (featurep 'xemacs
)
2116 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2117 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2119 (when (article-goto-body)
2120 (let ((inhibit-read-only t
)
2123 (if (not (setq replace
(if (featurep 'xemacs
)
2124 (get-char-table (following-char) table
)
2125 (aref table
(following-char)))))
2128 (setq props
(text-properties-at (point)))
2130 (add-text-properties (point) (progn (insert replace
) (point))
2132 (insert replace
)))))))))
2134 (defun article-translate-strings (map)
2135 "Translate all string in the body of the article according to MAP.
2136 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2138 (when (article-goto-body)
2139 (let ((inhibit-read-only t
))
2141 (let ((from (car elem
))
2145 (while (search-forward from nil t
)
2148 (if (eq (following-char) from
)
2152 (forward-char 1)))))))))))
2154 (defun article-treat-overstrike ()
2155 "Translate overstrikes into bold text."
2158 (when (article-goto-body)
2159 (let ((inhibit-read-only t
))
2160 (while (search-forward "\b" nil t
)
2161 (let ((next (char-after))
2162 (previous (char-after (- (point) 2))))
2163 ;; We do the boldification/underlining by hiding the
2164 ;; overstrikes and putting the proper text property
2168 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2169 (put-text-property (point) (1+ (point)) 'face
'bold
))
2171 (gnus-article-hide-text-type
2172 (1- (point)) (1+ (point)) 'overstrike
)
2174 (- (point) 2) (1- (point)) 'face
'underline
))
2176 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2178 (point) (1+ (point)) 'face
'underline
)))))))))
2180 (defun article-treat-ansi-sequences ()
2181 "Translate ANSI SGR control sequences into overlays or extents."
2184 (when (article-goto-body)
2185 (let ((inhibit-read-only t
))
2186 (ansi-color-apply-on-region (point) (point-max))))))
2188 (defun gnus-article-treat-unfold-headers ()
2189 "Unfold folded message headers.
2190 Only the headers that fit into the current window width will be
2193 (gnus-with-article-headers
2197 (mail-header-narrow-to-field)
2198 (let* ((header (buffer-string))
2200 (or (equal gnus-article-unfold-long-headers t
)
2201 (and (stringp gnus-article-unfold-long-headers
)
2202 (string-match gnus-article-unfold-long-headers
2206 (goto-char (point-min))
2207 (while (re-search-forward "\n[\t ]" nil t
)
2208 (replace-match " " t t
)))
2209 (setq length
(- (point-max) (point-min) 1))
2210 (when (or unfoldable
2211 (< length
(window-width)))
2212 (while (re-search-forward "\n[\t ]" nil t
)
2213 (replace-match " " t t
))))
2214 (goto-char (point-max)))))))
2216 (defun gnus-article-treat-fold-headers ()
2217 "Fold message headers."
2219 (gnus-with-article-headers
2222 (mail-header-narrow-to-field)
2223 (mail-header-fold-field)
2224 (goto-char (point-max))))))
2226 (defun gnus-treat-smiley ()
2227 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2229 (gnus-with-article-buffer
2230 (if (memq 'smiley gnus-article-wash-types
)
2231 (gnus-delete-images 'smiley
)
2233 (let ((images (smiley-region (point) (point-max))))
2235 (gnus-add-wash-type 'smiley
)
2236 (dolist (image images
)
2237 (gnus-add-image 'smiley image
)))))))
2239 (defun gnus-article-remove-images ()
2240 "Remove all images from the article buffer."
2242 (gnus-with-article-buffer
2245 (dolist (elem gnus-article-image-alist
)
2246 (gnus-delete-images (car elem
))))))
2248 (autoload 'w3m-toggle-inline-images
"w3m")
2250 (defun gnus-article-show-images ()
2251 "Show any images that are in the HTML-rendered article buffer.
2252 This only works if the article in question is HTML."
2254 (gnus-with-article-buffer
2257 (if (eq mm-text-html-renderer
'w3m
)
2258 (let ((mm-inline-text-html-with-images nil
))
2259 (w3m-toggle-inline-images))
2260 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2262 (destructuring-bind (start end function
) region
2263 (funcall function
(get-text-property start
'image-url
)
2266 (defun gnus-article-treat-fold-newsgroups ()
2267 "Unfold folded message headers.
2268 Only the headers that fit into the current window width will be
2271 (gnus-with-article-headers
2272 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2274 (mail-header-narrow-to-field)
2275 (while (re-search-forward ", *" nil t
)
2276 (replace-match ", " t t
))
2277 (mail-header-fold-field)
2278 (goto-char (point-max))))))
2280 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2281 "Value of `truncate-lines' in Gnus Article buffer.
2282 Valid values are nil, t, `head', `first', `last', an integer or a
2283 predicate. See Info node `(gnus)Customizing Articles'."
2284 :version
"23.1" ;; No Gnus
2285 :group
'gnus-article
2286 ;; :link '(custom-manual "(gnus)Customizing Articles")
2289 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2290 "Toggle whether to fold or truncate long lines in article the buffer.
2291 If ARG is non-nil and not a number, toggle
2292 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2293 long lines if and only if arg is positive."
2296 ((and (numberp arg
) (> arg
0))
2297 (setq gnus-article-truncate-lines t
))
2299 (setq gnus-article-truncate-lines nil
))
2301 (setq gnus-article-truncate-lines
2302 (not gnus-article-truncate-lines
))))
2303 (gnus-with-article-buffer
2305 ((and (numberp arg
) (> arg
0))
2306 (setq truncate-lines nil
))
2308 (setq truncate-lines t
)))
2309 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2310 ;; `toggle-truncate-lines' needs an argument.
2311 (toggle-truncate-lines)))
2313 (defun gnus-article-treat-body-boundary ()
2314 "Place a boundary line at the end of the headers."
2316 (when (and gnus-body-boundary-delimiter
2317 (> (length gnus-body-boundary-delimiter
) 0))
2318 (gnus-with-article-headers
2319 (goto-char (point-max))
2320 (let ((start (point)))
2321 (insert "X-Boundary: ")
2322 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2323 (insert (let (str (max (window-width)))
2324 (if (featurep 'xemacs
)
2325 (setq max
(1- max
)))
2326 (while (>= max
(length str
))
2327 (setq str
(concat str gnus-body-boundary-delimiter
)))
2328 (substring str
0 max
))
2330 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2332 (defun article-fill-long-lines ()
2333 "Fill lines that are wider than the window width."
2336 (let ((inhibit-read-only t
)
2337 (width (window-width (get-buffer-window (current-buffer)))))
2340 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2343 (when (>= (current-column) (min fill-column width
))
2344 (narrow-to-region (min (1+ (point)) (point-max))
2346 (let ((goback (point-marker)))
2347 (fill-paragraph nil
)
2348 (goto-char (marker-position goback
)))
2350 (forward-line 1)))))))
2352 (defun article-capitalize-sentences ()
2353 "Capitalize the first word in each sentence."
2356 (let ((inhibit-read-only t
)
2357 (paragraph-start "^[\n\^L]"))
2361 (forward-sentence)))))
2363 (defun article-remove-cr ()
2364 "Remove trailing CRs and then translate remaining CRs into LFs."
2367 (let ((inhibit-read-only t
))
2368 (goto-char (point-min))
2369 (while (re-search-forward "\r+$" nil t
)
2370 (replace-match "" t t
))
2371 (goto-char (point-min))
2372 (while (search-forward "\r" nil t
)
2373 (replace-match "\n" t t
)))))
2375 (defun article-remove-trailing-blank-lines ()
2376 "Remove all trailing blank lines from the article."
2379 (let ((inhibit-read-only t
))
2380 (goto-char (point-max))
2384 (while (and (not (bobp))
2385 (looking-at "^[ \t]*$")
2386 (not (gnus-annotation-in-region-p
2387 (point) (point-at-eol))))
2392 (defvar gnus-face-properties-alist
)
2394 (defun article-display-face (&optional force
)
2395 "Display any Face headers in the header."
2396 (interactive (list 'force
))
2397 (let ((wash-face-p buffer-read-only
))
2398 (gnus-with-article-headers
2399 ;; When displaying parts, this function can be called several times on
2400 ;; the same article, without any intended toggle semantic (as typing `W
2401 ;; D d' would have). So face deletion must occur only when we come from
2402 ;; an interactive command, that is when the *Article* buffer is
2404 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2405 (gnus-delete-images 'face
)
2406 (let ((from (message-fetch-field "from"))
2408 (save-current-buffer
2409 (when (and wash-face-p
2410 (gnus-buffer-live-p gnus-original-article-buffer
)
2411 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2412 (set-buffer gnus-original-article-buffer
))
2414 (mail-narrow-to-head)
2416 ;; Check whether this face is censored.
2417 (not (and gnus-article-x-face-too-ugly
2419 (setq from
(message-fetch-field "from")))
2420 (string-match gnus-article-x-face-too-ugly
2422 (while (gnus-article-goto-header "Face")
2423 (push (mail-header-field-value) faces
)))))
2425 (goto-char (point-min))
2427 (unless (setq from
(gnus-article-goto-header "from"))
2430 (insert " [no `from' set]\n"))
2432 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2434 (apply 'gnus-create-image png
'png t
2435 (cdr (assq 'png gnus-face-properties-alist
))))
2438 (gnus-add-wash-type 'face
)
2439 (gnus-add-image 'face image
)
2440 (gnus-put-image image nil
'face
)))))))))))
2442 (defun article-display-x-face (&optional force
)
2443 "Look for an X-Face header and display it if present."
2444 (interactive (list 'force
))
2445 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2446 (gnus-with-article-headers
2447 ;; Delete the old process, if any.
2448 (when (process-status "article-x-face")
2449 (delete-process "article-x-face"))
2450 ;; See the comment in `article-display-face'.
2451 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2452 ;; We have already displayed X-Faces, so we remove them
2454 (gnus-delete-images 'xface
)
2456 (let ((from (message-fetch-field "from"))
2458 (save-current-buffer
2459 (when (and wash-face-p
2460 (gnus-buffer-live-p gnus-original-article-buffer
)
2461 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2462 ;; If type `W f', use gnus-original-article-buffer,
2463 ;; otherwise use the current buffer because displaying
2464 ;; RFC822 parts calls this function too.
2465 (set-buffer gnus-original-article-buffer
))
2467 (mail-narrow-to-head)
2468 (and gnus-article-x-face-command
2470 ;; Check whether this face is censored.
2471 (not (and gnus-article-x-face-too-ugly
2473 (setq from
(message-fetch-field "from")))
2474 (string-match gnus-article-x-face-too-ugly
2476 (while (gnus-article-goto-header "X-Face")
2477 (push (mail-header-field-value) x-faces
)))))
2479 ;; We display the face.
2480 (cond ((functionp gnus-article-x-face-command
)
2481 ;; The command is a lisp function, so we call it.
2482 (mapc gnus-article-x-face-command x-faces
))
2483 ((stringp gnus-article-x-face-command
)
2484 ;; The command is a string, so we interpret the command
2485 ;; as a, well, command, and fork it off.
2486 (let ((process-connection-type nil
))
2487 (gnus-set-process-query-on-exit-flag
2489 "article-x-face" nil shell-file-name
2490 shell-command-switch gnus-article-x-face-command
)
2492 ;; Sending multiple EOFs to xv doesn't work,
2493 ;; so we only do a single external face.
2495 (insert (car x-faces
))
2496 (process-send-region "article-x-face"
2497 (point-min) (point-max)))
2498 (process-send-eof "article-x-face")))
2500 (error "`%s' set to `%s' is not a function"
2501 gnus-article-x-face-command
2502 'gnus-article-x-face-command
)))))))))
2504 (defun article-decode-mime-words ()
2505 "Decode all MIME-encoded words in the article."
2507 (gnus-with-article-buffer
2508 (let ((inhibit-point-motion-hooks t
)
2509 (mail-parse-charset gnus-newsgroup-charset
)
2510 (mail-parse-ignored-charsets
2511 (with-current-buffer gnus-summary-buffer
2512 gnus-newsgroup-ignored-charsets
)))
2513 (mail-decode-encoded-word-region (point-min) (point-max)))))
2515 (defun article-decode-charset (&optional prompt
)
2516 "Decode charset-encoded text in the article.
2517 If PROMPT (the prefix), prompt for a coding system to use."
2519 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2520 (inhibit-read-only t
)
2521 (mail-parse-charset gnus-newsgroup-charset
)
2522 (mail-parse-ignored-charsets
2523 (save-excursion (condition-case nil
2524 (set-buffer gnus-summary-buffer
)
2526 gnus-newsgroup-ignored-charsets
))
2527 ct cte ctl charset format
)
2530 (article-narrow-to-head)
2531 (setq ct
(message-fetch-field "Content-Type" t
)
2532 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2533 ctl
(and ct
(mail-header-parse-content-type ct
))
2536 (mm-read-coding-system "Charset to decode: "))
2538 (mail-content-type-get ctl
'charset
)))
2539 format
(and ctl
(mail-content-type-get ctl
'format
)))
2541 (setq cte
(mail-header-strip cte
)))
2542 (if (and ctl
(not (string-match "/" (car ctl
))))
2544 (goto-char (point-max)))
2547 (narrow-to-region (point) (point-max))
2548 (when (and (eq mail-parse-charset
'gnus-decoded
)
2549 (eq (mm-body-7-or-8) '8bit
))
2550 ;; The text code could have been decoded.
2551 (setq charset mail-parse-charset
))
2552 (when (and (or (not ctl
)
2553 (equal (car ctl
) "text/plain"))
2554 (not format
)) ;; article with format will decode later.
2556 charset
(and cte
(intern (downcase
2557 (gnus-strip-whitespace cte
))))
2560 (defun article-decode-encoded-words ()
2561 "Remove encoded-word encoding from headers."
2562 (let ((inhibit-point-motion-hooks t
)
2563 (mail-parse-charset gnus-newsgroup-charset
)
2564 (mail-parse-ignored-charsets
2565 (save-excursion (condition-case nil
2566 (set-buffer gnus-summary-buffer
)
2568 gnus-newsgroup-ignored-charsets
))
2569 (inhibit-read-only t
)
2571 (goto-char (point-min))
2572 (when (search-forward "\n\n" nil
'move
)
2579 (memq (char-after) '(?
\t ?
)))))
2580 (setq start
(point))
2582 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2583 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2584 (funcall gnus-decode-address-function start end
)
2585 (funcall gnus-decode-header-function start end
))
2586 (goto-char (setq end start
)))))
2588 (defun article-decode-group-name ()
2589 "Decode group names in Newsgroups, Followup-To and Xref headers."
2590 (let ((inhibit-point-motion-hooks t
)
2591 (inhibit-read-only t
)
2592 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2594 (when (and (or gnus-group-name-charset-method-alist
2595 gnus-group-name-charset-group-alist
)
2596 (gnus-buffer-live-p gnus-original-article-buffer
))
2598 (article-narrow-to-head)
2599 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2600 (with-current-buffer gnus-original-article-buffer
2601 (goto-char (point-min)))
2602 (setq regexp
(concat "^" header
2603 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2604 (while (re-search-forward regexp nil t
)
2605 (replace-match (save-match-data
2606 (gnus-decode-newsgroups
2607 ;; XXX how to use data in article buffer?
2608 (with-current-buffer gnus-original-article-buffer
2609 (re-search-forward regexp nil t
)
2611 gnus-newsgroup-name method
))
2613 (goto-char (point-min)))))))
2615 (autoload 'idna-to-unicode
"idna")
2617 (defun article-decode-idna-rhs ()
2618 "Decode IDNA strings in RHS in various headers in current buffer.
2619 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2620 Mail-Reply-To: and Mail-Followup-To:."
2623 (let ((inhibit-point-motion-hooks t
)
2624 (inhibit-read-only t
))
2625 (article-narrow-to-head)
2626 (goto-char (point-min))
2627 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2629 (when (save-match-data
2630 (and (setq ace
(match-string 1))
2632 (and (re-search-backward "^[^ \t]" nil t
)
2633 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2634 (setq unicode
(idna-to-unicode ace
))))
2635 (unless (string= ace unicode
)
2636 (replace-match unicode nil nil nil
1)))))))))
2638 (defun article-de-quoted-unreadable (&optional force read-charset
)
2639 "Translate a quoted-printable-encoded article.
2640 If FORCE, decode the article whether it is marked as quoted-printable
2642 If READ-CHARSET, ask for a coding system."
2643 (interactive (list 'force current-prefix-arg
))
2645 (let ((inhibit-read-only t
) type charset
)
2646 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2647 (with-current-buffer gnus-original-article-buffer
2649 (gnus-fetch-field "content-transfer-encoding"))
2650 (let* ((ct (gnus-fetch-field "content-type"))
2651 (ctl (and ct
(mail-header-parse-content-type ct
))))
2652 (setq charset
(and ctl
2653 (mail-content-type-get ctl
'charset
)))
2654 (if (stringp charset
)
2655 (setq charset
(intern (downcase charset
)))))))
2657 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2659 (setq charset gnus-newsgroup-charset
))
2661 (and type
(let ((case-fold-search t
))
2662 (string-match "quoted-printable" type
))))
2664 (quoted-printable-decode-region
2665 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2667 (defun article-de-base64-unreadable (&optional force read-charset
)
2668 "Translate a base64 article.
2669 If FORCE, decode the article whether it is marked as base64 not.
2670 If READ-CHARSET, ask for a coding system."
2671 (interactive (list 'force current-prefix-arg
))
2673 (let ((inhibit-read-only t
) type charset
)
2674 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2675 (with-current-buffer gnus-original-article-buffer
2677 (gnus-fetch-field "content-transfer-encoding"))
2678 (let* ((ct (gnus-fetch-field "content-type"))
2679 (ctl (and ct
(mail-header-parse-content-type ct
))))
2680 (setq charset
(and ctl
2681 (mail-content-type-get ctl
'charset
)))
2682 (if (stringp charset
)
2683 (setq charset
(intern (downcase charset
)))))))
2685 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2687 (setq charset gnus-newsgroup-charset
))
2689 (and type
(let ((case-fold-search t
))
2690 (string-match "base64" type
))))
2693 (narrow-to-region (point) (point-max))
2694 (base64-decode-region (point-min) (point-max))
2695 (mm-decode-coding-region
2696 (point-min) (point-max)
2697 (mm-charset-to-coding-system charset nil t
)))))))
2702 (defun article-decode-HZ ()
2703 "Translate a HZ-encoded article."
2707 (let ((inhibit-read-only t
))
2708 (rfc1843-decode-region (point-min) (point-max)))))
2710 (defun article-unsplit-urls ()
2711 "Remove the newlines that some other mailers insert into URLs."
2714 (let ((inhibit-read-only t
))
2715 (goto-char (point-min))
2716 (while (re-search-forward
2717 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2718 (replace-match "\\1\\3" t
)))
2719 (when (gmm-called-interactively-p 'any
)
2720 (gnus-treat-article nil
))))
2722 (defun article-wash-html ()
2723 "Format an HTML article."
2726 (buffer-read-only nil
))
2727 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2728 (with-current-buffer gnus-original-article-buffer
2729 (setq handles
(mm-dissect-buffer t t
))))
2731 (delete-region (point) (point-max))
2732 (mm-enable-multibyte)
2733 (mm-inline-text-html handles
)))
2735 (defvar gnus-article-browse-html-temp-list nil
2736 "List of temporary files created by `gnus-article-browse-html-parts'.
2737 Internal variable.")
2739 (defcustom gnus-article-browse-delete-temp
'ask
2740 "What to do with temporary files from `gnus-article-browse-html-parts'.
2741 If nil, don't delete temporary files. If it is t, delete them on
2742 exit from the summary buffer. If it is the symbol `file', query
2743 on each file, if it is `ask' ask once when exiting from the
2745 :group
'gnus-article
2746 :version
"23.1" ;; No Gnus
2747 :type
'(choice (const :tag
"Don't delete" nil
)
2748 (const :tag
"Don't ask" t
)
2749 (const :tag
"Ask" ask
)
2750 (const :tag
"Ask for each file" file
)))
2752 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2754 (defun gnus-article-browse-delete-temp-files (&optional how
)
2755 "Delete temp-files created by `gnus-article-browse-html-parts'."
2756 (when (and gnus-article-browse-html-temp-list
2758 (or how
(setq how gnus-article-browse-delete-temp
))
2760 (let ((files (length gnus-article-browse-html-temp-list
)))
2763 "Delete the temporary HTML file? "
2764 (format "Delete all %s temporary HTML files? "
2766 (setq gnus-article-browse-html-temp-list nil
)))
2768 (dolist (file gnus-article-browse-html-temp-list
)
2769 (cond ((file-directory-p file
)
2770 (when (or (not (eq how
'file
))
2773 "Delete temporary HTML file(s) in directory `%s'? "
2774 (file-name-as-directory file
))))
2775 (gnus-delete-directory file
)))
2776 ((file-exists-p file
)
2777 (when (or (not (eq how
'file
))
2779 (format "Delete temporary HTML file `%s'? " file
)))
2780 (delete-file file
)))))
2781 ;; Also remove file from the list when not deleted or if file doesn't
2783 (setq gnus-article-browse-html-temp-list nil
))
2784 gnus-article-browse-html-temp-list
)
2786 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2787 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2792 (dolist (handle handles
)
2794 ((not (listp handle
)))
2795 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2797 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2798 ((equal (mm-handle-media-supertype handle
) "multipart")
2799 (when (setq file
(gnus-article-browse-html-save-cid-content
2800 cid handle directory
))
2801 (throw 'found file
)))
2802 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2805 (or (mm-handle-filename handle
)
2807 (make-temp-name "cid")
2808 (car (rassoc (car (mm-handle-type handle
))
2809 mailcap-mime-extensions
))))
2811 (mm-save-part-to-file handle file
)
2812 (throw 'found file
))))))))
2814 (defun gnus-article-browse-html-parts (list &optional header
)
2815 "View all \"text/html\" parts from LIST.
2816 Recurse into multiparts. The optional HEADER that should be a decoded
2817 message header will be added to the bodies of the \"text/html\" parts."
2818 ;; Internal function used by `gnus-article-browse-html-article'.
2819 (let (type file charset content cid-dir tmp-file showed
)
2820 ;; Find and show the html-parts.
2821 (dolist (handle list
)
2822 ;; If HTML, show it:
2823 (cond ((not (listp handle
)))
2824 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2825 (and (equal (car type
) "message/external-body")
2827 (setq file
(mm-handle-filename handle
)))
2828 (or (mm-handle-cache handle
)
2829 (condition-case code
2830 (progn (mm-extern-cache-contents handle
) t
)
2832 (gnus-message 3 "%s" (error-message-string code
))
2833 (when (>= gnus-verbose
3) (sit-for 2))
2836 (setq handle
(mm-handle-cache handle
)
2837 type
(mm-handle-type handle
))
2838 (equal (car type
) "text/html"))))
2839 (setq charset
(mail-content-type-get type
'charset
)
2840 content
(mm-get-part handle
))
2842 (if (eq charset
'gnus-decoded
)
2843 (mm-enable-multibyte)
2844 (mm-disable-multibyte))
2846 ;; resolve cid contents
2847 (let ((case-fold-search t
)
2849 (goto-char (point-min))
2850 (while (re-search-forward "\
2851 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2854 (setq cid-dir
(mm-make-temp-file "cid" t
))
2855 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2858 (when (setq cid-file
2859 (gnus-article-browse-html-save-cid-content
2861 (with-current-buffer gnus-article-buffer
2862 gnus-article-mime-handles
)
2864 (when (eq system-type
'cygwin
)
2866 (concat "/" (substring
2867 (with-output-to-string
2868 (call-process "cygpath" nil
2872 (replace-match (concat "file://" cid-file
)
2874 (unless content
(setq content
(buffer-string))))
2875 (when (or charset header
(not file
))
2876 (setq tmp-file
(mm-make-temp-file
2877 ;; Do we need to care for 8.3 filenames?
2878 "mm-" nil
".html")))
2879 ;; Add a meta html tag to specify charset and a header.
2882 (let (title eheader body hcharset coding
)
2884 (mm-enable-multibyte)
2885 (setq case-fold-search t
)
2886 (insert header
"\n")
2887 (setq title
(message-fetch-field "subject"))
2888 (goto-char (point-min))
2889 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2891 (replace-match (cond ((match-beginning 1) "<")
2892 ((match-beginning 2) ">")
2893 ((match-beginning 3) "&")
2895 (goto-char (point-min))
2896 (while (re-search-forward "^[\t ]+" nil t
)
2899 (delete-region (match-beginning 0)
2902 (goto-char (point-min))
2903 (insert "<div align=\"left\">\n")
2904 (goto-char (point-max))
2905 (insert "</div>\n<hr>\n")
2906 ;; We have to examine charset one by one since
2907 ;; charset specified in parts might be different.
2908 (if (eq charset
'gnus-decoded
)
2909 (setq charset
'utf-8
2910 eheader
(mm-encode-coding-string (buffer-string)
2913 (mm-encode-coding-string title charset
))
2914 body
(mm-encode-coding-string content charset
))
2915 (setq hcharset
(mm-find-mime-charset-region (point-min)
2917 (cond ((= (length hcharset
) 1)
2918 (setq hcharset
(car hcharset
)
2919 coding
(mm-charset-to-coding-system
2921 ((> (length hcharset
) 1)
2922 (setq hcharset
'utf-8
2928 (mm-charset-to-coding-system charset
2930 (if (eq coding body
)
2931 (setq eheader
(mm-encode-coding-string
2932 (buffer-string) coding
)
2934 (mm-encode-coding-string
2937 (setq charset
'utf-8
2938 eheader
(mm-encode-coding-string
2939 (buffer-string) charset
)
2941 (mm-encode-coding-string
2943 body
(mm-encode-coding-string
2944 (mm-decode-coding-string
2947 (setq charset hcharset
2948 eheader
(mm-encode-coding-string
2949 (buffer-string) coding
)
2951 (mm-encode-coding-string
2954 (setq eheader
(mm-string-as-unibyte (buffer-string))
2957 (mm-disable-multibyte)
2960 (mm-add-meta-html-tag handle charset t
))
2962 (goto-char (point-min))
2963 (unless (search-forward "<title>" nil t
)
2964 (re-search-forward "<head>\\s-*" nil t
)
2965 (insert "<title>" title
"</title>\n")))
2966 (goto-char (point-min))
2967 (or (re-search-forward
2968 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2970 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2972 (mm-write-region (point-min) (point-max)
2973 tmp-file nil nil nil
'binary t
))))
2975 (mm-with-unibyte-buffer
2976 (insert (if (eq charset
'gnus-decoded
)
2977 (mm-encode-coding-string content
2978 (setq charset
'utf-8
))
2980 (if (or (mm-add-meta-html-tag handle charset
)
2982 (mm-write-region (point-min) (point-max)
2983 tmp-file nil nil nil
'binary t
)
2984 (setq tmp-file nil
))))
2986 (mm-save-part-to-file handle tmp-file
)))
2988 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2989 (add-hook 'gnus-summary-prepare-exit-hook
2990 'gnus-article-browse-delete-temp-files
)
2991 (add-hook 'gnus-exit-gnus-hook
2993 (gnus-article-browse-delete-temp-files t
)))
2994 ;; FIXME: Warn if there's an <img> tag?
2995 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2997 ;; If multipart, recurse
2998 ((equal (mm-handle-media-supertype handle
) "multipart")
2999 (when (gnus-article-browse-html-parts handle header
)
3001 ((equal (mm-handle-media-type handle
) "message/rfc822")
3002 (mm-with-multibyte-buffer
3003 (mm-insert-part handle
)
3004 (setq handle
(mm-dissect-buffer t t
))
3005 (when (and (bufferp (car handle
))
3006 (stringp (car (mm-handle-type handle
))))
3007 (setq handle
(list handle
)))
3009 (article-decode-encoded-words)
3010 (let ((gnus-visible-headers
3011 (or (get 'gnus-visible-headers
'standard-value
)
3012 gnus-visible-headers
)))
3013 (article-hide-headers))
3014 (goto-char (point-min))
3015 (search-forward "\n\n" nil
'move
)
3016 (skip-chars-backward "\t\n ")
3017 (setq header
(buffer-substring (point-min) (point)))))
3019 (gnus-article-browse-html-parts handle header
)
3020 (mm-destroy-parts handle
))
3024 (defun gnus-article-browse-html-article (&optional arg
)
3025 "View \"text/html\" parts of the current article with a WWW browser.
3026 Inline images embedded in a message using the cid scheme, as they are
3027 generally considered to be safe, will be processed properly.
3028 The message header is added to the beginning of every html part unless
3029 the prefix argument ARG is given.
3031 Warning: Spammers use links to images (using the http scheme) in HTML
3032 articles to verify whether you have read the message. As
3033 `gnus-article-browse-html-article' passes the HTML content to the
3034 browser without eliminating these \"web bugs\" you should only
3035 use it for mails from trusted senders.
3037 If you always want to display HTML parts in the browser, set
3038 `mm-text-html-renderer' to nil.
3040 This command creates temporary files to pass HTML contents including
3041 images if any to the browser, and deletes them when exiting the group
3043 ;; Cf. `mm-w3m-safe-url-regexp'
3046 (gnus-summary-show-article)
3047 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3048 gnus-visible-headers
))
3049 ;; As we insert a <hr>, there's no need for the body boundary.
3050 (gnus-treat-body-boundary nil
))
3051 (gnus-summary-show-article)))
3052 (with-current-buffer gnus-article-buffer
3053 (let ((header (unless arg
3056 (buffer-substring-no-properties
3057 (goto-char (point-min))
3058 (if (search-forward "\n\n" nil t
)
3060 (goto-char (point-max))
3061 (skip-chars-backward "\t\n ")
3064 (set-buffer gnus-original-article-buffer
)
3065 (setq parts
(mm-dissect-buffer t t
))
3066 ;; If singlepart, enforce a list.
3067 (when (and (bufferp (car parts
))
3068 (stringp (car (mm-handle-type parts
))))
3069 (setq parts
(list parts
)))
3071 (unless (gnus-article-browse-html-parts parts header
)
3072 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3073 (mm-destroy-parts parts
)
3075 (gnus-summary-show-article)))))
3077 (defun article-hide-list-identifiers ()
3078 "Remove list identifies from the Subject header.
3079 The `gnus-list-identifiers' variable specifies what to do."
3081 (let ((inhibit-point-motion-hooks t
)
3082 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3083 (inhibit-read-only t
))
3087 (article-narrow-to-head)
3088 (goto-char (point-min))
3089 (while (re-search-forward
3090 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3092 (delete-region (match-beginning 2) (match-end 0))
3093 (beginning-of-line))
3094 (when (re-search-forward
3095 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3096 (delete-region (match-beginning 1) (match-end 1))))))))
3098 (defun article-hide-pem (&optional arg
)
3099 "Toggle hiding of any PEM headers and signatures in the current article.
3100 If given a negative prefix, always show; if given a positive prefix,
3102 (interactive (gnus-article-hidden-arg))
3103 (unless (gnus-article-check-hidden-text 'pem arg
)
3105 (let ((inhibit-read-only t
) end
)
3106 (goto-char (point-min))
3107 ;; Hide the horrendously ugly "header".
3108 (when (and (search-forward
3109 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3111 (setq end
(1+ (match-beginning 0))))
3112 (gnus-add-wash-type 'pem
)
3113 (gnus-article-hide-text-type
3115 (if (search-forward "\n\n" nil t
)
3119 ;; Hide the trailer as well
3120 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3122 (gnus-article-hide-text-type
3123 (match-beginning 0) (match-end 0) 'pem
)))))))
3125 (defun article-strip-banner ()
3126 "Strip the banners specified by the `banner' group parameter and by
3127 `gnus-article-address-banner-alist'."
3131 (let ((inhibit-point-motion-hooks t
))
3132 (when (gnus-parameter-banner gnus-newsgroup-name
)
3133 (article-really-strip-banner
3134 (gnus-parameter-banner gnus-newsgroup-name
)))
3135 (when gnus-article-address-banner-alist
3136 ;; Note that the From header is decoded here, so it is
3137 ;; required that the *-extract-address-components function
3138 ;; supports non-ASCII text.
3139 (let ((from (save-restriction
3141 (article-narrow-to-head)
3142 (mail-fetch-field "from"))))
3145 (cadr (funcall gnus-extract-address-components
3148 (dolist (pair gnus-article-address-banner-alist
)
3149 (when (string-match (car pair
) from
)
3151 (article-really-strip-banner (cdr pair
)))))))))))))
3153 (defun article-really-strip-banner (banner)
3154 "Strip the banner specified by the argument."
3157 (let ((inhibit-point-motion-hooks t
)
3158 (gnus-signature-limit nil
)
3159 (inhibit-read-only t
))
3162 ((eq banner
'signature
)
3163 (when (gnus-article-narrow-to-signature)
3166 (delete-region (point) (point-max))))
3168 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3169 (while (re-search-forward banner nil t
)
3170 (delete-region (match-beginning 0) (match-end 0)))))
3172 (while (re-search-forward banner nil t
)
3173 (delete-region (match-beginning 0) (match-end 0)))))))))
3175 (defun article-babel ()
3176 "Translate article using an online translation service."
3179 (gnus-with-article-buffer
3180 (when (article-goto-body)
3181 (let* ((start (point))
3183 (orig (buffer-substring start end
))
3184 (trans (babel-as-string orig
)))
3186 (narrow-to-region start end
)
3187 (delete-region start end
)
3190 (defun article-hide-signature (&optional arg
)
3191 "Hide the signature in the current article.
3192 If given a negative prefix, always show; if given a positive prefix,
3194 (interactive (gnus-article-hidden-arg))
3195 (unless (gnus-article-check-hidden-text 'signature arg
)
3198 (let ((inhibit-read-only t
))
3199 (when (gnus-article-narrow-to-signature)
3200 (gnus-article-hide-text-type
3201 (point-min) (point-max) 'signature
))))))
3202 (gnus-set-mode-line 'article
))
3204 (defun article-strip-headers-in-body ()
3205 "Strip offensive headers from bodies."
3209 (let ((case-fold-search t
))
3210 (when (looking-at "x-no-archive:")
3211 (gnus-delete-line)))))
3213 (defun article-strip-leading-blank-lines ()
3214 "Remove all blank lines from the beginning of the article."
3217 (let ((inhibit-point-motion-hooks t
)
3218 (inhibit-read-only t
))
3219 (when (article-goto-body)
3220 (while (and (not (eobp))
3221 (looking-at "[ \t]*$"))
3222 (gnus-delete-line))))))
3224 (defun article-narrow-to-head ()
3225 "Narrow the buffer to the head of the message.
3226 Point is left at the beginning of the narrowed-to region."
3228 (goto-char (point-min))
3230 ;; Absolutely no headers displayed.
3234 ((search-forward "\n\n" nil
1)
3236 ;; Nothing but headers.
3239 (goto-char (point-min)))
3241 (defun article-goto-body ()
3242 "Place point at the start of the body."
3243 (goto-char (point-min))
3245 ;; This variable is only bound when dealing with separate
3247 (article-goto-body-goes-to-point-min-p
3249 ((search-forward "\n\n" nil t
)
3252 (goto-char (point-max))
3255 (defun article-strip-multiple-blank-lines ()
3256 "Replace consecutive blank lines with one empty line."
3259 (let ((inhibit-point-motion-hooks t
)
3260 (inhibit-read-only t
))
3261 ;; First make all blank lines empty.
3263 (while (re-search-forward "^[ \t]+$" nil t
)
3264 (unless (gnus-annotation-in-region-p
3265 (match-beginning 0) (match-end 0))
3266 (replace-match "" nil t
)))
3267 ;; Then replace multiple empty lines with a single empty line.
3269 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3270 (unless (gnus-annotation-in-region-p
3271 (match-beginning 0) (match-end 0))
3272 (delete-region (match-beginning 1) (match-end 1)))))))
3274 (defun article-strip-leading-space ()
3275 "Remove all white space from the beginning of the lines in the article."
3278 (let ((inhibit-point-motion-hooks t
)
3279 (inhibit-read-only t
))
3281 (while (re-search-forward "^[ \t]+" nil t
)
3282 (replace-match "" t t
)))))
3284 (defun article-strip-trailing-space ()
3285 "Remove all white space from the end of the lines in the article."
3288 (let ((inhibit-point-motion-hooks t
)
3289 (inhibit-read-only t
))
3291 (while (re-search-forward "[ \t]+$" nil t
)
3292 (replace-match "" t t
)))))
3294 (defun article-strip-blank-lines ()
3295 "Strip leading, trailing and multiple blank lines."
3297 (article-strip-leading-blank-lines)
3298 (article-remove-trailing-blank-lines)
3299 (article-strip-multiple-blank-lines))
3301 (defun article-strip-all-blank-lines ()
3302 "Strip all blank lines."
3305 (let ((inhibit-point-motion-hooks t
)
3306 (inhibit-read-only t
))
3308 (while (re-search-forward "^[ \t]*\n" nil t
)
3309 (replace-match "" t t
)))))
3311 (defun gnus-article-narrow-to-signature ()
3312 "Narrow to the signature; return t if a signature is found, else nil."
3313 (let ((inhibit-point-motion-hooks t
))
3314 (when (gnus-article-search-signature)
3316 ;; Check whether we have some limits to what we consider
3317 ;; to be a signature.
3318 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3319 (list gnus-signature-limit
)))
3321 (while (setq limit
(pop limits
))
3322 (if (or (and (integerp limit
)
3323 (< (- (point-max) (point)) limit
))
3325 (< (count-lines (point) (point-max)) limit
))
3326 (and (functionp limit
)
3328 (and (stringp limit
)
3329 (not (re-search-forward limit nil t
))))
3330 () ; This limit did not succeed.
3334 (narrow-to-region (point) (point-max))
3337 (defun gnus-article-search-signature ()
3338 "Search the current buffer for the signature separator.
3339 Put point at the beginning of the signature separator."
3340 (let ((cur (point)))
3341 (goto-char (point-max))
3342 (if (if (stringp gnus-signature-separator
)
3343 (re-search-backward gnus-signature-separator nil t
)
3344 (let ((seps gnus-signature-separator
))
3346 (not (re-search-backward (car seps
) nil t
)))
3353 (defun gnus-article-hidden-arg ()
3354 "Return the current prefix arg as a number, or 0 if no prefix."
3355 (list (if current-prefix-arg
3356 (prefix-numeric-value current-prefix-arg
)
3359 (defun gnus-article-check-hidden-text (type arg
)
3360 "Return nil if hiding is necessary.
3361 Arg can be nil or a number. nil and positive means hide, negative
3362 means show, 0 means toggle."
3365 (let ((hide (gnus-article-hidden-text-p type
)))
3371 (gnus-article-show-hidden-text type
)
3374 (if (eq hide
'hidden
)
3376 (gnus-article-show-hidden-text type
)
3380 (defun gnus-article-hidden-text-p (type)
3381 "Say whether the current buffer contains hidden text of type TYPE."
3382 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3384 (not (get-text-property pos
'invisible
))
3385 (not (get-text-property pos
'dummy-invisible
)))
3387 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3392 (defun gnus-article-show-hidden-text (type &optional dummy
)
3393 "Show all hidden text of type TYPE.
3394 Originally it is hide instead of DUMMY."
3395 (let ((inhibit-read-only t
)
3396 (inhibit-point-motion-hooks t
))
3397 (gnus-remove-text-properties-when
3399 (point-min) (point-max)
3400 (cons 'article-type
(cons type
3401 gnus-hidden-properties
)))
3402 (gnus-delete-wash-type type
)))
3404 (defconst article-time-units
3405 `((year .
,(* 365.25 24 60 60))
3406 (week .
,(* 7 24 60 60))
3407 (day .
,(* 24 60 60))
3411 "Mapping from time units to seconds.")
3413 (defun gnus-article-forward-header ()
3414 "Move point to the start of the next header.
3415 If the current header is a continuation header, this can be several
3420 (if (looking-at "[ \t]+[^ \t]")
3424 (defun article-treat-date ()
3425 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3426 (with-current-buffer gnus-summary-buffer
3427 gnus-article-date-headers
)
3428 gnus-article-date-headers
)
3431 (defun article-date-ut (&optional type highlight date-position
)
3432 "Convert DATE date to TYPE in the current article.
3433 The default type is `ut'. See `gnus-article-date-headers' for
3435 (interactive (list 'ut t
))
3436 (let* ((case-fold-search t
)
3437 (inhibit-read-only t
)
3438 (inhibit-point-motion-hooks t
)
3440 (visible-date (mail-fetch-field "Date"))
3441 pos date bface eface
)
3445 (goto-char date-position
)
3446 (setq date
(get-text-property (point) 'original-date
))
3447 (when (looking-at "[^:]+:[\t ]*")
3448 (setq bface
(get-text-property (match-beginning 0) 'face
)
3449 eface
(get-text-property (match-end 0) 'face
)))
3450 (delete-region (point)
3452 (gnus-article-forward-header)
3454 (article-transform-date date type bface eface
))
3457 (goto-char (point-min))
3458 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3459 (and (setq pos
(next-single-property-change
3460 (point) 'original-date
))
3462 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3463 (1+ (match-beginning 0))
3465 (while (setq pos
(text-property-not-all pos
(point-max)
3466 'gnus-date-type nil
))
3467 (setq date
(get-text-property pos
'original-date
))
3469 (when (looking-at "[^:]+:[\t ]*")
3470 (setq bface
(get-text-property (match-beginning 0) 'face
)
3471 eface
(get-text-property (match-end 0) 'face
)))
3472 (delete-region pos
(or (text-property-any pos
(point-max)
3473 'gnus-date-type nil
)
3475 (unless date
;; the 1st time
3476 (goto-char (point-min))
3477 (while (re-search-forward "^Date:[\t ]*" nil t
)
3478 (setq date
(get-text-property (match-beginning 0)
3480 bface
(get-text-property (match-beginning 0) 'face
)
3481 eface
(get-text-property (match-end 0) 'face
))
3482 (delete-region (point-at-bol) (progn
3483 (gnus-article-forward-header)
3485 (when (and (not date
)
3487 (setq date visible-date
))
3489 (article-transform-date date type bface eface
))
3490 (goto-char (point-max))
3493 (defun article-transform-date (date type bface eface
)
3494 (dolist (this-type (cond
3504 (add-text-properties
3507 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3509 (list 'original-date date
'gnus-date-type this-type
))))
3512 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3513 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3514 (when (match-beginning 2)
3515 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3516 (while (and (zerop (forward-line 1))
3517 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3518 (when (match-beginning 1)
3519 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3521 (defun article-make-date-line (date type
)
3522 "Return a DATE line of TYPE."
3523 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3525 (error "Unknown conversion type: %s" type
))
3527 (let ((time (ignore-errors (date-to-time date
))))
3529 ;; Convert to the local timezone.
3531 (concat "Date: " (message-make-date time
)))
3532 ;; Convert to Universal Time.
3537 (let* ((e (parse-time-string date
))
3538 (tm (apply 'encode-time e
))
3540 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3541 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3542 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3546 ;; Get the original date from the article.
3547 ((eq type
'original
)
3548 (concat "Date: " (if (string-match "\n+$" date
)
3549 (substring date
0 (match-beginning 0))
3551 ;; Let the user define the format.
3552 ((eq type
'user-defined
)
3553 (let ((format (or (condition-case nil
3554 (with-current-buffer gnus-summary-buffer
3555 gnus-article-time-format
)
3557 gnus-article-time-format
)))
3558 (if (functionp format
)
3559 (funcall format time
)
3560 (concat "Date: " (format-time-string format time
)))))
3563 (let ((tz (car (current-time-zone time
))))
3566 (format-time-string "%Y%m%dT%H%M%S" time
)
3567 (format "%s%02d%02d"
3568 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3569 (/ (%
(abs tz
) 3600) 60)))))
3570 ;; Do a lapsed format.
3572 (concat "Date: " (article-lapsed-string time
)))
3573 ;; A combined date/lapsed format.
3574 ((eq type
'combined-lapsed
)
3575 (let ((date-string (article-make-date-line date
'original
))
3581 (concat " (" (article-lapsed-string time segments
) ")"))
3582 (> (+ (length date-string
)
3583 (length lapsed-string
))
3586 (setq segments
(1- segments
)))
3588 (concat date-string lapsed-string
)
3590 ;; Display the date in proper English
3592 (let ((dtime (decode-time time
)))
3595 (number-to-string (nth 3 dtime
))
3596 (let ((digit (%
(nth 3 dtime
) 10)))
3598 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3604 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3606 (number-to-string (nth 5 dtime
))
3608 (format "%02d" (nth 2 dtime
))
3610 (format "%02d" (nth 1 dtime
)))))))
3612 (format "Date: %s (from Gnus)" date
))))
3614 (defun article-lapsed-string (time &optional max-segments
)
3615 ;; If the date is seriously mangled, the timezone functions are
3616 ;; liable to bug out, so we ignore all errors.
3617 (let* ((now (current-time))
3618 (real-time (subtract-time now time
))
3619 (real-sec (and real-time
3620 (+ (* (float (car real-time
)) 65536)
3622 (sec (and real-time
(abs real-sec
)))
3625 (unless max-segments
3626 (setq max-segments
(length article-time-units
)))
3634 ;; This is a bit convoluted, but basically we go
3635 ;; through the time units for years, weeks, etc,
3636 ;; and divide things to see whether that results
3637 ;; in positive answers.
3640 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3641 (>= segments max-segments
))
3642 ;; The (remaining) seconds are too few to
3643 ;; be divided into this time unit.
3645 ;; It's big enough, so we output it.
3646 (setq sec
(- sec
(* num
(cdr unit
))))
3648 (concat (if prev
", " "") (int-to-string
3650 " " (symbol-name (car unit
))
3651 (if (> num
1) "s" ""))
3653 segments
(1+ segments
)))))
3654 article-time-units
"")
3655 ;; If dates are odd, then it might appear like the
3656 ;; article was sent in the future.
3659 " in the future"))))))
3661 (defun article-date-local (&optional highlight
)
3662 "Convert the current article date to the local timezone."
3663 (interactive (list t
))
3664 (article-date-ut 'local highlight
))
3666 (defun article-date-english (&optional highlight
)
3667 "Convert the current article date to something that is proper English."
3668 (interactive (list t
))
3669 (article-date-ut 'english highlight
))
3671 (defun article-date-original (&optional highlight
)
3672 "Convert the current article date to what it was originally.
3673 This is only useful if you have used some other date conversion
3674 function and want to see what the date was before converting."
3675 (interactive (list t
))
3676 (article-date-ut 'original highlight
))
3678 (defun article-date-lapsed (&optional highlight
)
3679 "Convert the current article date to time lapsed since it was sent."
3680 (interactive (list t
))
3681 (article-date-ut 'lapsed highlight
))
3683 (defun article-date-combined-lapsed (&optional highlight
)
3684 "Convert the current article date to time lapsed since it was sent."
3685 (interactive (list t
))
3686 (article-date-ut 'combined-lapsed highlight
))
3688 (defun article-update-date-lapsed ()
3689 "Function to be run from a timer to update the lapsed time line."
3691 (let ((buffer (current-buffer)))
3695 (set-buffer (window-buffer w
))
3696 (when (derived-mode-p 'gnus-article-mode
)
3697 (let ((old-line (count-lines (point-min) (point)))
3698 (old-column (- (point) (line-beginning-position)))
3699 (window-start (window-start w
))
3702 (while (setq pos
(text-property-not-all pos
(point-max)
3703 'gnus-date-type nil
))
3704 (setq next
(or (next-single-property-change pos
3707 (setq type
(get-text-property pos
'gnus-date-type
))
3708 (when (memq type
'(lapsed combined-lapsed user-defined
))
3709 (article-date-ut type t pos
)
3710 (setq end
(or (next-single-property-change pos
3714 (if (/= window-start next
)
3715 (setq window-start nil
)
3716 (set-window-start w end
)))
3719 (goto-char (point-min))
3720 (when (> old-column
0)
3721 (setq old-line
(1- old-line
)))
3722 (forward-line old-line
)
3724 (when (> (current-column) old-column
)
3726 (forward-char old-column
)))))
3728 (set-buffer buffer
))))
3730 (defun gnus-start-date-timer (&optional n
)
3731 "Start a timer to update the Date headers in the article buffers.
3732 The numerical prefix says how frequently (in seconds) the function
3737 (gnus-stop-date-timer)
3738 (setq article-lapsed-timer
3739 (run-at-time 1 n
'article-update-date-lapsed
)))
3741 (defun gnus-stop-date-timer ()
3742 "Stop the Date timer."
3744 (when article-lapsed-timer
3745 (nnheader-cancel-timer article-lapsed-timer
)
3746 (setq article-lapsed-timer nil
)))
3748 (defun article-date-user (&optional highlight
)
3749 "Convert the current article date to the user-defined format.
3750 This format is defined by the `gnus-article-time-format' variable."
3751 (interactive (list t
))
3752 (article-date-ut 'user highlight
))
3754 (defun article-date-iso8601 (&optional highlight
)
3755 "Convert the current article date to ISO8601."
3756 (interactive (list t
))
3757 (article-date-ut 'iso8601 highlight
))
3759 (defmacro gnus-article-save-original-date
(&rest forms
)
3760 "Save the original date as a text property and evaluate FORMS."
3761 `(let* ((case-fold-search t
)
3763 (goto-char (point-min))
3764 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3767 (date (when (and start
3768 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3770 (buffer-substring-no-properties start
3771 (match-beginning 0)))))
3772 (goto-char (point-max))
3773 (skip-chars-backward "\n")
3774 (put-text-property (point-min) (point) 'original-date date
)
3776 (goto-char (point-max))
3777 (skip-chars-backward "\n")
3778 (put-text-property (point-min) (point) 'original-date date
)))
3780 ;; (defun article-show-all ()
3781 ;; "Show all hidden text in the article buffer."
3784 ;; (let ((inhibit-read-only t))
3785 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3787 (defun article-remove-leading-whitespace ()
3788 "Remove excessive whitespace from all headers."
3792 (let ((inhibit-read-only t
))
3793 (article-narrow-to-head)
3794 (goto-char (point-min))
3795 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3796 (delete-region (match-beginning 1) (match-end 1)))))))
3798 (defun article-emphasize (&optional arg
)
3799 "Emphasize text according to `gnus-emphasis-alist'."
3800 (interactive (gnus-article-hidden-arg))
3801 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3805 (with-current-buffer gnus-summary-buffer
3806 gnus-article-emphasis-alist
)
3808 gnus-emphasis-alist
))
3809 (inhibit-read-only t
)
3810 (props (append '(article-type emphasis
)
3811 gnus-hidden-properties
))
3812 regexp elem beg invisible visible face
)
3815 (while (setq elem
(pop alist
))
3817 (setq regexp
(car elem
)
3818 invisible
(nth 1 elem
)
3819 visible
(nth 2 elem
)
3821 (while (re-search-forward regexp nil t
)
3822 (when (and (match-beginning visible
) (match-beginning invisible
))
3823 (gnus-article-hide-text
3824 (match-beginning invisible
) (match-end invisible
) props
)
3825 (gnus-article-unhide-text-type
3826 (match-beginning visible
) (match-end visible
) 'emphasis
)
3827 (gnus-put-overlay-excluding-newlines
3828 (match-beginning visible
) (match-end visible
) 'face face
)
3829 (gnus-add-wash-type 'emphasis
)
3830 (goto-char (match-end invisible
)))))))))
3832 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3833 "Setup newsgroup emphasis alist."
3834 (unless gnus-article-emphasis-alist
3835 (let ((name (and gnus-newsgroup-name
3836 (gnus-group-real-name gnus-newsgroup-name
))))
3837 (make-local-variable 'gnus-article-emphasis-alist
)
3838 (setq gnus-article-emphasis-alist
3840 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3841 (while (setq elem
(pop alist
))
3842 (when (and name
(string-match (car elem
) name
))
3844 highlight
(copy-sequence (cdr elem
)))))
3846 (copy-sequence highlight-words
)
3847 (if gnus-newsgroup-name
3848 (copy-sequence (gnus-group-find-parameter
3849 gnus-newsgroup-name
'highlight-words t
)))
3850 gnus-emphasis-alist
)))))
3852 (defvar gnus-summary-article-menu
)
3853 (defvar gnus-summary-post-menu
)
3855 ;;; Saving functions.
3857 (defun gnus-article-save (save-buffer file
&optional num
)
3858 "Save the currently selected article."
3859 (when (or (get gnus-default-article-saver
:headers
)
3860 (not gnus-save-all-headers
))
3861 ;; Remove headers according to `gnus-saved-headers' or the value
3862 ;; of the `:headers' property that the saver function might have.
3863 (let ((gnus-visible-headers
3864 (or (symbol-value (get gnus-default-article-saver
:headers
))
3865 gnus-saved-headers gnus-visible-headers
))
3866 ;; Ignore group parameter. See `article-hide-headers'.
3867 (gnus-summary-buffer nil
))
3868 (with-current-buffer save-buffer
3869 (article-hide-headers 1 t
))))
3870 (save-window-excursion
3871 (if (not gnus-default-article-saver
)
3872 (error "No default saver is defined")
3873 ;; !!! Magic! The saving functions all save
3874 ;; `gnus-save-article-buffer' (or so they think), but we
3875 ;; bind that variable to our save-buffer.
3876 (set-buffer gnus-article-buffer
)
3877 (let* ((gnus-save-article-buffer save-buffer
)
3880 ((not gnus-prompt-before-saving
) 'default
)
3881 ((eq gnus-prompt-before-saving
'always
) nil
)
3883 (gnus-number-of-articles-to-be-saved
3884 (when (eq gnus-prompt-before-saving t
)
3886 (set-buffer gnus-article-current-summary
)
3887 (funcall gnus-default-article-saver filename
)))))
3889 (defun gnus-read-save-file-name (prompt &optional filename
3890 function group headers variable
3893 (funcall function group headers
(symbol-value variable
)))
3898 ((eq filename
'default
)
3904 (when (symbol-value dir-var
)
3905 (setq default-name
(expand-file-name
3906 (file-name-nondirectory default-name
)
3907 (symbol-value dir-var
))))
3908 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3911 (if (and gnus-number-of-articles-to-be-saved
3912 (> gnus-number-of-articles-to-be-saved
1))
3913 (format "these %d articles"
3914 gnus-number-of-articles-to-be-saved
)
3917 ;; Let the split methods have their say.
3919 ;; No split name was found.
3922 (concat prompt
" (default "
3923 (file-name-nondirectory default-name
) "): ")
3924 (file-name-directory default-name
)
3926 ;; A single group name is returned.
3927 ((stringp split-name
)
3929 (funcall function split-name headers
3930 (symbol-value variable
)))
3932 (concat prompt
" (default "
3933 (file-name-nondirectory default-name
) "): ")
3934 (file-name-directory default-name
)
3936 ;; A single split name was found
3937 ((= 1 (length split-name
))
3938 (let* ((name (expand-file-name
3940 gnus-article-save-directory
))
3941 (dir (cond ((file-directory-p name
)
3942 (file-name-as-directory name
))
3943 ((file-exists-p name
) name
)
3944 (t gnus-article-save-directory
))))
3946 (concat prompt
" (default " name
"): ")
3948 ;; A list of splits was found.
3950 (setq split-name
(nreverse split-name
))
3952 (let ((file-name-history
3953 (nconc split-name file-name-history
)))
3957 (concat prompt
" (`M-p' for defaults): ")
3958 gnus-article-save-directory
3960 gnus-article-save-directory
)))
3961 (car (push result file-name-history
)))))))
3962 ;; Create the directory.
3963 (gnus-make-directory (file-name-directory file
))
3964 ;; If we have read a directory, we append the default file name.
3965 (when (file-directory-p file
)
3966 (setq file
(expand-file-name (file-name-nondirectory
3968 (file-name-as-directory file
))))
3969 ;; Possibly translate some characters.
3970 (nnheader-translate-file-chars file
))))))
3971 (gnus-make-directory (file-name-directory result
))
3973 (set variable result
))
3975 (set dir-var
(file-name-directory result
)))
3978 (defun gnus-article-archive-name (group)
3979 "Return the first instance of an \"Archive-name\" in the current buffer."
3980 (let ((case-fold-search t
))
3981 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3982 (nnheader-concat gnus-article-save-directory
3983 (match-string 1)))))
3985 (defun gnus-article-nndoc-name (group)
3986 "If GROUP is an nndoc group, return the name of the parent group."
3987 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3988 (gnus-group-get-parameter group
'save-article-group
)))
3990 (defun gnus-summary-save-in-rmail (&optional filename
)
3991 "Append this article to Rmail file.
3992 Optional argument FILENAME specifies file name.
3993 Directory to save to is default to `gnus-article-save-directory'."
3994 (setq filename
(gnus-read-save-file-name
3995 "Save %s in rmail file" filename
3996 gnus-rmail-save-name gnus-newsgroup-name
3997 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3998 (with-current-buffer gnus-save-article-buffer
4002 ;; Note that unlike gnus-summary-save-in-mail, there is no
4003 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4005 (gnus-output-to-rmail filename
))))
4008 (defun gnus-summary-save-in-mail (&optional filename
)
4009 "Append this article to Unix mail file.
4010 Optional argument FILENAME specifies file name.
4011 Directory to save to is default to `gnus-article-save-directory'."
4012 (setq filename
(gnus-read-save-file-name
4013 "Save %s in Unix mail file" filename
4014 gnus-mail-save-name gnus-newsgroup-name
4015 gnus-current-headers
'gnus-newsgroup-last-mail
))
4016 (with-current-buffer gnus-save-article-buffer
4020 (if (and (file-readable-p filename
)
4021 (file-regular-p filename
)
4022 (mail-file-babyl-p filename
))
4023 (gnus-output-to-rmail filename
)
4024 (gnus-output-to-mail filename
)))))
4027 (put 'gnus-summary-save-in-file
:decode t
)
4028 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4029 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4030 "Append this article to file.
4031 Optional argument FILENAME specifies file name.
4032 Directory to save to is default to `gnus-article-save-directory'."
4033 (setq filename
(gnus-read-save-file-name
4034 "Save %s in file" filename
4035 gnus-file-save-name gnus-newsgroup-name
4036 gnus-current-headers
'gnus-newsgroup-last-file
))
4037 (with-current-buffer gnus-save-article-buffer
4041 (when (and overwrite
4042 (file-exists-p filename
))
4043 (delete-file filename
))
4044 (gnus-output-to-file filename
))))
4047 (put 'gnus-summary-write-to-file
:decode t
)
4048 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4049 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4050 (defun gnus-summary-write-to-file (&optional filename
)
4051 "Write this article to a file, overwriting it if the file exists.
4052 Optional argument FILENAME specifies file name.
4053 The directory to save in defaults to `gnus-article-save-directory'."
4054 (setq filename
(gnus-read-save-file-name
4055 "Save %s in file" filename
4056 gnus-file-save-name gnus-newsgroup-name
4057 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4058 (gnus-summary-save-in-file filename t
))
4060 (put 'gnus-summary-save-body-in-file
:decode t
)
4061 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4062 "Append this article body to a file.
4063 Optional argument FILENAME specifies file name.
4064 The directory to save in defaults to `gnus-article-save-directory'."
4065 (setq filename
(gnus-read-save-file-name
4066 "Save %s body in file" filename
4067 gnus-file-save-name gnus-newsgroup-name
4068 gnus-current-headers
'gnus-newsgroup-last-file
))
4069 (with-current-buffer gnus-save-article-buffer
4073 (when (article-goto-body)
4074 (narrow-to-region (point) (point-max)))
4075 (when (and overwrite
4076 (file-exists-p filename
))
4077 (delete-file filename
))
4078 (gnus-output-to-file filename
))))
4081 (put 'gnus-summary-write-body-to-file
:decode t
)
4082 (put 'gnus-summary-write-body-to-file
4083 :function
'gnus-summary-save-body-in-file
)
4084 (defun gnus-summary-write-body-to-file (&optional filename
)
4085 "Write this article body to a file, overwriting it if the file exists.
4086 Optional argument FILENAME specifies file name.
4087 The directory to save in defaults to `gnus-article-save-directory'."
4088 (setq filename
(gnus-read-save-file-name
4089 "Save %s body in file" filename
4090 gnus-file-save-name gnus-newsgroup-name
4091 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4092 (gnus-summary-save-body-in-file filename t
))
4094 (put 'gnus-summary-save-in-pipe
:decode t
)
4095 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4096 (defun gnus-summary-save-in-pipe (&optional command raw
)
4097 "Pipe this article to subprocess COMMAND.
4098 Valid values for COMMAND include:
4100 The executable command name and possibly arguments.
4102 You will be prompted for the command in the minibuffer.
4103 the symbol `default'
4104 It will be replaced with the command which the variable
4105 `gnus-summary-pipe-output-default-command' holds or the command
4106 last used for saving.
4107 Non-nil value for RAW overrides `:decode' and `:headers' properties
4108 and the raw article including all headers will be piped."
4109 (let ((article (gnus-summary-article-number))
4111 (get 'gnus-summary-save-in-pipe
:decode
)))
4112 save-buffer default
)
4114 (if (vectorp (gnus-summary-article-header article
))
4115 (save-current-buffer
4116 (gnus-summary-select-article decode decode nil article
)
4117 (insert-buffer-substring
4121 gnus-original-article-buffer
)
4123 (nnheader-set-temp-buffer " *Gnus Save*"))))
4124 ;; Remove unwanted headers.
4125 (when (and (not raw
)
4126 (or (get 'gnus-summary-save-in-pipe
:headers
)
4127 (not gnus-save-all-headers
)))
4128 (let ((gnus-visible-headers
4129 (or (symbol-value (get 'gnus-summary-save-in-pipe
4131 gnus-saved-headers gnus-visible-headers
))
4132 (gnus-summary-buffer nil
))
4133 (article-hide-headers 1 t
))))
4134 (error "%d is not a real article" article
))
4135 (error "No article to pipe"))
4136 (setq default
(or gnus-summary-pipe-output-default-command
4137 gnus-last-shell-command
))
4138 (unless (stringp command
)
4140 (if (and (eq command
'default
) default
)
4142 (gnus-read-shell-command "Shell command on this article: "
4144 (when (string-equal command
"")
4146 (setq command default
)
4147 (error "A command is required")))
4148 (with-current-buffer save-buffer
4151 (shell-command-on-region (point-min) (point-max) command nil
)))
4152 (gnus-kill-buffer save-buffer
))
4153 (setq gnus-summary-pipe-output-default-command command
))
4155 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4156 "Pipe this article to muttprint."
4157 (unless (stringp command
)
4158 (setq command
(read-string
4159 "Print using command: " gnus-summary-muttprint-program
4160 nil gnus-summary-muttprint-program
)))
4161 (let ((gnus-summary-pipe-output-default-command
4162 gnus-summary-pipe-output-default-command
))
4163 (gnus-summary-save-in-pipe command
))
4164 (setq gnus-summary-muttprint-program command
))
4166 ;;; Article file names when saving.
4168 (defun gnus-capitalize-newsgroup (newsgroup)
4169 "Capitalize NEWSGROUP name."
4170 (when (not (zerop (length newsgroup
)))
4171 (concat (char-to-string (upcase (aref newsgroup
0)))
4172 (substring newsgroup
1))))
4174 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4175 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4176 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4177 Otherwise, it is like ~/News/news/group/num."
4180 (concat (if (gnus-use-long-file-name 'not-save
)
4181 (gnus-capitalize-newsgroup newsgroup
)
4182 (gnus-newsgroup-directory-form newsgroup
))
4183 "/" (int-to-string (mail-header-number headers
)))
4184 gnus-article-save-directory
)))
4186 (string-equal (file-name-directory default
)
4187 (file-name-directory last-file
))
4188 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4190 (or last-file default
))))
4192 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4193 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4194 If variable `gnus-use-long-file-name' is non-nil, it is
4195 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4198 (concat (if (gnus-use-long-file-name 'not-save
)
4200 (gnus-newsgroup-directory-form newsgroup
))
4201 "/" (int-to-string (mail-header-number headers
)))
4202 gnus-article-save-directory
)))
4204 (string-equal (file-name-directory default
)
4205 (file-name-directory last-file
))
4206 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4208 (or last-file default
))))
4210 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4211 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4212 If variable `gnus-use-long-file-name' is non-nil, it is
4213 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4216 (if (gnus-use-long-file-name 'not-save
)
4219 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4221 gnus-article-save-directory
)))
4223 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4224 "Generate file name from sender."
4225 (let ((from (mail-header-from headers
)))
4227 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4228 (match-string 1 from
)
4230 gnus-article-save-directory
)))
4232 (defun article-verify-x-pgp-sig ()
4234 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4236 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4237 (let ((sig (with-current-buffer gnus-original-article-buffer
4238 (gnus-fetch-field "X-PGP-Sig")))
4242 (mml2015-clear-verify-function))
4244 (insert-buffer-substring gnus-original-article-buffer
)
4245 (setq items
(split-string sig
))
4246 (message-narrow-to-head)
4247 (let ((inhibit-point-motion-hooks t
)
4248 (case-fold-search t
))
4249 ;; Don't verify multiple headers.
4250 (setq headers
(mapconcat (lambda (header)
4252 (mail-fetch-field header
)
4254 (split-string (nth 1 items
) ",") "")))
4255 (delete-region (point-min) (point-max))
4256 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4257 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4262 (if (looking-at "^-")
4265 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4266 (insert "Version: " (car items
) "\n\n")
4267 (insert (mapconcat 'identity
(cddr items
) "\n"))
4268 (insert "\n-----END PGP SIGNATURE-----\n")
4269 (let ((mm-security-handle (list (format "multipart/signed"))))
4270 (mml2015-clean-buffer)
4271 (let ((coding-system-for-write (or gnus-newsgroup-charset
4273 (funcall (mml2015-clear-verify-function)))
4275 (or (mm-handle-multipart-ctl-parameter
4276 mm-security-handle
'gnus-details
)
4277 (mm-handle-multipart-ctl-parameter
4278 mm-security-handle
'gnus-info
)))))
4280 (let ((inhibit-read-only t
) bface eface
)
4282 (message-narrow-to-head)
4283 (goto-char (point-max))
4285 (setq bface
(get-text-property (point-at-bol) 'face
)
4286 eface
(get-text-property (1- (point-at-eol)) 'face
))
4287 (message-remove-header "X-Gnus-PGP-Verify")
4288 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4290 (goto-char (point-max)))
4291 (narrow-to-region (point) (point))
4292 (insert "X-Gnus-PGP-Verify: " info
"\n")
4293 (goto-char (point-min))
4296 (if (not (looking-at "^[ \t]"))
4300 (goto-char (point-min))
4301 (when (looking-at "\\([^:]+\\): *")
4302 (put-text-property (match-beginning 1) (1+ (match-end 1))
4304 (put-text-property (match-end 0) (point-max)
4305 'face eface
)))))))))
4307 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4309 (defun article-verify-cancel-lock ()
4310 "Verify Cancel-Lock header."
4312 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4313 (canlock-verify gnus-original-article-buffer
)))
4320 (setq afunc
(car func
)
4323 gfunc
(intern (format "gnus-%s" func
))))
4325 (when (fboundp afunc
)
4326 `(lambda (&optional interactive
&rest args
)
4327 ,(documentation afunc t
)
4328 (interactive (list t
))
4329 (with-current-buffer gnus-article-buffer
4331 (call-interactively ',afunc
)
4332 (apply ',afunc args
))))))))
4333 '(article-hide-headers
4334 article-verify-x-pgp-sig
4335 article-verify-cancel-lock
4336 article-hide-boring-headers
4337 article-treat-overstrike
4338 article-treat-ansi-sequences
4339 article-fill-long-lines
4340 article-capitalize-sentences
4342 article-remove-leading-whitespace
4343 article-display-x-face
4344 article-display-face
4345 article-de-quoted-unreadable
4346 article-de-base64-unreadable
4349 article-unsplit-urls
4350 article-hide-list-identifiers
4351 article-strip-banner
4354 article-hide-signature
4355 article-strip-headers-in-body
4356 article-remove-trailing-blank-lines
4357 article-strip-leading-blank-lines
4358 article-strip-multiple-blank-lines
4359 article-strip-leading-space
4360 article-strip-trailing-space
4361 article-strip-blank-lines
4362 article-strip-all-blank-lines
4364 article-date-english
4365 article-date-iso8601
4366 article-date-original
4369 article-decode-mime-words
4370 article-decode-charset
4371 article-decode-encoded-words
4374 article-date-combined-lapsed
4376 article-treat-dumbquotes
4377 article-treat-non-ascii
4378 article-normalize-headers
4379 ;;(article-show-all . gnus-article-show-all-headers)
4383 ;;; Gnus article mode
4386 (put 'gnus-article-mode
'mode-class
'special
)
4388 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4390 (gnus-define-keys gnus-article-mode-map
4391 " " gnus-article-goto-next-page
4392 [?\S-\
] gnus-article-goto-prev-page
4393 "\177" gnus-article-goto-prev-page
4394 [delete] gnus-article-goto-prev-page
4395 "\C-c^" gnus-article-refer-article
4396 "h" gnus-article-show-summary
4397 "s" gnus-article-show-summary
4398 "\C-c\C-m" gnus-article-mail
4399 "?" gnus-article-describe-briefly
4400 "<" beginning-of-buffer
4402 "\C-c\C-i" gnus-info-find-node
4404 "R" gnus-article-reply-with-original
4405 "F" gnus-article-followup-with-original
4406 "\C-hk" gnus-article-describe-key
4407 "\C-hc" gnus-article-describe-key-briefly
4408 "\C-hb" gnus-article-describe-bindings
4410 "e" gnus-article-read-summary-keys
4411 "\C-d" gnus-article-read-summary-keys
4412 "\M-*" gnus-article-read-summary-keys
4413 "\M-#" gnus-article-read-summary-keys
4414 "\M-^" gnus-article-read-summary-keys
4415 "\M-g" gnus-article-read-summary-keys)
4417 (substitute-key-definition
4418 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4420 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4421 "W" gnus-article-wide-reply-with-original)
4422 (if (featurep 'xemacs)
4423 (set-keymap-default-binding gnus-article-send-map
4424 'gnus-article-read-summary-send-keys)
4425 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4427 (defun gnus-article-make-menu-bar ()
4428 (unless (boundp 'gnus-article-commands-menu)
4429 (gnus-summary-make-menu-bar))
4430 (unless (boundp 'gnus-article-article-menu)
4432 gnus-article-article-menu gnus-article-mode-map ""
4434 ["Scroll forwards" gnus-article-goto-next-page t]
4435 ["Scroll backwards" gnus-article-goto-prev-page t]
4436 ["Show summary" gnus-article-show-summary t]
4437 ["Fetch Message-ID at point" gnus-article-refer-article t]
4438 ["Mail to address at point" gnus-article-mail t]
4439 ["Send a bug report" gnus-bug t]))
4442 gnus-article-treatment-menu gnus-article-mode-map ""
4443 ;; Fixme: this should use :active (and maybe :visible).
4445 ["Hide headers" gnus-article-hide-headers t]
4446 ["Hide signature" gnus-article-hide-signature t]
4447 ["Hide citation" gnus-article-hide-citation t]
4448 ["Treat overstrike" gnus-article-treat-overstrike t]
4449 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4450 ["Remove carriage return" gnus-article-remove-cr t]
4451 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4452 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4453 ["Remove base64" gnus-article-de-base64-unreadable t]
4454 ["Treat html" gnus-article-wash-html t]
4455 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4456 ["Decode HZ" gnus-article-decode-HZ t]))
4458 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4460 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4462 (gnus-run-hooks 'gnus-article-menu-hook)))
4464 (defvar bookmark-make-record-function)
4465 (defvar shr-put-image-function)
4467 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4468 "Major mode for displaying an article.
4470 All normal editing commands are switched off.
4472 The following commands are available in addition to all summary mode
4474 \\<gnus-article-mode-map>
4475 \\[gnus-article-next-page]\t Scroll the article one page forwards
4476 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4477 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4478 \\[gnus-article-show-summary]\t Display the summary buffer
4479 \\[gnus-article-mail]\t Send a reply to the address near point
4480 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4481 \\[gnus-info-find-node]\t Go to the Gnus info node"
4482 (gnus-simplify-mode-line)
4483 (make-local-variable 'minor-mode-alist)
4484 (when (gnus-visual-p 'article-menu 'menu)
4485 (gnus-article-make-menu-bar)
4486 (when gnus-summary-tool-bar-map
4487 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4488 (gnus-update-format-specifications nil 'article-mode)
4489 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4490 (set (make-local-variable 'gnus-page-broken) nil)
4491 (make-local-variable 'gnus-article-current-summary)
4492 (make-local-variable 'gnus-article-mime-handles)
4493 (make-local-variable 'gnus-article-decoded-p)
4494 (make-local-variable 'gnus-article-mime-handle-alist)
4495 (make-local-variable 'gnus-article-wash-types)
4496 (make-local-variable 'gnus-article-image-alist)
4497 (make-local-variable 'gnus-article-charset)
4498 (make-local-variable 'gnus-article-ignored-charsets)
4499 (set (make-local-variable 'bookmark-make-record-function)
4500 'gnus-summary-bookmark-make-record)
4501 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4503 (set (make-local-variable 'nobreak-char-display) nil)
4504 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4505 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4506 (setq cursor-in-non-selected-windows nil)
4507 (gnus-set-default-directory)
4508 (buffer-disable-undo)
4509 (setq buffer-read-only t
4510 show-trailing-whitespace nil)
4511 (mm-enable-multibyte))
4513 (defun gnus-article-setup-buffer ()
4514 "Initialize the article buffer."
4515 (let* ((name (if gnus-single-article-buffer "*Article*"
4517 (gnus-group-decoded-name gnus-newsgroup-name)
4520 (progn (string-match "\\*Article" name)
4521 (concat " *Original Article"
4522 (substring name (match-end 0))))))
4523 (setq gnus-article-buffer name)
4524 (setq gnus-original-article-buffer original)
4525 (setq gnus-article-mime-handle-alist nil)
4526 (with-current-buffer gnus-summary-buffer
4527 ;; This might be a variable local to the summary buffer.
4528 (unless gnus-single-article-buffer
4529 (setq gnus-article-buffer name)
4530 (setq gnus-original-article-buffer original)
4531 (gnus-set-global-variables)))
4532 (gnus-article-setup-highlight-words)
4533 ;; Init original article buffer.
4534 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4535 (mm-enable-multibyte)
4536 (setq major-mode 'gnus-original-article-mode)
4537 (make-local-variable 'gnus-original-article))
4538 (if (and (get-buffer name)
4539 (with-current-buffer name
4540 (if gnus-article-edit-mode
4541 (if (y-or-n-p "Article mode edit in progress; discard? ")
4543 (set-buffer-modified-p nil)
4544 (gnus-kill-buffer name)
4547 (error "Action aborted"))
4549 (let ((summary gnus-summary-buffer))
4550 (with-current-buffer name
4551 (set (make-local-variable 'gnus-article-edit-mode) nil)
4552 (gnus-article-stop-animations)
4553 (when gnus-article-mime-handles
4554 (mm-destroy-parts gnus-article-mime-handles)
4555 (setq gnus-article-mime-handles nil))
4556 ;; Set it to nil in article-buffer!
4557 (setq gnus-article-mime-handle-alist nil)
4558 (buffer-disable-undo)
4559 (setq buffer-read-only t)
4560 (unless (derived-mode-p 'gnus-article-mode)
4561 (gnus-article-mode))
4562 (set (make-local-variable 'gnus-summary-buffer) summary)
4563 (setq truncate-lines gnus-article-truncate-lines)
4565 (let ((summary gnus-summary-buffer))
4566 (with-current-buffer (gnus-get-buffer-create name)
4568 (setq truncate-lines gnus-article-truncate-lines)
4569 (set (make-local-variable 'gnus-summary-buffer) summary)
4570 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4571 (when article-lapsed-timer
4572 (gnus-stop-date-timer))
4573 (when gnus-article-update-date-headers
4574 (gnus-start-date-timer gnus-article-update-date-headers))
4575 (current-buffer))))))
4577 (defun gnus-article-stop-animations ()
4578 (dolist (timer (and (boundp 'timer-list)
4580 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4581 (cancel-timer timer))))
4583 (defun gnus-stop-downloads ()
4584 (when (boundp 'url-queue)
4585 (set (intern "url-queue" obarray) nil)))
4587 ;; Set article window start at LINE, where LINE is the number of lines
4588 ;; from the head of the article.
4589 (defun gnus-article-set-window-start (&optional line)
4590 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4591 (when article-window
4594 (with-current-buffer gnus-article-buffer
4595 (goto-char (point-min))
4598 (gnus-message 6 "Moved to bookmark")
4599 (search-forward "\n\n" nil t)
4603 (defun gnus-article-prepare (article &optional all-headers header)
4604 "Prepare ARTICLE in article mode buffer.
4605 ARTICLE should either be an article number or a Message-ID.
4606 If ARTICLE is an id, HEADER should be the article headers.
4607 If ALL-HEADERS is non-nil, no headers are hidden."
4609 ;; Make sure we start in a summary buffer.
4610 (unless (derived-mode-p 'gnus-summary-mode)
4611 (set-buffer gnus-summary-buffer))
4612 (setq gnus-summary-buffer (current-buffer))
4613 (let* ((gnus-article (if header (mail-header-number header) article))
4614 (summary-buffer (current-buffer))
4615 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4616 (group gnus-newsgroup-name)
4619 (gnus-article-setup-buffer)
4620 (set-buffer gnus-article-buffer)
4621 ;; Deactivate active regions.
4622 (when (and (boundp 'transient-mark-mode)
4623 transient-mark-mode)
4624 (setq mark-active nil))
4625 (if (not (setq result (let ((inhibit-read-only t))
4626 (gnus-request-article-this-buffer
4628 ;; There is no such article.
4630 (when (and (numberp article)
4631 (not (memq article gnus-newsgroup-sparse)))
4632 (setq gnus-article-current
4633 (cons gnus-newsgroup-name article))
4634 (set-buffer gnus-summary-buffer)
4635 (setq gnus-current-article article)
4636 (if (and (memq article gnus-newsgroup-undownloaded)
4637 (not (gnus-online (gnus-find-method-for-group
4638 gnus-newsgroup-name))))
4640 (gnus-summary-set-agent-mark article)
4641 (message "Message marked for downloading"))
4642 (gnus-summary-mark-article article gnus-canceled-mark)
4643 (unless (memq article gnus-newsgroup-sparse)
4644 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4645 (if (or (eq result 'pseudo)
4646 (eq result 'nneething))
4648 (with-current-buffer summary-buffer
4649 (push article gnus-newsgroup-history)
4650 (setq gnus-last-article gnus-current-article
4651 gnus-current-article 0
4652 gnus-current-headers nil
4653 gnus-article-current nil)
4654 (if (eq result 'nneething)
4655 (gnus-configure-windows 'summary)
4656 (gnus-configure-windows 'article))
4657 (gnus-set-global-variables))
4658 (let ((gnus-article-mime-handle-alist-1
4659 gnus-article-mime-handle-alist))
4660 (gnus-set-mode-line 'article)))
4661 ;; The result from the `request' was an actual article -
4662 ;; or at least some text that is now displayed in the
4664 (when (and (numberp article)
4665 (not (eq article gnus-current-article)))
4666 ;; Seems like a new article has been selected.
4667 ;; `gnus-current-article' must be an article number.
4668 (with-current-buffer summary-buffer
4669 (push article gnus-newsgroup-history)
4670 (setq gnus-last-article gnus-current-article
4671 gnus-current-article article
4672 gnus-current-headers
4673 (gnus-summary-article-header gnus-current-article)
4674 gnus-article-current
4675 (cons gnus-newsgroup-name gnus-current-article))
4676 (unless (vectorp gnus-current-headers)
4677 (setq gnus-current-headers nil))
4678 (gnus-summary-goto-subject gnus-current-article)
4679 (when (gnus-summary-show-thread)
4680 ;; If the summary buffer really was folded, the
4681 ;; previous goto may not actually have gone to
4682 ;; the right article, but the thread root instead.
4684 (gnus-summary-goto-subject gnus-current-article))
4685 (gnus-run-hooks 'gnus-mark-article-hook)
4686 (gnus-set-mode-line 'summary)
4687 (when (gnus-visual-p 'article-highlight 'highlight)
4688 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4689 ;; Set the global newsgroup variables here.
4690 (gnus-set-global-variables)
4691 (setq gnus-have-all-headers
4692 (or all-headers gnus-show-all-headers))))
4694 (gnus-configure-windows 'article))
4695 (when (or (numberp article)
4697 (gnus-article-prepare-display)
4699 (goto-char (point-min))
4700 (when gnus-break-pages
4701 (gnus-narrow-to-page)))
4702 (let ((gnus-article-mime-handle-alist-1
4703 gnus-article-mime-handle-alist))
4704 (gnus-set-mode-line 'article))
4708 (set-window-point (get-buffer-window (current-buffer)) (point))
4709 (gnus-configure-windows 'article)
4710 (gnus-run-hooks 'gnus-article-prepare-hook)
4714 (defun gnus-article-prepare-display ()
4715 "Make the current buffer look like a nice article."
4716 ;; Hooks for getting information from the article.
4717 ;; This hook must be called before being narrowed.
4718 (let ((gnus-article-buffer (current-buffer))
4720 (inhibit-read-only t))
4721 (unless (derived-mode-p 'gnus-article-mode)
4722 (gnus-article-mode))
4723 (setq buffer-read-only nil
4724 gnus-article-wash-types nil
4725 gnus-article-image-alist nil)
4726 (gnus-run-hooks 'gnus-tmp-internal-hook)
4727 (when gnus-display-mime-function
4728 (funcall gnus-display-mime-function))
4729 ;; Add attachment buttons to the header.
4730 (when gnus-mime-display-attachment-buttons-in-header
4731 (gnus-mime-buttonize-attachments-in-header))))
4734 ;;; Gnus Sticky Article Mode
4737 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4738 "Mode for sticky articles."
4739 ;; Release bindings that won't work.
4740 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4741 gnus-sticky-article-mode-map)
4742 (substitute-key-definition 'gnus-article-refer-article 'undefined
4743 gnus-sticky-article-mode-map)
4744 (dolist (k '("e" "h" "s" "F" "R"))
4745 (define-key gnus-sticky-article-mode-map k nil))
4746 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4747 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4748 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4749 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4751 (defun gnus-sticky-article (arg)
4752 "Make the current article sticky.
4753 If a prefix ARG is given, ask for a name for this sticky article buffer."
4755 (gnus-summary-show-thread)
4756 (gnus-summary-select-article nil nil 'pseudo)
4757 (let (new-art-buf-name)
4758 (gnus-eval-in-buffer-window gnus-article-buffer
4759 (setq new-art-buf-name
4763 (read-from-minibuffer "Sticky article buffer name: ")
4764 (gnus-with-article-headers
4765 (gnus-article-goto-header "subject")
4766 (setq new-art-buf-name
4767 (buffer-substring-no-properties
4768 (line-beginning-position) (line-end-position)))
4769 (goto-char (point-min))
4770 (gnus-article-goto-header "from")
4771 (setq new-art-buf-name
4773 new-art-buf-name ", "
4774 (buffer-substring-no-properties
4775 (line-beginning-position) (line-end-position))))
4776 (goto-char (point-min))
4777 (gnus-article-goto-header "date")
4778 (setq new-art-buf-name
4780 new-art-buf-name ", "
4781 (buffer-substring-no-properties
4782 (line-beginning-position) (line-end-position))))))
4784 (if (and (gnus-buffer-live-p new-art-buf-name)
4785 (with-current-buffer new-art-buf-name
4786 (derived-mode-p 'gnus-sticky-article-mode)))
4787 (switch-to-buffer new-art-buf-name)
4788 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4789 (gnus-sticky-article-mode))
4790 (setq gnus-article-buffer new-art-buf-name))
4791 (gnus-summary-recenter)
4792 (gnus-summary-position-point))
4794 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4795 "Kill the given sticky article BUFFER.
4796 If none is given, assume the current buffer and kill it if it has
4797 `gnus-sticky-article-mode'."
4800 (setq buffer (current-buffer)))
4801 (with-current-buffer buffer
4802 (when (derived-mode-p 'gnus-sticky-article-mode)
4803 (gnus-kill-buffer buffer))))
4805 (defun gnus-kill-sticky-article-buffers (arg)
4806 "Kill all sticky article buffers.
4807 If a prefix ARG is given, ask for confirmation."
4809 (dolist (buf (gnus-buffers))
4810 (with-current-buffer buf
4811 (when (derived-mode-p 'gnus-sticky-article-mode)
4813 (gnus-kill-buffer buf)
4814 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4815 (gnus-kill-buffer buf)))))))
4818 ;;; Gnus MIME viewing functions
4821 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4822 "Format of the MIME buttons.
4824 Valid specifiers include:
4826 %T MIME type, along with additional info
4827 %n The `name' parameter
4828 %d The description, if any
4829 %l The length of the encoded part
4830 %p The part identifier number
4831 %e Dots if the part isn't displayed
4833 General format specifiers can also be used. See Info node
4834 `(gnus)Formatting Variables'.")
4836 (defvar gnus-mime-button-line-format-alist
4837 '((?t gnus-tmp-type ?s)
4838 (?T gnus-tmp-type-long ?s)
4839 (?n gnus-tmp-name ?s)
4840 (?d gnus-tmp-description ?s)
4842 (?l gnus-tmp-length ?d)
4843 (?e gnus-tmp-dots ?s)))
4845 (defvar gnus-mime-button-commands
4846 '((gnus-article-press-button "\r" "Toggle Display")
4847 (gnus-mime-view-part "v" "View Interactively...")
4848 (gnus-mime-view-part-as-type "t" "View As Type...")
4849 (gnus-mime-view-part-as-charset "C" "View As charset...")
4850 (gnus-mime-save-part "o" "Save...")
4851 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4852 (gnus-mime-replace-part "r" "Replace part")
4853 (gnus-mime-delete-part "d" "Delete part")
4854 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4855 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4856 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4857 (gnus-mime-view-part-externally "e" "View Externally")
4858 (gnus-mime-print-part "p" "Print")
4859 (gnus-mime-pipe-part "|" "Pipe To Command...")
4860 (gnus-mime-action-on-part "." "Take action on the part...")))
4862 (defun gnus-article-mime-part-status ()
4863 (if gnus-article-mime-handle-alist-1
4864 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4866 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4869 (defvar gnus-mime-button-map
4870 (let ((map (make-sparse-keymap)))
4871 (define-key map gnus-mouse-2 'gnus-article-push-button)
4872 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4873 (dolist (c gnus-mime-button-commands)
4874 (define-key map (cadr c) (car c)))
4878 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4880 ,@(mapcar (lambda (c)
4881 (vector (caddr c) (car c) :active t))
4882 gnus-mime-button-commands)))
4884 (defvar gnus-url-button-commands
4885 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4887 (defvar gnus-url-button-map
4888 (let ((map (make-sparse-keymap)))
4889 (dolist (c gnus-url-button-commands)
4890 (define-key map (cadr c) (car c)))
4894 gnus-url-button-menu gnus-url-button-map "URL button menu."
4896 ,@(mapcar (lambda (c)
4897 (vector (caddr c) (car c) :active t))
4898 gnus-url-button-commands)))
4900 (defmacro gnus-bind-safe-url-regexp (&rest body)
4901 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4902 `(let ((mm-w3m-safe-url-regexp
4903 (let ((group (if (and (derived-mode-p 'gnus-article-mode)
4905 gnus-article-current-summary))
4906 (with-current-buffer gnus-article-current-summary
4907 gnus-newsgroup-name)
4908 gnus-newsgroup-name)))
4909 (if (cond ((not group)
4910 ;; Maybe we're in a mml-preview buffer
4911 ;; and no group is selected.
4913 ((stringp gnus-safe-html-newsgroups)
4914 (string-match gnus-safe-html-newsgroups group))
4915 ((consp gnus-safe-html-newsgroups)
4916 (member group gnus-safe-html-newsgroups)))
4918 mm-w3m-safe-url-regexp))))
4921 (defun gnus-mime-button-menu (event prefix)
4922 "Construct a context-sensitive menu of MIME commands."
4923 (interactive "e\nP")
4924 (save-window-excursion
4925 (let ((pos (event-start event)))
4926 (select-window (posn-window pos))
4927 (goto-char (posn-point pos))
4928 (gnus-article-check-buffer)
4929 (popup-menu gnus-mime-button-menu nil prefix))))
4931 (defun gnus-mime-view-all-parts (&optional handles)
4932 "View all the MIME parts."
4934 (with-current-buffer gnus-article-buffer
4935 (let ((handles (or handles gnus-article-mime-handles))
4936 (mail-parse-charset gnus-newsgroup-charset)
4937 (mail-parse-ignored-charsets
4938 (with-current-buffer gnus-summary-buffer
4939 gnus-newsgroup-ignored-charsets)))
4941 (mm-remove-parts handles)
4942 (goto-char (point-min))
4943 (or (search-forward "\n\n") (goto-char (point-max)))
4944 (let ((inhibit-read-only t))
4945 (delete-region (point) (point-max))
4946 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4948 (defun gnus-article-jump-to-part (n)
4949 "Jump to MIME part N."
4951 (let ((parts (with-current-buffer gnus-article-buffer
4952 (length gnus-article-mime-handle-alist))))
4954 (error "No such part"))
4955 (pop-to-buffer gnus-article-buffer)
4957 (setq n (if (= parts 1)
4959 (read-number (format "Jump to part (1..%s): " parts)))))
4960 (unless (and (integerp n) (<= n parts) (>= n 1))
4963 (gnus-message 7 "Invalid part `%s', using %s instead."
4966 (gnus-message 9 "Jumping to part %s." n)
4967 (cond ((>= gnus-auto-select-part 1)
4968 (while (and (<= n parts)
4969 (not (gnus-article-goto-part n)))
4971 ((< gnus-auto-select-part 0)
4972 (while (and (>= n 1)
4973 (not (gnus-article-goto-part n)))
4976 (gnus-article-goto-part n)))))
4978 (defvar gnus-mime-buttonized-part-id nil
4979 "ID of a mime part that should be buttonized.
4980 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4983 (defsubst gnus-article-edit-part (handles &optional current-id)
4984 "Edit an article in order to delete a mime part.
4985 This function is exclusively used by `gnus-mime-save-part-and-strip'
4986 and `gnus-mime-delete-part', and not provided at run-time normally."
4987 (gnus-article-edit-article
4989 (buffer-disable-undo)
4991 (let ((mail-parse-charset (or gnus-article-charset
4992 ',gnus-newsgroup-charset))
4993 (mail-parse-ignored-charsets
4994 (or gnus-article-ignored-charsets
4995 ',gnus-newsgroup-ignored-charsets))
4996 (mbl mml-buffer-list))
4997 (setq mml-buffer-list nil)
4998 (insert-buffer-substring gnus-original-article-buffer)
4999 (mime-to-mml ',handles)
5000 (setq gnus-article-mime-handles nil)
5001 (let ((mbl1 mml-buffer-list))
5002 (setq mml-buffer-list mbl)
5003 (set (make-local-variable 'mml-buffer-list) mbl1))
5004 (gnus-make-local-hook 'kill-buffer-hook)
5005 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5006 `(lambda (no-highlight)
5007 (let ((mail-parse-charset (or gnus-article-charset
5008 ',gnus-newsgroup-charset))
5009 (message-options message-options)
5010 (message-options-set-recipient)
5011 (mail-parse-ignored-charsets
5012 (or gnus-article-ignored-charsets
5013 ',gnus-newsgroup-ignored-charsets)))
5015 (mml-destroy-buffers)
5016 (remove-hook 'kill-buffer-hook
5017 'mml-destroy-buffers t)
5018 (kill-local-variable 'mml-buffer-list))
5019 (gnus-summary-edit-article-done
5020 ,(or (mail-header-references gnus-current-headers) "")
5021 ,(gnus-group-read-only-p)
5022 ,gnus-summary-buffer no-highlight))
5024 ;; Force buttonizing this part.
5025 (let ((gnus-mime-buttonized-part-id current-id))
5026 (gnus-article-edit-done))
5027 (gnus-configure-windows 'article)
5028 (when (and current-id (integerp gnus-auto-select-part))
5029 (gnus-article-jump-to-part
5030 (min (max (+ current-id gnus-auto-select-part) 1)
5031 (with-current-buffer gnus-article-buffer
5032 (length gnus-article-mime-handle-alist)))))))
5034 (defun gnus-mime-replace-part (file)
5035 "Replace MIME part under point with an external body."
5036 ;; Useful if file has already been saved to disk
5039 (read-file-name "Replace MIME part with file: "
5040 (or mm-default-directory default-directory)
5042 (gnus-mime-save-part-and-strip file))
5044 (defun gnus-mime-save-part-and-strip (&optional file)
5045 "Save the MIME part under point then replace it with an external body.
5046 If FILE is given, use it for the external part."
5048 (gnus-article-check-buffer)
5049 (when (gnus-group-read-only-p)
5050 (error "The current group does not support deleting of parts"))
5051 (when (mm-complicated-handles gnus-article-mime-handles)
5053 The current article has a complicated MIME structure, giving up..."))
5054 (let* ((data (get-text-property (point) 'gnus-data))
5055 (id (get-text-property (point) 'gnus-part))
5057 (handles gnus-article-mime-handles))
5060 (and data (mm-save-part data "Delete MIME part and save to: "))))
5062 (with-current-buffer (mm-handle-buffer data)
5064 (insert "Content-Type: " (mm-handle-media-type data))
5065 (mml-insert-parameter-string (cdr (mm-handle-type data))
5067 ;; Add a filename for the sake of saving the part again.
5068 (mml-insert-parameter
5069 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5071 (insert "Content-ID: " (message-make-message-id) "\n")
5072 (insert "Content-Transfer-Encoding: binary\n")
5075 (cdr (mm-make-handle nil
5076 `("message/external-body"
5077 (access-type . "LOCAL-FILE")
5079 ;; (set-buffer gnus-summary-buffer)
5080 (gnus-article-edit-part handles id))))
5082 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5083 ;; parts...>') but with stripping would be nice.
5085 (defun gnus-mime-delete-part ()
5086 "Delete the MIME part under point.
5087 Replace it with some information about the removed part."
5089 (gnus-article-check-buffer)
5090 (when (gnus-group-read-only-p)
5091 (error "The current group does not support deleting of parts"))
5092 (when (mm-complicated-handles gnus-article-mime-handles)
5094 The current article has a complicated MIME structure, giving up..."))
5095 (when (or gnus-expert-user
5096 (gnus-yes-or-no-p "\
5097 Deleting parts may malfunction or destroy the article; continue? "))
5098 (let* ((data (get-text-property (point) 'gnus-data))
5099 (id (get-text-property (point) 'gnus-part))
5100 (handles gnus-article-mime-handles)
5102 (let ((desc (mm-handle-description data)))
5104 (mail-decode-encoded-word-string desc))))
5105 (filename (or (mm-handle-filename data) "(none)"))
5106 (type (mm-handle-media-type data)))
5108 (error "No MIME part under point"))
5109 (with-current-buffer (mm-handle-buffer data)
5110 (let ((bsize (buffer-size)))
5115 "| The following attachment has been deleted:\n"
5117 "| Type: " type "\n"
5118 "| Filename: " filename "\n"
5119 "| Size (encoded): " (format "%s byte%s\n"
5120 bsize (if (= bsize 1)
5124 (concat "| Description: " description "\n"))
5127 (cdr (mm-make-handle
5128 nil `("text/plain" (charset . gnus-decoded)) nil nil
5130 (format "Deleted attachment (%s bytes)" bsize))))))
5131 ;; (set-buffer gnus-summary-buffer)
5132 (gnus-article-edit-part handles id))))
5134 (defun gnus-mime-save-part ()
5135 "Save the MIME part under point."
5137 (gnus-article-check-buffer)
5138 (let ((data (get-text-property (point) 'gnus-data)))
5140 (mm-save-part data))))
5142 (defun gnus-mime-pipe-part (&optional cmd)
5143 "Pipe the MIME part under point to a process.
5144 Use CMD as the process."
5146 (gnus-article-check-buffer)
5147 (let ((data (get-text-property (point) 'gnus-data)))
5149 (mm-pipe-part data cmd))))
5151 (defun gnus-mime-view-part ()
5152 "Interactively choose a viewing method for the MIME part under point."
5154 (gnus-article-check-buffer)
5155 (let ((data (get-text-property (point) 'gnus-data)))
5157 (setq gnus-article-mime-handles
5159 gnus-article-mime-handles (setq data (copy-sequence data))))
5160 (mm-interactively-view-part data))))
5162 (defun gnus-mime-view-part-as-type-internal ()
5163 (gnus-article-check-buffer)
5164 (let* ((handle (get-text-property (point) 'gnus-data))
5166 ;; Content-Type: foo/bar; name=...
5167 (mail-content-type-get (mm-handle-type handle) 'name)
5168 ;; Content-Disposition: attachment; filename=...
5169 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5170 (def-type (and name (mm-default-file-encoding name))))
5171 (or (and def-type (cons def-type 0))
5173 (equal (mm-handle-media-supertype handle) "text")
5174 '("text/plain" . 0))
5175 '("application/octet-stream" . 0))))
5177 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5178 "Choose a MIME media type, and view the part as such.
5179 If non-nil, PRED is a predicate to use during completion to limit the
5180 available media-types."
5184 (let ((default (gnus-mime-view-part-as-type-internal)))
5185 (gnus-completing-read
5188 (gnus-remove-if-not pred (mailcap-mime-types))
5189 (mailcap-mime-types))
5192 (gnus-article-check-buffer)
5193 (let ((handle (get-text-property (point) 'gnus-data)))
5195 (when (equal (mm-handle-media-type handle) "message/external-body")
5196 (unless (mm-handle-cache handle)
5197 (mm-extern-cache-contents handle))
5198 (setq handle (mm-handle-cache handle)))
5200 (mm-make-handle (mm-handle-buffer handle)
5201 (cons mime-type (cdr (mm-handle-type handle)))
5202 (mm-handle-encoding handle)
5203 (mm-handle-undisplayer handle)
5204 (mm-handle-disposition handle)
5205 (mm-handle-description handle)
5207 (mm-handle-id handle)))
5208 (setq gnus-article-mime-handles
5209 (mm-merge-handles gnus-article-mime-handles handle))
5210 (when (mm-handle-displayed-p handle)
5211 (mm-remove-part handle))
5212 (gnus-mm-display-part handle))))
5214 (defun gnus-mime-copy-part (&optional handle arg)
5215 "Put the MIME part under point into a new buffer.
5216 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5218 (interactive (list nil current-prefix-arg))
5219 (gnus-article-check-buffer)
5221 (setq handle (get-text-property (point) 'gnus-data)))
5223 (let ((filename (mm-handle-filename handle))
5224 contents dont-decode charset coding-system)
5225 (mm-with-unibyte-buffer
5226 (mm-insert-part handle)
5227 (setq contents (or (condition-case nil
5228 (mm-decompress-buffer filename nil 'sig)
5230 (setq dont-decode t)
5233 (setq filename (cond (filename (file-name-nondirectory filename))
5234 (dont-decode "*raw data*")
5239 (unless (setq charset (mail-content-type-get
5240 (mm-handle-type handle) 'charset))
5241 (unless (setq coding-system (mm-with-unibyte-buffer
5243 (mm-find-buffer-file-coding-system)))
5244 (setq charset gnus-newsgroup-charset))))
5246 (setq charset (or (cdr (assq arg
5247 gnus-summary-show-article-charset-alist))
5248 (mm-read-coding-system "Charset: ")))))
5249 (switch-to-buffer (generate-new-buffer filename))
5250 (if (or coding-system
5252 (setq coding-system (mm-charset-to-coding-system
5254 (not (eq coding-system 'ascii))))
5256 (mm-enable-multibyte)
5257 (insert (mm-decode-coding-string contents coding-system))
5258 (setq buffer-file-coding-system
5259 (if (boundp 'last-coding-system-used)
5260 (symbol-value 'last-coding-system-used)
5262 (mm-disable-multibyte)
5264 (setq buffer-file-coding-system mm-binary-coding-system))
5265 ;; We do it this way to make `normal-mode' set the appropriate mode.
5268 (setq buffer-file-name (expand-file-name filename))
5270 (setq buffer-file-name nil))
5271 (goto-char (point-min)))))
5273 (defun gnus-mime-print-part (&optional handle filename)
5274 "Print the MIME part under point."
5275 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5276 (gnus-article-check-buffer)
5277 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5278 (contents (and handle (mm-get-part handle)))
5279 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5280 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5285 (mm-save-part-to-file handle file)
5286 (call-process shell-file-name nil
5287 (generate-new-buffer " *mm*")
5289 shell-command-switch
5291 printer file (mm-handle-type handle))))
5295 (gnus-print-buffer))
5296 (ps-despool filename)))))
5298 (defun gnus-mime-inline-part (&optional handle arg)
5299 "Insert the MIME part under point into the current buffer.
5300 Compressed files like .gz and .bz2 are decompressed."
5301 (interactive (list nil current-prefix-arg))
5302 (gnus-article-check-buffer)
5303 (let* ((inhibit-read-only t)
5305 (btn ;; position where the MIME button exists
5307 (if (eq handle (get-text-property b 'gnus-data))
5310 (or (text-property-any (point) (point-max) 'gnus-data handle)
5311 (text-property-any (point-min) (point) 'gnus-data handle)))
5312 (setq handle (get-text-property b 'gnus-data))
5314 start contents charset coding-system)
5318 (setq start (next-single-property-change btn 'gnus-data
5320 btn (previous-single-property-change start
5323 (if (and (not arg) (mm-handle-undisplayer handle))
5324 (mm-remove-part handle)
5325 (mm-with-unibyte-buffer
5326 (mm-insert-part handle)
5328 (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
5332 (unless (setq charset (mail-content-type-get
5333 (mm-handle-type handle) 'charset))
5334 (unless (setq coding-system
5335 (mm-with-unibyte-buffer
5337 (mm-find-buffer-file-coding-system)))
5338 (setq charset gnus-newsgroup-charset))))
5340 (if (mm-handle-undisplayer handle)
5341 (mm-remove-part handle))
5344 gnus-summary-show-article-charset-alist))
5345 (mm-read-coding-system "Charset: "))))
5346 ((mm-handle-undisplayer handle)
5347 (mm-remove-part handle)))
5350 ;; This is a header button.
5352 (mm-display-inline handle))
5353 ;; Toggle the button appearance between `[button]...' and `[button]'.
5355 (let ((displayed-p (mm-handle-displayed-p handle)))
5356 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5358 (if (featurep 'emacs)
5361 (next-single-property-change (point) 'gnus-data nil (point-max)))
5362 (let* ((end (next-single-property-change (point) 'gnus-data))
5363 (annots (annotations-at (or end (point-max)))))
5364 (delete-region (point)
5366 (if annots (1+ end) end)
5368 (dolist (annot annots)
5369 (set-extent-endpoints annot (point) (point)))))
5370 (setq start (point))
5371 (if (search-backward "\n\n" nil t)
5374 (unless (or displayed-p (eolp))
5375 ;; Add extra newline.
5376 (insert (propertize (buffer-substring (1- start) start)
5377 'gnus-undeletable t))))
5378 ;; We're in the article header.
5380 (dolist (ovl (gnus-overlays-in btn (point)))
5381 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5382 (gnus-overlay-put ovl 'face nil))
5384 (message-narrow-to-field)
5385 (let ((gnus-treatment-function-alist
5386 '((gnus-treat-highlight-headers
5387 gnus-article-highlight-headers))))
5388 (gnus-treat-article 'head)))))
5391 (defun gnus-mime-set-charset-parameters (handle charset)
5392 "Set CHARSET to parameters in HANDLE.
5393 CHARSET may either be a string or a symbol."
5394 (unless (stringp charset)
5395 (setq charset (symbol-name charset)))
5396 (if (stringp (car handle))
5397 (dolist (h (cdr handle))
5398 (gnus-mime-set-charset-parameters h charset))
5399 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5400 "message/external-body")
5402 (unless (mm-handle-cache handle)
5403 (mm-extern-cache-contents handle))
5404 (mm-handle-cache handle))
5406 (param (assq 'charset (cdr type))))
5408 (setcdr param charset)
5409 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5411 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5412 "Insert the MIME part under point into the current buffer using the
5414 (interactive (list nil current-prefix-arg))
5415 (gnus-article-check-buffer)
5416 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5417 (fun (get-text-property (point) 'gnus-callback))
5418 (gnus-newsgroup-ignored-charsets 'gnus-all)
5419 charset form preferred parts)
5426 gnus-summary-show-article-charset-alist))
5427 (mm-read-coding-system "Charset: "))))
5428 (if (mm-handle-undisplayer handle)
5429 (mm-remove-part handle)))
5430 (gnus-mime-set-charset-parameters handle charset)
5431 (when (and (consp (setq form (cdr-safe fun)))
5432 (setq form (ignore-errors
5433 (assq 'gnus-mime-display-alternative form)))
5434 (setq preferred (caddr form))
5436 (when (eq (car preferred) 'quote)
5437 (setq preferred (cadr preferred)))
5438 (not (equal preferred
5439 (get-text-property (point) 'gnus-data))))
5440 (setq parts (get-text-property (point) 'gnus-part))
5441 (setq parts (cdr (assq parts
5442 gnus-article-mime-handle-alist)))
5443 (equal (mm-handle-media-type parts) "multipart/alternative")
5444 (setq parts (reverse (cdr parts))))
5446 (list 'quote (or (cadr (member preferred parts))
5448 (funcall fun handle)))))
5450 (defun gnus-mime-view-part-externally (&optional handle)
5451 "View the MIME part under point with an external viewer."
5453 (gnus-article-check-buffer)
5454 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5455 (mm-user-display-methods nil)
5456 (mm-inlined-types nil)
5457 (mail-parse-charset gnus-newsgroup-charset)
5458 (mail-parse-ignored-charsets
5459 (with-current-buffer gnus-summary-buffer
5460 gnus-newsgroup-ignored-charsets))
5461 (type (mm-handle-media-type handle))
5462 (method (mailcap-mime-info type))
5463 (mm-enable-external t))
5464 (if (not (stringp method))
5465 (gnus-mime-view-part-as-type
5466 nil (lambda (type) (stringp (mailcap-mime-info type))))
5468 (mm-display-part handle nil t)))))
5470 (defun gnus-mime-view-part-internally (&optional handle)
5471 "View the MIME part under point with an internal viewer.
5472 If no internal viewer is available, use an external viewer."
5474 (gnus-article-check-buffer)
5475 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5476 (mm-inlined-types '(".*"))
5477 (mm-inline-large-images t)
5478 (mail-parse-charset gnus-newsgroup-charset)
5479 (mail-parse-ignored-charsets
5480 (with-current-buffer gnus-summary-buffer
5481 gnus-newsgroup-ignored-charsets))
5482 (inhibit-read-only t))
5483 (if (not (mm-inlinable-p handle))
5484 (gnus-mime-view-part-as-type
5485 nil (lambda (type) (mm-inlinable-p handle type)))
5487 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5489 (defun gnus-mime-action-on-part (&optional action)
5490 "Do something with the MIME attachment at \(point\)."
5492 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5493 (gnus-article-check-buffer)
5494 (let ((action-pair (assoc action gnus-mime-action-alist)))
5496 (funcall (cdr action-pair)))))
5498 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5499 "Call FUNCTION on MIME part N.
5500 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5501 If INTERACTIVE, call FUNCTION interactively."
5503 ;; Check whether the article is displayed.
5504 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5505 (setq window (get-buffer-window gnus-article-buffer t))
5506 (frame-visible-p (setq frame (window-frame window))))
5507 (error "No article is displayed"))
5508 (with-current-buffer gnus-article-buffer
5509 ;; Check whether the article displays the right contents.
5510 (unless (with-current-buffer gnus-summary-buffer
5511 (eq gnus-current-article (gnus-summary-article-number)))
5512 (error "You should select the right article first"))
5514 (setq n (prefix-numeric-value n))
5516 (setq n (or (get-text-property pt 'gnus-part)
5518 (get-text-property (1- pt) 'gnus-part))
5519 (get-text-property (prog2
5525 (or (and (setq pt (previous-single-property-change
5528 (next-single-property-change (point) 'gnus-part)
5532 ;; Check whether the specified part exists.
5533 (when (> n (length gnus-article-mime-handle-alist))
5534 (error "No such part")))
5537 ;; To select the window is needed so that the cursor
5538 ;; might be visible on the MIME button.
5539 (select-window (prog1
5541 (setq window (selected-window))
5542 ;; Article may be displayed in the other frame.
5543 (gnus-select-frame-set-input-focus
5546 (setq frame (selected-frame))))))
5547 (when (gnus-article-goto-part n)
5548 ;; We point the cursor and the arrow at the MIME button
5549 ;; when the `function' prompt the user for something.
5550 (unless (and (pos-visible-in-window-p)
5551 (> (count-lines (point) (window-end))
5552 (/ (1- (window-height)) 3)))
5553 (recenter (/ (1- (window-height)) 3)))
5554 (let ((cursor-in-non-selected-windows t)
5555 (overlay-arrow-string "=>")
5556 (overlay-arrow-position (point-marker)))
5559 ((and no-handle interactive)
5560 (call-interactively function))
5565 function (get-text-property (point) 'gnus-data)))
5568 (get-text-property (point) 'gnus-data))))
5569 (set-marker overlay-arrow-position nil)
5570 (unless gnus-auto-select-part
5571 (gnus-select-frame-set-input-focus frame)
5572 (select-window window))))
5574 (if gnus-inhibit-mime-unbuttonizing
5575 ;; This is the default though the program shouldn't reach here.
5576 (error "No such part")
5577 ;; The part which doesn't have the MIME button is selected.
5578 ;; So, we display all the buttons and redo it.
5579 (let ((gnus-inhibit-mime-unbuttonizing t))
5580 (gnus-summary-show-article)
5581 (gnus-article-part-wrapper n function no-handle))))))
5583 (defun gnus-article-pipe-part (n)
5584 "Pipe MIME part N, which is the numerical prefix."
5586 (gnus-article-part-wrapper n 'mm-pipe-part))
5588 (defun gnus-article-save-part (n)
5589 "Save MIME part N, which is the numerical prefix."
5591 (gnus-article-part-wrapper n 'mm-save-part))
5593 (defun gnus-article-interactively-view-part (n)
5594 "View MIME part N interactively, which is the numerical prefix."
5596 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5598 (defun gnus-article-copy-part (n)
5599 "Copy MIME part N, which is the numerical prefix."
5601 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5603 (defun gnus-article-view-part-as-charset (n)
5604 "View MIME part N using a specified charset.
5605 N is the numerical prefix."
5607 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5609 (defun gnus-article-view-part-externally (n)
5610 "View MIME part N externally, which is the numerical prefix."
5612 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5614 (defun gnus-article-inline-part (n)
5615 "Inline MIME part N, which is the numerical prefix."
5617 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5619 (defun gnus-article-save-part-and-strip (n)
5620 "Save MIME part N and replace it with an external body.
5621 N is the numerical prefix."
5623 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5625 (defun gnus-article-replace-part (n)
5626 "Replace MIME part N with an external body.
5627 N is the numerical prefix."
5629 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5631 (defun gnus-article-delete-part (n)
5632 "Delete MIME part N and add some information about the removed part.
5633 N is the numerical prefix."
5635 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5637 (defun gnus-article-view-part-as-type (n)
5638 "Choose a MIME media type, and view part N as such.
5639 N is the numerical prefix."
5641 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5643 (defun gnus-article-mime-match-handle-first (condition)
5646 (dolist (ihandle gnus-article-mime-handle-alist)
5648 ((functionp condition)
5649 (funcall condition (cdr ihandle)))
5650 ((eq condition 'undisplayed)
5651 (not (or (mm-handle-undisplayer (cdr ihandle))
5652 (equal (mm-handle-media-type (cdr ihandle))
5653 "multipart/alternative"))))
5654 ((eq condition 'undisplayed-alternative)
5655 (not (mm-handle-undisplayer (cdr ihandle))))
5657 (gnus-article-goto-part (car ihandle))
5658 (or (not n) (< (car ihandle) n)))
5659 (setq n (car ihandle))))
5663 (defun gnus-article-view-part (&optional n)
5664 "View MIME part N, which is the numerical prefix.
5665 If the part is already shown, hide the part. If N is nil, view
5668 (with-current-buffer gnus-article-buffer
5669 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5670 gnus-article-mime-match-handle-function)))
5671 (when (> n (length gnus-article-mime-handle-alist))
5672 (error "No such part"))
5673 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5674 (when (gnus-article-goto-part n)
5675 (if (equal (car handle) "multipart/alternative")
5677 (beginning-of-line) ;; Make it toggle subparts
5678 (gnus-article-press-button))
5679 (when (eq (gnus-mm-display-part handle) 'internal)
5680 (gnus-set-window-start)))))))
5682 (defsubst gnus-article-mime-total-parts ()
5683 (if (bufferp (car gnus-article-mime-handles))
5685 (1- (length gnus-article-mime-handles))))
5687 (defun gnus-mm-display-part (handle)
5688 "Display HANDLE and fix MIME button."
5689 (let ((id (get-text-property (point) 'gnus-part))
5691 (inhibit-read-only t)
5692 (window (selected-window))
5693 (mail-parse-charset gnus-newsgroup-charset)
5694 (mail-parse-ignored-charsets
5695 (if (gnus-buffer-live-p gnus-summary-buffer)
5696 (with-current-buffer gnus-summary-buffer
5697 gnus-newsgroup-ignored-charsets)
5702 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5706 (setq start (next-single-property-change point 'gnus-data
5708 point (previous-single-property-change start 'gnus-data))
5709 (if (mm-handle-displayed-p handle)
5710 ;; This will remove the part.
5711 (setq retval (mm-display-part handle))
5712 (let ((part (or (and (mm-inlinable-p handle)
5713 (mm-inlined-p handle)
5716 (gnus-bind-safe-url-regexp
5717 (setq retval (mm-display-part handle)))
5718 (unless (zerop (buffer-size))
5719 (buffer-string))))))
5722 ;; This is a header button.
5724 (cond ((stringp part)
5726 (narrow-to-region (point)
5729 (unless (bolp) (insert "\n"))
5731 (gnus-treat-article nil id
5732 (gnus-article-mime-total-parts)
5733 (mm-handle-media-type handle))
5734 (mm-handle-set-undisplayer
5737 (let ((inhibit-read-only t))
5738 (delete-region ,(copy-marker (point-min) t)
5739 ,(point-max-marker)))))))
5741 (mm-display-inline handle))))))
5743 ;; Toggle the button appearance between `[button]...' and `[button]'.
5744 (let ((displayed-p (mm-handle-displayed-p handle)))
5745 (gnus-insert-mime-button handle id (list displayed-p))
5746 (if (featurep 'emacs)
5749 (next-single-property-change (point) 'gnus-data nil (point-max)))
5750 (let* ((end (next-single-property-change (point) 'gnus-data))
5751 (annots (annotations-at (or end (point-max)))))
5752 (delete-region (point)
5754 (if annots (1+ end) end)
5756 (dolist (annot annots)
5757 (set-extent-endpoints annot (point) (point)))))
5758 (setq start (point))
5759 (if (search-backward "\n\n" nil t)
5762 (unless (or displayed-p (eolp))
5763 ;; Add extra newline.
5764 (insert (propertize (buffer-substring (1- start) start)
5765 'gnus-undeletable t))))
5766 ;; We're in the article header.
5768 (dolist (ovl (gnus-overlays-in point (point)))
5769 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5770 (gnus-overlay-put ovl 'face nil))
5772 (message-narrow-to-field)
5773 (let ((gnus-treatment-function-alist
5774 '((gnus-treat-highlight-headers
5775 gnus-article-highlight-headers))))
5776 (gnus-treat-article 'head)))))
5778 (if (window-live-p window)
5779 (select-window window)))
5782 (defun gnus-article-goto-part (n)
5783 "Go to MIME part N."
5784 (when gnus-break-pages
5788 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5789 ;; There may be header buttons.
5790 (text-property-any (point-min) (point) 'gnus-part n)))
5791 part handle end next handles)
5794 (if (setq handle (get-text-property start 'gnus-data))
5796 ;; Go to the displayed subpart, assuming this is
5797 ;; multipart/alternative.
5800 (while (and (not handle)
5803 (setq next (text-property-not-all part end
5806 handle (get-text-property part 'gnus-data))
5807 (push (cons handle part) handles)
5808 (unless (mm-handle-displayed-p handle)
5810 part (text-property-any part end 'gnus-data nil))))
5812 ;; No subpart is displayed, so we find preferred one.
5814 (cdr (assq (mm-preferred-alternative
5815 (nreverse (mapcar 'car handles)))
5818 (goto-char (1+ part))
5820 (when gnus-break-pages
5821 (gnus-narrow-to-page))))
5823 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5824 (let ((gnus-tmp-name
5825 (or (mm-handle-filename handle)
5826 (mail-content-type-get (mm-handle-type handle) 'url)
5828 (gnus-tmp-type (mm-handle-media-type handle))
5829 (gnus-tmp-description (or (mm-handle-description handle) ""))
5831 (if (if displayed (car displayed)
5832 (mm-handle-displayed-p handle))
5834 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5836 gnus-tmp-type-long b e)
5837 (when (string-match ".*/" gnus-tmp-name)
5838 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5839 (setq gnus-tmp-type-long (concat gnus-tmp-type
5840 (and (not (equal gnus-tmp-name ""))
5841 (concat "; " gnus-tmp-name))))
5842 (unless (equal gnus-tmp-description "")
5843 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5846 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5847 `(keymap ,gnus-mime-button-map
5848 gnus-callback gnus-mm-display-part
5849 gnus-part ,gnus-tmp-id
5850 article-type annotation
5854 ;; Exclude a newline.
5857 (when gnus-article-button-face
5858 (gnus-overlay-put (gnus-make-overlay b e nil t)
5859 'face gnus-article-button-face))
5860 (widget-convert-button
5863 :action 'gnus-widget-press-button
5864 :button-keymap gnus-mime-button-map
5867 ;; Needed to properly clear the message due to a bug in
5868 ;; wid-edit (XEmacs only).
5869 (if (boundp 'help-echo-owns-message)
5870 (setq help-echo-owns-message t))
5872 "%S: %s the MIME part; %S: more options"
5873 (aref gnus-mouse-2 0)
5874 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5876 (aref gnus-down-mouse-3 0))))))
5878 (defun gnus-widget-press-button (elems el)
5879 (goto-char (widget-get elems :from))
5880 (gnus-article-press-button))
5882 (defvar gnus-displaying-mime nil)
5884 (defun gnus-display-mime (&optional ihandles)
5885 "Display the MIME parts."
5887 (save-selected-window
5888 (let ((window (get-buffer-window gnus-article-buffer))
5891 (select-window window)
5892 ;; We have to do this since selecting the window
5893 ;; may change the point. So we set the window point.
5894 (set-window-point window point)))
5895 (let ((handles ihandles)
5896 (inhibit-read-only t)
5899 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5900 (when gnus-article-emulate-mime
5901 (mm-uu-dissect-text-parts handles)))
5902 (gnus-article-emulate-mime
5903 (setq handles (mm-uu-dissect))))
5904 (when (and (not ihandles)
5905 (not gnus-displaying-mime))
5906 ;; Top-level call; we clean up.
5907 (when gnus-article-mime-handles
5908 (mm-destroy-parts gnus-article-mime-handles)
5909 (setq gnus-article-mime-handle-alist nil));; A trick.
5910 (setq gnus-article-mime-handles handles)
5911 ;; We allow users to glean info from the handles.
5912 (when gnus-article-mime-part-function
5913 (gnus-mime-part-function handles)))
5915 (or (not (stringp (car handles)))
5918 (when (and (not ihandles)
5919 (not gnus-displaying-mime))
5920 ;; Clean up for mime parts.
5922 (delete-region (point) (point-max)))
5923 (let ((gnus-displaying-mime t))
5924 (gnus-mime-display-part handles)))
5927 (narrow-to-region (point) (point-max))
5928 (gnus-treat-article nil 1 1 "text/plain")
5931 ;; Highlight the headers.
5935 (narrow-to-region (point-min) (point))
5936 (gnus-article-save-original-date
5937 (gnus-treat-article 'head)))))))
5938 ;; Cope with broken MIME messages.
5939 (goto-char (point-max))
5943 (defcustom gnus-mime-display-multipart-as-mixed nil
5944 "Display \"multipart\" parts as \"multipart/mixed\".
5946 If t, it overrides nil values of
5947 `gnus-mime-display-multipart-alternative-as-mixed' and
5948 `gnus-mime-display-multipart-related-as-mixed'."
5949 :group 'gnus-article-mime
5952 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5953 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5955 :group 'gnus-article-mime
5958 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5959 "Display \"multipart/related\" parts as \"multipart/mixed\".
5961 If displaying \"text/html\" is discouraged \(see
5962 `mm-discouraged-alternatives'\) images or other material inside a
5963 \"multipart/related\" part might be overlooked when this variable is nil."
5965 :group 'gnus-article-mime
5968 (defcustom gnus-mime-display-attachment-buttons-in-header t
5969 "Add attachment buttons in the end of the header of an article.
5970 Since MIME attachments tend to be put at the end of an article, we may
5971 overlook them if there is a huge body. This option offers you a copy
5972 of all non-inlinable MIME parts as buttons shown in front of an article.
5973 If nil, don't show those extra buttons."
5975 :group 'gnus-article-mime
5978 (defun gnus-mime-display-part (handle)
5980 ;; Maybe a broken MIME message.
5983 ((not (stringp (car handle)))
5984 (gnus-mime-display-single handle))
5985 ;; User-defined multipart
5986 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5987 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5989 ;; multipart/alternative
5990 ((and (equal (car handle) "multipart/alternative")
5991 (not (or gnus-mime-display-multipart-as-mixed
5992 gnus-mime-display-multipart-alternative-as-mixed)))
5993 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5994 (push (cons id handle) gnus-article-mime-handle-alist)
5995 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5996 ;; multipart/related
5997 ((and (equal (car handle) "multipart/related")
5998 (not (or gnus-mime-display-multipart-as-mixed
5999 gnus-mime-display-multipart-related-as-mixed)))
6000 (gnus-mime-display-part (cadr handle)))
6001 ((equal (car handle) "multipart/signed")
6002 (gnus-add-wash-type 'signed)
6003 (gnus-mime-display-security handle))
6004 ((equal (car handle) "multipart/encrypted")
6005 (gnus-add-wash-type 'encrypted)
6006 (gnus-mime-display-security handle))
6007 ;; Other multiparts are handled like multipart/mixed.
6009 (gnus-mime-display-mixed (cdr handle)))))
6011 (defun gnus-mime-part-function (handles)
6012 (if (stringp (car handles))
6013 (mapcar 'gnus-mime-part-function (cdr handles))
6014 (funcall gnus-article-mime-part-function handles)))
6016 (defun gnus-mime-display-mixed (handles)
6017 (mapcar 'gnus-mime-display-part handles))
6019 (defun gnus-mime-display-single (handle)
6020 (let ((type (mm-handle-media-type handle))
6021 (ignored gnus-ignored-mime-types)
6027 (when (string-match (pop ignored) type)
6028 (throw 'ignored nil)))
6029 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6030 (with-current-buffer gnus-summary-buffer
6031 gnus-inhibit-images)
6032 gnus-inhibit-images)
6033 (string-match "\\`image/" type)))
6034 (setq not-attachment
6035 (and (not (mm-inline-override-p handle))
6036 (or (not (mm-handle-disposition handle))
6037 (equal (car (mm-handle-disposition handle))
6039 (mm-attachment-override-p handle))))
6040 (mm-automatic-display-p handle)
6042 (mm-inlinable-p handle)
6043 (mm-inlined-p handle))
6044 (mm-automatic-external-display-p type)))
6046 (when (equal (mm-handle-media-supertype handle) "text")
6048 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6051 (setq id (1+ (length gnus-article-mime-handle-alist)))
6052 (push (cons id handle) gnus-article-mime-handle-alist))
6054 (equal (mm-handle-media-supertype handle) "message"))
6057 (cond ((not (bolp)) 2)
6058 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6060 (when (or (not display)
6061 (not (gnus-unbuttonized-mime-type-p type))
6062 (eq id gnus-mime-buttonized-part-id))
6063 (gnus-insert-mime-button
6064 handle id (list (or display (and not-attachment text)))))
6068 (let ((mail-parse-charset gnus-newsgroup-charset)
6069 (mail-parse-ignored-charsets
6070 (save-excursion (condition-case ()
6071 (set-buffer gnus-summary-buffer)
6073 gnus-newsgroup-ignored-charsets)))
6074 (gnus-bind-safe-url-regexp (mm-display-part handle t))))
6075 ((and text not-attachment)
6076 (mm-display-inline handle)))
6077 (goto-char (point-max))
6078 (if (string-match "\\`image/" type)
6079 (gnus-article-insert-newline)
6081 (= (skip-chars-backward "\n") -1)
6083 (gnus-article-insert-newline)
6084 (put-text-property (point) (point-max) 'gnus-undeletable t))
6085 (goto-char (point-max)))
6089 (narrow-to-region beg (point))
6090 (if (eq handle gnus-article-mime-handles)
6091 ;; The format=flowed case.
6092 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6093 ;; Don't count signature parts that are never displayed.
6094 ;; The part number should be re-calculated supposing this
6095 ;; might be a message/rfc822 part.
6097 (dolist (part gnus-article-mime-handles)
6098 (unless (or (stringp part)
6099 (equal (car (mm-handle-type part))
6100 "application/pgp-signature"))
6101 (push part handles)))
6103 nil (length (memq handle handles)) (length handles)
6104 (mm-handle-media-type handle)))))))))))
6106 (defun gnus-unbuttonized-mime-type-p (type)
6107 "Say whether TYPE is to be unbuttonized."
6108 (unless gnus-inhibit-mime-unbuttonizing
6110 (let ((types gnus-unbuttonized-mime-types))
6112 (when (string-match (pop types) type)
6113 (throw 'found t)))))
6115 (let ((types gnus-buttonized-mime-types))
6117 (when (string-match (pop types) type)
6118 (throw 'found t)))))))))
6120 (defun gnus-article-insert-newline ()
6121 "Insert a newline, but mark it as undeletable."
6122 (gnus-put-text-property
6123 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6125 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6126 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6129 handle (inhibit-read-only t) from props begend not-pref)
6130 (save-window-excursion
6133 (narrow-to-region (car ibegend)
6136 (goto-char (car ibegend))
6139 (delete-region (point-min) (point-max))
6140 (mm-remove-parts handles))
6141 (setq begend (list (point-marker)))
6143 (unless (setq not-pref (cadr (member preferred ihandles)))
6144 (setq not-pref (car ihandles)))
6147 (not (gnus-unbuttonized-mime-type-p
6148 "multipart/alternative")))
6149 (gnus-add-text-properties
6152 (insert (format "%d. " id))
6156 (unless ,(not ibegend)
6157 (setq gnus-article-mime-handle-alist
6158 ',gnus-article-mime-handle-alist))
6159 (gnus-mime-display-alternative
6160 ',ihandles ',not-pref ',begend ,id))
6161 keymap ,gnus-mime-button-map
6162 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6163 face ,gnus-article-button-face
6165 article-type multipart
6167 (widget-convert-button 'link from (point)
6168 :action 'gnus-widget-press-button
6169 :button-keymap gnus-widget-button-keymap)
6171 (while (setq handle (pop handles))
6172 (gnus-add-text-properties
6175 (insert (format "(%c) %-18s"
6176 (if (equal handle preferred) ?* ? )
6177 (mm-handle-media-type handle)))
6181 (unless ,(not ibegend)
6182 (setq gnus-article-mime-handle-alist
6183 ',gnus-article-mime-handle-alist))
6184 (gnus-mime-display-alternative
6185 ',ihandles ',handle ',begend ,id))
6186 keymap ,gnus-mime-button-map
6187 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6188 face ,gnus-article-button-face
6192 (widget-convert-button 'link from (point)
6193 :action 'gnus-widget-press-button
6194 :button-keymap gnus-widget-button-keymap)
6198 (if (stringp (car preferred))
6199 (gnus-display-mime preferred)
6200 (let ((mail-parse-charset gnus-newsgroup-charset)
6201 (mail-parse-ignored-charsets
6202 (with-current-buffer gnus-summary-buffer
6203 gnus-newsgroup-ignored-charsets)))
6204 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6208 (narrow-to-region (car begend) (point-max))
6210 nil (length gnus-article-mime-handle-alist)
6211 (gnus-article-mime-total-parts)
6212 (mm-handle-media-type preferred))))))
6213 (goto-char (point-max))
6214 (setcdr begend (point-marker)))))
6217 ;; Redraw attachment buttons in the header.
6218 (when gnus-mime-display-attachment-buttons-in-header
6219 (gnus-mime-buttonize-attachments-in-header)))
6221 (defconst gnus-article-wash-status-strings
6222 (let ((alist '((cite "c" "Possible hidden citation text"
6223 " " "All citation text visible")
6224 (headers "h" "Hidden headers"
6225 " " "All headers visible.")
6226 (pgp "p" "Encrypted or signed message status hidden"
6227 " " "No hidden encryption nor digital signature status")
6228 (signature "s" "Signature has been hidden"
6229 " " "Signature is visible")
6230 (overstrike "o" "Overstrike (^H) characters applied"
6231 " " "No overstrike characters applied")
6232 (emphasis "e" "/*_Emphasis_*/ characters applied"
6233 " " "No /*_emphasis_*/ characters applied")))
6235 (dolist (entry alist result)
6236 (let ((key (nth 0 entry))
6237 (on (copy-sequence (nth 1 entry)))
6238 (on-help (nth 2 entry))
6239 (off (copy-sequence (nth 3 entry)))
6240 (off-help (nth 4 entry)))
6241 (put-text-property 0 1 'help-echo on-help on)
6242 (put-text-property 0 1 'help-echo off-help off)
6243 (push (list key on off) result))))
6244 "Alist of strings describing wash status in the mode line.
6245 Each entry has the form (KEY ON OF), where the KEY is a symbol
6246 representing the particular washing function, ON is the string to use
6247 in the article mode line when the washing function is active, and OFF
6248 is the string to use when it is inactive.")
6250 (defun gnus-article-wash-status-entry (key value)
6251 (let ((entry (assoc key gnus-article-wash-status-strings)))
6252 (if value (nth 1 entry) (nth 2 entry))))
6254 (defun gnus-article-wash-status ()
6255 "Return a string which display status of article washing."
6256 (with-current-buffer gnus-article-buffer
6257 (let ((cite (memq 'cite gnus-article-wash-types))
6258 (headers (memq 'headers gnus-article-wash-types))
6259 (boring (memq 'boring-headers gnus-article-wash-types))
6260 (pgp (memq 'pgp gnus-article-wash-types))
6261 (pem (memq 'pem gnus-article-wash-types))
6262 (signed (memq 'signed gnus-article-wash-types))
6263 (encrypted (memq 'encrypted gnus-article-wash-types))
6264 (signature (memq 'signature gnus-article-wash-types))
6265 (overstrike (memq 'overstrike gnus-article-wash-types))
6266 (emphasis (memq 'emphasis gnus-article-wash-types)))
6268 (gnus-article-wash-status-entry 'cite cite)
6269 (gnus-article-wash-status-entry 'headers (or headers boring))
6270 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6271 (gnus-article-wash-status-entry 'signature signature)
6272 (gnus-article-wash-status-entry 'overstrike overstrike)
6273 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6275 (defun gnus-add-wash-type (type)
6276 "Add a washing of TYPE to the current status."
6277 (add-to-list 'gnus-article-wash-types type))
6279 (defun gnus-delete-wash-type (type)
6280 "Add a washing of TYPE to the current status."
6281 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6283 (defun gnus-add-image (category image)
6284 "Add IMAGE of CATEGORY to the list of displayed images."
6285 (let ((entry (assq category gnus-article-image-alist)))
6287 (setq entry (list category))
6288 (push entry gnus-article-image-alist))
6289 (nconc entry (list image))))
6291 (defun gnus-delete-images (category)
6292 "Delete all images in CATEGORY."
6293 (let ((entry (assq category gnus-article-image-alist)))
6294 (dolist (image (cdr entry))
6295 (gnus-remove-image image category))
6296 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6297 (gnus-delete-wash-type category)))
6299 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6301 (defun gnus-article-maybe-hide-headers ()
6302 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6303 Provided for backwards compatibility."
6304 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6305 (not (with-current-buffer gnus-summary-buffer
6306 gnus-have-all-headers)))
6307 (not gnus-inhibit-hiding))
6308 (gnus-article-hide-headers)))
6310 (declare-function shr-put-image "shr" (data alt &optional flags))
6312 (defun gnus-shr-put-image (data alt &optional flags)
6313 "Put image DATA with a string ALT. Enable image to be deleted."
6314 (let ((image (if flags
6315 (shr-put-image data (propertize (or alt "*")
6316 'gnus-image-category 'shr)
6318 ;; Old `shr-put-image' doesn't take the optional `flags'
6320 (shr-put-image data (propertize (or alt "*")
6321 'gnus-image-category 'shr)))))
6323 (gnus-add-image 'shr image))))
6325 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6326 "Show attachments as buttons in the end of the header of an article.
6327 This function toggles the display when called interactively. Note that
6328 buttons to be added to the header are only the ones that aren't inlined
6329 in the body. Use `gnus-header-face-alist' to highlight buttons."
6330 (interactive (list t))
6331 (gnus-with-article-buffer
6333 ;; Function that returns a flattened version of
6334 ;; `gnus-article-mime-handle-alist'.
6336 (&optional alist id all)
6338 (let ((i 1) newid flat)
6339 (dolist (handle alist flat)
6340 (setq newid (append id (list i))
6342 (if (stringp (car handle))
6343 (setq flat (nconc flat (flattened-alist (cdr handle)
6345 (delq (rassq handle all) all)
6346 (setq flat (nconc flat (list (cons newid handle)))))))
6347 (let ((flat (list nil)))
6348 ;; Assume that elements of `gnus-article-mime-handle-alist'
6349 ;; are in the decreasing order, but unnumbered subsidiaries
6350 ;; in each element are in the increasing order.
6351 (dolist (handle (reverse gnus-article-mime-handle-alist))
6352 (if (stringp (cadr handle))
6353 (setq flat (nconc flat (flattened-alist (cddr handle)
6356 (delq (rassq (cdr handle) flat) flat)
6357 (setq flat (nconc flat (list (cons (list (car handle))
6359 (setq flat (cdr flat))
6360 (mapc (lambda (handle)
6362 ;; This is a hidden (i.e. unnumbered) handle.
6365 (1+ (caar gnus-article-mime-handle-alist)))
6366 (push handle gnus-article-mime-handle-alist))
6367 (setcar handle (caar handle))))
6370 (let ((case-fold-search t) buttons st handle)
6374 (article-narrow-to-head)
6375 ;; Header buttons exist?
6376 (while (and (not buttons)
6377 (re-search-forward "^attachments?:[\n ]+" nil t))
6378 (when (get-char-property (match-end 0)
6379 'gnus-button-attachment-extra)
6380 (setq buttons (match-beginning 0))))
6383 ;; Delete header buttons.
6384 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6387 (unless (and interactive buttons)
6390 (dolist (handle (flattened-alist))
6391 (when (and (not (stringp (cadr handle)))
6392 (or (equal (car (mm-handle-disposition
6395 (not (and (mm-inlinable-p (cdr handle))
6396 (mm-inlined-p (cdr handle))))))
6397 (push handle buttons)))
6399 ;; Add header buttons.
6402 (narrow-to-region (point) (point))
6403 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6404 (dolist (button (nreverse buttons))
6407 (mm-handle-set-undisplayer
6408 (setq handle (copy-sequence (cdr button))) nil)
6409 (gnus-insert-mime-button handle (car button))
6410 (skip-chars-backward "\t\n ")
6411 (delete-region (point) (point-max))
6412 (when (> (current-column) (window-width))
6417 (dolist (ovl (gnus-overlays-in (point-min) (point)))
6418 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
6419 (gnus-overlay-put ovl 'face nil))
6420 (let ((gnus-treatment-function-alist
6421 '((gnus-treat-highlight-headers
6422 gnus-article-highlight-headers))))
6423 (gnus-treat-article 'head))))))))))
6427 (defun gnus-output-to-file (file-name)
6428 "Append the current article to a file named FILE-NAME.
6429 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6430 text and used as the value of the coding cookie which is added to the
6431 top of a file. Otherwise, this function saves a raw article without
6433 (let* ((artbuf (current-buffer))
6434 (file-name-coding-system nnmail-pathname-coding-system)
6435 (coding gnus-article-save-coding-system)
6436 (coding-system-for-read (if coding
6437 nil ;; Rely on the coding cookie.
6438 mm-text-coding-system))
6439 (coding-system-for-write (or coding
6440 mm-text-coding-system-for-write
6441 mm-text-coding-system))
6442 (exists (file-exists-p file-name)))
6445 (insert-file-contents file-name)
6446 (goto-char (point-min))
6447 ;; Remove the existing coding cookie.
6448 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6449 (delete-region (match-beginning 0) (match-end 0))))
6450 (goto-char (point-max))
6451 (insert-buffer-substring artbuf)
6452 ;; Append newline at end of the buffer as separator, and then
6454 (goto-char (point-max))
6457 ;; If the coding system is not suitable to encode the text,
6458 ;; ask a user for a proper one.
6459 (when (fboundp 'select-safe-coding-system)
6460 (setq coding (coding-system-base
6461 (save-window-excursion
6462 (select-safe-coding-system (point-min) (point-max)
6464 (setq coding-system-for-write
6465 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6467 (goto-char (point-min))
6468 ;; Add the coding cookie.
6469 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6470 coding-system-for-write)))
6473 (write-region (point-min) (point-max) file-name nil 'no-message)
6474 (message "Appended to %s" file-name))
6475 (write-region (point-min) (point-max) file-name))))
6478 (defun gnus-narrow-to-page (&optional arg)
6479 "Narrow the article buffer to a page.
6480 If given a numerical ARG, move forward ARG pages."
6482 (setq arg (if arg (prefix-numeric-value arg) 0))
6483 (with-current-buffer gnus-article-buffer
6485 ;; Remove any old next/prev buttons.
6486 (when (gnus-visual-p 'page-marker)
6487 (let ((inhibit-read-only t))
6488 (gnus-remove-text-with-property 'gnus-prev)
6489 (gnus-remove-text-with-property 'gnus-next)))
6491 (when (save-excursion
6493 (if (re-search-backward page-delimiter nil 'move (abs arg))
6495 (setq nd (match-beginning 0)
6497 (when (re-search-backward page-delimiter nil t)
6498 (setq st (match-end 0))))
6499 (when (re-search-forward page-delimiter nil t)
6500 (setq nd (match-beginning 0)
6503 (if (re-search-forward page-delimiter nil 'move arg)
6505 (setq st (match-end 0)
6507 (when (re-search-forward page-delimiter nil t)
6508 (setq nd (match-beginning 0))))
6509 (when (re-search-backward page-delimiter nil t)
6510 (setq st (match-end 0)
6513 (when (re-search-backward page-delimiter nil t)
6514 (goto-char (setq st (match-end 0))))
6515 (when (re-search-forward page-delimiter nil t)
6516 (setq nd (match-beginning 0)))
6518 (setq gnus-page-broken t)
6519 (when pt (goto-char pt))
6520 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6521 (when (gnus-visual-p 'page-marker)
6525 (gnus-insert-next-page-button))
6528 (gnus-insert-prev-page-button))))))))
6530 ;; Article mode commands
6532 (defun gnus-article-goto-next-page ()
6533 "Show the next page of the article."
6535 (when (gnus-article-next-page)
6536 (goto-char (point-min))
6537 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6540 (defun gnus-article-goto-prev-page ()
6541 "Show the previous page of the article."
6543 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6544 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6545 (gnus-article-prev-page nil)))
6547 ;; This is cleaner but currently breaks `gnus-pick-mode':
6549 ;; (defun gnus-article-goto-next-page ()
6550 ;; "Show the next page of the article."
6552 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6553 ;; (gnus-summary-next-page)))
6555 ;; (defun gnus-article-goto-prev-page ()
6556 ;; "Show the next page of the article."
6558 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6559 ;; (gnus-summary-prev-page)))
6561 (defun gnus-article-next-page (&optional lines)
6562 "Show the next page of the current article.
6563 If end of article, return non-nil. Otherwise return nil.
6564 Argument LINES specifies lines to be scrolled up."
6566 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6567 (if (and (not (and gnus-article-over-scroll
6568 (> (count-lines (window-start) (point-max))
6569 (if (featurep 'xemacs)
6570 (or lines (1- (window-height)))
6571 (+ (or lines (1- (window-height))) scroll-margin)))))
6574 (and (pos-visible-in-window-p) ;Not continuation line.
6575 (>= (point) (point-max)))))
6576 ;; Nothing in this page.
6577 (if (or (not gnus-page-broken)
6582 (eobp)))) ;Real end-of-buffer?
6584 (when gnus-article-over-scroll
6585 (gnus-article-next-page-1 lines))
6587 (gnus-narrow-to-page 1) ;Go to next page.
6589 ;; More in this page.
6590 (gnus-article-next-page-1 lines)
6593 (defun gnus-article-beginning-of-window ()
6594 "Move point to the beginning of the window.
6595 In Emacs, the point is placed at the line number which `scroll-margin'
6597 (if (featurep 'xemacs)
6598 (move-to-window-line 0)
6599 ;; There is an obscure bug in Emacs that makes it impossible to
6600 ;; scroll past big pictures in the article buffer. Try to fix
6601 ;; this by adding a sanity check by counting the lines visible.
6602 (when (> (count-lines (window-start) (window-end)) 30)
6603 (move-to-window-line
6604 (min (max 0 scroll-margin)
6605 (max 1 (- (window-height)
6606 (if mode-line-format 1 0)
6607 (if header-line-format 1 0)
6610 (defun gnus-article-next-page-1 (lines)
6612 (let ((scroll-in-place nil)
6613 (auto-window-vscroll nil))
6616 ;; Long lines may cause an end-of-buffer error.
6617 (goto-char (point-max))))
6618 (gnus-article-beginning-of-window))
6620 (defun gnus-article-prev-page (&optional lines)
6621 "Show previous page of current article.
6622 Argument LINES specifies lines to be scrolled down."
6624 (move-to-window-line 0)
6625 (if (and gnus-page-broken
6627 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6629 (gnus-narrow-to-page -1) ;Go to previous page.
6630 (goto-char (point-max))
6631 (recenter (if gnus-article-over-scroll
6633 (max (if (featurep 'xemacs)
6635 (+ lines scroll-margin))
6637 (- (window-height) 2))
6641 (let ((scroll-in-place nil))
6642 (scroll-down lines))
6643 (beginning-of-buffer
6644 (goto-char (point-min))))
6645 (gnus-article-beginning-of-window))))
6647 (defun gnus-article-only-boring-p ()
6648 "Decide whether there is only boring text remaining in the article.
6649 Something \"interesting\" is a word of at least two letters that does
6650 not have a face in `gnus-article-boring-faces'."
6651 (when (and gnus-article-skip-boring
6652 (boundp 'gnus-article-boring-faces)
6653 (symbol-value 'gnus-article-boring-faces))
6655 (let ((inhibit-point-motion-hooks t))
6657 (while (re-search-forward "\\b\\w\\w" nil t)
6659 (when (not (gnus-intersection
6660 (gnus-faces-at (point))
6661 (symbol-value 'gnus-article-boring-faces)))
6662 (throw 'only-boring nil)))
6663 (throw 'only-boring t))))))
6665 (defun gnus-article-refer-article ()
6666 "Read article specified by message-id around point."
6669 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6670 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6671 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6672 (let ((msg-id (concat "<" (match-string 0) ">")))
6673 (set-buffer gnus-summary-buffer)
6674 (gnus-summary-refer-article msg-id))
6675 (error "No references around point"))))
6677 (defun gnus-article-show-summary ()
6678 "Reconfigure windows to show summary buffer."
6680 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6681 (error "There is no summary buffer for this article buffer")
6682 (gnus-article-set-globals)
6683 (gnus-configure-windows 'article)
6684 (gnus-summary-goto-subject gnus-current-article)
6685 (gnus-summary-position-point)))
6687 (defun gnus-article-describe-briefly ()
6688 "Describe article mode commands briefly."
6690 (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")))
6692 (defun gnus-article-check-buffer ()
6693 "Beep if not in an article buffer."
6694 (unless (derived-mode-p 'gnus-article-mode)
6695 (error "Command invoked outside of a Gnus article buffer")))
6697 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6698 "Read a summary buffer key sequence and execute it from the article buffer."
6700 (gnus-article-check-buffer)
6702 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6703 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6704 "=" "^" "\M-^" "|"))
6706 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6707 "An" "Ap" [?A (meta return)] [?A delete]))
6711 '("n" "Gn" "p" "Gp"))
6713 (with-current-buffer gnus-article-current-summary
6714 (let (gnus-pick-mode)
6715 (setq unread-command-events (nconc unread-command-events
6716 (list (or key last-command-event)))
6717 keys (if (featurep 'xemacs)
6718 (events-to-keys (read-key-sequence nil t))
6719 (read-key-sequence nil t)))))
6724 ((eq (aref keys (1- (length keys))) ?\C-h)
6725 (gnus-article-describe-bindings (substring keys 0 -1)))
6726 ((or (member keys nosaves)
6727 (member keys nosave-but-article)
6728 (member keys nosave-in-article))
6730 (save-window-excursion
6731 (pop-to-buffer gnus-article-current-summary)
6732 ;; We disable the pick minor mode commands.
6733 (let (gnus-pick-mode)
6734 (setq func (key-binding keys t))))
6738 (unless (member keys nosave-in-article)
6739 (set-buffer gnus-article-current-summary))
6740 (when (and (symbolp func)
6741 (get func 'disabled))
6742 (error "Function %s disabled" func))
6743 (call-interactively func)
6744 (setq new-sum-point (point)))
6745 (when (member keys nosave-but-article)
6746 (pop-to-buffer gnus-article-buffer))))
6748 ;; These commands should restore window configuration.
6749 (let ((obuf (current-buffer))
6750 (owin (current-window-configuration))
6751 win func in-buffer selected new-sum-start new-sum-hscroll err)
6752 (cond (not-restore-window
6753 (pop-to-buffer gnus-article-current-summary)
6754 (setq win (selected-window)))
6755 ((setq win (get-buffer-window gnus-article-current-summary))
6756 (select-window win))
6758 (let ((summary-buffer gnus-article-current-summary))
6759 (gnus-configure-windows 'article)
6760 (unless (setq win (get-buffer-window summary-buffer 'visible))
6761 (let ((gnus-buffer-configuration
6762 '((article ((vertical 1.0
6763 (summary 0.25 point)
6765 (gnus-configure-windows 'article))
6766 (setq win (get-buffer-window summary-buffer 'visible)))
6767 (gnus-select-frame-set-input-focus (window-frame win))
6768 (select-window win))))
6769 (setq in-buffer (current-buffer))
6770 ;; We disable the pick minor mode commands.
6771 (setq func (let (gnus-pick-mode)
6772 (key-binding keys t)))
6773 (when (get func 'disabled)
6774 (error "Function %s disabled" func))
6777 (condition-case code
6779 (call-interactively func)
6785 (when (eq win (selected-window))
6786 (setq new-sum-point (point)
6787 new-sum-start (window-start win)
6788 new-sum-hscroll (window-hscroll win)))
6789 (when (or (eq in-buffer (current-buffer))
6790 (when (eq obuf (current-buffer))
6791 (set-buffer in-buffer)
6793 (setq selected (gnus-summary-select-article))
6795 (unless not-restore-window
6796 (set-window-configuration owin))
6797 (when (and (eq selected 'old)
6799 (set-window-start (get-buffer-window (current-buffer))
6801 (set-window-point (get-buffer-window (current-buffer))
6802 (if (article-goto-body)
6805 (when (and (not not-restore-window)
6808 (with-current-buffer (window-buffer win)
6809 (derived-mode-p 'gnus-summary-mode)))
6810 (set-window-point win new-sum-point)
6811 (set-window-start win new-sum-start)
6812 (set-window-hscroll win new-sum-hscroll))))
6813 (set-window-configuration owin)
6815 (signal (car err) (cdr err))
6818 (defun gnus-article-read-summary-send-keys ()
6820 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6821 (gnus-article-read-summary-keys)))
6823 (defun gnus-article-describe-key (key)
6824 "Display documentation of the function invoked by KEY.
6825 KEY is a string or a vector."
6826 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6827 (read-key-sequence "Describe key: "))))
6828 (gnus-article-check-buffer)
6829 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6830 gnus-article-read-summary-send-keys))
6831 (with-current-buffer gnus-article-current-summary
6832 (setq unread-command-events
6833 (if (featurep 'xemacs)
6835 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6836 (list 'meta (- x 128))
6839 (let ((cursor-in-echo-area t)
6841 (describe-key (read-key-sequence nil t))))
6842 (describe-key key)))
6844 (defun gnus-article-describe-key-briefly (key &optional insert)
6845 "Display documentation of the function invoked by KEY.
6846 KEY is a string or a vector."
6847 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6848 (read-key-sequence "Describe key: "))
6849 current-prefix-arg))
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-briefly (read-key-sequence nil t) insert)))
6864 (describe-key-briefly key insert)))
6866 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6867 (defvar gnus-agent-summary-mode)
6868 (defvar gnus-draft-mode)
6869 (defvar help-xref-stack-item)
6871 (defun gnus-article-describe-bindings (&optional prefix)
6872 "Show a list of all defined keys, and their definitions.
6873 The optional argument PREFIX, if non-nil, should be a key sequence;
6874 then we display only bindings that start with that prefix."
6876 (gnus-article-check-buffer)
6877 (let ((keymap (copy-keymap gnus-article-mode-map))
6878 (map (copy-keymap gnus-article-send-map))
6879 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6881 (define-key keymap "S" map)
6882 (define-key map [t] nil)
6883 (with-current-buffer gnus-article-current-summary
6886 (if (setq parent (keymap-parent gnus-article-mode-map))
6888 (setq parent (copy-keymap parent))
6889 (set-keymap-parent parent (current-local-map)))
6890 (current-local-map)))
6891 (set-keymap-parent map (key-binding "S"))
6892 (let (key def gnus-pick-mode)
6894 (setq key (pop sumkeys))
6895 (cond ((and (vectorp key) (= (length key) 1)
6896 (consp (setq def (aref key 0)))
6897 (numberp (car def)) (numberp (cdr def)))
6898 (when (< (max (car def) (cdr def)) 128)
6902 (nreverse (gnus-uncompress-range def)))
6904 ((setq def (key-binding key))
6905 (unless (eq def 'undefined)
6906 (define-key keymap key def))))))
6907 (when (boundp 'gnus-agent-summary-mode)
6908 (setq agent gnus-agent-summary-mode))
6909 (when (boundp 'gnus-draft-mode)
6910 (setq draft gnus-draft-mode)))
6912 (use-local-map keymap)
6913 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6914 (set (make-local-variable 'gnus-draft-mode) draft)
6915 (describe-bindings prefix))
6916 (let ((item `((lambda (prefix)
6917 (with-current-buffer ,(current-buffer)
6918 (gnus-article-describe-bindings prefix)))
6920 ;; Loading `help-mode' here is necessary if `describe-bindings'
6921 ;; is replaced with something, e.g. `helm-descbinds'.
6922 (require 'help-mode)
6923 (with-current-buffer (let (help-xref-following) (help-buffer))
6924 (setq help-xref-stack-item item)))))
6926 (defun gnus-article-reply-with-original (&optional wide)
6927 "Start composing a reply mail to the current message.
6928 The text in the region will be yanked. If the region isn't active,
6929 the entire article will be yanked."
6931 (let ((article (cdr gnus-article-current))
6933 (if (not (gnus-region-active-p))
6934 (with-current-buffer gnus-summary-buffer
6935 (gnus-summary-reply (list (list article)) wide))
6936 (setq contents (buffer-substring (point) (mark t)))
6937 ;; Deactivate active regions.
6938 (when (and (boundp 'transient-mark-mode)
6939 transient-mark-mode)
6940 (setq mark-active nil))
6941 (with-current-buffer gnus-summary-buffer
6943 (list (list article contents)) wide)))))
6945 (defun gnus-article-wide-reply-with-original ()
6946 "Start composing a wide reply mail to the current message.
6947 The text in the region will be yanked. If the region isn't active,
6948 the entire article will be yanked."
6950 (gnus-article-reply-with-original t))
6952 (defun gnus-article-followup-with-original ()
6953 "Compose a followup to the current article.
6954 The text in the region will be yanked. If the region isn't active,
6955 the entire article will be yanked."
6957 (let ((article (cdr gnus-article-current))
6959 (if (not (gnus-region-active-p))
6960 (with-current-buffer gnus-summary-buffer
6961 (gnus-summary-followup (list (list article))))
6962 (setq contents (buffer-substring (point) (mark t)))
6963 ;; Deactivate active regions.
6964 (when (and (boundp 'transient-mark-mode)
6965 transient-mark-mode)
6966 (setq mark-active nil))
6967 (with-current-buffer gnus-summary-buffer
6968 (gnus-summary-followup
6969 (list (list article contents)))))))
6971 (defun gnus-article-hide (&optional arg force)
6972 "Hide all the gruft in the current article.
6973 This means that signatures, cited text and (some) headers will be
6975 If given a prefix, show the hidden text instead."
6976 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6977 (gnus-article-hide-headers arg)
6978 (gnus-article-hide-list-identifiers arg)
6979 (gnus-article-hide-citation-maybe arg force)
6980 (gnus-article-hide-signature arg))
6982 (defun gnus-check-group-server ()
6983 ;; Make sure the connection to the server is alive.
6984 (unless (gnus-server-opened
6985 (gnus-find-method-for-group gnus-newsgroup-name))
6986 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6987 (gnus-request-group gnus-newsgroup-name t)))
6990 (autoload 'nneething-get-file-name "nneething"))
6992 (defun gnus-request-article-this-buffer (article group)
6993 "Get an article and insert it into this buffer."
6994 (let (do-update-line sparse-header)
6998 (gnus-kill-all-overlays)
6999 (setq group (or group gnus-newsgroup-name))
7001 ;; Using `gnus-request-article' directly will insert the article into
7002 ;; `nntp-server-buffer' - so we'll save some time by not having to
7003 ;; copy it from the server buffer into the article buffer.
7005 ;; We only request an article by message-id when we do not have the
7006 ;; headers for it, so we'll have to get those.
7007 (when (stringp article)
7008 (gnus-read-header article))
7010 ;; If the article number is negative, that means that this article
7011 ;; doesn't belong in this newsgroup (possibly), so we find its
7012 ;; message-id and request it by id instead of number.
7013 (when (and (numberp article)
7015 (get-buffer gnus-summary-buffer)
7016 (gnus-buffer-exists-p gnus-summary-buffer))
7017 (with-current-buffer gnus-summary-buffer
7018 (let ((header (gnus-summary-article-header article)))
7021 ((memq article gnus-newsgroup-sparse)
7022 ;; This is a sparse gap article.
7023 (setq do-update-line article)
7024 (setq article (mail-header-id header))
7025 (setq sparse-header (gnus-read-header article))
7026 (setq gnus-newsgroup-sparse
7027 (delq article gnus-newsgroup-sparse)))
7029 ;; It's a real article.
7030 (setq article (mail-header-id header)))
7032 ;; It is an extracted pseudo-article.
7033 (setq article 'pseudo)
7034 (gnus-request-pseudo-article header))))
7036 (let ((method (gnus-find-method-for-group
7037 gnus-newsgroup-name)))
7038 (when (and (eq (car method) 'nneething)
7040 (let ((dir (nneething-get-file-name
7041 (mail-header-id header))))
7042 (when (and (stringp dir)
7043 (file-directory-p dir))
7044 (setq article 'nneething)
7045 (gnus-group-enter-directory dir))))))))
7048 ;; Refuse to select canceled articles.
7049 ((and (numberp article)
7051 (get-buffer gnus-summary-buffer)
7052 (gnus-buffer-exists-p gnus-summary-buffer)
7053 (eq (cdr (with-current-buffer gnus-summary-buffer
7054 (assq article gnus-newsgroup-reads)))
7055 gnus-canceled-mark))
7057 ;; We first check `gnus-original-article-buffer'.
7058 ((and (get-buffer gnus-original-article-buffer)
7060 (with-current-buffer gnus-original-article-buffer
7061 (and (equal (car gnus-original-article) group)
7062 (eq (cdr gnus-original-article) article))))
7063 ;; `insert-buffer-substring' would incorrectly use the
7064 ;; equivalent of string-make-multibyte which amount to decoding
7065 ;; with locale-coding-system, causing failure of
7066 ;; subsequent decoding.
7067 (insert (mm-string-to-multibyte
7068 (with-current-buffer gnus-original-article-buffer
7069 (buffer-substring (point-min) (point-max)))))
7071 ;; Check the backlog.
7072 ((and gnus-keep-backlog
7073 (gnus-backlog-request-article group article (current-buffer)))
7075 ;; Check asynchronous pre-fetch.
7076 ((gnus-async-request-fetched-article group article (current-buffer))
7077 (gnus-async-prefetch-next group article gnus-summary-buffer)
7078 (when (and (numberp article) gnus-keep-backlog)
7079 (gnus-backlog-enter-article group article (current-buffer)))
7082 ((and gnus-use-cache
7084 (gnus-cache-request-article article group))
7086 ;; Check the agent cache.
7087 ((gnus-agent-request-article article group)
7089 ;; Get the article and put into the article buffer.
7090 ((or (stringp article)
7092 (let ((gnus-override-method gnus-override-method)
7093 (methods (and (stringp article)
7094 (with-current-buffer gnus-summary-buffer
7095 (gnus-refer-article-methods))))
7096 (backend (car (gnus-find-method-for-group
7097 gnus-newsgroup-name)))
7099 (inhibit-read-only t))
7100 (when (and (null gnus-override-method)
7102 (setq gnus-override-method (pop methods)))
7105 (gnus-kill-all-overlays)
7106 (let ((gnus-newsgroup-name group))
7107 (gnus-check-group-server))
7109 ((gnus-request-article article group (current-buffer))
7110 (when (numberp article)
7111 (gnus-async-prefetch-next group article
7112 gnus-summary-buffer)
7113 (when gnus-keep-backlog
7114 (gnus-backlog-enter-article
7115 group article (current-buffer)))
7116 (when (and gnus-agent
7117 (gnus-agent-group-covered-p group))
7118 (gnus-agent-store-article article group)))
7119 (setq result 'article))
7121 (setq gnus-override-method (pop methods)))
7122 ((not (string-match "^400 "
7123 (nnheader-get-report backend)))
7124 ;; If we get 400 server disconnect, reconnect and
7125 ;; retry; otherwise, assume the article has expired.
7126 (setq result 'done))))
7127 (and (eq result 'article) 'article)))
7131 ;; Associate this article with the current summary buffer.
7132 (setq gnus-article-current-summary gnus-summary-buffer)
7134 ;; Take the article from the original article buffer
7135 ;; and place it in the buffer it's supposed to be in.
7136 (when (and (get-buffer gnus-article-buffer)
7137 (equal (buffer-name (current-buffer))
7138 (buffer-name (get-buffer gnus-article-buffer))))
7140 (if (get-buffer gnus-original-article-buffer)
7141 (set-buffer gnus-original-article-buffer)
7142 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7143 (buffer-disable-undo)
7144 (setq major-mode 'gnus-original-article-mode)
7145 (setq buffer-read-only t))
7146 (let ((inhibit-read-only t))
7148 (insert-buffer-substring gnus-article-buffer))
7149 (setq gnus-original-article (cons group article)))
7152 (run-hooks 'gnus-article-decode-hook)
7153 ;; Mark article as decoded or not.
7154 (setq gnus-article-decoded-p gnus-article-decode-hook))
7156 ;; Update sparse articles.
7157 (when (and do-update-line
7158 (or (numberp article)
7160 (let ((buf (current-buffer)))
7161 (set-buffer gnus-summary-buffer)
7162 (gnus-summary-update-article do-update-line sparse-header)
7163 (gnus-summary-goto-subject do-update-line nil t)
7164 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7166 (set-buffer buf))))))
7168 (defun gnus-block-private-groups (group)
7169 (if (or (gnus-news-group-p group)
7170 (gnus-member-of-valid 'global group))
7171 ;; Block nothing in news groups.
7173 ;; Block everything anywhere else.
7176 (defun gnus-blocked-images ()
7177 (if (functionp gnus-blocked-images)
7178 (funcall gnus-blocked-images gnus-newsgroup-name)
7179 gnus-blocked-images))
7185 (defcustom gnus-article-edit-mode-hook nil
7186 "Hook run in article edit mode buffers."
7187 :group 'gnus-article-various
7190 (defvar gnus-article-edit-done-function nil)
7192 (defvar gnus-article-edit-mode-map nil)
7194 ;; Should we be using derived.el for this?
7195 (unless gnus-article-edit-mode-map
7196 (setq gnus-article-edit-mode-map (make-keymap))
7197 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7199 (gnus-define-keys gnus-article-edit-mode-map
7200 "\C-c?" describe-mode
7201 "\C-c\C-c" gnus-article-edit-done
7202 "\C-c\C-k" gnus-article-edit-exit
7203 "\C-c\C-f\C-t" message-goto-to
7204 "\C-c\C-f\C-o" message-goto-from
7205 "\C-c\C-f\C-b" message-goto-bcc
7206 ;;"\C-c\C-f\C-w" message-goto-fcc
7207 "\C-c\C-f\C-c" message-goto-cc
7208 "\C-c\C-f\C-s" message-goto-subject
7209 "\C-c\C-f\C-r" message-goto-reply-to
7210 "\C-c\C-f\C-n" message-goto-newsgroups
7211 "\C-c\C-f\C-d" message-goto-distribution
7212 "\C-c\C-f\C-f" message-goto-followup-to
7213 "\C-c\C-f\C-m" message-goto-mail-followup-to
7214 "\C-c\C-f\C-k" message-goto-keywords
7215 "\C-c\C-f\C-u" message-goto-summary
7216 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7217 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7218 "\C-c\C-b" message-goto-body
7219 "\C-c\C-i" message-goto-signature
7221 "\C-c\C-t" message-insert-to
7222 "\C-c\C-n" message-insert-newsgroups
7223 "\C-c\C-o" message-sort-headers
7224 "\C-c\C-e" message-elide-region
7225 "\C-c\C-v" message-delete-not-region
7226 "\C-c\C-z" message-kill-to-signature
7227 "\M-\r" message-newline-and-reformat
7228 "\C-c\C-a" mml-attach-file
7229 "\C-a" message-beginning-of-line
7231 "\M-;" comment-region)
7233 (gnus-define-keys (gnus-article-edit-wash-map
7234 "\C-c\C-w" gnus-article-edit-mode-map)
7235 "f" gnus-article-edit-full-stops))
7238 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7240 ["Fetch To" message-insert-to t]
7241 ["Fetch Newsgroups" message-insert-newsgroups t]
7243 ["To" message-goto-to t]
7244 ["From" message-goto-from t]
7245 ["Subject" message-goto-subject t]
7246 ["Cc" message-goto-cc t]
7247 ["Reply-To" message-goto-reply-to t]
7248 ["Summary" message-goto-summary t]
7249 ["Keywords" message-goto-keywords t]
7250 ["Newsgroups" message-goto-newsgroups t]
7251 ["Followup-To" message-goto-followup-to t]
7252 ["Mail-Followup-To" message-goto-mail-followup-to t]
7253 ["Distribution" message-goto-distribution t]
7254 ["Body" message-goto-body t]
7255 ["Signature" message-goto-signature t]))
7257 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7258 "Major mode for editing articles.
7259 This is an extended text-mode.
7261 \\{gnus-article-edit-mode-map}"
7262 (make-local-variable 'gnus-article-edit-done-function)
7263 (make-local-variable 'gnus-prev-winconf)
7264 (set (make-local-variable 'font-lock-defaults)
7265 '(message-font-lock-keywords t))
7266 (set (make-local-variable 'mail-header-separator) "")
7267 (set (make-local-variable 'gnus-article-edit-mode) t)
7268 (easy-menu-add message-mode-field-menu message-mode-map)
7270 (setq buffer-read-only nil)
7271 (buffer-enable-undo)
7274 (defun gnus-article-edit (&optional force)
7275 "Edit the current article.
7276 This will have permanent effect only in mail groups.
7277 If FORCE is non-nil, allow editing of articles even in read-only
7280 (when (and (not force)
7281 (gnus-group-read-only-p))
7282 (error "The current newsgroup does not support article editing"))
7283 (gnus-article-date-original)
7284 (gnus-article-edit-article
7286 `(lambda (no-highlight)
7288 (gnus-summary-edit-article-done
7289 ,(or (mail-header-references gnus-current-headers) "")
7290 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7292 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7293 "Start editing the contents of the current article buffer."
7294 (let ((winconf (current-window-configuration)))
7295 (set-buffer gnus-article-buffer)
7296 (let ((message-auto-save-directory
7297 ;; Don't associate the article buffer with a draft file.
7299 (gnus-article-edit-mode))
7300 (funcall start-func)
7301 (set-buffer-modified-p nil)
7302 (gnus-configure-windows 'edit-article)
7303 (setq gnus-article-edit-done-function exit-func)
7304 (setq gnus-prev-winconf winconf)
7306 (gnus-message 6 "C-c C-c to end edits"))))
7308 (defun gnus-article-edit-done (&optional arg)
7309 "Update the article edits and exit."
7311 (let ((func gnus-article-edit-done-function)
7312 (buf (current-buffer))
7313 (start (window-start))
7315 (winconf gnus-prev-winconf))
7316 (widen) ;; Widen it in case that users narrowed the buffer.
7319 ;; The cache and backlog have to be flushed somewhat.
7320 (when gnus-keep-backlog
7321 (gnus-backlog-remove-article
7322 (car gnus-article-current) (cdr gnus-article-current)))
7323 ;; Flush original article as well.
7324 (gnus-flush-original-article-buffer)
7325 (when gnus-use-cache
7326 (gnus-cache-update-article
7327 (car gnus-article-current) (cdr gnus-article-current)))
7328 ;; We remove all text props from the article buffer.
7329 (kill-all-local-variables)
7330 (set-text-properties (point-min) (point-max) nil)
7332 (set-window-configuration winconf)
7334 (set-window-start (get-buffer-window buf) start)
7335 (set-window-point (get-buffer-window buf) (point)))
7336 (gnus-summary-show-article))
7338 (defun gnus-flush-original-article-buffer ()
7339 (when (get-buffer gnus-original-article-buffer)
7340 (with-current-buffer gnus-original-article-buffer
7341 (setq gnus-original-article nil))))
7343 (defun gnus-article-edit-exit ()
7344 "Exit the article editing without updating."
7346 (when (or (not (buffer-modified-p))
7347 (yes-or-no-p "Article modified; kill anyway? "))
7348 (let ((curbuf (current-buffer))
7350 (window-start (window-start)))
7352 (if (gnus-buffer-live-p gnus-original-article-buffer)
7353 (insert-buffer-substring gnus-original-article-buffer))
7354 (let ((winconf gnus-prev-winconf))
7355 (kill-all-local-variables)
7357 (set-window-configuration winconf)
7358 ;; Tippy-toe some to make sure that point remains where it was.
7359 (save-current-buffer
7361 (set-window-start (get-buffer-window (current-buffer)) window-start)
7363 (gnus-summary-show-article)))
7365 (defun gnus-article-edit-full-stops ()
7366 "Interactively repair spacing at end of sentences."
7369 (goto-char (point-min))
7370 (search-forward-regexp "^$" nil t)
7371 (let ((case-fold-search nil))
7372 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7375 ;;; Article highlights
7378 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7380 ;;; Internal Variables:
7382 (defcustom gnus-button-url-regexp
7384 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7385 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7386 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7387 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7388 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7392 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7393 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7394 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7395 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7397 "[" chars punct "]+" "[" chars "]"
7399 (concat ;; XEmacs 21.4 doesn't support POSIX.
7400 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7401 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7403 "Regular expression that matches URLs."
7405 :group 'gnus-article-buttons
7408 (defcustom gnus-button-valid-fqdn-regexp
7409 message-valid-fqdn-regexp
7410 "Regular expression that matches a valid FQDN."
7412 :group 'gnus-article-buttons
7415 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7416 (defcustom gnus-button-valid-localpart-regexp
7417 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7418 "Regular expression that matches a localpart of mail addresses or MIDs."
7420 :group 'gnus-article-buttons
7423 (defcustom gnus-button-man-handler 'manual-entry
7424 "Function to use for displaying man pages.
7425 The function must take at least one argument with a string naming the
7428 :type '(choice (function-item :tag "Man" manual-entry)
7429 (function-item :tag "Woman" woman)
7430 (function :tag "Other"))
7431 :group 'gnus-article-buttons)
7433 (defcustom gnus-button-mid-or-mail-regexp
7434 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7435 gnus-button-valid-fqdn-regexp
7437 "Regular expression that matches a message ID or a mail address."
7439 :group 'gnus-article-buttons
7442 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7443 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7444 Strings like this can be either a message ID or a mail address. If it is one
7445 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7446 message ID or a mail address, respectively. If this variable is set to the
7447 symbol `ask', always query the user what do do. If it is a function, this
7448 function will be called with the string as its only argument. The function
7449 must return `mid', `mail', `invalid' or `ask'."
7451 :group 'gnus-article-buttons
7452 :type '(choice (function-item :tag "Heuristic function"
7453 gnus-button-mid-or-mail-heuristic)
7458 (defcustom gnus-button-mid-or-mail-heuristic-alist
7459 '((-10.0 . ".+\\$.+@")
7462 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7463 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7464 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7465 (-1.0 . "^[^a-z]+@")
7467 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7468 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7469 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7470 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7473 (-1.0 . "^[0-9][0-9]")
7475 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7476 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7477 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7478 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7480 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7481 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7484 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7486 ;; compensation for TDMA dated mail addresses:
7487 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7489 (-20.0 . "\\.fsf@") ;; Gnus
7492 (-20.0 . "^alpine\\.")
7493 (-20.0 . "_-_") ;; Subject change in thread
7495 (-20.0 . "\\.ln@") ;; leafnode
7496 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7497 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7499 ;; (5.0 . "") ;; $local_part_len <= 7
7500 (10.0 . "^[^0-9]+@")
7501 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7502 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7505 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7507 (0.5 . "^[A-Z][a-z]")
7508 (0.5 . "^[A-Z][a-z][a-z]")
7509 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7510 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7511 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7513 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7514 address. The REGEXP is processed with `case-fold-search' set to nil."
7516 :group 'gnus-article-buttons
7517 :type '(repeat (cons (number :tag "Rate")
7518 (regexp :tag "Regexp"))))
7520 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7521 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7522 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7523 address, `ask' if unsure and `invalid' if the string is invalid."
7524 (let ((case-fold-search nil)
7525 (list gnus-button-mid-or-mail-heuristic-alist)
7526 (result 0) rate regexp lpartlen elem)
7528 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7529 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7530 ;; Certain special cases...
7533 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7534 "^[0-9]+\\.[0-9]+@compuserve\\|"
7535 "@public\\.gmane\\.org")
7537 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7538 (setq result 'mail))
7539 (when (string-match "@.*@\\| " mid-or-mail)
7540 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7541 (setq result 'invalid))
7542 ;; Nothing more to do, if result is not a number here...
7543 (when (numberp result)
7545 (setq elem (car list)
7549 (when (string-match regexp mid-or-mail)
7550 (setq result (+ result rate))
7552 9 "`%s' matched `%s', rate `%s', result `%s'."
7553 mid-or-mail regexp rate result)))
7554 (when (<= lpartlen 7)
7555 (setq result (+ result 5.0))
7556 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7557 mid-or-mail result))
7558 (when (>= lpartlen 12)
7559 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7561 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7562 ;; Long local part should contain realname if e-mail address,
7563 ;; too many digits: message-id.
7564 ;; $score -= 5.0 + 0.1 * $local_part_len;
7565 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7566 (setq result (+ result rate))
7568 9 "Many digits in `%s', rate `%s', result `%s'."
7569 mid-or-mail rate result))
7570 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7572 ;; Too few vowels [^aeiouy]{4,}.*\@
7573 (setq result (+ result -5.0))
7575 9 "Few vowels in `%s', rate `%s', result `%s'."
7576 mid-or-mail -5.0 result))
7578 (setq result (+ result 5.0))
7580 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7581 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7582 ;; Maybe we should make this a customizable alist: (condition . 'result)
7584 ((symbolp result) result)
7585 ;; Now convert number into proper results:
7586 ((< result -10.0) 'mid)
7587 ((> result 10.0) 'mail)
7590 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7591 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7592 (url-mid (concat "news" ":" mid-or-mail))
7593 (url-mailto (concat "mailto" ":" mid-or-mail)))
7594 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7595 (when (fboundp pref)
7597 ;; get rid of surrounding angles...
7599 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7600 (if (or (eq 'mid guessed) (eq 'mail guessed))
7604 (save-window-excursion
7605 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7608 (cond ((eq pref 'mid)
7609 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7610 (gnus-button-handle-news url-mid))
7612 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7613 (gnus-url-mailto url-mailto))
7614 (t (gnus-message 3 "Invalid string.")))))
7616 (defun gnus-button-handle-custom (fun arg)
7617 "Call function FUN on argument ARG.
7618 Both FUN and ARG are supposed to be strings. ARG will be passed
7619 as a symbol to FUN."
7620 (funcall (intern fun)
7621 (if (string-match "^customize-apropos" fun)
7625 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7627 (defun gnus-button-handle-describe-function (url)
7628 "Call `describe-function' when pushing the corresponding URL button."
7631 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7633 (defun gnus-button-handle-describe-variable (url)
7634 "Call `describe-variable' when pushing the corresponding URL button."
7637 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7639 (defun gnus-button-handle-symbol (url)
7640 "Display help on variable or function.
7641 Calls `describe-variable' or `describe-function'."
7642 (let ((sym (intern url)))
7644 ((fboundp sym) (describe-function sym))
7645 ((boundp sym) (describe-variable sym))
7646 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7648 (defun gnus-button-handle-describe-key (url)
7649 "Call `describe-key' when pushing the corresponding URL button."
7651 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7652 (keys (ignore-errors (eval `(kbd ,key-string)))))
7655 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7657 (defun gnus-button-handle-apropos (url)
7658 "Call `apropos' when pushing the corresponding URL button."
7659 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7661 (defun gnus-button-handle-apropos-command (url)
7662 "Call `apropos' when pushing the corresponding URL button."
7664 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7666 (defun gnus-button-handle-apropos-variable (url)
7667 "Call `apropos' when pushing the corresponding URL button."
7669 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7670 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7672 (defun gnus-button-handle-apropos-documentation (url)
7673 "Call `apropos' when pushing the corresponding URL button."
7675 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7676 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7678 (defun gnus-button-handle-library (url)
7679 "Call `locate-library' when pushing the corresponding URL button."
7680 (gnus-message 9 "url=`%s'" url)
7681 (let* ((lib (locate-library url))
7682 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7684 (gnus-message 1 "Cannot locale library `%s'." url)
7685 (find-file-read-only file))))
7687 (defcustom gnus-button-man-level 5
7688 "*Integer that says how many man-related buttons Gnus will show.
7689 The higher the number, the more buttons will appear and the more false
7690 positives are possible. Note that you can set this variable local to
7691 specific groups. Setting it higher in Unix groups is probably a good idea.
7692 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7693 how to set variables in specific groups."
7695 :group 'gnus-article-buttons
7696 :link '(custom-manual "(gnus)Group Parameters")
7699 (defcustom gnus-button-emacs-level 5
7700 "*Integer that says how many emacs-related buttons Gnus will show.
7701 The higher the number, the more buttons will appear and the more false
7702 positives are possible. Note that you can set this variable local to
7703 specific groups. Setting it higher in Emacs or Gnus related groups is
7704 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7705 `gnus-parameters' on how to set variables in specific groups."
7707 :group 'gnus-article-buttons
7708 :link '(custom-manual "(gnus)Group Parameters")
7711 (defcustom gnus-button-message-level 5
7712 "*Integer that says how many buttons for news or mail messages will appear.
7713 The higher the number, the more buttons will appear and the more false
7714 positives are possible."
7715 ;; mail addresses, MIDs, URLs for news, ...
7717 :group 'gnus-article-buttons
7720 (defcustom gnus-button-browse-level 5
7721 "*Integer that says how many buttons for browsing will appear.
7722 The higher the number, the more buttons will appear and the more false
7723 positives are possible."
7724 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7726 :group 'gnus-article-buttons
7729 (defcustom gnus-button-alist
7730 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7731 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7732 ((concat "\\b\\(nntp\\|news\\):\\("
7733 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7734 0 t gnus-button-handle-news 2)
7735 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7736 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7737 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7738 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7739 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7740 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7741 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7742 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7743 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7744 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7745 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7746 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7747 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7748 ;; RFC 2368 (The mailto URL scheme)
7749 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7750 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7751 ("\\bmailto:\\([^ \n\t]+\\)"
7752 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7753 ;; Info Konqueror style <info:/foo/bar baz>.
7754 ;; Must come before " Gnus home-grown style".
7755 ("\\binfo://?\\([^'\">\n\t]+\\)"
7756 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7757 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7758 ("\\binfo://\\([^'\">\n\t ]+\\)"
7759 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7760 ;; Info GNOME style <info:foo#bar_baz>
7761 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7762 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7763 ;; Info KDE style <info:(foo)bar baz>
7764 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7765 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7766 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7767 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7768 ("\\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,]*\\)\\)?"
7769 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7770 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7772 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7773 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7774 ;; Emacs help commands
7775 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7776 ;; regexp doesn't match arguments containing ` '.
7777 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7778 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7779 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7780 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7781 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7782 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7783 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7784 ;; The following entries may lead to many false positives so don't enable
7785 ;; them by default (use a high button level).
7786 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7787 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7788 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7789 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7790 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7791 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7792 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7793 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7794 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7795 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7796 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7797 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7798 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7799 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7800 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7801 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7802 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7803 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7804 ;; Unlike the other regexps we really have to require quoting
7805 ;; here to determine where it ends.
7806 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7807 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7808 ("<URL: *\\([^\n<>]*\\)>"
7809 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7810 ;; RFC 2396 (2.4.3., delims) ...
7811 ("\"URL: *\\([^\n\"]*\\)\""
7812 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7814 (gnus-button-url-regexp
7815 0 (>= gnus-button-browse-level 0) browse-url 0)
7817 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7818 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7819 gnus-button-handle-man 1)
7820 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7821 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7822 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7823 gnus-button-handle-man 1)
7824 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7825 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7826 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7827 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7828 ;; Recognizing patches to .el files. This is somewhat obscure,
7829 ;; but considering the percentage of Gnus users who hack Emacs
7831 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7832 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7833 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7834 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7835 ;; MID or mail: To avoid too many false positives we don't try to catch
7836 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7837 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7838 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7839 ;; so that non-ambiguous entries (see above) match first.
7840 (gnus-button-mid-or-mail-regexp
7841 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7842 "*Alist of regexps matching buttons in article bodies.
7844 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7845 REGEXP: is the string (case insensitive) matching text around the button (can
7846 also be Lisp expression evaluating to a string),
7847 BUTTON: is the number of the regexp grouping actually matching the button,
7848 FORM: is a Lisp expression which must eval to true for the button to
7850 CALLBACK: is the function to call when the user push this button, and each
7851 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7853 CALLBACK can also be a variable, in that case the value of that
7854 variable it the real callback function."
7855 :group 'gnus-article-buttons
7856 :type '(repeat (list (choice regexp variable sexp)
7857 (integer :tag "Button")
7859 (function :tag "Callback")
7862 (integer :tag "Regexp group")))))
7863 (put 'gnus-button-alist 'risky-local-variable t)
7865 (defcustom gnus-header-button-alist
7866 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7867 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7868 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7869 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7870 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7871 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7872 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7873 0 (>= gnus-button-browse-level 0) browse-url 0)
7874 ("^Subject:" gnus-button-url-regexp
7875 0 (>= gnus-button-browse-level 0) browse-url 0)
7876 ("^[^:]+:" gnus-button-url-regexp
7877 0 (>= gnus-button-browse-level 0) browse-url 0)
7878 ("^OpenPGP:.*url=" gnus-button-url-regexp
7879 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7880 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7881 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7882 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7883 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7884 "*Alist of headers and regexps to match buttons in article heads.
7886 This alist is very similar to `gnus-button-alist', except that each
7887 alist has an additional HEADER element first in each entry:
7889 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7891 HEADER is a regexp to match a header. For a fuller explanation, see
7892 `gnus-button-alist'."
7893 :group 'gnus-article-buttons
7894 :group 'gnus-article-headers
7895 :type '(repeat (list (regexp :tag "Header")
7896 (choice regexp variable)
7897 (integer :tag "Button")
7899 (function :tag "Callback")
7902 (integer :tag "Regexp group")))))
7903 (put 'gnus-header-button-alist 'risky-local-variable t)
7907 (defun gnus-article-push-button (event)
7908 "Check text under the mouse pointer for a callback function.
7909 If the text under the mouse pointer has a `gnus-callback' property,
7910 call it with the value of the `gnus-data' text property."
7912 (set-buffer (window-buffer (posn-window (event-start event))))
7913 (let* ((pos (posn-point (event-start event)))
7914 (data (get-text-property pos 'gnus-data))
7915 (fun (get-text-property pos 'gnus-callback)))
7918 (funcall fun data))))
7920 (defun gnus-article-press-button ()
7921 "Check text at point for a callback function.
7922 If the text at point has a `gnus-callback' property,
7923 call it with the value of the `gnus-data' text property."
7925 (let ((data (get-text-property (point) 'gnus-data))
7926 (fun (get-text-property (point) 'gnus-callback)))
7928 (funcall fun data))))
7930 (defun gnus-article-highlight (&optional force)
7931 "Highlight current article.
7932 This function calls `gnus-article-highlight-headers',
7933 `gnus-article-highlight-citation',
7934 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7935 do the highlighting. See the documentation for those functions."
7936 (interactive (list 'force))
7937 (gnus-article-highlight-headers)
7938 (gnus-article-highlight-citation force)
7939 (gnus-article-highlight-signature)
7940 (gnus-article-add-buttons)
7941 (gnus-article-add-buttons-to-head))
7943 (defun gnus-article-highlight-some (&optional force)
7944 "Highlight current article.
7945 This function calls `gnus-article-highlight-headers',
7946 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7947 do the highlighting. See the documentation for those functions."
7948 (interactive (list 'force))
7949 (gnus-article-highlight-headers)
7950 (gnus-article-highlight-signature)
7951 (gnus-article-add-buttons))
7953 (defun gnus-article-highlight-headers ()
7954 "Highlight article headers as specified by `gnus-header-face-alist'."
7956 (gnus-with-article-headers
7957 (let (regexp header-face field-face from hpoints fpoints)
7958 (dolist (entry gnus-header-face-alist)
7959 (goto-char (point-min))
7960 (setq regexp (concat "^\\("
7961 (if (string-equal "" (nth 0 entry))
7965 header-face (nth 1 entry)
7966 field-face (nth 2 entry))
7967 (while (and (re-search-forward regexp nil t)
7971 (unless (search-forward ":" nil t)
7973 (when (and header-face
7974 (not (memq (point) hpoints)))
7975 (push (point) hpoints)
7976 (gnus-put-text-property from (point) 'face header-face))
7977 (when (and field-face
7978 (not (memq (setq from (point)) fpoints)))
7980 (if (re-search-forward "^[^ \t]" nil t)
7982 (goto-char (point-max)))
7983 (gnus-put-text-property from (point) 'face field-face)))))))
7985 (defun gnus-article-highlight-signature ()
7986 "Highlight the signature in an article.
7987 It does this by highlighting everything after
7988 `gnus-signature-separator' using the face `gnus-signature'."
7990 (gnus-with-article-buffer
7991 (let ((inhibit-point-motion-hooks t))
7993 (when (and gnus-signature-face
7994 (gnus-article-narrow-to-signature))
7995 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7996 'face gnus-signature-face)
7998 (gnus-article-search-signature)
7999 (let ((start (match-beginning 0))
8000 (end (set-marker (make-marker) (1+ (match-end 0)))))
8001 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
8004 (defun gnus-button-in-region-p (b e prop)
8005 "Say whether PROP exists in the region."
8006 (text-property-not-all b e prop nil))
8008 (defun gnus-article-add-buttons ()
8009 "Find external references in the article and make buttons of them.
8010 \"External references\" are things like Message-IDs and URLs, as
8011 specified by `gnus-button-alist'."
8013 (gnus-with-article-buffer
8014 (let ((inhibit-point-motion-hooks t)
8015 (case-fold-search t)
8016 (alist gnus-button-alist)
8018 ;; We skip the headers.
8021 (while (setq entry (pop alist))
8022 (setq regexp (eval (car entry)))
8024 (while (re-search-forward regexp nil t)
8025 (let ((start (match-beginning (nth 1 entry)))
8026 (end (match-end (nth 1 entry)))
8027 (from (match-beginning 0)))
8028 (when (and (eval (nth 2 entry))
8029 (not (gnus-button-in-region-p
8030 start end 'gnus-callback)))
8031 ;; That optional form returned non-nil, so we add the
8033 (setq from (set-marker (make-marker) from))
8034 (unless (and (eq (car entry) 'gnus-button-url-regexp)
8035 (gnus-article-extend-url-button from start end))
8036 (gnus-article-add-button start end
8037 'gnus-button-push (list from entry))
8038 (gnus-put-text-property
8040 'gnus-string (buffer-substring-no-properties
8043 (defun gnus-article-extend-url-button (beg start end)
8044 "Extend url button if url is folded into two or more lines.
8045 Return non-nil if button is extended. BEG is a marker that points to
8046 the beginning position of a text containing url. START and END are
8047 the endpoints of a url button before it is extended. The concatenated
8048 url is put as the `gnus-button-url' overlay property on the button."
8049 (let ((opoint (point))
8050 (points (list start end))
8055 (not (looking-at "[\t ]*[\">]")))
8059 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8060 (buffer-substring (point-at-bol) start)))
8062 (setq url (list (buffer-substring start end))
8063 delim (if (match-beginning 1) ">" "\""))
8065 (setq regexp (concat
8066 (when (and (looking-at
8067 message-cite-prefix-regexp)
8068 (< (match-end 0) start))
8069 (regexp-quote (match-string 0)))
8071 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8075 (and (looking-at regexp)
8078 (push (or (match-string 2)
8081 (push (setq end (or (match-end 2)
8084 (push (or (match-beginning 2)
8085 (match-beginning 1))
8087 (match-beginning 2)))
8088 (let (gnus-article-mouse-face widget-mouse-face)
8090 (gnus-article-add-button (pop points) (pop points)
8092 (list beg (assq 'gnus-button-url-regexp
8093 gnus-button-alist)))))
8094 (let ((overlay (gnus-make-overlay start end)))
8095 (gnus-overlay-put overlay 'evaporate t)
8096 (gnus-overlay-put overlay 'gnus-button-url
8097 (list (mapconcat 'identity (nreverse url) "")))
8098 (when gnus-article-mouse-face
8099 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8101 (goto-char opoint))))
8103 ;; Add buttons to the head of an article.
8104 (defun gnus-article-add-buttons-to-head ()
8105 "Add buttons to the head of the article."
8107 (gnus-with-article-headers
8109 (dolist (entry gnus-header-button-alist)
8110 ;; Each alist entry.
8111 (goto-char (point-min))
8112 (while (re-search-forward (car entry) nil t)
8113 ;; Each header matching the entry.
8114 (setq beg (match-beginning 0))
8115 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8116 (match-beginning 0))
8119 (while (re-search-forward (eval (nth 1 entry)) end t)
8120 ;; Each match within a header.
8121 (let* ((entry (cdr entry))
8122 (start (match-beginning (nth 1 entry)))
8123 (end (match-end (nth 1 entry)))
8124 (form (nth 2 entry)))
8125 (goto-char (match-end 0))
8127 (gnus-article-add-button
8128 start end (nth 3 entry)
8129 (buffer-substring (match-beginning (nth 4 entry))
8130 (match-end (nth 4 entry)))))))
8131 (goto-char end))))))
8133 ;;; External functions:
8135 (defun gnus-article-add-button (from to fun &optional data text)
8136 "Create a button between FROM and TO with callback FUN and data DATA."
8137 (when gnus-article-button-face
8138 (gnus-overlay-put (gnus-make-overlay from to nil t)
8139 'face gnus-article-button-face))
8140 (gnus-add-text-properties
8142 (nconc (and gnus-article-mouse-face
8143 (list gnus-mouse-face-prop gnus-article-mouse-face))
8144 (list 'gnus-callback fun)
8145 (and data (list 'gnus-data data))))
8146 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8147 :help-echo (or text "Follow the link")
8148 :keymap gnus-url-button-map
8149 :button-keymap gnus-widget-button-keymap))
8151 (defun gnus-article-copy-string ()
8152 "Copy the string in the button to the kill ring."
8154 (gnus-article-check-buffer)
8155 (let ((data (get-text-property (point) 'gnus-string)))
8159 (copy-region-as-kill (point-min) (point-max))
8160 (message "Copied %s" data)))))
8162 ;;; Internal functions:
8164 (defun gnus-article-set-globals ()
8165 (with-current-buffer gnus-summary-buffer
8166 (gnus-set-global-variables)))
8168 (defun gnus-signature-toggle (end)
8169 (gnus-with-article-buffer
8170 (let ((inhibit-point-motion-hooks t))
8171 (if (text-property-any end (point-max) 'article-type 'signature)
8173 (gnus-delete-wash-type 'signature)
8174 (gnus-remove-text-properties-when
8175 'article-type 'signature end (point-max)
8176 (cons 'article-type (cons 'signature
8177 gnus-hidden-properties))))
8178 (gnus-add-wash-type 'signature)
8179 (gnus-add-text-properties-when
8180 'article-type nil end (point-max)
8181 (cons 'article-type (cons 'signature
8182 gnus-hidden-properties)))))
8183 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8184 (gnus-set-mode-line 'article))))
8186 (defun gnus-button-push (marker-and-entry)
8187 ;; Push button starting at MARKER.
8189 (let* ((marker (car marker-and-entry))
8190 (entry (cadr marker-and-entry))
8191 (regexp (car entry))
8192 (inhibit-point-motion-hooks t))
8194 ;; This is obviously true, or something bad is happening :)
8195 ;; But we need it to have the match-data
8196 (when (looking-at (or (if (symbolp regexp)
8197 (symbol-value regexp)
8199 (let ((fun (nth 3 entry))
8200 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8201 (get-char-property marker 'gnus-button-url))
8202 (mapcar (lambda (group)
8203 (let ((string (match-string group)))
8204 (set-text-properties
8205 0 (length string) nil string)
8207 (nthcdr 4 entry)))))
8213 (fboundp (symbol-value fun)))
8214 (apply (symbol-value fun) args))
8216 (gnus-message 1 "You must define `%S' to use this button"
8217 (cons fun args)))))))))
8219 (defun gnus-parse-news-url (url)
8220 (let (scheme server port group message-id articles)
8223 (goto-char (point-min))
8224 (when (looking-at "\\([A-Za-z]+\\):")
8225 (setq scheme (match-string 1))
8226 (goto-char (match-end 0)))
8227 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8228 (setq server (match-string 1))
8229 (setq port (if (stringp (match-string 3))
8230 (string-to-number (match-string 3))
8232 (goto-char (match-end 0)))
8235 ((looking-at "\\(.*@.*\\)")
8236 (setq message-id (match-string 1)))
8237 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8238 (setq group (match-string 1)
8239 articles (split-string (match-string 2) "-")))
8240 ((looking-at "\\([^/]+\\)/?")
8241 (setq group (match-string 1)))
8243 (error "Unknown news URL syntax"))))
8244 (list scheme server port group message-id articles)))
8246 (defun gnus-button-handle-news (url)
8248 (destructuring-bind (scheme server port group message-id articles)
8249 (gnus-parse-news-url url)
8252 (with-current-buffer gnus-summary-buffer
8254 (let ((gnus-refer-article-method
8255 (nconc (list (list 'nntp server))
8256 gnus-refer-article-method))
8257 (nntp-port-number (or port "nntp")))
8258 (gnus-message 7 "Fetching %s with %s"
8259 message-id gnus-refer-article-method)
8260 (gnus-summary-refer-article message-id))
8261 (gnus-summary-refer-article message-id))))
8263 (gnus-button-fetch-group url)))))
8265 (defun gnus-button-patch (library line)
8266 "Visit an Emacs Lisp library LIBRARY on line LINE."
8268 (let ((file (locate-library (file-name-nondirectory library))))
8270 (error "Couldn't find library %s" library))
8272 (goto-char (point-min))
8273 (forward-line (1- (string-to-number line)))))
8275 (defun gnus-button-handle-man (url)
8277 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8278 (when (eq gnus-button-man-handler 'woman)
8279 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8280 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8281 (funcall gnus-button-man-handler url))
8283 (defun gnus-button-handle-info-url (url)
8284 "Fetch an info URL."
8285 (setq url (mm-subst-char-in-string ?+ ?\ url))
8287 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8288 (gnus-info-find-node
8289 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8291 ")" (gnus-url-unhex-string (match-string 2 url)))))
8292 ((string-match "([^)\"]+)[^\"]+" url)
8294 (gnus-replace-in-string
8295 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8296 (gnus-info-find-node url))
8297 (t (error "Can't parse %s" url))))
8299 (defun gnus-button-handle-info-url-gnome (url)
8300 "Fetch GNOME style info URL."
8301 (setq url (mm-subst-char-in-string ?_ ?\ url))
8302 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8303 (gnus-info-find-node
8305 (gnus-url-unhex-string
8306 (match-string 1 url))
8308 (or (gnus-url-unhex-string
8309 (match-string 2 url))
8311 (error "Can't parse %s" url)))
8313 (defun gnus-button-handle-info-url-kde (url)
8314 "Fetch KDE style info URL."
8315 (gnus-info-find-node (gnus-url-unhex-string url)))
8317 ;; (info) will autoload info.el
8318 (declare-function Info-menu "info" (menu-item &optional fork))
8319 (declare-function Info-index-next "info" (num))
8321 (defun gnus-button-handle-info-keystrokes (url)
8322 "Call `info' when pushing the corresponding URL button."
8323 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8324 (let (node indx comma)
8326 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8327 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8328 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8329 "\\(?:[ \t\n,]*\\)\\)?")
8331 (setq node (match-string 2 url)
8332 indx (match-string 3 url))
8333 (error "Can't parse %s" url))
8337 (when (> (length indx) 0)
8338 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8341 (setq comma (match-string 2 indx))
8342 (setq indx (match-string 1 indx))
8345 (dotimes (i (with-temp-buffer
8347 ;; Note: the XEmacs version of `how-many' takes
8348 ;; no optional argument.
8349 (goto-char (point-min))
8351 (Info-index-next 1)))
8354 (autoload 'pgg-snarf-keys-region "pgg")
8355 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8356 (declare-function pgg-display-output-buffer "pgg" (start end status))
8358 (defun gnus-button-openpgp (url)
8359 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8361 (mm-url-insert-file-contents-external url)
8362 (pgg-snarf-keys-region (point-min) (point-max))
8363 (pgg-display-output-buffer nil nil nil)))
8365 (defun gnus-button-message-id (message-id)
8367 (with-current-buffer gnus-summary-buffer
8368 (gnus-summary-refer-article message-id)))
8370 (defun gnus-button-fetch-group (address &rest ignore)
8371 "Fetch GROUP specified by ADDRESS."
8372 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8374 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8375 ;; for nntp:// and news://
8376 (setq address (match-string 3 address)))
8377 (if (not (string-match "[:/]" address))
8378 ;; This is just a simple group url.
8379 (gnus-group-read-ephemeral-group address gnus-select-method)
8382 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8384 (error "Can't parse %s" address)
8385 (gnus-group-read-ephemeral-group
8386 (match-string 4 address)
8387 `(nntp ,(match-string 1 address)
8388 (nntp-address ,(match-string 1 address))
8389 (nntp-port-number ,(if (match-end 3)
8390 (match-string 3 address)
8393 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8395 (defun gnus-url-parse-query-string (query &optional downcase)
8396 (let (retval pairs cur key val)
8397 (setq pairs (split-string query "&"))
8399 (setq cur (car pairs)
8401 (if (not (string-match "=" cur))
8403 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8404 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8406 (setq key (downcase key)))
8407 (setq cur (assoc key retval))
8409 (setcdr cur (cons val (cdr cur)))
8410 (setq retval (cons (list key val) retval)))))
8413 (defun gnus-url-mailto (url)
8414 ;; Send mail to someone
8415 (setq url (replace-regexp-in-string "\n" " " url))
8416 (when (string-match "mailto:/*\\(.*\\)" url)
8417 (setq url (substring url (match-beginning 1) nil)))
8418 (let (to args subject func)
8419 (setq args (gnus-url-parse-query-string
8420 (if (string-match "^\\?" url)
8422 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8423 (concat "to=" (match-string 1 url) "&"
8424 (match-string 2 url))
8425 (concat "to=" url))))
8426 subject (cdr-safe (assoc "subject" args)))
8429 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8432 (message-position-on-field (caar args)))
8433 (insert (gnus-replace-in-string
8434 (mapconcat 'identity (reverse (cdar args)) ", ")
8436 (setq args (cdr args)))
8439 (message-goto-subject))))
8441 (defun gnus-button-embedded-url (address)
8442 "Activate ADDRESS with `browse-url'."
8443 (browse-url (gnus-strip-whitespace address)))
8445 ;;; Next/prev buttons in the article buffer.
8447 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8448 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8450 (defvar gnus-prev-page-map
8451 (let ((map (make-sparse-keymap)))
8452 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8453 (define-key map "\r" 'gnus-button-prev-page)
8456 (defvar gnus-next-page-map
8457 (let ((map (make-sparse-keymap)))
8458 (define-key map gnus-mouse-2 'gnus-button-next-page)
8459 (define-key map "\r" 'gnus-button-next-page)
8462 (defun gnus-insert-prev-page-button ()
8464 (inhibit-read-only t))
8466 gnus-prev-page-line-format nil
8467 `(keymap ,gnus-prev-page-map
8469 gnus-callback gnus-article-button-prev-page
8470 article-type annotation))
8472 ;; Exclude a newline.
8475 (when gnus-article-button-face
8476 (gnus-overlay-put (gnus-make-overlay b e nil t)
8477 'face gnus-article-button-face))
8478 (widget-convert-button
8480 :action 'gnus-button-prev-page
8481 :button-keymap gnus-prev-page-map)))
8483 (defun gnus-button-next-page (&optional args more-args)
8484 "Go to the next page."
8486 (let ((win (selected-window)))
8487 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8488 (gnus-article-next-page)
8489 (select-window win)))
8491 (defun gnus-button-prev-page (&optional args more-args)
8492 "Go to the prev page."
8494 (let ((win (selected-window)))
8495 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8496 (gnus-article-prev-page)
8497 (select-window win)))
8499 (defun gnus-insert-next-page-button ()
8501 (inhibit-read-only t))
8502 (gnus-eval-format gnus-next-page-line-format nil
8503 `(keymap ,gnus-next-page-map
8505 gnus-callback gnus-article-button-next-page
8506 article-type annotation))
8508 ;; Exclude a newline.
8511 (when gnus-article-button-face
8512 (gnus-overlay-put (gnus-make-overlay b e nil t)
8513 'face gnus-article-button-face))
8514 (widget-convert-button
8516 :action 'gnus-button-next-page
8517 :button-keymap gnus-next-page-map)))
8519 (defun gnus-article-button-next-page (arg)
8520 "Go to the next page."
8522 (let ((win (selected-window)))
8523 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8524 (gnus-article-next-page)
8525 (select-window win)))
8527 (defun gnus-article-button-prev-page (arg)
8528 "Go to the prev page."
8530 (let ((win (selected-window)))
8531 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8532 (gnus-article-prev-page)
8533 (select-window win)))
8535 (defvar gnus-decode-header-methods
8536 '(mail-decode-encoded-word-region)
8537 "List of methods used to decode headers.
8539 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8540 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8541 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8542 whose names match REGEXP.
8545 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8546 mail-decode-encoded-word-region
8547 (\"chinese\" . rfc1843-decode-region))
8550 (defvar gnus-decode-header-methods-cache nil)
8552 (defun gnus-multi-decode-header (start end)
8553 "Apply the functions from `gnus-encoded-word-methods' that match."
8554 (unless (and gnus-decode-header-methods-cache
8555 (eq gnus-newsgroup-name
8556 (car gnus-decode-header-methods-cache)))
8557 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8558 (dolist (x gnus-decode-header-methods)
8560 (nconc gnus-decode-header-methods-cache (list x))
8561 (if (and gnus-newsgroup-name
8562 (string-match (car x) gnus-newsgroup-name))
8563 (nconc gnus-decode-header-methods-cache
8565 (let ((xlist gnus-decode-header-methods-cache))
8568 (narrow-to-region start end)
8570 (funcall (pop xlist) (point-min) (point-max))))))
8573 ;;; Treatment top-level handling.
8576 (defvar gnus-inhibit-article-treatments nil)
8578 (defun gnus-treat-article (gnus-treat-condition
8579 &optional part-number total-parts gnus-treat-type)
8580 (let ((gnus-treat-length (- (point-max) (point-min)))
8581 (alist gnus-treatment-function-alist)
8582 (article-goto-body-goes-to-point-min-p t)
8584 (or (not gnus-treat-type)
8586 (let ((list gnus-article-treat-types))
8588 (when (string-match (pop list) gnus-treat-type)
8589 (throw 'found t)))))))
8590 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8592 (gnus-run-hooks 'gnus-part-display-hook)
8593 (dolist (elem alist)
8596 (when (gnus-buffer-live-p gnus-summary-buffer)
8597 (set-buffer gnus-summary-buffer))
8598 (symbol-value (car elem))))
8599 (when (and (or (consp val)
8601 (or (not gnus-inhibit-article-treatments)
8602 (eq gnus-treat-condition 'head))
8603 (gnus-treat-predicate val)
8604 (or (not (get (car elem) 'highlight))
8607 (funcall (cadr elem)))))))
8609 ;; Dynamic variables.
8610 (defvar part-number)
8611 (defvar total-parts)
8612 (defvar gnus-treat-type)
8613 (defvar gnus-treat-condition)
8614 (defvar gnus-treat-length)
8616 (defun gnus-treat-predicate (val)
8620 (gnus-treat-condition
8621 (eq gnus-treat-condition val))
8623 (stringp (car val)))
8624 (apply 'gnus-or (mapcar `(lambda (s)
8625 (string-match s ,(or gnus-newsgroup-name "")))
8628 (let ((pred (pop val)))
8631 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8633 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8635 (not (gnus-treat-predicate (car val))))
8637 (equal (car val) gnus-treat-type))
8641 (error "%S is not a valid predicate" pred)))))
8649 (eq part-number total-parts))
8651 (< gnus-treat-length val))
8653 (error "%S is not a valid value" val))))
8655 (defun gnus-article-encrypt-body (protocol &optional n)
8656 "Encrypt the article body."
8659 (or gnus-article-encrypt-protocol
8660 (gnus-completing-read "Encrypt protocol"
8661 (mapcar 'car gnus-article-encrypt-protocol-alist)
8663 current-prefix-arg))
8664 ;; User might hit `K E' instead of `K e', so prompt once.
8665 (when (and gnus-article-encrypt-protocol
8667 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8668 (error "Encrypt aborted")))
8669 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8671 (error "Can't find the encrypt protocol %s" protocol))
8672 (if (member gnus-newsgroup-name '("nndraft:delayed"
8675 (error "Can't encrypt the article in group %s"
8676 gnus-newsgroup-name))
8677 (gnus-summary-iterate n
8678 (with-current-buffer gnus-summary-buffer
8679 (let ((mail-parse-charset gnus-newsgroup-charset)
8680 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8681 (summary-buffer gnus-summary-buffer)
8683 (gnus-set-global-variables)
8684 (when (gnus-group-read-only-p)
8685 (error "The current newsgroup does not support article encrypt"))
8686 (gnus-summary-show-article t)
8688 (or (mail-header-references gnus-current-headers) ""))
8689 (set-buffer gnus-article-buffer)
8690 (let* ((inhibit-read-only t)
8692 (mapcar (lambda (field)
8693 (and (save-restriction
8694 (message-narrow-to-head)
8695 (goto-char (point-min))
8696 (search-forward field nil t))
8698 (message-narrow-to-field)
8700 (delete-region (point-min) (point-max))
8702 '("Content-Type:" "Content-Transfer-Encoding:"
8703 "Content-Disposition:"))))
8704 (message-narrow-to-head)
8705 (message-remove-header "MIME-Version")
8706 (goto-char (point-max))
8707 (setq point (point))
8708 (insert (apply 'concat headers))
8710 (narrow-to-region point (point-max))
8711 (let ((message-options message-options))
8712 (message-options-set 'message-sender user-mail-address)
8713 (message-options-set 'message-recipients user-mail-address)
8714 (message-options-set 'message-sign-encrypt 'not)
8716 (goto-char (point-min))
8717 (insert "MIME-Version: 1.0\n")
8719 (gnus-summary-edit-article-done
8720 references nil summary-buffer t))
8721 (when gnus-keep-backlog
8722 (gnus-backlog-remove-article
8723 (car gnus-article-current) (cdr gnus-article-current)))
8724 (gnus-flush-original-article-buffer)
8725 (when gnus-use-cache
8726 (gnus-cache-update-article
8727 (car gnus-article-current) (cdr gnus-article-current))))))))
8729 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8730 "The following specs can be used:
8731 %t The security MIME type
8734 %D Details if button is pressed")
8736 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8737 "The following specs can be used:
8738 %t The security MIME type
8741 %D Details if button is pressed")
8743 (defvar gnus-mime-security-button-line-format-alist
8744 '((?t gnus-tmp-type ?s)
8745 (?i gnus-tmp-info ?s)
8746 (?d gnus-tmp-details ?s)
8747 (?D gnus-tmp-pressed-details ?s)))
8749 (defvar gnus-mime-security-button-commands
8750 '((gnus-article-press-button "\r" "Show Detail")
8754 (gnus-mime-security-save-part "o" "Save...")
8763 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8766 (defvar gnus-mime-security-button-map
8767 (let ((map (make-sparse-keymap)))
8768 (define-key map gnus-mouse-2 'gnus-article-push-button)
8769 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8770 (dolist (c gnus-mime-security-button-commands)
8771 (define-key map (cadr c) (car c)))
8775 gnus-mime-security-button-menu gnus-mime-security-button-map
8776 "Security button menu."
8780 (unless (eq (car c) 'undefined)
8781 (vector (caddr c) (car c) :active t)))
8782 gnus-mime-security-button-commands))))
8784 (defun gnus-mime-security-button-menu (event prefix)
8785 "Construct a context-sensitive menu of security commands."
8786 (interactive "e\nP")
8787 (save-window-excursion
8788 (let ((pos (event-start event)))
8789 (select-window (posn-window pos))
8790 (goto-char (posn-point pos))
8791 (gnus-article-check-buffer)
8792 (popup-menu gnus-mime-security-button-menu nil prefix))))
8794 (defvar gnus-mime-security-details-buffer nil)
8796 (defvar gnus-mime-security-button-pressed nil)
8798 (defvar gnus-mime-security-show-details-inline t
8799 "If non-nil, show details in the article buffer.")
8801 (defun gnus-mime-security-verify-or-decrypt (handle)
8802 (mm-remove-parts (cdr handle))
8803 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8804 point (inhibit-read-only t))
8806 (goto-char (car region)))
8807 (setq point (point))
8808 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8809 (let* ((mm-verify-option 'known)
8810 (mm-decrypt-option 'known)
8811 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8812 (unless (eq nparts (cdr handle))
8813 (mm-destroy-parts (cdr handle))
8814 (setcdr handle nparts))))
8815 (gnus-mime-display-security handle)
8817 (delete-region (point) (cdr region))
8818 (set-marker (car region) nil)
8819 (set-marker (cdr region) nil))
8822 (defun gnus-mime-security-show-details (handle)
8823 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8825 (gnus-message 5 "No details.")
8826 (if gnus-mime-security-show-details-inline
8827 (let ((gnus-mime-security-button-pressed
8828 (not (get-text-property (point) 'gnus-mime-details)))
8829 (gnus-mime-security-button-line-format
8830 (get-text-property (point) 'gnus-line-format))
8831 (inhibit-read-only t))
8833 (while (eq (get-text-property (point) 'gnus-line-format)
8834 gnus-mime-security-button-line-format)
8838 (narrow-to-region (point) (point))
8839 (gnus-insert-mime-security-button handle))
8840 (delete-region (point)
8841 (or (text-property-not-all
8844 gnus-mime-security-button-line-format)
8847 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8848 (with-current-buffer gnus-mime-security-details-buffer
8851 (setq gnus-mime-security-details-buffer
8852 (gnus-get-buffer-create "*MIME Security Details*")))
8853 (with-current-buffer gnus-mime-security-details-buffer
8855 (goto-char (point-min)))
8856 (pop-to-buffer gnus-mime-security-details-buffer)))))
8858 (defun gnus-mime-security-press-button (handle)
8860 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8861 (gnus-mime-security-show-details handle)
8862 (gnus-mime-security-verify-or-decrypt handle))))
8864 (defun gnus-insert-mime-security-button (handle &optional displayed)
8865 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8868 (or (nth 2 (assoc protocol mm-verify-function-alist))
8869 (nth 2 (assoc protocol mm-decrypt-function-alist))
8871 (if (equal (car handle) "multipart/signed")
8872 " Signed" " Encrypted")
8875 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8878 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8879 gnus-tmp-pressed-details
8881 (setq gnus-tmp-details
8882 (if gnus-tmp-details
8883 (concat "\n" gnus-tmp-details)
8885 (setq gnus-tmp-pressed-details
8886 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8891 gnus-mime-security-button-line-format
8892 gnus-mime-security-button-line-format-alist
8893 `(keymap ,gnus-mime-security-button-map
8894 gnus-callback gnus-mime-security-press-button
8895 gnus-line-format ,gnus-mime-security-button-line-format
8896 gnus-mime-details ,gnus-mime-security-button-pressed
8897 article-type annotation
8900 ;; Exclude a newline.
8903 (when gnus-article-button-face
8904 (gnus-overlay-put (gnus-make-overlay b e nil t)
8905 'face gnus-article-button-face))
8906 (widget-convert-button
8909 :action 'gnus-widget-press-button
8910 :button-keymap gnus-mime-security-button-map
8913 ;; Needed to properly clear the message due to a bug in
8914 ;; wid-edit (XEmacs only).
8915 (when (boundp 'help-echo-owns-message)
8916 (setq help-echo-owns-message t))
8918 "%S: show detail; %S: more options"
8919 (aref gnus-mouse-2 0)
8920 (aref gnus-down-mouse-3 0))))))
8922 (defun gnus-mime-display-security (handle)
8924 (narrow-to-region (point) (point))
8925 (unless (gnus-unbuttonized-mime-type-p (car handle))
8926 (gnus-insert-mime-security-button handle))
8927 (gnus-mime-display-part (cadr handle))
8930 (unless (gnus-unbuttonized-mime-type-p (car handle))
8931 (let ((gnus-mime-security-button-line-format
8932 gnus-mime-security-button-end-line-format))
8933 (gnus-insert-mime-security-button handle)))
8934 (mm-set-handle-multipart-parameter
8935 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8936 (goto-char (point-max))))
8938 (defun gnus-mime-security-run-function (function)
8939 "Run FUNCTION with the security part under point."
8940 (gnus-article-check-buffer)
8941 (let ((data (get-text-property (point) 'gnus-data))
8943 (when (and (stringp (car-safe data))
8944 (setq buffer (mm-handle-multipart-original-buffer data))
8945 (setq handle (cadr data)))
8946 (if (bufferp (mm-handle-buffer handle))
8948 (setq handle (cons buffer (copy-sequence (cdr handle))))
8949 (mm-handle-set-undisplayer handle nil))
8950 (setq handle (mm-make-handle
8952 (mm-handle-multipart-ctl-parameter handle 'protocol)
8953 nil nil nil nil nil nil)))
8954 (funcall function handle))))
8956 (defun gnus-mime-security-save-part ()
8957 "Save the security part under point."
8959 (gnus-mime-security-run-function 'mm-save-part))
8961 (defun gnus-mime-security-pipe-part ()
8962 "Pipe the security part under point to a process."
8964 (gnus-mime-security-run-function 'mm-pipe-part))
8970 (run-hooks 'gnus-art-load-hook)
8972 ;;; gnus-art.el ends here