1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map
))
48 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
49 (autoload 'gnus-button-mailto
"gnus-msg")
50 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
51 (autoload 'parse-time-string
"parse-time" nil nil
)
52 (autoload 'mm-extern-cache-contents
"mm-extern")
54 (defgroup gnus-article nil
56 :link
'(custom-manual "(gnus)Article Buffer")
59 (defgroup gnus-article-treat nil
60 "Treating article parts."
61 :link
'(custom-manual "(gnus)Article Hiding")
64 (defgroup gnus-article-hiding nil
65 "Hiding article parts."
66 :link
'(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-highlight nil
70 "Article highlighting."
71 :link
'(custom-manual "(gnus)Article Highlighting")
75 (defgroup gnus-article-signature nil
77 :link
'(custom-manual "(gnus)Article Signature")
80 (defgroup gnus-article-headers nil
82 :link
'(custom-manual "(gnus)Hiding Headers")
85 (defgroup gnus-article-washing nil
86 "Special commands on articles."
87 :link
'(custom-manual "(gnus)Article Washing")
90 (defgroup gnus-article-emphasis nil
91 "Fontisizing articles."
92 :link
'(custom-manual "(gnus)Article Fontisizing")
95 (defgroup gnus-article-saving nil
97 :link
'(custom-manual "(gnus)Saving Articles")
100 (defgroup gnus-article-mime nil
101 "Worshiping the MIME wonder."
102 :link
'(custom-manual "(gnus)Using MIME")
103 :group
'gnus-article
)
105 (defgroup gnus-article-buttons nil
106 "Pushable buttons in the article buffer."
107 :link
'(custom-manual "(gnus)Article Buttons")
108 :group
'gnus-article
)
110 (defgroup gnus-article-various nil
111 "Other article options."
112 :link
'(custom-manual "(gnus)Misc Article")
113 :group
'gnus-article
)
115 (defcustom gnus-ignored-headers
118 (concat "^" header
":"))
119 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
120 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
121 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
122 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
123 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
124 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
125 "X-Attribution" "X-Originating-IP" "Delivered-To"
126 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
127 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
128 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
129 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
130 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
131 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
132 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
133 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
134 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
135 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
136 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
137 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
138 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
139 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
140 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
141 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
142 "List-[A-Za-z]+" "X-Listprocessor-Version"
143 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
144 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
145 "X-Received" "Content-length" "X-precedence"
146 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
147 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
148 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
149 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
150 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
151 "X-Content-length" "X-Posting-Agent" "Original-Received"
152 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
157 "*All headers that start with this regexp will be hidden.
158 This variable can also be a list of regexps of headers to be ignored.
159 If `gnus-visible-headers' is non-nil, this variable will be ignored."
160 :type
'(choice :custom-show nil
163 :group
'gnus-article-hiding
)
165 (defcustom gnus-visible-headers
166 "^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:"
167 "*All headers that do not match this regexp will be hidden.
168 This variable can also be a list of regexp of headers to remain visible.
169 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
170 :type
'(repeat :value-to-internal
(lambda (widget value
)
171 (custom-split-regexp-maybe value
))
172 :match
(lambda (widget value
)
174 (widget-editable-list-match widget value
)))
176 :group
'gnus-article-hiding
)
178 (defcustom gnus-sorted-header-list
179 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
180 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
181 "*This variable is a list of regular expressions.
182 If it is non-nil, headers that match the regular expressions will
183 be placed first in the article buffer in the sequence specified by
185 :type
'(repeat regexp
)
186 :group
'gnus-article-hiding
)
188 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
189 "Headers that are only to be displayed if they have interesting data.
190 Possible values in this list are:
192 'empty Headers with no content.
193 'newsgroups Newsgroup identical to Gnus group.
194 'to-address To identical to To-address.
195 'to-list To identical to To-list.
196 'cc-list CC identical to To-list.
197 'followup-to Followup-to identical to Newsgroups.
198 'reply-to Reply-to identical to From.
199 'date Date less than four days old.
200 'long-to To and/or Cc longer than 1024 characters.
201 'many-to Multiple To and/or Cc."
202 :type
'(set (const :tag
"Headers with no content." empty
)
203 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
204 (const :tag
"To identical to To-address." to-address
)
205 (const :tag
"To identical to To-list." to-list
)
206 (const :tag
"CC identical to To-list." cc-list
)
207 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
208 (const :tag
"Reply-to identical to From." reply-to
)
209 (const :tag
"Date less than four days old." date
)
210 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
211 (const :tag
"Multiple To and/or Cc headers." many-to
))
212 :group
'gnus-article-hiding
)
214 (defcustom gnus-article-skip-boring nil
215 "Skip over text that is not worth reading.
216 By default, if you set this t, then Gnus will display citations and
217 signatures, but will never scroll down to show you a page consisting
218 only of boring text. Boring text is controlled by
219 `gnus-article-boring-faces'."
222 :group
'gnus-article-hiding
)
224 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
225 "Regexp matching signature separator.
226 This can also be a list of regexps. In that case, it will be checked
227 from head to tail looking for a separator. Searches will be done from
228 the end of the buffer."
229 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
231 (repeat :tag
"List of regexp" regexp
))
232 :group
'gnus-article-signature
)
234 (defcustom gnus-signature-limit nil
235 "Provide a limit to what is considered a signature.
236 If it is a number, no signature may not be longer (in characters) than
237 that number. If it is a floating point number, no signature may be
238 longer (in lines) than that number. If it is a function, the function
239 will be called without any parameters, and if it returns nil, there is
240 no signature in the buffer. If it is a string, it will be used as a
241 regexp. If it matches, the text in question is not a signature."
242 :type
'(choice (const nil
)
245 (function :value fun
)
246 (regexp :value
".*"))
247 :group
'gnus-article-signature
)
249 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
250 "Property list to use for hiding text."
252 :group
'gnus-article-hiding
)
254 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
255 ;; frames in a session.
256 (defcustom gnus-article-x-face-command
257 (if (featurep 'xemacs
)
258 (if (or (gnus-image-type-available-p 'xface
)
259 (gnus-image-type-available-p 'pbm
))
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
262 (if (gnus-image-type-available-p 'pbm
)
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
266 "*String or function to be executed to display an X-Face header.
267 If it is a string, the command will be executed in a sub-shell
268 asynchronously. The compressed face will be piped to this command."
269 :type
`(choice string
270 (function-item gnus-display-x-face-in-from
)
274 :group
'gnus-article-washing
)
276 (defcustom gnus-article-x-face-too-ugly nil
277 "Regexp matching posters whose face shouldn't be shown automatically."
278 :type
'(choice regexp
(const nil
))
279 :group
'gnus-article-washing
)
281 (defcustom gnus-article-banner-alist nil
282 "Banner alist for stripping.
284 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
286 :type
'(repeat (cons symbol regexp
))
287 :group
'gnus-article-washing
)
289 (gnus-define-group-parameter
292 "Alist of regexps (to match group names) and banner."
293 :variable-group gnus-article-washing
295 '(choice :tag
"Banner"
297 (const :tag
"Remove signature" signature
)
298 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
300 (const :tag
"None" nil
))
302 "If non-nil, specify how to remove `banners' from articles.
304 Symbol `signature' means to remove signatures delimited by
305 `gnus-signature-separator'. Any other symbol is used to look up a
306 regular expression to match the banner in `gnus-article-banner-alist'.
307 A string is used as a regular expression to match the banner
310 (defcustom gnus-article-address-banner-alist nil
311 "Alist of mail addresses and banners.
312 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
313 to match a mail address in the From: header, BANNER is one of a symbol
314 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
315 If ADDRESS matches author's mail address, it will remove things like
316 advertisements. For example:
318 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
322 (regexp :tag
"Address")
323 (choice :tag
"Banner" :value nil
324 (const :tag
"Remove signature" signature
)
325 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
327 (const :tag
"None" nil
))))
329 :group
'gnus-article-washing
)
331 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
333 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
334 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
337 (defun gnus-emphasis-custom-value-to-external (value)
338 (gnus-emphasis-custom-with-format
339 (if (consp (car value
))
340 (list (format format
(car (car value
)) (cdr (car value
)))
342 (if (nth 1 value
) 2 3)
346 (defun gnus-emphasis-custom-value-to-internal (value)
347 (gnus-emphasis-custom-with-format
348 (let ((regexp (concat "\\`"
349 (format (regexp-quote format
)
350 "\\([^()]+\\)" "\\([^()]+\\)")
353 (if (string-match regexp
(setq pattern
(car value
)))
354 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
359 (defcustom gnus-emphasis-alist
361 '(("\\*" "\\*" bold nil
2)
364 ("_/" "/_" underline-italic
)
365 ("_\\*" "\\*_" underline-bold
)
366 ("\\*/" "/\\*" bold-italic
)
367 ("_\\*/" "/\\*_" underline-bold-italic
))))
369 (gnus-emphasis-custom-with-format
370 (mapcar (lambda (spec)
371 (list (format format
(car spec
) (cadr spec
))
374 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
376 '(;; I've never seen anyone use this strikethru convention whereas I've
377 ;; several times seen it triggered by normal text. --Stef
378 ;; Miles suggests that this form is sometimes used but for italics,
379 ;; so maybe we should map it to `italic'.
380 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
381 ;; 2 3 gnus-emphasis-strikethru)
382 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-underline
))))
384 "*Alist that says how to fontify certain phrases.
385 Each item looks like this:
387 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
389 The first element is a regular expression to be matched. The second
390 is a number that says what regular expression grouping used to find
391 the entire emphasized word. The third is a number that says what
392 regexp grouping should be displayed and highlighted. The fourth
393 is the face used for highlighting."
397 :format
"%[Customizing Style%]\n%v"
399 (group :tag
"Default"
400 :value
("" 0 0 default
)
403 (let ((value (widget-get
404 (cadr (widget-get (widget-get widget
:parent
)
407 (if (not (eq (nth 2 value
) 'default
))
411 (gnus-emphasis-custom-value-to-external value
))))
412 (widget-group-value-create widget
))
414 (integer :format
"Match group: %v")
415 (integer :format
"Emphasize group: %v")
418 :value
(("_" .
"_") nil default
)
420 (regexp :format
"Start regexp: %v")
421 (regexp :format
"End regexp: %v"))
422 (boolean :format
"Show start and end patterns: %[%v%]\n"
423 :on
" On " :off
" Off ")
425 :get
(lambda (symbol)
426 (mapcar 'gnus-emphasis-custom-value-to-internal
427 (default-value symbol
)))
428 :set
(lambda (symbol value
)
429 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
431 :group
'gnus-article-emphasis
)
433 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
434 "A regexp to describe whitespace which should not be emphasized.
435 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
436 The former avoids underlining of leading and trailing whitespace,
437 and the latter avoids underlining any whitespace at all."
439 :group
'gnus-article-emphasis
442 (defface gnus-emphasis-bold
'((t (:bold t
)))
443 "Face used for displaying strong emphasized text (*word*)."
444 :group
'gnus-article-emphasis
)
446 (defface gnus-emphasis-italic
'((t (:italic t
)))
447 "Face used for displaying italic emphasized text (/word/)."
448 :group
'gnus-article-emphasis
)
450 (defface gnus-emphasis-underline
'((t (:underline t
)))
451 "Face used for displaying underlined emphasized text (_word_)."
452 :group
'gnus-article-emphasis
)
454 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
455 "Face used for displaying underlined bold emphasized text (_*word*_)."
456 :group
'gnus-article-emphasis
)
458 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
459 "Face used for displaying underlined italic emphasized text (_/word/_)."
460 :group
'gnus-article-emphasis
)
462 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
463 "Face used for displaying bold italic emphasized text (/*word*/)."
464 :group
'gnus-article-emphasis
)
466 (defface gnus-emphasis-underline-bold-italic
467 '((t (:bold t
:italic t
:underline t
)))
468 "Face used for displaying underlined bold italic emphasized text.
469 Example: (_/*word*/_)."
470 :group
'gnus-article-emphasis
)
472 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
473 '((t (:strikethru t
)))
474 '((t (:strike-through t
))))
475 "Face used for displaying strike-through text (-word-)."
476 :group
'gnus-article-emphasis
)
478 (defface gnus-emphasis-highlight-words
479 '((t (:background
"black" :foreground
"yellow")))
480 "Face used for displaying highlighted words."
481 :group
'gnus-article-emphasis
)
483 (defcustom gnus-article-time-format
"%a, %b %d %Y %T %Z"
484 "Format for display of Date headers in article bodies.
485 See `format-time-string' for the possible values.
487 The variable can also be function, which should return a complete Date
488 header. The function is called with one argument, the time, which can
489 be fed to `format-time-string'."
490 :type
'(choice string symbol
)
491 :link
'(custom-manual "(gnus)Article Date")
492 :group
'gnus-article-washing
)
494 (defcustom gnus-save-all-headers t
495 "*If non-nil, don't remove any headers before saving.
496 This will be overridden by the `:headers' property that the symbol of
497 the saver function, which is specified by `gnus-default-article-saver',
499 :group
'gnus-article-saving
502 (defcustom gnus-prompt-before-saving
'always
503 "*This variable says how much prompting is to be done when saving articles.
504 If it is nil, no prompting will be done, and the articles will be
505 saved to the default files. If this variable is `always', each and
506 every article that is saved will be preceded by a prompt, even when
507 saving large batches of articles. If this variable is neither nil not
508 `always', there the user will be prompted once for a file name for
509 each invocation of the saving commands."
510 :group
'gnus-article-saving
511 :type
'(choice (item always
)
512 (item :tag
"never" nil
)
513 (sexp :tag
"once" :format
"%t\n" :value t
)))
515 (defcustom gnus-saved-headers gnus-visible-headers
516 "Headers to keep if `gnus-save-all-headers' is nil.
517 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
518 If that variable is nil, however, all headers that match this regexp
519 will be kept while the rest will be deleted before saving. This and
520 `gnus-save-all-headers' will be overridden by the `:headers' property
521 that the symbol of the saver function, which is specified by
522 `gnus-default-article-saver', might have."
523 :group
'gnus-article-saving
526 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
527 "A function to save articles in your favourite format.
528 The function will be called by way of the `gnus-summary-save-article'
529 command, and friends such as `gnus-summary-save-article-rmail'.
531 Gnus provides the following functions:
533 * gnus-summary-save-in-rmail (Rmail format)
534 * gnus-summary-save-in-mail (Unix mail format)
535 * gnus-summary-save-in-folder (MH folder)
536 * gnus-summary-save-in-file (article format)
537 * gnus-summary-save-body-in-file (article body)
538 * gnus-summary-save-in-vm (use VM's folder format)
539 * gnus-summary-write-to-file (article format -- overwrite)
540 * gnus-summary-write-body-to-file (article body -- overwrite)
542 The symbol of each function may have the following properties:
545 The value non-nil means save decoded articles. This is meaningful
546 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
547 `gnus-summary-write-to-file', and `gnus-summary-write-body-to-file'.
550 The value specifies an alternative function which appends, not
551 overwrites, articles to a file. This implies that when saving many
552 articles at a time, `gnus-prompt-before-saving' is bound to t and all
553 articles are saved in a single file. This is meaningful only with
554 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
557 The value specifies the symbol of a variable of which the value
558 specifies headers to be saved. If it is omitted,
559 `gnus-save-all-headers' and `gnus-saved-headers' control what
560 headers should be saved."
561 :group
'gnus-article-saving
562 :type
'(radio (function-item gnus-summary-save-in-rmail
)
563 (function-item gnus-summary-save-in-mail
)
564 (function-item gnus-summary-save-in-folder
)
565 (function-item gnus-summary-save-in-file
)
566 (function-item gnus-summary-save-body-in-file
)
567 (function-item gnus-summary-save-in-vm
)
568 (function-item gnus-summary-write-to-file
)
569 (function-item gnus-summary-write-body-to-file
)
572 (defcustom gnus-article-save-coding-system
573 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
574 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
575 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
576 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
577 "Coding system used to save decoded articles to a file.
579 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
580 which can safely encode any characters in text. This is used by the
583 * gnus-summary-save-article-file
584 * gnus-summary-save-article-body-file
585 * gnus-summary-write-article-file
586 * gnus-summary-write-article-body-file
588 and the functions to which you may set `gnus-default-article-saver':
590 * gnus-summary-save-in-file
591 * gnus-summary-save-body-in-file
592 * gnus-summary-write-to-file
593 * gnus-summary-write-body-to-file
595 Those commands and functions save just text displayed in the article
596 buffer to a file if the value of this variable is non-nil. Note that
597 buttonized MIME parts will be lost in a saved file in that case.
598 Otherwise, raw articles will be saved."
599 :group
'gnus-article-saving
601 :format
"%{%t%}:\n %[Value Menu%] %v"
602 (const :tag
"Save raw articles" nil
)
605 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
606 '((const :tag
"UTF-8" utf-8
)
607 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
608 (const :tag
"Emacs internal" emacs-mule
)
609 (const :tag
"escape-quoted" escape-quoted
))))
610 (symbol :tag
"Coding system")))
612 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
613 "A function generating a file name to save articles in Rmail format.
614 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
615 :group
'gnus-article-saving
618 (defcustom gnus-mail-save-name
'gnus-plain-save-name
619 "A function generating a file name to save articles in Unix mail format.
620 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
621 :group
'gnus-article-saving
624 (defcustom gnus-folder-save-name
'gnus-folder-save-name
625 "A function generating a file name to save articles in MH folder.
626 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
627 :group
'gnus-article-saving
630 (defcustom gnus-file-save-name
'gnus-numeric-save-name
631 "A function generating a file name to save articles in article format.
632 The function is called with NEWSGROUP, HEADERS, and optional
634 :group
'gnus-article-saving
637 (defcustom gnus-split-methods
638 '((gnus-article-archive-name)
639 (gnus-article-nndoc-name))
640 "*Variable used to suggest where articles are to be saved.
641 For instance, if you would like to save articles related to Gnus in
642 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
643 you could set this variable to something like:
645 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
646 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
648 This variable is an alist where the where the key is the match and the
649 value is a list of possible files to save in if the match is non-nil.
651 If the match is a string, it is used as a regexp match on the
652 article. If the match is a symbol, that symbol will be funcalled
653 from the buffer of the article to be saved with the newsgroup as the
654 parameter. If it is a list, it will be evaled in the same buffer.
656 If this form or function returns a string, this string will be used as
657 a possible file name; and if it returns a non-nil list, that list will
658 be used as possible file names."
659 :group
'gnus-article-saving
660 :type
'(repeat (choice (list :value
(fun) function
)
661 (cons :value
("" "") regexp
(repeat string
))
664 (defcustom gnus-page-delimiter
"^\^L"
665 "*Regexp describing what to use as article page delimiters.
666 The default value is \"^\^L\", which is a form linefeed at the
667 beginning of a line."
669 :group
'gnus-article-various
)
671 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
672 "*The format specification for the article mode line.
673 See `gnus-summary-mode-line-format' for a closer description.
675 The following additional specs are available:
677 %w The article washing status.
678 %m The number of MIME parts in the article."
680 :group
'gnus-article-various
)
682 (defcustom gnus-article-mode-hook nil
683 "*A hook for Gnus article mode."
685 :group
'gnus-article-various
)
687 (when (featurep 'xemacs
)
688 ;; Extracted from gnus-xmas-define in order to preserve user settings
689 (when (fboundp 'turn-off-scroll-in-place
)
690 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
691 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
692 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
694 (defcustom gnus-article-menu-hook nil
695 "*Hook run after the creation of the article mode menu."
697 :group
'gnus-article-various
)
699 (defcustom gnus-article-prepare-hook nil
700 "*A hook called after an article has been prepared in the article buffer."
702 :group
'gnus-article-various
)
704 (make-obsolete-variable 'gnus-article-hide-pgp-hook
705 "This variable is obsolete in Gnus 5.10.")
707 (defcustom gnus-article-button-face
'bold
708 "Face used for highlighting buttons in the article buffer.
710 An article button is a piece of text that you can activate by pressing
711 `RET' or `mouse-2' above it."
713 :group
'gnus-article-buttons
)
715 (defcustom gnus-article-mouse-face
'highlight
716 "Face used for mouse highlighting in the article buffer.
718 Article buttons will be displayed in this face when the cursor is
721 :group
'gnus-article-buttons
)
723 (defcustom gnus-signature-face
'gnus-signature
724 "Face used for highlighting a signature in the article buffer.
725 Obsolete; use the face `gnus-signature' for customizations instead."
727 :group
'gnus-article-highlight
728 :group
'gnus-article-signature
)
730 (defface gnus-signature
733 "Face used for highlighting a signature in the article buffer."
734 :group
'gnus-article-highlight
735 :group
'gnus-article-signature
)
736 ;; backward-compatibility alias
737 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
739 (defface gnus-header-from
742 (:foreground
"spring green"))
745 (:foreground
"red3"))
748 "Face used for displaying from headers."
749 :group
'gnus-article-headers
750 :group
'gnus-article-highlight
)
751 ;; backward-compatibility alias
752 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
754 (defface gnus-header-subject
757 (:foreground
"SeaGreen3"))
760 (:foreground
"red4"))
762 (:bold t
:italic t
)))
763 "Face used for displaying subject headers."
764 :group
'gnus-article-headers
765 :group
'gnus-article-highlight
)
766 ;; backward-compatibility alias
767 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
769 (defface gnus-header-newsgroups
772 (:foreground
"yellow" :italic t
))
775 (:foreground
"MidnightBlue" :italic t
))
778 "Face used for displaying newsgroups headers.
779 In the default setup this face is only used for crossposted
781 :group
'gnus-article-headers
782 :group
'gnus-article-highlight
)
783 ;; backward-compatibility alias
784 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
786 (defface gnus-header-name
789 (:foreground
"SeaGreen"))
792 (:foreground
"maroon"))
795 "Face used for displaying header names."
796 :group
'gnus-article-headers
797 :group
'gnus-article-highlight
)
798 ;; backward-compatibility alias
799 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
801 (defface gnus-header-content
804 (:foreground
"forest green" :italic t
))
807 (:foreground
"indianred4" :italic t
))
809 (:italic t
))) "Face used for displaying header content."
810 :group
'gnus-article-headers
811 :group
'gnus-article-highlight
)
812 ;; backward-compatibility alias
813 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
815 (defcustom gnus-header-face-alist
816 '(("From" nil gnus-header-from
)
817 ("Subject" nil gnus-header-subject
)
818 ("Newsgroups:.*," nil gnus-header-newsgroups
)
819 ("" gnus-header-name gnus-header-content
))
820 "*Controls highlighting of article headers.
822 An alist of the form (HEADER NAME CONTENT).
824 HEADER is a regular expression which should match the name of a
825 header and NAME and CONTENT are either face names or nil.
827 The name of each header field will be displayed using the face
828 specified by the first element in the list where HEADER matches
829 the header name and NAME is non-nil. Similarly, the content will
830 be displayed by the first non-nil matching CONTENT face."
831 :group
'gnus-article-headers
832 :group
'gnus-article-highlight
833 :type
'(repeat (list (regexp :tag
"Header")
835 (item :tag
"skip" nil
)
836 (face :value default
))
837 (choice :tag
"Content"
838 (item :tag
"skip" nil
)
839 (face :value default
)))))
841 (defcustom gnus-article-decode-hook
842 '(article-decode-charset article-decode-encoded-words
843 article-decode-group-name article-decode-idna-rhs
)
844 "*Hook run to decode charsets in articles."
845 :group
'gnus-article-headers
848 (defcustom gnus-display-mime-function
'gnus-display-mime
849 "Function to display MIME articles."
850 :group
'gnus-article-mime
853 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
854 "Function used to decode headers.")
856 (defvar gnus-article-dumbquotes-map
876 "Table for MS-to-Latin1 translation.")
878 (defcustom gnus-ignored-mime-types nil
879 "List of MIME types that should be ignored by Gnus."
881 :group
'gnus-article-mime
882 :type
'(repeat regexp
))
884 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
885 "List of MIME types that should not be given buttons when rendered inline.
886 See also `gnus-buttonized-mime-types' which may override this variable.
887 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
889 :group
'gnus-article-mime
890 :type
'(repeat regexp
))
892 (defcustom gnus-buttonized-mime-types nil
893 "List of MIME types that should be given buttons when rendered inline.
894 If set, this variable overrides `gnus-unbuttonized-mime-types'.
895 To see e.g. security buttons you could set this to
896 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
897 this list to display radio buttons that allow you to choose one of two
898 media types those mails include. See also `mm-discouraged-alternatives'.
899 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
901 :group
'gnus-article-mime
902 :type
'(repeat regexp
))
904 (defcustom gnus-inhibit-mime-unbuttonizing nil
905 "If non-nil, all MIME parts get buttons.
906 When nil (the default value), then some MIME parts do not get buttons,
907 as described by the variables `gnus-buttonized-mime-types' and
908 `gnus-unbuttonized-mime-types'."
910 :group
'gnus-article-mime
913 (defcustom gnus-body-boundary-delimiter
"_"
914 "String used to delimit header and body.
915 This variable is used by `gnus-article-treat-body-boundary' which can
916 be controlled by `gnus-treat-body-boundary'."
918 :group
'gnus-article-various
919 :type
'(choice (item :tag
"None" :value nil
)
922 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
924 "Defines the location of the faces database.
925 For information on obtaining this database of pretty pictures, please
926 see http://www.cs.indiana.edu/picons/ftp/index.html"
928 :type
'(repeat directory
)
929 :link
'(url-link :tag
"download"
930 "http://www.cs.indiana.edu/picons/ftp/index.html")
931 :link
'(custom-manual "(gnus)Picons")
934 (defun gnus-picons-installed-p ()
935 "Say whether picons are installed on your machine."
936 (let ((installed nil
))
937 (dolist (database gnus-picon-databases
)
938 (when (file-exists-p database
)
942 (defcustom gnus-article-mime-part-function nil
943 "Function called with a MIME handle as the argument.
944 This is meant for people who want to do something automatic based
945 on parts -- for instance, adding Vcard info to a database."
946 :group
'gnus-article-mime
947 :type
'(choice (const nil
)
950 (defcustom gnus-mime-multipart-functions nil
951 "An alist of MIME types to functions to display them."
953 :group
'gnus-article-mime
956 (defcustom gnus-article-date-lapsed-new-header nil
957 "Whether the X-Sent and Date headers can coexist.
958 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
959 either replace the old \"Date:\" header (if this variable is nil), or
960 be added below it (otherwise)."
962 :group
'gnus-article-headers
965 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
966 "Function called with a MIME handle as the argument.
967 This is meant for people who want to view first matched part.
968 For `undisplayed-alternative' (default), the first undisplayed
969 part or alternative part is used. For `undisplayed', the first
970 undisplayed part is used. For a function, the first part which
971 the function return t is used. For nil, the first part is
974 :group
'gnus-article-mime
976 (item :tag
"first" :value nil
)
977 (item :tag
"undisplayed" :value undisplayed
)
978 (item :tag
"undisplayed or alternative"
979 :value undisplayed-alternative
)
982 (defcustom gnus-mime-action-alist
983 '(("save to file" . gnus-mime-save-part
)
984 ("save and strip" . gnus-mime-save-part-and-strip
)
985 ("delete part" . gnus-mime-delete-part
)
986 ("display as text" . gnus-mime-inline-part
)
987 ("view the part" . gnus-mime-view-part
)
988 ("pipe to command" . gnus-mime-pipe-part
)
989 ("toggle display" . gnus-article-press-button
)
990 ("toggle display" . gnus-article-view-part-as-charset
)
991 ("view as type" . gnus-mime-view-part-as-type
)
992 ("view internally" . gnus-mime-view-part-internally
)
993 ("view externally" . gnus-mime-view-part-externally
))
994 "An alist of actions that run on the MIME attachment."
995 :group
'gnus-article-mime
996 :type
'(repeat (cons (string :tag
"name")
1000 ;;; The treatment variables
1003 (defvar gnus-part-display-hook nil
1004 "Hook called on parts that are to receive treatment.")
1006 (defvar gnus-article-treat-custom
1007 '(choice (const :tag
"Off" nil
)
1009 (const :tag
"Header" head
)
1010 (const :tag
"Last" last
)
1011 (integer :tag
"Less")
1012 (repeat :tag
"Groups" regexp
)
1013 (sexp :tag
"Predicate")))
1015 (defvar gnus-article-treat-head-custom
1016 '(choice (const :tag
"Off" nil
)
1017 (const :tag
"Header" head
)))
1019 (defvar gnus-article-treat-types
'("text/plain")
1022 (defvar gnus-inhibit-treatment nil
1023 "Whether to inhibit treatment.")
1025 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1026 "Highlight the signature.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles'."
1029 :group
'gnus-article-treat
1030 :link
'(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom
)
1032 (put 'gnus-treat-highlight-signature
'highlight t
)
1034 (defcustom gnus-treat-buttonize
100000
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles'."
1038 :group
'gnus-article-treat
1039 :link
'(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom
)
1041 (put 'gnus-treat-buttonize
'highlight t
)
1043 (defcustom gnus-treat-buttonize-head
'head
1044 "Add buttons to the head.
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group
'gnus-article-treat
1048 :link
'(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-head-custom
)
1050 (put 'gnus-treat-buttonize-head
'highlight t
)
1052 (defcustom gnus-treat-emphasize
1053 (and (or window-system
1055 (>= (string-to-number emacs-version
) 21))
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group
'gnus-article-treat
1061 :link
'(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-custom
)
1063 (put 'gnus-treat-emphasize
'highlight t
)
1065 (defcustom gnus-treat-strip-cr nil
1066 "Remove carriage returns.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 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-unsplit-urls nil
1075 "Remove newlines from within URLs.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1079 :group
'gnus-article-treat
1080 :link
'(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom
)
1083 (defcustom gnus-treat-leading-whitespace nil
1084 "Remove leading whitespace in headers.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1088 :group
'gnus-article-treat
1089 :link
'(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-custom
)
1092 (defcustom gnus-treat-hide-headers
'head
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-hide-boring-headers nil
1101 "Hide boring headers.
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-hide-signature nil
1109 "Hide the signature.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group
'gnus-article-treat
1113 :link
'(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom
)
1116 (defcustom gnus-treat-fill-article nil
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group
'gnus-article-treat
1121 :link
'(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-custom
)
1124 (defcustom gnus-treat-hide-citation nil
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1128 :group
'gnus-article-treat
1129 :link
'(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-custom
)
1132 (defcustom gnus-treat-hide-citation-maybe nil
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136 :group
'gnus-article-treat
1137 :link
'(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom
)
1140 (defcustom gnus-treat-strip-list-identifiers
'head
1141 "Strip list identifiers from `gnus-list-identifiers`.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1145 :group
'gnus-article-treat
1146 :link
'(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom
)
1149 (make-obsolete-variable 'gnus-treat-strip-pgp
1150 "This option is obsolete in Gnus 5.10.")
1152 (defcustom gnus-treat-strip-pem nil
1153 "Strip PEM signatures.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 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-banner t
1161 "Strip banners from articles.
1162 The banner to be stripped is specified in the `banner' group parameter.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1165 :group
'gnus-article-treat
1166 :link
'(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-custom
)
1169 (defcustom gnus-treat-highlight-headers
'head
1170 "Highlight the headers.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' for details."
1173 :group
'gnus-article-treat
1174 :link
'(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-head-custom
)
1176 (put 'gnus-treat-highlight-headers
'highlight t
)
1178 (defcustom gnus-treat-highlight-citation t
1179 "Highlight cited text.
1180 Valid values are nil, t, `head', `last', an integer or a predicate.
1181 See Info node `(gnus)Customizing Articles' for details."
1182 :group
'gnus-article-treat
1183 :link
'(custom-manual "(gnus)Customizing Articles")
1184 :type gnus-article-treat-custom
)
1185 (put 'gnus-treat-highlight-citation
'highlight t
)
1187 (defcustom gnus-treat-date-ut nil
1188 "Display the Date in UT (GMT).
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group
'gnus-article-treat
1192 :link
'(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-head-custom
)
1195 (defcustom gnus-treat-date-local nil
1196 "Display the Date in the local timezone.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1199 :group
'gnus-article-treat
1200 :link
'(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-head-custom
)
1203 (defcustom gnus-treat-date-english nil
1204 "Display the Date in a format that can be read aloud in English.
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group
'gnus-article-treat
1209 :link
'(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-head-custom
)
1212 (defcustom gnus-treat-date-lapsed nil
1213 "Display the Date header in a way that says how much time has elapsed.
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' for details."
1216 :group
'gnus-article-treat
1217 :link
'(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-head-custom
)
1220 (defcustom gnus-treat-date-original nil
1221 "Display the date in the original timezone.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1224 :group
'gnus-article-treat
1225 :link
'(custom-manual "(gnus)Customizing Articles")
1226 :type gnus-article-treat-head-custom
)
1228 (defcustom gnus-treat-date-iso8601 nil
1229 "Display the date in the ISO8601 format.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' for details."
1233 :group
'gnus-article-treat
1234 :link
'(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-head-custom
)
1237 (defcustom gnus-treat-date-user-defined nil
1238 "Display the date in a user-defined format.
1239 The format is defined by the `gnus-article-time-format' variable.
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' for details."
1242 :group
'gnus-article-treat
1243 :link
'(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-head-custom
)
1246 (defcustom gnus-treat-strip-headers-in-body t
1247 "Strip the X-No-Archive header line from the beginning of the body.
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' for details."
1251 :group
'gnus-article-treat
1252 :link
'(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom
)
1255 (defcustom gnus-treat-strip-trailing-blank-lines nil
1256 "Strip trailing blank lines.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details.
1260 When set to t, it also strips trailing blanks in all MIME parts.
1261 Consider to use `last' instead."
1262 :group
'gnus-article-treat
1263 :link
'(custom-manual "(gnus)Customizing Articles")
1264 :type gnus-article-treat-custom
)
1266 (defcustom gnus-treat-strip-leading-blank-lines nil
1267 "Strip leading blank lines.
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' for details.
1271 When set to t, it also strips trailing blanks in all MIME parts."
1272 :group
'gnus-article-treat
1273 :link
'(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-custom
)
1276 (defcustom gnus-treat-strip-multiple-blank-lines nil
1277 "Strip multiple blank lines.
1278 Valid values are nil, t, `head', `last', an integer or a predicate.
1279 See Info node `(gnus)Customizing Articles' for details."
1280 :group
'gnus-article-treat
1281 :link
'(custom-manual "(gnus)Customizing Articles")
1282 :type gnus-article-treat-custom
)
1284 (defcustom gnus-treat-unfold-headers
'head
1285 "Unfold folded header lines.
1286 Valid values are nil, t, `head', `last', an integer or a predicate.
1287 See Info node `(gnus)Customizing Articles' for details."
1289 :group
'gnus-article-treat
1290 :link
'(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-custom
)
1293 (defcustom gnus-treat-fold-headers nil
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' for details."
1298 :group
'gnus-article-treat
1299 :link
'(custom-manual "(gnus)Customizing Articles")
1300 :type gnus-article-treat-custom
)
1302 (defcustom gnus-treat-fold-newsgroups
'head
1303 "Fold the Newsgroups and Followup-To headers.
1304 Valid values are nil, t, `head', `last', an integer or a predicate.
1305 See Info node `(gnus)Customizing Articles' for details."
1307 :group
'gnus-article-treat
1308 :link
'(custom-manual "(gnus)Customizing Articles")
1309 :type gnus-article-treat-custom
)
1311 (defcustom gnus-treat-overstrike t
1312 "Treat overstrike highlighting.
1313 Valid values are nil, t, `head', `last', an integer or a predicate.
1314 See Info node `(gnus)Customizing Articles' for details."
1315 :group
'gnus-article-treat
1316 :link
'(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom
)
1318 (put 'gnus-treat-overstrike
'highlight t
)
1320 (make-obsolete-variable 'gnus-treat-display-xface
1321 'gnus-treat-display-x-face
)
1323 (defcustom gnus-treat-display-x-face
1324 (and (not noninteractive
)
1325 (or (and (fboundp 'image-type-available-p
)
1326 (image-type-available-p 'xbm
)
1327 (string-match "^0x" (shell-command-to-string "uncompface"))
1328 (executable-find "icontopbm"))
1329 (and (featurep 'xemacs
)
1332 "Display X-Face headers.
1333 Valid values are nil, t, `head', `last', an integer or a predicate.
1334 See Info node `(gnus)Customizing Articles' and Info node
1335 `(gnus)X-Face' for details."
1336 :group
'gnus-article-treat
1338 :link
'(custom-manual "(gnus)Customizing Articles")
1339 :link
'(custom-manual "(gnus)X-Face")
1340 :type gnus-article-treat-head-custom
1341 :set
(lambda (symbol value
)
1344 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1346 ((boundp 'gnus-treat-display-xface
)
1348 ** gnus-treat-display-xface is an obsolete variable;\
1349 use gnus-treat-display-x-face instead")
1350 (default-value 'gnus-treat-display-xface
))
1351 ((get 'gnus-treat-display-xface
'saved-value
)
1353 ** gnus-treat-display-xface is an obsolete variable;\
1354 use gnus-treat-display-x-face instead")
1355 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1358 (put 'gnus-treat-display-x-face
'highlight t
)
1360 (defcustom gnus-treat-display-face
1361 (and (not noninteractive
)
1362 (or (and (fboundp 'image-type-available-p
)
1363 (image-type-available-p 'png
))
1364 (and (featurep 'xemacs
)
1367 "Display Face headers.
1368 Valid values are nil, t, `head', `last', an integer or a predicate.
1369 See Info node `(gnus)Customizing Articles' and Info node
1370 `(gnus)X-Face' for details."
1371 :group
'gnus-article-treat
1373 :link
'(custom-manual "(gnus)Customizing Articles")
1374 :link
'(custom-manual "(gnus)X-Face")
1375 :type gnus-article-treat-head-custom
)
1376 (put 'gnus-treat-display-face
'highlight t
)
1378 (defcustom gnus-treat-display-smileys
1379 (if (or (and (featurep 'xemacs
)
1381 (and (fboundp 'image-type-available-p
)
1382 (image-type-available-p 'pbm
)))
1385 Valid values are nil, t, `head', `last', an integer or a predicate.
1386 See Info node `(gnus)Customizing Articles' and Info node
1387 `(gnus)Smileys' for details."
1388 :group
'gnus-article-treat
1390 :link
'(custom-manual "(gnus)Customizing Articles")
1391 :link
'(custom-manual "(gnus)Smileys")
1392 :type gnus-article-treat-custom
)
1393 (put 'gnus-treat-display-smileys
'highlight t
)
1395 (defcustom gnus-treat-from-picon
1396 (if (and (gnus-image-type-available-p 'xpm
)
1397 (gnus-picons-installed-p))
1399 "Display picons in the From header.
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' and Info node
1402 `(gnus)Picons' for details."
1404 :group
'gnus-article-treat
1406 :link
'(custom-manual "(gnus)Customizing Articles")
1407 :link
'(custom-manual "(gnus)Picons")
1408 :type gnus-article-treat-head-custom
)
1409 (put 'gnus-treat-from-picon
'highlight t
)
1411 (defcustom gnus-treat-mail-picon
1412 (if (and (gnus-image-type-available-p 'xpm
)
1413 (gnus-picons-installed-p))
1415 "Display picons in To and Cc headers.
1416 Valid values are nil, t, `head', `last', an integer or a predicate.
1417 See Info node `(gnus)Customizing Articles' and Info node
1418 `(gnus)Picons' for details."
1420 :group
'gnus-article-treat
1422 :link
'(custom-manual "(gnus)Customizing Articles")
1423 :link
'(custom-manual "(gnus)Picons")
1424 :type gnus-article-treat-head-custom
)
1425 (put 'gnus-treat-mail-picon
'highlight t
)
1427 (defcustom gnus-treat-newsgroups-picon
1428 (if (and (gnus-image-type-available-p 'xpm
)
1429 (gnus-picons-installed-p))
1431 "Display picons in the Newsgroups and Followup-To headers.
1432 Valid values are nil, t, `head', `last', an integer or a predicate.
1433 See Info node `(gnus)Customizing Articles' and Info node
1434 `(gnus)Picons' for details."
1436 :group
'gnus-article-treat
1438 :link
'(custom-manual "(gnus)Customizing Articles")
1439 :link
'(custom-manual "(gnus)Picons")
1440 :type gnus-article-treat-head-custom
)
1441 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1443 (defcustom gnus-treat-body-boundary
1444 (if (or gnus-treat-newsgroups-picon
1445 gnus-treat-mail-picon
1446 gnus-treat-from-picon
)
1448 "Draw a boundary at the end of the headers.
1449 Valid values are nil and `head'.
1450 See Info node `(gnus)Customizing Articles' for details."
1452 :group
'gnus-article-treat
1453 :link
'(custom-manual "(gnus)Customizing Articles")
1454 :type gnus-article-treat-head-custom
)
1456 (defcustom gnus-treat-capitalize-sentences nil
1457 "Capitalize sentence-starting words.
1458 Valid values are nil, t, `head', `last', an integer or a predicate.
1459 See Info node `(gnus)Customizing Articles' for details."
1461 :group
'gnus-article-treat
1462 :link
'(custom-manual "(gnus)Customizing Articles")
1463 :type gnus-article-treat-custom
)
1465 (defcustom gnus-treat-wash-html nil
1467 Valid values are nil, t, `head', `last', an integer or a predicate.
1468 See Info node `(gnus)Customizing Articles' for details."
1470 :group
'gnus-article-treat
1471 :link
'(custom-manual "(gnus)Customizing Articles")
1472 :type gnus-article-treat-custom
)
1474 (defcustom gnus-treat-fill-long-lines nil
1476 Valid values are nil, t, `head', `last', an integer or a predicate.
1477 See Info node `(gnus)Customizing Articles' for details."
1478 :group
'gnus-article-treat
1479 :link
'(custom-manual "(gnus)Customizing Articles")
1480 :type gnus-article-treat-custom
)
1482 (defcustom gnus-treat-play-sounds nil
1484 Valid values are nil, t, `head', `last', an integer or a predicate.
1485 See Info node `(gnus)Customizing Articles' for details."
1487 :group
'gnus-article-treat
1488 :link
'(custom-manual "(gnus)Customizing Articles")
1489 :type gnus-article-treat-custom
)
1491 (defcustom gnus-treat-translate nil
1492 "Translate articles from one language to another.
1493 Valid values are nil, t, `head', `last', an integer or a predicate.
1494 See Info node `(gnus)Customizing Articles' for details."
1496 :group
'gnus-article-treat
1497 :link
'(custom-manual "(gnus)Customizing Articles")
1498 :type gnus-article-treat-custom
)
1500 (defcustom gnus-treat-x-pgp-sig nil
1502 To automatically treat X-PGP-Sig, set it to head.
1503 Valid values are nil, t, `head', `last', an integer or a predicate.
1504 See Info node `(gnus)Customizing Articles' for details."
1506 :group
'gnus-article-treat
1507 :group
'mime-security
1508 :link
'(custom-manual "(gnus)Customizing Articles")
1509 :type gnus-article-treat-custom
)
1511 (defvar gnus-article-encrypt-protocol-alist
1512 '(("PGP" . mml2015-self-encrypt
)))
1514 ;; Set to nil if more than one protocol added to
1515 ;; gnus-article-encrypt-protocol-alist.
1516 (defcustom gnus-article-encrypt-protocol
"PGP"
1517 "The protocol used for encrypt articles.
1518 It is a string, such as \"PGP\". If nil, ask user."
1521 :group
'mime-security
)
1523 (defvar gnus-article-wash-function nil
1524 "Function used for converting HTML into text.")
1526 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1527 (mm-coding-system-p 'utf-8
)
1528 (executable-find idna-program
))
1529 "Whether IDNA decoding of headers is used when viewing messages.
1530 This requires GNU Libidn, and by default only enabled if it is found."
1532 :group
'gnus-article-headers
1535 (defcustom gnus-article-over-scroll nil
1536 "If non-nil, allow scrolling the article buffer even when there no more text."
1538 :group
'gnus-article
1541 ;;; Internal variables
1543 (defvar gnus-english-month-names
1544 '("January" "February" "March" "April" "May" "June" "July" "August"
1545 "September" "October" "November" "December"))
1547 (defvar article-goto-body-goes-to-point-min-p nil
)
1548 (defvar gnus-article-wash-types nil
)
1549 (defvar gnus-article-emphasis-alist nil
)
1550 (defvar gnus-article-image-alist nil
)
1552 (defvar gnus-article-mime-handle-alist-1 nil
)
1553 (defvar gnus-treatment-function-alist
1554 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1555 (gnus-treat-strip-banner gnus-article-strip-banner
)
1556 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1557 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1558 (gnus-treat-buttonize gnus-article-add-buttons
)
1559 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1560 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1561 (gnus-treat-strip-cr gnus-article-remove-cr
)
1562 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1563 (gnus-treat-date-ut gnus-article-date-ut
)
1564 (gnus-treat-date-local gnus-article-date-local
)
1565 (gnus-treat-date-english gnus-article-date-english
)
1566 (gnus-treat-date-original gnus-article-date-original
)
1567 (gnus-treat-date-user-defined gnus-article-date-user
)
1568 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1569 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1570 (gnus-treat-display-x-face gnus-article-display-x-face
)
1571 (gnus-treat-display-face gnus-article-display-face
)
1572 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1573 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1574 (gnus-treat-hide-signature gnus-article-hide-signature
)
1575 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1576 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1577 (gnus-treat-strip-pem gnus-article-hide-pem
)
1578 (gnus-treat-from-picon gnus-treat-from-picon
)
1579 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1580 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1581 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1582 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1583 (gnus-treat-strip-trailing-blank-lines
1584 gnus-article-remove-trailing-blank-lines
)
1585 (gnus-treat-strip-leading-blank-lines
1586 gnus-article-strip-leading-blank-lines
)
1587 (gnus-treat-strip-multiple-blank-lines
1588 gnus-article-strip-multiple-blank-lines
)
1589 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1590 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1591 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1592 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1593 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1594 (gnus-treat-display-smileys gnus-treat-smiley
)
1595 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1596 (gnus-treat-wash-html gnus-article-wash-html
)
1597 (gnus-treat-emphasize gnus-article-emphasize
)
1598 (gnus-treat-hide-citation gnus-article-hide-citation
)
1599 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1600 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1601 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)
1602 (gnus-treat-play-sounds gnus-earcon-display
)))
1604 (defvar gnus-article-mime-handle-alist nil
)
1605 (defvar article-lapsed-timer nil
)
1606 (defvar gnus-article-current-summary nil
)
1608 (defvar gnus-article-mode-syntax-table
1609 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1610 ;; This causes the citation match run O(2^n).
1611 ;; (modify-syntax-entry ?- "w" table)
1612 (modify-syntax-entry ?
> ")<" table
)
1613 (modify-syntax-entry ?
< "(>" table
)
1614 ;; make M-. in article buffers work for `foo' strings
1615 (modify-syntax-entry ?
' " " table
)
1616 (modify-syntax-entry ?
` " " table
)
1618 "Syntax table used in article mode buffers.
1619 Initialized from `text-mode-syntax-table.")
1621 (defvar gnus-save-article-buffer nil
)
1623 (defvar gnus-article-mode-line-format-alist
1624 (nconc '((?w
(gnus-article-wash-status) ?s
)
1625 (?m
(gnus-article-mime-part-status) ?s
))
1626 gnus-summary-mode-line-format-alist
))
1628 (defvar gnus-number-of-articles-to-be-saved nil
)
1630 (defvar gnus-inhibit-hiding nil
)
1632 (defvar gnus-article-edit-mode nil
)
1634 ;;; Macros for dealing with the article buffer.
1636 (defmacro gnus-with-article-headers
(&rest forms
)
1638 (set-buffer gnus-article-buffer
)
1640 (let ((inhibit-read-only t
)
1641 (inhibit-point-motion-hooks t
)
1642 (case-fold-search t
))
1643 (article-narrow-to-head)
1646 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1647 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1649 (defmacro gnus-with-article-buffer
(&rest forms
)
1651 (set-buffer gnus-article-buffer
)
1652 (let ((inhibit-read-only t
))
1655 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1656 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1658 (defun gnus-article-goto-header (header)
1659 "Go to HEADER, which is a regular expression."
1660 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1662 (defsubst gnus-article-hide-text
(b e props
)
1663 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1664 (gnus-add-text-properties-when 'article-type nil b e props
)
1665 (when (memq 'intangible props
)
1667 (max (1- b
) (point-min))
1668 b
'intangible
(cddr (memq 'intangible props
)))))
1670 (defsubst gnus-article-unhide-text
(b e
)
1671 "Remove hidden text properties from region between B and E."
1672 (remove-text-properties b e gnus-hidden-properties
)
1673 (when (memq 'intangible gnus-hidden-properties
)
1674 (put-text-property (max (1- b
) (point-min))
1675 b
'intangible nil
)))
1677 (defun gnus-article-hide-text-type (b e type
)
1678 "Hide text of TYPE between B and E."
1679 (gnus-add-wash-type type
)
1680 (gnus-article-hide-text
1681 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1683 (defun gnus-article-unhide-text-type (b e type
)
1684 "Unhide text of TYPE between B and E."
1685 (gnus-delete-wash-type type
)
1686 (remove-text-properties
1687 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1688 (when (memq 'intangible gnus-hidden-properties
)
1689 (put-text-property (max (1- b
) (point-min))
1690 b
'intangible nil
)))
1692 (defun gnus-article-hide-text-of-type (type)
1693 "Hide text of TYPE in the current buffer."
1695 (let ((b (point-min))
1697 (while (setq b
(text-property-any b e
'article-type type
))
1698 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1700 (defun gnus-article-delete-text-of-type (type)
1701 "Delete text of TYPE in the current buffer."
1703 (let ((b (point-min)))
1704 (if (eq type
'multipart
)
1705 ;; Remove MIME buttons associated with multipart/alternative parts.
1708 (while (if (get-text-property (point) 'gnus-part
)
1710 (when (setq b
(next-single-property-change (point)
1715 (skip-chars-forward "\n")
1716 (when (eq (get-text-property b
'article-type
) 'multipart
)
1717 (delete-region b
(point)))))
1718 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1720 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1723 (defun gnus-article-delete-invisible-text ()
1724 "Delete all invisible text in the current buffer."
1726 (let ((b (point-min)))
1727 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1729 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1732 (defun gnus-article-text-type-exists-p (type)
1733 "Say whether any text of type TYPE exists in the buffer."
1734 (text-property-any (point-min) (point-max) 'article-type type
))
1736 (defsubst gnus-article-header-rank
()
1737 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1738 (let ((list gnus-sorted-header-list
)
1741 (if (looking-at (car list
))
1743 (setq list
(cdr list
))
1747 (defun article-hide-headers (&optional arg delete
)
1748 "Hide unwanted headers and possibly sort them as well."
1750 ;; This function might be inhibited.
1751 (unless gnus-inhibit-hiding
1752 (let ((inhibit-read-only nil
)
1753 (case-fold-search t
)
1754 (max (1+ (length gnus-sorted-header-list
)))
1755 (inhibit-point-motion-hooks t
)
1756 (cur (current-buffer))
1757 ignored visible beg
)
1759 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1760 ;; group parameters, so we should go to the summary buffer.
1763 (progn (set-buffer gnus-summary-buffer
) t
)
1765 (setq ignored
(when (not gnus-visible-headers
)
1766 (cond ((stringp gnus-ignored-headers
)
1767 gnus-ignored-headers
)
1768 ((listp gnus-ignored-headers
)
1769 (mapconcat 'identity
1770 gnus-ignored-headers
1772 visible
(cond ((stringp gnus-visible-headers
)
1773 gnus-visible-headers
)
1774 ((and gnus-visible-headers
1775 (listp gnus-visible-headers
))
1776 (mapconcat 'identity
1777 gnus-visible-headers
1781 ;; First we narrow to just the headers.
1782 (article-narrow-to-head)
1783 ;; Hide any "From " lines at the beginning of (mail) articles.
1784 (while (looking-at "From ")
1787 (delete-region (point-min) (point)))
1788 ;; Then treat the rest of the header lines.
1789 ;; Then we use the two regular expressions
1790 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1791 ;; select which header lines is to remain visible in the
1793 (while (re-search-forward "^[^ \t:]*:" nil t
)
1795 ;; Mark the rank of the header.
1797 (point) (1+ (point)) 'message-rank
1798 (if (or (and visible
(looking-at visible
))
1800 (not (looking-at ignored
))))
1801 (gnus-article-header-rank)
1804 (message-sort-headers-1)
1805 (when (setq beg
(text-property-any
1806 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1807 ;; We delete the unwanted headers.
1808 (gnus-add-wash-type 'headers
)
1809 (add-text-properties (point-min) (+ 5 (point-min))
1810 '(article-type headers dummy-invisible t
))
1811 (delete-region beg
(point-max))))))))
1813 (defun article-hide-boring-headers (&optional arg
)
1814 "Toggle hiding of headers that aren't very interesting.
1815 If given a negative prefix, always show; if given a positive prefix,
1817 (interactive (gnus-article-hidden-arg))
1818 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1819 (not gnus-show-all-headers
))
1822 (let ((inhibit-read-only t
)
1823 (list gnus-boring-article-headers
)
1824 (inhibit-point-motion-hooks t
)
1826 (article-narrow-to-head)
1828 (setq elem
(pop list
))
1829 (goto-char (point-min))
1831 ;; Hide empty headers.
1833 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1835 (gnus-article-hide-text-type
1839 (if (re-search-forward "^[^ \t]" nil t
)
1843 ;; Hide boring Newsgroups header.
1844 ((eq elem
'newsgroups
)
1845 (when (gnus-string-equal
1846 (gnus-fetch-field "newsgroups")
1847 (gnus-group-real-name
1848 (if (boundp 'gnus-newsgroup-name
)
1851 (gnus-article-hide-header "newsgroups")))
1852 ((eq elem
'to-address
)
1853 (let ((to (message-fetch-field "to"))
1855 (gnus-parameter-to-address
1856 (if (boundp 'gnus-newsgroup-name
)
1857 gnus-newsgroup-name
""))))
1858 (when (and to to-address
1861 ;; only one address in To
1862 (nth 1 (mail-extract-address-components to
))
1864 (gnus-article-hide-header "to"))))
1866 (let ((to (message-fetch-field "to"))
1868 (gnus-parameter-to-list
1869 (if (boundp 'gnus-newsgroup-name
)
1870 gnus-newsgroup-name
""))))
1871 (when (and to to-list
1874 ;; only one address in To
1875 (nth 1 (mail-extract-address-components to
))
1877 (gnus-article-hide-header "to"))))
1879 (let ((cc (message-fetch-field "cc"))
1881 (gnus-parameter-to-list
1882 (if (boundp 'gnus-newsgroup-name
)
1883 gnus-newsgroup-name
""))))
1884 (when (and cc to-list
1887 ;; only one address in CC
1888 (nth 1 (mail-extract-address-components cc
))
1890 (gnus-article-hide-header "cc"))))
1891 ((eq elem
'followup-to
)
1892 (when (gnus-string-equal
1893 (message-fetch-field "followup-to")
1894 (message-fetch-field "newsgroups"))
1895 (gnus-article-hide-header "followup-to")))
1896 ((eq elem
'reply-to
)
1897 (if (gnus-group-find-parameter
1898 gnus-newsgroup-name
'broken-reply-to
)
1899 (gnus-article-hide-header "reply-to")
1900 (let ((from (message-fetch-field "from"))
1901 (reply-to (message-fetch-field "reply-to")))
1908 (lambda (x) (downcase (cadr x
)))
1909 (mail-extract-address-components from t
))
1912 (lambda (x) (downcase (cadr x
)))
1913 (mail-extract-address-components reply-to t
))
1915 (gnus-article-hide-header "reply-to")))))
1917 (let ((date (message-fetch-field "date")))
1919 (< (days-between (current-time-string) date
)
1921 (gnus-article-hide-header "date"))))
1923 (let ((to (message-fetch-field "to"))
1924 (cc (message-fetch-field "cc")))
1925 (when (> (length to
) 1024)
1926 (gnus-article-hide-header "to"))
1927 (when (> (length cc
) 1024)
1928 (gnus-article-hide-header "cc"))))
1932 (goto-char (point-min))
1933 (while (re-search-forward "^to:" nil t
)
1934 (setq to-count
(1+ to-count
)))
1935 (when (> to-count
1)
1936 (while (> to-count
0)
1937 (goto-char (point-min))
1939 (re-search-forward "^to:" nil nil to-count
)
1941 (narrow-to-region (point) (point-max))
1942 (gnus-article-hide-header "to"))
1943 (setq to-count
(1- to-count
))))
1944 (goto-char (point-min))
1945 (while (re-search-forward "^cc:" nil t
)
1946 (setq cc-count
(1+ cc-count
)))
1947 (when (> cc-count
1)
1948 (while (> cc-count
0)
1949 (goto-char (point-min))
1951 (re-search-forward "^cc:" nil nil cc-count
)
1953 (narrow-to-region (point) (point-max))
1954 (gnus-article-hide-header "cc"))
1955 (setq cc-count
(1- cc-count
)))))))))))))
1957 (defun gnus-article-hide-header (header)
1959 (goto-char (point-min))
1960 (when (re-search-forward (concat "^" header
":") nil t
)
1961 (gnus-article-hide-text-type
1965 (if (re-search-forward "^[^ \t]" nil t
)
1970 (defvar gnus-article-normalized-header-length
40
1971 "Length of normalized headers.")
1973 (defun article-normalize-headers ()
1974 "Make all header lines 40 characters long."
1976 (let ((inhibit-read-only t
)
1980 (article-narrow-to-head)
1983 ((< (setq column
(- (gnus-point-at-eol) (point)))
1984 gnus-article-normalized-header-length
)
1986 (insert (make-string
1987 (- gnus-article-normalized-header-length column
)
1989 ((> column gnus-article-normalized-header-length
)
1990 (gnus-put-text-property
1992 (forward-char gnus-article-normalized-header-length
)
1999 (forward-line 1))))))
2001 (defun article-treat-dumbquotes ()
2002 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2003 Note that this function guesses whether a character is a sm*rtq**t* or
2004 not, so it should only be used interactively.
2006 Sm*rtq**t*s are M****s***'s unilateral extension to the
2007 iso-8859-1 character map in an attempt to provide more quoting
2008 characters. If you see something like \\222 or \\264 where
2009 you're expecting some kind of apostrophe or quotation mark, then
2012 (article-translate-strings gnus-article-dumbquotes-map
))
2014 (defun article-translate-characters (from to
)
2015 "Translate all characters in the body of the article according to FROM and TO.
2016 FROM is a string of characters to translate from; to is a string of
2017 characters to translate to."
2019 (when (article-goto-body)
2020 (let ((inhibit-read-only t
)
2021 (x (make-string 225 ?x
))
2023 (while (< (incf i
) (length x
))
2026 (while (< i
(length from
))
2027 (aset x
(aref from i
) (aref to i
))
2029 (translate-region (point) (point-max) x
)))))
2031 (defun article-translate-strings (map)
2032 "Translate all string in the body of the article according to MAP.
2033 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2035 (when (article-goto-body)
2036 (let ((inhibit-read-only t
)
2038 (while (setq elem
(pop map
))
2040 (while (search-forward (car elem
) nil t
)
2041 (replace-match (cadr elem
)))))))))
2043 (defun article-treat-overstrike ()
2044 "Translate overstrikes into bold text."
2047 (when (article-goto-body)
2048 (let ((inhibit-read-only t
))
2049 (while (search-forward "\b" nil t
)
2050 (let ((next (char-after))
2051 (previous (char-after (- (point) 2))))
2052 ;; We do the boldification/underlining by hiding the
2053 ;; overstrikes and putting the proper text property
2057 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2058 (put-text-property (point) (1+ (point)) 'face
'bold
))
2060 (gnus-article-hide-text-type
2061 (1- (point)) (1+ (point)) 'overstrike
)
2063 (- (point) 2) (1- (point)) 'face
'underline
))
2065 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2067 (point) (1+ (point)) 'face
'underline
)))))))))
2069 (defun gnus-article-treat-unfold-headers ()
2070 "Unfold folded message headers.
2071 Only the headers that fit into the current window width will be
2074 (gnus-with-article-headers
2078 (mail-header-narrow-to-field)
2079 (let ((header (buffer-string)))
2082 (goto-char (point-min))
2083 (while (re-search-forward "\n[\t ]" nil t
)
2084 (replace-match " " t t
)))
2085 (setq length
(- (point-max) (point-min) 1)))
2086 (when (< length
(window-width))
2087 (while (re-search-forward "\n[\t ]" nil t
)
2088 (replace-match " " t t
)))
2089 (goto-char (point-max)))))))
2091 (defun gnus-article-treat-fold-headers ()
2092 "Fold message headers."
2094 (gnus-with-article-headers
2097 (mail-header-narrow-to-field)
2098 (mail-header-fold-field)
2099 (goto-char (point-max))))))
2101 (defun gnus-treat-smiley ()
2102 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2104 (gnus-with-article-buffer
2105 (if (memq 'smiley gnus-article-wash-types
)
2106 (gnus-delete-images 'smiley
)
2108 (let ((images (smiley-region (point) (point-max))))
2110 (gnus-add-wash-type 'smiley
)
2111 (dolist (image images
)
2112 (gnus-add-image 'smiley image
)))))))
2114 (defun gnus-article-remove-images ()
2115 "Remove all images from the article buffer."
2117 (gnus-with-article-buffer
2118 (dolist (elem gnus-article-image-alist
)
2119 (gnus-delete-images (car elem
)))))
2121 (defun gnus-article-treat-fold-newsgroups ()
2122 "Unfold folded message headers.
2123 Only the headers that fit into the current window width will be
2126 (gnus-with-article-headers
2127 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2129 (mail-header-narrow-to-field)
2130 (while (re-search-forward ", *" nil t
)
2131 (replace-match ", " t t
))
2132 (mail-header-fold-field)
2133 (goto-char (point-max))))))
2135 (defun gnus-article-treat-body-boundary ()
2136 "Place a boundary line at the end of the headers."
2138 (when (and gnus-body-boundary-delimiter
2139 (> (length gnus-body-boundary-delimiter
) 0))
2140 (gnus-with-article-headers
2141 (goto-char (point-max))
2142 (let ((start (point)))
2143 (insert "X-Boundary: ")
2144 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2146 (while (>= (1- (window-width)) (length str
))
2147 (setq str
(concat str gnus-body-boundary-delimiter
)))
2148 (substring str
0 (1- (window-width))))
2150 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2152 (defun article-fill-long-lines ()
2153 "Fill lines that are wider than the window width."
2156 (let ((inhibit-read-only t
)
2157 (width (window-width (get-buffer-window (current-buffer)))))
2160 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2163 (when (>= (current-column) (min fill-column width
))
2164 (narrow-to-region (min (1+ (point)) (point-max))
2165 (gnus-point-at-bol))
2166 (let ((goback (point-marker)))
2167 (fill-paragraph nil
)
2168 (goto-char (marker-position goback
)))
2170 (forward-line 1)))))))
2172 (defun article-capitalize-sentences ()
2173 "Capitalize the first word in each sentence."
2176 (let ((inhibit-read-only t
)
2177 (paragraph-start "^[\n\^L]"))
2181 (forward-sentence)))))
2183 (defun article-remove-cr ()
2184 "Remove trailing CRs and then translate remaining CRs into LFs."
2187 (let ((inhibit-read-only t
))
2188 (goto-char (point-min))
2189 (while (re-search-forward "\r+$" nil t
)
2190 (replace-match "" t t
))
2191 (goto-char (point-min))
2192 (while (search-forward "\r" nil t
)
2193 (replace-match "\n" t t
)))))
2195 (defun article-remove-trailing-blank-lines ()
2196 "Remove all trailing blank lines from the article."
2199 (let ((inhibit-read-only t
))
2200 (goto-char (point-max))
2204 (while (and (not (bobp))
2205 (looking-at "^[ \t]*$")
2206 (not (gnus-annotation-in-region-p
2207 (point) (gnus-point-at-eol))))
2212 (defun article-display-face ()
2213 "Display any Face headers in the header."
2215 (let ((wash-face-p buffer-read-only
))
2216 (gnus-with-article-headers
2217 ;; When displaying parts, this function can be called several times on
2218 ;; the same article, without any intended toggle semantic (as typing `W
2219 ;; D d' would have). So face deletion must occur only when we come from
2220 ;; an interactive command, that is when the *Article* buffer is
2222 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2223 (gnus-delete-images 'face
)
2224 (let (face faces from
)
2225 (save-current-buffer
2226 (when (and wash-face-p
2227 (gnus-buffer-live-p gnus-original-article-buffer
)
2228 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2229 (set-buffer gnus-original-article-buffer
))
2231 (mail-narrow-to-head)
2232 (while (gnus-article-goto-header "Face")
2233 (push (mail-header-field-value) faces
))))
2235 (goto-char (point-min))
2236 (let ((from (gnus-article-goto-header "from"))
2241 (insert "[no `from' set]\n"))
2243 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2244 (setq image
(gnus-create-image png
'png t
))
2246 (gnus-add-wash-type 'face
)
2247 (gnus-add-image 'face image
)
2248 (gnus-put-image image nil
'face
))))))))))
2250 (defun article-display-x-face (&optional force
)
2251 "Look for an X-Face header and display it if present."
2252 (interactive (list 'force
))
2253 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2254 (gnus-with-article-headers
2255 ;; Delete the old process, if any.
2256 (when (process-status "article-x-face")
2257 (delete-process "article-x-face"))
2258 ;; See the comment in `article-display-face'.
2259 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2260 ;; We have already displayed X-Faces, so we remove them
2262 (gnus-delete-images 'xface
)
2264 (let (x-faces from face
)
2265 (save-current-buffer
2266 (when (and wash-face-p
2267 (gnus-buffer-live-p gnus-original-article-buffer
)
2268 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2269 ;; If type `W f', use gnus-original-article-buffer,
2270 ;; otherwise use the current buffer because displaying
2271 ;; RFC822 parts calls this function too.
2272 (set-buffer gnus-original-article-buffer
))
2274 (mail-narrow-to-head)
2275 (while (gnus-article-goto-header "X-Face")
2276 (push (mail-header-field-value) x-faces
))
2277 (setq from
(message-fetch-field "from"))))
2278 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2279 ;; single external face.
2280 (when (stringp gnus-article-x-face-command
)
2281 (setq x-faces
(list (car x-faces
))))
2283 gnus-article-x-face-command
2285 ;; Check whether this face is censored.
2286 (not gnus-article-x-face-too-ugly
)
2288 (not (string-match gnus-article-x-face-too-ugly
2290 (while (setq face
(pop x-faces
))
2291 ;; We display the face.
2292 (cond ((stringp gnus-article-x-face-command
)
2293 ;; The command is a string, so we interpret the command
2294 ;; as a, well, command, and fork it off.
2295 (let ((process-connection-type nil
))
2296 (gnus-set-process-query-on-exit-flag
2298 "article-x-face" nil shell-file-name
2299 shell-command-switch gnus-article-x-face-command
)
2303 (process-send-region "article-x-face"
2304 (point-min) (point-max)))
2305 (process-send-eof "article-x-face")))
2306 ((functionp gnus-article-x-face-command
)
2307 ;; The command is a lisp function, so we call it.
2308 (funcall gnus-article-x-face-command face
))
2310 (error "%s is not a function"
2311 gnus-article-x-face-command
))))))))))
2313 (defun article-decode-mime-words ()
2314 "Decode all MIME-encoded words in the article."
2317 (set-buffer gnus-article-buffer
)
2318 (let ((inhibit-point-motion-hooks t
)
2319 (inhibit-read-only t
)
2320 (mail-parse-charset gnus-newsgroup-charset
)
2321 (mail-parse-ignored-charsets
2322 (save-excursion (set-buffer gnus-summary-buffer
)
2323 gnus-newsgroup-ignored-charsets
)))
2324 (mail-decode-encoded-word-region (point-min) (point-max)))))
2326 (defun article-decode-charset (&optional prompt
)
2327 "Decode charset-encoded text in the article.
2328 If PROMPT (the prefix), prompt for a coding system to use."
2330 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2331 (inhibit-read-only t
)
2332 (mail-parse-charset gnus-newsgroup-charset
)
2333 (mail-parse-ignored-charsets
2334 (save-excursion (condition-case nil
2335 (set-buffer gnus-summary-buffer
)
2337 gnus-newsgroup-ignored-charsets
))
2338 ct cte ctl charset format
)
2341 (article-narrow-to-head)
2342 (setq ct
(message-fetch-field "Content-Type" t
)
2343 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2344 ctl
(and ct
(mail-header-parse-content-type ct
))
2347 (mm-read-coding-system "Charset to decode: "))
2349 (mail-content-type-get ctl
'charset
)))
2350 format
(and ctl
(mail-content-type-get ctl
'format
)))
2352 (setq cte
(mail-header-strip cte
)))
2353 (if (and ctl
(not (string-match "/" (car ctl
))))
2355 (goto-char (point-max)))
2358 (narrow-to-region (point) (point-max))
2359 (when (and (eq mail-parse-charset
'gnus-decoded
)
2360 (eq (mm-body-7-or-8) '8bit
))
2361 ;; The text code could have been decoded.
2362 (setq charset mail-parse-charset
))
2363 (when (and (or (not ctl
)
2364 (equal (car ctl
) "text/plain"))
2365 (not format
)) ;; article with format will decode later.
2367 charset
(and cte
(intern (downcase
2368 (gnus-strip-whitespace cte
))))
2371 (defun article-decode-encoded-words ()
2372 "Remove encoded-word encoding from headers."
2373 (let ((inhibit-point-motion-hooks t
)
2374 (mail-parse-charset gnus-newsgroup-charset
)
2375 (mail-parse-ignored-charsets
2376 (save-excursion (condition-case nil
2377 (set-buffer gnus-summary-buffer
)
2379 gnus-newsgroup-ignored-charsets
))
2380 (inhibit-read-only t
))
2382 (article-narrow-to-head)
2383 (funcall gnus-decode-header-function
(point-min) (point-max)))))
2385 (defun article-decode-group-name ()
2386 "Decode group names in `Newsgroups:'."
2387 (let ((inhibit-point-motion-hooks t
)
2388 (inhibit-read-only t
)
2389 (method (gnus-find-method-for-group gnus-newsgroup-name
)))
2390 (when (and (or gnus-group-name-charset-method-alist
2391 gnus-group-name-charset-group-alist
)
2392 (gnus-buffer-live-p gnus-original-article-buffer
))
2394 (article-narrow-to-head)
2395 (with-current-buffer gnus-original-article-buffer
2396 (goto-char (point-min)))
2397 (while (re-search-forward
2398 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2399 (replace-match (save-match-data
2400 (gnus-decode-newsgroups
2401 ;; XXX how to use data in article buffer?
2402 (with-current-buffer gnus-original-article-buffer
2404 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2407 gnus-newsgroup-name method
))
2409 (goto-char (point-min))
2410 (with-current-buffer gnus-original-article-buffer
2411 (goto-char (point-min)))
2412 (while (re-search-forward
2413 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t
)
2414 (replace-match (save-match-data
2415 (gnus-decode-newsgroups
2416 ;; XXX how to use data in article buffer?
2417 (with-current-buffer gnus-original-article-buffer
2419 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2422 gnus-newsgroup-name method
))
2425 (autoload 'idna-to-unicode
"idna")
2427 (defun article-decode-idna-rhs ()
2428 "Decode IDNA strings in RHS in various headers in current buffer.
2429 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2430 Mail-Reply-To: and Mail-Followup-To:."
2433 (let ((inhibit-point-motion-hooks t
)
2434 (inhibit-read-only t
))
2435 (article-narrow-to-head)
2436 (goto-char (point-min))
2437 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2439 (when (save-match-data
2440 (and (setq ace
(match-string 1))
2442 (and (re-search-backward "^[^ \t]" nil t
)
2443 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2444 (setq unicode
(idna-to-unicode ace
))))
2445 (unless (string= ace unicode
)
2446 (replace-match unicode nil nil nil
1)))))))))
2448 (defun article-de-quoted-unreadable (&optional force read-charset
)
2449 "Translate a quoted-printable-encoded article.
2450 If FORCE, decode the article whether it is marked as quoted-printable
2452 If READ-CHARSET, ask for a coding system."
2453 (interactive (list 'force current-prefix-arg
))
2455 (let ((inhibit-read-only t
) type charset
)
2456 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2457 (with-current-buffer gnus-original-article-buffer
2459 (gnus-fetch-field "content-transfer-encoding"))
2460 (let* ((ct (gnus-fetch-field "content-type"))
2461 (ctl (and ct
(mail-header-parse-content-type ct
))))
2462 (setq charset
(and ctl
2463 (mail-content-type-get ctl
'charset
)))
2464 (if (stringp charset
)
2465 (setq charset
(intern (downcase charset
)))))))
2467 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2469 (setq charset gnus-newsgroup-charset
))
2471 (and type
(let ((case-fold-search t
))
2472 (string-match "quoted-printable" type
))))
2474 (quoted-printable-decode-region
2475 (point) (point-max) (mm-charset-to-coding-system charset
))))))
2477 (defun article-de-base64-unreadable (&optional force read-charset
)
2478 "Translate a base64 article.
2479 If FORCE, decode the article whether it is marked as base64 not.
2480 If READ-CHARSET, ask for a coding system."
2481 (interactive (list 'force current-prefix-arg
))
2483 (let ((inhibit-read-only t
) type charset
)
2484 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2485 (with-current-buffer gnus-original-article-buffer
2487 (gnus-fetch-field "content-transfer-encoding"))
2488 (let* ((ct (gnus-fetch-field "content-type"))
2489 (ctl (and ct
(mail-header-parse-content-type ct
))))
2490 (setq charset
(and ctl
2491 (mail-content-type-get ctl
'charset
)))
2492 (if (stringp charset
)
2493 (setq charset
(intern (downcase charset
)))))))
2495 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2497 (setq charset gnus-newsgroup-charset
))
2499 (and type
(let ((case-fold-search t
))
2500 (string-match "base64" type
))))
2503 (narrow-to-region (point) (point-max))
2504 (base64-decode-region (point-min) (point-max))
2505 (mm-decode-coding-region
2506 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
2511 (defun article-decode-HZ ()
2512 "Translate a HZ-encoded article."
2516 (let ((inhibit-read-only t
))
2517 (rfc1843-decode-region (point-min) (point-max)))))
2519 (defun article-unsplit-urls ()
2520 "Remove the newlines that some other mailers insert into URLs."
2523 (let ((inhibit-read-only t
))
2524 (goto-char (point-min))
2525 (while (re-search-forward
2526 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2527 (replace-match "\\1\\3" t
)))
2528 (when (interactive-p)
2529 (gnus-treat-article nil
))))
2532 (defun article-wash-html (&optional read-charset
)
2533 "Format an HTML article.
2534 If READ-CHARSET, ask for a coding system. If it is a number, the
2535 charset defined in `gnus-summary-show-article-charset-alist' is used."
2538 (let ((inhibit-read-only t
)
2541 (if (or (and (numberp read-charset
)
2545 gnus-summary-show-article-charset-alist
))))
2546 (setq charset
(mm-read-coding-system "Charset: ")))
2547 (let ((gnus-summary-show-article-charset-alist
2548 (list (cons 1 charset
))))
2549 (with-current-buffer gnus-summary-buffer
2550 (gnus-summary-show-article 1)))
2551 (error "No charset is given"))
2552 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2553 (with-current-buffer gnus-original-article-buffer
2554 (let* ((ct (gnus-fetch-field "content-type"))
2555 (ctl (and ct
(mail-header-parse-content-type ct
))))
2556 (setq charset
(and ctl
2557 (mail-content-type-get ctl
'charset
)))
2558 (when (stringp charset
)
2559 (setq charset
(intern (downcase charset
)))))))
2561 (setq charset gnus-newsgroup-charset
)))
2563 (save-window-excursion
2565 (narrow-to-region (point) (point-max))
2566 (let* ((func (or gnus-article-wash-function mm-text-html-renderer
))
2567 (entry (assq func mm-text-html-washer-alist
)))
2569 (setq func
(cdr entry
)))
2574 (apply (car func
) (cdr func
))))))))))
2576 (defun gnus-article-wash-html-with-w3 ()
2577 "Wash the current buffer with w3."
2579 (let ((w3-strict-width (window-width))
2580 (url-standalone-mode t
)
2581 (url-gateway-unplugged t
)
2582 (w3-honor-stylesheets nil
))
2584 (w3-region (point-min) (point-max))
2587 (defun gnus-article-wash-html-with-w3m ()
2588 "Wash the current buffer with emacs-w3m."
2590 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp
)
2591 w3m-force-redisplay
)
2592 (w3m-region (point-min) (point-max)))
2593 (when (and mm-inline-text-html-with-w3m-keymap
2594 (boundp 'w3m-minor-mode-map
)
2596 (add-text-properties
2597 (point-min) (point-max)
2598 (list 'keymap w3m-minor-mode-map
2599 ;; Put the mark meaning this part was rendered by emacs-w3m.
2600 'mm-inline-text-html-with-w3m t
))))
2602 (eval-when-compile (defvar charset
)) ;; Bound by `article-wash-html'.
2604 (defun gnus-article-wash-html-with-w3m-standalone ()
2605 "Wash the current buffer with w3m."
2606 (if (mm-w3m-standalone-supports-m17n-p)
2608 (unless (mm-coding-system-p charset
) ;; Bound by `article-wash-html'.
2610 (setq charset
'iso-8859-1
))
2611 (let ((coding-system-for-write charset
)
2612 (coding-system-for-read charset
))
2613 (call-process-region
2614 (point-min) (point-max)
2615 "w3m" t t nil
"-dump" "-T" "text/html"
2616 "-I" (symbol-name charset
) "-O" (symbol-name charset
))))
2617 (mm-inline-wash-with-stdin nil
"w3m" "-dump" "-T" "text/html")))
2619 (defun article-hide-list-identifiers ()
2620 "Remove list identifies from the Subject header.
2621 The `gnus-list-identifiers' variable specifies what to do."
2623 (let ((inhibit-point-motion-hooks t
)
2624 (regexp (if (consp gnus-list-identifiers
)
2625 (mapconcat 'identity gnus-list-identifiers
" *\\|")
2626 gnus-list-identifiers
))
2627 (inhibit-read-only t
))
2631 (article-narrow-to-head)
2632 (goto-char (point-min))
2633 (while (re-search-forward
2634 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
2636 (delete-region (match-beginning 2) (match-end 0))
2637 (beginning-of-line))
2638 (when (re-search-forward
2639 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
2640 (delete-region (match-beginning 1) (match-end 1))))))))
2642 (defun article-hide-pem (&optional arg
)
2643 "Toggle hiding of any PEM headers and signatures in the current article.
2644 If given a negative prefix, always show; if given a positive prefix,
2646 (interactive (gnus-article-hidden-arg))
2647 (unless (gnus-article-check-hidden-text 'pem arg
)
2649 (let ((inhibit-read-only t
) end
)
2650 (goto-char (point-min))
2651 ;; Hide the horrendously ugly "header".
2652 (when (and (search-forward
2653 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2655 (setq end
(1+ (match-beginning 0))))
2656 (gnus-add-wash-type 'pem
)
2657 (gnus-article-hide-text-type
2659 (if (search-forward "\n\n" nil t
)
2663 ;; Hide the trailer as well
2664 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2666 (gnus-article-hide-text-type
2667 (match-beginning 0) (match-end 0) 'pem
)))))))
2669 (defun article-strip-banner ()
2670 "Strip the banners specified by the `banner' group parameter and by
2671 `gnus-article-address-banner-alist'."
2675 (let ((inhibit-point-motion-hooks t
))
2676 (when (gnus-parameter-banner gnus-newsgroup-name
)
2677 (article-really-strip-banner
2678 (gnus-parameter-banner gnus-newsgroup-name
)))
2679 (when gnus-article-address-banner-alist
2680 ;; Note that the From header is decoded here, so it is
2681 ;; required that the *-extract-address-components function
2682 ;; supports non-ASCII text.
2683 (let ((from (save-restriction
2685 (article-narrow-to-head)
2686 (mail-fetch-field "from"))))
2689 (cadr (funcall gnus-extract-address-components
2692 (dolist (pair gnus-article-address-banner-alist
)
2693 (when (string-match (car pair
) from
)
2695 (article-really-strip-banner (cdr pair
)))))))))))))
2697 (defun article-really-strip-banner (banner)
2698 "Strip the banner specified by the argument."
2701 (let ((inhibit-point-motion-hooks t
)
2702 (gnus-signature-limit nil
)
2703 (inhibit-read-only t
))
2706 ((eq banner
'signature
)
2707 (when (gnus-article-narrow-to-signature)
2710 (delete-region (point) (point-max))))
2712 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
2713 (while (re-search-forward banner nil t
)
2714 (delete-region (match-beginning 0) (match-end 0)))))
2716 (while (re-search-forward banner nil t
)
2717 (delete-region (match-beginning 0) (match-end 0)))))))))
2719 (defun article-babel ()
2720 "Translate article using an online translation service."
2724 (set-buffer gnus-article-buffer
)
2725 (when (article-goto-body)
2726 (let* ((inhibit-read-only t
)
2729 (orig (buffer-substring start end
))
2730 (trans (babel-as-string orig
)))
2732 (narrow-to-region start end
)
2733 (delete-region start end
)
2736 (defun article-hide-signature (&optional arg
)
2737 "Hide the signature in the current article.
2738 If given a negative prefix, always show; if given a positive prefix,
2740 (interactive (gnus-article-hidden-arg))
2741 (unless (gnus-article-check-hidden-text 'signature arg
)
2744 (let ((inhibit-read-only t
))
2745 (when (gnus-article-narrow-to-signature)
2746 (gnus-article-hide-text-type
2747 (point-min) (point-max) 'signature
))))))
2748 (gnus-set-mode-line 'article
))
2750 (defun article-strip-headers-in-body ()
2751 "Strip offensive headers from bodies."
2755 (let ((case-fold-search t
))
2756 (when (looking-at "x-no-archive:")
2757 (gnus-delete-line)))))
2759 (defun article-strip-leading-blank-lines ()
2760 "Remove all blank lines from the beginning of the article."
2763 (let ((inhibit-point-motion-hooks t
)
2764 (inhibit-read-only t
))
2765 (when (article-goto-body)
2766 (while (and (not (eobp))
2767 (looking-at "[ \t]*$"))
2768 (gnus-delete-line))))))
2770 (defun article-narrow-to-head ()
2771 "Narrow the buffer to the head of the message.
2772 Point is left at the beginning of the narrowed-to region."
2774 (goto-char (point-min))
2775 (if (search-forward "\n\n" nil
1)
2778 (goto-char (point-min)))
2780 (defun article-goto-body ()
2781 "Place point at the start of the body."
2782 (goto-char (point-min))
2784 ;; This variable is only bound when dealing with separate
2786 (article-goto-body-goes-to-point-min-p
2788 ((search-forward "\n\n" nil t
)
2791 (goto-char (point-max))
2794 (defun article-strip-multiple-blank-lines ()
2795 "Replace consecutive blank lines with one empty line."
2798 (let ((inhibit-point-motion-hooks t
)
2799 (inhibit-read-only t
))
2800 ;; First make all blank lines empty.
2802 (while (re-search-forward "^[ \t]+$" nil t
)
2803 (unless (gnus-annotation-in-region-p
2804 (match-beginning 0) (match-end 0))
2805 (replace-match "" nil t
)))
2806 ;; Then replace multiple empty lines with a single empty line.
2808 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
2809 (unless (gnus-annotation-in-region-p
2810 (match-beginning 0) (match-end 0))
2811 (delete-region (match-beginning 1) (match-end 1)))))))
2813 (defun article-strip-leading-space ()
2814 "Remove all white space from the beginning of the lines in the article."
2817 (let ((inhibit-point-motion-hooks t
)
2818 (inhibit-read-only t
))
2820 (while (re-search-forward "^[ \t]+" nil t
)
2821 (replace-match "" t t
)))))
2823 (defun article-strip-trailing-space ()
2824 "Remove all white space from the end of the lines in the article."
2827 (let ((inhibit-point-motion-hooks t
)
2828 (inhibit-read-only t
))
2830 (while (re-search-forward "[ \t]+$" nil t
)
2831 (replace-match "" t t
)))))
2833 (defun article-strip-blank-lines ()
2834 "Strip leading, trailing and multiple blank lines."
2836 (article-strip-leading-blank-lines)
2837 (article-remove-trailing-blank-lines)
2838 (article-strip-multiple-blank-lines))
2840 (defun article-strip-all-blank-lines ()
2841 "Strip all blank lines."
2844 (let ((inhibit-point-motion-hooks t
)
2845 (inhibit-read-only t
))
2847 (while (re-search-forward "^[ \t]*\n" nil t
)
2848 (replace-match "" t t
)))))
2850 (defun gnus-article-narrow-to-signature ()
2851 "Narrow to the signature; return t if a signature is found, else nil."
2852 (let ((inhibit-point-motion-hooks t
))
2853 (when (gnus-article-search-signature)
2855 ;; Check whether we have some limits to what we consider
2856 ;; to be a signature.
2857 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
2858 (list gnus-signature-limit
)))
2860 (while (setq limit
(pop limits
))
2861 (if (or (and (integerp limit
)
2862 (< (- (point-max) (point)) limit
))
2864 (< (count-lines (point) (point-max)) limit
))
2865 (and (functionp limit
)
2867 (and (stringp limit
)
2868 (not (re-search-forward limit nil t
))))
2869 () ; This limit did not succeed.
2873 (narrow-to-region (point) (point-max))
2876 (defun gnus-article-search-signature ()
2877 "Search the current buffer for the signature separator.
2878 Put point at the beginning of the signature separator."
2879 (let ((cur (point)))
2880 (goto-char (point-max))
2881 (if (if (stringp gnus-signature-separator
)
2882 (re-search-backward gnus-signature-separator nil t
)
2883 (let ((seps gnus-signature-separator
))
2885 (not (re-search-backward (car seps
) nil t
)))
2892 (defun gnus-article-hidden-arg ()
2893 "Return the current prefix arg as a number, or 0 if no prefix."
2894 (list (if current-prefix-arg
2895 (prefix-numeric-value current-prefix-arg
)
2898 (defun gnus-article-check-hidden-text (type arg
)
2899 "Return nil if hiding is necessary.
2900 Arg can be nil or a number. nil and positive means hide, negative
2901 means show, 0 means toggle."
2904 (let ((hide (gnus-article-hidden-text-p type
)))
2910 (gnus-article-show-hidden-text type
)
2913 (if (eq hide
'hidden
)
2915 (gnus-article-show-hidden-text type
)
2919 (defun gnus-article-hidden-text-p (type)
2920 "Say whether the current buffer contains hidden text of type TYPE."
2921 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
2923 (not (get-text-property pos
'invisible
))
2924 (not (get-text-property pos
'dummy-invisible
)))
2926 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
2931 (defun gnus-article-show-hidden-text (type &optional dummy
)
2932 "Show all hidden text of type TYPE.
2933 Originally it is hide instead of DUMMY."
2934 (let ((inhibit-read-only t
)
2935 (inhibit-point-motion-hooks t
))
2936 (gnus-remove-text-properties-when
2938 (point-min) (point-max)
2939 (cons 'article-type
(cons type
2940 gnus-hidden-properties
)))
2941 (gnus-delete-wash-type type
)))
2943 (defconst article-time-units
2944 `((year .
,(* 365.25 24 60 60))
2945 (week .
,(* 7 24 60 60))
2946 (day .
,(* 24 60 60))
2950 "Mapping from time units to seconds.")
2952 (defun gnus-article-forward-header ()
2953 "Move point to the start of the next header.
2954 If the current header is a continuation header, this can be several
2959 (if (looking-at "[ \t]+[^ \t]")
2963 (defun article-date-ut (&optional type highlight
)
2964 "Convert DATE date to universal time in the current article.
2965 If TYPE is `local', convert to local time; if it is `lapsed', output
2966 how much time has lapsed since DATE. For `lapsed', the value of
2967 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2968 should replace the \"Date:\" one, or should be added below it."
2969 (interactive (list 'ut t
))
2970 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2971 (date-regexp (cond ((not gnus-article-date-lapsed-new-header
)
2975 (article-lapsed-timer
2979 (case-fold-search t
)
2980 (inhibit-read-only t
)
2981 (inhibit-point-motion-hooks t
)
2982 pos date bface eface
)
2986 (goto-char (point-min))
2987 (while (or (setq date
(get-text-property (setq pos
(point))
2989 (when (setq pos
(next-single-property-change
2990 (point) 'original-date
))
2991 (setq date
(get-text-property pos
'original-date
))
2993 (narrow-to-region pos
(or (text-property-any pos
(point-max)
2996 (goto-char (point-min))
2997 (when (re-search-forward tdate-regexp nil t
)
2998 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
2999 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
)))
3000 (goto-char (point-min))
3002 ;; Delete any old Date headers.
3003 (while (re-search-forward date-regexp nil t
)
3005 (delete-region (gnus-point-at-bol)
3007 (gnus-article-forward-header)
3009 (delete-region (gnus-point-at-bol)
3011 (gnus-article-forward-header)
3014 (setq pos
(point))))
3015 (when (and (not pos
)
3016 (re-search-forward tdate-regexp nil t
))
3018 (gnus-goto-char pos
)
3019 (insert (article-make-date-line date
(or type
'ut
)))
3025 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3026 (put-text-property (match-beginning 1) (1+ (match-end 1))
3028 (put-text-property (match-beginning 2) (match-end 2)
3030 (put-text-property (point-min) (1- (point-max)) 'original-date date
)
3031 (goto-char (point-max))
3034 (defun article-make-date-line (date type
)
3035 "Return a DATE line of TYPE."
3036 (unless (memq type
'(local ut original user iso8601 lapsed english
))
3037 (error "Unknown conversion type: %s" type
))
3039 (let ((time (date-to-time date
)))
3041 ;; Convert to the local timezone.
3043 (let ((tz (car (current-time-zone time
))))
3044 (format "Date: %s %s%02d%02d" (current-time-string time
)
3045 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3046 (/ (%
(abs tz
) 3600) 60))))
3047 ;; Convert to Universal Time.
3050 (current-time-string
3051 (let* ((e (parse-time-string date
))
3052 (tm (apply 'encode-time e
))
3054 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3055 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3056 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3059 ;; Get the original date from the article.
3060 ((eq type
'original
)
3061 (concat "Date: " (if (string-match "\n+$" date
)
3062 (substring date
0 (match-beginning 0))
3064 ;; Let the user define the format.
3066 (let ((format (or (condition-case nil
3067 (with-current-buffer gnus-summary-buffer
3068 gnus-article-time-format
)
3070 gnus-article-time-format
)))
3071 (if (functionp format
)
3072 (funcall format time
)
3073 (concat "Date: " (format-time-string format time
)))))
3076 (let ((tz (car (current-time-zone time
))))
3079 (format-time-string "%Y%m%dT%H%M%S" time
)
3080 (format "%s%02d%02d"
3081 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3082 (/ (%
(abs tz
) 3600) 60)))))
3083 ;; Do an X-Sent lapsed format.
3085 ;; If the date is seriously mangled, the timezone functions are
3086 ;; liable to bug out, so we ignore all errors.
3087 (let* ((now (current-time))
3088 (real-time (subtract-time now time
))
3089 (real-sec (and real-time
3090 (+ (* (float (car real-time
)) 65536)
3092 (sec (and real-time
(abs real-sec
)))
3102 ;; This is a bit convoluted, but basically we go
3103 ;; through the time units for years, weeks, etc,
3104 ;; and divide things to see whether that results
3105 ;; in positive answers.
3108 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3109 ;; The (remaining) seconds are too few to
3110 ;; be divided into this time unit.
3112 ;; It's big enough, so we output it.
3113 (setq sec
(- sec
(* num
(cdr unit
))))
3115 (concat (if prev
", " "") (int-to-string
3117 " " (symbol-name (car unit
))
3118 (if (> num
1) "s" ""))
3120 article-time-units
"")
3121 ;; If dates are odd, then it might appear like the
3122 ;; article was sent in the future.
3125 " in the future"))))))
3126 ;; Display the date in proper English
3128 (let ((dtime (decode-time time
)))
3131 (number-to-string (nth 3 dtime
))
3132 (let ((digit (%
(nth 3 dtime
) 10)))
3134 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3140 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3142 (number-to-string (nth 5 dtime
))
3144 (format "%02d" (nth 2 dtime
))
3146 (format "%02d" (nth 1 dtime
)))))))
3148 (format "Date: %s (from Gnus)" date
))))
3150 (defun article-date-local (&optional highlight
)
3151 "Convert the current article date to the local timezone."
3152 (interactive (list t
))
3153 (article-date-ut 'local highlight
))
3155 (defun article-date-english (&optional highlight
)
3156 "Convert the current article date to something that is proper English."
3157 (interactive (list t
))
3158 (article-date-ut 'english highlight
))
3160 (defun article-date-original (&optional highlight
)
3161 "Convert the current article date to what it was originally.
3162 This is only useful if you have used some other date conversion
3163 function and want to see what the date was before converting."
3164 (interactive (list t
))
3165 (article-date-ut 'original highlight
))
3167 (defun article-date-lapsed (&optional highlight
)
3168 "Convert the current article date to time lapsed since it was sent."
3169 (interactive (list t
))
3170 (article-date-ut 'lapsed highlight
))
3172 (defun article-update-date-lapsed ()
3173 "Function to be run from a timer to update the lapsed time line."
3175 (let (deactivate-mark)
3180 (set-buffer (window-buffer w
))
3181 (when (eq major-mode
'gnus-article-mode
)
3182 (let ((mark (point-marker)))
3183 (goto-char (point-min))
3184 (when (re-search-forward "^X-Sent:" nil t
)
3185 (article-date-lapsed t
))
3186 (goto-char (marker-position mark
))
3187 (move-marker mark nil
))))
3190 (defun gnus-start-date-timer (&optional n
)
3191 "Start a timer to update the X-Sent header in the article buffers.
3192 The numerical prefix says how frequently (in seconds) the function
3197 (gnus-stop-date-timer)
3198 (setq article-lapsed-timer
3199 (nnheader-run-at-time 1 n
'article-update-date-lapsed
)))
3201 (defun gnus-stop-date-timer ()
3202 "Stop the X-Sent timer."
3204 (when article-lapsed-timer
3205 (nnheader-cancel-timer article-lapsed-timer
)
3206 (setq article-lapsed-timer nil
)))
3208 (defun article-date-user (&optional highlight
)
3209 "Convert the current article date to the user-defined format.
3210 This format is defined by the `gnus-article-time-format' variable."
3211 (interactive (list t
))
3212 (article-date-ut 'user highlight
))
3214 (defun article-date-iso8601 (&optional highlight
)
3215 "Convert the current article date to ISO8601."
3216 (interactive (list t
))
3217 (article-date-ut 'iso8601 highlight
))
3219 (defmacro gnus-article-save-original-date
(&rest forms
)
3220 "Save the original date as a text property and evaluate FORMS."
3221 `(let* ((case-fold-search t
)
3223 (goto-char (point-min))
3224 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3227 (date (when (and start
3228 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3230 (buffer-substring-no-properties start
3231 (match-beginning 0)))))
3232 (goto-char (point-max))
3233 (skip-chars-backward "\n")
3234 (put-text-property (point-min) (point) 'original-date date
)
3236 (goto-char (point-max))
3237 (skip-chars-backward "\n")
3238 (put-text-property (point-min) (point) 'original-date date
)))
3240 ;; (defun article-show-all ()
3241 ;; "Show all hidden text in the article buffer."
3244 ;; (let ((inhibit-read-only t))
3245 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3247 (defun article-remove-leading-whitespace ()
3248 "Remove excessive whitespace from all headers."
3252 (let ((inhibit-read-only t
))
3253 (article-narrow-to-head)
3254 (goto-char (point-min))
3255 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3256 (delete-region (match-beginning 1) (match-end 1)))))))
3258 (defun article-emphasize (&optional arg
)
3259 "Emphasize text according to `gnus-emphasis-alist'."
3260 (interactive (gnus-article-hidden-arg))
3261 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3265 (with-current-buffer gnus-summary-buffer
3266 gnus-article-emphasis-alist
)
3268 gnus-emphasis-alist
))
3269 (inhibit-read-only t
)
3270 (props (append '(article-type emphasis
)
3271 gnus-hidden-properties
))
3272 regexp elem beg invisible visible face
)
3275 (while (setq elem
(pop alist
))
3277 (setq regexp
(car elem
)
3278 invisible
(nth 1 elem
)
3279 visible
(nth 2 elem
)
3281 (while (re-search-forward regexp nil t
)
3282 (when (and (match-beginning visible
) (match-beginning invisible
))
3283 (gnus-article-hide-text
3284 (match-beginning invisible
) (match-end invisible
) props
)
3285 (gnus-article-unhide-text-type
3286 (match-beginning visible
) (match-end visible
) 'emphasis
)
3287 (gnus-put-overlay-excluding-newlines
3288 (match-beginning visible
) (match-end visible
) 'face face
)
3289 (gnus-add-wash-type 'emphasis
)
3290 (goto-char (match-end invisible
)))))))))
3292 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3293 "Setup newsgroup emphasis alist."
3294 (unless gnus-article-emphasis-alist
3295 (let ((name (and gnus-newsgroup-name
3296 (gnus-group-real-name gnus-newsgroup-name
))))
3297 (make-local-variable 'gnus-article-emphasis-alist
)
3298 (setq gnus-article-emphasis-alist
3300 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3301 (while (setq elem
(pop alist
))
3302 (when (and name
(string-match (car elem
) name
))
3304 highlight
(copy-sequence (cdr elem
)))))
3306 (copy-sequence highlight-words
)
3307 (if gnus-newsgroup-name
3308 (copy-sequence (gnus-group-find-parameter
3309 gnus-newsgroup-name
'highlight-words t
)))
3310 gnus-emphasis-alist
)))))
3313 (defvar gnus-summary-article-menu
)
3314 (defvar gnus-summary-post-menu
))
3316 ;;; Saving functions.
3318 (defun gnus-article-save (save-buffer file
&optional num
)
3319 "Save the currently selected article."
3320 (when (or (get gnus-default-article-saver
:headers
)
3321 (not gnus-save-all-headers
))
3322 ;; Remove headers according to `gnus-saved-headers' or the value
3323 ;; of the `:headers' property that the saver function might have.
3324 (let ((gnus-visible-headers
3325 (or (symbol-value (get gnus-default-article-saver
:headers
))
3326 gnus-saved-headers gnus-visible-headers
))
3327 (gnus-article-buffer save-buffer
))
3329 (set-buffer save-buffer
)
3330 (article-hide-headers 1 t
))))
3331 (save-window-excursion
3332 (if (not gnus-default-article-saver
)
3333 (error "No default saver is defined")
3334 ;; !!! Magic! The saving functions all save
3335 ;; `gnus-save-article-buffer' (or so they think), but we
3336 ;; bind that variable to our save-buffer.
3337 (set-buffer gnus-article-buffer
)
3338 (let* ((gnus-save-article-buffer save-buffer
)
3341 ((not gnus-prompt-before-saving
) 'default
)
3342 ((eq gnus-prompt-before-saving
'always
) nil
)
3344 (gnus-number-of-articles-to-be-saved
3345 (when (eq gnus-prompt-before-saving t
)
3347 (set-buffer gnus-article-current-summary
)
3348 (funcall gnus-default-article-saver filename
)))))
3350 (defun gnus-read-save-file-name (prompt &optional filename
3351 function group headers variable
3354 (funcall function group headers
(symbol-value variable
)))
3359 ((eq filename
'default
)
3365 (when (symbol-value dir-var
)
3366 (setq default-name
(expand-file-name
3367 (file-name-nondirectory default-name
)
3368 (symbol-value dir-var
))))
3369 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3372 (if (and gnus-number-of-articles-to-be-saved
3373 (> gnus-number-of-articles-to-be-saved
1))
3374 (format "these %d articles"
3375 gnus-number-of-articles-to-be-saved
)
3378 ;; Let the split methods have their say.
3380 ;; No split name was found.
3383 (concat prompt
" (default "
3384 (file-name-nondirectory default-name
) "): ")
3385 (file-name-directory default-name
)
3387 ;; A single group name is returned.
3388 ((stringp split-name
)
3390 (funcall function split-name headers
3391 (symbol-value variable
)))
3393 (concat prompt
" (default "
3394 (file-name-nondirectory default-name
) "): ")
3395 (file-name-directory default-name
)
3397 ;; A single split name was found
3398 ((= 1 (length split-name
))
3399 (let* ((name (expand-file-name
3401 gnus-article-save-directory
))
3402 (dir (cond ((file-directory-p name
)
3403 (file-name-as-directory name
))
3404 ((file-exists-p name
) name
)
3405 (t gnus-article-save-directory
))))
3407 (concat prompt
" (default " name
"): ")
3409 ;; A list of splits was found.
3411 (setq split-name
(nreverse split-name
))
3413 (let ((file-name-history
3414 (nconc split-name file-name-history
)))
3418 (concat prompt
" (`M-p' for defaults): ")
3419 gnus-article-save-directory
3421 gnus-article-save-directory
)))
3422 (car (push result file-name-history
)))))))
3423 ;; Create the directory.
3424 (gnus-make-directory (file-name-directory file
))
3425 ;; If we have read a directory, we append the default file name.
3426 (when (file-directory-p file
)
3427 (setq file
(expand-file-name (file-name-nondirectory
3429 (file-name-as-directory file
))))
3430 ;; Possibly translate some characters.
3431 (nnheader-translate-file-chars file
))))))
3432 (gnus-make-directory (file-name-directory result
))
3434 (set variable result
))
3436 (set dir-var
(file-name-directory result
)))
3439 (defun gnus-article-archive-name (group)
3440 "Return the first instance of an \"Archive-name\" in the current buffer."
3441 (let ((case-fold-search t
))
3442 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3443 (nnheader-concat gnus-article-save-directory
3444 (match-string 1)))))
3446 (defun gnus-article-nndoc-name (group)
3447 "If GROUP is an nndoc group, return the name of the parent group."
3448 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3449 (gnus-group-get-parameter group
'save-article-group
)))
3451 (defun gnus-summary-save-in-rmail (&optional filename
)
3452 "Append this article to Rmail file.
3453 Optional argument FILENAME specifies file name.
3454 Directory to save to is default to `gnus-article-save-directory'."
3455 (setq filename
(gnus-read-save-file-name
3456 "Save %s in rmail file" filename
3457 gnus-rmail-save-name gnus-newsgroup-name
3458 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3459 (gnus-eval-in-buffer-window gnus-save-article-buffer
3463 (gnus-output-to-rmail filename
))))
3466 (defun gnus-summary-save-in-mail (&optional filename
)
3467 "Append this article to Unix mail file.
3468 Optional argument FILENAME specifies file name.
3469 Directory to save to is default to `gnus-article-save-directory'."
3470 (setq filename
(gnus-read-save-file-name
3471 "Save %s in Unix mail file" filename
3472 gnus-mail-save-name gnus-newsgroup-name
3473 gnus-current-headers
'gnus-newsgroup-last-mail
))
3474 (gnus-eval-in-buffer-window gnus-save-article-buffer
3478 (if (and (file-readable-p filename
)
3479 (file-regular-p filename
)
3480 (mail-file-babyl-p filename
))
3481 (rmail-output-to-rmail-file filename t
)
3482 (gnus-output-to-mail filename
)))))
3485 (put 'gnus-summary-save-in-file
:decode t
)
3486 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
3487 (defun gnus-summary-save-in-file (&optional filename overwrite
)
3488 "Append this article to file.
3489 Optional argument FILENAME specifies file name.
3490 Directory to save to is default to `gnus-article-save-directory'."
3491 (setq filename
(gnus-read-save-file-name
3492 "Save %s in file" filename
3493 gnus-file-save-name gnus-newsgroup-name
3494 gnus-current-headers
'gnus-newsgroup-last-file
))
3495 (gnus-eval-in-buffer-window gnus-save-article-buffer
3499 (when (and overwrite
3500 (file-exists-p filename
))
3501 (delete-file filename
))
3502 (gnus-output-to-file filename
))))
3505 (put 'gnus-summary-write-to-file
:decode t
)
3506 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
3507 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
3508 (defun gnus-summary-write-to-file (&optional filename
)
3509 "Write this article to a file, overwriting it if the file exists.
3510 Optional argument FILENAME specifies file name.
3511 The directory to save in defaults to `gnus-article-save-directory'."
3512 (setq filename
(gnus-read-save-file-name
3513 "Save %s in file" filename
3514 gnus-file-save-name gnus-newsgroup-name
3515 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3516 (gnus-summary-save-in-file filename t
))
3518 (put 'gnus-summary-save-body-in-file
:decode t
)
3519 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
3520 "Append this article body to a file.
3521 Optional argument FILENAME specifies file name.
3522 The directory to save in defaults to `gnus-article-save-directory'."
3523 (setq filename
(gnus-read-save-file-name
3524 "Save %s body in file" filename
3525 gnus-file-save-name gnus-newsgroup-name
3526 gnus-current-headers
'gnus-newsgroup-last-file
))
3527 (gnus-eval-in-buffer-window gnus-save-article-buffer
3531 (when (article-goto-body)
3532 (narrow-to-region (point) (point-max)))
3533 (when (and overwrite
3534 (file-exists-p filename
))
3535 (delete-file filename
))
3536 (gnus-output-to-file filename
))))
3539 (put 'gnus-summary-write-body-to-file
:decode t
)
3540 (put 'gnus-summary-write-body-to-file
3541 :function
'gnus-summary-save-body-in-file
)
3542 (defun gnus-summary-write-body-to-file (&optional filename
)
3543 "Write this article body to a file, overwriting it if the file exists.
3544 Optional argument FILENAME specifies file name.
3545 The directory to save in defaults to `gnus-article-save-directory'."
3546 (setq filename
(gnus-read-save-file-name
3547 "Save %s body in file" filename
3548 gnus-file-save-name gnus-newsgroup-name
3549 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
3550 (gnus-summary-save-body-in-file filename t
))
3552 (defun gnus-summary-save-in-pipe (&optional command
)
3553 "Pipe this article to subprocess."
3555 (cond ((and (eq command
'default
)
3556 gnus-last-shell-command
)
3557 gnus-last-shell-command
)
3562 "Shell command on %s: "
3563 (if (and gnus-number-of-articles-to-be-saved
3564 (> gnus-number-of-articles-to-be-saved
1))
3565 (format "these %d articles"
3566 gnus-number-of-articles-to-be-saved
)
3568 gnus-last-shell-command
))))
3569 (when (string-equal command
"")
3570 (if gnus-last-shell-command
3571 (setq command gnus-last-shell-command
)
3572 (error "A command is required")))
3573 (gnus-eval-in-buffer-window gnus-article-buffer
3576 (shell-command-on-region (point-min) (point-max) command nil
)))
3577 (setq gnus-last-shell-command command
))
3579 (defmacro gnus-read-string
(prompt &optional initial-contents history
3581 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3582 (if (and (featurep 'xemacs
)
3583 (< emacs-minor-version
2))
3584 `(read-string ,prompt
,initial-contents
,history
)
3585 `(read-string ,prompt
,initial-contents
,history
,default-value
)))
3587 (defun gnus-summary-pipe-to-muttprint (&optional command
)
3588 "Pipe this article to muttprint."
3589 (setq command
(gnus-read-string
3590 "Print using command: " gnus-summary-muttprint-program
3591 nil gnus-summary-muttprint-program
))
3592 (gnus-summary-save-in-pipe command
))
3594 ;;; Article file names when saving.
3596 (defun gnus-capitalize-newsgroup (newsgroup)
3597 "Capitalize NEWSGROUP name."
3598 (when (not (zerop (length newsgroup
)))
3599 (concat (char-to-string (upcase (aref newsgroup
0)))
3600 (substring newsgroup
1))))
3602 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
3603 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3604 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3605 Otherwise, it is like ~/News/news/group/num."
3608 (concat (if (gnus-use-long-file-name 'not-save
)
3609 (gnus-capitalize-newsgroup newsgroup
)
3610 (gnus-newsgroup-directory-form newsgroup
))
3611 "/" (int-to-string (mail-header-number headers
)))
3612 gnus-article-save-directory
)))
3614 (string-equal (file-name-directory default
)
3615 (file-name-directory last-file
))
3616 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3618 (or last-file default
))))
3620 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
3621 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3622 If variable `gnus-use-long-file-name' is non-nil, it is
3623 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3626 (concat (if (gnus-use-long-file-name 'not-save
)
3628 (gnus-newsgroup-directory-form newsgroup
))
3629 "/" (int-to-string (mail-header-number headers
)))
3630 gnus-article-save-directory
)))
3632 (string-equal (file-name-directory default
)
3633 (file-name-directory last-file
))
3634 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
3636 (or last-file default
))))
3638 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
3639 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3640 If variable `gnus-use-long-file-name' is non-nil, it is
3641 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3644 (if (gnus-use-long-file-name 'not-save
)
3647 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
3649 gnus-article-save-directory
)))
3651 (defun gnus-sender-save-name (newsgroup headers
&optional last-file
)
3652 "Generate file name from sender."
3653 (let ((from (mail-header-from headers
)))
3655 (if (and from
(string-match "\\([^ <]+\\)@" from
))
3656 (match-string 1 from
)
3658 gnus-article-save-directory
)))
3660 (defun article-verify-x-pgp-sig ()
3663 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3664 (let ((sig (with-current-buffer gnus-original-article-buffer
3665 (gnus-fetch-field "X-PGP-Sig")))
3669 (mml2015-clear-verify-function))
3671 (insert-buffer-substring gnus-original-article-buffer
)
3672 (setq items
(split-string sig
))
3673 (message-narrow-to-head)
3674 (let ((inhibit-point-motion-hooks t
)
3675 (case-fold-search t
))
3676 ;; Don't verify multiple headers.
3677 (setq headers
(mapconcat (lambda (header)
3679 (mail-fetch-field header
)
3681 (split-string (nth 1 items
) ",") "")))
3682 (delete-region (point-min) (point-max))
3683 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3684 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
3689 (if (looking-at "^-")
3692 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3693 (insert "Version: " (car items
) "\n\n")
3694 (insert (mapconcat 'identity
(cddr items
) "\n"))
3695 (insert "\n-----END PGP SIGNATURE-----\n")
3696 (let ((mm-security-handle (list (format "multipart/signed"))))
3697 (mml2015-clean-buffer)
3698 (let ((coding-system-for-write (or gnus-newsgroup-charset
3700 (funcall (mml2015-clear-verify-function)))
3702 (or (mm-handle-multipart-ctl-parameter
3703 mm-security-handle
'gnus-details
)
3704 (mm-handle-multipart-ctl-parameter
3705 mm-security-handle
'gnus-info
)))))
3707 (let ((inhibit-read-only t
) bface eface
)
3709 (message-narrow-to-head)
3710 (goto-char (point-max))
3712 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
3713 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
))
3714 (message-remove-header "X-Gnus-PGP-Verify")
3715 (if (re-search-forward "^X-PGP-Sig:" nil t
)
3717 (goto-char (point-max)))
3718 (narrow-to-region (point) (point))
3719 (insert "X-Gnus-PGP-Verify: " info
"\n")
3720 (goto-char (point-min))
3723 (if (not (looking-at "^[ \t]"))
3727 (goto-char (point-min))
3728 (when (looking-at "\\([^:]+\\): *")
3729 (put-text-property (match-beginning 1) (1+ (match-end 1))
3731 (put-text-property (match-end 0) (point-max)
3732 'face eface
)))))))))
3734 (defun article-verify-cancel-lock ()
3735 "Verify Cancel-Lock header."
3737 (if (gnus-buffer-live-p gnus-original-article-buffer
)
3738 (canlock-verify gnus-original-article-buffer
)))
3745 (setq afunc
(car func
)
3748 gfunc
(intern (format "gnus-%s" func
))))
3750 (when (fboundp afunc
)
3751 `(lambda (&optional interactive
&rest args
)
3752 ,(documentation afunc t
)
3753 (interactive (list t
))
3755 (set-buffer gnus-article-buffer
)
3757 (call-interactively ',afunc
)
3758 (apply ',afunc args
))))))))
3759 '(article-hide-headers
3760 article-verify-x-pgp-sig
3761 article-verify-cancel-lock
3762 article-hide-boring-headers
3763 article-treat-overstrike
3764 article-fill-long-lines
3765 article-capitalize-sentences
3767 article-remove-leading-whitespace
3768 article-display-x-face
3769 article-display-face
3770 article-de-quoted-unreadable
3771 article-de-base64-unreadable
3774 article-unsplit-urls
3775 article-hide-list-identifiers
3776 article-strip-banner
3779 article-hide-signature
3780 article-strip-headers-in-body
3781 article-remove-trailing-blank-lines
3782 article-strip-leading-blank-lines
3783 article-strip-multiple-blank-lines
3784 article-strip-leading-space
3785 article-strip-trailing-space
3786 article-strip-blank-lines
3787 article-strip-all-blank-lines
3789 article-date-english
3790 article-date-iso8601
3791 article-date-original
3793 article-decode-mime-words
3794 article-decode-charset
3795 article-decode-encoded-words
3799 article-treat-dumbquotes
3800 article-normalize-headers
3801 ;; (article-show-all . gnus-article-show-all-headers)
3805 ;;; Gnus article mode
3808 (put 'gnus-article-mode
'mode-class
'special
)
3810 (set-keymap-parent gnus-article-mode-map widget-keymap
)
3812 (gnus-define-keys gnus-article-mode-map
3813 " " gnus-article-goto-next-page
3814 "\177" gnus-article-goto-prev-page
3815 [delete] gnus-article-goto-prev-page
3816 [backspace] gnus-article-goto-prev-page
3817 "\C-c^" gnus-article-refer-article
3818 "h" gnus-article-show-summary
3819 "s" gnus-article-show-summary
3820 "\C-c\C-m" gnus-article-mail
3821 "?" gnus-article-describe-briefly
3822 "e" gnus-summary-edit-article
3823 "<" beginning-of-buffer
3825 "\C-c\C-i" gnus-info-find-node
3827 "R" gnus-article-reply-with-original
3828 "F" gnus-article-followup-with-original
3829 "\C-hk" gnus-article-describe-key
3830 "\C-hc" gnus-article-describe-key-briefly
3832 "\C-d" gnus-article-read-summary-keys
3833 "\M-*" gnus-article-read-summary-keys
3834 "\M-#" gnus-article-read-summary-keys
3835 "\M-^" gnus-article-read-summary-keys
3836 "\M-g" gnus-article-read-summary-keys)
3838 (substitute-key-definition
3839 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3841 (defun gnus-article-make-menu-bar ()
3842 (unless (boundp 'gnus-article-commands-menu)
3843 (gnus-summary-make-menu-bar))
3844 (gnus-turn-off-edit-menu 'article)
3845 (unless (boundp 'gnus-article-article-menu)
3847 gnus-article-article-menu gnus-article-mode-map ""
3849 ["Scroll forwards" gnus-article-goto-next-page t]
3850 ["Scroll backwards" gnus-article-goto-prev-page t]
3851 ["Show summary" gnus-article-show-summary t]
3852 ["Fetch Message-ID at point" gnus-article-refer-article t]
3853 ["Mail to address at point" gnus-article-mail t]
3854 ["Send a bug report" gnus-bug t]))
3857 gnus-article-treatment-menu gnus-article-mode-map ""
3858 ;; Fixme: this should use :active (and maybe :visible).
3860 ["Hide headers" gnus-article-hide-headers t]
3861 ["Hide signature" gnus-article-hide-signature t]
3862 ["Hide citation" gnus-article-hide-citation t]
3863 ["Treat overstrike" gnus-article-treat-overstrike t]
3864 ["Remove carriage return" gnus-article-remove-cr t]
3865 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3866 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3867 ["Remove base64" gnus-article-de-base64-unreadable t]
3868 ["Treat html" gnus-article-wash-html t]
3869 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3870 ["Decode HZ" gnus-article-decode-HZ t]))
3872 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3874 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3876 (gnus-run-hooks 'gnus-article-menu-hook)))
3878 (defun gnus-article-mode ()
3879 "Major mode for displaying an article.
3881 All normal editing commands are switched off.
3883 The following commands are available in addition to all summary mode
3885 \\<gnus-article-mode-map>
3886 \\[gnus-article-next-page]\t Scroll the article one page forwards
3887 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3888 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3889 \\[gnus-article-show-summary]\t Display the summary buffer
3890 \\[gnus-article-mail]\t Send a reply to the address near point
3891 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3892 \\[gnus-info-find-node]\t Go to the Gnus info node"
3894 (kill-all-local-variables)
3895 (gnus-simplify-mode-line)
3896 (setq mode-name "Article")
3897 (setq major-mode 'gnus-article-mode)
3898 (make-local-variable 'minor-mode-alist)
3899 (use-local-map gnus-article-mode-map)
3900 (when (gnus-visual-p 'article-menu 'menu)
3901 (gnus-article-make-menu-bar)
3902 (when gnus-summary-tool-bar-map
3903 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3904 (gnus-update-format-specifications nil 'article-mode)
3905 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3906 (set (make-local-variable 'gnus-page-broken) nil)
3907 (make-local-variable 'gnus-button-marker-list)
3908 (make-local-variable 'gnus-article-current-summary)
3909 (make-local-variable 'gnus-article-mime-handles)
3910 (make-local-variable 'gnus-article-decoded-p)
3911 (make-local-variable 'gnus-article-mime-handle-alist)
3912 (make-local-variable 'gnus-article-wash-types)
3913 (make-local-variable 'gnus-article-image-alist)
3914 (make-local-variable 'gnus-article-charset)
3915 (make-local-variable 'gnus-article-ignored-charsets)
3916 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3917 (set (make-local-variable 'nobreak-char-display) nil)
3918 (setq cursor-in-non-selected-windows nil)
3919 (gnus-set-default-directory)
3920 (buffer-disable-undo)
3921 (setq buffer-read-only t)
3922 (set-syntax-table gnus-article-mode-syntax-table)
3923 (mm-enable-multibyte)
3924 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3926 (defun gnus-article-setup-buffer ()
3927 "Initialize the article buffer."
3928 (let* ((name (if gnus-single-article-buffer "*Article*"
3929 (concat "*Article " gnus-newsgroup-name "*")))
3931 (progn (string-match "\\*Article" name)
3932 (concat " *Original Article"
3933 (substring name (match-end 0))))))
3934 (setq gnus-article-buffer name)
3935 (setq gnus-original-article-buffer original)
3936 (setq gnus-article-mime-handle-alist nil)
3937 ;; This might be a variable local to the summary buffer.
3938 (unless gnus-single-article-buffer
3940 (set-buffer gnus-summary-buffer)
3941 (setq gnus-article-buffer name)
3942 (setq gnus-original-article-buffer original)
3943 (gnus-set-global-variables)))
3944 (gnus-article-setup-highlight-words)
3945 ;; Init original article buffer.
3947 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3948 (mm-enable-multibyte)
3949 (setq major-mode 'gnus-original-article-mode)
3950 (make-local-variable 'gnus-original-article))
3951 (if (and (get-buffer name)
3952 (with-current-buffer name
3953 (if gnus-article-edit-mode
3954 (if (y-or-n-p "Article mode edit in progress; discard? ")
3956 (set-buffer-modified-p nil)
3957 (gnus-kill-buffer name)
3960 (error "Action aborted"))
3964 (set (make-local-variable 'gnus-article-edit-mode) nil)
3965 (when gnus-article-mime-handles
3966 (mm-destroy-parts gnus-article-mime-handles)
3967 (setq gnus-article-mime-handles nil))
3968 ;; Set it to nil in article-buffer!
3969 (setq gnus-article-mime-handle-alist nil)
3970 (buffer-disable-undo)
3971 (setq buffer-read-only t)
3972 ;; This list just keeps growing if we don't reset it.
3973 (setq gnus-button-marker-list nil)
3974 (unless (eq major-mode 'gnus-article-mode)
3975 (gnus-article-mode))
3978 (set-buffer (gnus-get-buffer-create name))
3980 (make-local-variable 'gnus-summary-buffer)
3981 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3982 (current-buffer)))))
3984 ;; Set article window start at LINE, where LINE is the number of lines
3985 ;; from the head of the article.
3986 (defun gnus-article-set-window-start (&optional line)
3988 (gnus-get-buffer-window gnus-article-buffer t)
3990 (set-buffer gnus-article-buffer)
3991 (goto-char (point-min))
3994 (gnus-message 6 "Moved to bookmark")
3995 (search-forward "\n\n" nil t)
3999 (defun gnus-article-prepare (article &optional all-headers header)
4000 "Prepare ARTICLE in article mode buffer.
4001 ARTICLE should either be an article number or a Message-ID.
4002 If ARTICLE is an id, HEADER should be the article headers.
4003 If ALL-HEADERS is non-nil, no headers are hidden."
4005 ;; Make sure we start in a summary buffer.
4006 (unless (eq major-mode 'gnus-summary-mode)
4007 (set-buffer gnus-summary-buffer))
4008 (setq gnus-summary-buffer (current-buffer))
4009 (let* ((gnus-article (if header (mail-header-number header) article))
4010 (summary-buffer (current-buffer))
4011 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4012 (group gnus-newsgroup-name)
4015 (gnus-article-setup-buffer)
4016 (set-buffer gnus-article-buffer)
4017 ;; Deactivate active regions.
4018 (when (and (boundp 'transient-mark-mode)
4019 transient-mark-mode)
4020 (setq mark-active nil))
4021 (if (not (setq result (let ((inhibit-read-only t))
4022 (gnus-request-article-this-buffer
4024 ;; There is no such article.
4026 (when (and (numberp article)
4027 (not (memq article gnus-newsgroup-sparse)))
4028 (setq gnus-article-current
4029 (cons gnus-newsgroup-name article))
4030 (set-buffer gnus-summary-buffer)
4031 (setq gnus-current-article article)
4032 (if (and (memq article gnus-newsgroup-undownloaded)
4033 (not (gnus-online (gnus-find-method-for-group
4034 gnus-newsgroup-name))))
4036 (gnus-summary-set-agent-mark article)
4037 (message "Message marked for downloading"))
4038 (gnus-summary-mark-article article gnus-canceled-mark)
4039 (unless (memq article gnus-newsgroup-sparse)
4040 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4041 (if (or (eq result 'pseudo)
4042 (eq result 'nneething))
4045 (set-buffer summary-buffer)
4046 (push article gnus-newsgroup-history)
4047 (setq gnus-last-article gnus-current-article
4048 gnus-current-article 0
4049 gnus-current-headers nil
4050 gnus-article-current nil)
4051 (if (eq result 'nneething)
4052 (gnus-configure-windows 'summary)
4053 (gnus-configure-windows 'article))
4054 (gnus-set-global-variables))
4055 (let ((gnus-article-mime-handle-alist-1
4056 gnus-article-mime-handle-alist))
4057 (gnus-set-mode-line 'article)))
4058 ;; The result from the `request' was an actual article -
4059 ;; or at least some text that is now displayed in the
4061 (when (and (numberp article)
4062 (not (eq article gnus-current-article)))
4063 ;; Seems like a new article has been selected.
4064 ;; `gnus-current-article' must be an article number.
4066 (set-buffer summary-buffer)
4067 (push article gnus-newsgroup-history)
4068 (setq gnus-last-article gnus-current-article
4069 gnus-current-article article
4070 gnus-current-headers
4071 (gnus-summary-article-header gnus-current-article)
4072 gnus-article-current
4073 (cons gnus-newsgroup-name gnus-current-article))
4074 (unless (vectorp gnus-current-headers)
4075 (setq gnus-current-headers nil))
4076 (gnus-summary-goto-subject gnus-current-article)
4077 (when (gnus-summary-show-thread)
4078 ;; If the summary buffer really was folded, the
4079 ;; previous goto may not actually have gone to
4080 ;; the right article, but the thread root instead.
4082 (gnus-summary-goto-subject gnus-current-article))
4083 (gnus-run-hooks 'gnus-mark-article-hook)
4084 (gnus-set-mode-line 'summary)
4085 (when (gnus-visual-p 'article-highlight 'highlight)
4086 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4087 ;; Set the global newsgroup variables here.
4088 (gnus-set-global-variables)
4089 (setq gnus-have-all-headers
4090 (or all-headers gnus-show-all-headers))))
4092 (gnus-configure-windows 'article))
4093 (when (or (numberp article)
4095 (gnus-article-prepare-display)
4097 (goto-char (point-min))
4098 (when gnus-break-pages
4099 (gnus-narrow-to-page)))
4100 (let ((gnus-article-mime-handle-alist-1
4101 gnus-article-mime-handle-alist))
4102 (gnus-set-mode-line 'article))
4106 (set-window-point (get-buffer-window (current-buffer)) (point))
4107 (gnus-configure-windows 'article)
4111 (defun gnus-article-prepare-display ()
4112 "Make the current buffer look like a nice article."
4113 ;; Hooks for getting information from the article.
4114 ;; This hook must be called before being narrowed.
4115 (let ((gnus-article-buffer (current-buffer))
4117 (inhibit-read-only t))
4118 (unless (eq major-mode 'gnus-article-mode)
4119 (gnus-article-mode))
4120 (setq buffer-read-only nil
4121 gnus-article-wash-types nil
4122 gnus-article-image-alist nil)
4123 (gnus-run-hooks 'gnus-tmp-internal-hook)
4124 (when gnus-display-mime-function
4125 (funcall gnus-display-mime-function))
4126 (gnus-run-hooks 'gnus-article-prepare-hook)))
4129 ;;; Gnus MIME viewing functions
4132 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4133 "Format of the MIME buttons.
4135 Valid specifiers include:
4137 %T MIME type, along with additional info
4138 %n The `name' parameter
4139 %d The description, if any
4140 %l The length of the encoded part
4141 %p The part identifier number
4142 %e Dots if the part isn't displayed
4144 General format specifiers can also be used. See Info node
4145 `(gnus)Formatting Variables'.")
4147 (defvar gnus-mime-button-line-format-alist
4148 '((?t gnus-tmp-type ?s)
4149 (?T gnus-tmp-type-long ?s)
4150 (?n gnus-tmp-name ?s)
4151 (?d gnus-tmp-description ?s)
4153 (?l gnus-tmp-length ?d)
4154 (?e gnus-tmp-dots ?s)))
4156 (defvar gnus-mime-button-commands
4157 '((gnus-article-press-button "\r" "Toggle Display")
4158 (gnus-mime-view-part "v" "View Interactively...")
4159 (gnus-mime-view-part-as-type "t" "View As Type...")
4160 (gnus-mime-view-part-as-charset "C" "View As charset...")
4161 (gnus-mime-save-part "o" "Save...")
4162 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4163 (gnus-mime-delete-part "d" "Delete part")
4164 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4165 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4166 (gnus-mime-view-part-internally "E" "View Internally")
4167 (gnus-mime-view-part-externally "e" "View Externally")
4168 (gnus-mime-print-part "p" "Print")
4169 (gnus-mime-pipe-part "|" "Pipe To Command...")
4170 (gnus-mime-action-on-part "." "Take action on the part...")))
4172 (defun gnus-article-mime-part-status ()
4173 (if gnus-article-mime-handle-alist-1
4174 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4176 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4179 (defvar gnus-mime-button-map
4180 (let ((map (make-sparse-keymap)))
4181 (unless (>= (string-to-number emacs-version) 21)
4182 ;; XEmacs doesn't care.
4183 (set-keymap-parent map gnus-article-mode-map))
4184 (define-key map gnus-mouse-2 'gnus-article-push-button)
4185 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4186 (dolist (c gnus-mime-button-commands)
4187 (define-key map (cadr c) (car c)))
4191 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4193 ,@(mapcar (lambda (c)
4194 (vector (caddr c) (car c) :enable t))
4195 gnus-mime-button-commands)))
4198 (define-compiler-macro popup-menu (&whole form
4199 menu &optional position prefix)
4200 (if (and (fboundp 'popup-menu)
4201 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4203 ;; Gnus is probably running under Emacs 20.
4204 `(let* ((menu (cdr ,menu))
4205 (response (x-popup-menu
4207 (cons "" (mapcar (lambda (c)
4208 (cons (caddr c) (car c)))
4211 (call-interactively (nth 3 (assq response menu))))))))
4213 (defun gnus-mime-button-menu (event prefix)
4214 "Construct a context-sensitive menu of MIME commands."
4215 (interactive "e\nP")
4216 (save-window-excursion
4217 (let ((pos (event-start event)))
4218 (select-window (posn-window pos))
4219 (goto-char (posn-point pos))
4220 (gnus-article-check-buffer)
4221 (popup-menu gnus-mime-button-menu nil prefix))))
4223 (defun gnus-mime-view-all-parts (&optional handles)
4224 "View all the MIME parts."
4226 (save-current-buffer
4227 (set-buffer gnus-article-buffer)
4228 (let ((handles (or handles gnus-article-mime-handles))
4229 (mail-parse-charset gnus-newsgroup-charset)
4230 (mail-parse-ignored-charsets
4231 (with-current-buffer gnus-summary-buffer
4232 gnus-newsgroup-ignored-charsets)))
4234 (mm-remove-parts handles)
4235 (goto-char (point-min))
4236 (or (search-forward "\n\n") (goto-char (point-max)))
4237 (let ((inhibit-read-only t))
4238 (delete-region (point) (point-max))
4239 (mm-display-parts handles))))))
4241 (defun gnus-mime-save-part-and-strip ()
4242 "Save the MIME part under point then replace it with an external body."
4244 (gnus-article-check-buffer)
4245 (when (gnus-group-read-only-p)
4246 (error "The current group does not support deleting of parts"))
4247 (when (mm-complicated-handles gnus-article-mime-handles)
4249 The current article has a complicated MIME structure, giving up..."))
4250 (when (gnus-yes-or-no-p "\
4251 Deleting parts may malfunction or destroy the article; continue? ")
4252 (let* ((data (get-text-property (point) 'gnus-data))
4254 (handles gnus-article-mime-handles))
4255 (setq file (and data (mm-save-part data)))
4257 (with-current-buffer (mm-handle-buffer data)
4259 (insert "Content-Type: " (mm-handle-media-type data))
4260 (mml-insert-parameter-string (cdr (mm-handle-type data))
4262 ;; Add a filename for the sake of saving the part again.
4263 (mml-insert-parameter
4264 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4266 (insert "Content-ID: " (message-make-message-id) "\n")
4267 (insert "Content-Transfer-Encoding: binary\n")
4270 (cdr (mm-make-handle nil
4271 `("message/external-body"
4272 (access-type . "LOCAL-FILE")
4274 (set-buffer gnus-summary-buffer)
4275 (gnus-article-edit-article
4278 (let ((mail-parse-charset (or gnus-article-charset
4279 ',gnus-newsgroup-charset))
4280 (mail-parse-ignored-charsets
4281 (or gnus-article-ignored-charsets
4282 ',gnus-newsgroup-ignored-charsets))
4283 (mbl mml-buffer-list))
4284 (setq mml-buffer-list nil)
4285 (insert-buffer-substring gnus-original-article-buffer)
4286 (mime-to-mml ',handles)
4287 (setq gnus-article-mime-handles nil)
4288 (let ((mbl1 mml-buffer-list))
4289 (setq mml-buffer-list mbl)
4290 (set (make-local-variable 'mml-buffer-list) mbl1))
4291 (gnus-make-local-hook 'kill-buffer-hook)
4292 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4293 `(lambda (no-highlight)
4294 (let ((mail-parse-charset (or gnus-article-charset
4295 ',gnus-newsgroup-charset))
4296 (message-options message-options)
4297 (message-options-set-recipient)
4298 (mail-parse-ignored-charsets
4299 (or gnus-article-ignored-charsets
4300 ',gnus-newsgroup-ignored-charsets)))
4302 (mml-destroy-buffers)
4303 (remove-hook 'kill-buffer-hook
4304 'mml-destroy-buffers t)
4305 (kill-local-variable 'mml-buffer-list))
4306 (gnus-summary-edit-article-done
4307 ,(or (mail-header-references gnus-current-headers) "")
4308 ,(gnus-group-read-only-p)
4309 ,gnus-summary-buffer no-highlight)))))))
4311 (defun gnus-mime-delete-part ()
4312 "Delete the MIME part under point.
4313 Replace it with some information about the removed part."
4315 (gnus-article-check-buffer)
4316 (when (gnus-group-read-only-p)
4317 (error "The current group does not support deleting of parts"))
4318 (when (mm-complicated-handles gnus-article-mime-handles)
4320 The current article has a complicated MIME structure, giving up..."))
4321 (when (gnus-yes-or-no-p "\
4322 Deleting parts may malfunction or destroy the article; continue? ")
4323 (let* ((data (get-text-property (point) 'gnus-data))
4324 (handles gnus-article-mime-handles)
4328 (mail-decode-encoded-word-string (or (mm-handle-description data)
4331 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4333 (type (mm-handle-media-type data)))
4335 (error "No MIME part under point"))
4336 (with-current-buffer (mm-handle-buffer data)
4337 (let ((bsize (format "%s" (buffer-size))))
4342 "| The following attachment has been deleted:\n"
4344 "| Type: " type "\n"
4345 "| Filename: " filename "\n"
4346 "| Size (encoded): " bsize " Byte\n"
4347 "| Description: " description "\n"
4350 (cdr (mm-make-handle
4351 nil `("text/plain") nil nil
4353 (format "Deleted attachment (%s bytes)" bsize))))))
4354 (set-buffer gnus-summary-buffer)
4355 ;; FIXME: maybe some of the following code (borrowed from
4356 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4357 (gnus-article-edit-article
4360 (let ((mail-parse-charset (or gnus-article-charset
4361 ',gnus-newsgroup-charset))
4362 (mail-parse-ignored-charsets
4363 (or gnus-article-ignored-charsets
4364 ',gnus-newsgroup-ignored-charsets))
4365 (mbl mml-buffer-list))
4366 (setq mml-buffer-list nil)
4367 (insert-buffer-substring gnus-original-article-buffer)
4368 (mime-to-mml ',handles)
4369 (setq gnus-article-mime-handles nil)
4370 (let ((mbl1 mml-buffer-list))
4371 (setq mml-buffer-list mbl)
4372 (set (make-local-variable 'mml-buffer-list) mbl1))
4373 (gnus-make-local-hook 'kill-buffer-hook)
4374 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4375 `(lambda (no-highlight)
4376 (let ((mail-parse-charset (or gnus-article-charset
4377 ',gnus-newsgroup-charset))
4378 (message-options message-options)
4379 (message-options-set-recipient)
4380 (mail-parse-ignored-charsets
4381 (or gnus-article-ignored-charsets
4382 ',gnus-newsgroup-ignored-charsets)))
4384 (mml-destroy-buffers)
4385 (remove-hook 'kill-buffer-hook
4386 'mml-destroy-buffers t)
4387 (kill-local-variable 'mml-buffer-list))
4388 (gnus-summary-edit-article-done
4389 ,(or (mail-header-references gnus-current-headers) "")
4390 ,(gnus-group-read-only-p)
4391 ,gnus-summary-buffer no-highlight)))))
4392 ;; Not in `gnus-mime-save-part-and-strip':
4393 (gnus-article-edit-done)
4394 (gnus-summary-expand-window)
4395 (gnus-summary-show-article))
4397 (defun gnus-mime-save-part ()
4398 "Save the MIME part under point."
4400 (gnus-article-check-buffer)
4401 (let ((data (get-text-property (point) 'gnus-data)))
4403 (mm-save-part data))))
4405 (defun gnus-mime-pipe-part ()
4406 "Pipe the MIME part under point to a process."
4408 (gnus-article-check-buffer)
4409 (let ((data (get-text-property (point) 'gnus-data)))
4411 (mm-pipe-part data))))
4413 (defun gnus-mime-view-part ()
4414 "Interactively choose a viewing method for the MIME part under point."
4416 (gnus-article-check-buffer)
4417 (let ((data (get-text-property (point) 'gnus-data)))
4419 (setq gnus-article-mime-handles
4421 gnus-article-mime-handles (setq data (copy-sequence data))))
4422 (mm-interactively-view-part data))))
4424 (defun gnus-mime-view-part-as-type-internal ()
4425 (gnus-article-check-buffer)
4426 (let* ((handle (get-text-property (point) 'gnus-data))
4428 ;; Content-Type: foo/bar; name=...
4429 (mail-content-type-get (mm-handle-type handle) 'name)
4430 ;; Content-Disposition: attachment; filename=...
4431 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4432 (def-type (and name (mm-default-file-encoding name))))
4433 (and def-type (cons def-type 0))))
4435 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4436 "Choose a MIME media type, and view the part as such.
4437 If non-nil, PRED is a predicate to use during completion to limit the
4438 available media-types."
4442 (let ((default (gnus-mime-view-part-as-type-internal)))
4444 (format "View as MIME type (default %s): "
4446 (mapcar #'list (mailcap-mime-types))
4449 (gnus-article-check-buffer)
4450 (let ((handle (get-text-property (point) 'gnus-data)))
4452 (when (equal (mm-handle-media-type handle) "message/external-body")
4453 (unless (mm-handle-cache handle)
4454 (mm-extern-cache-contents handle))
4455 (setq handle (mm-handle-cache handle)))
4457 (mm-make-handle (mm-handle-buffer handle)
4458 (cons mime-type (cdr (mm-handle-type handle)))
4459 (mm-handle-encoding handle)
4460 (mm-handle-undisplayer handle)
4461 (mm-handle-disposition handle)
4462 (mm-handle-description handle)
4464 (mm-handle-id handle)))
4465 (setq gnus-article-mime-handles
4466 (mm-merge-handles gnus-article-mime-handles handle))
4467 (gnus-mm-display-part handle))))
4470 (require 'jka-compr))
4472 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4473 ;; emacs can do that itself.
4475 (defun gnus-mime-jka-compr-maybe-uncompress ()
4476 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4477 The uncompress method used is derived from `buffer-file-name'."
4478 (when (and (fboundp 'jka-compr-installed-p)
4479 (jka-compr-installed-p))
4480 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4482 (let ((basename (file-name-nondirectory buffer-file-name))
4483 (args (jka-compr-info-uncompress-args info))
4484 (prog (jka-compr-info-uncompress-program info))
4485 (message (jka-compr-info-uncompress-message info))
4486 (err-file (jka-compr-make-temp-name)))
4488 (message "%s %s..." message basename))
4490 (unless (memq (apply 'call-process-region
4491 (point-min) (point-max)
4493 t (list t err-file) nil
4495 jka-compr-acceptable-retval-list)
4496 (jka-compr-error prog args basename message err-file))
4497 (jka-compr-delete-temp-file err-file)))))))
4499 (defun gnus-mime-copy-part (&optional handle)
4500 "Put the MIME part under point into a new buffer.
4501 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4504 (gnus-article-check-buffer)
4505 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4506 (contents (and handle (mm-get-part handle)))
4508 (file-name-nondirectory
4510 (mail-content-type-get (mm-handle-type handle) 'name)
4511 (mail-content-type-get (mm-handle-disposition handle)
4514 (buffer (and base (generate-new-buffer base))))
4516 (switch-to-buffer buffer)
4518 ;; We do it this way to make `normal-mode' set the appropriate mode.
4521 (setq buffer-file-name (expand-file-name base))
4522 (gnus-mime-jka-compr-maybe-uncompress)
4524 (setq buffer-file-name nil))
4525 (goto-char (point-min)))))
4527 (defun gnus-mime-print-part (&optional handle filename)
4528 "Print the MIME part under point."
4529 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4530 (gnus-article-check-buffer)
4531 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4532 (contents (and handle (mm-get-part handle)))
4533 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4534 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4539 (mm-save-part-to-file handle file)
4540 (call-process shell-file-name nil
4541 (generate-new-buffer " *mm*")
4543 shell-command-switch
4545 printer file (mm-handle-type handle))))
4549 (gnus-print-buffer))
4550 (ps-despool filename)))))
4552 (defun gnus-mime-inline-part (&optional handle arg)
4553 "Insert the MIME part under point into the current buffer."
4554 (interactive (list nil current-prefix-arg))
4555 (gnus-article-check-buffer)
4556 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4559 (inhibit-read-only t))
4561 (if (and (not arg) (mm-handle-undisplayer handle))
4562 (mm-remove-part handle)
4563 (setq contents (mm-get-part handle))
4566 (setq charset (or (mail-content-type-get
4567 (mm-handle-type handle) 'charset)
4568 gnus-newsgroup-charset)))
4570 (if (mm-handle-undisplayer handle)
4571 (mm-remove-part handle))
4574 gnus-summary-show-article-charset-alist))
4575 (mm-read-coding-system "Charset: "))))
4577 (if (mm-handle-undisplayer handle)
4578 (mm-remove-part handle))))
4583 (setq charset (mm-charset-to-coding-system
4585 (not (eq charset 'ascii)))
4586 (mm-decode-coding-string contents charset)
4587 (mm-string-to-multibyte contents)))
4590 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4591 "Insert the MIME part under point into the current buffer using the
4593 (interactive (list nil current-prefix-arg))
4594 (gnus-article-check-buffer)
4595 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4596 (fun (get-text-property (point) 'gnus-callback))
4597 (gnus-newsgroup-ignored-charsets 'gnus-all)
4598 gnus-newsgroup-charset type charset)
4600 (if (mm-handle-undisplayer handle)
4601 (mm-remove-part handle))
4603 (setq gnus-newsgroup-charset
4604 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4605 (mm-read-coding-system "Charset: ")))
4606 ;; Strip the charset parameter from `handle'.
4607 (setq type (mm-handle-type
4608 (if (equal (mm-handle-media-type handle)
4609 "message/external-body")
4611 (unless (mm-handle-cache handle)
4612 (mm-extern-cache-contents handle))
4613 (mm-handle-cache handle))
4615 charset (assq 'charset (cdr type)))
4617 (funcall fun handle)))))
4619 (defun gnus-mime-view-part-externally (&optional handle)
4620 "View the MIME part under point with an external viewer."
4622 (gnus-article-check-buffer)
4623 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4624 (mm-user-display-methods nil)
4625 (mm-inlined-types nil)
4626 (mail-parse-charset gnus-newsgroup-charset)
4627 (mail-parse-ignored-charsets
4628 (with-current-buffer gnus-summary-buffer
4629 gnus-newsgroup-ignored-charsets))
4630 (type (mm-handle-media-type handle))
4631 (method (mailcap-mime-info type))
4632 (mm-enable-external t))
4633 (if (not (stringp method))
4634 (gnus-mime-view-part-as-type
4635 nil (lambda (type) (stringp (mailcap-mime-info type))))
4637 (if (mm-handle-undisplayer handle)
4638 (mm-remove-part handle)
4639 (mm-display-part handle))))))
4641 (defun gnus-mime-view-part-internally (&optional handle)
4642 "View the MIME part under point with an internal viewer.
4643 If no internal viewer is available, use an external viewer."
4645 (gnus-article-check-buffer)
4646 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4647 (mm-inlined-types '(".*"))
4648 (mm-inline-large-images t)
4649 (mail-parse-charset gnus-newsgroup-charset)
4650 (mail-parse-ignored-charsets
4651 (with-current-buffer gnus-summary-buffer
4652 gnus-newsgroup-ignored-charsets))
4653 (inhibit-read-only t))
4654 (if (not (mm-inlinable-p handle))
4655 (gnus-mime-view-part-as-type
4656 nil (lambda (type) (mm-inlinable-p handle type)))
4658 (if (mm-handle-undisplayer handle)
4659 (mm-remove-part handle)
4660 (mm-display-part handle))))))
4662 (defun gnus-mime-action-on-part (&optional action)
4663 "Do something with the MIME attachment at \(point\)."
4665 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4666 (gnus-article-check-buffer)
4667 (let ((action-pair (assoc action gnus-mime-action-alist)))
4669 (funcall (cdr action-pair)))))
4671 (defun gnus-article-part-wrapper (n function)
4672 (save-current-buffer
4673 (set-buffer gnus-article-buffer)
4674 (when (> n (length gnus-article-mime-handle-alist))
4675 (error "No such part"))
4676 (gnus-article-goto-part n)
4677 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4678 (funcall function handle))))
4680 (defun gnus-article-pipe-part (n)
4681 "Pipe MIME part N, which is the numerical prefix."
4683 (gnus-article-part-wrapper n 'mm-pipe-part))
4685 (defun gnus-article-save-part (n)
4686 "Save MIME part N, which is the numerical prefix."
4688 (gnus-article-part-wrapper n 'mm-save-part))
4690 (defun gnus-article-interactively-view-part (n)
4691 "View MIME part N interactively, which is the numerical prefix."
4693 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4695 (defun gnus-article-copy-part (n)
4696 "Copy MIME part N, which is the numerical prefix."
4698 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4700 (defun gnus-article-view-part-as-charset (n)
4701 "View MIME part N using a specified charset.
4702 N is the numerical prefix."
4704 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4706 (defun gnus-article-view-part-externally (n)
4707 "View MIME part N externally, which is the numerical prefix."
4709 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4711 (defun gnus-article-inline-part (n)
4712 "Inline MIME part N, which is the numerical prefix."
4714 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4716 (defun gnus-article-mime-match-handle-first (condition)
4718 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4719 (while (setq ihandle (pop alist))
4721 ((functionp condition)
4722 (funcall condition (cdr ihandle)))
4723 ((eq condition 'undisplayed)
4724 (not (or (mm-handle-undisplayer (cdr ihandle))
4725 (equal (mm-handle-media-type (cdr ihandle))
4726 "multipart/alternative"))))
4727 ((eq condition 'undisplayed-alternative)
4728 (not (mm-handle-undisplayer (cdr ihandle))))
4730 (gnus-article-goto-part (car ihandle))
4731 (or (not n) (< (car ihandle) n)))
4732 (setq n (car ihandle))))
4736 (defun gnus-article-view-part (&optional n)
4737 "View MIME part N, which is the numerical prefix."
4739 (save-current-buffer
4740 (set-buffer gnus-article-buffer)
4741 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4742 gnus-article-mime-match-handle-function)))
4743 (when (> n (length gnus-article-mime-handle-alist))
4744 (error "No such part"))
4745 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4746 (when (gnus-article-goto-part n)
4747 (if (equal (car handle) "multipart/alternative")
4748 (gnus-article-press-button)
4749 (when (eq (gnus-mm-display-part handle) 'internal)
4750 (gnus-set-window-start)))))))
4752 (defsubst gnus-article-mime-total-parts ()
4753 (if (bufferp (car gnus-article-mime-handles))
4755 (1- (length gnus-article-mime-handles))))
4757 (defun gnus-mm-display-part (handle)
4758 "Display HANDLE and fix MIME button."
4759 (let ((id (get-text-property (point) 'gnus-part))
4761 (inhibit-read-only t))
4764 (let ((window (selected-window))
4765 (mail-parse-charset gnus-newsgroup-charset)
4766 (mail-parse-ignored-charsets
4767 (if (gnus-buffer-live-p gnus-summary-buffer)
4769 (set-buffer gnus-summary-buffer)
4770 gnus-newsgroup-ignored-charsets)
4774 (let ((win (gnus-get-buffer-window (current-buffer) t))
4777 (select-window win))
4780 (if (mm-handle-displayed-p handle)
4781 ;; This will remove the part.
4782 (mm-display-part handle)
4784 (narrow-to-region (point)
4785 (if (eobp) (point) (1+ (point))))
4786 (mm-display-part handle)
4787 ;; We narrow to the part itself and
4788 ;; then call the treatment functions.
4789 (goto-char (point-min))
4791 (narrow-to-region (point) (point-max))
4794 (gnus-article-mime-total-parts)
4795 (mm-handle-media-type handle)))))
4796 (if (window-live-p window)
4797 (select-window window)))))
4800 (gnus-insert-mime-button
4801 handle id (list (mm-handle-displayed-p handle)))
4802 (goto-char point))))
4804 (defun gnus-article-goto-part (n)
4805 "Go to MIME part N."
4806 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4808 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4809 (let ((gnus-tmp-name
4810 (or (mail-content-type-get (mm-handle-type handle) 'name)
4811 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4812 (mail-content-type-get (mm-handle-type handle) 'url)
4814 (gnus-tmp-type (mm-handle-media-type handle))
4815 (gnus-tmp-description
4816 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4819 (if (if displayed (car displayed)
4820 (mm-handle-displayed-p handle))
4822 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4824 gnus-tmp-type-long b e)
4825 (when (string-match ".*/" gnus-tmp-name)
4826 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4827 (setq gnus-tmp-type-long (concat gnus-tmp-type
4828 (and (not (equal gnus-tmp-name ""))
4829 (concat "; " gnus-tmp-name))))
4830 (unless (equal gnus-tmp-description "")
4831 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4836 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4837 `(,@(gnus-local-map-property gnus-mime-button-map)
4838 gnus-callback gnus-mm-display-part
4839 gnus-part ,gnus-tmp-id
4840 article-type annotation
4843 ;; Exclude a newline.
4846 (widget-convert-button
4849 :action 'gnus-widget-press-button
4850 :button-keymap gnus-mime-button-map
4852 (lambda (widget/window &optional overlay pos)
4853 ;; Needed to properly clear the message due to a bug in
4854 ;; wid-edit (XEmacs only).
4855 (if (boundp 'help-echo-owns-message)
4856 (setq help-echo-owns-message t))
4858 "%S: %s the MIME part; %S: more options"
4859 (aref gnus-mouse-2 0)
4860 ;; XEmacs will get a single widget arg; Emacs 21 will get
4861 ;; window, overlay, position.
4862 (if (mm-handle-displayed-p
4864 (with-current-buffer (gnus-overlay-buffer overlay)
4865 (widget-get (widget-at (gnus-overlay-start overlay))
4867 (widget-get widget/window :mime-handle)))
4869 (aref gnus-down-mouse-3 0))))))
4871 (defun gnus-widget-press-button (elems el)
4872 (goto-char (widget-get elems :from))
4873 (gnus-article-press-button))
4875 (defvar gnus-displaying-mime nil)
4877 (defun gnus-display-mime (&optional ihandles)
4878 "Display the MIME parts."
4880 (save-selected-window
4881 (let ((window (get-buffer-window gnus-article-buffer))
4884 (select-window window)
4885 ;; We have to do this since selecting the window
4886 ;; may change the point. So we set the window point.
4887 (set-window-point window point)))
4888 (let ((handles ihandles)
4889 (inhibit-read-only t)
4892 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4893 (when gnus-article-emulate-mime
4894 (mm-uu-dissect-text-parts handles)))
4895 (gnus-article-emulate-mime
4896 (setq handles (mm-uu-dissect))))
4897 (when (and (not ihandles)
4898 (not gnus-displaying-mime))
4899 ;; Top-level call; we clean up.
4900 (when gnus-article-mime-handles
4901 (mm-destroy-parts gnus-article-mime-handles)
4902 (setq gnus-article-mime-handle-alist nil));; A trick.
4903 (setq gnus-article-mime-handles handles)
4904 ;; We allow users to glean info from the handles.
4905 (when gnus-article-mime-part-function
4906 (gnus-mime-part-function handles)))
4908 (or (not (stringp (car handles)))
4911 (when (and (not ihandles)
4912 (not gnus-displaying-mime))
4913 ;; Clean up for mime parts.
4915 (delete-region (point) (point-max)))
4916 (let ((gnus-displaying-mime t))
4917 (gnus-mime-display-part handles)))
4920 (narrow-to-region (point) (point-max))
4921 (gnus-treat-article nil 1 1)
4924 ;; Highlight the headers.
4928 (narrow-to-region (point-min) (point))
4929 (gnus-article-save-original-date
4930 (gnus-treat-article 'head)))))))
4931 ;; Cope with broken MIME messages.
4932 (goto-char (point-max))
4936 (defcustom gnus-mime-display-multipart-as-mixed nil
4937 "Display \"multipart\" parts as \"multipart/mixed\".
4939 If t, it overrides nil values of
4940 `gnus-mime-display-multipart-alternative-as-mixed' and
4941 `gnus-mime-display-multipart-related-as-mixed'."
4942 :group 'gnus-article-mime
4945 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4946 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4948 :group 'gnus-article-mime
4951 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4952 "Display \"multipart/related\" parts as \"multipart/mixed\".
4954 If displaying \"text/html\" is discouraged \(see
4955 `mm-discouraged-alternatives'\) images or other material inside a
4956 \"multipart/related\" part might be overlooked when this variable is nil."
4958 :group 'gnus-article-mime
4961 (defun gnus-mime-display-part (handle)
4963 ;; Maybe a broken MIME message.
4966 ((not (stringp (car handle)))
4967 (gnus-mime-display-single handle))
4968 ;; User-defined multipart
4969 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4970 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4972 ;; multipart/alternative
4973 ((and (equal (car handle) "multipart/alternative")
4974 (not (or gnus-mime-display-multipart-as-mixed
4975 gnus-mime-display-multipart-alternative-as-mixed)))
4976 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4977 (push (cons id handle) gnus-article-mime-handle-alist)
4978 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4979 ;; multipart/related
4980 ((and (equal (car handle) "multipart/related")
4981 (not (or gnus-mime-display-multipart-as-mixed
4982 gnus-mime-display-multipart-related-as-mixed)))
4983 ;;;!!!We should find the start part, but we just default
4984 ;;;!!!to the first part.
4985 ;;(gnus-mime-display-part (cadr handle))
4986 ;;;!!! Most multipart/related is an HTML message plus images.
4987 ;;;!!! Unfortunately we are unable to let W3 display those
4988 ;;;!!! included images, so we just display it as a mixed multipart.
4989 ;;(gnus-mime-display-mixed (cdr handle))
4990 ;;;!!! No, w3 can display everything just fine.
4991 (gnus-mime-display-part (cadr handle)))
4992 ((equal (car handle) "multipart/signed")
4993 (gnus-add-wash-type 'signed)
4994 (gnus-mime-display-security handle))
4995 ((equal (car handle) "multipart/encrypted")
4996 (gnus-add-wash-type 'encrypted)
4997 (gnus-mime-display-security handle))
4998 ;; Other multiparts are handled like multipart/mixed.
5000 (gnus-mime-display-mixed (cdr handle)))))
5002 (defun gnus-mime-part-function (handles)
5003 (if (stringp (car handles))
5004 (mapcar 'gnus-mime-part-function (cdr handles))
5005 (funcall gnus-article-mime-part-function handles)))
5007 (defun gnus-mime-display-mixed (handles)
5008 (mapcar 'gnus-mime-display-part handles))
5010 (defun gnus-mime-display-single (handle)
5011 (let ((type (mm-handle-media-type handle))
5012 (ignored gnus-ignored-mime-types)
5019 (when (string-match (pop ignored) type)
5020 (throw 'ignored nil)))
5021 (if (and (setq not-attachment
5022 (and (not (mm-inline-override-p handle))
5023 (or (not (mm-handle-disposition handle))
5024 (equal (car (mm-handle-disposition handle))
5026 (mm-attachment-override-p handle))))
5027 (mm-automatic-display-p handle)
5029 (mm-inlinable-p handle)
5030 (mm-inlined-p handle))
5031 (mm-automatic-external-display-p type)))
5033 (when (equal (mm-handle-media-supertype handle) "text")
5035 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5037 (push (cons id handle) gnus-article-mime-handle-alist)
5039 (equal (mm-handle-media-supertype handle) "message"))
5042 (cond ((not (bolp)) 2)
5043 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5045 (when (or (not display)
5046 (not (gnus-unbuttonized-mime-type-p type)))
5047 (gnus-insert-mime-button
5048 handle id (list (or display (and not-attachment text))))
5049 (gnus-article-insert-newline)
5050 ;; Remember modify the number of forward lines.
5058 (let ((mail-parse-charset gnus-newsgroup-charset)
5059 (mail-parse-ignored-charsets
5060 (save-excursion (condition-case ()
5061 (set-buffer gnus-summary-buffer)
5063 gnus-newsgroup-ignored-charsets)))
5064 (mm-display-part handle t))
5065 (goto-char (point-max)))
5066 ((and text not-attachment)
5070 (gnus-article-insert-newline)
5073 (let ((charset (mail-content-type-get (mm-handle-type handle)
5075 (cond ((not charset)
5076 (mm-string-as-multibyte (mm-get-part handle)))
5077 ((eq charset 'gnus-decoded)
5078 (with-current-buffer (mm-handle-buffer handle)
5081 (mm-decode-string (mm-get-part handle) charset)))))
5082 (goto-char (point-max))))
5086 (narrow-to-region beg (point))
5089 (gnus-article-mime-total-parts)
5090 (mm-handle-media-type handle)))))))))
5092 (defun gnus-unbuttonized-mime-type-p (type)
5093 "Say whether TYPE is to be unbuttonized."
5094 (unless gnus-inhibit-mime-unbuttonizing
5096 (let ((types gnus-unbuttonized-mime-types))
5098 (when (string-match (pop types) type)
5099 (throw 'found t)))))
5101 (let ((types gnus-buttonized-mime-types))
5103 (when (string-match (pop types) type)
5104 (throw 'found t)))))))))
5106 (defun gnus-article-insert-newline ()
5107 "Insert a newline, but mark it as undeletable."
5108 (gnus-put-text-property
5109 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5111 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5112 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5115 handle (inhibit-read-only t) from props begend not-pref)
5116 (save-window-excursion
5119 (narrow-to-region (car ibegend)
5122 (goto-char (car ibegend))
5125 (delete-region (point-min) (point-max))
5126 (mm-remove-parts handles))
5127 (setq begend (list (point-marker)))
5129 (unless (setq not-pref (cadr (member preferred ihandles)))
5130 (setq not-pref (car ihandles)))
5133 (not (gnus-unbuttonized-mime-type-p
5134 "multipart/alternative")))
5135 (gnus-add-text-properties
5138 (insert (format "%d. " id))
5142 (unless ,(not ibegend)
5143 (setq gnus-article-mime-handle-alist
5144 ',gnus-article-mime-handle-alist))
5145 (gnus-mime-display-alternative
5146 ',ihandles ',not-pref ',begend ,id))
5147 ,@(gnus-local-map-property gnus-mime-button-map)
5148 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5149 face ,gnus-article-button-face
5151 article-type multipart))
5152 (widget-convert-button 'link from (point)
5153 :action 'gnus-widget-press-button
5154 :button-keymap gnus-widget-button-keymap)
5156 (while (setq handle (pop handles))
5157 (gnus-add-text-properties
5160 (insert (format "(%c) %-18s"
5161 (if (equal handle preferred) ?* ? )
5162 (mm-handle-media-type handle)))
5166 (unless ,(not ibegend)
5167 (setq gnus-article-mime-handle-alist
5168 ',gnus-article-mime-handle-alist))
5169 (gnus-mime-display-alternative
5170 ',ihandles ',handle ',begend ,id))
5171 ,@(gnus-local-map-property gnus-mime-button-map)
5172 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5173 face ,gnus-article-button-face
5176 (widget-convert-button 'link from (point)
5177 :action 'gnus-widget-press-button
5178 :button-keymap gnus-widget-button-keymap)
5182 (if (stringp (car preferred))
5183 (gnus-display-mime preferred)
5184 (let ((mail-parse-charset gnus-newsgroup-charset)
5185 (mail-parse-ignored-charsets
5186 (save-excursion (set-buffer gnus-summary-buffer)
5187 gnus-newsgroup-ignored-charsets)))
5188 (mm-display-part preferred)
5192 (narrow-to-region (car begend) (point-max))
5194 nil (length gnus-article-mime-handle-alist)
5195 (gnus-article-mime-total-parts)
5196 (mm-handle-media-type handle))))))
5197 (goto-char (point-max))
5198 (setcdr begend (point-marker)))))
5200 (goto-char point))))
5202 (defconst gnus-article-wash-status-strings
5203 (let ((alist '((cite "c" "Possible hidden citation text"
5204 " " "All citation text visible")
5205 (headers "h" "Hidden headers"
5206 " " "All headers visible.")
5207 (pgp "p" "Encrypted or signed message status hidden"
5208 " " "No hidden encryption nor digital signature status")
5209 (signature "s" "Signature has been hidden"
5210 " " "Signature is visible")
5211 (overstrike "o" "Overstrike (^H) characters applied"
5212 " " "No overstrike characters applied")
5213 (emphasis "e" "/*_Emphasis_*/ characters applied"
5214 " " "No /*_emphasis_*/ characters applied")))
5216 (dolist (entry alist result)
5217 (let ((key (nth 0 entry))
5218 (on (copy-sequence (nth 1 entry)))
5219 (on-help (nth 2 entry))
5220 (off (copy-sequence (nth 3 entry)))
5221 (off-help (nth 4 entry)))
5222 (put-text-property 0 1 'help-echo on-help on)
5223 (put-text-property 0 1 'help-echo off-help off)
5224 (push (list key on off) result))))
5225 "Alist of strings describing wash status in the mode line.
5226 Each entry has the form (KEY ON OF), where the KEY is a symbol
5227 representing the particular washing function, ON is the string to use
5228 in the article mode line when the washing function is active, and OFF
5229 is the string to use when it is inactive.")
5231 (defun gnus-article-wash-status-entry (key value)
5232 (let ((entry (assoc key gnus-article-wash-status-strings)))
5233 (if value (nth 1 entry) (nth 2 entry))))
5235 (defun gnus-article-wash-status ()
5236 "Return a string which display status of article washing."
5238 (set-buffer gnus-article-buffer)
5239 (let ((cite (memq 'cite gnus-article-wash-types))
5240 (headers (memq 'headers gnus-article-wash-types))
5241 (boring (memq 'boring-headers gnus-article-wash-types))
5242 (pgp (memq 'pgp gnus-article-wash-types))
5243 (pem (memq 'pem gnus-article-wash-types))
5244 (signed (memq 'signed gnus-article-wash-types))
5245 (encrypted (memq 'encrypted gnus-article-wash-types))
5246 (signature (memq 'signature gnus-article-wash-types))
5247 (overstrike (memq 'overstrike gnus-article-wash-types))
5248 (emphasis (memq 'emphasis gnus-article-wash-types)))
5250 (gnus-article-wash-status-entry 'cite cite)
5251 (gnus-article-wash-status-entry 'headers (or headers boring))
5252 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5253 (gnus-article-wash-status-entry 'signature signature)
5254 (gnus-article-wash-status-entry 'overstrike overstrike)
5255 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5257 (defun gnus-add-wash-type (type)
5258 "Add a washing of TYPE to the current status."
5259 (add-to-list 'gnus-article-wash-types type))
5261 (defun gnus-delete-wash-type (type)
5262 "Add a washing of TYPE to the current status."
5263 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5265 (defun gnus-add-image (category image)
5266 "Add IMAGE of CATEGORY to the list of displayed images."
5267 (let ((entry (assq category gnus-article-image-alist)))
5269 (setq entry (list category))
5270 (push entry gnus-article-image-alist))
5271 (nconc entry (list image))))
5273 (defun gnus-delete-images (category)
5274 "Delete all images in CATEGORY."
5275 (let ((entry (assq category gnus-article-image-alist)))
5276 (dolist (image (cdr entry))
5277 (gnus-remove-image image category))
5278 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5279 (gnus-delete-wash-type category)))
5281 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5283 (defun gnus-article-maybe-hide-headers ()
5284 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5285 Provided for backwards compatibility."
5286 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5287 (not (save-excursion (set-buffer gnus-summary-buffer)
5288 gnus-have-all-headers)))
5289 (not gnus-inhibit-hiding))
5290 (gnus-article-hide-headers)))
5294 (defun gnus-output-to-file (file-name)
5295 "Append the current article to a file named FILE-NAME.
5296 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5297 text and used as the value of the coding cookie which is added to the
5298 top of a file. Otherwise, this function saves a raw article without
5300 (let* ((artbuf (current-buffer))
5301 (file-name-coding-system nnmail-pathname-coding-system)
5302 (coding gnus-article-save-coding-system)
5303 (coding-system-for-read (if coding
5304 nil ;; Rely on the coding cookie.
5305 mm-text-coding-system))
5306 (coding-system-for-write (or coding
5307 mm-text-coding-system-for-write
5308 mm-text-coding-system))
5309 (exists (file-exists-p file-name)))
5312 (insert-file-contents file-name)
5313 (goto-char (point-min))
5314 ;; Remove the existing coding cookie.
5315 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5316 (delete-region (match-beginning 0) (match-end 0))))
5317 (goto-char (point-max))
5318 (insert-buffer-substring artbuf)
5319 ;; Append newline at end of the buffer as separator, and then
5321 (goto-char (point-max))
5324 ;; If the coding system is not suitable to encode the text,
5325 ;; ask a user for a proper one.
5326 (when (fboundp 'select-safe-coding-system)
5327 (setq coding (coding-system-base
5328 (save-window-excursion
5329 (select-safe-coding-system (point-min) (point-max)
5331 (setq coding-system-for-write
5332 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5334 (goto-char (point-min))
5335 ;; Add the coding cookie.
5336 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5337 coding-system-for-write)))
5340 (write-region (point-min) (point-max) file-name nil 'no-message)
5341 (message "Appended to %s" file-name))
5342 (write-region (point-min) (point-max) file-name))))
5345 (defun gnus-narrow-to-page (&optional arg)
5346 "Narrow the article buffer to a page.
5347 If given a numerical ARG, move forward ARG pages."
5349 (setq arg (if arg (prefix-numeric-value arg) 0))
5351 (set-buffer gnus-article-buffer)
5352 (goto-char (point-min))
5354 ;; Remove any old next/prev buttons.
5355 (when (gnus-visual-p 'page-marker)
5356 (let ((inhibit-read-only t))
5357 (gnus-remove-text-with-property 'gnus-prev)
5358 (gnus-remove-text-with-property 'gnus-next)))
5361 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5363 (re-search-forward page-delimiter nil 'move arg)))
5364 (goto-char (match-end 0))
5366 (goto-char (point-min))
5367 (setq gnus-page-broken
5368 (and (re-search-forward page-delimiter nil t) t))))
5369 (when gnus-page-broken
5372 (if (re-search-forward page-delimiter nil 'move)
5375 (when (and (gnus-visual-p 'page-marker)
5376 (> (point-min) (save-restriction (widen) (point-min))))
5378 (goto-char (point-min))
5379 (gnus-insert-prev-page-button)))
5380 (when (and (gnus-visual-p 'page-marker)
5381 (< (point-max) (save-restriction (widen) (point-max))))
5383 (goto-char (point-max))
5384 (gnus-insert-next-page-button))))))
5386 ;; Article mode commands
5388 (defun gnus-article-goto-next-page ()
5389 "Show the next page of the article."
5391 (when (gnus-article-next-page)
5392 (goto-char (point-min))
5393 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5396 (defun gnus-article-goto-prev-page ()
5397 "Show the previous page of the article."
5400 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5401 (gnus-article-prev-page nil)))
5403 ;; This is cleaner but currently breaks `gnus-pick-mode':
5405 ;; (defun gnus-article-goto-next-page ()
5406 ;; "Show the next page of the article."
5408 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5409 ;; (gnus-summary-next-page)))
5411 ;; (defun gnus-article-goto-prev-page ()
5412 ;; "Show the next page of the article."
5414 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5415 ;; (gnus-summary-prev-page)))
5417 (defun gnus-article-next-page (&optional lines)
5418 "Show the next page of the current article.
5419 If end of article, return non-nil. Otherwise return nil.
5420 Argument LINES specifies lines to be scrolled up."
5422 (move-to-window-line -1)
5425 (and (pos-visible-in-window-p) ;Not continuation line.
5426 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5427 ;; Nothing in this page.
5428 (if (or (not gnus-page-broken)
5433 (eobp)))) ;Real end-of-buffer?
5435 (when gnus-article-over-scroll
5436 (gnus-article-next-page-1 lines))
5438 (gnus-narrow-to-page 1) ;Go to next page.
5440 ;; More in this page.
5441 (gnus-article-next-page-1 lines)
5444 (defmacro gnus-article-beginning-of-window ()
5445 "Move point to the beginning of the window.
5446 In Emacs, the point is placed at the line number which `scroll-margin'
5448 (if (featurep 'xemacs)
5449 '(move-to-window-line 0)
5450 '(move-to-window-line
5451 (min (max 0 scroll-margin)
5452 (max 1 (- (window-height)
5453 (if mode-line-format 1 0)
5454 (if (and (boundp 'header-line-format)
5455 (symbol-value 'header-line-format))
5458 (defun gnus-article-next-page-1 (lines)
5459 (when (and (not (featurep 'xemacs))
5462 (numberp (symbol-value 'scroll-margin))
5463 (> (symbol-value 'scroll-margin) 0))
5464 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5465 ;; too many number of lines if `scroll-margin' is set as two or greater.
5466 (setq lines (min lines
5467 (max 0 (- (count-lines (window-start) (point-max))
5468 (symbol-value 'scroll-margin))))))
5470 (let ((scroll-in-place nil))
5473 ;; Long lines may cause an end-of-buffer error.
5474 (goto-char (point-max))))
5475 (gnus-article-beginning-of-window))
5477 (defun gnus-article-prev-page (&optional lines)
5478 "Show previous page of current article.
5479 Argument LINES specifies lines to be scrolled down."
5481 (move-to-window-line 0)
5482 (if (and gnus-page-broken
5484 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5486 (gnus-narrow-to-page -1) ;Go to previous page.
5487 (goto-char (point-max))
5491 (let ((scroll-in-place nil))
5492 (scroll-down lines))
5493 (beginning-of-buffer
5494 (goto-char (point-min))))
5495 (gnus-article-beginning-of-window))))
5497 (defun gnus-article-only-boring-p ()
5498 "Decide whether there is only boring text remaining in the article.
5499 Something \"interesting\" is a word of at least two letters that does
5500 not have a face in `gnus-article-boring-faces'."
5501 (when (and gnus-article-skip-boring
5502 (boundp 'gnus-article-boring-faces)
5503 (symbol-value 'gnus-article-boring-faces))
5505 (let ((inhibit-point-motion-hooks t))
5507 (while (re-search-forward "\\b\\w\\w" nil t)
5509 (when (not (gnus-intersection
5510 (gnus-faces-at (point))
5511 (symbol-value 'gnus-article-boring-faces)))
5512 (throw 'only-boring nil)))
5513 (throw 'only-boring t))))))
5515 (defun gnus-article-refer-article ()
5516 "Read article specified by message-id around point."
5519 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5520 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5521 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5522 (let ((msg-id (concat "<" (match-string 0) ">")))
5523 (set-buffer gnus-summary-buffer)
5524 (gnus-summary-refer-article msg-id))
5525 (error "No references around point"))))
5527 (defun gnus-article-show-summary ()
5528 "Reconfigure windows to show summary buffer."
5530 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5531 (error "There is no summary buffer for this article buffer")
5532 (gnus-article-set-globals)
5533 (gnus-configure-windows 'article)
5534 (gnus-summary-goto-subject gnus-current-article)
5535 (gnus-summary-position-point)))
5537 (defun gnus-article-describe-briefly ()
5538 "Describe article mode commands briefly."
5540 (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")))
5542 (defun gnus-article-summary-command ()
5543 "Execute the last keystroke in the summary buffer."
5545 (let ((obuf (current-buffer))
5546 (owin (current-window-configuration))
5548 (switch-to-buffer gnus-article-current-summary 'norecord)
5549 (setq func (lookup-key (current-local-map) (this-command-keys)))
5550 (call-interactively func)
5552 (set-window-configuration owin)
5553 (set-window-point (get-buffer-window (current-buffer)) (point))))
5555 (defun gnus-article-summary-command-nosave ()
5556 "Execute the last keystroke in the summary buffer."
5559 (pop-to-buffer gnus-article-current-summary 'norecord)
5560 (setq func (lookup-key (current-local-map) (this-command-keys)))
5561 (call-interactively func)))
5563 (defun gnus-article-check-buffer ()
5564 "Beep if not in an article buffer."
5565 (unless (equal major-mode 'gnus-article-mode)
5566 (error "Command invoked outside of a Gnus article buffer")))
5568 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5569 "Read a summary buffer key sequence and execute it from the article buffer."
5571 (gnus-article-check-buffer)
5573 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5574 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5575 "=" "^" "\M-^" "|"))
5581 '("n" "Gn" "p" "Gp"))
5584 (set-buffer gnus-article-current-summary)
5585 (let (gnus-pick-mode)
5586 (push (or key last-command-event) unread-command-events)
5587 (setq keys (if (featurep 'xemacs)
5588 (events-to-keys (read-key-sequence nil))
5589 (read-key-sequence nil)))))
5593 (if (or (member keys nosaves)
5594 (member keys nosave-but-article)
5595 (member keys nosave-in-article))
5597 (save-window-excursion
5598 (pop-to-buffer gnus-article-current-summary 'norecord)
5599 ;; We disable the pick minor mode commands.
5600 (let (gnus-pick-mode)
5601 (setq func (lookup-key (current-local-map) keys))))
5605 (unless (member keys nosave-in-article)
5606 (set-buffer gnus-article-current-summary))
5607 (call-interactively func)
5608 (setq new-sum-point (point)))
5609 (when (member keys nosave-but-article)
5610 (pop-to-buffer gnus-article-buffer 'norecord)))
5611 ;; These commands should restore window configuration.
5612 (let ((obuf (current-buffer))
5613 (owin (current-window-configuration))
5615 win func in-buffer selected new-sum-start new-sum-hscroll)
5616 (cond (not-restore-window
5617 (pop-to-buffer gnus-article-current-summary 'norecord))
5618 ((setq win (get-buffer-window gnus-article-current-summary))
5619 (select-window win))
5621 (switch-to-buffer gnus-article-current-summary 'norecord)))
5622 (setq in-buffer (current-buffer))
5623 ;; We disable the pick minor mode commands.
5624 (if (and (setq func (let (gnus-pick-mode)
5625 (lookup-key (current-local-map) keys)))
5628 (call-interactively func)
5629 (when (eq win (selected-window))
5630 (setq new-sum-point (point)
5631 new-sum-start (window-start win)
5632 new-sum-hscroll (window-hscroll win)))
5633 (when (eq in-buffer (current-buffer))
5634 (setq selected (gnus-summary-select-article))
5636 (unless not-restore-window
5637 (set-window-configuration owin))
5638 (when (eq selected 'old)
5640 (set-window-start (get-buffer-window (current-buffer))
5642 (set-window-point (get-buffer-window (current-buffer))
5644 (when (and (not not-restore-window)
5646 (set-window-point win new-sum-point)
5647 (set-window-start win new-sum-start)
5648 (set-window-hscroll win new-sum-hscroll))))
5649 (set-window-configuration owin)
5652 (defun gnus-article-describe-key (key)
5653 "Display documentation of the function invoked by KEY. KEY is a string."
5654 (interactive "kDescribe key: ")
5655 (gnus-article-check-buffer)
5656 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5658 (set-buffer gnus-article-current-summary)
5659 (let (gnus-pick-mode)
5660 (if (featurep 'xemacs)
5662 (push (elt key 0) unread-command-events)
5663 (setq key (events-to-keys
5664 (read-key-sequence "Describe key: "))))
5665 (setq unread-command-events
5667 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5668 (string-to-list key)))
5669 (setq key (read-key-sequence "Describe key: "))))
5671 (describe-key key)))
5673 (defun gnus-article-describe-key-briefly (key &optional insert)
5674 "Display documentation of the function invoked by KEY. KEY is a string."
5675 (interactive "kDescribe key: \nP")
5676 (gnus-article-check-buffer)
5677 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5679 (set-buffer gnus-article-current-summary)
5680 (let (gnus-pick-mode)
5681 (if (featurep 'xemacs)
5683 (push (elt key 0) unread-command-events)
5684 (setq key (events-to-keys
5685 (read-key-sequence "Describe key: "))))
5686 (setq unread-command-events
5688 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5689 (string-to-list key)))
5690 (setq key (read-key-sequence "Describe key: "))))
5691 (describe-key-briefly key insert))
5692 (describe-key-briefly key insert)))
5694 (defun gnus-article-reply-with-original (&optional wide)
5695 "Start composing a reply mail to the current message.
5696 The text in the region will be yanked. If the region isn't active,
5697 the entire article will be yanked."
5699 (let ((article (cdr gnus-article-current))
5701 (if (not (gnus-mark-active-p))
5702 (with-current-buffer gnus-summary-buffer
5703 (gnus-summary-reply (list (list article)) wide))
5704 (setq contents (buffer-substring (point) (mark t)))
5705 ;; Deactivate active regions.
5706 (when (and (boundp 'transient-mark-mode)
5707 transient-mark-mode)
5708 (setq mark-active nil))
5709 (with-current-buffer gnus-summary-buffer
5711 (list (list article contents)) wide)))))
5713 (defun gnus-article-followup-with-original ()
5714 "Compose a followup to the current article.
5715 The text in the region will be yanked. If the region isn't active,
5716 the entire article will be yanked."
5718 (let ((article (cdr gnus-article-current))
5720 (if (not (gnus-mark-active-p))
5721 (with-current-buffer gnus-summary-buffer
5722 (gnus-summary-followup (list (list article))))
5723 (setq contents (buffer-substring (point) (mark t)))
5724 ;; Deactivate active regions.
5725 (when (and (boundp 'transient-mark-mode)
5726 transient-mark-mode)
5727 (setq mark-active nil))
5728 (with-current-buffer gnus-summary-buffer
5729 (gnus-summary-followup
5730 (list (list article contents)))))))
5732 (defun gnus-article-hide (&optional arg force)
5733 "Hide all the gruft in the current article.
5734 This means that signatures, cited text and (some) headers will be
5736 If given a prefix, show the hidden text instead."
5737 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5738 (gnus-article-hide-headers arg)
5739 (gnus-article-hide-list-identifiers arg)
5740 (gnus-article-hide-citation-maybe arg force)
5741 (gnus-article-hide-signature arg))
5743 (defun gnus-article-maybe-highlight ()
5744 "Do some article highlighting if article highlighting is requested."
5745 (when (gnus-visual-p 'article-highlight 'highlight)
5746 (gnus-article-highlight-some)))
5748 (defun gnus-check-group-server ()
5749 ;; Make sure the connection to the server is alive.
5750 (unless (gnus-server-opened
5751 (gnus-find-method-for-group gnus-newsgroup-name))
5752 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5753 (gnus-request-group gnus-newsgroup-name t)))
5756 (autoload 'nneething-get-file-name "nneething"))
5758 (defun gnus-request-article-this-buffer (article group)
5759 "Get an article and insert it into this buffer."
5760 (let (do-update-line sparse-header)
5764 (gnus-kill-all-overlays)
5765 (setq group (or group gnus-newsgroup-name))
5767 ;; Using `gnus-request-article' directly will insert the article into
5768 ;; `nntp-server-buffer' - so we'll save some time by not having to
5769 ;; copy it from the server buffer into the article buffer.
5771 ;; We only request an article by message-id when we do not have the
5772 ;; headers for it, so we'll have to get those.
5773 (when (stringp article)
5774 (gnus-read-header article))
5776 ;; If the article number is negative, that means that this article
5777 ;; doesn't belong in this newsgroup (possibly), so we find its
5778 ;; message-id and request it by id instead of number.
5779 (when (and (numberp article)
5781 (get-buffer gnus-summary-buffer)
5782 (gnus-buffer-exists-p gnus-summary-buffer))
5784 (set-buffer gnus-summary-buffer)
5785 (let ((header (gnus-summary-article-header article)))
5788 ((memq article gnus-newsgroup-sparse)
5789 ;; This is a sparse gap article.
5790 (setq do-update-line article)
5791 (setq article (mail-header-id header))
5792 (setq sparse-header (gnus-read-header article))
5793 (setq gnus-newsgroup-sparse
5794 (delq article gnus-newsgroup-sparse)))
5796 ;; It's a real article.
5797 (setq article (mail-header-id header)))
5799 ;; It is an extracted pseudo-article.
5800 (setq article 'pseudo)
5801 (gnus-request-pseudo-article header))))
5803 (let ((method (gnus-find-method-for-group
5804 gnus-newsgroup-name)))
5805 (when (and (eq (car method) 'nneething)
5807 (let ((dir (nneething-get-file-name
5808 (mail-header-id header))))
5809 (when (and (stringp dir)
5810 (file-directory-p dir))
5811 (setq article 'nneething)
5812 (gnus-group-enter-directory dir))))))))
5815 ;; Refuse to select canceled articles.
5816 ((and (numberp article)
5818 (get-buffer gnus-summary-buffer)
5819 (gnus-buffer-exists-p gnus-summary-buffer)
5820 (eq (cdr (save-excursion
5821 (set-buffer gnus-summary-buffer)
5822 (assq article gnus-newsgroup-reads)))
5823 gnus-canceled-mark))
5825 ;; We first check `gnus-original-article-buffer'.
5826 ((and (get-buffer gnus-original-article-buffer)
5829 (set-buffer gnus-original-article-buffer)
5830 (and (equal (car gnus-original-article) group)
5831 (eq (cdr gnus-original-article) article))))
5832 (insert-buffer-substring gnus-original-article-buffer)
5834 ;; Check the backlog.
5835 ((and gnus-keep-backlog
5836 (gnus-backlog-request-article group article (current-buffer)))
5838 ;; Check asynchronous pre-fetch.
5839 ((gnus-async-request-fetched-article group article (current-buffer))
5840 (gnus-async-prefetch-next group article gnus-summary-buffer)
5841 (when (and (numberp article) gnus-keep-backlog)
5842 (gnus-backlog-enter-article group article (current-buffer)))
5845 ((and gnus-use-cache
5847 (gnus-cache-request-article article group))
5849 ;; Check the agent cache.
5850 ((gnus-agent-request-article article group)
5852 ;; Get the article and put into the article buffer.
5853 ((or (stringp article)
5855 (let ((gnus-override-method gnus-override-method)
5856 (methods (and (stringp article)
5857 gnus-refer-article-method))
5858 (backend (car (gnus-find-method-for-group
5859 gnus-newsgroup-name)))
5861 (inhibit-read-only t))
5862 (if (or (not (listp methods))
5863 (and (symbolp (car methods))
5864 (assq (car methods) nnoo-definition-alist)))
5865 (setq methods (list methods)))
5866 (when (and (null gnus-override-method)
5868 (setq gnus-override-method (pop methods)))
5870 (when (eq gnus-override-method 'current)
5871 (setq gnus-override-method
5872 (with-current-buffer gnus-summary-buffer
5873 gnus-current-select-method)))
5875 (gnus-kill-all-overlays)
5876 (let ((gnus-newsgroup-name group))
5877 (gnus-check-group-server))
5879 ((gnus-request-article article group (current-buffer))
5880 (when (numberp article)
5881 (gnus-async-prefetch-next group article
5882 gnus-summary-buffer)
5883 (when gnus-keep-backlog
5884 (gnus-backlog-enter-article
5885 group article (current-buffer))))
5886 (setq result 'article))
5888 (setq gnus-override-method (pop methods)))
5889 ((not (string-match "^400 "
5890 (nnheader-get-report backend)))
5891 ;; If we get 400 server disconnect, reconnect and
5892 ;; retry; otherwise, assume the article has expired.
5893 (setq result 'done))))
5894 (and (eq result 'article) 'article)))
5898 ;; Associate this article with the current summary buffer.
5899 (setq gnus-article-current-summary gnus-summary-buffer)
5901 ;; Take the article from the original article buffer
5902 ;; and place it in the buffer it's supposed to be in.
5903 (when (and (get-buffer gnus-article-buffer)
5904 (equal (buffer-name (current-buffer))
5905 (buffer-name (get-buffer gnus-article-buffer))))
5907 (if (get-buffer gnus-original-article-buffer)
5908 (set-buffer gnus-original-article-buffer)
5909 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5910 (buffer-disable-undo)
5911 (setq major-mode 'gnus-original-article-mode)
5912 (setq buffer-read-only t))
5913 (let ((inhibit-read-only t))
5915 (insert-buffer-substring gnus-article-buffer))
5916 (setq gnus-original-article (cons group article)))
5919 (run-hooks 'gnus-article-decode-hook)
5920 ;; Mark article as decoded or not.
5921 (setq gnus-article-decoded-p gnus-article-decode-hook))
5923 ;; Update sparse articles.
5924 (when (and do-update-line
5925 (or (numberp article)
5927 (let ((buf (current-buffer)))
5928 (set-buffer gnus-summary-buffer)
5929 (gnus-summary-update-article do-update-line sparse-header)
5930 (gnus-summary-goto-subject do-update-line nil t)
5931 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5933 (set-buffer buf))))))
5939 (defcustom gnus-article-edit-mode-hook nil
5940 "Hook run in article edit mode buffers."
5941 :group 'gnus-article-various
5944 (defvar gnus-article-edit-done-function nil)
5946 (defvar gnus-article-edit-mode-map nil)
5947 (defvar gnus-article-edit-mode nil)
5949 ;; Should we be using derived.el for this?
5950 (unless gnus-article-edit-mode-map
5951 (setq gnus-article-edit-mode-map (make-keymap))
5952 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5954 (gnus-define-keys gnus-article-edit-mode-map
5955 "\C-c?" describe-mode
5956 "\C-c\C-c" gnus-article-edit-done
5957 "\C-c\C-k" gnus-article-edit-exit
5958 "\C-c\C-f\C-t" message-goto-to
5959 "\C-c\C-f\C-o" message-goto-from
5960 "\C-c\C-f\C-b" message-goto-bcc
5961 ;;"\C-c\C-f\C-w" message-goto-fcc
5962 "\C-c\C-f\C-c" message-goto-cc
5963 "\C-c\C-f\C-s" message-goto-subject
5964 "\C-c\C-f\C-r" message-goto-reply-to
5965 "\C-c\C-f\C-n" message-goto-newsgroups
5966 "\C-c\C-f\C-d" message-goto-distribution
5967 "\C-c\C-f\C-f" message-goto-followup-to
5968 "\C-c\C-f\C-m" message-goto-mail-followup-to
5969 "\C-c\C-f\C-k" message-goto-keywords
5970 "\C-c\C-f\C-u" message-goto-summary
5971 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5972 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5973 "\C-c\C-b" message-goto-body
5974 "\C-c\C-i" message-goto-signature
5976 "\C-c\C-t" message-insert-to
5977 "\C-c\C-n" message-insert-newsgroups
5978 "\C-c\C-o" message-sort-headers
5979 "\C-c\C-e" message-elide-region
5980 "\C-c\C-v" message-delete-not-region
5981 "\C-c\C-z" message-kill-to-signature
5982 "\M-\r" message-newline-and-reformat
5983 "\C-c\C-a" mml-attach-file
5984 "\C-a" message-beginning-of-line
5986 "\M-;" comment-region)
5988 (gnus-define-keys (gnus-article-edit-wash-map
5989 "\C-c\C-w" gnus-article-edit-mode-map)
5990 "f" gnus-article-edit-full-stops))
5993 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5995 ["Fetch To" message-insert-to t]
5996 ["Fetch Newsgroups" message-insert-newsgroups t]
5998 ["To" message-goto-to t]
5999 ["From" message-goto-from t]
6000 ["Subject" message-goto-subject t]
6001 ["Cc" message-goto-cc t]
6002 ["Reply-To" message-goto-reply-to t]
6003 ["Summary" message-goto-summary t]
6004 ["Keywords" message-goto-keywords t]
6005 ["Newsgroups" message-goto-newsgroups t]
6006 ["Followup-To" message-goto-followup-to t]
6007 ["Mail-Followup-To" message-goto-mail-followup-to t]
6008 ["Distribution" message-goto-distribution t]
6009 ["Body" message-goto-body t]
6010 ["Signature" message-goto-signature t]))
6012 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6013 "Major mode for editing articles.
6014 This is an extended text-mode.
6016 \\{gnus-article-edit-mode-map}"
6017 (make-local-variable 'gnus-article-edit-done-function)
6018 (make-local-variable 'gnus-prev-winconf)
6019 (set (make-local-variable 'font-lock-defaults)
6020 '(message-font-lock-keywords t))
6021 (set (make-local-variable 'mail-header-separator) "")
6022 (set (make-local-variable 'gnus-article-edit-mode) t)
6023 (easy-menu-add message-mode-field-menu message-mode-map)
6025 (setq buffer-read-only nil)
6026 (buffer-enable-undo)
6029 (defun gnus-article-edit (&optional force)
6030 "Edit the current article.
6031 This will have permanent effect only in mail groups.
6032 If FORCE is non-nil, allow editing of articles even in read-only
6035 (when (and (not force)
6036 (gnus-group-read-only-p))
6037 (error "The current newsgroup does not support article editing"))
6038 (gnus-article-date-original)
6039 (gnus-article-edit-article
6041 `(lambda (no-highlight)
6043 (gnus-summary-edit-article-done
6044 ,(or (mail-header-references gnus-current-headers) "")
6045 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6047 (defun gnus-article-edit-article (start-func exit-func)
6048 "Start editing the contents of the current article buffer."
6049 (let ((winconf (current-window-configuration)))
6050 (set-buffer gnus-article-buffer)
6051 (let ((message-auto-save-directory
6052 ;; Don't associate the article buffer with a draft file.
6054 (gnus-article-edit-mode))
6055 (funcall start-func)
6056 (set-buffer-modified-p nil)
6057 (gnus-configure-windows 'edit-article)
6058 (setq gnus-article-edit-done-function exit-func)
6059 (setq gnus-prev-winconf winconf)
6060 (gnus-message 6 "C-c C-c to end edits")))
6062 (defun gnus-article-edit-done (&optional arg)
6063 "Update the article edits and exit."
6065 (let ((func gnus-article-edit-done-function)
6066 (buf (current-buffer))
6067 (start (window-start))
6069 (winconf gnus-prev-winconf))
6070 (widen) ;; Widen it in case that users narrowed the buffer.
6073 ;; The cache and backlog have to be flushed somewhat.
6074 (when gnus-keep-backlog
6075 (gnus-backlog-remove-article
6076 (car gnus-article-current) (cdr gnus-article-current)))
6077 ;; Flush original article as well.
6079 (when (get-buffer gnus-original-article-buffer)
6080 (set-buffer gnus-original-article-buffer)
6081 (setq gnus-original-article nil)))
6082 (when gnus-use-cache
6083 (gnus-cache-update-article
6084 (car gnus-article-current) (cdr gnus-article-current)))
6085 ;; We remove all text props from the article buffer.
6086 (kill-all-local-variables)
6087 (gnus-set-text-properties (point-min) (point-max) nil)
6089 (set-window-configuration winconf)
6091 (set-window-start (get-buffer-window buf) start)
6092 (set-window-point (get-buffer-window buf) (point)))
6093 (gnus-summary-show-article))
6095 (defun gnus-article-edit-exit ()
6096 "Exit the article editing without updating."
6098 (when (or (not (buffer-modified-p))
6099 (yes-or-no-p "Article modified; kill anyway? "))
6100 (let ((curbuf (current-buffer))
6102 (window-start (window-start)))
6104 (if (gnus-buffer-live-p gnus-original-article-buffer)
6105 (insert-buffer-substring gnus-original-article-buffer))
6106 (let ((winconf gnus-prev-winconf))
6107 (kill-all-local-variables)
6109 (set-window-configuration winconf)
6110 ;; Tippy-toe some to make sure that point remains where it was.
6111 (save-current-buffer
6113 (set-window-start (get-buffer-window (current-buffer)) window-start)
6115 (gnus-summary-show-article)))
6117 (defun gnus-article-edit-full-stops ()
6118 "Interactively repair spacing at end of sentences."
6121 (goto-char (point-min))
6122 (search-forward-regexp "^$" nil t)
6123 (let ((case-fold-search nil))
6124 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6127 ;;; Article highlights
6130 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6132 ;;; Internal Variables:
6134 (defcustom gnus-button-url-regexp
6135 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6136 "\\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:]]\\)"
6137 "\\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\\)\\)")
6138 "Regular expression that matches URLs."
6139 :group 'gnus-article-buttons
6142 (defcustom gnus-button-valid-fqdn-regexp
6143 message-valid-fqdn-regexp
6144 "Regular expression that matches a valid FQDN."
6146 :group 'gnus-article-buttons
6149 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6150 (defcustom gnus-button-valid-localpart-regexp
6151 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6152 "Regular expression that matches a localpart of mail addresses or MIDs."
6154 :group 'gnus-article-buttons
6157 (defcustom gnus-button-man-handler 'manual-entry
6158 "Function to use for displaying man pages.
6159 The function must take at least one argument with a string naming the
6162 :type '(choice (function-item :tag "Man" manual-entry)
6163 (function-item :tag "Woman" woman)
6164 (function :tag "Other"))
6165 :group 'gnus-article-buttons)
6167 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6168 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6169 If the default site is too slow, try to find a CTAN mirror, see
6170 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6171 the variable `gnus-button-handle-ctan'."
6173 :group 'gnus-article-buttons
6174 :link '(custom-manual "(gnus)Group Parameters")
6175 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6176 (const "http://tug.ctan.org/tex-archive/")
6177 (const "http://www.dante.de/CTAN/")
6178 (string :tag "Other")))
6180 (defcustom gnus-button-ctan-handler 'browse-url
6181 "Function to use for displaying CTAN links.
6182 The function must take one argument, the string naming the URL."
6184 :type '(choice (function-item :tag "Browse Url" browse-url)
6185 (function :tag "Other"))
6186 :group 'gnus-article-buttons)
6188 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6189 "Bogus strings removed from CTAN URLs."
6191 :group 'gnus-article-buttons
6192 :type '(choice (const "^/?tex-archive/\\|/")
6193 (regexp :tag "Other")))
6195 (defcustom gnus-button-ctan-directory-regexp
6197 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6198 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6199 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6200 "tds" "tools" "usergrps" "web") t)
6201 "Regular expression for ctan directories.
6202 It should match all directories in the top level of `gnus-ctan-url'."
6204 :group 'gnus-article-buttons
6207 (defcustom gnus-button-mid-or-mail-regexp
6208 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6209 gnus-button-valid-fqdn-regexp
6211 "Regular expression that matches a message ID or a mail address."
6213 :group 'gnus-article-buttons
6216 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6217 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6218 Strings like this can be either a message ID or a mail address. If it is one
6219 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6220 message ID or a mail address, respectively. If this variable is set to the
6221 symbol `ask', always query the user what do do. If it is a function, this
6222 function will be called with the string as it's only argument. The function
6223 must return `mid', `mail', `invalid' or `ask'."
6225 :group 'gnus-article-buttons
6226 :type '(choice (function-item :tag "Heuristic function"
6227 gnus-button-mid-or-mail-heuristic)
6232 (defcustom gnus-button-mid-or-mail-heuristic-alist
6233 '((-10.0 . ".+\\$.+@")
6236 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6237 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6238 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6239 (-1.0 . "^[^a-z]+@")
6241 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6242 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6243 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6244 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6247 (-1.0 . "^[0-9][0-9]")
6249 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6250 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6251 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6252 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6254 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6255 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6258 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6260 ;; compensation for TDMA dated mail addresses:
6261 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6263 (-20.0 . "\\.fsf@") ;; Gnus
6266 (-20.0 . "_-_") ;; Subject change in thread
6268 (-20.0 . "\\.ln@") ;; leafnode
6269 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6270 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6272 ;; (5.0 . "") ;; $local_part_len <= 7
6273 (10.0 . "^[^0-9]+@")
6274 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6275 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6278 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6280 (0.5 . "^[A-Z][a-z]")
6281 (0.5 . "^[A-Z][a-z][a-z]")
6282 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6283 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6284 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6286 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6287 address. The REGEXP is processed with `case-fold-search' set to nil."
6289 :group 'gnus-article-buttons
6290 :type '(repeat (cons (number :tag "Rate")
6291 (regexp :tag "Regexp"))))
6293 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6294 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6295 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6296 address, `ask' if unsure and `invalid' if the string is invalid."
6297 (let ((case-fold-search nil)
6298 (list gnus-button-mid-or-mail-heuristic-alist)
6299 (result 0) rate regexp lpartlen elem)
6301 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6302 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6303 ;; Certain special cases...
6306 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6307 "^[0-9]+\\.[0-9]+@compuserve\\|"
6308 "@public\\.gmane\\.org")
6310 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6311 (setq result 'mail))
6312 (when (string-match "@.*@\\| " mid-or-mail)
6313 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6314 (setq result 'invalid))
6315 ;; Nothing more to do, if result is not a number here...
6316 (when (numberp result)
6318 (setq elem (car list)
6322 (when (string-match regexp mid-or-mail)
6323 (setq result (+ result rate))
6325 9 "`%s' matched `%s', rate `%s', result `%s'."
6326 mid-or-mail regexp rate result)))
6327 (when (<= lpartlen 7)
6328 (setq result (+ result 5.0))
6329 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6330 mid-or-mail result))
6331 (when (>= lpartlen 12)
6332 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6334 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6335 ;; Long local part should contain realname if e-mail address,
6336 ;; too many digits: message-id.
6337 ;; $score -= 5.0 + 0.1 * $local_part_len;
6338 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6339 (setq result (+ result rate))
6341 9 "Many digits in `%s', rate `%s', result `%s'."
6342 mid-or-mail rate result))
6343 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6345 ;; Too few vowels [^aeiouy]{4,}.*\@
6346 (setq result (+ result -5.0))
6348 9 "Few vowels in `%s', rate `%s', result `%s'."
6349 mid-or-mail -5.0 result))
6351 (setq result (+ result 5.0))
6353 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6354 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6355 ;; Maybe we should make this a customizable alist: (condition . 'result)
6357 ((symbolp result) result)
6358 ;; Now convert number into proper results:
6359 ((< result -10.0) 'mid)
6360 ((> result 10.0) 'mail)
6363 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6364 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6365 (url-mid (concat "news" ":" mid-or-mail))
6366 (url-mailto (concat "mailto" ":" mid-or-mail)))
6367 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6368 (when (fboundp pref)
6370 ;; get rid of surrounding angles...
6372 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6373 (if (or (eq 'mid guessed) (eq 'mail guessed))
6377 (save-window-excursion
6378 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6381 (cond ((eq pref 'mid)
6382 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6383 (gnus-button-handle-news url-mid))
6385 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6386 (gnus-url-mailto url-mailto))
6387 (t (gnus-message 3 "Invalid string.")))))
6389 (defun gnus-button-handle-custom (url)
6390 "Follow a Custom URL."
6391 (customize-apropos (gnus-url-unhex-string url)))
6393 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6395 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6398 (defun gnus-button-handle-describe-function (url)
6399 "Call `describe-function' when pushing the corresponding URL button."
6402 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6404 (defun gnus-button-handle-describe-variable (url)
6405 "Call `describe-variable' when pushing the corresponding URL button."
6408 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6410 (defun gnus-button-handle-symbol (url)
6411 "Display help on variable or function.
6412 Calls `describe-variable' or `describe-function'."
6413 (let ((sym (intern url)))
6415 ((fboundp sym) (describe-function sym))
6416 ((boundp sym) (describe-variable sym))
6417 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6419 (defun gnus-button-handle-describe-key (url)
6420 "Call `describe-key' when pushing the corresponding URL button."
6422 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6423 (keys (ignore-errors (eval `(kbd ,key-string)))))
6426 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6428 (defun gnus-button-handle-apropos (url)
6429 "Call `apropos' when pushing the corresponding URL button."
6430 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6432 (defun gnus-button-handle-apropos-command (url)
6433 "Call `apropos' when pushing the corresponding URL button."
6435 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6437 (defun gnus-button-handle-apropos-variable (url)
6438 "Call `apropos' when pushing the corresponding URL button."
6440 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6441 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6443 (defun gnus-button-handle-apropos-documentation (url)
6444 "Call `apropos' when pushing the corresponding URL button."
6446 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6447 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6449 (defun gnus-button-handle-library (url)
6450 "Call `locate-library' when pushing the corresponding URL button."
6451 (gnus-message 9 "url=`%s'" url)
6452 (let* ((lib (locate-library url))
6453 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6455 (gnus-message 1 "Cannot locale library `%s'." url)
6456 (find-file-read-only file))))
6458 (defun gnus-button-handle-ctan (url)
6459 "Call `browse-url' when pushing a CTAN URL button."
6461 gnus-button-ctan-handler
6464 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6466 (defcustom gnus-button-tex-level 5
6467 "*Integer that says how many TeX-related buttons Gnus will show.
6468 The higher the number, the more buttons will appear and the more false
6469 positives are possible. Note that you can set this variable local to
6470 specific groups. Setting it higher in TeX groups is probably a good idea.
6471 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6472 how to set variables in specific groups."
6474 :group 'gnus-article-buttons
6475 :link '(custom-manual "(gnus)Group Parameters")
6478 (defcustom gnus-button-man-level 5
6479 "*Integer that says how many man-related buttons Gnus will show.
6480 The higher the number, the more buttons will appear and the more false
6481 positives are possible. Note that you can set this variable local to
6482 specific groups. Setting it higher in Unix groups is probably a good idea.
6483 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6484 how to set variables in specific groups."
6486 :group 'gnus-article-buttons
6487 :link '(custom-manual "(gnus)Group Parameters")
6490 (defcustom gnus-button-emacs-level 5
6491 "*Integer that says how many emacs-related buttons Gnus will show.
6492 The higher the number, the more buttons will appear and the more false
6493 positives are possible. Note that you can set this variable local to
6494 specific groups. Setting it higher in Emacs or Gnus related groups is
6495 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6496 `gnus-parameters' on how to set variables in specific groups."
6498 :group 'gnus-article-buttons
6499 :link '(custom-manual "(gnus)Group Parameters")
6502 (defcustom gnus-button-message-level 5
6503 "*Integer that says how many buttons for news or mail messages will appear.
6504 The higher the number, the more buttons will appear and the more false
6505 positives are possible."
6506 ;; mail addresses, MIDs, URLs for news, ...
6508 :group 'gnus-article-buttons
6511 (defcustom gnus-button-browse-level 5
6512 "*Integer that says how many buttons for browsing will appear.
6513 The higher the number, the more buttons will appear and the more false
6514 positives are possible."
6515 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6517 :group 'gnus-article-buttons
6520 (defcustom gnus-button-alist
6521 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6522 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6523 ((concat "\\b\\(nntp\\|news\\):\\("
6524 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6525 0 t gnus-button-handle-news 2)
6526 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6527 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6528 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6529 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6530 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6531 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6532 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6533 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6534 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6535 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6536 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6537 ;; RFC 2368 (The mailto URL scheme)
6538 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6539 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6540 ("\\bmailto:\\([^ \n\t]+\\)"
6541 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6543 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6544 gnus-button-ctan-directory-regexp
6545 "[^][>)!;:,'\n\t ]+\\)")
6546 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6547 ((concat "\\btex-archive/\\("
6548 gnus-button-ctan-directory-regexp
6549 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6550 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6553 gnus-button-ctan-directory-regexp
6554 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6555 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6556 ;; This is info (home-grown style) <info://foo/bar+baz>
6557 ("\\binfo://\\([^'\">\n\t ]+\\)"
6558 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6559 ;; Info GNOME style <info:foo#bar_baz>
6560 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6561 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6562 ;; Info KDE style <info:(foo)bar baz>
6563 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6564 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6565 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6566 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6567 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6568 ;; Info links like `C-h i d m CC Mode RET'
6569 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6571 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6572 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6573 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6574 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6575 ;; Emacs help commands
6576 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6577 ;; regexp doesn't match arguments containing ` '.
6578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6579 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6580 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6581 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6582 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6583 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6584 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6585 ;; The following entries may lead to many false positives so don't enable
6586 ;; them by default (use a high button level).
6587 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6588 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6589 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6590 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6591 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6592 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6593 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6594 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6595 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6596 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6597 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6598 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6599 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6600 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6601 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6602 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6603 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6604 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6605 ;; Unlike the other regexps we really have to require quoting
6606 ;; here to determine where it ends.
6607 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6608 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6609 ("<URL: *\\([^<>]*\\)>"
6610 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6611 ;; RFC 2396 (2.4.3., delims) ...
6612 ("\"URL: *\\([^\"]*\\)\""
6613 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6614 ;; RFC 2396 (2.4.3., delims) ...
6615 ("\"URL: *\\([^\"]*\\)\""
6616 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6618 (gnus-button-url-regexp
6619 0 (>= gnus-button-browse-level 0) browse-url 0)
6621 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6622 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6623 gnus-button-handle-man 1)
6624 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6625 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6626 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6627 gnus-button-handle-man 1)
6628 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6629 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6630 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6631 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6632 ;; MID or mail: To avoid too many false positives we don't try to catch
6633 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6634 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6635 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6636 ;; so that non-ambiguous entries (see above) match first.
6637 (gnus-button-mid-or-mail-regexp
6638 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6639 "*Alist of regexps matching buttons in article bodies.
6641 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6642 REGEXP: is the string (case insensitive) matching text around the button (can
6643 also be Lisp expression evaluating to a string),
6644 BUTTON: is the number of the regexp grouping actually matching the button,
6645 FORM: is a Lisp expression which must eval to true for the button to
6647 CALLBACK: is the function to call when the user push this button, and each
6648 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6650 CALLBACK can also be a variable, in that case the value of that
6651 variable it the real callback function."
6652 :group 'gnus-article-buttons
6653 :type '(repeat (list (choice regexp variable sexp)
6654 (integer :tag "Button")
6656 (function :tag "Callback")
6659 (integer :tag "Regexp group")))))
6661 (defcustom gnus-header-button-alist
6662 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6663 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6664 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6665 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6666 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6667 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6668 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6669 0 (>= gnus-button-browse-level 0) browse-url 0)
6670 ("^Subject:" gnus-button-url-regexp
6671 0 (>= gnus-button-browse-level 0) browse-url 0)
6672 ("^[^:]+:" gnus-button-url-regexp
6673 0 (>= gnus-button-browse-level 0) browse-url 0)
6674 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6675 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6676 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6677 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6678 "*Alist of headers and regexps to match buttons in article heads.
6680 This alist is very similar to `gnus-button-alist', except that each
6681 alist has an additional HEADER element first in each entry:
6683 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6685 HEADER is a regexp to match a header. For a fuller explanation, see
6686 `gnus-button-alist'."
6687 :group 'gnus-article-buttons
6688 :group 'gnus-article-headers
6689 :type '(repeat (list (regexp :tag "Header")
6690 (choice regexp variable)
6691 (integer :tag "Button")
6693 (function :tag "Callback")
6696 (integer :tag "Regexp group")))))
6698 (defvar gnus-button-regexp nil)
6699 (defvar gnus-button-marker-list nil)
6700 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6702 (defvar gnus-button-last nil)
6703 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6707 (defun gnus-article-push-button (event)
6708 "Check text under the mouse pointer for a callback function.
6709 If the text under the mouse pointer has a `gnus-callback' property,
6710 call it with the value of the `gnus-data' text property."
6712 (set-buffer (window-buffer (posn-window (event-start event))))
6713 (let* ((pos (posn-point (event-start event)))
6714 (data (get-text-property pos 'gnus-data))
6715 (fun (get-text-property pos 'gnus-callback)))
6718 (funcall fun data))))
6720 (defun gnus-article-press-button ()
6721 "Check text at point for a callback function.
6722 If the text at point has a `gnus-callback' property,
6723 call it with the value of the `gnus-data' text property."
6725 (let ((data (get-text-property (point) 'gnus-data))
6726 (fun (get-text-property (point) 'gnus-callback)))
6728 (funcall fun data))))
6730 (defun gnus-article-highlight (&optional force)
6731 "Highlight current article.
6732 This function calls `gnus-article-highlight-headers',
6733 `gnus-article-highlight-citation',
6734 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6735 do the highlighting. See the documentation for those functions."
6736 (interactive (list 'force))
6737 (gnus-article-highlight-headers)
6738 (gnus-article-highlight-citation force)
6739 (gnus-article-highlight-signature)
6740 (gnus-article-add-buttons force)
6741 (gnus-article-add-buttons-to-head))
6743 (defun gnus-article-highlight-some (&optional force)
6744 "Highlight current article.
6745 This function calls `gnus-article-highlight-headers',
6746 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6747 do the highlighting. See the documentation for those functions."
6748 (interactive (list 'force))
6749 (gnus-article-highlight-headers)
6750 (gnus-article-highlight-signature)
6751 (gnus-article-add-buttons))
6753 (defun gnus-article-highlight-headers ()
6754 "Highlight article headers as specified by `gnus-header-face-alist'."
6757 (set-buffer gnus-article-buffer)
6759 (let ((alist gnus-header-face-alist)
6760 (inhibit-read-only t)
6761 (case-fold-search t)
6762 (inhibit-point-motion-hooks t)
6763 entry regexp header-face field-face from hpoints fpoints)
6764 (article-narrow-to-head)
6765 (while (setq entry (pop alist))
6766 (goto-char (point-min))
6767 (setq regexp (concat "^\\("
6768 (if (string-equal "" (nth 0 entry))
6772 header-face (nth 1 entry)
6773 field-face (nth 2 entry))
6774 (while (and (re-search-forward regexp nil t)
6778 (unless (search-forward ":" nil t)
6780 (when (and header-face
6781 (not (memq (point) hpoints)))
6782 (push (point) hpoints)
6783 (gnus-put-text-property from (point) 'face header-face))
6784 (when (and field-face
6785 (not (memq (setq from (point)) fpoints)))
6787 (if (re-search-forward "^[^ \t]" nil t)
6789 (goto-char (point-max)))
6790 (gnus-put-text-property from (point) 'face field-face))))))))
6792 (defun gnus-article-highlight-signature ()
6793 "Highlight the signature in an article.
6794 It does this by highlighting everything after
6795 `gnus-signature-separator' using the face `gnus-signature'."
6798 (set-buffer gnus-article-buffer)
6799 (let ((inhibit-read-only t)
6800 (inhibit-point-motion-hooks t))
6802 (when (and gnus-signature-face
6803 (gnus-article-narrow-to-signature))
6804 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6805 'face gnus-signature-face)
6807 (gnus-article-search-signature)
6808 (let ((start (match-beginning 0))
6809 (end (set-marker (make-marker) (1+ (match-end 0)))))
6810 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6813 (defun gnus-button-in-region-p (b e prop)
6814 "Say whether PROP exists in the region."
6815 (text-property-not-all b e prop nil))
6817 (defun gnus-article-add-buttons (&optional force)
6818 "Find external references in the article and make buttons of them.
6819 \"External references\" are things like Message-IDs and URLs, as
6820 specified by `gnus-button-alist'."
6821 (interactive (list 'force))
6823 (set-buffer gnus-article-buffer)
6824 (let ((inhibit-read-only t)
6825 (inhibit-point-motion-hooks t)
6826 (case-fold-search t)
6827 (alist gnus-button-alist)
6829 ;; Remove all old markers.
6830 (let (marker entry new-list)
6831 (while (setq marker (pop gnus-button-marker-list))
6832 (if (or (< marker (point-min)) (>= marker (point-max)))
6833 (push marker new-list)
6835 (when (setq entry (gnus-button-entry))
6836 (put-text-property (match-beginning (nth 1 entry))
6837 (match-end (nth 1 entry))
6838 'gnus-callback nil))
6839 (set-marker marker nil)))
6840 (setq gnus-button-marker-list new-list))
6841 ;; We skip the headers.
6844 (while (setq entry (pop alist))
6845 (setq regexp (eval (car entry)))
6847 (while (re-search-forward regexp nil t)
6848 (let* ((start (and entry (match-beginning (nth 1 entry))))
6849 (end (and entry (match-end (nth 1 entry))))
6850 (from (match-beginning 0)))
6851 (when (and (or (eq t (nth 2 entry))
6852 (eval (nth 2 entry)))
6853 (not (gnus-button-in-region-p
6854 start end 'gnus-callback)))
6855 ;; That optional form returned non-nil, so we add the
6857 (gnus-article-add-button
6858 start end 'gnus-button-push
6859 (car (push (set-marker (make-marker) from)
6860 gnus-button-marker-list))))))))))
6862 ;; Add buttons to the head of an article.
6863 (defun gnus-article-add-buttons-to-head ()
6864 "Add buttons to the head of the article."
6867 (set-buffer gnus-article-buffer)
6869 (let ((inhibit-read-only t)
6870 (inhibit-point-motion-hooks t)
6871 (case-fold-search t)
6872 (alist gnus-header-button-alist)
6874 (article-narrow-to-head)
6876 ;; Each alist entry.
6877 (setq entry (car alist)
6879 (goto-char (point-min))
6880 (while (re-search-forward (car entry) nil t)
6881 ;; Each header matching the entry.
6882 (setq beg (match-beginning 0))
6883 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6884 (match-beginning 0))
6887 (while (re-search-forward (eval (nth 1 entry)) end t)
6888 ;; Each match within a header.
6889 (let* ((entry (cdr entry))
6890 (start (match-beginning (nth 1 entry)))
6891 (end (match-end (nth 1 entry)))
6892 (form (nth 2 entry)))
6893 (goto-char (match-end 0))
6895 (gnus-article-add-button
6896 start end (nth 3 entry)
6897 (buffer-substring (match-beginning (nth 4 entry))
6898 (match-end (nth 4 entry)))))))
6899 (goto-char end)))))))
6901 ;;; External functions:
6903 (defun gnus-article-add-button (from to fun &optional data)
6904 "Create a button between FROM and TO with callback FUN and data DATA."
6905 (when gnus-article-button-face
6906 (gnus-overlay-put (gnus-make-overlay from to)
6907 'face gnus-article-button-face))
6908 (gnus-add-text-properties
6910 (nconc (and gnus-article-mouse-face
6911 (list gnus-mouse-face-prop gnus-article-mouse-face))
6912 (list 'gnus-callback fun)
6913 (and data (list 'gnus-data data))))
6914 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6915 :button-keymap gnus-widget-button-keymap))
6917 ;;; Internal functions:
6919 (defun gnus-article-set-globals ()
6921 (set-buffer gnus-summary-buffer)
6922 (gnus-set-global-variables)))
6924 (defun gnus-signature-toggle (end)
6926 (set-buffer gnus-article-buffer)
6927 (let ((inhibit-read-only t)
6928 (inhibit-point-motion-hooks t))
6929 (if (text-property-any end (point-max) 'article-type 'signature)
6931 (gnus-delete-wash-type 'signature)
6932 (gnus-remove-text-properties-when
6933 'article-type 'signature end (point-max)
6934 (cons 'article-type (cons 'signature
6935 gnus-hidden-properties))))
6936 (gnus-add-wash-type 'signature)
6937 (gnus-add-text-properties-when
6938 'article-type nil end (point-max)
6939 (cons 'article-type (cons 'signature
6940 gnus-hidden-properties)))))
6941 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6942 (gnus-set-mode-line 'article))))
6944 (defun gnus-button-entry ()
6945 ;; Return the first entry in `gnus-button-alist' matching this place.
6946 (let ((alist gnus-button-alist)
6949 (setq entry (pop alist))
6950 (if (looking-at (eval (car entry)))
6955 (defun gnus-button-push (marker)
6956 ;; Push button starting at MARKER.
6959 (let* ((entry (gnus-button-entry))
6960 (inhibit-point-motion-hooks t)
6962 (args (mapcar (lambda (group)
6963 (let ((string (match-string group)))
6964 (gnus-set-text-properties
6965 0 (length string) nil string)
6972 (fboundp (symbol-value fun)))
6973 (apply (symbol-value fun) args))
6975 (gnus-message 1 "You must define `%S' to use this button"
6976 (cons fun args)))))))
6978 (defun gnus-parse-news-url (url)
6979 (let (scheme server port group message-id articles)
6982 (goto-char (point-min))
6983 (when (looking-at "\\([A-Za-z]+\\):")
6984 (setq scheme (match-string 1))
6985 (goto-char (match-end 0)))
6986 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6987 (setq server (match-string 1))
6988 (setq port (if (stringp (match-string 3))
6989 (string-to-number (match-string 3))
6991 (goto-char (match-end 0)))
6994 ((looking-at "\\(.*@.*\\)")
6995 (setq message-id (match-string 1)))
6996 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6997 (setq group (match-string 1)
6998 articles (split-string (match-string 2) "-")))
6999 ((looking-at "\\([^/]+\\)/?")
7000 (setq group (match-string 1)))
7002 (error "Unknown news URL syntax"))))
7003 (list scheme server port group message-id articles)))
7005 (defun gnus-button-handle-news (url)
7007 (destructuring-bind (scheme server port group message-id articles)
7008 (gnus-parse-news-url url)
7012 (set-buffer gnus-summary-buffer)
7014 (let ((gnus-refer-article-method
7015 (nconc (list (list 'nntp server))
7016 gnus-refer-article-method))
7017 (nntp-port-number (or port "nntp")))
7018 (gnus-message 7 "Fetching %s with %s"
7019 message-id gnus-refer-article-method)
7020 (gnus-summary-refer-article message-id))
7021 (gnus-summary-refer-article message-id))))
7023 (gnus-button-fetch-group url)))))
7025 (defun gnus-button-handle-man (url)
7027 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7028 (when (eq gnus-button-man-handler 'woman)
7029 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7030 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7031 (funcall gnus-button-man-handler url))
7033 (defun gnus-button-handle-info-url (url)
7034 "Fetch an info URL."
7035 (setq url (mm-subst-char-in-string ?+ ?\ url))
7037 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7038 (gnus-info-find-node
7039 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7041 ")" (gnus-url-unhex-string (match-string 2 url)))))
7042 ((string-match "([^)\"]+)[^\"]+" url)
7044 (gnus-replace-in-string
7045 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7046 (gnus-info-find-node url))
7047 (t (error "Can't parse %s" url))))
7049 (defun gnus-button-handle-info-url-gnome (url)
7050 "Fetch GNOME style info URL."
7051 (setq url (mm-subst-char-in-string ?_ ?\ url))
7052 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7053 (gnus-info-find-node
7055 (gnus-url-unhex-string
7056 (match-string 1 url))
7058 (or (gnus-url-unhex-string
7059 (match-string 2 url))
7061 (error "Can't parse %s" url)))
7063 (defun gnus-button-handle-info-url-kde (url)
7064 "Fetch KDE style info URL."
7065 (gnus-info-find-node (gnus-url-unhex-string url)))
7067 (defun gnus-button-handle-info-keystrokes (url)
7068 "Call `info' when pushing the corresponding URL button."
7069 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7074 (defun gnus-button-message-id (message-id)
7077 (set-buffer gnus-summary-buffer)
7078 (gnus-summary-refer-article message-id)))
7080 (defun gnus-button-fetch-group (address)
7081 "Fetch GROUP specified by ADDRESS."
7082 (if (not (string-match "[:/]" address))
7083 ;; This is just a simple group url.
7084 (gnus-group-read-ephemeral-group address gnus-select-method)
7087 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7089 (error "Can't parse %s" address)
7090 (gnus-group-read-ephemeral-group
7091 (match-string 4 address)
7092 `(nntp ,(match-string 1 address)
7093 (nntp-address ,(match-string 1 address))
7094 (nntp-port-number ,(if (match-end 3)
7095 (match-string 3 address)
7098 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7100 (defun gnus-url-parse-query-string (query &optional downcase)
7101 (let (retval pairs cur key val)
7102 (setq pairs (split-string query "&"))
7104 (setq cur (car pairs)
7106 (if (not (string-match "=" cur))
7108 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7109 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7111 (setq key (downcase key)))
7112 (setq cur (assoc key retval))
7114 (setcdr cur (cons val (cdr cur)))
7115 (setq retval (cons (list key val) retval)))))
7118 (defun gnus-url-mailto (url)
7119 ;; Send mail to someone
7120 (when (string-match "mailto:/*\\(.*\\)" url)
7121 (setq url (substring url (match-beginning 1) nil)))
7122 (let (to args subject func)
7123 (setq args (gnus-url-parse-query-string
7124 (if (string-match "^\\?" url)
7126 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7127 (concat "to=" (match-string 1 url) "&"
7128 (match-string 2 url))
7129 (concat "to=" url)))
7131 subject (cdr-safe (assoc "subject" args)))
7134 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7137 (message-position-on-field (caar args)))
7138 (insert (gnus-replace-in-string
7139 (mapconcat 'identity (reverse (cdar args)) ", ")
7141 (setq args (cdr args)))
7144 (message-goto-subject))))
7146 (defun gnus-button-embedded-url (address)
7147 "Activate ADDRESS with `browse-url'."
7148 (browse-url (gnus-strip-whitespace address)))
7150 ;;; Next/prev buttons in the article buffer.
7152 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7153 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7155 (defvar gnus-prev-page-map
7156 (let ((map (make-sparse-keymap)))
7157 (unless (>= emacs-major-version 21)
7158 ;; XEmacs doesn't care.
7159 (set-keymap-parent map gnus-article-mode-map))
7160 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7161 (define-key map "\r" 'gnus-button-prev-page)
7164 (defvar gnus-next-page-map
7165 (let ((map (make-sparse-keymap)))
7166 (unless (>= emacs-major-version 21)
7167 ;; XEmacs doesn't care.
7168 (set-keymap-parent map gnus-article-mode-map))
7169 (define-key map gnus-mouse-2 'gnus-button-next-page)
7170 (define-key map "\r" 'gnus-button-next-page)
7173 (defun gnus-insert-prev-page-button ()
7175 (inhibit-read-only t))
7177 gnus-prev-page-line-format nil
7178 `(,@(gnus-local-map-property gnus-prev-page-map)
7180 gnus-callback gnus-article-button-prev-page
7181 article-type annotation))
7182 (widget-convert-button
7184 ;; Exclude a newline.
7187 :action 'gnus-button-prev-page
7188 :button-keymap gnus-prev-page-map)))
7190 (defun gnus-button-next-page (&optional args more-args)
7191 "Go to the next page."
7193 (let ((win (selected-window)))
7194 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7195 (gnus-article-next-page)
7196 (select-window win)))
7198 (defun gnus-button-prev-page (&optional args more-args)
7199 "Go to the prev page."
7201 (let ((win (selected-window)))
7202 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7203 (gnus-article-prev-page)
7204 (select-window win)))
7206 (defun gnus-insert-next-page-button ()
7208 (inhibit-read-only t))
7209 (gnus-eval-format gnus-next-page-line-format nil
7210 `(,@(gnus-local-map-property gnus-next-page-map)
7212 gnus-callback gnus-article-button-next-page
7213 article-type annotation))
7214 (widget-convert-button
7216 ;; Exclude a newline.
7219 :action 'gnus-button-next-page
7220 :button-keymap gnus-next-page-map)))
7222 (defun gnus-article-button-next-page (arg)
7223 "Go to the next page."
7225 (let ((win (selected-window)))
7226 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7227 (gnus-article-next-page)
7228 (select-window win)))
7230 (defun gnus-article-button-prev-page (arg)
7231 "Go to the prev page."
7233 (let ((win (selected-window)))
7234 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7235 (gnus-article-prev-page)
7236 (select-window win)))
7238 (defvar gnus-decode-header-methods
7239 '(mail-decode-encoded-word-region)
7240 "List of methods used to decode headers.
7242 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7243 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7244 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7245 whose names match REGEXP.
7248 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7249 mail-decode-encoded-word-region
7250 (\"chinese\" . rfc1843-decode-region))
7253 (defvar gnus-decode-header-methods-cache nil)
7255 (defun gnus-multi-decode-header (start end)
7256 "Apply the functions from `gnus-encoded-word-methods' that match."
7257 (unless (and gnus-decode-header-methods-cache
7258 (eq gnus-newsgroup-name
7259 (car gnus-decode-header-methods-cache)))
7260 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7263 (nconc gnus-decode-header-methods-cache (list x))
7264 (if (and gnus-newsgroup-name
7265 (string-match (car x) gnus-newsgroup-name))
7266 (nconc gnus-decode-header-methods-cache
7268 gnus-decode-header-methods))
7269 (let ((xlist gnus-decode-header-methods-cache))
7272 (narrow-to-region start end)
7274 (funcall (pop xlist) (point-min) (point-max))))))
7277 ;;; Treatment top-level handling.
7280 (defun gnus-treat-article (condition &optional part-number total-parts type)
7281 (let ((length (- (point-max) (point-min)))
7282 (alist gnus-treatment-function-alist)
7283 (article-goto-body-goes-to-point-min-p t)
7287 (let ((list gnus-article-treat-types))
7289 (when (string-match (pop list) type)
7290 (throw 'found t)))))))
7291 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7293 (gnus-run-hooks 'gnus-part-display-hook)
7294 (dolist (elem alist)
7297 (when (gnus-buffer-live-p gnus-summary-buffer)
7298 (set-buffer gnus-summary-buffer))
7299 (symbol-value (car elem))))
7300 (when (and (or (consp val)
7302 (gnus-treat-predicate val)
7303 (or (not (get (car elem) 'highlight))
7306 (funcall (cadr elem)))))))
7308 ;; Dynamic variables.
7310 (defvar part-number)
7311 (defvar total-parts)
7316 (defun gnus-treat-predicate (val)
7323 (stringp (car val)))
7324 (apply 'gnus-or (mapcar `(lambda (s)
7325 (string-match s ,(or gnus-newsgroup-name "")))
7328 (let ((pred (pop val)))
7331 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7333 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7335 (not (gnus-treat-predicate (car val))))
7337 (equal (car val) type))
7339 (error "%S is not a valid predicate" pred)))))
7345 (eq part-number total-parts))
7349 (error "%S is not a valid value" val))))
7351 (defun gnus-article-encrypt-body (protocol &optional n)
7352 "Encrypt the article body."
7355 (or gnus-article-encrypt-protocol
7356 (completing-read "Encrypt protocol: "
7357 gnus-article-encrypt-protocol-alist
7359 current-prefix-arg))
7360 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7362 (error "Can't find the encrypt protocol %s" protocol))
7363 (if (member gnus-newsgroup-name '("nndraft:delayed"
7366 (error "Can't encrypt the article in group %s"
7367 gnus-newsgroup-name))
7368 (gnus-summary-iterate n
7370 (set-buffer gnus-summary-buffer)
7371 (let ((mail-parse-charset gnus-newsgroup-charset)
7372 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7373 (summary-buffer gnus-summary-buffer)
7375 (gnus-set-global-variables)
7376 (when (gnus-group-read-only-p)
7377 (error "The current newsgroup does not support article encrypt"))
7378 (gnus-summary-show-article t)
7380 (or (mail-header-references gnus-current-headers) ""))
7381 (set-buffer gnus-article-buffer)
7382 (let* ((inhibit-read-only t)
7384 (mapcar (lambda (field)
7385 (and (save-restriction
7386 (message-narrow-to-head)
7387 (goto-char (point-min))
7388 (search-forward field nil t))
7390 (message-narrow-to-field)
7392 (delete-region (point-min) (point-max))
7394 '("Content-Type:" "Content-Transfer-Encoding:"
7395 "Content-Disposition:"))))
7396 (message-narrow-to-head)
7397 (message-remove-header "MIME-Version")
7398 (goto-char (point-max))
7399 (setq point (point))
7400 (insert (apply 'concat headers))
7402 (narrow-to-region point (point-max))
7403 (let ((message-options message-options))
7404 (message-options-set 'message-sender user-mail-address)
7405 (message-options-set 'message-recipients user-mail-address)
7406 (message-options-set 'message-sign-encrypt 'not)
7408 (goto-char (point-min))
7409 (insert "MIME-Version: 1.0\n")
7411 (gnus-summary-edit-article-done
7412 references nil summary-buffer t))
7413 (when gnus-keep-backlog
7414 (gnus-backlog-remove-article
7415 (car gnus-article-current) (cdr gnus-article-current)))
7417 (when (get-buffer gnus-original-article-buffer)
7418 (set-buffer gnus-original-article-buffer)
7419 (setq gnus-original-article nil)))
7420 (when gnus-use-cache
7421 (gnus-cache-update-article
7422 (car gnus-article-current) (cdr gnus-article-current))))))))
7424 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7425 "The following specs can be used:
7426 %t The security MIME type
7429 %D Details if button is pressed")
7431 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7432 "The following specs can be used:
7433 %t The security MIME type
7436 %D Details if button is pressed")
7438 (defvar gnus-mime-security-button-line-format-alist
7439 '((?t gnus-tmp-type ?s)
7440 (?i gnus-tmp-info ?s)
7441 (?d gnus-tmp-details ?s)
7442 (?D gnus-tmp-pressed-details ?s)))
7444 (defvar gnus-mime-security-button-map
7445 (let ((map (make-sparse-keymap)))
7446 (unless (>= (string-to-number emacs-version) 21)
7447 (set-keymap-parent map gnus-article-mode-map))
7448 (define-key map gnus-mouse-2 'gnus-article-push-button)
7449 (define-key map "\r" 'gnus-article-press-button)
7452 (defvar gnus-mime-security-details-buffer nil)
7454 (defvar gnus-mime-security-button-pressed nil)
7456 (defvar gnus-mime-security-show-details-inline t
7457 "If non-nil, show details in the article buffer.")
7459 (defun gnus-mime-security-verify-or-decrypt (handle)
7460 (mm-remove-parts (cdr handle))
7461 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7462 point (inhibit-read-only t))
7464 (goto-char (car region)))
7466 (narrow-to-region (point) (point))
7467 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7468 (let* ((mm-verify-option 'known)
7469 (mm-decrypt-option 'known)
7470 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7471 (unless (eq nparts (cdr handle))
7472 (mm-destroy-parts (cdr handle))
7473 (setcdr handle nparts))))
7474 (setq point (point))
7475 (gnus-mime-display-security handle)
7476 (goto-char (point-max)))
7478 (delete-region (point) (cdr region))
7479 (set-marker (car region) nil)
7480 (set-marker (cdr region) nil))
7483 (defun gnus-mime-security-show-details (handle)
7484 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7486 (gnus-message 5 "No details.")
7487 (if gnus-mime-security-show-details-inline
7488 (let ((gnus-mime-security-button-pressed
7489 (not (get-text-property (point) 'gnus-mime-details)))
7490 (gnus-mime-security-button-line-format
7491 (get-text-property (point) 'gnus-line-format))
7492 (inhibit-read-only t))
7494 (while (eq (get-text-property (point) 'gnus-line-format)
7495 gnus-mime-security-button-line-format)
7499 (narrow-to-region (point) (point))
7500 (gnus-insert-mime-security-button handle))
7501 (delete-region (point)
7502 (or (text-property-not-all
7505 gnus-mime-security-button-line-format)
7508 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7509 (with-current-buffer gnus-mime-security-details-buffer
7512 (setq gnus-mime-security-details-buffer
7513 (gnus-get-buffer-create "*MIME Security Details*")))
7514 (with-current-buffer gnus-mime-security-details-buffer
7516 (goto-char (point-min)))
7517 (pop-to-buffer gnus-mime-security-details-buffer)))))
7519 (defun gnus-mime-security-press-button (handle)
7521 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7522 (gnus-mime-security-show-details handle)
7523 (gnus-mime-security-verify-or-decrypt handle))))
7525 (defun gnus-insert-mime-security-button (handle &optional displayed)
7526 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7529 (or (nth 2 (assoc protocol mm-verify-function-alist))
7530 (nth 2 (assoc protocol mm-decrypt-function-alist))
7532 (if (equal (car handle) "multipart/signed")
7533 " Signed" " Encrypted")
7536 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7539 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7540 gnus-tmp-pressed-details
7542 (setq gnus-tmp-details
7543 (if gnus-tmp-details
7544 (concat "\n" gnus-tmp-details)
7546 (setq gnus-tmp-pressed-details
7547 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7552 gnus-mime-security-button-line-format
7553 gnus-mime-security-button-line-format-alist
7554 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7555 gnus-callback gnus-mime-security-press-button
7556 gnus-line-format ,gnus-mime-security-button-line-format
7557 gnus-mime-details ,gnus-mime-security-button-pressed
7558 article-type annotation
7561 ;; Exclude a newline.
7564 (widget-convert-button
7567 :action 'gnus-widget-press-button
7568 :button-keymap gnus-mime-security-button-map
7570 (lambda (widget/window &optional overlay pos)
7571 ;; Needed to properly clear the message due to a bug in
7572 ;; wid-edit (XEmacs only).
7573 (when (boundp 'help-echo-owns-message)
7574 (setq help-echo-owns-message t))
7577 (aref gnus-mouse-2 0))))))
7579 (defun gnus-mime-display-security (handle)
7581 (narrow-to-region (point) (point))
7582 (unless (gnus-unbuttonized-mime-type-p (car handle))
7583 (gnus-insert-mime-security-button handle))
7584 (gnus-mime-display-mixed (cdr handle))
7587 (unless (gnus-unbuttonized-mime-type-p (car handle))
7588 (let ((gnus-mime-security-button-line-format
7589 gnus-mime-security-button-end-line-format))
7590 (gnus-insert-mime-security-button handle)))
7591 (mm-set-handle-multipart-parameter
7593 (cons (set-marker (make-marker) (point-min))
7594 (set-marker (make-marker) (point-max))))))
7600 (run-hooks 'gnus-art-load-hook)
7602 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7603 ;;; gnus-art.el ends here