1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; 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 2, or (at your option)
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; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map
))
46 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
47 (autoload 'gnus-button-mailto
"gnus-msg")
48 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
49 (autoload 'parse-time-string
"parse-time" nil nil
)
51 (defgroup gnus-article nil
53 :link
'(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link
'(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link
'(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link
'(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link
'(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link
'(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link
'(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link
'(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link
'(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link
'(custom-manual "(gnus)Using MIME")
100 :group
'gnus-article
)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link
'(custom-manual "(gnus)Article Buttons")
105 :group
'gnus-article
)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link
'(custom-manual "(gnus)Misc Article")
110 :group
'gnus-article
)
112 (defcustom gnus-ignored-headers
115 (concat "^" header
":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type
'(choice :custom-show nil
160 :group
'gnus-article-hiding
)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type
'(repeat :value-to-internal
(lambda (widget value
)
168 (custom-split-regexp-maybe value
))
169 :match
(lambda (widget value
)
171 (widget-editable-list-match widget value
)))
173 :group
'gnus-article-hiding
)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type
'(repeat regexp
)
183 :group
'gnus-article-hiding
)
185 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type
'(set (const :tag
"Headers with no content." empty
)
200 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
201 (const :tag
"To identical to To-address." to-address
)
202 (const :tag
"To identical to To-list." to-list
)
203 (const :tag
"CC identical to To-list." cc-list
)
204 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
205 (const :tag
"Reply-to identical to From." reply-to
)
206 (const :tag
"Date less than four days old." date
)
207 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
208 (const :tag
"Multiple To and/or Cc headers." many-to
))
209 :group
'gnus-article-hiding
)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
219 :group
'gnus-article-hiding
)
221 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type
'(repeat string
)
227 :group
'gnus-article-signature
)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature."
237 :type
'(choice (integer :value
200)
239 (function :value fun
)
240 (regexp :value
".*"))
241 :group
'gnus-article-signature
)
243 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
244 "Property list to use for hiding text."
246 :group
'gnus-article-hiding
)
248 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
249 ;; frames in a session.
250 (defcustom gnus-article-x-face-command
251 (if (featurep 'xemacs
)
252 (if (or (gnus-image-type-available-p 'xface
)
253 (gnus-image-type-available-p 'pbm
))
254 'gnus-display-x-face-in-from
255 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
256 (if (gnus-image-type-available-p 'pbm
)
257 'gnus-display-x-face-in-from
258 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
260 "*String or function to be executed to display an X-Face header.
261 If it is a string, the command will be executed in a sub-shell
262 asynchronously. The compressed face will be piped to this command."
263 :type
`(choice string
264 (function-item gnus-display-x-face-in-from
)
268 :group
'gnus-article-washing
)
270 (defcustom gnus-article-x-face-too-ugly nil
271 "Regexp matching posters whose face shouldn't be shown automatically."
272 :type
'(choice regexp
(const nil
))
273 :group
'gnus-article-washing
)
275 (defcustom gnus-article-banner-alist nil
276 "Banner alist for stripping.
278 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
280 :type
'(repeat (cons symbol regexp
))
281 :group
'gnus-article-washing
)
283 (gnus-define-group-parameter
286 "Alist of regexps (to match group names) and banner."
287 :variable-group gnus-article-washing
289 '(choice :tag
"Banner"
291 (const :tag
"Remove signature" signature
)
292 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
294 (const :tag
"None" nil
))
296 "If non-nil, specify how to remove `banners' from articles.
298 Symbol `signature' means to remove signatures delimited by
299 `gnus-signature-separator'. Any other symbol is used to look up a
300 regular expression to match the banner in `gnus-article-banner-alist'.
301 A string is used as a regular expression to match the banner
304 (defcustom gnus-article-address-banner-alist nil
305 "Alist of mail addresses and banners.
306 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
307 to match a mail address in the From: header, BANNER is one of a symbol
308 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
309 If ADDRESS matches author's mail address, it will remove things like
310 advertisements. For example:
312 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
316 (regexp :tag
"Address")
317 (choice :tag
"Banner" :value nil
318 (const :tag
"Remove signature" signature
)
319 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
321 (const :tag
"None" nil
))))
323 :group
'gnus-article-washing
)
325 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
327 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
328 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
331 (defun gnus-emphasis-custom-value-to-external (value)
332 (gnus-emphasis-custom-with-format
333 (if (consp (car value
))
334 (list (format format
(car (car value
)) (cdr (car value
)))
336 (if (nth 1 value
) 2 3)
340 (defun gnus-emphasis-custom-value-to-internal (value)
341 (gnus-emphasis-custom-with-format
342 (let ((regexp (concat "\\`"
343 (format (regexp-quote format
)
344 "\\([^()]+\\)" "\\([^()]+\\)")
347 (if (string-match regexp
(setq pattern
(car value
)))
348 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
353 (defcustom gnus-emphasis-alist
355 '(("\\*" "\\*" bold nil
2)
358 ("_/" "/_" underline-italic
)
359 ("_\\*" "\\*_" underline-bold
)
360 ("\\*/" "/\\*" bold-italic
)
361 ("_\\*/" "/\\*_" underline-bold-italic
))))
363 (gnus-emphasis-custom-with-format
364 (mapcar (lambda (spec)
365 (list (format format
(car spec
) (cadr spec
))
368 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
370 '(;; I've never seen anyone use this strikethru convention whereas I've
371 ;; several times seen it triggered by normal text. --Stef
372 ;; Miles suggests that this form is sometimes used but for italics,
373 ;; so maybe we should map it to `italic'.
374 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
375 ;; 2 3 gnus-emphasis-strikethru)
376 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
377 2 3 gnus-emphasis-underline
))))
378 "*Alist that says how to fontify certain phrases.
379 Each item looks like this:
381 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
383 The first element is a regular expression to be matched. The second
384 is a number that says what regular expression grouping used to find
385 the entire emphasized word. The third is a number that says what
386 regexp grouping should be displayed and highlighted. The fourth
387 is the face used for highlighting."
391 :format
"%[Customizing Style%]\n%v"
393 (group :tag
"Default"
394 :value
("" 0 0 default
)
397 (let ((value (widget-get
398 (cadr (widget-get (widget-get widget
:parent
)
401 (if (not (eq (nth 2 value
) 'default
))
405 (gnus-emphasis-custom-value-to-external value
))))
406 (widget-group-value-create widget
))
408 (integer :format
"Match group: %v")
409 (integer :format
"Emphasize group: %v")
412 :value
(("_" .
"_") nil default
)
414 (regexp :format
"Start regexp: %v")
415 (regexp :format
"End regexp: %v"))
416 (boolean :format
"Show start and end patterns: %[%v%]\n"
417 :on
" On " :off
" Off ")
419 :get
(lambda (symbol)
420 (mapcar 'gnus-emphasis-custom-value-to-internal
421 (default-value symbol
)))
422 :set
(lambda (symbol value
)
423 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
425 :group
'gnus-article-emphasis
)
427 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
428 "A regexp to describe whitespace which should not be emphasized.
429 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
430 The former avoids underlining of leading and trailing whitespace,
431 and the latter avoids underlining any whitespace at all."
433 :group
'gnus-article-emphasis
436 (defface gnus-emphasis-bold
'((t (:bold t
)))
437 "Face used for displaying strong emphasized text (*word*)."
438 :group
'gnus-article-emphasis
)
440 (defface gnus-emphasis-italic
'((t (:italic t
)))
441 "Face used for displaying italic emphasized text (/word/)."
442 :group
'gnus-article-emphasis
)
444 (defface gnus-emphasis-underline
'((t (:underline t
)))
445 "Face used for displaying underlined emphasized text (_word_)."
446 :group
'gnus-article-emphasis
)
448 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
449 "Face used for displaying underlined bold emphasized text (_*word*_)."
450 :group
'gnus-article-emphasis
)
452 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
453 "Face used for displaying underlined italic emphasized text (_/word/_)."
454 :group
'gnus-article-emphasis
)
456 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
457 "Face used for displaying bold italic emphasized text (/*word*/)."
458 :group
'gnus-article-emphasis
)
460 (defface gnus-emphasis-underline-bold-italic
461 '((t (:bold t
:italic t
:underline t
)))
462 "Face used for displaying underlined bold italic emphasized text.
463 Example: (_/*word*/_)."
464 :group
'gnus-article-emphasis
)
466 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
467 '((t (:strikethru t
)))
468 '((t (:strike-through t
))))
469 "Face used for displaying strike-through text (-word-)."
470 :group
'gnus-article-emphasis
)
472 (defface gnus-emphasis-highlight-words
473 '((t (:background
"black" :foreground
"yellow")))
474 "Face used for displaying highlighted words."
475 :group
'gnus-article-emphasis
)
477 (defcustom gnus-article-time-format
"%a, %b %d %Y %T %Z"
478 "Format for display of Date headers in article bodies.
479 See `format-time-string' for the possible values.
481 The variable can also be function, which should return a complete Date
482 header. The function is called with one argument, the time, which can
483 be fed to `format-time-string'."
484 :type
'(choice string symbol
)
485 :link
'(custom-manual "(gnus)Article Date")
486 :group
'gnus-article-washing
)
488 (defcustom gnus-save-all-headers t
489 "*If non-nil, don't remove any headers before saving."
490 :group
'gnus-article-saving
493 (defcustom gnus-prompt-before-saving
'always
494 "*This variable says how much prompting is to be done when saving articles.
495 If it is nil, no prompting will be done, and the articles will be
496 saved to the default files. If this variable is `always', each and
497 every article that is saved will be preceded by a prompt, even when
498 saving large batches of articles. If this variable is neither nil not
499 `always', there the user will be prompted once for a file name for
500 each invocation of the saving commands."
501 :group
'gnus-article-saving
502 :type
'(choice (item always
)
503 (item :tag
"never" nil
)
504 (sexp :tag
"once" :format
"%t\n" :value t
)))
506 (defcustom gnus-saved-headers gnus-visible-headers
507 "Headers to keep if `gnus-save-all-headers' is nil.
508 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
509 If that variable is nil, however, all headers that match this regexp
510 will be kept while the rest will be deleted before saving."
511 :group
'gnus-article-saving
514 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
515 "A function to save articles in your favourite format.
516 The function must be interactively callable (in other words, it must
517 be an Emacs command).
519 Gnus provides the following functions:
521 * gnus-summary-save-in-rmail (Rmail format)
522 * gnus-summary-save-in-mail (Unix mail format)
523 * gnus-summary-save-in-folder (MH folder)
524 * gnus-summary-save-in-file (article format)
525 * gnus-summary-save-body-in-file (article body)
526 * gnus-summary-save-in-vm (use VM's folder format)
527 * gnus-summary-write-to-file (article format -- overwrite)."
528 :group
'gnus-article-saving
529 :type
'(radio (function-item gnus-summary-save-in-rmail
)
530 (function-item gnus-summary-save-in-mail
)
531 (function-item gnus-summary-save-in-folder
)
532 (function-item gnus-summary-save-in-file
)
533 (function-item gnus-summary-save-body-in-file
)
534 (function-item gnus-summary-save-in-vm
)
535 (function-item gnus-summary-write-to-file
)))
537 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
538 "A function generating a file name to save articles in Rmail format.
539 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
540 :group
'gnus-article-saving
543 (defcustom gnus-mail-save-name
'gnus-plain-save-name
544 "A function generating a file name to save articles in Unix mail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group
'gnus-article-saving
549 (defcustom gnus-folder-save-name
'gnus-folder-save-name
550 "A function generating a file name to save articles in MH folder.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
552 :group
'gnus-article-saving
555 (defcustom gnus-file-save-name
'gnus-numeric-save-name
556 "A function generating a file name to save articles in article format.
557 The function is called with NEWSGROUP, HEADERS, and optional
559 :group
'gnus-article-saving
562 (defcustom gnus-split-methods
563 '((gnus-article-archive-name)
564 (gnus-article-nndoc-name))
565 "*Variable used to suggest where articles are to be saved.
566 For instance, if you would like to save articles related to Gnus in
567 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
568 you could set this variable to something like:
570 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
571 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
573 This variable is an alist where the where the key is the match and the
574 value is a list of possible files to save in if the match is non-nil.
576 If the match is a string, it is used as a regexp match on the
577 article. If the match is a symbol, that symbol will be funcalled
578 from the buffer of the article to be saved with the newsgroup as the
579 parameter. If it is a list, it will be evaled in the same buffer.
581 If this form or function returns a string, this string will be used as
582 a possible file name; and if it returns a non-nil list, that list will
583 be used as possible file names."
584 :group
'gnus-article-saving
585 :type
'(repeat (choice (list :value
(fun) function
)
586 (cons :value
("" "") regexp
(repeat string
))
589 (defcustom gnus-page-delimiter
"^\^L"
590 "*Regexp describing what to use as article page delimiters.
591 The default value is \"^\^L\", which is a form linefeed at the
592 beginning of a line."
594 :group
'gnus-article-various
)
596 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
597 "*The format specification for the article mode line.
598 See `gnus-summary-mode-line-format' for a closer description.
600 The following additional specs are available:
602 %w The article washing status.
603 %m The number of MIME parts in the article."
605 :group
'gnus-article-various
)
607 (defcustom gnus-article-mode-hook nil
608 "*A hook for Gnus article mode."
610 :group
'gnus-article-various
)
612 (when (featurep 'xemacs
)
613 ;; Extracted from gnus-xmas-define in order to preserve user settings
614 (when (fboundp 'turn-off-scroll-in-place
)
615 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
616 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
617 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
619 (defcustom gnus-article-menu-hook nil
620 "*Hook run after the creation of the article mode menu."
622 :group
'gnus-article-various
)
624 (defcustom gnus-article-prepare-hook nil
625 "*A hook called after an article has been prepared in the article buffer."
627 :group
'gnus-article-various
)
629 (make-obsolete-variable 'gnus-article-hide-pgp-hook
630 "This variable is obsolete in Gnus 5.10.")
632 (defcustom gnus-article-button-face
'bold
633 "Face used for highlighting buttons in the article buffer.
635 An article button is a piece of text that you can activate by pressing
636 `RET' or `mouse-2' above it."
638 :group
'gnus-article-buttons
)
640 (defcustom gnus-article-mouse-face
'highlight
641 "Face used for mouse highlighting in the article buffer.
643 Article buttons will be displayed in this face when the cursor is
646 :group
'gnus-article-buttons
)
648 (defcustom gnus-signature-face
'gnus-signature
649 "Face used for highlighting a signature in the article buffer.
650 Obsolete; use the face `gnus-signature' for customizations instead."
652 :group
'gnus-article-highlight
653 :group
'gnus-article-signature
)
655 (defface gnus-signature
658 "Face used for highlighting a signature in the article buffer."
659 :group
'gnus-article-highlight
660 :group
'gnus-article-signature
)
661 ;; backward-compatibility alias
662 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
664 (defface gnus-header-from
667 (:foreground
"spring green"))
670 (:foreground
"red3"))
673 "Face used for displaying from headers."
674 :group
'gnus-article-headers
675 :group
'gnus-article-highlight
)
676 ;; backward-compatibility alias
677 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
679 (defface gnus-header-subject
682 (:foreground
"SeaGreen3"))
685 (:foreground
"red4"))
687 (:bold t
:italic t
)))
688 "Face used for displaying subject headers."
689 :group
'gnus-article-headers
690 :group
'gnus-article-highlight
)
691 ;; backward-compatibility alias
692 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
694 (defface gnus-header-newsgroups
697 (:foreground
"yellow" :italic t
))
700 (:foreground
"MidnightBlue" :italic t
))
703 "Face used for displaying newsgroups headers.
704 In the default setup this face is only used for crossposted
706 :group
'gnus-article-headers
707 :group
'gnus-article-highlight
)
708 ;; backward-compatibility alias
709 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
711 (defface gnus-header-name
714 (:foreground
"SeaGreen"))
717 (:foreground
"maroon"))
720 "Face used for displaying header names."
721 :group
'gnus-article-headers
722 :group
'gnus-article-highlight
)
723 ;; backward-compatibility alias
724 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
726 (defface gnus-header-content
729 (:foreground
"forest green" :italic t
))
732 (:foreground
"indianred4" :italic t
))
734 (:italic t
))) "Face used for displaying header content."
735 :group
'gnus-article-headers
736 :group
'gnus-article-highlight
)
737 ;; backward-compatibility alias
738 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
740 (defcustom gnus-header-face-alist
741 '(("From" nil gnus-header-from
)
742 ("Subject" nil gnus-header-subject
)
743 ("Newsgroups:.*," nil gnus-header-newsgroups
)
744 ("" gnus-header-name gnus-header-content
))
745 "*Controls highlighting of article headers.
747 An alist of the form (HEADER NAME CONTENT).
749 HEADER is a regular expression which should match the name of a
750 header and NAME and CONTENT are either face names or nil.
752 The name of each header field will be displayed using the face
753 specified by the first element in the list where HEADER matches
754 the header name and NAME is non-nil. Similarly, the content will
755 be displayed by the first non-nil matching CONTENT face."
756 :group
'gnus-article-headers
757 :group
'gnus-article-highlight
758 :type
'(repeat (list (regexp :tag
"Header")
760 (item :tag
"skip" nil
)
761 (face :value default
))
762 (choice :tag
"Content"
763 (item :tag
"skip" nil
)
764 (face :value default
)))))
766 (defcustom gnus-article-decode-hook
767 '(article-decode-charset article-decode-encoded-words
768 article-decode-group-name article-decode-idna-rhs
)
769 "*Hook run to decode charsets in articles."
770 :group
'gnus-article-headers
773 (defcustom gnus-display-mime-function
'gnus-display-mime
774 "Function to display MIME articles."
775 :group
'gnus-article-mime
778 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
779 "Function used to decode headers.")
781 (defvar gnus-article-dumbquotes-map
801 "Table for MS-to-Latin1 translation.")
803 (defcustom gnus-ignored-mime-types nil
804 "List of MIME types that should be ignored by Gnus."
806 :group
'gnus-article-mime
807 :type
'(repeat regexp
))
809 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
810 "List of MIME types that should not be given buttons when rendered inline.
811 See also `gnus-buttonized-mime-types' which may override this variable.
812 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
814 :group
'gnus-article-mime
815 :type
'(repeat regexp
))
817 (defcustom gnus-buttonized-mime-types nil
818 "List of MIME types that should be given buttons when rendered inline.
819 If set, this variable overrides `gnus-unbuttonized-mime-types'.
820 To see e.g. security buttons you could set this to
821 `(\"multipart/signed\")'.
822 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
824 :group
'gnus-article-mime
825 :type
'(repeat regexp
))
827 (defcustom gnus-inhibit-mime-unbuttonizing nil
828 "If non-nil, all MIME parts get buttons.
829 When nil (the default value), then some MIME parts do not get buttons,
830 as described by the variables `gnus-buttonized-mime-types' and
831 `gnus-unbuttonized-mime-types'."
833 :group
'gnus-article-mime
836 (defcustom gnus-body-boundary-delimiter
"_"
837 "String used to delimit header and body.
838 This variable is used by `gnus-article-treat-body-boundary' which can
839 be controlled by `gnus-treat-body-boundary'."
841 :group
'gnus-article-various
842 :type
'(choice (item :tag
"None" :value nil
)
845 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces")
846 "Defines the location of the faces database.
847 For information on obtaining this database of pretty pictures, please
848 see http://www.cs.indiana.edu/picons/ftp/index.html"
850 :type
'(repeat directory
)
851 :link
'(url-link :tag
"download"
852 "http://www.cs.indiana.edu/picons/ftp/index.html")
853 :link
'(custom-manual "(gnus)Picons")
856 (defun gnus-picons-installed-p ()
857 "Say whether picons are installed on your machine."
858 (let ((installed nil
))
859 (dolist (database gnus-picon-databases
)
860 (when (file-exists-p database
)
864 (defcustom gnus-article-mime-part-function nil
865 "Function called with a MIME handle as the argument.
866 This is meant for people who want to do something automatic based
867 on parts -- for instance, adding Vcard info to a database."
868 :group
'gnus-article-mime
871 (defcustom gnus-mime-multipart-functions nil
872 "An alist of MIME types to functions to display them."
874 :group
'gnus-article-mime
877 (defcustom gnus-article-date-lapsed-new-header nil
878 "Whether the X-Sent and Date headers can coexist.
879 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
880 either replace the old \"Date:\" header (if this variable is nil), or
881 be added below it (otherwise)."
883 :group
'gnus-article-headers
886 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
887 "Function called with a MIME handle as the argument.
888 This is meant for people who want to view first matched part.
889 For `undisplayed-alternative' (default), the first undisplayed
890 part or alternative part is used. For `undisplayed', the first
891 undisplayed part is used. For a function, the first part which
892 the function return t is used. For nil, the first part is
895 :group
'gnus-article-mime
897 (item :tag
"first" :value nil
)
898 (item :tag
"undisplayed" :value undisplayed
)
899 (item :tag
"undisplayed or alternative"
900 :value undisplayed-alternative
)
903 (defcustom gnus-mime-action-alist
904 '(("save to file" . gnus-mime-save-part
)
905 ("save and strip" . gnus-mime-save-part-and-strip
)
906 ("delete part" . gnus-mime-delete-part
)
907 ("display as text" . gnus-mime-inline-part
)
908 ("view the part" . gnus-mime-view-part
)
909 ("pipe to command" . gnus-mime-pipe-part
)
910 ("toggle display" . gnus-article-press-button
)
911 ("toggle display" . gnus-article-view-part-as-charset
)
912 ("view as type" . gnus-mime-view-part-as-type
)
913 ("view internally" . gnus-mime-view-part-internally
)
914 ("view externally" . gnus-mime-view-part-externally
))
915 "An alist of actions that run on the MIME attachment."
916 :group
'gnus-article-mime
917 :type
'(repeat (cons (string :tag
"name")
921 ;;; The treatment variables
924 (defvar gnus-part-display-hook nil
925 "Hook called on parts that are to receive treatment.")
927 (defvar gnus-article-treat-custom
928 '(choice (const :tag
"Off" nil
)
930 (const :tag
"Header" head
)
931 (const :tag
"Last" last
)
932 (integer :tag
"Less")
933 (repeat :tag
"Groups" regexp
)
934 (sexp :tag
"Predicate")))
936 (defvar gnus-article-treat-head-custom
937 '(choice (const :tag
"Off" nil
)
938 (const :tag
"Header" head
)))
940 (defvar gnus-article-treat-types
'("text/plain")
943 (defvar gnus-inhibit-treatment nil
944 "Whether to inhibit treatment.")
946 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
947 "Highlight the signature.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles'."
950 :group
'gnus-article-treat
951 :link
'(custom-manual "(gnus)Customizing Articles")
952 :type gnus-article-treat-custom
)
953 (put 'gnus-treat-highlight-signature
'highlight t
)
955 (defcustom gnus-treat-buttonize
100000
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles'."
959 :group
'gnus-article-treat
960 :link
'(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom
)
962 (put 'gnus-treat-buttonize
'highlight t
)
964 (defcustom gnus-treat-buttonize-head
'head
965 "Add buttons to the head.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group
'gnus-article-treat
969 :link
'(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-head-custom
)
971 (put 'gnus-treat-buttonize-head
'highlight t
)
973 (defcustom gnus-treat-emphasize
974 (and (or window-system
976 (>= (string-to-number emacs-version
) 21))
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group
'gnus-article-treat
982 :link
'(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom
)
984 (put 'gnus-treat-emphasize
'highlight t
)
986 (defcustom gnus-treat-strip-cr nil
987 "Remove carriage returns.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
991 :group
'gnus-article-treat
992 :link
'(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom
)
995 (defcustom gnus-treat-unsplit-urls nil
996 "Remove newlines from within URLs.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group
'gnus-article-treat
1001 :link
'(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom
)
1004 (defcustom gnus-treat-leading-whitespace nil
1005 "Remove leading whitespace in headers.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1009 :group
'gnus-article-treat
1010 :link
'(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom
)
1013 (defcustom gnus-treat-hide-headers
'head
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group
'gnus-article-treat
1018 :link
'(custom-manual "(gnus)Customizing Articles")
1019 :type gnus-article-treat-head-custom
)
1021 (defcustom gnus-treat-hide-boring-headers nil
1022 "Hide boring headers.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group
'gnus-article-treat
1026 :link
'(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-head-custom
)
1029 (defcustom gnus-treat-hide-signature nil
1030 "Hide the signature.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group
'gnus-article-treat
1034 :link
'(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom
)
1037 (defcustom gnus-treat-fill-article nil
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group
'gnus-article-treat
1042 :link
'(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom
)
1045 (defcustom gnus-treat-hide-citation nil
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group
'gnus-article-treat
1050 :link
'(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom
)
1053 (defcustom gnus-treat-hide-citation-maybe nil
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group
'gnus-article-treat
1058 :link
'(custom-manual "(gnus)Customizing Articles")
1059 :type gnus-article-treat-custom
)
1061 (defcustom gnus-treat-strip-list-identifiers
'head
1062 "Strip list identifiers from `gnus-list-identifiers`.
1063 Valid values are nil, t, `head', `last', an integer or a predicate.
1064 See Info node `(gnus)Customizing Articles' for details."
1066 :group
'gnus-article-treat
1067 :link
'(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom
)
1070 (make-obsolete-variable 'gnus-treat-strip-pgp
1071 "This option is obsolete in Gnus 5.10.")
1073 (defcustom gnus-treat-strip-pem nil
1074 "Strip PEM signatures.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group
'gnus-article-treat
1078 :link
'(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom
)
1081 (defcustom gnus-treat-strip-banner t
1082 "Strip banners from articles.
1083 The banner to be stripped is specified in the `banner' group parameter.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group
'gnus-article-treat
1087 :link
'(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom
)
1090 (defcustom gnus-treat-highlight-headers
'head
1091 "Highlight the headers.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group
'gnus-article-treat
1095 :link
'(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-head-custom
)
1097 (put 'gnus-treat-highlight-headers
'highlight t
)
1099 (defcustom gnus-treat-highlight-citation t
1100 "Highlight cited text.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group
'gnus-article-treat
1104 :link
'(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom
)
1106 (put 'gnus-treat-highlight-citation
'highlight t
)
1108 (defcustom gnus-treat-date-ut nil
1109 "Display the Date in UT (GMT).
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group
'gnus-article-treat
1113 :link
'(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom
)
1116 (defcustom gnus-treat-date-local nil
1117 "Display the Date in the local timezone.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group
'gnus-article-treat
1121 :link
'(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom
)
1124 (defcustom gnus-treat-date-english nil
1125 "Display the Date in a format that can be read aloud in English.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1129 :group
'gnus-article-treat
1130 :link
'(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom
)
1133 (defcustom gnus-treat-date-lapsed nil
1134 "Display the Date header in a way that says how much time has elapsed.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group
'gnus-article-treat
1138 :link
'(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom
)
1141 (defcustom gnus-treat-date-original nil
1142 "Display the date in the original timezone.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group
'gnus-article-treat
1146 :link
'(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-head-custom
)
1149 (defcustom gnus-treat-date-iso8601 nil
1150 "Display the date in the ISO8601 format.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1154 :group
'gnus-article-treat
1155 :link
'(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-head-custom
)
1158 (defcustom gnus-treat-date-user-defined nil
1159 "Display the date in a user-defined format.
1160 The format is defined by the `gnus-article-time-format' variable.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group
'gnus-article-treat
1164 :link
'(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom
)
1167 (defcustom gnus-treat-strip-headers-in-body t
1168 "Strip the X-No-Archive header line from the beginning of the body.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group
'gnus-article-treat
1173 :link
'(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom
)
1176 (defcustom gnus-treat-strip-trailing-blank-lines nil
1177 "Strip trailing blank lines.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group
'gnus-article-treat
1181 :link
'(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom
)
1184 (defcustom gnus-treat-strip-leading-blank-lines nil
1185 "Strip leading blank lines.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group
'gnus-article-treat
1189 :link
'(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom
)
1192 (defcustom gnus-treat-strip-multiple-blank-lines nil
1193 "Strip multiple blank lines.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group
'gnus-article-treat
1197 :link
'(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom
)
1200 (defcustom gnus-treat-unfold-headers
'head
1201 "Unfold folded header lines.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1205 :group
'gnus-article-treat
1206 :link
'(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-custom
)
1209 (defcustom gnus-treat-fold-headers nil
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1214 :group
'gnus-article-treat
1215 :link
'(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-custom
)
1218 (defcustom gnus-treat-fold-newsgroups
'head
1219 "Fold the Newsgroups and Followup-To headers.
1220 Valid values are nil, t, `head', `last', an integer or a predicate.
1221 See Info node `(gnus)Customizing Articles' for details."
1223 :group
'gnus-article-treat
1224 :link
'(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom
)
1227 (defcustom gnus-treat-overstrike t
1228 "Treat overstrike highlighting.
1229 Valid values are nil, t, `head', `last', an integer or a predicate.
1230 See Info node `(gnus)Customizing Articles' for details."
1231 :group
'gnus-article-treat
1232 :link
'(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom
)
1234 (put 'gnus-treat-overstrike
'highlight t
)
1236 (make-obsolete-variable 'gnus-treat-display-xface
1237 'gnus-treat-display-x-face
)
1239 (defcustom gnus-treat-display-x-face
1240 (and (not noninteractive
)
1241 (or (and (fboundp 'image-type-available-p
)
1242 (image-type-available-p 'xbm
)
1243 (string-match "^0x" (shell-command-to-string "uncompface"))
1244 (executable-find "icontopbm"))
1245 (and (featurep 'xemacs
)
1248 "Display X-Face headers.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' and Info node
1251 `(gnus)X-Face' for details."
1252 :group
'gnus-article-treat
1254 :link
'(custom-manual "(gnus)Customizing Articles")
1255 :link
'(custom-manual "(gnus)X-Face")
1256 :type gnus-article-treat-head-custom
1257 :set
(lambda (symbol value
)
1260 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1262 ((boundp 'gnus-treat-display-xface
)
1264 ** gnus-treat-display-xface is an obsolete variable;\
1265 use gnus-treat-display-x-face instead")
1266 (default-value 'gnus-treat-display-xface
))
1267 ((get 'gnus-treat-display-xface
'saved-value
)
1269 ** gnus-treat-display-xface is an obsolete variable;\
1270 use gnus-treat-display-x-face instead")
1271 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1274 (put 'gnus-treat-display-x-face
'highlight t
)
1276 (defcustom gnus-treat-display-face
1277 (and (not noninteractive
)
1278 (or (and (fboundp 'image-type-available-p
)
1279 (image-type-available-p 'png
))
1280 (and (featurep 'xemacs
)
1283 "Display Face headers.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' and Info node
1286 `(gnus)X-Face' for details."
1287 :group
'gnus-article-treat
1289 :link
'(custom-manual "(gnus)Customizing Articles")
1290 :link
'(custom-manual "(gnus)X-Face")
1291 :type gnus-article-treat-head-custom
)
1292 (put 'gnus-treat-display-face
'highlight t
)
1294 (defcustom gnus-treat-display-smileys
1295 (if (or (and (featurep 'xemacs
)
1297 (and (fboundp 'image-type-available-p
)
1298 (image-type-available-p 'pbm
)))
1301 Valid values are nil, t, `head', `last', an integer or a predicate.
1302 See Info node `(gnus)Customizing Articles' and Info node
1303 `(gnus)Smileys' for details."
1304 :group
'gnus-article-treat
1306 :link
'(custom-manual "(gnus)Customizing Articles")
1307 :link
'(custom-manual "(gnus)Smileys")
1308 :type gnus-article-treat-custom
)
1309 (put 'gnus-treat-display-smileys
'highlight t
)
1311 (defcustom gnus-treat-from-picon
1312 (if (and (gnus-image-type-available-p 'xpm
)
1313 (gnus-picons-installed-p))
1315 "Display picons in the From header.
1316 Valid values are nil, t, `head', `last', an integer or a predicate.
1317 See Info node `(gnus)Customizing Articles' and Info node
1318 `(gnus)Picons' for details."
1320 :group
'gnus-article-treat
1322 :link
'(custom-manual "(gnus)Customizing Articles")
1323 :link
'(custom-manual "(gnus)Picons")
1324 :type gnus-article-treat-head-custom
)
1325 (put 'gnus-treat-from-picon
'highlight t
)
1327 (defcustom gnus-treat-mail-picon
1328 (if (and (gnus-image-type-available-p 'xpm
)
1329 (gnus-picons-installed-p))
1331 "Display picons in To and Cc headers.
1332 Valid values are nil, t, `head', `last', an integer or a predicate.
1333 See Info node `(gnus)Customizing Articles' and Info node
1334 `(gnus)Picons' for details."
1336 :group
'gnus-article-treat
1338 :link
'(custom-manual "(gnus)Customizing Articles")
1339 :link
'(custom-manual "(gnus)Picons")
1340 :type gnus-article-treat-head-custom
)
1341 (put 'gnus-treat-mail-picon
'highlight t
)
1343 (defcustom gnus-treat-newsgroups-picon
1344 (if (and (gnus-image-type-available-p 'xpm
)
1345 (gnus-picons-installed-p))
1347 "Display picons in the Newsgroups and Followup-To headers.
1348 Valid values are nil, t, `head', `last', an integer or a predicate.
1349 See Info node `(gnus)Customizing Articles' and Info node
1350 `(gnus)Picons' for details."
1352 :group
'gnus-article-treat
1354 :link
'(custom-manual "(gnus)Customizing Articles")
1355 :link
'(custom-manual "(gnus)Picons")
1356 :type gnus-article-treat-head-custom
)
1357 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1359 (defcustom gnus-treat-body-boundary
1360 (if (or gnus-treat-newsgroups-picon
1361 gnus-treat-mail-picon
1362 gnus-treat-from-picon
)
1364 "Draw a boundary at the end of the headers.
1365 Valid values are nil and `head'.
1366 See Info node `(gnus)Customizing Articles' for details."
1368 :group
'gnus-article-treat
1369 :link
'(custom-manual "(gnus)Customizing Articles")
1370 :type gnus-article-treat-head-custom
)
1372 (defcustom gnus-treat-capitalize-sentences nil
1373 "Capitalize sentence-starting words.
1374 Valid values are nil, t, `head', `last', an integer or a predicate.
1375 See Info node `(gnus)Customizing Articles' for details."
1377 :group
'gnus-article-treat
1378 :link
'(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom
)
1381 (defcustom gnus-treat-wash-html nil
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' for details."
1386 :group
'gnus-article-treat
1387 :link
'(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom
)
1390 (defcustom gnus-treat-fill-long-lines nil
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' for details."
1394 :group
'gnus-article-treat
1395 :link
'(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom
)
1398 (defcustom gnus-treat-play-sounds nil
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' for details."
1403 :group
'gnus-article-treat
1404 :link
'(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom
)
1407 (defcustom gnus-treat-translate nil
1408 "Translate articles from one language to another.
1409 Valid values are nil, t, `head', `last', an integer or a predicate.
1410 See Info node `(gnus)Customizing Articles' for details."
1412 :group
'gnus-article-treat
1413 :link
'(custom-manual "(gnus)Customizing Articles")
1414 :type gnus-article-treat-custom
)
1416 (defcustom gnus-treat-x-pgp-sig nil
1418 To automatically treat X-PGP-Sig, set it to head.
1419 Valid values are nil, t, `head', `last', an integer or a predicate.
1420 See Info node `(gnus)Customizing Articles' for details."
1422 :group
'gnus-article-treat
1423 :group
'mime-security
1424 :link
'(custom-manual "(gnus)Customizing Articles")
1425 :type gnus-article-treat-custom
)
1427 (defvar gnus-article-encrypt-protocol-alist
1428 '(("PGP" . mml2015-self-encrypt
)))
1430 ;; Set to nil if more than one protocol added to
1431 ;; gnus-article-encrypt-protocol-alist.
1432 (defcustom gnus-article-encrypt-protocol
"PGP"
1433 "The protocol used for encrypt articles.
1434 It is a string, such as \"PGP\". If nil, ask user."
1437 :group
'mime-security
)
1439 (defvar gnus-article-wash-function nil
1440 "Function used for converting HTML into text.")
1442 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1443 (mm-coding-system-p 'utf-8
)
1444 (executable-find idna-program
))
1445 "Whether IDNA decoding of headers is used when viewing messages.
1446 This requires GNU Libidn, and by default only enabled if it is found."
1448 :group
'gnus-article-headers
1451 (defcustom gnus-article-over-scroll nil
1452 "If non-nil, allow scrolling the article buffer even when there no more text."
1454 :group
'gnus-article
1457 ;;; Internal variables
1459 (defvar gnus-english-month-names
1460 '("January" "February" "March" "April" "May" "June" "July" "August"
1461 "September" "October" "November" "December"))
1463 (defvar article-goto-body-goes-to-point-min-p nil
)
1464 (defvar gnus-article-wash-types nil
)
1465 (defvar gnus-article-emphasis-alist nil
)
1466 (defvar gnus-article-image-alist nil
)
1468 (defvar gnus-article-mime-handle-alist-1 nil
)
1469 (defvar gnus-treatment-function-alist
1470 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1471 (gnus-treat-strip-banner gnus-article-strip-banner
)
1472 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1473 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1474 (gnus-treat-buttonize gnus-article-add-buttons
)
1475 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1476 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1477 (gnus-treat-strip-cr gnus-article-remove-cr
)
1478 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1479 (gnus-treat-date-ut gnus-article-date-ut
)
1480 (gnus-treat-date-local gnus-article-date-local
)
1481 (gnus-treat-date-english gnus-article-date-english
)
1482 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1483 (gnus-treat-date-original gnus-article-date-original
)
1484 (gnus-treat-date-user-defined gnus-article-date-user
)
1485 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1486 (gnus-treat-display-x-face gnus-article-display-x-face
)
1487 (gnus-treat-display-face gnus-article-display-face
)
1488 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1489 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1490 (gnus-treat-hide-signature gnus-article-hide-signature
)
1491 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1492 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1493 (gnus-treat-strip-pem gnus-article-hide-pem
)
1494 (gnus-treat-from-picon gnus-treat-from-picon
)
1495 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1496 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1497 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1498 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1499 (gnus-treat-strip-trailing-blank-lines
1500 gnus-article-remove-trailing-blank-lines
)
1501 (gnus-treat-strip-leading-blank-lines
1502 gnus-article-strip-leading-blank-lines
)
1503 (gnus-treat-strip-multiple-blank-lines
1504 gnus-article-strip-multiple-blank-lines
)
1505 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1506 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1507 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1508 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1509 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1510 (gnus-treat-display-smileys gnus-treat-smiley
)
1511 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1512 (gnus-treat-wash-html gnus-article-wash-html
)
1513 (gnus-treat-emphasize gnus-article-emphasize
)
1514 (gnus-treat-hide-citation gnus-article-hide-citation
)
1515 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1516 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1517 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)
1518 (gnus-treat-play-sounds gnus-earcon-display
)))
1520 (defvar gnus-article-mime-handle-alist nil
)
1521 (defvar article-lapsed-timer nil
)
1522 (defvar gnus-article-current-summary nil
)
1524 (defvar gnus-article-mode-syntax-table
1525 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1526 ;; This causes the citation match run O(2^n).
1527 ;; (modify-syntax-entry ?- "w" table)
1528 (modify-syntax-entry ?
> ")<" table
)
1529 (modify-syntax-entry ?
< "(>" table
)
1530 ;; make M-. in article buffers work for `foo' strings
1531 (modify-syntax-entry ?
' " " table
)
1532 (modify-syntax-entry ?
` " " table
)
1534 "Syntax table used in article mode buffers.
1535 Initialized from `text-mode-syntax-table.")
1537 (defvar gnus-save-article-buffer nil
)
1539 (defvar gnus-article-mode-line-format-alist
1540 (nconc '((?w
(gnus-article-wash-status) ?s
)
1541 (?m
(gnus-article-mime-part-status) ?s
))
1542 gnus-summary-mode-line-format-alist
))
1544 (defvar gnus-number-of-articles-to-be-saved nil
)
1546 (defvar gnus-inhibit-hiding nil
)
1548 (defvar gnus-article-edit-mode nil
)
1550 ;;; Macros for dealing with the article buffer.
1552 (defmacro gnus-with-article-headers
(&rest forms
)
1554 (set-buffer gnus-article-buffer
)
1556 (let ((inhibit-read-only t
)
1557 (inhibit-point-motion-hooks t
)
1558 (case-fold-search t
))
1559 (article-narrow-to-head)
1562 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1563 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1565 (defmacro gnus-with-article-buffer
(&rest forms
)
1567 (set-buffer gnus-article-buffer
)
1568 (let ((inhibit-read-only t
))
1571 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1572 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1574 (defun gnus-article-goto-header (header)
1575 "Go to HEADER, which is a regular expression."
1576 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1578 (defsubst gnus-article-hide-text
(b e props
)
1579 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1580 (gnus-add-text-properties-when 'article-type nil b e props
)
1581 (when (memq 'intangible props
)
1583 (max (1- b
) (point-min))
1584 b
'intangible
(cddr (memq 'intangible props
)))))
1586 (defsubst gnus-article-unhide-text
(b e
)
1587 "Remove hidden text properties from region between B and E."
1588 (remove-text-properties b e gnus-hidden-properties
)
1589 (when (memq 'intangible gnus-hidden-properties
)
1590 (put-text-property (max (1- b
) (point-min))
1591 b
'intangible nil
)))
1593 (defun gnus-article-hide-text-type (b e type
)
1594 "Hide text of TYPE between B and E."
1595 (gnus-add-wash-type type
)
1596 (gnus-article-hide-text
1597 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1599 (defun gnus-article-unhide-text-type (b e type
)
1600 "Unhide text of TYPE between B and E."
1601 (gnus-delete-wash-type type
)
1602 (remove-text-properties
1603 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1604 (when (memq 'intangible gnus-hidden-properties
)
1605 (put-text-property (max (1- b
) (point-min))
1606 b
'intangible nil
)))
1608 (defun gnus-article-hide-text-of-type (type)
1609 "Hide text of TYPE in the current buffer."
1611 (let ((b (point-min))
1613 (while (setq b
(text-property-any b e
'article-type type
))
1614 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1616 (defun gnus-article-delete-text-of-type (type)
1617 "Delete text of TYPE in the current buffer."
1619 (let ((b (point-min)))
1620 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1622 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1625 (defun gnus-article-delete-invisible-text ()
1626 "Delete all invisible text in the current buffer."
1628 (let ((b (point-min)))
1629 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1631 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1634 (defun gnus-article-text-type-exists-p (type)
1635 "Say whether any text of type TYPE exists in the buffer."
1636 (text-property-any (point-min) (point-max) 'article-type type
))
1638 (defsubst gnus-article-header-rank
()
1639 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1640 (let ((list gnus-sorted-header-list
)
1643 (if (looking-at (car list
))
1645 (setq list
(cdr list
))
1649 (defun article-hide-headers (&optional arg delete
)
1650 "Hide unwanted headers and possibly sort them as well."
1652 ;; This function might be inhibited.
1653 (unless gnus-inhibit-hiding
1654 (let ((inhibit-read-only nil
)
1655 (case-fold-search t
)
1656 (max (1+ (length gnus-sorted-header-list
)))
1657 (inhibit-point-motion-hooks t
)
1658 (cur (current-buffer))
1659 ignored visible beg
)
1661 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1662 ;; group parameters, so we should go to the summary buffer.
1665 (progn (set-buffer gnus-summary-buffer
) t
)
1667 (setq ignored
(when (not gnus-visible-headers
)
1668 (cond ((stringp gnus-ignored-headers
)
1669 gnus-ignored-headers
)
1670 ((listp gnus-ignored-headers
)
1671 (mapconcat 'identity
1672 gnus-ignored-headers
1674 visible
(cond ((stringp gnus-visible-headers
)
1675 gnus-visible-headers
)
1676 ((and gnus-visible-headers
1677 (listp gnus-visible-headers
))
1678 (mapconcat 'identity
1679 gnus-visible-headers
1683 ;; First we narrow to just the headers.
1684 (article-narrow-to-head)
1685 ;; Hide any "From " lines at the beginning of (mail) articles.
1686 (while (looking-at "From ")
1689 (delete-region (point-min) (point)))
1690 ;; Then treat the rest of the header lines.
1691 ;; Then we use the two regular expressions
1692 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1693 ;; select which header lines is to remain visible in the
1695 (while (re-search-forward "^[^ \t:]*:" nil t
)
1697 ;; Mark the rank of the header.
1699 (point) (1+ (point)) 'message-rank
1700 (if (or (and visible
(looking-at visible
))
1702 (not (looking-at ignored
))))
1703 (gnus-article-header-rank)
1706 (message-sort-headers-1)
1707 (when (setq beg
(text-property-any
1708 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1709 ;; We delete the unwanted headers.
1710 (gnus-add-wash-type 'headers
)
1711 (add-text-properties (point-min) (+ 5 (point-min))
1712 '(article-type headers dummy-invisible t
))
1713 (delete-region beg
(point-max))))))))
1715 (defun article-hide-boring-headers (&optional arg
)
1716 "Toggle hiding of headers that aren't very interesting.
1717 If given a negative prefix, always show; if given a positive prefix,
1719 (interactive (gnus-article-hidden-arg))
1720 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1721 (not gnus-show-all-headers
))
1724 (let ((inhibit-read-only t
)
1725 (list gnus-boring-article-headers
)
1726 (inhibit-point-motion-hooks t
)
1728 (article-narrow-to-head)
1730 (setq elem
(pop list
))
1731 (goto-char (point-min))
1733 ;; Hide empty headers.
1735 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1737 (gnus-article-hide-text-type
1741 (if (re-search-forward "^[^ \t]" nil t
)
1745 ;; Hide boring Newsgroups header.
1746 ((eq elem
'newsgroups
)
1747 (when (gnus-string-equal
1748 (gnus-fetch-field "newsgroups")
1749 (gnus-group-real-name
1750 (if (boundp 'gnus-newsgroup-name
)
1753 (gnus-article-hide-header "newsgroups")))
1754 ((eq elem
'to-address
)
1755 (let ((to (message-fetch-field "to"))
1757 (gnus-parameter-to-address
1758 (if (boundp 'gnus-newsgroup-name
)
1759 gnus-newsgroup-name
""))))
1760 (when (and to to-address
1763 ;; only one address in To
1764 (nth 1 (mail-extract-address-components to
))
1766 (gnus-article-hide-header "to"))))
1768 (let ((to (message-fetch-field "to"))
1770 (gnus-parameter-to-list
1771 (if (boundp 'gnus-newsgroup-name
)
1772 gnus-newsgroup-name
""))))
1773 (when (and to to-list
1776 ;; only one address in To
1777 (nth 1 (mail-extract-address-components to
))
1779 (gnus-article-hide-header "to"))))
1781 (let ((cc (message-fetch-field "cc"))
1783 (gnus-parameter-to-list
1784 (if (boundp 'gnus-newsgroup-name
)
1785 gnus-newsgroup-name
""))))
1786 (when (and cc to-list
1789 ;; only one address in CC
1790 (nth 1 (mail-extract-address-components cc
))
1792 (gnus-article-hide-header "cc"))))
1793 ((eq elem
'followup-to
)
1794 (when (gnus-string-equal
1795 (message-fetch-field "followup-to")
1796 (message-fetch-field "newsgroups"))
1797 (gnus-article-hide-header "followup-to")))
1798 ((eq elem
'reply-to
)
1799 (if (gnus-group-find-parameter
1800 gnus-newsgroup-name
'broken-reply-to
)
1801 (gnus-article-hide-header "reply-to")
1802 (let ((from (message-fetch-field "from"))
1803 (reply-to (message-fetch-field "reply-to")))
1810 (lambda (x) (downcase (cadr x
)))
1811 (mail-extract-address-components from t
))
1814 (lambda (x) (downcase (cadr x
)))
1815 (mail-extract-address-components reply-to t
))
1817 (gnus-article-hide-header "reply-to")))))
1819 (let ((date (message-fetch-field "date")))
1821 (< (days-between (current-time-string) date
)
1823 (gnus-article-hide-header "date"))))
1825 (let ((to (message-fetch-field "to"))
1826 (cc (message-fetch-field "cc")))
1827 (when (> (length to
) 1024)
1828 (gnus-article-hide-header "to"))
1829 (when (> (length cc
) 1024)
1830 (gnus-article-hide-header "cc"))))
1834 (goto-char (point-min))
1835 (while (re-search-forward "^to:" nil t
)
1836 (setq to-count
(1+ to-count
)))
1837 (when (> to-count
1)
1838 (while (> to-count
0)
1839 (goto-char (point-min))
1841 (re-search-forward "^to:" nil nil to-count
)
1843 (narrow-to-region (point) (point-max))
1844 (gnus-article-hide-header "to"))
1845 (setq to-count
(1- to-count
))))
1846 (goto-char (point-min))
1847 (while (re-search-forward "^cc:" nil t
)
1848 (setq cc-count
(1+ cc-count
)))
1849 (when (> cc-count
1)
1850 (while (> cc-count
0)
1851 (goto-char (point-min))
1853 (re-search-forward "^cc:" nil nil cc-count
)
1855 (narrow-to-region (point) (point-max))
1856 (gnus-article-hide-header "cc"))
1857 (setq cc-count
(1- cc-count
)))))))))))))
1859 (defun gnus-article-hide-header (header)
1861 (goto-char (point-min))
1862 (when (re-search-forward (concat "^" header
":") nil t
)
1863 (gnus-article-hide-text-type
1867 (if (re-search-forward "^[^ \t]" nil t
)
1872 (defvar gnus-article-normalized-header-length
40
1873 "Length of normalized headers.")
1875 (defun article-normalize-headers ()
1876 "Make all header lines 40 characters long."
1878 (let ((inhibit-read-only t
)
1882 (article-narrow-to-head)
1885 ((< (setq column
(- (gnus-point-at-eol) (point)))
1886 gnus-article-normalized-header-length
)
1888 (insert (make-string
1889 (- gnus-article-normalized-header-length column
)
1891 ((> column gnus-article-normalized-header-length
)
1892 (gnus-put-text-property
1894 (forward-char gnus-article-normalized-header-length
)
1901 (forward-line 1))))))
1903 (defun article-treat-dumbquotes ()
1904 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1905 Note that this function guesses whether a character is a sm*rtq**t* or
1906 not, so it should only be used interactively.
1908 Sm*rtq**t*s are M****s***'s unilateral extension to the
1909 iso-8859-1 character map in an attempt to provide more quoting
1910 characters. If you see something like \\222 or \\264 where
1911 you're expecting some kind of apostrophe or quotation mark, then
1914 (article-translate-strings gnus-article-dumbquotes-map
))
1916 (defun article-translate-characters (from to
)
1917 "Translate all characters in the body of the article according to FROM and TO.
1918 FROM is a string of characters to translate from; to is a string of
1919 characters to translate to."
1921 (when (article-goto-body)
1922 (let ((inhibit-read-only t
)
1923 (x (make-string 225 ?x
))
1925 (while (< (incf i
) (length x
))
1928 (while (< i
(length from
))
1929 (aset x
(aref from i
) (aref to i
))
1931 (translate-region (point) (point-max) x
)))))
1933 (defun article-translate-strings (map)
1934 "Translate all string in the body of the article according to MAP.
1935 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1937 (when (article-goto-body)
1938 (let ((inhibit-read-only t
)
1940 (while (setq elem
(pop map
))
1942 (while (search-forward (car elem
) nil t
)
1943 (replace-match (cadr elem
)))))))))
1945 (defun article-treat-overstrike ()
1946 "Translate overstrikes into bold text."
1949 (when (article-goto-body)
1950 (let ((inhibit-read-only t
))
1951 (while (search-forward "\b" nil t
)
1952 (let ((next (char-after))
1953 (previous (char-after (- (point) 2))))
1954 ;; We do the boldification/underlining by hiding the
1955 ;; overstrikes and putting the proper text property
1959 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1960 (put-text-property (point) (1+ (point)) 'face
'bold
))
1962 (gnus-article-hide-text-type
1963 (1- (point)) (1+ (point)) 'overstrike
)
1965 (- (point) 2) (1- (point)) 'face
'underline
))
1967 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1969 (point) (1+ (point)) 'face
'underline
)))))))))
1971 (defun gnus-article-treat-unfold-headers ()
1972 "Unfold folded message headers.
1973 Only the headers that fit into the current window width will be
1976 (gnus-with-article-headers
1980 (mail-header-narrow-to-field)
1981 (let ((header (buffer-string)))
1984 (goto-char (point-min))
1985 (while (re-search-forward "\n[\t ]" nil t
)
1986 (replace-match " " t t
)))
1987 (setq length
(- (point-max) (point-min) 1)))
1988 (when (< length
(window-width))
1989 (while (re-search-forward "\n[\t ]" nil t
)
1990 (replace-match " " t t
)))
1991 (goto-char (point-max)))))))
1993 (defun gnus-article-treat-fold-headers ()
1994 "Fold message headers."
1996 (gnus-with-article-headers
1999 (mail-header-narrow-to-field)
2000 (mail-header-fold-field)
2001 (goto-char (point-max))))))
2003 (defun gnus-treat-smiley ()
2004 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2006 (gnus-with-article-buffer
2007 (if (memq 'smiley gnus-article-wash-types
)
2008 (gnus-delete-images 'smiley
)
2010 (let ((images (smiley-region (point) (point-max))))
2012 (gnus-add-wash-type 'smiley
)
2013 (dolist (image images
)
2014 (gnus-add-image 'smiley image
)))))))
2016 (defun gnus-article-remove-images ()
2017 "Remove all images from the article buffer."
2019 (gnus-with-article-buffer
2020 (dolist (elem gnus-article-image-alist
)
2021 (gnus-delete-images (car elem
)))))
2023 (defun gnus-article-treat-fold-newsgroups ()
2024 "Unfold folded message headers.
2025 Only the headers that fit into the current window width will be
2028 (gnus-with-article-headers
2029 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2031 (mail-header-narrow-to-field)
2032 (while (re-search-forward ", *" nil t
)
2033 (replace-match ", " t t
))
2034 (mail-header-fold-field)
2035 (goto-char (point-max))))))
2037 (defun gnus-article-treat-body-boundary ()
2038 "Place a boundary line at the end of the headers."
2040 (when (and gnus-body-boundary-delimiter
2041 (> (length gnus-body-boundary-delimiter
) 0))
2042 (gnus-with-article-headers
2043 (goto-char (point-max))
2044 (let ((start (point)))
2045 (insert "X-Boundary: ")
2046 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2048 (while (>= (1- (window-width)) (length str
))
2049 (setq str
(concat str gnus-body-boundary-delimiter
)))
2050 (substring str
0 (1- (window-width))))
2052 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2054 (defun article-fill-long-lines ()
2055 "Fill lines that are wider than the window width."
2058 (let ((inhibit-read-only t
)
2059 (width (window-width (get-buffer-window (current-buffer)))))
2062 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2065 (when (>= (current-column) (min fill-column width
))
2066 (narrow-to-region (min (1+ (point)) (point-max))
2067 (gnus-point-at-bol))
2068 (let ((goback (point-marker)))
2069 (fill-paragraph nil
)
2070 (goto-char (marker-position goback
)))
2072 (forward-line 1)))))))
2074 (defun article-capitalize-sentences ()
2075 "Capitalize the first word in each sentence."
2078 (let ((inhibit-read-only t
)
2079 (paragraph-start "^[\n\^L]"))
2083 (forward-sentence)))))
2085 (defun article-remove-cr ()
2086 "Remove trailing CRs and then translate remaining CRs into LFs."
2089 (let ((inhibit-read-only t
))
2090 (goto-char (point-min))
2091 (while (re-search-forward "\r+$" nil t
)
2092 (replace-match "" t t
))
2093 (goto-char (point-min))
2094 (while (search-forward "\r" nil t
)
2095 (replace-match "\n" t t
)))))
2097 (defun article-remove-trailing-blank-lines ()
2098 "Remove all trailing blank lines from the article."
2101 (let ((inhibit-read-only t
))
2102 (goto-char (point-max))
2106 (while (and (not (bobp))
2107 (looking-at "^[ \t]*$")
2108 (not (gnus-annotation-in-region-p
2109 (point) (gnus-point-at-eol))))
2114 (defun article-display-face ()
2115 "Display any Face headers in the header."
2117 (let ((wash-face-p buffer-read-only
))
2118 (gnus-with-article-headers
2119 ;; When displaying parts, this function can be called several times on
2120 ;; the same article, without any intended toggle semantic (as typing `W
2121 ;; D d' would have). So face deletion must occur only when we come from
2122 ;; an interactive command, that is when the *Article* buffer is
2124 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2125 (gnus-delete-images 'face
)
2128 (when (and wash-face-p
2130 (goto-char (point-min))
2131 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2132 (gnus-buffer-live-p gnus-original-article-buffer
))
2133 (set-buffer gnus-original-article-buffer
))
2135 (mail-narrow-to-head)
2136 (while (gnus-article-goto-header "Face")
2137 (push (mail-header-field-value) faces
))))
2138 (while (setq face
(pop faces
))
2139 (let ((png (gnus-convert-face-to-png face
))
2142 (setq image
(gnus-create-image png
'png t
))
2143 (gnus-article-goto-header "from")
2145 (insert "From: [no `from' set]\n")
2147 (gnus-add-wash-type 'face
)
2148 (gnus-add-image 'face image
)
2149 (gnus-put-image image nil
'face
))))))
2152 (defun article-display-x-face (&optional force
)
2153 "Look for an X-Face header and display it if present."
2154 (interactive (list 'force
))
2155 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2156 (gnus-with-article-headers
2157 ;; Delete the old process, if any.
2158 (when (process-status "article-x-face")
2159 (delete-process "article-x-face"))
2160 ;; See the comment in `article-display-face'.
2161 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2162 ;; We have already displayed X-Faces, so we remove them
2164 (gnus-delete-images 'xface
)
2166 (let (x-faces from face
)
2168 (when (and wash-face-p
2170 (goto-char (point-min))
2171 (not (re-search-forward
2172 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t
)))
2173 (gnus-buffer-live-p gnus-original-article-buffer
))
2174 ;; If type `W f', use gnus-original-article-buffer,
2175 ;; otherwise use the current buffer because displaying
2176 ;; RFC822 parts calls this function too.
2177 (set-buffer gnus-original-article-buffer
))
2179 (mail-narrow-to-head)
2180 (while (gnus-article-goto-header "X-Face")
2181 (push (mail-header-field-value) x-faces
))
2182 (setq from
(message-fetch-field "from"))))
2183 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2184 ;; single external face.
2185 (when (stringp gnus-article-x-face-command
)
2186 (setq x-faces
(list (car x-faces
))))
2187 (while (and (setq face
(pop x-faces
))
2188 gnus-article-x-face-command
2190 ;; Check whether this face is censored.
2191 (not gnus-article-x-face-too-ugly
)
2192 (and gnus-article-x-face-too-ugly from
2193 (not (string-match gnus-article-x-face-too-ugly
2195 ;; We display the face.
2196 (cond ((stringp gnus-article-x-face-command
)
2197 ;; The command is a string, so we interpret the command
2198 ;; as a, well, command, and fork it off.
2199 (let ((process-connection-type nil
))
2200 (gnus-set-process-query-on-exit-flag
2202 "article-x-face" nil shell-file-name
2203 shell-command-switch gnus-article-x-face-command
)
2207 (process-send-region "article-x-face"
2208 (point-min) (point-max)))
2209 (process-send-eof "article-x-face")))
2210 ((functionp gnus-article-x-face-command
)
2211 ;; The command is a lisp function, so we call it.
2212 (funcall gnus-article-x-face-command face
))
2214 (error "%s is not a function"
2215 gnus-article-x-face-command
)))))))))
2217 (defun article-decode-mime-words ()
2218 "Decode all MIME-encoded words in the article."
2221 (set-buffer gnus-article-buffer
)
2222 (let ((inhibit-point-motion-hooks t
)
2223 (inhibit-read-only t
)
2224 (mail-parse-charset gnus-newsgroup-charset
)
2225 (mail-parse-ignored-charsets
2226 (save-excursion (set-buffer gnus-summary-buffer
)
2227 gnus-newsgroup-ignored-charsets
)))
2228 (mail-decode-encoded-word-region (point-min) (point-max)))))
2230 (defun article-decode-charset (&optional prompt
)
2231 "Decode charset-encoded text in the article.
2232 If PROMPT (the prefix), prompt for a coding system to use."
2234 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2235 (inhibit-read-only t
)
2236 (mail-parse-charset gnus-newsgroup-charset
)
2237 (mail-parse-ignored-charsets
2238 (save-excursion (condition-case nil
2239 (set-buffer gnus-summary-buffer
)
2241 gnus-newsgroup-ignored-charsets
))
2242 ct cte ctl charset format
)
2245 (article-narrow-to-head)
2246 (setq ct
(message-fetch-field "Content-Type" t
)
2247 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2248 ctl
(and ct
(ignore-errors
2249 (mail-header-parse-content-type ct
)))
2252 (mm-read-coding-system "Charset to decode: "))
2254 (mail-content-type-get ctl
'charset
)))
2255 format
(and ctl
(mail-content-type-get ctl
'format
)))
2257 (setq cte
(mail-header-strip cte
)))
2258 (if (and ctl
(not (string-match "/" (car ctl
))))
2260 (goto-char (point-max)))
2263 (narrow-to-region (point) (point-max))
2264 (when (and (eq mail-parse-charset
'gnus-decoded
)
2265 (eq (mm-body-7-or-8) '8bit
))
2266 ;; The text code could have been decoded.
2267 (setq charset mail-parse-charset
))
2268 (when (and (or (not ctl
)
2269 (equal (car ctl
) "text/plain"))
2270 (not format
)) ;; article with format will decode later.
2272 charset
(and cte
(intern (downcase
2273 (gnus-strip-whitespace cte
))))
2276 (defun article-decode-encoded-words ()
2277 "Remove encoded-word encoding from headers."
2278 (let ((inhibit-point-motion-hooks t
)
2279 (mail-parse-charset gnus-newsgroup-charset
)
2280 (mail-parse-ignored-charsets
2281 (save-excursion (condition-case nil
2282 (set-buffer gnus-summary-buffer
)
2284 gnus-newsgroup-ignored-charsets
))
2285 (inhibit-read-only t
))
2287 (article-narrow-to-head)
2288 (funcall gnus-decode-header-function
(point-min) (point-max)))))
2290 (defun article-decode-group-name ()
2291 "Decode group names in `Newsgroups:'."
2292 (let ((inhibit-point-motion-hooks t
)
2293 (inhibit-read-only t
)
2294 (method (gnus-find-method-for-group gnus-newsgroup-name
)))
2295 (when (and (or gnus-group-name-charset-method-alist
2296 gnus-group-name-charset-group-alist
)
2297 (gnus-buffer-live-p gnus-original-article-buffer
))
2299 (article-narrow-to-head)
2300 (with-current-buffer gnus-original-article-buffer
2301 (goto-char (point-min)))
2302 (while (re-search-forward
2303 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2304 (replace-match (save-match-data
2305 (gnus-decode-newsgroups
2306 ;; XXX how to use data in article buffer?
2307 (with-current-buffer gnus-original-article-buffer
2309 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2312 gnus-newsgroup-name method
))
2314 (goto-char (point-min))
2315 (with-current-buffer gnus-original-article-buffer
2316 (goto-char (point-min)))
2317 (while (re-search-forward
2318 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2319 (replace-match (save-match-data
2320 (gnus-decode-newsgroups
2321 ;; XXX how to use data in article buffer?
2322 (with-current-buffer gnus-original-article-buffer
2324 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2327 gnus-newsgroup-name method
))
2330 (autoload 'idna-to-unicode
"idna")
2332 (defun article-decode-idna-rhs ()
2333 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2336 (let ((inhibit-point-motion-hooks t
)
2337 (inhibit-read-only t
))
2338 (article-narrow-to-head)
2339 (goto-char (point-min))
2340 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2342 (when (save-match-data
2343 (and (setq ace
(match-string 1))
2345 (and (re-search-backward "^[^ \t]" nil t
)
2346 (looking-at "From\\|To\\|Cc")))
2347 (setq unicode
(idna-to-unicode ace
))))
2348 (unless (string= ace unicode
)
2349 (replace-match unicode nil nil nil
1)))))))))
2351 (defun article-de-quoted-unreadable (&optional force read-charset
)
2352 "Translate a quoted-printable-encoded article.
2353 If FORCE, decode the article whether it is marked as quoted-printable
2355 If READ-CHARSET, ask for a coding system."
2356 (interactive (list 'force current-prefix-arg
))
2358 (let ((inhibit-read-only t
) type charset
)
2359 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2360 (with-current-buffer gnus-original-article-buffer
2362 (gnus-fetch-field "content-transfer-encoding"))
2363 (let* ((ct (gnus-fetch-field "content-type"))
2366 (mail-header-parse-content-type ct
)))))
2367 (setq charset
(and ctl
2368 (mail-content-type-get ctl
'charset
)))
2369 (if (stringp charset
)
2370 (setq charset
(intern (downcase charset
)))))))
2372 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2374 (setq charset gnus-newsgroup-charset
))
2376 (and type
(let ((case-fold-search t
))
2377 (string-match "quoted-printable" type
))))
2379 (quoted-printable-decode-region
2380 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2382 (defun article-de-base64-unreadable (&optional force read-charset
)
2383 "Translate a base64 article.
2384 If FORCE, decode the article whether it is marked as base64 not.
2385 If READ-CHARSET, ask for a coding system."
2386 (interactive (list 'force current-prefix-arg
))
2388 (let ((inhibit-read-only t
) type charset
)
2389 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2390 (with-current-buffer gnus-original-article-buffer
2392 (gnus-fetch-field "content-transfer-encoding"))
2393 (let* ((ct (gnus-fetch-field "content-type"))
2396 (mail-header-parse-content-type ct
)))))
2397 (setq charset
(and ctl
2398 (mail-content-type-get ctl
'charset
)))
2399 (if (stringp charset
)
2400 (setq charset
(intern (downcase charset
)))))))
2402 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2404 (setq charset gnus-newsgroup-charset
))
2406 (and type
(let ((case-fold-search t
))
2407 (string-match "base64" type
))))
2410 (narrow-to-region (point) (point-max))
2411 (base64-decode-region (point-min) (point-max))
2412 (mm-decode-coding-region
2413 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2418 (defun article-decode-HZ ()
2419 "Translate a HZ-encoded article."
2423 (let ((inhibit-read-only t
))
2424 (rfc1843-decode-region (point-min) (point-max)))))
2426 (defun article-unsplit-urls ()
2427 "Remove the newlines that some other mailers insert into URLs."
2430 (let ((inhibit-read-only t
))
2431 (goto-char (point-min))
2432 (while (re-search-forward
2433 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2434 (replace-match "\\1\\3" t
)))
2435 (when (interactive-p)
2436 (gnus-treat-article nil
))))
2439 (defun article-wash-html (&optional read-charset
)
2440 "Format an HTML article.
2441 If READ-CHARSET, ask for a coding system."
2444 (let ((inhibit-read-only t
)
2446 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2447 (with-current-buffer gnus-original-article-buffer
2448 (let* ((ct (gnus-fetch-field "content-type"))
2451 (mail-header-parse-content-type ct
)))))
2452 (setq charset
(and ctl
2453 (mail-content-type-get ctl
'charset
)))
2454 (when (stringp charset
)
2455 (setq charset
(intern (downcase charset
)))))))
2457 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2459 (setq charset gnus-newsgroup-charset
))
2461 (save-window-excursion
2463 (narrow-to-region (point) (point-max))
2464 (let* ((func (or gnus-article-wash-function mm-text-html-renderer
))
2465 (entry (assq func mm-text-html-washer-alist
)))
2467 (setq func
(cdr entry
)))
2472 (apply (car func
) (cdr func
))))))))))
2474 (defun gnus-article-wash-html-with-w3 ()
2475 "Wash the current buffer with w3."
2477 (let ((w3-strict-width (window-width))
2478 (url-standalone-mode t
)
2479 (url-gateway-unplugged t
)
2480 (w3-honor-stylesheets nil
))
2482 (w3-region (point-min) (point-max))
2485 (defun gnus-article-wash-html-with-w3m ()
2486 "Wash the current buffer with emacs-w3m."
2489 (narrow-to-region (point) (point-max))
2490 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp
)
2491 w3m-force-redisplay
)
2492 (w3m-region (point-min) (point-max)))
2493 (when (and mm-inline-text-html-with-w3m-keymap
2494 (boundp 'w3m-minor-mode-map
)
2496 (add-text-properties
2497 (point-min) (point-max)
2498 (list 'keymap w3m-minor-mode-map
2499 ;; Put the mark meaning this part was rendered by emacs-w3m.
2500 'mm-inline-text-html-with-w3m t
)))))
2502 (defun article-hide-list-identifiers ()
2503 "Remove list identifies from the Subject header.
2504 The `gnus-list-identifiers' variable specifies what to do."
2506 (let ((inhibit-point-motion-hooks t
)
2507 (regexp (if (consp gnus-list-identifiers
)
2508 (mapconcat 'identity gnus-list-identifiers
" *\\|")
2509 gnus-list-identifiers
))
2510 (inhibit-read-only t
))
2514 (article-narrow-to-head)
2515 (goto-char (point-min))
2516 (while (re-search-forward
2517 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
2519 (delete-region (match-beginning 2) (match-end 0))
2520 (beginning-of-line))
2521 (when (re-search-forward
2522 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
2523 (delete-region (match-beginning 1) (match-end 1))))))))
2525 (defun article-hide-pem (&optional arg
)
2526 "Toggle hiding of any PEM headers and signatures in the current article.
2527 If given a negative prefix, always show; if given a positive prefix,
2529 (interactive (gnus-article-hidden-arg))
2530 (unless (gnus-article-check-hidden-text 'pem arg
)
2532 (let ((inhibit-read-only t
) end
)
2533 (goto-char (point-min))
2534 ;; Hide the horrendously ugly "header".
2535 (when (and (search-forward
2536 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2538 (setq end
(1+ (match-beginning 0))))
2539 (gnus-add-wash-type 'pem
)
2540 (gnus-article-hide-text-type
2542 (if (search-forward "\n\n" nil t
)
2546 ;; Hide the trailer as well
2547 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2549 (gnus-article-hide-text-type
2550 (match-beginning 0) (match-end 0) 'pem
)))))))
2552 (defun article-strip-banner ()
2553 "Strip the banners specified by the `banner' group parameter and by
2554 `gnus-article-address-banner-alist'."
2558 (let ((inhibit-point-motion-hooks t
))
2559 (when (gnus-parameter-banner gnus-newsgroup-name
)
2560 (article-really-strip-banner
2561 (gnus-parameter-banner gnus-newsgroup-name
)))
2562 (when gnus-article-address-banner-alist
2563 (article-really-strip-banner
2564 (let ((from (save-restriction
2566 (article-narrow-to-head)
2567 (mail-fetch-field "from"))))
2570 (caar (mail-header-parse-addresses from
))))
2572 (dolist (pair gnus-article-address-banner-alist
)
2573 (when (string-match (car pair
) from
)
2574 (throw 'found
(cdr pair
)))))))))))))
2576 (defun article-really-strip-banner (banner)
2577 "Strip the banner specified by the argument."
2580 (let ((inhibit-point-motion-hooks t
)
2581 (gnus-signature-limit nil
)
2582 (inhibit-read-only t
))
2585 ((eq banner
'signature
)
2586 (when (gnus-article-narrow-to-signature)
2589 (delete-region (point) (point-max))))
2591 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
2592 (while (re-search-forward banner nil t
)
2593 (delete-region (match-beginning 0) (match-end 0)))))
2595 (while (re-search-forward banner nil t
)
2596 (delete-region (match-beginning 0) (match-end 0)))))))))
2598 (defun article-babel ()
2599 "Translate article using an online translation service."
2603 (set-buffer gnus-article-buffer
)
2604 (when (article-goto-body)
2605 (let* ((inhibit-read-only t
)
2608 (orig (buffer-substring start end
))
2609 (trans (babel-as-string orig
)))
2611 (narrow-to-region start end
)
2612 (delete-region start end
)
2615 (defun article-hide-signature (&optional arg
)
2616 "Hide the signature in the current article.
2617 If given a negative prefix, always show; if given a positive prefix,
2619 (interactive (gnus-article-hidden-arg))
2620 (unless (gnus-article-check-hidden-text 'signature arg
)
2623 (let ((inhibit-read-only t
))
2624 (when (gnus-article-narrow-to-signature)
2625 (gnus-article-hide-text-type
2626 (point-min) (point-max) 'signature
))))))
2627 (gnus-set-mode-line 'article
))
2629 (defun article-strip-headers-in-body ()
2630 "Strip offensive headers from bodies."
2634 (let ((case-fold-search t
))
2635 (when (looking-at "x-no-archive:")
2636 (gnus-delete-line)))))
2638 (defun article-strip-leading-blank-lines ()
2639 "Remove all blank lines from the beginning of the article."
2642 (let ((inhibit-point-motion-hooks t
)
2643 (inhibit-read-only t
))
2644 (when (article-goto-body)
2645 (while (and (not (eobp))
2646 (looking-at "[ \t]*$"))
2647 (gnus-delete-line))))))
2649 (defun article-narrow-to-head ()
2650 "Narrow the buffer to the head of the message.
2651 Point is left at the beginning of the narrowed-to region."
2653 (goto-char (point-min))
2654 (if (search-forward "\n\n" nil
1)
2657 (goto-char (point-min)))
2659 (defun article-goto-body ()
2660 "Place point at the start of the body."
2661 (goto-char (point-min))
2663 ;; This variable is only bound when dealing with separate
2665 (article-goto-body-goes-to-point-min-p
2667 ((search-forward "\n\n" nil t
)
2670 (goto-char (point-max))
2673 (defun article-strip-multiple-blank-lines ()
2674 "Replace consecutive blank lines with one empty line."
2677 (let ((inhibit-point-motion-hooks t
)
2678 (inhibit-read-only t
))
2679 ;; First make all blank lines empty.
2681 (while (re-search-forward "^[ \t]+$" nil t
)
2682 (unless (gnus-annotation-in-region-p
2683 (match-beginning 0) (match-end 0))
2684 (replace-match "" nil t
)))
2685 ;; Then replace multiple empty lines with a single empty line.
2687 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
2688 (unless (gnus-annotation-in-region-p
2689 (match-beginning 0) (match-end 0))
2690 (delete-region (match-beginning 1) (match-end 1)))))))
2692 (defun article-strip-leading-space ()
2693 "Remove all white space from the beginning of the lines in the article."
2696 (let ((inhibit-point-motion-hooks t
)
2697 (inhibit-read-only t
))
2699 (while (re-search-forward "^[ \t]+" nil t
)
2700 (replace-match "" t t
)))))
2702 (defun article-strip-trailing-space ()
2703 "Remove all white space from the end of the lines in the article."
2706 (let ((inhibit-point-motion-hooks t
)
2707 (inhibit-read-only t
))
2709 (while (re-search-forward "[ \t]+$" nil t
)
2710 (replace-match "" t t
)))))
2712 (defun article-strip-blank-lines ()
2713 "Strip leading, trailing and multiple blank lines."
2715 (article-strip-leading-blank-lines)
2716 (article-remove-trailing-blank-lines)
2717 (article-strip-multiple-blank-lines))
2719 (defun article-strip-all-blank-lines ()
2720 "Strip all blank lines."
2723 (let ((inhibit-point-motion-hooks t
)
2724 (inhibit-read-only t
))
2726 (while (re-search-forward "^[ \t]*\n" nil t
)
2727 (replace-match "" t t
)))))
2729 (defun gnus-article-narrow-to-signature ()
2730 "Narrow to the signature; return t if a signature is found, else nil."
2731 (let ((inhibit-point-motion-hooks t
))
2732 (when (gnus-article-search-signature)
2734 ;; Check whether we have some limits to what we consider
2735 ;; to be a signature.
2736 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
2737 (list gnus-signature-limit
)))
2739 (while (setq limit
(pop limits
))
2740 (if (or (and (integerp limit
)
2741 (< (- (point-max) (point)) limit
))
2743 (< (count-lines (point) (point-max)) limit
))
2744 (and (functionp limit
)
2746 (and (stringp limit
)
2747 (not (re-search-forward limit nil t
))))
2748 () ; This limit did not succeed.
2752 (narrow-to-region (point) (point-max))
2755 (defun gnus-article-search-signature ()
2756 "Search the current buffer for the signature separator.
2757 Put point at the beginning of the signature separator."
2758 (let ((cur (point)))
2759 (goto-char (point-max))
2760 (if (if (stringp gnus-signature-separator
)
2761 (re-search-backward gnus-signature-separator nil t
)
2762 (let ((seps gnus-signature-separator
))
2764 (not (re-search-backward (car seps
) nil t
)))
2771 (defun gnus-article-hidden-arg ()
2772 "Return the current prefix arg as a number, or 0 if no prefix."
2773 (list (if current-prefix-arg
2774 (prefix-numeric-value current-prefix-arg
)
2777 (defun gnus-article-check-hidden-text (type arg
)
2778 "Return nil if hiding is necessary.
2779 Arg can be nil or a number. nil and positive means hide, negative
2780 means show, 0 means toggle."
2783 (let ((hide (gnus-article-hidden-text-p type
)))
2789 (gnus-article-show-hidden-text type
)
2792 (if (eq hide
'hidden
)
2794 (gnus-article-show-hidden-text type
)
2798 (defun gnus-article-hidden-text-p (type)
2799 "Say whether the current buffer contains hidden text of type TYPE."
2800 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
2802 (not (get-text-property pos
'invisible
))
2803 (not (get-text-property pos
'dummy-invisible
)))
2805 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
2810 (defun gnus-article-show-hidden-text (type &optional dummy
)
2811 "Show all hidden text of type TYPE.
2812 Originally it is hide instead of DUMMY."
2813 (let ((inhibit-read-only t
)
2814 (inhibit-point-motion-hooks t
))
2815 (gnus-remove-text-properties-when
2817 (point-min) (point-max)
2818 (cons 'article-type
(cons type
2819 gnus-hidden-properties
)))
2820 (gnus-delete-wash-type type
)))
2822 (defconst article-time-units
2823 `((year .
,(* 365.25 24 60 60))
2824 (week .
,(* 7 24 60 60))
2825 (day .
,(* 24 60 60))
2829 "Mapping from time units to seconds.")
2831 (defun gnus-article-forward-header ()
2832 "Move point to the start of the next header.
2833 If the current header is a continuation header, this can be several
2838 (if (looking-at "[ \t]+[^ \t]")
2842 (defun article-date-ut (&optional type highlight
)
2843 "Convert DATE date to universal time in the current article.
2844 If TYPE is `local', convert to local time; if it is `lapsed', output
2845 how much time has lapsed since DATE. For `lapsed', the value of
2846 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2847 should replace the \"Date:\" one, or should be added below it."
2848 (interactive (list 'ut t
))
2849 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2850 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
2854 (article-lapsed-timer
2858 (case-fold-search t
)
2859 (inhibit-read-only t
)
2860 (inhibit-point-motion-hooks t
)
2861 pos date bface eface
)
2865 (goto-char (point-min))
2866 (while (or (setq date
(get-text-property (setq pos
(point))
2868 (when (setq pos
(next-single-property-change
2869 (point) 'original-date
))
2870 (setq date
(get-text-property pos
'original-date
))
2872 (narrow-to-region pos
(or (text-property-any pos
(point-max)
2875 (goto-char (point-min))
2876 (when (re-search-forward tdate-regexp nil t
)
2877 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
2878 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
)))
2879 (goto-char (point-min))
2881 ;; Delete any old Date headers.
2882 (while (re-search-forward date-regexp nil t
)
2884 (delete-region (gnus-point-at-bol)
2886 (gnus-article-forward-header)
2888 (delete-region (gnus-point-at-bol)
2890 (gnus-article-forward-header)
2893 (setq pos
(point))))
2894 (when (and (not pos
)
2895 (re-search-forward tdate-regexp nil t
))
2897 (gnus-goto-char pos
)
2898 (insert (article-make-date-line date
(or type
'ut
)))
2904 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2905 (put-text-property (match-beginning 1) (1+ (match-end 1))
2907 (put-text-property (match-beginning 2) (match-end 2)
2909 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
2910 (goto-char (point-max))
2913 (defun article-make-date-line (date type
)
2914 "Return a DATE line of TYPE."
2915 (unless (memq type
'(local ut original user iso8601 lapsed english
))
2916 (error "Unknown conversion type: %s" type
))
2918 (let ((time (date-to-time date
)))
2920 ;; Convert to the local timezone.
2922 (let ((tz (car (current-time-zone time
))))
2923 (format "Date: %s %s%02d%02d" (current-time-string time
)
2924 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2925 (/ (%
(abs tz
) 3600) 60))))
2926 ;; Convert to Universal Time.
2929 (current-time-string
2930 (let* ((e (parse-time-string date
))
2931 (tm (apply 'encode-time e
))
2933 (ls (- (cadr tm
) (car (current-time-zone time
)))))
2934 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
2935 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
2938 ;; Get the original date from the article.
2939 ((eq type
'original
)
2940 (concat "Date: " (if (string-match "\n+$" date
)
2941 (substring date
0 (match-beginning 0))
2943 ;; Let the user define the format.
2945 (let ((format (or (condition-case nil
2946 (with-current-buffer gnus-summary-buffer
2947 gnus-article-time-format
)
2949 gnus-article-time-format
)))
2950 (if (functionp format
)
2951 (funcall format time
)
2952 (concat "Date: " (format-time-string format time
)))))
2955 (let ((tz (car (current-time-zone time
))))
2958 (format-time-string "%Y%m%dT%H%M%S" time
)
2959 (format "%s%02d%02d"
2960 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2961 (/ (%
(abs tz
) 3600) 60)))))
2962 ;; Do an X-Sent lapsed format.
2964 ;; If the date is seriously mangled, the timezone functions are
2965 ;; liable to bug out, so we ignore all errors.
2966 (let* ((now (current-time))
2967 (real-time (subtract-time now time
))
2968 (real-sec (and real-time
2969 (+ (* (float (car real-time
)) 65536)
2971 (sec (and real-time
(abs real-sec
)))
2981 ;; This is a bit convoluted, but basically we go
2982 ;; through the time units for years, weeks, etc,
2983 ;; and divide things to see whether that results
2984 ;; in positive answers.
2987 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
2988 ;; The (remaining) seconds are too few to
2989 ;; be divided into this time unit.
2991 ;; It's big enough, so we output it.
2992 (setq sec
(- sec
(* num
(cdr unit
))))
2994 (concat (if prev
", " "") (int-to-string
2996 " " (symbol-name (car unit
))
2997 (if (> num
1) "s" ""))
2999 article-time-units
"")
3000 ;; If dates are odd, then it might appear like the
3001 ;; article was sent in the future.
3004 " in the future"))))))
3005 ;; Display the date in proper English
3007 (let ((dtime (decode-time time
)))
3010 (number-to-string (nth 3 dtime
))
3011 (let ((digit (%
(nth 3 dtime
) 10)))
3013 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3019 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3021 (number-to-string (nth 5 dtime
))
3023 (format "%02d" (nth 2 dtime
))
3025 (format "%02d" (nth 1 dtime
)))))))
3027 (format "Date: %s (from Gnus)" date
))))
3029 (defun article-date-local (&optional highlight
)
3030 "Convert the current article date to the local timezone."
3031 (interactive (list t
))
3032 (article-date-ut 'local highlight
))
3034 (defun article-date-english (&optional highlight
)
3035 "Convert the current article date to something that is proper English."
3036 (interactive (list t
))
3037 (article-date-ut 'english highlight
))
3039 (defun article-date-original (&optional highlight
)
3040 "Convert the current article date to what it was originally.
3041 This is only useful if you have used some other date conversion
3042 function and want to see what the date was before converting."
3043 (interactive (list t
))
3044 (article-date-ut 'original highlight
))
3046 (defun article-date-lapsed (&optional highlight
)
3047 "Convert the current article date to time lapsed since it was sent."
3048 (interactive (list t
))
3049 (article-date-ut 'lapsed highlight
))
3051 (defun article-update-date-lapsed ()
3052 "Function to be run from a timer to update the lapsed time line."
3054 (let (deactivate-mark)
3059 (set-buffer (window-buffer w
))
3060 (when (eq major-mode
'gnus-article-mode
)
3061 (let ((mark (point-marker)))
3062 (goto-char (point-min))
3063 (when (re-search-forward "^X-Sent:" nil t
)
3064 (article-date-lapsed t
))
3065 (goto-char (marker-position mark
))
3066 (move-marker mark nil
))))
3069 (defun gnus-start-date-timer (&optional n
)
3070 "Start a timer to update the X-Sent header in the article buffers.
3071 The numerical prefix says how frequently (in seconds) the function
3076 (gnus-stop-date-timer)
3077 (setq article-lapsed-timer
3078 (nnheader-run-at-time 1 n
'article-update-date-lapsed
)))
3080 (defun gnus-stop-date-timer ()
3081 "Stop the X-Sent timer."
3083 (when article-lapsed-timer
3084 (nnheader-cancel-timer article-lapsed-timer
)
3085 (setq article-lapsed-timer nil
)))
3087 (defun article-date-user (&optional highlight
)
3088 "Convert the current article date to the user-defined format.
3089 This format is defined by the `gnus-article-time-format' variable."
3090 (interactive (list t
))
3091 (article-date-ut 'user highlight
))
3093 (defun article-date-iso8601 (&optional highlight
)
3094 "Convert the current article date to ISO8601."
3095 (interactive (list t
))
3096 (article-date-ut 'iso8601 highlight
))
3098 (defmacro gnus-article-save-original-date
(&rest forms
)
3099 "Save the original date as a text property and evaluate FORMS."
3100 `(let* ((case-fold-search t
)
3102 (goto-char (point-min))
3103 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3106 (date (when (and start
3107 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3109 (buffer-substring-no-properties start
3110 (match-beginning 0)))))
3111 (goto-char (point-max))
3112 (skip-chars-backward "\n")
3113 (put-text-property (point-min) (point) 'original-date date
)
3115 (goto-char (point-max))
3116 (skip-chars-backward "\n")
3117 (put-text-property (point-min) (point) 'original-date date
)))
3119 ;; (defun article-show-all ()
3120 ;; "Show all hidden text in the article buffer."
3123 ;; (let ((inhibit-read-only t))
3124 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3126 (defun article-remove-leading-whitespace ()
3127 "Remove excessive whitespace from all headers."
3131 (let ((inhibit-read-only t
))
3132 (article-narrow-to-head)
3133 (goto-char (point-min))
3134 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3135 (delete-region (match-beginning 1) (match-end 1)))))))
3137 (defun article-emphasize (&optional arg
)
3138 "Emphasize text according to `gnus-emphasis-alist'."
3139 (interactive (gnus-article-hidden-arg))
3140 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3144 (with-current-buffer gnus-summary-buffer
3145 gnus-article-emphasis-alist
)
3147 gnus-emphasis-alist
))
3148 (inhibit-read-only t
)
3149 (props (append '(article-type emphasis
)
3150 gnus-hidden-properties
))
3151 regexp elem beg invisible visible face
)
3154 (while (setq elem
(pop alist
))
3156 (setq regexp
(car elem
)
3157 invisible
(nth 1 elem
)
3158 visible
(nth 2 elem
)
3160 (while (re-search-forward regexp nil t
)
3161 (when (and (match-beginning visible
) (match-beginning invisible
))
3162 (gnus-article-hide-text
3163 (match-beginning invisible
) (match-end invisible
) props
)
3164 (gnus-article-unhide-text-type
3165 (match-beginning visible
) (match-end visible
) 'emphasis
)
3166 (gnus-put-overlay-excluding-newlines
3167 (match-beginning visible
) (match-end visible
) 'face face
)
3168 (gnus-add-wash-type 'emphasis
)
3169 (goto-char (match-end invisible
)))))))))
3171 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3172 "Setup newsgroup emphasis alist."
3173 (unless gnus-article-emphasis-alist
3174 (let ((name (and gnus-newsgroup-name
3175 (gnus-group-real-name gnus-newsgroup-name
))))
3176 (make-local-variable 'gnus-article-emphasis-alist
)
3177 (setq gnus-article-emphasis-alist
3179 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3180 (while (setq elem
(pop alist
))
3181 (when (and name
(string-match (car elem
) name
))
3183 highlight
(copy-sequence (cdr elem
)))))
3185 (copy-sequence highlight-words
)
3186 (if gnus-newsgroup-name
3187 (copy-sequence (gnus-group-find-parameter
3188 gnus-newsgroup-name
'highlight-words t
)))
3189 gnus-emphasis-alist
)))))
3192 (defvar gnus-summary-article-menu
)
3193 (defvar gnus-summary-post-menu
))
3195 ;;; Saving functions.
3197 (defun gnus-article-save (save-buffer file
&optional num
)
3198 "Save the currently selected article."
3199 (unless gnus-save-all-headers
3200 ;; Remove headers according to `gnus-saved-headers'.
3201 (let ((gnus-visible-headers
3202 (or gnus-saved-headers gnus-visible-headers
))
3203 (gnus-article-buffer save-buffer
))
3205 (set-buffer save-buffer
)
3206 (article-hide-headers 1 t
))))
3207 (save-window-excursion
3208 (if (not gnus-default-article-saver
)
3209 (error "No default saver is defined")
3210 ;; !!! Magic! The saving functions all save
3211 ;; `gnus-save-article-buffer' (or so they think), but we
3212 ;; bind that variable to our save-buffer.
3213 (set-buffer gnus-article-buffer
)
3214 (let* ((gnus-save-article-buffer save-buffer
)
3217 ((not gnus-prompt-before-saving
) 'default
)
3218 ((eq gnus-prompt-before-saving
'always
) nil
)
3220 (gnus-number-of-articles-to-be-saved
3221 (when (eq gnus-prompt-before-saving t
)
3223 (set-buffer gnus-article-current-summary
)
3224 (funcall gnus-default-article-saver filename
)))))
3226 (defun gnus-read-save-file-name (prompt &optional filename
3227 function group headers variable
)
3229 (funcall function group headers
(symbol-value variable
)))
3234 ((eq filename
'default
)
3240 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3243 (if (and gnus-number-of-articles-to-be-saved
3244 (> gnus-number-of-articles-to-be-saved
1))
3245 (format "these %d articles"
3246 gnus-number-of-articles-to-be-saved
)
3249 ;; Let the split methods have their say.
3251 ;; No split name was found.
3254 (concat prompt
" (default "
3255 (file-name-nondirectory default-name
) ") ")
3256 (file-name-directory default-name
)
3258 ;; A single group name is returned.
3259 ((stringp split-name
)
3261 (funcall function split-name headers
3262 (symbol-value variable
)))
3264 (concat prompt
" (default "
3265 (file-name-nondirectory default-name
) ") ")
3266 (file-name-directory default-name
)
3268 ;; A single split name was found
3269 ((= 1 (length split-name
))
3270 (let* ((name (expand-file-name
3272 gnus-article-save-directory
))
3273 (dir (cond ((file-directory-p name
)
3274 (file-name-as-directory name
))
3275 ((file-exists-p name
) name
)
3276 (t gnus-article-save-directory
))))
3278 (concat prompt
" (default " name
") ")
3280 ;; A list of splits was found.
3282 (setq split-name
(nreverse split-name
))
3284 (let ((file-name-history
3285 (nconc split-name file-name-history
)))
3289 (concat prompt
" (`M-p' for defaults) ")
3290 gnus-article-save-directory
3292 gnus-article-save-directory
)))
3293 (car (push result file-name-history
)))))))
3294 ;; Create the directory.
3295 (gnus-make-directory (file-name-directory file
))
3296 ;; If we have read a directory, we append the default file name.
3297 (when (file-directory-p file
)
3298 (setq file
(expand-file-name (file-name-nondirectory
3300 (file-name-as-directory file
))))
3301 ;; Possibly translate some characters.
3302 (nnheader-translate-file-chars file
))))))
3303 (gnus-make-directory (file-name-directory result
))
3304 (set variable result
)))
3306 (defun gnus-article-archive-name (group)
3307 "Return the first instance of an \"Archive-name\" in the current buffer."
3308 (let ((case-fold-search t
))
3309 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3310 (nnheader-concat gnus-article-save-directory
3311 (match-string 1)))))
3313 (defun gnus-article-nndoc-name (group)
3314 "If GROUP is an nndoc group, return the name of the parent group."
3315 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3316 (gnus-group-get-parameter group
'save-article-group
)))
3318 (defun gnus-summary-save-in-rmail (&optional filename
)
3319 "Append this article to Rmail file.
3320 Optional argument FILENAME specifies file name.
3321 Directory to save to is default to `gnus-article-save-directory'."
3322 (setq filename
(gnus-read-save-file-name
3323 "Save %s in rmail file:" filename
3324 gnus-rmail-save-name gnus-newsgroup-name
3325 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3326 (gnus-eval-in-buffer-window gnus-save-article-buffer
3330 (gnus-output-to-rmail filename
))))
3333 (defun gnus-summary-save-in-mail (&optional filename
)
3334 "Append this article to Unix mail file.
3335 Optional argument FILENAME specifies file name.
3336 Directory to save to is default to `gnus-article-save-directory'."
3337 (setq filename
(gnus-read-save-file-name
3338 "Save %s in Unix mail file:" filename
3339 gnus-mail-save-name gnus-newsgroup-name
3340 gnus-current-headers
'gnus-newsgroup-last-mail
))
3341 (gnus-eval-in-buffer-window gnus-save-article-buffer
3345 (if (and (file-readable-p filename
)
3346 (file-regular-p filename
)
3347 (mail-file-babyl-p filename
))
3348 (rmail-output-to-rmail-file filename t
)
3349 (gnus-output-to-mail filename
)))))
3352 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3353 "Append this article to file.
3354 Optional argument FILENAME specifies file name.
3355 Directory to save to is default to `gnus-article-save-directory'."
3356 (setq filename
(gnus-read-save-file-name
3357 "Save %s in file:" filename
3358 gnus-file-save-name gnus-newsgroup-name
3359 gnus-current-headers
'gnus-newsgroup-last-file
))
3360 (gnus-eval-in-buffer-window gnus-save-article-buffer
3364 (when (and overwrite
3365 (file-exists-p filename
))
3366 (delete-file filename
))
3367 (gnus-output-to-file filename
))))
3370 (defun gnus-summary-write-to-file (&optional filename
)
3371 "Write this article to a file, overwriting it if the file exists.
3372 Optional argument FILENAME specifies file name.
3373 The directory to save in defaults to `gnus-article-save-directory'."
3374 (gnus-summary-save-in-file nil t
))
3376 (defun gnus-summary-save-body-in-file (&optional filename
)
3377 "Append this article body to a file.
3378 Optional argument FILENAME specifies file name.
3379 The directory to save in defaults to `gnus-article-save-directory'."
3380 (setq filename
(gnus-read-save-file-name
3381 "Save %s body in file:" filename
3382 gnus-file-save-name gnus-newsgroup-name
3383 gnus-current-headers
'gnus-newsgroup-last-file
))
3384 (gnus-eval-in-buffer-window gnus-save-article-buffer
3388 (when (article-goto-body)
3389 (narrow-to-region (point) (point-max)))
3390 (gnus-output-to-file filename
))))
3393 (defun gnus-summary-save-in-pipe (&optional command
)
3394 "Pipe this article to subprocess."
3396 (cond ((and (eq command
'default
)
3397 gnus-last-shell-command
)
3398 gnus-last-shell-command
)
3403 "Shell command on %s: "
3404 (if (and gnus-number-of-articles-to-be-saved
3405 (> gnus-number-of-articles-to-be-saved
1))
3406 (format "these %d articles"
3407 gnus-number-of-articles-to-be-saved
)
3409 gnus-last-shell-command
))))
3410 (when (string-equal command
"")
3411 (if gnus-last-shell-command
3412 (setq command gnus-last-shell-command
)
3413 (error "A command is required")))
3414 (gnus-eval-in-buffer-window gnus-article-buffer
3417 (shell-command-on-region (point-min) (point-max) command nil
)))
3418 (setq gnus-last-shell-command command
))
3420 (defmacro gnus-read-string
(prompt &optional initial-contents history
3422 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3423 (if (and (featurep 'xemacs
)
3424 (< emacs-minor-version
2))
3425 `(read-string ,prompt
,initial-contents
,history
)
3426 `(read-string ,prompt
,initial-contents
,history
,default-value
)))
3428 (defun gnus-summary-pipe-to-muttprint (&optional command
)
3429 "Pipe this article to muttprint."
3430 (setq command
(gnus-read-string
3431 "Print using command: " gnus-summary-muttprint-program
3432 nil gnus-summary-muttprint-program
))
3433 (gnus-summary-save-in-pipe command
))
3435 ;;; Article file names when saving.
3437 (defun gnus-capitalize-newsgroup (newsgroup)
3438 "Capitalize NEWSGROUP name."
3439 (when (not (zerop (length newsgroup
)))
3440 (concat (char-to-string (upcase (aref newsgroup
0)))
3441 (substring newsgroup
1))))
3443 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
3444 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3445 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3446 Otherwise, it is like ~/News/news/group/num."
3449 (concat (if (gnus-use-long-file-name 'not-save
)
3450 (gnus-capitalize-newsgroup newsgroup
)
3451 (gnus-newsgroup-directory-form newsgroup
))
3452 "/" (int-to-string (mail-header-number headers
)))
3453 gnus-article-save-directory
)))
3455 (string-equal (file-name-directory default
)
3456 (file-name-directory last-file
))
3457 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3459 (or last-file default
))))
3461 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
3462 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3463 If variable `gnus-use-long-file-name' is non-nil, it is
3464 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3467 (concat (if (gnus-use-long-file-name 'not-save
)
3469 (gnus-newsgroup-directory-form newsgroup
))
3470 "/" (int-to-string (mail-header-number headers
)))
3471 gnus-article-save-directory
)))
3473 (string-equal (file-name-directory default
)
3474 (file-name-directory last-file
))
3475 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3477 (or last-file default
))))
3479 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
3480 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3481 If variable `gnus-use-long-file-name' is non-nil, it is
3482 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3485 (if (gnus-use-long-file-name 'not-save
)
3488 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
3490 gnus-article-save-directory
)))
3492 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
3493 "Generate file name from sender."
3494 (let ((from (mail-header-from headers
)))
3496 (if (and from
(string-match "\\([^ <]+\\)@" from
))
3497 (match-string 1 from
)
3499 gnus-article-save-directory
)))
3501 (defun article-verify-x-pgp-sig ()
3504 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3505 (let ((sig (with-current-buffer gnus-original-article-buffer
3506 (gnus-fetch-field "X-PGP-Sig")))
3510 (mml2015-clear-verify-function))
3512 (insert-buffer-substring gnus-original-article-buffer
)
3513 (setq items
(split-string sig
))
3514 (message-narrow-to-head)
3515 (let ((inhibit-point-motion-hooks t
)
3516 (case-fold-search t
))
3517 ;; Don't verify multiple headers.
3518 (setq headers
(mapconcat (lambda (header)
3520 (mail-fetch-field header
)
3522 (split-string (nth 1 items
) ",") "")))
3523 (delete-region (point-min) (point-max))
3524 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3525 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
3530 (if (looking-at "^-")
3533 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3534 (insert "Version: " (car items
) "\n\n")
3535 (insert (mapconcat 'identity
(cddr items
) "\n"))
3536 (insert "\n-----END PGP SIGNATURE-----\n")
3537 (let ((mm-security-handle (list (format "multipart/signed"))))
3538 (mml2015-clean-buffer)
3539 (let ((coding-system-for-write (or gnus-newsgroup-charset
3541 (funcall (mml2015-clear-verify-function)))
3543 (or (mm-handle-multipart-ctl-parameter
3544 mm-security-handle
'gnus-details
)
3545 (mm-handle-multipart-ctl-parameter
3546 mm-security-handle
'gnus-info
)))))
3548 (let ((inhibit-read-only t
) bface eface
)
3550 (message-narrow-to-head)
3551 (goto-char (point-max))
3553 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
3554 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
))
3555 (message-remove-header "X-Gnus-PGP-Verify")
3556 (if (re-search-forward "^X-PGP-Sig:" nil t
)
3558 (goto-char (point-max)))
3559 (narrow-to-region (point) (point))
3560 (insert "X-Gnus-PGP-Verify: " info
"\n")
3561 (goto-char (point-min))
3564 (if (not (looking-at "^[ \t]"))
3568 (goto-char (point-min))
3569 (when (looking-at "\\([^:]+\\): *")
3570 (put-text-property (match-beginning 1) (1+ (match-end 1))
3572 (put-text-property (match-end 0) (point-max)
3573 'face eface
)))))))))
3575 (defun article-verify-cancel-lock ()
3576 "Verify Cancel-Lock header."
3578 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3579 (canlock-verify gnus-original-article-buffer
)))
3586 (setq afunc
(car func
)
3589 gfunc
(intern (format "gnus-%s" func
))))
3591 (when (fboundp afunc
)
3592 `(lambda (&optional interactive
&rest args
)
3593 ,(documentation afunc t
)
3594 (interactive (list t
))
3596 (set-buffer gnus-article-buffer
)
3598 (call-interactively ',afunc
)
3599 (apply ',afunc args
))))))))
3600 '(article-hide-headers
3601 article-verify-x-pgp-sig
3602 article-verify-cancel-lock
3603 article-hide-boring-headers
3604 article-treat-overstrike
3605 article-fill-long-lines
3606 article-capitalize-sentences
3608 article-remove-leading-whitespace
3609 article-display-x-face
3610 article-display-face
3611 article-de-quoted-unreadable
3612 article-de-base64-unreadable
3615 article-unsplit-urls
3616 article-hide-list-identifiers
3617 article-strip-banner
3620 article-hide-signature
3621 article-strip-headers-in-body
3622 article-remove-trailing-blank-lines
3623 article-strip-leading-blank-lines
3624 article-strip-multiple-blank-lines
3625 article-strip-leading-space
3626 article-strip-trailing-space
3627 article-strip-blank-lines
3628 article-strip-all-blank-lines
3630 article-date-english
3631 article-date-iso8601
3632 article-date-original
3634 article-decode-mime-words
3635 article-decode-charset
3636 article-decode-encoded-words
3640 article-treat-dumbquotes
3641 article-normalize-headers
3642 ;; (article-show-all . gnus-article-show-all-headers)
3646 ;;; Gnus article mode
3649 (put 'gnus-article-mode
'mode-class
'special
)
3651 (set-keymap-parent gnus-article-mode-map widget-keymap
)
3653 (gnus-define-keys gnus-article-mode-map
3654 " " gnus-article-goto-next-page
3655 "\177" gnus-article-goto-prev-page
3656 [delete] gnus-article-goto-prev-page
3657 [backspace] gnus-article-goto-prev-page
3658 "\C-c^" gnus-article-refer-article
3659 "h" gnus-article-show-summary
3660 "s" gnus-article-show-summary
3661 "\C-c\C-m" gnus-article-mail
3662 "?" gnus-article-describe-briefly
3663 "e" gnus-summary-edit-article
3664 "<" beginning-of-buffer
3666 "\C-c\C-i" gnus-info-find-node
3668 "R" gnus-article-reply-with-original
3669 "F" gnus-article-followup-with-original
3670 "\C-hk" gnus-article-describe-key
3671 "\C-hc" gnus-article-describe-key-briefly
3673 "\C-d" gnus-article-read-summary-keys
3674 "\M-*" gnus-article-read-summary-keys
3675 "\M-#" gnus-article-read-summary-keys
3676 "\M-^" gnus-article-read-summary-keys
3677 "\M-g" gnus-article-read-summary-keys)
3679 (substitute-key-definition
3680 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3682 (defun gnus-article-make-menu-bar ()
3683 (unless (boundp 'gnus-article-commands-menu)
3684 (gnus-summary-make-menu-bar))
3685 (gnus-turn-off-edit-menu 'article)
3686 (unless (boundp 'gnus-article-article-menu)
3688 gnus-article-article-menu gnus-article-mode-map ""
3690 ["Scroll forwards" gnus-article-goto-next-page t]
3691 ["Scroll backwards" gnus-article-goto-prev-page t]
3692 ["Show summary" gnus-article-show-summary t]
3693 ["Fetch Message-ID at point" gnus-article-refer-article t]
3694 ["Mail to address at point" gnus-article-mail t]
3695 ["Send a bug report" gnus-bug t]))
3698 gnus-article-treatment-menu gnus-article-mode-map ""
3699 ;; Fixme: this should use :active (and maybe :visible).
3701 ["Hide headers" gnus-article-hide-headers t]
3702 ["Hide signature" gnus-article-hide-signature t]
3703 ["Hide citation" gnus-article-hide-citation t]
3704 ["Treat overstrike" gnus-article-treat-overstrike t]
3705 ["Remove carriage return" gnus-article-remove-cr t]
3706 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3707 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3708 ["Remove base64" gnus-article-de-base64-unreadable t]
3709 ["Treat html" gnus-article-wash-html t]
3710 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3711 ["Decode HZ" gnus-article-decode-HZ t]))
3713 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3715 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3717 (gnus-run-hooks 'gnus-article-menu-hook)))
3719 (defun gnus-article-mode ()
3720 "Major mode for displaying an article.
3722 All normal editing commands are switched off.
3724 The following commands are available in addition to all summary mode
3726 \\<gnus-article-mode-map>
3727 \\[gnus-article-next-page]\t Scroll the article one page forwards
3728 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3729 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3730 \\[gnus-article-show-summary]\t Display the summary buffer
3731 \\[gnus-article-mail]\t Send a reply to the address near point
3732 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3733 \\[gnus-info-find-node]\t Go to the Gnus info node"
3735 (kill-all-local-variables)
3736 (gnus-simplify-mode-line)
3737 (setq mode-name "Article")
3738 (setq major-mode 'gnus-article-mode)
3739 (make-local-variable 'minor-mode-alist)
3740 (use-local-map gnus-article-mode-map)
3741 (when (gnus-visual-p 'article-menu 'menu)
3742 (gnus-article-make-menu-bar)
3743 (when gnus-summary-tool-bar-map
3744 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3745 (gnus-update-format-specifications nil 'article-mode)
3746 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3747 (set (make-local-variable 'gnus-page-broken) nil)
3748 (make-local-variable 'gnus-button-marker-list)
3749 (make-local-variable 'gnus-article-current-summary)
3750 (make-local-variable 'gnus-article-mime-handles)
3751 (make-local-variable 'gnus-article-decoded-p)
3752 (make-local-variable 'gnus-article-mime-handle-alist)
3753 (make-local-variable 'gnus-article-wash-types)
3754 (make-local-variable 'gnus-article-image-alist)
3755 (make-local-variable 'gnus-article-charset)
3756 (make-local-variable 'gnus-article-ignored-charsets)
3757 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3758 (set (make-local-variable 'nobreak-char-display) nil)
3759 (gnus-set-default-directory)
3760 (buffer-disable-undo)
3761 (setq buffer-read-only t)
3762 (set-syntax-table gnus-article-mode-syntax-table)
3763 (mm-enable-multibyte)
3764 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3766 (defun gnus-article-setup-buffer ()
3767 "Initialize the article buffer."
3768 (let* ((name (if gnus-single-article-buffer "*Article*"
3769 (concat "*Article " gnus-newsgroup-name "*")))
3771 (progn (string-match "\\*Article" name)
3772 (concat " *Original Article"
3773 (substring name (match-end 0))))))
3774 (setq gnus-article-buffer name)
3775 (setq gnus-original-article-buffer original)
3776 (setq gnus-article-mime-handle-alist nil)
3777 ;; This might be a variable local to the summary buffer.
3778 (unless gnus-single-article-buffer
3780 (set-buffer gnus-summary-buffer)
3781 (setq gnus-article-buffer name)
3782 (setq gnus-original-article-buffer original)
3783 (gnus-set-global-variables)))
3784 (gnus-article-setup-highlight-words)
3785 ;; Init original article buffer.
3787 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3788 (mm-enable-multibyte)
3789 (setq major-mode 'gnus-original-article-mode)
3790 (make-local-variable 'gnus-original-article))
3791 (if (and (get-buffer name)
3792 (with-current-buffer name
3793 (if gnus-article-edit-mode
3794 (if (y-or-n-p "Article mode edit in progress; discard? ")
3796 (set-buffer-modified-p nil)
3797 (gnus-kill-buffer name)
3800 (error "Action aborted"))
3804 (set (make-local-variable 'gnus-article-edit-mode) nil)
3805 (when gnus-article-mime-handles
3806 (mm-destroy-parts gnus-article-mime-handles)
3807 (setq gnus-article-mime-handles nil))
3808 ;; Set it to nil in article-buffer!
3809 (setq gnus-article-mime-handle-alist nil)
3810 (buffer-disable-undo)
3811 (setq buffer-read-only t)
3812 ;; This list just keeps growing if we don't reset it.
3813 (setq gnus-button-marker-list nil)
3814 (unless (eq major-mode 'gnus-article-mode)
3815 (gnus-article-mode))
3818 (set-buffer (gnus-get-buffer-create name))
3820 (make-local-variable 'gnus-summary-buffer)
3821 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3822 (current-buffer)))))
3824 ;; Set article window start at LINE, where LINE is the number of lines
3825 ;; from the head of the article.
3826 (defun gnus-article-set-window-start (&optional line)
3828 (gnus-get-buffer-window gnus-article-buffer t)
3830 (set-buffer gnus-article-buffer)
3831 (goto-char (point-min))
3834 (gnus-message 6 "Moved to bookmark")
3835 (search-forward "\n\n" nil t)
3839 (defun gnus-article-prepare (article &optional all-headers header)
3840 "Prepare ARTICLE in article mode buffer.
3841 ARTICLE should either be an article number or a Message-ID.
3842 If ARTICLE is an id, HEADER should be the article headers.
3843 If ALL-HEADERS is non-nil, no headers are hidden."
3845 ;; Make sure we start in a summary buffer.
3846 (unless (eq major-mode 'gnus-summary-mode)
3847 (set-buffer gnus-summary-buffer))
3848 (setq gnus-summary-buffer (current-buffer))
3849 (let* ((gnus-article (if header (mail-header-number header) article))
3850 (summary-buffer (current-buffer))
3851 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3852 (group gnus-newsgroup-name)
3855 (gnus-article-setup-buffer)
3856 (set-buffer gnus-article-buffer)
3857 ;; Deactivate active regions.
3858 (when (and (boundp 'transient-mark-mode)
3859 transient-mark-mode)
3860 (setq mark-active nil))
3861 (if (not (setq result (let ((inhibit-read-only t))
3862 (gnus-request-article-this-buffer
3864 ;; There is no such article.
3866 (when (and (numberp article)
3867 (not (memq article gnus-newsgroup-sparse)))
3868 (setq gnus-article-current
3869 (cons gnus-newsgroup-name article))
3870 (set-buffer gnus-summary-buffer)
3871 (setq gnus-current-article article)
3872 (if (and (memq article gnus-newsgroup-undownloaded)
3873 (not (gnus-online (gnus-find-method-for-group
3874 gnus-newsgroup-name))))
3876 (gnus-summary-set-agent-mark article)
3877 (message "Message marked for downloading"))
3878 (gnus-summary-mark-article article gnus-canceled-mark)
3879 (unless (memq article gnus-newsgroup-sparse)
3880 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3881 (if (or (eq result 'pseudo)
3882 (eq result 'nneething))
3885 (set-buffer summary-buffer)
3886 (push article gnus-newsgroup-history)
3887 (setq gnus-last-article gnus-current-article
3888 gnus-current-article 0
3889 gnus-current-headers nil
3890 gnus-article-current nil)
3891 (if (eq result 'nneething)
3892 (gnus-configure-windows 'summary)
3893 (gnus-configure-windows 'article))
3894 (gnus-set-global-variables))
3895 (let ((gnus-article-mime-handle-alist-1
3896 gnus-article-mime-handle-alist))
3897 (gnus-set-mode-line 'article)))
3898 ;; The result from the `request' was an actual article -
3899 ;; or at least some text that is now displayed in the
3901 (when (and (numberp article)
3902 (not (eq article gnus-current-article)))
3903 ;; Seems like a new article has been selected.
3904 ;; `gnus-current-article' must be an article number.
3906 (set-buffer summary-buffer)
3907 (push article gnus-newsgroup-history)
3908 (setq gnus-last-article gnus-current-article
3909 gnus-current-article article
3910 gnus-current-headers
3911 (gnus-summary-article-header gnus-current-article)
3912 gnus-article-current
3913 (cons gnus-newsgroup-name gnus-current-article))
3914 (unless (vectorp gnus-current-headers)
3915 (setq gnus-current-headers nil))
3916 (gnus-summary-goto-subject gnus-current-article)
3917 (when (gnus-summary-show-thread)
3918 ;; If the summary buffer really was folded, the
3919 ;; previous goto may not actually have gone to
3920 ;; the right article, but the thread root instead.
3922 (gnus-summary-goto-subject gnus-current-article))
3923 (gnus-run-hooks 'gnus-mark-article-hook)
3924 (gnus-set-mode-line 'summary)
3925 (when (gnus-visual-p 'article-highlight 'highlight)
3926 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3927 ;; Set the global newsgroup variables here.
3928 (gnus-set-global-variables)
3929 (setq gnus-have-all-headers
3930 (or all-headers gnus-show-all-headers))))
3932 (gnus-configure-windows 'article))
3933 (when (or (numberp article)
3935 (gnus-article-prepare-display)
3937 (goto-char (point-min))
3938 (when gnus-break-pages
3939 (gnus-narrow-to-page)))
3940 (let ((gnus-article-mime-handle-alist-1
3941 gnus-article-mime-handle-alist))
3942 (gnus-set-mode-line 'article))
3946 (set-window-point (get-buffer-window (current-buffer)) (point))
3947 (gnus-configure-windows 'article)
3951 (defun gnus-article-prepare-display ()
3952 "Make the current buffer look like a nice article."
3953 ;; Hooks for getting information from the article.
3954 ;; This hook must be called before being narrowed.
3955 (let ((gnus-article-buffer (current-buffer))
3957 (inhibit-read-only t))
3958 (unless (eq major-mode 'gnus-article-mode)
3959 (gnus-article-mode))
3960 (setq buffer-read-only nil
3961 gnus-article-wash-types nil
3962 gnus-article-image-alist nil)
3963 (gnus-run-hooks 'gnus-tmp-internal-hook)
3964 (when gnus-display-mime-function
3965 (funcall gnus-display-mime-function))
3966 (gnus-run-hooks 'gnus-article-prepare-hook)))
3969 ;;; Gnus MIME viewing functions
3972 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3973 "Format of the MIME buttons.
3975 Valid specifiers include:
3977 %T MIME type, along with additional info
3978 %n The `name' parameter
3979 %d The description, if any
3980 %l The length of the encoded part
3981 %p The part identifier number
3982 %e Dots if the part isn't displayed
3984 General format specifiers can also be used. See Info node
3985 `(gnus)Formatting Variables'.")
3987 (defvar gnus-mime-button-line-format-alist
3988 '((?t gnus-tmp-type ?s)
3989 (?T gnus-tmp-type-long ?s)
3990 (?n gnus-tmp-name ?s)
3991 (?d gnus-tmp-description ?s)
3993 (?l gnus-tmp-length ?d)
3994 (?e gnus-tmp-dots ?s)))
3996 (defvar gnus-mime-button-commands
3997 '((gnus-article-press-button "\r" "Toggle Display")
3998 (gnus-mime-view-part "v" "View Interactively...")
3999 (gnus-mime-view-part-as-type "t" "View As Type...")
4000 (gnus-mime-view-part-as-charset "C" "View As charset...")
4001 (gnus-mime-save-part "o" "Save...")
4002 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4003 (gnus-mime-delete-part "d" "Delete part")
4004 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4005 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4006 (gnus-mime-view-part-internally "E" "View Internally")
4007 (gnus-mime-view-part-externally "e" "View Externally")
4008 (gnus-mime-print-part "p" "Print")
4009 (gnus-mime-pipe-part "|" "Pipe To Command...")
4010 (gnus-mime-action-on-part "." "Take action on the part...")))
4012 (defun gnus-article-mime-part-status ()
4013 (if gnus-article-mime-handle-alist-1
4014 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4016 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4019 (defvar gnus-mime-button-map
4020 (let ((map (make-sparse-keymap)))
4021 (unless (>= (string-to-number emacs-version) 21)
4022 ;; XEmacs doesn't care.
4023 (set-keymap-parent map gnus-article-mode-map))
4024 (define-key map gnus-mouse-2 'gnus-article-push-button)
4025 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4026 (dolist (c gnus-mime-button-commands)
4027 (define-key map (cadr c) (car c)))
4031 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4033 ,@(mapcar (lambda (c)
4034 (vector (caddr c) (car c) :enable t))
4035 gnus-mime-button-commands)))
4038 (define-compiler-macro popup-menu (&whole form
4039 menu &optional position prefix)
4040 (if (and (fboundp 'popup-menu)
4041 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4043 ;; Gnus is probably running under Emacs 20.
4044 `(let* ((menu (cdr ,menu))
4045 (response (x-popup-menu
4047 (cons "" (mapcar (lambda (c)
4048 (cons (caddr c) (car c)))
4051 (call-interactively (nth 3 (assq response menu))))))))
4053 (defun gnus-mime-button-menu (event prefix)
4054 "Construct a context-sensitive menu of MIME commands."
4055 (interactive "e\nP")
4056 (save-window-excursion
4057 (let ((pos (event-start event)))
4058 (select-window (posn-window pos))
4059 (goto-char (posn-point pos))
4060 (gnus-article-check-buffer)
4061 (popup-menu gnus-mime-button-menu nil prefix))))
4063 (defun gnus-mime-view-all-parts (&optional handles)
4064 "View all the MIME parts."
4066 (save-current-buffer
4067 (set-buffer gnus-article-buffer)
4068 (let ((handles (or handles gnus-article-mime-handles))
4069 (mail-parse-charset gnus-newsgroup-charset)
4070 (mail-parse-ignored-charsets
4071 (with-current-buffer gnus-summary-buffer
4072 gnus-newsgroup-ignored-charsets)))
4074 (mm-remove-parts handles)
4075 (goto-char (point-min))
4076 (or (search-forward "\n\n") (goto-char (point-max)))
4077 (let ((inhibit-read-only t))
4078 (delete-region (point) (point-max))
4079 (mm-display-parts handles))))))
4081 (defun gnus-mime-save-part-and-strip ()
4082 "Save the MIME part under point then replace it with an external body."
4084 (gnus-article-check-buffer)
4085 (when (gnus-group-read-only-p)
4086 (error "The current group does not support deleting of parts"))
4087 (when (mm-complicated-handles gnus-article-mime-handles)
4089 The current article has a complicated MIME structure, giving up..."))
4090 (when (gnus-yes-or-no-p "\
4091 Deleting parts may malfunction or destroy the article; continue? ")
4092 (let* ((data (get-text-property (point) 'gnus-data))
4094 (handles gnus-article-mime-handles))
4095 (setq file (and data (mm-save-part data)))
4097 (with-current-buffer (mm-handle-buffer data)
4099 (insert "Content-Type: " (mm-handle-media-type data))
4100 (mml-insert-parameter-string (cdr (mm-handle-type data))
4103 (insert "Content-ID: " (message-make-message-id) "\n")
4104 (insert "Content-Transfer-Encoding: binary\n")
4107 (cdr (mm-make-handle nil
4108 `("message/external-body"
4109 (access-type . "LOCAL-FILE")
4111 (set-buffer gnus-summary-buffer)
4112 (gnus-article-edit-article
4115 (let ((mail-parse-charset (or gnus-article-charset
4116 ',gnus-newsgroup-charset))
4117 (mail-parse-ignored-charsets
4118 (or gnus-article-ignored-charsets
4119 ',gnus-newsgroup-ignored-charsets))
4120 (mbl mml-buffer-list))
4121 (setq mml-buffer-list nil)
4122 (insert-buffer gnus-original-article-buffer)
4123 (mime-to-mml ',handles)
4124 (setq gnus-article-mime-handles nil)
4125 (let ((mbl1 mml-buffer-list))
4126 (setq mml-buffer-list mbl)
4127 (set (make-local-variable 'mml-buffer-list) mbl1))
4128 (gnus-make-local-hook 'kill-buffer-hook)
4129 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4130 `(lambda (no-highlight)
4131 (let ((mail-parse-charset (or gnus-article-charset
4132 ',gnus-newsgroup-charset))
4133 (message-options message-options)
4134 (message-options-set-recipient)
4135 (mail-parse-ignored-charsets
4136 (or gnus-article-ignored-charsets
4137 ',gnus-newsgroup-ignored-charsets)))
4139 (mml-destroy-buffers)
4140 (remove-hook 'kill-buffer-hook
4141 'mml-destroy-buffers t)
4142 (kill-local-variable 'mml-buffer-list))
4143 (gnus-summary-edit-article-done
4144 ,(or (mail-header-references gnus-current-headers) "")
4145 ,(gnus-group-read-only-p)
4146 ,gnus-summary-buffer no-highlight)))))))
4148 (defun gnus-mime-delete-part ()
4149 "Delete the MIME part under point.
4150 Replace it with some information about the removed part."
4152 (gnus-article-check-buffer)
4153 (when (gnus-group-read-only-p)
4154 (error "The current group does not support deleting of parts"))
4155 (when (mm-complicated-handles gnus-article-mime-handles)
4157 The current article has a complicated MIME structure, giving up..."))
4158 (when (gnus-yes-or-no-p "\
4159 Deleting parts may malfunction or destroy the article; continue? ")
4160 (let* ((data (get-text-property (point) 'gnus-data))
4161 (handles gnus-article-mime-handles)
4165 (mail-decode-encoded-word-string (or (mm-handle-description data)
4168 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4170 (type (mm-handle-media-type data)))
4172 (error "No MIME part under point"))
4173 (with-current-buffer (mm-handle-buffer data)
4174 (let ((bsize (format "%s" (buffer-size))))
4179 "| The following attachment has been deleted:\n"
4181 "| Type: " type "\n"
4182 "| Filename: " filename "\n"
4183 "| Size (encoded): " bsize " Byte\n"
4184 "| Description: " description "\n"
4187 (cdr (mm-make-handle
4188 nil `("text/plain") nil nil
4190 (format "Deleted attachment (%s bytes)" bsize))))))
4191 (set-buffer gnus-summary-buffer)
4192 ;; FIXME: maybe some of the following code (borrowed from
4193 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4194 (gnus-article-edit-article
4197 (let ((mail-parse-charset (or gnus-article-charset
4198 ',gnus-newsgroup-charset))
4199 (mail-parse-ignored-charsets
4200 (or gnus-article-ignored-charsets
4201 ',gnus-newsgroup-ignored-charsets))
4202 (mbl mml-buffer-list))
4203 (setq mml-buffer-list nil)
4204 (insert-buffer gnus-original-article-buffer)
4205 (mime-to-mml ',handles)
4206 (setq gnus-article-mime-handles nil)
4207 (let ((mbl1 mml-buffer-list))
4208 (setq mml-buffer-list mbl)
4209 (set (make-local-variable 'mml-buffer-list) mbl1))
4210 (gnus-make-local-hook 'kill-buffer-hook)
4211 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4212 `(lambda (no-highlight)
4213 (let ((mail-parse-charset (or gnus-article-charset
4214 ',gnus-newsgroup-charset))
4215 (message-options message-options)
4216 (message-options-set-recipient)
4217 (mail-parse-ignored-charsets
4218 (or gnus-article-ignored-charsets
4219 ',gnus-newsgroup-ignored-charsets)))
4221 (mml-destroy-buffers)
4222 (remove-hook 'kill-buffer-hook
4223 'mml-destroy-buffers t)
4224 (kill-local-variable 'mml-buffer-list))
4225 (gnus-summary-edit-article-done
4226 ,(or (mail-header-references gnus-current-headers) "")
4227 ,(gnus-group-read-only-p)
4228 ,gnus-summary-buffer no-highlight)))))
4229 ;; Not in `gnus-mime-save-part-and-strip':
4230 (gnus-article-edit-done)
4231 (gnus-summary-expand-window)
4232 (gnus-summary-show-article))
4234 (defun gnus-mime-save-part ()
4235 "Save the MIME part under point."
4237 (gnus-article-check-buffer)
4238 (let ((data (get-text-property (point) 'gnus-data)))
4240 (mm-save-part data))))
4242 (defun gnus-mime-pipe-part ()
4243 "Pipe the MIME part under point to a process."
4245 (gnus-article-check-buffer)
4246 (let ((data (get-text-property (point) 'gnus-data)))
4248 (mm-pipe-part data))))
4250 (defun gnus-mime-view-part ()
4251 "Interactively choose a viewing method for the MIME part under point."
4253 (gnus-article-check-buffer)
4254 (let ((data (get-text-property (point) 'gnus-data)))
4256 (setq gnus-article-mime-handles
4258 gnus-article-mime-handles (setq data (copy-sequence data))))
4259 (mm-interactively-view-part data))))
4261 (defun gnus-mime-view-part-as-type-internal ()
4262 (gnus-article-check-buffer)
4263 (let* ((name (mail-content-type-get
4264 (mm-handle-type (get-text-property (point) 'gnus-data))
4266 (def-type (and name (mm-default-file-encoding name))))
4267 (and def-type (cons def-type 0))))
4269 (defun gnus-mime-view-part-as-type (&optional mime-type)
4270 "Choose a MIME media type, and view the part as such."
4273 (setq mime-type (completing-read
4274 "View as MIME type: "
4275 (mapcar #'list (mailcap-mime-types))
4277 (gnus-mime-view-part-as-type-internal))))
4278 (gnus-article-check-buffer)
4279 (let ((handle (get-text-property (point) 'gnus-data)))
4282 (mm-make-handle (mm-handle-buffer handle)
4283 (cons mime-type (cdr (mm-handle-type handle)))
4284 (mm-handle-encoding handle)
4285 (mm-handle-undisplayer handle)
4286 (mm-handle-disposition handle)
4287 (mm-handle-description handle)
4289 (mm-handle-id handle)))
4290 (setq gnus-article-mime-handles
4291 (mm-merge-handles gnus-article-mime-handles handle))
4292 (gnus-mm-display-part handle))))
4295 (require 'jka-compr))
4297 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4298 ;; emacs can do that itself.
4300 (defun gnus-mime-jka-compr-maybe-uncompress ()
4301 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4302 The uncompress method used is derived from `buffer-file-name'."
4303 (when (and (fboundp 'jka-compr-installed-p)
4304 (jka-compr-installed-p))
4305 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4307 (let ((basename (file-name-nondirectory buffer-file-name))
4308 (args (jka-compr-info-uncompress-args info))
4309 (prog (jka-compr-info-uncompress-program info))
4310 (message (jka-compr-info-uncompress-message info))
4311 (err-file (jka-compr-make-temp-name)))
4313 (message "%s %s..." message basename))
4315 (unless (memq (apply 'call-process-region
4316 (point-min) (point-max)
4318 t (list t err-file) nil
4320 jka-compr-acceptable-retval-list)
4321 (jka-compr-error prog args basename message err-file))
4322 (jka-compr-delete-temp-file err-file)))))))
4324 (defun gnus-mime-copy-part (&optional handle)
4325 "Put the MIME part under point into a new buffer.
4326 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4329 (gnus-article-check-buffer)
4330 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4331 (contents (and handle (mm-get-part handle)))
4333 (file-name-nondirectory
4335 (mail-content-type-get (mm-handle-type handle) 'name)
4336 (mail-content-type-get (mm-handle-disposition handle)
4339 (buffer (and base (generate-new-buffer base))))
4341 (switch-to-buffer buffer)
4343 ;; We do it this way to make `normal-mode' set the appropriate mode.
4346 (setq buffer-file-name (expand-file-name base))
4347 (gnus-mime-jka-compr-maybe-uncompress)
4349 (setq buffer-file-name nil))
4350 (goto-char (point-min)))))
4352 (defun gnus-mime-print-part (&optional handle filename)
4353 "Print the MIME part under point."
4354 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4355 (gnus-article-check-buffer)
4356 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4357 (contents (and handle (mm-get-part handle)))
4358 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4359 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4364 (mm-save-part-to-file handle file)
4365 (call-process shell-file-name nil
4366 (generate-new-buffer " *mm*")
4368 shell-command-switch
4370 printer file (mm-handle-type handle))))
4374 (gnus-print-buffer))
4375 (ps-despool filename)))))
4377 (defun gnus-mime-inline-part (&optional handle arg)
4378 "Insert the MIME part under point into the current buffer."
4379 (interactive (list nil current-prefix-arg))
4380 (gnus-article-check-buffer)
4381 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4384 (inhibit-read-only t))
4386 (if (and (not arg) (mm-handle-undisplayer handle))
4387 (mm-remove-part handle)
4388 (setq contents (mm-get-part handle))
4391 (setq charset (or (mail-content-type-get
4392 (mm-handle-type handle) 'charset)
4393 gnus-newsgroup-charset)))
4395 (if (mm-handle-undisplayer handle)
4396 (mm-remove-part handle))
4399 gnus-summary-show-article-charset-alist))
4400 (mm-read-coding-system "Charset: "))))
4402 (if (mm-handle-undisplayer handle)
4403 (mm-remove-part handle))))
4408 (setq charset (mm-charset-to-coding-system
4410 (not (eq charset 'ascii)))
4411 (mm-decode-coding-string contents charset)
4412 (mm-string-to-multibyte contents)))
4415 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4416 "Insert the MIME part under point into the current buffer using the
4418 (interactive (list nil current-prefix-arg))
4419 (gnus-article-check-buffer)
4420 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4423 (inhibit-read-only t))
4425 (if (mm-handle-undisplayer handle)
4426 (mm-remove-part handle))
4427 (let ((gnus-newsgroup-charset
4429 gnus-summary-show-article-charset-alist))
4430 (mm-read-coding-system "Charset: ")))
4431 (gnus-newsgroup-ignored-charsets 'gnus-all))
4432 (gnus-article-press-button)))))
4434 (defun gnus-mime-view-part-externally (&optional handle)
4435 "View the MIME part under point with an external viewer."
4437 (gnus-article-check-buffer)
4438 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4439 (mm-user-display-methods nil)
4440 (mm-inlined-types nil)
4441 (mail-parse-charset gnus-newsgroup-charset)
4442 (mail-parse-ignored-charsets
4443 (save-excursion (set-buffer gnus-summary-buffer)
4444 gnus-newsgroup-ignored-charsets)))
4446 (if (mm-handle-undisplayer handle)
4447 (mm-remove-part handle)
4448 (mm-display-part handle)))))
4450 (defun gnus-mime-view-part-internally (&optional handle)
4451 "View the MIME part under point with an internal viewer.
4452 If no internal viewer is available, use an external viewer."
4454 (gnus-article-check-buffer)
4455 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4456 (mm-inlined-types '(".*"))
4457 (mm-inline-large-images t)
4458 (mail-parse-charset gnus-newsgroup-charset)
4459 (mail-parse-ignored-charsets
4460 (save-excursion (set-buffer gnus-summary-buffer)
4461 gnus-newsgroup-ignored-charsets))
4462 (inhibit-read-only t))
4464 (if (mm-handle-undisplayer handle)
4465 (mm-remove-part handle)
4466 (mm-display-part handle)))))
4468 (defun gnus-mime-action-on-part (&optional action)
4469 "Do something with the MIME attachment at \(point\)."
4471 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4472 (gnus-article-check-buffer)
4473 (let ((action-pair (assoc action gnus-mime-action-alist)))
4475 (funcall (cdr action-pair)))))
4477 (defun gnus-article-part-wrapper (n function)
4478 (save-current-buffer
4479 (set-buffer gnus-article-buffer)
4480 (when (> n (length gnus-article-mime-handle-alist))
4481 (error "No such part"))
4482 (gnus-article-goto-part n)
4483 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4484 (funcall function handle))))
4486 (defun gnus-article-pipe-part (n)
4487 "Pipe MIME part N, which is the numerical prefix."
4489 (gnus-article-part-wrapper n 'mm-pipe-part))
4491 (defun gnus-article-save-part (n)
4492 "Save MIME part N, which is the numerical prefix."
4494 (gnus-article-part-wrapper n 'mm-save-part))
4496 (defun gnus-article-interactively-view-part (n)
4497 "View MIME part N interactively, which is the numerical prefix."
4499 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4501 (defun gnus-article-copy-part (n)
4502 "Copy MIME part N, which is the numerical prefix."
4504 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4506 (defun gnus-article-view-part-as-charset (n)
4507 "View MIME part N using a specified charset.
4508 N is the numerical prefix."
4510 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4512 (defun gnus-article-view-part-externally (n)
4513 "View MIME part N externally, which is the numerical prefix."
4515 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4517 (defun gnus-article-inline-part (n)
4518 "Inline MIME part N, which is the numerical prefix."
4520 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4522 (defun gnus-article-mime-match-handle-first (condition)
4524 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4525 (while (setq ihandle (pop alist))
4527 ((functionp condition)
4528 (funcall condition (cdr ihandle)))
4529 ((eq condition 'undisplayed)
4530 (not (or (mm-handle-undisplayer (cdr ihandle))
4531 (equal (mm-handle-media-type (cdr ihandle))
4532 "multipart/alternative"))))
4533 ((eq condition 'undisplayed-alternative)
4534 (not (mm-handle-undisplayer (cdr ihandle))))
4536 (gnus-article-goto-part (car ihandle))
4537 (or (not n) (< (car ihandle) n)))
4538 (setq n (car ihandle))))
4542 (defun gnus-article-view-part (&optional n)
4543 "View MIME part N, which is the numerical prefix."
4545 (save-current-buffer
4546 (set-buffer gnus-article-buffer)
4547 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4548 gnus-article-mime-match-handle-function)))
4549 (when (> n (length gnus-article-mime-handle-alist))
4550 (error "No such part"))
4551 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4552 (when (gnus-article-goto-part n)
4553 (if (equal (car handle) "multipart/alternative")
4554 (gnus-article-press-button)
4555 (when (eq (gnus-mm-display-part handle) 'internal)
4556 (gnus-set-window-start)))))))
4558 (defsubst gnus-article-mime-total-parts ()
4559 (if (bufferp (car gnus-article-mime-handles))
4561 (1- (length gnus-article-mime-handles))))
4563 (defun gnus-mm-display-part (handle)
4564 "Display HANDLE and fix MIME button."
4565 (let ((id (get-text-property (point) 'gnus-part))
4567 (inhibit-read-only t))
4570 (let ((window (selected-window))
4571 (mail-parse-charset gnus-newsgroup-charset)
4572 (mail-parse-ignored-charsets
4573 (if (gnus-buffer-live-p gnus-summary-buffer)
4575 (set-buffer gnus-summary-buffer)
4576 gnus-newsgroup-ignored-charsets)
4580 (let ((win (gnus-get-buffer-window (current-buffer) t))
4583 (select-window win))
4586 (if (mm-handle-displayed-p handle)
4587 ;; This will remove the part.
4588 (mm-display-part handle)
4590 (narrow-to-region (point)
4591 (if (eobp) (point) (1+ (point))))
4592 (mm-display-part handle)
4593 ;; We narrow to the part itself and
4594 ;; then call the treatment functions.
4595 (goto-char (point-min))
4597 (narrow-to-region (point) (point-max))
4600 (gnus-article-mime-total-parts)
4601 (mm-handle-media-type handle)))))
4602 (if (window-live-p window)
4603 (select-window window)))))
4606 (gnus-insert-mime-button
4607 handle id (list (mm-handle-displayed-p handle)))
4608 (goto-char point))))
4610 (defun gnus-article-goto-part (n)
4611 "Go to MIME part N."
4612 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4614 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4615 (let ((gnus-tmp-name
4616 (or (mail-content-type-get (mm-handle-type handle) 'name)
4617 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4618 (mail-content-type-get (mm-handle-type handle) 'url)
4620 (gnus-tmp-type (mm-handle-media-type handle))
4621 (gnus-tmp-description
4622 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4625 (if (if displayed (car displayed)
4626 (mm-handle-displayed-p handle))
4628 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4630 gnus-tmp-type-long b e)
4631 (when (string-match ".*/" gnus-tmp-name)
4632 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4633 (setq gnus-tmp-type-long (concat gnus-tmp-type
4634 (and (not (equal gnus-tmp-name ""))
4635 (concat "; " gnus-tmp-name))))
4636 (unless (equal gnus-tmp-description "")
4637 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4642 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4643 `(,@(gnus-local-map-property gnus-mime-button-map)
4644 gnus-callback gnus-mm-display-part
4645 gnus-part ,gnus-tmp-id
4646 article-type annotation
4649 ;; Exclude a newline.
4652 (widget-convert-button
4655 :action 'gnus-widget-press-button
4656 :button-keymap gnus-mime-button-map
4658 (lambda (widget/window &optional overlay pos)
4659 ;; Needed to properly clear the message due to a bug in
4660 ;; wid-edit (XEmacs only).
4661 (if (boundp 'help-echo-owns-message)
4662 (setq help-echo-owns-message t))
4664 "%S: %s the MIME part; %S: more options"
4665 (aref gnus-mouse-2 0)
4666 ;; XEmacs will get a single widget arg; Emacs 21 will get
4667 ;; window, overlay, position.
4668 (if (mm-handle-displayed-p
4670 (with-current-buffer (gnus-overlay-buffer overlay)
4671 (widget-get (widget-at (gnus-overlay-start overlay))
4673 (widget-get widget/window :mime-handle)))
4675 (aref gnus-down-mouse-3 0))))))
4677 (defun gnus-widget-press-button (elems el)
4678 (goto-char (widget-get elems :from))
4679 (gnus-article-press-button))
4681 (defvar gnus-displaying-mime nil)
4683 (defun gnus-display-mime (&optional ihandles)
4684 "Display the MIME parts."
4686 (save-selected-window
4687 (let ((window (get-buffer-window gnus-article-buffer))
4690 (select-window window)
4691 ;; We have to do this since selecting the window
4692 ;; may change the point. So we set the window point.
4693 (set-window-point window point)))
4694 (let* ((handles (or ihandles
4695 (mm-dissect-buffer nil gnus-article-loose-mime)
4696 (and gnus-article-emulate-mime
4698 (inhibit-read-only t) handle name type b e display)
4699 (when (and (not ihandles)
4700 (not gnus-displaying-mime))
4701 ;; Top-level call; we clean up.
4702 (when gnus-article-mime-handles
4703 (mm-destroy-parts gnus-article-mime-handles)
4704 (setq gnus-article-mime-handle-alist nil));; A trick.
4705 (setq gnus-article-mime-handles handles)
4706 ;; We allow users to glean info from the handles.
4707 (when gnus-article-mime-part-function
4708 (gnus-mime-part-function handles)))
4710 (or (not (stringp (car handles)))
4713 (when (and (not ihandles)
4714 (not gnus-displaying-mime))
4715 ;; Clean up for mime parts.
4717 (delete-region (point) (point-max)))
4718 (let ((gnus-displaying-mime t))
4719 (gnus-mime-display-part handles)))
4722 (narrow-to-region (point) (point-max))
4723 (gnus-treat-article nil 1 1)
4726 ;; Highlight the headers.
4730 (narrow-to-region (point-min) (point))
4731 (gnus-article-save-original-date
4732 (gnus-treat-article 'head)))))))))
4734 (defcustom gnus-mime-display-multipart-as-mixed nil
4735 "Display \"multipart\" parts as \"multipart/mixed\".
4737 If t, it overrides nil values of
4738 `gnus-mime-display-multipart-alternative-as-mixed' and
4739 `gnus-mime-display-multipart-related-as-mixed'."
4740 :group 'gnus-article-mime
4743 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4744 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4746 :group 'gnus-article-mime
4749 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4750 "Display \"multipart/related\" parts as \"multipart/mixed\".
4752 If displaying \"text/html\" is discouraged \(see
4753 `mm-discouraged-alternatives'\) images or other material inside a
4754 \"multipart/related\" part might be overlooked when this variable is nil."
4756 :group 'gnus-article-mime
4759 (defun gnus-mime-display-part (handle)
4762 ((not (stringp (car handle)))
4763 (gnus-mime-display-single handle))
4764 ;; User-defined multipart
4765 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4766 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4768 ;; multipart/alternative
4769 ((and (equal (car handle) "multipart/alternative")
4770 (not (or gnus-mime-display-multipart-as-mixed
4771 gnus-mime-display-multipart-alternative-as-mixed)))
4772 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4773 (push (cons id handle) gnus-article-mime-handle-alist)
4774 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4775 ;; multipart/related
4776 ((and (equal (car handle) "multipart/related")
4777 (not (or gnus-mime-display-multipart-as-mixed
4778 gnus-mime-display-multipart-related-as-mixed)))
4779 ;;;!!!We should find the start part, but we just default
4780 ;;;!!!to the first part.
4781 ;;(gnus-mime-display-part (cadr handle))
4782 ;;;!!! Most multipart/related is an HTML message plus images.
4783 ;;;!!! Unfortunately we are unable to let W3 display those
4784 ;;;!!! included images, so we just display it as a mixed multipart.
4785 ;;(gnus-mime-display-mixed (cdr handle))
4786 ;;;!!! No, w3 can display everything just fine.
4787 (gnus-mime-display-part (cadr handle)))
4788 ((equal (car handle) "multipart/signed")
4789 (gnus-add-wash-type 'signed)
4790 (gnus-mime-display-security handle))
4791 ((equal (car handle) "multipart/encrypted")
4792 (gnus-add-wash-type 'encrypted)
4793 (gnus-mime-display-security handle))
4794 ;; Other multiparts are handled like multipart/mixed.
4796 (gnus-mime-display-mixed (cdr handle)))))
4798 (defun gnus-mime-part-function (handles)
4799 (if (stringp (car handles))
4800 (mapcar 'gnus-mime-part-function (cdr handles))
4801 (funcall gnus-article-mime-part-function handles)))
4803 (defun gnus-mime-display-mixed (handles)
4804 (mapcar 'gnus-mime-display-part handles))
4806 (defun gnus-mime-display-single (handle)
4807 (let ((type (mm-handle-media-type handle))
4808 (ignored gnus-ignored-mime-types)
4815 (when (string-match (pop ignored) type)
4816 (throw 'ignored nil)))
4817 (if (and (setq not-attachment
4818 (and (not (mm-inline-override-p handle))
4819 (or (not (mm-handle-disposition handle))
4820 (equal (car (mm-handle-disposition handle))
4822 (mm-attachment-override-p handle))))
4823 (mm-automatic-display-p handle)
4825 (mm-inlinable-p handle)
4826 (mm-inlined-p handle))
4827 (mm-automatic-external-display-p type)))
4829 (when (equal (mm-handle-media-supertype handle) "text")
4831 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4833 (push (cons id handle) gnus-article-mime-handle-alist)
4834 (when (or (not display)
4835 (not (gnus-unbuttonized-mime-type-p type)))
4836 ;(gnus-article-insert-newline)
4837 (gnus-insert-mime-button
4838 handle id (list (or display (and not-attachment text))))
4839 (gnus-article-insert-newline)
4840 ;(gnus-article-insert-newline)
4841 ;; Remember modify the number of forward lines.
4849 (let ((mail-parse-charset gnus-newsgroup-charset)
4850 (mail-parse-ignored-charsets
4851 (save-excursion (condition-case ()
4852 (set-buffer gnus-summary-buffer)
4854 gnus-newsgroup-ignored-charsets)))
4855 (mm-display-part handle t))
4856 (goto-char (point-max)))
4857 ((and text not-attachment)
4861 (gnus-article-insert-newline)
4862 (mm-insert-inline handle (mm-get-part handle))
4863 (goto-char (point-max))))
4867 (narrow-to-region beg (point))
4870 (gnus-article-mime-total-parts)
4871 (mm-handle-media-type handle)))))))))
4873 (defun gnus-unbuttonized-mime-type-p (type)
4874 "Say whether TYPE is to be unbuttonized."
4875 (unless gnus-inhibit-mime-unbuttonizing
4877 (let ((types gnus-unbuttonized-mime-types))
4879 (when (string-match (pop types) type)
4880 (throw 'found t)))))
4882 (let ((types gnus-buttonized-mime-types))
4884 (when (string-match (pop types) type)
4885 (throw 'found t)))))))))
4887 (defun gnus-article-insert-newline ()
4888 "Insert a newline, but mark it as undeletable."
4889 (gnus-put-text-property
4890 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4892 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4893 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4896 handle (inhibit-read-only t) from props begend not-pref)
4897 (save-window-excursion
4900 (narrow-to-region (car ibegend)
4903 (goto-char (car ibegend))
4906 (delete-region (point-min) (point-max))
4907 (mm-remove-parts handles))
4908 (setq begend (list (point-marker)))
4910 (unless (setq not-pref (cadr (member preferred ihandles)))
4911 (setq not-pref (car ihandles)))
4914 (not (gnus-unbuttonized-mime-type-p
4915 "multipart/alternative")))
4916 (gnus-add-text-properties
4919 (insert (format "%d. " id))
4923 (unless ,(not ibegend)
4924 (setq gnus-article-mime-handle-alist
4925 ',gnus-article-mime-handle-alist))
4926 (gnus-mime-display-alternative
4927 ',ihandles ',not-pref ',begend ,id))
4928 ,@(gnus-local-map-property gnus-mime-button-map)
4929 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4930 face ,gnus-article-button-face
4933 (widget-convert-button 'link from (point)
4934 :action 'gnus-widget-press-button
4935 :button-keymap gnus-widget-button-keymap)
4937 (while (setq handle (pop handles))
4938 (gnus-add-text-properties
4941 (insert (format "(%c) %-18s"
4942 (if (equal handle preferred) ?* ? )
4943 (mm-handle-media-type handle)))
4947 (unless ,(not ibegend)
4948 (setq gnus-article-mime-handle-alist
4949 ',gnus-article-mime-handle-alist))
4950 (gnus-mime-display-alternative
4951 ',ihandles ',handle ',begend ,id))
4952 ,@(gnus-local-map-property gnus-mime-button-map)
4953 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4954 face ,gnus-article-button-face
4957 (widget-convert-button 'link from (point)
4958 :action 'gnus-widget-press-button
4959 :button-keymap gnus-widget-button-keymap)
4963 (if (stringp (car preferred))
4964 (gnus-display-mime preferred)
4965 (let ((mail-parse-charset gnus-newsgroup-charset)
4966 (mail-parse-ignored-charsets
4967 (save-excursion (set-buffer gnus-summary-buffer)
4968 gnus-newsgroup-ignored-charsets)))
4969 (mm-display-part preferred)
4973 (narrow-to-region (car begend) (point-max))
4975 nil (length gnus-article-mime-handle-alist)
4976 (gnus-article-mime-total-parts)
4977 (mm-handle-media-type handle))))))
4978 (goto-char (point-max))
4979 (setcdr begend (point-marker)))))
4981 (goto-char point))))
4983 (defconst gnus-article-wash-status-strings
4984 (let ((alist '((cite "c" "Possible hidden citation text"
4985 " " "All citation text visible")
4986 (headers "h" "Hidden headers"
4987 " " "All headers visible.")
4988 (pgp "p" "Encrypted or signed message status hidden"
4989 " " "No hidden encryption nor digital signature status")
4990 (signature "s" "Signature has been hidden"
4991 " " "Signature is visible")
4992 (overstrike "o" "Overstrike (^H) characters applied"
4993 " " "No overstrike characters applied")
4994 (emphasis "e" "/*_Emphasis_*/ characters applied"
4995 " " "No /*_emphasis_*/ characters applied")))
4997 (dolist (entry alist result)
4998 (let ((key (nth 0 entry))
4999 (on (copy-sequence (nth 1 entry)))
5000 (on-help (nth 2 entry))
5001 (off (copy-sequence (nth 3 entry)))
5002 (off-help (nth 4 entry)))
5003 (put-text-property 0 1 'help-echo on-help on)
5004 (put-text-property 0 1 'help-echo off-help off)
5005 (push (list key on off) result))))
5006 "Alist of strings describing wash status in the mode line.
5007 Each entry has the form (KEY ON OF), where the KEY is a symbol
5008 representing the particular washing function, ON is the string to use
5009 in the article mode line when the washing function is active, and OFF
5010 is the string to use when it is inactive.")
5012 (defun gnus-article-wash-status-entry (key value)
5013 (let ((entry (assoc key gnus-article-wash-status-strings)))
5014 (if value (nth 1 entry) (nth 2 entry))))
5016 (defun gnus-article-wash-status ()
5017 "Return a string which display status of article washing."
5019 (set-buffer gnus-article-buffer)
5020 (let ((cite (memq 'cite gnus-article-wash-types))
5021 (headers (memq 'headers gnus-article-wash-types))
5022 (boring (memq 'boring-headers gnus-article-wash-types))
5023 (pgp (memq 'pgp gnus-article-wash-types))
5024 (pem (memq 'pem gnus-article-wash-types))
5025 (signed (memq 'signed gnus-article-wash-types))
5026 (encrypted (memq 'encrypted gnus-article-wash-types))
5027 (signature (memq 'signature gnus-article-wash-types))
5028 (overstrike (memq 'overstrike gnus-article-wash-types))
5029 (emphasis (memq 'emphasis gnus-article-wash-types)))
5031 (gnus-article-wash-status-entry 'cite cite)
5032 (gnus-article-wash-status-entry 'headers (or headers boring))
5033 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5034 (gnus-article-wash-status-entry 'signature signature)
5035 (gnus-article-wash-status-entry 'overstrike overstrike)
5036 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5038 (defun gnus-add-wash-type (type)
5039 "Add a washing of TYPE to the current status."
5040 (add-to-list 'gnus-article-wash-types type))
5042 (defun gnus-delete-wash-type (type)
5043 "Add a washing of TYPE to the current status."
5044 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5046 (defun gnus-add-image (category image)
5047 "Add IMAGE of CATEGORY to the list of displayed images."
5048 (let ((entry (assq category gnus-article-image-alist)))
5050 (setq entry (list category))
5051 (push entry gnus-article-image-alist))
5052 (nconc entry (list image))))
5054 (defun gnus-delete-images (category)
5055 "Delete all images in CATEGORY."
5056 (let ((entry (assq category gnus-article-image-alist)))
5057 (dolist (image (cdr entry))
5058 (gnus-remove-image image category))
5059 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5060 (gnus-delete-wash-type category)))
5062 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5064 (defun gnus-article-maybe-hide-headers ()
5065 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5066 Provided for backwards compatibility."
5067 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5068 (not (save-excursion (set-buffer gnus-summary-buffer)
5069 gnus-have-all-headers)))
5070 (not gnus-inhibit-hiding))
5071 (gnus-article-hide-headers)))
5075 (defun gnus-output-to-file (file-name)
5076 "Append the current article to a file named FILE-NAME."
5077 (let ((artbuf (current-buffer)))
5079 (insert-buffer-substring artbuf)
5080 ;; Append newline at end of the buffer as separator, and then
5082 (goto-char (point-max))
5084 (let ((file-name-coding-system nnmail-pathname-coding-system))
5085 (mm-append-to-file (point-min) (point-max) file-name))
5088 (defun gnus-narrow-to-page (&optional arg)
5089 "Narrow the article buffer to a page.
5090 If given a numerical ARG, move forward ARG pages."
5092 (setq arg (if arg (prefix-numeric-value arg) 0))
5094 (set-buffer gnus-article-buffer)
5095 (goto-char (point-min))
5097 ;; Remove any old next/prev buttons.
5098 (when (gnus-visual-p 'page-marker)
5099 (let ((inhibit-read-only t))
5100 (gnus-remove-text-with-property 'gnus-prev)
5101 (gnus-remove-text-with-property 'gnus-next)))
5104 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5106 (re-search-forward page-delimiter nil 'move arg)))
5107 (goto-char (match-end 0))
5109 (goto-char (point-min))
5110 (setq gnus-page-broken
5111 (and (re-search-forward page-delimiter nil t) t))))
5112 (when gnus-page-broken
5115 (if (re-search-forward page-delimiter nil 'move)
5118 (when (and (gnus-visual-p 'page-marker)
5119 (> (point-min) (save-restriction (widen) (point-min))))
5121 (goto-char (point-min))
5122 (gnus-insert-prev-page-button)))
5123 (when (and (gnus-visual-p 'page-marker)
5124 (< (point-max) (save-restriction (widen) (point-max))))
5126 (goto-char (point-max))
5127 (gnus-insert-next-page-button))))))
5129 ;; Article mode commands
5131 (defun gnus-article-goto-next-page ()
5132 "Show the next page of the article."
5134 (when (gnus-article-next-page)
5135 (goto-char (point-min))
5136 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5139 (defun gnus-article-goto-prev-page ()
5140 "Show the previous page of the article."
5143 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5144 (gnus-article-prev-page nil)))
5146 ;; This is cleaner but currently breaks `gnus-pick-mode':
5148 ;; (defun gnus-article-goto-next-page ()
5149 ;; "Show the next page of the article."
5151 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5152 ;; (gnus-summary-next-page)))
5154 ;; (defun gnus-article-goto-prev-page ()
5155 ;; "Show the next page of the article."
5157 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5158 ;; (gnus-summary-prev-page)))
5160 (defun gnus-article-next-page (&optional lines)
5161 "Show the next page of the current article.
5162 If end of article, return non-nil. Otherwise return nil.
5163 Argument LINES specifies lines to be scrolled up."
5165 (move-to-window-line -1)
5168 (and (pos-visible-in-window-p) ;Not continuation line.
5169 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5170 ;; Nothing in this page.
5171 (if (or (not gnus-page-broken)
5176 (eobp)))) ;Real end-of-buffer?
5178 (when gnus-article-over-scroll
5179 (gnus-article-next-page-1 lines))
5181 (gnus-narrow-to-page 1) ;Go to next page.
5183 ;; More in this page.
5184 (gnus-article-next-page-1 lines)
5187 (defun gnus-article-next-page-1 (lines)
5188 (let ((scroll-in-place nil))
5192 ;; Long lines may cause an end-of-buffer error.
5193 (goto-char (point-max)))))
5194 (move-to-window-line 0))
5196 (defun gnus-article-prev-page (&optional lines)
5197 "Show previous page of current article.
5198 Argument LINES specifies lines to be scrolled down."
5200 (move-to-window-line 0)
5201 (if (and gnus-page-broken
5203 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5205 (gnus-narrow-to-page -1) ;Go to previous page.
5206 (goto-char (point-max))
5208 (let ((scroll-in-place nil))
5212 (beginning-of-buffer
5213 (goto-char (point-min))))
5214 (move-to-window-line 0)))))
5216 (defun gnus-article-only-boring-p ()
5217 "Decide whether there is only boring text remaining in the article.
5218 Something \"interesting\" is a word of at least two letters that does
5219 not have a face in `gnus-article-boring-faces'."
5220 (when (and gnus-article-skip-boring
5221 (boundp 'gnus-article-boring-faces)
5222 (symbol-value 'gnus-article-boring-faces))
5225 (while (re-search-forward "\\b\\w\\w" nil t)
5227 (when (not (gnus-intersection
5228 (gnus-faces-at (point))
5229 (symbol-value 'gnus-article-boring-faces)))
5230 (throw 'only-boring nil)))
5231 (throw 'only-boring t)))))
5233 (defun gnus-article-refer-article ()
5234 "Read article specified by message-id around point."
5237 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5238 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5239 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5240 (let ((msg-id (concat "<" (match-string 0) ">")))
5241 (set-buffer gnus-summary-buffer)
5242 (gnus-summary-refer-article msg-id))
5243 (error "No references around point"))))
5245 (defun gnus-article-show-summary ()
5246 "Reconfigure windows to show summary buffer."
5248 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5249 (error "There is no summary buffer for this article buffer")
5250 (gnus-article-set-globals)
5251 (gnus-configure-windows 'article)
5252 (gnus-summary-goto-subject gnus-current-article)
5253 (gnus-summary-position-point)))
5255 (defun gnus-article-describe-briefly ()
5256 "Describe article mode commands briefly."
5258 (gnus-message 6 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
5260 (defun gnus-article-summary-command ()
5261 "Execute the last keystroke in the summary buffer."
5263 (let ((obuf (current-buffer))
5264 (owin (current-window-configuration))
5266 (switch-to-buffer gnus-article-current-summary 'norecord)
5267 (setq func (lookup-key (current-local-map) (this-command-keys)))
5268 (call-interactively func)
5270 (set-window-configuration owin)
5271 (set-window-point (get-buffer-window (current-buffer)) (point))))
5273 (defun gnus-article-summary-command-nosave ()
5274 "Execute the last keystroke in the summary buffer."
5277 (pop-to-buffer gnus-article-current-summary 'norecord)
5278 (setq func (lookup-key (current-local-map) (this-command-keys)))
5279 (call-interactively func)))
5281 (defun gnus-article-check-buffer ()
5282 "Beep if not in an article buffer."
5283 (unless (equal major-mode 'gnus-article-mode)
5284 (error "Command invoked outside of a Gnus article buffer")))
5286 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5287 "Read a summary buffer key sequence and execute it from the article buffer."
5289 (gnus-article-check-buffer)
5291 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5292 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5293 "=" "^" "\M-^" "|"))
5299 '("n" "Gn" "p" "Gp"))
5302 (set-buffer gnus-article-current-summary)
5303 (let (gnus-pick-mode)
5304 (push (or key last-command-event) unread-command-events)
5305 (setq keys (if (featurep 'xemacs)
5306 (events-to-keys (read-key-sequence nil))
5307 (read-key-sequence nil)))))
5311 (if (or (member keys nosaves)
5312 (member keys nosave-but-article)
5313 (member keys nosave-in-article))
5315 (save-window-excursion
5316 (pop-to-buffer gnus-article-current-summary 'norecord)
5317 ;; We disable the pick minor mode commands.
5318 (let (gnus-pick-mode)
5319 (setq func (lookup-key (current-local-map) keys))))
5323 (unless (member keys nosave-in-article)
5324 (set-buffer gnus-article-current-summary))
5325 (call-interactively func)
5326 (setq new-sum-point (point)))
5327 (when (member keys nosave-but-article)
5328 (pop-to-buffer gnus-article-buffer 'norecord)))
5329 ;; These commands should restore window configuration.
5330 (let ((obuf (current-buffer))
5331 (owin (current-window-configuration))
5333 win func in-buffer selected new-sum-start new-sum-hscroll)
5334 (cond (not-restore-window
5335 (pop-to-buffer gnus-article-current-summary 'norecord))
5336 ((setq win (get-buffer-window gnus-article-current-summary))
5337 (select-window win))
5339 (switch-to-buffer gnus-article-current-summary 'norecord)))
5340 (setq in-buffer (current-buffer))
5341 ;; We disable the pick minor mode commands.
5342 (if (and (setq func (let (gnus-pick-mode)
5343 (lookup-key (current-local-map) keys)))
5346 (call-interactively func)
5347 (when (eq win (selected-window))
5348 (setq new-sum-point (point)
5349 new-sum-start (window-start win)
5350 new-sum-hscroll (window-hscroll win)))
5351 (when (eq in-buffer (current-buffer))
5352 (setq selected (gnus-summary-select-article))
5354 (unless not-restore-window
5355 (set-window-configuration owin))
5356 (when (eq selected 'old)
5358 (set-window-start (get-buffer-window (current-buffer))
5360 (set-window-point (get-buffer-window (current-buffer))
5362 (when (and (not not-restore-window)
5364 (set-window-point win new-sum-point)
5365 (set-window-start win new-sum-start)
5366 (set-window-hscroll win new-sum-hscroll))))
5367 (set-window-configuration owin)
5370 (defun gnus-article-describe-key (key)
5371 "Display documentation of the function invoked by KEY. KEY is a string."
5372 (interactive "kDescribe key: ")
5373 (gnus-article-check-buffer)
5374 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5376 (set-buffer gnus-article-current-summary)
5377 (let (gnus-pick-mode)
5378 (if (featurep 'xemacs)
5380 (push (elt key 0) unread-command-events)
5381 (setq key (events-to-keys
5382 (read-key-sequence "Describe key: "))))
5383 (setq unread-command-events
5385 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5386 (string-to-list key)))
5387 (setq key (read-key-sequence "Describe key: "))))
5389 (describe-key key)))
5391 (defun gnus-article-describe-key-briefly (key &optional insert)
5392 "Display documentation of the function invoked by KEY. KEY is a string."
5393 (interactive "kDescribe key: \nP")
5394 (gnus-article-check-buffer)
5395 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5397 (set-buffer gnus-article-current-summary)
5398 (let (gnus-pick-mode)
5399 (if (featurep 'xemacs)
5401 (push (elt key 0) unread-command-events)
5402 (setq key (events-to-keys
5403 (read-key-sequence "Describe key: "))))
5404 (setq unread-command-events
5406 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5407 (string-to-list key)))
5408 (setq key (read-key-sequence "Describe key: "))))
5409 (describe-key-briefly key insert))
5410 (describe-key-briefly key insert)))
5412 (defun gnus-article-reply-with-original (&optional wide)
5413 "Start composing a reply mail to the current message.
5414 The text in the region will be yanked. If the region isn't active,
5415 the entire article will be yanked."
5417 (let ((article (cdr gnus-article-current))
5419 (if (not (gnus-mark-active-p))
5420 (with-current-buffer gnus-summary-buffer
5421 (gnus-summary-reply (list (list article)) wide))
5422 (setq contents (buffer-substring (point) (mark t)))
5423 ;; Deactivate active regions.
5424 (when (and (boundp 'transient-mark-mode)
5425 transient-mark-mode)
5426 (setq mark-active nil))
5427 (with-current-buffer gnus-summary-buffer
5429 (list (list article contents)) wide)))))
5431 (defun gnus-article-followup-with-original ()
5432 "Compose a followup to the current article.
5433 The text in the region will be yanked. If the region isn't active,
5434 the entire article will be yanked."
5436 (let ((article (cdr gnus-article-current))
5438 (if (not (gnus-mark-active-p))
5439 (with-current-buffer gnus-summary-buffer
5440 (gnus-summary-followup (list (list article))))
5441 (setq contents (buffer-substring (point) (mark t)))
5442 ;; Deactivate active regions.
5443 (when (and (boundp 'transient-mark-mode)
5444 transient-mark-mode)
5445 (setq mark-active nil))
5446 (with-current-buffer gnus-summary-buffer
5447 (gnus-summary-followup
5448 (list (list article contents)))))))
5450 (defun gnus-article-hide (&optional arg force)
5451 "Hide all the gruft in the current article.
5452 This means that signatures, cited text and (some) headers will be
5454 If given a prefix, show the hidden text instead."
5455 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5456 (gnus-article-hide-headers arg)
5457 (gnus-article-hide-list-identifiers arg)
5458 (gnus-article-hide-citation-maybe arg force)
5459 (gnus-article-hide-signature arg))
5461 (defun gnus-article-maybe-highlight ()
5462 "Do some article highlighting if article highlighting is requested."
5463 (when (gnus-visual-p 'article-highlight 'highlight)
5464 (gnus-article-highlight-some)))
5466 (defun gnus-check-group-server ()
5467 ;; Make sure the connection to the server is alive.
5468 (unless (gnus-server-opened
5469 (gnus-find-method-for-group gnus-newsgroup-name))
5470 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5471 (gnus-request-group gnus-newsgroup-name t)))
5474 (autoload 'nneething-get-file-name "nneething"))
5476 (defun gnus-request-article-this-buffer (article group)
5477 "Get an article and insert it into this buffer."
5478 (let (do-update-line sparse-header)
5482 (gnus-kill-all-overlays)
5483 (setq group (or group gnus-newsgroup-name))
5485 ;; Using `gnus-request-article' directly will insert the article into
5486 ;; `nntp-server-buffer' - so we'll save some time by not having to
5487 ;; copy it from the server buffer into the article buffer.
5489 ;; We only request an article by message-id when we do not have the
5490 ;; headers for it, so we'll have to get those.
5491 (when (stringp article)
5492 (gnus-read-header article))
5494 ;; If the article number is negative, that means that this article
5495 ;; doesn't belong in this newsgroup (possibly), so we find its
5496 ;; message-id and request it by id instead of number.
5497 (when (and (numberp article)
5499 (get-buffer gnus-summary-buffer)
5500 (gnus-buffer-exists-p gnus-summary-buffer))
5502 (set-buffer gnus-summary-buffer)
5503 (let ((header (gnus-summary-article-header article)))
5506 ((memq article gnus-newsgroup-sparse)
5507 ;; This is a sparse gap article.
5508 (setq do-update-line article)
5509 (setq article (mail-header-id header))
5510 (setq sparse-header (gnus-read-header article))
5511 (setq gnus-newsgroup-sparse
5512 (delq article gnus-newsgroup-sparse)))
5514 ;; It's a real article.
5515 (setq article (mail-header-id header)))
5517 ;; It is an extracted pseudo-article.
5518 (setq article 'pseudo)
5519 (gnus-request-pseudo-article header))))
5521 (let ((method (gnus-find-method-for-group
5522 gnus-newsgroup-name)))
5523 (when (and (eq (car method) 'nneething)
5525 (let ((dir (nneething-get-file-name
5526 (mail-header-id header))))
5527 (when (and (stringp dir)
5528 (file-directory-p dir))
5529 (setq article 'nneething)
5530 (gnus-group-enter-directory dir))))))))
5533 ;; Refuse to select canceled articles.
5534 ((and (numberp article)
5536 (get-buffer gnus-summary-buffer)
5537 (gnus-buffer-exists-p gnus-summary-buffer)
5538 (eq (cdr (save-excursion
5539 (set-buffer gnus-summary-buffer)
5540 (assq article gnus-newsgroup-reads)))
5541 gnus-canceled-mark))
5543 ;; We first check `gnus-original-article-buffer'.
5544 ((and (get-buffer gnus-original-article-buffer)
5547 (set-buffer gnus-original-article-buffer)
5548 (and (equal (car gnus-original-article) group)
5549 (eq (cdr gnus-original-article) article))))
5550 (insert-buffer-substring gnus-original-article-buffer)
5552 ;; Check the backlog.
5553 ((and gnus-keep-backlog
5554 (gnus-backlog-request-article group article (current-buffer)))
5556 ;; Check asynchronous pre-fetch.
5557 ((gnus-async-request-fetched-article group article (current-buffer))
5558 (gnus-async-prefetch-next group article gnus-summary-buffer)
5559 (when (and (numberp article) gnus-keep-backlog)
5560 (gnus-backlog-enter-article group article (current-buffer)))
5563 ((and gnus-use-cache
5565 (gnus-cache-request-article article group))
5567 ;; Check the agent cache.
5568 ((gnus-agent-request-article article group)
5570 ;; Get the article and put into the article buffer.
5571 ((or (stringp article)
5573 (let ((gnus-override-method gnus-override-method)
5574 (methods (and (stringp article)
5575 gnus-refer-article-method))
5576 (backend (car (gnus-find-method-for-group
5577 gnus-newsgroup-name)))
5579 (inhibit-read-only t))
5580 (if (or (not (listp methods))
5581 (and (symbolp (car methods))
5582 (assq (car methods) nnoo-definition-alist)))
5583 (setq methods (list methods)))
5584 (when (and (null gnus-override-method)
5586 (setq gnus-override-method (pop methods)))
5588 (when (eq gnus-override-method 'current)
5589 (setq gnus-override-method
5590 (with-current-buffer gnus-summary-buffer
5591 gnus-current-select-method)))
5593 (gnus-kill-all-overlays)
5594 (let ((gnus-newsgroup-name group))
5595 (gnus-check-group-server))
5597 ((gnus-request-article article group (current-buffer))
5598 (when (numberp article)
5599 (gnus-async-prefetch-next group article
5600 gnus-summary-buffer)
5601 (when gnus-keep-backlog
5602 (gnus-backlog-enter-article
5603 group article (current-buffer))))
5604 (setq result 'article))
5606 (setq gnus-override-method (pop methods)))
5607 ((not (string-match "^400 "
5608 (nnheader-get-report backend)))
5609 ;; If we get 400 server disconnect, reconnect and
5610 ;; retry; otherwise, assume the article has expired.
5611 (setq result 'done))))
5612 (and (eq result 'article) 'article)))
5616 ;; Associate this article with the current summary buffer.
5617 (setq gnus-article-current-summary gnus-summary-buffer)
5619 ;; Take the article from the original article buffer
5620 ;; and place it in the buffer it's supposed to be in.
5621 (when (and (get-buffer gnus-article-buffer)
5622 (equal (buffer-name (current-buffer))
5623 (buffer-name (get-buffer gnus-article-buffer))))
5625 (if (get-buffer gnus-original-article-buffer)
5626 (set-buffer gnus-original-article-buffer)
5627 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5628 (buffer-disable-undo)
5629 (setq major-mode 'gnus-original-article-mode)
5630 (setq buffer-read-only t))
5631 (let ((inhibit-read-only t))
5633 (insert-buffer-substring gnus-article-buffer))
5634 (setq gnus-original-article (cons group article)))
5637 (run-hooks 'gnus-article-decode-hook)
5638 ;; Mark article as decoded or not.
5639 (setq gnus-article-decoded-p gnus-article-decode-hook))
5641 ;; Update sparse articles.
5642 (when (and do-update-line
5643 (or (numberp article)
5645 (let ((buf (current-buffer)))
5646 (set-buffer gnus-summary-buffer)
5647 (gnus-summary-update-article do-update-line sparse-header)
5648 (gnus-summary-goto-subject do-update-line nil t)
5649 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5651 (set-buffer buf))))))
5657 (defcustom gnus-article-edit-mode-hook nil
5658 "Hook run in article edit mode buffers."
5659 :group 'gnus-article-various
5662 (defvar gnus-article-edit-done-function nil)
5664 (defvar gnus-article-edit-mode-map nil)
5665 (defvar gnus-article-edit-mode nil)
5667 ;; Should we be using derived.el for this?
5668 (unless gnus-article-edit-mode-map
5669 (setq gnus-article-edit-mode-map (make-keymap))
5670 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5672 (gnus-define-keys gnus-article-edit-mode-map
5673 "\C-c?" describe-mode
5674 "\C-c\C-c" gnus-article-edit-done
5675 "\C-c\C-k" gnus-article-edit-exit
5676 "\C-c\C-f\C-t" message-goto-to
5677 "\C-c\C-f\C-o" message-goto-from
5678 "\C-c\C-f\C-b" message-goto-bcc
5679 ;;"\C-c\C-f\C-w" message-goto-fcc
5680 "\C-c\C-f\C-c" message-goto-cc
5681 "\C-c\C-f\C-s" message-goto-subject
5682 "\C-c\C-f\C-r" message-goto-reply-to
5683 "\C-c\C-f\C-n" message-goto-newsgroups
5684 "\C-c\C-f\C-d" message-goto-distribution
5685 "\C-c\C-f\C-f" message-goto-followup-to
5686 "\C-c\C-f\C-m" message-goto-mail-followup-to
5687 "\C-c\C-f\C-k" message-goto-keywords
5688 "\C-c\C-f\C-u" message-goto-summary
5689 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5690 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5691 "\C-c\C-b" message-goto-body
5692 "\C-c\C-i" message-goto-signature
5694 "\C-c\C-t" message-insert-to
5695 "\C-c\C-n" message-insert-newsgroups
5696 "\C-c\C-o" message-sort-headers
5697 "\C-c\C-e" message-elide-region
5698 "\C-c\C-v" message-delete-not-region
5699 "\C-c\C-z" message-kill-to-signature
5700 "\M-\r" message-newline-and-reformat
5701 "\C-c\C-a" mml-attach-file
5702 "\C-a" message-beginning-of-line
5704 "\M-;" comment-region)
5706 (gnus-define-keys (gnus-article-edit-wash-map
5707 "\C-c\C-w" gnus-article-edit-mode-map)
5708 "f" gnus-article-edit-full-stops))
5711 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5713 ["Fetch To" message-insert-to t]
5714 ["Fetch Newsgroups" message-insert-newsgroups t]
5716 ["To" message-goto-to t]
5717 ["From" message-goto-from t]
5718 ["Subject" message-goto-subject t]
5719 ["Cc" message-goto-cc t]
5720 ["Reply-To" message-goto-reply-to t]
5721 ["Summary" message-goto-summary t]
5722 ["Keywords" message-goto-keywords t]
5723 ["Newsgroups" message-goto-newsgroups t]
5724 ["Followup-To" message-goto-followup-to t]
5725 ["Mail-Followup-To" message-goto-mail-followup-to t]
5726 ["Distribution" message-goto-distribution t]
5727 ["Body" message-goto-body t]
5728 ["Signature" message-goto-signature t]))
5730 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5731 "Major mode for editing articles.
5732 This is an extended text-mode.
5734 \\{gnus-article-edit-mode-map}"
5735 (make-local-variable 'gnus-article-edit-done-function)
5736 (make-local-variable 'gnus-prev-winconf)
5737 (set (make-local-variable 'font-lock-defaults)
5738 '(message-font-lock-keywords t))
5739 (set (make-local-variable 'mail-header-separator) "")
5740 (set (make-local-variable 'gnus-article-edit-mode) t)
5741 (easy-menu-add message-mode-field-menu message-mode-map)
5743 (setq buffer-read-only nil)
5744 (buffer-enable-undo)
5747 (defun gnus-article-edit (&optional force)
5748 "Edit the current article.
5749 This will have permanent effect only in mail groups.
5750 If FORCE is non-nil, allow editing of articles even in read-only
5753 (when (and (not force)
5754 (gnus-group-read-only-p))
5755 (error "The current newsgroup does not support article editing"))
5756 (gnus-article-date-original)
5757 (gnus-article-edit-article
5759 `(lambda (no-highlight)
5761 (gnus-summary-edit-article-done
5762 ,(or (mail-header-references gnus-current-headers) "")
5763 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5765 (defun gnus-article-edit-article (start-func exit-func)
5766 "Start editing the contents of the current article buffer."
5767 (let ((winconf (current-window-configuration)))
5768 (set-buffer gnus-article-buffer)
5769 (let ((message-auto-save-directory
5770 ;; Don't associate the article buffer with a draft file.
5772 (gnus-article-edit-mode))
5773 (funcall start-func)
5774 (set-buffer-modified-p nil)
5775 (gnus-configure-windows 'edit-article)
5776 (setq gnus-article-edit-done-function exit-func)
5777 (setq gnus-prev-winconf winconf)
5778 (gnus-message 6 "C-c C-c to end edits")))
5780 (defun gnus-article-edit-done (&optional arg)
5781 "Update the article edits and exit."
5783 (let ((func gnus-article-edit-done-function)
5784 (buf (current-buffer))
5785 (start (window-start))
5787 (winconf gnus-prev-winconf))
5788 (widen) ;; Widen it in case that users narrowed the buffer.
5791 ;; The cache and backlog have to be flushed somewhat.
5792 (when gnus-keep-backlog
5793 (gnus-backlog-remove-article
5794 (car gnus-article-current) (cdr gnus-article-current)))
5795 ;; Flush original article as well.
5797 (when (get-buffer gnus-original-article-buffer)
5798 (set-buffer gnus-original-article-buffer)
5799 (setq gnus-original-article nil)))
5800 (when gnus-use-cache
5801 (gnus-cache-update-article
5802 (car gnus-article-current) (cdr gnus-article-current)))
5803 ;; We remove all text props from the article buffer.
5804 (kill-all-local-variables)
5805 (gnus-set-text-properties (point-min) (point-max) nil)
5807 (set-window-configuration winconf)
5809 (set-window-start (get-buffer-window buf) start)
5810 (set-window-point (get-buffer-window buf) (point)))
5811 (gnus-summary-show-article))
5813 (defun gnus-article-edit-exit ()
5814 "Exit the article editing without updating."
5816 (when (or (not (buffer-modified-p))
5817 (yes-or-no-p "Article modified; kill anyway? "))
5818 (let ((curbuf (current-buffer))
5820 (window-start (window-start)))
5822 (if (gnus-buffer-live-p gnus-original-article-buffer)
5823 (insert-buffer gnus-original-article-buffer))
5824 (let ((winconf gnus-prev-winconf))
5825 (kill-all-local-variables)
5827 (set-window-configuration winconf)
5828 ;; Tippy-toe some to make sure that point remains where it was.
5829 (save-current-buffer
5831 (set-window-start (get-buffer-window (current-buffer)) window-start)
5833 (gnus-summary-show-article)))
5835 (defun gnus-article-edit-full-stops ()
5836 "Interactively repair spacing at end of sentences."
5839 (goto-char (point-min))
5840 (search-forward-regexp "^$" nil t)
5841 (let ((case-fold-search nil))
5842 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5845 ;;; Article highlights
5848 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5850 ;;; Internal Variables:
5852 (defcustom gnus-button-url-regexp
5853 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5854 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5855 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5856 "Regular expression that matches URLs."
5857 :group 'gnus-article-buttons
5860 (defcustom gnus-button-valid-fqdn-regexp
5861 message-valid-fqdn-regexp
5862 "Regular expression that matches a valid FQDN."
5864 :group 'gnus-article-buttons
5867 (defcustom gnus-button-man-handler 'manual-entry
5868 "Function to use for displaying man pages.
5869 The function must take at least one argument with a string naming the
5872 :type '(choice (function-item :tag "Man" manual-entry)
5873 (function-item :tag "Woman" woman)
5874 (function :tag "Other"))
5875 :group 'gnus-article-buttons)
5877 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5878 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5879 If the default site is too slow, try to find a CTAN mirror, see
5880 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5881 the variable `gnus-button-handle-ctan'."
5883 :group 'gnus-article-buttons
5884 :link '(custom-manual "(gnus)Group Parameters")
5885 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5886 (const "http://tug.ctan.org/tex-archive/")
5887 (const "http://www.dante.de/CTAN/")
5888 (string :tag "Other")))
5890 (defcustom gnus-button-ctan-handler 'browse-url
5891 "Function to use for displaying CTAN links.
5892 The function must take one argument, the string naming the URL."
5894 :type '(choice (function-item :tag "Browse Url" browse-url)
5895 (function :tag "Other"))
5896 :group 'gnus-article-buttons)
5898 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5899 "Bogus strings removed from CTAN URLs."
5901 :group 'gnus-article-buttons
5902 :type '(choice (const "^/?tex-archive/\\|/")
5903 (regexp :tag "Other")))
5905 (defcustom gnus-button-ctan-directory-regexp
5907 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5908 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5909 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5910 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5912 "Regular expression for ctan directories.
5913 It should match all directories in the top level of `gnus-ctan-url'."
5915 :group 'gnus-article-buttons
5918 (defcustom gnus-button-mid-or-mail-regexp
5919 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5920 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5921 gnus-button-valid-fqdn-regexp
5923 "Regular expression that matches a message ID or a mail address."
5925 :group 'gnus-article-buttons
5928 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5929 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5930 Strings like this can be either a message ID or a mail address. If it is one
5931 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5932 message ID or a mail address, respectively. If this variable is set to the
5933 symbol `ask', always query the user what do do. If it is a function, this
5934 function will be called with the string as it's only argument. The function
5935 must return `mid', `mail', `invalid' or `ask'."
5937 :group 'gnus-article-buttons
5938 :type '(choice (function-item :tag "Heuristic function"
5939 gnus-button-mid-or-mail-heuristic)
5944 (defcustom gnus-button-mid-or-mail-heuristic-alist
5945 '((-10.0 . ".+\\$.+@")
5948 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5949 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5950 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5951 (-1.0 . "^[^a-z]+@")
5953 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5954 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5955 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5956 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5959 (-1.0 . "^[0-9][0-9]")
5961 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5962 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5963 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5964 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5966 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5967 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5970 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5972 ;; compensation for TDMA dated mail addresses:
5973 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5975 (-20.0 . "\\.fsf@") ;; Gnus
5978 (-20.0 . "_-_") ;; Subject change in thread
5980 (-20.0 . "\\.ln@") ;; leafnode
5981 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5982 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5984 ;; (5.0 . "") ;; $local_part_len <= 7
5985 (10.0 . "^[^0-9]+@")
5986 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5987 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5990 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5992 (0.5 . "^[A-Z][a-z]")
5993 (0.5 . "^[A-Z][a-z][a-z]")
5994 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5995 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5996 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5998 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5999 address. The REGEXP is processed with `case-fold-search' set to nil."
6001 :group 'gnus-article-buttons
6002 :type '(repeat (cons (number :tag "Rate")
6003 (regexp :tag "Regexp"))))
6005 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6006 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6007 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6008 address, `ask' if unsure and `invalid' if the string is invalid."
6009 (let ((case-fold-search nil)
6010 (list gnus-button-mid-or-mail-heuristic-alist)
6011 (result 0) rate regexp lpartlen elem)
6013 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6014 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6015 ;; Certain special cases...
6018 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6019 "^[0-9]+\\.[0-9]+@compuserve\\|"
6020 "@public\\.gmane\\.org")
6022 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6023 (setq result 'mail))
6024 (when (string-match "@.*@\\| " mid-or-mail)
6025 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6026 (setq result 'invalid))
6027 ;; Nothing more to do, if result is not a number here...
6028 (when (numberp result)
6030 (setq elem (car list)
6034 (when (string-match regexp mid-or-mail)
6035 (setq result (+ result rate))
6037 9 "`%s' matched `%s', rate `%s', result `%s'."
6038 mid-or-mail regexp rate result)))
6039 (when (<= lpartlen 7)
6040 (setq result (+ result 5.0))
6041 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6042 mid-or-mail result))
6043 (when (>= lpartlen 12)
6044 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6046 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6047 ;; Long local part should contain realname if e-mail address,
6048 ;; too many digits: message-id.
6049 ;; $score -= 5.0 + 0.1 * $local_part_len;
6050 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6051 (setq result (+ result rate))
6053 9 "Many digits in `%s', rate `%s', result `%s'."
6054 mid-or-mail rate result))
6055 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6057 ;; Too few vowels [^aeiouy]{4,}.*\@
6058 (setq result (+ result -5.0))
6060 9 "Few vowels in `%s', rate `%s', result `%s'."
6061 mid-or-mail -5.0 result))
6063 (setq result (+ result 5.0))
6065 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6066 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6067 ;; Maybe we should make this a customizable alist: (condition . 'result)
6069 ((symbolp result) result)
6070 ;; Now convert number into proper results:
6071 ((< result -10.0) 'mid)
6072 ((> result 10.0) 'mail)
6075 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6076 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6077 (url-mid (concat "news" ":" mid-or-mail))
6078 (url-mailto (concat "mailto" ":" mid-or-mail)))
6079 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6080 (when (fboundp pref)
6082 ;; get rid of surrounding angles...
6084 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6085 (if (or (eq 'mid guessed) (eq 'mail guessed))
6089 (save-window-excursion
6090 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6093 (cond ((eq pref 'mid)
6094 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6095 (gnus-button-handle-news url-mid))
6097 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6098 (gnus-url-mailto url-mailto))
6099 (t (gnus-message 3 "Invalid string.")))))
6101 (defun gnus-button-handle-custom (url)
6102 "Follow a Custom URL."
6103 (customize-apropos (gnus-url-unhex-string url)))
6105 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6107 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6110 (defun gnus-button-handle-describe-function (url)
6111 "Call `describe-function' when pushing the corresponding URL button."
6114 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6116 (defun gnus-button-handle-describe-variable (url)
6117 "Call `describe-variable' when pushing the corresponding URL button."
6120 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6122 (defun gnus-button-handle-symbol (url)
6123 "Display help on variable or function.
6124 Calls `describe-variable' or `describe-function'."
6125 (let ((sym (intern url)))
6127 ((fboundp sym) (describe-function sym))
6128 ((boundp sym) (describe-variable sym))
6129 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6131 (defun gnus-button-handle-describe-key (url)
6132 "Call `describe-key' when pushing the corresponding URL button."
6134 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6135 (keys (ignore-errors (eval `(kbd ,key-string)))))
6138 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6140 (defun gnus-button-handle-apropos (url)
6141 "Call `apropos' when pushing the corresponding URL button."
6142 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6144 (defun gnus-button-handle-apropos-command (url)
6145 "Call `apropos' when pushing the corresponding URL button."
6147 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6149 (defun gnus-button-handle-apropos-variable (url)
6150 "Call `apropos' when pushing the corresponding URL button."
6152 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6153 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6155 (defun gnus-button-handle-apropos-documentation (url)
6156 "Call `apropos' when pushing the corresponding URL button."
6158 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6159 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6161 (defun gnus-button-handle-library (url)
6162 "Call `locate-library' when pushing the corresponding URL button."
6163 (gnus-message 9 "url=`%s'" url)
6164 (let* ((lib (locate-library url))
6165 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6167 (gnus-message 1 "Cannot locale library `%s'." url)
6168 (find-file-read-only file))))
6170 (defun gnus-button-handle-ctan (url)
6171 "Call `browse-url' when pushing a CTAN URL button."
6173 gnus-button-ctan-handler
6176 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6178 (defcustom gnus-button-tex-level 5
6179 "*Integer that says how many TeX-related buttons Gnus will show.
6180 The higher the number, the more buttons will appear and the more false
6181 positives are possible. Note that you can set this variable local to
6182 specific groups. Setting it higher in TeX groups is probably a good idea.
6183 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6184 how to set variables in specific groups."
6186 :group 'gnus-article-buttons
6187 :link '(custom-manual "(gnus)Group Parameters")
6190 (defcustom gnus-button-man-level 5
6191 "*Integer that says how many man-related buttons Gnus will show.
6192 The higher the number, the more buttons will appear and the more false
6193 positives are possible. Note that you can set this variable local to
6194 specific groups. Setting it higher in Unix groups is probably a good idea.
6195 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6196 how to set variables in specific groups."
6198 :group 'gnus-article-buttons
6199 :link '(custom-manual "(gnus)Group Parameters")
6202 (defcustom gnus-button-emacs-level 5
6203 "*Integer that says how many emacs-related buttons Gnus will show.
6204 The higher the number, the more buttons will appear and the more false
6205 positives are possible. Note that you can set this variable local to
6206 specific groups. Setting it higher in Emacs or Gnus related groups is
6207 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6208 `gnus-parameters' on how to set variables in specific groups."
6210 :group 'gnus-article-buttons
6211 :link '(custom-manual "(gnus)Group Parameters")
6214 (defcustom gnus-button-message-level 5
6215 "*Integer that says how many buttons for news or mail messages will appear.
6216 The higher the number, the more buttons will appear and the more false
6217 positives are possible."
6218 ;; mail addresses, MIDs, URLs for news, ...
6220 :group 'gnus-article-buttons
6223 (defcustom gnus-button-browse-level 5
6224 "*Integer that says how many buttons for browsing will appear.
6225 The higher the number, the more buttons will appear and the more false
6226 positives are possible."
6227 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6229 :group 'gnus-article-buttons
6232 (defcustom gnus-button-alist
6233 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6234 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6235 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6236 gnus-button-handle-news 2)
6237 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6238 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6239 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6240 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6241 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6242 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6243 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6244 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6245 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6246 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6247 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6248 ;; RFC 2368 (The mailto URL scheme)
6249 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6250 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6251 ("\\bmailto:\\([^ \n\t]+\\)"
6252 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6254 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6255 gnus-button-ctan-directory-regexp
6256 "[^][>)!;:,'\n\t ]+\\)")
6257 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6258 ((concat "\\btex-archive/\\("
6259 gnus-button-ctan-directory-regexp
6260 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6261 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6264 gnus-button-ctan-directory-regexp
6265 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6266 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6267 ;; This is info (home-grown style) <info://foo/bar+baz>
6268 ("\\binfo://\\([^'\">\n\t ]+\\)"
6269 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6270 ;; Info GNOME style <info:foo#bar_baz>
6271 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6272 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6273 ;; Info KDE style <info:(foo)bar baz>
6274 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6275 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6276 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6277 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6278 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6279 ;; Info links like `C-h i d m CC Mode RET'
6280 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6282 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6283 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6284 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6285 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6286 ;; Emacs help commands
6287 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6288 ;; regexp doesn't match arguments containing ` '.
6289 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6290 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6291 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6292 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6293 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6294 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6295 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6296 ;; The following entries may lead to many false positives so don't enable
6297 ;; them by default (use a high button level).
6298 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6299 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6300 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6301 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6302 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6303 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6304 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6305 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6306 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6307 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6308 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6309 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6310 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6311 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6312 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6313 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6314 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6315 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6316 ;; Unlike the other regexps we really have to require quoting
6317 ;; here to determine where it ends.
6318 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6319 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6320 ("<URL: *\\([^<>]*\\)>"
6321 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6322 ;; RFC 2396 (2.4.3., delims) ...
6323 ("\"URL: *\\([^\"]*\\)\""
6324 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6325 ;; RFC 2396 (2.4.3., delims) ...
6326 ("\"URL: *\\([^\"]*\\)\""
6327 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6329 (gnus-button-url-regexp
6330 0 (>= gnus-button-browse-level 0) browse-url 0)
6332 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6333 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6334 gnus-button-handle-man 1)
6335 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6336 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6337 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6338 gnus-button-handle-man 1)
6339 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6340 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6341 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6342 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6343 ;; MID or mail: To avoid too many false positives we don't try to catch
6344 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6345 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6346 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6347 ;; so that non-ambiguous entries (see above) match first.
6348 (gnus-button-mid-or-mail-regexp
6349 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6350 "*Alist of regexps matching buttons in article bodies.
6352 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6353 REGEXP: is the string (case insensitive) matching text around the button (can
6354 also be Lisp expression evaluating to a string),
6355 BUTTON: is the number of the regexp grouping actually matching the button,
6356 FORM: is a Lisp expression which must eval to true for the button to
6358 CALLBACK: is the function to call when the user push this button, and each
6359 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6361 CALLBACK can also be a variable, in that case the value of that
6362 variable it the real callback function."
6363 :group 'gnus-article-buttons
6364 :type '(repeat (list (choice regexp variable sexp)
6365 (integer :tag "Button")
6367 (function :tag "Callback")
6370 (integer :tag "Regexp group")))))
6372 (defcustom gnus-header-button-alist
6373 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6374 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6375 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6376 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6377 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6378 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6379 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6380 0 (>= gnus-button-browse-level 0) browse-url 0)
6381 ("^Subject:" gnus-button-url-regexp
6382 0 (>= gnus-button-browse-level 0) browse-url 0)
6383 ("^[^:]+:" gnus-button-url-regexp
6384 0 (>= gnus-button-browse-level 0) browse-url 0)
6385 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6386 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6387 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6388 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6389 "*Alist of headers and regexps to match buttons in article heads.
6391 This alist is very similar to `gnus-button-alist', except that each
6392 alist has an additional HEADER element first in each entry:
6394 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6396 HEADER is a regexp to match a header. For a fuller explanation, see
6397 `gnus-button-alist'."
6398 :group 'gnus-article-buttons
6399 :group 'gnus-article-headers
6400 :type '(repeat (list (regexp :tag "Header")
6401 (choice regexp variable)
6402 (integer :tag "Button")
6404 (function :tag "Callback")
6407 (integer :tag "Regexp group")))))
6409 (defvar gnus-button-regexp nil)
6410 (defvar gnus-button-marker-list nil)
6411 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6413 (defvar gnus-button-last nil)
6414 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6418 (defun gnus-article-push-button (event)
6419 "Check text under the mouse pointer for a callback function.
6420 If the text under the mouse pointer has a `gnus-callback' property,
6421 call it with the value of the `gnus-data' text property."
6423 (set-buffer (window-buffer (posn-window (event-start event))))
6424 (let* ((pos (posn-point (event-start event)))
6425 (data (get-text-property pos 'gnus-data))
6426 (fun (get-text-property pos 'gnus-callback)))
6429 (funcall fun data))))
6431 (defun gnus-article-press-button ()
6432 "Check text at point for a callback function.
6433 If the text at point has a `gnus-callback' property,
6434 call it with the value of the `gnus-data' text property."
6436 (let ((data (get-text-property (point) 'gnus-data))
6437 (fun (get-text-property (point) 'gnus-callback)))
6439 (funcall fun data))))
6441 (defun gnus-article-highlight (&optional force)
6442 "Highlight current article.
6443 This function calls `gnus-article-highlight-headers',
6444 `gnus-article-highlight-citation',
6445 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6446 do the highlighting. See the documentation for those functions."
6447 (interactive (list 'force))
6448 (gnus-article-highlight-headers)
6449 (gnus-article-highlight-citation force)
6450 (gnus-article-highlight-signature)
6451 (gnus-article-add-buttons force)
6452 (gnus-article-add-buttons-to-head))
6454 (defun gnus-article-highlight-some (&optional force)
6455 "Highlight current article.
6456 This function calls `gnus-article-highlight-headers',
6457 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6458 do the highlighting. See the documentation for those functions."
6459 (interactive (list 'force))
6460 (gnus-article-highlight-headers)
6461 (gnus-article-highlight-signature)
6462 (gnus-article-add-buttons))
6464 (defun gnus-article-highlight-headers ()
6465 "Highlight article headers as specified by `gnus-header-face-alist'."
6468 (set-buffer gnus-article-buffer)
6470 (let ((alist gnus-header-face-alist)
6471 (inhibit-read-only t)
6472 (case-fold-search t)
6473 (inhibit-point-motion-hooks t)
6474 entry regexp header-face field-face from hpoints fpoints)
6475 (article-narrow-to-head)
6476 (while (setq entry (pop alist))
6477 (goto-char (point-min))
6478 (setq regexp (concat "^\\("
6479 (if (string-equal "" (nth 0 entry))
6483 header-face (nth 1 entry)
6484 field-face (nth 2 entry))
6485 (while (and (re-search-forward regexp nil t)
6489 (unless (search-forward ":" nil t)
6491 (when (and header-face
6492 (not (memq (point) hpoints)))
6493 (push (point) hpoints)
6494 (gnus-put-text-property from (point) 'face header-face))
6495 (when (and field-face
6496 (not (memq (setq from (point)) fpoints)))
6498 (if (re-search-forward "^[^ \t]" nil t)
6500 (goto-char (point-max)))
6501 (gnus-put-text-property from (point) 'face field-face))))))))
6503 (defun gnus-article-highlight-signature ()
6504 "Highlight the signature in an article.
6505 It does this by highlighting everything after
6506 `gnus-signature-separator' using the face `gnus-signature'."
6509 (set-buffer gnus-article-buffer)
6510 (let ((inhibit-read-only t)
6511 (inhibit-point-motion-hooks t))
6513 (when (and gnus-signature-face
6514 (gnus-article-narrow-to-signature))
6515 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6516 'face gnus-signature-face)
6518 (gnus-article-search-signature)
6519 (let ((start (match-beginning 0))
6520 (end (set-marker (make-marker) (1+ (match-end 0)))))
6521 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6524 (defun gnus-button-in-region-p (b e prop)
6525 "Say whether PROP exists in the region."
6526 (text-property-not-all b e prop nil))
6528 (defun gnus-article-add-buttons (&optional force)
6529 "Find external references in the article and make buttons of them.
6530 \"External references\" are things like Message-IDs and URLs, as
6531 specified by `gnus-button-alist'."
6532 (interactive (list 'force))
6534 (set-buffer gnus-article-buffer)
6535 (let ((inhibit-read-only t)
6536 (inhibit-point-motion-hooks t)
6537 (case-fold-search t)
6538 (alist gnus-button-alist)
6540 ;; Remove all old markers.
6541 (let (marker entry new-list)
6542 (while (setq marker (pop gnus-button-marker-list))
6543 (if (or (< marker (point-min)) (>= marker (point-max)))
6544 (push marker new-list)
6546 (when (setq entry (gnus-button-entry))
6547 (put-text-property (match-beginning (nth 1 entry))
6548 (match-end (nth 1 entry))
6549 'gnus-callback nil))
6550 (set-marker marker nil)))
6551 (setq gnus-button-marker-list new-list))
6552 ;; We skip the headers.
6555 (while (setq entry (pop alist))
6556 (setq regexp (eval (car entry)))
6558 (while (re-search-forward regexp nil t)
6559 (let* ((start (and entry (match-beginning (nth 1 entry))))
6560 (end (and entry (match-end (nth 1 entry))))
6561 (from (match-beginning 0)))
6562 (when (and (or (eq t (nth 2 entry))
6563 (eval (nth 2 entry)))
6564 (not (gnus-button-in-region-p
6565 start end 'gnus-callback)))
6566 ;; That optional form returned non-nil, so we add the
6568 (gnus-article-add-button
6569 start end 'gnus-button-push
6570 (car (push (set-marker (make-marker) from)
6571 gnus-button-marker-list))))))))))
6573 ;; Add buttons to the head of an article.
6574 (defun gnus-article-add-buttons-to-head ()
6575 "Add buttons to the head of the article."
6578 (set-buffer gnus-article-buffer)
6580 (let ((inhibit-read-only t)
6581 (inhibit-point-motion-hooks t)
6582 (case-fold-search t)
6583 (alist gnus-header-button-alist)
6585 (article-narrow-to-head)
6587 ;; Each alist entry.
6588 (setq entry (car alist)
6590 (goto-char (point-min))
6591 (while (re-search-forward (car entry) nil t)
6592 ;; Each header matching the entry.
6593 (setq beg (match-beginning 0))
6594 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6595 (match-beginning 0))
6598 (while (re-search-forward (eval (nth 1 entry)) end t)
6599 ;; Each match within a header.
6600 (let* ((entry (cdr entry))
6601 (start (match-beginning (nth 1 entry)))
6602 (end (match-end (nth 1 entry)))
6603 (form (nth 2 entry)))
6604 (goto-char (match-end 0))
6606 (gnus-article-add-button
6607 start end (nth 3 entry)
6608 (buffer-substring (match-beginning (nth 4 entry))
6609 (match-end (nth 4 entry)))))))
6610 (goto-char end)))))))
6612 ;;; External functions:
6614 (defun gnus-article-add-button (from to fun &optional data)
6615 "Create a button between FROM and TO with callback FUN and data DATA."
6616 (when gnus-article-button-face
6617 (gnus-overlay-put (gnus-make-overlay from to)
6618 'face gnus-article-button-face))
6619 (gnus-add-text-properties
6621 (nconc (and gnus-article-mouse-face
6622 (list gnus-mouse-face-prop gnus-article-mouse-face))
6623 (list 'gnus-callback fun)
6624 (and data (list 'gnus-data data))))
6625 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6626 :button-keymap gnus-widget-button-keymap))
6628 ;;; Internal functions:
6630 (defun gnus-article-set-globals ()
6632 (set-buffer gnus-summary-buffer)
6633 (gnus-set-global-variables)))
6635 (defun gnus-signature-toggle (end)
6637 (set-buffer gnus-article-buffer)
6638 (let ((inhibit-read-only t)
6639 (inhibit-point-motion-hooks t))
6640 (if (text-property-any end (point-max) 'article-type 'signature)
6642 (gnus-delete-wash-type 'signature)
6643 (gnus-remove-text-properties-when
6644 'article-type 'signature end (point-max)
6645 (cons 'article-type (cons 'signature
6646 gnus-hidden-properties))))
6647 (gnus-add-wash-type 'signature)
6648 (gnus-add-text-properties-when
6649 'article-type nil end (point-max)
6650 (cons 'article-type (cons 'signature
6651 gnus-hidden-properties)))))
6652 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6653 (gnus-set-mode-line 'article))))
6655 (defun gnus-button-entry ()
6656 ;; Return the first entry in `gnus-button-alist' matching this place.
6657 (let ((alist gnus-button-alist)
6660 (setq entry (pop alist))
6661 (if (looking-at (eval (car entry)))
6666 (defun gnus-button-push (marker)
6667 ;; Push button starting at MARKER.
6670 (let* ((entry (gnus-button-entry))
6671 (inhibit-point-motion-hooks t)
6673 (args (mapcar (lambda (group)
6674 (let ((string (match-string group)))
6675 (gnus-set-text-properties
6676 0 (length string) nil string)
6683 (fboundp (symbol-value fun)))
6684 (apply (symbol-value fun) args))
6686 (gnus-message 1 "You must define `%S' to use this button"
6687 (cons fun args)))))))
6689 (defun gnus-parse-news-url (url)
6690 (let (scheme server port group message-id articles)
6693 (goto-char (point-min))
6694 (when (looking-at "\\([A-Za-z]+\\):")
6695 (setq scheme (match-string 1))
6696 (goto-char (match-end 0)))
6697 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6698 (setq server (match-string 1))
6699 (setq port (if (stringp (match-string 3))
6700 (string-to-number (match-string 3))
6702 (goto-char (match-end 0)))
6705 ((looking-at "\\(.*@.*\\)")
6706 (setq message-id (match-string 1)))
6707 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6708 (setq group (match-string 1)
6709 articles (split-string (match-string 2) "-")))
6710 ((looking-at "\\([^/]+\\)/?")
6711 (setq group (match-string 1)))
6713 (error "Unknown news URL syntax"))))
6714 (list scheme server port group message-id articles)))
6716 (defun gnus-button-handle-news (url)
6718 (destructuring-bind (scheme server port group message-id articles)
6719 (gnus-parse-news-url url)
6723 (set-buffer gnus-summary-buffer)
6725 (let ((gnus-refer-article-method
6726 (nconc (list (list 'nntp server))
6727 gnus-refer-article-method))
6728 (nntp-port-number (or port "nntp")))
6729 (gnus-message 7 "Fetching %s with %s"
6730 message-id gnus-refer-article-method)
6731 (gnus-summary-refer-article message-id))
6732 (gnus-summary-refer-article message-id))))
6734 (gnus-button-fetch-group url)))))
6736 (defun gnus-button-handle-man (url)
6738 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6739 (when (eq gnus-button-man-handler 'woman)
6740 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6741 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6742 (funcall gnus-button-man-handler url))
6744 (defun gnus-button-handle-info-url (url)
6745 "Fetch an info URL."
6746 (setq url (mm-subst-char-in-string ?+ ?\ url))
6748 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6749 (gnus-info-find-node
6750 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6752 ")" (gnus-url-unhex-string (match-string 2 url)))))
6753 ((string-match "([^)\"]+)[^\"]+" url)
6755 (gnus-replace-in-string
6756 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6757 (gnus-info-find-node url))
6758 (t (error "Can't parse %s" url))))
6760 (defun gnus-button-handle-info-url-gnome (url)
6761 "Fetch GNOME style info URL."
6762 (setq url (mm-subst-char-in-string ?_ ?\ url))
6763 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6764 (gnus-info-find-node
6766 (gnus-url-unhex-string
6767 (match-string 1 url))
6769 (or (gnus-url-unhex-string
6770 (match-string 2 url))
6772 (error "Can't parse %s" url)))
6774 (defun gnus-button-handle-info-url-kde (url)
6775 "Fetch KDE style info URL."
6776 (gnus-info-find-node (gnus-url-unhex-string url)))
6778 (defun gnus-button-handle-info-keystrokes (url)
6779 "Call `info' when pushing the corresponding URL button."
6780 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6785 (defun gnus-button-message-id (message-id)
6788 (set-buffer gnus-summary-buffer)
6789 (gnus-summary-refer-article message-id)))
6791 (defun gnus-button-fetch-group (address)
6792 "Fetch GROUP specified by ADDRESS."
6793 (if (not (string-match "[:/]" address))
6794 ;; This is just a simple group url.
6795 (gnus-group-read-ephemeral-group address gnus-select-method)
6798 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6800 (error "Can't parse %s" address)
6801 (gnus-group-read-ephemeral-group
6802 (match-string 4 address)
6803 `(nntp ,(match-string 1 address)
6804 (nntp-address ,(match-string 1 address))
6805 (nntp-port-number ,(if (match-end 3)
6806 (match-string 3 address)
6809 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6811 (defun gnus-url-parse-query-string (query &optional downcase)
6812 (let (retval pairs cur key val)
6813 (setq pairs (split-string query "&"))
6815 (setq cur (car pairs)
6817 (if (not (string-match "=" cur))
6819 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6820 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6822 (setq key (downcase key)))
6823 (setq cur (assoc key retval))
6825 (setcdr cur (cons val (cdr cur)))
6826 (setq retval (cons (list key val) retval)))))
6829 (defun gnus-url-mailto (url)
6830 ;; Send mail to someone
6831 (when (string-match "mailto:/*\\(.*\\)" url)
6832 (setq url (substring url (match-beginning 1) nil)))
6833 (let (to args subject func)
6834 (setq args (gnus-url-parse-query-string
6835 (if (string-match "^\\?" url)
6837 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6838 (concat "to=" (match-string 1 url) "&"
6839 (match-string 2 url))
6840 (concat "to=" url)))
6842 subject (cdr-safe (assoc "subject" args)))
6845 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6848 (message-position-on-field (caar args)))
6849 (insert (gnus-replace-in-string
6850 (mapconcat 'identity (reverse (cdar args)) ", ")
6852 (setq args (cdr args)))
6855 (message-goto-subject))))
6857 (defun gnus-button-embedded-url (address)
6858 "Activate ADDRESS with `browse-url'."
6859 (browse-url (gnus-strip-whitespace address)))
6861 ;;; Next/prev buttons in the article buffer.
6863 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6864 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6866 (defvar gnus-prev-page-map
6867 (let ((map (make-sparse-keymap)))
6868 (unless (>= emacs-major-version 21)
6869 ;; XEmacs doesn't care.
6870 (set-keymap-parent map gnus-article-mode-map))
6871 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6872 (define-key map "\r" 'gnus-button-prev-page)
6875 (defvar gnus-next-page-map
6876 (let ((map (make-sparse-keymap)))
6877 (unless (>= emacs-major-version 21)
6878 ;; XEmacs doesn't care.
6879 (set-keymap-parent map gnus-article-mode-map))
6880 (define-key map gnus-mouse-2 'gnus-button-next-page)
6881 (define-key map "\r" 'gnus-button-next-page)
6884 (defun gnus-insert-prev-page-button ()
6886 (inhibit-read-only t))
6888 gnus-prev-page-line-format nil
6889 `(,@(gnus-local-map-property gnus-prev-page-map)
6891 gnus-callback gnus-article-button-prev-page
6892 article-type annotation))
6893 (widget-convert-button
6895 ;; Exclude a newline.
6898 :action 'gnus-button-prev-page
6899 :button-keymap gnus-prev-page-map)))
6901 (defun gnus-button-next-page (&optional args more-args)
6902 "Go to the next page."
6904 (let ((win (selected-window)))
6905 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6906 (gnus-article-next-page)
6907 (select-window win)))
6909 (defun gnus-button-prev-page (&optional args more-args)
6910 "Go to the prev page."
6912 (let ((win (selected-window)))
6913 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6914 (gnus-article-prev-page)
6915 (select-window win)))
6917 (defun gnus-insert-next-page-button ()
6919 (inhibit-read-only t))
6920 (gnus-eval-format gnus-next-page-line-format nil
6921 `(,@(gnus-local-map-property gnus-next-page-map)
6923 gnus-callback gnus-article-button-next-page
6924 article-type annotation))
6925 (widget-convert-button
6927 ;; Exclude a newline.
6930 :action 'gnus-button-next-page
6931 :button-keymap gnus-next-page-map)))
6933 (defun gnus-article-button-next-page (arg)
6934 "Go to the next page."
6936 (let ((win (selected-window)))
6937 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6938 (gnus-article-next-page)
6939 (select-window win)))
6941 (defun gnus-article-button-prev-page (arg)
6942 "Go to the prev page."
6944 (let ((win (selected-window)))
6945 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6946 (gnus-article-prev-page)
6947 (select-window win)))
6949 (defvar gnus-decode-header-methods
6950 '(mail-decode-encoded-word-region)
6951 "List of methods used to decode headers.
6953 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6954 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6955 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6956 whose names match REGEXP.
6959 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6960 mail-decode-encoded-word-region
6961 (\"chinese\" . rfc1843-decode-region))
6964 (defvar gnus-decode-header-methods-cache nil)
6966 (defun gnus-multi-decode-header (start end)
6967 "Apply the functions from `gnus-encoded-word-methods' that match."
6968 (unless (and gnus-decode-header-methods-cache
6969 (eq gnus-newsgroup-name
6970 (car gnus-decode-header-methods-cache)))
6971 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6974 (nconc gnus-decode-header-methods-cache (list x))
6975 (if (and gnus-newsgroup-name
6976 (string-match (car x) gnus-newsgroup-name))
6977 (nconc gnus-decode-header-methods-cache
6979 gnus-decode-header-methods))
6980 (let ((xlist gnus-decode-header-methods-cache))
6983 (narrow-to-region start end)
6985 (funcall (pop xlist) (point-min) (point-max))))))
6988 ;;; Treatment top-level handling.
6991 (defun gnus-treat-article (condition &optional part-number total-parts type)
6992 (let ((length (- (point-max) (point-min)))
6993 (alist gnus-treatment-function-alist)
6994 (article-goto-body-goes-to-point-min-p t)
6998 (let ((list gnus-article-treat-types))
7000 (when (string-match (pop list) type)
7001 (throw 'found t)))))))
7002 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7004 (gnus-run-hooks 'gnus-part-display-hook)
7005 (dolist (elem alist)
7008 (when (gnus-buffer-live-p gnus-summary-buffer)
7009 (set-buffer gnus-summary-buffer))
7010 (symbol-value (car elem))))
7011 (when (and (or (consp val)
7013 (gnus-treat-predicate val)
7014 (or (not (get (car elem) 'highlight))
7017 (funcall (cadr elem)))))))
7019 ;; Dynamic variables.
7021 (defvar part-number)
7022 (defvar total-parts)
7027 (defun gnus-treat-predicate (val)
7034 (stringp (car val)))
7035 (apply 'gnus-or (mapcar `(lambda (s)
7036 (string-match s ,(or gnus-newsgroup-name "")))
7039 (let ((pred (pop val)))
7042 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7044 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7046 (not (gnus-treat-predicate (car val))))
7048 (equal (car val) type))
7050 (error "%S is not a valid predicate" pred)))))
7056 (eq part-number total-parts))
7060 (error "%S is not a valid value" val))))
7062 (defun gnus-article-encrypt-body (protocol &optional n)
7063 "Encrypt the article body."
7066 (or gnus-article-encrypt-protocol
7067 (completing-read "Encrypt protocol: "
7068 gnus-article-encrypt-protocol-alist
7070 current-prefix-arg))
7071 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7073 (error "Can't find the encrypt protocol %s" protocol))
7074 (if (member gnus-newsgroup-name '("nndraft:delayed"
7077 (error "Can't encrypt the article in group %s"
7078 gnus-newsgroup-name))
7079 (gnus-summary-iterate n
7081 (set-buffer gnus-summary-buffer)
7082 (let ((mail-parse-charset gnus-newsgroup-charset)
7083 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7084 (summary-buffer gnus-summary-buffer)
7086 (gnus-set-global-variables)
7087 (when (gnus-group-read-only-p)
7088 (error "The current newsgroup does not support article encrypt"))
7089 (gnus-summary-show-article t)
7091 (or (mail-header-references gnus-current-headers) ""))
7092 (set-buffer gnus-article-buffer)
7093 (let* ((inhibit-read-only t)
7095 (mapcar (lambda (field)
7096 (and (save-restriction
7097 (message-narrow-to-head)
7098 (goto-char (point-min))
7099 (search-forward field nil t))
7101 (message-narrow-to-field)
7103 (delete-region (point-min) (point-max))
7105 '("Content-Type:" "Content-Transfer-Encoding:"
7106 "Content-Disposition:"))))
7107 (message-narrow-to-head)
7108 (message-remove-header "MIME-Version")
7109 (goto-char (point-max))
7110 (setq point (point))
7111 (insert (apply 'concat headers))
7113 (narrow-to-region point (point-max))
7114 (let ((message-options message-options))
7115 (message-options-set 'message-sender user-mail-address)
7116 (message-options-set 'message-recipients user-mail-address)
7117 (message-options-set 'message-sign-encrypt 'not)
7119 (goto-char (point-min))
7120 (insert "MIME-Version: 1.0\n")
7122 (gnus-summary-edit-article-done
7123 references nil summary-buffer t))
7124 (when gnus-keep-backlog
7125 (gnus-backlog-remove-article
7126 (car gnus-article-current) (cdr gnus-article-current)))
7128 (when (get-buffer gnus-original-article-buffer)
7129 (set-buffer gnus-original-article-buffer)
7130 (setq gnus-original-article nil)))
7131 (when gnus-use-cache
7132 (gnus-cache-update-article
7133 (car gnus-article-current) (cdr gnus-article-current))))))))
7135 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7136 "The following specs can be used:
7137 %t The security MIME type
7140 %D Details if button is pressed")
7142 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7143 "The following specs can be used:
7144 %t The security MIME type
7147 %D Details if button is pressed")
7149 (defvar gnus-mime-security-button-line-format-alist
7150 '((?t gnus-tmp-type ?s)
7151 (?i gnus-tmp-info ?s)
7152 (?d gnus-tmp-details ?s)
7153 (?D gnus-tmp-pressed-details ?s)))
7155 (defvar gnus-mime-security-button-map
7156 (let ((map (make-sparse-keymap)))
7157 (unless (>= (string-to-number emacs-version) 21)
7158 (set-keymap-parent map gnus-article-mode-map))
7159 (define-key map gnus-mouse-2 'gnus-article-push-button)
7160 (define-key map "\r" 'gnus-article-press-button)
7163 (defvar gnus-mime-security-details-buffer nil)
7165 (defvar gnus-mime-security-button-pressed nil)
7167 (defvar gnus-mime-security-show-details-inline t
7168 "If non-nil, show details in the article buffer.")
7170 (defun gnus-mime-security-verify-or-decrypt (handle)
7171 (mm-remove-parts (cdr handle))
7172 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7173 point (inhibit-read-only t))
7175 (goto-char (car region)))
7177 (narrow-to-region (point) (point))
7178 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7179 (let* ((mm-verify-option 'known)
7180 (mm-decrypt-option 'known)
7181 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7182 (unless (eq nparts (cdr handle))
7183 (mm-destroy-parts (cdr handle))
7184 (setcdr handle nparts))))
7185 (setq point (point))
7186 (gnus-mime-display-security handle)
7187 (goto-char (point-max)))
7189 (delete-region (point) (cdr region))
7190 (set-marker (car region) nil)
7191 (set-marker (cdr region) nil))
7194 (defun gnus-mime-security-show-details (handle)
7195 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7197 (gnus-message 5 "No details.")
7198 (if gnus-mime-security-show-details-inline
7199 (let ((gnus-mime-security-button-pressed
7200 (not (get-text-property (point) 'gnus-mime-details)))
7201 (gnus-mime-security-button-line-format
7202 (get-text-property (point) 'gnus-line-format))
7203 (inhibit-read-only t))
7205 (while (eq (get-text-property (point) 'gnus-line-format)
7206 gnus-mime-security-button-line-format)
7210 (narrow-to-region (point) (point))
7211 (gnus-insert-mime-security-button handle))
7212 (delete-region (point)
7213 (or (text-property-not-all
7216 gnus-mime-security-button-line-format)
7219 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7220 (with-current-buffer gnus-mime-security-details-buffer
7223 (setq gnus-mime-security-details-buffer
7224 (gnus-get-buffer-create "*MIME Security Details*")))
7225 (with-current-buffer gnus-mime-security-details-buffer
7227 (goto-char (point-min)))
7228 (pop-to-buffer gnus-mime-security-details-buffer)))))
7230 (defun gnus-mime-security-press-button (handle)
7232 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7233 (gnus-mime-security-show-details handle)
7234 (gnus-mime-security-verify-or-decrypt handle))))
7236 (defun gnus-insert-mime-security-button (handle &optional displayed)
7237 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7240 (or (nth 2 (assoc protocol mm-verify-function-alist))
7241 (nth 2 (assoc protocol mm-decrypt-function-alist))
7243 (if (equal (car handle) "multipart/signed")
7244 " Signed" " Encrypted")
7247 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7250 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7251 gnus-tmp-pressed-details
7253 (setq gnus-tmp-details
7254 (if gnus-tmp-details
7255 (concat "\n" gnus-tmp-details)
7257 (setq gnus-tmp-pressed-details
7258 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7263 gnus-mime-security-button-line-format
7264 gnus-mime-security-button-line-format-alist
7265 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7266 gnus-callback gnus-mime-security-press-button
7267 gnus-line-format ,gnus-mime-security-button-line-format
7268 gnus-mime-details ,gnus-mime-security-button-pressed
7269 article-type annotation
7272 ;; Exclude a newline.
7275 (widget-convert-button
7278 :action 'gnus-widget-press-button
7279 :button-keymap gnus-mime-security-button-map
7281 (lambda (widget/window &optional overlay pos)
7282 ;; Needed to properly clear the message due to a bug in
7283 ;; wid-edit (XEmacs only).
7284 (when (boundp 'help-echo-owns-message)
7285 (setq help-echo-owns-message t))
7288 (aref gnus-mouse-2 0))))))
7290 (defun gnus-mime-display-security (handle)
7292 (narrow-to-region (point) (point))
7293 (unless (gnus-unbuttonized-mime-type-p (car handle))
7294 (gnus-insert-mime-security-button handle))
7295 (gnus-mime-display-mixed (cdr handle))
7298 (unless (gnus-unbuttonized-mime-type-p (car handle))
7299 (let ((gnus-mime-security-button-line-format
7300 gnus-mime-security-button-end-line-format))
7301 (gnus-insert-mime-security-button handle)))
7302 (mm-set-handle-multipart-parameter
7304 (cons (set-marker (make-marker) (point-min))
7305 (set-marker (make-marker) (point-max))))))
7311 (run-hooks 'gnus-art-load-hook)
7313 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7314 ;;; gnus-art.el ends here