1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function
) (defmacro declare-function
(&rest r
))))
33 (defvar w3m-minor-mode-map
)
48 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
49 (autoload 'gnus-button-mailto
"gnus-msg")
50 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
51 (autoload 'parse-time-string
"parse-time" nil nil
)
52 (autoload 'ansi-color-apply-on-region
"ansi-color")
53 (autoload 'mm-url-insert-file-contents-external
"mm-url")
54 (autoload 'mm-extern-cache-contents
"mm-extern")
56 (defgroup gnus-article nil
58 :link
'(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link
'(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link
'(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link
'(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link
'(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link
'(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link
'(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link
'(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link
'(custom-manual "(gnus)Saving Articles")
100 :group
'gnus-article
)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link
'(custom-manual "(gnus)Using MIME")
105 :group
'gnus-article
)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link
'(custom-manual "(gnus)Article Buttons")
110 :group
'gnus-article
)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link
'(custom-manual "(gnus)Misc Article")
115 :group
'gnus-article
)
117 (defcustom gnus-ignored-headers
120 (concat "^" header
":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
159 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
160 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
161 "Envelope-Sender" "Envelope-Recipients"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type
'(choice :custom-show nil
168 :group
'gnus-article-hiding
)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 (repeat :value-to-internal
(lambda (widget value
)
177 (custom-split-regexp-maybe value
))
178 :match
(lambda (widget value
)
180 (widget-editable-list-match widget value
)))
182 (const :tag
"Use gnus-ignored-headers" nil
)
184 :group
'gnus-article-hiding
)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type
'(repeat regexp
)
194 :group
'gnus-article-hiding
)
196 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type
'(set (const :tag
"Headers with no content." empty
)
211 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
212 (const :tag
"To identical to To-address." to-address
)
213 (const :tag
"To identical to To-list." to-list
)
214 (const :tag
"CC identical to To-list." cc-list
)
215 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
216 (const :tag
"Reply-to identical to From." reply-to
)
217 (const :tag
"Date less than four days old." date
)
218 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
219 (const :tag
"Multiple To and/or Cc headers." many-to
))
220 :group
'gnus-article-hiding
)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group
'gnus-article-hiding
)
232 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag
"List of regexp" regexp
))
240 :group
'gnus-article-signature
)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type
'(choice (const nil
)
256 (regexp :value
".*"))
257 :group
'gnus-article-signature
)
259 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
260 "Property list to use for hiding text."
262 :group
'gnus-article-hiding
)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs
)
268 (if (or (gnus-image-type-available-p 'xface
)
269 (gnus-image-type-available-p 'pbm
))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm
)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
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 favourite 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 evaled 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 [%w] %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."
695 :group
'gnus-article-various
)
697 (defcustom gnus-article-mode-hook nil
698 "*A hook for Gnus article mode."
700 :group
'gnus-article-various
)
702 (when (featurep 'xemacs
)
703 ;; Extracted from gnus-xmas-define in order to preserve user settings
704 (when (fboundp 'turn-off-scroll-in-place
)
705 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
706 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
707 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
709 (defcustom gnus-article-menu-hook nil
710 "*Hook run after the creation of the article mode menu."
712 :group
'gnus-article-various
)
714 (defcustom gnus-article-prepare-hook nil
715 "*A hook called after an article has been prepared in the article buffer."
717 :group
'gnus-article-various
)
719 (defcustom gnus-copy-article-ignored-headers nil
720 "List of headers to be removed when copying an article.
721 Each element is a regular expression."
722 :version
"23.1" ;; No Gnus
723 :type
'(repeat regexp
)
724 :group
'gnus-article-various
)
726 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
727 "Gnus 5.10 (Emacs 22.1)")
730 '((t (:weight bold
)))
731 "Face used for highlighting a button in the article buffer."
732 :group
'gnus-article-buttons
)
734 (defcustom gnus-article-button-face
'gnus-button
735 "Face used for highlighting buttons in the article buffer.
737 An article button is a piece of text that you can activate by pressing
738 `RET' or `mouse-2' above it."
740 :group
'gnus-article-buttons
)
742 (defcustom gnus-article-mouse-face
'highlight
743 "Face used for mouse highlighting in the article buffer.
745 Article buttons will be displayed in this face when the cursor is
748 :group
'gnus-article-buttons
)
750 (defcustom gnus-signature-face
'gnus-signature
751 "Face used for highlighting a signature in the article buffer.
752 Obsolete; use the face `gnus-signature' for customizations instead."
754 :group
'gnus-article-highlight
755 :group
'gnus-article-signature
)
757 (defface gnus-signature
760 "Face used for highlighting a signature in the article buffer."
761 :group
'gnus-article-highlight
762 :group
'gnus-article-signature
)
763 ;; backward-compatibility alias
764 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
765 (put 'gnus-signature-face
'obsolete-face
"22.1")
767 (defface gnus-header-from
770 (:foreground
"PaleGreen1"))
773 (:foreground
"red3"))
776 "Face used for displaying from headers."
777 :group
'gnus-article-headers
778 :group
'gnus-article-highlight
)
779 ;; backward-compatibility alias
780 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
781 (put 'gnus-header-from-face
'obsolete-face
"22.1")
783 (defface gnus-header-subject
786 (:foreground
"SeaGreen1"))
789 (:foreground
"red4"))
791 (:bold t
:italic t
)))
792 "Face used for displaying subject headers."
793 :group
'gnus-article-headers
794 :group
'gnus-article-highlight
)
795 ;; backward-compatibility alias
796 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
797 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
799 (defface gnus-header-newsgroups
802 (:foreground
"yellow" :italic t
))
805 (:foreground
"MidnightBlue" :italic t
))
808 "Face used for displaying newsgroups headers.
809 In the default setup this face is only used for crossposted
811 :group
'gnus-article-headers
812 :group
'gnus-article-highlight
)
813 ;; backward-compatibility alias
814 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
815 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
817 (defface gnus-header-name
820 (:foreground
"SpringGreen2"))
823 (:foreground
"maroon"))
826 "Face used for displaying header names."
827 :group
'gnus-article-headers
828 :group
'gnus-article-highlight
)
829 ;; backward-compatibility alias
830 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
831 (put 'gnus-header-name-face
'obsolete-face
"22.1")
833 (defface gnus-header-content
836 (:foreground
"SpringGreen1" :italic t
))
839 (:foreground
"indianred4" :italic t
))
841 (:italic t
))) "Face used for displaying header content."
842 :group
'gnus-article-headers
843 :group
'gnus-article-highlight
)
844 ;; backward-compatibility alias
845 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
846 (put 'gnus-header-content-face
'obsolete-face
"22.1")
848 (defcustom gnus-header-face-alist
849 '(("From" nil gnus-header-from
)
850 ("Subject" nil gnus-header-subject
)
851 ("Newsgroups:.*," nil gnus-header-newsgroups
)
852 ("" gnus-header-name gnus-header-content
))
853 "*Controls highlighting of article headers.
855 An alist of the form (HEADER NAME CONTENT).
857 HEADER is a regular expression which should match the name of a
858 header and NAME and CONTENT are either face names or nil.
860 The name of each header field will be displayed using the face
861 specified by the first element in the list where HEADER matches
862 the header name and NAME is non-nil. Similarly, the content will
863 be displayed by the first non-nil matching CONTENT face."
864 :group
'gnus-article-headers
865 :group
'gnus-article-highlight
866 :type
'(repeat (list (regexp :tag
"Header")
868 (item :tag
"skip" nil
)
869 (face :value default
))
870 (choice :tag
"Content"
871 (item :tag
"skip" nil
)
872 (face :value default
)))))
874 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
875 '((xface .
(:face gnus-x-face
)))
876 '((pbm .
(:face gnus-x-face
))
878 "Alist of image types and properties applied to Face and X-Face images.
881 ;; Specify the altitude of Face images in the From header.
882 \(setq gnus-face-properties-alist
883 '((pbm . (:face gnus-x-face :ascent 80))
884 (png . (:ascent 80))))
886 ;; Show Face images as pressed buttons.
887 \(setq gnus-face-properties-alist
888 '((pbm . (:face gnus-x-face :relief -2))
889 (png . (:relief -2))))
891 See the manual for the valid properties for various image types.
892 Currently, `pbm' is used for X-Face images and `png' is used for Face
893 images in Emacs. Only the `:face' property is effective on the `xface'
894 image type in XEmacs if it is built with the libcompface library."
895 :version
"23.1" ;; No Gnus
896 :group
'gnus-article-headers
897 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
899 (defcustom gnus-article-decode-hook
900 '(article-decode-charset article-decode-encoded-words
901 article-decode-group-name article-decode-idna-rhs
)
902 "*Hook run to decode charsets in articles."
903 :group
'gnus-article-headers
906 (defcustom gnus-display-mime-function
'gnus-display-mime
907 "Function to display MIME articles."
908 :group
'gnus-article-mime
911 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
912 "Function used to decode headers.")
914 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
915 "Function used to decode addresses.")
917 (defvar gnus-article-dumbquotes-map
937 "Table for MS-to-Latin1 translation.")
939 (defcustom gnus-ignored-mime-types nil
940 "List of MIME types that should be ignored by Gnus."
942 :group
'gnus-article-mime
943 :type
'(repeat regexp
))
945 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
946 "List of MIME types that should not be given buttons when rendered inline.
947 See also `gnus-buttonized-mime-types' which may override this variable.
948 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
950 :group
'gnus-article-mime
951 :type
'(repeat regexp
))
953 (defcustom gnus-buttonized-mime-types nil
954 "List of MIME types that should be given buttons when rendered inline.
955 If set, this variable overrides `gnus-unbuttonized-mime-types'.
956 To see e.g. security buttons you could set this to
957 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
958 this list to display radio buttons that allow you to choose one of two
959 media types those mails include. See also `mm-discouraged-alternatives'.
960 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
962 :group
'gnus-article-mime
963 :type
'(repeat regexp
))
965 (defcustom gnus-inhibit-mime-unbuttonizing nil
966 "If non-nil, all MIME parts get buttons.
967 When nil (the default value), then some MIME parts do not get buttons,
968 as described by the variables `gnus-buttonized-mime-types' and
969 `gnus-unbuttonized-mime-types'."
971 :group
'gnus-article-mime
974 (defcustom gnus-body-boundary-delimiter
"_"
975 "String used to delimit header and body.
976 This variable is used by `gnus-article-treat-body-boundary' which can
977 be controlled by `gnus-treat-body-boundary'."
979 :group
'gnus-article-various
980 :type
'(choice (item :tag
"None" :value nil
)
983 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
985 "Defines the location of the faces database.
986 For information on obtaining this database of pretty pictures, please
987 see http://www.cs.indiana.edu/picons/ftp/index.html"
989 :type
'(repeat directory
)
990 :link
'(url-link :tag
"download"
991 "http://www.cs.indiana.edu/picons/ftp/index.html")
992 :link
'(custom-manual "(gnus)Picons")
995 (defun gnus-picons-installed-p ()
996 "Say whether picons are installed on your machine."
997 (let ((installed nil
))
998 (dolist (database gnus-picon-databases
)
999 (when (file-exists-p database
)
1000 (setq installed t
)))
1003 (defcustom gnus-article-mime-part-function nil
1004 "Function called with a MIME handle as the argument.
1005 This is meant for people who want to do something automatic based
1006 on parts -- for instance, adding Vcard info to a database."
1007 :group
'gnus-article-mime
1008 :type
'(choice (const nil
)
1011 (defcustom gnus-mime-multipart-functions nil
1012 "An alist of MIME types to functions to display them."
1014 :group
'gnus-article-mime
1015 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1017 (defcustom gnus-article-date-lapsed-new-header nil
1018 "Whether the X-Sent and Date headers can coexist.
1019 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1020 either replace the old \"Date:\" header (if this variable is nil), or
1021 be added below it (otherwise)."
1023 :group
'gnus-article-headers
1026 (defcustom gnus-article-update-lapsed-header
1
1027 "How often to update the lapsed date header.
1028 If nil, don't update it at all."
1030 :group
'gnus-article-headers
1032 (item :tag
"Don't update" :value nil
)
1035 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1036 "Function called with a MIME handle as the argument.
1037 This is meant for people who want to view first matched part.
1038 For `undisplayed-alternative' (default), the first undisplayed
1039 part or alternative part is used. For `undisplayed', the first
1040 undisplayed part is used. For a function, the first part which
1041 the function return t is used. For nil, the first part is
1044 :group
'gnus-article-mime
1046 (item :tag
"first" :value nil
)
1047 (item :tag
"undisplayed" :value undisplayed
)
1048 (item :tag
"undisplayed or alternative"
1049 :value undisplayed-alternative
)
1052 (defcustom gnus-mime-action-alist
1053 '(("save to file" . gnus-mime-save-part
)
1054 ("save and strip" . gnus-mime-save-part-and-strip
)
1055 ("replace with file" . gnus-mime-replace-part
)
1056 ("delete part" . gnus-mime-delete-part
)
1057 ("display as text" . gnus-mime-inline-part
)
1058 ("view the part" . gnus-mime-view-part
)
1059 ("pipe to command" . gnus-mime-pipe-part
)
1060 ("toggle display" . gnus-article-press-button
)
1061 ("toggle display" . gnus-article-view-part-as-charset
)
1062 ("view as type" . gnus-mime-view-part-as-type
)
1063 ("view internally" . gnus-mime-view-part-internally
)
1064 ("view externally" . gnus-mime-view-part-externally
))
1065 "An alist of actions that run on the MIME attachment."
1066 :group
'gnus-article-mime
1067 :type
'(repeat (cons (string :tag
"name")
1070 (defcustom gnus-auto-select-part
1
1071 "Advance to next MIME part when deleting or stripping parts.
1073 When 0, point will be placed on the same part as before. When
1074 positive (negative), move point forward (backwards) this many
1075 parts. When nil, redisplay article."
1076 :version
"23.1" ;; No Gnus
1077 :group
'gnus-article-mime
1078 :type
'(choice (const nil
:tag
"Redisplay article.")
1079 (const 1 :tag
"Next part.")
1080 (const 0 :tag
"Current part.")
1084 ;;; The treatment variables
1087 (defvar gnus-part-display-hook nil
1088 "Hook called on parts that are to receive treatment.")
1090 (defvar gnus-article-treat-custom
1091 '(choice (const :tag
"Off" nil
)
1093 (const :tag
"Header" head
)
1094 (const :tag
"First" first
)
1095 (const :tag
"Last" last
)
1096 (integer :tag
"Less")
1097 (repeat :tag
"Groups" regexp
)
1098 (sexp :tag
"Predicate")))
1100 (defvar gnus-article-treat-head-custom
1101 '(choice (const :tag
"Off" nil
)
1102 (const :tag
"Header" head
)))
1104 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1108 (defvar gnus-inhibit-treatment nil
1109 "Whether to inhibit treatment.")
1111 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1112 "Highlight the signature.
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group
'gnus-article-treat
1116 :link
'(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom
)
1118 (put 'gnus-treat-highlight-signature
'highlight t
)
1120 (defcustom gnus-treat-buttonize
100000
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group
'gnus-article-treat
1125 :link
'(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom
)
1127 (put 'gnus-treat-buttonize
'highlight t
)
1129 (defcustom gnus-treat-buttonize-head
'head
1130 "Add buttons to the head.
1131 Valid values are nil, t, `head', `first', `last', an integer or a
1132 predicate. See Info node `(gnus)Customizing Articles'."
1133 :group
'gnus-article-treat
1134 :link
'(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-head-custom
)
1136 (put 'gnus-treat-buttonize-head
'highlight t
)
1138 (defcustom gnus-treat-emphasize
50000
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1142 :group
'gnus-article-treat
1143 :link
'(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom
)
1145 (put 'gnus-treat-emphasize
'highlight t
)
1147 (defcustom gnus-treat-strip-cr nil
1148 "Remove carriage returns.
1149 Valid values are nil, t, `head', `first', `last', an integer or a
1150 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group
'gnus-article-treat
1153 :link
'(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom
)
1156 (defcustom gnus-treat-unsplit-urls nil
1157 "Remove newlines from within URLs.
1158 Valid values are nil, t, `head', `first', `last', an integer or a
1159 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group
'gnus-article-treat
1162 :link
'(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom
)
1165 (defcustom gnus-treat-leading-whitespace nil
1166 "Remove leading whitespace in headers.
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1170 :group
'gnus-article-treat
1171 :link
'(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom
)
1174 (defcustom gnus-treat-hide-headers
'head
1176 Valid values are nil, t, `head', `first', `last', an integer or a
1177 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group
'gnus-article-treat
1179 :link
'(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom
)
1182 (defcustom gnus-treat-hide-boring-headers nil
1183 "Hide boring headers.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group
'gnus-article-treat
1187 :link
'(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-head-custom
)
1190 (defcustom gnus-treat-hide-signature nil
1191 "Hide the signature.
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1194 :group
'gnus-article-treat
1195 :link
'(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom
)
1198 (defcustom gnus-treat-fill-article nil
1200 Valid values are nil, t, `head', `first', `last', an integer or a
1201 predicate. See Info node `(gnus)Customizing Articles'."
1202 :group
'gnus-article-treat
1203 :link
'(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom
)
1206 (defcustom gnus-treat-hide-citation nil
1208 Valid values are nil, t, `head', `first', `last', an integer or a
1209 predicate. See Info node `(gnus)Customizing Articles'."
1210 :group
'gnus-article-treat
1211 :link
'(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-custom
)
1214 (defcustom gnus-treat-hide-citation-maybe nil
1216 Valid values are nil, t, `head', `first', `last', an integer or a
1217 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group
'gnus-article-treat
1219 :link
'(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom
)
1222 (defcustom gnus-treat-strip-list-identifiers
'head
1223 "Strip list identifiers from `gnus-list-identifiers`.
1224 Valid values are nil, t, `head', `first', `last', an integer or a
1225 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 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1232 "Gnus 5.10 (Emacs 22.1)")
1234 (defcustom gnus-treat-strip-pem nil
1235 "Strip PEM signatures.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1238 :group
'gnus-article-treat
1239 :link
'(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom
)
1242 (defcustom gnus-treat-strip-banner t
1243 "Strip banners from articles.
1244 The banner to be stripped is specified in the `banner' group parameter.
1245 Valid values are nil, t, `head', `first', `last', an integer or a
1246 predicate. See Info node `(gnus)Customizing Articles'."
1247 :group
'gnus-article-treat
1248 :link
'(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom
)
1251 (defcustom gnus-treat-highlight-headers
'head
1252 "Highlight the headers.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group
'gnus-article-treat
1256 :link
'(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-head-custom
)
1258 (put 'gnus-treat-highlight-headers
'highlight t
)
1260 (defcustom gnus-treat-highlight-citation t
1261 "Highlight cited text.
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group
'gnus-article-treat
1265 :link
'(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom
)
1267 (put 'gnus-treat-highlight-citation
'highlight t
)
1269 (defcustom gnus-treat-date-ut nil
1270 "Display the Date in UT (GMT).
1271 Valid values are nil, t, `head', `first', `last', an integer or a
1272 predicate. See Info node `(gnus)Customizing Articles'."
1273 :group
'gnus-article-treat
1274 :link
'(custom-manual "(gnus)Customizing Articles")
1275 :type gnus-article-treat-head-custom
)
1277 (defcustom gnus-treat-date-local nil
1278 "Display the Date in the local timezone.
1279 Valid values are nil, t, `head', `first', `last', an integer or a
1280 predicate. See Info node `(gnus)Customizing Articles'."
1281 :group
'gnus-article-treat
1282 :link
'(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-head-custom
)
1285 (defcustom gnus-treat-date-english nil
1286 "Display the Date in a format that can be read aloud in English.
1287 Valid values are nil, t, `head', `first', `last', an integer or a
1288 predicate. See Info node `(gnus)Customizing Articles'."
1290 :group
'gnus-article-treat
1291 :link
'(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-head-custom
)
1294 (defcustom gnus-treat-date-lapsed nil
1295 "Display the Date header in a way that says how much time has elapsed.
1296 Valid values are nil, t, `head', `first', `last', an integer or a
1297 predicate. See Info node `(gnus)Customizing Articles'."
1298 :group
'gnus-article-treat
1299 :link
'(custom-manual "(gnus)Customizing Articles")
1300 :type gnus-article-treat-head-custom
)
1302 (defcustom gnus-treat-date-combined-lapsed
'head
1303 "Display the Date header in a way that says how much time has elapsed.
1304 Valid values are nil, t, `head', `first', `last', an integer or a
1305 predicate. See Info node `(gnus)Customizing Articles'."
1306 :group
'gnus-article-treat
1307 :link
'(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom
)
1310 (defcustom gnus-treat-date-original nil
1311 "Display the date in the original timezone.
1312 Valid values are nil, t, `head', `first', `last', an integer or a
1313 predicate. See Info node `(gnus)Customizing Articles'."
1314 :group
'gnus-article-treat
1315 :link
'(custom-manual "(gnus)Customizing Articles")
1316 :type gnus-article-treat-head-custom
)
1318 (defcustom gnus-treat-date-iso8601 nil
1319 "Display the date in the ISO8601 format.
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-head-custom
)
1327 (defcustom gnus-treat-date-user-defined nil
1328 "Display the date in a user-defined format.
1329 The format is defined by the `gnus-article-time-format' variable.
1330 Valid values are nil, t, `head', `first', `last', an integer or a
1331 predicate. See Info node `(gnus)Customizing Articles'."
1332 :group
'gnus-article-treat
1333 :link
'(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-head-custom
)
1336 (defcustom gnus-treat-strip-headers-in-body t
1337 "Strip the X-No-Archive header line from the beginning of the body.
1338 Valid values are nil, t, `head', `first', `last', an integer or a
1339 predicate. See Info node `(gnus)Customizing Articles'."
1341 :group
'gnus-article-treat
1342 :link
'(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom
)
1345 (defcustom gnus-treat-strip-trailing-blank-lines nil
1346 "Strip trailing blank lines.
1347 Valid values are nil, t, `head', `first', `last', an integer or a
1348 predicate. See Info node `(gnus)Customizing Articles'.
1350 When set to t, it also strips trailing blanks in all MIME parts.
1351 Consider to use `last' instead."
1352 :group
'gnus-article-treat
1353 :link
'(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom
)
1356 (defcustom gnus-treat-strip-leading-blank-lines nil
1357 "Strip leading blank lines.
1358 Valid values are nil, t, `head', `first', `last', an integer or a
1359 predicate. See Info node `(gnus)Customizing Articles'.
1361 When set to t, it also strips trailing blanks in all MIME parts."
1362 :group
'gnus-article-treat
1363 :link
'(custom-manual "(gnus)Customizing Articles")
1364 :type gnus-article-treat-custom
)
1366 (defcustom gnus-treat-strip-multiple-blank-lines nil
1367 "Strip multiple blank lines.
1368 Valid values are nil, t, `head', `first', `last', an integer or a
1369 predicate. See Info node `(gnus)Customizing Articles'."
1370 :group
'gnus-article-treat
1371 :link
'(custom-manual "(gnus)Customizing Articles")
1372 :type gnus-article-treat-custom
)
1374 (defcustom gnus-treat-unfold-headers
'head
1375 "Unfold folded header lines.
1376 Valid values are nil, t, `head', `first', `last', an integer or a
1377 predicate. See Info node `(gnus)Customizing Articles'."
1379 :group
'gnus-article-treat
1380 :link
'(custom-manual "(gnus)Customizing Articles")
1381 :type gnus-article-treat-custom
)
1383 (defcustom gnus-article-unfold-long-headers nil
1384 "If non-nil, allow unfolding headers even if the header is long.
1385 If it is a regexp, only long headers matching this regexp are unfolded.
1386 If it is t, all long headers are unfolded.
1388 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1389 :version
"23.1" ;; No Gnus
1390 :group
'gnus-article-treat
1391 :type
'(choice (const nil
)
1392 (const :tag
"all" t
)
1395 (defcustom gnus-treat-fold-headers nil
1397 Valid values are nil, t, `head', `first', `last', an integer or a
1398 predicate. See Info node `(gnus)Customizing Articles'."
1400 :group
'gnus-article-treat
1401 :link
'(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom
)
1404 (defcustom gnus-treat-fold-newsgroups
'head
1405 "Fold the Newsgroups and Followup-To headers.
1406 Valid values are nil, t, `head', `first', `last', an integer or a
1407 predicate. See Info node `(gnus)Customizing Articles'."
1409 :group
'gnus-article-treat
1410 :link
'(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom
)
1413 (defcustom gnus-treat-overstrike t
1414 "Treat overstrike highlighting.
1415 Valid values are nil, t, `head', `first', `last', an integer or a
1416 predicate. See Info node `(gnus)Customizing Articles'."
1417 :group
'gnus-article-treat
1418 :link
'(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom
)
1420 (put 'gnus-treat-overstrike
'highlight t
)
1422 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1423 "Treat ANSI SGR control sequences.
1424 Valid values are nil, t, `head', `first', `last', an integer or a
1425 predicate. See Info node `(gnus)Customizing Articles'."
1426 :group
'gnus-article-treat
1427 :link
'(custom-manual "(gnus)Customizing Articles")
1428 :type gnus-article-treat-custom
)
1430 (make-obsolete-variable 'gnus-treat-display-xface
1431 'gnus-treat-display-x-face
"Emacs 22.1")
1433 (defcustom gnus-treat-display-x-face
1434 (and (not noninteractive
)
1435 (gnus-image-type-available-p 'xbm
)
1436 (if (featurep 'xemacs
)
1439 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1440 (executable-find "icontopbm"))
1441 ;; shell-command-to-string may signal an error, e.g. if
1442 ;; shell-file-name is not found.
1445 "Display X-Face headers.
1446 Valid values are nil and `head'.
1447 See Info node `(gnus)Customizing Articles' and Info node
1448 `(gnus)X-Face' for details."
1449 :group
'gnus-article-treat
1451 :link
'(custom-manual "(gnus)Customizing Articles")
1452 :link
'(custom-manual "(gnus)X-Face")
1453 :type gnus-article-treat-head-custom
1454 :set
(lambda (symbol value
)
1457 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1459 ((boundp 'gnus-treat-display-xface
)
1461 ** gnus-treat-display-xface is an obsolete variable;\
1462 use gnus-treat-display-x-face instead")
1463 (default-value 'gnus-treat-display-xface
))
1464 ((get 'gnus-treat-display-xface
'saved-value
)
1466 ** gnus-treat-display-xface is an obsolete variable;\
1467 use gnus-treat-display-x-face instead")
1468 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1471 (put 'gnus-treat-display-x-face
'highlight t
)
1473 (defcustom gnus-treat-display-face
1474 (and (not noninteractive
)
1475 (gnus-image-type-available-p 'png
)
1477 "Display Face headers.
1478 Valid values are nil, t, `head', `first', `last', an integer or a
1479 predicate. See Info node `(gnus)Customizing Articles' and Info
1480 node `(gnus)Face' for details."
1481 :group
'gnus-article-treat
1483 :link
'(custom-manual "(gnus)Customizing Articles")
1484 :link
'(custom-manual "(gnus)X-Face")
1485 :type gnus-article-treat-head-custom
)
1486 (put 'gnus-treat-display-face
'highlight t
)
1488 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1490 Valid values are nil, t, `head', `first', `last', an integer or a
1491 predicate. See Info node `(gnus)Customizing Articles' and Info
1492 node `(gnus)Smileys' for details."
1493 :group
'gnus-article-treat
1495 :link
'(custom-manual "(gnus)Customizing Articles")
1496 :link
'(custom-manual "(gnus)Smileys")
1497 :type gnus-article-treat-custom
)
1498 (put 'gnus-treat-display-smileys
'highlight t
)
1500 (defcustom gnus-treat-from-picon
1501 (if (and (gnus-image-type-available-p 'xpm
)
1502 (gnus-picons-installed-p))
1504 "Display picons in the From header.
1505 Valid values are nil, t, `head', `first', `last', an integer or a
1506 predicate. See Info node `(gnus)Customizing Articles' and Info
1507 node `(gnus)Picons' for details."
1509 :group
'gnus-article-treat
1511 :link
'(custom-manual "(gnus)Customizing Articles")
1512 :link
'(custom-manual "(gnus)Picons")
1513 :type gnus-article-treat-head-custom
)
1514 (put 'gnus-treat-from-picon
'highlight t
)
1516 (defcustom gnus-treat-mail-picon
1517 (if (and (gnus-image-type-available-p 'xpm
)
1518 (gnus-picons-installed-p))
1520 "Display picons in To and Cc headers.
1521 Valid values are nil, t, `head', `first', `last', an integer or a
1522 predicate. See Info node `(gnus)Customizing Articles' and Info
1523 node `(gnus)Picons' for details."
1525 :group
'gnus-article-treat
1527 :link
'(custom-manual "(gnus)Customizing Articles")
1528 :link
'(custom-manual "(gnus)Picons")
1529 :type gnus-article-treat-head-custom
)
1530 (put 'gnus-treat-mail-picon
'highlight t
)
1532 (defcustom gnus-treat-newsgroups-picon
1533 (if (and (gnus-image-type-available-p 'xpm
)
1534 (gnus-picons-installed-p))
1536 "Display picons in the Newsgroups and Followup-To headers.
1537 Valid values are nil, t, `head', `first', `last', an integer or a
1538 predicate. See Info node `(gnus)Customizing Articles' and Info
1539 node `(gnus)Picons' for details."
1541 :group
'gnus-article-treat
1543 :link
'(custom-manual "(gnus)Customizing Articles")
1544 :link
'(custom-manual "(gnus)Picons")
1545 :type gnus-article-treat-head-custom
)
1546 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1548 (defcustom gnus-treat-from-gravatar nil
1549 "Display gravatars in the From header.
1550 Valid values are nil, t, `head', `first', `last', an integer or a
1551 predicate. See Info node `(gnus)Customizing Articles' and Info
1552 node `(gnus)Gravatars' for details."
1554 :group
'gnus-article-treat
1555 :group
'gnus-gravatar
1556 :link
'(custom-manual "(gnus)Customizing Articles")
1557 :link
'(custom-manual "(gnus)Gravatars")
1558 :type gnus-article-treat-head-custom
)
1559 (put 'gnus-treat-from-gravatar
'highlight t
)
1561 (defcustom gnus-treat-mail-gravatar nil
1562 "Display gravatars in To and Cc headers.
1563 Valid values are nil, t, `head', `first', `last', an integer or a
1564 predicate. See Info node `(gnus)Customizing Articles' and Info
1565 node `(gnus)Gravatars' for details."
1567 :group
'gnus-article-treat
1568 :group
'gnus-gravatar
1569 :link
'(custom-manual "(gnus)Customizing Articles")
1570 :link
'(custom-manual "(gnus)Gravatars")
1571 :type gnus-article-treat-head-custom
)
1572 (put 'gnus-treat-mail-gravatar
'highlight t
)
1574 (defcustom gnus-treat-body-boundary
1575 (if (or gnus-treat-newsgroups-picon
1576 gnus-treat-mail-picon
1577 gnus-treat-from-picon
1578 gnus-treat-from-gravatar
1579 gnus-treat-mail-gravatar
)
1580 ;; If there's much decoration, the user might prefer a boundery.
1583 "Draw a boundary at the end of the headers.
1584 Valid values are nil and `head'.
1585 See Info node `(gnus)Customizing Articles' for details."
1587 :group
'gnus-article-treat
1588 :link
'(custom-manual "(gnus)Customizing Articles")
1589 :type gnus-article-treat-head-custom
)
1591 (defcustom gnus-treat-capitalize-sentences nil
1592 "Capitalize sentence-starting words.
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-wash-html nil
1602 Valid values are nil, t, `head', `first', `last', an integer or a
1603 predicate. See Info node `(gnus)Customizing Articles'."
1605 :group
'gnus-article-treat
1606 :link
'(custom-manual "(gnus)Customizing Articles")
1607 :type gnus-article-treat-custom
)
1609 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1611 Valid values are nil, t, `head', `first', `last', an integer or a
1612 predicate. See Info node `(gnus)Customizing Articles'."
1614 :group
'gnus-article-treat
1615 :link
'(custom-manual "(gnus)Customizing Articles")
1616 :type gnus-article-treat-custom
)
1618 (defcustom gnus-treat-x-pgp-sig nil
1620 To automatically treat X-PGP-Sig, set it to head.
1621 Valid values are nil, t, `head', `first', `last', an integer or a
1622 predicate. See Info node `(gnus)Customizing Articles'."
1624 :group
'gnus-article-treat
1625 :group
'mime-security
1626 :link
'(custom-manual "(gnus)Customizing Articles")
1627 :type gnus-article-treat-custom
)
1629 (defvar gnus-article-encrypt-protocol-alist
1630 '(("PGP" . mml2015-self-encrypt
)))
1632 ;; Set to nil if more than one protocol added to
1633 ;; gnus-article-encrypt-protocol-alist.
1634 (defcustom gnus-article-encrypt-protocol
"PGP"
1635 "The protocol used for encrypt articles.
1636 It is a string, such as \"PGP\". If nil, ask user."
1639 :group
'mime-security
)
1641 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1642 (mm-coding-system-p 'utf-8
)
1643 (executable-find idna-program
))
1644 "Whether IDNA decoding of headers is used when viewing messages.
1645 This requires GNU Libidn, and by default only enabled if it is found."
1647 :group
'gnus-article-headers
1650 (defcustom gnus-article-over-scroll nil
1651 "If non-nil, allow scrolling the article buffer even when there no more text."
1653 :group
'gnus-article
1656 (defcustom gnus-inhibit-images nil
1657 "Non-nil means inhibit displaying of images inline in the article body."
1659 :group
'gnus-article
1662 (defcustom gnus-blocked-images
'gnus-block-private-groups
1663 "Images that have URLs matching this regexp will be blocked.
1664 This can also be a function to be evaluated. If so, it will be
1665 called with the group name as the parameter, and should return a
1671 ;;; Internal variables
1673 (defvar gnus-english-month-names
1674 '("January" "February" "March" "April" "May" "June" "July" "August"
1675 "September" "October" "November" "December"))
1677 (defvar article-goto-body-goes-to-point-min-p nil
)
1678 (defvar gnus-article-wash-types nil
)
1679 (defvar gnus-article-emphasis-alist nil
)
1680 (defvar gnus-article-image-alist nil
)
1682 (defvar gnus-article-mime-handle-alist-1 nil
)
1683 (defvar gnus-treatment-function-alist
1684 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1685 (gnus-treat-strip-banner gnus-article-strip-banner
)
1686 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1687 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1688 (gnus-treat-buttonize gnus-article-add-buttons
)
1689 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1690 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1691 (gnus-treat-strip-cr gnus-article-remove-cr
)
1692 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1693 (gnus-treat-date-ut gnus-article-date-ut
)
1694 (gnus-treat-date-local gnus-article-date-local
)
1695 (gnus-treat-date-english gnus-article-date-english
)
1696 (gnus-treat-date-original gnus-article-date-original
)
1697 (gnus-treat-date-user-defined gnus-article-date-user
)
1698 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1699 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1700 (gnus-treat-date-combined-lapsed gnus-article-date-combined-lapsed
)
1701 (gnus-treat-display-x-face gnus-article-display-x-face
)
1702 (gnus-treat-display-face gnus-article-display-face
)
1703 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1704 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1705 (gnus-treat-hide-signature gnus-article-hide-signature
)
1706 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1707 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1708 (gnus-treat-from-picon gnus-treat-from-picon
)
1709 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1710 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1711 (gnus-treat-strip-pem gnus-article-hide-pem
)
1712 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1713 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1714 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1715 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1716 (gnus-treat-strip-trailing-blank-lines
1717 gnus-article-remove-trailing-blank-lines
)
1718 (gnus-treat-strip-leading-blank-lines
1719 gnus-article-strip-leading-blank-lines
)
1720 (gnus-treat-strip-multiple-blank-lines
1721 gnus-article-strip-multiple-blank-lines
)
1722 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1723 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1724 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1725 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1726 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1727 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1728 (gnus-treat-display-smileys gnus-treat-smiley
)
1729 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1730 (gnus-treat-wash-html gnus-article-wash-html
)
1731 (gnus-treat-emphasize gnus-article-emphasize
)
1732 (gnus-treat-hide-citation gnus-article-hide-citation
)
1733 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1734 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1735 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1737 (defvar gnus-article-mime-handle-alist nil
)
1738 (defvar article-lapsed-timer nil
)
1739 (defvar gnus-article-current-summary nil
)
1741 (defvar gnus-article-mode-syntax-table
1742 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1743 ;; This causes the citation match run O(2^n).
1744 ;; (modify-syntax-entry ?- "w" table)
1745 (modify-syntax-entry ?
> ")<" table
)
1746 (modify-syntax-entry ?
< "(>" table
)
1747 ;; make M-. in article buffers work for `foo' strings
1748 (modify-syntax-entry ?
' " " table
)
1749 (modify-syntax-entry ?
` " " table
)
1751 "Syntax table used in article mode buffers.
1752 Initialized from `text-mode-syntax-table.")
1754 (defvar gnus-save-article-buffer nil
)
1756 (defvar gnus-number-of-articles-to-be-saved nil
)
1758 (defvar gnus-inhibit-hiding nil
)
1760 (defvar gnus-article-edit-mode nil
)
1762 ;;; Macros for dealing with the article buffer.
1764 (defmacro gnus-with-article-headers
(&rest forms
)
1765 `(with-current-buffer gnus-article-buffer
1767 (let ((inhibit-read-only t
)
1768 (inhibit-point-motion-hooks t
)
1769 (case-fold-search t
))
1770 (article-narrow-to-head)
1773 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1774 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1776 (defmacro gnus-with-article-buffer
(&rest forms
)
1777 `(with-current-buffer gnus-article-buffer
1778 (let ((inhibit-read-only t
))
1781 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1782 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1784 (defun gnus-article-goto-header (header)
1785 "Go to HEADER, which is a regular expression."
1786 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1788 (defsubst gnus-article-hide-text
(b e props
)
1789 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1790 (gnus-add-text-properties-when 'article-type nil b e props
)
1791 (when (memq 'intangible props
)
1793 (max (1- b
) (point-min))
1794 b
'intangible
(cddr (memq 'intangible props
)))))
1796 (defsubst gnus-article-unhide-text
(b e
)
1797 "Remove hidden text properties from region between B and E."
1798 (remove-text-properties b e gnus-hidden-properties
)
1799 (when (memq 'intangible gnus-hidden-properties
)
1800 (put-text-property (max (1- b
) (point-min))
1801 b
'intangible nil
)))
1803 (defun gnus-article-hide-text-type (b e type
)
1804 "Hide text of TYPE between B and E."
1805 (gnus-add-wash-type type
)
1806 (gnus-article-hide-text
1807 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1809 (defun gnus-article-unhide-text-type (b e type
)
1810 "Unhide text of TYPE between B and E."
1811 (gnus-delete-wash-type type
)
1812 (remove-text-properties
1813 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1814 (when (memq 'intangible gnus-hidden-properties
)
1815 (put-text-property (max (1- b
) (point-min))
1816 b
'intangible nil
)))
1818 (defun gnus-article-hide-text-of-type (type)
1819 "Hide text of TYPE in the current buffer."
1821 (let ((b (point-min))
1823 (while (setq b
(text-property-any b e
'article-type type
))
1824 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1826 (defun gnus-article-delete-text-of-type (type)
1827 "Delete text of TYPE in the current buffer."
1829 (let ((b (point-min)))
1830 (if (eq type
'multipart
)
1831 ;; Remove MIME buttons associated with multipart/alternative parts.
1834 (while (if (get-text-property (point) 'gnus-part
)
1836 (when (setq b
(next-single-property-change (point)
1841 (skip-chars-forward "\n")
1842 (when (eq (get-text-property b
'article-type
) 'multipart
)
1843 (delete-region b
(point)))))
1844 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1846 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1849 (defun gnus-article-delete-invisible-text ()
1850 "Delete all invisible text in the current buffer."
1852 (let ((b (point-min)))
1853 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1855 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1858 (defun gnus-article-text-type-exists-p (type)
1859 "Say whether any text of type TYPE exists in the buffer."
1860 (text-property-any (point-min) (point-max) 'article-type type
))
1862 (defsubst gnus-article-header-rank
()
1863 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1864 (let ((list gnus-sorted-header-list
)
1867 (if (looking-at (car list
))
1869 (setq list
(cdr list
))
1873 (defun article-hide-headers (&optional arg delete
)
1874 "Hide unwanted headers and possibly sort them as well."
1876 ;; This function might be inhibited.
1877 (unless gnus-inhibit-hiding
1878 (let ((inhibit-read-only t
)
1879 (case-fold-search t
)
1880 (max (1+ (length gnus-sorted-header-list
)))
1881 (inhibit-point-motion-hooks t
)
1882 (cur (current-buffer))
1883 ignored visible beg
)
1885 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1886 ;; group parameters, so we should go to the summary buffer.
1889 (progn (set-buffer gnus-summary-buffer
) t
)
1891 (setq ignored
(when (not gnus-visible-headers
)
1892 (cond ((stringp gnus-ignored-headers
)
1893 gnus-ignored-headers
)
1894 ((listp gnus-ignored-headers
)
1895 (mapconcat 'identity
1896 gnus-ignored-headers
1898 visible
(cond ((stringp gnus-visible-headers
)
1899 gnus-visible-headers
)
1900 ((and gnus-visible-headers
1901 (listp gnus-visible-headers
))
1902 (mapconcat 'identity
1903 gnus-visible-headers
1907 ;; First we narrow to just the headers.
1908 (article-narrow-to-head)
1909 ;; Hide any "From " lines at the beginning of (mail) articles.
1910 (while (looking-at "From ")
1913 (delete-region (point-min) (point)))
1914 ;; Then treat the rest of the header lines.
1915 ;; Then we use the two regular expressions
1916 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1917 ;; select which header lines is to remain visible in the
1919 (while (re-search-forward "^[^ \t:]*:" nil t
)
1921 ;; Mark the rank of the header.
1923 (point) (1+ (point)) 'message-rank
1924 (if (or (and visible
(looking-at visible
))
1926 (not (looking-at ignored
))))
1927 (gnus-article-header-rank)
1930 (message-sort-headers-1)
1931 (when (setq beg
(text-property-any
1932 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1933 ;; We delete the unwanted headers.
1934 (gnus-add-wash-type 'headers
)
1935 (add-text-properties (point-min) (+ 5 (point-min))
1936 '(article-type headers dummy-invisible t
))
1937 (delete-region beg
(point-max))))))))
1939 (defun article-hide-boring-headers (&optional arg
)
1940 "Toggle hiding of headers that aren't very interesting.
1941 If given a negative prefix, always show; if given a positive prefix,
1943 (interactive (gnus-article-hidden-arg))
1944 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1945 (not gnus-show-all-headers
))
1948 (let ((inhibit-read-only t
)
1949 (inhibit-point-motion-hooks t
))
1950 (article-narrow-to-head)
1951 (dolist (elem gnus-boring-article-headers
)
1952 (goto-char (point-min))
1954 ;; Hide empty headers.
1956 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1958 (gnus-article-hide-text-type
1962 (if (re-search-forward "^[^ \t]" nil t
)
1966 ;; Hide boring Newsgroups header.
1967 ((eq elem
'newsgroups
)
1968 (when (gnus-string-equal
1969 (gnus-fetch-field "newsgroups")
1970 (gnus-group-real-name
1971 (if (boundp 'gnus-newsgroup-name
)
1974 (gnus-article-hide-header "newsgroups")))
1975 ((eq elem
'to-address
)
1976 (let ((to (message-fetch-field "to"))
1978 (gnus-parameter-to-address
1979 (if (boundp 'gnus-newsgroup-name
)
1980 gnus-newsgroup-name
""))))
1981 (when (and to to-address
1984 ;; only one address in To
1985 (nth 1 (mail-extract-address-components to
))
1987 (gnus-article-hide-header "to"))))
1989 (let ((to (message-fetch-field "to"))
1991 (gnus-parameter-to-list
1992 (if (boundp 'gnus-newsgroup-name
)
1993 gnus-newsgroup-name
""))))
1994 (when (and to to-list
1997 ;; only one address in To
1998 (nth 1 (mail-extract-address-components to
))
2000 (gnus-article-hide-header "to"))))
2002 (let ((cc (message-fetch-field "cc"))
2004 (gnus-parameter-to-list
2005 (if (boundp 'gnus-newsgroup-name
)
2006 gnus-newsgroup-name
""))))
2007 (when (and cc to-list
2010 ;; only one address in CC
2011 (nth 1 (mail-extract-address-components cc
))
2013 (gnus-article-hide-header "cc"))))
2014 ((eq elem
'followup-to
)
2015 (when (gnus-string-equal
2016 (message-fetch-field "followup-to")
2017 (message-fetch-field "newsgroups"))
2018 (gnus-article-hide-header "followup-to")))
2019 ((eq elem
'reply-to
)
2020 (if (gnus-group-find-parameter
2021 gnus-newsgroup-name
'broken-reply-to
)
2022 (gnus-article-hide-header "reply-to")
2023 (let ((from (message-fetch-field "from"))
2024 (reply-to (message-fetch-field "reply-to")))
2031 (lambda (x) (downcase (cadr x
)))
2032 (mail-extract-address-components from t
))
2035 (lambda (x) (downcase (cadr x
)))
2036 (mail-extract-address-components reply-to t
))
2038 (gnus-article-hide-header "reply-to")))))
2040 (let ((date (with-current-buffer gnus-original-article-buffer
2041 ;; If date in `gnus-article-buffer' is localized
2042 ;; (`gnus-treat-date-user-defined'),
2043 ;; `days-between' might fail.
2044 (message-fetch-field "date"))))
2046 (< (days-between (current-time-string) date
)
2048 (gnus-article-hide-header "date"))))
2050 (let ((to (message-fetch-field "to"))
2051 (cc (message-fetch-field "cc")))
2052 (when (> (length to
) 1024)
2053 (gnus-article-hide-header "to"))
2054 (when (> (length cc
) 1024)
2055 (gnus-article-hide-header "cc"))))
2059 (goto-char (point-min))
2060 (while (re-search-forward "^to:" nil t
)
2061 (setq to-count
(1+ to-count
)))
2062 (when (> to-count
1)
2063 (while (> to-count
0)
2064 (goto-char (point-min))
2066 (re-search-forward "^to:" nil nil to-count
)
2068 (narrow-to-region (point) (point-max))
2069 (gnus-article-hide-header "to"))
2070 (setq to-count
(1- to-count
))))
2071 (goto-char (point-min))
2072 (while (re-search-forward "^cc:" nil t
)
2073 (setq cc-count
(1+ cc-count
)))
2074 (when (> cc-count
1)
2075 (while (> cc-count
0)
2076 (goto-char (point-min))
2078 (re-search-forward "^cc:" nil nil cc-count
)
2080 (narrow-to-region (point) (point-max))
2081 (gnus-article-hide-header "cc"))
2082 (setq cc-count
(1- cc-count
)))))))))))))
2084 (defun gnus-article-hide-header (header)
2086 (goto-char (point-min))
2087 (when (re-search-forward (concat "^" header
":") nil t
)
2088 (gnus-article-hide-text-type
2092 (if (re-search-forward "^[^ \t]" nil t
)
2097 (defvar gnus-article-normalized-header-length
40
2098 "Length of normalized headers.")
2100 (defun article-normalize-headers ()
2101 "Make all header lines 40 characters long."
2103 (let ((inhibit-read-only t
)
2107 (article-narrow-to-head)
2110 ((< (setq column
(- (point-at-eol) (point)))
2111 gnus-article-normalized-header-length
)
2113 (insert (make-string
2114 (- gnus-article-normalized-header-length column
)
2116 ((> column gnus-article-normalized-header-length
)
2117 (gnus-put-text-property
2119 (forward-char gnus-article-normalized-header-length
)
2126 (forward-line 1))))))
2128 (defun article-treat-dumbquotes ()
2129 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2130 Note that this function guesses whether a character is a sm*rtq**t* or
2131 not, so it should only be used interactively.
2133 Sm*rtq**t*s are M****s***'s unilateral extension to the
2134 iso-8859-1 character map in an attempt to provide more quoting
2135 characters. If you see something like \\222 or \\264 where
2136 you're expecting some kind of apostrophe or quotation mark, then
2139 (article-translate-strings gnus-article-dumbquotes-map
))
2141 (defvar org-entities
)
2143 (defun article-treat-non-ascii ()
2144 "Translate many Unicode characters into their ASCII equivalents."
2146 (require 'org-entities
)
2147 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2148 (dolist (elem org-entities
)
2149 (when (and (listp elem
)
2150 (= (length (nth 6 elem
)) 1))
2151 (if (featurep 'xemacs
)
2152 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2153 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2155 (when (article-goto-body)
2156 (let ((inhibit-read-only t
)
2159 (if (not (setq replace
(if (featurep 'xemacs
)
2160 (get-char-table (following-char) table
)
2161 (aref table
(following-char)))))
2164 (setq props
(text-properties-at (point)))
2166 (add-text-properties (point) (progn (insert replace
) (point))
2168 (insert replace
)))))))))
2170 (defun article-translate-characters (from to
)
2171 "Translate all characters in the body of the article according to FROM and TO.
2172 FROM is a string of characters to translate from; to is a string of
2173 characters to translate to."
2175 (when (article-goto-body)
2176 (let ((inhibit-read-only t
)
2177 (x (make-string 225 ?x
))
2179 (while (< (incf i
) (length x
))
2182 (while (< i
(length from
))
2183 (aset x
(aref from i
) (aref to i
))
2185 (translate-region (point) (point-max) x
)))))
2187 (defun article-translate-strings (map)
2188 "Translate all string in the body of the article according to MAP.
2189 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2191 (when (article-goto-body)
2192 (let ((inhibit-read-only t
))
2194 (let ((from (car elem
))
2198 (while (search-forward from nil t
)
2201 (if (eq (following-char) from
)
2205 (forward-char 1)))))))))))
2207 (defun article-treat-overstrike ()
2208 "Translate overstrikes into bold text."
2211 (when (article-goto-body)
2212 (let ((inhibit-read-only t
))
2213 (while (search-forward "\b" nil t
)
2214 (let ((next (char-after))
2215 (previous (char-after (- (point) 2))))
2216 ;; We do the boldification/underlining by hiding the
2217 ;; overstrikes and putting the proper text property
2221 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2222 (put-text-property (point) (1+ (point)) 'face
'bold
))
2224 (gnus-article-hide-text-type
2225 (1- (point)) (1+ (point)) 'overstrike
)
2227 (- (point) 2) (1- (point)) 'face
'underline
))
2229 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2231 (point) (1+ (point)) 'face
'underline
)))))))))
2233 (defun article-treat-ansi-sequences ()
2234 "Translate ANSI SGR control sequences into overlays or extents."
2237 (when (article-goto-body)
2238 (let ((inhibit-read-only t
))
2239 (ansi-color-apply-on-region (point) (point-max))))))
2241 (defun gnus-article-treat-unfold-headers ()
2242 "Unfold folded message headers.
2243 Only the headers that fit into the current window width will be
2246 (gnus-with-article-headers
2250 (mail-header-narrow-to-field)
2251 (let* ((header (buffer-string))
2253 (or (equal gnus-article-unfold-long-headers t
)
2254 (and (stringp gnus-article-unfold-long-headers
)
2255 (string-match gnus-article-unfold-long-headers header
)))))
2258 (goto-char (point-min))
2259 (while (re-search-forward "\n[\t ]" nil t
)
2260 (replace-match " " t t
)))
2261 (setq length
(- (point-max) (point-min) 1))
2262 (when (or unfoldable
2263 (< length
(window-width)))
2264 (while (re-search-forward "\n[\t ]" nil t
)
2265 (replace-match " " t t
))))
2266 (goto-char (point-max)))))))
2268 (defun gnus-article-treat-fold-headers ()
2269 "Fold message headers."
2271 (gnus-with-article-headers
2274 (mail-header-narrow-to-field)
2275 (mail-header-fold-field)
2276 (goto-char (point-max))))))
2278 (defun gnus-treat-smiley ()
2279 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2281 (gnus-with-article-buffer
2282 (if (memq 'smiley gnus-article-wash-types
)
2283 (gnus-delete-images 'smiley
)
2285 (let ((images (smiley-region (point) (point-max))))
2287 (gnus-add-wash-type 'smiley
)
2288 (dolist (image images
)
2289 (gnus-add-image 'smiley image
)))))))
2291 (defun gnus-article-remove-images ()
2292 "Remove all images from the article buffer."
2294 (gnus-with-article-buffer
2297 (dolist (elem gnus-article-image-alist
)
2298 (gnus-delete-images (car elem
))))))
2300 (defun gnus-article-show-images ()
2301 "Show any images that are in the HTML-rendered article buffer.
2302 This only works if the article in question is HTML."
2304 (gnus-with-article-buffer
2307 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2309 (destructuring-bind (start end function
) region
2310 (funcall function
(get-text-property start
'image-url
)
2313 (defun gnus-article-treat-fold-newsgroups ()
2314 "Unfold folded message headers.
2315 Only the headers that fit into the current window width will be
2318 (gnus-with-article-headers
2319 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2321 (mail-header-narrow-to-field)
2322 (while (re-search-forward ", *" nil t
)
2323 (replace-match ", " t t
))
2324 (mail-header-fold-field)
2325 (goto-char (point-max))))))
2327 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2328 "Value of `truncate-lines' in Gnus Article buffer.
2329 Valid values are nil, t, `head', `first', `last', an integer or a
2330 predicate. See Info node `(gnus)Customizing Articles'."
2331 :version
"23.1" ;; No Gnus
2332 :group
'gnus-article
2333 ;; :link '(custom-manual "(gnus)Customizing Articles")
2336 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2337 "Toggle whether to fold or truncate long lines in article the buffer.
2338 If ARG is non-nil and not a number, toggle
2339 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2340 long lines if and only if arg is positive."
2343 ((and (numberp arg
) (> arg
0))
2344 (setq gnus-article-truncate-lines t
))
2346 (setq gnus-article-truncate-lines nil
))
2348 (setq gnus-article-truncate-lines
2349 (not gnus-article-truncate-lines
))))
2350 (gnus-with-article-buffer
2352 ((and (numberp arg
) (> arg
0))
2353 (setq truncate-lines nil
))
2355 (setq truncate-lines t
)))
2356 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2357 ;; `toggle-truncate-lines' needs an argument.
2358 (toggle-truncate-lines)))
2360 (defun gnus-article-treat-body-boundary ()
2361 "Place a boundary line at the end of the headers."
2363 (when (and gnus-body-boundary-delimiter
2364 (> (length gnus-body-boundary-delimiter
) 0))
2365 (gnus-with-article-headers
2366 (goto-char (point-max))
2367 (let ((start (point)))
2368 (insert "X-Boundary: ")
2369 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2371 (while (>= (window-width) (length str
))
2372 (setq str
(concat str gnus-body-boundary-delimiter
)))
2373 (substring str
0 (window-width)))
2375 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2377 (defun article-fill-long-lines ()
2378 "Fill lines that are wider than the window width."
2381 (let ((inhibit-read-only t
)
2382 (width (window-width (get-buffer-window (current-buffer)))))
2385 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2388 (when (>= (current-column) (min fill-column width
))
2389 (narrow-to-region (min (1+ (point)) (point-max))
2391 (let ((goback (point-marker)))
2392 (fill-paragraph nil
)
2393 (goto-char (marker-position goback
)))
2395 (forward-line 1)))))))
2397 (defun article-capitalize-sentences ()
2398 "Capitalize the first word in each sentence."
2401 (let ((inhibit-read-only t
)
2402 (paragraph-start "^[\n\^L]"))
2406 (forward-sentence)))))
2408 (defun article-remove-cr ()
2409 "Remove trailing CRs and then translate remaining CRs into LFs."
2412 (let ((inhibit-read-only t
))
2413 (goto-char (point-min))
2414 (while (re-search-forward "\r+$" nil t
)
2415 (replace-match "" t t
))
2416 (goto-char (point-min))
2417 (while (search-forward "\r" nil t
)
2418 (replace-match "\n" t t
)))))
2420 (defun article-remove-trailing-blank-lines ()
2421 "Remove all trailing blank lines from the article."
2424 (let ((inhibit-read-only t
))
2425 (goto-char (point-max))
2429 (while (and (not (bobp))
2430 (looking-at "^[ \t]*$")
2431 (not (gnus-annotation-in-region-p
2432 (point) (point-at-eol))))
2437 (defvar gnus-face-properties-alist
)
2439 (defun article-display-face (&optional force
)
2440 "Display any Face headers in the header."
2441 (interactive (list 'force
))
2442 (let ((wash-face-p buffer-read-only
))
2443 (gnus-with-article-headers
2444 ;; When displaying parts, this function can be called several times on
2445 ;; the same article, without any intended toggle semantic (as typing `W
2446 ;; D d' would have). So face deletion must occur only when we come from
2447 ;; an interactive command, that is when the *Article* buffer is
2449 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2450 (gnus-delete-images 'face
)
2451 (let ((from (message-fetch-field "from"))
2453 (save-current-buffer
2454 (when (and wash-face-p
2455 (gnus-buffer-live-p gnus-original-article-buffer
)
2456 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2457 (set-buffer gnus-original-article-buffer
))
2459 (mail-narrow-to-head)
2461 ;; Check whether this face is censored.
2462 (not (and gnus-article-x-face-too-ugly
2464 (setq from
(message-fetch-field "from")))
2465 (string-match gnus-article-x-face-too-ugly
2467 (while (gnus-article-goto-header "Face")
2468 (push (mail-header-field-value) faces
)))))
2470 (goto-char (point-min))
2472 (unless (setq from
(gnus-article-goto-header "from"))
2475 (insert " [no `from' set]\n"))
2477 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2479 (apply 'gnus-create-image png
'png t
2480 (cdr (assq 'png gnus-face-properties-alist
))))
2482 (gnus-add-wash-type 'face
)
2483 (gnus-add-image 'face image
)
2484 (gnus-put-image image nil
'face
))))))))))
2486 (defun article-display-x-face (&optional force
)
2487 "Look for an X-Face header and display it if present."
2488 (interactive (list 'force
))
2489 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2490 (gnus-with-article-headers
2491 ;; Delete the old process, if any.
2492 (when (process-status "article-x-face")
2493 (delete-process "article-x-face"))
2494 ;; See the comment in `article-display-face'.
2495 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2496 ;; We have already displayed X-Faces, so we remove them
2498 (gnus-delete-images 'xface
)
2500 (let ((from (message-fetch-field "from"))
2502 (save-current-buffer
2503 (when (and wash-face-p
2504 (gnus-buffer-live-p gnus-original-article-buffer
)
2505 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2506 ;; If type `W f', use gnus-original-article-buffer,
2507 ;; otherwise use the current buffer because displaying
2508 ;; RFC822 parts calls this function too.
2509 (set-buffer gnus-original-article-buffer
))
2511 (mail-narrow-to-head)
2512 (and gnus-article-x-face-command
2514 ;; Check whether this face is censored.
2515 (not (and gnus-article-x-face-too-ugly
2517 (setq from
(message-fetch-field "from")))
2518 (string-match gnus-article-x-face-too-ugly
2520 (while (gnus-article-goto-header "X-Face")
2521 (push (mail-header-field-value) x-faces
)))))
2523 ;; We display the face.
2524 (cond ((functionp gnus-article-x-face-command
)
2525 ;; The command is a lisp function, so we call it.
2526 (mapc gnus-article-x-face-command x-faces
))
2527 ((stringp gnus-article-x-face-command
)
2528 ;; The command is a string, so we interpret the command
2529 ;; as a, well, command, and fork it off.
2530 (let ((process-connection-type nil
))
2531 (gnus-set-process-query-on-exit-flag
2533 "article-x-face" nil shell-file-name
2534 shell-command-switch gnus-article-x-face-command
)
2536 ;; Sending multiple EOFs to xv doesn't work,
2537 ;; so we only do a single external face.
2539 (insert (car x-faces
))
2540 (process-send-region "article-x-face"
2541 (point-min) (point-max)))
2542 (process-send-eof "article-x-face")))
2544 (error "`%s' set to `%s' is not a function"
2545 gnus-article-x-face-command
2546 'gnus-article-x-face-command
)))))))))
2548 (defun article-decode-mime-words ()
2549 "Decode all MIME-encoded words in the article."
2551 (gnus-with-article-buffer
2552 (let ((inhibit-point-motion-hooks t
)
2553 (mail-parse-charset gnus-newsgroup-charset
)
2554 (mail-parse-ignored-charsets
2555 (with-current-buffer gnus-summary-buffer
2556 gnus-newsgroup-ignored-charsets
)))
2557 (mail-decode-encoded-word-region (point-min) (point-max)))))
2559 (defun article-decode-charset (&optional prompt
)
2560 "Decode charset-encoded text in the article.
2561 If PROMPT (the prefix), prompt for a coding system to use."
2563 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2564 (inhibit-read-only t
)
2565 (mail-parse-charset gnus-newsgroup-charset
)
2566 (mail-parse-ignored-charsets
2567 (save-excursion (condition-case nil
2568 (set-buffer gnus-summary-buffer
)
2570 gnus-newsgroup-ignored-charsets
))
2571 ct cte ctl charset format
)
2574 (article-narrow-to-head)
2575 (setq ct
(message-fetch-field "Content-Type" t
)
2576 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2577 ctl
(and ct
(mail-header-parse-content-type ct
))
2580 (mm-read-coding-system "Charset to decode: "))
2582 (mail-content-type-get ctl
'charset
)))
2583 format
(and ctl
(mail-content-type-get ctl
'format
)))
2585 (setq cte
(mail-header-strip cte
)))
2586 (if (and ctl
(not (string-match "/" (car ctl
))))
2588 (goto-char (point-max)))
2591 (narrow-to-region (point) (point-max))
2592 (when (and (eq mail-parse-charset
'gnus-decoded
)
2593 (eq (mm-body-7-or-8) '8bit
))
2594 ;; The text code could have been decoded.
2595 (setq charset mail-parse-charset
))
2596 (when (and (or (not ctl
)
2597 (equal (car ctl
) "text/plain"))
2598 (not format
)) ;; article with format will decode later.
2600 charset
(and cte
(intern (downcase
2601 (gnus-strip-whitespace cte
))))
2604 (defun article-decode-encoded-words ()
2605 "Remove encoded-word encoding from headers."
2606 (let ((inhibit-point-motion-hooks t
)
2607 (mail-parse-charset gnus-newsgroup-charset
)
2608 (mail-parse-ignored-charsets
2609 (save-excursion (condition-case nil
2610 (set-buffer gnus-summary-buffer
)
2612 gnus-newsgroup-ignored-charsets
))
2613 (inhibit-read-only t
)
2615 (goto-char (point-min))
2616 (when (search-forward "\n\n" nil
'move
)
2623 (memq (char-after) '(?
\t ?
)))))
2624 (setq start
(point))
2626 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2627 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2628 (funcall gnus-decode-address-function start end
)
2629 (funcall gnus-decode-header-function start end
))
2630 (goto-char (setq end start
)))))
2632 (defun article-decode-group-name ()
2633 "Decode group names in Newsgroups, Followup-To and Xref headers."
2634 (let ((inhibit-point-motion-hooks t
)
2635 (inhibit-read-only t
)
2636 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2638 (when (and (or gnus-group-name-charset-method-alist
2639 gnus-group-name-charset-group-alist
)
2640 (gnus-buffer-live-p gnus-original-article-buffer
))
2642 (article-narrow-to-head)
2643 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2644 (with-current-buffer gnus-original-article-buffer
2645 (goto-char (point-min)))
2646 (setq regexp
(concat "^" header
2647 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2648 (while (re-search-forward regexp nil t
)
2649 (replace-match (save-match-data
2650 (gnus-decode-newsgroups
2651 ;; XXX how to use data in article buffer?
2652 (with-current-buffer gnus-original-article-buffer
2653 (re-search-forward regexp nil t
)
2655 gnus-newsgroup-name method
))
2657 (goto-char (point-min)))))))
2659 (autoload 'idna-to-unicode
"idna")
2661 (defun article-decode-idna-rhs ()
2662 "Decode IDNA strings in RHS in various headers in current buffer.
2663 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2664 Mail-Reply-To: and Mail-Followup-To:."
2667 (let ((inhibit-point-motion-hooks t
)
2668 (inhibit-read-only t
))
2669 (article-narrow-to-head)
2670 (goto-char (point-min))
2671 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2673 (when (save-match-data
2674 (and (setq ace
(match-string 1))
2676 (and (re-search-backward "^[^ \t]" nil t
)
2677 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2678 (setq unicode
(idna-to-unicode ace
))))
2679 (unless (string= ace unicode
)
2680 (replace-match unicode nil nil nil
1)))))))))
2682 (defun article-de-quoted-unreadable (&optional force read-charset
)
2683 "Translate a quoted-printable-encoded article.
2684 If FORCE, decode the article whether it is marked as quoted-printable
2686 If READ-CHARSET, ask for a coding system."
2687 (interactive (list 'force current-prefix-arg
))
2689 (let ((inhibit-read-only t
) type charset
)
2690 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2691 (with-current-buffer gnus-original-article-buffer
2693 (gnus-fetch-field "content-transfer-encoding"))
2694 (let* ((ct (gnus-fetch-field "content-type"))
2695 (ctl (and ct
(mail-header-parse-content-type ct
))))
2696 (setq charset
(and ctl
2697 (mail-content-type-get ctl
'charset
)))
2698 (if (stringp charset
)
2699 (setq charset
(intern (downcase charset
)))))))
2701 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2703 (setq charset gnus-newsgroup-charset
))
2705 (and type
(let ((case-fold-search t
))
2706 (string-match "quoted-printable" type
))))
2708 (quoted-printable-decode-region
2709 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2711 (defun article-de-base64-unreadable (&optional force read-charset
)
2712 "Translate a base64 article.
2713 If FORCE, decode the article whether it is marked as base64 not.
2714 If READ-CHARSET, ask for a coding system."
2715 (interactive (list 'force current-prefix-arg
))
2717 (let ((inhibit-read-only t
) type charset
)
2718 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2719 (with-current-buffer gnus-original-article-buffer
2721 (gnus-fetch-field "content-transfer-encoding"))
2722 (let* ((ct (gnus-fetch-field "content-type"))
2723 (ctl (and ct
(mail-header-parse-content-type ct
))))
2724 (setq charset
(and ctl
2725 (mail-content-type-get ctl
'charset
)))
2726 (if (stringp charset
)
2727 (setq charset
(intern (downcase charset
)))))))
2729 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2731 (setq charset gnus-newsgroup-charset
))
2733 (and type
(let ((case-fold-search t
))
2734 (string-match "base64" type
))))
2737 (narrow-to-region (point) (point-max))
2738 (base64-decode-region (point-min) (point-max))
2739 (mm-decode-coding-region
2740 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2745 (defun article-decode-HZ ()
2746 "Translate a HZ-encoded article."
2750 (let ((inhibit-read-only t
))
2751 (rfc1843-decode-region (point-min) (point-max)))))
2753 (defun article-unsplit-urls ()
2754 "Remove the newlines that some other mailers insert into URLs."
2757 (let ((inhibit-read-only t
))
2758 (goto-char (point-min))
2759 (while (re-search-forward
2760 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2761 (replace-match "\\1\\3" t
)))
2762 (when (interactive-p)
2763 (gnus-treat-article nil
))))
2765 (defun article-wash-html ()
2766 "Format an HTML article."
2769 (buffer-read-only nil
))
2770 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2771 (setq handles
(mm-dissect-buffer t t
)))
2773 (delete-region (point) (point-max))
2774 (mm-inline-text-html handles
)))
2776 (defvar gnus-article-browse-html-temp-list nil
2777 "List of temporary files created by `gnus-article-browse-html-parts'.
2778 Internal variable.")
2780 (defcustom gnus-article-browse-delete-temp
'ask
2781 "What to do with temporary files from `gnus-article-browse-html-parts'.
2782 If nil, don't delete temporary files. If it is t, delete them on
2783 exit from the summary buffer. If it is the symbol `file', query
2784 on each file, if it is `ask' ask once when exiting from the
2786 :group
'gnus-article
2787 :version
"23.1" ;; No Gnus
2788 :type
'(choice (const :tag
"Don't delete" nil
)
2789 (const :tag
"Don't ask" t
)
2790 (const :tag
"Ask" ask
)
2791 (const :tag
"Ask for each file" file
)))
2793 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2795 (defun gnus-article-browse-delete-temp-files (&optional how
)
2796 "Delete temp-files created by `gnus-article-browse-html-parts'."
2797 (when (and gnus-article-browse-html-temp-list
2799 (or how
(setq how gnus-article-browse-delete-temp
))
2801 (let ((files (length gnus-article-browse-html-temp-list
)))
2802 (gnus-y-or-n-p (format
2803 "Delete all %s temporary HTML file%s? "
2805 (if (> files
1) "s" ""))))
2807 (dolist (file gnus-article-browse-html-temp-list
)
2808 (cond ((file-directory-p file
)
2809 (when (or (not (eq how
'file
))
2812 "Delete temporary HTML file(s) in directory `%s'? "
2813 (file-name-as-directory file
))))
2814 (gnus-delete-directory file
)))
2815 ((file-exists-p file
)
2816 (when (or (not (eq how
'file
))
2818 (format "Delete temporary HTML file `%s'? " file
)))
2819 (delete-file file
)))))
2820 ;; Also remove file from the list when not deleted or if file doesn't
2822 (setq gnus-article-browse-html-temp-list nil
))
2823 gnus-article-browse-html-temp-list
)
2825 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2826 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2831 (dolist (handle handles
)
2833 ((not (listp handle
)))
2834 ((equal (mm-handle-media-supertype handle
) "multipart")
2835 (when (setq file
(gnus-article-browse-html-save-cid-content
2836 cid handle directory
))
2837 (throw 'found file
)))
2838 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2841 (or (mail-content-type-get
2842 (mm-handle-disposition handle
) 'filename
)
2843 (mail-content-type-get
2844 (setq type
(mm-handle-type handle
)) 'name
)
2846 (make-temp-name "cid")
2847 (car (rassoc (car type
) mailcap-mime-extensions
))))
2849 (mm-save-part-to-file handle file
)
2850 (throw 'found file
))))))))
2852 (defun gnus-article-browse-html-parts (list &optional header
)
2853 "View all \"text/html\" parts from LIST.
2854 Recurse into multiparts. The optional HEADER that should be a decoded
2855 message header will be added to the bodies of the \"text/html\" parts."
2856 ;; Internal function used by `gnus-article-browse-html-article'.
2857 (let (type file charset content cid-dir tmp-file showed
)
2858 ;; Find and show the html-parts.
2859 (dolist (handle list
)
2860 ;; If HTML, show it:
2861 (cond ((not (listp handle
)))
2862 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2863 (and (equal (car type
) "message/external-body")
2865 (setq file
(or (mail-content-type-get type
'name
)
2866 (mail-content-type-get
2867 (mm-handle-disposition handle
)
2869 (or (mm-handle-cache handle
)
2870 (condition-case code
2871 (progn (mm-extern-cache-contents handle
) t
)
2873 (gnus-message 3 "%s" (error-message-string code
))
2874 (when (>= gnus-verbose
3) (sit-for 2))
2877 (setq handle
(mm-handle-cache handle
)
2878 type
(mm-handle-type handle
))
2879 (equal (car type
) "text/html"))))
2880 (setq charset
(mail-content-type-get type
'charset
)
2881 content
(mm-get-part handle
))
2883 (if (eq charset
'gnus-decoded
)
2884 (mm-enable-multibyte)
2885 (mm-disable-multibyte))
2887 ;; resolve cid contents
2888 (let ((case-fold-search t
)
2890 (goto-char (point-min))
2891 (while (re-search-forward "\
2892 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2895 (setq cid-dir
(mm-make-temp-file "cid" t
))
2896 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2899 (when (setq cid-file
2900 (gnus-article-browse-html-save-cid-content
2902 (with-current-buffer gnus-article-buffer
2903 gnus-article-mime-handles
)
2905 (replace-match (concat "file://" cid-file
)
2907 (unless content
(setq content
(buffer-string))))
2908 (when (or charset header
(not file
))
2909 (setq tmp-file
(mm-make-temp-file
2910 ;; Do we need to care for 8.3 filenames?
2911 "mm-" nil
".html")))
2912 ;; Add a meta html tag to specify charset and a header.
2915 (let (title eheader body hcharset coding force-charset
)
2917 (mm-enable-multibyte)
2918 (setq case-fold-search t
)
2919 (insert header
"\n")
2920 (setq title
(message-fetch-field "subject"))
2921 (goto-char (point-min))
2922 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t
)
2923 (replace-match (cond ((match-beginning 1) "<")
2924 ((match-beginning 2) ">")
2926 (goto-char (point-min))
2928 (goto-char (point-max))
2929 (insert "</pre>\n<hr>\n")
2930 ;; We have to examine charset one by one since
2931 ;; charset specified in parts might be different.
2932 (if (eq charset
'gnus-decoded
)
2933 (setq charset
'utf-8
2934 eheader
(mm-encode-coding-string (buffer-string)
2937 (mm-encode-coding-string title charset
))
2938 body
(mm-encode-coding-string content charset
)
2940 (setq hcharset
(mm-find-mime-charset-region (point-min)
2942 (cond ((= (length hcharset
) 1)
2943 (setq hcharset
(car hcharset
)
2944 coding
(mm-charset-to-coding-system
2946 ((> (length hcharset
) 1)
2947 (setq hcharset
'utf-8
2953 (mm-charset-to-coding-system charset
))
2954 (if (eq coding body
)
2955 (setq eheader
(mm-encode-coding-string
2956 (buffer-string) coding
)
2958 (mm-encode-coding-string
2961 (setq charset
'utf-8
2962 eheader
(mm-encode-coding-string
2963 (buffer-string) charset
)
2965 (mm-encode-coding-string
2967 body
(mm-encode-coding-string
2968 (mm-decode-coding-string
2972 (setq charset hcharset
2973 eheader
(mm-encode-coding-string
2974 (buffer-string) coding
)
2976 (mm-encode-coding-string
2979 (setq eheader
(mm-string-as-unibyte (buffer-string))
2982 (mm-disable-multibyte)
2985 (mm-add-meta-html-tag handle charset force-charset
))
2987 (goto-char (point-min))
2988 (unless (search-forward "<title>" nil t
)
2989 (re-search-forward "<head>\\s-*" nil t
)
2990 (insert "<title>" title
"</title>\n")))
2991 (goto-char (point-min))
2992 (or (re-search-forward
2993 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2995 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2997 (mm-write-region (point-min) (point-max)
2998 tmp-file nil nil nil
'binary t
))))
3000 (mm-with-unibyte-buffer
3001 (insert (if (eq charset
'gnus-decoded
)
3002 (mm-encode-coding-string content
3003 (setq charset
'utf-8
))
3005 (if (or (mm-add-meta-html-tag handle charset
)
3007 (mm-write-region (point-min) (point-max)
3008 tmp-file nil nil nil
'binary t
)
3009 (setq tmp-file nil
))))
3011 (mm-save-part-to-file handle tmp-file
)))
3013 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
3014 (add-hook 'gnus-summary-prepare-exit-hook
3015 'gnus-article-browse-delete-temp-files
)
3016 (add-hook 'gnus-exit-gnus-hook
3018 (gnus-article-browse-delete-temp-files t
)))
3019 ;; FIXME: Warn if there's an <img> tag?
3020 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
3022 ;; If multipart, recurse
3023 ((equal (mm-handle-media-supertype handle
) "multipart")
3024 (when (gnus-article-browse-html-parts handle header
)
3026 ((equal (mm-handle-media-type handle
) "message/rfc822")
3027 (mm-with-multibyte-buffer
3028 (mm-insert-part handle
)
3029 (setq handle
(mm-dissect-buffer t t
))
3030 (when (and (bufferp (car handle
))
3031 (stringp (car (mm-handle-type handle
))))
3032 (setq handle
(list handle
)))
3034 (article-decode-encoded-words)
3035 (let ((gnus-visible-headers
3036 (or (get 'gnus-visible-headers
'standard-value
)
3037 gnus-visible-headers
)))
3038 (article-hide-headers))
3039 (goto-char (point-min))
3040 (search-forward "\n\n" nil
'move
)
3041 (skip-chars-backward "\t\n ")
3042 (setq header
(buffer-substring (point-min) (point)))))
3044 (gnus-article-browse-html-parts handle header
)
3045 (mm-destroy-parts handle
))
3049 (defun gnus-article-browse-html-article (&optional arg
)
3050 "View \"text/html\" parts of the current article with a WWW browser.
3051 Inline images embedded in a message using the cid scheme, as they are
3052 generally considered to be safe, will be processed properly.
3053 The message header is added to the beginning of every html part unless
3054 the prefix argument ARG is given.
3056 Warning: Spammers use links to images (using the http scheme) in HTML
3057 articles to verify whether you have read the message. As
3058 `gnus-article-browse-html-article' passes the HTML content to the
3059 browser without eliminating these \"web bugs\" you should only
3060 use it for mails from trusted senders.
3062 If you always want to display HTML parts in the browser, set
3063 `mm-text-html-renderer' to nil.
3065 This command creates temporary files to pass HTML contents including
3066 images if any to the browser, and deletes them when exiting the group
3068 ;; Cf. `mm-w3m-safe-url-regexp'
3071 (gnus-summary-show-article)
3072 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3073 gnus-visible-headers
))
3074 ;; As we insert a <hr>, there's no need for the body boundary.
3075 (gnus-treat-body-boundary nil
))
3076 (gnus-summary-show-article)))
3077 (with-current-buffer gnus-article-buffer
3078 (let ((header (unless arg
3081 (buffer-substring-no-properties
3082 (goto-char (point-min))
3083 (if (search-forward "\n\n" nil t
)
3085 (goto-char (point-max))
3086 (skip-chars-backward "\t\n ")
3089 (set-buffer gnus-original-article-buffer
)
3090 (setq parts
(mm-dissect-buffer t t
))
3091 ;; If singlepart, enforce a list.
3092 (when (and (bufferp (car parts
))
3093 (stringp (car (mm-handle-type parts
))))
3094 (setq parts
(list parts
)))
3096 (unless (gnus-article-browse-html-parts parts header
)
3097 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3098 (mm-destroy-parts parts
)
3100 (gnus-summary-show-article)))))
3102 (defun article-hide-list-identifiers ()
3103 "Remove list identifies from the Subject header.
3104 The `gnus-list-identifiers' variable specifies what to do."
3106 (let ((inhibit-point-motion-hooks t
)
3107 (regexp (if (consp gnus-list-identifiers
)
3108 (mapconcat 'identity gnus-list-identifiers
" *\\|")
3109 gnus-list-identifiers
))
3110 (inhibit-read-only t
))
3114 (article-narrow-to-head)
3115 (goto-char (point-min))
3116 (while (re-search-forward
3117 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3119 (delete-region (match-beginning 2) (match-end 0))
3120 (beginning-of-line))
3121 (when (re-search-forward
3122 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3123 (delete-region (match-beginning 1) (match-end 1))))))))
3125 (defun article-hide-pem (&optional arg
)
3126 "Toggle hiding of any PEM headers and signatures in the current article.
3127 If given a negative prefix, always show; if given a positive prefix,
3129 (interactive (gnus-article-hidden-arg))
3130 (unless (gnus-article-check-hidden-text 'pem arg
)
3132 (let ((inhibit-read-only t
) end
)
3133 (goto-char (point-min))
3134 ;; Hide the horrendously ugly "header".
3135 (when (and (search-forward
3136 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3138 (setq end
(1+ (match-beginning 0))))
3139 (gnus-add-wash-type 'pem
)
3140 (gnus-article-hide-text-type
3142 (if (search-forward "\n\n" nil t
)
3146 ;; Hide the trailer as well
3147 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3149 (gnus-article-hide-text-type
3150 (match-beginning 0) (match-end 0) 'pem
)))))))
3152 (defun article-strip-banner ()
3153 "Strip the banners specified by the `banner' group parameter and by
3154 `gnus-article-address-banner-alist'."
3158 (let ((inhibit-point-motion-hooks t
))
3159 (when (gnus-parameter-banner gnus-newsgroup-name
)
3160 (article-really-strip-banner
3161 (gnus-parameter-banner gnus-newsgroup-name
)))
3162 (when gnus-article-address-banner-alist
3163 ;; Note that the From header is decoded here, so it is
3164 ;; required that the *-extract-address-components function
3165 ;; supports non-ASCII text.
3166 (let ((from (save-restriction
3168 (article-narrow-to-head)
3169 (mail-fetch-field "from"))))
3172 (cadr (funcall gnus-extract-address-components
3175 (dolist (pair gnus-article-address-banner-alist
)
3176 (when (string-match (car pair
) from
)
3178 (article-really-strip-banner (cdr pair
)))))))))))))
3180 (defun article-really-strip-banner (banner)
3181 "Strip the banner specified by the argument."
3184 (let ((inhibit-point-motion-hooks t
)
3185 (gnus-signature-limit nil
)
3186 (inhibit-read-only t
))
3189 ((eq banner
'signature
)
3190 (when (gnus-article-narrow-to-signature)
3193 (delete-region (point) (point-max))))
3195 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3196 (while (re-search-forward banner nil t
)
3197 (delete-region (match-beginning 0) (match-end 0)))))
3199 (while (re-search-forward banner nil t
)
3200 (delete-region (match-beginning 0) (match-end 0)))))))))
3202 (defun article-babel ()
3203 "Translate article using an online translation service."
3206 (gnus-with-article-buffer
3207 (when (article-goto-body)
3208 (let* ((start (point))
3210 (orig (buffer-substring start end
))
3211 (trans (babel-as-string orig
)))
3213 (narrow-to-region start end
)
3214 (delete-region start end
)
3217 (defun article-hide-signature (&optional arg
)
3218 "Hide the signature in the current article.
3219 If given a negative prefix, always show; if given a positive prefix,
3221 (interactive (gnus-article-hidden-arg))
3222 (unless (gnus-article-check-hidden-text 'signature arg
)
3225 (let ((inhibit-read-only t
))
3226 (when (gnus-article-narrow-to-signature)
3227 (gnus-article-hide-text-type
3228 (point-min) (point-max) 'signature
))))))
3229 (gnus-set-mode-line 'article
))
3231 (defun article-strip-headers-in-body ()
3232 "Strip offensive headers from bodies."
3236 (let ((case-fold-search t
))
3237 (when (looking-at "x-no-archive:")
3238 (gnus-delete-line)))))
3240 (defun article-strip-leading-blank-lines ()
3241 "Remove all blank lines from the beginning of the article."
3244 (let ((inhibit-point-motion-hooks t
)
3245 (inhibit-read-only t
))
3246 (when (article-goto-body)
3247 (while (and (not (eobp))
3248 (looking-at "[ \t]*$"))
3249 (gnus-delete-line))))))
3251 (defun article-narrow-to-head ()
3252 "Narrow the buffer to the head of the message.
3253 Point is left at the beginning of the narrowed-to region."
3255 (goto-char (point-min))
3256 (if (search-forward "\n\n" nil
1)
3259 (goto-char (point-min)))
3261 (defun article-goto-body ()
3262 "Place point at the start of the body."
3263 (goto-char (point-min))
3265 ;; This variable is only bound when dealing with separate
3267 (article-goto-body-goes-to-point-min-p
3269 ((search-forward "\n\n" nil t
)
3272 (goto-char (point-max))
3275 (defun article-strip-multiple-blank-lines ()
3276 "Replace consecutive blank lines with one empty line."
3279 (let ((inhibit-point-motion-hooks t
)
3280 (inhibit-read-only t
))
3281 ;; First make all blank lines empty.
3283 (while (re-search-forward "^[ \t]+$" nil t
)
3284 (unless (gnus-annotation-in-region-p
3285 (match-beginning 0) (match-end 0))
3286 (replace-match "" nil t
)))
3287 ;; Then replace multiple empty lines with a single empty line.
3289 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3290 (unless (gnus-annotation-in-region-p
3291 (match-beginning 0) (match-end 0))
3292 (delete-region (match-beginning 1) (match-end 1)))))))
3294 (defun article-strip-leading-space ()
3295 "Remove all white space from the beginning of the lines in the article."
3298 (let ((inhibit-point-motion-hooks t
)
3299 (inhibit-read-only t
))
3301 (while (re-search-forward "^[ \t]+" nil t
)
3302 (replace-match "" t t
)))))
3304 (defun article-strip-trailing-space ()
3305 "Remove all white space from the end of the lines in the article."
3308 (let ((inhibit-point-motion-hooks t
)
3309 (inhibit-read-only t
))
3311 (while (re-search-forward "[ \t]+$" nil t
)
3312 (replace-match "" t t
)))))
3314 (defun article-strip-blank-lines ()
3315 "Strip leading, trailing and multiple blank lines."
3317 (article-strip-leading-blank-lines)
3318 (article-remove-trailing-blank-lines)
3319 (article-strip-multiple-blank-lines))
3321 (defun article-strip-all-blank-lines ()
3322 "Strip all blank lines."
3325 (let ((inhibit-point-motion-hooks t
)
3326 (inhibit-read-only t
))
3328 (while (re-search-forward "^[ \t]*\n" nil t
)
3329 (replace-match "" t t
)))))
3331 (defun gnus-article-narrow-to-signature ()
3332 "Narrow to the signature; return t if a signature is found, else nil."
3333 (let ((inhibit-point-motion-hooks t
))
3334 (when (gnus-article-search-signature)
3336 ;; Check whether we have some limits to what we consider
3337 ;; to be a signature.
3338 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3339 (list gnus-signature-limit
)))
3341 (while (setq limit
(pop limits
))
3342 (if (or (and (integerp limit
)
3343 (< (- (point-max) (point)) limit
))
3345 (< (count-lines (point) (point-max)) limit
))
3346 (and (functionp limit
)
3348 (and (stringp limit
)
3349 (not (re-search-forward limit nil t
))))
3350 () ; This limit did not succeed.
3354 (narrow-to-region (point) (point-max))
3357 (defun gnus-article-search-signature ()
3358 "Search the current buffer for the signature separator.
3359 Put point at the beginning of the signature separator."
3360 (let ((cur (point)))
3361 (goto-char (point-max))
3362 (if (if (stringp gnus-signature-separator
)
3363 (re-search-backward gnus-signature-separator nil t
)
3364 (let ((seps gnus-signature-separator
))
3366 (not (re-search-backward (car seps
) nil t
)))
3373 (defun gnus-article-hidden-arg ()
3374 "Return the current prefix arg as a number, or 0 if no prefix."
3375 (list (if current-prefix-arg
3376 (prefix-numeric-value current-prefix-arg
)
3379 (defun gnus-article-check-hidden-text (type arg
)
3380 "Return nil if hiding is necessary.
3381 Arg can be nil or a number. nil and positive means hide, negative
3382 means show, 0 means toggle."
3385 (let ((hide (gnus-article-hidden-text-p type
)))
3391 (gnus-article-show-hidden-text type
)
3394 (if (eq hide
'hidden
)
3396 (gnus-article-show-hidden-text type
)
3400 (defun gnus-article-hidden-text-p (type)
3401 "Say whether the current buffer contains hidden text of type TYPE."
3402 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3404 (not (get-text-property pos
'invisible
))
3405 (not (get-text-property pos
'dummy-invisible
)))
3407 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3412 (defun gnus-article-show-hidden-text (type &optional dummy
)
3413 "Show all hidden text of type TYPE.
3414 Originally it is hide instead of DUMMY."
3415 (let ((inhibit-read-only t
)
3416 (inhibit-point-motion-hooks t
))
3417 (gnus-remove-text-properties-when
3419 (point-min) (point-max)
3420 (cons 'article-type
(cons type
3421 gnus-hidden-properties
)))
3422 (gnus-delete-wash-type type
)))
3424 (defconst article-time-units
3425 `((year .
,(* 365.25 24 60 60))
3426 (week .
,(* 7 24 60 60))
3427 (day .
,(* 24 60 60))
3431 "Mapping from time units to seconds.")
3433 (defun gnus-article-forward-header ()
3434 "Move point to the start of the next header.
3435 If the current header is a continuation header, this can be several
3440 (if (looking-at "[ \t]+[^ \t]")
3444 (defun article-date-ut (&optional type highlight
)
3445 "Convert DATE date to universal time in the current article.
3446 If TYPE is `local', convert to local time; if it is `lapsed', output
3447 how much time has lapsed since DATE. For `lapsed', the value of
3448 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3449 should replace the \"Date:\" one, or should be added below it."
3450 (interactive (list 'ut t
))
3451 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3452 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
3456 (article-lapsed-timer
3460 (case-fold-search t
)
3461 (inhibit-read-only t
)
3462 (inhibit-point-motion-hooks t
)
3463 pos date bface eface
)
3467 (goto-char (point-min))
3468 (while (or (setq date
(get-text-property (setq pos
(point))
3470 (when (setq pos
(next-single-property-change
3471 (point) 'original-date
))
3472 (setq date
(get-text-property pos
'original-date
))
3475 pos
(if (setq pos
(text-property-any pos
(point-max)
3476 'original-date nil
))
3479 (if (or (bolp) (eobp))
3483 (goto-char (point-min))
3484 (when (re-search-forward tdate-regexp nil t
)
3485 (setq bface
(get-text-property (point-at-bol) 'face
)
3486 eface
(get-text-property (1- (point-at-eol)) 'face
)))
3487 (goto-char (point-min))
3489 ;; Delete any old Date headers.
3490 (while (re-search-forward date-regexp nil t
)
3492 (delete-region (point-at-bol) (progn
3493 (gnus-article-forward-header)
3495 (delete-region (point-at-bol) (progn
3496 (gnus-article-forward-header)
3499 (setq pos
(point))))
3500 (when (and (not pos
)
3501 (re-search-forward tdate-regexp nil t
))
3503 (gnus-goto-char pos
)
3504 (insert (article-make-date-line date
(or type
'ut
)))
3510 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3511 (put-text-property (match-beginning 1) (1+ (match-end 1))
3513 (put-text-property (match-beginning 2) (match-end 2)
3515 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
3516 (goto-char (point-max))
3519 (defun article-make-date-line (date type
)
3520 "Return a DATE line of TYPE."
3521 (unless (memq type
'(local ut original user iso8601 lapsed english
3523 (error "Unknown conversion type: %s" type
))
3525 (let ((time (date-to-time date
)))
3527 ;; Convert to the local timezone.
3529 (concat "Date: " (message-make-date time
)))
3530 ;; Convert to Universal Time.
3535 (let* ((e (parse-time-string date
))
3536 (tm (apply 'encode-time e
))
3538 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3539 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3540 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3544 ;; Get the original date from the article.
3545 ((eq type
'original
)
3546 (concat "Date: " (if (string-match "\n+$" date
)
3547 (substring date
0 (match-beginning 0))
3549 ;; Let the user define the format.
3551 (let ((format (or (condition-case nil
3552 (with-current-buffer gnus-summary-buffer
3553 gnus-article-time-format
)
3555 gnus-article-time-format
)))
3556 (if (functionp format
)
3557 (funcall format time
)
3558 (concat "Date: " (format-time-string format time
)))))
3561 (let ((tz (car (current-time-zone time
))))
3564 (format-time-string "%Y%m%dT%H%M%S" time
)
3565 (format "%s%02d%02d"
3566 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3567 (/ (%
(abs tz
) 3600) 60)))))
3568 ;; Do an X-Sent lapsed format.
3570 (concat "X-Sent: " (article-lapsed-string time
)))
3571 ;; A combined date/lapsed format.
3572 ((eq type
'combined-lapsed
)
3573 (let ((date-string (article-make-date-line date
'original
))
3578 (concat " (" (article-lapsed-string time segments
) ")"))
3579 (> (+ (length date-string
)
3580 (length lapsed-string
))
3583 (setq segments
(1- segments
)))
3585 (concat date-string lapsed-string
)
3587 ;; Display the date in proper English
3589 (let ((dtime (decode-time time
)))
3592 (number-to-string (nth 3 dtime
))
3593 (let ((digit (%
(nth 3 dtime
) 10)))
3595 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3601 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3603 (number-to-string (nth 5 dtime
))
3605 (format "%02d" (nth 2 dtime
))
3607 (format "%02d" (nth 1 dtime
)))))))
3609 (format "Date: %s (from Gnus)" date
))))
3611 (defun article-lapsed-string (time &optional max-segments
)
3612 ;; If the date is seriously mangled, the timezone functions are
3613 ;; liable to bug out, so we ignore all errors.
3614 (let* ((now (current-time))
3615 (real-time (subtract-time now time
))
3616 (real-sec (and real-time
3617 (+ (* (float (car real-time
)) 65536)
3619 (sec (and real-time
(abs real-sec
)))
3622 (unless max-segments
3623 (setq max-segments
(length article-time-units
)))
3631 ;; This is a bit convoluted, but basically we go
3632 ;; through the time units for years, weeks, etc,
3633 ;; and divide things to see whether that results
3634 ;; in positive answers.
3637 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3638 (>= segments max-segments
))
3639 ;; The (remaining) seconds are too few to
3640 ;; be divided into this time unit.
3642 ;; It's big enough, so we output it.
3643 (setq sec
(- sec
(* num
(cdr unit
))))
3645 (concat (if prev
", " "") (int-to-string
3647 " " (symbol-name (car unit
))
3648 (if (> num
1) "s" ""))
3650 segments
(1+ segments
)))))
3651 article-time-units
"")
3652 ;; If dates are odd, then it might appear like the
3653 ;; article was sent in the future.
3656 " in the future"))))))
3658 (defun article-date-local (&optional highlight
)
3659 "Convert the current article date to the local timezone."
3660 (interactive (list t
))
3661 (article-date-ut 'local highlight
))
3663 (defun article-date-english (&optional highlight
)
3664 "Convert the current article date to something that is proper English."
3665 (interactive (list t
))
3666 (article-date-ut 'english highlight
))
3668 (defun article-date-original (&optional highlight
)
3669 "Convert the current article date to what it was originally.
3670 This is only useful if you have used some other date conversion
3671 function and want to see what the date was before converting."
3672 (interactive (list t
))
3673 (article-date-ut 'original highlight
))
3675 (defun article-date-lapsed (&optional highlight
)
3676 "Convert the current article date to time lapsed since it was sent."
3677 (interactive (list t
))
3678 (article-date-ut 'lapsed highlight
))
3680 (defun article-date-combined-lapsed (&optional highlight
)
3681 "Convert the current article date to time lapsed since it was sent."
3682 (interactive (list t
))
3683 (article-date-ut 'combined-lapsed highlight
))
3685 (defun article-update-date-lapsed ()
3686 "Function to be run from a timer to update the lapsed time line."
3688 (let (deactivate-mark)
3689 (save-window-excursion
3693 (set-buffer (window-buffer w
))
3694 (when (eq major-mode
'gnus-article-mode
)
3695 (let ((mark (point-marker))
3696 (old-point (point)))
3697 (goto-char (point-min))
3698 (when (re-search-forward "^X-Sent:\\|^Date:" nil t
)
3699 ;; If the point is on the Date line, then use that
3700 ;; absolute position. Otherwise, use the mark.
3701 ;; This will ensure that point stays at the "same
3703 (when (or (< old-point
(match-beginning 0))
3706 (while (and (not (eobp))
3707 (looking-at "X-Sent:\\|Date:"))
3710 (setq old-point nil
))
3711 (when gnus-treat-date-combined-lapsed
3712 (article-date-combined-lapsed t
))
3713 (when gnus-treat-date-lapsed
3714 (article-date-lapsed t
)))
3715 (goto-char (or old-point
(marker-position mark
)))
3716 (move-marker mark nil
))))
3719 (defun gnus-start-date-timer (&optional n
)
3720 "Start a timer to update the X-Sent header in the article buffers.
3721 The numerical prefix says how frequently (in seconds) the function
3726 (gnus-stop-date-timer)
3727 (setq article-lapsed-timer
3728 (run-at-time 1 n
'article-update-date-lapsed
)))
3730 (defun gnus-stop-date-timer ()
3731 "Stop the X-Sent timer."
3733 (when article-lapsed-timer
3734 (nnheader-cancel-timer article-lapsed-timer
)
3735 (setq article-lapsed-timer nil
)))
3737 (defun article-date-user (&optional highlight
)
3738 "Convert the current article date to the user-defined format.
3739 This format is defined by the `gnus-article-time-format' variable."
3740 (interactive (list t
))
3741 (article-date-ut 'user highlight
))
3743 (defun article-date-iso8601 (&optional highlight
)
3744 "Convert the current article date to ISO8601."
3745 (interactive (list t
))
3746 (article-date-ut 'iso8601 highlight
))
3748 (defmacro gnus-article-save-original-date
(&rest forms
)
3749 "Save the original date as a text property and evaluate FORMS."
3750 `(let* ((case-fold-search t
)
3752 (goto-char (point-min))
3753 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3756 (date (when (and start
3757 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3759 (buffer-substring-no-properties start
3760 (match-beginning 0)))))
3761 (goto-char (point-max))
3762 (skip-chars-backward "\n")
3763 (put-text-property (point-min) (point) 'original-date date
)
3765 (goto-char (point-max))
3766 (skip-chars-backward "\n")
3767 (put-text-property (point-min) (point) 'original-date date
)))
3769 ;; (defun article-show-all ()
3770 ;; "Show all hidden text in the article buffer."
3773 ;; (let ((inhibit-read-only t))
3774 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3776 (defun article-remove-leading-whitespace ()
3777 "Remove excessive whitespace from all headers."
3781 (let ((inhibit-read-only t
))
3782 (article-narrow-to-head)
3783 (goto-char (point-min))
3784 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3785 (delete-region (match-beginning 1) (match-end 1)))))))
3787 (defun article-emphasize (&optional arg
)
3788 "Emphasize text according to `gnus-emphasis-alist'."
3789 (interactive (gnus-article-hidden-arg))
3790 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3794 (with-current-buffer gnus-summary-buffer
3795 gnus-article-emphasis-alist
)
3797 gnus-emphasis-alist
))
3798 (inhibit-read-only t
)
3799 (props (append '(article-type emphasis
)
3800 gnus-hidden-properties
))
3801 regexp elem beg invisible visible face
)
3804 (while (setq elem
(pop alist
))
3806 (setq regexp
(car elem
)
3807 invisible
(nth 1 elem
)
3808 visible
(nth 2 elem
)
3810 (while (re-search-forward regexp nil t
)
3811 (when (and (match-beginning visible
) (match-beginning invisible
))
3812 (gnus-article-hide-text
3813 (match-beginning invisible
) (match-end invisible
) props
)
3814 (gnus-article-unhide-text-type
3815 (match-beginning visible
) (match-end visible
) 'emphasis
)
3816 (gnus-put-overlay-excluding-newlines
3817 (match-beginning visible
) (match-end visible
) 'face face
)
3818 (gnus-add-wash-type 'emphasis
)
3819 (goto-char (match-end invisible
)))))))))
3821 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3822 "Setup newsgroup emphasis alist."
3823 (unless gnus-article-emphasis-alist
3824 (let ((name (and gnus-newsgroup-name
3825 (gnus-group-real-name gnus-newsgroup-name
))))
3826 (make-local-variable 'gnus-article-emphasis-alist
)
3827 (setq gnus-article-emphasis-alist
3829 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3830 (while (setq elem
(pop alist
))
3831 (when (and name
(string-match (car elem
) name
))
3833 highlight
(copy-sequence (cdr elem
)))))
3835 (copy-sequence highlight-words
)
3836 (if gnus-newsgroup-name
3837 (copy-sequence (gnus-group-find-parameter
3838 gnus-newsgroup-name
'highlight-words t
)))
3839 gnus-emphasis-alist
)))))
3841 (defvar gnus-summary-article-menu
)
3842 (defvar gnus-summary-post-menu
)
3844 ;;; Saving functions.
3846 (defun gnus-article-save (save-buffer file
&optional num
)
3847 "Save the currently selected article."
3848 (when (or (get gnus-default-article-saver
:headers
)
3849 (not gnus-save-all-headers
))
3850 ;; Remove headers according to `gnus-saved-headers' or the value
3851 ;; of the `:headers' property that the saver function might have.
3852 (let ((gnus-visible-headers
3853 (or (symbol-value (get gnus-default-article-saver
:headers
))
3854 gnus-saved-headers gnus-visible-headers
))
3855 ;; Ignore group parameter. See `article-hide-headers'.
3856 (gnus-summary-buffer nil
))
3857 (with-current-buffer save-buffer
3858 (article-hide-headers 1 t
))))
3859 (save-window-excursion
3860 (if (not gnus-default-article-saver
)
3861 (error "No default saver is defined")
3862 ;; !!! Magic! The saving functions all save
3863 ;; `gnus-save-article-buffer' (or so they think), but we
3864 ;; bind that variable to our save-buffer.
3865 (set-buffer gnus-article-buffer
)
3866 (let* ((gnus-save-article-buffer save-buffer
)
3869 ((not gnus-prompt-before-saving
) 'default
)
3870 ((eq gnus-prompt-before-saving
'always
) nil
)
3872 (gnus-number-of-articles-to-be-saved
3873 (when (eq gnus-prompt-before-saving t
)
3875 (set-buffer gnus-article-current-summary
)
3876 (funcall gnus-default-article-saver filename
)))))
3878 (defun gnus-read-save-file-name (prompt &optional filename
3879 function group headers variable
3882 (funcall function group headers
(symbol-value variable
)))
3887 ((eq filename
'default
)
3893 (when (symbol-value dir-var
)
3894 (setq default-name
(expand-file-name
3895 (file-name-nondirectory default-name
)
3896 (symbol-value dir-var
))))
3897 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3900 (if (and gnus-number-of-articles-to-be-saved
3901 (> gnus-number-of-articles-to-be-saved
1))
3902 (format "these %d articles"
3903 gnus-number-of-articles-to-be-saved
)
3906 ;; Let the split methods have their say.
3908 ;; No split name was found.
3911 (concat prompt
" (default "
3912 (file-name-nondirectory default-name
) "): ")
3913 (file-name-directory default-name
)
3915 ;; A single group name is returned.
3916 ((stringp split-name
)
3918 (funcall function split-name headers
3919 (symbol-value variable
)))
3921 (concat prompt
" (default "
3922 (file-name-nondirectory default-name
) "): ")
3923 (file-name-directory default-name
)
3925 ;; A single split name was found
3926 ((= 1 (length split-name
))
3927 (let* ((name (expand-file-name
3929 gnus-article-save-directory
))
3930 (dir (cond ((file-directory-p name
)
3931 (file-name-as-directory name
))
3932 ((file-exists-p name
) name
)
3933 (t gnus-article-save-directory
))))
3935 (concat prompt
" (default " name
"): ")
3937 ;; A list of splits was found.
3939 (setq split-name
(nreverse split-name
))
3941 (let ((file-name-history
3942 (nconc split-name file-name-history
)))
3946 (concat prompt
" (`M-p' for defaults): ")
3947 gnus-article-save-directory
3949 gnus-article-save-directory
)))
3950 (car (push result file-name-history
)))))))
3951 ;; Create the directory.
3952 (gnus-make-directory (file-name-directory file
))
3953 ;; If we have read a directory, we append the default file name.
3954 (when (file-directory-p file
)
3955 (setq file
(expand-file-name (file-name-nondirectory
3957 (file-name-as-directory file
))))
3958 ;; Possibly translate some characters.
3959 (nnheader-translate-file-chars file
))))))
3960 (gnus-make-directory (file-name-directory result
))
3962 (set variable result
))
3964 (set dir-var
(file-name-directory result
)))
3967 (defun gnus-article-archive-name (group)
3968 "Return the first instance of an \"Archive-name\" in the current buffer."
3969 (let ((case-fold-search t
))
3970 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3971 (nnheader-concat gnus-article-save-directory
3972 (match-string 1)))))
3974 (defun gnus-article-nndoc-name (group)
3975 "If GROUP is an nndoc group, return the name of the parent group."
3976 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3977 (gnus-group-get-parameter group
'save-article-group
)))
3979 (defun gnus-summary-save-in-rmail (&optional filename
)
3980 "Append this article to Rmail file.
3981 Optional argument FILENAME specifies file name.
3982 Directory to save to is default to `gnus-article-save-directory'."
3983 (setq filename
(gnus-read-save-file-name
3984 "Save %s in rmail file" filename
3985 gnus-rmail-save-name gnus-newsgroup-name
3986 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3987 (with-current-buffer gnus-save-article-buffer
3991 ;; Note that unlike gnus-summary-save-in-mail, there is no
3992 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3994 (gnus-output-to-rmail filename
))))
3997 (defun gnus-summary-save-in-mail (&optional filename
)
3998 "Append this article to Unix mail file.
3999 Optional argument FILENAME specifies file name.
4000 Directory to save to is default to `gnus-article-save-directory'."
4001 (setq filename
(gnus-read-save-file-name
4002 "Save %s in Unix mail file" filename
4003 gnus-mail-save-name gnus-newsgroup-name
4004 gnus-current-headers
'gnus-newsgroup-last-mail
))
4005 (with-current-buffer gnus-save-article-buffer
4009 (if (and (file-readable-p filename
)
4010 (file-regular-p filename
)
4011 (mail-file-babyl-p filename
))
4012 (gnus-output-to-rmail filename
)
4013 (gnus-output-to-mail filename
)))))
4016 (put 'gnus-summary-save-in-file
:decode t
)
4017 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4018 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4019 "Append this article to file.
4020 Optional argument FILENAME specifies file name.
4021 Directory to save to is default to `gnus-article-save-directory'."
4022 (setq filename
(gnus-read-save-file-name
4023 "Save %s in file" filename
4024 gnus-file-save-name gnus-newsgroup-name
4025 gnus-current-headers
'gnus-newsgroup-last-file
))
4026 (with-current-buffer gnus-save-article-buffer
4030 (when (and overwrite
4031 (file-exists-p filename
))
4032 (delete-file filename
))
4033 (gnus-output-to-file filename
))))
4036 (put 'gnus-summary-write-to-file
:decode t
)
4037 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4038 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4039 (defun gnus-summary-write-to-file (&optional filename
)
4040 "Write this article to a file, overwriting it if the file exists.
4041 Optional argument FILENAME specifies file name.
4042 The directory to save in defaults to `gnus-article-save-directory'."
4043 (setq filename
(gnus-read-save-file-name
4044 "Save %s in file" filename
4045 gnus-file-save-name gnus-newsgroup-name
4046 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4047 (gnus-summary-save-in-file filename t
))
4049 (put 'gnus-summary-save-body-in-file
:decode t
)
4050 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4051 "Append this article body to a file.
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 body in file" filename
4056 gnus-file-save-name gnus-newsgroup-name
4057 gnus-current-headers
'gnus-newsgroup-last-file
))
4058 (with-current-buffer gnus-save-article-buffer
4062 (when (article-goto-body)
4063 (narrow-to-region (point) (point-max)))
4064 (when (and overwrite
4065 (file-exists-p filename
))
4066 (delete-file filename
))
4067 (gnus-output-to-file filename
))))
4070 (put 'gnus-summary-write-body-to-file
:decode t
)
4071 (put 'gnus-summary-write-body-to-file
4072 :function
'gnus-summary-save-body-in-file
)
4073 (defun gnus-summary-write-body-to-file (&optional filename
)
4074 "Write this article body to a file, overwriting it if the file exists.
4075 Optional argument FILENAME specifies file name.
4076 The directory to save in defaults to `gnus-article-save-directory'."
4077 (setq filename
(gnus-read-save-file-name
4078 "Save %s body in file" filename
4079 gnus-file-save-name gnus-newsgroup-name
4080 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4081 (gnus-summary-save-body-in-file filename t
))
4083 (put 'gnus-summary-save-in-pipe
:decode t
)
4084 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4085 (defun gnus-summary-save-in-pipe (&optional command raw
)
4086 "Pipe this article to subprocess COMMAND.
4087 Valid values for COMMAND include:
4089 The executable command name and possibly arguments.
4091 You will be prompted for the command in the minibuffer.
4092 the symbol `default'
4093 It will be replaced with the command which the variable
4094 `gnus-summary-pipe-output-default-command' holds or the command
4095 last used for saving.
4096 Non-nil value for RAW overrides `:decode' and `:headers' properties
4097 and the raw article including all headers will be piped."
4098 (let ((article (gnus-summary-article-number))
4100 (get 'gnus-summary-save-in-pipe
:decode
)))
4101 save-buffer default
)
4103 (if (vectorp (gnus-summary-article-header article
))
4104 (save-current-buffer
4105 (gnus-summary-select-article decode decode nil article
)
4106 (insert-buffer-substring
4110 gnus-original-article-buffer
)
4112 (nnheader-set-temp-buffer " *Gnus Save*"))))
4113 ;; Remove unwanted headers.
4114 (when (and (not raw
)
4115 (or (get 'gnus-summary-save-in-pipe
:headers
)
4116 (not gnus-save-all-headers
)))
4117 (let ((gnus-visible-headers
4118 (or (symbol-value (get 'gnus-summary-save-in-pipe
4120 gnus-saved-headers gnus-visible-headers
))
4121 (gnus-summary-buffer nil
))
4122 (article-hide-headers 1 t
))))
4123 (error "%d is not a real article" article
))
4124 (error "No article to pipe"))
4125 (setq default
(or gnus-summary-pipe-output-default-command
4126 gnus-last-shell-command
))
4127 (unless (stringp command
)
4129 (if (and (eq command
'default
) default
)
4131 (gnus-read-shell-command "Shell command on this article: "
4133 (when (string-equal command
"")
4135 (setq command default
)
4136 (error "A command is required")))
4137 (with-current-buffer save-buffer
4140 (shell-command-on-region (point-min) (point-max) command nil
)))
4141 (gnus-kill-buffer save-buffer
))
4142 (setq gnus-summary-pipe-output-default-command command
))
4144 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4145 "Pipe this article to muttprint."
4146 (unless (stringp command
)
4147 (setq command
(read-string
4148 "Print using command: " gnus-summary-muttprint-program
4149 nil gnus-summary-muttprint-program
)))
4150 (let ((gnus-summary-pipe-output-default-command
4151 gnus-summary-pipe-output-default-command
))
4152 (gnus-summary-save-in-pipe command
))
4153 (setq gnus-summary-muttprint-program command
))
4155 ;;; Article file names when saving.
4157 (defun gnus-capitalize-newsgroup (newsgroup)
4158 "Capitalize NEWSGROUP name."
4159 (when (not (zerop (length newsgroup
)))
4160 (concat (char-to-string (upcase (aref newsgroup
0)))
4161 (substring newsgroup
1))))
4163 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4164 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4165 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4166 Otherwise, it is like ~/News/news/group/num."
4169 (concat (if (gnus-use-long-file-name 'not-save
)
4170 (gnus-capitalize-newsgroup newsgroup
)
4171 (gnus-newsgroup-directory-form newsgroup
))
4172 "/" (int-to-string (mail-header-number headers
)))
4173 gnus-article-save-directory
)))
4175 (string-equal (file-name-directory default
)
4176 (file-name-directory last-file
))
4177 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4179 (or last-file default
))))
4181 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4182 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4183 If variable `gnus-use-long-file-name' is non-nil, it is
4184 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4187 (concat (if (gnus-use-long-file-name 'not-save
)
4189 (gnus-newsgroup-directory-form newsgroup
))
4190 "/" (int-to-string (mail-header-number headers
)))
4191 gnus-article-save-directory
)))
4193 (string-equal (file-name-directory default
)
4194 (file-name-directory last-file
))
4195 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4197 (or last-file default
))))
4199 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
4200 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4201 If variable `gnus-use-long-file-name' is non-nil, it is
4202 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4205 (if (gnus-use-long-file-name 'not-save
)
4208 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4210 gnus-article-save-directory
)))
4212 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
4213 "Generate file name from sender."
4214 (let ((from (mail-header-from headers
)))
4216 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4217 (match-string 1 from
)
4219 gnus-article-save-directory
)))
4221 (defun article-verify-x-pgp-sig ()
4223 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4225 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4226 (let ((sig (with-current-buffer gnus-original-article-buffer
4227 (gnus-fetch-field "X-PGP-Sig")))
4231 (mml2015-clear-verify-function))
4233 (insert-buffer-substring gnus-original-article-buffer
)
4234 (setq items
(split-string sig
))
4235 (message-narrow-to-head)
4236 (let ((inhibit-point-motion-hooks t
)
4237 (case-fold-search t
))
4238 ;; Don't verify multiple headers.
4239 (setq headers
(mapconcat (lambda (header)
4241 (mail-fetch-field header
)
4243 (split-string (nth 1 items
) ",") "")))
4244 (delete-region (point-min) (point-max))
4245 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4246 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4251 (if (looking-at "^-")
4254 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4255 (insert "Version: " (car items
) "\n\n")
4256 (insert (mapconcat 'identity
(cddr items
) "\n"))
4257 (insert "\n-----END PGP SIGNATURE-----\n")
4258 (let ((mm-security-handle (list (format "multipart/signed"))))
4259 (mml2015-clean-buffer)
4260 (let ((coding-system-for-write (or gnus-newsgroup-charset
4262 (funcall (mml2015-clear-verify-function)))
4264 (or (mm-handle-multipart-ctl-parameter
4265 mm-security-handle
'gnus-details
)
4266 (mm-handle-multipart-ctl-parameter
4267 mm-security-handle
'gnus-info
)))))
4269 (let ((inhibit-read-only t
) bface eface
)
4271 (message-narrow-to-head)
4272 (goto-char (point-max))
4274 (setq bface
(get-text-property (point-at-bol) 'face
)
4275 eface
(get-text-property (1- (point-at-eol)) 'face
))
4276 (message-remove-header "X-Gnus-PGP-Verify")
4277 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4279 (goto-char (point-max)))
4280 (narrow-to-region (point) (point))
4281 (insert "X-Gnus-PGP-Verify: " info
"\n")
4282 (goto-char (point-min))
4285 (if (not (looking-at "^[ \t]"))
4289 (goto-char (point-min))
4290 (when (looking-at "\\([^:]+\\): *")
4291 (put-text-property (match-beginning 1) (1+ (match-end 1))
4293 (put-text-property (match-end 0) (point-max)
4294 'face eface
)))))))))
4296 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4298 (defun article-verify-cancel-lock ()
4299 "Verify Cancel-Lock header."
4301 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4302 (canlock-verify gnus-original-article-buffer
)))
4309 (setq afunc
(car func
)
4312 gfunc
(intern (format "gnus-%s" func
))))
4314 (when (fboundp afunc
)
4315 `(lambda (&optional interactive
&rest args
)
4316 ,(documentation afunc t
)
4317 (interactive (list t
))
4318 (with-current-buffer gnus-article-buffer
4320 (call-interactively ',afunc
)
4321 (apply ',afunc args
))))))))
4322 '(article-hide-headers
4323 article-verify-x-pgp-sig
4324 article-verify-cancel-lock
4325 article-hide-boring-headers
4326 article-treat-overstrike
4327 article-treat-ansi-sequences
4328 article-fill-long-lines
4329 article-capitalize-sentences
4331 article-remove-leading-whitespace
4332 article-display-x-face
4333 article-display-face
4334 article-de-quoted-unreadable
4335 article-de-base64-unreadable
4338 article-unsplit-urls
4339 article-hide-list-identifiers
4340 article-strip-banner
4343 article-hide-signature
4344 article-strip-headers-in-body
4345 article-remove-trailing-blank-lines
4346 article-strip-leading-blank-lines
4347 article-strip-multiple-blank-lines
4348 article-strip-leading-space
4349 article-strip-trailing-space
4350 article-strip-blank-lines
4351 article-strip-all-blank-lines
4353 article-date-english
4354 article-date-iso8601
4355 article-date-original
4357 article-decode-mime-words
4358 article-decode-charset
4359 article-decode-encoded-words
4362 article-date-combined-lapsed
4364 article-treat-dumbquotes
4365 article-treat-non-ascii
4366 article-normalize-headers
4367 ;;(article-show-all . gnus-article-show-all-headers)
4371 ;;; Gnus article mode
4374 (put 'gnus-article-mode
'mode-class
'special
)
4376 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4378 (gnus-define-keys gnus-article-mode-map
4379 " " gnus-article-goto-next-page
4380 "\177" gnus-article-goto-prev-page
4381 [delete] gnus-article-goto-prev-page
4382 [backspace] gnus-article-goto-prev-page
4383 "\C-c^" gnus-article-refer-article
4384 "h" gnus-article-show-summary
4385 "s" gnus-article-show-summary
4386 "\C-c\C-m" gnus-article-mail
4387 "?" gnus-article-describe-briefly
4388 "<" beginning-of-buffer
4390 "\C-c\C-i" gnus-info-find-node
4392 "R" gnus-article-reply-with-original
4393 "F" gnus-article-followup-with-original
4394 "\C-hk" gnus-article-describe-key
4395 "\C-hc" gnus-article-describe-key-briefly
4396 "\C-hb" gnus-article-describe-bindings
4398 "e" gnus-article-read-summary-keys
4399 "\C-d" gnus-article-read-summary-keys
4400 "\M-*" gnus-article-read-summary-keys
4401 "\M-#" gnus-article-read-summary-keys
4402 "\M-^" gnus-article-read-summary-keys
4403 "\M-g" gnus-article-read-summary-keys)
4405 (substitute-key-definition
4406 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4408 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4409 "W" gnus-article-wide-reply-with-original)
4410 (if (featurep 'xemacs)
4411 (set-keymap-default-binding gnus-article-send-map
4412 'gnus-article-read-summary-send-keys)
4413 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4415 (defun gnus-article-make-menu-bar ()
4416 (unless (boundp 'gnus-article-commands-menu)
4417 (gnus-summary-make-menu-bar))
4418 (unless (boundp 'gnus-article-article-menu)
4420 gnus-article-article-menu gnus-article-mode-map ""
4422 ["Scroll forwards" gnus-article-goto-next-page t]
4423 ["Scroll backwards" gnus-article-goto-prev-page t]
4424 ["Show summary" gnus-article-show-summary t]
4425 ["Fetch Message-ID at point" gnus-article-refer-article t]
4426 ["Mail to address at point" gnus-article-mail t]
4427 ["Send a bug report" gnus-bug t]))
4430 gnus-article-treatment-menu gnus-article-mode-map ""
4431 ;; Fixme: this should use :active (and maybe :visible).
4433 ["Hide headers" gnus-article-hide-headers t]
4434 ["Hide signature" gnus-article-hide-signature t]
4435 ["Hide citation" gnus-article-hide-citation t]
4436 ["Treat overstrike" gnus-article-treat-overstrike t]
4437 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4438 ["Remove carriage return" gnus-article-remove-cr t]
4439 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4440 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4441 ["Remove base64" gnus-article-de-base64-unreadable t]
4442 ["Treat html" gnus-article-wash-html t]
4443 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4444 ["Decode HZ" gnus-article-decode-HZ t]))
4446 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4448 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4450 (gnus-run-hooks 'gnus-article-menu-hook)))
4452 (defvar bookmark-make-record-function)
4454 (defun gnus-article-mode ()
4455 "Major mode for displaying an article.
4457 All normal editing commands are switched off.
4459 The following commands are available in addition to all summary mode
4461 \\<gnus-article-mode-map>
4462 \\[gnus-article-next-page]\t Scroll the article one page forwards
4463 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4464 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4465 \\[gnus-article-show-summary]\t Display the summary buffer
4466 \\[gnus-article-mail]\t Send a reply to the address near point
4467 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4468 \\[gnus-info-find-node]\t Go to the Gnus info node"
4470 (kill-all-local-variables)
4471 (gnus-simplify-mode-line)
4472 (setq mode-name "Article")
4473 (setq major-mode 'gnus-article-mode)
4474 (make-local-variable 'minor-mode-alist)
4475 (use-local-map gnus-article-mode-map)
4476 (when (gnus-visual-p 'article-menu 'menu)
4477 (gnus-article-make-menu-bar)
4478 (when gnus-summary-tool-bar-map
4479 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4480 (gnus-update-format-specifications nil 'article-mode)
4481 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4482 (set (make-local-variable 'gnus-page-broken) nil)
4483 (make-local-variable 'gnus-article-current-summary)
4484 (make-local-variable 'gnus-article-mime-handles)
4485 (make-local-variable 'gnus-article-decoded-p)
4486 (make-local-variable 'gnus-article-mime-handle-alist)
4487 (make-local-variable 'gnus-article-wash-types)
4488 (make-local-variable 'gnus-article-image-alist)
4489 (make-local-variable 'gnus-article-charset)
4490 (make-local-variable 'gnus-article-ignored-charsets)
4491 (set (make-local-variable 'bookmark-make-record-function)
4492 'gnus-summary-bookmark-make-record)
4493 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4495 (set (make-local-variable 'nobreak-char-display) nil)
4496 (setq cursor-in-non-selected-windows nil)
4497 (gnus-set-default-directory)
4498 (buffer-disable-undo)
4499 (setq buffer-read-only t
4500 show-trailing-whitespace nil)
4501 (set-syntax-table gnus-article-mode-syntax-table)
4502 (mm-enable-multibyte)
4503 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4505 (defun gnus-article-setup-buffer ()
4506 "Initialize the article buffer."
4507 (let* ((name (if gnus-single-article-buffer "*Article*"
4508 (concat "*Article " gnus-newsgroup-name "*")))
4510 (progn (string-match "\\*Article" name)
4511 (concat " *Original Article"
4512 (substring name (match-end 0))))))
4513 (setq gnus-article-buffer name)
4514 (setq gnus-original-article-buffer original)
4515 (setq gnus-article-mime-handle-alist nil)
4516 (with-current-buffer gnus-summary-buffer
4517 ;; This might be a variable local to the summary buffer.
4518 (unless gnus-single-article-buffer
4519 (setq gnus-article-buffer name)
4520 (setq gnus-original-article-buffer original)
4521 (gnus-set-global-variables)))
4522 (gnus-article-setup-highlight-words)
4523 ;; Init original article buffer.
4524 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4525 (mm-enable-multibyte)
4526 (setq major-mode 'gnus-original-article-mode)
4527 (make-local-variable 'gnus-original-article))
4528 (if (and (get-buffer name)
4529 (with-current-buffer name
4530 (if gnus-article-edit-mode
4531 (if (y-or-n-p "Article mode edit in progress; discard? ")
4533 (set-buffer-modified-p nil)
4534 (gnus-kill-buffer name)
4537 (error "Action aborted"))
4539 (with-current-buffer name
4540 (set (make-local-variable 'gnus-article-edit-mode) nil)
4541 (when gnus-article-mime-handles
4542 (mm-destroy-parts gnus-article-mime-handles)
4543 (setq gnus-article-mime-handles nil))
4544 ;; Set it to nil in article-buffer!
4545 (setq gnus-article-mime-handle-alist nil)
4546 (buffer-disable-undo)
4547 (setq buffer-read-only t)
4548 (unless (eq major-mode 'gnus-article-mode)
4549 (gnus-article-mode))
4550 (setq truncate-lines gnus-article-truncate-lines)
4552 (with-current-buffer (gnus-get-buffer-create name)
4554 (setq truncate-lines gnus-article-truncate-lines)
4555 (make-local-variable 'gnus-summary-buffer)
4556 (setq gnus-summary-buffer
4557 (gnus-summary-buffer-name gnus-newsgroup-name))
4558 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4559 (when (and gnus-article-update-lapsed-header
4560 (not article-lapsed-timer))
4561 (gnus-start-date-timer gnus-article-update-lapsed-header))
4562 (current-buffer)))))
4564 ;; Set article window start at LINE, where LINE is the number of lines
4565 ;; from the head of the article.
4566 (defun gnus-article-set-window-start (&optional line)
4567 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4568 (when article-window
4571 (with-current-buffer gnus-article-buffer
4572 (goto-char (point-min))
4575 (gnus-message 6 "Moved to bookmark")
4576 (search-forward "\n\n" nil t)
4580 (defun gnus-article-prepare (article &optional all-headers header)
4581 "Prepare ARTICLE in article mode buffer.
4582 ARTICLE should either be an article number or a Message-ID.
4583 If ARTICLE is an id, HEADER should be the article headers.
4584 If ALL-HEADERS is non-nil, no headers are hidden."
4586 ;; Make sure we start in a summary buffer.
4587 (unless (eq major-mode 'gnus-summary-mode)
4588 (set-buffer gnus-summary-buffer))
4589 (setq gnus-summary-buffer (current-buffer))
4590 (let* ((gnus-article (if header (mail-header-number header) article))
4591 (summary-buffer (current-buffer))
4592 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4593 (group gnus-newsgroup-name)
4596 (gnus-article-setup-buffer)
4597 (set-buffer gnus-article-buffer)
4598 ;; Deactivate active regions.
4599 (when (and (boundp 'transient-mark-mode)
4600 transient-mark-mode)
4601 (setq mark-active nil))
4602 (if (not (setq result (let ((inhibit-read-only t))
4603 (gnus-request-article-this-buffer
4605 ;; There is no such article.
4607 (when (and (numberp article)
4608 (not (memq article gnus-newsgroup-sparse)))
4609 (setq gnus-article-current
4610 (cons gnus-newsgroup-name article))
4611 (set-buffer gnus-summary-buffer)
4612 (setq gnus-current-article article)
4613 (if (and (memq article gnus-newsgroup-undownloaded)
4614 (not (gnus-online (gnus-find-method-for-group
4615 gnus-newsgroup-name))))
4617 (gnus-summary-set-agent-mark article)
4618 (message "Message marked for downloading"))
4619 (gnus-summary-mark-article article gnus-canceled-mark)
4620 (unless (memq article gnus-newsgroup-sparse)
4621 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4622 (if (or (eq result 'pseudo)
4623 (eq result 'nneething))
4625 (with-current-buffer summary-buffer
4626 (push article gnus-newsgroup-history)
4627 (setq gnus-last-article gnus-current-article
4628 gnus-current-article 0
4629 gnus-current-headers nil
4630 gnus-article-current nil)
4631 (if (eq result 'nneething)
4632 (gnus-configure-windows 'summary)
4633 (gnus-configure-windows 'article))
4634 (gnus-set-global-variables))
4635 (let ((gnus-article-mime-handle-alist-1
4636 gnus-article-mime-handle-alist))
4637 (gnus-set-mode-line 'article)))
4638 ;; The result from the `request' was an actual article -
4639 ;; or at least some text that is now displayed in the
4641 (when (and (numberp article)
4642 (not (eq article gnus-current-article)))
4643 ;; Seems like a new article has been selected.
4644 ;; `gnus-current-article' must be an article number.
4645 (with-current-buffer summary-buffer
4646 (push article gnus-newsgroup-history)
4647 (setq gnus-last-article gnus-current-article
4648 gnus-current-article article
4649 gnus-current-headers
4650 (gnus-summary-article-header gnus-current-article)
4651 gnus-article-current
4652 (cons gnus-newsgroup-name gnus-current-article))
4653 (unless (vectorp gnus-current-headers)
4654 (setq gnus-current-headers nil))
4655 (gnus-summary-goto-subject gnus-current-article)
4656 (when (gnus-summary-show-thread)
4657 ;; If the summary buffer really was folded, the
4658 ;; previous goto may not actually have gone to
4659 ;; the right article, but the thread root instead.
4661 (gnus-summary-goto-subject gnus-current-article))
4662 (gnus-run-hooks 'gnus-mark-article-hook)
4663 (gnus-set-mode-line 'summary)
4664 (when (gnus-visual-p 'article-highlight 'highlight)
4665 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4666 ;; Set the global newsgroup variables here.
4667 (gnus-set-global-variables)
4668 (setq gnus-have-all-headers
4669 (or all-headers gnus-show-all-headers))))
4671 (gnus-configure-windows 'article))
4672 (when (or (numberp article)
4674 (gnus-article-prepare-display)
4676 (goto-char (point-min))
4677 (when gnus-break-pages
4678 (gnus-narrow-to-page)))
4679 (let ((gnus-article-mime-handle-alist-1
4680 gnus-article-mime-handle-alist))
4681 (gnus-set-mode-line 'article))
4685 (set-window-point (get-buffer-window (current-buffer)) (point))
4686 (gnus-configure-windows 'article)
4690 (defun gnus-article-prepare-display ()
4691 "Make the current buffer look like a nice article."
4692 ;; Hooks for getting information from the article.
4693 ;; This hook must be called before being narrowed.
4694 (let ((gnus-article-buffer (current-buffer))
4696 (inhibit-read-only t))
4697 (unless (eq major-mode 'gnus-article-mode)
4698 (gnus-article-mode))
4699 (setq buffer-read-only nil
4700 gnus-article-wash-types nil
4701 gnus-article-image-alist nil)
4702 (gnus-run-hooks 'gnus-tmp-internal-hook)
4703 (when gnus-display-mime-function
4704 (funcall gnus-display-mime-function))
4705 (gnus-run-hooks 'gnus-article-prepare-hook)))
4708 ;;; Gnus Sticky Article Mode
4711 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4712 "Mode for sticky articles."
4713 ;; Release bindings that won't work.
4714 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4715 gnus-sticky-article-mode-map)
4716 (substitute-key-definition 'gnus-article-refer-article 'undefined
4717 gnus-sticky-article-mode-map)
4718 (dolist (k '("e" "h" "s" "F" "R"))
4719 (define-key gnus-sticky-article-mode-map k nil))
4720 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4721 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4722 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4723 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4725 (defun gnus-sticky-article (arg)
4726 "Make the current article sticky.
4727 If a prefix ARG is given, ask for a name for this sticky article buffer."
4729 (gnus-summary-show-thread)
4730 (gnus-summary-select-article nil nil 'pseudo)
4731 (let (new-art-buf-name)
4732 (gnus-eval-in-buffer-window gnus-article-buffer
4733 (setq new-art-buf-name
4737 (read-from-minibuffer "Sticky article buffer name: ")
4738 (gnus-with-article-headers
4739 (gnus-article-goto-header "subject")
4740 (setq new-art-buf-name
4741 (buffer-substring-no-properties
4742 (line-beginning-position) (line-end-position)))
4743 (goto-char (point-min))
4744 (gnus-article-goto-header "from")
4745 (setq new-art-buf-name
4747 new-art-buf-name ", "
4748 (buffer-substring-no-properties
4749 (line-beginning-position) (line-end-position))))
4750 (goto-char (point-min))
4751 (gnus-article-goto-header "date")
4752 (setq new-art-buf-name
4754 new-art-buf-name ", "
4755 (buffer-substring-no-properties
4756 (line-beginning-position) (line-end-position))))))
4758 (if (and (gnus-buffer-live-p new-art-buf-name)
4759 (with-current-buffer new-art-buf-name
4760 (eq major-mode 'gnus-sticky-article-mode)))
4761 (switch-to-buffer new-art-buf-name)
4762 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4763 (gnus-sticky-article-mode))
4764 (setq gnus-article-buffer new-art-buf-name))
4765 (gnus-summary-recenter)
4766 (gnus-summary-position-point))
4768 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4769 "Kill the given sticky article BUFFER.
4770 If none is given, assume the current buffer and kill it if it has
4771 `gnus-sticky-article-mode'."
4774 (setq buffer (current-buffer)))
4775 (with-current-buffer buffer
4776 (when (eq major-mode 'gnus-sticky-article-mode)
4777 (gnus-kill-buffer buffer))))
4779 (defun gnus-kill-sticky-article-buffers (arg)
4780 "Kill all sticky article buffers.
4781 If a prefix ARG is given, ask for confirmation."
4783 (dolist (buf (gnus-buffers))
4784 (with-current-buffer buf
4785 (when (eq major-mode 'gnus-sticky-article-mode)
4787 (gnus-kill-buffer buf)
4788 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4789 (gnus-kill-buffer buf)))))))
4792 ;;; Gnus MIME viewing functions
4795 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4796 "Format of the MIME buttons.
4798 Valid specifiers include:
4800 %T MIME type, along with additional info
4801 %n The `name' parameter
4802 %d The description, if any
4803 %l The length of the encoded part
4804 %p The part identifier number
4805 %e Dots if the part isn't displayed
4807 General format specifiers can also be used. See Info node
4808 `(gnus)Formatting Variables'.")
4810 (defvar gnus-mime-button-line-format-alist
4811 '((?t gnus-tmp-type ?s)
4812 (?T gnus-tmp-type-long ?s)
4813 (?n gnus-tmp-name ?s)
4814 (?d gnus-tmp-description ?s)
4816 (?l gnus-tmp-length ?d)
4817 (?e gnus-tmp-dots ?s)))
4819 (defvar gnus-mime-button-commands
4820 '((gnus-article-press-button "\r" "Toggle Display")
4821 (gnus-mime-view-part "v" "View Interactively...")
4822 (gnus-mime-view-part-as-type "t" "View As Type...")
4823 (gnus-mime-view-part-as-charset "C" "View As charset...")
4824 (gnus-mime-save-part "o" "Save...")
4825 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4826 (gnus-mime-replace-part "r" "Replace part")
4827 (gnus-mime-delete-part "d" "Delete part")
4828 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4829 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4830 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4831 (gnus-mime-view-part-externally "e" "View Externally")
4832 (gnus-mime-print-part "p" "Print")
4833 (gnus-mime-pipe-part "|" "Pipe To Command...")
4834 (gnus-mime-action-on-part "." "Take action on the part...")))
4836 (defun gnus-article-mime-part-status ()
4837 (if gnus-article-mime-handle-alist-1
4838 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4840 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4843 (defvar gnus-mime-button-map
4844 (let ((map (make-sparse-keymap)))
4845 (define-key map gnus-mouse-2 'gnus-article-push-button)
4846 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4847 (dolist (c gnus-mime-button-commands)
4848 (define-key map (cadr c) (car c)))
4852 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4854 ,@(mapcar (lambda (c)
4855 (vector (caddr c) (car c) :active t))
4856 gnus-mime-button-commands)))
4858 (defvar gnus-url-button-commands
4859 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4861 (defvar gnus-url-button-map
4862 (let ((map (make-sparse-keymap)))
4863 (dolist (c gnus-url-button-commands)
4864 (define-key map (cadr c) (car c)))
4868 gnus-url-button-menu gnus-url-button-map "URL button menu."
4870 ,@(mapcar (lambda (c)
4871 (vector (caddr c) (car c) :active t))
4872 gnus-url-button-commands)))
4874 (defmacro gnus-bind-safe-url-regexp (&rest body)
4875 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4876 `(let ((mm-w3m-safe-url-regexp
4877 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4879 gnus-article-current-summary))
4880 (with-current-buffer gnus-article-current-summary
4881 gnus-newsgroup-name)
4882 gnus-newsgroup-name)))
4883 (if (cond ((not group)
4884 ;; Maybe we're in a mml-preview buffer
4885 ;; and no group is selected.
4887 ((stringp gnus-safe-html-newsgroups)
4888 (string-match gnus-safe-html-newsgroups group))
4889 ((consp gnus-safe-html-newsgroups)
4890 (member group gnus-safe-html-newsgroups)))
4892 mm-w3m-safe-url-regexp))))
4895 (defun gnus-mime-button-menu (event prefix)
4896 "Construct a context-sensitive menu of MIME commands."
4897 (interactive "e\nP")
4898 (save-window-excursion
4899 (let ((pos (event-start event)))
4900 (select-window (posn-window pos))
4901 (goto-char (posn-point pos))
4902 (gnus-article-check-buffer)
4903 (popup-menu gnus-mime-button-menu nil prefix))))
4905 (defun gnus-mime-view-all-parts (&optional handles)
4906 "View all the MIME parts."
4908 (with-current-buffer gnus-article-buffer
4909 (let ((handles (or handles gnus-article-mime-handles))
4910 (mail-parse-charset gnus-newsgroup-charset)
4911 (mail-parse-ignored-charsets
4912 (with-current-buffer gnus-summary-buffer
4913 gnus-newsgroup-ignored-charsets)))
4915 (mm-remove-parts handles)
4916 (goto-char (point-min))
4917 (or (search-forward "\n\n") (goto-char (point-max)))
4918 (let ((inhibit-read-only t))
4919 (delete-region (point) (point-max))
4920 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4922 (defun gnus-article-jump-to-part (n)
4923 "Jump to MIME part N."
4925 (let ((parts (with-current-buffer gnus-article-buffer
4926 (length gnus-article-mime-handle-alist))))
4928 (error "No such part"))
4929 (pop-to-buffer gnus-article-buffer)
4930 ;; FIXME: why is it necessary?
4933 (setq n (if (= parts 1)
4935 (read-number (format "Jump to part (1..%s): " parts)))))
4936 (unless (and (integerp n) (<= n parts) (>= n 1))
4939 (gnus-message 7 "Invalid part `%s', using %s instead."
4942 (gnus-message 9 "Jumping to part %s." n)
4943 (cond ((>= gnus-auto-select-part 1)
4944 (while (and (<= n parts)
4945 (not (gnus-article-goto-part n)))
4947 ((< gnus-auto-select-part 0)
4948 (while (and (>= n 1)
4949 (not (gnus-article-goto-part n)))
4952 (gnus-article-goto-part n)))))
4954 (defvar gnus-mime-buttonized-part-id nil
4955 "ID of a mime part that should be buttonized.
4956 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4959 (defsubst gnus-article-edit-part (handles &optional current-id)
4960 "Edit an article in order to delete a mime part.
4961 This function is exclusively used by `gnus-mime-save-part-and-strip'
4962 and `gnus-mime-delete-part', and not provided at run-time normally."
4963 (gnus-article-edit-article
4965 (buffer-disable-undo)
4967 (let ((mail-parse-charset (or gnus-article-charset
4968 ',gnus-newsgroup-charset))
4969 (mail-parse-ignored-charsets
4970 (or gnus-article-ignored-charsets
4971 ',gnus-newsgroup-ignored-charsets))
4972 (mbl mml-buffer-list))
4973 (setq mml-buffer-list nil)
4974 (insert-buffer-substring gnus-original-article-buffer)
4975 (mime-to-mml ',handles)
4976 (setq gnus-article-mime-handles nil)
4977 (let ((mbl1 mml-buffer-list))
4978 (setq mml-buffer-list mbl)
4979 (set (make-local-variable 'mml-buffer-list) mbl1))
4980 (gnus-make-local-hook 'kill-buffer-hook)
4981 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4982 `(lambda (no-highlight)
4983 (let ((mail-parse-charset (or gnus-article-charset
4984 ',gnus-newsgroup-charset))
4985 (message-options message-options)
4986 (message-options-set-recipient)
4987 (mail-parse-ignored-charsets
4988 (or gnus-article-ignored-charsets
4989 ',gnus-newsgroup-ignored-charsets)))
4991 (mml-destroy-buffers)
4992 (remove-hook 'kill-buffer-hook
4993 'mml-destroy-buffers t)
4994 (kill-local-variable 'mml-buffer-list))
4995 (gnus-summary-edit-article-done
4996 ,(or (mail-header-references gnus-current-headers) "")
4997 ,(gnus-group-read-only-p)
4998 ,gnus-summary-buffer no-highlight))
5000 ;; Force buttonizing this part.
5001 (let ((gnus-mime-buttonized-part-id current-id))
5002 (gnus-article-edit-done))
5003 (gnus-configure-windows 'article)
5004 (when (and current-id (integerp gnus-auto-select-part))
5005 (gnus-article-jump-to-part
5006 (min (max (+ current-id gnus-auto-select-part) 1)
5007 (with-current-buffer gnus-article-buffer
5008 (length gnus-article-mime-handle-alist)))))))
5010 (defun gnus-mime-replace-part (file)
5011 "Replace MIME part under point with an external body."
5012 ;; Useful if file has already been saved to disk
5015 (read-file-name "Replace MIME part with file: "
5016 (or mm-default-directory default-directory)
5018 (gnus-mime-save-part-and-strip file))
5020 (defun gnus-mime-save-part-and-strip (&optional file)
5021 "Save the MIME part under point then replace it with an external body.
5022 If FILE is given, use it for the external part."
5024 (gnus-article-check-buffer)
5025 (when (gnus-group-read-only-p)
5026 (error "The current group does not support deleting of parts"))
5027 (when (mm-complicated-handles gnus-article-mime-handles)
5029 The current article has a complicated MIME structure, giving up..."))
5030 (let* ((data (get-text-property (point) 'gnus-data))
5031 (id (get-text-property (point) 'gnus-part))
5033 (handles gnus-article-mime-handles))
5036 (and data (mm-save-part data "Delete MIME part and save to: "))))
5038 (with-current-buffer (mm-handle-buffer data)
5040 (insert "Content-Type: " (mm-handle-media-type data))
5041 (mml-insert-parameter-string (cdr (mm-handle-type data))
5043 ;; Add a filename for the sake of saving the part again.
5044 (mml-insert-parameter
5045 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5047 (insert "Content-ID: " (message-make-message-id) "\n")
5048 (insert "Content-Transfer-Encoding: binary\n")
5051 (cdr (mm-make-handle nil
5052 `("message/external-body"
5053 (access-type . "LOCAL-FILE")
5055 ;; (set-buffer gnus-summary-buffer)
5056 (gnus-article-edit-part handles id))))
5058 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5059 ;; parts...>') but with stripping would be nice.
5061 (defun gnus-mime-delete-part ()
5062 "Delete the MIME part under point.
5063 Replace it with some information about the removed part."
5065 (gnus-article-check-buffer)
5066 (when (gnus-group-read-only-p)
5067 (error "The current group does not support deleting of parts"))
5068 (when (mm-complicated-handles gnus-article-mime-handles)
5070 The current article has a complicated MIME structure, giving up..."))
5071 (when (or gnus-expert-user
5072 (gnus-yes-or-no-p "\
5073 Deleting parts may malfunction or destroy the article; continue? "))
5074 (let* ((data (get-text-property (point) 'gnus-data))
5075 (id (get-text-property (point) 'gnus-part))
5076 (handles gnus-article-mime-handles)
5079 (let ((desc (mm-handle-description data)))
5081 (mail-decode-encoded-word-string desc))))
5083 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
5085 (type (mm-handle-media-type data)))
5087 (error "No MIME part under point"))
5088 (with-current-buffer (mm-handle-buffer data)
5089 (let ((bsize (buffer-size)))
5094 "| The following attachment has been deleted:\n"
5096 "| Type: " type "\n"
5097 "| Filename: " filename "\n"
5098 "| Size (encoded): " (format "%s byte%s\n"
5099 bsize (if (= bsize 1)
5103 (concat "| Description: " description "\n"))
5106 (cdr (mm-make-handle
5107 nil `("text/plain" (charset . gnus-decoded)) nil nil
5109 (format "Deleted attachment (%s bytes)" bsize))))))
5110 ;; (set-buffer gnus-summary-buffer)
5111 (gnus-article-edit-part handles id))))
5113 (defun gnus-mime-save-part ()
5114 "Save the MIME part under point."
5116 (gnus-article-check-buffer)
5117 (let ((data (get-text-property (point) 'gnus-data)))
5119 (mm-save-part data))))
5121 (defun gnus-mime-pipe-part (&optional cmd)
5122 "Pipe the MIME part under point to a process.
5123 Use CMD as the process."
5125 (gnus-article-check-buffer)
5126 (let ((data (get-text-property (point) 'gnus-data)))
5128 (mm-pipe-part data cmd))))
5130 (defun gnus-mime-view-part ()
5131 "Interactively choose a viewing method for the MIME part under point."
5133 (gnus-article-check-buffer)
5134 (let ((data (get-text-property (point) 'gnus-data)))
5136 (setq gnus-article-mime-handles
5138 gnus-article-mime-handles (setq data (copy-sequence data))))
5139 (mm-interactively-view-part data))))
5141 (defun gnus-mime-view-part-as-type-internal ()
5142 (gnus-article-check-buffer)
5143 (let* ((handle (get-text-property (point) 'gnus-data))
5145 ;; Content-Type: foo/bar; name=...
5146 (mail-content-type-get (mm-handle-type handle) 'name)
5147 ;; Content-Disposition: attachment; filename=...
5148 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5149 (def-type (and name (mm-default-file-encoding name))))
5150 (or (and def-type (cons def-type 0))
5152 (equal (mm-handle-media-supertype handle) "text")
5153 '("text/plain" . 0))
5154 '("application/octet-stream" . 0))))
5156 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5157 "Choose a MIME media type, and view the part as such.
5158 If non-nil, PRED is a predicate to use during completion to limit the
5159 available media-types."
5163 (let ((default (gnus-mime-view-part-as-type-internal)))
5164 (gnus-completing-read
5167 (gnus-remove-if-not pred (mailcap-mime-types))
5168 (mailcap-mime-types))
5171 (gnus-article-check-buffer)
5172 (let ((handle (get-text-property (point) 'gnus-data)))
5174 (when (equal (mm-handle-media-type handle) "message/external-body")
5175 (unless (mm-handle-cache handle)
5176 (mm-extern-cache-contents handle))
5177 (setq handle (mm-handle-cache handle)))
5179 (mm-make-handle (mm-handle-buffer handle)
5180 (cons mime-type (cdr (mm-handle-type handle)))
5181 (mm-handle-encoding handle)
5182 (mm-handle-undisplayer handle)
5183 (mm-handle-disposition handle)
5184 (mm-handle-description handle)
5186 (mm-handle-id handle)))
5187 (setq gnus-article-mime-handles
5188 (mm-merge-handles gnus-article-mime-handles handle))
5189 (when (mm-handle-displayed-p handle)
5190 (mm-remove-part handle))
5191 (gnus-mm-display-part handle))))
5193 (defun gnus-mime-copy-part (&optional handle arg)
5194 "Put the MIME part under point into a new buffer.
5195 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5197 (interactive (list nil current-prefix-arg))
5198 (gnus-article-check-buffer)
5200 (setq handle (get-text-property (point) 'gnus-data)))
5202 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5204 (mail-content-type-get (mm-handle-disposition handle)
5206 contents dont-decode charset coding-system)
5207 (mm-with-unibyte-buffer
5208 (mm-insert-part handle)
5209 (setq contents (or (condition-case nil
5210 (mm-decompress-buffer filename nil 'sig)
5212 (setq dont-decode t)
5215 (setq filename (cond (filename (file-name-nondirectory filename))
5216 (dont-decode "*raw data*")
5221 (unless (setq charset (mail-content-type-get
5222 (mm-handle-type handle) 'charset))
5223 (unless (setq coding-system (mm-with-unibyte-buffer
5225 (mm-find-buffer-file-coding-system)))
5226 (setq charset gnus-newsgroup-charset))))
5228 (setq charset (or (cdr (assq arg
5229 gnus-summary-show-article-charset-alist))
5230 (mm-read-coding-system "Charset: ")))))
5231 (switch-to-buffer (generate-new-buffer filename))
5232 (if (or coding-system
5234 (setq coding-system (mm-charset-to-coding-system charset))
5235 (not (eq coding-system 'ascii))))
5237 (mm-enable-multibyte)
5238 (insert (mm-decode-coding-string contents coding-system))
5239 (setq buffer-file-coding-system
5240 (if (boundp 'last-coding-system-used)
5241 (symbol-value 'last-coding-system-used)
5243 (mm-disable-multibyte)
5245 (setq buffer-file-coding-system mm-binary-coding-system))
5246 ;; We do it this way to make `normal-mode' set the appropriate mode.
5249 (setq buffer-file-name (expand-file-name filename))
5251 (setq buffer-file-name nil))
5252 (goto-char (point-min)))))
5254 (defun gnus-mime-print-part (&optional handle filename)
5255 "Print the MIME part under point."
5256 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5257 (gnus-article-check-buffer)
5258 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5259 (contents (and handle (mm-get-part handle)))
5260 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5261 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5266 (mm-save-part-to-file handle file)
5267 (call-process shell-file-name nil
5268 (generate-new-buffer " *mm*")
5270 shell-command-switch
5272 printer file (mm-handle-type handle))))
5276 (gnus-print-buffer))
5277 (ps-despool filename)))))
5279 (defun gnus-mime-inline-part (&optional handle arg)
5280 "Insert the MIME part under point into the current buffer.
5281 Compressed files like .gz and .bz2 are decompressed."
5282 (interactive (list nil current-prefix-arg))
5283 (gnus-article-check-buffer)
5285 (setq handle (get-text-property (point) 'gnus-data)))
5288 (inhibit-read-only t)
5289 contents charset coding-system)
5290 (if (and (not arg) (mm-handle-undisplayer handle))
5291 (mm-remove-part handle)
5292 (mm-with-unibyte-buffer
5293 (mm-insert-part handle)
5295 (or (mm-decompress-buffer
5296 (or (mail-content-type-get (mm-handle-type handle)
5298 (mail-content-type-get (mm-handle-disposition handle)
5304 (unless (setq charset (mail-content-type-get
5305 (mm-handle-type handle) 'charset))
5306 (unless (setq coding-system
5307 (mm-with-unibyte-buffer
5309 (mm-find-buffer-file-coding-system)))
5310 (setq charset gnus-newsgroup-charset))))
5312 (if (mm-handle-undisplayer handle)
5313 (mm-remove-part handle))
5316 gnus-summary-show-article-charset-alist))
5317 (mm-read-coding-system "Charset: "))))
5319 (if (mm-handle-undisplayer handle)
5320 (mm-remove-part handle))))
5322 (mm-display-inline handle)
5325 (defun gnus-mime-set-charset-parameters (handle charset)
5326 "Set CHARSET to parameters in HANDLE.
5327 CHARSET may either be a string or a symbol."
5328 (unless (stringp charset)
5329 (setq charset (symbol-name charset)))
5330 (if (stringp (car handle))
5331 (dolist (h (cdr handle))
5332 (gnus-mime-set-charset-parameters h charset))
5333 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5334 "message/external-body")
5336 (unless (mm-handle-cache handle)
5337 (mm-extern-cache-contents handle))
5338 (mm-handle-cache handle))
5340 (param (assq 'charset (cdr type))))
5342 (setcdr param charset)
5343 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5345 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5346 "Insert the MIME part under point into the current buffer using the
5348 (interactive (list nil current-prefix-arg))
5349 (gnus-article-check-buffer)
5350 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5351 (fun (get-text-property (point) 'gnus-callback))
5352 (gnus-newsgroup-ignored-charsets 'gnus-all)
5353 charset form preferred parts)
5360 gnus-summary-show-article-charset-alist))
5361 (mm-read-coding-system "Charset: "))))
5362 (if (mm-handle-undisplayer handle)
5363 (mm-remove-part handle)))
5364 (gnus-mime-set-charset-parameters handle charset)
5365 (when (and (consp (setq form (cdr-safe fun)))
5366 (setq form (ignore-errors
5367 (assq 'gnus-mime-display-alternative form)))
5368 (setq preferred (caddr form))
5370 (when (eq (car preferred) 'quote)
5371 (setq preferred (cadr preferred)))
5372 (not (equal preferred
5373 (get-text-property (point) 'gnus-data))))
5374 (setq parts (get-text-property (point) 'gnus-part))
5375 (setq parts (cdr (assq parts
5376 gnus-article-mime-handle-alist)))
5377 (equal (mm-handle-media-type parts) "multipart/alternative")
5378 (setq parts (reverse (cdr parts))))
5380 (list 'quote (or (cadr (member preferred parts))
5382 (funcall fun handle)))))
5384 (defun gnus-mime-view-part-externally (&optional handle)
5385 "View the MIME part under point with an external viewer."
5387 (gnus-article-check-buffer)
5388 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5389 (mm-user-display-methods nil)
5390 (mm-inlined-types nil)
5391 (mail-parse-charset gnus-newsgroup-charset)
5392 (mail-parse-ignored-charsets
5393 (with-current-buffer gnus-summary-buffer
5394 gnus-newsgroup-ignored-charsets))
5395 (type (mm-handle-media-type handle))
5396 (method (mailcap-mime-info type))
5397 (mm-enable-external t))
5398 (if (not (stringp method))
5399 (gnus-mime-view-part-as-type
5400 nil (lambda (type) (stringp (mailcap-mime-info type))))
5402 (mm-display-part handle nil t)))))
5404 (defun gnus-mime-view-part-internally (&optional handle)
5405 "View the MIME part under point with an internal viewer.
5406 If no internal viewer is available, use an external viewer."
5408 (gnus-article-check-buffer)
5409 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5410 (mm-inlined-types '(".*"))
5411 (mm-inline-large-images t)
5412 (mail-parse-charset gnus-newsgroup-charset)
5413 (mail-parse-ignored-charsets
5414 (with-current-buffer gnus-summary-buffer
5415 gnus-newsgroup-ignored-charsets))
5416 (inhibit-read-only t))
5417 (if (not (mm-inlinable-p handle))
5418 (gnus-mime-view-part-as-type
5419 nil (lambda (type) (mm-inlinable-p handle type)))
5421 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5423 (defun gnus-mime-action-on-part (&optional action)
5424 "Do something with the MIME attachment at \(point\)."
5426 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5427 (gnus-article-check-buffer)
5428 (let ((action-pair (assoc action gnus-mime-action-alist)))
5430 (funcall (cdr action-pair)))))
5432 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5433 "Call FUNCTION on MIME part N.
5434 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5435 If INTERACTIVE, call FUNCTION interactivly."
5437 ;; Check whether the article is displayed.
5438 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5439 (setq window (get-buffer-window gnus-article-buffer t))
5440 (frame-visible-p (setq frame (window-frame window))))
5441 (error "No article is displayed"))
5442 (with-current-buffer gnus-article-buffer
5443 ;; Check whether the article displays the right contents.
5444 (unless (with-current-buffer gnus-summary-buffer
5445 (eq gnus-current-article (gnus-summary-article-number)))
5446 (error "You should select the right article first"))
5448 (setq n (prefix-numeric-value n))
5450 (setq n (or (get-text-property pt 'gnus-part)
5452 (get-text-property (1- pt) 'gnus-part))
5453 (get-text-property (prog2
5459 (or (and (setq pt (previous-single-property-change
5462 (next-single-property-change (point) 'gnus-part)
5466 ;; Check whether the specified part exists.
5467 (when (> n (length gnus-article-mime-handle-alist))
5468 (error "No such part")))
5471 ;; To select the window is needed so that the cursor
5472 ;; might be visible on the MIME button.
5473 (select-window (prog1
5475 (setq window (selected-window))
5476 ;; Article may be displayed in the other frame.
5477 (gnus-select-frame-set-input-focus
5480 (setq frame (selected-frame))))))
5481 (when (gnus-article-goto-part n)
5482 ;; We point the cursor and the arrow at the MIME button
5483 ;; when the `function' prompt the user for something.
5484 (unless (and (pos-visible-in-window-p)
5485 (> (count-lines (point) (window-end))
5486 (/ (1- (window-height)) 3)))
5487 (recenter (/ (1- (window-height)) 3)))
5488 (let ((cursor-in-non-selected-windows t)
5489 (overlay-arrow-string "=>")
5490 (overlay-arrow-position (point-marker)))
5493 ((and no-handle interactive)
5494 (call-interactively function))
5499 function (get-text-property (point) 'gnus-data)))
5502 (get-text-property (point) 'gnus-data))))
5503 (set-marker overlay-arrow-position nil)
5504 (unless gnus-auto-select-part
5505 (gnus-select-frame-set-input-focus frame)
5506 (select-window window))))
5508 (if gnus-inhibit-mime-unbuttonizing
5509 ;; This is the default though the program shouldn't reach here.
5510 (error "No such part")
5511 ;; The part which doesn't have the MIME button is selected.
5512 ;; So, we display all the buttons and redo it.
5513 (let ((gnus-inhibit-mime-unbuttonizing t))
5514 (gnus-summary-show-article)
5515 (gnus-article-part-wrapper n function no-handle))))))
5517 (defun gnus-article-pipe-part (n)
5518 "Pipe MIME part N, which is the numerical prefix."
5520 (gnus-article-part-wrapper n 'mm-pipe-part))
5522 (defun gnus-article-save-part (n)
5523 "Save MIME part N, which is the numerical prefix."
5525 (gnus-article-part-wrapper n 'mm-save-part))
5527 (defun gnus-article-interactively-view-part (n)
5528 "View MIME part N interactively, which is the numerical prefix."
5530 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5532 (defun gnus-article-copy-part (n)
5533 "Copy MIME part N, which is the numerical prefix."
5535 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5537 (defun gnus-article-view-part-as-charset (n)
5538 "View MIME part N using a specified charset.
5539 N is the numerical prefix."
5541 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5543 (defun gnus-article-view-part-externally (n)
5544 "View MIME part N externally, which is the numerical prefix."
5546 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5548 (defun gnus-article-inline-part (n)
5549 "Inline MIME part N, which is the numerical prefix."
5551 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5553 (defun gnus-article-save-part-and-strip (n)
5554 "Save MIME part N and replace it with an external body.
5555 N is the numerical prefix."
5557 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5559 (defun gnus-article-replace-part (n)
5560 "Replace MIME part N with an external body.
5561 N is the numerical prefix."
5563 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5565 (defun gnus-article-delete-part (n)
5566 "Delete MIME part N and add some information about the removed part.
5567 N is the numerical prefix."
5569 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5571 (defun gnus-article-view-part-as-type (n)
5572 "Choose a MIME media type, and view part N as such.
5573 N is the numerical prefix."
5575 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5577 (defun gnus-article-mime-match-handle-first (condition)
5580 (dolist (ihandle gnus-article-mime-handle-alist)
5582 ((functionp condition)
5583 (funcall condition (cdr ihandle)))
5584 ((eq condition 'undisplayed)
5585 (not (or (mm-handle-undisplayer (cdr ihandle))
5586 (equal (mm-handle-media-type (cdr ihandle))
5587 "multipart/alternative"))))
5588 ((eq condition 'undisplayed-alternative)
5589 (not (mm-handle-undisplayer (cdr ihandle))))
5591 (gnus-article-goto-part (car ihandle))
5592 (or (not n) (< (car ihandle) n)))
5593 (setq n (car ihandle))))
5597 (defun gnus-article-view-part (&optional n)
5598 "View MIME part N, which is the numerical prefix.
5599 If the part is already shown, hide the part. If N is nil, view
5602 (with-current-buffer gnus-article-buffer
5603 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5604 gnus-article-mime-match-handle-function)))
5605 (when (> n (length gnus-article-mime-handle-alist))
5606 (error "No such part"))
5607 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5608 (when (gnus-article-goto-part n)
5609 (if (equal (car handle) "multipart/alternative")
5610 (gnus-article-press-button)
5611 (when (eq (gnus-mm-display-part handle) 'internal)
5612 (gnus-set-window-start)))))))
5614 (defsubst gnus-article-mime-total-parts ()
5615 (if (bufferp (car gnus-article-mime-handles))
5617 (1- (length gnus-article-mime-handles))))
5619 (defun gnus-mm-display-part (handle)
5620 "Display HANDLE and fix MIME button."
5621 (let ((id (get-text-property (point) 'gnus-part))
5623 (inhibit-read-only t))
5626 (let ((window (selected-window))
5627 (mail-parse-charset gnus-newsgroup-charset)
5628 (mail-parse-ignored-charsets
5629 (if (gnus-buffer-live-p gnus-summary-buffer)
5630 (with-current-buffer gnus-summary-buffer
5631 gnus-newsgroup-ignored-charsets)
5635 (let ((win (gnus-get-buffer-window (current-buffer) t))
5638 (select-window win))
5641 (if (mm-handle-displayed-p handle)
5642 ;; This will remove the part.
5643 (mm-display-part handle)
5645 (narrow-to-region (point)
5646 (if (eobp) (point) (1+ (point))))
5647 (gnus-bind-safe-url-regexp (mm-display-part handle))
5648 ;; We narrow to the part itself and
5649 ;; then call the treatment functions.
5650 (goto-char (point-min))
5652 (narrow-to-region (point) (point-max))
5655 (gnus-article-mime-total-parts)
5656 (mm-handle-media-type handle)))))
5657 (if (window-live-p window)
5658 (select-window window)))))
5661 (gnus-insert-mime-button
5662 handle id (list (mm-handle-displayed-p handle)))
5663 (goto-char point))))
5665 (defun gnus-article-goto-part (n)
5666 "Go to MIME part N."
5667 (when gnus-break-pages
5670 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5671 part handle end next handles)
5674 (if (setq handle (get-text-property start 'gnus-data))
5676 ;; Go to the displayed subpart, assuming this is
5677 ;; multipart/alternative.
5680 (while (and (not handle)
5683 (setq next (text-property-not-all part end
5686 handle (get-text-property part 'gnus-data))
5687 (push (cons handle part) handles)
5688 (unless (mm-handle-displayed-p handle)
5690 part (text-property-any part end 'gnus-data nil))))
5692 ;; No subpart is displayed, so we find preferred one.
5694 (cdr (assq (mm-preferred-alternative
5695 (nreverse (mapcar 'car handles)))
5698 (goto-char (1+ part))
5700 (when gnus-break-pages
5701 (gnus-narrow-to-page))))
5703 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5704 (let ((gnus-tmp-name
5705 (or (mail-content-type-get (mm-handle-type handle) 'name)
5706 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5707 (mail-content-type-get (mm-handle-type handle) 'url)
5709 (gnus-tmp-type (mm-handle-media-type handle))
5710 (gnus-tmp-description (or (mm-handle-description handle) ""))
5712 (if (if displayed (car displayed)
5713 (mm-handle-displayed-p handle))
5715 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5717 gnus-tmp-type-long b e)
5718 (when (string-match ".*/" gnus-tmp-name)
5719 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5720 (setq gnus-tmp-type-long (concat gnus-tmp-type
5721 (and (not (equal gnus-tmp-name ""))
5722 (concat "; " gnus-tmp-name))))
5723 (unless (equal gnus-tmp-description "")
5724 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5729 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5730 `(keymap ,gnus-mime-button-map
5731 gnus-callback gnus-mm-display-part
5732 gnus-part ,gnus-tmp-id
5733 article-type annotation
5736 ;; Exclude a newline.
5739 (when gnus-article-button-face
5740 (gnus-overlay-put (gnus-make-overlay b e nil t)
5741 'face gnus-article-button-face))
5742 (widget-convert-button
5745 :action 'gnus-widget-press-button
5746 :button-keymap gnus-mime-button-map
5749 ;; Needed to properly clear the message due to a bug in
5750 ;; wid-edit (XEmacs only).
5751 (if (boundp 'help-echo-owns-message)
5752 (setq help-echo-owns-message t))
5754 "%S: %s the MIME part; %S: more options"
5755 (aref gnus-mouse-2 0)
5756 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5758 (aref gnus-down-mouse-3 0))))))
5760 (defun gnus-widget-press-button (elems el)
5761 (goto-char (widget-get elems :from))
5762 (gnus-article-press-button))
5764 (defvar gnus-displaying-mime nil)
5766 (defun gnus-display-mime (&optional ihandles)
5767 "Display the MIME parts."
5769 (save-selected-window
5770 (let ((window (get-buffer-window gnus-article-buffer))
5773 (select-window window)
5774 ;; We have to do this since selecting the window
5775 ;; may change the point. So we set the window point.
5776 (set-window-point window point)))
5777 (let ((handles ihandles)
5778 (inhibit-read-only t)
5781 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5782 (when gnus-article-emulate-mime
5783 (mm-uu-dissect-text-parts handles)))
5784 (gnus-article-emulate-mime
5785 (setq handles (mm-uu-dissect))))
5786 (when (and (not ihandles)
5787 (not gnus-displaying-mime))
5788 ;; Top-level call; we clean up.
5789 (when gnus-article-mime-handles
5790 (mm-destroy-parts gnus-article-mime-handles)
5791 (setq gnus-article-mime-handle-alist nil));; A trick.
5792 (setq gnus-article-mime-handles handles)
5793 ;; We allow users to glean info from the handles.
5794 (when gnus-article-mime-part-function
5795 (gnus-mime-part-function handles)))
5797 (or (not (stringp (car handles)))
5800 (when (and (not ihandles)
5801 (not gnus-displaying-mime))
5802 ;; Clean up for mime parts.
5804 (delete-region (point) (point-max)))
5805 (let ((gnus-displaying-mime t))
5806 (gnus-mime-display-part handles)))
5809 (narrow-to-region (point) (point-max))
5810 (gnus-treat-article nil 1 1 "text/plain")
5813 ;; Highlight the headers.
5817 (narrow-to-region (point-min) (point))
5818 (gnus-article-save-original-date
5819 (gnus-treat-article 'head)))))))
5820 ;; Cope with broken MIME messages.
5821 (goto-char (point-max))
5825 (defcustom gnus-mime-display-multipart-as-mixed nil
5826 "Display \"multipart\" parts as \"multipart/mixed\".
5828 If t, it overrides nil values of
5829 `gnus-mime-display-multipart-alternative-as-mixed' and
5830 `gnus-mime-display-multipart-related-as-mixed'."
5831 :group 'gnus-article-mime
5834 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5835 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5837 :group 'gnus-article-mime
5840 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5841 "Display \"multipart/related\" parts as \"multipart/mixed\".
5843 If displaying \"text/html\" is discouraged \(see
5844 `mm-discouraged-alternatives'\) images or other material inside a
5845 \"multipart/related\" part might be overlooked when this variable is nil."
5847 :group 'gnus-article-mime
5850 (defun gnus-mime-display-part (handle)
5852 ;; Maybe a broken MIME message.
5855 ((not (stringp (car handle)))
5856 (gnus-mime-display-single handle))
5857 ;; User-defined multipart
5858 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5859 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5861 ;; multipart/alternative
5862 ((and (equal (car handle) "multipart/alternative")
5863 (not (or gnus-mime-display-multipart-as-mixed
5864 gnus-mime-display-multipart-alternative-as-mixed)))
5865 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5866 (push (cons id handle) gnus-article-mime-handle-alist)
5867 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5868 ;; multipart/related
5869 ((and (equal (car handle) "multipart/related")
5870 (not (or gnus-mime-display-multipart-as-mixed
5871 gnus-mime-display-multipart-related-as-mixed)))
5872 ;;;!!!We should find the start part, but we just default
5873 ;;;!!!to the first part.
5874 ;;(gnus-mime-display-part (cadr handle))
5875 ;;;!!! Most multipart/related is an HTML message plus images.
5876 ;;;!!! Unfortunately we are unable to let W3 display those
5877 ;;;!!! included images, so we just display it as a mixed multipart.
5878 ;;(gnus-mime-display-mixed (cdr handle))
5879 ;;;!!! No, w3 can display everything just fine.
5880 (gnus-mime-display-part (cadr handle)))
5881 ((equal (car handle) "multipart/signed")
5882 (gnus-add-wash-type 'signed)
5883 (gnus-mime-display-security handle))
5884 ((equal (car handle) "multipart/encrypted")
5885 (gnus-add-wash-type 'encrypted)
5886 (gnus-mime-display-security handle))
5887 ;; Other multiparts are handled like multipart/mixed.
5889 (gnus-mime-display-mixed (cdr handle)))))
5891 (defun gnus-mime-part-function (handles)
5892 (if (stringp (car handles))
5893 (mapcar 'gnus-mime-part-function (cdr handles))
5894 (funcall gnus-article-mime-part-function handles)))
5896 (defun gnus-mime-display-mixed (handles)
5897 (mapcar 'gnus-mime-display-part handles))
5899 (defun gnus-mime-display-single (handle)
5900 (let ((type (mm-handle-media-type handle))
5901 (ignored gnus-ignored-mime-types)
5908 (when (string-match (pop ignored) type)
5909 (throw 'ignored nil)))
5910 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5911 (with-current-buffer gnus-summary-buffer
5912 gnus-inhibit-images)
5913 gnus-inhibit-images)
5914 (string-match "\\`image/" type)))
5915 (setq not-attachment
5916 (and (not (mm-inline-override-p handle))
5917 (or (not (mm-handle-disposition handle))
5918 (equal (car (mm-handle-disposition handle))
5920 (mm-attachment-override-p handle))))
5921 (mm-automatic-display-p handle)
5923 (mm-inlinable-p handle)
5924 (mm-inlined-p handle))
5925 (mm-automatic-external-display-p type)))
5927 (when (equal (mm-handle-media-supertype handle) "text")
5929 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5931 (push (cons id handle) gnus-article-mime-handle-alist)
5933 (equal (mm-handle-media-supertype handle) "message"))
5936 (cond ((not (bolp)) 2)
5937 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5939 (when (or (not display)
5940 (not (gnus-unbuttonized-mime-type-p type))
5941 (eq id gnus-mime-buttonized-part-id))
5942 (gnus-insert-mime-button
5943 handle id (list (or display (and not-attachment text))))
5944 (gnus-article-insert-newline)
5945 ;; Remember modify the number of forward lines.
5953 (let ((mail-parse-charset gnus-newsgroup-charset)
5954 (mail-parse-ignored-charsets
5955 (save-excursion (condition-case ()
5956 (set-buffer gnus-summary-buffer)
5958 gnus-newsgroup-ignored-charsets)))
5959 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5960 (goto-char (point-max)))
5961 ((and text not-attachment)
5965 (gnus-article-insert-newline)
5966 (mm-display-inline handle)
5967 (goto-char (point-max))))
5971 (narrow-to-region beg (point))
5972 (if (eq handle gnus-article-mime-handles)
5973 ;; The format=flowed case.
5974 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5975 ;; Don't count signature parts that are never displayed.
5976 ;; The part number should be re-calculated supposing this
5977 ;; might be a message/rfc822 part.
5979 (dolist (part gnus-article-mime-handles)
5980 (unless (or (stringp part)
5981 (equal (car (mm-handle-type part))
5982 "application/pgp-signature"))
5983 (push part handles)))
5985 nil (length (memq handle handles)) (length handles)
5986 (mm-handle-media-type handle)))))))))))
5988 (defun gnus-unbuttonized-mime-type-p (type)
5989 "Say whether TYPE is to be unbuttonized."
5990 (unless gnus-inhibit-mime-unbuttonizing
5992 (let ((types gnus-unbuttonized-mime-types))
5994 (when (string-match (pop types) type)
5995 (throw 'found t)))))
5997 (let ((types gnus-buttonized-mime-types))
5999 (when (string-match (pop types) type)
6000 (throw 'found t)))))))))
6002 (defun gnus-article-insert-newline ()
6003 "Insert a newline, but mark it as undeletable."
6004 (gnus-put-text-property
6005 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6007 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6008 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6011 handle (inhibit-read-only t) from props begend not-pref)
6012 (save-window-excursion
6015 (narrow-to-region (car ibegend)
6018 (goto-char (car ibegend))
6021 (delete-region (point-min) (point-max))
6022 (mm-remove-parts handles))
6023 (setq begend (list (point-marker)))
6025 (unless (setq not-pref (cadr (member preferred ihandles)))
6026 (setq not-pref (car ihandles)))
6029 (not (gnus-unbuttonized-mime-type-p
6030 "multipart/alternative")))
6031 (gnus-add-text-properties
6034 (insert (format "%d. " id))
6038 (unless ,(not ibegend)
6039 (setq gnus-article-mime-handle-alist
6040 ',gnus-article-mime-handle-alist))
6041 (gnus-mime-display-alternative
6042 ',ihandles ',not-pref ',begend ,id))
6043 keymap ,gnus-mime-button-map
6044 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6045 face ,gnus-article-button-face
6047 article-type multipart))
6048 (widget-convert-button 'link from (point)
6049 :action 'gnus-widget-press-button
6050 :button-keymap gnus-widget-button-keymap)
6052 (while (setq handle (pop handles))
6053 (gnus-add-text-properties
6056 (insert (format "(%c) %-18s"
6057 (if (equal handle preferred) ?* ? )
6058 (mm-handle-media-type handle)))
6062 (unless ,(not ibegend)
6063 (setq gnus-article-mime-handle-alist
6064 ',gnus-article-mime-handle-alist))
6065 (gnus-mime-display-alternative
6066 ',ihandles ',handle ',begend ,id))
6067 keymap ,gnus-mime-button-map
6068 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6069 face ,gnus-article-button-face
6072 (widget-convert-button 'link from (point)
6073 :action 'gnus-widget-press-button
6074 :button-keymap gnus-widget-button-keymap)
6078 (if (stringp (car preferred))
6079 (gnus-display-mime preferred)
6080 (let ((mail-parse-charset gnus-newsgroup-charset)
6081 (mail-parse-ignored-charsets
6082 (with-current-buffer gnus-summary-buffer
6083 gnus-newsgroup-ignored-charsets)))
6084 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6088 (narrow-to-region (car begend) (point-max))
6090 nil (length gnus-article-mime-handle-alist)
6091 (gnus-article-mime-total-parts)
6092 (mm-handle-media-type preferred))))))
6093 (goto-char (point-max))
6094 (setcdr begend (point-marker)))))
6096 (goto-char point))))
6098 (defconst gnus-article-wash-status-strings
6099 (let ((alist '((cite "c" "Possible hidden citation text"
6100 " " "All citation text visible")
6101 (headers "h" "Hidden headers"
6102 " " "All headers visible.")
6103 (pgp "p" "Encrypted or signed message status hidden"
6104 " " "No hidden encryption nor digital signature status")
6105 (signature "s" "Signature has been hidden"
6106 " " "Signature is visible")
6107 (overstrike "o" "Overstrike (^H) characters applied"
6108 " " "No overstrike characters applied")
6109 (emphasis "e" "/*_Emphasis_*/ characters applied"
6110 " " "No /*_emphasis_*/ characters applied")))
6112 (dolist (entry alist result)
6113 (let ((key (nth 0 entry))
6114 (on (copy-sequence (nth 1 entry)))
6115 (on-help (nth 2 entry))
6116 (off (copy-sequence (nth 3 entry)))
6117 (off-help (nth 4 entry)))
6118 (put-text-property 0 1 'help-echo on-help on)
6119 (put-text-property 0 1 'help-echo off-help off)
6120 (push (list key on off) result))))
6121 "Alist of strings describing wash status in the mode line.
6122 Each entry has the form (KEY ON OF), where the KEY is a symbol
6123 representing the particular washing function, ON is the string to use
6124 in the article mode line when the washing function is active, and OFF
6125 is the string to use when it is inactive.")
6127 (defun gnus-article-wash-status-entry (key value)
6128 (let ((entry (assoc key gnus-article-wash-status-strings)))
6129 (if value (nth 1 entry) (nth 2 entry))))
6131 (defun gnus-article-wash-status ()
6132 "Return a string which display status of article washing."
6133 (with-current-buffer gnus-article-buffer
6134 (let ((cite (memq 'cite gnus-article-wash-types))
6135 (headers (memq 'headers gnus-article-wash-types))
6136 (boring (memq 'boring-headers gnus-article-wash-types))
6137 (pgp (memq 'pgp gnus-article-wash-types))
6138 (pem (memq 'pem gnus-article-wash-types))
6139 (signed (memq 'signed gnus-article-wash-types))
6140 (encrypted (memq 'encrypted gnus-article-wash-types))
6141 (signature (memq 'signature gnus-article-wash-types))
6142 (overstrike (memq 'overstrike gnus-article-wash-types))
6143 (emphasis (memq 'emphasis gnus-article-wash-types)))
6145 (gnus-article-wash-status-entry 'cite cite)
6146 (gnus-article-wash-status-entry 'headers (or headers boring))
6147 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6148 (gnus-article-wash-status-entry 'signature signature)
6149 (gnus-article-wash-status-entry 'overstrike overstrike)
6150 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6152 (defun gnus-add-wash-type (type)
6153 "Add a washing of TYPE to the current status."
6154 (add-to-list 'gnus-article-wash-types type))
6156 (defun gnus-delete-wash-type (type)
6157 "Add a washing of TYPE to the current status."
6158 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6160 (defun gnus-add-image (category image)
6161 "Add IMAGE of CATEGORY to the list of displayed images."
6162 (let ((entry (assq category gnus-article-image-alist)))
6164 (setq entry (list category))
6165 (push entry gnus-article-image-alist))
6166 (nconc entry (list image))))
6168 (defun gnus-delete-images (category)
6169 "Delete all images in CATEGORY."
6170 (let ((entry (assq category gnus-article-image-alist)))
6171 (dolist (image (cdr entry))
6172 (gnus-remove-image image category))
6173 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6174 (gnus-delete-wash-type category)))
6176 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6178 (defun gnus-article-maybe-hide-headers ()
6179 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6180 Provided for backwards compatibility."
6181 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6182 (not (with-current-buffer gnus-summary-buffer
6183 gnus-have-all-headers)))
6184 (not gnus-inhibit-hiding))
6185 (gnus-article-hide-headers)))
6189 (defun gnus-output-to-file (file-name)
6190 "Append the current article to a file named FILE-NAME.
6191 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6192 text and used as the value of the coding cookie which is added to the
6193 top of a file. Otherwise, this function saves a raw article without
6195 (let* ((artbuf (current-buffer))
6196 (file-name-coding-system nnmail-pathname-coding-system)
6197 (coding gnus-article-save-coding-system)
6198 (coding-system-for-read (if coding
6199 nil ;; Rely on the coding cookie.
6200 mm-text-coding-system))
6201 (coding-system-for-write (or coding
6202 mm-text-coding-system-for-write
6203 mm-text-coding-system))
6204 (exists (file-exists-p file-name)))
6207 (insert-file-contents file-name)
6208 (goto-char (point-min))
6209 ;; Remove the existing coding cookie.
6210 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6211 (delete-region (match-beginning 0) (match-end 0))))
6212 (goto-char (point-max))
6213 (insert-buffer-substring artbuf)
6214 ;; Append newline at end of the buffer as separator, and then
6216 (goto-char (point-max))
6219 ;; If the coding system is not suitable to encode the text,
6220 ;; ask a user for a proper one.
6221 (when (fboundp 'select-safe-coding-system)
6222 (setq coding (coding-system-base
6223 (save-window-excursion
6224 (select-safe-coding-system (point-min) (point-max)
6226 (setq coding-system-for-write
6227 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6229 (goto-char (point-min))
6230 ;; Add the coding cookie.
6231 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6232 coding-system-for-write)))
6235 (write-region (point-min) (point-max) file-name nil 'no-message)
6236 (message "Appended to %s" file-name))
6237 (write-region (point-min) (point-max) file-name))))
6240 (defun gnus-narrow-to-page (&optional arg)
6241 "Narrow the article buffer to a page.
6242 If given a numerical ARG, move forward ARG pages."
6244 (setq arg (if arg (prefix-numeric-value arg) 0))
6245 (with-current-buffer gnus-article-buffer
6247 ;; Remove any old next/prev buttons.
6248 (when (gnus-visual-p 'page-marker)
6249 (let ((inhibit-read-only t))
6250 (gnus-remove-text-with-property 'gnus-prev)
6251 (gnus-remove-text-with-property 'gnus-next)))
6253 (when (save-excursion
6255 (if (re-search-backward page-delimiter nil 'move (abs arg))
6257 (setq nd (match-beginning 0)
6259 (when (re-search-backward page-delimiter nil t)
6260 (setq st (match-end 0))))
6261 (when (re-search-forward page-delimiter nil t)
6262 (setq nd (match-beginning 0)
6265 (if (re-search-forward page-delimiter nil 'move arg)
6267 (setq st (match-end 0)
6269 (when (re-search-forward page-delimiter nil t)
6270 (setq nd (match-beginning 0))))
6271 (when (re-search-backward page-delimiter nil t)
6272 (setq st (match-end 0)
6275 (when (re-search-backward page-delimiter nil t)
6276 (goto-char (setq st (match-end 0))))
6277 (when (re-search-forward page-delimiter nil t)
6278 (setq nd (match-beginning 0)))
6280 (setq gnus-page-broken t)
6281 (when pt (goto-char pt))
6282 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6283 (when (gnus-visual-p 'page-marker)
6287 (gnus-insert-next-page-button))
6290 (gnus-insert-prev-page-button))))))))
6292 ;; Article mode commands
6294 (defun gnus-article-goto-next-page ()
6295 "Show the next page of the article."
6297 (when (gnus-article-next-page)
6298 (goto-char (point-min))
6299 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6302 (defun gnus-article-goto-prev-page ()
6303 "Show the previous page of the article."
6305 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6306 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6307 (gnus-article-prev-page nil)))
6309 ;; This is cleaner but currently breaks `gnus-pick-mode':
6311 ;; (defun gnus-article-goto-next-page ()
6312 ;; "Show the next page of the article."
6314 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6315 ;; (gnus-summary-next-page)))
6317 ;; (defun gnus-article-goto-prev-page ()
6318 ;; "Show the next page of the article."
6320 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6321 ;; (gnus-summary-prev-page)))
6323 (defun gnus-article-next-page (&optional lines)
6324 "Show the next page of the current article.
6325 If end of article, return non-nil. Otherwise return nil.
6326 Argument LINES specifies lines to be scrolled up."
6328 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6329 (if (and (not (and gnus-article-over-scroll
6330 (> (count-lines (window-start) (point-max))
6331 (if (featurep 'xemacs)
6332 (or lines (1- (window-height)))
6333 (+ (or lines (1- (window-height))) scroll-margin)))))
6336 (and (pos-visible-in-window-p) ;Not continuation line.
6337 (>= (point) (point-max)))))
6338 ;; Nothing in this page.
6339 (if (or (not gnus-page-broken)
6344 (eobp)))) ;Real end-of-buffer?
6346 (when gnus-article-over-scroll
6347 (gnus-article-next-page-1 lines))
6349 (gnus-narrow-to-page 1) ;Go to next page.
6351 ;; More in this page.
6352 (gnus-article-next-page-1 lines)
6355 (defun gnus-article-beginning-of-window ()
6356 "Move point to the beginning of the window.
6357 In Emacs, the point is placed at the line number which `scroll-margin'
6359 (if (featurep 'xemacs)
6360 (move-to-window-line 0)
6361 ;; There is an obscure bug in Emacs that makes it impossible to
6362 ;; scroll past big pictures in the article buffer. Try to fix
6363 ;; this by adding a sanity check by counting the lines visible.
6364 (when (> (count-lines (window-start) (window-end)) 30)
6365 (move-to-window-line
6366 (min (max 0 scroll-margin)
6367 (max 1 (- (window-height)
6368 (if mode-line-format 1 0)
6369 (if header-line-format 1 0)
6372 (defun gnus-article-next-page-1 (lines)
6374 (let ((scroll-in-place nil))
6377 ;; Long lines may cause an end-of-buffer error.
6378 (goto-char (point-max))))
6379 (gnus-article-beginning-of-window))
6381 (defun gnus-article-prev-page (&optional lines)
6382 "Show previous page of current article.
6383 Argument LINES specifies lines to be scrolled down."
6385 (move-to-window-line 0)
6386 (if (and gnus-page-broken
6388 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6390 (gnus-narrow-to-page -1) ;Go to previous page.
6391 (goto-char (point-max))
6392 (recenter (if gnus-article-over-scroll
6394 (max (if (featurep 'xemacs)
6396 (+ lines scroll-margin))
6398 (- (window-height) 2))
6402 (let ((scroll-in-place nil))
6403 (scroll-down lines))
6404 (beginning-of-buffer
6405 (goto-char (point-min))))
6406 (gnus-article-beginning-of-window))))
6408 (defun gnus-article-only-boring-p ()
6409 "Decide whether there is only boring text remaining in the article.
6410 Something \"interesting\" is a word of at least two letters that does
6411 not have a face in `gnus-article-boring-faces'."
6412 (when (and gnus-article-skip-boring
6413 (boundp 'gnus-article-boring-faces)
6414 (symbol-value 'gnus-article-boring-faces))
6416 (let ((inhibit-point-motion-hooks t))
6418 (while (re-search-forward "\\b\\w\\w" nil t)
6420 (when (not (gnus-intersection
6421 (gnus-faces-at (point))
6422 (symbol-value 'gnus-article-boring-faces)))
6423 (throw 'only-boring nil)))
6424 (throw 'only-boring t))))))
6426 (defun gnus-article-refer-article ()
6427 "Read article specified by message-id around point."
6430 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6431 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6432 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6433 (let ((msg-id (concat "<" (match-string 0) ">")))
6434 (set-buffer gnus-summary-buffer)
6435 (gnus-summary-refer-article msg-id))
6436 (error "No references around point"))))
6438 (defun gnus-article-show-summary ()
6439 "Reconfigure windows to show summary buffer."
6441 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6442 (error "There is no summary buffer for this article buffer")
6443 (gnus-article-set-globals)
6444 (gnus-configure-windows 'article)
6445 (gnus-summary-goto-subject gnus-current-article)
6446 (gnus-summary-position-point)))
6448 (defun gnus-article-describe-briefly ()
6449 "Describe article mode commands briefly."
6451 (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")))
6453 (defun gnus-article-check-buffer ()
6454 "Beep if not in an article buffer."
6455 (unless (equal major-mode 'gnus-article-mode)
6456 (error "Command invoked outside of a Gnus article buffer")))
6458 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6459 "Read a summary buffer key sequence and execute it from the article buffer."
6461 (gnus-article-check-buffer)
6463 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6464 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6465 "=" "^" "\M-^" "|"))
6467 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6468 "An" "Ap" [?A (meta return)] [?A delete]))
6472 '("n" "Gn" "p" "Gp"))
6474 (with-current-buffer gnus-article-current-summary
6475 (let (gnus-pick-mode)
6476 (setq unread-command-events (nconc unread-command-events
6477 (list (or key last-command-event)))
6478 keys (if (featurep 'xemacs)
6479 (events-to-keys (read-key-sequence nil t))
6480 (read-key-sequence nil t)))))
6485 ((eq (aref keys (1- (length keys))) ?\C-h)
6486 (gnus-article-describe-bindings (substring keys 0 -1)))
6487 ((or (member keys nosaves)
6488 (member keys nosave-but-article)
6489 (member keys nosave-in-article))
6491 (save-window-excursion
6492 (pop-to-buffer gnus-article-current-summary)
6493 ;; We disable the pick minor mode commands.
6494 (let (gnus-pick-mode)
6495 (setq func (key-binding keys t))))
6499 (unless (member keys nosave-in-article)
6500 (set-buffer gnus-article-current-summary))
6501 (when (get func 'disabled)
6502 (error "Function %s disabled" func))
6503 (call-interactively func)
6504 (setq new-sum-point (point)))
6505 (when (member keys nosave-but-article)
6506 (pop-to-buffer gnus-article-buffer))))
6508 ;; These commands should restore window configuration.
6509 (let ((obuf (current-buffer))
6510 (owin (current-window-configuration))
6511 win func in-buffer selected new-sum-start new-sum-hscroll err)
6512 (cond (not-restore-window
6513 (pop-to-buffer gnus-article-current-summary)
6514 (setq win (selected-window)))
6515 ((setq win (get-buffer-window gnus-article-current-summary))
6516 (select-window win))
6518 (let ((summary-buffer gnus-article-current-summary))
6519 (gnus-configure-windows 'article)
6520 (unless (setq win (get-buffer-window summary-buffer 'visible))
6521 (let ((gnus-buffer-configuration
6522 '((article ((vertical 1.0
6523 (summary 0.25 point)
6525 (gnus-configure-windows 'article))
6526 (setq win (get-buffer-window summary-buffer 'visible)))
6527 (gnus-select-frame-set-input-focus (window-frame win))
6528 (select-window win))))
6529 (setq in-buffer (current-buffer))
6530 ;; We disable the pick minor mode commands.
6531 (setq func (let (gnus-pick-mode)
6532 (key-binding keys t)))
6533 (when (get func 'disabled)
6534 (error "Function %s disabled" func))
6537 (condition-case code
6539 (call-interactively func)
6545 (when (eq win (selected-window))
6546 (setq new-sum-point (point)
6547 new-sum-start (window-start win)
6548 new-sum-hscroll (window-hscroll win)))
6549 (when (or (eq in-buffer (current-buffer))
6550 (when (eq obuf (current-buffer))
6551 (set-buffer in-buffer)
6553 (setq selected (gnus-summary-select-article))
6555 (unless not-restore-window
6556 (set-window-configuration owin))
6557 (when (and (eq selected 'old)
6559 (set-window-start (get-buffer-window (current-buffer))
6561 (set-window-point (get-buffer-window (current-buffer))
6562 (if (article-goto-body)
6565 (when (and (not not-restore-window)
6568 (with-current-buffer (window-buffer win)
6569 (eq major-mode 'gnus-summary-mode)))
6570 (set-window-point win new-sum-point)
6571 (set-window-start win new-sum-start)
6572 (set-window-hscroll win new-sum-hscroll))))
6573 (set-window-configuration owin)
6575 (signal (car err) (cdr err))
6578 (defun gnus-article-read-summary-send-keys ()
6580 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6581 (gnus-article-read-summary-keys)))
6583 (defun gnus-article-describe-key (key)
6584 "Display documentation of the function invoked by KEY.
6585 KEY is a string or a vector."
6586 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6587 (read-key-sequence "Describe key: "))))
6588 (gnus-article-check-buffer)
6589 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6590 gnus-article-read-summary-send-keys))
6591 (with-current-buffer gnus-article-current-summary
6592 (setq unread-command-events
6593 (if (featurep 'xemacs)
6595 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6596 (list 'meta (- x 128))
6599 (let ((cursor-in-echo-area t)
6601 (describe-key (read-key-sequence nil t))))
6602 (describe-key key)))
6604 (defun gnus-article-describe-key-briefly (key &optional insert)
6605 "Display documentation of the function invoked by KEY.
6606 KEY is a string or a vector."
6607 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6608 (read-key-sequence "Describe key: "))
6609 current-prefix-arg))
6610 (gnus-article-check-buffer)
6611 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6612 gnus-article-read-summary-send-keys))
6613 (with-current-buffer gnus-article-current-summary
6614 (setq unread-command-events
6615 (if (featurep 'xemacs)
6617 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6618 (list 'meta (- x 128))
6621 (let ((cursor-in-echo-area t)
6623 (describe-key-briefly (read-key-sequence nil t) insert)))
6624 (describe-key-briefly key insert)))
6626 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6627 (defvar gnus-agent-summary-mode)
6628 (defvar gnus-draft-mode)
6629 ;; Calling help-buffer will autoload help-mode.
6630 (defvar help-xref-stack-item)
6631 ;; Emacs 22 doesn't load it in the batch mode.
6633 (autoload 'help-buffer "help-mode"))
6635 (defun gnus-article-describe-bindings (&optional prefix)
6636 "Show a list of all defined keys, and their definitions.
6637 The optional argument PREFIX, if non-nil, should be a key sequence;
6638 then we display only bindings that start with that prefix."
6640 (gnus-article-check-buffer)
6641 (let ((keymap (copy-keymap gnus-article-mode-map))
6642 (map (copy-keymap gnus-article-send-map))
6643 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6645 (define-key keymap "S" map)
6646 (define-key map [t] nil)
6647 (with-current-buffer gnus-article-current-summary
6650 (if (setq parent (keymap-parent gnus-article-mode-map))
6652 (setq parent (copy-keymap parent))
6653 (set-keymap-parent parent (current-local-map)))
6654 (current-local-map)))
6655 (set-keymap-parent map (key-binding "S"))
6656 (let (key def gnus-pick-mode)
6658 (setq key (pop sumkeys))
6659 (cond ((and (vectorp key) (= (length key) 1)
6660 (consp (setq def (aref key 0)))
6661 (numberp (car def)) (numberp (cdr def)))
6662 (when (< (max (car def) (cdr def)) 128)
6666 (nreverse (gnus-uncompress-range def)))
6668 ((setq def (key-binding key))
6669 (unless (eq def 'undefined)
6670 (define-key keymap key def))))))
6671 (when (boundp 'gnus-agent-summary-mode)
6672 (setq agent gnus-agent-summary-mode))
6673 (when (boundp 'gnus-draft-mode)
6674 (setq draft gnus-draft-mode)))
6676 (use-local-map keymap)
6677 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6678 (set (make-local-variable 'gnus-draft-mode) draft)
6679 (describe-bindings prefix))
6680 (let ((item `((lambda (prefix)
6681 (with-current-buffer ,(current-buffer)
6682 (gnus-article-describe-bindings prefix)))
6684 (with-current-buffer (let (help-xref-following) (help-buffer))
6685 (setq help-xref-stack-item item)))))
6687 (defun gnus-article-reply-with-original (&optional wide)
6688 "Start composing a reply mail to the current message.
6689 The text in the region will be yanked. If the region isn't active,
6690 the entire article will be yanked."
6692 (let ((article (cdr gnus-article-current))
6694 (if (not (gnus-region-active-p))
6695 (with-current-buffer gnus-summary-buffer
6696 (gnus-summary-reply (list (list article)) wide))
6697 (setq contents (buffer-substring (point) (mark t)))
6698 ;; Deactivate active regions.
6699 (when (and (boundp 'transient-mark-mode)
6700 transient-mark-mode)
6701 (setq mark-active nil))
6702 (with-current-buffer gnus-summary-buffer
6704 (list (list article contents)) wide)))))
6706 (defun gnus-article-wide-reply-with-original ()
6707 "Start composing a wide reply mail to the current message.
6708 The text in the region will be yanked. If the region isn't active,
6709 the entire article will be yanked."
6711 (gnus-article-reply-with-original t))
6713 (defun gnus-article-followup-with-original ()
6714 "Compose a followup to the current article.
6715 The text in the region will be yanked. If the region isn't active,
6716 the entire article will be yanked."
6718 (let ((article (cdr gnus-article-current))
6720 (if (not (gnus-region-active-p))
6721 (with-current-buffer gnus-summary-buffer
6722 (gnus-summary-followup (list (list article))))
6723 (setq contents (buffer-substring (point) (mark t)))
6724 ;; Deactivate active regions.
6725 (when (and (boundp 'transient-mark-mode)
6726 transient-mark-mode)
6727 (setq mark-active nil))
6728 (with-current-buffer gnus-summary-buffer
6729 (gnus-summary-followup
6730 (list (list article contents)))))))
6732 (defun gnus-article-hide (&optional arg force)
6733 "Hide all the gruft in the current article.
6734 This means that signatures, cited text and (some) headers will be
6736 If given a prefix, show the hidden text instead."
6737 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6738 (gnus-article-hide-headers arg)
6739 (gnus-article-hide-list-identifiers arg)
6740 (gnus-article-hide-citation-maybe arg force)
6741 (gnus-article-hide-signature arg))
6743 (defun gnus-article-maybe-highlight ()
6744 "Do some article highlighting if article highlighting is requested."
6745 (when (gnus-visual-p 'article-highlight 'highlight)
6746 (gnus-article-highlight-some)))
6748 (defun gnus-check-group-server ()
6749 ;; Make sure the connection to the server is alive.
6750 (unless (gnus-server-opened
6751 (gnus-find-method-for-group gnus-newsgroup-name))
6752 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6753 (gnus-request-group gnus-newsgroup-name t)))
6756 (autoload 'nneething-get-file-name "nneething"))
6758 (defun gnus-request-article-this-buffer (article group)
6759 "Get an article and insert it into this buffer."
6760 (let (do-update-line sparse-header)
6764 (gnus-kill-all-overlays)
6765 (setq group (or group gnus-newsgroup-name))
6767 ;; Using `gnus-request-article' directly will insert the article into
6768 ;; `nntp-server-buffer' - so we'll save some time by not having to
6769 ;; copy it from the server buffer into the article buffer.
6771 ;; We only request an article by message-id when we do not have the
6772 ;; headers for it, so we'll have to get those.
6773 (when (stringp article)
6774 (gnus-read-header article))
6776 ;; If the article number is negative, that means that this article
6777 ;; doesn't belong in this newsgroup (possibly), so we find its
6778 ;; message-id and request it by id instead of number.
6779 (when (and (numberp article)
6781 (get-buffer gnus-summary-buffer)
6782 (gnus-buffer-exists-p gnus-summary-buffer))
6783 (with-current-buffer gnus-summary-buffer
6784 (let ((header (gnus-summary-article-header article)))
6787 ((memq article gnus-newsgroup-sparse)
6788 ;; This is a sparse gap article.
6789 (setq do-update-line article)
6790 (setq article (mail-header-id header))
6791 (setq sparse-header (gnus-read-header article))
6792 (setq gnus-newsgroup-sparse
6793 (delq article gnus-newsgroup-sparse)))
6795 ;; It's a real article.
6796 (setq article (mail-header-id header)))
6798 ;; It is an extracted pseudo-article.
6799 (setq article 'pseudo)
6800 (gnus-request-pseudo-article header))))
6802 (let ((method (gnus-find-method-for-group
6803 gnus-newsgroup-name)))
6804 (when (and (eq (car method) 'nneething)
6806 (let ((dir (nneething-get-file-name
6807 (mail-header-id header))))
6808 (when (and (stringp dir)
6809 (file-directory-p dir))
6810 (setq article 'nneething)
6811 (gnus-group-enter-directory dir))))))))
6814 ;; Refuse to select canceled articles.
6815 ((and (numberp article)
6817 (get-buffer gnus-summary-buffer)
6818 (gnus-buffer-exists-p gnus-summary-buffer)
6819 (eq (cdr (with-current-buffer gnus-summary-buffer
6820 (assq article gnus-newsgroup-reads)))
6821 gnus-canceled-mark))
6823 ;; We first check `gnus-original-article-buffer'.
6824 ((and (get-buffer gnus-original-article-buffer)
6826 (with-current-buffer gnus-original-article-buffer
6827 (and (equal (car gnus-original-article) group)
6828 (eq (cdr gnus-original-article) article))))
6829 ;; `insert-buffer-substring' would incorrectly use the
6830 ;; equivalent of string-make-multibyte which amount to decoding
6831 ;; with locale-coding-system, causing failure of
6832 ;; subsequent decoding.
6833 (insert (mm-string-to-multibyte
6834 (with-current-buffer gnus-original-article-buffer
6835 (buffer-substring (point-min) (point-max)))))
6837 ;; Check the backlog.
6838 ((and gnus-keep-backlog
6839 (gnus-backlog-request-article group article (current-buffer)))
6841 ;; Check asynchronous pre-fetch.
6842 ((gnus-async-request-fetched-article group article (current-buffer))
6843 (gnus-async-prefetch-next group article gnus-summary-buffer)
6844 (when (and (numberp article) gnus-keep-backlog)
6845 (gnus-backlog-enter-article group article (current-buffer)))
6848 ((and gnus-use-cache
6850 (gnus-cache-request-article article group))
6852 ;; Check the agent cache.
6853 ((gnus-agent-request-article article group)
6855 ;; Get the article and put into the article buffer.
6856 ((or (stringp article)
6858 (let ((gnus-override-method gnus-override-method)
6859 (methods (and (stringp article)
6860 gnus-refer-article-method))
6861 (backend (car (gnus-find-method-for-group
6862 gnus-newsgroup-name)))
6864 (inhibit-read-only t))
6865 (if (or (not (listp methods))
6866 (and (symbolp (car methods))
6867 (assq (car methods) nnoo-definition-alist)))
6868 (setq methods (list methods)))
6869 (when (and (null gnus-override-method)
6871 (setq gnus-override-method (pop methods)))
6873 (when (eq gnus-override-method 'current)
6874 (setq gnus-override-method
6875 (with-current-buffer gnus-summary-buffer
6876 gnus-current-select-method)))
6878 (gnus-kill-all-overlays)
6879 (let ((gnus-newsgroup-name group))
6880 (gnus-check-group-server))
6882 ((gnus-request-article article group (current-buffer))
6883 (when (numberp article)
6884 (gnus-async-prefetch-next group article
6885 gnus-summary-buffer)
6886 (when gnus-keep-backlog
6887 (gnus-backlog-enter-article
6888 group article (current-buffer))))
6889 (setq result 'article))
6891 (setq gnus-override-method (pop methods)))
6892 ((not (string-match "^400 "
6893 (nnheader-get-report backend)))
6894 ;; If we get 400 server disconnect, reconnect and
6895 ;; retry; otherwise, assume the article has expired.
6896 (setq result 'done))))
6897 (and (eq result 'article) 'article)))
6901 ;; Associate this article with the current summary buffer.
6902 (setq gnus-article-current-summary gnus-summary-buffer)
6904 ;; Take the article from the original article buffer
6905 ;; and place it in the buffer it's supposed to be in.
6906 (when (and (get-buffer gnus-article-buffer)
6907 (equal (buffer-name (current-buffer))
6908 (buffer-name (get-buffer gnus-article-buffer))))
6910 (if (get-buffer gnus-original-article-buffer)
6911 (set-buffer gnus-original-article-buffer)
6912 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6913 (buffer-disable-undo)
6914 (setq major-mode 'gnus-original-article-mode)
6915 (setq buffer-read-only t))
6916 (let ((inhibit-read-only t))
6918 (insert-buffer-substring gnus-article-buffer))
6919 (setq gnus-original-article (cons group article)))
6922 (run-hooks 'gnus-article-decode-hook)
6923 ;; Mark article as decoded or not.
6924 (setq gnus-article-decoded-p gnus-article-decode-hook))
6926 ;; Update sparse articles.
6927 (when (and do-update-line
6928 (or (numberp article)
6930 (let ((buf (current-buffer)))
6931 (set-buffer gnus-summary-buffer)
6932 (gnus-summary-update-article do-update-line sparse-header)
6933 (gnus-summary-goto-subject do-update-line nil t)
6934 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6936 (set-buffer buf))))))
6938 (defun gnus-block-private-groups (group)
6939 (if (gnus-news-group-p group)
6940 ;; Block nothing in news groups.
6942 ;; Block everything anywhere else.
6945 (defun gnus-blocked-images ()
6946 (if (functionp gnus-blocked-images)
6947 (funcall gnus-blocked-images gnus-newsgroup-name)
6948 gnus-blocked-images))
6954 (defcustom gnus-article-edit-mode-hook nil
6955 "Hook run in article edit mode buffers."
6956 :group 'gnus-article-various
6959 (defvar gnus-article-edit-done-function nil)
6961 (defvar gnus-article-edit-mode-map nil)
6963 ;; Should we be using derived.el for this?
6964 (unless gnus-article-edit-mode-map
6965 (setq gnus-article-edit-mode-map (make-keymap))
6966 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6968 (gnus-define-keys gnus-article-edit-mode-map
6969 "\C-c?" describe-mode
6970 "\C-c\C-c" gnus-article-edit-done
6971 "\C-c\C-k" gnus-article-edit-exit
6972 "\C-c\C-f\C-t" message-goto-to
6973 "\C-c\C-f\C-o" message-goto-from
6974 "\C-c\C-f\C-b" message-goto-bcc
6975 ;;"\C-c\C-f\C-w" message-goto-fcc
6976 "\C-c\C-f\C-c" message-goto-cc
6977 "\C-c\C-f\C-s" message-goto-subject
6978 "\C-c\C-f\C-r" message-goto-reply-to
6979 "\C-c\C-f\C-n" message-goto-newsgroups
6980 "\C-c\C-f\C-d" message-goto-distribution
6981 "\C-c\C-f\C-f" message-goto-followup-to
6982 "\C-c\C-f\C-m" message-goto-mail-followup-to
6983 "\C-c\C-f\C-k" message-goto-keywords
6984 "\C-c\C-f\C-u" message-goto-summary
6985 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6986 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6987 "\C-c\C-b" message-goto-body
6988 "\C-c\C-i" message-goto-signature
6990 "\C-c\C-t" message-insert-to
6991 "\C-c\C-n" message-insert-newsgroups
6992 "\C-c\C-o" message-sort-headers
6993 "\C-c\C-e" message-elide-region
6994 "\C-c\C-v" message-delete-not-region
6995 "\C-c\C-z" message-kill-to-signature
6996 "\M-\r" message-newline-and-reformat
6997 "\C-c\C-a" mml-attach-file
6998 "\C-a" message-beginning-of-line
7000 "\M-;" comment-region)
7002 (gnus-define-keys (gnus-article-edit-wash-map
7003 "\C-c\C-w" gnus-article-edit-mode-map)
7004 "f" gnus-article-edit-full-stops))
7007 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7009 ["Fetch To" message-insert-to t]
7010 ["Fetch Newsgroups" message-insert-newsgroups t]
7012 ["To" message-goto-to t]
7013 ["From" message-goto-from t]
7014 ["Subject" message-goto-subject t]
7015 ["Cc" message-goto-cc t]
7016 ["Reply-To" message-goto-reply-to t]
7017 ["Summary" message-goto-summary t]
7018 ["Keywords" message-goto-keywords t]
7019 ["Newsgroups" message-goto-newsgroups t]
7020 ["Followup-To" message-goto-followup-to t]
7021 ["Mail-Followup-To" message-goto-mail-followup-to t]
7022 ["Distribution" message-goto-distribution t]
7023 ["Body" message-goto-body t]
7024 ["Signature" message-goto-signature t]))
7026 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7027 "Major mode for editing articles.
7028 This is an extended text-mode.
7030 \\{gnus-article-edit-mode-map}"
7031 (make-local-variable 'gnus-article-edit-done-function)
7032 (make-local-variable 'gnus-prev-winconf)
7033 (set (make-local-variable 'font-lock-defaults)
7034 '(message-font-lock-keywords t))
7035 (set (make-local-variable 'mail-header-separator) "")
7036 (set (make-local-variable 'gnus-article-edit-mode) t)
7037 (easy-menu-add message-mode-field-menu message-mode-map)
7039 (setq buffer-read-only nil)
7040 (buffer-enable-undo)
7043 (defun gnus-article-edit (&optional force)
7044 "Edit the current article.
7045 This will have permanent effect only in mail groups.
7046 If FORCE is non-nil, allow editing of articles even in read-only
7049 (when (and (not force)
7050 (gnus-group-read-only-p))
7051 (error "The current newsgroup does not support article editing"))
7052 (gnus-article-date-original)
7053 (gnus-article-edit-article
7055 `(lambda (no-highlight)
7057 (gnus-summary-edit-article-done
7058 ,(or (mail-header-references gnus-current-headers) "")
7059 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7061 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7062 "Start editing the contents of the current article buffer."
7063 (let ((winconf (current-window-configuration)))
7064 (set-buffer gnus-article-buffer)
7065 (let ((message-auto-save-directory
7066 ;; Don't associate the article buffer with a draft file.
7068 (gnus-article-edit-mode))
7069 (funcall start-func)
7070 (set-buffer-modified-p nil)
7071 (gnus-configure-windows 'edit-article)
7072 (setq gnus-article-edit-done-function exit-func)
7073 (setq gnus-prev-winconf winconf)
7075 (gnus-message 6 "C-c C-c to end edits"))))
7077 (defun gnus-article-edit-done (&optional arg)
7078 "Update the article edits and exit."
7080 (let ((func gnus-article-edit-done-function)
7081 (buf (current-buffer))
7082 (start (window-start))
7084 (winconf gnus-prev-winconf))
7085 (widen) ;; Widen it in case that users narrowed the buffer.
7088 ;; The cache and backlog have to be flushed somewhat.
7089 (when gnus-keep-backlog
7090 (gnus-backlog-remove-article
7091 (car gnus-article-current) (cdr gnus-article-current)))
7092 ;; Flush original article as well.
7093 (gnus-flush-original-article-buffer)
7094 (when gnus-use-cache
7095 (gnus-cache-update-article
7096 (car gnus-article-current) (cdr gnus-article-current)))
7097 ;; We remove all text props from the article buffer.
7098 (kill-all-local-variables)
7099 (set-text-properties (point-min) (point-max) nil)
7101 (set-window-configuration winconf)
7103 (set-window-start (get-buffer-window buf) start)
7104 (set-window-point (get-buffer-window buf) (point)))
7105 (gnus-summary-show-article))
7107 (defun gnus-flush-original-article-buffer ()
7108 (when (get-buffer gnus-original-article-buffer)
7109 (with-current-buffer gnus-original-article-buffer
7110 (setq gnus-original-article nil))))
7112 (defun gnus-article-edit-exit ()
7113 "Exit the article editing without updating."
7115 (when (or (not (buffer-modified-p))
7116 (yes-or-no-p "Article modified; kill anyway? "))
7117 (let ((curbuf (current-buffer))
7119 (window-start (window-start)))
7121 (if (gnus-buffer-live-p gnus-original-article-buffer)
7122 (insert-buffer-substring gnus-original-article-buffer))
7123 (let ((winconf gnus-prev-winconf))
7124 (kill-all-local-variables)
7126 (set-window-configuration winconf)
7127 ;; Tippy-toe some to make sure that point remains where it was.
7128 (save-current-buffer
7130 (set-window-start (get-buffer-window (current-buffer)) window-start)
7132 (gnus-summary-show-article)))
7134 (defun gnus-article-edit-full-stops ()
7135 "Interactively repair spacing at end of sentences."
7138 (goto-char (point-min))
7139 (search-forward-regexp "^$" nil t)
7140 (let ((case-fold-search nil))
7141 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7144 ;;; Article highlights
7147 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7149 ;;; Internal Variables:
7151 (defcustom gnus-button-url-regexp
7153 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7154 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7155 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7156 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7157 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7161 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7162 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7163 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7165 "[" chars punct "]+" "[" chars "]"
7167 (concat ;; XEmacs 21.4 doesn't support POSIX.
7168 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7169 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7171 "Regular expression that matches URLs."
7172 :group 'gnus-article-buttons
7175 (defcustom gnus-button-valid-fqdn-regexp
7176 message-valid-fqdn-regexp
7177 "Regular expression that matches a valid FQDN."
7179 :group 'gnus-article-buttons
7182 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7183 (defcustom gnus-button-valid-localpart-regexp
7184 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7185 "Regular expression that matches a localpart of mail addresses or MIDs."
7187 :group 'gnus-article-buttons
7190 (defcustom gnus-button-man-handler 'manual-entry
7191 "Function to use for displaying man pages.
7192 The function must take at least one argument with a string naming the
7195 :type '(choice (function-item :tag "Man" manual-entry)
7196 (function-item :tag "Woman" woman)
7197 (function :tag "Other"))
7198 :group 'gnus-article-buttons)
7200 (defcustom gnus-button-mid-or-mail-regexp
7201 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7202 gnus-button-valid-fqdn-regexp
7204 "Regular expression that matches a message ID or a mail address."
7206 :group 'gnus-article-buttons
7209 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7210 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7211 Strings like this can be either a message ID or a mail address. If it is one
7212 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7213 message ID or a mail address, respectively. If this variable is set to the
7214 symbol `ask', always query the user what do do. If it is a function, this
7215 function will be called with the string as its only argument. The function
7216 must return `mid', `mail', `invalid' or `ask'."
7218 :group 'gnus-article-buttons
7219 :type '(choice (function-item :tag "Heuristic function"
7220 gnus-button-mid-or-mail-heuristic)
7225 (defcustom gnus-button-mid-or-mail-heuristic-alist
7226 '((-10.0 . ".+\\$.+@")
7229 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7230 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7231 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7232 (-1.0 . "^[^a-z]+@")
7234 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7235 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7236 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7237 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7240 (-1.0 . "^[0-9][0-9]")
7242 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7243 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7244 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7245 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7247 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7248 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7251 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7253 ;; compensation for TDMA dated mail addresses:
7254 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7256 (-20.0 . "\\.fsf@") ;; Gnus
7259 (-20.0 . "^alpine\\.")
7260 (-20.0 . "_-_") ;; Subject change in thread
7262 (-20.0 . "\\.ln@") ;; leafnode
7263 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7264 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7266 ;; (5.0 . "") ;; $local_part_len <= 7
7267 (10.0 . "^[^0-9]+@")
7268 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7269 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7272 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7274 (0.5 . "^[A-Z][a-z]")
7275 (0.5 . "^[A-Z][a-z][a-z]")
7276 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7277 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7278 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7280 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7281 address. The REGEXP is processed with `case-fold-search' set to nil."
7283 :group 'gnus-article-buttons
7284 :type '(repeat (cons (number :tag "Rate")
7285 (regexp :tag "Regexp"))))
7287 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7288 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7289 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7290 address, `ask' if unsure and `invalid' if the string is invalid."
7291 (let ((case-fold-search nil)
7292 (list gnus-button-mid-or-mail-heuristic-alist)
7293 (result 0) rate regexp lpartlen elem)
7295 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7296 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7297 ;; Certain special cases...
7300 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7301 "^[0-9]+\\.[0-9]+@compuserve\\|"
7302 "@public\\.gmane\\.org")
7304 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7305 (setq result 'mail))
7306 (when (string-match "@.*@\\| " mid-or-mail)
7307 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7308 (setq result 'invalid))
7309 ;; Nothing more to do, if result is not a number here...
7310 (when (numberp result)
7312 (setq elem (car list)
7316 (when (string-match regexp mid-or-mail)
7317 (setq result (+ result rate))
7319 9 "`%s' matched `%s', rate `%s', result `%s'."
7320 mid-or-mail regexp rate result)))
7321 (when (<= lpartlen 7)
7322 (setq result (+ result 5.0))
7323 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7324 mid-or-mail result))
7325 (when (>= lpartlen 12)
7326 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7328 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7329 ;; Long local part should contain realname if e-mail address,
7330 ;; too many digits: message-id.
7331 ;; $score -= 5.0 + 0.1 * $local_part_len;
7332 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7333 (setq result (+ result rate))
7335 9 "Many digits in `%s', rate `%s', result `%s'."
7336 mid-or-mail rate result))
7337 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7339 ;; Too few vowels [^aeiouy]{4,}.*\@
7340 (setq result (+ result -5.0))
7342 9 "Few vowels in `%s', rate `%s', result `%s'."
7343 mid-or-mail -5.0 result))
7345 (setq result (+ result 5.0))
7347 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7348 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7349 ;; Maybe we should make this a customizable alist: (condition . 'result)
7351 ((symbolp result) result)
7352 ;; Now convert number into proper results:
7353 ((< result -10.0) 'mid)
7354 ((> result 10.0) 'mail)
7357 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7358 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7359 (url-mid (concat "news" ":" mid-or-mail))
7360 (url-mailto (concat "mailto" ":" mid-or-mail)))
7361 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7362 (when (fboundp pref)
7364 ;; get rid of surrounding angles...
7366 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7367 (if (or (eq 'mid guessed) (eq 'mail guessed))
7371 (save-window-excursion
7372 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7375 (cond ((eq pref 'mid)
7376 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7377 (gnus-button-handle-news url-mid))
7379 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7380 (gnus-url-mailto url-mailto))
7381 (t (gnus-message 3 "Invalid string.")))))
7383 (defun gnus-button-handle-custom (fun arg)
7384 "Call function FUN on argument ARG.
7385 Both FUN and ARG are supposed to be strings. ARG will be passed
7386 as a symbol to FUN."
7387 (funcall (intern fun)
7388 (if (string-match "^customize-apropos" fun)
7392 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7394 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7397 (defun gnus-button-handle-describe-function (url)
7398 "Call `describe-function' when pushing the corresponding URL button."
7401 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7403 (defun gnus-button-handle-describe-variable (url)
7404 "Call `describe-variable' when pushing the corresponding URL button."
7407 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7409 (defun gnus-button-handle-symbol (url)
7410 "Display help on variable or function.
7411 Calls `describe-variable' or `describe-function'."
7412 (let ((sym (intern url)))
7414 ((fboundp sym) (describe-function sym))
7415 ((boundp sym) (describe-variable sym))
7416 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7418 (defun gnus-button-handle-describe-key (url)
7419 "Call `describe-key' when pushing the corresponding URL button."
7421 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7422 (keys (ignore-errors (eval `(kbd ,key-string)))))
7425 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7427 (defun gnus-button-handle-apropos (url)
7428 "Call `apropos' when pushing the corresponding URL button."
7429 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7431 (defun gnus-button-handle-apropos-command (url)
7432 "Call `apropos' when pushing the corresponding URL button."
7434 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7436 (defun gnus-button-handle-apropos-variable (url)
7437 "Call `apropos' when pushing the corresponding URL button."
7439 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7440 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7442 (defun gnus-button-handle-apropos-documentation (url)
7443 "Call `apropos' when pushing the corresponding URL button."
7445 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7446 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7448 (defun gnus-button-handle-library (url)
7449 "Call `locate-library' when pushing the corresponding URL button."
7450 (gnus-message 9 "url=`%s'" url)
7451 (let* ((lib (locate-library url))
7452 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7454 (gnus-message 1 "Cannot locale library `%s'." url)
7455 (find-file-read-only file))))
7457 (defcustom gnus-button-man-level 5
7458 "*Integer that says how many man-related buttons Gnus will show.
7459 The higher the number, the more buttons will appear and the more false
7460 positives are possible. Note that you can set this variable local to
7461 specific groups. Setting it higher in Unix groups is probably a good idea.
7462 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7463 how to set variables in specific groups."
7465 :group 'gnus-article-buttons
7466 :link '(custom-manual "(gnus)Group Parameters")
7469 (defcustom gnus-button-emacs-level 5
7470 "*Integer that says how many emacs-related buttons Gnus will show.
7471 The higher the number, the more buttons will appear and the more false
7472 positives are possible. Note that you can set this variable local to
7473 specific groups. Setting it higher in Emacs or Gnus related groups is
7474 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7475 `gnus-parameters' on how to set variables in specific groups."
7477 :group 'gnus-article-buttons
7478 :link '(custom-manual "(gnus)Group Parameters")
7481 (defcustom gnus-button-message-level 5
7482 "*Integer that says how many buttons for news or mail messages will appear.
7483 The higher the number, the more buttons will appear and the more false
7484 positives are possible."
7485 ;; mail addresses, MIDs, URLs for news, ...
7487 :group 'gnus-article-buttons
7490 (defcustom gnus-button-browse-level 5
7491 "*Integer that says how many buttons for browsing will appear.
7492 The higher the number, the more buttons will appear and the more false
7493 positives are possible."
7494 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7496 :group 'gnus-article-buttons
7499 (defcustom gnus-button-alist
7500 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7501 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7502 ((concat "\\b\\(nntp\\|news\\):\\("
7503 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7504 0 t gnus-button-handle-news 2)
7505 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7506 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7507 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7508 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7509 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7510 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7511 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7512 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7513 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7514 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7515 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7516 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7517 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7518 ;; RFC 2368 (The mailto URL scheme)
7519 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7520 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7521 ("\\bmailto:\\([^ \n\t]+\\)"
7522 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7523 ;; Info Konqueror style <info:/foo/bar baz>.
7524 ;; Must come before " Gnus home-grown style".
7525 ("\\binfo://?\\([^'\">\n\t]+\\)"
7526 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7527 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7528 ("\\binfo://\\([^'\">\n\t ]+\\)"
7529 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7530 ;; Info GNOME style <info:foo#bar_baz>
7531 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7532 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7533 ;; Info KDE style <info:(foo)bar baz>
7534 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7535 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7536 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7537 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7538 ("\\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,]*\\)\\)?"
7539 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7540 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7542 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7543 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7544 ;; Emacs help commands
7545 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7546 ;; regexp doesn't match arguments containing ` '.
7547 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7548 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7549 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7550 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7551 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7552 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7553 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7554 ;; The following entries may lead to many false positives so don't enable
7555 ;; them by default (use a high button level).
7556 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7557 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7558 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7559 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7560 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7561 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7562 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7563 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7564 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7565 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7566 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7567 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7568 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7569 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7570 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7571 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7572 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7573 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7574 ;; Unlike the other regexps we really have to require quoting
7575 ;; here to determine where it ends.
7576 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7577 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7578 ("<URL: *\\([^\n<>]*\\)>"
7579 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7580 ;; RFC 2396 (2.4.3., delims) ...
7581 ("\"URL: *\\([^\n\"]*\\)\""
7582 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7584 (gnus-button-url-regexp
7585 0 (>= gnus-button-browse-level 0) browse-url 0)
7587 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7588 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7589 gnus-button-handle-man 1)
7590 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7591 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7592 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7593 gnus-button-handle-man 1)
7594 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7595 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7596 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7597 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7598 ;; Recognizing patches to .el files. This is somewhat obscure,
7599 ;; but considering the percentage of Gnus users who hack Emacs
7601 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7602 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7603 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7604 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7605 ;; MID or mail: To avoid too many false positives we don't try to catch
7606 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7607 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7608 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7609 ;; so that non-ambiguous entries (see above) match first.
7610 (gnus-button-mid-or-mail-regexp
7611 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7612 "*Alist of regexps matching buttons in article bodies.
7614 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7615 REGEXP: is the string (case insensitive) matching text around the button (can
7616 also be Lisp expression evaluating to a string),
7617 BUTTON: is the number of the regexp grouping actually matching the button,
7618 FORM: is a Lisp expression which must eval to true for the button to
7620 CALLBACK: is the function to call when the user push this button, and each
7621 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7623 CALLBACK can also be a variable, in that case the value of that
7624 variable it the real callback function."
7625 :group 'gnus-article-buttons
7626 :type '(repeat (list (choice regexp variable sexp)
7627 (integer :tag "Button")
7629 (function :tag "Callback")
7632 (integer :tag "Regexp group")))))
7633 (put 'gnus-button-alist 'risky-local-variable t)
7635 (defcustom gnus-header-button-alist
7636 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7637 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7638 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7639 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7640 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7641 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7642 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7643 0 (>= gnus-button-browse-level 0) browse-url 0)
7644 ("^Subject:" gnus-button-url-regexp
7645 0 (>= gnus-button-browse-level 0) browse-url 0)
7646 ("^[^:]+:" gnus-button-url-regexp
7647 0 (>= gnus-button-browse-level 0) browse-url 0)
7648 ("^OpenPGP:.*url=" gnus-button-url-regexp
7649 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7650 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7651 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7652 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7653 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7654 "*Alist of headers and regexps to match buttons in article heads.
7656 This alist is very similar to `gnus-button-alist', except that each
7657 alist has an additional HEADER element first in each entry:
7659 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7661 HEADER is a regexp to match a header. For a fuller explanation, see
7662 `gnus-button-alist'."
7663 :group 'gnus-article-buttons
7664 :group 'gnus-article-headers
7665 :type '(repeat (list (regexp :tag "Header")
7666 (choice regexp variable)
7667 (integer :tag "Button")
7669 (function :tag "Callback")
7672 (integer :tag "Regexp group")))))
7673 (put 'gnus-header-button-alist 'risky-local-variable t)
7677 (defun gnus-article-push-button (event)
7678 "Check text under the mouse pointer for a callback function.
7679 If the text under the mouse pointer has a `gnus-callback' property,
7680 call it with the value of the `gnus-data' text property."
7682 (set-buffer (window-buffer (posn-window (event-start event))))
7683 (let* ((pos (posn-point (event-start event)))
7684 (data (get-text-property pos 'gnus-data))
7685 (fun (get-text-property pos 'gnus-callback)))
7688 (funcall fun data))))
7690 (defun gnus-article-press-button ()
7691 "Check text at point for a callback function.
7692 If the text at point has a `gnus-callback' property,
7693 call it with the value of the `gnus-data' text property."
7695 (let ((data (get-text-property (point) 'gnus-data))
7696 (fun (get-text-property (point) 'gnus-callback)))
7698 (funcall fun data))))
7700 (defun gnus-article-highlight (&optional force)
7701 "Highlight current article.
7702 This function calls `gnus-article-highlight-headers',
7703 `gnus-article-highlight-citation',
7704 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7705 do the highlighting. See the documentation for those functions."
7706 (interactive (list 'force))
7707 (gnus-article-highlight-headers)
7708 (gnus-article-highlight-citation force)
7709 (gnus-article-highlight-signature)
7710 (gnus-article-add-buttons)
7711 (gnus-article-add-buttons-to-head))
7713 (defun gnus-article-highlight-some (&optional force)
7714 "Highlight current article.
7715 This function calls `gnus-article-highlight-headers',
7716 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7717 do the highlighting. See the documentation for those functions."
7718 (interactive (list 'force))
7719 (gnus-article-highlight-headers)
7720 (gnus-article-highlight-signature)
7721 (gnus-article-add-buttons))
7723 (defun gnus-article-highlight-headers ()
7724 "Highlight article headers as specified by `gnus-header-face-alist'."
7726 (gnus-with-article-headers
7727 (let (regexp header-face field-face from hpoints fpoints)
7728 (dolist (entry gnus-header-face-alist)
7729 (goto-char (point-min))
7730 (setq regexp (concat "^\\("
7731 (if (string-equal "" (nth 0 entry))
7735 header-face (nth 1 entry)
7736 field-face (nth 2 entry))
7737 (while (and (re-search-forward regexp nil t)
7741 (unless (search-forward ":" nil t)
7743 (when (and header-face
7744 (not (memq (point) hpoints)))
7745 (push (point) hpoints)
7746 (gnus-put-text-property from (point) 'face header-face))
7747 (when (and field-face
7748 (not (memq (setq from (point)) fpoints)))
7750 (if (re-search-forward "^[^ \t]" nil t)
7752 (goto-char (point-max)))
7753 (gnus-put-text-property from (point) 'face field-face)))))))
7755 (defun gnus-article-highlight-signature ()
7756 "Highlight the signature in an article.
7757 It does this by highlighting everything after
7758 `gnus-signature-separator' using the face `gnus-signature'."
7760 (gnus-with-article-buffer
7761 (let ((inhibit-point-motion-hooks t))
7763 (when (and gnus-signature-face
7764 (gnus-article-narrow-to-signature))
7765 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7766 'face gnus-signature-face)
7768 (gnus-article-search-signature)
7769 (let ((start (match-beginning 0))
7770 (end (set-marker (make-marker) (1+ (match-end 0)))))
7771 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7774 (defun gnus-button-in-region-p (b e prop)
7775 "Say whether PROP exists in the region."
7776 (text-property-not-all b e prop nil))
7778 (defun gnus-article-add-buttons ()
7779 "Find external references in the article and make buttons of them.
7780 \"External references\" are things like Message-IDs and URLs, as
7781 specified by `gnus-button-alist'."
7783 (gnus-with-article-buffer
7784 (let ((inhibit-point-motion-hooks t)
7785 (case-fold-search t)
7786 (alist gnus-button-alist)
7788 ;; We skip the headers.
7791 (while (setq entry (pop alist))
7792 (setq regexp (eval (car entry)))
7794 (while (re-search-forward regexp nil t)
7795 (let ((start (match-beginning (nth 1 entry)))
7796 (end (match-end (nth 1 entry)))
7797 (from (match-beginning 0)))
7798 (when (and (eval (nth 2 entry))
7799 (not (gnus-button-in-region-p
7800 start end 'gnus-callback)))
7801 ;; That optional form returned non-nil, so we add the
7803 (setq from (set-marker (make-marker) from))
7804 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7805 (gnus-article-extend-url-button from start end))
7806 (gnus-article-add-button start end
7807 'gnus-button-push (list from entry))
7808 (gnus-put-text-property
7810 'gnus-string (buffer-substring-no-properties
7813 (defun gnus-article-extend-url-button (beg start end)
7814 "Extend url button if url is folded into two or more lines.
7815 Return non-nil if button is extended. BEG is a marker that points to
7816 the beginning position of a text containing url. START and END are
7817 the endpoints of a url button before it is extended. The concatenated
7818 url is put as the `gnus-button-url' overlay property on the button."
7819 (let ((opoint (point))
7820 (points (list start end))
7825 (not (looking-at "[\t ]*[\">]")))
7829 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7830 (buffer-substring (point-at-bol) start)))
7832 (setq url (list (buffer-substring start end))
7833 delim (if (match-beginning 1) ">" "\""))
7835 (setq regexp (concat
7836 (when (and (looking-at
7837 message-cite-prefix-regexp)
7838 (< (match-end 0) start))
7839 (regexp-quote (match-string 0)))
7841 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7845 (and (looking-at regexp)
7848 (push (or (match-string 2)
7851 (push (setq end (or (match-end 2)
7854 (push (or (match-beginning 2)
7855 (match-beginning 1))
7857 (match-beginning 2)))
7858 (let (gnus-article-mouse-face widget-mouse-face)
7860 (gnus-article-add-button (pop points) (pop points)
7861 'gnus-button-push beg)))
7862 (let ((overlay (gnus-make-overlay start end)))
7863 (gnus-overlay-put overlay 'evaporate t)
7864 (gnus-overlay-put overlay 'gnus-button-url
7865 (list (mapconcat 'identity (nreverse url) "")))
7866 (when gnus-article-mouse-face
7867 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7869 (goto-char opoint))))
7871 ;; Add buttons to the head of an article.
7872 (defun gnus-article-add-buttons-to-head ()
7873 "Add buttons to the head of the article."
7875 (gnus-with-article-headers
7877 (dolist (entry gnus-header-button-alist)
7878 ;; Each alist entry.
7879 (goto-char (point-min))
7880 (while (re-search-forward (car entry) nil t)
7881 ;; Each header matching the entry.
7882 (setq beg (match-beginning 0))
7883 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7884 (match-beginning 0))
7887 (while (re-search-forward (eval (nth 1 entry)) end t)
7888 ;; Each match within a header.
7889 (let* ((entry (cdr entry))
7890 (start (match-beginning (nth 1 entry)))
7891 (end (match-end (nth 1 entry)))
7892 (form (nth 2 entry)))
7893 (goto-char (match-end 0))
7895 (gnus-article-add-button
7896 start end (nth 3 entry)
7897 (buffer-substring (match-beginning (nth 4 entry))
7898 (match-end (nth 4 entry)))))))
7899 (goto-char end))))))
7901 ;;; External functions:
7903 (defun gnus-article-add-button (from to fun &optional data text)
7904 "Create a button between FROM and TO with callback FUN and data DATA."
7905 (when gnus-article-button-face
7906 (gnus-overlay-put (gnus-make-overlay from to nil t)
7907 'face gnus-article-button-face))
7908 (gnus-add-text-properties
7910 (nconc (and gnus-article-mouse-face
7911 (list gnus-mouse-face-prop gnus-article-mouse-face))
7912 (list 'gnus-callback fun)
7913 (and data (list 'gnus-data data))))
7914 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7915 :help-echo (or text "Follow the link")
7916 :keymap gnus-url-button-map
7917 :button-keymap gnus-widget-button-keymap))
7919 (defun gnus-article-copy-string ()
7920 "Copy the string in the button to the kill ring."
7922 (gnus-article-check-buffer)
7923 (let ((data (get-text-property (point) 'gnus-string)))
7927 (copy-region-as-kill (point-min) (point-max))
7928 (message "Copied %s" data)))))
7930 ;;; Internal functions:
7932 (defun gnus-article-set-globals ()
7933 (with-current-buffer gnus-summary-buffer
7934 (gnus-set-global-variables)))
7936 (defun gnus-signature-toggle (end)
7937 (gnus-with-article-buffer
7938 (let ((inhibit-point-motion-hooks t))
7939 (if (text-property-any end (point-max) 'article-type 'signature)
7941 (gnus-delete-wash-type 'signature)
7942 (gnus-remove-text-properties-when
7943 'article-type 'signature end (point-max)
7944 (cons 'article-type (cons 'signature
7945 gnus-hidden-properties))))
7946 (gnus-add-wash-type 'signature)
7947 (gnus-add-text-properties-when
7948 'article-type nil end (point-max)
7949 (cons 'article-type (cons 'signature
7950 gnus-hidden-properties)))))
7951 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7952 (gnus-set-mode-line 'article))))
7954 (defun gnus-button-push (marker-and-entry)
7955 ;; Push button starting at MARKER.
7957 (let* ((marker (car marker-and-entry))
7958 (entry (cadr marker-and-entry))
7959 (regexp (car entry))
7960 (inhibit-point-motion-hooks t))
7962 ;; This is obviously true, or something bad is happening :)
7963 ;; But we need it to have the match-data
7964 (when (looking-at (or (if (symbolp regexp)
7965 (symbol-value regexp)
7967 (let ((fun (nth 3 entry))
7968 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7969 (get-char-property marker 'gnus-button-url))
7970 (mapcar (lambda (group)
7971 (let ((string (match-string group)))
7972 (set-text-properties
7973 0 (length string) nil string)
7975 (nthcdr 4 entry)))))
7981 (fboundp (symbol-value fun)))
7982 (apply (symbol-value fun) args))
7984 (gnus-message 1 "You must define `%S' to use this button"
7985 (cons fun args)))))))))
7987 (defun gnus-parse-news-url (url)
7988 (let (scheme server port group message-id articles)
7991 (goto-char (point-min))
7992 (when (looking-at "\\([A-Za-z]+\\):")
7993 (setq scheme (match-string 1))
7994 (goto-char (match-end 0)))
7995 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7996 (setq server (match-string 1))
7997 (setq port (if (stringp (match-string 3))
7998 (string-to-number (match-string 3))
8000 (goto-char (match-end 0)))
8003 ((looking-at "\\(.*@.*\\)")
8004 (setq message-id (match-string 1)))
8005 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8006 (setq group (match-string 1)
8007 articles (split-string (match-string 2) "-")))
8008 ((looking-at "\\([^/]+\\)/?")
8009 (setq group (match-string 1)))
8011 (error "Unknown news URL syntax"))))
8012 (list scheme server port group message-id articles)))
8014 (defun gnus-button-handle-news (url)
8016 (destructuring-bind (scheme server port group message-id articles)
8017 (gnus-parse-news-url url)
8020 (with-current-buffer gnus-summary-buffer
8022 (let ((gnus-refer-article-method
8023 (nconc (list (list 'nntp server))
8024 gnus-refer-article-method))
8025 (nntp-port-number (or port "nntp")))
8026 (gnus-message 7 "Fetching %s with %s"
8027 message-id gnus-refer-article-method)
8028 (gnus-summary-refer-article message-id))
8029 (gnus-summary-refer-article message-id))))
8031 (gnus-button-fetch-group url)))))
8033 (defun gnus-button-patch (library line)
8034 "Visit an Emacs Lisp library LIBRARY on line LINE."
8036 (let ((file (locate-library (file-name-nondirectory library))))
8038 (error "Couldn't find library %s" library))
8040 (goto-char (point-min))
8041 (forward-line (1- (string-to-number line)))))
8043 (defun gnus-button-handle-man (url)
8045 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8046 (when (eq gnus-button-man-handler 'woman)
8047 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8048 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8049 (funcall gnus-button-man-handler url))
8051 (defun gnus-button-handle-info-url (url)
8052 "Fetch an info URL."
8053 (setq url (mm-subst-char-in-string ?+ ?\ url))
8055 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8056 (gnus-info-find-node
8057 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8059 ")" (gnus-url-unhex-string (match-string 2 url)))))
8060 ((string-match "([^)\"]+)[^\"]+" url)
8062 (gnus-replace-in-string
8063 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8064 (gnus-info-find-node url))
8065 (t (error "Can't parse %s" url))))
8067 (defun gnus-button-handle-info-url-gnome (url)
8068 "Fetch GNOME style info URL."
8069 (setq url (mm-subst-char-in-string ?_ ?\ url))
8070 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8071 (gnus-info-find-node
8073 (gnus-url-unhex-string
8074 (match-string 1 url))
8076 (or (gnus-url-unhex-string
8077 (match-string 2 url))
8079 (error "Can't parse %s" url)))
8081 (defun gnus-button-handle-info-url-kde (url)
8082 "Fetch KDE style info URL."
8083 (gnus-info-find-node (gnus-url-unhex-string url)))
8085 ;; (info) will autoload info.el
8086 (declare-function Info-menu "info" (menu-item &optional fork))
8087 (declare-function Info-index-next "info" (num))
8089 (defun gnus-button-handle-info-keystrokes (url)
8090 "Call `info' when pushing the corresponding URL button."
8091 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8092 (let (node indx comma)
8094 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8095 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8096 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8097 "\\(?:[ \t\n,]*\\)\\)?")
8099 (setq node (match-string 2 url)
8100 indx (match-string 3 url))
8101 (error "Can't parse %s" url))
8105 (when (> (length indx) 0)
8106 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8109 (setq comma (match-string 2 indx))
8110 (setq indx (match-string 1 indx))
8113 (dotimes (i (with-temp-buffer
8115 ;; Note: the XEmacs version of `how-many' takes
8116 ;; no optional argument.
8117 (goto-char (point-min))
8119 (Info-index-next 1)))
8122 (autoload 'pgg-snarf-keys-region "pgg")
8123 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8124 (declare-function pgg-display-output-buffer "pgg" (start end status))
8126 (defun gnus-button-openpgp (url)
8127 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8129 (mm-url-insert-file-contents-external url)
8130 (pgg-snarf-keys-region (point-min) (point-max))
8131 (pgg-display-output-buffer nil nil nil)))
8133 (defun gnus-button-message-id (message-id)
8135 (with-current-buffer gnus-summary-buffer
8136 (gnus-summary-refer-article message-id)))
8138 (defun gnus-button-fetch-group (address &rest ignore)
8139 "Fetch GROUP specified by ADDRESS."
8140 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8142 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8143 ;; for nntp:// and news://
8144 (setq address (match-string 3 address)))
8145 (if (not (string-match "[:/]" address))
8146 ;; This is just a simple group url.
8147 (gnus-group-read-ephemeral-group address gnus-select-method)
8150 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8152 (error "Can't parse %s" address)
8153 (gnus-group-read-ephemeral-group
8154 (match-string 4 address)
8155 `(nntp ,(match-string 1 address)
8156 (nntp-address ,(match-string 1 address))
8157 (nntp-port-number ,(if (match-end 3)
8158 (match-string 3 address)
8161 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8163 (defun gnus-url-parse-query-string (query &optional downcase)
8164 (let (retval pairs cur key val)
8165 (setq pairs (split-string query "&"))
8167 (setq cur (car pairs)
8169 (if (not (string-match "=" cur))
8171 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8172 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8174 (setq key (downcase key)))
8175 (setq cur (assoc key retval))
8177 (setcdr cur (cons val (cdr cur)))
8178 (setq retval (cons (list key val) retval)))))
8181 (defun gnus-url-mailto (url)
8182 ;; Send mail to someone
8183 (setq url (replace-regexp-in-string "\n" " " url))
8184 (when (string-match "mailto:/*\\(.*\\)" url)
8185 (setq url (substring url (match-beginning 1) nil)))
8186 (let (to args subject func)
8187 (setq args (gnus-url-parse-query-string
8188 (if (string-match "^\\?" url)
8190 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8191 (concat "to=" (match-string 1 url) "&"
8192 (match-string 2 url))
8193 (concat "to=" url))))
8194 subject (cdr-safe (assoc "subject" args)))
8197 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8200 (message-position-on-field (caar args)))
8201 (insert (gnus-replace-in-string
8202 (mapconcat 'identity (reverse (cdar args)) ", ")
8204 (setq args (cdr args)))
8207 (message-goto-subject))))
8209 (defun gnus-button-embedded-url (address)
8210 "Activate ADDRESS with `browse-url'."
8211 (browse-url (gnus-strip-whitespace address)))
8213 ;;; Next/prev buttons in the article buffer.
8215 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8216 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8218 (defvar gnus-prev-page-map
8219 (let ((map (make-sparse-keymap)))
8220 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8221 (define-key map "\r" 'gnus-button-prev-page)
8224 (defvar gnus-next-page-map
8225 (let ((map (make-sparse-keymap)))
8226 (define-key map gnus-mouse-2 'gnus-button-next-page)
8227 (define-key map "\r" 'gnus-button-next-page)
8230 (defun gnus-insert-prev-page-button ()
8232 (inhibit-read-only t))
8234 gnus-prev-page-line-format nil
8235 `(keymap ,gnus-prev-page-map
8237 gnus-callback gnus-article-button-prev-page
8238 article-type annotation))
8240 ;; Exclude a newline.
8243 (when gnus-article-button-face
8244 (gnus-overlay-put (gnus-make-overlay b e nil t)
8245 'face gnus-article-button-face))
8246 (widget-convert-button
8248 :action 'gnus-button-prev-page
8249 :button-keymap gnus-prev-page-map)))
8251 (defun gnus-button-next-page (&optional args more-args)
8252 "Go to the next page."
8254 (let ((win (selected-window)))
8255 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8256 (gnus-article-next-page)
8257 (select-window win)))
8259 (defun gnus-button-prev-page (&optional args more-args)
8260 "Go to the prev page."
8262 (let ((win (selected-window)))
8263 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8264 (gnus-article-prev-page)
8265 (select-window win)))
8267 (defun gnus-insert-next-page-button ()
8269 (inhibit-read-only t))
8270 (gnus-eval-format gnus-next-page-line-format nil
8271 `(keymap ,gnus-next-page-map
8273 gnus-callback gnus-article-button-next-page
8274 article-type annotation))
8276 ;; Exclude a newline.
8279 (when gnus-article-button-face
8280 (gnus-overlay-put (gnus-make-overlay b e nil t)
8281 'face gnus-article-button-face))
8282 (widget-convert-button
8284 :action 'gnus-button-next-page
8285 :button-keymap gnus-next-page-map)))
8287 (defun gnus-article-button-next-page (arg)
8288 "Go to the next page."
8290 (let ((win (selected-window)))
8291 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8292 (gnus-article-next-page)
8293 (select-window win)))
8295 (defun gnus-article-button-prev-page (arg)
8296 "Go to the prev page."
8298 (let ((win (selected-window)))
8299 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8300 (gnus-article-prev-page)
8301 (select-window win)))
8303 (defvar gnus-decode-header-methods
8304 '(mail-decode-encoded-word-region)
8305 "List of methods used to decode headers.
8307 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8308 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8309 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8310 whose names match REGEXP.
8313 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8314 mail-decode-encoded-word-region
8315 (\"chinese\" . rfc1843-decode-region))
8318 (defvar gnus-decode-header-methods-cache nil)
8320 (defun gnus-multi-decode-header (start end)
8321 "Apply the functions from `gnus-encoded-word-methods' that match."
8322 (unless (and gnus-decode-header-methods-cache
8323 (eq gnus-newsgroup-name
8324 (car gnus-decode-header-methods-cache)))
8325 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8326 (dolist (x gnus-decode-header-methods)
8328 (nconc gnus-decode-header-methods-cache (list x))
8329 (if (and gnus-newsgroup-name
8330 (string-match (car x) gnus-newsgroup-name))
8331 (nconc gnus-decode-header-methods-cache
8333 (let ((xlist gnus-decode-header-methods-cache))
8336 (narrow-to-region start end)
8338 (funcall (pop xlist) (point-min) (point-max))))))
8341 ;;; Treatment top-level handling.
8344 (defvar gnus-inhibit-article-treatments nil)
8346 (defun gnus-treat-article (gnus-treat-condition
8347 &optional part-number total-parts gnus-treat-type)
8348 (let ((gnus-treat-length (- (point-max) (point-min)))
8349 (alist gnus-treatment-function-alist)
8350 (article-goto-body-goes-to-point-min-p t)
8352 (or (not gnus-treat-type)
8354 (let ((list gnus-article-treat-types))
8356 (when (string-match (pop list) gnus-treat-type)
8357 (throw 'found t)))))))
8358 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8360 (gnus-run-hooks 'gnus-part-display-hook)
8361 (dolist (elem alist)
8364 (when (gnus-buffer-live-p gnus-summary-buffer)
8365 (set-buffer gnus-summary-buffer))
8366 (symbol-value (car elem))))
8367 (when (and (or (consp val)
8369 (or (not gnus-inhibit-article-treatments)
8370 (eq gnus-treat-condition 'head))
8371 (gnus-treat-predicate val)
8372 (or (not (get (car elem) 'highlight))
8375 (funcall (cadr elem)))))))
8377 ;; Dynamic variables.
8378 (defvar part-number)
8379 (defvar total-parts)
8380 (defvar gnus-treat-type)
8381 (defvar gnus-treat-condition)
8382 (defvar gnus-treat-length)
8384 (defun gnus-treat-predicate (val)
8388 (gnus-treat-condition
8389 (eq gnus-treat-condition val))
8391 (stringp (car val)))
8392 (apply 'gnus-or (mapcar `(lambda (s)
8393 (string-match s ,(or gnus-newsgroup-name "")))
8396 (let ((pred (pop val)))
8399 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8401 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8403 (not (gnus-treat-predicate (car val))))
8405 (equal (car val) gnus-treat-type))
8407 (error "%S is not a valid predicate" pred)))))
8415 (eq part-number total-parts))
8417 (< gnus-treat-length val))
8419 (error "%S is not a valid value" val))))
8421 (defun gnus-article-encrypt-body (protocol &optional n)
8422 "Encrypt the article body."
8425 (or gnus-article-encrypt-protocol
8426 (gnus-completing-read "Encrypt protocol"
8427 (mapcar 'car gnus-article-encrypt-protocol-alist)
8429 current-prefix-arg))
8430 ;; User might hit `K E' instead of `K e', so prompt once.
8431 (when (and gnus-article-encrypt-protocol
8433 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8434 (error "Encrypt aborted")))
8435 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8437 (error "Can't find the encrypt protocol %s" protocol))
8438 (if (member gnus-newsgroup-name '("nndraft:delayed"
8441 (error "Can't encrypt the article in group %s"
8442 gnus-newsgroup-name))
8443 (gnus-summary-iterate n
8444 (with-current-buffer gnus-summary-buffer
8445 (let ((mail-parse-charset gnus-newsgroup-charset)
8446 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8447 (summary-buffer gnus-summary-buffer)
8449 (gnus-set-global-variables)
8450 (when (gnus-group-read-only-p)
8451 (error "The current newsgroup does not support article encrypt"))
8452 (gnus-summary-show-article t)
8454 (or (mail-header-references gnus-current-headers) ""))
8455 (set-buffer gnus-article-buffer)
8456 (let* ((inhibit-read-only t)
8458 (mapcar (lambda (field)
8459 (and (save-restriction
8460 (message-narrow-to-head)
8461 (goto-char (point-min))
8462 (search-forward field nil t))
8464 (message-narrow-to-field)
8466 (delete-region (point-min) (point-max))
8468 '("Content-Type:" "Content-Transfer-Encoding:"
8469 "Content-Disposition:"))))
8470 (message-narrow-to-head)
8471 (message-remove-header "MIME-Version")
8472 (goto-char (point-max))
8473 (setq point (point))
8474 (insert (apply 'concat headers))
8476 (narrow-to-region point (point-max))
8477 (let ((message-options message-options))
8478 (message-options-set 'message-sender user-mail-address)
8479 (message-options-set 'message-recipients user-mail-address)
8480 (message-options-set 'message-sign-encrypt 'not)
8482 (goto-char (point-min))
8483 (insert "MIME-Version: 1.0\n")
8485 (gnus-summary-edit-article-done
8486 references nil summary-buffer t))
8487 (when gnus-keep-backlog
8488 (gnus-backlog-remove-article
8489 (car gnus-article-current) (cdr gnus-article-current)))
8490 (gnus-flush-original-article-buffer)
8491 (when gnus-use-cache
8492 (gnus-cache-update-article
8493 (car gnus-article-current) (cdr gnus-article-current))))))))
8495 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8496 "The following specs can be used:
8497 %t The security MIME type
8500 %D Details if button is pressed")
8502 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8503 "The following specs can be used:
8504 %t The security MIME type
8507 %D Details if button is pressed")
8509 (defvar gnus-mime-security-button-line-format-alist
8510 '((?t gnus-tmp-type ?s)
8511 (?i gnus-tmp-info ?s)
8512 (?d gnus-tmp-details ?s)
8513 (?D gnus-tmp-pressed-details ?s)))
8515 (defvar gnus-mime-security-button-commands
8516 '((gnus-article-press-button "\r" "Show Detail")
8520 (gnus-mime-security-save-part "o" "Save...")
8529 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8532 (defvar gnus-mime-security-button-map
8533 (let ((map (make-sparse-keymap)))
8534 (define-key map gnus-mouse-2 'gnus-article-push-button)
8535 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8536 (dolist (c gnus-mime-security-button-commands)
8537 (define-key map (cadr c) (car c)))
8541 gnus-mime-security-button-menu gnus-mime-security-button-map
8542 "Security button menu."
8546 (unless (eq (car c) 'undefined)
8547 (vector (caddr c) (car c) :active t)))
8548 gnus-mime-security-button-commands))))
8550 (defun gnus-mime-security-button-menu (event prefix)
8551 "Construct a context-sensitive menu of security commands."
8552 (interactive "e\nP")
8553 (save-window-excursion
8554 (let ((pos (event-start event)))
8555 (select-window (posn-window pos))
8556 (goto-char (posn-point pos))
8557 (gnus-article-check-buffer)
8558 (popup-menu gnus-mime-security-button-menu nil prefix))))
8560 (defvar gnus-mime-security-details-buffer nil)
8562 (defvar gnus-mime-security-button-pressed nil)
8564 (defvar gnus-mime-security-show-details-inline t
8565 "If non-nil, show details in the article buffer.")
8567 (defun gnus-mime-security-verify-or-decrypt (handle)
8568 (mm-remove-parts (cdr handle))
8569 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8570 point (inhibit-read-only t))
8572 (goto-char (car region)))
8573 (setq point (point))
8574 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8575 (let* ((mm-verify-option 'known)
8576 (mm-decrypt-option 'known)
8577 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8578 (unless (eq nparts (cdr handle))
8579 (mm-destroy-parts (cdr handle))
8580 (setcdr handle nparts))))
8581 (gnus-mime-display-security handle)
8583 (delete-region (point) (cdr region))
8584 (set-marker (car region) nil)
8585 (set-marker (cdr region) nil))
8588 (defun gnus-mime-security-show-details (handle)
8589 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8591 (gnus-message 5 "No details.")
8592 (if gnus-mime-security-show-details-inline
8593 (let ((gnus-mime-security-button-pressed
8594 (not (get-text-property (point) 'gnus-mime-details)))
8595 (gnus-mime-security-button-line-format
8596 (get-text-property (point) 'gnus-line-format))
8597 (inhibit-read-only t))
8599 (while (eq (get-text-property (point) 'gnus-line-format)
8600 gnus-mime-security-button-line-format)
8604 (narrow-to-region (point) (point))
8605 (gnus-insert-mime-security-button handle))
8606 (delete-region (point)
8607 (or (text-property-not-all
8610 gnus-mime-security-button-line-format)
8613 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8614 (with-current-buffer gnus-mime-security-details-buffer
8617 (setq gnus-mime-security-details-buffer
8618 (gnus-get-buffer-create "*MIME Security Details*")))
8619 (with-current-buffer gnus-mime-security-details-buffer
8621 (goto-char (point-min)))
8622 (pop-to-buffer gnus-mime-security-details-buffer)))))
8624 (defun gnus-mime-security-press-button (handle)
8626 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8627 (gnus-mime-security-show-details handle)
8628 (gnus-mime-security-verify-or-decrypt handle))))
8630 (defun gnus-insert-mime-security-button (handle &optional displayed)
8631 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8634 (or (nth 2 (assoc protocol mm-verify-function-alist))
8635 (nth 2 (assoc protocol mm-decrypt-function-alist))
8637 (if (equal (car handle) "multipart/signed")
8638 " Signed" " Encrypted")
8641 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8644 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8645 gnus-tmp-pressed-details
8647 (setq gnus-tmp-details
8648 (if gnus-tmp-details
8649 (concat "\n" gnus-tmp-details)
8651 (setq gnus-tmp-pressed-details
8652 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8657 gnus-mime-security-button-line-format
8658 gnus-mime-security-button-line-format-alist
8659 `(keymap ,gnus-mime-security-button-map
8660 gnus-callback gnus-mime-security-press-button
8661 gnus-line-format ,gnus-mime-security-button-line-format
8662 gnus-mime-details ,gnus-mime-security-button-pressed
8663 article-type annotation
8666 ;; Exclude a newline.
8669 (when gnus-article-button-face
8670 (gnus-overlay-put (gnus-make-overlay b e nil t)
8671 'face gnus-article-button-face))
8672 (widget-convert-button
8675 :action 'gnus-widget-press-button
8676 :button-keymap gnus-mime-security-button-map
8679 ;; Needed to properly clear the message due to a bug in
8680 ;; wid-edit (XEmacs only).
8681 (when (boundp 'help-echo-owns-message)
8682 (setq help-echo-owns-message t))
8684 "%S: show detail; %S: more options"
8685 (aref gnus-mouse-2 0)
8686 (aref gnus-down-mouse-3 0))))))
8688 (defun gnus-mime-display-security (handle)
8690 (narrow-to-region (point) (point))
8691 (unless (gnus-unbuttonized-mime-type-p (car handle))
8692 (gnus-insert-mime-security-button handle))
8693 (gnus-mime-display-part (cadr handle))
8696 (unless (gnus-unbuttonized-mime-type-p (car handle))
8697 (let ((gnus-mime-security-button-line-format
8698 gnus-mime-security-button-end-line-format))
8699 (gnus-insert-mime-security-button handle)))
8700 (mm-set-handle-multipart-parameter
8702 (cons (set-marker (make-marker) (point-min))
8703 (set-marker (make-marker) (point-max))))
8704 (goto-char (point-max))))
8706 (defun gnus-mime-security-run-function (function)
8707 "Run FUNCTION with the security part under point."
8708 (gnus-article-check-buffer)
8709 (let ((data (get-text-property (point) 'gnus-data))
8711 (when (and (stringp (car-safe data))
8712 (setq buffer (mm-handle-multipart-original-buffer data))
8713 (setq handle (cadr data)))
8714 (if (bufferp (mm-handle-buffer handle))
8716 (setq handle (cons buffer (copy-sequence (cdr handle))))
8717 (mm-handle-set-undisplayer handle nil))
8718 (setq handle (mm-make-handle
8720 (mm-handle-multipart-ctl-parameter handle 'protocol)
8721 nil nil nil nil nil nil)))
8722 (funcall function handle))))
8724 (defun gnus-mime-security-save-part ()
8725 "Save the security part under point."
8727 (gnus-mime-security-run-function 'mm-save-part))
8729 (defun gnus-mime-security-pipe-part ()
8730 "Pipe the security part under point to a process."
8732 (gnus-mime-security-run-function 'mm-pipe-part))
8738 (run-hooks 'gnus-art-load-hook)
8740 ;;; gnus-art.el ends here