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 '(("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
371 2 3 gnus-emphasis-strikethru
)
372 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
373 2 3 gnus-emphasis-underline
))))
374 "*Alist that says how to fontify certain phrases.
375 Each item looks like this:
377 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
379 The first element is a regular expression to be matched. The second
380 is a number that says what regular expression grouping used to find
381 the entire emphasized word. The third is a number that says what
382 regexp grouping should be displayed and highlighted. The fourth
383 is the face used for highlighting."
387 :format
"%[Customizing Style%]\n%v"
389 (group :tag
"Default"
390 :value
("" 0 0 default
)
393 (let ((value (widget-get
394 (cadr (widget-get (widget-get widget
:parent
)
397 (if (not (eq (nth 2 value
) 'default
))
401 (gnus-emphasis-custom-value-to-external value
))))
402 (widget-group-value-create widget
))
404 (integer :format
"Match group: %v")
405 (integer :format
"Emphasize group: %v")
408 :value
(("_" .
"_") nil default
)
410 (regexp :format
"Start regexp: %v")
411 (regexp :format
"End regexp: %v"))
412 (boolean :format
"Show start and end patterns: %[%v%]\n"
413 :on
" On " :off
" Off ")
415 :get
(lambda (symbol)
416 (mapcar 'gnus-emphasis-custom-value-to-internal
417 (default-value symbol
)))
418 :set
(lambda (symbol value
)
419 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
421 :group
'gnus-article-emphasis
)
423 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
424 "A regexp to describe whitespace which should not be emphasized.
425 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
426 The former avoids underlining of leading and trailing whitespace,
427 and the latter avoids underlining any whitespace at all."
429 :group
'gnus-article-emphasis
432 (defface gnus-emphasis-bold
'((t (:bold t
)))
433 "Face used for displaying strong emphasized text (*word*)."
434 :group
'gnus-article-emphasis
)
436 (defface gnus-emphasis-italic
'((t (:italic t
)))
437 "Face used for displaying italic emphasized text (/word/)."
438 :group
'gnus-article-emphasis
)
440 (defface gnus-emphasis-underline
'((t (:underline t
)))
441 "Face used for displaying underlined emphasized text (_word_)."
442 :group
'gnus-article-emphasis
)
444 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
445 "Face used for displaying underlined bold emphasized text (_*word*_)."
446 :group
'gnus-article-emphasis
)
448 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
449 "Face used for displaying underlined italic emphasized text (_/word/_)."
450 :group
'gnus-article-emphasis
)
452 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
453 "Face used for displaying bold italic emphasized text (/*word*/)."
454 :group
'gnus-article-emphasis
)
456 (defface gnus-emphasis-underline-bold-italic
457 '((t (:bold t
:italic t
:underline t
)))
458 "Face used for displaying underlined bold italic emphasized text.
459 Example: (_/*word*/_)."
460 :group
'gnus-article-emphasis
)
462 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
463 '((t (:strikethru t
)))
464 '((t (:strike-through t
))))
465 "Face used for displaying strike-through text (-word-)."
466 :group
'gnus-article-emphasis
)
468 (defface gnus-emphasis-highlight-words
469 '((t (:background
"black" :foreground
"yellow")))
470 "Face used for displaying highlighted words."
471 :group
'gnus-article-emphasis
)
473 (defcustom gnus-article-time-format
"%a, %b %d %Y %T %Z"
474 "Format for display of Date headers in article bodies.
475 See `format-time-string' for the possible values.
477 The variable can also be function, which should return a complete Date
478 header. The function is called with one argument, the time, which can
479 be fed to `format-time-string'."
480 :type
'(choice string symbol
)
481 :link
'(custom-manual "(gnus)Article Date")
482 :group
'gnus-article-washing
)
484 (defcustom gnus-save-all-headers t
485 "*If non-nil, don't remove any headers before saving."
486 :group
'gnus-article-saving
489 (defcustom gnus-prompt-before-saving
'always
490 "*This variable says how much prompting is to be done when saving articles.
491 If it is nil, no prompting will be done, and the articles will be
492 saved to the default files. If this variable is `always', each and
493 every article that is saved will be preceded by a prompt, even when
494 saving large batches of articles. If this variable is neither nil not
495 `always', there the user will be prompted once for a file name for
496 each invocation of the saving commands."
497 :group
'gnus-article-saving
498 :type
'(choice (item always
)
499 (item :tag
"never" nil
)
500 (sexp :tag
"once" :format
"%t\n" :value t
)))
502 (defcustom gnus-saved-headers gnus-visible-headers
503 "Headers to keep if `gnus-save-all-headers' is nil.
504 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
505 If that variable is nil, however, all headers that match this regexp
506 will be kept while the rest will be deleted before saving."
507 :group
'gnus-article-saving
510 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
511 "A function to save articles in your favourite format.
512 The function must be interactively callable (in other words, it must
513 be an Emacs command).
515 Gnus provides the following functions:
517 * gnus-summary-save-in-rmail (Rmail format)
518 * gnus-summary-save-in-mail (Unix mail format)
519 * gnus-summary-save-in-folder (MH folder)
520 * gnus-summary-save-in-file (article format)
521 * gnus-summary-save-body-in-file (article body)
522 * gnus-summary-save-in-vm (use VM's folder format)
523 * gnus-summary-write-to-file (article format -- overwrite)."
524 :group
'gnus-article-saving
525 :type
'(radio (function-item gnus-summary-save-in-rmail
)
526 (function-item gnus-summary-save-in-mail
)
527 (function-item gnus-summary-save-in-folder
)
528 (function-item gnus-summary-save-in-file
)
529 (function-item gnus-summary-save-body-in-file
)
530 (function-item gnus-summary-save-in-vm
)
531 (function-item gnus-summary-write-to-file
)))
533 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
534 "A function generating a file name to save articles in Rmail format.
535 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
536 :group
'gnus-article-saving
539 (defcustom gnus-mail-save-name
'gnus-plain-save-name
540 "A function generating a file name to save articles in Unix mail format.
541 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
542 :group
'gnus-article-saving
545 (defcustom gnus-folder-save-name
'gnus-folder-save-name
546 "A function generating a file name to save articles in MH folder.
547 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
548 :group
'gnus-article-saving
551 (defcustom gnus-file-save-name
'gnus-numeric-save-name
552 "A function generating a file name to save articles in article format.
553 The function is called with NEWSGROUP, HEADERS, and optional
555 :group
'gnus-article-saving
558 (defcustom gnus-split-methods
559 '((gnus-article-archive-name)
560 (gnus-article-nndoc-name))
561 "*Variable used to suggest where articles are to be saved.
562 For instance, if you would like to save articles related to Gnus in
563 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
564 you could set this variable to something like:
566 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
567 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
569 This variable is an alist where the where the key is the match and the
570 value is a list of possible files to save in if the match is non-nil.
572 If the match is a string, it is used as a regexp match on the
573 article. If the match is a symbol, that symbol will be funcalled
574 from the buffer of the article to be saved with the newsgroup as the
575 parameter. If it is a list, it will be evaled in the same buffer.
577 If this form or function returns a string, this string will be used as
578 a possible file name; and if it returns a non-nil list, that list will
579 be used as possible file names."
580 :group
'gnus-article-saving
581 :type
'(repeat (choice (list :value
(fun) function
)
582 (cons :value
("" "") regexp
(repeat string
))
585 (defcustom gnus-page-delimiter
"^\^L"
586 "*Regexp describing what to use as article page delimiters.
587 The default value is \"^\^L\", which is a form linefeed at the
588 beginning of a line."
590 :group
'gnus-article-various
)
592 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
593 "*The format specification for the article mode line.
594 See `gnus-summary-mode-line-format' for a closer description.
596 The following additional specs are available:
598 %w The article washing status.
599 %m The number of MIME parts in the article."
601 :group
'gnus-article-various
)
603 (defcustom gnus-article-mode-hook nil
604 "*A hook for Gnus article mode."
606 :group
'gnus-article-various
)
608 (when (featurep 'xemacs
)
609 ;; Extracted from gnus-xmas-define in order to preserve user settings
610 (when (fboundp 'turn-off-scroll-in-place
)
611 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
612 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
613 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
615 (defcustom gnus-article-menu-hook nil
616 "*Hook run after the creation of the article mode menu."
618 :group
'gnus-article-various
)
620 (defcustom gnus-article-prepare-hook nil
621 "*A hook called after an article has been prepared in the article buffer."
623 :group
'gnus-article-various
)
625 (make-obsolete-variable 'gnus-article-hide-pgp-hook
626 "This variable is obsolete in Gnus 5.10.")
628 (defcustom gnus-article-button-face
'bold
629 "Face used for highlighting buttons in the article buffer.
631 An article button is a piece of text that you can activate by pressing
632 `RET' or `mouse-2' above it."
634 :group
'gnus-article-buttons
)
636 (defcustom gnus-article-mouse-face
'highlight
637 "Face used for mouse highlighting in the article buffer.
639 Article buttons will be displayed in this face when the cursor is
642 :group
'gnus-article-buttons
)
644 (defcustom gnus-signature-face
'gnus-signature-face
645 "Face used for highlighting a signature in the article buffer.
646 Obsolete; use the face `gnus-signature-face' for customizations instead."
648 :group
'gnus-article-highlight
649 :group
'gnus-article-signature
)
651 (defface gnus-signature-face
654 "Face used for highlighting a signature in the article buffer."
655 :group
'gnus-article-highlight
656 :group
'gnus-article-signature
)
658 (defface gnus-header-from-face
661 (:foreground
"spring green"))
664 (:foreground
"red3"))
667 "Face used for displaying from headers."
668 :group
'gnus-article-headers
669 :group
'gnus-article-highlight
)
671 (defface gnus-header-subject-face
674 (:foreground
"SeaGreen3"))
677 (:foreground
"red4"))
679 (:bold t
:italic t
)))
680 "Face used for displaying subject headers."
681 :group
'gnus-article-headers
682 :group
'gnus-article-highlight
)
684 (defface gnus-header-newsgroups-face
687 (:foreground
"yellow" :italic t
))
690 (:foreground
"MidnightBlue" :italic t
))
693 "Face used for displaying newsgroups headers.
694 In the default setup this face is only used for crossposted
696 :group
'gnus-article-headers
697 :group
'gnus-article-highlight
)
699 (defface gnus-header-name-face
702 (:foreground
"SeaGreen"))
705 (:foreground
"maroon"))
708 "Face used for displaying header names."
709 :group
'gnus-article-headers
710 :group
'gnus-article-highlight
)
712 (defface gnus-header-content-face
715 (:foreground
"forest green" :italic t
))
718 (:foreground
"indianred4" :italic t
))
720 (:italic t
))) "Face used for displaying header content."
721 :group
'gnus-article-headers
722 :group
'gnus-article-highlight
)
724 (defcustom gnus-header-face-alist
725 '(("From" nil gnus-header-from-face
)
726 ("Subject" nil gnus-header-subject-face
)
727 ("Newsgroups:.*," nil gnus-header-newsgroups-face
)
728 ("" gnus-header-name-face gnus-header-content-face
))
729 "*Controls highlighting of article headers.
731 An alist of the form (HEADER NAME CONTENT).
733 HEADER is a regular expression which should match the name of a
734 header and NAME and CONTENT are either face names or nil.
736 The name of each header field will be displayed using the face
737 specified by the first element in the list where HEADER matches
738 the header name and NAME is non-nil. Similarly, the content will
739 be displayed by the first non-nil matching CONTENT face."
740 :group
'gnus-article-headers
741 :group
'gnus-article-highlight
742 :type
'(repeat (list (regexp :tag
"Header")
744 (item :tag
"skip" nil
)
745 (face :value default
))
746 (choice :tag
"Content"
747 (item :tag
"skip" nil
)
748 (face :value default
)))))
750 (defcustom gnus-article-decode-hook
751 '(article-decode-charset article-decode-encoded-words
752 article-decode-group-name article-decode-idna-rhs
)
753 "*Hook run to decode charsets in articles."
754 :group
'gnus-article-headers
757 (defcustom gnus-display-mime-function
'gnus-display-mime
758 "Function to display MIME articles."
759 :group
'gnus-article-mime
762 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
763 "Function used to decode headers.")
765 (defvar gnus-article-dumbquotes-map
785 "Table for MS-to-Latin1 translation.")
787 (defcustom gnus-ignored-mime-types nil
788 "List of MIME types that should be ignored by Gnus."
790 :group
'gnus-article-mime
791 :type
'(repeat regexp
))
793 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
794 "List of MIME types that should not be given buttons when rendered inline.
795 See also `gnus-buttonized-mime-types' which may override this variable.
796 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
798 :group
'gnus-article-mime
799 :type
'(repeat regexp
))
801 (defcustom gnus-buttonized-mime-types nil
802 "List of MIME types that should be given buttons when rendered inline.
803 If set, this variable overrides `gnus-unbuttonized-mime-types'.
804 To see e.g. security buttons you could set this to
805 `(\"multipart/signed\")'.
806 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
808 :group
'gnus-article-mime
809 :type
'(repeat regexp
))
811 (defcustom gnus-inhibit-mime-unbuttonizing nil
812 "If non-nil, all MIME parts get buttons.
813 When nil (the default value), then some MIME parts do not get buttons,
814 as described by the variables `gnus-buttonized-mime-types' and
815 `gnus-unbuttonized-mime-types'."
817 :group
'gnus-article-mime
820 (defcustom gnus-body-boundary-delimiter
"_"
821 "String used to delimit header and body.
822 This variable is used by `gnus-article-treat-body-boundary' which can
823 be controlled by `gnus-treat-body-boundary'."
825 :group
'gnus-article-various
826 :type
'(choice (item :tag
"None" :value nil
)
829 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces")
830 "Defines the location of the faces database.
831 For information on obtaining this database of pretty pictures, please
832 see http://www.cs.indiana.edu/picons/ftp/index.html"
834 :type
'(repeat directory
)
835 :link
'(url-link :tag
"download"
836 "http://www.cs.indiana.edu/picons/ftp/index.html")
837 :link
'(custom-manual "(gnus)Picons")
840 (defun gnus-picons-installed-p ()
841 "Say whether picons are installed on your machine."
842 (let ((installed nil
))
843 (dolist (database gnus-picon-databases
)
844 (when (file-exists-p database
)
848 (defcustom gnus-article-mime-part-function nil
849 "Function called with a MIME handle as the argument.
850 This is meant for people who want to do something automatic based
851 on parts -- for instance, adding Vcard info to a database."
852 :group
'gnus-article-mime
855 (defcustom gnus-mime-multipart-functions nil
856 "An alist of MIME types to functions to display them."
858 :group
'gnus-article-mime
861 (defcustom gnus-article-date-lapsed-new-header nil
862 "Whether the X-Sent and Date headers can coexist.
863 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
864 either replace the old \"Date:\" header (if this variable is nil), or
865 be added below it (otherwise)."
867 :group
'gnus-article-headers
870 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
871 "Function called with a MIME handle as the argument.
872 This is meant for people who want to view first matched part.
873 For `undisplayed-alternative' (default), the first undisplayed
874 part or alternative part is used. For `undisplayed', the first
875 undisplayed part is used. For a function, the first part which
876 the function return t is used. For nil, the first part is
879 :group
'gnus-article-mime
881 (item :tag
"first" :value nil
)
882 (item :tag
"undisplayed" :value undisplayed
)
883 (item :tag
"undisplayed or alternative"
884 :value undisplayed-alternative
)
887 (defcustom gnus-mime-action-alist
888 '(("save to file" . gnus-mime-save-part
)
889 ("save and strip" . gnus-mime-save-part-and-strip
)
890 ("delete part" . gnus-mime-delete-part
)
891 ("display as text" . gnus-mime-inline-part
)
892 ("view the part" . gnus-mime-view-part
)
893 ("pipe to command" . gnus-mime-pipe-part
)
894 ("toggle display" . gnus-article-press-button
)
895 ("toggle display" . gnus-article-view-part-as-charset
)
896 ("view as type" . gnus-mime-view-part-as-type
)
897 ("view internally" . gnus-mime-view-part-internally
)
898 ("view externally" . gnus-mime-view-part-externally
))
899 "An alist of actions that run on the MIME attachment."
900 :group
'gnus-article-mime
901 :type
'(repeat (cons (string :tag
"name")
905 ;;; The treatment variables
908 (defvar gnus-part-display-hook nil
909 "Hook called on parts that are to receive treatment.")
911 (defvar gnus-article-treat-custom
912 '(choice (const :tag
"Off" nil
)
914 (const :tag
"Header" head
)
915 (const :tag
"Last" last
)
916 (integer :tag
"Less")
917 (repeat :tag
"Groups" regexp
)
918 (sexp :tag
"Predicate")))
920 (defvar gnus-article-treat-head-custom
921 '(choice (const :tag
"Off" nil
)
922 (const :tag
"Header" head
)))
924 (defvar gnus-article-treat-types
'("text/plain")
927 (defvar gnus-inhibit-treatment nil
928 "Whether to inhibit treatment.")
930 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
931 "Highlight the signature.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles'."
934 :group
'gnus-article-treat
935 :link
'(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-custom
)
937 (put 'gnus-treat-highlight-signature
'highlight t
)
939 (defcustom gnus-treat-buttonize
100000
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles'."
943 :group
'gnus-article-treat
944 :link
'(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-custom
)
946 (put 'gnus-treat-buttonize
'highlight t
)
948 (defcustom gnus-treat-buttonize-head
'head
949 "Add buttons to the head.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group
'gnus-article-treat
953 :link
'(custom-manual "(gnus)Customizing Articles")
954 :type gnus-article-treat-head-custom
)
955 (put 'gnus-treat-buttonize-head
'highlight t
)
957 (defcustom gnus-treat-emphasize
958 (and (or window-system
960 (>= (string-to-number emacs-version
) 21))
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group
'gnus-article-treat
966 :link
'(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom
)
968 (put 'gnus-treat-emphasize
'highlight t
)
970 (defcustom gnus-treat-strip-cr nil
971 "Remove carriage returns.
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See Info node `(gnus)Customizing Articles' for details."
975 :group
'gnus-article-treat
976 :link
'(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom
)
979 (defcustom gnus-treat-unsplit-urls nil
980 "Remove newlines from within URLs.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group
'gnus-article-treat
985 :link
'(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom
)
988 (defcustom gnus-treat-leading-whitespace nil
989 "Remove leading whitespace in headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
993 :group
'gnus-article-treat
994 :link
'(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom
)
997 (defcustom gnus-treat-hide-headers
'head
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group
'gnus-article-treat
1002 :link
'(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-head-custom
)
1005 (defcustom gnus-treat-hide-boring-headers nil
1006 "Hide boring headers.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 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-head-custom
)
1013 (defcustom gnus-treat-hide-signature nil
1014 "Hide the signature.
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-custom
)
1021 (defcustom gnus-treat-fill-article nil
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-custom
)
1029 (defcustom gnus-treat-hide-citation nil
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-hide-citation-maybe 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-strip-list-identifiers
'head
1046 "Strip list identifiers from `gnus-list-identifiers`.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1050 :group
'gnus-article-treat
1051 :link
'(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-custom
)
1054 (make-obsolete-variable 'gnus-treat-strip-pgp
1055 "This option is obsolete in Gnus 5.10.")
1057 (defcustom gnus-treat-strip-pem nil
1058 "Strip PEM signatures.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group
'gnus-article-treat
1062 :link
'(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-custom
)
1065 (defcustom gnus-treat-strip-banner t
1066 "Strip banners from articles.
1067 The banner to be stripped is specified in the `banner' group parameter.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group
'gnus-article-treat
1071 :link
'(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-custom
)
1074 (defcustom gnus-treat-highlight-headers
'head
1075 "Highlight the headers.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group
'gnus-article-treat
1079 :link
'(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-head-custom
)
1081 (put 'gnus-treat-highlight-headers
'highlight t
)
1083 (defcustom gnus-treat-highlight-citation t
1084 "Highlight cited text.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group
'gnus-article-treat
1088 :link
'(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom
)
1090 (put 'gnus-treat-highlight-citation
'highlight t
)
1092 (defcustom gnus-treat-date-ut nil
1093 "Display the Date in UT (GMT).
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group
'gnus-article-treat
1097 :link
'(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-head-custom
)
1100 (defcustom gnus-treat-date-local nil
1101 "Display the Date in the local timezone.
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group
'gnus-article-treat
1105 :link
'(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-head-custom
)
1108 (defcustom gnus-treat-date-english nil
1109 "Display the Date in a format that can be read aloud in English.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1113 :group
'gnus-article-treat
1114 :link
'(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-head-custom
)
1117 (defcustom gnus-treat-date-lapsed nil
1118 "Display the Date header in a way that says how much time has elapsed.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group
'gnus-article-treat
1122 :link
'(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-head-custom
)
1125 (defcustom gnus-treat-date-original nil
1126 "Display the date in the original timezone.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 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-iso8601 nil
1134 "Display the date in the ISO8601 format.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1138 :group
'gnus-article-treat
1139 :link
'(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-head-custom
)
1142 (defcustom gnus-treat-date-user-defined nil
1143 "Display the date in a user-defined format.
1144 The format is defined by the `gnus-article-time-format' variable.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1147 :group
'gnus-article-treat
1148 :link
'(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-head-custom
)
1151 (defcustom gnus-treat-strip-headers-in-body t
1152 "Strip the X-No-Archive header line from the beginning of the body.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1156 :group
'gnus-article-treat
1157 :link
'(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom
)
1160 (defcustom gnus-treat-strip-trailing-blank-lines nil
1161 "Strip trailing blank lines.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group
'gnus-article-treat
1165 :link
'(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom
)
1168 (defcustom gnus-treat-strip-leading-blank-lines nil
1169 "Strip leading blank lines.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 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-multiple-blank-lines nil
1177 "Strip multiple 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-unfold-headers
'head
1185 "Unfold folded header lines.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1189 :group
'gnus-article-treat
1190 :link
'(custom-manual "(gnus)Customizing Articles")
1191 :type gnus-article-treat-custom
)
1193 (defcustom gnus-treat-fold-headers nil
1195 Valid values are nil, t, `head', `last', an integer or a predicate.
1196 See Info node `(gnus)Customizing Articles' for details."
1198 :group
'gnus-article-treat
1199 :link
'(custom-manual "(gnus)Customizing Articles")
1200 :type gnus-article-treat-custom
)
1202 (defcustom gnus-treat-fold-newsgroups
'head
1203 "Fold the Newsgroups and Followup-To headers.
1204 Valid values are nil, t, `head', `last', an integer or a predicate.
1205 See Info node `(gnus)Customizing Articles' for details."
1207 :group
'gnus-article-treat
1208 :link
'(custom-manual "(gnus)Customizing Articles")
1209 :type gnus-article-treat-custom
)
1211 (defcustom gnus-treat-overstrike t
1212 "Treat overstrike highlighting.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' for details."
1215 :group
'gnus-article-treat
1216 :link
'(custom-manual "(gnus)Customizing Articles")
1217 :type gnus-article-treat-custom
)
1218 (put 'gnus-treat-overstrike
'highlight t
)
1220 (make-obsolete-variable 'gnus-treat-display-xface
1221 'gnus-treat-display-x-face
)
1223 (defcustom gnus-treat-display-x-face
1224 (and (not noninteractive
)
1225 (or (and (fboundp 'image-type-available-p
)
1226 (image-type-available-p 'xbm
)
1227 (string-match "^0x" (shell-command-to-string "uncompface"))
1228 (executable-find "icontopbm"))
1229 (and (featurep 'xemacs
)
1232 "Display X-Face headers.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' and Info node
1235 `(gnus)X-Face' for details."
1236 :group
'gnus-article-treat
1238 :link
'(custom-manual "(gnus)Customizing Articles")
1239 :link
'(custom-manual "(gnus)X-Face")
1240 :type gnus-article-treat-head-custom
1241 :set
(lambda (symbol value
)
1244 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1246 ((boundp 'gnus-treat-display-xface
)
1248 ** gnus-treat-display-xface is an obsolete variable;\
1249 use gnus-treat-display-x-face instead")
1250 (default-value 'gnus-treat-display-xface
))
1251 ((get 'gnus-treat-display-xface
'saved-value
)
1253 ** gnus-treat-display-xface is an obsolete variable;\
1254 use gnus-treat-display-x-face instead")
1255 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1258 (put 'gnus-treat-display-x-face
'highlight t
)
1260 (defcustom gnus-treat-display-face
1261 (and (not noninteractive
)
1262 (or (and (fboundp 'image-type-available-p
)
1263 (image-type-available-p 'png
))
1264 (and (featurep 'xemacs
)
1267 "Display Face headers.
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' and Info node
1270 `(gnus)X-Face' for details."
1271 :group
'gnus-article-treat
1273 :link
'(custom-manual "(gnus)Customizing Articles")
1274 :link
'(custom-manual "(gnus)X-Face")
1275 :type gnus-article-treat-head-custom
)
1276 (put 'gnus-treat-display-face
'highlight t
)
1278 (defcustom gnus-treat-display-smileys
1279 (if (or (and (featurep 'xemacs
)
1281 (and (fboundp 'image-type-available-p
)
1282 (image-type-available-p 'pbm
)))
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' and Info node
1287 `(gnus)Smileys' for details."
1288 :group
'gnus-article-treat
1290 :link
'(custom-manual "(gnus)Customizing Articles")
1291 :link
'(custom-manual "(gnus)Smileys")
1292 :type gnus-article-treat-custom
)
1293 (put 'gnus-treat-display-smileys
'highlight t
)
1295 (defcustom gnus-treat-from-picon
1296 (if (and (gnus-image-type-available-p 'xpm
)
1297 (gnus-picons-installed-p))
1299 "Display picons in the From header.
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' and Info node
1302 `(gnus)Picons' for details."
1304 :group
'gnus-article-treat
1306 :link
'(custom-manual "(gnus)Customizing Articles")
1307 :link
'(custom-manual "(gnus)Picons")
1308 :type gnus-article-treat-head-custom
)
1309 (put 'gnus-treat-from-picon
'highlight t
)
1311 (defcustom gnus-treat-mail-picon
1312 (if (and (gnus-image-type-available-p 'xpm
)
1313 (gnus-picons-installed-p))
1315 "Display picons in To and Cc headers.
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-mail-picon
'highlight t
)
1327 (defcustom gnus-treat-newsgroups-picon
1328 (if (and (gnus-image-type-available-p 'xpm
)
1329 (gnus-picons-installed-p))
1331 "Display picons in the Newsgroups and Followup-To 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-newsgroups-picon
'highlight t
)
1343 (defcustom gnus-treat-body-boundary
1344 (if (or gnus-treat-newsgroups-picon
1345 gnus-treat-mail-picon
1346 gnus-treat-from-picon
)
1348 "Draw a boundary at the end of the headers.
1349 Valid values are nil and `head'.
1350 See Info node `(gnus)Customizing Articles' for details."
1352 :group
'gnus-article-treat
1353 :link
'(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-head-custom
)
1356 (defcustom gnus-treat-capitalize-sentences nil
1357 "Capitalize sentence-starting words.
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' for details."
1361 :group
'gnus-article-treat
1362 :link
'(custom-manual "(gnus)Customizing Articles")
1363 :type gnus-article-treat-custom
)
1365 (defcustom gnus-treat-wash-html nil
1367 Valid values are nil, t, `head', `last', an integer or a predicate.
1368 See Info node `(gnus)Customizing Articles' for details."
1370 :group
'gnus-article-treat
1371 :link
'(custom-manual "(gnus)Customizing Articles")
1372 :type gnus-article-treat-custom
)
1374 (defcustom gnus-treat-fill-long-lines nil
1376 Valid values are nil, t, `head', `last', an integer or a predicate.
1377 See Info node `(gnus)Customizing Articles' for details."
1378 :group
'gnus-article-treat
1379 :link
'(custom-manual "(gnus)Customizing Articles")
1380 :type gnus-article-treat-custom
)
1382 (defcustom gnus-treat-play-sounds nil
1384 Valid values are nil, t, `head', `last', an integer or a predicate.
1385 See Info node `(gnus)Customizing Articles' for details."
1387 :group
'gnus-article-treat
1388 :link
'(custom-manual "(gnus)Customizing Articles")
1389 :type gnus-article-treat-custom
)
1391 (defcustom gnus-treat-translate nil
1392 "Translate articles from one language to another.
1393 Valid values are nil, t, `head', `last', an integer or a predicate.
1394 See Info node `(gnus)Customizing Articles' for details."
1396 :group
'gnus-article-treat
1397 :link
'(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom
)
1400 (defcustom gnus-treat-x-pgp-sig nil
1402 To automatically treat X-PGP-Sig, set it to head.
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1406 :group
'gnus-article-treat
1407 :group
'mime-security
1408 :link
'(custom-manual "(gnus)Customizing Articles")
1409 :type gnus-article-treat-custom
)
1411 (defvar gnus-article-encrypt-protocol-alist
1412 '(("PGP" . mml2015-self-encrypt
)))
1414 ;; Set to nil if more than one protocol added to
1415 ;; gnus-article-encrypt-protocol-alist.
1416 (defcustom gnus-article-encrypt-protocol
"PGP"
1417 "The protocol used for encrypt articles.
1418 It is a string, such as \"PGP\". If nil, ask user."
1421 :group
'mime-security
)
1423 (defvar gnus-article-wash-function nil
1424 "Function used for converting HTML into text.")
1426 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1427 (mm-coding-system-p 'utf-8
)
1428 (executable-find idna-program
))
1429 "Whether IDNA decoding of headers is used when viewing messages.
1430 This requires GNU Libidn, and by default only enabled if it is found."
1432 :group
'gnus-article-headers
1435 (defcustom gnus-article-over-scroll nil
1436 "If non-nil, allow scrolling the article buffer even when there no more text."
1438 :group
'gnus-article
1441 ;;; Internal variables
1443 (defvar gnus-english-month-names
1444 '("January" "February" "March" "April" "May" "June" "July" "August"
1445 "September" "October" "November" "December"))
1447 (defvar article-goto-body-goes-to-point-min-p nil
)
1448 (defvar gnus-article-wash-types nil
)
1449 (defvar gnus-article-emphasis-alist nil
)
1450 (defvar gnus-article-image-alist nil
)
1452 (defvar gnus-article-mime-handle-alist-1 nil
)
1453 (defvar gnus-treatment-function-alist
1454 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1455 (gnus-treat-strip-banner gnus-article-strip-banner
)
1456 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1457 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1458 (gnus-treat-buttonize gnus-article-add-buttons
)
1459 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1460 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1461 (gnus-treat-strip-cr gnus-article-remove-cr
)
1462 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1463 (gnus-treat-date-ut gnus-article-date-ut
)
1464 (gnus-treat-date-local gnus-article-date-local
)
1465 (gnus-treat-date-english gnus-article-date-english
)
1466 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1467 (gnus-treat-date-original gnus-article-date-original
)
1468 (gnus-treat-date-user-defined gnus-article-date-user
)
1469 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1470 (gnus-treat-display-x-face gnus-article-display-x-face
)
1471 (gnus-treat-display-face gnus-article-display-face
)
1472 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1473 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1474 (gnus-treat-hide-signature gnus-article-hide-signature
)
1475 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1476 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1477 (gnus-treat-strip-pem gnus-article-hide-pem
)
1478 (gnus-treat-from-picon gnus-treat-from-picon
)
1479 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1480 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1481 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1482 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1483 (gnus-treat-strip-trailing-blank-lines
1484 gnus-article-remove-trailing-blank-lines
)
1485 (gnus-treat-strip-leading-blank-lines
1486 gnus-article-strip-leading-blank-lines
)
1487 (gnus-treat-strip-multiple-blank-lines
1488 gnus-article-strip-multiple-blank-lines
)
1489 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1490 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1491 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1492 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1493 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1494 (gnus-treat-display-smileys gnus-treat-smiley
)
1495 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1496 (gnus-treat-wash-html gnus-article-wash-html
)
1497 (gnus-treat-emphasize gnus-article-emphasize
)
1498 (gnus-treat-hide-citation gnus-article-hide-citation
)
1499 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1500 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1501 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)
1502 (gnus-treat-play-sounds gnus-earcon-display
)))
1504 (defvar gnus-article-mime-handle-alist nil
)
1505 (defvar article-lapsed-timer nil
)
1506 (defvar gnus-article-current-summary nil
)
1508 (defvar gnus-article-mode-syntax-table
1509 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1510 ;; This causes the citation match run O(2^n).
1511 ;; (modify-syntax-entry ?- "w" table)
1512 (modify-syntax-entry ?
> ")<" table
)
1513 (modify-syntax-entry ?
< "(>" table
)
1514 ;; make M-. in article buffers work for `foo' strings
1515 (modify-syntax-entry ?
' " " table
)
1516 (modify-syntax-entry ?
` " " table
)
1518 "Syntax table used in article mode buffers.
1519 Initialized from `text-mode-syntax-table.")
1521 (defvar gnus-save-article-buffer nil
)
1523 (defvar gnus-article-mode-line-format-alist
1524 (nconc '((?w
(gnus-article-wash-status) ?s
)
1525 (?m
(gnus-article-mime-part-status) ?s
))
1526 gnus-summary-mode-line-format-alist
))
1528 (defvar gnus-number-of-articles-to-be-saved nil
)
1530 (defvar gnus-inhibit-hiding nil
)
1532 (defvar gnus-article-edit-mode nil
)
1534 ;;; Macros for dealing with the article buffer.
1536 (defmacro gnus-with-article-headers
(&rest forms
)
1538 (set-buffer gnus-article-buffer
)
1540 (let ((inhibit-read-only t
)
1541 (inhibit-point-motion-hooks t
)
1542 (case-fold-search t
))
1543 (article-narrow-to-head)
1546 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1547 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1549 (defmacro gnus-with-article-buffer
(&rest forms
)
1551 (set-buffer gnus-article-buffer
)
1552 (let ((inhibit-read-only t
))
1555 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1556 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1558 (defun gnus-article-goto-header (header)
1559 "Go to HEADER, which is a regular expression."
1560 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1562 (defsubst gnus-article-hide-text
(b e props
)
1563 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1564 (gnus-add-text-properties-when 'article-type nil b e props
)
1565 (when (memq 'intangible props
)
1567 (max (1- b
) (point-min))
1568 b
'intangible
(cddr (memq 'intangible props
)))))
1570 (defsubst gnus-article-unhide-text
(b e
)
1571 "Remove hidden text properties from region between B and E."
1572 (remove-text-properties b e gnus-hidden-properties
)
1573 (when (memq 'intangible gnus-hidden-properties
)
1574 (put-text-property (max (1- b
) (point-min))
1575 b
'intangible nil
)))
1577 (defun gnus-article-hide-text-type (b e type
)
1578 "Hide text of TYPE between B and E."
1579 (gnus-add-wash-type type
)
1580 (gnus-article-hide-text
1581 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1583 (defun gnus-article-unhide-text-type (b e type
)
1584 "Unhide text of TYPE between B and E."
1585 (gnus-delete-wash-type type
)
1586 (remove-text-properties
1587 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1588 (when (memq 'intangible gnus-hidden-properties
)
1589 (put-text-property (max (1- b
) (point-min))
1590 b
'intangible nil
)))
1592 (defun gnus-article-hide-text-of-type (type)
1593 "Hide text of TYPE in the current buffer."
1595 (let ((b (point-min))
1597 (while (setq b
(text-property-any b e
'article-type type
))
1598 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1600 (defun gnus-article-delete-text-of-type (type)
1601 "Delete text of TYPE in the current buffer."
1603 (let ((b (point-min)))
1604 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1606 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1609 (defun gnus-article-delete-invisible-text ()
1610 "Delete all invisible text in the current buffer."
1612 (let ((b (point-min)))
1613 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1615 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1618 (defun gnus-article-text-type-exists-p (type)
1619 "Say whether any text of type TYPE exists in the buffer."
1620 (text-property-any (point-min) (point-max) 'article-type type
))
1622 (defsubst gnus-article-header-rank
()
1623 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1624 (let ((list gnus-sorted-header-list
)
1627 (if (looking-at (car list
))
1629 (setq list
(cdr list
))
1633 (defun article-hide-headers (&optional arg delete
)
1634 "Hide unwanted headers and possibly sort them as well."
1636 ;; This function might be inhibited.
1637 (unless gnus-inhibit-hiding
1638 (let ((inhibit-read-only nil
)
1639 (case-fold-search t
)
1640 (max (1+ (length gnus-sorted-header-list
)))
1641 (inhibit-point-motion-hooks t
)
1642 (cur (current-buffer))
1643 ignored visible beg
)
1645 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1646 ;; group parameters, so we should go to the summary buffer.
1649 (progn (set-buffer gnus-summary-buffer
) t
)
1651 (setq ignored
(when (not gnus-visible-headers
)
1652 (cond ((stringp gnus-ignored-headers
)
1653 gnus-ignored-headers
)
1654 ((listp gnus-ignored-headers
)
1655 (mapconcat 'identity
1656 gnus-ignored-headers
1658 visible
(cond ((stringp gnus-visible-headers
)
1659 gnus-visible-headers
)
1660 ((and gnus-visible-headers
1661 (listp gnus-visible-headers
))
1662 (mapconcat 'identity
1663 gnus-visible-headers
1667 ;; First we narrow to just the headers.
1668 (article-narrow-to-head)
1669 ;; Hide any "From " lines at the beginning of (mail) articles.
1670 (while (looking-at "From ")
1673 (delete-region (point-min) (point)))
1674 ;; Then treat the rest of the header lines.
1675 ;; Then we use the two regular expressions
1676 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1677 ;; select which header lines is to remain visible in the
1679 (while (re-search-forward "^[^ \t:]*:" nil t
)
1681 ;; Mark the rank of the header.
1683 (point) (1+ (point)) 'message-rank
1684 (if (or (and visible
(looking-at visible
))
1686 (not (looking-at ignored
))))
1687 (gnus-article-header-rank)
1690 (message-sort-headers-1)
1691 (when (setq beg
(text-property-any
1692 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1693 ;; We delete the unwanted headers.
1694 (gnus-add-wash-type 'headers
)
1695 (add-text-properties (point-min) (+ 5 (point-min))
1696 '(article-type headers dummy-invisible t
))
1697 (delete-region beg
(point-max))))))))
1699 (defun article-hide-boring-headers (&optional arg
)
1700 "Toggle hiding of headers that aren't very interesting.
1701 If given a negative prefix, always show; if given a positive prefix,
1703 (interactive (gnus-article-hidden-arg))
1704 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1705 (not gnus-show-all-headers
))
1708 (let ((inhibit-read-only t
)
1709 (list gnus-boring-article-headers
)
1710 (inhibit-point-motion-hooks t
)
1712 (article-narrow-to-head)
1714 (setq elem
(pop list
))
1715 (goto-char (point-min))
1717 ;; Hide empty headers.
1719 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1721 (gnus-article-hide-text-type
1725 (if (re-search-forward "^[^ \t]" nil t
)
1729 ;; Hide boring Newsgroups header.
1730 ((eq elem
'newsgroups
)
1731 (when (gnus-string-equal
1732 (gnus-fetch-field "newsgroups")
1733 (gnus-group-real-name
1734 (if (boundp 'gnus-newsgroup-name
)
1737 (gnus-article-hide-header "newsgroups")))
1738 ((eq elem
'to-address
)
1739 (let ((to (message-fetch-field "to"))
1741 (gnus-parameter-to-address
1742 (if (boundp 'gnus-newsgroup-name
)
1743 gnus-newsgroup-name
""))))
1744 (when (and to to-address
1747 ;; only one address in To
1748 (nth 1 (mail-extract-address-components to
))
1750 (gnus-article-hide-header "to"))))
1752 (let ((to (message-fetch-field "to"))
1754 (gnus-parameter-to-list
1755 (if (boundp 'gnus-newsgroup-name
)
1756 gnus-newsgroup-name
""))))
1757 (when (and to to-list
1760 ;; only one address in To
1761 (nth 1 (mail-extract-address-components to
))
1763 (gnus-article-hide-header "to"))))
1765 (let ((cc (message-fetch-field "cc"))
1767 (gnus-parameter-to-list
1768 (if (boundp 'gnus-newsgroup-name
)
1769 gnus-newsgroup-name
""))))
1770 (when (and cc to-list
1773 ;; only one address in CC
1774 (nth 1 (mail-extract-address-components cc
))
1776 (gnus-article-hide-header "cc"))))
1777 ((eq elem
'followup-to
)
1778 (when (gnus-string-equal
1779 (message-fetch-field "followup-to")
1780 (message-fetch-field "newsgroups"))
1781 (gnus-article-hide-header "followup-to")))
1782 ((eq elem
'reply-to
)
1783 (if (gnus-group-find-parameter
1784 gnus-newsgroup-name
'broken-reply-to
)
1785 (gnus-article-hide-header "reply-to")
1786 (let ((from (message-fetch-field "from"))
1787 (reply-to (message-fetch-field "reply-to")))
1794 (lambda (x) (downcase (cadr x
)))
1795 (mail-extract-address-components from t
))
1798 (lambda (x) (downcase (cadr x
)))
1799 (mail-extract-address-components reply-to t
))
1801 (gnus-article-hide-header "reply-to")))))
1803 (let ((date (message-fetch-field "date")))
1805 (< (days-between (current-time-string) date
)
1807 (gnus-article-hide-header "date"))))
1809 (let ((to (message-fetch-field "to"))
1810 (cc (message-fetch-field "cc")))
1811 (when (> (length to
) 1024)
1812 (gnus-article-hide-header "to"))
1813 (when (> (length cc
) 1024)
1814 (gnus-article-hide-header "cc"))))
1818 (goto-char (point-min))
1819 (while (re-search-forward "^to:" nil t
)
1820 (setq to-count
(1+ to-count
)))
1821 (when (> to-count
1)
1822 (while (> to-count
0)
1823 (goto-char (point-min))
1825 (re-search-forward "^to:" nil nil to-count
)
1827 (narrow-to-region (point) (point-max))
1828 (gnus-article-hide-header "to"))
1829 (setq to-count
(1- to-count
))))
1830 (goto-char (point-min))
1831 (while (re-search-forward "^cc:" nil t
)
1832 (setq cc-count
(1+ cc-count
)))
1833 (when (> cc-count
1)
1834 (while (> cc-count
0)
1835 (goto-char (point-min))
1837 (re-search-forward "^cc:" nil nil cc-count
)
1839 (narrow-to-region (point) (point-max))
1840 (gnus-article-hide-header "cc"))
1841 (setq cc-count
(1- cc-count
)))))))))))))
1843 (defun gnus-article-hide-header (header)
1845 (goto-char (point-min))
1846 (when (re-search-forward (concat "^" header
":") nil t
)
1847 (gnus-article-hide-text-type
1851 (if (re-search-forward "^[^ \t]" nil t
)
1856 (defvar gnus-article-normalized-header-length
40
1857 "Length of normalized headers.")
1859 (defun article-normalize-headers ()
1860 "Make all header lines 40 characters long."
1862 (let ((inhibit-read-only t
)
1866 (article-narrow-to-head)
1869 ((< (setq column
(- (gnus-point-at-eol) (point)))
1870 gnus-article-normalized-header-length
)
1872 (insert (make-string
1873 (- gnus-article-normalized-header-length column
)
1875 ((> column gnus-article-normalized-header-length
)
1876 (gnus-put-text-property
1878 (forward-char gnus-article-normalized-header-length
)
1885 (forward-line 1))))))
1887 (defun article-treat-dumbquotes ()
1888 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1889 Note that this function guesses whether a character is a sm*rtq**t* or
1890 not, so it should only be used interactively.
1892 Sm*rtq**t*s are M****s***'s unilateral extension to the
1893 iso-8859-1 character map in an attempt to provide more quoting
1894 characters. If you see something like \\222 or \\264 where
1895 you're expecting some kind of apostrophe or quotation mark, then
1898 (article-translate-strings gnus-article-dumbquotes-map
))
1900 (defun article-translate-characters (from to
)
1901 "Translate all characters in the body of the article according to FROM and TO.
1902 FROM is a string of characters to translate from; to is a string of
1903 characters to translate to."
1905 (when (article-goto-body)
1906 (let ((inhibit-read-only t
)
1907 (x (make-string 225 ?x
))
1909 (while (< (incf i
) (length x
))
1912 (while (< i
(length from
))
1913 (aset x
(aref from i
) (aref to i
))
1915 (translate-region (point) (point-max) x
)))))
1917 (defun article-translate-strings (map)
1918 "Translate all string in the body of the article according to MAP.
1919 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1921 (when (article-goto-body)
1922 (let ((inhibit-read-only t
)
1924 (while (setq elem
(pop map
))
1926 (while (search-forward (car elem
) nil t
)
1927 (replace-match (cadr elem
)))))))))
1929 (defun article-treat-overstrike ()
1930 "Translate overstrikes into bold text."
1933 (when (article-goto-body)
1934 (let ((inhibit-read-only t
))
1935 (while (search-forward "\b" nil t
)
1936 (let ((next (char-after))
1937 (previous (char-after (- (point) 2))))
1938 ;; We do the boldification/underlining by hiding the
1939 ;; overstrikes and putting the proper text property
1943 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1944 (put-text-property (point) (1+ (point)) 'face
'bold
))
1946 (gnus-article-hide-text-type
1947 (1- (point)) (1+ (point)) 'overstrike
)
1949 (- (point) 2) (1- (point)) 'face
'underline
))
1951 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1953 (point) (1+ (point)) 'face
'underline
)))))))))
1955 (defun gnus-article-treat-unfold-headers ()
1956 "Unfold folded message headers.
1957 Only the headers that fit into the current window width will be
1960 (gnus-with-article-headers
1964 (mail-header-narrow-to-field)
1965 (let ((header (buffer-string)))
1968 (goto-char (point-min))
1969 (while (re-search-forward "\n[\t ]" nil t
)
1970 (replace-match " " t t
)))
1971 (setq length
(- (point-max) (point-min) 1)))
1972 (when (< length
(window-width))
1973 (while (re-search-forward "\n[\t ]" nil t
)
1974 (replace-match " " t t
)))
1975 (goto-char (point-max)))))))
1977 (defun gnus-article-treat-fold-headers ()
1978 "Fold message headers."
1980 (gnus-with-article-headers
1983 (mail-header-narrow-to-field)
1984 (mail-header-fold-field)
1985 (goto-char (point-max))))))
1987 (defun gnus-treat-smiley ()
1988 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1990 (gnus-with-article-buffer
1991 (if (memq 'smiley gnus-article-wash-types
)
1992 (gnus-delete-images 'smiley
)
1994 (let ((images (smiley-region (point) (point-max))))
1996 (gnus-add-wash-type 'smiley
)
1997 (dolist (image images
)
1998 (gnus-add-image 'smiley image
)))))))
2000 (defun gnus-article-remove-images ()
2001 "Remove all images from the article buffer."
2003 (gnus-with-article-buffer
2004 (dolist (elem gnus-article-image-alist
)
2005 (gnus-delete-images (car elem
)))))
2007 (defun gnus-article-treat-fold-newsgroups ()
2008 "Unfold folded message headers.
2009 Only the headers that fit into the current window width will be
2012 (gnus-with-article-headers
2013 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2015 (mail-header-narrow-to-field)
2016 (while (re-search-forward ", *" nil t
)
2017 (replace-match ", " t t
))
2018 (mail-header-fold-field)
2019 (goto-char (point-max))))))
2021 (defun gnus-article-treat-body-boundary ()
2022 "Place a boundary line at the end of the headers."
2024 (when (and gnus-body-boundary-delimiter
2025 (> (length gnus-body-boundary-delimiter
) 0))
2026 (gnus-with-article-headers
2027 (goto-char (point-max))
2028 (let ((start (point)))
2029 (insert "X-Boundary: ")
2030 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2032 (while (>= (1- (window-width)) (length str
))
2033 (setq str
(concat str gnus-body-boundary-delimiter
)))
2034 (substring str
0 (1- (window-width))))
2036 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2038 (defun article-fill-long-lines ()
2039 "Fill lines that are wider than the window width."
2042 (let ((inhibit-read-only t
)
2043 (width (window-width (get-buffer-window (current-buffer)))))
2046 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2049 (when (>= (current-column) (min fill-column width
))
2050 (narrow-to-region (min (1+ (point)) (point-max))
2051 (gnus-point-at-bol))
2052 (let ((goback (point-marker)))
2053 (fill-paragraph nil
)
2054 (goto-char (marker-position goback
)))
2056 (forward-line 1)))))))
2058 (defun article-capitalize-sentences ()
2059 "Capitalize the first word in each sentence."
2062 (let ((inhibit-read-only t
)
2063 (paragraph-start "^[\n\^L]"))
2067 (forward-sentence)))))
2069 (defun article-remove-cr ()
2070 "Remove trailing CRs and then translate remaining CRs into LFs."
2073 (let ((inhibit-read-only t
))
2074 (goto-char (point-min))
2075 (while (re-search-forward "\r+$" nil t
)
2076 (replace-match "" t t
))
2077 (goto-char (point-min))
2078 (while (search-forward "\r" nil t
)
2079 (replace-match "\n" t t
)))))
2081 (defun article-remove-trailing-blank-lines ()
2082 "Remove all trailing blank lines from the article."
2085 (let ((inhibit-read-only t
))
2086 (goto-char (point-max))
2090 (while (and (not (bobp))
2091 (looking-at "^[ \t]*$")
2092 (not (gnus-annotation-in-region-p
2093 (point) (gnus-point-at-eol))))
2098 (defun article-display-face ()
2099 "Display any Face headers in the header."
2101 (let ((wash-face-p buffer-read-only
))
2102 (gnus-with-article-headers
2103 ;; When displaying parts, this function can be called several times on
2104 ;; the same article, without any intended toggle semantic (as typing `W
2105 ;; D d' would have). So face deletion must occur only when we come from
2106 ;; an interactive command, that is when the *Article* buffer is
2108 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2109 (gnus-delete-images 'face
)
2112 (when (and wash-face-p
2114 (goto-char (point-min))
2115 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2116 (gnus-buffer-live-p gnus-original-article-buffer
))
2117 (set-buffer gnus-original-article-buffer
))
2119 (mail-narrow-to-head)
2120 (while (gnus-article-goto-header "Face")
2121 (push (mail-header-field-value) faces
))))
2122 (while (setq face
(pop faces
))
2123 (let ((png (gnus-convert-face-to-png face
))
2126 (setq image
(gnus-create-image png
'png t
))
2127 (gnus-article-goto-header "from")
2129 (insert "From: [no `from' set]\n")
2131 (gnus-add-wash-type 'face
)
2132 (gnus-add-image 'face image
)
2133 (gnus-put-image image nil
'face
))))))
2136 (defun article-display-x-face (&optional force
)
2137 "Look for an X-Face header and display it if present."
2138 (interactive (list 'force
))
2139 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2140 (gnus-with-article-headers
2141 ;; Delete the old process, if any.
2142 (when (process-status "article-x-face")
2143 (delete-process "article-x-face"))
2144 ;; See the comment in `article-display-face'.
2145 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2146 ;; We have already displayed X-Faces, so we remove them
2148 (gnus-delete-images 'xface
)
2150 (let (x-faces from face
)
2152 (when (and wash-face-p
2154 (goto-char (point-min))
2155 (not (re-search-forward
2156 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t
)))
2157 (gnus-buffer-live-p gnus-original-article-buffer
))
2158 ;; If type `W f', use gnus-original-article-buffer,
2159 ;; otherwise use the current buffer because displaying
2160 ;; RFC822 parts calls this function too.
2161 (set-buffer gnus-original-article-buffer
))
2163 (mail-narrow-to-head)
2164 (while (gnus-article-goto-header "X-Face")
2165 (push (mail-header-field-value) x-faces
))
2166 (setq from
(message-fetch-field "from"))))
2167 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2168 ;; single external face.
2169 (when (stringp gnus-article-x-face-command
)
2170 (setq x-faces
(list (car x-faces
))))
2171 (while (and (setq face
(pop x-faces
))
2172 gnus-article-x-face-command
2174 ;; Check whether this face is censored.
2175 (not gnus-article-x-face-too-ugly
)
2176 (and gnus-article-x-face-too-ugly from
2177 (not (string-match gnus-article-x-face-too-ugly
2179 ;; We display the face.
2180 (cond ((stringp gnus-article-x-face-command
)
2181 ;; The command is a string, so we interpret the command
2182 ;; as a, well, command, and fork it off.
2183 (let ((process-connection-type nil
))
2184 (gnus-set-process-query-on-exit-flag
2186 "article-x-face" nil shell-file-name
2187 shell-command-switch gnus-article-x-face-command
)
2191 (process-send-region "article-x-face"
2192 (point-min) (point-max)))
2193 (process-send-eof "article-x-face")))
2194 ((functionp gnus-article-x-face-command
)
2195 ;; The command is a lisp function, so we call it.
2196 (funcall gnus-article-x-face-command face
))
2198 (error "%s is not a function"
2199 gnus-article-x-face-command
)))))))))
2201 (defun article-decode-mime-words ()
2202 "Decode all MIME-encoded words in the article."
2205 (set-buffer gnus-article-buffer
)
2206 (let ((inhibit-point-motion-hooks t
)
2207 (inhibit-read-only t
)
2208 (mail-parse-charset gnus-newsgroup-charset
)
2209 (mail-parse-ignored-charsets
2210 (save-excursion (set-buffer gnus-summary-buffer
)
2211 gnus-newsgroup-ignored-charsets
)))
2212 (mail-decode-encoded-word-region (point-min) (point-max)))))
2214 (defun article-decode-charset (&optional prompt
)
2215 "Decode charset-encoded text in the article.
2216 If PROMPT (the prefix), prompt for a coding system to use."
2218 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2219 (inhibit-read-only t
)
2220 (mail-parse-charset gnus-newsgroup-charset
)
2221 (mail-parse-ignored-charsets
2222 (save-excursion (condition-case nil
2223 (set-buffer gnus-summary-buffer
)
2225 gnus-newsgroup-ignored-charsets
))
2226 ct cte ctl charset format
)
2229 (article-narrow-to-head)
2230 (setq ct
(message-fetch-field "Content-Type" t
)
2231 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2232 ctl
(and ct
(ignore-errors
2233 (mail-header-parse-content-type ct
)))
2236 (mm-read-coding-system "Charset to decode: "))
2238 (mail-content-type-get ctl
'charset
)))
2239 format
(and ctl
(mail-content-type-get ctl
'format
)))
2241 (setq cte
(mail-header-strip cte
)))
2242 (if (and ctl
(not (string-match "/" (car ctl
))))
2244 (goto-char (point-max)))
2247 (narrow-to-region (point) (point-max))
2248 (when (and (eq mail-parse-charset
'gnus-decoded
)
2249 (eq (mm-body-7-or-8) '8bit
))
2250 ;; The text code could have been decoded.
2251 (setq charset mail-parse-charset
))
2252 (when (and (or (not ctl
)
2253 (equal (car ctl
) "text/plain"))
2254 (not format
)) ;; article with format will decode later.
2256 charset
(and cte
(intern (downcase
2257 (gnus-strip-whitespace cte
))))
2260 (defun article-decode-encoded-words ()
2261 "Remove encoded-word encoding from headers."
2262 (let ((inhibit-point-motion-hooks t
)
2263 (mail-parse-charset gnus-newsgroup-charset
)
2264 (mail-parse-ignored-charsets
2265 (save-excursion (condition-case nil
2266 (set-buffer gnus-summary-buffer
)
2268 gnus-newsgroup-ignored-charsets
))
2269 (inhibit-read-only t
))
2271 (article-narrow-to-head)
2272 (funcall gnus-decode-header-function
(point-min) (point-max)))))
2274 (defun article-decode-group-name ()
2275 "Decode group names in `Newsgroups:'."
2276 (let ((inhibit-point-motion-hooks t
)
2277 (inhibit-read-only t
)
2278 (method (gnus-find-method-for-group gnus-newsgroup-name
)))
2279 (when (and (or gnus-group-name-charset-method-alist
2280 gnus-group-name-charset-group-alist
)
2281 (gnus-buffer-live-p gnus-original-article-buffer
))
2283 (article-narrow-to-head)
2284 (with-current-buffer gnus-original-article-buffer
2285 (goto-char (point-min)))
2286 (while (re-search-forward
2287 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2288 (replace-match (save-match-data
2289 (gnus-decode-newsgroups
2290 ;; XXX how to use data in article buffer?
2291 (with-current-buffer gnus-original-article-buffer
2293 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2296 gnus-newsgroup-name method
))
2298 (goto-char (point-min))
2299 (with-current-buffer gnus-original-article-buffer
2300 (goto-char (point-min)))
2301 (while (re-search-forward
2302 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2303 (replace-match (save-match-data
2304 (gnus-decode-newsgroups
2305 ;; XXX how to use data in article buffer?
2306 (with-current-buffer gnus-original-article-buffer
2308 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2311 gnus-newsgroup-name method
))
2314 (autoload 'idna-to-unicode
"idna")
2316 (defun article-decode-idna-rhs ()
2317 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2320 (let ((inhibit-point-motion-hooks t
)
2321 (inhibit-read-only t
))
2322 (article-narrow-to-head)
2323 (goto-char (point-min))
2324 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2326 (when (save-match-data
2327 (and (setq ace
(match-string 1))
2329 (and (re-search-backward "^[^ \t]" nil t
)
2330 (looking-at "From\\|To\\|Cc")))
2331 (setq unicode
(idna-to-unicode ace
))))
2332 (unless (string= ace unicode
)
2333 (replace-match unicode nil nil nil
1)))))))))
2335 (defun article-de-quoted-unreadable (&optional force read-charset
)
2336 "Translate a quoted-printable-encoded article.
2337 If FORCE, decode the article whether it is marked as quoted-printable
2339 If READ-CHARSET, ask for a coding system."
2340 (interactive (list 'force current-prefix-arg
))
2342 (let ((inhibit-read-only t
) type charset
)
2343 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2344 (with-current-buffer gnus-original-article-buffer
2346 (gnus-fetch-field "content-transfer-encoding"))
2347 (let* ((ct (gnus-fetch-field "content-type"))
2350 (mail-header-parse-content-type ct
)))))
2351 (setq charset
(and ctl
2352 (mail-content-type-get ctl
'charset
)))
2353 (if (stringp charset
)
2354 (setq charset
(intern (downcase charset
)))))))
2356 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2358 (setq charset gnus-newsgroup-charset
))
2360 (and type
(let ((case-fold-search t
))
2361 (string-match "quoted-printable" type
))))
2363 (quoted-printable-decode-region
2364 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2366 (defun article-de-base64-unreadable (&optional force read-charset
)
2367 "Translate a base64 article.
2368 If FORCE, decode the article whether it is marked as base64 not.
2369 If READ-CHARSET, ask for a coding system."
2370 (interactive (list 'force current-prefix-arg
))
2372 (let ((inhibit-read-only t
) type charset
)
2373 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2374 (with-current-buffer gnus-original-article-buffer
2376 (gnus-fetch-field "content-transfer-encoding"))
2377 (let* ((ct (gnus-fetch-field "content-type"))
2380 (mail-header-parse-content-type ct
)))))
2381 (setq charset
(and ctl
2382 (mail-content-type-get ctl
'charset
)))
2383 (if (stringp charset
)
2384 (setq charset
(intern (downcase charset
)))))))
2386 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2388 (setq charset gnus-newsgroup-charset
))
2390 (and type
(let ((case-fold-search t
))
2391 (string-match "base64" type
))))
2394 (narrow-to-region (point) (point-max))
2395 (base64-decode-region (point-min) (point-max))
2396 (mm-decode-coding-region
2397 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2402 (defun article-decode-HZ ()
2403 "Translate a HZ-encoded article."
2407 (let ((inhibit-read-only t
))
2408 (rfc1843-decode-region (point-min) (point-max)))))
2410 (defun article-unsplit-urls ()
2411 "Remove the newlines that some other mailers insert into URLs."
2414 (let ((inhibit-read-only t
))
2415 (goto-char (point-min))
2416 (while (re-search-forward
2417 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2418 (replace-match "\\1\\3" t
)))
2419 (when (interactive-p)
2420 (gnus-treat-article nil
))))
2423 (defun article-wash-html (&optional read-charset
)
2424 "Format an HTML article.
2425 If READ-CHARSET, ask for a coding system."
2428 (let ((inhibit-read-only t
)
2430 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2431 (with-current-buffer gnus-original-article-buffer
2432 (let* ((ct (gnus-fetch-field "content-type"))
2435 (mail-header-parse-content-type ct
)))))
2436 (setq charset
(and ctl
2437 (mail-content-type-get ctl
'charset
)))
2438 (when (stringp charset
)
2439 (setq charset
(intern (downcase charset
)))))))
2441 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2443 (setq charset gnus-newsgroup-charset
))
2445 (save-window-excursion
2447 (narrow-to-region (point) (point-max))
2448 (let* ((func (or gnus-article-wash-function mm-text-html-renderer
))
2449 (entry (assq func mm-text-html-washer-alist
)))
2451 (setq func
(cdr entry
)))
2456 (apply (car func
) (cdr func
))))))))))
2458 (defun gnus-article-wash-html-with-w3 ()
2459 "Wash the current buffer with w3."
2461 (let ((w3-strict-width (window-width))
2462 (url-standalone-mode t
)
2463 (url-gateway-unplugged t
)
2464 (w3-honor-stylesheets nil
))
2466 (w3-region (point-min) (point-max))
2469 (defun gnus-article-wash-html-with-w3m ()
2470 "Wash the current buffer with emacs-w3m."
2473 (narrow-to-region (point) (point-max))
2474 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp
)
2475 w3m-force-redisplay
)
2476 (w3m-region (point-min) (point-max)))
2477 (when (and mm-inline-text-html-with-w3m-keymap
2478 (boundp 'w3m-minor-mode-map
)
2480 (add-text-properties
2481 (point-min) (point-max)
2482 (list 'keymap w3m-minor-mode-map
2483 ;; Put the mark meaning this part was rendered by emacs-w3m.
2484 'mm-inline-text-html-with-w3m t
)))))
2486 (defun article-hide-list-identifiers ()
2487 "Remove list identifies from the Subject header.
2488 The `gnus-list-identifiers' variable specifies what to do."
2490 (let ((inhibit-point-motion-hooks t
)
2491 (regexp (if (consp gnus-list-identifiers
)
2492 (mapconcat 'identity gnus-list-identifiers
" *\\|")
2493 gnus-list-identifiers
))
2494 (inhibit-read-only t
))
2498 (article-narrow-to-head)
2499 (goto-char (point-min))
2500 (while (re-search-forward
2501 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
2503 (delete-region (match-beginning 2) (match-end 0))
2504 (beginning-of-line))
2505 (when (re-search-forward
2506 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
2507 (delete-region (match-beginning 1) (match-end 1))))))))
2509 (defun article-hide-pem (&optional arg
)
2510 "Toggle hiding of any PEM headers and signatures in the current article.
2511 If given a negative prefix, always show; if given a positive prefix,
2513 (interactive (gnus-article-hidden-arg))
2514 (unless (gnus-article-check-hidden-text 'pem arg
)
2516 (let ((inhibit-read-only t
) end
)
2517 (goto-char (point-min))
2518 ;; Hide the horrendously ugly "header".
2519 (when (and (search-forward
2520 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2522 (setq end
(1+ (match-beginning 0))))
2523 (gnus-add-wash-type 'pem
)
2524 (gnus-article-hide-text-type
2526 (if (search-forward "\n\n" nil t
)
2530 ;; Hide the trailer as well
2531 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2533 (gnus-article-hide-text-type
2534 (match-beginning 0) (match-end 0) 'pem
)))))))
2536 (defun article-strip-banner ()
2537 "Strip the banners specified by the `banner' group parameter and by
2538 `gnus-article-address-banner-alist'."
2542 (let ((inhibit-point-motion-hooks t
))
2543 (when (gnus-parameter-banner gnus-newsgroup-name
)
2544 (article-really-strip-banner
2545 (gnus-parameter-banner gnus-newsgroup-name
)))
2546 (when gnus-article-address-banner-alist
2547 (article-really-strip-banner
2548 (let ((from (save-restriction
2550 (article-narrow-to-head)
2551 (mail-fetch-field "from"))))
2554 (caar (mail-header-parse-addresses from
))))
2556 (dolist (pair gnus-article-address-banner-alist
)
2557 (when (string-match (car pair
) from
)
2558 (throw 'found
(cdr pair
)))))))))))))
2560 (defun article-really-strip-banner (banner)
2561 "Strip the banner specified by the argument."
2564 (let ((inhibit-point-motion-hooks t
)
2565 (gnus-signature-limit nil
)
2566 (inhibit-read-only t
))
2569 ((eq banner
'signature
)
2570 (when (gnus-article-narrow-to-signature)
2573 (delete-region (point) (point-max))))
2575 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
2576 (while (re-search-forward banner nil t
)
2577 (delete-region (match-beginning 0) (match-end 0)))))
2579 (while (re-search-forward banner nil t
)
2580 (delete-region (match-beginning 0) (match-end 0)))))))))
2582 (defun article-babel ()
2583 "Translate article using an online translation service."
2587 (set-buffer gnus-article-buffer
)
2588 (when (article-goto-body)
2589 (let* ((inhibit-read-only t
)
2592 (orig (buffer-substring start end
))
2593 (trans (babel-as-string orig
)))
2595 (narrow-to-region start end
)
2596 (delete-region start end
)
2599 (defun article-hide-signature (&optional arg
)
2600 "Hide the signature in the current article.
2601 If given a negative prefix, always show; if given a positive prefix,
2603 (interactive (gnus-article-hidden-arg))
2604 (unless (gnus-article-check-hidden-text 'signature arg
)
2607 (let ((inhibit-read-only t
))
2608 (when (gnus-article-narrow-to-signature)
2609 (gnus-article-hide-text-type
2610 (point-min) (point-max) 'signature
))))))
2611 (gnus-set-mode-line 'article
))
2613 (defun article-strip-headers-in-body ()
2614 "Strip offensive headers from bodies."
2618 (let ((case-fold-search t
))
2619 (when (looking-at "x-no-archive:")
2620 (gnus-delete-line)))))
2622 (defun article-strip-leading-blank-lines ()
2623 "Remove all blank lines from the beginning of the article."
2626 (let ((inhibit-point-motion-hooks t
)
2627 (inhibit-read-only t
))
2628 (when (article-goto-body)
2629 (while (and (not (eobp))
2630 (looking-at "[ \t]*$"))
2631 (gnus-delete-line))))))
2633 (defun article-narrow-to-head ()
2634 "Narrow the buffer to the head of the message.
2635 Point is left at the beginning of the narrowed-to region."
2637 (goto-char (point-min))
2638 (if (search-forward "\n\n" nil
1)
2641 (goto-char (point-min)))
2643 (defun article-goto-body ()
2644 "Place point at the start of the body."
2645 (goto-char (point-min))
2647 ;; This variable is only bound when dealing with separate
2649 (article-goto-body-goes-to-point-min-p
2651 ((search-forward "\n\n" nil t
)
2654 (goto-char (point-max))
2657 (defun article-strip-multiple-blank-lines ()
2658 "Replace consecutive blank lines with one empty line."
2661 (let ((inhibit-point-motion-hooks t
)
2662 (inhibit-read-only t
))
2663 ;; First make all blank lines empty.
2665 (while (re-search-forward "^[ \t]+$" nil t
)
2666 (unless (gnus-annotation-in-region-p
2667 (match-beginning 0) (match-end 0))
2668 (replace-match "" nil t
)))
2669 ;; Then replace multiple empty lines with a single empty line.
2671 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
2672 (unless (gnus-annotation-in-region-p
2673 (match-beginning 0) (match-end 0))
2674 (delete-region (match-beginning 1) (match-end 1)))))))
2676 (defun article-strip-leading-space ()
2677 "Remove all white space from the beginning of the lines in the article."
2680 (let ((inhibit-point-motion-hooks t
)
2681 (inhibit-read-only t
))
2683 (while (re-search-forward "^[ \t]+" nil t
)
2684 (replace-match "" t t
)))))
2686 (defun article-strip-trailing-space ()
2687 "Remove all white space from the end of the lines in the article."
2690 (let ((inhibit-point-motion-hooks t
)
2691 (inhibit-read-only t
))
2693 (while (re-search-forward "[ \t]+$" nil t
)
2694 (replace-match "" t t
)))))
2696 (defun article-strip-blank-lines ()
2697 "Strip leading, trailing and multiple blank lines."
2699 (article-strip-leading-blank-lines)
2700 (article-remove-trailing-blank-lines)
2701 (article-strip-multiple-blank-lines))
2703 (defun article-strip-all-blank-lines ()
2704 "Strip all blank lines."
2707 (let ((inhibit-point-motion-hooks t
)
2708 (inhibit-read-only t
))
2710 (while (re-search-forward "^[ \t]*\n" nil t
)
2711 (replace-match "" t t
)))))
2713 (defun gnus-article-narrow-to-signature ()
2714 "Narrow to the signature; return t if a signature is found, else nil."
2715 (let ((inhibit-point-motion-hooks t
))
2716 (when (gnus-article-search-signature)
2718 ;; Check whether we have some limits to what we consider
2719 ;; to be a signature.
2720 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
2721 (list gnus-signature-limit
)))
2723 (while (setq limit
(pop limits
))
2724 (if (or (and (integerp limit
)
2725 (< (- (point-max) (point)) limit
))
2727 (< (count-lines (point) (point-max)) limit
))
2728 (and (functionp limit
)
2730 (and (stringp limit
)
2731 (not (re-search-forward limit nil t
))))
2732 () ; This limit did not succeed.
2736 (narrow-to-region (point) (point-max))
2739 (defun gnus-article-search-signature ()
2740 "Search the current buffer for the signature separator.
2741 Put point at the beginning of the signature separator."
2742 (let ((cur (point)))
2743 (goto-char (point-max))
2744 (if (if (stringp gnus-signature-separator
)
2745 (re-search-backward gnus-signature-separator nil t
)
2746 (let ((seps gnus-signature-separator
))
2748 (not (re-search-backward (car seps
) nil t
)))
2755 (defun gnus-article-hidden-arg ()
2756 "Return the current prefix arg as a number, or 0 if no prefix."
2757 (list (if current-prefix-arg
2758 (prefix-numeric-value current-prefix-arg
)
2761 (defun gnus-article-check-hidden-text (type arg
)
2762 "Return nil if hiding is necessary.
2763 Arg can be nil or a number. nil and positive means hide, negative
2764 means show, 0 means toggle."
2767 (let ((hide (gnus-article-hidden-text-p type
)))
2773 (gnus-article-show-hidden-text type
)
2776 (if (eq hide
'hidden
)
2778 (gnus-article-show-hidden-text type
)
2782 (defun gnus-article-hidden-text-p (type)
2783 "Say whether the current buffer contains hidden text of type TYPE."
2784 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
2786 (not (get-text-property pos
'invisible
))
2787 (not (get-text-property pos
'dummy-invisible
)))
2789 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
2794 (defun gnus-article-show-hidden-text (type &optional dummy
)
2795 "Show all hidden text of type TYPE.
2796 Originally it is hide instead of DUMMY."
2797 (let ((inhibit-read-only t
)
2798 (inhibit-point-motion-hooks t
))
2799 (gnus-remove-text-properties-when
2801 (point-min) (point-max)
2802 (cons 'article-type
(cons type
2803 gnus-hidden-properties
)))
2804 (gnus-delete-wash-type type
)))
2806 (defconst article-time-units
2807 `((year .
,(* 365.25 24 60 60))
2808 (week .
,(* 7 24 60 60))
2809 (day .
,(* 24 60 60))
2813 "Mapping from time units to seconds.")
2815 (defun gnus-article-forward-header ()
2816 "Move point to the start of the next header.
2817 If the current header is a continuation header, this can be several
2822 (if (looking-at "[ \t]+[^ \t]")
2826 (defun article-date-ut (&optional type highlight
)
2827 "Convert DATE date to universal time in the current article.
2828 If TYPE is `local', convert to local time; if it is `lapsed', output
2829 how much time has lapsed since DATE. For `lapsed', the value of
2830 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2831 should replace the \"Date:\" one, or should be added below it."
2832 (interactive (list 'ut t
))
2833 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2834 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
2838 (article-lapsed-timer
2842 (case-fold-search t
)
2843 (inhibit-read-only t
)
2844 (inhibit-point-motion-hooks t
)
2845 pos date bface eface
)
2849 (goto-char (point-min))
2850 (while (or (setq date
(get-text-property (setq pos
(point))
2852 (when (setq pos
(next-single-property-change
2853 (point) 'original-date
))
2854 (setq date
(get-text-property pos
'original-date
))
2856 (narrow-to-region pos
(or (text-property-any pos
(point-max)
2859 (goto-char (point-min))
2860 (when (re-search-forward tdate-regexp nil t
)
2861 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
2862 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
)))
2863 (goto-char (point-min))
2865 ;; Delete any old Date headers.
2866 (while (re-search-forward date-regexp nil t
)
2868 (delete-region (gnus-point-at-bol)
2870 (gnus-article-forward-header)
2872 (delete-region (gnus-point-at-bol)
2874 (gnus-article-forward-header)
2877 (setq pos
(point))))
2878 (when (and (not pos
)
2879 (re-search-forward tdate-regexp nil t
))
2881 (gnus-goto-char pos
)
2882 (insert (article-make-date-line date
(or type
'ut
)))
2888 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2889 (put-text-property (match-beginning 1) (1+ (match-end 1))
2891 (put-text-property (match-beginning 2) (match-end 2)
2893 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
2894 (goto-char (point-max))
2897 (defun article-make-date-line (date type
)
2898 "Return a DATE line of TYPE."
2899 (unless (memq type
'(local ut original user iso8601 lapsed english
))
2900 (error "Unknown conversion type: %s" type
))
2902 (let ((time (date-to-time date
)))
2904 ;; Convert to the local timezone.
2906 (let ((tz (car (current-time-zone time
))))
2907 (format "Date: %s %s%02d%02d" (current-time-string time
)
2908 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2909 (/ (%
(abs tz
) 3600) 60))))
2910 ;; Convert to Universal Time.
2913 (current-time-string
2914 (let* ((e (parse-time-string date
))
2915 (tm (apply 'encode-time e
))
2917 (ls (- (cadr tm
) (car (current-time-zone time
)))))
2918 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
2919 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
2922 ;; Get the original date from the article.
2923 ((eq type
'original
)
2924 (concat "Date: " (if (string-match "\n+$" date
)
2925 (substring date
0 (match-beginning 0))
2927 ;; Let the user define the format.
2929 (let ((format (or (condition-case nil
2930 (with-current-buffer gnus-summary-buffer
2931 gnus-article-time-format
)
2933 gnus-article-time-format
)))
2934 (if (functionp format
)
2935 (funcall format time
)
2936 (concat "Date: " (format-time-string format time
)))))
2939 (let ((tz (car (current-time-zone time
))))
2942 (format-time-string "%Y%m%dT%H%M%S" time
)
2943 (format "%s%02d%02d"
2944 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2945 (/ (%
(abs tz
) 3600) 60)))))
2946 ;; Do an X-Sent lapsed format.
2948 ;; If the date is seriously mangled, the timezone functions are
2949 ;; liable to bug out, so we ignore all errors.
2950 (let* ((now (current-time))
2951 (real-time (subtract-time now time
))
2952 (real-sec (and real-time
2953 (+ (* (float (car real-time
)) 65536)
2955 (sec (and real-time
(abs real-sec
)))
2965 ;; This is a bit convoluted, but basically we go
2966 ;; through the time units for years, weeks, etc,
2967 ;; and divide things to see whether that results
2968 ;; in positive answers.
2971 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
2972 ;; The (remaining) seconds are too few to
2973 ;; be divided into this time unit.
2975 ;; It's big enough, so we output it.
2976 (setq sec
(- sec
(* num
(cdr unit
))))
2978 (concat (if prev
", " "") (int-to-string
2980 " " (symbol-name (car unit
))
2981 (if (> num
1) "s" ""))
2983 article-time-units
"")
2984 ;; If dates are odd, then it might appear like the
2985 ;; article was sent in the future.
2988 " in the future"))))))
2989 ;; Display the date in proper English
2991 (let ((dtime (decode-time time
)))
2994 (number-to-string (nth 3 dtime
))
2995 (let ((digit (%
(nth 3 dtime
) 10)))
2997 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3003 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3005 (number-to-string (nth 5 dtime
))
3007 (format "%02d" (nth 2 dtime
))
3009 (format "%02d" (nth 1 dtime
)))))))
3011 (format "Date: %s (from Gnus)" date
))))
3013 (defun article-date-local (&optional highlight
)
3014 "Convert the current article date to the local timezone."
3015 (interactive (list t
))
3016 (article-date-ut 'local highlight
))
3018 (defun article-date-english (&optional highlight
)
3019 "Convert the current article date to something that is proper English."
3020 (interactive (list t
))
3021 (article-date-ut 'english highlight
))
3023 (defun article-date-original (&optional highlight
)
3024 "Convert the current article date to what it was originally.
3025 This is only useful if you have used some other date conversion
3026 function and want to see what the date was before converting."
3027 (interactive (list t
))
3028 (article-date-ut 'original highlight
))
3030 (defun article-date-lapsed (&optional highlight
)
3031 "Convert the current article date to time lapsed since it was sent."
3032 (interactive (list t
))
3033 (article-date-ut 'lapsed highlight
))
3035 (defun article-update-date-lapsed ()
3036 "Function to be run from a timer to update the lapsed time line."
3037 (let (deactivate-mark)
3042 (set-buffer (window-buffer w
))
3043 (when (eq major-mode
'gnus-article-mode
)
3044 (let ((mark (point-marker)))
3045 (goto-char (point-min))
3046 (when (re-search-forward "^X-Sent:" nil t
)
3047 (article-date-lapsed t
))
3048 (goto-char (marker-position mark
))
3049 (move-marker mark nil
))))
3052 (defun gnus-start-date-timer (&optional n
)
3053 "Start a timer to update the X-Sent header in the article buffers.
3054 The numerical prefix says how frequently (in seconds) the function
3059 (gnus-stop-date-timer)
3060 (setq article-lapsed-timer
3061 (nnheader-run-at-time 1 n
'article-update-date-lapsed
)))
3063 (defun gnus-stop-date-timer ()
3064 "Stop the X-Sent timer."
3066 (when article-lapsed-timer
3067 (nnheader-cancel-timer article-lapsed-timer
)
3068 (setq article-lapsed-timer nil
)))
3070 (defun article-date-user (&optional highlight
)
3071 "Convert the current article date to the user-defined format.
3072 This format is defined by the `gnus-article-time-format' variable."
3073 (interactive (list t
))
3074 (article-date-ut 'user highlight
))
3076 (defun article-date-iso8601 (&optional highlight
)
3077 "Convert the current article date to ISO8601."
3078 (interactive (list t
))
3079 (article-date-ut 'iso8601 highlight
))
3081 (defmacro gnus-article-save-original-date
(&rest forms
)
3082 "Save the original date as a text property and evaluate FORMS."
3083 `(let* ((case-fold-search t
)
3085 (goto-char (point-min))
3086 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3089 (date (when (and start
3090 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3092 (buffer-substring-no-properties start
3093 (match-beginning 0)))))
3094 (goto-char (point-max))
3095 (skip-chars-backward "\n")
3096 (put-text-property (point-min) (point) 'original-date date
)
3098 (goto-char (point-max))
3099 (skip-chars-backward "\n")
3100 (put-text-property (point-min) (point) 'original-date date
)))
3102 ;; (defun article-show-all ()
3103 ;; "Show all hidden text in the article buffer."
3106 ;; (let ((inhibit-read-only t))
3107 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3109 (defun article-remove-leading-whitespace ()
3110 "Remove excessive whitespace from all headers."
3114 (let ((inhibit-read-only t
))
3115 (article-narrow-to-head)
3116 (goto-char (point-min))
3117 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3118 (delete-region (match-beginning 1) (match-end 1)))))))
3120 (defun article-emphasize (&optional arg
)
3121 "Emphasize text according to `gnus-emphasis-alist'."
3122 (interactive (gnus-article-hidden-arg))
3123 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3127 (with-current-buffer gnus-summary-buffer
3128 gnus-article-emphasis-alist
)
3130 gnus-emphasis-alist
))
3131 (inhibit-read-only t
)
3132 (props (append '(article-type emphasis
)
3133 gnus-hidden-properties
))
3134 regexp elem beg invisible visible face
)
3137 (while (setq elem
(pop alist
))
3139 (setq regexp
(car elem
)
3140 invisible
(nth 1 elem
)
3141 visible
(nth 2 elem
)
3143 (while (re-search-forward regexp nil t
)
3144 (when (and (match-beginning visible
) (match-beginning invisible
))
3145 (gnus-article-hide-text
3146 (match-beginning invisible
) (match-end invisible
) props
)
3147 (gnus-article-unhide-text-type
3148 (match-beginning visible
) (match-end visible
) 'emphasis
)
3149 (gnus-put-overlay-excluding-newlines
3150 (match-beginning visible
) (match-end visible
) 'face face
)
3151 (gnus-add-wash-type 'emphasis
)
3152 (goto-char (match-end invisible
)))))))))
3154 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3155 "Setup newsgroup emphasis alist."
3156 (unless gnus-article-emphasis-alist
3157 (let ((name (and gnus-newsgroup-name
3158 (gnus-group-real-name gnus-newsgroup-name
))))
3159 (make-local-variable 'gnus-article-emphasis-alist
)
3160 (setq gnus-article-emphasis-alist
3162 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3163 (while (setq elem
(pop alist
))
3164 (when (and name
(string-match (car elem
) name
))
3166 highlight
(copy-sequence (cdr elem
)))))
3168 (copy-sequence highlight-words
)
3169 (if gnus-newsgroup-name
3170 (copy-sequence (gnus-group-find-parameter
3171 gnus-newsgroup-name
'highlight-words t
)))
3172 gnus-emphasis-alist
)))))
3175 (defvar gnus-summary-article-menu
)
3176 (defvar gnus-summary-post-menu
))
3178 ;;; Saving functions.
3180 (defun gnus-article-save (save-buffer file
&optional num
)
3181 "Save the currently selected article."
3182 (unless gnus-save-all-headers
3183 ;; Remove headers according to `gnus-saved-headers'.
3184 (let ((gnus-visible-headers
3185 (or gnus-saved-headers gnus-visible-headers
))
3186 (gnus-article-buffer save-buffer
))
3188 (set-buffer save-buffer
)
3189 (article-hide-headers 1 t
))))
3190 (save-window-excursion
3191 (if (not gnus-default-article-saver
)
3192 (error "No default saver is defined")
3193 ;; !!! Magic! The saving functions all save
3194 ;; `gnus-save-article-buffer' (or so they think), but we
3195 ;; bind that variable to our save-buffer.
3196 (set-buffer gnus-article-buffer
)
3197 (let* ((gnus-save-article-buffer save-buffer
)
3200 ((not gnus-prompt-before-saving
) 'default
)
3201 ((eq gnus-prompt-before-saving
'always
) nil
)
3203 (gnus-number-of-articles-to-be-saved
3204 (when (eq gnus-prompt-before-saving t
)
3206 (set-buffer gnus-article-current-summary
)
3207 (funcall gnus-default-article-saver filename
)))))
3209 (defun gnus-read-save-file-name (prompt &optional filename
3210 function group headers variable
)
3212 (funcall function group headers
(symbol-value variable
)))
3217 ((eq filename
'default
)
3223 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3226 (if (and gnus-number-of-articles-to-be-saved
3227 (> gnus-number-of-articles-to-be-saved
1))
3228 (format "these %d articles"
3229 gnus-number-of-articles-to-be-saved
)
3232 ;; Let the split methods have their say.
3234 ;; No split name was found.
3237 (concat prompt
" (default "
3238 (file-name-nondirectory default-name
) ") ")
3239 (file-name-directory default-name
)
3241 ;; A single group name is returned.
3242 ((stringp split-name
)
3244 (funcall function split-name headers
3245 (symbol-value variable
)))
3247 (concat prompt
" (default "
3248 (file-name-nondirectory default-name
) ") ")
3249 (file-name-directory default-name
)
3251 ;; A single split name was found
3252 ((= 1 (length split-name
))
3253 (let* ((name (expand-file-name
3255 gnus-article-save-directory
))
3256 (dir (cond ((file-directory-p name
)
3257 (file-name-as-directory name
))
3258 ((file-exists-p name
) name
)
3259 (t gnus-article-save-directory
))))
3261 (concat prompt
" (default " name
") ")
3263 ;; A list of splits was found.
3265 (setq split-name
(nreverse split-name
))
3267 (let ((file-name-history
3268 (nconc split-name file-name-history
)))
3272 (concat prompt
" (`M-p' for defaults) ")
3273 gnus-article-save-directory
3275 gnus-article-save-directory
)))
3276 (car (push result file-name-history
)))))))
3277 ;; Create the directory.
3278 (gnus-make-directory (file-name-directory file
))
3279 ;; If we have read a directory, we append the default file name.
3280 (when (file-directory-p file
)
3281 (setq file
(expand-file-name (file-name-nondirectory
3283 (file-name-as-directory file
))))
3284 ;; Possibly translate some characters.
3285 (nnheader-translate-file-chars file
))))))
3286 (gnus-make-directory (file-name-directory result
))
3287 (set variable result
)))
3289 (defun gnus-article-archive-name (group)
3290 "Return the first instance of an \"Archive-name\" in the current buffer."
3291 (let ((case-fold-search t
))
3292 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3293 (nnheader-concat gnus-article-save-directory
3294 (match-string 1)))))
3296 (defun gnus-article-nndoc-name (group)
3297 "If GROUP is an nndoc group, return the name of the parent group."
3298 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3299 (gnus-group-get-parameter group
'save-article-group
)))
3301 (defun gnus-summary-save-in-rmail (&optional filename
)
3302 "Append this article to Rmail file.
3303 Optional argument FILENAME specifies file name.
3304 Directory to save to is default to `gnus-article-save-directory'."
3305 (setq filename
(gnus-read-save-file-name
3306 "Save %s in rmail file:" filename
3307 gnus-rmail-save-name gnus-newsgroup-name
3308 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3309 (gnus-eval-in-buffer-window gnus-save-article-buffer
3313 (gnus-output-to-rmail filename
))))
3316 (defun gnus-summary-save-in-mail (&optional filename
)
3317 "Append this article to Unix mail file.
3318 Optional argument FILENAME specifies file name.
3319 Directory to save to is default to `gnus-article-save-directory'."
3320 (setq filename
(gnus-read-save-file-name
3321 "Save %s in Unix mail file:" filename
3322 gnus-mail-save-name gnus-newsgroup-name
3323 gnus-current-headers
'gnus-newsgroup-last-mail
))
3324 (gnus-eval-in-buffer-window gnus-save-article-buffer
3328 (if (and (file-readable-p filename
)
3329 (file-regular-p filename
)
3330 (mail-file-babyl-p filename
))
3331 (rmail-output-to-rmail-file filename t
)
3332 (gnus-output-to-mail filename
)))))
3335 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3336 "Append this article to file.
3337 Optional argument FILENAME specifies file name.
3338 Directory to save to is default to `gnus-article-save-directory'."
3339 (setq filename
(gnus-read-save-file-name
3340 "Save %s in file:" filename
3341 gnus-file-save-name gnus-newsgroup-name
3342 gnus-current-headers
'gnus-newsgroup-last-file
))
3343 (gnus-eval-in-buffer-window gnus-save-article-buffer
3347 (when (and overwrite
3348 (file-exists-p filename
))
3349 (delete-file filename
))
3350 (gnus-output-to-file filename
))))
3353 (defun gnus-summary-write-to-file (&optional filename
)
3354 "Write this article to a file, overwriting it if the file exists.
3355 Optional argument FILENAME specifies file name.
3356 The directory to save in defaults to `gnus-article-save-directory'."
3357 (gnus-summary-save-in-file nil t
))
3359 (defun gnus-summary-save-body-in-file (&optional filename
)
3360 "Append this article body to a file.
3361 Optional argument FILENAME specifies file name.
3362 The directory to save in defaults to `gnus-article-save-directory'."
3363 (setq filename
(gnus-read-save-file-name
3364 "Save %s body in file:" filename
3365 gnus-file-save-name gnus-newsgroup-name
3366 gnus-current-headers
'gnus-newsgroup-last-file
))
3367 (gnus-eval-in-buffer-window gnus-save-article-buffer
3371 (when (article-goto-body)
3372 (narrow-to-region (point) (point-max)))
3373 (gnus-output-to-file filename
))))
3376 (defun gnus-summary-save-in-pipe (&optional command
)
3377 "Pipe this article to subprocess."
3379 (cond ((and (eq command
'default
)
3380 gnus-last-shell-command
)
3381 gnus-last-shell-command
)
3386 "Shell command on %s: "
3387 (if (and gnus-number-of-articles-to-be-saved
3388 (> gnus-number-of-articles-to-be-saved
1))
3389 (format "these %d articles"
3390 gnus-number-of-articles-to-be-saved
)
3392 gnus-last-shell-command
))))
3393 (when (string-equal command
"")
3394 (if gnus-last-shell-command
3395 (setq command gnus-last-shell-command
)
3396 (error "A command is required")))
3397 (gnus-eval-in-buffer-window gnus-article-buffer
3400 (shell-command-on-region (point-min) (point-max) command nil
)))
3401 (setq gnus-last-shell-command command
))
3403 (defmacro gnus-read-string
(prompt &optional initial-contents history
3405 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3406 (if (and (featurep 'xemacs
)
3407 (< emacs-minor-version
2))
3408 `(read-string ,prompt
,initial-contents
,history
)
3409 `(read-string ,prompt
,initial-contents
,history
,default-value
)))
3411 (defun gnus-summary-pipe-to-muttprint (&optional command
)
3412 "Pipe this article to muttprint."
3413 (setq command
(gnus-read-string
3414 "Print using command: " gnus-summary-muttprint-program
3415 nil gnus-summary-muttprint-program
))
3416 (gnus-summary-save-in-pipe command
))
3418 ;;; Article file names when saving.
3420 (defun gnus-capitalize-newsgroup (newsgroup)
3421 "Capitalize NEWSGROUP name."
3422 (when (not (zerop (length newsgroup
)))
3423 (concat (char-to-string (upcase (aref newsgroup
0)))
3424 (substring newsgroup
1))))
3426 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
3427 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3428 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3429 Otherwise, it is like ~/News/news/group/num."
3432 (concat (if (gnus-use-long-file-name 'not-save
)
3433 (gnus-capitalize-newsgroup newsgroup
)
3434 (gnus-newsgroup-directory-form newsgroup
))
3435 "/" (int-to-string (mail-header-number headers
)))
3436 gnus-article-save-directory
)))
3438 (string-equal (file-name-directory default
)
3439 (file-name-directory last-file
))
3440 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3442 (or last-file default
))))
3444 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
3445 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3446 If variable `gnus-use-long-file-name' is non-nil, it is
3447 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3450 (concat (if (gnus-use-long-file-name 'not-save
)
3452 (gnus-newsgroup-directory-form newsgroup
))
3453 "/" (int-to-string (mail-header-number headers
)))
3454 gnus-article-save-directory
)))
3456 (string-equal (file-name-directory default
)
3457 (file-name-directory last-file
))
3458 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3460 (or last-file default
))))
3462 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
3463 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3464 If variable `gnus-use-long-file-name' is non-nil, it is
3465 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3468 (if (gnus-use-long-file-name 'not-save
)
3471 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
3473 gnus-article-save-directory
)))
3475 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
3476 "Generate file name from sender."
3477 (let ((from (mail-header-from headers
)))
3479 (if (and from
(string-match "\\([^ <]+\\)@" from
))
3480 (match-string 1 from
)
3482 gnus-article-save-directory
)))
3484 (defun article-verify-x-pgp-sig ()
3487 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3488 (let ((sig (with-current-buffer gnus-original-article-buffer
3489 (gnus-fetch-field "X-PGP-Sig")))
3493 (mml2015-clear-verify-function))
3495 (insert-buffer-substring gnus-original-article-buffer
)
3496 (setq items
(split-string sig
))
3497 (message-narrow-to-head)
3498 (let ((inhibit-point-motion-hooks t
)
3499 (case-fold-search t
))
3500 ;; Don't verify multiple headers.
3501 (setq headers
(mapconcat (lambda (header)
3503 (mail-fetch-field header
)
3505 (split-string (nth 1 items
) ",") "")))
3506 (delete-region (point-min) (point-max))
3507 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3508 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
3513 (if (looking-at "^-")
3516 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3517 (insert "Version: " (car items
) "\n\n")
3518 (insert (mapconcat 'identity
(cddr items
) "\n"))
3519 (insert "\n-----END PGP SIGNATURE-----\n")
3520 (let ((mm-security-handle (list (format "multipart/signed"))))
3521 (mml2015-clean-buffer)
3522 (let ((coding-system-for-write (or gnus-newsgroup-charset
3524 (funcall (mml2015-clear-verify-function)))
3526 (or (mm-handle-multipart-ctl-parameter
3527 mm-security-handle
'gnus-details
)
3528 (mm-handle-multipart-ctl-parameter
3529 mm-security-handle
'gnus-info
)))))
3531 (let ((inhibit-read-only t
) bface eface
)
3533 (message-narrow-to-head)
3534 (goto-char (point-max))
3536 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
3537 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
))
3538 (message-remove-header "X-Gnus-PGP-Verify")
3539 (if (re-search-forward "^X-PGP-Sig:" nil t
)
3541 (goto-char (point-max)))
3542 (narrow-to-region (point) (point))
3543 (insert "X-Gnus-PGP-Verify: " info
"\n")
3544 (goto-char (point-min))
3547 (if (not (looking-at "^[ \t]"))
3551 (goto-char (point-min))
3552 (when (looking-at "\\([^:]+\\): *")
3553 (put-text-property (match-beginning 1) (1+ (match-end 1))
3555 (put-text-property (match-end 0) (point-max)
3556 'face eface
)))))))))
3558 (defun article-verify-cancel-lock ()
3559 "Verify Cancel-Lock header."
3561 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3562 (canlock-verify gnus-original-article-buffer
)))
3569 (setq afunc
(car func
)
3572 gfunc
(intern (format "gnus-%s" func
))))
3574 (when (fboundp afunc
)
3575 `(lambda (&optional interactive
&rest args
)
3576 ,(documentation afunc t
)
3577 (interactive (list t
))
3579 (set-buffer gnus-article-buffer
)
3581 (call-interactively ',afunc
)
3582 (apply ',afunc args
))))))))
3583 '(article-hide-headers
3584 article-verify-x-pgp-sig
3585 article-verify-cancel-lock
3586 article-hide-boring-headers
3587 article-treat-overstrike
3588 article-fill-long-lines
3589 article-capitalize-sentences
3591 article-remove-leading-whitespace
3592 article-display-x-face
3593 article-display-face
3594 article-de-quoted-unreadable
3595 article-de-base64-unreadable
3598 article-unsplit-urls
3599 article-hide-list-identifiers
3600 article-strip-banner
3603 article-hide-signature
3604 article-strip-headers-in-body
3605 article-remove-trailing-blank-lines
3606 article-strip-leading-blank-lines
3607 article-strip-multiple-blank-lines
3608 article-strip-leading-space
3609 article-strip-trailing-space
3610 article-strip-blank-lines
3611 article-strip-all-blank-lines
3613 article-date-english
3614 article-date-iso8601
3615 article-date-original
3617 article-decode-mime-words
3618 article-decode-charset
3619 article-decode-encoded-words
3623 article-treat-dumbquotes
3624 article-normalize-headers
3625 ;; (article-show-all . gnus-article-show-all-headers)
3629 ;;; Gnus article mode
3632 (put 'gnus-article-mode
'mode-class
'special
)
3634 (set-keymap-parent gnus-article-mode-map widget-keymap
)
3636 (gnus-define-keys gnus-article-mode-map
3637 " " gnus-article-goto-next-page
3638 "\177" gnus-article-goto-prev-page
3639 [delete] gnus-article-goto-prev-page
3640 [backspace] gnus-article-goto-prev-page
3641 "\C-c^" gnus-article-refer-article
3642 "h" gnus-article-show-summary
3643 "s" gnus-article-show-summary
3644 "\C-c\C-m" gnus-article-mail
3645 "?" gnus-article-describe-briefly
3646 "e" gnus-summary-edit-article
3647 "<" beginning-of-buffer
3649 "\C-c\C-i" gnus-info-find-node
3651 "R" gnus-article-reply-with-original
3652 "F" gnus-article-followup-with-original
3653 "\C-hk" gnus-article-describe-key
3654 "\C-hc" gnus-article-describe-key-briefly
3656 "\C-d" gnus-article-read-summary-keys
3657 "\M-*" gnus-article-read-summary-keys
3658 "\M-#" gnus-article-read-summary-keys
3659 "\M-^" gnus-article-read-summary-keys
3660 "\M-g" gnus-article-read-summary-keys)
3662 (substitute-key-definition
3663 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3665 (defun gnus-article-make-menu-bar ()
3666 (unless (boundp 'gnus-article-commands-menu)
3667 (gnus-summary-make-menu-bar))
3668 (gnus-turn-off-edit-menu 'article)
3669 (unless (boundp 'gnus-article-article-menu)
3671 gnus-article-article-menu gnus-article-mode-map ""
3673 ["Scroll forwards" gnus-article-goto-next-page t]
3674 ["Scroll backwards" gnus-article-goto-prev-page t]
3675 ["Show summary" gnus-article-show-summary t]
3676 ["Fetch Message-ID at point" gnus-article-refer-article t]
3677 ["Mail to address at point" gnus-article-mail t]
3678 ["Send a bug report" gnus-bug t]))
3681 gnus-article-treatment-menu gnus-article-mode-map ""
3682 ;; Fixme: this should use :active (and maybe :visible).
3684 ["Hide headers" gnus-article-hide-headers t]
3685 ["Hide signature" gnus-article-hide-signature t]
3686 ["Hide citation" gnus-article-hide-citation t]
3687 ["Treat overstrike" gnus-article-treat-overstrike t]
3688 ["Remove carriage return" gnus-article-remove-cr t]
3689 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3690 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3691 ["Remove base64" gnus-article-de-base64-unreadable t]
3692 ["Treat html" gnus-article-wash-html t]
3693 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3694 ["Decode HZ" gnus-article-decode-HZ t]))
3696 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3698 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3700 (gnus-run-hooks 'gnus-article-menu-hook)))
3702 (defun gnus-article-mode ()
3703 "Major mode for displaying an article.
3705 All normal editing commands are switched off.
3707 The following commands are available in addition to all summary mode
3709 \\<gnus-article-mode-map>
3710 \\[gnus-article-next-page]\t Scroll the article one page forwards
3711 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3712 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3713 \\[gnus-article-show-summary]\t Display the summary buffer
3714 \\[gnus-article-mail]\t Send a reply to the address near point
3715 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3716 \\[gnus-info-find-node]\t Go to the Gnus info node"
3718 (gnus-simplify-mode-line)
3719 (setq mode-name "Article")
3720 (setq major-mode 'gnus-article-mode)
3721 (make-local-variable 'minor-mode-alist)
3722 (use-local-map gnus-article-mode-map)
3723 (when (gnus-visual-p 'article-menu 'menu)
3724 (gnus-article-make-menu-bar)
3725 (when gnus-summary-tool-bar-map
3726 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3727 (gnus-update-format-specifications nil 'article-mode)
3728 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3729 (set (make-local-variable 'gnus-page-broken) nil)
3730 (make-local-variable 'gnus-button-marker-list)
3731 (make-local-variable 'gnus-article-current-summary)
3732 (make-local-variable 'gnus-article-mime-handles)
3733 (make-local-variable 'gnus-article-decoded-p)
3734 (make-local-variable 'gnus-article-mime-handle-alist)
3735 (make-local-variable 'gnus-article-wash-types)
3736 (make-local-variable 'gnus-article-image-alist)
3737 (make-local-variable 'gnus-article-charset)
3738 (make-local-variable 'gnus-article-ignored-charsets)
3739 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3740 (set (make-local-variable 'show-nonbreak-escape) nil)
3741 (gnus-set-default-directory)
3742 (buffer-disable-undo)
3743 (setq buffer-read-only t)
3744 (set-syntax-table gnus-article-mode-syntax-table)
3745 (mm-enable-multibyte)
3746 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3748 (defun gnus-article-setup-buffer ()
3749 "Initialize the article buffer."
3750 (let* ((name (if gnus-single-article-buffer "*Article*"
3751 (concat "*Article " gnus-newsgroup-name "*")))
3753 (progn (string-match "\\*Article" name)
3754 (concat " *Original Article"
3755 (substring name (match-end 0))))))
3756 (setq gnus-article-buffer name)
3757 (setq gnus-original-article-buffer original)
3758 (setq gnus-article-mime-handle-alist nil)
3759 ;; This might be a variable local to the summary buffer.
3760 (unless gnus-single-article-buffer
3762 (set-buffer gnus-summary-buffer)
3763 (setq gnus-article-buffer name)
3764 (setq gnus-original-article-buffer original)
3765 (gnus-set-global-variables)))
3766 (gnus-article-setup-highlight-words)
3767 ;; Init original article buffer.
3769 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3770 (mm-enable-multibyte)
3771 (setq major-mode 'gnus-original-article-mode)
3772 (make-local-variable 'gnus-original-article))
3773 (if (and (get-buffer name)
3774 (with-current-buffer name
3775 (if gnus-article-edit-mode
3776 (if (y-or-n-p "Article mode edit in progress; discard? ")
3778 (set-buffer-modified-p nil)
3779 (gnus-kill-buffer name)
3782 (error "Action aborted"))
3786 (set (make-local-variable 'gnus-article-edit-mode) nil)
3787 (when gnus-article-mime-handles
3788 (mm-destroy-parts gnus-article-mime-handles)
3789 (setq gnus-article-mime-handles nil))
3790 ;; Set it to nil in article-buffer!
3791 (setq gnus-article-mime-handle-alist nil)
3792 (buffer-disable-undo)
3793 (setq buffer-read-only t)
3794 ;; This list just keeps growing if we don't reset it.
3795 (setq gnus-button-marker-list nil)
3796 (unless (eq major-mode 'gnus-article-mode)
3797 (gnus-article-mode))
3800 (set-buffer (gnus-get-buffer-create name))
3802 (make-local-variable 'gnus-summary-buffer)
3803 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3804 (current-buffer)))))
3806 ;; Set article window start at LINE, where LINE is the number of lines
3807 ;; from the head of the article.
3808 (defun gnus-article-set-window-start (&optional line)
3810 (gnus-get-buffer-window gnus-article-buffer t)
3812 (set-buffer gnus-article-buffer)
3813 (goto-char (point-min))
3816 (gnus-message 6 "Moved to bookmark")
3817 (search-forward "\n\n" nil t)
3821 (defun gnus-article-prepare (article &optional all-headers header)
3822 "Prepare ARTICLE in article mode buffer.
3823 ARTICLE should either be an article number or a Message-ID.
3824 If ARTICLE is an id, HEADER should be the article headers.
3825 If ALL-HEADERS is non-nil, no headers are hidden."
3827 ;; Make sure we start in a summary buffer.
3828 (unless (eq major-mode 'gnus-summary-mode)
3829 (set-buffer gnus-summary-buffer))
3830 (setq gnus-summary-buffer (current-buffer))
3831 (let* ((gnus-article (if header (mail-header-number header) article))
3832 (summary-buffer (current-buffer))
3833 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3834 (group gnus-newsgroup-name)
3837 (gnus-article-setup-buffer)
3838 (set-buffer gnus-article-buffer)
3839 ;; Deactivate active regions.
3840 (when (and (boundp 'transient-mark-mode)
3841 transient-mark-mode)
3842 (setq mark-active nil))
3843 (if (not (setq result (let ((inhibit-read-only t))
3844 (gnus-request-article-this-buffer
3846 ;; There is no such article.
3848 (when (and (numberp article)
3849 (not (memq article gnus-newsgroup-sparse)))
3850 (setq gnus-article-current
3851 (cons gnus-newsgroup-name article))
3852 (set-buffer gnus-summary-buffer)
3853 (setq gnus-current-article article)
3854 (if (and (memq article gnus-newsgroup-undownloaded)
3855 (not (gnus-online (gnus-find-method-for-group
3856 gnus-newsgroup-name))))
3858 (gnus-summary-set-agent-mark article)
3859 (message "Message marked for downloading"))
3860 (gnus-summary-mark-article article gnus-canceled-mark)
3861 (unless (memq article gnus-newsgroup-sparse)
3862 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3863 (if (or (eq result 'pseudo)
3864 (eq result 'nneething))
3867 (set-buffer summary-buffer)
3868 (push article gnus-newsgroup-history)
3869 (setq gnus-last-article gnus-current-article
3870 gnus-current-article 0
3871 gnus-current-headers nil
3872 gnus-article-current nil)
3873 (if (eq result 'nneething)
3874 (gnus-configure-windows 'summary)
3875 (gnus-configure-windows 'article))
3876 (gnus-set-global-variables))
3877 (let ((gnus-article-mime-handle-alist-1
3878 gnus-article-mime-handle-alist))
3879 (gnus-set-mode-line 'article)))
3880 ;; The result from the `request' was an actual article -
3881 ;; or at least some text that is now displayed in the
3883 (when (and (numberp article)
3884 (not (eq article gnus-current-article)))
3885 ;; Seems like a new article has been selected.
3886 ;; `gnus-current-article' must be an article number.
3888 (set-buffer summary-buffer)
3889 (push article gnus-newsgroup-history)
3890 (setq gnus-last-article gnus-current-article
3891 gnus-current-article article
3892 gnus-current-headers
3893 (gnus-summary-article-header gnus-current-article)
3894 gnus-article-current
3895 (cons gnus-newsgroup-name gnus-current-article))
3896 (unless (vectorp gnus-current-headers)
3897 (setq gnus-current-headers nil))
3898 (gnus-summary-goto-subject gnus-current-article)
3899 (when (gnus-summary-show-thread)
3900 ;; If the summary buffer really was folded, the
3901 ;; previous goto may not actually have gone to
3902 ;; the right article, but the thread root instead.
3904 (gnus-summary-goto-subject gnus-current-article))
3905 (gnus-run-hooks 'gnus-mark-article-hook)
3906 (gnus-set-mode-line 'summary)
3907 (when (gnus-visual-p 'article-highlight 'highlight)
3908 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3909 ;; Set the global newsgroup variables here.
3910 (gnus-set-global-variables)
3911 (setq gnus-have-all-headers
3912 (or all-headers gnus-show-all-headers))))
3914 (gnus-configure-windows 'article))
3915 (when (or (numberp article)
3917 (gnus-article-prepare-display)
3919 (goto-char (point-min))
3920 (when gnus-break-pages
3921 (gnus-narrow-to-page)))
3922 (let ((gnus-article-mime-handle-alist-1
3923 gnus-article-mime-handle-alist))
3924 (gnus-set-mode-line 'article))
3928 (set-window-point (get-buffer-window (current-buffer)) (point))
3929 (gnus-configure-windows 'article)
3933 (defun gnus-article-prepare-display ()
3934 "Make the current buffer look like a nice article."
3935 ;; Hooks for getting information from the article.
3936 ;; This hook must be called before being narrowed.
3937 (let ((gnus-article-buffer (current-buffer))
3939 (inhibit-read-only t))
3940 (unless (eq major-mode 'gnus-article-mode)
3941 (gnus-article-mode))
3942 (setq buffer-read-only nil
3943 gnus-article-wash-types nil
3944 gnus-article-image-alist nil)
3945 (gnus-run-hooks 'gnus-tmp-internal-hook)
3946 (when gnus-display-mime-function
3947 (funcall gnus-display-mime-function))
3948 (gnus-run-hooks 'gnus-article-prepare-hook)))
3951 ;;; Gnus MIME viewing functions
3954 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3955 "Format of the MIME buttons.
3957 Valid specifiers include:
3959 %T MIME type, along with additional info
3960 %n The `name' parameter
3961 %d The description, if any
3962 %l The length of the encoded part
3963 %p The part identifier number
3964 %e Dots if the part isn't displayed
3966 General format specifiers can also be used. See Info node
3967 `(gnus)Formatting Variables'.")
3969 (defvar gnus-mime-button-line-format-alist
3970 '((?t gnus-tmp-type ?s)
3971 (?T gnus-tmp-type-long ?s)
3972 (?n gnus-tmp-name ?s)
3973 (?d gnus-tmp-description ?s)
3975 (?l gnus-tmp-length ?d)
3976 (?e gnus-tmp-dots ?s)))
3978 (defvar gnus-mime-button-commands
3979 '((gnus-article-press-button "\r" "Toggle Display")
3980 (gnus-mime-view-part "v" "View Interactively...")
3981 (gnus-mime-view-part-as-type "t" "View As Type...")
3982 (gnus-mime-view-part-as-charset "C" "View As charset...")
3983 (gnus-mime-save-part "o" "Save...")
3984 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3985 (gnus-mime-delete-part "d" "Delete part")
3986 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3987 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3988 (gnus-mime-view-part-internally "E" "View Internally")
3989 (gnus-mime-view-part-externally "e" "View Externally")
3990 (gnus-mime-print-part "p" "Print")
3991 (gnus-mime-pipe-part "|" "Pipe To Command...")
3992 (gnus-mime-action-on-part "." "Take action on the part...")))
3994 (defun gnus-article-mime-part-status ()
3995 (if gnus-article-mime-handle-alist-1
3996 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3998 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4001 (defvar gnus-mime-button-map
4002 (let ((map (make-sparse-keymap)))
4003 (unless (>= (string-to-number emacs-version) 21)
4004 ;; XEmacs doesn't care.
4005 (set-keymap-parent map gnus-article-mode-map))
4006 (define-key map gnus-mouse-2 'gnus-article-push-button)
4007 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4008 (dolist (c gnus-mime-button-commands)
4009 (define-key map (cadr c) (car c)))
4013 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4015 ,@(mapcar (lambda (c)
4016 (vector (caddr c) (car c) :enable t))
4017 gnus-mime-button-commands)))
4020 (define-compiler-macro popup-menu (&whole form
4021 menu &optional position prefix)
4022 (if (and (fboundp 'popup-menu)
4023 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4025 ;; Gnus is probably running under Emacs 20.
4026 `(let* ((menu (cdr ,menu))
4027 (response (x-popup-menu
4029 (cons "" (mapcar (lambda (c)
4030 (cons (caddr c) (car c)))
4033 (call-interactively (nth 3 (assq response menu))))))))
4035 (defun gnus-mime-button-menu (event prefix)
4036 "Construct a context-sensitive menu of MIME commands."
4037 (interactive "e\nP")
4038 (save-window-excursion
4039 (let ((pos (event-start event)))
4040 (select-window (posn-window pos))
4041 (goto-char (posn-point pos))
4042 (gnus-article-check-buffer)
4043 (popup-menu gnus-mime-button-menu nil prefix))))
4045 (defun gnus-mime-view-all-parts (&optional handles)
4046 "View all the MIME parts."
4048 (save-current-buffer
4049 (set-buffer gnus-article-buffer)
4050 (let ((handles (or handles gnus-article-mime-handles))
4051 (mail-parse-charset gnus-newsgroup-charset)
4052 (mail-parse-ignored-charsets
4053 (with-current-buffer gnus-summary-buffer
4054 gnus-newsgroup-ignored-charsets)))
4056 (mm-remove-parts handles)
4057 (goto-char (point-min))
4058 (or (search-forward "\n\n") (goto-char (point-max)))
4059 (let ((inhibit-read-only t))
4060 (delete-region (point) (point-max))
4061 (mm-display-parts handles))))))
4063 (defun gnus-mime-save-part-and-strip ()
4064 "Save the MIME part under point then replace it with an external body."
4066 (gnus-article-check-buffer)
4067 (when (gnus-group-read-only-p)
4068 (error "The current group does not support deleting of parts"))
4069 (when (mm-complicated-handles gnus-article-mime-handles)
4071 The current article has a complicated MIME structure, giving up..."))
4072 (when (gnus-yes-or-no-p "\
4073 Deleting parts may malfunction or destroy the article; continue? ")
4074 (let* ((data (get-text-property (point) 'gnus-data))
4076 (handles gnus-article-mime-handles))
4077 (setq file (and data (mm-save-part data)))
4079 (with-current-buffer (mm-handle-buffer data)
4081 (insert "Content-Type: " (mm-handle-media-type data))
4082 (mml-insert-parameter-string (cdr (mm-handle-type data))
4085 (insert "Content-ID: " (message-make-message-id) "\n")
4086 (insert "Content-Transfer-Encoding: binary\n")
4089 (cdr (mm-make-handle nil
4090 `("message/external-body"
4091 (access-type . "LOCAL-FILE")
4093 (set-buffer gnus-summary-buffer)
4094 (gnus-article-edit-article
4097 (let ((mail-parse-charset (or gnus-article-charset
4098 ',gnus-newsgroup-charset))
4099 (mail-parse-ignored-charsets
4100 (or gnus-article-ignored-charsets
4101 ',gnus-newsgroup-ignored-charsets))
4102 (mbl mml-buffer-list))
4103 (setq mml-buffer-list nil)
4104 (insert-buffer gnus-original-article-buffer)
4105 (mime-to-mml ',handles)
4106 (setq gnus-article-mime-handles nil)
4107 (let ((mbl1 mml-buffer-list))
4108 (setq mml-buffer-list mbl)
4109 (set (make-local-variable 'mml-buffer-list) mbl1))
4110 (gnus-make-local-hook 'kill-buffer-hook)
4111 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4112 `(lambda (no-highlight)
4113 (let ((mail-parse-charset (or gnus-article-charset
4114 ',gnus-newsgroup-charset))
4115 (message-options message-options)
4116 (message-options-set-recipient)
4117 (mail-parse-ignored-charsets
4118 (or gnus-article-ignored-charsets
4119 ',gnus-newsgroup-ignored-charsets)))
4121 (mml-destroy-buffers)
4122 (remove-hook 'kill-buffer-hook
4123 'mml-destroy-buffers t)
4124 (kill-local-variable 'mml-buffer-list))
4125 (gnus-summary-edit-article-done
4126 ,(or (mail-header-references gnus-current-headers) "")
4127 ,(gnus-group-read-only-p)
4128 ,gnus-summary-buffer no-highlight)))))))
4130 (defun gnus-mime-delete-part ()
4131 "Delete the MIME part under point.
4132 Replace it with some information about the removed part."
4134 (gnus-article-check-buffer)
4135 (when (gnus-group-read-only-p)
4136 (error "The current group does not support deleting of parts"))
4137 (when (mm-complicated-handles gnus-article-mime-handles)
4139 The current article has a complicated MIME structure, giving up..."))
4140 (when (gnus-yes-or-no-p "\
4141 Deleting parts may malfunction or destroy the article; continue? ")
4142 (let* ((data (get-text-property (point) 'gnus-data))
4143 (handles gnus-article-mime-handles)
4147 (mail-decode-encoded-word-string (or (mm-handle-description data)
4150 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4152 (type (mm-handle-media-type data)))
4154 (error "No MIME part under point"))
4155 (with-current-buffer (mm-handle-buffer data)
4156 (let ((bsize (format "%s" (buffer-size))))
4161 "| The following attachment has been deleted:\n"
4163 "| Type: " type "\n"
4164 "| Filename: " filename "\n"
4165 "| Size (encoded): " bsize " Byte\n"
4166 "| Description: " description "\n"
4169 (cdr (mm-make-handle
4170 nil `("text/plain") nil nil
4172 (format "Deleted attachment (%s bytes)" bsize))))))
4173 (set-buffer gnus-summary-buffer)
4174 ;; FIXME: maybe some of the following code (borrowed from
4175 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4176 (gnus-article-edit-article
4179 (let ((mail-parse-charset (or gnus-article-charset
4180 ',gnus-newsgroup-charset))
4181 (mail-parse-ignored-charsets
4182 (or gnus-article-ignored-charsets
4183 ',gnus-newsgroup-ignored-charsets))
4184 (mbl mml-buffer-list))
4185 (setq mml-buffer-list nil)
4186 (insert-buffer gnus-original-article-buffer)
4187 (mime-to-mml ',handles)
4188 (setq gnus-article-mime-handles nil)
4189 (let ((mbl1 mml-buffer-list))
4190 (setq mml-buffer-list mbl)
4191 (set (make-local-variable 'mml-buffer-list) mbl1))
4192 (gnus-make-local-hook 'kill-buffer-hook)
4193 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4194 `(lambda (no-highlight)
4195 (let ((mail-parse-charset (or gnus-article-charset
4196 ',gnus-newsgroup-charset))
4197 (message-options message-options)
4198 (message-options-set-recipient)
4199 (mail-parse-ignored-charsets
4200 (or gnus-article-ignored-charsets
4201 ',gnus-newsgroup-ignored-charsets)))
4203 (mml-destroy-buffers)
4204 (remove-hook 'kill-buffer-hook
4205 'mml-destroy-buffers t)
4206 (kill-local-variable 'mml-buffer-list))
4207 (gnus-summary-edit-article-done
4208 ,(or (mail-header-references gnus-current-headers) "")
4209 ,(gnus-group-read-only-p)
4210 ,gnus-summary-buffer no-highlight)))))
4211 ;; Not in `gnus-mime-save-part-and-strip':
4212 (gnus-article-edit-done)
4213 (gnus-summary-expand-window)
4214 (gnus-summary-show-article))
4216 (defun gnus-mime-save-part ()
4217 "Save the MIME part under point."
4219 (gnus-article-check-buffer)
4220 (let ((data (get-text-property (point) 'gnus-data)))
4222 (mm-save-part data))))
4224 (defun gnus-mime-pipe-part ()
4225 "Pipe the MIME part under point to a process."
4227 (gnus-article-check-buffer)
4228 (let ((data (get-text-property (point) 'gnus-data)))
4230 (mm-pipe-part data))))
4232 (defun gnus-mime-view-part ()
4233 "Interactively choose a viewing method for the MIME part under point."
4235 (gnus-article-check-buffer)
4236 (let ((data (get-text-property (point) 'gnus-data)))
4238 (setq gnus-article-mime-handles
4240 gnus-article-mime-handles (setq data (copy-sequence data))))
4241 (mm-interactively-view-part data))))
4243 (defun gnus-mime-view-part-as-type-internal ()
4244 (gnus-article-check-buffer)
4245 (let* ((name (mail-content-type-get
4246 (mm-handle-type (get-text-property (point) 'gnus-data))
4248 (def-type (and name (mm-default-file-encoding name))))
4249 (and def-type (cons def-type 0))))
4251 (defun gnus-mime-view-part-as-type (&optional mime-type)
4252 "Choose a MIME media type, and view the part as such."
4255 (setq mime-type (completing-read
4256 "View as MIME type: "
4257 (mapcar #'list (mailcap-mime-types))
4259 (gnus-mime-view-part-as-type-internal))))
4260 (gnus-article-check-buffer)
4261 (let ((handle (get-text-property (point) 'gnus-data)))
4264 (mm-make-handle (mm-handle-buffer handle)
4265 (cons mime-type (cdr (mm-handle-type handle)))
4266 (mm-handle-encoding handle)
4267 (mm-handle-undisplayer handle)
4268 (mm-handle-disposition handle)
4269 (mm-handle-description handle)
4271 (mm-handle-id handle)))
4272 (setq gnus-article-mime-handles
4273 (mm-merge-handles gnus-article-mime-handles handle))
4274 (gnus-mm-display-part handle))))
4277 (require 'jka-compr))
4279 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4280 ;; emacs can do that itself.
4282 (defun gnus-mime-jka-compr-maybe-uncompress ()
4283 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4284 The uncompress method used is derived from `buffer-file-name'."
4285 (when (and (fboundp 'jka-compr-installed-p)
4286 (jka-compr-installed-p))
4287 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4289 (let ((basename (file-name-nondirectory buffer-file-name))
4290 (args (jka-compr-info-uncompress-args info))
4291 (prog (jka-compr-info-uncompress-program info))
4292 (message (jka-compr-info-uncompress-message info))
4293 (err-file (jka-compr-make-temp-name)))
4295 (message "%s %s..." message basename))
4297 (unless (memq (apply 'call-process-region
4298 (point-min) (point-max)
4300 t (list t err-file) nil
4302 jka-compr-acceptable-retval-list)
4303 (jka-compr-error prog args basename message err-file))
4304 (jka-compr-delete-temp-file err-file)))))))
4306 (defun gnus-mime-copy-part (&optional handle)
4307 "Put the MIME part under point into a new buffer.
4308 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4311 (gnus-article-check-buffer)
4312 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4313 (contents (and handle (mm-get-part handle)))
4315 (file-name-nondirectory
4317 (mail-content-type-get (mm-handle-type handle) 'name)
4318 (mail-content-type-get (mm-handle-disposition handle)
4321 (buffer (and base (generate-new-buffer base))))
4323 (switch-to-buffer buffer)
4325 ;; We do it this way to make `normal-mode' set the appropriate mode.
4328 (setq buffer-file-name (expand-file-name base))
4329 (gnus-mime-jka-compr-maybe-uncompress)
4331 (setq buffer-file-name nil))
4332 (goto-char (point-min)))))
4334 (defun gnus-mime-print-part (&optional handle filename)
4335 "Print the MIME part under point."
4336 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4337 (gnus-article-check-buffer)
4338 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4339 (contents (and handle (mm-get-part handle)))
4340 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4341 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4346 (mm-save-part-to-file handle file)
4347 (call-process shell-file-name nil
4348 (generate-new-buffer " *mm*")
4350 shell-command-switch
4352 printer file (mm-handle-type handle))))
4356 (gnus-print-buffer))
4357 (ps-despool filename)))))
4359 (defun gnus-mime-inline-part (&optional handle arg)
4360 "Insert the MIME part under point into the current buffer."
4361 (interactive (list nil current-prefix-arg))
4362 (gnus-article-check-buffer)
4363 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4366 (inhibit-read-only t))
4368 (if (and (not arg) (mm-handle-undisplayer handle))
4369 (mm-remove-part handle)
4370 (setq contents (mm-get-part handle))
4373 (setq charset (or (mail-content-type-get
4374 (mm-handle-type handle) 'charset)
4375 gnus-newsgroup-charset)))
4377 (if (mm-handle-undisplayer handle)
4378 (mm-remove-part handle))
4381 gnus-summary-show-article-charset-alist))
4382 (mm-read-coding-system "Charset: "))))
4384 (if (mm-handle-undisplayer handle)
4385 (mm-remove-part handle))))
4390 (setq charset (mm-charset-to-coding-system
4392 (not (eq charset 'ascii)))
4393 (mm-decode-coding-string contents charset)
4394 (mm-string-to-multibyte contents)))
4397 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4398 "Insert the MIME part under point into the current buffer using the
4400 (interactive (list nil current-prefix-arg))
4401 (gnus-article-check-buffer)
4402 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4405 (inhibit-read-only t))
4407 (if (mm-handle-undisplayer handle)
4408 (mm-remove-part handle))
4409 (let ((gnus-newsgroup-charset
4411 gnus-summary-show-article-charset-alist))
4412 (mm-read-coding-system "Charset: ")))
4413 (gnus-newsgroup-ignored-charsets 'gnus-all))
4414 (gnus-article-press-button)))))
4416 (defun gnus-mime-view-part-externally (&optional handle)
4417 "View the MIME part under point with an external viewer."
4419 (gnus-article-check-buffer)
4420 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4421 (mm-user-display-methods nil)
4422 (mm-inlined-types nil)
4423 (mail-parse-charset gnus-newsgroup-charset)
4424 (mail-parse-ignored-charsets
4425 (save-excursion (set-buffer gnus-summary-buffer)
4426 gnus-newsgroup-ignored-charsets)))
4428 (if (mm-handle-undisplayer handle)
4429 (mm-remove-part handle)
4430 (mm-display-part handle)))))
4432 (defun gnus-mime-view-part-internally (&optional handle)
4433 "View the MIME part under point with an internal viewer.
4434 If no internal viewer is available, use an external viewer."
4436 (gnus-article-check-buffer)
4437 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4438 (mm-inlined-types '(".*"))
4439 (mm-inline-large-images t)
4440 (mail-parse-charset gnus-newsgroup-charset)
4441 (mail-parse-ignored-charsets
4442 (save-excursion (set-buffer gnus-summary-buffer)
4443 gnus-newsgroup-ignored-charsets))
4444 (inhibit-read-only t))
4446 (if (mm-handle-undisplayer handle)
4447 (mm-remove-part handle)
4448 (mm-display-part handle)))))
4450 (defun gnus-mime-action-on-part (&optional action)
4451 "Do something with the MIME attachment at \(point\)."
4453 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4454 (gnus-article-check-buffer)
4455 (let ((action-pair (assoc action gnus-mime-action-alist)))
4457 (funcall (cdr action-pair)))))
4459 (defun gnus-article-part-wrapper (n function)
4460 (save-current-buffer
4461 (set-buffer gnus-article-buffer)
4462 (when (> n (length gnus-article-mime-handle-alist))
4463 (error "No such part"))
4464 (gnus-article-goto-part n)
4465 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4466 (funcall function handle))))
4468 (defun gnus-article-pipe-part (n)
4469 "Pipe MIME part N, which is the numerical prefix."
4471 (gnus-article-part-wrapper n 'mm-pipe-part))
4473 (defun gnus-article-save-part (n)
4474 "Save MIME part N, which is the numerical prefix."
4476 (gnus-article-part-wrapper n 'mm-save-part))
4478 (defun gnus-article-interactively-view-part (n)
4479 "View MIME part N interactively, which is the numerical prefix."
4481 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4483 (defun gnus-article-copy-part (n)
4484 "Copy MIME part N, which is the numerical prefix."
4486 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4488 (defun gnus-article-view-part-as-charset (n)
4489 "View MIME part N using a specified charset.
4490 N is the numerical prefix."
4492 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4494 (defun gnus-article-view-part-externally (n)
4495 "View MIME part N externally, which is the numerical prefix."
4497 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4499 (defun gnus-article-inline-part (n)
4500 "Inline MIME part N, which is the numerical prefix."
4502 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4504 (defun gnus-article-mime-match-handle-first (condition)
4506 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4507 (while (setq ihandle (pop alist))
4509 ((functionp condition)
4510 (funcall condition (cdr ihandle)))
4511 ((eq condition 'undisplayed)
4512 (not (or (mm-handle-undisplayer (cdr ihandle))
4513 (equal (mm-handle-media-type (cdr ihandle))
4514 "multipart/alternative"))))
4515 ((eq condition 'undisplayed-alternative)
4516 (not (mm-handle-undisplayer (cdr ihandle))))
4518 (gnus-article-goto-part (car ihandle))
4519 (or (not n) (< (car ihandle) n)))
4520 (setq n (car ihandle))))
4524 (defun gnus-article-view-part (&optional n)
4525 "View MIME part N, which is the numerical prefix."
4527 (save-current-buffer
4528 (set-buffer gnus-article-buffer)
4529 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4530 gnus-article-mime-match-handle-function)))
4531 (when (> n (length gnus-article-mime-handle-alist))
4532 (error "No such part"))
4533 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4534 (when (gnus-article-goto-part n)
4535 (if (equal (car handle) "multipart/alternative")
4536 (gnus-article-press-button)
4537 (when (eq (gnus-mm-display-part handle) 'internal)
4538 (gnus-set-window-start)))))))
4540 (defsubst gnus-article-mime-total-parts ()
4541 (if (bufferp (car gnus-article-mime-handles))
4543 (1- (length gnus-article-mime-handles))))
4545 (defun gnus-mm-display-part (handle)
4546 "Display HANDLE and fix MIME button."
4547 (let ((id (get-text-property (point) 'gnus-part))
4549 (inhibit-read-only t))
4552 (let ((window (selected-window))
4553 (mail-parse-charset gnus-newsgroup-charset)
4554 (mail-parse-ignored-charsets
4555 (if (gnus-buffer-live-p gnus-summary-buffer)
4557 (set-buffer gnus-summary-buffer)
4558 gnus-newsgroup-ignored-charsets)
4562 (let ((win (gnus-get-buffer-window (current-buffer) t))
4565 (select-window win))
4568 (if (mm-handle-displayed-p handle)
4569 ;; This will remove the part.
4570 (mm-display-part handle)
4572 (narrow-to-region (point)
4573 (if (eobp) (point) (1+ (point))))
4574 (mm-display-part handle)
4575 ;; We narrow to the part itself and
4576 ;; then call the treatment functions.
4577 (goto-char (point-min))
4579 (narrow-to-region (point) (point-max))
4582 (gnus-article-mime-total-parts)
4583 (mm-handle-media-type handle)))))
4584 (if (window-live-p window)
4585 (select-window window)))))
4588 (gnus-insert-mime-button
4589 handle id (list (mm-handle-displayed-p handle)))
4590 (goto-char point))))
4592 (defun gnus-article-goto-part (n)
4593 "Go to MIME part N."
4594 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4596 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4597 (let ((gnus-tmp-name
4598 (or (mail-content-type-get (mm-handle-type handle) 'name)
4599 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4600 (mail-content-type-get (mm-handle-type handle) 'url)
4602 (gnus-tmp-type (mm-handle-media-type handle))
4603 (gnus-tmp-description
4604 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4607 (if (if displayed (car displayed)
4608 (mm-handle-displayed-p handle))
4610 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4612 gnus-tmp-type-long b e)
4613 (when (string-match ".*/" gnus-tmp-name)
4614 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4615 (setq gnus-tmp-type-long (concat gnus-tmp-type
4616 (and (not (equal gnus-tmp-name ""))
4617 (concat "; " gnus-tmp-name))))
4618 (unless (equal gnus-tmp-description "")
4619 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4624 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4625 `(,@(gnus-local-map-property gnus-mime-button-map)
4626 gnus-callback gnus-mm-display-part
4627 gnus-part ,gnus-tmp-id
4628 article-type annotation
4631 ;; Exclude a newline.
4634 (widget-convert-button
4637 :action 'gnus-widget-press-button
4638 :button-keymap gnus-mime-button-map
4640 (lambda (widget/window &optional overlay pos)
4641 ;; Needed to properly clear the message due to a bug in
4642 ;; wid-edit (XEmacs only).
4643 (if (boundp 'help-echo-owns-message)
4644 (setq help-echo-owns-message t))
4646 "%S: %s the MIME part; %S: more options"
4647 (aref gnus-mouse-2 0)
4648 ;; XEmacs will get a single widget arg; Emacs 21 will get
4649 ;; window, overlay, position.
4650 (if (mm-handle-displayed-p
4652 (with-current-buffer (gnus-overlay-buffer overlay)
4653 (widget-get (widget-at (gnus-overlay-start overlay))
4655 (widget-get widget/window :mime-handle)))
4657 (aref gnus-down-mouse-3 0))))))
4659 (defun gnus-widget-press-button (elems el)
4660 (goto-char (widget-get elems :from))
4661 (gnus-article-press-button))
4663 (defvar gnus-displaying-mime nil)
4665 (defun gnus-display-mime (&optional ihandles)
4666 "Display the MIME parts."
4668 (save-selected-window
4669 (let ((window (get-buffer-window gnus-article-buffer))
4672 (select-window window)
4673 ;; We have to do this since selecting the window
4674 ;; may change the point. So we set the window point.
4675 (set-window-point window point)))
4676 (let* ((handles (or ihandles
4677 (mm-dissect-buffer nil gnus-article-loose-mime)
4678 (and gnus-article-emulate-mime
4680 (inhibit-read-only t) handle name type b e display)
4681 (when (and (not ihandles)
4682 (not gnus-displaying-mime))
4683 ;; Top-level call; we clean up.
4684 (when gnus-article-mime-handles
4685 (mm-destroy-parts gnus-article-mime-handles)
4686 (setq gnus-article-mime-handle-alist nil));; A trick.
4687 (setq gnus-article-mime-handles handles)
4688 ;; We allow users to glean info from the handles.
4689 (when gnus-article-mime-part-function
4690 (gnus-mime-part-function handles)))
4692 (or (not (stringp (car handles)))
4695 (when (and (not ihandles)
4696 (not gnus-displaying-mime))
4697 ;; Clean up for mime parts.
4699 (delete-region (point) (point-max)))
4700 (let ((gnus-displaying-mime t))
4701 (gnus-mime-display-part handles)))
4704 (narrow-to-region (point) (point-max))
4705 (gnus-treat-article nil 1 1)
4708 ;; Highlight the headers.
4712 (narrow-to-region (point-min) (point))
4713 (gnus-article-save-original-date
4714 (gnus-treat-article 'head)))))))))
4716 (defcustom gnus-mime-display-multipart-as-mixed nil
4717 "Display \"multipart\" parts as \"multipart/mixed\".
4719 If t, it overrides nil values of
4720 `gnus-mime-display-multipart-alternative-as-mixed' and
4721 `gnus-mime-display-multipart-related-as-mixed'."
4722 :group 'gnus-article-mime
4725 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4726 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4728 :group 'gnus-article-mime
4731 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4732 "Display \"multipart/related\" parts as \"multipart/mixed\".
4734 If displaying \"text/html\" is discouraged \(see
4735 `mm-discouraged-alternatives'\) images or other material inside a
4736 \"multipart/related\" part might be overlooked when this variable is nil."
4738 :group 'gnus-article-mime
4741 (defun gnus-mime-display-part (handle)
4744 ((not (stringp (car handle)))
4745 (gnus-mime-display-single handle))
4746 ;; User-defined multipart
4747 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4748 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4750 ;; multipart/alternative
4751 ((and (equal (car handle) "multipart/alternative")
4752 (not (or gnus-mime-display-multipart-as-mixed
4753 gnus-mime-display-multipart-alternative-as-mixed)))
4754 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4755 (push (cons id handle) gnus-article-mime-handle-alist)
4756 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4757 ;; multipart/related
4758 ((and (equal (car handle) "multipart/related")
4759 (not (or gnus-mime-display-multipart-as-mixed
4760 gnus-mime-display-multipart-related-as-mixed)))
4761 ;;;!!!We should find the start part, but we just default
4762 ;;;!!!to the first part.
4763 ;;(gnus-mime-display-part (cadr handle))
4764 ;;;!!! Most multipart/related is an HTML message plus images.
4765 ;;;!!! Unfortunately we are unable to let W3 display those
4766 ;;;!!! included images, so we just display it as a mixed multipart.
4767 ;;(gnus-mime-display-mixed (cdr handle))
4768 ;;;!!! No, w3 can display everything just fine.
4769 (gnus-mime-display-part (cadr handle)))
4770 ((equal (car handle) "multipart/signed")
4771 (gnus-add-wash-type 'signed)
4772 (gnus-mime-display-security handle))
4773 ((equal (car handle) "multipart/encrypted")
4774 (gnus-add-wash-type 'encrypted)
4775 (gnus-mime-display-security handle))
4776 ;; Other multiparts are handled like multipart/mixed.
4778 (gnus-mime-display-mixed (cdr handle)))))
4780 (defun gnus-mime-part-function (handles)
4781 (if (stringp (car handles))
4782 (mapcar 'gnus-mime-part-function (cdr handles))
4783 (funcall gnus-article-mime-part-function handles)))
4785 (defun gnus-mime-display-mixed (handles)
4786 (mapcar 'gnus-mime-display-part handles))
4788 (defun gnus-mime-display-single (handle)
4789 (let ((type (mm-handle-media-type handle))
4790 (ignored gnus-ignored-mime-types)
4797 (when (string-match (pop ignored) type)
4798 (throw 'ignored nil)))
4799 (if (and (setq not-attachment
4800 (and (not (mm-inline-override-p handle))
4801 (or (not (mm-handle-disposition handle))
4802 (equal (car (mm-handle-disposition handle))
4804 (mm-attachment-override-p handle))))
4805 (mm-automatic-display-p handle)
4807 (mm-inlinable-p handle)
4808 (mm-inlined-p handle))
4809 (mm-automatic-external-display-p type)))
4811 (when (equal (mm-handle-media-supertype handle) "text")
4813 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4815 (push (cons id handle) gnus-article-mime-handle-alist)
4816 (when (or (not display)
4817 (not (gnus-unbuttonized-mime-type-p type)))
4818 ;(gnus-article-insert-newline)
4819 (gnus-insert-mime-button
4820 handle id (list (or display (and not-attachment text))))
4821 (gnus-article-insert-newline)
4822 ;(gnus-article-insert-newline)
4823 ;; Remember modify the number of forward lines.
4831 (let ((mail-parse-charset gnus-newsgroup-charset)
4832 (mail-parse-ignored-charsets
4833 (save-excursion (condition-case ()
4834 (set-buffer gnus-summary-buffer)
4836 gnus-newsgroup-ignored-charsets)))
4837 (mm-display-part handle t))
4838 (goto-char (point-max)))
4839 ((and text not-attachment)
4843 (gnus-article-insert-newline)
4844 (mm-insert-inline handle (mm-get-part handle))
4845 (goto-char (point-max))))
4849 (narrow-to-region beg (point))
4852 (gnus-article-mime-total-parts)
4853 (mm-handle-media-type handle)))))))))
4855 (defun gnus-unbuttonized-mime-type-p (type)
4856 "Say whether TYPE is to be unbuttonized."
4857 (unless gnus-inhibit-mime-unbuttonizing
4859 (let ((types gnus-unbuttonized-mime-types))
4861 (when (string-match (pop types) type)
4862 (throw 'found t)))))
4864 (let ((types gnus-buttonized-mime-types))
4866 (when (string-match (pop types) type)
4867 (throw 'found t)))))))))
4869 (defun gnus-article-insert-newline ()
4870 "Insert a newline, but mark it as undeletable."
4871 (gnus-put-text-property
4872 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4874 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4875 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4878 handle (inhibit-read-only t) from props begend not-pref)
4879 (save-window-excursion
4882 (narrow-to-region (car ibegend)
4885 (goto-char (car ibegend))
4888 (delete-region (point-min) (point-max))
4889 (mm-remove-parts handles))
4890 (setq begend (list (point-marker)))
4892 (unless (setq not-pref (cadr (member preferred ihandles)))
4893 (setq not-pref (car ihandles)))
4896 (not (gnus-unbuttonized-mime-type-p
4897 "multipart/alternative")))
4898 (gnus-add-text-properties
4901 (insert (format "%d. " id))
4905 (unless ,(not ibegend)
4906 (setq gnus-article-mime-handle-alist
4907 ',gnus-article-mime-handle-alist))
4908 (gnus-mime-display-alternative
4909 ',ihandles ',not-pref ',begend ,id))
4910 ,@(gnus-local-map-property gnus-mime-button-map)
4911 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4912 face ,gnus-article-button-face
4915 (widget-convert-button 'link from (point)
4916 :action 'gnus-widget-press-button
4917 :button-keymap gnus-widget-button-keymap)
4919 (while (setq handle (pop handles))
4920 (gnus-add-text-properties
4923 (insert (format "(%c) %-18s"
4924 (if (equal handle preferred) ?* ? )
4925 (mm-handle-media-type handle)))
4929 (unless ,(not ibegend)
4930 (setq gnus-article-mime-handle-alist
4931 ',gnus-article-mime-handle-alist))
4932 (gnus-mime-display-alternative
4933 ',ihandles ',handle ',begend ,id))
4934 ,@(gnus-local-map-property gnus-mime-button-map)
4935 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4936 face ,gnus-article-button-face
4939 (widget-convert-button 'link from (point)
4940 :action 'gnus-widget-press-button
4941 :button-keymap gnus-widget-button-keymap)
4945 (if (stringp (car preferred))
4946 (gnus-display-mime preferred)
4947 (let ((mail-parse-charset gnus-newsgroup-charset)
4948 (mail-parse-ignored-charsets
4949 (save-excursion (set-buffer gnus-summary-buffer)
4950 gnus-newsgroup-ignored-charsets)))
4951 (mm-display-part preferred)
4955 (narrow-to-region (car begend) (point-max))
4957 nil (length gnus-article-mime-handle-alist)
4958 (gnus-article-mime-total-parts)
4959 (mm-handle-media-type handle))))))
4960 (goto-char (point-max))
4961 (setcdr begend (point-marker)))))
4963 (goto-char point))))
4965 (defconst gnus-article-wash-status-strings
4966 (let ((alist '((cite "c" "Possible hidden citation text"
4967 " " "All citation text visible")
4968 (headers "h" "Hidden headers"
4969 " " "All headers visible.")
4970 (pgp "p" "Encrypted or signed message status hidden"
4971 " " "No hidden encryption nor digital signature status")
4972 (signature "s" "Signature has been hidden"
4973 " " "Signature is visible")
4974 (overstrike "o" "Overstrike (^H) characters applied"
4975 " " "No overstrike characters applied")
4976 (emphasis "e" "/*_Emphasis_*/ characters applied"
4977 " " "No /*_emphasis_*/ characters applied")))
4979 (dolist (entry alist result)
4980 (let ((key (nth 0 entry))
4981 (on (copy-sequence (nth 1 entry)))
4982 (on-help (nth 2 entry))
4983 (off (copy-sequence (nth 3 entry)))
4984 (off-help (nth 4 entry)))
4985 (put-text-property 0 1 'help-echo on-help on)
4986 (put-text-property 0 1 'help-echo off-help off)
4987 (push (list key on off) result))))
4988 "Alist of strings describing wash status in the mode line.
4989 Each entry has the form (KEY ON OF), where the KEY is a symbol
4990 representing the particular washing function, ON is the string to use
4991 in the article mode line when the washing function is active, and OFF
4992 is the string to use when it is inactive.")
4994 (defun gnus-article-wash-status-entry (key value)
4995 (let ((entry (assoc key gnus-article-wash-status-strings)))
4996 (if value (nth 1 entry) (nth 2 entry))))
4998 (defun gnus-article-wash-status ()
4999 "Return a string which display status of article washing."
5001 (set-buffer gnus-article-buffer)
5002 (let ((cite (memq 'cite gnus-article-wash-types))
5003 (headers (memq 'headers gnus-article-wash-types))
5004 (boring (memq 'boring-headers gnus-article-wash-types))
5005 (pgp (memq 'pgp gnus-article-wash-types))
5006 (pem (memq 'pem gnus-article-wash-types))
5007 (signed (memq 'signed gnus-article-wash-types))
5008 (encrypted (memq 'encrypted gnus-article-wash-types))
5009 (signature (memq 'signature gnus-article-wash-types))
5010 (overstrike (memq 'overstrike gnus-article-wash-types))
5011 (emphasis (memq 'emphasis gnus-article-wash-types)))
5013 (gnus-article-wash-status-entry 'cite cite)
5014 (gnus-article-wash-status-entry 'headers (or headers boring))
5015 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5016 (gnus-article-wash-status-entry 'signature signature)
5017 (gnus-article-wash-status-entry 'overstrike overstrike)
5018 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5020 (defun gnus-add-wash-type (type)
5021 "Add a washing of TYPE to the current status."
5022 (add-to-list 'gnus-article-wash-types type))
5024 (defun gnus-delete-wash-type (type)
5025 "Add a washing of TYPE to the current status."
5026 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5028 (defun gnus-add-image (category image)
5029 "Add IMAGE of CATEGORY to the list of displayed images."
5030 (let ((entry (assq category gnus-article-image-alist)))
5032 (setq entry (list category))
5033 (push entry gnus-article-image-alist))
5034 (nconc entry (list image))))
5036 (defun gnus-delete-images (category)
5037 "Delete all images in CATEGORY."
5038 (let ((entry (assq category gnus-article-image-alist)))
5039 (dolist (image (cdr entry))
5040 (gnus-remove-image image category))
5041 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5042 (gnus-delete-wash-type category)))
5044 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5046 (defun gnus-article-maybe-hide-headers ()
5047 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5048 Provided for backwards compatibility."
5049 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5050 (not (save-excursion (set-buffer gnus-summary-buffer)
5051 gnus-have-all-headers)))
5052 (not gnus-inhibit-hiding))
5053 (gnus-article-hide-headers)))
5057 (defun gnus-output-to-file (file-name)
5058 "Append the current article to a file named FILE-NAME."
5059 (let ((artbuf (current-buffer)))
5061 (insert-buffer-substring artbuf)
5062 ;; Append newline at end of the buffer as separator, and then
5064 (goto-char (point-max))
5066 (let ((file-name-coding-system nnmail-pathname-coding-system))
5067 (mm-append-to-file (point-min) (point-max) file-name))
5070 (defun gnus-narrow-to-page (&optional arg)
5071 "Narrow the article buffer to a page.
5072 If given a numerical ARG, move forward ARG pages."
5074 (setq arg (if arg (prefix-numeric-value arg) 0))
5076 (set-buffer gnus-article-buffer)
5077 (goto-char (point-min))
5079 ;; Remove any old next/prev buttons.
5080 (when (gnus-visual-p 'page-marker)
5081 (let ((inhibit-read-only t))
5082 (gnus-remove-text-with-property 'gnus-prev)
5083 (gnus-remove-text-with-property 'gnus-next)))
5086 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5088 (re-search-forward page-delimiter nil 'move arg)))
5089 (goto-char (match-end 0))
5091 (goto-char (point-min))
5092 (setq gnus-page-broken
5093 (and (re-search-forward page-delimiter nil t) t))))
5094 (when gnus-page-broken
5097 (if (re-search-forward page-delimiter nil 'move)
5100 (when (and (gnus-visual-p 'page-marker)
5101 (> (point-min) (save-restriction (widen) (point-min))))
5103 (goto-char (point-min))
5104 (gnus-insert-prev-page-button)))
5105 (when (and (gnus-visual-p 'page-marker)
5106 (< (point-max) (save-restriction (widen) (point-max))))
5108 (goto-char (point-max))
5109 (gnus-insert-next-page-button))))))
5111 ;; Article mode commands
5113 (defun gnus-article-goto-next-page ()
5114 "Show the next page of the article."
5116 (when (gnus-article-next-page)
5117 (goto-char (point-min))
5118 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5121 (defun gnus-article-goto-prev-page ()
5122 "Show the previous page of the article."
5125 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5126 (gnus-article-prev-page nil)))
5128 ;; This is cleaner but currently breaks `gnus-pick-mode':
5130 ;; (defun gnus-article-goto-next-page ()
5131 ;; "Show the next page of the article."
5133 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5134 ;; (gnus-summary-next-page)))
5136 ;; (defun gnus-article-goto-prev-page ()
5137 ;; "Show the next page of the article."
5139 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5140 ;; (gnus-summary-prev-page)))
5142 (defun gnus-article-next-page (&optional lines)
5143 "Show the next page of the current article.
5144 If end of article, return non-nil. Otherwise return nil.
5145 Argument LINES specifies lines to be scrolled up."
5147 (move-to-window-line -1)
5150 (and (pos-visible-in-window-p) ;Not continuation line.
5151 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5152 ;; Nothing in this page.
5153 (if (or (not gnus-page-broken)
5158 (eobp)))) ;Real end-of-buffer?
5160 (when gnus-article-over-scroll
5161 (gnus-article-next-page-1 lines))
5163 (gnus-narrow-to-page 1) ;Go to next page.
5165 ;; More in this page.
5166 (gnus-article-next-page-1 lines)
5169 (defun gnus-article-next-page-1 (lines)
5170 (let ((scroll-in-place nil))
5174 ;; Long lines may cause an end-of-buffer error.
5175 (goto-char (point-max)))))
5176 (move-to-window-line 0))
5178 (defun gnus-article-prev-page (&optional lines)
5179 "Show previous page of current article.
5180 Argument LINES specifies lines to be scrolled down."
5182 (move-to-window-line 0)
5183 (if (and gnus-page-broken
5185 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5187 (gnus-narrow-to-page -1) ;Go to previous page.
5188 (goto-char (point-max))
5190 (let ((scroll-in-place nil))
5194 (beginning-of-buffer
5195 (goto-char (point-min))))
5196 (move-to-window-line 0)))))
5198 (defun gnus-article-only-boring-p ()
5199 "Decide whether there is only boring text remaining in the article.
5200 Something \"interesting\" is a word of at least two letters that does
5201 not have a face in `gnus-article-boring-faces'."
5202 (when (and gnus-article-skip-boring
5203 (boundp 'gnus-article-boring-faces)
5204 (symbol-value 'gnus-article-boring-faces))
5207 (while (re-search-forward "\\b\\w\\w" nil t)
5209 (when (not (gnus-intersection
5210 (gnus-faces-at (point))
5211 (symbol-value 'gnus-article-boring-faces)))
5212 (throw 'only-boring nil)))
5213 (throw 'only-boring t)))))
5215 (defun gnus-article-refer-article ()
5216 "Read article specified by message-id around point."
5219 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5220 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5221 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5222 (let ((msg-id (concat "<" (match-string 0) ">")))
5223 (set-buffer gnus-summary-buffer)
5224 (gnus-summary-refer-article msg-id))
5225 (error "No references around point"))))
5227 (defun gnus-article-show-summary ()
5228 "Reconfigure windows to show summary buffer."
5230 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5231 (error "There is no summary buffer for this article buffer")
5232 (gnus-article-set-globals)
5233 (gnus-configure-windows 'article)
5234 (gnus-summary-goto-subject gnus-current-article)
5235 (gnus-summary-position-point)))
5237 (defun gnus-article-describe-briefly ()
5238 "Describe article mode commands briefly."
5240 (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")))
5242 (defun gnus-article-summary-command ()
5243 "Execute the last keystroke in the summary buffer."
5245 (let ((obuf (current-buffer))
5246 (owin (current-window-configuration))
5248 (switch-to-buffer gnus-article-current-summary 'norecord)
5249 (setq func (lookup-key (current-local-map) (this-command-keys)))
5250 (call-interactively func)
5252 (set-window-configuration owin)
5253 (set-window-point (get-buffer-window (current-buffer)) (point))))
5255 (defun gnus-article-summary-command-nosave ()
5256 "Execute the last keystroke in the summary buffer."
5259 (pop-to-buffer gnus-article-current-summary 'norecord)
5260 (setq func (lookup-key (current-local-map) (this-command-keys)))
5261 (call-interactively func)))
5263 (defun gnus-article-check-buffer ()
5264 "Beep if not in an article buffer."
5265 (unless (equal major-mode 'gnus-article-mode)
5266 (error "Command invoked outside of a Gnus article buffer")))
5268 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5269 "Read a summary buffer key sequence and execute it from the article buffer."
5271 (gnus-article-check-buffer)
5273 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5274 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5275 "=" "^" "\M-^" "|"))
5281 '("n" "Gn" "p" "Gp"))
5284 (set-buffer gnus-article-current-summary)
5285 (let (gnus-pick-mode)
5286 (push (or key last-command-event) unread-command-events)
5287 (setq keys (if (featurep 'xemacs)
5288 (events-to-keys (read-key-sequence nil))
5289 (read-key-sequence nil)))))
5293 (if (or (member keys nosaves)
5294 (member keys nosave-but-article)
5295 (member keys nosave-in-article))
5297 (save-window-excursion
5298 (pop-to-buffer gnus-article-current-summary 'norecord)
5299 ;; We disable the pick minor mode commands.
5300 (let (gnus-pick-mode)
5301 (setq func (lookup-key (current-local-map) keys))))
5305 (unless (member keys nosave-in-article)
5306 (set-buffer gnus-article-current-summary))
5307 (call-interactively func)
5308 (setq new-sum-point (point)))
5309 (when (member keys nosave-but-article)
5310 (pop-to-buffer gnus-article-buffer 'norecord)))
5311 ;; These commands should restore window configuration.
5312 (let ((obuf (current-buffer))
5313 (owin (current-window-configuration))
5315 win func in-buffer selected new-sum-start new-sum-hscroll)
5316 (cond (not-restore-window
5317 (pop-to-buffer gnus-article-current-summary 'norecord))
5318 ((setq win (get-buffer-window gnus-article-current-summary))
5319 (select-window win))
5321 (switch-to-buffer gnus-article-current-summary 'norecord)))
5322 (setq in-buffer (current-buffer))
5323 ;; We disable the pick minor mode commands.
5324 (if (and (setq func (let (gnus-pick-mode)
5325 (lookup-key (current-local-map) keys)))
5328 (call-interactively func)
5329 (when (eq win (selected-window))
5330 (setq new-sum-point (point)
5331 new-sum-start (window-start win)
5332 new-sum-hscroll (window-hscroll win)))
5333 (when (eq in-buffer (current-buffer))
5334 (setq selected (gnus-summary-select-article))
5336 (unless not-restore-window
5337 (set-window-configuration owin))
5338 (when (eq selected 'old)
5340 (set-window-start (get-buffer-window (current-buffer))
5342 (set-window-point (get-buffer-window (current-buffer))
5344 (when (and (not not-restore-window)
5346 (set-window-point win new-sum-point)
5347 (set-window-start win new-sum-start)
5348 (set-window-hscroll win new-sum-hscroll))))
5349 (set-window-configuration owin)
5352 (defun gnus-article-describe-key (key)
5353 "Display documentation of the function invoked by KEY. KEY is a string."
5354 (interactive "kDescribe key: ")
5355 (gnus-article-check-buffer)
5356 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5358 (set-buffer gnus-article-current-summary)
5359 (let (gnus-pick-mode)
5360 (if (featurep 'xemacs)
5362 (push (elt key 0) unread-command-events)
5363 (setq key (events-to-keys
5364 (read-key-sequence "Describe key: "))))
5365 (setq unread-command-events
5367 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5368 (string-to-list key)))
5369 (setq key (read-key-sequence "Describe key: "))))
5371 (describe-key key)))
5373 (defun gnus-article-describe-key-briefly (key &optional insert)
5374 "Display documentation of the function invoked by KEY. KEY is a string."
5375 (interactive "kDescribe key: \nP")
5376 (gnus-article-check-buffer)
5377 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5379 (set-buffer gnus-article-current-summary)
5380 (let (gnus-pick-mode)
5381 (if (featurep 'xemacs)
5383 (push (elt key 0) unread-command-events)
5384 (setq key (events-to-keys
5385 (read-key-sequence "Describe key: "))))
5386 (setq unread-command-events
5388 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5389 (string-to-list key)))
5390 (setq key (read-key-sequence "Describe key: "))))
5391 (describe-key-briefly key insert))
5392 (describe-key-briefly key insert)))
5394 (defun gnus-article-reply-with-original (&optional wide)
5395 "Start composing a reply mail to the current message.
5396 The text in the region will be yanked. If the region isn't active,
5397 the entire article will be yanked."
5399 (let ((article (cdr gnus-article-current))
5401 (if (not (gnus-mark-active-p))
5402 (with-current-buffer gnus-summary-buffer
5403 (gnus-summary-reply (list (list article)) wide))
5404 (setq contents (buffer-substring (point) (mark t)))
5405 ;; Deactivate active regions.
5406 (when (and (boundp 'transient-mark-mode)
5407 transient-mark-mode)
5408 (setq mark-active nil))
5409 (with-current-buffer gnus-summary-buffer
5411 (list (list article contents)) wide)))))
5413 (defun gnus-article-followup-with-original ()
5414 "Compose a followup to the current article.
5415 The text in the region will be yanked. If the region isn't active,
5416 the entire article will be yanked."
5418 (let ((article (cdr gnus-article-current))
5420 (if (not (gnus-mark-active-p))
5421 (with-current-buffer gnus-summary-buffer
5422 (gnus-summary-followup (list (list article))))
5423 (setq contents (buffer-substring (point) (mark t)))
5424 ;; Deactivate active regions.
5425 (when (and (boundp 'transient-mark-mode)
5426 transient-mark-mode)
5427 (setq mark-active nil))
5428 (with-current-buffer gnus-summary-buffer
5429 (gnus-summary-followup
5430 (list (list article contents)))))))
5432 (defun gnus-article-hide (&optional arg force)
5433 "Hide all the gruft in the current article.
5434 This means that signatures, cited text and (some) headers will be
5436 If given a prefix, show the hidden text instead."
5437 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5438 (gnus-article-hide-headers arg)
5439 (gnus-article-hide-list-identifiers arg)
5440 (gnus-article-hide-citation-maybe arg force)
5441 (gnus-article-hide-signature arg))
5443 (defun gnus-article-maybe-highlight ()
5444 "Do some article highlighting if article highlighting is requested."
5445 (when (gnus-visual-p 'article-highlight 'highlight)
5446 (gnus-article-highlight-some)))
5448 (defun gnus-check-group-server ()
5449 ;; Make sure the connection to the server is alive.
5450 (unless (gnus-server-opened
5451 (gnus-find-method-for-group gnus-newsgroup-name))
5452 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5453 (gnus-request-group gnus-newsgroup-name t)))
5456 (autoload 'nneething-get-file-name "nneething"))
5458 (defun gnus-request-article-this-buffer (article group)
5459 "Get an article and insert it into this buffer."
5460 (let (do-update-line sparse-header)
5464 (gnus-kill-all-overlays)
5465 (setq group (or group gnus-newsgroup-name))
5467 ;; Using `gnus-request-article' directly will insert the article into
5468 ;; `nntp-server-buffer' - so we'll save some time by not having to
5469 ;; copy it from the server buffer into the article buffer.
5471 ;; We only request an article by message-id when we do not have the
5472 ;; headers for it, so we'll have to get those.
5473 (when (stringp article)
5474 (gnus-read-header article))
5476 ;; If the article number is negative, that means that this article
5477 ;; doesn't belong in this newsgroup (possibly), so we find its
5478 ;; message-id and request it by id instead of number.
5479 (when (and (numberp article)
5481 (get-buffer gnus-summary-buffer)
5482 (gnus-buffer-exists-p gnus-summary-buffer))
5484 (set-buffer gnus-summary-buffer)
5485 (let ((header (gnus-summary-article-header article)))
5488 ((memq article gnus-newsgroup-sparse)
5489 ;; This is a sparse gap article.
5490 (setq do-update-line article)
5491 (setq article (mail-header-id header))
5492 (setq sparse-header (gnus-read-header article))
5493 (setq gnus-newsgroup-sparse
5494 (delq article gnus-newsgroup-sparse)))
5496 ;; It's a real article.
5497 (setq article (mail-header-id header)))
5499 ;; It is an extracted pseudo-article.
5500 (setq article 'pseudo)
5501 (gnus-request-pseudo-article header))))
5503 (let ((method (gnus-find-method-for-group
5504 gnus-newsgroup-name)))
5505 (when (and (eq (car method) 'nneething)
5507 (let ((dir (nneething-get-file-name
5508 (mail-header-id header))))
5509 (when (and (stringp dir)
5510 (file-directory-p dir))
5511 (setq article 'nneething)
5512 (gnus-group-enter-directory dir))))))))
5515 ;; Refuse to select canceled articles.
5516 ((and (numberp article)
5518 (get-buffer gnus-summary-buffer)
5519 (gnus-buffer-exists-p gnus-summary-buffer)
5520 (eq (cdr (save-excursion
5521 (set-buffer gnus-summary-buffer)
5522 (assq article gnus-newsgroup-reads)))
5523 gnus-canceled-mark))
5525 ;; We first check `gnus-original-article-buffer'.
5526 ((and (get-buffer gnus-original-article-buffer)
5529 (set-buffer gnus-original-article-buffer)
5530 (and (equal (car gnus-original-article) group)
5531 (eq (cdr gnus-original-article) article))))
5532 (insert-buffer-substring gnus-original-article-buffer)
5534 ;; Check the backlog.
5535 ((and gnus-keep-backlog
5536 (gnus-backlog-request-article group article (current-buffer)))
5538 ;; Check asynchronous pre-fetch.
5539 ((gnus-async-request-fetched-article group article (current-buffer))
5540 (gnus-async-prefetch-next group article gnus-summary-buffer)
5541 (when (and (numberp article) gnus-keep-backlog)
5542 (gnus-backlog-enter-article group article (current-buffer)))
5545 ((and gnus-use-cache
5547 (gnus-cache-request-article article group))
5549 ;; Check the agent cache.
5550 ((gnus-agent-request-article article group)
5552 ;; Get the article and put into the article buffer.
5553 ((or (stringp article)
5555 (let ((gnus-override-method gnus-override-method)
5556 (methods (and (stringp article)
5557 gnus-refer-article-method))
5558 (backend (car (gnus-find-method-for-group
5559 gnus-newsgroup-name)))
5561 (inhibit-read-only t))
5562 (if (or (not (listp methods))
5563 (and (symbolp (car methods))
5564 (assq (car methods) nnoo-definition-alist)))
5565 (setq methods (list methods)))
5566 (when (and (null gnus-override-method)
5568 (setq gnus-override-method (pop methods)))
5570 (when (eq gnus-override-method 'current)
5571 (setq gnus-override-method
5572 (with-current-buffer gnus-summary-buffer
5573 gnus-current-select-method)))
5575 (gnus-kill-all-overlays)
5576 (let ((gnus-newsgroup-name group))
5577 (gnus-check-group-server))
5579 ((gnus-request-article article group (current-buffer))
5580 (when (numberp article)
5581 (gnus-async-prefetch-next group article
5582 gnus-summary-buffer)
5583 (when gnus-keep-backlog
5584 (gnus-backlog-enter-article
5585 group article (current-buffer))))
5586 (setq result 'article))
5588 (setq gnus-override-method (pop methods)))
5589 ((not (string-match "^400 "
5590 (nnheader-get-report backend)))
5591 ;; If we get 400 server disconnect, reconnect and
5592 ;; retry; otherwise, assume the article has expired.
5593 (setq result 'done))))
5594 (and (eq result 'article) 'article)))
5598 ;; Associate this article with the current summary buffer.
5599 (setq gnus-article-current-summary gnus-summary-buffer)
5601 ;; Take the article from the original article buffer
5602 ;; and place it in the buffer it's supposed to be in.
5603 (when (and (get-buffer gnus-article-buffer)
5604 (equal (buffer-name (current-buffer))
5605 (buffer-name (get-buffer gnus-article-buffer))))
5607 (if (get-buffer gnus-original-article-buffer)
5608 (set-buffer gnus-original-article-buffer)
5609 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5610 (buffer-disable-undo)
5611 (setq major-mode 'gnus-original-article-mode)
5612 (setq buffer-read-only t))
5613 (let ((inhibit-read-only t))
5615 (insert-buffer-substring gnus-article-buffer))
5616 (setq gnus-original-article (cons group article)))
5619 (run-hooks 'gnus-article-decode-hook)
5620 ;; Mark article as decoded or not.
5621 (setq gnus-article-decoded-p gnus-article-decode-hook))
5623 ;; Update sparse articles.
5624 (when (and do-update-line
5625 (or (numberp article)
5627 (let ((buf (current-buffer)))
5628 (set-buffer gnus-summary-buffer)
5629 (gnus-summary-update-article do-update-line sparse-header)
5630 (gnus-summary-goto-subject do-update-line nil t)
5631 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5633 (set-buffer buf))))))
5639 (defcustom gnus-article-edit-mode-hook nil
5640 "Hook run in article edit mode buffers."
5641 :group 'gnus-article-various
5644 (defvar gnus-article-edit-done-function nil)
5646 (defvar gnus-article-edit-mode-map nil)
5647 (defvar gnus-article-edit-mode nil)
5649 ;; Should we be using derived.el for this?
5650 (unless gnus-article-edit-mode-map
5651 (setq gnus-article-edit-mode-map (make-keymap))
5652 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5654 (gnus-define-keys gnus-article-edit-mode-map
5655 "\C-c?" describe-mode
5656 "\C-c\C-c" gnus-article-edit-done
5657 "\C-c\C-k" gnus-article-edit-exit
5658 "\C-c\C-f\C-t" message-goto-to
5659 "\C-c\C-f\C-o" message-goto-from
5660 "\C-c\C-f\C-b" message-goto-bcc
5661 ;;"\C-c\C-f\C-w" message-goto-fcc
5662 "\C-c\C-f\C-c" message-goto-cc
5663 "\C-c\C-f\C-s" message-goto-subject
5664 "\C-c\C-f\C-r" message-goto-reply-to
5665 "\C-c\C-f\C-n" message-goto-newsgroups
5666 "\C-c\C-f\C-d" message-goto-distribution
5667 "\C-c\C-f\C-f" message-goto-followup-to
5668 "\C-c\C-f\C-m" message-goto-mail-followup-to
5669 "\C-c\C-f\C-k" message-goto-keywords
5670 "\C-c\C-f\C-u" message-goto-summary
5671 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5672 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5673 "\C-c\C-b" message-goto-body
5674 "\C-c\C-i" message-goto-signature
5676 "\C-c\C-t" message-insert-to
5677 "\C-c\C-n" message-insert-newsgroups
5678 "\C-c\C-o" message-sort-headers
5679 "\C-c\C-e" message-elide-region
5680 "\C-c\C-v" message-delete-not-region
5681 "\C-c\C-z" message-kill-to-signature
5682 "\M-\r" message-newline-and-reformat
5683 "\C-c\C-a" mml-attach-file
5684 "\C-a" message-beginning-of-line
5686 "\M-;" comment-region)
5688 (gnus-define-keys (gnus-article-edit-wash-map
5689 "\C-c\C-w" gnus-article-edit-mode-map)
5690 "f" gnus-article-edit-full-stops))
5693 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5695 ["Fetch To" message-insert-to t]
5696 ["Fetch Newsgroups" message-insert-newsgroups t]
5698 ["To" message-goto-to t]
5699 ["From" message-goto-from t]
5700 ["Subject" message-goto-subject t]
5701 ["Cc" message-goto-cc t]
5702 ["Reply-To" message-goto-reply-to t]
5703 ["Summary" message-goto-summary t]
5704 ["Keywords" message-goto-keywords t]
5705 ["Newsgroups" message-goto-newsgroups t]
5706 ["Followup-To" message-goto-followup-to t]
5707 ["Mail-Followup-To" message-goto-mail-followup-to t]
5708 ["Distribution" message-goto-distribution t]
5709 ["Body" message-goto-body t]
5710 ["Signature" message-goto-signature t]))
5712 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5713 "Major mode for editing articles.
5714 This is an extended text-mode.
5716 \\{gnus-article-edit-mode-map}"
5717 (make-local-variable 'gnus-article-edit-done-function)
5718 (make-local-variable 'gnus-prev-winconf)
5719 (set (make-local-variable 'font-lock-defaults)
5720 '(message-font-lock-keywords t))
5721 (set (make-local-variable 'mail-header-separator) "")
5722 (set (make-local-variable 'gnus-article-edit-mode) t)
5723 (easy-menu-add message-mode-field-menu message-mode-map)
5725 (setq buffer-read-only nil)
5726 (buffer-enable-undo)
5729 (defun gnus-article-edit (&optional force)
5730 "Edit the current article.
5731 This will have permanent effect only in mail groups.
5732 If FORCE is non-nil, allow editing of articles even in read-only
5735 (when (and (not force)
5736 (gnus-group-read-only-p))
5737 (error "The current newsgroup does not support article editing"))
5738 (gnus-article-date-original)
5739 (gnus-article-edit-article
5741 `(lambda (no-highlight)
5743 (gnus-summary-edit-article-done
5744 ,(or (mail-header-references gnus-current-headers) "")
5745 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5747 (defun gnus-article-edit-article (start-func exit-func)
5748 "Start editing the contents of the current article buffer."
5749 (let ((winconf (current-window-configuration)))
5750 (set-buffer gnus-article-buffer)
5751 (let ((message-auto-save-directory
5752 ;; Don't associate the article buffer with a draft file.
5754 (gnus-article-edit-mode))
5755 (funcall start-func)
5756 (set-buffer-modified-p nil)
5757 (gnus-configure-windows 'edit-article)
5758 (setq gnus-article-edit-done-function exit-func)
5759 (setq gnus-prev-winconf winconf)
5760 (gnus-message 6 "C-c C-c to end edits")))
5762 (defun gnus-article-edit-done (&optional arg)
5763 "Update the article edits and exit."
5765 (let ((func gnus-article-edit-done-function)
5766 (buf (current-buffer))
5767 (start (window-start))
5769 (winconf gnus-prev-winconf))
5770 (widen) ;; Widen it in case that users narrowed the buffer.
5773 ;; The cache and backlog have to be flushed somewhat.
5774 (when gnus-keep-backlog
5775 (gnus-backlog-remove-article
5776 (car gnus-article-current) (cdr gnus-article-current)))
5777 ;; Flush original article as well.
5779 (when (get-buffer gnus-original-article-buffer)
5780 (set-buffer gnus-original-article-buffer)
5781 (setq gnus-original-article nil)))
5782 (when gnus-use-cache
5783 (gnus-cache-update-article
5784 (car gnus-article-current) (cdr gnus-article-current)))
5785 ;; We remove all text props from the article buffer.
5786 (kill-all-local-variables)
5787 (gnus-set-text-properties (point-min) (point-max) nil)
5789 (set-window-configuration winconf)
5791 (set-window-start (get-buffer-window buf) start)
5792 (set-window-point (get-buffer-window buf) (point)))
5793 (gnus-summary-show-article))
5795 (defun gnus-article-edit-exit ()
5796 "Exit the article editing without updating."
5798 (when (or (not (buffer-modified-p))
5799 (yes-or-no-p "Article modified; kill anyway? "))
5800 (let ((curbuf (current-buffer))
5802 (window-start (window-start)))
5804 (if (gnus-buffer-live-p gnus-original-article-buffer)
5805 (insert-buffer gnus-original-article-buffer))
5806 (let ((winconf gnus-prev-winconf))
5807 (kill-all-local-variables)
5809 (set-window-configuration winconf)
5810 ;; Tippy-toe some to make sure that point remains where it was.
5811 (save-current-buffer
5813 (set-window-start (get-buffer-window (current-buffer)) window-start)
5815 (gnus-summary-show-article)))
5817 (defun gnus-article-edit-full-stops ()
5818 "Interactively repair spacing at end of sentences."
5821 (goto-char (point-min))
5822 (search-forward-regexp "^$" nil t)
5823 (let ((case-fold-search nil))
5824 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5827 ;;; Article highlights
5830 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5832 ;;; Internal Variables:
5834 (defcustom gnus-button-url-regexp
5835 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5836 "\\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:]]\\)"
5837 "\\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\\)\\)")
5838 "Regular expression that matches URLs."
5839 :group 'gnus-article-buttons
5842 (defcustom gnus-button-valid-fqdn-regexp
5843 message-valid-fqdn-regexp
5844 "Regular expression that matches a valid FQDN."
5846 :group 'gnus-article-buttons
5849 (defcustom gnus-button-man-handler 'manual-entry
5850 "Function to use for displaying man pages.
5851 The function must take at least one argument with a string naming the
5854 :type '(choice (function-item :tag "Man" manual-entry)
5855 (function-item :tag "Woman" woman)
5856 (function :tag "Other"))
5857 :group 'gnus-article-buttons)
5859 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5860 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5861 If the default site is too slow, try to find a CTAN mirror, see
5862 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5863 the variable `gnus-button-handle-ctan'."
5865 :group 'gnus-article-buttons
5866 :link '(custom-manual "(gnus)Group Parameters")
5867 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5868 (const "http://tug.ctan.org/tex-archive/")
5869 (const "http://www.dante.de/CTAN/")
5870 (string :tag "Other")))
5872 (defcustom gnus-button-ctan-handler 'browse-url
5873 "Function to use for displaying CTAN links.
5874 The function must take one argument, the string naming the URL."
5876 :type '(choice (function-item :tag "Browse Url" browse-url)
5877 (function :tag "Other"))
5878 :group 'gnus-article-buttons)
5880 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5881 "Bogus strings removed from CTAN URLs."
5883 :group 'gnus-article-buttons
5884 :type '(choice (const "^/?tex-archive/\\|/")
5885 (regexp :tag "Other")))
5887 (defcustom gnus-button-ctan-directory-regexp
5889 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
5890 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5891 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5892 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5894 "Regular expression for ctan directories.
5895 It should match all directories in the top level of `gnus-ctan-url'."
5897 :group 'gnus-article-buttons
5900 (defcustom gnus-button-mid-or-mail-regexp
5901 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5902 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5903 gnus-button-valid-fqdn-regexp
5905 "Regular expression that matches a message ID or a mail address."
5907 :group 'gnus-article-buttons
5910 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5911 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5912 Strings like this can be either a message ID or a mail address. If it is one
5913 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5914 message ID or a mail address, respectively. If this variable is set to the
5915 symbol `ask', always query the user what do do. If it is a function, this
5916 function will be called with the string as it's only argument. The function
5917 must return `mid', `mail', `invalid' or `ask'."
5919 :group 'gnus-article-buttons
5920 :type '(choice (function-item :tag "Heuristic function"
5921 gnus-button-mid-or-mail-heuristic)
5926 (defcustom gnus-button-mid-or-mail-heuristic-alist
5927 '((-10.0 . ".+\\$.+@")
5930 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5931 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5932 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5933 (-1.0 . "^[^a-z]+@")
5935 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5936 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5937 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5938 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5941 (-1.0 . "^[0-9][0-9]")
5943 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5944 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5945 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5946 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5948 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5949 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5952 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5954 ;; compensation for TDMA dated mail addresses:
5955 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5957 (-20.0 . "\\.fsf@") ;; Gnus
5960 (-20.0 . "_-_") ;; Subject change in thread
5962 (-20.0 . "\\.ln@") ;; leafnode
5963 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5964 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5966 ;; (5.0 . "") ;; $local_part_len <= 7
5967 (10.0 . "^[^0-9]+@")
5968 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5969 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5972 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5974 (0.5 . "^[A-Z][a-z]")
5975 (0.5 . "^[A-Z][a-z][a-z]")
5976 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5977 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5978 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5980 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5981 address. The REGEXP is processed with `case-fold-search' set to nil."
5983 :group 'gnus-article-buttons
5984 :type '(repeat (cons (number :tag "Rate")
5985 (regexp :tag "Regexp"))))
5987 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5988 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5989 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5990 address, `ask' if unsure and `invalid' if the string is invalid."
5991 (let ((case-fold-search nil)
5992 (list gnus-button-mid-or-mail-heuristic-alist)
5993 (result 0) rate regexp lpartlen elem)
5995 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5996 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5997 ;; Certain special cases...
6000 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6001 "^[0-9]+\\.[0-9]+@compuserve\\|"
6002 "@public\\.gmane\\.org")
6004 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6005 (setq result 'mail))
6006 (when (string-match "@.*@\\| " mid-or-mail)
6007 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6008 (setq result 'invalid))
6009 ;; Nothing more to do, if result is not a number here...
6010 (when (numberp result)
6012 (setq elem (car list)
6016 (when (string-match regexp mid-or-mail)
6017 (setq result (+ result rate))
6019 9 "`%s' matched `%s', rate `%s', result `%s'."
6020 mid-or-mail regexp rate result)))
6021 (when (<= lpartlen 7)
6022 (setq result (+ result 5.0))
6023 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6024 mid-or-mail result))
6025 (when (>= lpartlen 12)
6026 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6028 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6029 ;; Long local part should contain realname if e-mail address,
6030 ;; too many digits: message-id.
6031 ;; $score -= 5.0 + 0.1 * $local_part_len;
6032 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6033 (setq result (+ result rate))
6035 9 "Many digits in `%s', rate `%s', result `%s'."
6036 mid-or-mail rate result))
6037 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6039 ;; Too few vowels [^aeiouy]{4,}.*\@
6040 (setq result (+ result -5.0))
6042 9 "Few vowels in `%s', rate `%s', result `%s'."
6043 mid-or-mail -5.0 result))
6045 (setq result (+ result 5.0))
6047 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6048 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6049 ;; Maybe we should make this a customizable alist: (condition . 'result)
6051 ((symbolp result) result)
6052 ;; Now convert number into proper results:
6053 ((< result -10.0) 'mid)
6054 ((> result 10.0) 'mail)
6057 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6058 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6059 (url-mid (concat "news" ":" mid-or-mail))
6060 (url-mailto (concat "mailto" ":" mid-or-mail)))
6061 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6062 (when (fboundp pref)
6064 ;; get rid of surrounding angles...
6066 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6067 (if (or (eq 'mid guessed) (eq 'mail guessed))
6071 (save-window-excursion
6072 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6075 (cond ((eq pref 'mid)
6076 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6077 (gnus-button-handle-news url-mid))
6079 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6080 (gnus-url-mailto url-mailto))
6081 (t (gnus-message 3 "Invalid string.")))))
6083 (defun gnus-button-handle-custom (url)
6084 "Follow a Custom URL."
6085 (customize-apropos (gnus-url-unhex-string url)))
6087 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6089 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6092 (defun gnus-button-handle-describe-function (url)
6093 "Call `describe-function' when pushing the corresponding URL button."
6096 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6098 (defun gnus-button-handle-describe-variable (url)
6099 "Call `describe-variable' when pushing the corresponding URL button."
6102 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6104 (defun gnus-button-handle-symbol (url)
6105 "Display help on variable or function.
6106 Calls `describe-variable' or `describe-function'."
6107 (let ((sym (intern url)))
6109 ((fboundp sym) (describe-function sym))
6110 ((boundp sym) (describe-variable sym))
6111 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6113 (defun gnus-button-handle-describe-key (url)
6114 "Call `describe-key' when pushing the corresponding URL button."
6116 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6117 (keys (ignore-errors (eval `(kbd ,key-string)))))
6120 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6122 (defun gnus-button-handle-apropos (url)
6123 "Call `apropos' when pushing the corresponding URL button."
6124 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6126 (defun gnus-button-handle-apropos-command (url)
6127 "Call `apropos' when pushing the corresponding URL button."
6129 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6131 (defun gnus-button-handle-apropos-variable (url)
6132 "Call `apropos' when pushing the corresponding URL button."
6134 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6135 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6137 (defun gnus-button-handle-apropos-documentation (url)
6138 "Call `apropos' when pushing the corresponding URL button."
6140 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6141 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6143 (defun gnus-button-handle-library (url)
6144 "Call `locate-library' when pushing the corresponding URL button."
6145 (gnus-message 9 "url=`%s'" url)
6146 (let* ((lib (locate-library url))
6147 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6149 (gnus-message 1 "Cannot locale library `%s'." url)
6150 (find-file-read-only file))))
6152 (defun gnus-button-handle-ctan (url)
6153 "Call `browse-url' when pushing a CTAN URL button."
6155 gnus-button-ctan-handler
6158 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6160 (defcustom gnus-button-tex-level 5
6161 "*Integer that says how many TeX-related buttons Gnus will show.
6162 The higher the number, the more buttons will appear and the more false
6163 positives are possible. Note that you can set this variable local to
6164 specific groups. Setting it higher in TeX groups is probably a good idea.
6165 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6166 how to set variables in specific groups."
6168 :group 'gnus-article-buttons
6169 :link '(custom-manual "(gnus)Group Parameters")
6172 (defcustom gnus-button-man-level 5
6173 "*Integer that says how many man-related buttons Gnus will show.
6174 The higher the number, the more buttons will appear and the more false
6175 positives are possible. Note that you can set this variable local to
6176 specific groups. Setting it higher in Unix groups is probably a good idea.
6177 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6178 how to set variables in specific groups."
6180 :group 'gnus-article-buttons
6181 :link '(custom-manual "(gnus)Group Parameters")
6184 (defcustom gnus-button-emacs-level 5
6185 "*Integer that says how many emacs-related buttons Gnus will show.
6186 The higher the number, the more buttons will appear and the more false
6187 positives are possible. Note that you can set this variable local to
6188 specific groups. Setting it higher in Emacs or Gnus related groups is
6189 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6190 `gnus-parameters' on how to set variables in specific groups."
6192 :group 'gnus-article-buttons
6193 :link '(custom-manual "(gnus)Group Parameters")
6196 (defcustom gnus-button-message-level 5
6197 "*Integer that says how many buttons for news or mail messages will appear.
6198 The higher the number, the more buttons will appear and the more false
6199 positives are possible."
6200 ;; mail addresses, MIDs, URLs for news, ...
6202 :group 'gnus-article-buttons
6205 (defcustom gnus-button-browse-level 5
6206 "*Integer that says how many buttons for browsing will appear.
6207 The higher the number, the more buttons will appear and the more false
6208 positives are possible."
6209 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6211 :group 'gnus-article-buttons
6214 (defcustom gnus-button-alist
6215 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6216 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6217 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6218 gnus-button-handle-news 2)
6219 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6220 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6221 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6222 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6223 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6224 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6225 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6226 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6227 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6228 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6229 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6230 ;; RFC 2368 (The mailto URL scheme)
6231 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6232 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6233 ("\\bmailto:\\([^ \n\t]+\\)"
6234 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6236 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6237 gnus-button-ctan-directory-regexp
6238 "[^][>)!;:,'\n\t ]+\\)")
6239 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6240 ((concat "\\btex-archive/\\("
6241 gnus-button-ctan-directory-regexp
6242 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6243 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6246 gnus-button-ctan-directory-regexp
6247 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6248 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6249 ;; This is info (home-grown style) <info://foo/bar+baz>
6250 ("\\binfo://\\([^'\">\n\t ]+\\)"
6251 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6252 ;; Info GNOME style <info:foo#bar_baz>
6253 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6254 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6255 ;; Info KDE style <info:(foo)bar baz>
6256 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6257 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6258 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6259 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6260 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6261 ;; Info links like `C-h i d m CC Mode RET'
6262 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6264 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6265 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6266 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6267 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6268 ;; Emacs help commands
6269 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6270 ;; regexp doesn't match arguments containing ` '.
6271 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6272 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6273 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6274 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6275 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6276 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6277 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6278 ;; The following entries may lead to many false positives so don't enable
6279 ;; them by default (use a high button level).
6280 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6281 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6282 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6283 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6284 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6285 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6286 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6287 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6288 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6289 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6290 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6291 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6292 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6293 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6294 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6295 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6296 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6297 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6298 ;; Unlike the other regexps we really have to require quoting
6299 ;; here to determine where it ends.
6300 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6301 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6302 ("<URL: *\\([^<>]*\\)>"
6303 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6304 ;; RFC 2396 (2.4.3., delims) ...
6305 ("\"URL: *\\([^\"]*\\)\""
6306 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6307 ;; RFC 2396 (2.4.3., delims) ...
6308 ("\"URL: *\\([^\"]*\\)\""
6309 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6311 (gnus-button-url-regexp
6312 0 (>= gnus-button-browse-level 0) browse-url 0)
6314 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6315 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6316 gnus-button-handle-man 1)
6317 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6318 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6319 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6320 gnus-button-handle-man 1)
6321 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6322 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6323 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6324 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6325 ;; MID or mail: To avoid too many false positives we don't try to catch
6326 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6327 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6328 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6329 ;; so that non-ambiguous entries (see above) match first.
6330 (gnus-button-mid-or-mail-regexp
6331 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6332 "*Alist of regexps matching buttons in article bodies.
6334 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6335 REGEXP: is the string (case insensitive) matching text around the button (can
6336 also be Lisp expression evaluating to a string),
6337 BUTTON: is the number of the regexp grouping actually matching the button,
6338 FORM: is a Lisp expression which must eval to true for the button to
6340 CALLBACK: is the function to call when the user push this button, and each
6341 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6343 CALLBACK can also be a variable, in that case the value of that
6344 variable it the real callback function."
6345 :group 'gnus-article-buttons
6346 :type '(repeat (list (choice regexp variable sexp)
6347 (integer :tag "Button")
6349 (function :tag "Callback")
6352 (integer :tag "Regexp group")))))
6354 (defcustom gnus-header-button-alist
6355 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6356 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6357 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6358 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6359 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6360 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6361 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6362 0 (>= gnus-button-browse-level 0) browse-url 0)
6363 ("^Subject:" gnus-button-url-regexp
6364 0 (>= gnus-button-browse-level 0) browse-url 0)
6365 ("^[^:]+:" gnus-button-url-regexp
6366 0 (>= gnus-button-browse-level 0) browse-url 0)
6367 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6368 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6369 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6370 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6371 "*Alist of headers and regexps to match buttons in article heads.
6373 This alist is very similar to `gnus-button-alist', except that each
6374 alist has an additional HEADER element first in each entry:
6376 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6378 HEADER is a regexp to match a header. For a fuller explanation, see
6379 `gnus-button-alist'."
6380 :group 'gnus-article-buttons
6381 :group 'gnus-article-headers
6382 :type '(repeat (list (regexp :tag "Header")
6383 (choice regexp variable)
6384 (integer :tag "Button")
6386 (function :tag "Callback")
6389 (integer :tag "Regexp group")))))
6391 (defvar gnus-button-regexp nil)
6392 (defvar gnus-button-marker-list nil)
6393 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6395 (defvar gnus-button-last nil)
6396 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6400 (defun gnus-article-push-button (event)
6401 "Check text under the mouse pointer for a callback function.
6402 If the text under the mouse pointer has a `gnus-callback' property,
6403 call it with the value of the `gnus-data' text property."
6405 (set-buffer (window-buffer (posn-window (event-start event))))
6406 (let* ((pos (posn-point (event-start event)))
6407 (data (get-text-property pos 'gnus-data))
6408 (fun (get-text-property pos 'gnus-callback)))
6411 (funcall fun data))))
6413 (defun gnus-article-press-button ()
6414 "Check text at point for a callback function.
6415 If the text at point has a `gnus-callback' property,
6416 call it with the value of the `gnus-data' text property."
6418 (let ((data (get-text-property (point) 'gnus-data))
6419 (fun (get-text-property (point) 'gnus-callback)))
6421 (funcall fun data))))
6423 (defun gnus-article-highlight (&optional force)
6424 "Highlight current article.
6425 This function calls `gnus-article-highlight-headers',
6426 `gnus-article-highlight-citation',
6427 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6428 do the highlighting. See the documentation for those functions."
6429 (interactive (list 'force))
6430 (gnus-article-highlight-headers)
6431 (gnus-article-highlight-citation force)
6432 (gnus-article-highlight-signature)
6433 (gnus-article-add-buttons force)
6434 (gnus-article-add-buttons-to-head))
6436 (defun gnus-article-highlight-some (&optional force)
6437 "Highlight current article.
6438 This function calls `gnus-article-highlight-headers',
6439 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6440 do the highlighting. See the documentation for those functions."
6441 (interactive (list 'force))
6442 (gnus-article-highlight-headers)
6443 (gnus-article-highlight-signature)
6444 (gnus-article-add-buttons))
6446 (defun gnus-article-highlight-headers ()
6447 "Highlight article headers as specified by `gnus-header-face-alist'."
6450 (set-buffer gnus-article-buffer)
6452 (let ((alist gnus-header-face-alist)
6453 (inhibit-read-only t)
6454 (case-fold-search t)
6455 (inhibit-point-motion-hooks t)
6456 entry regexp header-face field-face from hpoints fpoints)
6457 (article-narrow-to-head)
6458 (while (setq entry (pop alist))
6459 (goto-char (point-min))
6460 (setq regexp (concat "^\\("
6461 (if (string-equal "" (nth 0 entry))
6465 header-face (nth 1 entry)
6466 field-face (nth 2 entry))
6467 (while (and (re-search-forward regexp nil t)
6471 (unless (search-forward ":" nil t)
6473 (when (and header-face
6474 (not (memq (point) hpoints)))
6475 (push (point) hpoints)
6476 (gnus-put-text-property from (point) 'face header-face))
6477 (when (and field-face
6478 (not (memq (setq from (point)) fpoints)))
6480 (if (re-search-forward "^[^ \t]" nil t)
6482 (goto-char (point-max)))
6483 (gnus-put-text-property from (point) 'face field-face))))))))
6485 (defun gnus-article-highlight-signature ()
6486 "Highlight the signature in an article.
6487 It does this by highlighting everything after
6488 `gnus-signature-separator' using `gnus-signature-face'."
6491 (set-buffer gnus-article-buffer)
6492 (let ((inhibit-read-only t)
6493 (inhibit-point-motion-hooks t))
6495 (when (and gnus-signature-face
6496 (gnus-article-narrow-to-signature))
6497 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6498 'face gnus-signature-face)
6500 (gnus-article-search-signature)
6501 (let ((start (match-beginning 0))
6502 (end (set-marker (make-marker) (1+ (match-end 0)))))
6503 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6506 (defun gnus-button-in-region-p (b e prop)
6507 "Say whether PROP exists in the region."
6508 (text-property-not-all b e prop nil))
6510 (defun gnus-article-add-buttons (&optional force)
6511 "Find external references in the article and make buttons of them.
6512 \"External references\" are things like Message-IDs and URLs, as
6513 specified by `gnus-button-alist'."
6514 (interactive (list 'force))
6516 (set-buffer gnus-article-buffer)
6517 (let ((inhibit-read-only t)
6518 (inhibit-point-motion-hooks t)
6519 (case-fold-search t)
6520 (alist gnus-button-alist)
6522 ;; Remove all old markers.
6523 (let (marker entry new-list)
6524 (while (setq marker (pop gnus-button-marker-list))
6525 (if (or (< marker (point-min)) (>= marker (point-max)))
6526 (push marker new-list)
6528 (when (setq entry (gnus-button-entry))
6529 (put-text-property (match-beginning (nth 1 entry))
6530 (match-end (nth 1 entry))
6531 'gnus-callback nil))
6532 (set-marker marker nil)))
6533 (setq gnus-button-marker-list new-list))
6534 ;; We skip the headers.
6537 (while (setq entry (pop alist))
6538 (setq regexp (eval (car entry)))
6540 (while (re-search-forward regexp nil t)
6541 (let* ((start (and entry (match-beginning (nth 1 entry))))
6542 (end (and entry (match-end (nth 1 entry))))
6543 (from (match-beginning 0)))
6544 (when (and (or (eq t (nth 2 entry))
6545 (eval (nth 2 entry)))
6546 (not (gnus-button-in-region-p
6547 start end 'gnus-callback)))
6548 ;; That optional form returned non-nil, so we add the
6550 (gnus-article-add-button
6551 start end 'gnus-button-push
6552 (car (push (set-marker (make-marker) from)
6553 gnus-button-marker-list))))))))))
6555 ;; Add buttons to the head of an article.
6556 (defun gnus-article-add-buttons-to-head ()
6557 "Add buttons to the head of the article."
6560 (set-buffer gnus-article-buffer)
6562 (let ((inhibit-read-only t)
6563 (inhibit-point-motion-hooks t)
6564 (case-fold-search t)
6565 (alist gnus-header-button-alist)
6567 (article-narrow-to-head)
6569 ;; Each alist entry.
6570 (setq entry (car alist)
6572 (goto-char (point-min))
6573 (while (re-search-forward (car entry) nil t)
6574 ;; Each header matching the entry.
6575 (setq beg (match-beginning 0))
6576 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6577 (match-beginning 0))
6580 (while (re-search-forward (eval (nth 1 entry)) end t)
6581 ;; Each match within a header.
6582 (let* ((entry (cdr entry))
6583 (start (match-beginning (nth 1 entry)))
6584 (end (match-end (nth 1 entry)))
6585 (form (nth 2 entry)))
6586 (goto-char (match-end 0))
6588 (gnus-article-add-button
6589 start end (nth 3 entry)
6590 (buffer-substring (match-beginning (nth 4 entry))
6591 (match-end (nth 4 entry)))))))
6592 (goto-char end)))))))
6594 ;;; External functions:
6596 (defun gnus-article-add-button (from to fun &optional data)
6597 "Create a button between FROM and TO with callback FUN and data DATA."
6598 (when gnus-article-button-face
6599 (gnus-overlay-put (gnus-make-overlay from to)
6600 'face gnus-article-button-face))
6601 (gnus-add-text-properties
6603 (nconc (and gnus-article-mouse-face
6604 (list gnus-mouse-face-prop gnus-article-mouse-face))
6605 (list 'gnus-callback fun)
6606 (and data (list 'gnus-data data))))
6607 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6608 :button-keymap gnus-widget-button-keymap))
6610 ;;; Internal functions:
6612 (defun gnus-article-set-globals ()
6614 (set-buffer gnus-summary-buffer)
6615 (gnus-set-global-variables)))
6617 (defun gnus-signature-toggle (end)
6619 (set-buffer gnus-article-buffer)
6620 (let ((inhibit-read-only t)
6621 (inhibit-point-motion-hooks t))
6622 (if (text-property-any end (point-max) 'article-type 'signature)
6624 (gnus-delete-wash-type 'signature)
6625 (gnus-remove-text-properties-when
6626 'article-type 'signature end (point-max)
6627 (cons 'article-type (cons 'signature
6628 gnus-hidden-properties))))
6629 (gnus-add-wash-type 'signature)
6630 (gnus-add-text-properties-when
6631 'article-type nil end (point-max)
6632 (cons 'article-type (cons 'signature
6633 gnus-hidden-properties)))))
6634 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6635 (gnus-set-mode-line 'article))))
6637 (defun gnus-button-entry ()
6638 ;; Return the first entry in `gnus-button-alist' matching this place.
6639 (let ((alist gnus-button-alist)
6642 (setq entry (pop alist))
6643 (if (looking-at (eval (car entry)))
6648 (defun gnus-button-push (marker)
6649 ;; Push button starting at MARKER.
6652 (let* ((entry (gnus-button-entry))
6653 (inhibit-point-motion-hooks t)
6655 (args (mapcar (lambda (group)
6656 (let ((string (match-string group)))
6657 (gnus-set-text-properties
6658 0 (length string) nil string)
6665 (fboundp (symbol-value fun)))
6666 (apply (symbol-value fun) args))
6668 (gnus-message 1 "You must define `%S' to use this button"
6669 (cons fun args)))))))
6671 (defun gnus-parse-news-url (url)
6672 (let (scheme server port group message-id articles)
6675 (goto-char (point-min))
6676 (when (looking-at "\\([A-Za-z]+\\):")
6677 (setq scheme (match-string 1))
6678 (goto-char (match-end 0)))
6679 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6680 (setq server (match-string 1))
6681 (setq port (if (stringp (match-string 3))
6682 (string-to-number (match-string 3))
6684 (goto-char (match-end 0)))
6687 ((looking-at "\\(.*@.*\\)")
6688 (setq message-id (match-string 1)))
6689 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6690 (setq group (match-string 1)
6691 articles (split-string (match-string 2) "-")))
6692 ((looking-at "\\([^/]+\\)/?")
6693 (setq group (match-string 1)))
6695 (error "Unknown news URL syntax"))))
6696 (list scheme server port group message-id articles)))
6698 (defun gnus-button-handle-news (url)
6700 (destructuring-bind (scheme server port group message-id articles)
6701 (gnus-parse-news-url url)
6705 (set-buffer gnus-summary-buffer)
6707 (let ((gnus-refer-article-method
6708 (nconc (list (list 'nntp server))
6709 gnus-refer-article-method))
6710 (nntp-port-number (or port "nntp")))
6711 (gnus-message 7 "Fetching %s with %s"
6712 message-id gnus-refer-article-method)
6713 (gnus-summary-refer-article message-id))
6714 (gnus-summary-refer-article message-id))))
6716 (gnus-button-fetch-group url)))))
6718 (defun gnus-button-handle-man (url)
6720 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6721 (when (eq gnus-button-man-handler 'woman)
6722 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6723 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6724 (funcall gnus-button-man-handler url))
6726 (defun gnus-button-handle-info-url (url)
6727 "Fetch an info URL."
6728 (setq url (mm-subst-char-in-string ?+ ?\ url))
6730 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6731 (gnus-info-find-node
6732 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6734 ")" (gnus-url-unhex-string (match-string 2 url)))))
6735 ((string-match "([^)\"]+)[^\"]+" url)
6737 (gnus-replace-in-string
6738 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6739 (gnus-info-find-node url))
6740 (t (error "Can't parse %s" url))))
6742 (defun gnus-button-handle-info-url-gnome (url)
6743 "Fetch GNOME style info URL."
6744 (setq url (mm-subst-char-in-string ?_ ?\ url))
6745 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6746 (gnus-info-find-node
6748 (gnus-url-unhex-string
6749 (match-string 1 url))
6751 (or (gnus-url-unhex-string
6752 (match-string 2 url))
6754 (error "Can't parse %s" url)))
6756 (defun gnus-button-handle-info-url-kde (url)
6757 "Fetch KDE style info URL."
6758 (gnus-info-find-node (gnus-url-unhex-string url)))
6760 (defun gnus-button-handle-info-keystrokes (url)
6761 "Call `info' when pushing the corresponding URL button."
6762 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6767 (defun gnus-button-message-id (message-id)
6770 (set-buffer gnus-summary-buffer)
6771 (gnus-summary-refer-article message-id)))
6773 (defun gnus-button-fetch-group (address)
6774 "Fetch GROUP specified by ADDRESS."
6775 (if (not (string-match "[:/]" address))
6776 ;; This is just a simple group url.
6777 (gnus-group-read-ephemeral-group address gnus-select-method)
6780 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6782 (error "Can't parse %s" address)
6783 (gnus-group-read-ephemeral-group
6784 (match-string 4 address)
6785 `(nntp ,(match-string 1 address)
6786 (nntp-address ,(match-string 1 address))
6787 (nntp-port-number ,(if (match-end 3)
6788 (match-string 3 address)
6791 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6793 (defun gnus-url-parse-query-string (query &optional downcase)
6794 (let (retval pairs cur key val)
6795 (setq pairs (split-string query "&"))
6797 (setq cur (car pairs)
6799 (if (not (string-match "=" cur))
6801 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6802 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6804 (setq key (downcase key)))
6805 (setq cur (assoc key retval))
6807 (setcdr cur (cons val (cdr cur)))
6808 (setq retval (cons (list key val) retval)))))
6811 (defun gnus-url-mailto (url)
6812 ;; Send mail to someone
6813 (when (string-match "mailto:/*\\(.*\\)" url)
6814 (setq url (substring url (match-beginning 1) nil)))
6815 (let (to args subject func)
6816 (setq args (gnus-url-parse-query-string
6817 (if (string-match "^\\?" url)
6819 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6820 (concat "to=" (match-string 1 url) "&"
6821 (match-string 2 url))
6822 (concat "to=" url)))
6824 subject (cdr-safe (assoc "subject" args)))
6827 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6830 (message-position-on-field (caar args)))
6831 (insert (gnus-replace-in-string
6832 (mapconcat 'identity (reverse (cdar args)) ", ")
6834 (setq args (cdr args)))
6837 (message-goto-subject))))
6839 (defun gnus-button-embedded-url (address)
6840 "Activate ADDRESS with `browse-url'."
6841 (browse-url (gnus-strip-whitespace address)))
6843 ;;; Next/prev buttons in the article buffer.
6845 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6846 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6848 (defvar gnus-prev-page-map
6849 (let ((map (make-sparse-keymap)))
6850 (unless (>= emacs-major-version 21)
6851 ;; XEmacs doesn't care.
6852 (set-keymap-parent map gnus-article-mode-map))
6853 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6854 (define-key map "\r" 'gnus-button-prev-page)
6857 (defvar gnus-next-page-map
6858 (let ((map (make-sparse-keymap)))
6859 (unless (>= emacs-major-version 21)
6860 ;; XEmacs doesn't care.
6861 (set-keymap-parent map gnus-article-mode-map))
6862 (define-key map gnus-mouse-2 'gnus-button-next-page)
6863 (define-key map "\r" 'gnus-button-next-page)
6866 (defun gnus-insert-prev-page-button ()
6868 (inhibit-read-only t))
6870 gnus-prev-page-line-format nil
6871 `(,@(gnus-local-map-property gnus-prev-page-map)
6873 gnus-callback gnus-article-button-prev-page
6874 article-type annotation))
6875 (widget-convert-button
6877 ;; Exclude a newline.
6880 :action 'gnus-button-prev-page
6881 :button-keymap gnus-prev-page-map)))
6883 (defun gnus-button-next-page (&optional args more-args)
6884 "Go to the next page."
6886 (let ((win (selected-window)))
6887 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6888 (gnus-article-next-page)
6889 (select-window win)))
6891 (defun gnus-button-prev-page (&optional args more-args)
6892 "Go to the prev page."
6894 (let ((win (selected-window)))
6895 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6896 (gnus-article-prev-page)
6897 (select-window win)))
6899 (defun gnus-insert-next-page-button ()
6901 (inhibit-read-only t))
6902 (gnus-eval-format gnus-next-page-line-format nil
6903 `(,@(gnus-local-map-property gnus-next-page-map)
6905 gnus-callback gnus-article-button-next-page
6906 article-type annotation))
6907 (widget-convert-button
6909 ;; Exclude a newline.
6912 :action 'gnus-button-next-page
6913 :button-keymap gnus-next-page-map)))
6915 (defun gnus-article-button-next-page (arg)
6916 "Go to the next page."
6918 (let ((win (selected-window)))
6919 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6920 (gnus-article-next-page)
6921 (select-window win)))
6923 (defun gnus-article-button-prev-page (arg)
6924 "Go to the prev page."
6926 (let ((win (selected-window)))
6927 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6928 (gnus-article-prev-page)
6929 (select-window win)))
6931 (defvar gnus-decode-header-methods
6932 '(mail-decode-encoded-word-region)
6933 "List of methods used to decode headers.
6935 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6936 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6937 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6938 whose names match REGEXP.
6941 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6942 mail-decode-encoded-word-region
6943 (\"chinese\" . rfc1843-decode-region))
6946 (defvar gnus-decode-header-methods-cache nil)
6948 (defun gnus-multi-decode-header (start end)
6949 "Apply the functions from `gnus-encoded-word-methods' that match."
6950 (unless (and gnus-decode-header-methods-cache
6951 (eq gnus-newsgroup-name
6952 (car gnus-decode-header-methods-cache)))
6953 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6956 (nconc gnus-decode-header-methods-cache (list x))
6957 (if (and gnus-newsgroup-name
6958 (string-match (car x) gnus-newsgroup-name))
6959 (nconc gnus-decode-header-methods-cache
6961 gnus-decode-header-methods))
6962 (let ((xlist gnus-decode-header-methods-cache))
6965 (narrow-to-region start end)
6967 (funcall (pop xlist) (point-min) (point-max))))))
6970 ;;; Treatment top-level handling.
6973 (defun gnus-treat-article (condition &optional part-number total-parts type)
6974 (let ((length (- (point-max) (point-min)))
6975 (alist gnus-treatment-function-alist)
6976 (article-goto-body-goes-to-point-min-p t)
6980 (let ((list gnus-article-treat-types))
6982 (when (string-match (pop list) type)
6983 (throw 'found t)))))))
6984 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6986 (gnus-run-hooks 'gnus-part-display-hook)
6987 (dolist (elem alist)
6990 (when (gnus-buffer-live-p gnus-summary-buffer)
6991 (set-buffer gnus-summary-buffer))
6992 (symbol-value (car elem))))
6993 (when (and (or (consp val)
6995 (gnus-treat-predicate val)
6996 (or (not (get (car elem) 'highlight))
6999 (funcall (cadr elem)))))))
7001 ;; Dynamic variables.
7003 (defvar part-number)
7004 (defvar total-parts)
7009 (defun gnus-treat-predicate (val)
7016 (stringp (car val)))
7017 (apply 'gnus-or (mapcar `(lambda (s)
7018 (string-match s ,(or gnus-newsgroup-name "")))
7021 (let ((pred (pop val)))
7024 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7026 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7028 (not (gnus-treat-predicate (car val))))
7030 (equal (car val) type))
7032 (error "%S is not a valid predicate" pred)))))
7038 (eq part-number total-parts))
7042 (error "%S is not a valid value" val))))
7044 (defun gnus-article-encrypt-body (protocol &optional n)
7045 "Encrypt the article body."
7048 (or gnus-article-encrypt-protocol
7049 (completing-read "Encrypt protocol: "
7050 gnus-article-encrypt-protocol-alist
7052 current-prefix-arg))
7053 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7055 (error (format "Can't find the encrypt protocol %s" protocol)))
7056 (if (member gnus-newsgroup-name '("nndraft:delayed"
7059 (error "Can't encrypt the article in group %s"
7060 gnus-newsgroup-name))
7061 (gnus-summary-iterate n
7063 (set-buffer gnus-summary-buffer)
7064 (let ((mail-parse-charset gnus-newsgroup-charset)
7065 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7066 (summary-buffer gnus-summary-buffer)
7068 (gnus-set-global-variables)
7069 (when (gnus-group-read-only-p)
7070 (error "The current newsgroup does not support article encrypt"))
7071 (gnus-summary-show-article t)
7073 (or (mail-header-references gnus-current-headers) ""))
7074 (set-buffer gnus-article-buffer)
7075 (let* ((inhibit-read-only t)
7077 (mapcar (lambda (field)
7078 (and (save-restriction
7079 (message-narrow-to-head)
7080 (goto-char (point-min))
7081 (search-forward field nil t))
7083 (message-narrow-to-field)
7085 (delete-region (point-min) (point-max))
7087 '("Content-Type:" "Content-Transfer-Encoding:"
7088 "Content-Disposition:"))))
7089 (message-narrow-to-head)
7090 (message-remove-header "MIME-Version")
7091 (goto-char (point-max))
7092 (setq point (point))
7093 (insert (apply 'concat headers))
7095 (narrow-to-region point (point-max))
7096 (let ((message-options message-options))
7097 (message-options-set 'message-sender user-mail-address)
7098 (message-options-set 'message-recipients user-mail-address)
7099 (message-options-set 'message-sign-encrypt 'not)
7101 (goto-char (point-min))
7102 (insert "MIME-Version: 1.0\n")
7104 (gnus-summary-edit-article-done
7105 references nil summary-buffer t))
7106 (when gnus-keep-backlog
7107 (gnus-backlog-remove-article
7108 (car gnus-article-current) (cdr gnus-article-current)))
7110 (when (get-buffer gnus-original-article-buffer)
7111 (set-buffer gnus-original-article-buffer)
7112 (setq gnus-original-article nil)))
7113 (when gnus-use-cache
7114 (gnus-cache-update-article
7115 (car gnus-article-current) (cdr gnus-article-current))))))))
7117 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7118 "The following specs can be used:
7119 %t The security MIME type
7122 %D Details if button is pressed")
7124 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7125 "The following specs can be used:
7126 %t The security MIME type
7129 %D Details if button is pressed")
7131 (defvar gnus-mime-security-button-line-format-alist
7132 '((?t gnus-tmp-type ?s)
7133 (?i gnus-tmp-info ?s)
7134 (?d gnus-tmp-details ?s)
7135 (?D gnus-tmp-pressed-details ?s)))
7137 (defvar gnus-mime-security-button-map
7138 (let ((map (make-sparse-keymap)))
7139 (unless (>= (string-to-number emacs-version) 21)
7140 (set-keymap-parent map gnus-article-mode-map))
7141 (define-key map gnus-mouse-2 'gnus-article-push-button)
7142 (define-key map "\r" 'gnus-article-press-button)
7145 (defvar gnus-mime-security-details-buffer nil)
7147 (defvar gnus-mime-security-button-pressed nil)
7149 (defvar gnus-mime-security-show-details-inline t
7150 "If non-nil, show details in the article buffer.")
7152 (defun gnus-mime-security-verify-or-decrypt (handle)
7153 (mm-remove-parts (cdr handle))
7154 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7155 point (inhibit-read-only t))
7157 (goto-char (car region)))
7159 (narrow-to-region (point) (point))
7160 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7161 (let* ((mm-verify-option 'known)
7162 (mm-decrypt-option 'known)
7163 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7164 (unless (eq nparts (cdr handle))
7165 (mm-destroy-parts (cdr handle))
7166 (setcdr handle nparts))))
7167 (setq point (point))
7168 (gnus-mime-display-security handle)
7169 (goto-char (point-max)))
7171 (delete-region (point) (cdr region))
7172 (set-marker (car region) nil)
7173 (set-marker (cdr region) nil))
7176 (defun gnus-mime-security-show-details (handle)
7177 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7179 (gnus-message 5 "No details.")
7180 (if gnus-mime-security-show-details-inline
7181 (let ((gnus-mime-security-button-pressed
7182 (not (get-text-property (point) 'gnus-mime-details)))
7183 (gnus-mime-security-button-line-format
7184 (get-text-property (point) 'gnus-line-format))
7185 (inhibit-read-only t))
7187 (while (eq (get-text-property (point) 'gnus-line-format)
7188 gnus-mime-security-button-line-format)
7192 (narrow-to-region (point) (point))
7193 (gnus-insert-mime-security-button handle))
7194 (delete-region (point)
7195 (or (text-property-not-all
7198 gnus-mime-security-button-line-format)
7201 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7202 (with-current-buffer gnus-mime-security-details-buffer
7205 (setq gnus-mime-security-details-buffer
7206 (gnus-get-buffer-create "*MIME Security Details*")))
7207 (with-current-buffer gnus-mime-security-details-buffer
7209 (goto-char (point-min)))
7210 (pop-to-buffer gnus-mime-security-details-buffer)))))
7212 (defun gnus-mime-security-press-button (handle)
7214 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7215 (gnus-mime-security-show-details handle)
7216 (gnus-mime-security-verify-or-decrypt handle))))
7218 (defun gnus-insert-mime-security-button (handle &optional displayed)
7219 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7222 (or (nth 2 (assoc protocol mm-verify-function-alist))
7223 (nth 2 (assoc protocol mm-decrypt-function-alist))
7225 (if (equal (car handle) "multipart/signed")
7226 " Signed" " Encrypted")
7229 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7232 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7233 gnus-tmp-pressed-details
7235 (setq gnus-tmp-details
7236 (if gnus-tmp-details
7237 (concat "\n" gnus-tmp-details)
7239 (setq gnus-tmp-pressed-details
7240 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7245 gnus-mime-security-button-line-format
7246 gnus-mime-security-button-line-format-alist
7247 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7248 gnus-callback gnus-mime-security-press-button
7249 gnus-line-format ,gnus-mime-security-button-line-format
7250 gnus-mime-details ,gnus-mime-security-button-pressed
7251 article-type annotation
7254 ;; Exclude a newline.
7257 (widget-convert-button
7260 :action 'gnus-widget-press-button
7261 :button-keymap gnus-mime-security-button-map
7263 (lambda (widget/window &optional overlay pos)
7264 ;; Needed to properly clear the message due to a bug in
7265 ;; wid-edit (XEmacs only).
7266 (when (boundp 'help-echo-owns-message)
7267 (setq help-echo-owns-message t))
7270 (aref gnus-mouse-2 0))))))
7272 (defun gnus-mime-display-security (handle)
7274 (narrow-to-region (point) (point))
7275 (unless (gnus-unbuttonized-mime-type-p (car handle))
7276 (gnus-insert-mime-security-button handle))
7277 (gnus-mime-display-mixed (cdr handle))
7280 (unless (gnus-unbuttonized-mime-type-p (car handle))
7281 (let ((gnus-mime-security-button-line-format
7282 gnus-mime-security-button-end-line-format))
7283 (gnus-insert-mime-security-button handle)))
7284 (mm-set-handle-multipart-parameter
7286 (cons (set-marker (make-marker) (point-min))
7287 (set-marker (make-marker) (point-max))))))
7293 (run-hooks 'gnus-art-load-hook)
7295 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7296 ;;; gnus-art.el ends here