1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2014 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (defvar w3m-minor-mode-map
)
46 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
47 (autoload 'gnus-button-mailto
"gnus-msg")
48 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
49 (autoload 'parse-time-string
"parse-time" nil nil
)
50 (autoload 'ansi-color-apply-on-region
"ansi-color")
51 (autoload 'mm-url-insert-file-contents-external
"mm-url")
52 (autoload 'mm-extern-cache-contents
"mm-extern")
54 (defgroup gnus-article nil
56 :link
'(custom-manual "(gnus)Article Buffer")
59 (defgroup gnus-article-treat nil
60 "Treating article parts."
61 :link
'(custom-manual "(gnus)Article Hiding")
64 (defgroup gnus-article-hiding nil
65 "Hiding article parts."
66 :link
'(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-highlight nil
70 "Article highlighting."
71 :link
'(custom-manual "(gnus)Article Highlighting")
75 (defgroup gnus-article-signature nil
77 :link
'(custom-manual "(gnus)Article Signature")
80 (defgroup gnus-article-headers nil
82 :link
'(custom-manual "(gnus)Hiding Headers")
85 (defgroup gnus-article-washing nil
86 "Special commands on articles."
87 :link
'(custom-manual "(gnus)Article Washing")
90 (defgroup gnus-article-emphasis nil
91 "Fontisizing articles."
92 :link
'(custom-manual "(gnus)Article Fontisizing")
95 (defgroup gnus-article-saving nil
97 :link
'(custom-manual "(gnus)Saving Articles")
100 (defgroup gnus-article-mime nil
101 "Worshiping the MIME wonder."
102 :link
'(custom-manual "(gnus)Using MIME")
103 :group
'gnus-article
)
105 (defgroup gnus-article-buttons nil
106 "Pushable buttons in the article buffer."
107 :link
'(custom-manual "(gnus)Article Buttons")
108 :group
'gnus-article
)
110 (defgroup gnus-article-various nil
111 "Other article options."
112 :link
'(custom-manual "(gnus)Misc Article")
113 :group
'gnus-article
)
115 (defcustom gnus-ignored-headers
118 (concat "^" header
":"))
119 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
120 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
121 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
122 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
123 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
124 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
125 "X-Attribution" "X-Originating-IP" "Delivered-To"
126 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
127 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
128 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
129 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
130 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
131 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
132 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
133 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
134 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
135 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
136 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
137 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
138 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
139 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
140 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
141 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
142 "List-[A-Za-z]+" "X-Listprocessor-Version"
143 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
144 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
145 "X-Received" "Content-length" "X-precedence"
146 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
147 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
148 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
149 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
150 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
151 "X-Content-length" "X-Posting-Agent" "Original-Received"
152 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
157 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
158 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
159 "Envelope-Sender" "Envelope-Recipients"))
160 "*All headers that start with this regexp will be hidden.
161 This variable can also be a list of regexps of headers to be ignored.
162 If `gnus-visible-headers' is non-nil, this variable will be ignored."
163 :type
'(choice regexp
165 :group
'gnus-article-hiding
)
167 (defcustom gnus-visible-headers
168 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
173 (repeat :value-to-internal
(lambda (widget value
)
174 (custom-split-regexp-maybe value
))
175 :match
(lambda (widget value
)
177 (widget-editable-list-match widget value
)))
179 (const :tag
"Use gnus-ignored-headers" nil
)
181 :group
'gnus-article-hiding
)
183 (defcustom gnus-sorted-header-list
184 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
185 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
186 "*This variable is a list of regular expressions.
187 If it is non-nil, headers that match the regular expressions will
188 be placed first in the article buffer in the sequence specified by
190 :type
'(repeat regexp
)
191 :group
'gnus-article-hiding
)
193 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
194 "Headers that are only to be displayed if they have interesting data.
195 Possible values in this list are:
197 'empty Headers with no content.
198 'newsgroups Newsgroup identical to Gnus group.
199 'to-address To identical to To-address.
200 'to-list To identical to To-list.
201 'cc-list CC identical to To-list.
202 'followup-to Followup-to identical to Newsgroups.
203 'reply-to Reply-to identical to From.
204 'date Date less than four days old.
205 'long-to To and/or Cc longer than 1024 characters.
206 'many-to Multiple To and/or Cc."
207 :type
'(set (const :tag
"Headers with no content." empty
)
208 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
209 (const :tag
"To identical to To-address." to-address
)
210 (const :tag
"To identical to To-list." to-list
)
211 (const :tag
"CC identical to To-list." cc-list
)
212 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
213 (const :tag
"Reply-to identical to From." reply-to
)
214 (const :tag
"Date less than four days old." date
)
215 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
216 (const :tag
"Multiple To and/or Cc headers." many-to
))
217 :group
'gnus-article-hiding
)
219 (defcustom gnus-article-skip-boring nil
220 "Skip over text that is not worth reading.
221 By default, if you set this t, then Gnus will display citations and
222 signatures, but will never scroll down to show you a page consisting
223 only of boring text. Boring text is controlled by
224 `gnus-article-boring-faces'."
227 :group
'gnus-article-hiding
)
229 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
230 "Regexp matching signature separator.
231 This can also be a list of regexps. In that case, it will be checked
232 from head to tail looking for a separator. Searches will be done from
233 the end of the buffer."
234 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
236 (repeat :tag
"List of regexp" regexp
))
237 :group
'gnus-article-signature
)
239 (defcustom gnus-signature-limit nil
240 "Provide a limit to what is considered a signature.
241 If it is a number, no signature may not be longer (in characters) than
242 that number. If it is a floating point number, no signature may be
243 longer (in lines) than that number. If it is a function, the function
244 will be called without any parameters, and if it returns nil, there is
245 no signature in the buffer. If it is a string, it will be used as a
246 regexp. If it matches, the text in question is not a signature.
248 This can also be a list of the above values."
249 :type
'(choice (const nil
)
253 (regexp :value
".*"))
254 :group
'gnus-article-signature
)
256 (defcustom gnus-hidden-properties
257 (if (featurep 'xemacs
)
258 ;; `intangible' is evil, but I keep it here in case it's useful.
259 '(invisible t intangible t
)
260 ;; Emacs's command loop moves point out of invisible text anyway, so
261 ;; `intangible' is clearly not needed there.
263 "Property list to use for hiding text."
265 :group
'gnus-article-hiding
)
267 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
268 ;; frames in a session.
269 (defcustom gnus-article-x-face-command
270 (if (featurep 'xemacs
)
271 (if (or (gnus-image-type-available-p 'xface
)
272 (gnus-image-type-available-p 'pbm
))
273 'gnus-display-x-face-in-from
275 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
276 ; uncompface; } | icontopbm | ee -")
277 (if (gnus-image-type-available-p 'pbm
)
278 'gnus-display-x-face-in-from
280 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
281 ; uncompface; } | icontopbm | display -"))
282 "*String or function to be executed to display an X-Face header.
283 If it is a string, the command will be executed in a sub-shell
284 asynchronously. The compressed face will be piped to this command."
285 :type
`(choice string
286 (function-item gnus-display-x-face-in-from
)
290 :group
'gnus-article-washing
)
292 (defcustom gnus-article-x-face-too-ugly nil
293 "Regexp matching posters whose face shouldn't be shown automatically."
294 :type
'(choice regexp
(const nil
))
295 :group
'gnus-article-washing
)
297 (defcustom gnus-article-banner-alist nil
298 "Banner alist for stripping.
300 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
302 :type
'(repeat (cons symbol regexp
))
303 :group
'gnus-article-washing
)
305 (gnus-define-group-parameter
308 "Alist of regexps (to match group names) and banner."
309 :variable-group gnus-article-washing
311 '(choice :tag
"Banner"
313 (const :tag
"Remove signature" signature
)
314 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
316 (const :tag
"None" nil
))
318 "If non-nil, specify how to remove `banners' from articles.
320 Symbol `signature' means to remove signatures delimited by
321 `gnus-signature-separator'. Any other symbol is used to look up a
322 regular expression to match the banner in `gnus-article-banner-alist'.
323 A string is used as a regular expression to match the banner
326 (defcustom gnus-article-address-banner-alist nil
327 "Alist of mail addresses and banners.
328 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
329 to match a mail address in the From: header, BANNER is one of a symbol
330 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
331 If ADDRESS matches author's mail address, it will remove things like
332 advertisements. For example:
334 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
338 (regexp :tag
"Address")
339 (choice :tag
"Banner" :value nil
340 (const :tag
"Remove signature" signature
)
341 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
343 (const :tag
"None" nil
))))
345 :group
'gnus-article-washing
)
347 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
349 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
350 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
353 (defun gnus-emphasis-custom-value-to-external (value)
354 (gnus-emphasis-custom-with-format
355 (if (consp (car value
))
356 (list (format format
(car (car value
)) (cdr (car value
)))
358 (if (nth 1 value
) 2 3)
362 (defun gnus-emphasis-custom-value-to-internal (value)
363 (gnus-emphasis-custom-with-format
364 (let ((regexp (concat "\\`"
365 (format (regexp-quote format
)
366 "\\([^()]+\\)" "\\([^()]+\\)")
369 (if (string-match regexp
(setq pattern
(car value
)))
370 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
375 (defcustom gnus-emphasis-alist
377 '(("\\*" "\\*" bold nil
2)
380 ("_/" "/_" underline-italic
)
381 ("_\\*" "\\*_" underline-bold
)
382 ("\\*/" "/\\*" bold-italic
)
383 ("_\\*/" "/\\*_" underline-bold-italic
))))
385 (gnus-emphasis-custom-with-format
386 (mapcar (lambda (spec)
387 (list (format format
(car spec
) (cadr spec
))
390 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
392 '(;; I've never seen anyone use this strikethru convention whereas I've
393 ;; several times seen it triggered by normal text. --Stef
394 ;; Miles suggests that this form is sometimes used but for italics,
395 ;; so maybe we should map it to `italic'.
396 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
397 ;; 2 3 gnus-emphasis-strikethru)
398 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
399 2 3 gnus-emphasis-underline
))))
400 "*Alist that says how to fontify certain phrases.
401 Each item looks like this:
403 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
405 The first element is a regular expression to be matched. The second
406 is a number that says what regular expression grouping used to find
407 the entire emphasized word. The third is a number that says what
408 regexp grouping should be displayed and highlighted. The fourth
409 is the face used for highlighting."
413 :format
"%[Customizing Style%]\n%v"
415 (group :tag
"Default"
416 :value
("" 0 0 default
)
419 (let ((value (widget-get
420 (cadr (widget-get (widget-get widget
:parent
)
423 (if (not (eq (nth 2 value
) 'default
))
427 (gnus-emphasis-custom-value-to-external value
))))
428 (widget-group-value-create widget
))
430 (integer :format
"Match group: %v")
431 (integer :format
"Emphasize group: %v")
434 :value
(("_" .
"_") nil default
)
436 (regexp :format
"Start regexp: %v")
437 (regexp :format
"End regexp: %v"))
438 (boolean :format
"Show start and end patterns: %[%v%]\n"
439 :on
" On " :off
" Off ")
441 :get
(lambda (symbol)
442 (mapcar 'gnus-emphasis-custom-value-to-internal
443 (default-value symbol
)))
444 :set
(lambda (symbol value
)
445 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
447 :group
'gnus-article-emphasis
)
449 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
450 "A regexp to describe whitespace which should not be emphasized.
451 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
452 The former avoids underlining of leading and trailing whitespace,
453 and the latter avoids underlining any whitespace at all."
455 :group
'gnus-article-emphasis
458 (defface gnus-emphasis-bold
'((t (:bold t
)))
459 "Face used for displaying strong emphasized text (*word*)."
460 :group
'gnus-article-emphasis
)
462 (defface gnus-emphasis-italic
'((t (:italic t
)))
463 "Face used for displaying italic emphasized text (/word/)."
464 :group
'gnus-article-emphasis
)
466 (defface gnus-emphasis-underline
'((t (:underline t
)))
467 "Face used for displaying underlined emphasized text (_word_)."
468 :group
'gnus-article-emphasis
)
470 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
471 "Face used for displaying underlined bold emphasized text (_*word*_)."
472 :group
'gnus-article-emphasis
)
474 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
475 "Face used for displaying underlined italic emphasized text (_/word/_)."
476 :group
'gnus-article-emphasis
)
478 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
479 "Face used for displaying bold italic emphasized text (/*word*/)."
480 :group
'gnus-article-emphasis
)
482 (defface gnus-emphasis-underline-bold-italic
483 '((t (:bold t
:italic t
:underline t
)))
484 "Face used for displaying underlined bold italic emphasized text.
485 Example: (_/*word*/_)."
486 :group
'gnus-article-emphasis
)
488 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
489 '((t (:strikethru t
)))
490 '((t (:strike-through t
))))
491 "Face used for displaying strike-through text (-word-)."
492 :group
'gnus-article-emphasis
)
494 (defface gnus-emphasis-highlight-words
495 '((t (:background
"black" :foreground
"yellow")))
496 "Face used for displaying highlighted words."
497 :group
'gnus-article-emphasis
)
499 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
500 "Format for display of Date headers in article bodies.
501 See `format-time-string' for the possible values.
503 The variable can also be function, which should return a complete Date
504 header. The function is called with one argument, the time, which can
505 be fed to `format-time-string'."
506 :type
'(choice string function
)
507 :link
'(custom-manual "(gnus)Article Date")
508 :group
'gnus-article-washing
)
510 (defcustom gnus-save-all-headers t
511 "*If non-nil, don't remove any headers before saving.
512 This will be overridden by the `:headers' property that the symbol of
513 the saver function, which is specified by `gnus-default-article-saver',
515 :group
'gnus-article-saving
518 (defcustom gnus-prompt-before-saving
'always
519 "*This variable says how much prompting is to be done when saving articles.
520 If it is nil, no prompting will be done, and the articles will be
521 saved to the default files. If this variable is `always', each and
522 every article that is saved will be preceded by a prompt, even when
523 saving large batches of articles. If this variable is neither nil not
524 `always', there the user will be prompted once for a file name for
525 each invocation of the saving commands."
526 :group
'gnus-article-saving
527 :type
'(choice (item always
)
528 (item :tag
"never" nil
)
529 (sexp :tag
"once" :format
"%t\n" :value t
)))
531 (defcustom gnus-saved-headers gnus-visible-headers
532 "Headers to keep if `gnus-save-all-headers' is nil.
533 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
534 If that variable is nil, however, all headers that match this regexp
535 will be kept while the rest will be deleted before saving. This and
536 `gnus-save-all-headers' will be overridden by the `:headers' property
537 that the symbol of the saver function, which is specified by
538 `gnus-default-article-saver', might have."
539 :group
'gnus-article-saving
542 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
543 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
544 "A function to save articles in your favorite format.
545 The function will be called by way of the `gnus-summary-save-article'
546 command, and friends such as `gnus-summary-save-article-rmail'.
548 Gnus provides the following functions:
550 * gnus-summary-save-in-rmail (Rmail format)
551 * gnus-summary-save-in-mail (Unix mail format)
552 * gnus-summary-save-in-folder (MH folder)
553 * gnus-summary-save-in-file (article format)
554 * gnus-summary-save-body-in-file (article body)
555 * gnus-summary-save-in-vm (use VM's folder format)
556 * gnus-summary-write-to-file (article format -- overwrite)
557 * gnus-summary-write-body-to-file (article body -- overwrite)
558 * gnus-summary-save-in-pipe (article format)
560 The symbol of each function may have the following properties:
563 The value non-nil means save decoded articles. This is meaningful
564 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
565 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
566 `gnus-summary-save-in-pipe'.
569 The value specifies an alternative function which appends, not
570 overwrites, articles to a file. This implies that when saving many
571 articles at a time, `gnus-prompt-before-saving' is bound to t and all
572 articles are saved in a single file. This is meaningful only with
573 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
576 The value specifies the symbol of a variable of which the value
577 specifies headers to be saved. If it is omitted,
578 `gnus-save-all-headers' and `gnus-saved-headers' control what
579 headers should be saved."
580 :group
'gnus-article-saving
581 :type
'(radio (function-item gnus-summary-save-in-rmail
)
582 (function-item gnus-summary-save-in-mail
)
583 (function-item gnus-summary-save-in-folder
)
584 (function-item gnus-summary-save-in-file
)
585 (function-item gnus-summary-save-body-in-file
)
586 (function-item gnus-summary-save-in-vm
)
587 (function-item gnus-summary-write-to-file
)
588 (function-item gnus-summary-write-body-to-file
)
589 (function-item gnus-summary-save-in-pipe
)
592 (defcustom gnus-article-save-coding-system
593 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
594 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
595 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
596 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
597 "Coding system used to save decoded articles to a file.
599 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
600 which can safely encode any characters in text. This is used by the
603 * gnus-summary-save-article-file
604 * gnus-summary-save-article-body-file
605 * gnus-summary-write-article-file
606 * gnus-summary-write-article-body-file
608 and the functions to which you may set `gnus-default-article-saver':
610 * gnus-summary-save-in-file
611 * gnus-summary-save-body-in-file
612 * gnus-summary-write-to-file
613 * gnus-summary-write-body-to-file
615 Those commands and functions save just text displayed in the article
616 buffer to a file if the value of this variable is non-nil. Note that
617 buttonized MIME parts will be lost in a saved file in that case.
618 Otherwise, raw articles will be saved."
619 :group
'gnus-article-saving
621 :format
"%{%t%}:\n %[Value Menu%] %v"
622 (const :tag
"Save raw articles" nil
)
625 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
626 '((const :tag
"UTF-8" utf-8
)
627 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
628 (const :tag
"Emacs internal" emacs-mule
)
629 (const :tag
"escape-quoted" escape-quoted
))))
630 (symbol :tag
"Coding system")))
632 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
633 "A function generating a file name to save articles in Rmail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group
'gnus-article-saving
638 (defcustom gnus-mail-save-name
'gnus-plain-save-name
639 "A function generating a file name to save articles in Unix mail format.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
641 :group
'gnus-article-saving
644 (defcustom gnus-folder-save-name
'gnus-folder-save-name
645 "A function generating a file name to save articles in MH folder.
646 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
647 :group
'gnus-article-saving
650 (defcustom gnus-file-save-name
'gnus-numeric-save-name
651 "A function generating a file name to save articles in article format.
652 The function is called with NEWSGROUP, HEADERS, and optional
654 :group
'gnus-article-saving
657 (defcustom gnus-split-methods
658 '((gnus-article-archive-name)
659 (gnus-article-nndoc-name))
660 "*Variable used to suggest where articles are to be saved.
661 For instance, if you would like to save articles related to Gnus in
662 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
663 you could set this variable to something like:
665 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
666 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
668 This variable is an alist where the key is the match and the
669 value is a list of possible files to save in if the match is
672 If the match is a string, it is used as a regexp match on the
673 article. If the match is a symbol, that symbol will be funcalled
674 from the buffer of the article to be saved with the newsgroup as the
675 parameter. If it is a list, it will be evalled in the same buffer.
677 If this form or function returns a string, this string will be used as a
678 possible file name; and if it returns a non-nil list, that list will be
679 used as possible file names."
680 :group
'gnus-article-saving
681 :type
'(repeat (choice (list :value
(fun) function
)
682 (cons :value
("" "") regexp
(repeat string
))
685 (defcustom gnus-page-delimiter
"^\^L"
686 "*Regexp describing what to use as article page delimiters.
687 The default value is \"^\^L\", which is a form linefeed at the
688 beginning of a line."
690 :group
'gnus-article-various
)
692 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
693 "*The format specification for the article mode line.
694 See `gnus-summary-mode-line-format' for a closer description.
696 The following additional specs are available:
698 %w The article washing status.
699 %m The number of MIME parts in the article."
702 :group
'gnus-article-various
)
704 (defcustom gnus-article-mode-hook nil
705 "*A hook for Gnus article mode."
707 :group
'gnus-article-various
)
709 (when (featurep 'xemacs
)
710 ;; Extracted from gnus-xmas-define in order to preserve user settings
711 (when (fboundp 'turn-off-scroll-in-place
)
712 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
713 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
714 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
716 (defcustom gnus-article-menu-hook nil
717 "*Hook run after the creation of the article mode menu."
719 :group
'gnus-article-various
)
721 (defcustom gnus-article-prepare-hook nil
722 "*A hook called after an article has been prepared in the article buffer."
724 :group
'gnus-article-various
)
726 (defcustom gnus-copy-article-ignored-headers nil
727 "List of headers to be removed when copying an article.
728 Each element is a regular expression."
729 :version
"23.1" ;; No Gnus
730 :type
'(repeat regexp
)
731 :group
'gnus-article-various
)
733 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
734 "Gnus 5.10 (Emacs 22.1)")
737 '((t (:weight bold
)))
738 "Face used for highlighting a button in the article buffer."
739 :group
'gnus-article-buttons
)
741 (defcustom gnus-article-button-face
'gnus-button
742 "Face used for highlighting buttons in the article buffer.
744 An article button is a piece of text that you can activate by pressing
745 `RET' or `mouse-2' above it."
747 :group
'gnus-article-buttons
)
749 (defcustom gnus-article-mouse-face
'highlight
750 "Face used for mouse highlighting in the article buffer.
752 Article buttons will be displayed in this face when the cursor is
755 :group
'gnus-article-buttons
)
757 (defcustom gnus-signature-face
'gnus-signature
758 "Face used for highlighting a signature in the article buffer.
759 Obsolete; use the face `gnus-signature' for customizations instead."
761 :group
'gnus-article-highlight
762 :group
'gnus-article-signature
)
764 (defface gnus-signature
767 "Face used for highlighting a signature in the article buffer."
768 :group
'gnus-article-highlight
769 :group
'gnus-article-signature
)
770 ;; backward-compatibility alias
771 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
772 (put 'gnus-signature-face
'obsolete-face
"22.1")
774 (defface gnus-header-from
777 (:foreground
"PaleGreen1"))
780 (:foreground
"red3"))
783 "Face used for displaying from headers."
784 :group
'gnus-article-headers
785 :group
'gnus-article-highlight
)
786 ;; backward-compatibility alias
787 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
788 (put 'gnus-header-from-face
'obsolete-face
"22.1")
790 (defface gnus-header-subject
793 (:foreground
"SeaGreen1"))
796 (:foreground
"red4"))
798 (:bold t
:italic t
)))
799 "Face used for displaying subject headers."
800 :group
'gnus-article-headers
801 :group
'gnus-article-highlight
)
802 ;; backward-compatibility alias
803 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
804 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
806 (defface gnus-header-newsgroups
809 (:foreground
"yellow" :italic t
))
812 (:foreground
"MidnightBlue" :italic t
))
815 "Face used for displaying newsgroups headers.
816 In the default setup this face is only used for crossposted
818 :group
'gnus-article-headers
819 :group
'gnus-article-highlight
)
820 ;; backward-compatibility alias
821 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
822 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
824 (defface gnus-header-name
827 (:foreground
"SpringGreen2"))
830 (:foreground
"maroon"))
833 "Face used for displaying header names."
834 :group
'gnus-article-headers
835 :group
'gnus-article-highlight
)
836 ;; backward-compatibility alias
837 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
838 (put 'gnus-header-name-face
'obsolete-face
"22.1")
840 (defface gnus-header-content
843 (:foreground
"SpringGreen1" :italic t
))
846 (:foreground
"indianred4" :italic t
))
848 (:italic t
))) "Face used for displaying header content."
849 :group
'gnus-article-headers
850 :group
'gnus-article-highlight
)
851 ;; backward-compatibility alias
852 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
853 (put 'gnus-header-content-face
'obsolete-face
"22.1")
855 (defcustom gnus-header-face-alist
856 '(("From" nil gnus-header-from
)
857 ("Subject" nil gnus-header-subject
)
858 ("Newsgroups:.*," nil gnus-header-newsgroups
)
859 ("" gnus-header-name gnus-header-content
))
860 "*Controls highlighting of article headers.
862 An alist of the form (HEADER NAME CONTENT).
864 HEADER is a regular expression which should match the name of a
865 header and NAME and CONTENT are either face names or nil.
867 The name of each header field will be displayed using the face
868 specified by the first element in the list where HEADER matches
869 the header name and NAME is non-nil. Similarly, the content will
870 be displayed by the first non-nil matching CONTENT face."
871 :group
'gnus-article-headers
872 :group
'gnus-article-highlight
873 :type
'(repeat (list (regexp :tag
"Header")
875 (item :tag
"skip" nil
)
876 (face :value default
))
877 (choice :tag
"Content"
878 (item :tag
"skip" nil
)
879 (face :value default
)))))
881 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
882 '((xface .
(:face gnus-x-face
)))
883 '((pbm .
(:face gnus-x-face
))
885 "Alist of image types and properties applied to Face and X-Face images.
888 ;; Specify the altitude of Face images in the From header.
889 \(setq gnus-face-properties-alist
890 '((pbm . (:face gnus-x-face :ascent 80))
891 (png . (:ascent 80))))
893 ;; Show Face images as pressed buttons.
894 \(setq gnus-face-properties-alist
895 '((pbm . (:face gnus-x-face :relief -2))
896 (png . (:relief -2))))
898 See the manual for the valid properties for various image types.
899 Currently, `pbm' is used for X-Face images and `png' is used for Face
900 images in Emacs. Only the `:face' property is effective on the `xface'
901 image type in XEmacs if it is built with the libcompface library."
902 :version
"23.1" ;; No Gnus
903 :group
'gnus-article-headers
904 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
906 (defcustom gnus-article-decode-hook
907 '(article-decode-charset article-decode-encoded-words
908 article-decode-group-name article-decode-idna-rhs
)
909 "*Hook run to decode charsets in articles."
910 :group
'gnus-article-headers
913 (defcustom gnus-display-mime-function
'gnus-display-mime
914 "Function to display MIME articles."
915 :group
'gnus-article-mime
918 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
919 "Function used to decode headers.")
921 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
922 "Function used to decode addresses.")
924 (defvar gnus-article-dumbquotes-map
944 "Table for MS-to-Latin1 translation.")
946 (defcustom gnus-ignored-mime-types nil
947 "List of MIME types that should be ignored by Gnus."
949 :group
'gnus-article-mime
950 :type
'(repeat regexp
))
952 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
953 "List of MIME types that should not be given buttons when rendered inline.
954 See also `gnus-buttonized-mime-types' which may override this variable.
955 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
957 :group
'gnus-article-mime
958 :type
'(repeat regexp
))
960 (defcustom gnus-buttonized-mime-types nil
961 "List of MIME types that should be given buttons when rendered inline.
962 If set, this variable overrides `gnus-unbuttonized-mime-types'.
963 To see e.g. security buttons you could set this to
964 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
965 this list to display radio buttons that allow you to choose one of two
966 media types those mails include. See also `mm-discouraged-alternatives'.
967 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
969 :group
'gnus-article-mime
970 :type
'(repeat regexp
))
972 (defcustom gnus-inhibit-mime-unbuttonizing nil
973 "If non-nil, all MIME parts get buttons.
974 When nil (the default value), then some MIME parts do not get buttons,
975 as described by the variables `gnus-buttonized-mime-types' and
976 `gnus-unbuttonized-mime-types'."
978 :group
'gnus-article-mime
981 (defcustom gnus-body-boundary-delimiter
"_"
982 "String used to delimit header and body.
983 This variable is used by `gnus-article-treat-body-boundary' which can
984 be controlled by `gnus-treat-body-boundary'."
986 :group
'gnus-article-various
987 :type
'(choice (item :tag
"None" :value nil
)
990 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
992 "Defines the location of the faces database.
993 For information on obtaining this database of pretty pictures, please
994 see http://www.cs.indiana.edu/picons/ftp/index.html"
996 :type
'(repeat directory
)
997 :link
'(url-link :tag
"download"
998 "http://www.cs.indiana.edu/picons/ftp/index.html")
999 :link
'(custom-manual "(gnus)Picons")
1002 (defun gnus-picons-installed-p ()
1003 "Say whether picons are installed on your machine."
1004 (let ((installed nil
))
1005 (dolist (database gnus-picon-databases
)
1006 (when (file-exists-p database
)
1007 (setq installed t
)))
1010 (defcustom gnus-article-mime-part-function nil
1011 "Function called with a MIME handle as the argument.
1012 This is meant for people who want to do something automatic based
1013 on parts -- for instance, adding Vcard info to a database."
1014 :group
'gnus-article-mime
1015 :type
'(choice (const nil
)
1018 (defcustom gnus-mime-multipart-functions nil
1019 "An alist of MIME types to functions to display them."
1021 :group
'gnus-article-mime
1022 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1024 (defcustom gnus-article-date-headers
'(combined-lapsed)
1025 "A list of Date header formats to display.
1026 Valid formats are `ut' (universal time), `local' (local time
1027 zone), `english' (readable English), `lapsed' (elapsed time),
1028 `combined-lapsed' (both the original date and the elapsed time),
1029 `original' (the original date header), `iso8601' (ISO8601
1030 format), and `user-defined' (a user-defined format defined by the
1031 `gnus-article-time-format' variable).
1033 You have as many date headers as you want in the article buffer.
1034 Some of these headers are updated automatically. See
1035 `gnus-article-update-date-headers' for details."
1037 :group
'gnus-article-headers
1039 (const :tag
"Universal time (UT)" ut
)
1040 (const :tag
"Local time zone" local
)
1041 (const :tag
"Readable English" english
)
1042 (const :tag
"Elapsed time" lapsed
)
1043 (const :tag
"Original and elapsed time" combined-lapsed
)
1044 (const :tag
"Original date header" original
)
1045 (const :tag
"ISO8601 format" iso8601
)
1046 (const :tag
"User-defined" user-defined
)))
1048 (defcustom gnus-article-update-date-headers nil
1049 "A number that says how often to update the date header (in seconds).
1050 If nil, don't update it at all."
1052 :group
'gnus-article-headers
1054 (item :tag
"Don't update" :value nil
)
1057 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1058 "Function called with a MIME handle as the argument.
1059 This is meant for people who want to view first matched part.
1060 For `undisplayed-alternative' (default), the first undisplayed
1061 part or alternative part is used. For `undisplayed', the first
1062 undisplayed part is used. For a function, the first part which
1063 the function return t is used. For nil, the first part is
1066 :group
'gnus-article-mime
1068 (item :tag
"first" :value nil
)
1069 (item :tag
"undisplayed" :value undisplayed
)
1070 (item :tag
"undisplayed or alternative"
1071 :value undisplayed-alternative
)
1074 (defcustom gnus-mime-action-alist
1075 '(("save to file" . gnus-mime-save-part
)
1076 ("save and strip" . gnus-mime-save-part-and-strip
)
1077 ("replace with file" . gnus-mime-replace-part
)
1078 ("delete part" . gnus-mime-delete-part
)
1079 ("display as text" . gnus-mime-inline-part
)
1080 ("view the part" . gnus-mime-view-part
)
1081 ("pipe to command" . gnus-mime-pipe-part
)
1082 ("toggle display" . gnus-article-press-button
)
1083 ("toggle display" . gnus-article-view-part-as-charset
)
1084 ("view as type" . gnus-mime-view-part-as-type
)
1085 ("view internally" . gnus-mime-view-part-internally
)
1086 ("view externally" . gnus-mime-view-part-externally
))
1087 "An alist of actions that run on the MIME attachment."
1088 :group
'gnus-article-mime
1089 :type
'(repeat (cons (string :tag
"name")
1092 (defcustom gnus-auto-select-part
1
1093 "Advance to next MIME part when deleting or stripping parts.
1095 When 0, point will be placed on the same part as before. When
1096 positive (negative), move point forward (backwards) this many
1097 parts. When nil, redisplay article."
1098 :version
"23.1" ;; No Gnus
1099 :group
'gnus-article-mime
1100 :type
'(choice (const nil
:tag
"Redisplay article.")
1101 (const 1 :tag
"Next part.")
1102 (const 0 :tag
"Current part.")
1106 ;;; The treatment variables
1109 (defvar gnus-part-display-hook nil
1110 "Hook called on parts that are to receive treatment.")
1112 (defvar gnus-article-treat-custom
1113 '(choice (const :tag
"Off" nil
)
1115 (const :tag
"Header" head
)
1116 (const :tag
"First" first
)
1117 (const :tag
"Last" last
)
1118 (integer :tag
"Less")
1119 (repeat :tag
"Groups" regexp
)
1120 (sexp :tag
"Predicate")))
1122 (defvar gnus-article-treat-head-custom
1123 '(choice (const :tag
"Off" nil
)
1124 (const :tag
"Header" head
)))
1126 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1127 "text/x-patch" "text/html")
1128 "Part types eligible for treatment.")
1130 (defvar gnus-inhibit-treatment nil
1131 "Whether to inhibit treatment.")
1133 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1134 "Highlight the signature.
1135 Valid values are nil, t, `head', `first', `last', an integer or a
1136 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group
'gnus-article-treat
1138 :link
'(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom
)
1140 (put 'gnus-treat-highlight-signature
'highlight t
)
1142 (defcustom gnus-treat-buttonize
100000
1144 Valid values are nil, t, `head', `first', `last', an integer or a
1145 predicate. See Info node `(gnus)Customizing Articles'."
1146 :group
'gnus-article-treat
1147 :link
'(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom
)
1149 (put 'gnus-treat-buttonize
'highlight t
)
1151 (defcustom gnus-treat-buttonize-head
'head
1152 "Add buttons to the head.
1153 Valid values are nil, t, `head', `first', `last', an integer or a
1154 predicate. See Info node `(gnus)Customizing Articles'."
1155 :group
'gnus-article-treat
1156 :link
'(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-head-custom
)
1158 (put 'gnus-treat-buttonize-head
'highlight t
)
1160 (defcustom gnus-treat-date
'head
1161 "Display dates according to the `gnus-article-date-headers' variable.
1162 Valid values are nil, t, `head', `first', `last', an integer or a
1163 predicate. See Info node `(gnus)Customizing Articles'."
1165 :group
'gnus-article-treat
1166 :link
'(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-head-custom
)
1169 (defcustom gnus-treat-emphasize
50000
1171 Valid values are nil, t, `head', `first', `last', an integer or a
1172 predicate. See Info node `(gnus)Customizing Articles'."
1173 :group
'gnus-article-treat
1174 :link
'(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-custom
)
1176 (put 'gnus-treat-emphasize
'highlight t
)
1178 (defcustom gnus-treat-strip-cr nil
1179 "Remove carriage returns.
1180 Valid values are nil, t, `head', `first', `last', an integer or a
1181 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group
'gnus-article-treat
1184 :link
'(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom
)
1187 (defcustom gnus-treat-unsplit-urls nil
1188 "Remove newlines from within URLs.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1192 :group
'gnus-article-treat
1193 :link
'(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-custom
)
1196 (defcustom gnus-treat-leading-whitespace nil
1197 "Remove leading whitespace in headers.
1198 Valid values are nil, t, `head', `first', `last', an integer or a
1199 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group
'gnus-article-treat
1202 :link
'(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom
)
1205 (defcustom gnus-treat-hide-headers
'head
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group
'gnus-article-treat
1210 :link
'(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom
)
1213 (defcustom gnus-treat-hide-boring-headers nil
1214 "Hide boring headers.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1217 :group
'gnus-article-treat
1218 :link
'(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-head-custom
)
1221 (defcustom gnus-treat-hide-signature nil
1222 "Hide the signature.
1223 Valid values are nil, t, `head', `first', `last', an integer or a
1224 predicate. See Info node `(gnus)Customizing Articles'."
1225 :group
'gnus-article-treat
1226 :link
'(custom-manual "(gnus)Customizing Articles")
1227 :type gnus-article-treat-custom
)
1229 (defcustom gnus-treat-fill-article nil
1231 Valid values are nil, t, `head', `first', `last', an integer or a
1232 predicate. See Info node `(gnus)Customizing Articles'."
1233 :group
'gnus-article-treat
1234 :link
'(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom
)
1237 (defcustom gnus-treat-hide-citation nil
1239 Valid values are nil, t, `head', `first', `last', an integer or a
1240 predicate. See Info node `(gnus)Customizing Articles'.
1242 See `gnus-article-highlight-citation' for variables used to
1243 control what it hides."
1244 :group
'gnus-article-treat
1245 :link
'(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom
)
1248 (defcustom gnus-treat-hide-citation-maybe nil
1249 "Hide cited text according to certain conditions.
1250 Valid values are nil, t, `head', `first', `last', an integer or a
1251 predicate. See Info node `(gnus)Customizing Articles'.
1253 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1254 how to control what it hides."
1255 :group
'gnus-article-treat
1256 :link
'(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom
)
1259 (defcustom gnus-treat-strip-list-identifiers
'head
1260 "Strip list identifiers from `gnus-list-identifiers`.
1261 Valid values are nil, t, `head', `first', `last', an integer or a
1262 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group
'gnus-article-treat
1265 :link
'(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom
)
1268 (gnus-define-group-parameter
1271 "Alist of regexps and correspondent identifiers."
1272 :variable-group gnus-article-washing
1274 '(choice :tag
"Identifier"
1276 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1278 (const :tag
"None" nil
))
1280 "If non-nil, specify how to remove `identifiers' from articles' subject.
1282 Any symbol is used to look up a regular expression to match the
1283 banner in `gnus-list-identifiers'. A string is used as a regular
1284 expression to match the identifier directly.")
1286 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1287 "Gnus 5.10 (Emacs 22.1)")
1289 (defcustom gnus-treat-strip-pem nil
1290 "Strip PEM signatures.
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1293 :group
'gnus-article-treat
1294 :link
'(custom-manual "(gnus)Customizing Articles")
1295 :type gnus-article-treat-custom
)
1297 (defcustom gnus-treat-strip-banner t
1298 "Strip banners from articles.
1299 The banner to be stripped is specified in the `banner' group parameter.
1300 Valid values are nil, t, `head', `first', `last', an integer or a
1301 predicate. See Info node `(gnus)Customizing Articles'."
1302 :group
'gnus-article-treat
1303 :link
'(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom
)
1306 (defcustom gnus-treat-highlight-headers
'head
1307 "Highlight the headers.
1308 Valid values are nil, t, `head', `first', `last', an integer or a
1309 predicate. See Info node `(gnus)Customizing Articles'."
1310 :group
'gnus-article-treat
1311 :link
'(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-head-custom
)
1313 (put 'gnus-treat-highlight-headers
'highlight t
)
1315 (defcustom gnus-treat-highlight-citation t
1316 "Highlight cited text.
1317 Valid values are nil, t, `head', `first', `last', an integer or a
1318 predicate. See Info node `(gnus)Customizing Articles'."
1319 :group
'gnus-article-treat
1320 :link
'(custom-manual "(gnus)Customizing Articles")
1321 :type gnus-article-treat-custom
)
1322 (put 'gnus-treat-highlight-citation
'highlight t
)
1324 (defcustom gnus-treat-strip-headers-in-body t
1325 "Strip the X-No-Archive header line from the beginning of the body.
1326 Valid values are nil, t, `head', `first', `last', an integer or a
1327 predicate. See Info node `(gnus)Customizing Articles'."
1329 :group
'gnus-article-treat
1330 :link
'(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom
)
1333 (defcustom gnus-treat-strip-trailing-blank-lines nil
1334 "Strip trailing blank lines.
1335 Valid values are nil, t, `head', `first', `last', an integer or a
1336 predicate. See Info node `(gnus)Customizing Articles'.
1338 When set to t, it also strips trailing blanks in all MIME parts.
1339 Consider to use `last' instead."
1340 :group
'gnus-article-treat
1341 :link
'(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom
)
1344 (defcustom gnus-treat-strip-leading-blank-lines nil
1345 "Strip leading blank lines.
1346 Valid values are nil, t, `head', `first', `last', an integer or a
1347 predicate. See Info node `(gnus)Customizing Articles'.
1349 When set to t, it also strips trailing blanks in all MIME parts."
1350 :group
'gnus-article-treat
1351 :link
'(custom-manual "(gnus)Customizing Articles")
1352 :type gnus-article-treat-custom
)
1354 (defcustom gnus-treat-strip-multiple-blank-lines nil
1355 "Strip multiple blank lines.
1356 Valid values are nil, t, `head', `first', `last', an integer or a
1357 predicate. See Info node `(gnus)Customizing Articles'."
1358 :group
'gnus-article-treat
1359 :link
'(custom-manual "(gnus)Customizing Articles")
1360 :type gnus-article-treat-custom
)
1362 (defcustom gnus-treat-unfold-headers
'head
1363 "Unfold folded header lines.
1364 Valid values are nil, t, `head', `first', `last', an integer or a
1365 predicate. See Info node `(gnus)Customizing Articles'."
1367 :group
'gnus-article-treat
1368 :link
'(custom-manual "(gnus)Customizing Articles")
1369 :type gnus-article-treat-custom
)
1371 (defcustom gnus-article-unfold-long-headers nil
1372 "If non-nil, allow unfolding headers even if the header is long.
1373 If it is a regexp, only long headers matching this regexp are unfolded.
1374 If it is t, all long headers are unfolded.
1376 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1377 :version
"23.1" ;; No Gnus
1378 :group
'gnus-article-treat
1379 :type
'(choice (const nil
)
1380 (const :tag
"all" t
)
1383 (defcustom gnus-treat-fold-headers nil
1385 Valid values are nil, t, `head', `first', `last', an integer or a
1386 predicate. See Info node `(gnus)Customizing Articles'."
1388 :group
'gnus-article-treat
1389 :link
'(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom
)
1392 (defcustom gnus-treat-fold-newsgroups
'head
1393 "Fold the Newsgroups and Followup-To headers.
1394 Valid values are nil, t, `head', `first', `last', an integer or a
1395 predicate. See Info node `(gnus)Customizing Articles'."
1397 :group
'gnus-article-treat
1398 :link
'(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom
)
1401 (defcustom gnus-treat-overstrike t
1402 "Treat overstrike highlighting.
1403 Valid values are nil, t, `head', `first', `last', an integer or a
1404 predicate. See Info node `(gnus)Customizing Articles'."
1405 :group
'gnus-article-treat
1406 :link
'(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom
)
1408 (put 'gnus-treat-overstrike
'highlight t
)
1410 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1411 "Treat ANSI SGR control sequences.
1412 Valid values are nil, t, `head', `first', `last', an integer or a
1413 predicate. See Info node `(gnus)Customizing Articles'."
1414 :group
'gnus-article-treat
1415 :link
'(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom
)
1418 (make-obsolete-variable 'gnus-treat-display-xface
1419 'gnus-treat-display-x-face
"Emacs 22.1")
1421 (defcustom gnus-treat-display-x-face
1422 (and (not noninteractive
)
1423 (gnus-image-type-available-p 'xbm
)
1424 (if (featurep 'xemacs
)
1427 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1428 (executable-find "icontopbm"))
1429 ;; shell-command-to-string may signal an error, e.g. if
1430 ;; shell-file-name is not found.
1433 "Display X-Face headers.
1434 Valid values are nil and `head'.
1435 See Info node `(gnus)Customizing Articles' and Info node
1436 `(gnus)X-Face' for details."
1437 :group
'gnus-article-treat
1439 :link
'(custom-manual "(gnus)Customizing Articles")
1440 :link
'(custom-manual "(gnus)X-Face")
1441 :type gnus-article-treat-head-custom
1442 :set
(lambda (symbol value
)
1445 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1447 ((boundp 'gnus-treat-display-xface
)
1449 ** gnus-treat-display-xface is an obsolete variable;\
1450 use gnus-treat-display-x-face instead")
1451 (default-value 'gnus-treat-display-xface
))
1452 ((get 'gnus-treat-display-xface
'saved-value
)
1454 ** gnus-treat-display-xface is an obsolete variable;\
1455 use gnus-treat-display-x-face instead")
1456 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1459 (put 'gnus-treat-display-x-face
'highlight t
)
1461 (defcustom gnus-treat-display-face
1462 (and (not noninteractive
)
1463 (gnus-image-type-available-p 'png
)
1465 "Display Face headers.
1466 Valid values are nil, t, `head', `first', `last', an integer or a
1467 predicate. See Info node `(gnus)Customizing Articles' and Info
1468 node `(gnus)Face' for details."
1469 :group
'gnus-article-treat
1471 :link
'(custom-manual "(gnus)Customizing Articles")
1472 :link
'(custom-manual "(gnus)X-Face")
1473 :type gnus-article-treat-head-custom
)
1474 (put 'gnus-treat-display-face
'highlight t
)
1476 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1478 Valid values are nil, t, `head', `first', `last', an integer or a
1479 predicate. See Info node `(gnus)Customizing Articles' and Info
1480 node `(gnus)Smileys' for details."
1481 :group
'gnus-article-treat
1483 :link
'(custom-manual "(gnus)Customizing Articles")
1484 :link
'(custom-manual "(gnus)Smileys")
1485 :type gnus-article-treat-custom
)
1486 (put 'gnus-treat-display-smileys
'highlight t
)
1488 (defcustom gnus-treat-from-picon
1489 (if (and (gnus-image-type-available-p 'xpm
)
1490 (gnus-picons-installed-p))
1492 "Display picons in the From header.
1493 Valid values are nil, t, `head', `first', `last', an integer or a
1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1495 node `(gnus)Picons' for details."
1497 :group
'gnus-article-treat
1499 :link
'(custom-manual "(gnus)Customizing Articles")
1500 :link
'(custom-manual "(gnus)Picons")
1501 :type gnus-article-treat-head-custom
)
1502 (put 'gnus-treat-from-picon
'highlight t
)
1504 (defcustom gnus-treat-mail-picon
1505 (if (and (gnus-image-type-available-p 'xpm
)
1506 (gnus-picons-installed-p))
1508 "Display picons in To and Cc headers.
1509 Valid values are nil, t, `head', `first', `last', an integer or a
1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1511 node `(gnus)Picons' for details."
1513 :group
'gnus-article-treat
1515 :link
'(custom-manual "(gnus)Customizing Articles")
1516 :link
'(custom-manual "(gnus)Picons")
1517 :type gnus-article-treat-head-custom
)
1518 (put 'gnus-treat-mail-picon
'highlight t
)
1520 (defcustom gnus-treat-newsgroups-picon
1521 (if (and (gnus-image-type-available-p 'xpm
)
1522 (gnus-picons-installed-p))
1524 "Display picons in the Newsgroups and Followup-To headers.
1525 Valid values are nil, t, `head', `first', `last', an integer or a
1526 predicate. See Info node `(gnus)Customizing Articles' and Info
1527 node `(gnus)Picons' for details."
1529 :group
'gnus-article-treat
1531 :link
'(custom-manual "(gnus)Customizing Articles")
1532 :link
'(custom-manual "(gnus)Picons")
1533 :type gnus-article-treat-head-custom
)
1534 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1536 (defcustom gnus-treat-from-gravatar nil
1537 "Display gravatars in the From header.
1538 Valid values are nil, t, `head', `first', `last', an integer or a
1539 predicate. See Info node `(gnus)Customizing Articles' and Info
1540 node `(gnus)Gravatars' for details."
1542 :group
'gnus-article-treat
1543 :group
'gnus-gravatar
1544 :link
'(custom-manual "(gnus)Customizing Articles")
1545 :link
'(custom-manual "(gnus)Gravatars")
1546 :type gnus-article-treat-head-custom
)
1547 (put 'gnus-treat-from-gravatar
'highlight t
)
1549 (defcustom gnus-treat-mail-gravatar nil
1550 "Display gravatars in To and Cc headers.
1551 Valid values are nil, t, `head', `first', `last', an integer or a
1552 predicate. See Info node `(gnus)Customizing Articles' and Info
1553 node `(gnus)Gravatars' for details."
1555 :group
'gnus-article-treat
1556 :group
'gnus-gravatar
1557 :link
'(custom-manual "(gnus)Customizing Articles")
1558 :link
'(custom-manual "(gnus)Gravatars")
1559 :type gnus-article-treat-head-custom
)
1560 (put 'gnus-treat-mail-gravatar
'highlight t
)
1562 (defcustom gnus-treat-body-boundary
1563 (if (or gnus-treat-newsgroups-picon
1564 gnus-treat-mail-picon
1565 gnus-treat-from-picon
1566 gnus-treat-from-gravatar
1567 gnus-treat-mail-gravatar
)
1568 ;; If there's much decoration, the user might prefer a boundary.
1571 "Draw a boundary at the end of the headers.
1572 Valid values are nil and `head'.
1573 See Info node `(gnus)Customizing Articles' for details."
1575 :group
'gnus-article-treat
1576 :link
'(custom-manual "(gnus)Customizing Articles")
1577 :type gnus-article-treat-head-custom
)
1579 (defcustom gnus-treat-capitalize-sentences nil
1580 "Capitalize sentence-starting words.
1581 Valid values are nil, t, `head', `first', `last', an integer or a
1582 predicate. See Info node `(gnus)Customizing Articles'."
1584 :group
'gnus-article-treat
1585 :link
'(custom-manual "(gnus)Customizing Articles")
1586 :type gnus-article-treat-custom
)
1588 (defcustom gnus-treat-wash-html nil
1590 Valid values are nil, t, `head', `first', `last', an integer or a
1591 predicate. See Info node `(gnus)Customizing Articles'."
1593 :group
'gnus-article-treat
1594 :link
'(custom-manual "(gnus)Customizing Articles")
1595 :type gnus-article-treat-custom
)
1597 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1599 Valid values are nil, t, `head', `first', `last', an integer or a
1600 predicate. See Info node `(gnus)Customizing Articles'."
1602 :group
'gnus-article-treat
1603 :link
'(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom
)
1606 (defcustom gnus-treat-x-pgp-sig nil
1608 To automatically treat X-PGP-Sig, set it to head.
1609 Valid values are nil, t, `head', `first', `last', an integer or a
1610 predicate. See Info node `(gnus)Customizing Articles'."
1612 :group
'gnus-article-treat
1613 :group
'mime-security
1614 :link
'(custom-manual "(gnus)Customizing Articles")
1615 :type gnus-article-treat-custom
)
1617 (defvar gnus-article-encrypt-protocol-alist
1618 '(("PGP" . mml2015-self-encrypt
)))
1620 ;; Set to nil if more than one protocol added to
1621 ;; gnus-article-encrypt-protocol-alist.
1622 (defcustom gnus-article-encrypt-protocol
"PGP"
1623 "The protocol used for encrypt articles.
1624 It is a string, such as \"PGP\". If nil, ask user."
1627 :group
'mime-security
)
1629 (defvar idna-program
)
1631 (defcustom gnus-use-idna
(and (condition-case nil
(require 'idna
) (file-error))
1632 (mm-coding-system-p 'utf-8
)
1634 (executable-find idna-program
))
1635 "Whether IDNA decoding of headers is used when viewing messages.
1636 This requires GNU Libidn, and by default only enabled if it is found."
1638 :group
'gnus-article-headers
1641 (defcustom gnus-article-over-scroll nil
1642 "If non-nil, allow scrolling the article buffer even when there no more text."
1644 :group
'gnus-article
1647 (defcustom gnus-inhibit-images nil
1648 "Non-nil means inhibit displaying of images inline in the article body."
1650 :group
'gnus-article
1653 (defcustom gnus-blocked-images
'gnus-block-private-groups
1654 "Images that have URLs matching this regexp will be blocked.
1655 This can also be a function to be evaluated. If so, it will be
1656 called with the group name as the parameter, and should return a
1660 :type
'(choice regexp function
))
1662 ;;; Internal variables
1664 (defvar gnus-english-month-names
1665 '("January" "February" "March" "April" "May" "June" "July" "August"
1666 "September" "October" "November" "December"))
1668 (defvar article-goto-body-goes-to-point-min-p nil
)
1669 (defvar gnus-article-wash-types nil
)
1670 (defvar gnus-article-emphasis-alist nil
)
1671 (defvar gnus-article-image-alist nil
)
1673 (defvar gnus-article-mime-handle-alist-1 nil
)
1674 (defvar gnus-treatment-function-alist
1675 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1676 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1677 (gnus-treat-strip-banner gnus-article-strip-banner
)
1678 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1679 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1680 (gnus-treat-buttonize gnus-article-add-buttons
)
1681 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1682 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1683 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1684 (gnus-treat-display-x-face gnus-article-display-x-face
)
1685 (gnus-treat-display-face gnus-article-display-face
)
1686 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1687 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1688 (gnus-treat-hide-signature gnus-article-hide-signature
)
1689 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1690 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1691 (gnus-treat-from-picon gnus-treat-from-picon
)
1692 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1693 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1694 (gnus-treat-strip-pem gnus-article-hide-pem
)
1695 (gnus-treat-date gnus-article-treat-date
)
1696 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1697 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1698 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1699 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1700 (gnus-treat-strip-trailing-blank-lines
1701 gnus-article-remove-trailing-blank-lines
)
1702 (gnus-treat-strip-leading-blank-lines
1703 gnus-article-strip-leading-blank-lines
)
1704 (gnus-treat-strip-multiple-blank-lines
1705 gnus-article-strip-multiple-blank-lines
)
1706 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1707 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1708 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1709 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1710 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1711 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1712 (gnus-treat-display-smileys gnus-treat-smiley
)
1713 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1714 (gnus-treat-wash-html gnus-article-wash-html
)
1715 (gnus-treat-emphasize gnus-article-emphasize
)
1716 (gnus-treat-hide-citation gnus-article-hide-citation
)
1717 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1718 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1719 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1721 (defvar gnus-article-mime-handle-alist nil
)
1722 (defvar article-lapsed-timer nil
)
1723 (defvar gnus-article-current-summary nil
)
1725 (defvar gnus-article-mode-syntax-table
1726 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1727 ;; This causes the citation match run O(2^n).
1728 ;; (modify-syntax-entry ?- "w" table)
1729 (modify-syntax-entry ?
> ")<" table
)
1730 (modify-syntax-entry ?
< "(>" table
)
1731 ;; make M-. in article buffers work for `foo' strings
1732 (modify-syntax-entry ?
' " " table
)
1733 (modify-syntax-entry ?
` " " table
)
1735 "Syntax table used in article mode buffers.
1736 Initialized from `text-mode-syntax-table.")
1738 (defvar gnus-save-article-buffer nil
)
1740 (defvar gnus-number-of-articles-to-be-saved nil
)
1742 (defvar gnus-inhibit-hiding nil
)
1744 (defvar gnus-article-edit-mode nil
)
1746 ;;; Macros for dealing with the article buffer.
1748 (defmacro gnus-with-article-headers
(&rest forms
)
1749 `(with-current-buffer gnus-article-buffer
1751 (let ((inhibit-read-only t
)
1752 (inhibit-point-motion-hooks t
)
1753 (case-fold-search t
))
1754 (article-narrow-to-head)
1757 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1758 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1760 (defmacro gnus-with-article-buffer
(&rest forms
)
1761 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1762 (with-current-buffer gnus-article-buffer
1763 (let ((inhibit-read-only t
))
1766 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1767 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1769 (defun gnus-article-goto-header (header)
1770 "Go to HEADER, which is a regular expression."
1771 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1773 (defsubst gnus-article-hide-text
(b e props
)
1774 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1775 (gnus-add-text-properties-when 'article-type nil b e props
)
1776 (when (memq 'intangible props
)
1778 (max (1- b
) (point-min))
1779 b
'intangible
(cddr (memq 'intangible props
)))))
1781 (defsubst gnus-article-unhide-text
(b e
)
1782 "Remove hidden text properties from region between B and E."
1783 (remove-text-properties b e gnus-hidden-properties
)
1784 (when (memq 'intangible gnus-hidden-properties
)
1785 (put-text-property (max (1- b
) (point-min))
1786 b
'intangible nil
)))
1788 (defun gnus-article-hide-text-type (b e type
)
1789 "Hide text of TYPE between B and E."
1790 (gnus-add-wash-type type
)
1791 (gnus-article-hide-text
1792 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1794 (defun gnus-article-unhide-text-type (b e type
)
1795 "Unhide text of TYPE between B and E."
1796 (gnus-delete-wash-type type
)
1797 (remove-text-properties
1798 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1799 (when (memq 'intangible gnus-hidden-properties
)
1800 (put-text-property (max (1- b
) (point-min))
1801 b
'intangible nil
)))
1803 (defun gnus-article-delete-text-of-type (type)
1804 "Delete text of TYPE in the current buffer."
1806 (let ((b (point-min)))
1807 (if (eq type
'multipart
)
1808 ;; Remove MIME buttons associated with multipart/alternative parts.
1811 (while (if (get-text-property (point) 'gnus-part
)
1813 (when (setq b
(next-single-property-change (point)
1818 (skip-chars-forward "\n")
1819 (when (eq (get-text-property b
'article-type
) 'multipart
)
1820 (delete-region b
(point)))))
1821 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1823 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1826 (defun gnus-article-delete-invisible-text ()
1827 "Delete all invisible text in the current buffer."
1829 (let ((b (point-min)))
1830 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1832 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1835 (defsubst gnus-article-header-rank
()
1836 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1837 (let ((list gnus-sorted-header-list
)
1840 (if (looking-at (car list
))
1842 (setq list
(cdr list
))
1846 (defun article-hide-headers (&optional _arg _delete
)
1847 "Hide unwanted headers and possibly sort them as well."
1849 ;; This function might be inhibited.
1850 (unless gnus-inhibit-hiding
1851 (let ((inhibit-read-only t
)
1852 (case-fold-search t
)
1853 (max (1+ (length gnus-sorted-header-list
)))
1854 (inhibit-point-motion-hooks t
)
1855 (cur (current-buffer))
1856 ignored visible beg
)
1858 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1859 ;; group parameters, so we should go to the summary buffer.
1862 (progn (set-buffer gnus-summary-buffer
) t
)
1864 (setq ignored
(when (not gnus-visible-headers
)
1865 (cond ((stringp gnus-ignored-headers
)
1866 gnus-ignored-headers
)
1867 ((listp gnus-ignored-headers
)
1868 (mapconcat 'identity
1869 gnus-ignored-headers
1871 visible
(cond ((stringp gnus-visible-headers
)
1872 gnus-visible-headers
)
1873 ((and gnus-visible-headers
1874 (listp gnus-visible-headers
))
1875 (mapconcat 'identity
1876 gnus-visible-headers
1880 ;; First we narrow to just the headers.
1881 (article-narrow-to-head)
1882 ;; Hide any "From " lines at the beginning of (mail) articles.
1883 (while (looking-at "From ")
1886 (delete-region (point-min) (point)))
1887 ;; Then treat the rest of the header lines.
1888 ;; Then we use the two regular expressions
1889 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1890 ;; select which header lines is to remain visible in the
1892 (while (re-search-forward "^[^ \t:]*:" nil t
)
1894 ;; Mark the rank of the header.
1896 (point) (1+ (point)) 'message-rank
1897 (if (or (and visible
(looking-at visible
))
1899 (not (looking-at ignored
))))
1900 (gnus-article-header-rank)
1903 (message-sort-headers-1)
1904 (when (setq beg
(text-property-any
1905 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1906 ;; We delete the unwanted headers.
1907 (gnus-add-wash-type 'headers
)
1908 (add-text-properties (point-min) (+ 5 (point-min))
1909 '(article-type headers dummy-invisible t
))
1910 (delete-region beg
(point-max))))))))
1912 (defun article-hide-boring-headers (&optional arg
)
1913 "Toggle hiding of headers that aren't very interesting.
1914 If given a negative prefix, always show; if given a positive prefix,
1916 (interactive (gnus-article-hidden-arg))
1917 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1918 (not gnus-show-all-headers
))
1921 (let ((inhibit-read-only t
)
1922 (inhibit-point-motion-hooks t
))
1923 (article-narrow-to-head)
1924 (dolist (elem gnus-boring-article-headers
)
1925 (goto-char (point-min))
1927 ;; Hide empty headers.
1929 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1931 (gnus-article-hide-text-type
1935 (if (re-search-forward "^[^ \t]" nil t
)
1939 ;; Hide boring Newsgroups header.
1940 ((eq elem
'newsgroups
)
1941 (when (gnus-string-equal
1942 (gnus-fetch-field "newsgroups")
1943 (gnus-group-real-name
1944 (if (boundp 'gnus-newsgroup-name
)
1947 (gnus-article-hide-header "newsgroups")))
1948 ((eq elem
'to-address
)
1949 (let ((to (message-fetch-field "to"))
1951 (gnus-parameter-to-address
1952 (if (boundp 'gnus-newsgroup-name
)
1953 gnus-newsgroup-name
""))))
1954 (when (and to to-address
1957 ;; only one address in To
1958 (nth 1 (mail-extract-address-components to
))
1960 (gnus-article-hide-header "to"))))
1962 (let ((to (message-fetch-field "to"))
1964 (gnus-parameter-to-list
1965 (if (boundp 'gnus-newsgroup-name
)
1966 gnus-newsgroup-name
""))))
1967 (when (and to to-list
1970 ;; only one address in To
1971 (nth 1 (mail-extract-address-components to
))
1973 (gnus-article-hide-header "to"))))
1975 (let ((cc (message-fetch-field "cc"))
1977 (gnus-parameter-to-list
1978 (if (boundp 'gnus-newsgroup-name
)
1979 gnus-newsgroup-name
""))))
1980 (when (and cc to-list
1983 ;; only one address in CC
1984 (nth 1 (mail-extract-address-components cc
))
1986 (gnus-article-hide-header "cc"))))
1987 ((eq elem
'followup-to
)
1988 (when (gnus-string-equal
1989 (message-fetch-field "followup-to")
1990 (message-fetch-field "newsgroups"))
1991 (gnus-article-hide-header "followup-to")))
1992 ((eq elem
'reply-to
)
1993 (if (gnus-group-find-parameter
1994 gnus-newsgroup-name
'broken-reply-to
)
1995 (gnus-article-hide-header "reply-to")
1996 (let ((from (message-fetch-field "from"))
1997 (reply-to (message-fetch-field "reply-to")))
2004 (lambda (x) (downcase (cadr x
)))
2005 (mail-extract-address-components from t
))
2008 (lambda (x) (downcase (cadr x
)))
2009 (mail-extract-address-components reply-to t
))
2011 (gnus-article-hide-header "reply-to")))))
2013 (let ((date (with-current-buffer gnus-original-article-buffer
2014 ;; If date in `gnus-article-buffer' is localized
2015 ;; (`gnus-treat-date-user-defined'),
2016 ;; `days-between' might fail.
2017 (message-fetch-field "date"))))
2019 (< (days-between (current-time-string) date
)
2021 (gnus-article-hide-header "date"))))
2023 (let ((to (message-fetch-field "to"))
2024 (cc (message-fetch-field "cc")))
2025 (when (> (length to
) 1024)
2026 (gnus-article-hide-header "to"))
2027 (when (> (length cc
) 1024)
2028 (gnus-article-hide-header "cc"))))
2032 (goto-char (point-min))
2033 (while (re-search-forward "^to:" nil t
)
2034 (setq to-count
(1+ to-count
)))
2035 (when (> to-count
1)
2036 (while (> to-count
0)
2037 (goto-char (point-min))
2039 (re-search-forward "^to:" nil nil to-count
)
2041 (narrow-to-region (point) (point-max))
2042 (gnus-article-hide-header "to"))
2043 (setq to-count
(1- to-count
))))
2044 (goto-char (point-min))
2045 (while (re-search-forward "^cc:" nil t
)
2046 (setq cc-count
(1+ cc-count
)))
2047 (when (> cc-count
1)
2048 (while (> cc-count
0)
2049 (goto-char (point-min))
2051 (re-search-forward "^cc:" nil nil cc-count
)
2053 (narrow-to-region (point) (point-max))
2054 (gnus-article-hide-header "cc"))
2055 (setq cc-count
(1- cc-count
)))))))))))))
2057 (defun gnus-article-hide-header (header)
2059 (goto-char (point-min))
2060 (when (re-search-forward (concat "^" header
":") nil t
)
2061 (gnus-article-hide-text-type
2065 (if (re-search-forward "^[^ \t]" nil t
)
2070 (defvar gnus-article-normalized-header-length
40
2071 "Length of normalized headers.")
2073 (defun article-normalize-headers ()
2074 "Make all header lines 40 characters long."
2076 (let ((inhibit-read-only t
)
2080 (article-narrow-to-head)
2083 ((< (setq column
(- (point-at-eol) (point)))
2084 gnus-article-normalized-header-length
)
2086 (insert (make-string
2087 (- gnus-article-normalized-header-length column
)
2089 ((> column gnus-article-normalized-header-length
)
2090 (gnus-put-text-property
2092 (forward-char gnus-article-normalized-header-length
)
2099 (forward-line 1))))))
2101 (defun article-treat-dumbquotes ()
2102 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2103 Note that this function guesses whether a character is a sm*rtq**t* or
2104 not, so it should only be used interactively.
2106 Sm*rtq**t*s are M****s***'s unilateral extension to the
2107 iso-8859-1 character map in an attempt to provide more quoting
2108 characters. If you see something like \\222 or \\264 where
2109 you're expecting some kind of apostrophe or quotation mark, then
2112 (article-translate-strings gnus-article-dumbquotes-map
))
2114 (defvar org-entities
)
2116 (defun article-treat-non-ascii ()
2117 "Translate many Unicode characters into their ASCII equivalents."
2119 (require 'org-entities
)
2120 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2121 (dolist (elem org-entities
)
2122 (when (and (listp elem
)
2123 (= (length (nth 6 elem
)) 1))
2124 (if (featurep 'xemacs
)
2125 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2126 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2128 (when (article-goto-body)
2129 (let ((inhibit-read-only t
)
2132 (if (not (setq replace
(if (featurep 'xemacs
)
2133 (get-char-table (following-char) table
)
2134 (aref table
(following-char)))))
2137 (setq props
(text-properties-at (point)))
2139 (add-text-properties (point) (progn (insert replace
) (point))
2141 (insert replace
)))))))))
2143 (defun article-translate-strings (map)
2144 "Translate all string in the body of the article according to MAP.
2145 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2147 (when (article-goto-body)
2148 (let ((inhibit-read-only t
))
2150 (let ((from (car elem
))
2154 (while (search-forward from nil t
)
2157 (if (eq (following-char) from
)
2161 (forward-char 1)))))))))))
2163 (defun article-treat-overstrike ()
2164 "Translate overstrikes into bold text."
2167 (when (article-goto-body)
2168 (let ((inhibit-read-only t
))
2169 (while (search-forward "\b" nil t
)
2170 (let ((next (char-after))
2171 (previous (char-after (- (point) 2))))
2172 ;; We do the boldification/underlining by hiding the
2173 ;; overstrikes and putting the proper text property
2177 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2178 (put-text-property (point) (1+ (point)) 'face
'bold
))
2180 (gnus-article-hide-text-type
2181 (1- (point)) (1+ (point)) 'overstrike
)
2183 (- (point) 2) (1- (point)) 'face
'underline
))
2185 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2187 (point) (1+ (point)) 'face
'underline
)))))))))
2189 (defun article-treat-ansi-sequences ()
2190 "Translate ANSI SGR control sequences into overlays or extents."
2193 (when (article-goto-body)
2194 (let ((inhibit-read-only t
))
2195 (ansi-color-apply-on-region (point) (point-max))))))
2197 (defun gnus-article-treat-unfold-headers ()
2198 "Unfold folded message headers.
2199 Only the headers that fit into the current window width will be
2202 (gnus-with-article-headers
2206 (mail-header-narrow-to-field)
2207 (let* ((header (buffer-string))
2209 (or (equal gnus-article-unfold-long-headers t
)
2210 (and (stringp gnus-article-unfold-long-headers
)
2211 (string-match gnus-article-unfold-long-headers
2215 (goto-char (point-min))
2216 (while (re-search-forward "\n[\t ]" nil t
)
2217 (replace-match " " t t
)))
2218 (setq length
(- (point-max) (point-min) 1))
2219 (when (or unfoldable
2220 (< length
(window-width)))
2221 (while (re-search-forward "\n[\t ]" nil t
)
2222 (replace-match " " t t
))))
2223 (goto-char (point-max)))))))
2225 (defun gnus-article-treat-fold-headers ()
2226 "Fold message headers."
2228 (gnus-with-article-headers
2231 (mail-header-narrow-to-field)
2232 (mail-header-fold-field)
2233 (goto-char (point-max))))))
2235 (defun gnus-treat-smiley ()
2236 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2238 (gnus-with-article-buffer
2239 (if (memq 'smiley gnus-article-wash-types
)
2240 (gnus-delete-images 'smiley
)
2242 (let ((images (smiley-region (point) (point-max))))
2244 (gnus-add-wash-type 'smiley
)
2245 (dolist (image images
)
2246 (gnus-add-image 'smiley image
)))))))
2248 (defun gnus-article-remove-images ()
2249 "Remove all images from the article buffer."
2251 (gnus-with-article-buffer
2254 (dolist (elem gnus-article-image-alist
)
2255 (gnus-delete-images (car elem
))))))
2257 (autoload 'w3m-toggle-inline-images
"w3m")
2259 (defun gnus-article-show-images ()
2260 "Show any images that are in the HTML-rendered article buffer.
2261 This only works if the article in question is HTML."
2263 (gnus-with-article-buffer
2266 (if (eq mm-text-html-renderer
'w3m
)
2267 (let ((mm-inline-text-html-with-images nil
))
2268 (w3m-toggle-inline-images))
2269 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2271 (destructuring-bind (start end function
) region
2272 (funcall function
(get-text-property start
'image-url
)
2275 (defun gnus-article-treat-fold-newsgroups ()
2276 "Unfold folded message headers.
2277 Only the headers that fit into the current window width will be
2280 (gnus-with-article-headers
2281 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2283 (mail-header-narrow-to-field)
2284 (while (re-search-forward ", *" nil t
)
2285 (replace-match ", " t t
))
2286 (mail-header-fold-field)
2287 (goto-char (point-max))))))
2289 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2290 "Value of `truncate-lines' in Gnus Article buffer.
2291 Valid values are nil, t, `head', `first', `last', an integer or a
2292 predicate. See Info node `(gnus)Customizing Articles'."
2293 :version
"23.1" ;; No Gnus
2294 :group
'gnus-article
2295 ;; :link '(custom-manual "(gnus)Customizing Articles")
2298 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2299 "Toggle whether to fold or truncate long lines in article the buffer.
2300 If ARG is non-nil and not a number, toggle
2301 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2302 long lines if and only if arg is positive."
2305 ((and (numberp arg
) (> arg
0))
2306 (setq gnus-article-truncate-lines t
))
2308 (setq gnus-article-truncate-lines nil
))
2310 (setq gnus-article-truncate-lines
2311 (not gnus-article-truncate-lines
))))
2312 (gnus-with-article-buffer
2314 ((and (numberp arg
) (> arg
0))
2315 (setq truncate-lines nil
))
2317 (setq truncate-lines t
)))
2318 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2319 ;; `toggle-truncate-lines' needs an argument.
2320 (toggle-truncate-lines)))
2322 (defun gnus-article-treat-body-boundary ()
2323 "Place a boundary line at the end of the headers."
2325 (when (and gnus-body-boundary-delimiter
2326 (> (length gnus-body-boundary-delimiter
) 0))
2327 (gnus-with-article-headers
2328 (goto-char (point-max))
2329 (let ((start (point)))
2330 (insert "X-Boundary: ")
2331 (gnus-add-text-properties start
(point) '(invisible t intangible t
))
2332 (insert (let (str (max (window-width)))
2333 (if (featurep 'xemacs
)
2334 (setq max
(1- max
)))
2335 (while (>= max
(length str
))
2336 (setq str
(concat str gnus-body-boundary-delimiter
)))
2337 (substring str
0 max
))
2339 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2341 (defun article-fill-long-lines ()
2342 "Fill lines that are wider than the window width."
2345 (let ((inhibit-read-only t
)
2346 (width (window-width (get-buffer-window (current-buffer)))))
2349 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2352 (when (>= (current-column) (min fill-column width
))
2353 (narrow-to-region (min (1+ (point)) (point-max))
2355 (let ((goback (point-marker)))
2356 (fill-paragraph nil
)
2357 (goto-char (marker-position goback
)))
2359 (forward-line 1)))))))
2361 (defun article-capitalize-sentences ()
2362 "Capitalize the first word in each sentence."
2365 (let ((inhibit-read-only t
)
2366 (paragraph-start "^[\n\^L]"))
2370 (forward-sentence)))))
2372 (defun article-remove-cr ()
2373 "Remove trailing CRs and then translate remaining CRs into LFs."
2376 (let ((inhibit-read-only t
))
2377 (goto-char (point-min))
2378 (while (re-search-forward "\r+$" nil t
)
2379 (replace-match "" t t
))
2380 (goto-char (point-min))
2381 (while (search-forward "\r" nil t
)
2382 (replace-match "\n" t t
)))))
2384 (defun article-remove-trailing-blank-lines ()
2385 "Remove all trailing blank lines from the article."
2388 (let ((inhibit-read-only t
))
2389 (goto-char (point-max))
2393 (while (and (not (bobp))
2394 (looking-at "^[ \t]*$")
2395 (not (gnus-annotation-in-region-p
2396 (point) (point-at-eol))))
2401 (defvar gnus-face-properties-alist
)
2403 (defun article-display-face (&optional force
)
2404 "Display any Face headers in the header."
2405 (interactive (list 'force
))
2406 (let ((wash-face-p buffer-read-only
))
2407 (gnus-with-article-headers
2408 ;; When displaying parts, this function can be called several times on
2409 ;; the same article, without any intended toggle semantic (as typing `W
2410 ;; D d' would have). So face deletion must occur only when we come from
2411 ;; an interactive command, that is when the *Article* buffer is
2413 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2414 (gnus-delete-images 'face
)
2415 (let ((from (message-fetch-field "from"))
2417 (save-current-buffer
2418 (when (and wash-face-p
2419 (gnus-buffer-live-p gnus-original-article-buffer
)
2420 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2421 (set-buffer gnus-original-article-buffer
))
2423 (mail-narrow-to-head)
2425 ;; Check whether this face is censored.
2426 (not (and gnus-article-x-face-too-ugly
2428 (setq from
(message-fetch-field "from")))
2429 (string-match gnus-article-x-face-too-ugly
2431 (while (gnus-article-goto-header "Face")
2432 (push (mail-header-field-value) faces
)))))
2434 (goto-char (point-min))
2436 (unless (setq from
(gnus-article-goto-header "from"))
2439 (insert " [no `from' set]\n"))
2441 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2443 (apply 'gnus-create-image png
'png t
2444 (cdr (assq 'png gnus-face-properties-alist
))))
2447 (gnus-add-wash-type 'face
)
2448 (gnus-add-image 'face image
)
2449 (gnus-put-image image nil
'face
)))))))))))
2451 (defun article-display-x-face (&optional force
)
2452 "Look for an X-Face header and display it if present."
2453 (interactive (list 'force
))
2454 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2455 (gnus-with-article-headers
2456 ;; Delete the old process, if any.
2457 (when (process-status "article-x-face")
2458 (delete-process "article-x-face"))
2459 ;; See the comment in `article-display-face'.
2460 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2461 ;; We have already displayed X-Faces, so we remove them
2463 (gnus-delete-images 'xface
)
2465 (let ((from (message-fetch-field "from"))
2467 (save-current-buffer
2468 (when (and wash-face-p
2469 (gnus-buffer-live-p gnus-original-article-buffer
)
2470 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2471 ;; If type `W f', use gnus-original-article-buffer,
2472 ;; otherwise use the current buffer because displaying
2473 ;; RFC822 parts calls this function too.
2474 (set-buffer gnus-original-article-buffer
))
2476 (mail-narrow-to-head)
2477 (and gnus-article-x-face-command
2479 ;; Check whether this face is censored.
2480 (not (and gnus-article-x-face-too-ugly
2482 (setq from
(message-fetch-field "from")))
2483 (string-match gnus-article-x-face-too-ugly
2485 (while (gnus-article-goto-header "X-Face")
2486 (push (mail-header-field-value) x-faces
)))))
2488 ;; We display the face.
2489 (cond ((functionp gnus-article-x-face-command
)
2490 ;; The command is a lisp function, so we call it.
2491 (mapc gnus-article-x-face-command x-faces
))
2492 ((stringp gnus-article-x-face-command
)
2493 ;; The command is a string, so we interpret the command
2494 ;; as a, well, command, and fork it off.
2495 (let ((process-connection-type nil
))
2496 (gnus-set-process-query-on-exit-flag
2498 "article-x-face" nil shell-file-name
2499 shell-command-switch gnus-article-x-face-command
)
2501 ;; Sending multiple EOFs to xv doesn't work,
2502 ;; so we only do a single external face.
2504 (insert (car x-faces
))
2505 (process-send-region "article-x-face"
2506 (point-min) (point-max)))
2507 (process-send-eof "article-x-face")))
2509 (error "`%s' set to `%s' is not a function"
2510 gnus-article-x-face-command
2511 'gnus-article-x-face-command
)))))))))
2513 (defun article-decode-mime-words ()
2514 "Decode all MIME-encoded words in the article."
2516 (gnus-with-article-buffer
2517 (let ((inhibit-point-motion-hooks t
)
2518 (mail-parse-charset gnus-newsgroup-charset
)
2519 (mail-parse-ignored-charsets
2520 (with-current-buffer gnus-summary-buffer
2521 gnus-newsgroup-ignored-charsets
)))
2522 (mail-decode-encoded-word-region (point-min) (point-max)))))
2524 (defun article-decode-charset (&optional prompt
)
2525 "Decode charset-encoded text in the article.
2526 If PROMPT (the prefix), prompt for a coding system to use."
2528 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2529 (inhibit-read-only t
)
2530 (mail-parse-charset gnus-newsgroup-charset
)
2531 (mail-parse-ignored-charsets
2532 (save-excursion (condition-case nil
2533 (set-buffer gnus-summary-buffer
)
2535 gnus-newsgroup-ignored-charsets
))
2536 ct cte ctl charset format
)
2539 (article-narrow-to-head)
2540 (setq ct
(message-fetch-field "Content-Type" t
)
2541 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2542 ctl
(and ct
(mail-header-parse-content-type ct
))
2545 (mm-read-coding-system "Charset to decode: "))
2547 (mail-content-type-get ctl
'charset
)))
2548 format
(and ctl
(mail-content-type-get ctl
'format
)))
2550 (setq cte
(mail-header-strip cte
)))
2551 (if (and ctl
(not (string-match "/" (car ctl
))))
2553 (goto-char (point-max)))
2556 (narrow-to-region (point) (point-max))
2557 (when (and (eq mail-parse-charset
'gnus-decoded
)
2558 (eq (mm-body-7-or-8) '8bit
))
2559 ;; The text code could have been decoded.
2560 (setq charset mail-parse-charset
))
2561 (when (and (or (not ctl
)
2562 (equal (car ctl
) "text/plain"))
2563 (not format
)) ;; article with format will decode later.
2565 charset
(and cte
(intern (downcase
2566 (gnus-strip-whitespace cte
))))
2569 (defun article-decode-encoded-words ()
2570 "Remove encoded-word encoding from headers."
2571 (let ((inhibit-point-motion-hooks t
)
2572 (mail-parse-charset gnus-newsgroup-charset
)
2573 (mail-parse-ignored-charsets
2574 (save-excursion (condition-case nil
2575 (set-buffer gnus-summary-buffer
)
2577 gnus-newsgroup-ignored-charsets
))
2578 (inhibit-read-only t
)
2580 (goto-char (point-min))
2581 (when (search-forward "\n\n" nil
'move
)
2588 (memq (char-after) '(?
\t ?
)))))
2589 (setq start
(point))
2591 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2592 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2593 (funcall gnus-decode-address-function start end
)
2594 (funcall gnus-decode-header-function start end
))
2595 (goto-char (setq end start
)))))
2597 (defun article-decode-group-name ()
2598 "Decode group names in Newsgroups, Followup-To and Xref headers."
2599 (let ((inhibit-point-motion-hooks t
)
2600 (inhibit-read-only t
)
2601 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2603 (when (and (or gnus-group-name-charset-method-alist
2604 gnus-group-name-charset-group-alist
)
2605 (gnus-buffer-live-p gnus-original-article-buffer
))
2607 (article-narrow-to-head)
2608 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2609 (with-current-buffer gnus-original-article-buffer
2610 (goto-char (point-min)))
2611 (setq regexp
(concat "^" header
2612 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2613 (while (re-search-forward regexp nil t
)
2614 (replace-match (save-match-data
2615 (gnus-decode-newsgroups
2616 ;; XXX how to use data in article buffer?
2617 (with-current-buffer gnus-original-article-buffer
2618 (re-search-forward regexp nil t
)
2620 gnus-newsgroup-name method
))
2622 (goto-char (point-min)))))))
2624 (autoload 'idna-to-unicode
"idna")
2626 (defun article-decode-idna-rhs ()
2627 "Decode IDNA strings in RHS in various headers in current buffer.
2628 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2629 Mail-Reply-To: and Mail-Followup-To:."
2632 (let ((inhibit-point-motion-hooks t
)
2633 (inhibit-read-only t
))
2634 (article-narrow-to-head)
2635 (goto-char (point-min))
2636 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2638 (when (save-match-data
2639 (and (setq ace
(match-string 1))
2641 (and (re-search-backward "^[^ \t]" nil t
)
2642 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2643 (setq unicode
(idna-to-unicode ace
))))
2644 (unless (string= ace unicode
)
2645 (replace-match unicode nil nil nil
1)))))))))
2647 (defun article-de-quoted-unreadable (&optional force read-charset
)
2648 "Translate a quoted-printable-encoded article.
2649 If FORCE, decode the article whether it is marked as quoted-printable
2651 If READ-CHARSET, ask for a coding system."
2652 (interactive (list 'force current-prefix-arg
))
2654 (let ((inhibit-read-only t
) type charset
)
2655 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2656 (with-current-buffer gnus-original-article-buffer
2658 (gnus-fetch-field "content-transfer-encoding"))
2659 (let* ((ct (gnus-fetch-field "content-type"))
2660 (ctl (and ct
(mail-header-parse-content-type ct
))))
2661 (setq charset
(and ctl
2662 (mail-content-type-get ctl
'charset
)))
2663 (if (stringp charset
)
2664 (setq charset
(intern (downcase charset
)))))))
2666 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2668 (setq charset gnus-newsgroup-charset
))
2670 (and type
(let ((case-fold-search t
))
2671 (string-match "quoted-printable" type
))))
2673 (quoted-printable-decode-region
2674 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2676 (defun article-de-base64-unreadable (&optional force read-charset
)
2677 "Translate a base64 article.
2678 If FORCE, decode the article whether it is marked as base64 not.
2679 If READ-CHARSET, ask for a coding system."
2680 (interactive (list 'force current-prefix-arg
))
2682 (let ((inhibit-read-only t
) type charset
)
2683 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2684 (with-current-buffer gnus-original-article-buffer
2686 (gnus-fetch-field "content-transfer-encoding"))
2687 (let* ((ct (gnus-fetch-field "content-type"))
2688 (ctl (and ct
(mail-header-parse-content-type ct
))))
2689 (setq charset
(and ctl
2690 (mail-content-type-get ctl
'charset
)))
2691 (if (stringp charset
)
2692 (setq charset
(intern (downcase charset
)))))))
2694 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2696 (setq charset gnus-newsgroup-charset
))
2698 (and type
(let ((case-fold-search t
))
2699 (string-match "base64" type
))))
2702 (narrow-to-region (point) (point-max))
2703 (base64-decode-region (point-min) (point-max))
2704 (mm-decode-coding-region
2705 (point-min) (point-max)
2706 (mm-charset-to-coding-system charset nil t
)))))))
2711 (defun article-decode-HZ ()
2712 "Translate a HZ-encoded article."
2716 (let ((inhibit-read-only t
))
2717 (rfc1843-decode-region (point-min) (point-max)))))
2719 (defun article-unsplit-urls ()
2720 "Remove the newlines that some other mailers insert into URLs."
2723 (let ((inhibit-read-only t
))
2724 (goto-char (point-min))
2725 (while (re-search-forward
2726 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2727 (replace-match "\\1\\3" t
)))
2728 (when (gmm-called-interactively-p 'any
)
2729 (gnus-treat-article nil
))))
2731 (defun article-wash-html ()
2732 "Format an HTML article."
2735 (buffer-read-only nil
))
2736 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2737 (with-current-buffer gnus-original-article-buffer
2738 (setq handles
(mm-dissect-buffer t t
))))
2740 (delete-region (point) (point-max))
2741 (mm-enable-multibyte)
2742 (mm-inline-text-html handles
)))
2744 (defvar gnus-article-browse-html-temp-list nil
2745 "List of temporary files created by `gnus-article-browse-html-parts'.
2746 Internal variable.")
2748 (defcustom gnus-article-browse-delete-temp
'ask
2749 "What to do with temporary files from `gnus-article-browse-html-parts'.
2750 If nil, don't delete temporary files. If it is t, delete them on
2751 exit from the summary buffer. If it is the symbol `file', query
2752 on each file, if it is `ask' ask once when exiting from the
2754 :group
'gnus-article
2755 :version
"23.1" ;; No Gnus
2756 :type
'(choice (const :tag
"Don't delete" nil
)
2757 (const :tag
"Don't ask" t
)
2758 (const :tag
"Ask" ask
)
2759 (const :tag
"Ask for each file" file
)))
2761 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2763 (defun gnus-article-browse-delete-temp-files (&optional how
)
2764 "Delete temp-files created by `gnus-article-browse-html-parts'."
2765 (when (and gnus-article-browse-html-temp-list
2767 (or how
(setq how gnus-article-browse-delete-temp
))
2769 (let ((files (length gnus-article-browse-html-temp-list
)))
2772 "Delete the temporary HTML file? "
2773 (format "Delete all %s temporary HTML files? "
2775 (setq gnus-article-browse-html-temp-list nil
)))
2777 (dolist (file gnus-article-browse-html-temp-list
)
2778 (cond ((file-directory-p file
)
2779 (when (or (not (eq how
'file
))
2782 "Delete temporary HTML file(s) in directory `%s'? "
2783 (file-name-as-directory file
))))
2784 (gnus-delete-directory file
)))
2785 ((file-exists-p file
)
2786 (when (or (not (eq how
'file
))
2788 (format "Delete temporary HTML file `%s'? " file
)))
2789 (delete-file file
)))))
2790 ;; Also remove file from the list when not deleted or if file doesn't
2792 (setq gnus-article-browse-html-temp-list nil
))
2793 gnus-article-browse-html-temp-list
)
2795 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2796 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2801 (dolist (handle handles
)
2803 ((not (listp handle
)))
2804 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2806 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2807 ((equal (mm-handle-media-supertype handle
) "multipart")
2808 (when (setq file
(gnus-article-browse-html-save-cid-content
2809 cid handle directory
))
2810 (throw 'found file
)))
2811 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2814 (or (mm-handle-filename handle
)
2816 (make-temp-name "cid")
2817 (car (rassoc (car (mm-handle-type handle
))
2818 mailcap-mime-extensions
))))
2820 (mm-save-part-to-file handle file
)
2821 (throw 'found file
))))))))
2823 (defun gnus-article-browse-html-parts (list &optional header
)
2824 "View all \"text/html\" parts from LIST.
2825 Recurse into multiparts. The optional HEADER that should be a decoded
2826 message header will be added to the bodies of the \"text/html\" parts."
2827 ;; Internal function used by `gnus-article-browse-html-article'.
2828 (let (type file charset content cid-dir tmp-file showed
)
2829 ;; Find and show the html-parts.
2830 (dolist (handle list
)
2831 ;; If HTML, show it:
2832 (cond ((not (listp handle
)))
2833 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2834 (and (equal (car type
) "message/external-body")
2836 (setq file
(mm-handle-filename handle
)))
2837 (or (mm-handle-cache handle
)
2838 (condition-case code
2839 (progn (mm-extern-cache-contents handle
) t
)
2841 (gnus-message 3 "%s" (error-message-string code
))
2842 (when (>= gnus-verbose
3) (sit-for 2))
2845 (setq handle
(mm-handle-cache handle
)
2846 type
(mm-handle-type handle
))
2847 (equal (car type
) "text/html"))))
2848 (setq charset
(mail-content-type-get type
'charset
)
2849 content
(mm-get-part handle
))
2851 (if (eq charset
'gnus-decoded
)
2852 (mm-enable-multibyte)
2853 (mm-disable-multibyte))
2855 ;; resolve cid contents
2856 (let ((case-fold-search t
)
2858 (goto-char (point-min))
2859 (while (re-search-forward "\
2860 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2863 (setq cid-dir
(mm-make-temp-file "cid" t
))
2864 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2867 (when (setq cid-file
2868 (gnus-article-browse-html-save-cid-content
2870 (with-current-buffer gnus-article-buffer
2871 gnus-article-mime-handles
)
2873 (when (eq system-type
'cygwin
)
2875 (concat "/" (substring
2876 (with-output-to-string
2877 (call-process "cygpath" nil
2881 (replace-match (concat "file://" cid-file
)
2883 (unless content
(setq content
(buffer-string))))
2884 (when (or charset header
(not file
))
2885 (setq tmp-file
(mm-make-temp-file
2886 ;; Do we need to care for 8.3 filenames?
2887 "mm-" nil
".html")))
2888 ;; Add a meta html tag to specify charset and a header.
2891 (let (title eheader body hcharset coding
)
2893 (mm-enable-multibyte)
2894 (setq case-fold-search t
)
2895 (insert header
"\n")
2896 (setq title
(message-fetch-field "subject"))
2897 (goto-char (point-min))
2898 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2900 (replace-match (cond ((match-beginning 1) "<")
2901 ((match-beginning 2) ">")
2902 ((match-beginning 3) "&")
2904 (goto-char (point-min))
2905 (while (re-search-forward "^[\t ]+" nil t
)
2908 (delete-region (match-beginning 0)
2911 (goto-char (point-min))
2912 (insert "<div align=\"left\">\n")
2913 (goto-char (point-max))
2914 (insert "</div>\n<hr>\n")
2915 ;; We have to examine charset one by one since
2916 ;; charset specified in parts might be different.
2917 (if (eq charset
'gnus-decoded
)
2918 (setq charset
'utf-8
2919 eheader
(mm-encode-coding-string (buffer-string)
2922 (mm-encode-coding-string title charset
))
2923 body
(mm-encode-coding-string content charset
))
2924 (setq hcharset
(mm-find-mime-charset-region (point-min)
2926 (cond ((= (length hcharset
) 1)
2927 (setq hcharset
(car hcharset
)
2928 coding
(mm-charset-to-coding-system
2930 ((> (length hcharset
) 1)
2931 (setq hcharset
'utf-8
2937 (mm-charset-to-coding-system charset
2939 (if (eq coding body
)
2940 (setq eheader
(mm-encode-coding-string
2941 (buffer-string) coding
)
2943 (mm-encode-coding-string
2946 (setq charset
'utf-8
2947 eheader
(mm-encode-coding-string
2948 (buffer-string) charset
)
2950 (mm-encode-coding-string
2952 body
(mm-encode-coding-string
2953 (mm-decode-coding-string
2956 (setq charset hcharset
2957 eheader
(mm-encode-coding-string
2958 (buffer-string) coding
)
2960 (mm-encode-coding-string
2963 (setq eheader
(mm-string-as-unibyte (buffer-string))
2966 (mm-disable-multibyte)
2969 (mm-add-meta-html-tag handle charset t
))
2971 (goto-char (point-min))
2972 (unless (search-forward "<title>" nil t
)
2973 (re-search-forward "<head>\\s-*" nil t
)
2974 (insert "<title>" title
"</title>\n")))
2975 (goto-char (point-min))
2976 (or (re-search-forward
2977 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2979 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2981 (mm-write-region (point-min) (point-max)
2982 tmp-file nil nil nil
'binary t
))))
2984 (mm-with-unibyte-buffer
2985 (insert (if (eq charset
'gnus-decoded
)
2986 (mm-encode-coding-string content
2987 (setq charset
'utf-8
))
2989 (if (or (mm-add-meta-html-tag handle charset
)
2991 (mm-write-region (point-min) (point-max)
2992 tmp-file nil nil nil
'binary t
)
2993 (setq tmp-file nil
))))
2995 (mm-save-part-to-file handle tmp-file
)))
2997 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2998 (add-hook 'gnus-summary-prepare-exit-hook
2999 'gnus-article-browse-delete-temp-files
)
3000 (add-hook 'gnus-exit-gnus-hook
3002 (gnus-article-browse-delete-temp-files t
)))
3003 ;; FIXME: Warn if there's an <img> tag?
3004 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
3006 ;; If multipart, recurse
3007 ((equal (mm-handle-media-supertype handle
) "multipart")
3008 (when (gnus-article-browse-html-parts handle header
)
3010 ((equal (mm-handle-media-type handle
) "message/rfc822")
3011 (mm-with-multibyte-buffer
3012 (mm-insert-part handle
)
3013 (setq handle
(mm-dissect-buffer t t
))
3014 (when (and (bufferp (car handle
))
3015 (stringp (car (mm-handle-type handle
))))
3016 (setq handle
(list handle
)))
3018 (article-decode-encoded-words)
3019 (let ((gnus-visible-headers
3020 (or (get 'gnus-visible-headers
'standard-value
)
3021 gnus-visible-headers
)))
3022 (article-hide-headers))
3023 (goto-char (point-min))
3024 (search-forward "\n\n" nil
'move
)
3025 (skip-chars-backward "\t\n ")
3026 (setq header
(buffer-substring (point-min) (point)))))
3028 (gnus-article-browse-html-parts handle header
)
3029 (mm-destroy-parts handle
))
3033 (defun gnus-article-browse-html-article (&optional arg
)
3034 "View \"text/html\" parts of the current article with a WWW browser.
3035 Inline images embedded in a message using the cid scheme, as they are
3036 generally considered to be safe, will be processed properly.
3037 The message header is added to the beginning of every html part unless
3038 the prefix argument ARG is given.
3040 Warning: Spammers use links to images (using the http scheme) in HTML
3041 articles to verify whether you have read the message. As
3042 `gnus-article-browse-html-article' passes the HTML content to the
3043 browser without eliminating these \"web bugs\" you should only
3044 use it for mails from trusted senders.
3046 If you always want to display HTML parts in the browser, set
3047 `mm-text-html-renderer' to nil.
3049 This command creates temporary files to pass HTML contents including
3050 images if any to the browser, and deletes them when exiting the group
3052 ;; Cf. `mm-w3m-safe-url-regexp'
3055 (gnus-summary-show-article)
3056 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3057 gnus-visible-headers
))
3058 ;; As we insert a <hr>, there's no need for the body boundary.
3059 (gnus-treat-body-boundary nil
))
3060 (gnus-summary-show-article)))
3061 (with-current-buffer gnus-article-buffer
3062 (let ((header (unless arg
3065 (buffer-substring-no-properties
3066 (goto-char (point-min))
3067 (if (search-forward "\n\n" nil t
)
3069 (goto-char (point-max))
3070 (skip-chars-backward "\t\n ")
3073 (set-buffer gnus-original-article-buffer
)
3074 (setq parts
(mm-dissect-buffer t t
))
3075 ;; If singlepart, enforce a list.
3076 (when (and (bufferp (car parts
))
3077 (stringp (car (mm-handle-type parts
))))
3078 (setq parts
(list parts
)))
3080 (unless (gnus-article-browse-html-parts parts header
)
3081 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3082 (mm-destroy-parts parts
)
3084 (gnus-summary-show-article)))))
3086 (defun article-hide-list-identifiers ()
3087 "Remove list identifiers from the Subject header.
3088 The `gnus-list-identifiers' variable specifies what to do."
3090 (let ((inhibit-point-motion-hooks t
)
3091 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3092 (inhibit-read-only t
))
3096 (article-narrow-to-head)
3097 (goto-char (point-min))
3098 (while (re-search-forward
3099 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3101 (delete-region (match-beginning 2) (match-end 0))
3102 (beginning-of-line))
3103 (when (re-search-forward
3104 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3105 (delete-region (match-beginning 1) (match-end 1))))))))
3107 (defun article-hide-pem (&optional arg
)
3108 "Toggle hiding of any PEM headers and signatures in the current article.
3109 If given a negative prefix, always show; if given a positive prefix,
3111 (interactive (gnus-article-hidden-arg))
3112 (unless (gnus-article-check-hidden-text 'pem arg
)
3114 (let ((inhibit-read-only t
) end
)
3115 (goto-char (point-min))
3116 ;; Hide the horrendously ugly "header".
3117 (when (and (search-forward
3118 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3120 (setq end
(1+ (match-beginning 0))))
3121 (gnus-add-wash-type 'pem
)
3122 (gnus-article-hide-text-type
3124 (if (search-forward "\n\n" nil t
)
3128 ;; Hide the trailer as well
3129 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3131 (gnus-article-hide-text-type
3132 (match-beginning 0) (match-end 0) 'pem
)))))))
3134 (defun article-strip-banner ()
3135 "Strip the banners specified by the `banner' group parameter and by
3136 `gnus-article-address-banner-alist'."
3140 (let ((inhibit-point-motion-hooks t
))
3141 (when (gnus-parameter-banner gnus-newsgroup-name
)
3142 (article-really-strip-banner
3143 (gnus-parameter-banner gnus-newsgroup-name
)))
3144 (when gnus-article-address-banner-alist
3145 ;; Note that the From header is decoded here, so it is
3146 ;; required that the *-extract-address-components function
3147 ;; supports non-ASCII text.
3148 (let ((from (save-restriction
3150 (article-narrow-to-head)
3151 (mail-fetch-field "from"))))
3154 (cadr (funcall gnus-extract-address-components
3157 (dolist (pair gnus-article-address-banner-alist
)
3158 (when (string-match (car pair
) from
)
3160 (article-really-strip-banner (cdr pair
)))))))))))))
3162 (defun article-really-strip-banner (banner)
3163 "Strip the banner specified by the argument."
3166 (let ((inhibit-point-motion-hooks t
)
3167 (gnus-signature-limit nil
)
3168 (inhibit-read-only t
))
3171 ((eq banner
'signature
)
3172 (when (gnus-article-narrow-to-signature)
3175 (delete-region (point) (point-max))))
3177 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3178 (while (re-search-forward banner nil t
)
3179 (delete-region (match-beginning 0) (match-end 0)))))
3181 (while (re-search-forward banner nil t
)
3182 (delete-region (match-beginning 0) (match-end 0)))))))))
3184 (defun article-babel ()
3185 "Translate article using an online translation service."
3188 (gnus-with-article-buffer
3189 (when (article-goto-body)
3190 (let* ((start (point))
3192 (orig (buffer-substring start end
))
3193 (trans (babel-as-string orig
)))
3195 (narrow-to-region start end
)
3196 (delete-region start end
)
3199 (defun article-hide-signature (&optional arg
)
3200 "Hide the signature in the current article.
3201 If given a negative prefix, always show; if given a positive prefix,
3203 (interactive (gnus-article-hidden-arg))
3204 (unless (gnus-article-check-hidden-text 'signature arg
)
3207 (let ((inhibit-read-only t
))
3208 (when (gnus-article-narrow-to-signature)
3209 (gnus-article-hide-text-type
3210 (point-min) (point-max) 'signature
))))))
3211 (gnus-set-mode-line 'article
))
3213 (defun article-strip-headers-in-body ()
3214 "Strip offensive headers from bodies."
3218 (let ((case-fold-search t
))
3219 (when (looking-at "x-no-archive:")
3220 (gnus-delete-line)))))
3222 (defun article-strip-leading-blank-lines ()
3223 "Remove all blank lines from the beginning of the article."
3226 (let ((inhibit-point-motion-hooks t
)
3227 (inhibit-read-only t
))
3228 (when (article-goto-body)
3229 (while (and (not (eobp))
3230 (looking-at "[ \t]*$"))
3231 (gnus-delete-line))))))
3233 (defun article-narrow-to-head ()
3234 "Narrow the buffer to the head of the message.
3235 Point is left at the beginning of the narrowed-to region."
3237 (goto-char (point-min))
3239 ;; Absolutely no headers displayed.
3243 ((search-forward "\n\n" nil
1)
3245 ;; Nothing but headers.
3248 (goto-char (point-min)))
3250 (defun article-goto-body ()
3251 "Place point at the start of the body."
3252 (goto-char (point-min))
3254 ;; This variable is only bound when dealing with separate
3256 (article-goto-body-goes-to-point-min-p
3258 ((search-forward "\n\n" nil t
)
3261 (goto-char (point-max))
3264 (defun article-strip-multiple-blank-lines ()
3265 "Replace consecutive blank lines with one empty line."
3268 (let ((inhibit-point-motion-hooks t
)
3269 (inhibit-read-only t
))
3270 ;; First make all blank lines empty.
3272 (while (re-search-forward "^[ \t]+$" nil t
)
3273 (unless (gnus-annotation-in-region-p
3274 (match-beginning 0) (match-end 0))
3275 (replace-match "" nil t
)))
3276 ;; Then replace multiple empty lines with a single empty line.
3278 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3279 (unless (gnus-annotation-in-region-p
3280 (match-beginning 0) (match-end 0))
3281 (delete-region (match-beginning 1) (match-end 1)))))))
3283 (defun article-strip-leading-space ()
3284 "Remove all white space from the beginning of the lines in the article."
3287 (let ((inhibit-point-motion-hooks t
)
3288 (inhibit-read-only t
))
3290 (while (re-search-forward "^[ \t]+" nil t
)
3291 (replace-match "" t t
)))))
3293 (defun article-strip-trailing-space ()
3294 "Remove all white space from the end of the lines in the article."
3297 (let ((inhibit-point-motion-hooks t
)
3298 (inhibit-read-only t
))
3300 (while (re-search-forward "[ \t]+$" nil t
)
3301 (replace-match "" t t
)))))
3303 (defun article-strip-blank-lines ()
3304 "Strip leading, trailing and multiple blank lines."
3306 (article-strip-leading-blank-lines)
3307 (article-remove-trailing-blank-lines)
3308 (article-strip-multiple-blank-lines))
3310 (defun article-strip-all-blank-lines ()
3311 "Strip all blank lines."
3314 (let ((inhibit-point-motion-hooks t
)
3315 (inhibit-read-only t
))
3317 (while (re-search-forward "^[ \t]*\n" nil t
)
3318 (replace-match "" t t
)))))
3320 (defun gnus-article-narrow-to-signature ()
3321 "Narrow to the signature; return t if a signature is found, else nil."
3322 (let ((inhibit-point-motion-hooks t
))
3323 (when (gnus-article-search-signature)
3325 ;; Check whether we have some limits to what we consider
3326 ;; to be a signature.
3327 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3328 (list gnus-signature-limit
)))
3330 (while (setq limit
(pop limits
))
3331 (if (or (and (integerp limit
)
3332 (< (- (point-max) (point)) limit
))
3334 (< (count-lines (point) (point-max)) limit
))
3335 (and (functionp limit
)
3337 (and (stringp limit
)
3338 (not (re-search-forward limit nil t
))))
3339 () ; This limit did not succeed.
3343 (narrow-to-region (point) (point-max))
3346 (defun gnus-article-search-signature ()
3347 "Search the current buffer for the signature separator.
3348 Put point at the beginning of the signature separator."
3349 (let ((cur (point)))
3350 (goto-char (point-max))
3351 (if (if (stringp gnus-signature-separator
)
3352 (re-search-backward gnus-signature-separator nil t
)
3353 (let ((seps gnus-signature-separator
))
3355 (not (re-search-backward (car seps
) nil t
)))
3362 (defun gnus-article-hidden-arg ()
3363 "Return the current prefix arg as a number, or 0 if no prefix."
3364 (list (if current-prefix-arg
3365 (prefix-numeric-value current-prefix-arg
)
3368 (defun gnus-article-check-hidden-text (type arg
)
3369 "Return nil if hiding is necessary.
3370 Arg can be nil or a number. nil and positive means hide, negative
3371 means show, 0 means toggle."
3374 (let ((hide (gnus-article-hidden-text-p type
)))
3380 (gnus-article-show-hidden-text type
)
3383 (if (eq hide
'hidden
)
3385 (gnus-article-show-hidden-text type
)
3389 (defun gnus-article-hidden-text-p (type)
3390 "Say whether the current buffer contains hidden text of type TYPE."
3391 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3393 (not (get-text-property pos
'invisible
))
3394 (not (get-text-property pos
'dummy-invisible
)))
3396 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3401 (defun gnus-article-show-hidden-text (type &optional _dummy
)
3402 "Show all hidden text of type TYPE.
3403 Originally it is hide instead of DUMMY."
3404 (let ((inhibit-read-only t
)
3405 (inhibit-point-motion-hooks t
))
3406 (gnus-remove-text-properties-when
3408 (point-min) (point-max)
3409 (cons 'article-type
(cons type
3410 gnus-hidden-properties
)))
3411 (gnus-delete-wash-type type
)))
3413 (defconst article-time-units
3414 `((year .
,(* 365.25 24 60 60))
3415 (week .
,(* 7 24 60 60))
3416 (day .
,(* 24 60 60))
3420 "Mapping from time units to seconds.")
3422 (defun gnus-article-forward-header ()
3423 "Move point to the start of the next header.
3424 If the current header is a continuation header, this can be several
3429 (if (looking-at "[ \t]+[^ \t]")
3433 (defun article-treat-date ()
3434 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3435 (with-current-buffer gnus-summary-buffer
3436 gnus-article-date-headers
)
3437 gnus-article-date-headers
)
3440 (defun article-date-ut (&optional type _highlight date-position
)
3441 "Convert DATE date to TYPE in the current article.
3442 The default type is `ut'. See `gnus-article-date-headers' for
3444 (interactive (list 'ut t
))
3445 (let* ((case-fold-search t
)
3446 (inhibit-read-only t
)
3447 (inhibit-point-motion-hooks t
)
3448 (visible-date (mail-fetch-field "Date"))
3449 pos date bface eface
)
3453 (goto-char date-position
)
3454 (setq date
(get-text-property (point) 'original-date
))
3455 (when (looking-at "[^:]+:[\t ]*")
3456 (setq bface
(get-text-property (match-beginning 0) 'face
)
3457 eface
(get-text-property (match-end 0) 'face
)))
3458 (delete-region (point)
3460 (gnus-article-forward-header)
3462 (article-transform-date date type bface eface
))
3465 (goto-char (point-min))
3466 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3467 (and (setq pos
(next-single-property-change
3468 (point) 'original-date
))
3470 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3471 (1+ (match-beginning 0))
3473 (while (setq pos
(text-property-not-all pos
(point-max)
3474 'gnus-date-type nil
))
3475 (setq date
(get-text-property pos
'original-date
))
3477 (when (looking-at "[^:]+:[\t ]*")
3478 (setq bface
(get-text-property (match-beginning 0) 'face
)
3479 eface
(get-text-property (match-end 0) 'face
)))
3480 (delete-region pos
(or (text-property-any pos
(point-max)
3481 'gnus-date-type nil
)
3483 (unless date
;; the 1st time
3484 (goto-char (point-min))
3485 (while (re-search-forward "^Date:[\t ]*" nil t
)
3486 (setq date
(get-text-property (match-beginning 0)
3488 bface
(get-text-property (match-beginning 0) 'face
)
3489 eface
(get-text-property (match-end 0) 'face
))
3490 (delete-region (point-at-bol) (progn
3491 (gnus-article-forward-header)
3493 (when (and (not date
)
3495 (setq date visible-date
))
3497 (article-transform-date date type bface eface
))
3498 (goto-char (point-max))
3501 (defun article-transform-date (date type bface eface
)
3502 (dolist (this-type (cond
3512 (add-text-properties
3515 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3517 (list 'original-date date
'gnus-date-type this-type
))))
3520 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3521 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3522 (when (match-beginning 2)
3523 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3524 (while (and (zerop (forward-line 1))
3525 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3526 (when (match-beginning 1)
3527 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3529 (defun article-make-date-line (date type
)
3530 "Return a DATE line of TYPE."
3531 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3533 (error "Unknown conversion type: %s" type
))
3535 (let ((time (ignore-errors (date-to-time date
))))
3537 ;; Convert to the local timezone.
3539 (concat "Date: " (message-make-date time
)))
3540 ;; Convert to Universal Time.
3545 (let* ((e (parse-time-string date
))
3546 (tm (apply 'encode-time e
))
3548 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3549 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3550 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3554 ;; Get the original date from the article.
3555 ((eq type
'original
)
3556 (concat "Date: " (if (string-match "\n+$" date
)
3557 (substring date
0 (match-beginning 0))
3559 ;; Let the user define the format.
3560 ((eq type
'user-defined
)
3561 (let ((format (or (condition-case nil
3562 (with-current-buffer gnus-summary-buffer
3563 gnus-article-time-format
)
3565 gnus-article-time-format
)))
3566 (if (functionp format
)
3567 (funcall format time
)
3568 (concat "Date: " (format-time-string format time
)))))
3571 (let ((tz (car (current-time-zone time
))))
3574 (format-time-string "%Y%m%dT%H%M%S" time
)
3575 (format "%s%02d%02d"
3576 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3577 (/ (%
(abs tz
) 3600) 60)))))
3578 ;; Do a lapsed format.
3580 (concat "Date: " (article-lapsed-string time
)))
3581 ;; A combined date/lapsed format.
3582 ((eq type
'combined-lapsed
)
3583 (let ((date-string (article-make-date-line date
'original
))
3589 (concat " (" (article-lapsed-string time segments
) ")"))
3590 (> (+ (length date-string
)
3591 (length lapsed-string
))
3594 (setq segments
(1- segments
)))
3596 (concat date-string lapsed-string
)
3598 ;; Display the date in proper English
3600 (let ((dtime (decode-time time
)))
3603 (number-to-string (nth 3 dtime
))
3604 (let ((digit (%
(nth 3 dtime
) 10)))
3606 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3612 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3614 (number-to-string (nth 5 dtime
))
3616 (format "%02d" (nth 2 dtime
))
3618 (format "%02d" (nth 1 dtime
)))))))
3620 (format "Date: %s (from Gnus)" date
))))
3622 (defun article-lapsed-string (time &optional max-segments
)
3623 ;; If the date is seriously mangled, the timezone functions are
3624 ;; liable to bug out, so we ignore all errors.
3625 (let* ((now (current-time))
3626 (real-time (subtract-time now time
))
3627 (real-sec (and real-time
3628 (+ (* (float (car real-time
)) 65536)
3630 (sec (and real-time
(abs real-sec
)))
3633 (unless max-segments
3634 (setq max-segments
(length article-time-units
)))
3642 ;; This is a bit convoluted, but basically we go
3643 ;; through the time units for years, weeks, etc,
3644 ;; and divide things to see whether that results
3645 ;; in positive answers.
3648 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3649 (>= segments max-segments
))
3650 ;; The (remaining) seconds are too few to
3651 ;; be divided into this time unit.
3653 ;; It's big enough, so we output it.
3654 (setq sec
(- sec
(* num
(cdr unit
))))
3656 (concat (if prev
", " "") (int-to-string
3658 " " (symbol-name (car unit
))
3659 (if (> num
1) "s" ""))
3661 segments
(1+ segments
)))))
3662 article-time-units
"")
3663 ;; If dates are odd, then it might appear like the
3664 ;; article was sent in the future.
3667 " in the future"))))))
3669 (defun article-date-local (&optional highlight
)
3670 "Convert the current article date to the local timezone."
3671 (interactive (list t
))
3672 (article-date-ut 'local highlight
))
3674 (defun article-date-english (&optional highlight
)
3675 "Convert the current article date to something that is proper English."
3676 (interactive (list t
))
3677 (article-date-ut 'english highlight
))
3679 (defun article-date-original (&optional highlight
)
3680 "Convert the current article date to what it was originally.
3681 This is only useful if you have used some other date conversion
3682 function and want to see what the date was before converting."
3683 (interactive (list t
))
3684 (article-date-ut 'original highlight
))
3686 (defun article-date-lapsed (&optional highlight
)
3687 "Convert the current article date to time lapsed since it was sent."
3688 (interactive (list t
))
3689 (article-date-ut 'lapsed highlight
))
3691 (defun article-date-combined-lapsed (&optional highlight
)
3692 "Convert the current article date to time lapsed since it was sent."
3693 (interactive (list t
))
3694 (article-date-ut 'combined-lapsed highlight
))
3696 (defun article-update-date-lapsed ()
3697 "Function to be run from a timer to update the lapsed time line."
3699 (let ((buffer (current-buffer)))
3703 (set-buffer (window-buffer w
))
3704 (when (derived-mode-p 'gnus-article-mode
)
3705 (let ((old-line (count-lines (point-min) (point)))
3706 (old-column (- (point) (line-beginning-position)))
3707 (window-start (window-start w
))
3710 (while (setq pos
(text-property-not-all pos
(point-max)
3711 'gnus-date-type nil
))
3712 (setq next
(or (next-single-property-change pos
3715 (setq type
(get-text-property pos
'gnus-date-type
))
3716 (when (memq type
'(lapsed combined-lapsed user-defined
))
3717 (article-date-ut type t pos
)
3718 (setq end
(or (next-single-property-change pos
3722 (if (/= window-start next
)
3723 (setq window-start nil
)
3724 (set-window-start w end
)))
3727 (goto-char (point-min))
3728 (when (> old-column
0)
3729 (setq old-line
(1- old-line
)))
3730 (forward-line old-line
)
3732 (when (> (current-column) old-column
)
3734 (forward-char old-column
)))))
3736 (set-buffer buffer
))))
3738 (defun gnus-start-date-timer (&optional n
)
3739 "Start a timer to update the Date headers in the article buffers.
3740 The numerical prefix says how frequently (in seconds) the function
3745 (gnus-stop-date-timer)
3746 (setq article-lapsed-timer
3747 (run-at-time 1 n
'article-update-date-lapsed
)))
3749 (defun gnus-stop-date-timer ()
3750 "Stop the Date timer."
3752 (when article-lapsed-timer
3753 (nnheader-cancel-timer article-lapsed-timer
)
3754 (setq article-lapsed-timer nil
)))
3756 (defun article-date-user (&optional highlight
)
3757 "Convert the current article date to the user-defined format.
3758 This format is defined by the `gnus-article-time-format' variable."
3759 (interactive (list t
))
3760 (article-date-ut 'user highlight
))
3762 (defun article-date-iso8601 (&optional highlight
)
3763 "Convert the current article date to ISO8601."
3764 (interactive (list t
))
3765 (article-date-ut 'iso8601 highlight
))
3767 (defmacro gnus-article-save-original-date
(&rest forms
)
3768 "Save the original date as a text property and evaluate FORMS."
3769 `(let* ((case-fold-search t
)
3771 (goto-char (point-min))
3772 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3775 (date (when (and start
3776 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3778 (buffer-substring-no-properties start
3779 (match-beginning 0)))))
3780 (goto-char (point-max))
3781 (skip-chars-backward "\n")
3782 (put-text-property (point-min) (point) 'original-date date
)
3784 (goto-char (point-max))
3785 (skip-chars-backward "\n")
3786 (put-text-property (point-min) (point) 'original-date date
)))
3788 ;; (defun article-show-all ()
3789 ;; "Show all hidden text in the article buffer."
3792 ;; (let ((inhibit-read-only t))
3793 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3795 (defun article-remove-leading-whitespace ()
3796 "Remove excessive whitespace from all headers."
3800 (let ((inhibit-read-only t
))
3801 (article-narrow-to-head)
3802 (goto-char (point-min))
3803 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3804 (delete-region (match-beginning 1) (match-end 1)))))))
3806 (defun article-emphasize (&optional arg
)
3807 "Emphasize text according to `gnus-emphasis-alist'."
3808 (interactive (gnus-article-hidden-arg))
3809 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3813 (with-current-buffer gnus-summary-buffer
3814 gnus-article-emphasis-alist
)
3816 gnus-emphasis-alist
))
3817 (inhibit-read-only t
)
3818 (props (append '(article-type emphasis
)
3819 gnus-hidden-properties
))
3820 regexp elem beg invisible visible face
)
3823 (while (setq elem
(pop alist
))
3825 (setq regexp
(car elem
)
3826 invisible
(nth 1 elem
)
3827 visible
(nth 2 elem
)
3829 (while (re-search-forward regexp nil t
)
3830 (when (and (match-beginning visible
) (match-beginning invisible
))
3831 (gnus-article-hide-text
3832 (match-beginning invisible
) (match-end invisible
) props
)
3833 (gnus-article-unhide-text-type
3834 (match-beginning visible
) (match-end visible
) 'emphasis
)
3835 (gnus-put-overlay-excluding-newlines
3836 (match-beginning visible
) (match-end visible
) 'face face
)
3837 (gnus-add-wash-type 'emphasis
)
3838 (goto-char (match-end invisible
)))))))))
3840 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3841 "Setup newsgroup emphasis alist."
3842 (unless gnus-article-emphasis-alist
3843 (let ((name (and gnus-newsgroup-name
3844 (gnus-group-real-name gnus-newsgroup-name
))))
3845 (make-local-variable 'gnus-article-emphasis-alist
)
3846 (setq gnus-article-emphasis-alist
3848 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3849 (while (setq elem
(pop alist
))
3850 (when (and name
(string-match (car elem
) name
))
3852 highlight
(copy-sequence (cdr elem
)))))
3854 (copy-sequence highlight-words
)
3855 (if gnus-newsgroup-name
3856 (copy-sequence (gnus-group-find-parameter
3857 gnus-newsgroup-name
'highlight-words t
)))
3858 gnus-emphasis-alist
)))))
3860 (defvar gnus-summary-article-menu
)
3861 (defvar gnus-summary-post-menu
)
3863 ;;; Saving functions.
3865 (defun gnus-article-save (save-buffer file
&optional num
)
3866 "Save the currently selected article."
3867 (when (or (get gnus-default-article-saver
:headers
)
3868 (not gnus-save-all-headers
))
3869 ;; Remove headers according to `gnus-saved-headers' or the value
3870 ;; of the `:headers' property that the saver function might have.
3871 (let ((gnus-visible-headers
3872 (or (symbol-value (get gnus-default-article-saver
:headers
))
3873 gnus-saved-headers gnus-visible-headers
))
3874 ;; Ignore group parameter. See `article-hide-headers'.
3875 (gnus-summary-buffer nil
))
3876 (with-current-buffer save-buffer
3877 (article-hide-headers 1 t
))))
3878 (save-window-excursion
3879 (if (not gnus-default-article-saver
)
3880 (error "No default saver is defined")
3881 ;; !!! Magic! The saving functions all save
3882 ;; `gnus-save-article-buffer' (or so they think), but we
3883 ;; bind that variable to our save-buffer.
3884 (set-buffer gnus-article-buffer
)
3885 (let* ((gnus-save-article-buffer save-buffer
)
3888 ((not gnus-prompt-before-saving
) 'default
)
3889 ((eq gnus-prompt-before-saving
'always
) nil
)
3891 (gnus-number-of-articles-to-be-saved
3892 (when (eq gnus-prompt-before-saving t
)
3894 (set-buffer gnus-article-current-summary
)
3895 (funcall gnus-default-article-saver filename
)))))
3897 (defun gnus-read-save-file-name (prompt &optional filename
3898 function group headers variable
3901 (funcall function group headers
(symbol-value variable
)))
3906 ((eq filename
'default
)
3912 (when (symbol-value dir-var
)
3913 (setq default-name
(expand-file-name
3914 (file-name-nondirectory default-name
)
3915 (symbol-value dir-var
))))
3916 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3919 (if (and gnus-number-of-articles-to-be-saved
3920 (> gnus-number-of-articles-to-be-saved
1))
3921 (format "these %d articles"
3922 gnus-number-of-articles-to-be-saved
)
3925 ;; Let the split methods have their say.
3927 ;; No split name was found.
3930 (concat prompt
" (default "
3931 (file-name-nondirectory default-name
) "): ")
3932 (file-name-directory default-name
)
3934 ;; A single group name is returned.
3935 ((stringp split-name
)
3937 (funcall function split-name headers
3938 (symbol-value variable
)))
3940 (concat prompt
" (default "
3941 (file-name-nondirectory default-name
) "): ")
3942 (file-name-directory default-name
)
3944 ;; A single split name was found
3945 ((= 1 (length split-name
))
3946 (let* ((name (expand-file-name
3948 gnus-article-save-directory
))
3949 (dir (cond ((file-directory-p name
)
3950 (file-name-as-directory name
))
3951 ((file-exists-p name
) name
)
3952 (t gnus-article-save-directory
))))
3954 (concat prompt
" (default " name
"): ")
3956 ;; A list of splits was found.
3958 (setq split-name
(nreverse split-name
))
3960 (let ((file-name-history
3961 (nconc split-name file-name-history
)))
3965 (concat prompt
" (`M-p' for defaults): ")
3966 gnus-article-save-directory
3968 gnus-article-save-directory
)))
3969 (car (push result file-name-history
)))))))
3970 ;; Create the directory.
3971 (gnus-make-directory (file-name-directory file
))
3972 ;; If we have read a directory, we append the default file name.
3973 (when (file-directory-p file
)
3974 (setq file
(expand-file-name (file-name-nondirectory
3976 (file-name-as-directory file
))))
3977 ;; Possibly translate some characters.
3978 (nnheader-translate-file-chars file
))))))
3979 (gnus-make-directory (file-name-directory result
))
3981 (set variable result
))
3983 (set dir-var
(file-name-directory result
)))
3986 (defun gnus-article-archive-name (_group)
3987 "Return the first instance of an \"Archive-name\" in the current buffer."
3988 (let ((case-fold-search t
))
3989 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3990 (nnheader-concat gnus-article-save-directory
3991 (match-string 1)))))
3993 (defun gnus-article-nndoc-name (group)
3994 "If GROUP is an nndoc group, return the name of the parent group."
3995 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3996 (gnus-group-get-parameter group
'save-article-group
)))
3998 (defun gnus-summary-save-in-rmail (&optional filename
)
3999 "Append this article to Rmail file.
4000 Optional argument FILENAME specifies file name.
4001 Directory to save to is default to `gnus-article-save-directory'."
4002 (setq filename
(gnus-read-save-file-name
4003 "Save %s in rmail file" filename
4004 gnus-rmail-save-name gnus-newsgroup-name
4005 gnus-current-headers
'gnus-newsgroup-last-rmail
))
4006 (with-current-buffer gnus-save-article-buffer
4010 ;; Note that unlike gnus-summary-save-in-mail, there is no
4011 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4013 (gnus-output-to-rmail filename
))))
4016 (defun gnus-summary-save-in-mail (&optional filename
)
4017 "Append this article to Unix mail file.
4018 Optional argument FILENAME specifies file name.
4019 Directory to save to is default to `gnus-article-save-directory'."
4020 (setq filename
(gnus-read-save-file-name
4021 "Save %s in Unix mail file" filename
4022 gnus-mail-save-name gnus-newsgroup-name
4023 gnus-current-headers
'gnus-newsgroup-last-mail
))
4024 (with-current-buffer gnus-save-article-buffer
4028 (if (and (file-readable-p filename
)
4029 (file-regular-p filename
)
4030 (mail-file-babyl-p filename
))
4031 (gnus-output-to-rmail filename
)
4032 (gnus-output-to-mail filename
)))))
4035 (put 'gnus-summary-save-in-file
:decode t
)
4036 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4037 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4038 "Append this article to file.
4039 Optional argument FILENAME specifies file name.
4040 Directory to save to is default to `gnus-article-save-directory'."
4041 (setq filename
(gnus-read-save-file-name
4042 "Save %s in file" filename
4043 gnus-file-save-name gnus-newsgroup-name
4044 gnus-current-headers
'gnus-newsgroup-last-file
))
4045 (with-current-buffer gnus-save-article-buffer
4049 (when (and overwrite
4050 (file-exists-p filename
))
4051 (delete-file filename
))
4052 (gnus-output-to-file filename
))))
4055 (put 'gnus-summary-write-to-file
:decode t
)
4056 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4057 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4058 (defun gnus-summary-write-to-file (&optional filename
)
4059 "Write this article to a file, overwriting it if the file exists.
4060 Optional argument FILENAME specifies file name.
4061 The directory to save in defaults to `gnus-article-save-directory'."
4062 (setq filename
(gnus-read-save-file-name
4063 "Save %s in file" filename
4064 gnus-file-save-name gnus-newsgroup-name
4065 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4066 (gnus-summary-save-in-file filename t
))
4068 (put 'gnus-summary-save-body-in-file
:decode t
)
4069 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4070 "Append this article body to a file.
4071 Optional argument FILENAME specifies file name.
4072 The directory to save in defaults to `gnus-article-save-directory'."
4073 (setq filename
(gnus-read-save-file-name
4074 "Save %s body in file" filename
4075 gnus-file-save-name gnus-newsgroup-name
4076 gnus-current-headers
'gnus-newsgroup-last-file
))
4077 (with-current-buffer gnus-save-article-buffer
4081 (when (article-goto-body)
4082 (narrow-to-region (point) (point-max)))
4083 (when (and overwrite
4084 (file-exists-p filename
))
4085 (delete-file filename
))
4086 (gnus-output-to-file filename
))))
4089 (put 'gnus-summary-write-body-to-file
:decode t
)
4090 (put 'gnus-summary-write-body-to-file
4091 :function
'gnus-summary-save-body-in-file
)
4092 (defun gnus-summary-write-body-to-file (&optional filename
)
4093 "Write this article body to a file, overwriting it if the file exists.
4094 Optional argument FILENAME specifies file name.
4095 The directory to save in defaults to `gnus-article-save-directory'."
4096 (setq filename
(gnus-read-save-file-name
4097 "Save %s body in file" filename
4098 gnus-file-save-name gnus-newsgroup-name
4099 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4100 (gnus-summary-save-body-in-file filename t
))
4102 (put 'gnus-summary-save-in-pipe
:decode t
)
4103 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4104 (defun gnus-summary-save-in-pipe (&optional command raw
)
4105 "Pipe this article to subprocess COMMAND.
4106 Valid values for COMMAND include:
4108 The executable command name and possibly arguments.
4110 You will be prompted for the command in the minibuffer.
4111 the symbol `default'
4112 It will be replaced with the command which the variable
4113 `gnus-summary-pipe-output-default-command' holds or the command
4114 last used for saving.
4115 Non-nil value for RAW overrides `:decode' and `:headers' properties
4116 and the raw article including all headers will be piped."
4117 (let ((article (gnus-summary-article-number))
4119 (get 'gnus-summary-save-in-pipe
:decode
)))
4120 save-buffer default
)
4122 (if (vectorp (gnus-summary-article-header article
))
4123 (save-current-buffer
4124 (gnus-summary-select-article decode decode nil article
)
4125 (insert-buffer-substring
4129 gnus-original-article-buffer
)
4131 (nnheader-set-temp-buffer " *Gnus Save*"))))
4132 ;; Remove unwanted headers.
4133 (when (and (not raw
)
4134 (or (get 'gnus-summary-save-in-pipe
:headers
)
4135 (not gnus-save-all-headers
)))
4136 (let ((gnus-visible-headers
4137 (or (symbol-value (get 'gnus-summary-save-in-pipe
4139 gnus-saved-headers gnus-visible-headers
))
4140 (gnus-summary-buffer nil
))
4141 (article-hide-headers 1 t
))))
4142 (error "%d is not a real article" article
))
4143 (error "No article to pipe"))
4144 (setq default
(or gnus-summary-pipe-output-default-command
4145 gnus-last-shell-command
))
4146 (unless (stringp command
)
4148 (if (and (eq command
'default
) default
)
4150 (gnus-read-shell-command "Shell command on this article: "
4152 (when (string-equal command
"")
4154 (setq command default
)
4155 (error "A command is required")))
4156 (with-current-buffer save-buffer
4159 (shell-command-on-region (point-min) (point-max) command nil
)))
4160 (gnus-kill-buffer save-buffer
))
4161 (setq gnus-summary-pipe-output-default-command command
))
4163 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4164 "Pipe this article to muttprint."
4165 (unless (stringp command
)
4166 (setq command
(read-string
4167 "Print using command: " gnus-summary-muttprint-program
4168 nil gnus-summary-muttprint-program
)))
4169 (let ((gnus-summary-pipe-output-default-command
4170 gnus-summary-pipe-output-default-command
))
4171 (gnus-summary-save-in-pipe command
))
4172 (setq gnus-summary-muttprint-program command
))
4174 ;;; Article file names when saving.
4176 (defun gnus-capitalize-newsgroup (newsgroup)
4177 "Capitalize NEWSGROUP name."
4178 (when (not (zerop (length newsgroup
)))
4179 (concat (char-to-string (upcase (aref newsgroup
0)))
4180 (substring newsgroup
1))))
4182 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4183 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4184 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4185 Otherwise, it is like ~/News/news/group/num."
4188 (concat (if (gnus-use-long-file-name 'not-save
)
4189 (gnus-capitalize-newsgroup newsgroup
)
4190 (gnus-newsgroup-directory-form newsgroup
))
4191 "/" (int-to-string (mail-header-number headers
)))
4192 gnus-article-save-directory
)))
4194 (string-equal (file-name-directory default
)
4195 (file-name-directory last-file
))
4196 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4198 (or last-file default
))))
4200 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4201 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4202 If variable `gnus-use-long-file-name' is non-nil, it is
4203 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4206 (concat (if (gnus-use-long-file-name 'not-save
)
4208 (gnus-newsgroup-directory-form newsgroup
))
4209 "/" (int-to-string (mail-header-number headers
)))
4210 gnus-article-save-directory
)))
4212 (string-equal (file-name-directory default
)
4213 (file-name-directory last-file
))
4214 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4216 (or last-file default
))))
4218 (defun gnus-plain-save-name (newsgroup _headers
&optional last-file
)
4219 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4220 If variable `gnus-use-long-file-name' is non-nil, it is
4221 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4224 (if (gnus-use-long-file-name 'not-save
)
4227 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4229 gnus-article-save-directory
)))
4231 (defun gnus-sender-save-name (_newsgroup headers
&optional _last-file
)
4232 "Generate file name from sender."
4233 (let ((from (mail-header-from headers
)))
4235 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4236 (match-string 1 from
)
4238 gnus-article-save-directory
)))
4240 (defun article-verify-x-pgp-sig ()
4242 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4244 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4245 (let ((sig (with-current-buffer gnus-original-article-buffer
4246 (gnus-fetch-field "X-PGP-Sig")))
4250 (mml2015-clear-verify-function))
4252 (insert-buffer-substring gnus-original-article-buffer
)
4253 (setq items
(split-string sig
))
4254 (message-narrow-to-head)
4255 (let ((inhibit-point-motion-hooks t
)
4256 (case-fold-search t
))
4257 ;; Don't verify multiple headers.
4258 (setq headers
(mapconcat (lambda (header)
4260 (mail-fetch-field header
)
4262 (split-string (nth 1 items
) ",") "")))
4263 (delete-region (point-min) (point-max))
4264 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4265 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4270 (if (looking-at "^-")
4273 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4274 (insert "Version: " (car items
) "\n\n")
4275 (insert (mapconcat 'identity
(cddr items
) "\n"))
4276 (insert "\n-----END PGP SIGNATURE-----\n")
4277 (let ((mm-security-handle (list (format "multipart/signed"))))
4278 (mml2015-clean-buffer)
4279 (let ((coding-system-for-write (or gnus-newsgroup-charset
4281 (funcall (mml2015-clear-verify-function)))
4283 (or (mm-handle-multipart-ctl-parameter
4284 mm-security-handle
'gnus-details
)
4285 (mm-handle-multipart-ctl-parameter
4286 mm-security-handle
'gnus-info
)))))
4288 (let ((inhibit-read-only t
) bface eface
)
4290 (message-narrow-to-head)
4291 (goto-char (point-max))
4293 (setq bface
(get-text-property (point-at-bol) 'face
)
4294 eface
(get-text-property (1- (point-at-eol)) 'face
))
4295 (message-remove-header "X-Gnus-PGP-Verify")
4296 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4298 (goto-char (point-max)))
4299 (narrow-to-region (point) (point))
4300 (insert "X-Gnus-PGP-Verify: " info
"\n")
4301 (goto-char (point-min))
4304 (if (not (looking-at "^[ \t]"))
4308 (goto-char (point-min))
4309 (when (looking-at "\\([^:]+\\): *")
4310 (put-text-property (match-beginning 1) (1+ (match-end 1))
4312 (put-text-property (match-end 0) (point-max)
4313 'face eface
)))))))))
4315 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4317 (defun article-verify-cancel-lock ()
4318 "Verify Cancel-Lock header."
4320 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4321 (canlock-verify gnus-original-article-buffer
)))
4328 (setq afunc
(car func
)
4331 gfunc
(intern (format "gnus-%s" func
))))
4333 (when (fboundp afunc
)
4334 `(lambda (&optional interactive
&rest args
)
4335 ,(documentation afunc t
)
4336 (interactive (list t
))
4337 (with-current-buffer gnus-article-buffer
4339 (call-interactively ',afunc
)
4340 (apply ',afunc args
))))))))
4341 '(article-hide-headers
4342 article-verify-x-pgp-sig
4343 article-verify-cancel-lock
4344 article-hide-boring-headers
4345 article-treat-overstrike
4346 article-treat-ansi-sequences
4347 article-fill-long-lines
4348 article-capitalize-sentences
4350 article-remove-leading-whitespace
4351 article-display-x-face
4352 article-display-face
4353 article-de-quoted-unreadable
4354 article-de-base64-unreadable
4357 article-unsplit-urls
4358 article-hide-list-identifiers
4359 article-strip-banner
4362 article-hide-signature
4363 article-strip-headers-in-body
4364 article-remove-trailing-blank-lines
4365 article-strip-leading-blank-lines
4366 article-strip-multiple-blank-lines
4367 article-strip-leading-space
4368 article-strip-trailing-space
4369 article-strip-blank-lines
4370 article-strip-all-blank-lines
4372 article-date-english
4373 article-date-iso8601
4374 article-date-original
4377 article-decode-mime-words
4378 article-decode-charset
4379 article-decode-encoded-words
4382 article-date-combined-lapsed
4384 article-treat-dumbquotes
4385 article-treat-non-ascii
4386 article-normalize-headers
4387 ;;(article-show-all . gnus-article-show-all-headers)
4391 ;;; Gnus article mode
4394 (put 'gnus-article-mode
'mode-class
'special
)
4396 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4398 (gnus-define-keys gnus-article-mode-map
4399 " " gnus-article-goto-next-page
4400 [?\S-\
] gnus-article-goto-prev-page
4401 "\177" gnus-article-goto-prev-page
4402 [delete] gnus-article-goto-prev-page
4403 "\C-c^" gnus-article-refer-article
4404 "h" gnus-article-show-summary
4405 "s" gnus-article-show-summary
4406 "\C-c\C-m" gnus-article-mail
4407 "?" gnus-article-describe-briefly
4408 "<" beginning-of-buffer
4410 "\C-c\C-i" gnus-info-find-node
4412 "R" gnus-article-reply-with-original
4413 "F" gnus-article-followup-with-original
4414 "\C-hk" gnus-article-describe-key
4415 "\C-hc" gnus-article-describe-key-briefly
4416 "\C-hb" gnus-article-describe-bindings
4418 "e" gnus-article-read-summary-keys
4419 "\C-d" gnus-article-read-summary-keys
4420 "\M-*" gnus-article-read-summary-keys
4421 "\M-#" gnus-article-read-summary-keys
4422 "\M-^" gnus-article-read-summary-keys
4423 "\M-g" gnus-article-read-summary-keys)
4425 (substitute-key-definition
4426 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4428 (defvar gnus-article-send-map)
4430 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4431 "W" gnus-article-wide-reply-with-original)
4432 (if (featurep 'xemacs)
4433 (set-keymap-default-binding gnus-article-send-map
4434 'gnus-article-read-summary-send-keys)
4435 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4437 (defun gnus-article-make-menu-bar ()
4438 (unless (boundp 'gnus-article-commands-menu)
4439 (gnus-summary-make-menu-bar))
4440 (unless (boundp 'gnus-article-article-menu)
4442 gnus-article-article-menu gnus-article-mode-map ""
4444 ["Scroll forwards" gnus-article-goto-next-page t]
4445 ["Scroll backwards" gnus-article-goto-prev-page t]
4446 ["Show summary" gnus-article-show-summary t]
4447 ["Fetch Message-ID at point" gnus-article-refer-article t]
4448 ["Mail to address at point" gnus-article-mail t]
4449 ["Send a bug report" gnus-bug t]))
4452 gnus-article-treatment-menu gnus-article-mode-map ""
4453 ;; Fixme: this should use :active (and maybe :visible).
4455 ["Hide headers" gnus-article-hide-headers t]
4456 ["Hide signature" gnus-article-hide-signature t]
4457 ["Hide citation" gnus-article-hide-citation t]
4458 ["Treat overstrike" gnus-article-treat-overstrike t]
4459 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4460 ["Remove carriage return" gnus-article-remove-cr t]
4461 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4462 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4463 ["Remove base64" gnus-article-de-base64-unreadable t]
4464 ["Treat html" gnus-article-wash-html t]
4465 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4466 ["Decode HZ" gnus-article-decode-HZ t]))
4468 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4470 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4472 (gnus-run-hooks 'gnus-article-menu-hook)))
4474 (defvar bookmark-make-record-function)
4475 (defvar shr-put-image-function)
4477 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4478 "Major mode for displaying an article.
4480 All normal editing commands are switched off.
4482 The following commands are available in addition to all summary mode
4484 \\<gnus-article-mode-map>
4485 \\[gnus-article-next-page]\t Scroll the article one page forwards
4486 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4487 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4488 \\[gnus-article-show-summary]\t Display the summary buffer
4489 \\[gnus-article-mail]\t Send a reply to the address near point
4490 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4491 \\[gnus-info-find-node]\t Go to the Gnus info node"
4492 (gnus-simplify-mode-line)
4493 (make-local-variable 'minor-mode-alist)
4494 (when (gnus-visual-p 'article-menu 'menu)
4495 (gnus-article-make-menu-bar)
4496 (when gnus-summary-tool-bar-map
4497 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4498 (gnus-update-format-specifications nil 'article-mode)
4499 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4500 (set (make-local-variable 'gnus-page-broken) nil)
4501 (make-local-variable 'gnus-article-current-summary)
4502 (make-local-variable 'gnus-article-mime-handles)
4503 (make-local-variable 'gnus-article-decoded-p)
4504 (make-local-variable 'gnus-article-mime-handle-alist)
4505 (make-local-variable 'gnus-article-wash-types)
4506 (make-local-variable 'gnus-article-image-alist)
4507 (make-local-variable 'gnus-article-charset)
4508 (make-local-variable 'gnus-article-ignored-charsets)
4509 (set (make-local-variable 'bookmark-make-record-function)
4510 'gnus-summary-bookmark-make-record)
4511 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4513 (set (make-local-variable 'nobreak-char-display) nil)
4514 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4515 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4516 (setq cursor-in-non-selected-windows nil)
4517 (gnus-set-default-directory)
4518 (buffer-disable-undo)
4519 (setq buffer-read-only t
4520 show-trailing-whitespace nil)
4521 (mm-enable-multibyte))
4523 (defun gnus-article-setup-buffer ()
4524 "Initialize the article buffer."
4525 (let* ((name (if gnus-single-article-buffer "*Article*"
4527 (gnus-group-decoded-name gnus-newsgroup-name)
4530 (progn (string-match "\\*Article" name)
4531 (concat " *Original Article"
4532 (substring name (match-end 0))))))
4533 (setq gnus-article-buffer name)
4534 (setq gnus-original-article-buffer original)
4535 (setq gnus-article-mime-handle-alist nil)
4536 (with-current-buffer gnus-summary-buffer
4537 ;; This might be a variable local to the summary buffer.
4538 (unless gnus-single-article-buffer
4539 (setq gnus-article-buffer name)
4540 (setq gnus-original-article-buffer original)
4541 (gnus-set-global-variables)))
4542 (gnus-article-setup-highlight-words)
4543 ;; Init original article buffer.
4544 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4545 (mm-enable-multibyte)
4546 (setq major-mode 'gnus-original-article-mode)
4547 (make-local-variable 'gnus-original-article))
4548 (if (and (get-buffer name)
4549 (with-current-buffer name
4550 (if gnus-article-edit-mode
4551 (if (y-or-n-p "Article mode edit in progress; discard? ")
4553 (set-buffer-modified-p nil)
4554 (gnus-kill-buffer name)
4557 (error "Action aborted"))
4559 (let ((summary gnus-summary-buffer))
4560 (with-current-buffer name
4561 (set (make-local-variable 'gnus-article-edit-mode) nil)
4562 (gnus-article-stop-animations)
4563 (when gnus-article-mime-handles
4564 (mm-destroy-parts gnus-article-mime-handles)
4565 (setq gnus-article-mime-handles nil))
4566 ;; Set it to nil in article-buffer!
4567 (setq gnus-article-mime-handle-alist nil)
4568 (buffer-disable-undo)
4569 (setq buffer-read-only t)
4570 (unless (derived-mode-p 'gnus-article-mode)
4571 (gnus-article-mode))
4572 (set (make-local-variable 'gnus-summary-buffer) summary)
4573 (setq truncate-lines gnus-article-truncate-lines)
4575 (let ((summary gnus-summary-buffer))
4576 (with-current-buffer (gnus-get-buffer-create name)
4578 (setq truncate-lines gnus-article-truncate-lines)
4579 (set (make-local-variable 'gnus-summary-buffer) summary)
4580 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4581 (when article-lapsed-timer
4582 (gnus-stop-date-timer))
4583 (when gnus-article-update-date-headers
4584 (gnus-start-date-timer gnus-article-update-date-headers))
4585 (current-buffer))))))
4587 (defun gnus-article-stop-animations ()
4588 (dolist (timer (and (boundp 'timer-list)
4590 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4591 (cancel-timer timer))))
4593 (defun gnus-stop-downloads ()
4594 (when (boundp 'url-queue)
4595 (set (intern "url-queue" obarray) nil)))
4597 ;; Set article window start at LINE, where LINE is the number of lines
4598 ;; from the head of the article.
4599 (defun gnus-article-set-window-start (&optional line)
4600 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4601 (when article-window
4604 (with-current-buffer gnus-article-buffer
4605 (goto-char (point-min))
4608 (gnus-message 6 "Moved to bookmark")
4609 (search-forward "\n\n" nil t)
4613 (defvar gnus-tmp-internal-hook)
4615 (defun gnus-article-prepare (article &optional all-headers _header)
4616 "Prepare ARTICLE in article mode buffer.
4617 ARTICLE should either be an article number or a Message-ID.
4618 If ARTICLE is an id, HEADER should be the article headers.
4619 If ALL-HEADERS is non-nil, no headers are hidden."
4620 (save-excursion ;FIXME: Shouldn't that be save-current-buffer?
4621 ;; Make sure we start in a summary buffer.
4622 (unless (derived-mode-p 'gnus-summary-mode)
4623 (set-buffer gnus-summary-buffer))
4624 (setq gnus-summary-buffer (current-buffer))
4625 (let* ((summary-buffer (current-buffer))
4626 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4627 (group gnus-newsgroup-name)
4630 (gnus-article-setup-buffer)
4631 (set-buffer gnus-article-buffer)
4632 ;; Deactivate active regions.
4633 (when (and (boundp 'transient-mark-mode)
4634 transient-mark-mode)
4635 (setq mark-active nil))
4636 (if (not (setq result (let ((inhibit-read-only t))
4637 (gnus-request-article-this-buffer
4639 ;; There is no such article.
4641 (when (and (numberp article)
4642 (not (memq article gnus-newsgroup-sparse)))
4643 (setq gnus-article-current
4644 (cons gnus-newsgroup-name article))
4645 (set-buffer gnus-summary-buffer)
4646 (setq gnus-current-article article)
4647 (if (and (memq article gnus-newsgroup-undownloaded)
4648 (not (gnus-online (gnus-find-method-for-group
4649 gnus-newsgroup-name))))
4651 (gnus-summary-set-agent-mark article)
4652 (message "Message marked for downloading"))
4653 (gnus-summary-mark-article article gnus-canceled-mark)
4654 (unless (memq article gnus-newsgroup-sparse)
4655 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4656 (if (or (eq result 'pseudo)
4657 (eq result 'nneething))
4659 (with-current-buffer summary-buffer
4660 (push article gnus-newsgroup-history)
4661 (setq gnus-last-article gnus-current-article
4662 gnus-current-article 0
4663 gnus-current-headers nil
4664 gnus-article-current nil)
4665 (if (eq result 'nneething)
4666 (gnus-configure-windows 'summary)
4667 (gnus-configure-windows 'article))
4668 (gnus-set-global-variables))
4669 (let ((gnus-article-mime-handle-alist-1
4670 gnus-article-mime-handle-alist))
4671 (gnus-set-mode-line 'article)))
4672 ;; The result from the `request' was an actual article -
4673 ;; or at least some text that is now displayed in the
4675 (when (and (numberp article)
4676 (not (eq article gnus-current-article)))
4677 ;; Seems like a new article has been selected.
4678 ;; `gnus-current-article' must be an article number.
4679 (with-current-buffer summary-buffer
4680 (push article gnus-newsgroup-history)
4681 (setq gnus-last-article gnus-current-article
4682 gnus-current-article article
4683 gnus-current-headers
4684 (gnus-summary-article-header gnus-current-article)
4685 gnus-article-current
4686 (cons gnus-newsgroup-name gnus-current-article))
4687 (unless (vectorp gnus-current-headers)
4688 (setq gnus-current-headers nil))
4689 (gnus-summary-goto-subject gnus-current-article)
4690 (when (gnus-summary-show-thread)
4691 ;; If the summary buffer really was folded, the
4692 ;; previous goto may not actually have gone to
4693 ;; the right article, but the thread root instead.
4695 (gnus-summary-goto-subject gnus-current-article))
4696 (gnus-run-hooks 'gnus-mark-article-hook)
4697 (gnus-set-mode-line 'summary)
4698 (when (gnus-visual-p 'article-highlight 'highlight)
4699 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4700 ;; Set the global newsgroup variables here.
4701 (gnus-set-global-variables)
4702 (setq gnus-have-all-headers
4703 (or all-headers gnus-show-all-headers))))
4705 (gnus-configure-windows 'article))
4706 (when (or (numberp article)
4708 (gnus-article-prepare-display)
4710 (goto-char (point-min))
4711 (when gnus-break-pages
4712 (gnus-narrow-to-page)))
4713 (let ((gnus-article-mime-handle-alist-1
4714 gnus-article-mime-handle-alist))
4715 (gnus-set-mode-line 'article))
4719 (set-window-point (get-buffer-window (current-buffer)) (point))
4720 (gnus-configure-windows 'article)
4721 (gnus-run-hooks 'gnus-article-prepare-hook)
4724 (defvar gnus-mime-display-attachment-buttons-in-header)
4727 (defun gnus-article-prepare-display ()
4728 "Make the current buffer look like a nice article."
4729 ;; Hooks for getting information from the article.
4730 ;; This hook must be called before being narrowed.
4731 (let ((gnus-article-buffer (current-buffer))
4733 (inhibit-read-only t))
4734 (unless (derived-mode-p 'gnus-article-mode)
4735 (gnus-article-mode))
4736 (setq buffer-read-only nil
4737 gnus-article-wash-types nil
4738 gnus-article-image-alist nil)
4739 (gnus-run-hooks 'gnus-tmp-internal-hook)
4740 (when gnus-display-mime-function
4741 (funcall gnus-display-mime-function))
4742 ;; Add attachment buttons to the header.
4743 (when gnus-mime-display-attachment-buttons-in-header
4744 (gnus-mime-buttonize-attachments-in-header))))
4747 ;;; Gnus Sticky Article Mode
4750 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4751 "Mode for sticky articles."
4752 ;; Release bindings that won't work.
4753 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4754 gnus-sticky-article-mode-map)
4755 (substitute-key-definition 'gnus-article-refer-article 'undefined
4756 gnus-sticky-article-mode-map)
4757 (dolist (k '("e" "h" "s" "F" "R"))
4758 (define-key gnus-sticky-article-mode-map k nil))
4759 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4760 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4761 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4762 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4764 (defun gnus-sticky-article (arg)
4765 "Make the current article sticky.
4766 If a prefix ARG is given, ask for a name for this sticky article buffer."
4768 (gnus-summary-show-thread)
4769 (gnus-summary-select-article nil nil 'pseudo)
4770 (let (new-art-buf-name)
4771 (gnus-eval-in-buffer-window gnus-article-buffer
4772 (setq new-art-buf-name
4776 (read-from-minibuffer "Sticky article buffer name: ")
4777 (gnus-with-article-headers
4778 (gnus-article-goto-header "subject")
4779 (setq new-art-buf-name
4780 (buffer-substring-no-properties
4781 (line-beginning-position) (line-end-position)))
4782 (goto-char (point-min))
4783 (gnus-article-goto-header "from")
4784 (setq new-art-buf-name
4786 new-art-buf-name ", "
4787 (buffer-substring-no-properties
4788 (line-beginning-position) (line-end-position))))
4789 (goto-char (point-min))
4790 (gnus-article-goto-header "date")
4791 (setq new-art-buf-name
4793 new-art-buf-name ", "
4794 (buffer-substring-no-properties
4795 (line-beginning-position) (line-end-position))))))
4797 (if (and (gnus-buffer-live-p new-art-buf-name)
4798 (with-current-buffer new-art-buf-name
4799 (derived-mode-p 'gnus-sticky-article-mode)))
4800 (switch-to-buffer new-art-buf-name)
4801 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4802 (gnus-sticky-article-mode))
4803 (setq gnus-article-buffer new-art-buf-name))
4804 (gnus-summary-recenter)
4805 (gnus-summary-position-point))
4807 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4808 "Kill the given sticky article BUFFER.
4809 If none is given, assume the current buffer and kill it if it has
4810 `gnus-sticky-article-mode'."
4813 (setq buffer (current-buffer)))
4814 (with-current-buffer buffer
4815 (when (derived-mode-p 'gnus-sticky-article-mode)
4816 (gnus-kill-buffer buffer))))
4818 (defun gnus-kill-sticky-article-buffers (arg)
4819 "Kill all sticky article buffers.
4820 If a prefix ARG is given, ask for confirmation."
4822 (dolist (buf (gnus-buffers))
4823 (with-current-buffer buf
4824 (when (derived-mode-p 'gnus-sticky-article-mode)
4826 (gnus-kill-buffer buf)
4827 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4828 (gnus-kill-buffer buf)))))))
4831 ;;; Gnus MIME viewing functions
4834 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4835 "Format of the MIME buttons.
4837 Valid specifiers include:
4839 %T MIME type, along with additional info
4840 %n The `name' parameter
4841 %d The description, if any
4842 %l The length of the encoded part
4843 %p The part identifier number
4844 %e Dots if the part isn't displayed
4846 General format specifiers can also be used. See Info node
4847 `(gnus)Formatting Variables'.")
4849 (defvar gnus-tmp-type)
4850 (defvar gnus-tmp-type-long)
4851 (defvar gnus-tmp-name)
4852 (defvar gnus-tmp-description)
4853 (defvar gnus-tmp-id)
4854 (defvar gnus-tmp-length)
4855 (defvar gnus-tmp-dots)
4856 (defvar gnus-tmp-info)
4857 (defvar gnus-tmp-pressed-details)
4859 (defvar gnus-mime-button-line-format-alist
4860 '((?t gnus-tmp-type ?s)
4861 (?T gnus-tmp-type-long ?s)
4862 (?n gnus-tmp-name ?s)
4863 (?d gnus-tmp-description ?s)
4865 (?l gnus-tmp-length ?d)
4866 (?e gnus-tmp-dots ?s)))
4868 (defvar gnus-mime-button-commands
4869 '((gnus-article-press-button "\r" "Toggle Display")
4870 (gnus-mime-view-part "v" "View Interactively...")
4871 (gnus-mime-view-part-as-type "t" "View As Type...")
4872 (gnus-mime-view-part-as-charset "C" "View As charset...")
4873 (gnus-mime-save-part "o" "Save...")
4874 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4875 (gnus-mime-replace-part "r" "Replace part")
4876 (gnus-mime-delete-part "d" "Delete part")
4877 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4878 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4879 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4880 (gnus-mime-view-part-externally "e" "View Externally")
4881 (gnus-mime-print-part "p" "Print")
4882 (gnus-mime-pipe-part "|" "Pipe To Command...")
4883 (gnus-mime-action-on-part "." "Take action on the part...")))
4885 (defun gnus-article-mime-part-status ()
4886 (if gnus-article-mime-handle-alist-1
4887 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4889 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4892 (defvar gnus-mime-button-map
4893 (let ((map (make-sparse-keymap)))
4894 (define-key map gnus-mouse-2 'gnus-article-push-button)
4895 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4896 (dolist (c gnus-mime-button-commands)
4897 (define-key map (cadr c) (car c)))
4901 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4903 ,@(mapcar (lambda (c)
4904 (vector (caddr c) (car c) :active t))
4905 gnus-mime-button-commands)))
4907 (defvar gnus-url-button-commands
4908 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4910 (defvar gnus-url-button-map
4911 (let ((map (make-sparse-keymap)))
4912 (dolist (c gnus-url-button-commands)
4913 (define-key map (cadr c) (car c)))
4917 gnus-url-button-menu gnus-url-button-map "URL button menu."
4919 ,@(mapcar (lambda (c)
4920 (vector (caddr c) (car c) :active t))
4921 gnus-url-button-commands)))
4923 (defmacro gnus-bind-safe-url-regexp (&rest body)
4924 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4925 `(let ((mm-w3m-safe-url-regexp
4926 (let ((group (if (and (derived-mode-p 'gnus-article-mode)
4928 gnus-article-current-summary))
4929 (with-current-buffer gnus-article-current-summary
4930 gnus-newsgroup-name)
4931 gnus-newsgroup-name)))
4932 (if (cond ((not group)
4933 ;; Maybe we're in a mml-preview buffer
4934 ;; and no group is selected.
4936 ((stringp gnus-safe-html-newsgroups)
4937 (string-match gnus-safe-html-newsgroups group))
4938 ((consp gnus-safe-html-newsgroups)
4939 (member group gnus-safe-html-newsgroups)))
4941 mm-w3m-safe-url-regexp))))
4944 (defun gnus-mime-button-menu (event prefix)
4945 "Construct a context-sensitive menu of MIME commands."
4946 (interactive "e\nP")
4947 (save-window-excursion
4948 (let ((pos (event-start event)))
4949 (select-window (posn-window pos))
4950 (goto-char (posn-point pos))
4951 (gnus-article-check-buffer)
4952 (popup-menu gnus-mime-button-menu nil prefix))))
4954 (defun gnus-mime-view-all-parts (&optional handles)
4955 "View all the MIME parts."
4957 (with-current-buffer gnus-article-buffer
4958 (let ((handles (or handles gnus-article-mime-handles))
4959 (mail-parse-charset gnus-newsgroup-charset)
4960 (mail-parse-ignored-charsets
4961 (with-current-buffer gnus-summary-buffer
4962 gnus-newsgroup-ignored-charsets)))
4964 (mm-remove-parts handles)
4965 (goto-char (point-min))
4966 (or (search-forward "\n\n") (goto-char (point-max)))
4967 (let ((inhibit-read-only t))
4968 (delete-region (point) (point-max))
4969 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4971 (defun gnus-article-jump-to-part (n)
4972 "Jump to MIME part N."
4974 (let ((parts (with-current-buffer gnus-article-buffer
4975 (length gnus-article-mime-handle-alist))))
4977 (error "No such part"))
4978 (pop-to-buffer gnus-article-buffer)
4980 (setq n (if (= parts 1)
4982 (read-number (format "Jump to part (1..%s): " parts)))))
4983 (unless (and (integerp n) (<= n parts) (>= n 1))
4986 (gnus-message 7 "Invalid part `%s', using %s instead."
4989 (gnus-message 9 "Jumping to part %s." n)
4990 (cond ((>= gnus-auto-select-part 1)
4991 (while (and (<= n parts)
4992 (not (gnus-article-goto-part n)))
4994 ((< gnus-auto-select-part 0)
4995 (while (and (>= n 1)
4996 (not (gnus-article-goto-part n)))
4999 (gnus-article-goto-part n)))))
5001 (defvar gnus-mime-buttonized-part-id nil
5002 "ID of a mime part that should be buttonized.
5003 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
5006 (defsubst gnus-article-edit-part (handles &optional current-id)
5007 "Edit an article in order to delete a mime part.
5008 This function is exclusively used by `gnus-mime-save-part-and-strip'
5009 and `gnus-mime-delete-part', and not provided at run-time normally."
5010 (gnus-article-edit-article
5012 (buffer-disable-undo)
5013 (let ((mail-parse-charset (or gnus-article-charset
5014 ',gnus-newsgroup-charset))
5015 (mail-parse-ignored-charsets
5016 (or gnus-article-ignored-charsets
5017 ',gnus-newsgroup-ignored-charsets))
5018 (mbl mml-buffer-list))
5019 (setq mml-buffer-list nil)
5020 ;; A new text must be inserted before deleting existing ones
5021 ;; at the end so as not to move existing markers of which
5022 ;; the insertion type is t.
5026 (goto-char (point-max))
5027 (insert-buffer-substring gnus-original-article-buffer)))
5028 (mime-to-mml ',handles)
5029 (setq gnus-article-mime-handles nil)
5030 (let ((mbl1 mml-buffer-list))
5031 (setq mml-buffer-list mbl)
5032 (set (make-local-variable 'mml-buffer-list) mbl1))
5033 (gnus-make-local-hook 'kill-buffer-hook)
5034 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5035 `(lambda (no-highlight)
5036 (let ((mail-parse-charset (or gnus-article-charset
5037 ',gnus-newsgroup-charset))
5038 (message-options message-options)
5039 (message-options-set-recipient)
5040 (mail-parse-ignored-charsets
5041 (or gnus-article-ignored-charsets
5042 ',gnus-newsgroup-ignored-charsets)))
5044 (mml-destroy-buffers)
5045 (remove-hook 'kill-buffer-hook
5046 'mml-destroy-buffers t)
5047 (kill-local-variable 'mml-buffer-list))
5048 (gnus-summary-edit-article-done
5049 ,(or (mail-header-references gnus-current-headers) "")
5050 ,(gnus-group-read-only-p)
5051 ,gnus-summary-buffer no-highlight))
5053 ;; Force buttonizing this part.
5054 (let ((gnus-mime-buttonized-part-id current-id))
5055 (gnus-article-edit-done))
5056 (gnus-configure-windows 'article)
5057 (when (and current-id (integerp gnus-auto-select-part))
5058 (gnus-article-jump-to-part
5059 (min (max (+ current-id gnus-auto-select-part) 1)
5060 (with-current-buffer gnus-article-buffer
5061 (length gnus-article-mime-handle-alist)))))))
5063 (defun gnus-mime-replace-part (file)
5064 "Replace MIME part under point with an external body."
5065 ;; Useful if file has already been saved to disk
5068 (read-file-name "Replace MIME part with file: "
5069 (or mm-default-directory default-directory)
5071 (gnus-mime-save-part-and-strip file))
5073 (defun gnus-mime-save-part-and-strip (&optional file)
5074 "Save the MIME part under point then replace it with an external body.
5075 If FILE is given, use it for the external part."
5077 (gnus-article-check-buffer)
5078 (when (gnus-group-read-only-p)
5079 (error "The current group does not support deleting of parts"))
5080 (when (mm-complicated-handles gnus-article-mime-handles)
5082 The current article has a complicated MIME structure, giving up..."))
5083 (let* ((data (get-text-property (point) 'gnus-data))
5084 (id (get-text-property (point) 'gnus-part))
5085 (handles gnus-article-mime-handles))
5088 (and data (mm-save-part data "Delete MIME part and save to: "))))
5090 (with-current-buffer (mm-handle-buffer data)
5092 (insert "Content-Type: " (mm-handle-media-type data))
5093 (mml-insert-parameter-string (cdr (mm-handle-type data))
5095 ;; Add a filename for the sake of saving the part again.
5096 (mml-insert-parameter
5097 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5099 (insert "Content-ID: " (message-make-message-id) "\n")
5100 (insert "Content-Transfer-Encoding: binary\n")
5103 (cdr (mm-make-handle nil
5104 `("message/external-body"
5105 (access-type . "LOCAL-FILE")
5107 ;; (set-buffer gnus-summary-buffer)
5108 (gnus-article-edit-part handles id))))
5110 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5111 ;; parts...>') but with stripping would be nice.
5113 (defun gnus-mime-delete-part ()
5114 "Delete the MIME part under point.
5115 Replace it with some information about the removed part."
5117 (gnus-article-check-buffer)
5118 (when (gnus-group-read-only-p)
5119 (error "The current group does not support deleting of parts"))
5120 (when (mm-complicated-handles gnus-article-mime-handles)
5122 The current article has a complicated MIME structure, giving up..."))
5123 (when (or gnus-expert-user
5124 (gnus-yes-or-no-p "\
5125 Deleting parts may malfunction or destroy the article; continue? "))
5126 (let* ((data (get-text-property (point) 'gnus-data))
5127 (id (get-text-property (point) 'gnus-part))
5128 (handles gnus-article-mime-handles)
5130 (let ((desc (mm-handle-description data)))
5132 (mail-decode-encoded-word-string desc))))
5133 (filename (or (mm-handle-filename data) "(none)"))
5134 (type (mm-handle-media-type data)))
5136 (error "No MIME part under point"))
5137 (with-current-buffer (mm-handle-buffer data)
5138 (let ((bsize (buffer-size)))
5143 "| The following attachment has been deleted:\n"
5145 "| Type: " type "\n"
5146 "| Filename: " filename "\n"
5147 "| Size (encoded): " (format "%s byte%s\n"
5148 bsize (if (= bsize 1)
5152 (concat "| Description: " description "\n"))
5155 (cdr (mm-make-handle
5156 nil `("text/plain" (charset . gnus-decoded)) nil nil
5158 (format "Deleted attachment (%s bytes)" bsize))))))
5159 ;; (set-buffer gnus-summary-buffer)
5160 (gnus-article-edit-part handles id))))
5162 (defun gnus-mime-save-part ()
5163 "Save the MIME part under point."
5165 (gnus-article-check-buffer)
5166 (let ((data (get-text-property (point) 'gnus-data)))
5168 (mm-save-part data))))
5170 (defun gnus-mime-pipe-part (&optional cmd)
5171 "Pipe the MIME part under point to a process.
5172 Use CMD as the process."
5174 (gnus-article-check-buffer)
5175 (let ((data (get-text-property (point) 'gnus-data)))
5177 (mm-pipe-part data cmd))))
5179 (defun gnus-mime-view-part ()
5180 "Interactively choose a viewing method for the MIME part under point."
5182 (gnus-article-check-buffer)
5183 (let ((data (get-text-property (point) 'gnus-data)))
5185 (setq gnus-article-mime-handles
5187 gnus-article-mime-handles (setq data (copy-sequence data))))
5188 (mm-interactively-view-part data))))
5190 (defun gnus-mime-view-part-as-type-internal ()
5191 (gnus-article-check-buffer)
5192 (let* ((handle (get-text-property (point) 'gnus-data))
5194 ;; Content-Type: foo/bar; name=...
5195 (mail-content-type-get (mm-handle-type handle) 'name)
5196 ;; Content-Disposition: attachment; filename=...
5197 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5198 (def-type (and name (mm-default-file-encoding name))))
5199 (or (and def-type (cons def-type 0))
5201 (equal (mm-handle-media-supertype handle) "text")
5202 '("text/plain" . 0))
5203 '("application/octet-stream" . 0))))
5205 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5206 "Choose a MIME media type, and view the part as such.
5207 If non-nil, PRED is a predicate to use during completion to limit the
5208 available media-types."
5212 (let ((default (gnus-mime-view-part-as-type-internal)))
5213 (gnus-completing-read
5216 (gnus-remove-if-not pred (mailcap-mime-types))
5217 (mailcap-mime-types))
5220 (gnus-article-check-buffer)
5221 (let ((handle (get-text-property (point) 'gnus-data)))
5223 (when (equal (mm-handle-media-type handle) "message/external-body")
5224 (unless (mm-handle-cache handle)
5225 (mm-extern-cache-contents handle))
5226 (setq handle (mm-handle-cache handle)))
5228 (mm-make-handle (mm-handle-buffer handle)
5229 (cons mime-type (cdr (mm-handle-type handle)))
5230 (mm-handle-encoding handle)
5231 (mm-handle-undisplayer handle)
5232 (mm-handle-disposition handle)
5233 (mm-handle-description handle)
5235 (mm-handle-id handle)))
5236 (setq gnus-article-mime-handles
5237 (mm-merge-handles gnus-article-mime-handles handle))
5238 (when (mm-handle-displayed-p handle)
5239 (mm-remove-part handle))
5240 (gnus-mm-display-part handle))))
5242 (defun gnus-mime-copy-part (&optional handle arg)
5243 "Put the MIME part under point into a new buffer.
5244 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5246 (interactive (list nil current-prefix-arg))
5247 (gnus-article-check-buffer)
5249 (setq handle (get-text-property (point) 'gnus-data)))
5251 (let ((filename (mm-handle-filename handle))
5252 contents dont-decode charset coding-system)
5253 (mm-with-unibyte-buffer
5254 (mm-insert-part handle)
5255 (setq contents (or (condition-case nil
5256 (mm-decompress-buffer filename nil 'sig)
5258 (setq dont-decode t)
5261 (setq filename (cond (filename (file-name-nondirectory filename))
5262 (dont-decode "*raw data*")
5267 (unless (setq charset (mail-content-type-get
5268 (mm-handle-type handle) 'charset))
5269 (unless (setq coding-system (mm-with-unibyte-buffer
5271 (mm-find-buffer-file-coding-system)))
5272 (setq charset gnus-newsgroup-charset))))
5274 (setq charset (or (cdr (assq arg
5275 gnus-summary-show-article-charset-alist))
5276 (mm-read-coding-system "Charset: ")))))
5277 (switch-to-buffer (generate-new-buffer filename))
5278 (if (or coding-system
5280 (setq coding-system (mm-charset-to-coding-system
5282 (not (eq coding-system 'ascii))))
5284 (mm-enable-multibyte)
5285 (insert (mm-decode-coding-string contents coding-system))
5286 (setq buffer-file-coding-system
5287 (if (boundp 'last-coding-system-used)
5288 (symbol-value 'last-coding-system-used)
5290 (mm-disable-multibyte)
5292 (setq buffer-file-coding-system mm-binary-coding-system))
5293 ;; We do it this way to make `normal-mode' set the appropriate mode.
5296 (setq buffer-file-name (expand-file-name filename))
5298 (setq buffer-file-name nil))
5299 (goto-char (point-min)))))
5301 (defun gnus-mime-print-part (&optional handle filename)
5302 "Print the MIME part under point."
5303 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5304 (gnus-article-check-buffer)
5305 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5306 (contents (and handle (mm-get-part handle)))
5307 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5308 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5313 (mm-save-part-to-file handle file)
5314 (call-process shell-file-name nil
5315 (generate-new-buffer " *mm*")
5317 shell-command-switch
5319 printer file (mm-handle-type handle))))
5323 (gnus-print-buffer))
5324 (ps-despool filename)))))
5326 (defun gnus-mime-inline-part (&optional handle arg)
5327 "Insert the MIME part under point into the current buffer.
5328 Compressed files like .gz and .bz2 are decompressed."
5329 (interactive (list nil current-prefix-arg))
5330 (gnus-article-check-buffer)
5331 (let* ((inhibit-read-only t)
5333 (btn ;; position where the MIME button exists
5335 (if (eq handle (get-text-property b 'gnus-data))
5338 (or (text-property-any (point) (point-max) 'gnus-data handle)
5339 (text-property-any (point-min) (point) 'gnus-data handle)))
5340 (setq handle (get-text-property b 'gnus-data))
5346 (setq start (next-single-property-change btn 'gnus-data
5348 btn (previous-single-property-change start
5351 (if (and (not arg) (mm-handle-undisplayer handle))
5352 (mm-remove-part handle)
5356 (if (mm-handle-undisplayer handle)
5357 (mm-remove-part handle)))
5358 ((mm-handle-undisplayer handle)
5359 (mm-remove-part handle)))
5362 ;; This is a header button.
5364 (mm-display-inline handle))
5365 ;; Toggle the button appearance between `[button]...' and `[button]'.
5367 (let ((displayed-p (mm-handle-displayed-p handle)))
5368 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5370 (if (featurep 'emacs)
5373 (next-single-property-change (point) 'gnus-data nil (point-max)))
5374 (let* ((end (next-single-property-change (point) 'gnus-data))
5375 (annots (annotations-at (or end (point-max)))))
5376 (delete-region (point)
5378 (if annots (1+ end) end)
5380 (dolist (annot annots)
5381 (set-extent-endpoints annot (point) (point)))))
5382 (setq start (point))
5383 (if (search-backward "\n\n" nil t)
5386 (unless (or displayed-p (eolp))
5387 ;; Add extra newline.
5388 (insert (propertize (buffer-substring (1- start) start)
5389 'gnus-undeletable t))))
5390 ;; We're in the article header.
5392 (dolist (ovl (gnus-overlays-in btn (point)))
5393 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5394 (gnus-overlay-put ovl 'face nil))
5396 (message-narrow-to-field)
5397 (let ((gnus-treatment-function-alist
5398 '((gnus-treat-highlight-headers
5399 gnus-article-highlight-headers))))
5400 (gnus-treat-article 'head)))))
5403 (defun gnus-mime-set-charset-parameters (handle charset)
5404 "Set CHARSET to parameters in HANDLE.
5405 CHARSET may either be a string or a symbol."
5406 (unless (stringp charset)
5407 (setq charset (symbol-name charset)))
5408 (if (stringp (car handle))
5409 (dolist (h (cdr handle))
5410 (gnus-mime-set-charset-parameters h charset))
5411 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5412 "message/external-body")
5414 (unless (mm-handle-cache handle)
5415 (mm-extern-cache-contents handle))
5416 (mm-handle-cache handle))
5418 (param (assq 'charset (cdr type))))
5420 (setcdr param charset)
5421 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5423 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5424 "Insert the MIME part under point into the current buffer using the
5426 (interactive (list nil current-prefix-arg))
5427 (gnus-article-check-buffer)
5428 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5429 (fun (get-text-property (point) 'gnus-callback))
5430 (gnus-newsgroup-ignored-charsets 'gnus-all)
5431 charset form preferred parts)
5438 gnus-summary-show-article-charset-alist))
5439 (mm-read-coding-system "Charset: "))))
5440 (if (mm-handle-undisplayer handle)
5441 (mm-remove-part handle)))
5442 (gnus-mime-set-charset-parameters handle charset)
5443 (when (and (consp (setq form (cdr-safe fun)))
5444 (setq form (ignore-errors
5445 (assq 'gnus-mime-display-alternative form)))
5446 (setq preferred (caddr form))
5448 (when (eq (car preferred) 'quote)
5449 (setq preferred (cadr preferred)))
5450 (not (equal preferred
5451 (get-text-property (point) 'gnus-data))))
5452 (setq parts (get-text-property (point) 'gnus-part))
5453 (setq parts (cdr (assq parts
5454 gnus-article-mime-handle-alist)))
5455 (equal (mm-handle-media-type parts) "multipart/alternative")
5456 (setq parts (reverse (cdr parts))))
5458 (list 'quote (or (cadr (member preferred parts))
5460 (funcall fun handle)))))
5462 (defun gnus-mime-view-part-externally (&optional handle)
5463 "View the MIME part under point with an external viewer."
5465 (gnus-article-check-buffer)
5466 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5467 (mm-inlined-types nil)
5468 (mail-parse-charset gnus-newsgroup-charset)
5469 (mail-parse-ignored-charsets
5470 (with-current-buffer gnus-summary-buffer
5471 gnus-newsgroup-ignored-charsets))
5472 (type (mm-handle-media-type handle))
5473 (method (mailcap-mime-info type))
5474 (mm-enable-external t))
5475 (if (not (stringp method))
5476 (gnus-mime-view-part-as-type
5477 nil (lambda (type) (stringp (mailcap-mime-info type))))
5479 (mm-display-part handle nil t)))))
5481 (defun gnus-mime-view-part-internally (&optional handle)
5482 "View the MIME part under point with an internal viewer.
5483 If no internal viewer is available, use an external viewer."
5485 (gnus-article-check-buffer)
5486 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5487 (mm-inlined-types '(".*"))
5488 (mm-inline-large-images t)
5489 (mail-parse-charset gnus-newsgroup-charset)
5490 (mail-parse-ignored-charsets
5491 (with-current-buffer gnus-summary-buffer
5492 gnus-newsgroup-ignored-charsets))
5493 (inhibit-read-only t))
5494 (if (not (mm-inlinable-p handle))
5495 (gnus-mime-view-part-as-type
5496 nil (lambda (type) (mm-inlinable-p handle type)))
5498 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5500 (defun gnus-mime-action-on-part (&optional action)
5501 "Do something with the MIME attachment at \(point\)."
5503 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5504 (gnus-article-check-buffer)
5505 (let ((action-pair (assoc action gnus-mime-action-alist)))
5507 (funcall (cdr action-pair)))))
5509 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5510 "Call FUNCTION on MIME part N.
5511 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5512 If INTERACTIVE, call FUNCTION interactively."
5514 ;; Check whether the article is displayed.
5515 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5516 (setq window (get-buffer-window gnus-article-buffer t))
5517 (frame-visible-p (setq frame (window-frame window))))
5518 (error "No article is displayed"))
5519 (with-current-buffer gnus-article-buffer
5520 ;; Check whether the article displays the right contents.
5521 (unless (with-current-buffer gnus-summary-buffer
5522 (eq gnus-current-article (gnus-summary-article-number)))
5523 (error "You should select the right article first"))
5525 (setq n (prefix-numeric-value n))
5527 (setq n (or (get-text-property pt 'gnus-part)
5529 (get-text-property (1- pt) 'gnus-part))
5530 (get-text-property (prog2
5536 (or (and (setq pt (previous-single-property-change
5539 (next-single-property-change (point) 'gnus-part)
5543 ;; Check whether the specified part exists.
5544 (when (> n (length gnus-article-mime-handle-alist))
5545 (error "No such part")))
5548 ;; To select the window is needed so that the cursor
5549 ;; might be visible on the MIME button.
5550 (select-window (prog1
5552 (setq window (selected-window))
5553 ;; Article may be displayed in the other frame.
5554 (gnus-select-frame-set-input-focus
5557 (setq frame (selected-frame))))))
5558 (when (gnus-article-goto-part n)
5559 ;; We point the cursor and the arrow at the MIME button
5560 ;; when the `function' prompt the user for something.
5561 (unless (and (pos-visible-in-window-p)
5562 (> (count-lines (point) (window-end))
5563 (/ (1- (window-height)) 3)))
5564 (recenter (/ (1- (window-height)) 3)))
5565 (let ((cursor-in-non-selected-windows t)
5566 (overlay-arrow-string "=>")
5567 (overlay-arrow-position (point-marker)))
5570 ((and no-handle interactive)
5571 (call-interactively function))
5576 function (get-text-property (point) 'gnus-data)))
5579 (get-text-property (point) 'gnus-data))))
5580 (set-marker overlay-arrow-position nil)
5581 (unless gnus-auto-select-part
5582 (gnus-select-frame-set-input-focus frame)
5583 (select-window window))))
5585 (if gnus-inhibit-mime-unbuttonizing
5586 ;; This is the default though the program shouldn't reach here.
5587 (error "No such part")
5588 ;; The part which doesn't have the MIME button is selected.
5589 ;; So, we display all the buttons and redo it.
5590 (let ((gnus-inhibit-mime-unbuttonizing t))
5591 (gnus-summary-show-article)
5592 (gnus-article-part-wrapper n function no-handle))))))
5594 (defun gnus-article-pipe-part (n)
5595 "Pipe MIME part N, which is the numerical prefix."
5597 (gnus-article-part-wrapper n 'mm-pipe-part))
5599 (defun gnus-article-save-part (n)
5600 "Save MIME part N, which is the numerical prefix."
5602 (gnus-article-part-wrapper n 'mm-save-part))
5604 (defun gnus-article-interactively-view-part (n)
5605 "View MIME part N interactively, which is the numerical prefix."
5607 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5609 (defun gnus-article-copy-part (n)
5610 "Copy MIME part N, which is the numerical prefix."
5612 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5614 (defun gnus-article-view-part-as-charset (n)
5615 "View MIME part N using a specified charset.
5616 N is the numerical prefix."
5618 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5620 (defun gnus-article-view-part-externally (n)
5621 "View MIME part N externally, which is the numerical prefix."
5623 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5625 (defun gnus-article-inline-part (n)
5626 "Inline MIME part N, which is the numerical prefix."
5628 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5630 (defun gnus-article-save-part-and-strip (n)
5631 "Save MIME part N and replace it with an external body.
5632 N is the numerical prefix."
5634 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5636 (defun gnus-article-replace-part (n)
5637 "Replace MIME part N with an external body.
5638 N is the numerical prefix."
5640 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5642 (defun gnus-article-delete-part (n)
5643 "Delete MIME part N and add some information about the removed part.
5644 N is the numerical prefix."
5646 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5648 (defun gnus-article-view-part-as-type (n)
5649 "Choose a MIME media type, and view part N as such.
5650 N is the numerical prefix."
5652 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5654 (defun gnus-article-mime-match-handle-first (condition)
5657 (dolist (ihandle gnus-article-mime-handle-alist)
5659 ((functionp condition)
5660 (funcall condition (cdr ihandle)))
5661 ((eq condition 'undisplayed)
5662 (not (or (mm-handle-undisplayer (cdr ihandle))
5663 (equal (mm-handle-media-type (cdr ihandle))
5664 "multipart/alternative"))))
5665 ((eq condition 'undisplayed-alternative)
5666 (not (mm-handle-undisplayer (cdr ihandle))))
5668 (gnus-article-goto-part (car ihandle))
5669 (or (not n) (< (car ihandle) n)))
5670 (setq n (car ihandle))))
5674 (defun gnus-article-view-part (&optional n)
5675 "View MIME part N, which is the numerical prefix.
5676 If the part is already shown, hide the part. If N is nil, view
5679 (with-current-buffer gnus-article-buffer
5680 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5681 gnus-article-mime-match-handle-function)))
5682 (when (> n (length gnus-article-mime-handle-alist))
5683 (error "No such part"))
5684 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5685 (when (gnus-article-goto-part n)
5686 (if (equal (car handle) "multipart/alternative")
5688 (beginning-of-line) ;; Make it toggle subparts
5689 (gnus-article-press-button))
5690 (when (eq (gnus-mm-display-part handle) 'internal)
5691 (gnus-set-window-start)))))))
5693 (defsubst gnus-article-mime-total-parts ()
5694 (if (bufferp (car gnus-article-mime-handles))
5696 (1- (length gnus-article-mime-handles))))
5698 (defun gnus-mm-display-part (handle)
5699 "Display HANDLE and fix MIME button."
5700 (let ((id (get-text-property (point) 'gnus-part))
5702 (inhibit-read-only t)
5703 (window (selected-window))
5704 (mail-parse-charset gnus-newsgroup-charset)
5705 (mail-parse-ignored-charsets
5706 (if (gnus-buffer-live-p gnus-summary-buffer)
5707 (with-current-buffer gnus-summary-buffer
5708 gnus-newsgroup-ignored-charsets)
5713 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5717 (setq start (next-single-property-change point 'gnus-data
5719 point (previous-single-property-change start 'gnus-data))
5720 (if (mm-handle-displayed-p handle)
5721 ;; This will remove the part.
5722 (setq retval (mm-display-part handle))
5723 (let ((part (or (and (mm-inlinable-p handle)
5724 (mm-inlined-p handle)
5727 (gnus-bind-safe-url-regexp
5728 (setq retval (mm-display-part handle)))
5729 (unless (zerop (buffer-size))
5730 (buffer-string))))))
5733 ;; This is a header button.
5735 (cond ((stringp part)
5737 (narrow-to-region (point)
5740 (unless (bolp) (insert "\n"))
5742 (gnus-treat-article nil id
5743 (gnus-article-mime-total-parts)
5744 (mm-handle-media-type handle))
5745 (mm-handle-set-undisplayer
5748 (let ((inhibit-read-only t))
5749 (delete-region ,(copy-marker (point-min) t)
5750 ,(point-max-marker)))))))
5752 (mm-display-inline handle))))))
5754 ;; Toggle the button appearance between `[button]...' and `[button]'.
5755 (let ((displayed-p (mm-handle-displayed-p handle)))
5756 (gnus-insert-mime-button handle id (list displayed-p))
5757 (if (featurep 'emacs)
5760 (next-single-property-change (point) 'gnus-data nil (point-max)))
5761 (let* ((end (next-single-property-change (point) 'gnus-data))
5762 (annots (annotations-at (or end (point-max)))))
5763 (delete-region (point)
5765 (if annots (1+ end) end)
5767 (dolist (annot annots)
5768 (set-extent-endpoints annot (point) (point)))))
5769 (setq start (point))
5770 (if (search-backward "\n\n" nil t)
5773 (unless (or displayed-p (eolp))
5774 ;; Add extra newline.
5775 (insert (propertize (buffer-substring (1- start) start)
5776 'gnus-undeletable t))))
5777 ;; We're in the article header.
5779 (dolist (ovl (gnus-overlays-in point (point)))
5780 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5781 (gnus-overlay-put ovl 'face nil))
5783 (message-narrow-to-field)
5784 (let ((gnus-treatment-function-alist
5785 '((gnus-treat-highlight-headers
5786 gnus-article-highlight-headers))))
5787 (gnus-treat-article 'head)))))
5789 (if (window-live-p window)
5790 (select-window window)))
5793 (defun gnus-article-goto-part (n)
5794 "Go to MIME part N."
5795 (when gnus-break-pages
5799 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5800 ;; There may be header buttons.
5801 (text-property-any (point-min) (point) 'gnus-part n)))
5802 part handle end next handles)
5805 (if (setq handle (get-text-property start 'gnus-data))
5807 ;; Go to the displayed subpart, assuming this is
5808 ;; multipart/alternative.
5811 (while (and (not handle)
5814 (setq next (text-property-not-all part end
5817 handle (get-text-property part 'gnus-data))
5818 (push (cons handle part) handles)
5819 (unless (mm-handle-displayed-p handle)
5821 part (text-property-any part end 'gnus-data nil))))
5823 ;; No subpart is displayed, so we find preferred one.
5825 (cdr (assq (mm-preferred-alternative
5826 (nreverse (mapcar 'car handles)))
5829 (goto-char (1+ part))
5831 (when gnus-break-pages
5832 (gnus-narrow-to-page))))
5834 (defun gnus-insert-mime-button (handle id &optional displayed)
5835 (let ((gnus-tmp-name
5836 (or (mm-handle-filename handle)
5837 (mail-content-type-get (mm-handle-type handle) 'url)
5840 (gnus-tmp-type (mm-handle-media-type handle))
5841 (gnus-tmp-description (or (mm-handle-description handle) ""))
5843 (if (if displayed (car displayed)
5844 (mm-handle-displayed-p handle))
5846 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5848 gnus-tmp-type-long b e)
5849 (when (string-match ".*/" gnus-tmp-name)
5850 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5851 (setq gnus-tmp-type-long (concat gnus-tmp-type
5852 (and (not (equal gnus-tmp-name ""))
5853 (concat "; " gnus-tmp-name))))
5854 (unless (equal gnus-tmp-description "")
5855 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5858 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5859 `(keymap ,gnus-mime-button-map
5860 gnus-callback gnus-mm-display-part
5861 gnus-part ,gnus-tmp-id
5862 article-type annotation
5866 ;; Exclude a newline.
5869 (when gnus-article-button-face
5870 (gnus-overlay-put (gnus-make-overlay b e nil t)
5871 'face gnus-article-button-face))
5872 (widget-convert-button
5875 :action 'gnus-widget-press-button
5876 :button-keymap gnus-mime-button-map
5879 ;; Needed to properly clear the message due to a bug in
5880 ;; wid-edit (XEmacs only).
5881 (if (boundp 'help-echo-owns-message)
5882 (setq help-echo-owns-message t))
5884 "%S: %s the MIME part; %S: more options"
5885 (aref gnus-mouse-2 0)
5886 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5888 (aref gnus-down-mouse-3 0))))))
5890 (defun gnus-widget-press-button (elems _el)
5891 (goto-char (widget-get elems :from))
5892 (gnus-article-press-button))
5894 (defvar gnus-displaying-mime nil)
5896 (defun gnus-display-mime (&optional ihandles)
5897 "Display the MIME parts."
5899 (save-selected-window
5900 (let ((window (get-buffer-window gnus-article-buffer))
5903 (select-window window)
5904 ;; We have to do this since selecting the window
5905 ;; may change the point. So we set the window point.
5906 (set-window-point window point)))
5907 (let ((handles ihandles)
5908 (inhibit-read-only t))
5910 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5911 (when gnus-article-emulate-mime
5912 (mm-uu-dissect-text-parts handles)))
5913 (gnus-article-emulate-mime
5914 (setq handles (mm-uu-dissect))))
5915 (when (and (not ihandles)
5916 (not gnus-displaying-mime))
5917 ;; Top-level call; we clean up.
5918 (when gnus-article-mime-handles
5919 (mm-destroy-parts gnus-article-mime-handles)
5920 (setq gnus-article-mime-handle-alist nil));; A trick.
5921 (setq gnus-article-mime-handles handles)
5922 ;; We allow users to glean info from the handles.
5923 (when gnus-article-mime-part-function
5924 (gnus-mime-part-function handles)))
5926 (or (not (stringp (car handles)))
5929 (when (and (not ihandles)
5930 (not gnus-displaying-mime))
5931 ;; Clean up for mime parts.
5933 (delete-region (point) (point-max)))
5934 (let ((gnus-displaying-mime t))
5935 (gnus-mime-display-part handles)))
5938 (narrow-to-region (point) (point-max))
5939 (gnus-treat-article nil 1 1 "text/plain")
5942 ;; Highlight the headers.
5946 (narrow-to-region (point-min) (point))
5947 (gnus-article-save-original-date
5948 (gnus-treat-article 'head)))))))
5949 ;; Cope with broken MIME messages.
5950 (goto-char (point-max))
5954 (defcustom gnus-mime-display-multipart-as-mixed nil
5955 "Display \"multipart\" parts as \"multipart/mixed\".
5957 If t, it overrides nil values of
5958 `gnus-mime-display-multipart-alternative-as-mixed' and
5959 `gnus-mime-display-multipart-related-as-mixed'."
5960 :group 'gnus-article-mime
5963 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5964 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5966 :group 'gnus-article-mime
5969 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5970 "Display \"multipart/related\" parts as \"multipart/mixed\".
5972 If displaying \"text/html\" is discouraged \(see
5973 `mm-discouraged-alternatives'\) images or other material inside a
5974 \"multipart/related\" part might be overlooked when this variable is nil."
5976 :group 'gnus-article-mime
5979 (defcustom gnus-mime-display-attachment-buttons-in-header t
5980 "Add attachment buttons in the end of the header of an article.
5981 Since MIME attachments tend to be put at the end of an article, we may
5982 overlook them if there is a huge body. This option offers you a copy
5983 of all non-inlinable MIME parts as buttons shown in front of an article.
5984 If nil, don't show those extra buttons."
5986 :group 'gnus-article-mime
5989 (defun gnus-mime-display-part (handle)
5991 ;; Maybe a broken MIME message.
5994 ((not (stringp (car handle)))
5995 (gnus-mime-display-single handle))
5996 ;; User-defined multipart
5997 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5998 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
6000 ;; multipart/alternative
6001 ((and (equal (car handle) "multipart/alternative")
6002 (not (or gnus-mime-display-multipart-as-mixed
6003 gnus-mime-display-multipart-alternative-as-mixed)))
6004 (let ((id (1+ (length gnus-article-mime-handle-alist))))
6005 (push (cons id handle) gnus-article-mime-handle-alist)
6006 (gnus-mime-display-alternative (cdr handle) nil nil id)))
6007 ;; multipart/related
6008 ((and (equal (car handle) "multipart/related")
6009 (not (or gnus-mime-display-multipart-as-mixed
6010 gnus-mime-display-multipart-related-as-mixed)))
6011 (gnus-mime-display-part (cadr handle)))
6012 ((equal (car handle) "multipart/signed")
6013 (gnus-add-wash-type 'signed)
6014 (gnus-mime-display-security handle))
6015 ((equal (car handle) "multipart/encrypted")
6016 (gnus-add-wash-type 'encrypted)
6017 (gnus-mime-display-security handle))
6018 ;; Other multiparts are handled like multipart/mixed.
6020 (gnus-mime-display-mixed (cdr handle)))))
6022 (defun gnus-mime-part-function (handles)
6023 (if (stringp (car handles))
6024 (mapcar 'gnus-mime-part-function (cdr handles))
6025 (funcall gnus-article-mime-part-function handles)))
6027 (defun gnus-mime-display-mixed (handles)
6028 (mapcar 'gnus-mime-display-part handles))
6030 (defun gnus-mime-display-single (handle)
6031 (let ((type (mm-handle-media-type handle))
6032 (ignored gnus-ignored-mime-types)
6038 (when (string-match (pop ignored) type)
6039 (throw 'ignored nil)))
6040 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6041 (with-current-buffer gnus-summary-buffer
6042 gnus-inhibit-images)
6043 gnus-inhibit-images)
6044 (string-match "\\`image/" type)))
6045 (setq not-attachment
6046 (and (not (mm-inline-override-p handle))
6047 (or (not (mm-handle-disposition handle))
6048 (equal (car (mm-handle-disposition handle))
6050 (mm-attachment-override-p handle))))
6051 (mm-automatic-display-p handle)
6053 (mm-inlinable-p handle)
6054 (mm-inlined-p handle))
6055 (mm-automatic-external-display-p type)))
6057 (when (equal (mm-handle-media-supertype handle) "text")
6059 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6062 (setq id (1+ (length gnus-article-mime-handle-alist)))
6063 (push (cons id handle) gnus-article-mime-handle-alist))
6065 (equal (mm-handle-media-supertype handle) "message"))
6068 (cond ((not (bolp)) 2)
6069 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6071 (when (or (not display)
6072 (not (gnus-unbuttonized-mime-type-p type))
6073 (eq id gnus-mime-buttonized-part-id))
6074 (gnus-insert-mime-button
6075 handle id (list (or display (and not-attachment text)))))
6079 (let ((mail-parse-charset gnus-newsgroup-charset)
6080 (mail-parse-ignored-charsets
6081 (save-excursion (condition-case ()
6082 (set-buffer gnus-summary-buffer)
6084 gnus-newsgroup-ignored-charsets)))
6085 (gnus-bind-safe-url-regexp (mm-display-part handle t))))
6086 ((and text not-attachment)
6087 (mm-display-inline handle)))
6088 (goto-char (point-max))
6089 (if (string-match "\\`image/" type)
6090 (gnus-article-insert-newline)
6092 (= (skip-chars-backward "\n") -1)
6094 (gnus-article-insert-newline)
6095 (put-text-property (point) (point-max) 'gnus-undeletable t))
6096 (goto-char (point-max)))
6100 (narrow-to-region beg (point))
6101 (if (eq handle gnus-article-mime-handles)
6102 ;; The format=flowed case.
6103 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6104 ;; Don't count signature parts that are never displayed.
6105 ;; The part number should be re-calculated supposing this
6106 ;; might be a message/rfc822 part.
6108 (dolist (part gnus-article-mime-handles)
6109 (unless (or (stringp part)
6110 (equal (car (mm-handle-type part))
6111 "application/pgp-signature"))
6112 (push part handles)))
6114 nil (length (memq handle handles)) (length handles)
6115 (mm-handle-media-type handle)))))))))))
6117 (defun gnus-unbuttonized-mime-type-p (type)
6118 "Say whether TYPE is to be unbuttonized."
6119 (unless gnus-inhibit-mime-unbuttonizing
6121 (let ((types gnus-unbuttonized-mime-types))
6123 (when (string-match (pop types) type)
6124 (throw 'found t)))))
6126 (let ((types gnus-buttonized-mime-types))
6128 (when (string-match (pop types) type)
6129 (throw 'found t)))))))))
6131 (defun gnus-article-insert-newline ()
6132 "Insert a newline, but mark it as undeletable."
6133 (gnus-put-text-property
6134 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6136 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6137 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6140 handle (inhibit-read-only t) from begend not-pref)
6141 (save-window-excursion
6144 (narrow-to-region (car ibegend)
6147 (goto-char (car ibegend))
6150 (delete-region (point-min) (point-max))
6151 (mm-remove-parts handles))
6152 (setq begend (list (point-marker)))
6154 (unless (setq not-pref (cadr (member preferred ihandles)))
6155 (setq not-pref (car ihandles)))
6158 (not (gnus-unbuttonized-mime-type-p
6159 "multipart/alternative")))
6160 (gnus-add-text-properties
6163 (insert (format "%d. " id))
6167 (unless ,(not ibegend)
6168 (setq gnus-article-mime-handle-alist
6169 ',gnus-article-mime-handle-alist))
6170 (gnus-mime-display-alternative
6171 ',ihandles ',not-pref ',begend ,id))
6172 keymap ,gnus-mime-button-map
6173 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6174 face ,gnus-article-button-face
6176 article-type multipart
6178 (widget-convert-button 'link from (point)
6179 :action 'gnus-widget-press-button
6180 :button-keymap gnus-widget-button-keymap)
6182 (while (setq handle (pop handles))
6183 (gnus-add-text-properties
6186 (insert (format "(%c) %-18s"
6187 (if (equal handle preferred) ?* ? )
6188 (mm-handle-media-type handle)))
6192 (unless ,(not ibegend)
6193 (setq gnus-article-mime-handle-alist
6194 ',gnus-article-mime-handle-alist))
6195 (gnus-mime-display-alternative
6196 ',ihandles ',handle ',begend ,id))
6197 keymap ,gnus-mime-button-map
6198 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6199 face ,gnus-article-button-face
6203 (widget-convert-button 'link from (point)
6204 :action 'gnus-widget-press-button
6205 :button-keymap gnus-widget-button-keymap)
6209 (if (stringp (car preferred))
6210 (gnus-display-mime preferred)
6211 (let ((mail-parse-charset gnus-newsgroup-charset)
6212 (mail-parse-ignored-charsets
6213 (with-current-buffer gnus-summary-buffer
6214 gnus-newsgroup-ignored-charsets)))
6215 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6219 (narrow-to-region (car begend) (point-max))
6221 nil (length gnus-article-mime-handle-alist)
6222 (gnus-article-mime-total-parts)
6223 (mm-handle-media-type preferred))))))
6224 (goto-char (point-max))
6225 (setcdr begend (point-marker)))))
6228 ;; Redraw attachment buttons in the header.
6229 (when gnus-mime-display-attachment-buttons-in-header
6230 (gnus-mime-buttonize-attachments-in-header)))
6232 (defconst gnus-article-wash-status-strings
6233 (let ((alist '((cite "c" "Possible hidden citation text"
6234 " " "All citation text visible")
6235 (headers "h" "Hidden headers"
6236 " " "All headers visible.")
6237 (pgp "p" "Encrypted or signed message status hidden"
6238 " " "No hidden encryption nor digital signature status")
6239 (signature "s" "Signature has been hidden"
6240 " " "Signature is visible")
6241 (overstrike "o" "Overstrike (^H) characters applied"
6242 " " "No overstrike characters applied")
6243 (emphasis "e" "/*_Emphasis_*/ characters applied"
6244 " " "No /*_emphasis_*/ characters applied")))
6246 (dolist (entry alist result)
6247 (let ((key (nth 0 entry))
6248 (on (copy-sequence (nth 1 entry)))
6249 (on-help (nth 2 entry))
6250 (off (copy-sequence (nth 3 entry)))
6251 (off-help (nth 4 entry)))
6252 (put-text-property 0 1 'help-echo on-help on)
6253 (put-text-property 0 1 'help-echo off-help off)
6254 (push (list key on off) result))))
6255 "Alist of strings describing wash status in the mode line.
6256 Each entry has the form (KEY ON OF), where the KEY is a symbol
6257 representing the particular washing function, ON is the string to use
6258 in the article mode line when the washing function is active, and OFF
6259 is the string to use when it is inactive.")
6261 (defun gnus-article-wash-status-entry (key value)
6262 (let ((entry (assoc key gnus-article-wash-status-strings)))
6263 (if value (nth 1 entry) (nth 2 entry))))
6265 (defun gnus-article-wash-status ()
6266 "Return a string which display status of article washing."
6267 (with-current-buffer gnus-article-buffer
6268 (let ((cite (memq 'cite gnus-article-wash-types))
6269 (headers (memq 'headers gnus-article-wash-types))
6270 (boring (memq 'boring-headers gnus-article-wash-types))
6271 (pgp (memq 'pgp gnus-article-wash-types))
6272 (pem (memq 'pem gnus-article-wash-types))
6273 (signed (memq 'signed gnus-article-wash-types))
6274 (encrypted (memq 'encrypted gnus-article-wash-types))
6275 (signature (memq 'signature gnus-article-wash-types))
6276 (overstrike (memq 'overstrike gnus-article-wash-types))
6277 (emphasis (memq 'emphasis gnus-article-wash-types)))
6279 (gnus-article-wash-status-entry 'cite cite)
6280 (gnus-article-wash-status-entry 'headers (or headers boring))
6281 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6282 (gnus-article-wash-status-entry 'signature signature)
6283 (gnus-article-wash-status-entry 'overstrike overstrike)
6284 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6286 (defun gnus-add-wash-type (type)
6287 "Add a washing of TYPE to the current status."
6288 (add-to-list 'gnus-article-wash-types type))
6290 (defun gnus-delete-wash-type (type)
6291 "Add a washing of TYPE to the current status."
6292 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6294 (defun gnus-add-image (category image)
6295 "Add IMAGE of CATEGORY to the list of displayed images."
6296 (let ((entry (assq category gnus-article-image-alist)))
6298 (setq entry (list category))
6299 (push entry gnus-article-image-alist))
6300 (nconc entry (list image))))
6302 (defun gnus-delete-images (category)
6303 "Delete all images in CATEGORY."
6304 (let ((entry (assq category gnus-article-image-alist)))
6305 (dolist (image (cdr entry))
6306 (gnus-remove-image image category))
6307 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6308 (gnus-delete-wash-type category)))
6310 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6312 (defun gnus-article-maybe-hide-headers ()
6313 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6314 Provided for backwards compatibility."
6315 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6316 (not (with-current-buffer gnus-summary-buffer
6317 gnus-have-all-headers)))
6318 (not gnus-inhibit-hiding))
6319 (gnus-article-hide-headers)))
6321 (declare-function shr-put-image "shr" (data alt &optional flags))
6323 (defun gnus-shr-put-image (data alt &optional flags)
6324 "Put image DATA with a string ALT. Enable image to be deleted."
6325 (let ((image (if flags
6326 (shr-put-image data (propertize (or alt "*")
6327 'gnus-image-category 'shr)
6329 ;; Old `shr-put-image' doesn't take the optional `flags'
6331 (shr-put-image data (propertize (or alt "*")
6332 'gnus-image-category 'shr)))))
6334 (gnus-add-image 'shr image))))
6336 (defun gnus-article-mime-handles (&optional alist id all)
6338 (let ((i 1) newid flat)
6339 (dolist (handle alist flat)
6340 (setq newid (append id (list i))
6342 (if (stringp (car handle))
6343 (setq flat (nconc flat (gnus-article-mime-handles
6344 (cdr handle) newid all)))
6345 (delq (rassq handle all) all)
6346 (setq flat (nconc flat (list (cons newid handle)))))))
6347 (let ((flat (list nil)))
6348 ;; Assume that elements of `gnus-article-mime-handle-alist'
6349 ;; are in the decreasing order, but unnumbered subsidiaries
6350 ;; in each element are in the increasing order.
6351 (dolist (handle (reverse gnus-article-mime-handle-alist))
6352 (if (stringp (cadr handle))
6353 (setq flat (nconc flat (gnus-article-mime-handles
6354 (cddr handle) (list (car handle)) flat)))
6355 (delq (rassq (cdr handle) flat) flat)
6356 (setq flat (nconc flat (list (cons (list (car handle))
6358 (setq flat (cdr flat))
6359 (mapc (lambda (handle)
6361 ;; This is a hidden (i.e. unnumbered) handle.
6364 (1+ (caar gnus-article-mime-handle-alist)))
6365 (push handle gnus-article-mime-handle-alist))
6366 (setcar handle (caar handle))))
6370 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6371 "Show attachments as buttons in the end of the header of an article.
6372 This function toggles the display when called interactively. Note that
6373 buttons to be added to the header are only the ones that aren't inlined
6374 in the body. Use `gnus-header-face-alist' to highlight buttons."
6375 (interactive (list t))
6376 (gnus-with-article-buffer
6377 (let ((case-fold-search t) buttons handle type st)
6381 (article-narrow-to-head)
6382 ;; Header buttons exist?
6383 (while (and (not buttons)
6384 (re-search-forward "^attachments?:[\n ]+" nil t))
6385 (when (get-char-property (match-end 0)
6386 'gnus-button-attachment-extra)
6387 (setq buttons (match-beginning 0))))
6390 ;; Delete header buttons.
6391 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6394 (unless (and interactive buttons)
6397 (dolist (button (gnus-article-mime-handles))
6398 (setq handle (cdr button)
6399 type (mm-handle-media-type handle))
6400 (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
6401 (with-current-buffer gnus-summary-buffer
6402 gnus-inhibit-images)
6403 gnus-inhibit-images)
6404 (string-match "\\`image/" type))
6405 (mm-inline-override-p handle)
6406 (and (mm-handle-disposition handle)
6407 (not (equal (car (mm-handle-disposition handle))
6409 (not (mm-attachment-override-p handle)))
6410 (not (mm-automatic-display-p handle))
6411 (not (or (and (mm-inlinable-p handle)
6412 (mm-inlined-p handle))
6413 (mm-automatic-external-display-p type))))
6414 (push button buttons)))
6416 ;; Add header buttons.
6419 (narrow-to-region (point) (point))
6420 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6421 (dolist (button (nreverse buttons))
6424 (mm-handle-set-undisplayer
6425 (setq handle (copy-sequence (cdr button))) nil)
6426 (gnus-insert-mime-button handle (car button))
6427 (skip-chars-backward "\t\n ")
6428 (delete-region (point) (point-max))
6429 (when (> (current-column) (window-width))
6434 (dolist (ovl (gnus-overlays-in (point-min) (point)))
6435 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
6436 (gnus-overlay-put ovl 'face nil))
6437 (let ((gnus-treatment-function-alist
6438 '((gnus-treat-highlight-headers
6439 gnus-article-highlight-headers))))
6440 (gnus-treat-article 'head)))))))))
6444 (defun gnus-output-to-file (file-name)
6445 "Append the current article to a file named FILE-NAME.
6446 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6447 text and used as the value of the coding cookie which is added to the
6448 top of a file. Otherwise, this function saves a raw article without
6450 (let* ((artbuf (current-buffer))
6451 (file-name-coding-system nnmail-pathname-coding-system)
6452 (coding gnus-article-save-coding-system)
6453 (coding-system-for-read (if coding
6454 nil ;; Rely on the coding cookie.
6455 mm-text-coding-system))
6456 (coding-system-for-write (or coding
6457 mm-text-coding-system-for-write
6458 mm-text-coding-system))
6459 (exists (file-exists-p file-name)))
6462 (insert-file-contents file-name)
6463 (goto-char (point-min))
6464 ;; Remove the existing coding cookie.
6465 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6466 (delete-region (match-beginning 0) (match-end 0))))
6467 (goto-char (point-max))
6468 (insert-buffer-substring artbuf)
6469 ;; Append newline at end of the buffer as separator, and then
6471 (goto-char (point-max))
6474 ;; If the coding system is not suitable to encode the text,
6475 ;; ask a user for a proper one.
6476 (when (fboundp 'select-safe-coding-system)
6477 (setq coding (coding-system-base
6478 (save-window-excursion
6479 (select-safe-coding-system (point-min) (point-max)
6481 (setq coding-system-for-write
6482 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6484 (goto-char (point-min))
6485 ;; Add the coding cookie.
6486 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6487 coding-system-for-write)))
6490 (write-region (point-min) (point-max) file-name nil 'no-message)
6491 (message "Appended to %s" file-name))
6492 (write-region (point-min) (point-max) file-name))))
6495 (defun gnus-narrow-to-page (&optional arg)
6496 "Narrow the article buffer to a page.
6497 If given a numerical ARG, move forward ARG pages."
6499 (setq arg (if arg (prefix-numeric-value arg) 0))
6500 (with-current-buffer gnus-article-buffer
6502 ;; Remove any old next/prev buttons.
6503 (when (gnus-visual-p 'page-marker)
6504 (let ((inhibit-read-only t))
6505 (gnus-remove-text-with-property 'gnus-prev)
6506 (gnus-remove-text-with-property 'gnus-next)))
6508 (when (save-excursion
6510 (if (re-search-backward page-delimiter nil 'move (abs arg))
6512 (setq nd (match-beginning 0)
6514 (when (re-search-backward page-delimiter nil t)
6515 (setq st (match-end 0))))
6516 (when (re-search-forward page-delimiter nil t)
6517 (setq nd (match-beginning 0)
6520 (if (re-search-forward page-delimiter nil 'move arg)
6522 (setq st (match-end 0)
6524 (when (re-search-forward page-delimiter nil t)
6525 (setq nd (match-beginning 0))))
6526 (when (re-search-backward page-delimiter nil t)
6527 (setq st (match-end 0)
6530 (when (re-search-backward page-delimiter nil t)
6531 (goto-char (setq st (match-end 0))))
6532 (when (re-search-forward page-delimiter nil t)
6533 (setq nd (match-beginning 0)))
6535 (setq gnus-page-broken t)
6536 (when pt (goto-char pt))
6537 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6538 (when (gnus-visual-p 'page-marker)
6542 (gnus-insert-next-page-button))
6545 (gnus-insert-prev-page-button))))))))
6547 ;; Article mode commands
6549 (defun gnus-article-goto-next-page ()
6550 "Show the next page of the article."
6552 (when (gnus-article-next-page)
6553 (goto-char (point-min))
6554 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6557 (defun gnus-article-goto-prev-page ()
6558 "Show the previous page of the article."
6560 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6561 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6562 (gnus-article-prev-page nil)))
6564 ;; This is cleaner but currently breaks `gnus-pick-mode':
6566 ;; (defun gnus-article-goto-next-page ()
6567 ;; "Show the next page of the article."
6569 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6570 ;; (gnus-summary-next-page)))
6572 ;; (defun gnus-article-goto-prev-page ()
6573 ;; "Show the next page of the article."
6575 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6576 ;; (gnus-summary-prev-page)))
6578 (defun gnus-article-next-page (&optional lines)
6579 "Show the next page of the current article.
6580 If end of article, return non-nil. Otherwise return nil.
6581 Argument LINES specifies lines to be scrolled up."
6583 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6584 (if (and (not (and gnus-article-over-scroll
6585 (> (count-lines (window-start) (point-max))
6586 (if (featurep 'xemacs)
6587 (or lines (1- (window-height)))
6588 (+ (or lines (1- (window-height))) scroll-margin)))))
6591 (and (pos-visible-in-window-p) ;Not continuation line.
6592 (>= (point) (point-max)))))
6593 ;; Nothing in this page.
6594 (if (or (not gnus-page-broken)
6599 (eobp)))) ;Real end-of-buffer?
6601 (when gnus-article-over-scroll
6602 (gnus-article-next-page-1 lines))
6604 (gnus-narrow-to-page 1) ;Go to next page.
6606 ;; More in this page.
6607 (gnus-article-next-page-1 lines)
6610 (defun gnus-article-beginning-of-window ()
6611 "Move point to the beginning of the window.
6612 In Emacs, the point is placed at the line number which `scroll-margin'
6614 (if (featurep 'xemacs)
6615 (move-to-window-line 0)
6616 ;; There is an obscure bug in Emacs that makes it impossible to
6617 ;; scroll past big pictures in the article buffer. Try to fix
6618 ;; this by adding a sanity check by counting the lines visible.
6619 (when (> (count-lines (window-start) (window-end)) 30)
6620 (move-to-window-line
6621 (min (max 0 scroll-margin)
6622 (max 1 (- (window-height)
6623 (if mode-line-format 1 0)
6624 (if header-line-format 1 0)
6627 (defvar scroll-in-place)
6629 (defun gnus-article-next-page-1 (lines)
6631 (let ((scroll-in-place nil)
6632 (auto-window-vscroll nil))
6635 ;; Long lines may cause an end-of-buffer error.
6636 (goto-char (point-max))))
6637 (gnus-article-beginning-of-window))
6639 (defun gnus-article-prev-page (&optional lines)
6640 "Show previous page of current article.
6641 Argument LINES specifies lines to be scrolled down."
6643 (move-to-window-line 0)
6644 (if (and gnus-page-broken
6646 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6648 (gnus-narrow-to-page -1) ;Go to previous page.
6649 (goto-char (point-max))
6650 (recenter (if gnus-article-over-scroll
6652 (max (if (featurep 'xemacs)
6654 (+ lines scroll-margin))
6656 (- (window-height) 2))
6660 (let ((scroll-in-place nil))
6661 (scroll-down lines))
6662 (beginning-of-buffer
6663 (goto-char (point-min))))
6664 (gnus-article-beginning-of-window))))
6666 (defun gnus-article-only-boring-p ()
6667 "Decide whether there is only boring text remaining in the article.
6668 Something \"interesting\" is a word of at least two letters that does
6669 not have a face in `gnus-article-boring-faces'."
6670 (when (and gnus-article-skip-boring
6671 (boundp 'gnus-article-boring-faces)
6672 (symbol-value 'gnus-article-boring-faces))
6674 (let ((inhibit-point-motion-hooks t))
6676 (while (re-search-forward "\\b\\w\\w" nil t)
6678 (when (not (gnus-intersection
6679 (gnus-faces-at (point))
6680 (symbol-value 'gnus-article-boring-faces)))
6681 (throw 'only-boring nil)))
6682 (throw 'only-boring t))))))
6684 (defun gnus-article-refer-article ()
6685 "Read article specified by message-id around point."
6688 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6689 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6690 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6691 (let ((msg-id (concat "<" (match-string 0) ">")))
6692 (set-buffer gnus-summary-buffer)
6693 (gnus-summary-refer-article msg-id))
6694 (error "No references around point"))))
6696 (defun gnus-article-show-summary ()
6697 "Reconfigure windows to show summary buffer."
6699 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6700 (error "There is no summary buffer for this article buffer")
6701 (gnus-article-set-globals)
6702 (gnus-configure-windows 'article)
6703 (gnus-summary-goto-subject gnus-current-article)
6704 (gnus-summary-position-point)))
6706 (defun gnus-article-describe-briefly ()
6707 "Describe article mode commands briefly."
6709 (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
6711 (defun gnus-article-check-buffer ()
6712 "Beep if not in an article buffer."
6713 (unless (derived-mode-p 'gnus-article-mode)
6714 (error "Command invoked outside of a Gnus article buffer")))
6716 (defvar gnus-pick-mode)
6718 (defun gnus-article-read-summary-keys (&optional _arg key not-restore-window)
6719 "Read a summary buffer key sequence and execute it from the article buffer."
6721 (gnus-article-check-buffer)
6723 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6724 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6725 "=" "^" "\M-^" "|"))
6727 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6728 "An" "Ap" [?A (meta return)] [?A delete]))
6732 (with-current-buffer gnus-article-current-summary
6733 (let (gnus-pick-mode)
6734 (setq unread-command-events (nconc unread-command-events
6735 (list (or key last-command-event)))
6736 keys (if (featurep 'xemacs)
6737 (events-to-keys (read-key-sequence nil t))
6738 (read-key-sequence nil t)))))
6743 ((eq (aref keys (1- (length keys))) ?\C-h)
6744 (gnus-article-describe-bindings (substring keys 0 -1)))
6745 ((or (member keys nosaves)
6746 (member keys nosave-but-article)
6747 (member keys nosave-in-article))
6749 (save-window-excursion
6750 (pop-to-buffer gnus-article-current-summary)
6751 ;; We disable the pick minor mode commands.
6752 (let (gnus-pick-mode)
6753 (setq func (key-binding keys t))))
6757 (unless (member keys nosave-in-article)
6758 (set-buffer gnus-article-current-summary))
6759 (when (and (symbolp func)
6760 (get func 'disabled))
6761 (error "Function %s disabled" func))
6762 (call-interactively func)
6763 (setq new-sum-point (point)))
6764 (when (member keys nosave-but-article)
6765 (pop-to-buffer gnus-article-buffer))))
6767 ;; These commands should restore window configuration.
6768 (let ((obuf (current-buffer))
6769 (owin (current-window-configuration))
6770 win func in-buffer selected new-sum-start new-sum-hscroll err)
6771 (cond (not-restore-window
6772 (pop-to-buffer gnus-article-current-summary)
6773 (setq win (selected-window)))
6774 ((setq win (get-buffer-window gnus-article-current-summary))
6775 (select-window win))
6777 (let ((summary-buffer gnus-article-current-summary))
6778 (gnus-configure-windows 'article)
6779 (unless (setq win (get-buffer-window summary-buffer 'visible))
6780 (let ((gnus-buffer-configuration
6781 '((article ((vertical 1.0
6782 (summary 0.25 point)
6784 (gnus-configure-windows 'article))
6785 (setq win (get-buffer-window summary-buffer 'visible)))
6786 (gnus-select-frame-set-input-focus (window-frame win))
6787 (select-window win))))
6788 (setq in-buffer (current-buffer))
6789 ;; We disable the pick minor mode commands.
6790 (setq func (let (gnus-pick-mode)
6791 (key-binding keys t)))
6792 (when (get func 'disabled)
6793 (error "Function %s disabled" func))
6796 (condition-case code
6798 (call-interactively func)
6804 (when (eq win (selected-window))
6805 (setq new-sum-point (point)
6806 new-sum-start (window-start win)
6807 new-sum-hscroll (window-hscroll win)))
6808 (when (or (eq in-buffer (current-buffer))
6809 (when (eq obuf (current-buffer))
6810 (set-buffer in-buffer)
6812 (setq selected (ignore-errors (gnus-summary-select-article)))
6814 (unless not-restore-window
6815 (set-window-configuration owin))
6816 (when (and (eq selected 'old)
6818 (set-window-start (get-buffer-window (current-buffer))
6820 (set-window-point (get-buffer-window (current-buffer))
6821 (if (article-goto-body)
6824 (when (and (not not-restore-window)
6827 (with-current-buffer (window-buffer win)
6828 (derived-mode-p 'gnus-summary-mode)))
6829 (set-window-point win new-sum-point)
6830 (set-window-start win new-sum-start)
6831 (set-window-hscroll win new-sum-hscroll))))
6832 (set-window-configuration owin)
6834 (signal (car err) (cdr err))
6837 (defun gnus-article-read-summary-send-keys ()
6839 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6840 (gnus-article-read-summary-keys)))
6842 (defun gnus-article-describe-key (key)
6843 "Display documentation of the function invoked by KEY.
6844 KEY is a string or a vector."
6845 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6846 (read-key-sequence "Describe key: "))))
6847 (gnus-article-check-buffer)
6848 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6849 gnus-article-read-summary-send-keys))
6850 (with-current-buffer gnus-article-current-summary
6851 (setq unread-command-events
6852 (if (featurep 'xemacs)
6854 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6855 (list 'meta (- x 128))
6858 (let ((cursor-in-echo-area t)
6860 (describe-key (read-key-sequence nil t))))
6861 (describe-key key)))
6863 (defun gnus-article-describe-key-briefly (key &optional insert)
6864 "Display documentation of the function invoked by KEY.
6865 KEY is a string or a vector."
6866 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6867 (read-key-sequence "Describe key: "))
6868 current-prefix-arg))
6869 (gnus-article-check-buffer)
6870 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6871 gnus-article-read-summary-send-keys))
6872 (with-current-buffer gnus-article-current-summary
6873 (setq unread-command-events
6874 (if (featurep 'xemacs)
6876 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6877 (list 'meta (- x 128))
6880 (let ((cursor-in-echo-area t)
6882 (describe-key-briefly (read-key-sequence nil t) insert)))
6883 (describe-key-briefly key insert)))
6885 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6886 (defvar gnus-agent-summary-mode)
6887 (defvar gnus-draft-mode)
6888 (defvar help-xref-stack-item)
6889 (defvar help-xref-following)
6891 (defun gnus-article-describe-bindings (&optional prefix)
6892 "Show a list of all defined keys, and their definitions.
6893 The optional argument PREFIX, if non-nil, should be a key sequence;
6894 then we display only bindings that start with that prefix."
6896 (gnus-article-check-buffer)
6897 (let ((keymap (copy-keymap gnus-article-mode-map))
6898 (map (copy-keymap gnus-article-send-map))
6899 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6901 (define-key keymap "S" map)
6902 (define-key map [t] nil)
6903 (with-current-buffer gnus-article-current-summary
6906 (if (setq parent (keymap-parent gnus-article-mode-map))
6908 (setq parent (copy-keymap parent))
6909 (set-keymap-parent parent (current-local-map)))
6910 (current-local-map)))
6911 (set-keymap-parent map (key-binding "S"))
6912 (let (key def gnus-pick-mode)
6914 (setq key (pop sumkeys))
6915 (cond ((and (vectorp key) (= (length key) 1)
6916 (consp (setq def (aref key 0)))
6917 (numberp (car def)) (numberp (cdr def)))
6918 (when (< (max (car def) (cdr def)) 128)
6922 (nreverse (gnus-uncompress-range def)))
6924 ((setq def (key-binding key))
6925 (unless (eq def 'undefined)
6926 (define-key keymap key def))))))
6927 (when (boundp 'gnus-agent-summary-mode)
6928 (setq agent gnus-agent-summary-mode))
6929 (when (boundp 'gnus-draft-mode)
6930 (setq draft gnus-draft-mode)))
6932 (use-local-map keymap)
6933 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6934 (set (make-local-variable 'gnus-draft-mode) draft)
6935 (describe-bindings prefix))
6936 (let ((item `((lambda (prefix)
6937 (with-current-buffer ,(current-buffer)
6938 (gnus-article-describe-bindings prefix)))
6940 ;; Loading `help-mode' here is necessary if `describe-bindings'
6941 ;; is replaced with something, e.g. `helm-descbinds'.
6942 (require 'help-mode)
6943 (with-current-buffer (let (help-xref-following) (help-buffer))
6944 (setq help-xref-stack-item item)))))
6946 (defun gnus-article-reply-with-original (&optional wide)
6947 "Start composing a reply mail to the current message.
6948 The text in the region will be yanked. If the region isn't active,
6949 the entire article will be yanked."
6951 (let ((article (cdr gnus-article-current))
6953 (if (not (gnus-region-active-p))
6954 (with-current-buffer gnus-summary-buffer
6955 (gnus-summary-reply (list (list article)) wide))
6956 (setq contents (buffer-substring (point) (mark t)))
6957 ;; Deactivate active regions.
6958 (when (and (boundp 'transient-mark-mode)
6959 transient-mark-mode)
6960 (setq mark-active nil))
6961 (with-current-buffer gnus-summary-buffer
6963 (list (list article contents)) wide)))))
6965 (defun gnus-article-wide-reply-with-original ()
6966 "Start composing a wide reply mail to the current message.
6967 The text in the region will be yanked. If the region isn't active,
6968 the entire article will be yanked."
6970 (gnus-article-reply-with-original t))
6972 (defun gnus-article-followup-with-original ()
6973 "Compose a followup to the current article.
6974 The text in the region will be yanked. If the region isn't active,
6975 the entire article will be yanked."
6977 (let ((article (cdr gnus-article-current))
6979 (if (not (gnus-region-active-p))
6980 (with-current-buffer gnus-summary-buffer
6981 (gnus-summary-followup (list (list article))))
6982 (setq contents (buffer-substring (point) (mark t)))
6983 ;; Deactivate active regions.
6984 (when (and (boundp 'transient-mark-mode)
6985 transient-mark-mode)
6986 (setq mark-active nil))
6987 (with-current-buffer gnus-summary-buffer
6988 (gnus-summary-followup
6989 (list (list article contents)))))))
6991 (defun gnus-article-hide (&optional arg force)
6992 "Hide all the gruft in the current article.
6993 This means that signatures, cited text and (some) headers will be
6995 If given a prefix, show the hidden text instead."
6996 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6997 (gnus-article-hide-headers arg)
6998 (gnus-article-hide-list-identifiers arg)
6999 (gnus-article-hide-citation-maybe arg force)
7000 (gnus-article-hide-signature arg))
7002 (defun gnus-check-group-server ()
7003 ;; Make sure the connection to the server is alive.
7004 (unless (gnus-server-opened
7005 (gnus-find-method-for-group gnus-newsgroup-name))
7006 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7007 (gnus-request-group gnus-newsgroup-name t)))
7010 (autoload 'nneething-get-file-name "nneething"))
7012 (defun gnus-request-article-this-buffer (article group)
7013 "Get an article and insert it into this buffer."
7014 (let (do-update-line sparse-header)
7018 (gnus-kill-all-overlays)
7019 (setq group (or group gnus-newsgroup-name))
7021 ;; Using `gnus-request-article' directly will insert the article into
7022 ;; `nntp-server-buffer' - so we'll save some time by not having to
7023 ;; copy it from the server buffer into the article buffer.
7025 ;; We only request an article by message-id when we do not have the
7026 ;; headers for it, so we'll have to get those.
7027 (when (stringp article)
7028 (gnus-read-header article))
7030 ;; If the article number is negative, that means that this article
7031 ;; doesn't belong in this newsgroup (possibly), so we find its
7032 ;; message-id and request it by id instead of number.
7033 (when (and (numberp article)
7035 (get-buffer gnus-summary-buffer)
7036 (gnus-buffer-exists-p gnus-summary-buffer))
7037 (with-current-buffer gnus-summary-buffer
7038 (let ((header (gnus-summary-article-header article)))
7041 ((memq article gnus-newsgroup-sparse)
7042 ;; This is a sparse gap article.
7043 (setq do-update-line article)
7044 (setq article (mail-header-id header))
7045 (setq sparse-header (gnus-read-header article))
7046 (setq gnus-newsgroup-sparse
7047 (delq article gnus-newsgroup-sparse)))
7049 ;; It's a real article.
7050 (setq article (mail-header-id header)))
7052 ;; It is an extracted pseudo-article.
7053 (setq article 'pseudo)
7054 (gnus-request-pseudo-article header))))
7056 (let ((method (gnus-find-method-for-group
7057 gnus-newsgroup-name)))
7058 (when (and (eq (car method) 'nneething)
7060 (let ((dir (nneething-get-file-name
7061 (mail-header-id header))))
7062 (when (and (stringp dir)
7063 (file-directory-p dir))
7064 (setq article 'nneething)
7065 (gnus-group-enter-directory dir))))))))
7068 ;; Refuse to select canceled articles.
7069 ((and (numberp article)
7071 (get-buffer gnus-summary-buffer)
7072 (gnus-buffer-exists-p gnus-summary-buffer)
7073 (eq (cdr (with-current-buffer gnus-summary-buffer
7074 (assq article gnus-newsgroup-reads)))
7075 gnus-canceled-mark))
7077 ;; We first check `gnus-original-article-buffer'.
7078 ((and (get-buffer gnus-original-article-buffer)
7080 (with-current-buffer gnus-original-article-buffer
7081 (and (equal (car gnus-original-article) group)
7082 (eq (cdr gnus-original-article) article))))
7083 ;; `insert-buffer-substring' would incorrectly use the
7084 ;; equivalent of string-make-multibyte which amount to decoding
7085 ;; with locale-coding-system, causing failure of
7086 ;; subsequent decoding.
7087 (insert (mm-string-to-multibyte
7088 (with-current-buffer gnus-original-article-buffer
7089 (buffer-substring (point-min) (point-max)))))
7091 ;; Check the backlog.
7092 ((and gnus-keep-backlog
7093 (gnus-backlog-request-article group article (current-buffer)))
7095 ;; Check asynchronous pre-fetch.
7096 ((gnus-async-request-fetched-article group article (current-buffer))
7097 (gnus-async-prefetch-next group article gnus-summary-buffer)
7098 (when (and (numberp article) gnus-keep-backlog)
7099 (gnus-backlog-enter-article group article (current-buffer)))
7102 ((and gnus-use-cache
7104 (gnus-cache-request-article article group))
7106 ;; Check the agent cache.
7107 ((gnus-agent-request-article article group)
7109 ;; Get the article and put into the article buffer.
7110 ((or (stringp article)
7112 (let ((gnus-override-method gnus-override-method)
7113 (methods (and (stringp article)
7114 (with-current-buffer gnus-summary-buffer
7115 (gnus-refer-article-methods))))
7116 (backend (car (gnus-find-method-for-group
7117 gnus-newsgroup-name)))
7119 (inhibit-read-only t))
7120 (when (and (null gnus-override-method)
7122 (setq gnus-override-method (pop methods)))
7125 (gnus-kill-all-overlays)
7126 (let ((gnus-newsgroup-name group))
7127 (gnus-check-group-server))
7129 ((gnus-request-article article group (current-buffer))
7130 (when (numberp article)
7131 (gnus-async-prefetch-next group article
7132 gnus-summary-buffer)
7133 (when gnus-keep-backlog
7134 (gnus-backlog-enter-article
7135 group article (current-buffer)))
7136 (when (and gnus-agent
7137 (gnus-agent-group-covered-p group))
7138 (gnus-agent-store-article article group)))
7139 (setq result 'article))
7141 (setq gnus-override-method (pop methods)))
7142 ((not (string-match "^400 "
7143 (nnheader-get-report backend)))
7144 ;; If we get 400 server disconnect, reconnect and
7145 ;; retry; otherwise, assume the article has expired.
7146 (setq result 'done))))
7147 (and (eq result 'article) 'article)))
7151 ;; Associate this article with the current summary buffer.
7152 (setq gnus-article-current-summary gnus-summary-buffer)
7154 ;; Take the article from the original article buffer
7155 ;; and place it in the buffer it's supposed to be in.
7156 (when (and (get-buffer gnus-article-buffer)
7157 (equal (buffer-name (current-buffer))
7158 (buffer-name (get-buffer gnus-article-buffer))))
7160 (if (get-buffer gnus-original-article-buffer)
7161 (set-buffer gnus-original-article-buffer)
7162 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7163 (buffer-disable-undo)
7164 (setq major-mode 'gnus-original-article-mode)
7165 (setq buffer-read-only t))
7166 (let ((inhibit-read-only t))
7168 (insert-buffer-substring gnus-article-buffer))
7169 (setq gnus-original-article (cons group article)))
7172 (run-hooks 'gnus-article-decode-hook)
7173 ;; Mark article as decoded or not.
7174 (setq gnus-article-decoded-p gnus-article-decode-hook))
7176 ;; Update sparse articles.
7177 (when (and do-update-line
7178 (or (numberp article)
7180 (let ((buf (current-buffer)))
7181 (set-buffer gnus-summary-buffer)
7182 (gnus-summary-update-article do-update-line sparse-header)
7183 (gnus-summary-goto-subject do-update-line nil t)
7184 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7186 (set-buffer buf))))))
7188 (defun gnus-block-private-groups (group)
7189 (if (or (gnus-news-group-p group)
7190 (gnus-member-of-valid 'global group))
7191 ;; Block nothing in news groups.
7193 ;; Block everything anywhere else.
7196 (defun gnus-blocked-images ()
7197 (if (functionp gnus-blocked-images)
7198 (funcall gnus-blocked-images gnus-newsgroup-name)
7199 gnus-blocked-images))
7205 (defcustom gnus-article-edit-mode-hook nil
7206 "Hook run in article edit mode buffers."
7207 :group 'gnus-article-various
7210 (defvar gnus-article-edit-done-function nil)
7212 (defvar gnus-article-edit-mode-map nil)
7214 ;; Should we be using derived.el for this?
7215 (unless gnus-article-edit-mode-map
7216 (setq gnus-article-edit-mode-map (make-keymap))
7217 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7219 (gnus-define-keys gnus-article-edit-mode-map
7220 "\C-c?" describe-mode
7221 "\C-c\C-c" gnus-article-edit-done
7222 "\C-c\C-k" gnus-article-edit-exit
7223 "\C-c\C-f\C-t" message-goto-to
7224 "\C-c\C-f\C-o" message-goto-from
7225 "\C-c\C-f\C-b" message-goto-bcc
7226 ;;"\C-c\C-f\C-w" message-goto-fcc
7227 "\C-c\C-f\C-c" message-goto-cc
7228 "\C-c\C-f\C-s" message-goto-subject
7229 "\C-c\C-f\C-r" message-goto-reply-to
7230 "\C-c\C-f\C-n" message-goto-newsgroups
7231 "\C-c\C-f\C-d" message-goto-distribution
7232 "\C-c\C-f\C-f" message-goto-followup-to
7233 "\C-c\C-f\C-m" message-goto-mail-followup-to
7234 "\C-c\C-f\C-k" message-goto-keywords
7235 "\C-c\C-f\C-u" message-goto-summary
7236 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7237 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7238 "\C-c\C-b" message-goto-body
7239 "\C-c\C-i" message-goto-signature
7241 "\C-c\C-t" message-insert-to
7242 "\C-c\C-n" message-insert-newsgroups
7243 "\C-c\C-o" message-sort-headers
7244 "\C-c\C-e" message-elide-region
7245 "\C-c\C-v" message-delete-not-region
7246 "\C-c\C-z" message-kill-to-signature
7247 "\M-\r" message-newline-and-reformat
7248 "\C-c\C-a" mml-attach-file
7249 "\C-a" message-beginning-of-line
7251 "\M-;" comment-region)
7253 (gnus-define-keys (gnus-article-edit-wash-map
7254 "\C-c\C-w" gnus-article-edit-mode-map)
7255 "f" gnus-article-edit-full-stops))
7258 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7260 ["Fetch To" message-insert-to t]
7261 ["Fetch Newsgroups" message-insert-newsgroups t]
7263 ["To" message-goto-to t]
7264 ["From" message-goto-from t]
7265 ["Subject" message-goto-subject t]
7266 ["Cc" message-goto-cc t]
7267 ["Reply-To" message-goto-reply-to t]
7268 ["Summary" message-goto-summary t]
7269 ["Keywords" message-goto-keywords t]
7270 ["Newsgroups" message-goto-newsgroups t]
7271 ["Followup-To" message-goto-followup-to t]
7272 ["Mail-Followup-To" message-goto-mail-followup-to t]
7273 ["Distribution" message-goto-distribution t]
7274 ["Body" message-goto-body t]
7275 ["Signature" message-goto-signature t]))
7277 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7278 "Major mode for editing articles.
7279 This is an extended text-mode.
7281 \\{gnus-article-edit-mode-map}"
7282 (make-local-variable 'gnus-article-edit-done-function)
7283 (make-local-variable 'gnus-prev-winconf)
7284 (set (make-local-variable 'font-lock-defaults)
7285 '(message-font-lock-keywords t))
7286 (set (make-local-variable 'mail-header-separator) "")
7287 (set (make-local-variable 'gnus-article-edit-mode) t)
7288 (easy-menu-add message-mode-field-menu message-mode-map)
7290 (setq buffer-read-only nil)
7291 (buffer-enable-undo)
7294 (defun gnus-article-edit (&optional force)
7295 "Edit the current article.
7296 This will have permanent effect only in mail groups.
7297 If FORCE is non-nil, allow editing of articles even in read-only
7300 (when (and (not force)
7301 (gnus-group-read-only-p))
7302 (error "The current newsgroup does not support article editing"))
7303 (gnus-article-date-original)
7304 (gnus-article-edit-article
7306 `(lambda (no-highlight)
7308 (gnus-summary-edit-article-done
7309 ,(or (mail-header-references gnus-current-headers) "")
7310 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7312 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7313 "Start editing the contents of the current article buffer."
7314 (let ((winconf (current-window-configuration)))
7315 (set-buffer gnus-article-buffer)
7316 (let ((message-auto-save-directory
7317 ;; Don't associate the article buffer with a draft file.
7319 (gnus-article-edit-mode))
7320 (funcall start-func)
7321 (set-buffer-modified-p nil)
7322 (gnus-configure-windows 'edit-article)
7323 (setq gnus-article-edit-done-function exit-func)
7324 (setq gnus-prev-winconf winconf)
7326 (gnus-message 6 "C-c C-c to end edits"))))
7328 (defun gnus-article-edit-done (&optional arg)
7329 "Update the article edits and exit."
7331 (let ((func gnus-article-edit-done-function)
7332 (buf (current-buffer))
7333 (start (window-start))
7334 (winconf gnus-prev-winconf))
7335 (widen) ;; Widen it in case that users narrowed the buffer.
7338 ;; The cache and backlog have to be flushed somewhat.
7339 (when gnus-keep-backlog
7340 (gnus-backlog-remove-article
7341 (car gnus-article-current) (cdr gnus-article-current)))
7342 ;; Flush original article as well.
7343 (gnus-flush-original-article-buffer)
7344 (when gnus-use-cache
7345 (gnus-cache-update-article
7346 (car gnus-article-current) (cdr gnus-article-current)))
7347 ;; We remove all text props from the article buffer.
7348 (kill-all-local-variables)
7349 (set-text-properties (point-min) (point-max) nil)
7351 (set-window-configuration winconf)
7353 (set-window-start (get-buffer-window buf) start)
7354 (set-window-point (get-buffer-window buf) (point)))
7355 (gnus-summary-show-article))
7357 (defun gnus-flush-original-article-buffer ()
7358 (when (get-buffer gnus-original-article-buffer)
7359 (with-current-buffer gnus-original-article-buffer
7360 (setq gnus-original-article nil))))
7362 (defun gnus-article-edit-exit ()
7363 "Exit the article editing without updating."
7365 (when (or (not (buffer-modified-p))
7366 (yes-or-no-p "Article modified; kill anyway? "))
7367 (let ((curbuf (current-buffer))
7369 (window-start (window-start)))
7371 (if (gnus-buffer-live-p gnus-original-article-buffer)
7372 (insert-buffer-substring gnus-original-article-buffer))
7373 (let ((winconf gnus-prev-winconf))
7374 (kill-all-local-variables)
7376 (set-window-configuration winconf)
7377 ;; Tippy-toe some to make sure that point remains where it was.
7378 (save-current-buffer
7380 (set-window-start (get-buffer-window (current-buffer)) window-start)
7382 (gnus-summary-show-article)))
7384 (defun gnus-article-edit-full-stops ()
7385 "Interactively repair spacing at end of sentences."
7388 (goto-char (point-min))
7389 (search-forward-regexp "^$" nil t)
7390 (let ((case-fold-search nil))
7391 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7394 ;;; Article highlights
7397 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7399 ;;; Internal Variables:
7401 (defcustom gnus-button-url-regexp
7403 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7404 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7405 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7406 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7407 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7411 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7412 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7413 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7414 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7416 "[" chars punct "]+" "[" chars "]"
7418 (concat ;; XEmacs 21.4 doesn't support POSIX.
7419 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7420 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7422 "Regular expression that matches URLs."
7424 :group 'gnus-article-buttons
7427 (defcustom gnus-button-valid-fqdn-regexp
7428 message-valid-fqdn-regexp
7429 "Regular expression that matches a valid FQDN."
7431 :group 'gnus-article-buttons
7434 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7435 (defcustom gnus-button-valid-localpart-regexp
7436 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7437 "Regular expression that matches a localpart of mail addresses or MIDs."
7439 :group 'gnus-article-buttons
7442 (defcustom gnus-button-man-handler 'manual-entry
7443 "Function to use for displaying man pages.
7444 The function must take at least one argument with a string naming the
7447 :type '(choice (function-item :tag "Man" manual-entry)
7448 (function-item :tag "Woman" woman)
7449 (function :tag "Other"))
7450 :group 'gnus-article-buttons)
7452 (defcustom gnus-button-mid-or-mail-regexp
7453 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7454 gnus-button-valid-fqdn-regexp
7456 "Regular expression that matches a message ID or a mail address."
7458 :group 'gnus-article-buttons
7461 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7462 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7463 Strings like this can be either a message ID or a mail address. If it is one
7464 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7465 message ID or a mail address, respectively. If this variable is set to the
7466 symbol `ask', always query the user what do do. If it is a function, this
7467 function will be called with the string as its only argument. The function
7468 must return `mid', `mail', `invalid' or `ask'."
7470 :group 'gnus-article-buttons
7471 :type '(choice (function-item :tag "Heuristic function"
7472 gnus-button-mid-or-mail-heuristic)
7477 (defcustom gnus-button-mid-or-mail-heuristic-alist
7478 '((-10.0 . ".+\\$.+@")
7481 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7482 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7483 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7484 (-1.0 . "^[^a-z]+@")
7486 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7487 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7488 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7489 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7492 (-1.0 . "^[0-9][0-9]")
7494 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7495 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7496 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7497 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7499 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7500 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7503 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7505 ;; compensation for TDMA dated mail addresses:
7506 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7508 (-20.0 . "\\.fsf@") ;; Gnus
7511 (-20.0 . "^alpine\\.")
7512 (-20.0 . "_-_") ;; Subject change in thread
7514 (-20.0 . "\\.ln@") ;; leafnode
7515 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7516 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7518 ;; (5.0 . "") ;; $local_part_len <= 7
7519 (10.0 . "^[^0-9]+@")
7520 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7521 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7524 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7526 (0.5 . "^[A-Z][a-z]")
7527 (0.5 . "^[A-Z][a-z][a-z]")
7528 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7529 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7530 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7532 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7533 address. The REGEXP is processed with `case-fold-search' set to nil."
7535 :group 'gnus-article-buttons
7536 :type '(repeat (cons (number :tag "Rate")
7537 (regexp :tag "Regexp"))))
7539 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7540 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7541 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7542 address, `ask' if unsure and `invalid' if the string is invalid."
7543 (let ((case-fold-search nil)
7544 (list gnus-button-mid-or-mail-heuristic-alist)
7545 (result 0) rate regexp lpartlen elem)
7547 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7548 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7549 ;; Certain special cases...
7552 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7553 "^[0-9]+\\.[0-9]+@compuserve\\|"
7554 "@public\\.gmane\\.org")
7556 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7557 (setq result 'mail))
7558 (when (string-match "@.*@\\| " mid-or-mail)
7559 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7560 (setq result 'invalid))
7561 ;; Nothing more to do, if result is not a number here...
7562 (when (numberp result)
7564 (setq elem (car list)
7568 (when (string-match regexp mid-or-mail)
7569 (setq result (+ result rate))
7571 9 "`%s' matched `%s', rate `%s', result `%s'."
7572 mid-or-mail regexp rate result)))
7573 (when (<= lpartlen 7)
7574 (setq result (+ result 5.0))
7575 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7576 mid-or-mail result))
7577 (when (>= lpartlen 12)
7578 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7580 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7581 ;; Long local part should contain realname if e-mail address,
7582 ;; too many digits: message-id.
7583 ;; $score -= 5.0 + 0.1 * $local_part_len;
7584 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7585 (setq result (+ result rate))
7587 9 "Many digits in `%s', rate `%s', result `%s'."
7588 mid-or-mail rate result))
7589 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7591 ;; Too few vowels [^aeiouy]{4,}.*\@
7592 (setq result (+ result -5.0))
7594 9 "Few vowels in `%s', rate `%s', result `%s'."
7595 mid-or-mail -5.0 result))
7597 (setq result (+ result 5.0))
7599 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7600 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7601 ;; Maybe we should make this a customizable alist: (condition . 'result)
7603 ((symbolp result) result)
7604 ;; Now convert number into proper results:
7605 ((< result -10.0) 'mid)
7606 ((> result 10.0) 'mail)
7609 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7610 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7611 (url-mid (concat "news" ":" mid-or-mail))
7612 (url-mailto (concat "mailto" ":" mid-or-mail)))
7613 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7614 (when (fboundp pref)
7616 ;; get rid of surrounding angles...
7618 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7619 (if (or (eq 'mid guessed) (eq 'mail guessed))
7623 (save-window-excursion
7624 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7627 (cond ((eq pref 'mid)
7628 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7629 (gnus-button-handle-news url-mid))
7631 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7632 (gnus-url-mailto url-mailto))
7633 (t (gnus-message 3 "Invalid string.")))))
7635 (defun gnus-button-handle-custom (fun arg)
7636 "Call function FUN on argument ARG.
7637 Both FUN and ARG are supposed to be strings. ARG will be passed
7638 as a symbol to FUN."
7639 (funcall (intern fun)
7640 (if (string-match "^customize-apropos" fun)
7644 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7646 (defun gnus-button-handle-describe-function (url)
7647 "Call `describe-function' when pushing the corresponding URL button."
7650 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7652 (defun gnus-button-handle-describe-variable (url)
7653 "Call `describe-variable' when pushing the corresponding URL button."
7656 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7658 (defun gnus-button-handle-symbol (url)
7659 "Display help on variable or function.
7660 Calls `describe-variable' or `describe-function'."
7661 (let ((sym (intern url)))
7663 ((fboundp sym) (describe-function sym))
7664 ((boundp sym) (describe-variable sym))
7665 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7667 (defun gnus-button-handle-describe-key (url)
7668 "Call `describe-key' when pushing the corresponding URL button."
7670 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7671 (keys (ignore-errors (eval `(kbd ,key-string)))))
7674 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7676 (defun gnus-button-handle-apropos (url)
7677 "Call `apropos' when pushing the corresponding URL button."
7678 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7680 (defun gnus-button-handle-apropos-command (url)
7681 "Call `apropos' when pushing the corresponding URL button."
7683 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7685 (defun gnus-button-handle-apropos-variable (url)
7686 "Call `apropos' when pushing the corresponding URL button."
7688 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7689 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7691 (defun gnus-button-handle-apropos-documentation (url)
7692 "Call `apropos' when pushing the corresponding URL button."
7694 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7695 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7697 (defun gnus-button-handle-library (url)
7698 "Call `locate-library' when pushing the corresponding URL button."
7699 (gnus-message 9 "url=`%s'" url)
7700 (let* ((lib (locate-library url))
7701 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7703 (gnus-message 1 "Cannot locale library `%s'." url)
7704 (find-file-read-only file))))
7706 (defcustom gnus-button-man-level 5
7707 "*Integer that says how many man-related buttons Gnus will show.
7708 The higher the number, the more buttons will appear and the more false
7709 positives are possible. Note that you can set this variable local to
7710 specific groups. Setting it higher in Unix groups is probably a good idea.
7711 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7712 how to set variables in specific groups."
7714 :group 'gnus-article-buttons
7715 :link '(custom-manual "(gnus)Group Parameters")
7718 (defcustom gnus-button-emacs-level 5
7719 "*Integer that says how many emacs-related buttons Gnus will show.
7720 The higher the number, the more buttons will appear and the more false
7721 positives are possible. Note that you can set this variable local to
7722 specific groups. Setting it higher in Emacs or Gnus related groups is
7723 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7724 `gnus-parameters' on how to set variables in specific groups."
7726 :group 'gnus-article-buttons
7727 :link '(custom-manual "(gnus)Group Parameters")
7730 (defcustom gnus-button-message-level 5
7731 "*Integer that says how many buttons for news or mail messages will appear.
7732 The higher the number, the more buttons will appear and the more false
7733 positives are possible."
7734 ;; mail addresses, MIDs, URLs for news, ...
7736 :group 'gnus-article-buttons
7739 (defcustom gnus-button-browse-level 5
7740 "*Integer that says how many buttons for browsing will appear.
7741 The higher the number, the more buttons will appear and the more false
7742 positives are possible."
7743 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7745 :group 'gnus-article-buttons
7748 (defcustom gnus-button-alist
7749 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7750 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7751 ((concat "\\b\\(nntp\\|news\\):\\("
7752 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7753 0 t gnus-button-handle-news 2)
7754 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7755 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7756 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7757 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7758 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7759 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7760 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7761 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7762 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7763 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7764 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7765 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7766 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7767 ;; RFC 2368 (The mailto URL scheme)
7768 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7769 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7770 ("\\bmailto:\\([^ \n\t]+\\)"
7771 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7772 ;; Info Konqueror style <info:/foo/bar baz>.
7773 ;; Must come before " Gnus home-grown style".
7774 ("\\binfo://?\\([^'\">\n\t]+\\)"
7775 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7776 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7777 ("\\binfo://\\([^'\">\n\t ]+\\)"
7778 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7779 ;; Info GNOME style <info:foo#bar_baz>
7780 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7781 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7782 ;; Info KDE style <info:(foo)bar baz>
7783 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7784 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7785 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7786 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7787 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n,]*\\)\\)?"
7788 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7789 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7791 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7792 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7793 ;; Emacs help commands
7794 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7795 ;; regexp doesn't match arguments containing ` '.
7796 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7797 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7798 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7799 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7800 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7801 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7802 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7803 ;; The following entries may lead to many false positives so don't enable
7804 ;; them by default (use a high button level).
7805 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7806 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7807 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7808 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7809 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7810 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7811 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7812 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7813 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7814 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7815 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7816 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7817 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7818 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7819 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7820 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7821 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7822 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7823 ;; Unlike the other regexps we really have to require quoting
7824 ;; here to determine where it ends.
7825 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7826 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7827 ("<URL: *\\([^\n<>]*\\)>"
7828 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7829 ;; RFC 2396 (2.4.3., delims) ...
7830 ("\"URL: *\\([^\n\"]*\\)\""
7831 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7833 (gnus-button-url-regexp
7834 0 (>= gnus-button-browse-level 0) browse-url 0)
7836 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7837 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7838 gnus-button-handle-man 1)
7839 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7840 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7841 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7842 gnus-button-handle-man 1)
7843 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7844 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7845 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7846 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7847 ;; Recognizing patches to .el files. This is somewhat obscure,
7848 ;; but considering the percentage of Gnus users who hack Emacs
7850 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7851 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7852 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7853 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7854 ;; MID or mail: To avoid too many false positives we don't try to catch
7855 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7856 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7857 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7858 ;; so that non-ambiguous entries (see above) match first.
7859 (gnus-button-mid-or-mail-regexp
7860 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7861 "*Alist of regexps matching buttons in article bodies.
7863 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7864 REGEXP: is the string (case insensitive) matching text around the button (can
7865 also be Lisp expression evaluating to a string),
7866 BUTTON: is the number of the regexp grouping actually matching the button,
7867 FORM: is a Lisp expression which must eval to true for the button to
7869 CALLBACK: is the function to call when the user push this button, and each
7870 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7872 CALLBACK can also be a variable, in that case the value of that
7873 variable it the real callback function."
7874 :group 'gnus-article-buttons
7875 :type '(repeat (list (choice regexp variable sexp)
7876 (integer :tag "Button")
7878 (function :tag "Callback")
7881 (integer :tag "Regexp group")))))
7882 (put 'gnus-button-alist 'risky-local-variable t)
7884 (defcustom gnus-header-button-alist
7885 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7886 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7887 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7888 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7889 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7890 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7891 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7892 0 (>= gnus-button-browse-level 0) browse-url 0)
7893 ("^Subject:" gnus-button-url-regexp
7894 0 (>= gnus-button-browse-level 0) browse-url 0)
7895 ("^[^:]+:" gnus-button-url-regexp
7896 0 (>= gnus-button-browse-level 0) browse-url 0)
7897 ("^OpenPGP:.*url=" gnus-button-url-regexp
7898 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7899 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7900 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7901 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7902 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7903 "*Alist of headers and regexps to match buttons in article heads.
7905 This alist is very similar to `gnus-button-alist', except that each
7906 alist has an additional HEADER element first in each entry:
7908 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7910 HEADER is a regexp to match a header. For a fuller explanation, see
7911 `gnus-button-alist'."
7912 :group 'gnus-article-buttons
7913 :group 'gnus-article-headers
7914 :type '(repeat (list (regexp :tag "Header")
7915 (choice regexp variable)
7916 (integer :tag "Button")
7918 (function :tag "Callback")
7921 (integer :tag "Regexp group")))))
7922 (put 'gnus-header-button-alist 'risky-local-variable t)
7926 (defun gnus-article-push-button (event)
7927 "Check text under the mouse pointer for a callback function.
7928 If the text under the mouse pointer has a `gnus-callback' property,
7929 call it with the value of the `gnus-data' text property."
7931 (set-buffer (window-buffer (posn-window (event-start event))))
7932 (let* ((pos (posn-point (event-start event)))
7933 (data (get-text-property pos 'gnus-data))
7934 (fun (get-text-property pos 'gnus-callback)))
7937 (funcall fun data))))
7939 (defun gnus-article-press-button ()
7940 "Check text at point for a callback function.
7941 If the text at point has a `gnus-callback' property,
7942 call it with the value of the `gnus-data' text property."
7944 (let ((data (get-text-property (point) 'gnus-data))
7945 (fun (get-text-property (point) 'gnus-callback)))
7947 (funcall fun data))))
7949 (defun gnus-article-highlight (&optional force)
7950 "Highlight current article.
7951 This function calls `gnus-article-highlight-headers',
7952 `gnus-article-highlight-citation',
7953 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7954 do the highlighting. See the documentation for those functions."
7955 (interactive (list 'force))
7956 (gnus-article-highlight-headers)
7957 (gnus-article-highlight-citation force)
7958 (gnus-article-highlight-signature)
7959 (gnus-article-add-buttons)
7960 (gnus-article-add-buttons-to-head))
7962 (defun gnus-article-highlight-some (&optional _force)
7963 "Highlight current article.
7964 This function calls `gnus-article-highlight-headers',
7965 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7966 do the highlighting. See the documentation for those functions."
7967 (interactive (list 'force))
7968 (gnus-article-highlight-headers)
7969 (gnus-article-highlight-signature)
7970 (gnus-article-add-buttons))
7972 (defun gnus-article-highlight-headers ()
7973 "Highlight article headers as specified by `gnus-header-face-alist'."
7975 (gnus-with-article-headers
7976 (let (regexp header-face field-face from hpoints fpoints)
7977 (dolist (entry gnus-header-face-alist)
7978 (goto-char (point-min))
7979 (setq regexp (concat "^\\("
7980 (if (string-equal "" (nth 0 entry))
7984 header-face (nth 1 entry)
7985 field-face (nth 2 entry))
7986 (while (and (re-search-forward regexp nil t)
7990 (unless (search-forward ":" nil t)
7992 (when (and header-face
7993 (not (memq (point) hpoints)))
7994 (push (point) hpoints)
7995 (gnus-put-text-property from (point) 'face header-face))
7996 (when (and field-face
7997 (not (memq (setq from (point)) fpoints)))
7999 (if (re-search-forward "^[^ \t]" nil t)
8001 (goto-char (point-max)))
8002 (gnus-put-text-property from (point) 'face field-face)))))))
8004 (defun gnus-article-highlight-signature ()
8005 "Highlight the signature in an article.
8006 It does this by highlighting everything after
8007 `gnus-signature-separator' using the face `gnus-signature'."
8009 (gnus-with-article-buffer
8010 (let ((inhibit-point-motion-hooks t))
8012 (when (and gnus-signature-face
8013 (gnus-article-narrow-to-signature))
8014 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
8015 'face gnus-signature-face)
8017 (gnus-article-search-signature)
8018 (let ((start (match-beginning 0))
8019 (end (set-marker (make-marker) (1+ (match-end 0)))))
8020 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
8023 (defun gnus-button-in-region-p (b e prop)
8024 "Say whether PROP exists in the region."
8025 (text-property-not-all b e prop nil))
8027 (defun gnus-article-add-buttons ()
8028 "Find external references in the article and make buttons of them.
8029 \"External references\" are things like Message-IDs and URLs, as
8030 specified by `gnus-button-alist'."
8032 (gnus-with-article-buffer
8033 (let ((inhibit-point-motion-hooks t)
8034 (case-fold-search t)
8035 (alist gnus-button-alist)
8037 ;; We skip the headers.
8040 (while (setq entry (pop alist))
8041 (setq regexp (eval (car entry)))
8043 (while (re-search-forward regexp nil t)
8044 (let ((start (match-beginning (nth 1 entry)))
8045 (end (match-end (nth 1 entry)))
8046 (from (match-beginning 0)))
8047 (when (and (eval (nth 2 entry))
8048 (not (gnus-button-in-region-p
8049 start end 'gnus-callback)))
8050 ;; That optional form returned non-nil, so we add the
8052 (setq from (set-marker (make-marker) from))
8053 (unless (and (eq (car entry) 'gnus-button-url-regexp)
8054 (gnus-article-extend-url-button from start end))
8055 (gnus-article-add-button start end
8056 'gnus-button-push (list from entry))
8057 (gnus-put-text-property
8059 'gnus-string (buffer-substring-no-properties
8062 (defun gnus-article-extend-url-button (beg start end)
8063 "Extend url button if url is folded into two or more lines.
8064 Return non-nil if button is extended. BEG is a marker that points to
8065 the beginning position of a text containing url. START and END are
8066 the endpoints of a url button before it is extended. The concatenated
8067 url is put as the `gnus-button-url' overlay property on the button."
8068 (let ((opoint (point))
8069 (points (list start end))
8074 (not (looking-at "[\t ]*[\">]")))
8078 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8079 (buffer-substring (point-at-bol) start)))
8081 (setq url (list (buffer-substring start end))
8082 delim (if (match-beginning 1) ">" "\""))
8084 (setq regexp (concat
8085 (when (and (looking-at
8086 message-cite-prefix-regexp)
8087 (< (match-end 0) start))
8088 (regexp-quote (match-string 0)))
8090 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8094 (and (looking-at regexp)
8097 (push (or (match-string 2)
8100 (push (setq end (or (match-end 2)
8103 (push (or (match-beginning 2)
8104 (match-beginning 1))
8106 (match-beginning 2)))
8107 (let (gnus-article-mouse-face widget-mouse-face)
8109 (gnus-article-add-button (pop points) (pop points)
8111 (list beg (assq 'gnus-button-url-regexp
8112 gnus-button-alist)))))
8113 (let ((overlay (gnus-make-overlay start end)))
8114 (gnus-overlay-put overlay 'evaporate t)
8115 (gnus-overlay-put overlay 'gnus-button-url
8116 (list (mapconcat 'identity (nreverse url) "")))
8117 (when gnus-article-mouse-face
8118 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8120 (goto-char opoint))))
8122 ;; Add buttons to the head of an article.
8123 (defun gnus-article-add-buttons-to-head ()
8124 "Add buttons to the head of the article."
8126 (gnus-with-article-headers
8128 (dolist (entry gnus-header-button-alist)
8129 ;; Each alist entry.
8130 (goto-char (point-min))
8131 (while (re-search-forward (car entry) nil t)
8132 ;; Each header matching the entry.
8133 (setq beg (match-beginning 0))
8134 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8135 (match-beginning 0))
8138 (while (re-search-forward (eval (nth 1 entry)) end t)
8139 ;; Each match within a header.
8140 (let* ((entry (cdr entry))
8141 (start (match-beginning (nth 1 entry)))
8142 (end (match-end (nth 1 entry)))
8143 (form (nth 2 entry)))
8144 (goto-char (match-end 0))
8146 (gnus-article-add-button
8147 start end (nth 3 entry)
8148 (buffer-substring (match-beginning (nth 4 entry))
8149 (match-end (nth 4 entry)))))))
8150 (goto-char end))))))
8152 ;;; External functions:
8154 (defun gnus-article-add-button (from to fun &optional data text)
8155 "Create a button between FROM and TO with callback FUN and data DATA."
8156 (when gnus-article-button-face
8157 (gnus-overlay-put (gnus-make-overlay from to nil t)
8158 'face gnus-article-button-face))
8159 (gnus-add-text-properties
8161 (nconc (and gnus-article-mouse-face
8162 (list gnus-mouse-face-prop gnus-article-mouse-face))
8163 (list 'gnus-callback fun)
8164 (and data (list 'gnus-data data))))
8165 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8166 :help-echo (or text "Follow the link")
8167 :keymap gnus-url-button-map
8168 :button-keymap gnus-widget-button-keymap))
8170 (defun gnus-article-copy-string ()
8171 "Copy the string in the button to the kill ring."
8173 (gnus-article-check-buffer)
8174 (let ((data (get-text-property (point) 'gnus-string)))
8178 (copy-region-as-kill (point-min) (point-max))
8179 (message "Copied %s" data)))))
8181 ;;; Internal functions:
8183 (defun gnus-article-set-globals ()
8184 (with-current-buffer gnus-summary-buffer
8185 (gnus-set-global-variables)))
8187 (defun gnus-signature-toggle (end)
8188 (gnus-with-article-buffer
8189 (let ((inhibit-point-motion-hooks t))
8190 (if (text-property-any end (point-max) 'article-type 'signature)
8192 (gnus-delete-wash-type 'signature)
8193 (gnus-remove-text-properties-when
8194 'article-type 'signature end (point-max)
8195 (cons 'article-type (cons 'signature
8196 gnus-hidden-properties))))
8197 (gnus-add-wash-type 'signature)
8198 (gnus-add-text-properties-when
8199 'article-type nil end (point-max)
8200 (cons 'article-type (cons 'signature
8201 gnus-hidden-properties)))))
8202 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8203 (gnus-set-mode-line 'article))))
8205 (defun gnus-button-push (marker-and-entry)
8206 ;; Push button starting at MARKER.
8208 (let* ((marker (car marker-and-entry))
8209 (entry (cadr marker-and-entry))
8210 (regexp (car entry))
8211 (inhibit-point-motion-hooks t))
8213 ;; This is obviously true, or something bad is happening :)
8214 ;; But we need it to have the match-data
8215 (when (looking-at (or (if (symbolp regexp)
8216 (symbol-value regexp)
8218 (let ((fun (nth 3 entry))
8219 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8220 (get-char-property marker 'gnus-button-url))
8221 (mapcar (lambda (group)
8222 (let ((string (match-string group)))
8223 (set-text-properties
8224 0 (length string) nil string)
8226 (nthcdr 4 entry)))))
8232 (fboundp (symbol-value fun)))
8233 (apply (symbol-value fun) args))
8235 (gnus-message 1 "You must define `%S' to use this button"
8236 (cons fun args)))))))))
8238 (defun gnus-parse-news-url (url)
8239 (let (scheme server port group message-id articles)
8242 (goto-char (point-min))
8243 (when (looking-at "\\([A-Za-z]+\\):")
8244 (setq scheme (match-string 1))
8245 (goto-char (match-end 0)))
8246 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8247 (setq server (match-string 1))
8248 (setq port (if (stringp (match-string 3))
8249 (string-to-number (match-string 3))
8251 (goto-char (match-end 0)))
8254 ((looking-at "\\(.*@.*\\)")
8255 (setq message-id (match-string 1)))
8256 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8257 (setq group (match-string 1)
8258 articles (split-string (match-string 2) "-")))
8259 ((looking-at "\\([^/]+\\)/?")
8260 (setq group (match-string 1)))
8262 (error "Unknown news URL syntax"))))
8263 (list scheme server port group message-id articles)))
8265 (defvar nntp-port-number)
8267 (defun gnus-button-handle-news (url)
8269 (destructuring-bind (_scheme server port group message-id _articles)
8270 (gnus-parse-news-url url)
8273 (with-current-buffer gnus-summary-buffer
8275 (let ((gnus-refer-article-method
8276 (nconc (list (list 'nntp server))
8277 gnus-refer-article-method))
8278 (nntp-port-number (or port "nntp")))
8279 (gnus-message 7 "Fetching %s with %s"
8280 message-id gnus-refer-article-method)
8281 (gnus-summary-refer-article message-id))
8282 (gnus-summary-refer-article message-id))))
8284 (gnus-button-fetch-group url)))))
8286 (defun gnus-button-patch (library line)
8287 "Visit an Emacs Lisp library LIBRARY on line LINE."
8289 (let ((file (locate-library (file-name-nondirectory library))))
8291 (error "Couldn't find library %s" library))
8293 (goto-char (point-min))
8294 (forward-line (1- (string-to-number line)))))
8296 (defun gnus-button-handle-man (url)
8298 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8299 (when (eq gnus-button-man-handler 'woman)
8300 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8301 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8302 (funcall gnus-button-man-handler url))
8304 (defun gnus-button-handle-info-url (url)
8305 "Fetch an info URL."
8306 (setq url (mm-subst-char-in-string ?+ ?\ url))
8308 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8309 (gnus-info-find-node
8310 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8312 ")" (gnus-url-unhex-string (match-string 2 url)))))
8313 ((string-match "([^)\"]+)[^\"]+" url)
8315 (gnus-replace-in-string
8316 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8317 (gnus-info-find-node url))
8318 (t (error "Can't parse %s" url))))
8320 (defun gnus-button-handle-info-url-gnome (url)
8321 "Fetch GNOME style info URL."
8322 (setq url (mm-subst-char-in-string ?_ ?\ url))
8323 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8324 (gnus-info-find-node
8326 (gnus-url-unhex-string
8327 (match-string 1 url))
8329 (or (gnus-url-unhex-string
8330 (match-string 2 url))
8332 (error "Can't parse %s" url)))
8334 (defun gnus-button-handle-info-url-kde (url)
8335 "Fetch KDE style info URL."
8336 (gnus-info-find-node (gnus-url-unhex-string url)))
8338 ;; (info) will autoload info.el
8339 (declare-function Info-menu "info" (menu-item &optional fork))
8340 (declare-function Info-index-next "info" (num))
8342 (defun gnus-button-handle-info-keystrokes (url)
8343 "Call `info' when pushing the corresponding URL button."
8344 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8345 (let (node indx comma)
8347 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8348 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8349 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8350 "\\(?:[ \t\n,]*\\)\\)?")
8352 (setq node (match-string 2 url)
8353 indx (match-string 3 url))
8354 (error "Can't parse %s" url))
8358 (when (> (length indx) 0)
8359 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8362 (setq comma (match-string 2 indx))
8363 (setq indx (match-string 1 indx))
8366 (dotimes (i (with-temp-buffer
8368 ;; Note: the XEmacs version of `how-many' takes
8369 ;; no optional argument.
8370 (goto-char (point-min))
8372 (Info-index-next 1)))
8375 (autoload 'pgg-snarf-keys-region "pgg")
8376 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8377 (declare-function pgg-display-output-buffer "pgg" (start end status))
8379 (defun gnus-button-openpgp (url)
8380 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8382 (mm-url-insert-file-contents-external url)
8383 (pgg-snarf-keys-region (point-min) (point-max))
8384 (pgg-display-output-buffer nil nil nil)))
8386 (defun gnus-button-message-id (message-id)
8388 (with-current-buffer gnus-summary-buffer
8389 (gnus-summary-refer-article message-id)))
8391 (defun gnus-button-fetch-group (address &rest _ignore)
8392 "Fetch GROUP specified by ADDRESS."
8393 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8395 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8396 ;; for nntp:// and news://
8397 (setq address (match-string 3 address)))
8398 (if (not (string-match "[:/]" address))
8399 ;; This is just a simple group url.
8400 (gnus-group-read-ephemeral-group address gnus-select-method)
8403 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8405 (error "Can't parse %s" address)
8406 (gnus-group-read-ephemeral-group
8407 (match-string 4 address)
8408 `(nntp ,(match-string 1 address)
8409 (nntp-address ,(match-string 1 address))
8410 (nntp-port-number ,(if (match-end 3)
8411 (match-string 3 address)
8414 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8416 (defun gnus-url-parse-query-string (query &optional downcase)
8417 (let (retval pairs cur key val)
8418 (setq pairs (split-string query "&"))
8420 (setq cur (car pairs)
8422 (if (not (string-match "=" cur))
8424 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8425 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8427 (setq key (downcase key)))
8428 (setq cur (assoc key retval))
8430 (setcdr cur (cons val (cdr cur)))
8431 (setq retval (cons (list key val) retval)))))
8434 (defun gnus-url-mailto (url)
8435 ;; Send mail to someone
8436 (setq url (replace-regexp-in-string "\n" " " url))
8437 (when (string-match "mailto:/*\\(.*\\)" url)
8438 (setq url (substring url (match-beginning 1) nil)))
8439 (let* ((args (gnus-url-parse-query-string
8440 (if (string-match "^\\?" url)
8442 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8443 (concat "to=" (match-string 1 url) "&"
8444 (match-string 2 url))
8445 (concat "to=" url)))))
8446 (subject (cdr-safe (assoc "subject" args)))
8450 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8453 (message-position-on-field (caar args)))
8454 (insert (gnus-replace-in-string
8455 (mapconcat 'identity (reverse (cdar args)) ", ")
8457 (setq args (cdr args)))
8460 (message-goto-subject))))
8462 (defun gnus-button-embedded-url (address)
8463 "Activate ADDRESS with `browse-url'."
8464 (browse-url (gnus-strip-whitespace address)))
8466 ;;; Next/prev buttons in the article buffer.
8468 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8469 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8471 (defvar gnus-prev-page-map
8472 (let ((map (make-sparse-keymap)))
8473 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8474 (define-key map "\r" 'gnus-button-prev-page)
8477 (defvar gnus-next-page-map
8478 (let ((map (make-sparse-keymap)))
8479 (define-key map gnus-mouse-2 'gnus-button-next-page)
8480 (define-key map "\r" 'gnus-button-next-page)
8483 (defun gnus-insert-prev-page-button ()
8485 (inhibit-read-only t))
8487 gnus-prev-page-line-format nil
8488 `(keymap ,gnus-prev-page-map
8490 gnus-callback gnus-article-button-prev-page
8491 article-type annotation))
8493 ;; Exclude a newline.
8496 (when gnus-article-button-face
8497 (gnus-overlay-put (gnus-make-overlay b e nil t)
8498 'face gnus-article-button-face))
8499 (widget-convert-button
8501 :action 'gnus-button-prev-page
8502 :button-keymap gnus-prev-page-map)))
8504 (defun gnus-button-next-page (&optional _args _more-args)
8505 "Go to the next page."
8507 (let ((win (selected-window)))
8508 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8509 (gnus-article-next-page)
8510 (select-window win)))
8512 (defun gnus-button-prev-page (&optional _args _more-args)
8513 "Go to the prev page."
8515 (let ((win (selected-window)))
8516 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8517 (gnus-article-prev-page)
8518 (select-window win)))
8520 (defun gnus-insert-next-page-button ()
8522 (inhibit-read-only t))
8523 (gnus-eval-format gnus-next-page-line-format nil
8524 `(keymap ,gnus-next-page-map
8526 gnus-callback gnus-article-button-next-page
8527 article-type annotation))
8529 ;; Exclude a newline.
8532 (when gnus-article-button-face
8533 (gnus-overlay-put (gnus-make-overlay b e nil t)
8534 'face gnus-article-button-face))
8535 (widget-convert-button
8537 :action 'gnus-button-next-page
8538 :button-keymap gnus-next-page-map)))
8540 (defun gnus-article-button-next-page (_arg)
8541 "Go to the next page."
8543 (let ((win (selected-window)))
8544 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8545 (gnus-article-next-page)
8546 (select-window win)))
8548 (defun gnus-article-button-prev-page (_arg)
8549 "Go to the prev page."
8551 (let ((win (selected-window)))
8552 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8553 (gnus-article-prev-page)
8554 (select-window win)))
8556 (defvar gnus-decode-header-methods
8557 '(mail-decode-encoded-word-region)
8558 "List of methods used to decode headers.
8560 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8561 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8562 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8563 whose names match REGEXP.
8566 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8567 mail-decode-encoded-word-region
8568 (\"chinese\" . rfc1843-decode-region))
8571 (defvar gnus-decode-header-methods-cache nil)
8573 (defun gnus-multi-decode-header (start end)
8574 "Apply the functions from `gnus-encoded-word-methods' that match."
8575 (unless (and gnus-decode-header-methods-cache
8576 (eq gnus-newsgroup-name
8577 (car gnus-decode-header-methods-cache)))
8578 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8579 (dolist (x gnus-decode-header-methods)
8581 (nconc gnus-decode-header-methods-cache (list x))
8582 (if (and gnus-newsgroup-name
8583 (string-match (car x) gnus-newsgroup-name))
8584 (nconc gnus-decode-header-methods-cache
8586 (let ((xlist gnus-decode-header-methods-cache))
8589 (narrow-to-region start end)
8591 (funcall (pop xlist) (point-min) (point-max))))))
8594 ;;; Treatment top-level handling.
8597 (defvar gnus-inhibit-article-treatments nil)
8599 ;; Dynamic variables.
8600 (defvar part-number) ;FIXME: Lacks a "gnus-" prefix.
8601 (defvar total-parts) ;FIXME: Lacks a "gnus-" prefix.
8602 (defvar gnus-treat-type)
8603 (defvar gnus-treat-condition)
8604 (defvar gnus-treat-length)
8606 (defun gnus-treat-article (condition
8607 &optional part-num total type)
8608 (let ((gnus-treat-condition condition)
8609 (part-number part-num)
8611 (gnus-treat-type type)
8612 (gnus-treat-length (- (point-max) (point-min)))
8613 (alist gnus-treatment-function-alist)
8614 (article-goto-body-goes-to-point-min-p t)
8618 (let ((list gnus-article-treat-types))
8620 (when (string-match (pop list) type)
8621 (throw 'found t)))))))
8622 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8624 (gnus-run-hooks 'gnus-part-display-hook)
8625 (dolist (elem alist)
8628 (when (gnus-buffer-live-p gnus-summary-buffer)
8629 (set-buffer gnus-summary-buffer))
8630 (symbol-value (car elem))))
8631 (when (and (or (consp val)
8633 (or (not gnus-inhibit-article-treatments)
8634 (eq gnus-treat-condition 'head))
8635 (gnus-treat-predicate val)
8636 (or (not (get (car elem) 'highlight))
8639 (funcall (cadr elem)))))))
8641 (defun gnus-treat-predicate (val)
8645 (gnus-treat-condition
8646 (eq gnus-treat-condition val))
8648 (stringp (car val)))
8649 (apply 'gnus-or (mapcar `(lambda (s)
8650 (string-match s ,(or gnus-newsgroup-name "")))
8653 (let ((pred (pop val)))
8656 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8658 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8660 (not (gnus-treat-predicate (car val))))
8662 (equal (car val) gnus-treat-type))
8666 (error "%S is not a valid predicate" pred)))))
8674 (eq part-number total-parts))
8676 (< gnus-treat-length val))
8678 (error "%S is not a valid value" val))))
8680 (defun gnus-article-encrypt-body (protocol &optional n)
8681 "Encrypt the article body."
8684 (or gnus-article-encrypt-protocol
8685 (gnus-completing-read "Encrypt protocol"
8686 (mapcar 'car gnus-article-encrypt-protocol-alist)
8688 current-prefix-arg))
8689 ;; User might hit `K E' instead of `K e', so prompt once.
8690 (when (and gnus-article-encrypt-protocol
8692 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8693 (error "Encrypt aborted")))
8694 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8696 (error "Can't find the encrypt protocol %s" protocol))
8697 (if (member gnus-newsgroup-name '("nndraft:delayed"
8700 (error "Can't encrypt the article in group %s"
8701 gnus-newsgroup-name))
8702 (gnus-summary-iterate n
8703 (with-current-buffer gnus-summary-buffer
8704 (let ((mail-parse-charset gnus-newsgroup-charset)
8705 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8706 (summary-buffer gnus-summary-buffer)
8708 (gnus-set-global-variables)
8709 (when (gnus-group-read-only-p)
8710 (error "The current newsgroup does not support article encrypt"))
8711 (gnus-summary-show-article t)
8713 (or (mail-header-references gnus-current-headers) ""))
8714 (set-buffer gnus-article-buffer)
8715 (let* ((inhibit-read-only t)
8717 (mapcar (lambda (field)
8718 (and (save-restriction
8719 (message-narrow-to-head)
8720 (goto-char (point-min))
8721 (search-forward field nil t))
8723 (message-narrow-to-field)
8725 (delete-region (point-min) (point-max))
8727 '("Content-Type:" "Content-Transfer-Encoding:"
8728 "Content-Disposition:"))))
8729 (message-narrow-to-head)
8730 (message-remove-header "MIME-Version")
8731 (goto-char (point-max))
8732 (setq point (point))
8733 (insert (apply 'concat headers))
8735 (narrow-to-region point (point-max))
8736 (let ((message-options message-options))
8737 (message-options-set 'message-sender user-mail-address)
8738 (message-options-set 'message-recipients user-mail-address)
8739 (message-options-set 'message-sign-encrypt 'not)
8741 (goto-char (point-min))
8742 (insert "MIME-Version: 1.0\n")
8744 (gnus-summary-edit-article-done
8745 references nil summary-buffer t))
8746 (when gnus-keep-backlog
8747 (gnus-backlog-remove-article
8748 (car gnus-article-current) (cdr gnus-article-current)))
8749 (gnus-flush-original-article-buffer)
8750 (when gnus-use-cache
8751 (gnus-cache-update-article
8752 (car gnus-article-current) (cdr gnus-article-current))))))))
8754 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8755 "The following specs can be used:
8756 %t The security MIME type
8759 %D Details if button is pressed")
8761 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8762 "The following specs can be used:
8763 %t The security MIME type
8766 %D Details if button is pressed")
8768 (defvar gnus-mime-security-button-line-format-alist
8769 '((?t gnus-tmp-type ?s)
8770 (?i gnus-tmp-info ?s)
8771 (?d gnus-tmp-details ?s)
8772 (?D gnus-tmp-pressed-details ?s)))
8774 (defvar gnus-mime-security-button-commands
8775 '((gnus-article-press-button "\r" "Show Detail")
8779 (gnus-mime-security-save-part "o" "Save...")
8788 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8791 (defvar gnus-mime-security-button-map
8792 (let ((map (make-sparse-keymap)))
8793 (define-key map gnus-mouse-2 'gnus-article-push-button)
8794 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8795 (dolist (c gnus-mime-security-button-commands)
8796 (define-key map (cadr c) (car c)))
8800 gnus-mime-security-button-menu gnus-mime-security-button-map
8801 "Security button menu."
8805 (unless (eq (car c) 'undefined)
8806 (vector (caddr c) (car c) :active t)))
8807 gnus-mime-security-button-commands))))
8809 (defun gnus-mime-security-button-menu (event prefix)
8810 "Construct a context-sensitive menu of security commands."
8811 (interactive "e\nP")
8812 (save-window-excursion
8813 (let ((pos (event-start event)))
8814 (select-window (posn-window pos))
8815 (goto-char (posn-point pos))
8816 (gnus-article-check-buffer)
8817 (popup-menu gnus-mime-security-button-menu nil prefix))))
8819 (defvar gnus-mime-security-details-buffer nil)
8821 (defvar gnus-mime-security-button-pressed nil)
8823 (defvar gnus-mime-security-show-details-inline t
8824 "If non-nil, show details in the article buffer.")
8826 (defun gnus-mime-security-verify-or-decrypt (handle)
8827 (mm-remove-parts (cdr handle))
8828 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8829 point (inhibit-read-only t))
8831 (goto-char (car region)))
8832 (setq point (point))
8833 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8834 (let* ((mm-verify-option 'known)
8835 (mm-decrypt-option 'known)
8836 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8837 (unless (eq nparts (cdr handle))
8838 (mm-destroy-parts (cdr handle))
8839 (setcdr handle nparts))))
8840 (gnus-mime-display-security handle)
8842 (delete-region (point) (cdr region))
8843 (set-marker (car region) nil)
8844 (set-marker (cdr region) nil))
8847 (defun gnus-mime-security-show-details (handle)
8848 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8850 (gnus-message 5 "No details.")
8851 (if gnus-mime-security-show-details-inline
8852 (let ((gnus-mime-security-button-pressed
8853 (not (get-text-property (point) 'gnus-mime-details)))
8854 (gnus-mime-security-button-line-format
8855 (get-text-property (point) 'gnus-line-format))
8856 (inhibit-read-only t))
8858 (while (eq (get-text-property (point) 'gnus-line-format)
8859 gnus-mime-security-button-line-format)
8863 (narrow-to-region (point) (point))
8864 (gnus-insert-mime-security-button handle))
8865 (delete-region (point)
8866 (or (text-property-not-all
8869 gnus-mime-security-button-line-format)
8872 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8873 (with-current-buffer gnus-mime-security-details-buffer
8876 (setq gnus-mime-security-details-buffer
8877 (gnus-get-buffer-create "*MIME Security Details*")))
8878 (with-current-buffer gnus-mime-security-details-buffer
8880 (goto-char (point-min)))
8881 (pop-to-buffer gnus-mime-security-details-buffer)))))
8883 (defun gnus-mime-security-press-button (handle)
8885 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8886 (gnus-mime-security-show-details handle)
8887 (gnus-mime-security-verify-or-decrypt handle))))
8889 (defun gnus-insert-mime-security-button (handle &optional _displayed)
8890 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8893 (or (nth 2 (assoc protocol mm-verify-function-alist))
8894 (nth 2 (assoc protocol mm-decrypt-function-alist))
8896 (if (equal (car handle) "multipart/signed")
8897 " Signed" " Encrypted")
8900 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8903 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8904 gnus-tmp-pressed-details
8906 (setq gnus-tmp-details
8907 (if gnus-tmp-details
8908 (concat "\n" gnus-tmp-details)
8910 (setq gnus-tmp-pressed-details
8911 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8916 gnus-mime-security-button-line-format
8917 gnus-mime-security-button-line-format-alist
8918 `(keymap ,gnus-mime-security-button-map
8919 gnus-callback gnus-mime-security-press-button
8920 gnus-line-format ,gnus-mime-security-button-line-format
8921 gnus-mime-details ,gnus-mime-security-button-pressed
8922 article-type annotation
8925 ;; Exclude a newline.
8928 (when gnus-article-button-face
8929 (gnus-overlay-put (gnus-make-overlay b e nil t)
8930 'face gnus-article-button-face))
8931 (widget-convert-button
8934 :action 'gnus-widget-press-button
8935 :button-keymap gnus-mime-security-button-map
8938 ;; Needed to properly clear the message due to a bug in
8939 ;; wid-edit (XEmacs only).
8940 (when (boundp 'help-echo-owns-message)
8941 (setq help-echo-owns-message t))
8943 "%S: show detail; %S: more options"
8944 (aref gnus-mouse-2 0)
8945 (aref gnus-down-mouse-3 0))))))
8947 (defun gnus-mime-display-security (handle)
8949 (narrow-to-region (point) (point))
8950 (unless (gnus-unbuttonized-mime-type-p (car handle))
8951 (gnus-insert-mime-security-button handle))
8952 (gnus-mime-display-part (cadr handle))
8955 (unless (gnus-unbuttonized-mime-type-p (car handle))
8956 (let ((gnus-mime-security-button-line-format
8957 gnus-mime-security-button-end-line-format))
8958 (gnus-insert-mime-security-button handle)))
8959 (mm-set-handle-multipart-parameter
8960 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8961 (goto-char (point-max))))
8963 (defun gnus-mime-security-run-function (function)
8964 "Run FUNCTION with the security part under point."
8965 (gnus-article-check-buffer)
8966 (let ((data (get-text-property (point) 'gnus-data))
8968 (when (and (stringp (car-safe data))
8969 (setq buffer (mm-handle-multipart-original-buffer data))
8970 (setq handle (cadr data)))
8971 (if (bufferp (mm-handle-buffer handle))
8973 (setq handle (cons buffer (copy-sequence (cdr handle))))
8974 (mm-handle-set-undisplayer handle nil))
8975 (setq handle (mm-make-handle
8977 (mm-handle-multipart-ctl-parameter handle 'protocol)
8978 nil nil nil nil nil nil)))
8979 (funcall function handle))))
8981 (defun gnus-mime-security-save-part ()
8982 "Save the security part under point."
8984 (gnus-mime-security-run-function 'mm-save-part))
8986 (defun gnus-mime-security-pipe-part ()
8987 "Pipe the security part under point to a process."
8989 (gnus-mime-security-run-function 'mm-pipe-part))
8995 (run-hooks 'gnus-art-load-hook)
8997 ;;; gnus-art.el ends here