1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2015 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")
53 (autoload 'url-expand-file-name
"url-expand")
55 (defgroup gnus-article nil
57 :link
'(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link
'(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link
'(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link
'(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link
'(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link
'(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link
'(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link
'(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link
'(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link
'(custom-manual "(gnus)Using MIME")
104 :group
'gnus-article
)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link
'(custom-manual "(gnus)Article Buttons")
109 :group
'gnus-article
)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link
'(custom-manual "(gnus)Misc Article")
114 :group
'gnus-article
)
116 (defcustom gnus-ignored-headers
119 (concat "^" header
":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
158 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
159 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
160 "Envelope-Sender" "Envelope-Recipients"))
161 "*All headers that start with this regexp will be hidden.
162 This variable can also be a list of regexps of headers to be ignored.
163 If `gnus-visible-headers' is non-nil, this variable will be ignored."
164 :type
'(choice regexp
166 :group
'gnus-article-hiding
)
168 (defcustom gnus-visible-headers
169 "^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:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
174 (repeat :value-to-internal
(lambda (widget value
)
175 (custom-split-regexp-maybe value
))
176 :match
(lambda (widget value
)
178 (widget-editable-list-match widget value
)))
180 (const :tag
"Use gnus-ignored-headers" nil
)
182 :group
'gnus-article-hiding
)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "*This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type
'(repeat regexp
)
192 :group
'gnus-article-hiding
)
194 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 'empty Headers with no content.
199 'newsgroups Newsgroup identical to Gnus group.
200 'to-address To identical to To-address.
201 'to-list To identical to To-list.
202 'cc-list CC identical to To-list.
203 'followup-to Followup-to identical to Newsgroups.
204 'reply-to Reply-to identical to From.
205 'date Date less than four days old.
206 'long-to To and/or Cc longer than 1024 characters.
207 'many-to Multiple To and/or Cc."
208 :type
'(set (const :tag
"Headers with no content." empty
)
209 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
210 (const :tag
"To identical to To-address." to-address
)
211 (const :tag
"To identical to To-list." to-list
)
212 (const :tag
"CC identical to To-list." cc-list
)
213 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
214 (const :tag
"Reply-to identical to From." reply-to
)
215 (const :tag
"Date less than four days old." date
)
216 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
217 (const :tag
"Multiple To and/or Cc headers." many-to
))
218 :group
'gnus-article-hiding
)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
228 :group
'gnus-article-hiding
)
230 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
231 "Regexp matching signature separator.
232 This can also be a list of regexps. In that case, it will be checked
233 from head to tail looking for a separator. Searches will be done from
234 the end of the buffer."
235 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
237 (repeat :tag
"List of regexp" regexp
))
238 :group
'gnus-article-signature
)
240 (defcustom gnus-signature-limit nil
241 "Provide a limit to what is considered a signature.
242 If it is a number, no signature may not be longer (in characters) than
243 that number. If it is a floating point number, no signature may be
244 longer (in lines) than that number. If it is a function, the function
245 will be called without any parameters, and if it returns nil, there is
246 no signature in the buffer. If it is a string, it will be used as a
247 regexp. If it matches, the text in question is not a signature.
249 This can also be a list of the above values."
250 :type
'(choice (const nil
)
254 (regexp :value
".*"))
255 :group
'gnus-article-signature
)
257 (defcustom gnus-hidden-properties
258 ;; We use to have `intangible' here as well, but Emacs's command loop moves
259 ;; point out of invisible text anyway, so `intangible' is clearly not
260 ;; needed there. And XEmacs doesn't handle `intangible' anyway.
262 "Property list to use for hiding text."
264 :group
'gnus-article-hiding
)
266 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
267 ;; frames in a session.
268 (defcustom gnus-article-x-face-command
269 (if (featurep 'xemacs
)
270 (if (or (gnus-image-type-available-p 'xface
)
271 (gnus-image-type-available-p 'pbm
))
272 'gnus-display-x-face-in-from
274 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
275 ; uncompface; } | icontopbm | ee -")
276 (if (gnus-image-type-available-p 'pbm
)
277 'gnus-display-x-face-in-from
279 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
280 ; uncompface; } | icontopbm | display -"))
281 "*String or function to be executed to display an X-Face header.
282 If it is a string, the command will be executed in a sub-shell
283 asynchronously. The compressed face will be piped to this command."
284 :type
`(choice string
285 (function-item gnus-display-x-face-in-from
)
289 :group
'gnus-article-washing
)
291 (defcustom gnus-article-x-face-too-ugly nil
292 "Regexp matching posters whose face shouldn't be shown automatically."
293 :type
'(choice regexp
(const nil
))
294 :group
'gnus-article-washing
)
296 (defcustom gnus-article-banner-alist nil
297 "Banner alist for stripping.
299 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
301 :type
'(repeat (cons symbol regexp
))
302 :group
'gnus-article-washing
)
304 (gnus-define-group-parameter
307 "Alist of regexps (to match group names) and banner."
308 :variable-group gnus-article-washing
310 '(choice :tag
"Banner"
312 (const :tag
"Remove signature" signature
)
313 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
315 (const :tag
"None" nil
))
317 "If non-nil, specify how to remove `banners' from articles.
319 Symbol `signature' means to remove signatures delimited by
320 `gnus-signature-separator'. Any other symbol is used to look up a
321 regular expression to match the banner in `gnus-article-banner-alist'.
322 A string is used as a regular expression to match the banner
325 (defcustom gnus-article-address-banner-alist nil
326 "Alist of mail addresses and banners.
327 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
328 to match a mail address in the From: header, BANNER is one of a symbol
329 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
330 If ADDRESS matches author's mail address, it will remove things like
331 advertisements. For example:
333 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
337 (regexp :tag
"Address")
338 (choice :tag
"Banner" :value nil
339 (const :tag
"Remove signature" signature
)
340 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
342 (const :tag
"None" nil
))))
344 :group
'gnus-article-washing
)
346 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
348 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
349 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
352 (defun gnus-emphasis-custom-value-to-external (value)
353 (gnus-emphasis-custom-with-format
354 (if (consp (car value
))
355 (list (format format
(car (car value
)) (cdr (car value
)))
357 (if (nth 1 value
) 2 3)
361 (defun gnus-emphasis-custom-value-to-internal (value)
362 (gnus-emphasis-custom-with-format
363 (let ((regexp (concat "\\`"
364 (format (regexp-quote format
)
365 "\\([^()]+\\)" "\\([^()]+\\)")
368 (if (string-match regexp
(setq pattern
(car value
)))
369 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
374 (defcustom gnus-emphasis-alist
376 '(("\\*" "\\*" bold nil
2)
379 ("_/" "/_" underline-italic
)
380 ("_\\*" "\\*_" underline-bold
)
381 ("\\*/" "/\\*" bold-italic
)
382 ("_\\*/" "/\\*_" underline-bold-italic
))))
384 (gnus-emphasis-custom-with-format
385 (mapcar (lambda (spec)
386 (list (format format
(car spec
) (cadr spec
))
389 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
391 '(;; I've never seen anyone use this strikethru convention whereas I've
392 ;; several times seen it triggered by normal text. --Stef
393 ;; Miles suggests that this form is sometimes used but for italics,
394 ;; so maybe we should map it to `italic'.
395 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
396 ;; 2 3 gnus-emphasis-strikethru)
397 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
398 2 3 gnus-emphasis-underline
))))
399 "*Alist that says how to fontify certain phrases.
400 Each item looks like this:
402 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
404 The first element is a regular expression to be matched. The second
405 is a number that says what regular expression grouping used to find
406 the entire emphasized word. The third is a number that says what
407 regexp grouping should be displayed and highlighted. The fourth
408 is the face used for highlighting."
412 :format
"%[Customizing Style%]\n%v"
414 (group :tag
"Default"
415 :value
("" 0 0 default
)
418 (let ((value (widget-get
419 (cadr (widget-get (widget-get widget
:parent
)
422 (if (not (eq (nth 2 value
) 'default
))
426 (gnus-emphasis-custom-value-to-external value
))))
427 (widget-group-value-create widget
))
429 (integer :format
"Match group: %v")
430 (integer :format
"Emphasize group: %v")
433 :value
(("_" .
"_") nil default
)
435 (regexp :format
"Start regexp: %v")
436 (regexp :format
"End regexp: %v"))
437 (boolean :format
"Show start and end patterns: %[%v%]\n"
438 :on
" On " :off
" Off ")
440 :get
(lambda (symbol)
441 (mapcar 'gnus-emphasis-custom-value-to-internal
442 (default-value symbol
)))
443 :set
(lambda (symbol value
)
444 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
446 :group
'gnus-article-emphasis
)
448 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
449 "A regexp to describe whitespace which should not be emphasized.
450 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
451 The former avoids underlining of leading and trailing whitespace,
452 and the latter avoids underlining any whitespace at all."
454 :group
'gnus-article-emphasis
457 (defface gnus-emphasis-bold
'((t (:bold t
)))
458 "Face used for displaying strong emphasized text (*word*)."
459 :group
'gnus-article-emphasis
)
461 (defface gnus-emphasis-italic
'((t (:italic t
)))
462 "Face used for displaying italic emphasized text (/word/)."
463 :group
'gnus-article-emphasis
)
465 (defface gnus-emphasis-underline
'((t (:underline t
)))
466 "Face used for displaying underlined emphasized text (_word_)."
467 :group
'gnus-article-emphasis
)
469 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
470 "Face used for displaying underlined bold emphasized text (_*word*_)."
471 :group
'gnus-article-emphasis
)
473 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
474 "Face used for displaying underlined italic emphasized text (_/word/_)."
475 :group
'gnus-article-emphasis
)
477 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
478 "Face used for displaying bold italic emphasized text (/*word*/)."
479 :group
'gnus-article-emphasis
)
481 (defface gnus-emphasis-underline-bold-italic
482 '((t (:bold t
:italic t
:underline t
)))
483 "Face used for displaying underlined bold italic emphasized text.
484 Example: (_/*word*/_)."
485 :group
'gnus-article-emphasis
)
487 (defface gnus-emphasis-strikethru
(if (featurep 'xemacs
)
488 '((t (:strikethru t
)))
489 '((t (:strike-through t
))))
490 "Face used for displaying strike-through text (-word-)."
491 :group
'gnus-article-emphasis
)
493 (defface gnus-emphasis-highlight-words
494 '((t (:background
"black" :foreground
"yellow")))
495 "Face used for displaying highlighted words."
496 :group
'gnus-article-emphasis
)
498 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
499 "Format for display of Date headers in article bodies.
500 See `format-time-string' for the possible values.
502 The variable can also be function, which should return a complete Date
503 header. The function is called with one argument, the time, which can
504 be fed to `format-time-string'."
505 :type
'(choice string function
)
506 :link
'(custom-manual "(gnus)Article Date")
507 :group
'gnus-article-washing
)
509 (defcustom gnus-save-all-headers t
510 "*If non-nil, don't remove any headers before saving.
511 This will be overridden by the `:headers' property that the symbol of
512 the saver function, which is specified by `gnus-default-article-saver',
514 :group
'gnus-article-saving
517 (defcustom gnus-prompt-before-saving
'always
518 "*This variable says how much prompting is to be done when saving articles.
519 If it is nil, no prompting will be done, and the articles will be
520 saved to the default files. If this variable is `always', each and
521 every article that is saved will be preceded by a prompt, even when
522 saving large batches of articles. If this variable is neither nil not
523 `always', there the user will be prompted once for a file name for
524 each invocation of the saving commands."
525 :group
'gnus-article-saving
526 :type
'(choice (item always
)
527 (item :tag
"never" nil
)
528 (sexp :tag
"once" :format
"%t\n" :value t
)))
530 (defcustom gnus-saved-headers gnus-visible-headers
531 "Headers to keep if `gnus-save-all-headers' is nil.
532 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
533 If that variable is nil, however, all headers that match this regexp
534 will be kept while the rest will be deleted before saving. This and
535 `gnus-save-all-headers' will be overridden by the `:headers' property
536 that the symbol of the saver function, which is specified by
537 `gnus-default-article-saver', might have."
538 :group
'gnus-article-saving
541 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
542 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
543 "A function to save articles in your favorite format.
544 The function will be called by way of the `gnus-summary-save-article'
545 command, and friends such as `gnus-summary-save-article-rmail'.
547 Gnus provides the following functions:
549 * gnus-summary-save-in-rmail (Rmail format)
550 * gnus-summary-save-in-mail (Unix mail format)
551 * gnus-summary-save-in-folder (MH folder)
552 * gnus-summary-save-in-file (article format)
553 * gnus-summary-save-body-in-file (article body)
554 * gnus-summary-save-in-vm (use VM's folder format)
555 * gnus-summary-write-to-file (article format -- overwrite)
556 * gnus-summary-write-body-to-file (article body -- overwrite)
557 * gnus-summary-save-in-pipe (article format)
559 The symbol of each function may have the following properties:
562 The value non-nil means save decoded articles. This is meaningful
563 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
564 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
565 `gnus-summary-save-in-pipe'.
568 The value specifies an alternative function which appends, not
569 overwrites, articles to a file. This implies that when saving many
570 articles at a time, `gnus-prompt-before-saving' is bound to t and all
571 articles are saved in a single file. This is meaningful only with
572 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
575 The value specifies the symbol of a variable of which the value
576 specifies headers to be saved. If it is omitted,
577 `gnus-save-all-headers' and `gnus-saved-headers' control what
578 headers should be saved."
579 :group
'gnus-article-saving
580 :type
'(radio (function-item gnus-summary-save-in-rmail
)
581 (function-item gnus-summary-save-in-mail
)
582 (function-item gnus-summary-save-in-folder
)
583 (function-item gnus-summary-save-in-file
)
584 (function-item gnus-summary-save-body-in-file
)
585 (function-item gnus-summary-save-in-vm
)
586 (function-item gnus-summary-write-to-file
)
587 (function-item gnus-summary-write-body-to-file
)
588 (function-item gnus-summary-save-in-pipe
)
591 (defcustom gnus-article-save-coding-system
592 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
593 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
594 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
595 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
596 "Coding system used to save decoded articles to a file.
598 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
599 which can safely encode any characters in text. This is used by the
602 * gnus-summary-save-article-file
603 * gnus-summary-save-article-body-file
604 * gnus-summary-write-article-file
605 * gnus-summary-write-article-body-file
607 and the functions to which you may set `gnus-default-article-saver':
609 * gnus-summary-save-in-file
610 * gnus-summary-save-body-in-file
611 * gnus-summary-write-to-file
612 * gnus-summary-write-body-to-file
614 Those commands and functions save just text displayed in the article
615 buffer to a file if the value of this variable is non-nil. Note that
616 buttonized MIME parts will be lost in a saved file in that case.
617 Otherwise, raw articles will be saved."
618 :group
'gnus-article-saving
620 :format
"%{%t%}:\n %[Value Menu%] %v"
621 (const :tag
"Save raw articles" nil
)
624 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
625 '((const :tag
"UTF-8" utf-8
)
626 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
627 (const :tag
"Emacs internal" emacs-mule
)
628 (const :tag
"escape-quoted" escape-quoted
))))
629 (symbol :tag
"Coding system")))
631 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
632 "A function generating a file name to save articles in Rmail format.
633 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
634 :group
'gnus-article-saving
637 (defcustom gnus-mail-save-name
'gnus-plain-save-name
638 "A function generating a file name to save articles in Unix mail format.
639 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
640 :group
'gnus-article-saving
643 (defcustom gnus-folder-save-name
'gnus-folder-save-name
644 "A function generating a file name to save articles in MH folder.
645 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
646 :group
'gnus-article-saving
649 (defcustom gnus-file-save-name
'gnus-numeric-save-name
650 "A function generating a file name to save articles in article format.
651 The function is called with NEWSGROUP, HEADERS, and optional
653 :group
'gnus-article-saving
656 (defcustom gnus-split-methods
657 '((gnus-article-archive-name)
658 (gnus-article-nndoc-name))
659 "*Variable used to suggest where articles are to be saved.
660 For instance, if you would like to save articles related to Gnus in
661 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
662 you could set this variable to something like:
664 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
665 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
667 This variable is an alist where the key is the match and the
668 value is a list of possible files to save in if the match is
671 If the match is a string, it is used as a regexp match on the
672 article. If the match is a symbol, that symbol will be funcalled
673 from the buffer of the article to be saved with the newsgroup as the
674 parameter. If it is a list, it will be evalled in the same buffer.
676 If this form or function returns a string, this string will be used as a
677 possible file name; and if it returns a non-nil list, that list will be
678 used as possible file names."
679 :group
'gnus-article-saving
680 :type
'(repeat (choice (list :value
(fun) function
)
681 (cons :value
("" "") regexp
(repeat string
))
684 (defcustom gnus-page-delimiter
"^\^L"
685 "*Regexp describing what to use as article page delimiters.
686 The default value is \"^\^L\", which is a form linefeed at the
687 beginning of a line."
689 :group
'gnus-article-various
)
691 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
692 "*The format specification for the article mode line.
693 See `gnus-summary-mode-line-format' for a closer description.
695 The following additional specs are available:
697 %w The article washing status.
698 %m The number of MIME parts in the article."
701 :group
'gnus-article-various
)
703 (defcustom gnus-article-mode-hook nil
704 "*A hook for Gnus article mode."
706 :group
'gnus-article-various
)
708 (when (featurep 'xemacs
)
709 ;; Extracted from gnus-xmas-define in order to preserve user settings
710 (when (fboundp 'turn-off-scroll-in-place
)
711 (add-hook 'gnus-article-mode-hook
'turn-off-scroll-in-place
))
712 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
713 (add-hook 'gnus-article-mode-hook
'gnus-xmas-article-menu-add
))
715 (defcustom gnus-article-menu-hook nil
716 "*Hook run after the creation of the article mode menu."
718 :group
'gnus-article-various
)
720 (defcustom gnus-article-prepare-hook nil
721 "*A hook called after an article has been prepared in the article buffer."
723 :group
'gnus-article-various
)
725 (defcustom gnus-copy-article-ignored-headers nil
726 "List of headers to be removed when copying an article.
727 Each element is a regular expression."
728 :version
"23.1" ;; No Gnus
729 :type
'(repeat regexp
)
730 :group
'gnus-article-various
)
732 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
733 "Gnus 5.10 (Emacs 22.1)")
736 '((t (:weight bold
)))
737 "Face used for highlighting a button in the article buffer."
738 :group
'gnus-article-buttons
)
740 (defcustom gnus-article-button-face
'gnus-button
741 "Face used for highlighting buttons in the article buffer.
743 An article button is a piece of text that you can activate by pressing
744 `RET' or `mouse-2' above it."
746 :group
'gnus-article-buttons
)
748 (defcustom gnus-article-mouse-face
'highlight
749 "Face used for mouse highlighting in the article buffer.
751 Article buttons will be displayed in this face when the cursor is
754 :group
'gnus-article-buttons
)
756 (defcustom gnus-signature-face
'gnus-signature
757 "Face used for highlighting a signature in the article buffer.
758 Obsolete; use the face `gnus-signature' for customizations instead."
760 :group
'gnus-article-highlight
761 :group
'gnus-article-signature
)
763 (defface gnus-signature
766 "Face used for highlighting a signature in the article buffer."
767 :group
'gnus-article-highlight
768 :group
'gnus-article-signature
)
769 ;; backward-compatibility alias
770 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
771 (put 'gnus-signature-face
'obsolete-face
"22.1")
773 (defface gnus-header-from
776 (:foreground
"PaleGreen1"))
779 (:foreground
"red3"))
782 "Face used for displaying from headers."
783 :group
'gnus-article-headers
784 :group
'gnus-article-highlight
)
785 ;; backward-compatibility alias
786 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
787 (put 'gnus-header-from-face
'obsolete-face
"22.1")
789 (defface gnus-header-subject
792 (:foreground
"SeaGreen1"))
795 (:foreground
"red4"))
797 (:bold t
:italic t
)))
798 "Face used for displaying subject headers."
799 :group
'gnus-article-headers
800 :group
'gnus-article-highlight
)
801 ;; backward-compatibility alias
802 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
803 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
805 (defface gnus-header-newsgroups
808 (:foreground
"yellow" :italic t
))
811 (:foreground
"MidnightBlue" :italic t
))
814 "Face used for displaying newsgroups headers.
815 In the default setup this face is only used for crossposted
817 :group
'gnus-article-headers
818 :group
'gnus-article-highlight
)
819 ;; backward-compatibility alias
820 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
821 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
823 (defface gnus-header-name
826 (:foreground
"SpringGreen2"))
829 (:foreground
"maroon"))
832 "Face used for displaying header names."
833 :group
'gnus-article-headers
834 :group
'gnus-article-highlight
)
835 ;; backward-compatibility alias
836 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
837 (put 'gnus-header-name-face
'obsolete-face
"22.1")
839 (defface gnus-header-content
842 (:foreground
"SpringGreen1" :italic t
))
845 (:foreground
"indianred4" :italic t
))
847 (:italic t
))) "Face used for displaying header content."
848 :group
'gnus-article-headers
849 :group
'gnus-article-highlight
)
850 ;; backward-compatibility alias
851 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
852 (put 'gnus-header-content-face
'obsolete-face
"22.1")
854 (defcustom gnus-header-face-alist
855 '(("From" nil gnus-header-from
)
856 ("Subject" nil gnus-header-subject
)
857 ("Newsgroups:.*," nil gnus-header-newsgroups
)
858 ("" gnus-header-name gnus-header-content
))
859 "*Controls highlighting of article headers.
861 An alist of the form (HEADER NAME CONTENT).
863 HEADER is a regular expression which should match the name of a
864 header and NAME and CONTENT are either face names or nil.
866 The name of each header field will be displayed using the face
867 specified by the first element in the list where HEADER matches
868 the header name and NAME is non-nil. Similarly, the content will
869 be displayed by the first non-nil matching CONTENT face."
870 :group
'gnus-article-headers
871 :group
'gnus-article-highlight
872 :type
'(repeat (list (regexp :tag
"Header")
874 (item :tag
"skip" nil
)
875 (face :value default
))
876 (choice :tag
"Content"
877 (item :tag
"skip" nil
)
878 (face :value default
)))))
880 (defcustom gnus-face-properties-alist
(if (featurep 'xemacs
)
881 '((xface .
(:face gnus-x-face
)))
882 '((pbm .
(:face gnus-x-face
))
884 "Alist of image types and properties applied to Face and X-Face images.
887 ;; Specify the altitude of Face images in the From header.
888 \(setq gnus-face-properties-alist
889 '((pbm . (:face gnus-x-face :ascent 80))
890 (png . (:ascent 80))))
892 ;; Show Face images as pressed buttons.
893 \(setq gnus-face-properties-alist
894 '((pbm . (:face gnus-x-face :relief -2))
895 (png . (:relief -2))))
897 See the manual for the valid properties for various image types.
898 Currently, `pbm' is used for X-Face images and `png' is used for Face
899 images in Emacs. Only the `:face' property is effective on the `xface'
900 image type in XEmacs if it is built with the libcompface library."
901 :version
"23.1" ;; No Gnus
902 :group
'gnus-article-headers
903 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
905 (defcustom gnus-article-decode-hook
906 '(article-decode-charset article-decode-encoded-words
907 article-decode-group-name article-decode-idna-rhs
)
908 "*Hook run to decode charsets in articles."
909 :group
'gnus-article-headers
912 (defcustom gnus-display-mime-function
'gnus-display-mime
913 "Function to display MIME articles."
914 :group
'gnus-article-mime
917 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
918 "Function used to decode headers.")
920 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
921 "Function used to decode addresses.")
923 (defvar gnus-article-dumbquotes-map
943 "Table for MS-to-Latin1 translation.")
945 (defcustom gnus-ignored-mime-types nil
946 "List of MIME types that should be ignored by Gnus."
948 :group
'gnus-article-mime
949 :type
'(repeat regexp
))
951 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
952 "List of MIME types that should not be given buttons when rendered inline.
953 See also `gnus-buttonized-mime-types' which may override this variable.
954 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
956 :group
'gnus-article-mime
957 :type
'(repeat regexp
))
959 (defcustom gnus-buttonized-mime-types nil
960 "List of MIME types that should be given buttons when rendered inline.
961 If set, this variable overrides `gnus-unbuttonized-mime-types'.
962 To see e.g. security buttons you could set this to
963 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
964 this list to display radio buttons that allow you to choose one of two
965 media types those mails include. See also `mm-discouraged-alternatives'.
966 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
968 :group
'gnus-article-mime
969 :type
'(repeat regexp
))
971 (defcustom gnus-inhibit-mime-unbuttonizing nil
972 "If non-nil, all MIME parts get buttons.
973 When nil (the default value), then some MIME parts do not get buttons,
974 as described by the variables `gnus-buttonized-mime-types' and
975 `gnus-unbuttonized-mime-types'."
977 :group
'gnus-article-mime
980 (defcustom gnus-body-boundary-delimiter
"_"
981 "String used to delimit header and body.
982 This variable is used by `gnus-article-treat-body-boundary' which can
983 be controlled by `gnus-treat-body-boundary'."
985 :group
'gnus-article-various
986 :type
'(choice (item :tag
"None" :value nil
)
989 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
991 "Defines the location of the faces database.
992 For information on obtaining this database of pretty pictures, please
993 see http://www.cs.indiana.edu/picons/ftp/index.html"
995 :type
'(repeat directory
)
996 :link
'(url-link :tag
"download"
997 "http://www.cs.indiana.edu/picons/ftp/index.html")
998 :link
'(custom-manual "(gnus)Picons")
1001 (defun gnus-picons-installed-p ()
1002 "Say whether picons are installed on your machine."
1003 (let ((installed nil
))
1004 (dolist (database gnus-picon-databases
)
1005 (when (file-exists-p database
)
1006 (setq installed t
)))
1009 (defcustom gnus-article-mime-part-function nil
1010 "Function called with a MIME handle as the argument.
1011 This is meant for people who want to do something automatic based
1012 on parts -- for instance, adding Vcard info to a database."
1013 :group
'gnus-article-mime
1014 :type
'(choice (const nil
)
1017 (defcustom gnus-mime-multipart-functions nil
1018 "An alist of MIME types to functions to display them."
1020 :group
'gnus-article-mime
1021 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1023 (defcustom gnus-article-date-headers
'(combined-lapsed)
1024 "A list of Date header formats to display.
1025 Valid formats are `ut' (universal time), `local' (local time
1026 zone), `english' (readable English), `lapsed' (elapsed time),
1027 `combined-lapsed' (both the original date and the elapsed time),
1028 `original' (the original date header), `iso8601' (ISO8601
1029 format), and `user-defined' (a user-defined format defined by the
1030 `gnus-article-time-format' variable).
1032 You have as many date headers as you want in the article buffer.
1033 Some of these headers are updated automatically. See
1034 `gnus-article-update-date-headers' for details."
1036 :group
'gnus-article-headers
1038 (const :tag
"Universal time (UT)" ut
)
1039 (const :tag
"Local time zone" local
)
1040 (const :tag
"Readable English" english
)
1041 (const :tag
"Elapsed time" lapsed
)
1042 (const :tag
"Original and elapsed time" combined-lapsed
)
1043 (const :tag
"Original date header" original
)
1044 (const :tag
"ISO8601 format" iso8601
)
1045 (const :tag
"User-defined" user-defined
)))
1047 (defcustom gnus-article-update-date-headers nil
1048 "A number that says how often to update the date header (in seconds).
1049 If nil, don't update it at all."
1051 :group
'gnus-article-headers
1053 (item :tag
"Don't update" :value nil
)
1056 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1057 "Function called with a MIME handle as the argument.
1058 This is meant for people who want to view first matched part.
1059 For `undisplayed-alternative' (default), the first undisplayed
1060 part or alternative part is used. For `undisplayed', the first
1061 undisplayed part is used. For a function, the first part which
1062 the function return t is used. For nil, the first part is
1065 :group
'gnus-article-mime
1067 (item :tag
"first" :value nil
)
1068 (item :tag
"undisplayed" :value undisplayed
)
1069 (item :tag
"undisplayed or alternative"
1070 :value undisplayed-alternative
)
1073 (defcustom gnus-mime-action-alist
1074 '(("save to file" . gnus-mime-save-part
)
1075 ("save and strip" . gnus-mime-save-part-and-strip
)
1076 ("replace with file" . gnus-mime-replace-part
)
1077 ("delete part" . gnus-mime-delete-part
)
1078 ("display as text" . gnus-mime-inline-part
)
1079 ("view the part" . gnus-mime-view-part
)
1080 ("pipe to command" . gnus-mime-pipe-part
)
1081 ("toggle display" . gnus-article-press-button
)
1082 ("toggle display" . gnus-article-view-part-as-charset
)
1083 ("view as type" . gnus-mime-view-part-as-type
)
1084 ("view internally" . gnus-mime-view-part-internally
)
1085 ("view externally" . gnus-mime-view-part-externally
))
1086 "An alist of actions that run on the MIME attachment."
1087 :group
'gnus-article-mime
1088 :type
'(repeat (cons (string :tag
"name")
1091 (defcustom gnus-auto-select-part
1
1092 "Advance to next MIME part when deleting or stripping parts.
1094 When 0, point will be placed on the same part as before. When
1095 positive (negative), move point forward (backwards) this many
1096 parts. When nil, redisplay article."
1097 :version
"23.1" ;; No Gnus
1098 :group
'gnus-article-mime
1099 :type
'(choice (const nil
:tag
"Redisplay article.")
1100 (const 1 :tag
"Next part.")
1101 (const 0 :tag
"Current part.")
1105 ;;; The treatment variables
1108 (defvar gnus-part-display-hook nil
1109 "Hook called on parts that are to receive treatment.")
1111 (defvar gnus-article-treat-custom
1112 '(choice (const :tag
"Off" nil
)
1114 (const :tag
"Header" head
)
1115 (const :tag
"First" first
)
1116 (const :tag
"Last" last
)
1117 (integer :tag
"Less")
1118 (repeat :tag
"Groups" regexp
)
1119 (sexp :tag
"Predicate")))
1121 (defvar gnus-article-treat-head-custom
1122 '(choice (const :tag
"Off" nil
)
1123 (const :tag
"Header" head
)))
1125 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1126 "text/x-patch" "text/html")
1127 "Part types eligible for treatment.")
1129 (defvar gnus-inhibit-treatment nil
1130 "Whether to inhibit treatment.")
1132 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1133 "Highlight the signature.
1134 Valid values are nil, t, `head', `first', `last', an integer or a
1135 predicate. See Info node `(gnus)Customizing Articles'."
1136 :group
'gnus-article-treat
1137 :link
'(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom
)
1139 (put 'gnus-treat-highlight-signature
'highlight t
)
1141 (defcustom gnus-treat-buttonize
'(and 100000 (typep "text/plain"))
1143 Valid values are nil, t, `head', `first', `last', an integer or a
1144 predicate. See Info node `(gnus)Customizing Articles'."
1145 :group
'gnus-article-treat
1146 :link
'(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom
)
1148 (put 'gnus-treat-buttonize
'highlight t
)
1150 (defcustom gnus-treat-buttonize-head
'head
1151 "Add buttons to the head.
1152 Valid values are nil, t, `head', `first', `last', an integer or a
1153 predicate. See Info node `(gnus)Customizing Articles'."
1154 :group
'gnus-article-treat
1155 :link
'(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-head-custom
)
1157 (put 'gnus-treat-buttonize-head
'highlight t
)
1159 (defcustom gnus-treat-date
'head
1160 "Display dates according to the `gnus-article-date-headers' variable.
1161 Valid values are nil, t, `head', `first', `last', an integer or a
1162 predicate. See Info node `(gnus)Customizing Articles'."
1164 :group
'gnus-article-treat
1165 :link
'(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-head-custom
)
1168 (defcustom gnus-treat-emphasize
50000
1170 Valid values are nil, t, `head', `first', `last', an integer or a
1171 predicate. See Info node `(gnus)Customizing Articles'."
1172 :group
'gnus-article-treat
1173 :link
'(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom
)
1175 (put 'gnus-treat-emphasize
'highlight t
)
1177 (defcustom gnus-treat-strip-cr nil
1178 "Remove carriage returns.
1179 Valid values are nil, t, `head', `first', `last', an integer or a
1180 predicate. See Info node `(gnus)Customizing Articles'."
1182 :group
'gnus-article-treat
1183 :link
'(custom-manual "(gnus)Customizing Articles")
1184 :type gnus-article-treat-custom
)
1186 (defcustom gnus-treat-unsplit-urls nil
1187 "Remove newlines from within URLs.
1188 Valid values are nil, t, `head', `first', `last', an integer or a
1189 predicate. See Info node `(gnus)Customizing Articles'."
1191 :group
'gnus-article-treat
1192 :link
'(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-custom
)
1195 (defcustom gnus-treat-leading-whitespace nil
1196 "Remove leading whitespace in headers.
1197 Valid values are nil, t, `head', `first', `last', an integer or a
1198 predicate. See Info node `(gnus)Customizing Articles'."
1200 :group
'gnus-article-treat
1201 :link
'(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-custom
)
1204 (defcustom gnus-treat-hide-headers
'head
1206 Valid values are nil, t, `head', `first', `last', an integer or a
1207 predicate. See Info node `(gnus)Customizing Articles'."
1208 :group
'gnus-article-treat
1209 :link
'(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-head-custom
)
1212 (defcustom gnus-treat-hide-boring-headers nil
1213 "Hide boring headers.
1214 Valid values are nil, t, `head', `first', `last', an integer or a
1215 predicate. See Info node `(gnus)Customizing Articles'."
1216 :group
'gnus-article-treat
1217 :link
'(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-head-custom
)
1220 (defcustom gnus-treat-hide-signature nil
1221 "Hide the signature.
1222 Valid values are nil, t, `head', `first', `last', an integer or a
1223 predicate. See Info node `(gnus)Customizing Articles'."
1224 :group
'gnus-article-treat
1225 :link
'(custom-manual "(gnus)Customizing Articles")
1226 :type gnus-article-treat-custom
)
1228 (defcustom gnus-treat-fill-article nil
1230 Valid values are nil, t, `head', `first', `last', an integer or a
1231 predicate. See Info node `(gnus)Customizing Articles'."
1232 :group
'gnus-article-treat
1233 :link
'(custom-manual "(gnus)Customizing Articles")
1234 :type gnus-article-treat-custom
)
1236 (defcustom gnus-treat-hide-citation nil
1238 Valid values are nil, t, `head', `first', `last', an integer or a
1239 predicate. See Info node `(gnus)Customizing Articles'.
1241 See `gnus-article-highlight-citation' for variables used to
1242 control what it hides."
1243 :group
'gnus-article-treat
1244 :link
'(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom
)
1247 (defcustom gnus-treat-hide-citation-maybe nil
1248 "Hide cited text according to certain conditions.
1249 Valid values are nil, t, `head', `first', `last', an integer or a
1250 predicate. See Info node `(gnus)Customizing Articles'.
1252 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1253 how to control what it hides."
1254 :group
'gnus-article-treat
1255 :link
'(custom-manual "(gnus)Customizing Articles")
1256 :type gnus-article-treat-custom
)
1258 (defcustom gnus-treat-strip-list-identifiers
'head
1259 "Strip list identifiers from `gnus-list-identifiers'.
1260 Valid values are nil, t, `head', `first', `last', an integer or a
1261 predicate. See Info node `(gnus)Customizing Articles'."
1263 :group
'gnus-article-treat
1264 :link
'(custom-manual "(gnus)Customizing Articles")
1265 :type gnus-article-treat-custom
)
1267 (gnus-define-group-parameter
1270 "Alist of regexps and correspondent identifiers."
1271 :variable-group gnus-article-washing
1273 '(choice :tag
"Identifier"
1275 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1277 (const :tag
"None" nil
))
1279 "If non-nil, specify how to remove `identifiers' from articles' subject.
1281 Any symbol is used to look up a regular expression to match the
1282 banner in `gnus-list-identifiers'. A string is used as a regular
1283 expression to match the identifier directly.")
1285 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1286 "Gnus 5.10 (Emacs 22.1)")
1288 (defcustom gnus-treat-strip-pem nil
1289 "Strip PEM signatures.
1290 Valid values are nil, t, `head', `first', `last', an integer or a
1291 predicate. See Info node `(gnus)Customizing Articles'."
1292 :group
'gnus-article-treat
1293 :link
'(custom-manual "(gnus)Customizing Articles")
1294 :type gnus-article-treat-custom
)
1296 (defcustom gnus-treat-strip-banner t
1297 "Strip banners from articles.
1298 The banner to be stripped is specified in the `banner' group parameter.
1299 Valid values are nil, t, `head', `first', `last', an integer or a
1300 predicate. See Info node `(gnus)Customizing Articles'."
1301 :group
'gnus-article-treat
1302 :link
'(custom-manual "(gnus)Customizing Articles")
1303 :type gnus-article-treat-custom
)
1305 (defcustom gnus-treat-highlight-headers
'head
1306 "Highlight the headers.
1307 Valid values are nil, t, `head', `first', `last', an integer or a
1308 predicate. See Info node `(gnus)Customizing Articles'."
1309 :group
'gnus-article-treat
1310 :link
'(custom-manual "(gnus)Customizing Articles")
1311 :type gnus-article-treat-head-custom
)
1312 (put 'gnus-treat-highlight-headers
'highlight t
)
1314 (defcustom gnus-treat-highlight-citation t
1315 "Highlight cited text.
1316 Valid values are nil, t, `head', `first', `last', an integer or a
1317 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group
'gnus-article-treat
1319 :link
'(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom
)
1321 (put 'gnus-treat-highlight-citation
'highlight t
)
1323 (defcustom gnus-treat-strip-headers-in-body t
1324 "Strip the X-No-Archive header line from the beginning of the body.
1325 Valid values are nil, t, `head', `first', `last', an integer or a
1326 predicate. See Info node `(gnus)Customizing Articles'."
1328 :group
'gnus-article-treat
1329 :link
'(custom-manual "(gnus)Customizing Articles")
1330 :type gnus-article-treat-custom
)
1332 (defcustom gnus-treat-strip-trailing-blank-lines nil
1333 "Strip trailing blank lines.
1334 Valid values are nil, t, `head', `first', `last', an integer or a
1335 predicate. See Info node `(gnus)Customizing Articles'.
1337 When set to t, it also strips trailing blanks in all MIME parts.
1338 Consider to use `last' instead."
1339 :group
'gnus-article-treat
1340 :link
'(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom
)
1343 (defcustom gnus-treat-strip-leading-blank-lines nil
1344 "Strip leading blank lines.
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'.
1348 When set to t, it also strips trailing blanks in all MIME parts."
1349 :group
'gnus-article-treat
1350 :link
'(custom-manual "(gnus)Customizing Articles")
1351 :type gnus-article-treat-custom
)
1353 (defcustom gnus-treat-strip-multiple-blank-lines nil
1354 "Strip multiple blank lines.
1355 Valid values are nil, t, `head', `first', `last', an integer or a
1356 predicate. See Info node `(gnus)Customizing Articles'."
1357 :group
'gnus-article-treat
1358 :link
'(custom-manual "(gnus)Customizing Articles")
1359 :type gnus-article-treat-custom
)
1361 (defcustom gnus-treat-unfold-headers
'head
1362 "Unfold folded header lines.
1363 Valid values are nil, t, `head', `first', `last', an integer or a
1364 predicate. See Info node `(gnus)Customizing Articles'."
1366 :group
'gnus-article-treat
1367 :link
'(custom-manual "(gnus)Customizing Articles")
1368 :type gnus-article-treat-custom
)
1370 (defcustom gnus-article-unfold-long-headers nil
1371 "If non-nil, allow unfolding headers even if the header is long.
1372 If it is a regexp, only long headers matching this regexp are unfolded.
1373 If it is t, all long headers are unfolded.
1375 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1376 :version
"23.1" ;; No Gnus
1377 :group
'gnus-article-treat
1378 :type
'(choice (const nil
)
1379 (const :tag
"all" t
)
1382 (defcustom gnus-treat-fold-headers nil
1384 Valid values are nil, t, `head', `first', `last', an integer or a
1385 predicate. See Info node `(gnus)Customizing Articles'."
1387 :group
'gnus-article-treat
1388 :link
'(custom-manual "(gnus)Customizing Articles")
1389 :type gnus-article-treat-custom
)
1391 (defcustom gnus-treat-fold-newsgroups
'head
1392 "Fold the Newsgroups and Followup-To headers.
1393 Valid values are nil, t, `head', `first', `last', an integer or a
1394 predicate. See Info node `(gnus)Customizing Articles'."
1396 :group
'gnus-article-treat
1397 :link
'(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom
)
1400 (defcustom gnus-treat-overstrike t
1401 "Treat overstrike highlighting.
1402 Valid values are nil, t, `head', `first', `last', an integer or a
1403 predicate. See Info node `(gnus)Customizing Articles'."
1404 :group
'gnus-article-treat
1405 :link
'(custom-manual "(gnus)Customizing Articles")
1406 :type gnus-article-treat-custom
)
1407 (put 'gnus-treat-overstrike
'highlight t
)
1409 (defcustom gnus-treat-ansi-sequences
(if (locate-library "ansi-color") t
)
1410 "Treat ANSI SGR control sequences.
1411 Valid values are nil, t, `head', `first', `last', an integer or a
1412 predicate. See Info node `(gnus)Customizing Articles'."
1413 :group
'gnus-article-treat
1414 :link
'(custom-manual "(gnus)Customizing Articles")
1415 :type gnus-article-treat-custom
)
1417 (make-obsolete-variable 'gnus-treat-display-xface
1418 'gnus-treat-display-x-face
"Emacs 22.1")
1420 (defcustom gnus-treat-display-x-face
1421 (and (not noninteractive
)
1422 (gnus-image-type-available-p 'xbm
)
1423 (if (featurep 'xemacs
)
1426 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1427 (executable-find "icontopbm"))
1428 ;; shell-command-to-string may signal an error, e.g. if
1429 ;; shell-file-name is not found.
1432 "Display X-Face headers.
1433 Valid values are nil and `head'.
1434 See Info node `(gnus)Customizing Articles' and Info node
1435 `(gnus)X-Face' for details."
1436 :group
'gnus-article-treat
1438 :link
'(custom-manual "(gnus)Customizing Articles")
1439 :link
'(custom-manual "(gnus)X-Face")
1440 :type gnus-article-treat-head-custom
1441 :set
(lambda (symbol value
)
1444 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1446 ((boundp 'gnus-treat-display-xface
)
1448 ** gnus-treat-display-xface is an obsolete variable;\
1449 use gnus-treat-display-x-face instead")
1450 (default-value 'gnus-treat-display-xface
))
1451 ((get 'gnus-treat-display-xface
'saved-value
)
1453 ** gnus-treat-display-xface is an obsolete variable;\
1454 use gnus-treat-display-x-face instead")
1455 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1458 (put 'gnus-treat-display-x-face
'highlight t
)
1460 (defcustom gnus-treat-display-face
1461 (and (not noninteractive
)
1462 (gnus-image-type-available-p 'png
)
1464 "Display Face headers.
1465 Valid values are nil, t, `head', `first', `last', an integer or a
1466 predicate. See Info node `(gnus)Customizing Articles' and Info
1467 node `(gnus)Face' for details."
1468 :group
'gnus-article-treat
1470 :link
'(custom-manual "(gnus)Customizing Articles")
1471 :link
'(custom-manual "(gnus)X-Face")
1472 :type gnus-article-treat-head-custom
)
1473 (put 'gnus-treat-display-face
'highlight t
)
1475 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1477 Valid values are nil, t, `head', `first', `last', an integer or a
1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1479 node `(gnus)Smileys' for details."
1480 :group
'gnus-article-treat
1482 :link
'(custom-manual "(gnus)Customizing Articles")
1483 :link
'(custom-manual "(gnus)Smileys")
1484 :type gnus-article-treat-custom
)
1485 (put 'gnus-treat-display-smileys
'highlight t
)
1487 (defcustom gnus-treat-from-picon
1488 (if (and (gnus-image-type-available-p 'xpm
)
1489 (gnus-picons-installed-p))
1491 "Display picons in the From header.
1492 Valid values are nil, t, `head', `first', `last', an integer or a
1493 predicate. See Info node `(gnus)Customizing Articles' and Info
1494 node `(gnus)Picons' for details."
1496 :group
'gnus-article-treat
1498 :link
'(custom-manual "(gnus)Customizing Articles")
1499 :link
'(custom-manual "(gnus)Picons")
1500 :type gnus-article-treat-head-custom
)
1501 (put 'gnus-treat-from-picon
'highlight t
)
1503 (defcustom gnus-treat-mail-picon
1504 (if (and (gnus-image-type-available-p 'xpm
)
1505 (gnus-picons-installed-p))
1507 "Display picons in To and Cc headers.
1508 Valid values are nil, t, `head', `first', `last', an integer or a
1509 predicate. See Info node `(gnus)Customizing Articles' and Info
1510 node `(gnus)Picons' for details."
1512 :group
'gnus-article-treat
1514 :link
'(custom-manual "(gnus)Customizing Articles")
1515 :link
'(custom-manual "(gnus)Picons")
1516 :type gnus-article-treat-head-custom
)
1517 (put 'gnus-treat-mail-picon
'highlight t
)
1519 (defcustom gnus-treat-newsgroups-picon
1520 (if (and (gnus-image-type-available-p 'xpm
)
1521 (gnus-picons-installed-p))
1523 "Display picons in the Newsgroups and Followup-To headers.
1524 Valid values are nil, t, `head', `first', `last', an integer or a
1525 predicate. See Info node `(gnus)Customizing Articles' and Info
1526 node `(gnus)Picons' for details."
1528 :group
'gnus-article-treat
1530 :link
'(custom-manual "(gnus)Customizing Articles")
1531 :link
'(custom-manual "(gnus)Picons")
1532 :type gnus-article-treat-head-custom
)
1533 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1535 (defcustom gnus-treat-from-gravatar nil
1536 "Display gravatars in the From header.
1537 Valid values are nil, t, `head', `first', `last', an integer or a
1538 predicate. See Info node `(gnus)Customizing Articles' and Info
1539 node `(gnus)Gravatars' for details."
1541 :group
'gnus-article-treat
1542 :group
'gnus-gravatar
1543 :link
'(custom-manual "(gnus)Customizing Articles")
1544 :link
'(custom-manual "(gnus)Gravatars")
1545 :type gnus-article-treat-head-custom
)
1546 (put 'gnus-treat-from-gravatar
'highlight t
)
1548 (defcustom gnus-treat-mail-gravatar nil
1549 "Display gravatars in To and Cc headers.
1550 Valid values are nil, t, `head', `first', `last', an integer or a
1551 predicate. See Info node `(gnus)Customizing Articles' and Info
1552 node `(gnus)Gravatars' for details."
1554 :group
'gnus-article-treat
1555 :group
'gnus-gravatar
1556 :link
'(custom-manual "(gnus)Customizing Articles")
1557 :link
'(custom-manual "(gnus)Gravatars")
1558 :type gnus-article-treat-head-custom
)
1559 (put 'gnus-treat-mail-gravatar
'highlight t
)
1561 (defcustom gnus-treat-body-boundary
1562 (if (or gnus-treat-newsgroups-picon
1563 gnus-treat-mail-picon
1564 gnus-treat-from-picon
1565 gnus-treat-from-gravatar
1566 gnus-treat-mail-gravatar
)
1567 ;; If there's much decoration, the user might prefer a boundary.
1570 "Draw a boundary at the end of the headers.
1571 Valid values are nil and `head'.
1572 See Info node `(gnus)Customizing Articles' for details."
1574 :group
'gnus-article-treat
1575 :link
'(custom-manual "(gnus)Customizing Articles")
1576 :type gnus-article-treat-head-custom
)
1578 (defcustom gnus-treat-capitalize-sentences nil
1579 "Capitalize sentence-starting words.
1580 Valid values are nil, t, `head', `first', `last', an integer or a
1581 predicate. See Info node `(gnus)Customizing Articles'."
1583 :group
'gnus-article-treat
1584 :link
'(custom-manual "(gnus)Customizing Articles")
1585 :type gnus-article-treat-custom
)
1587 (defcustom gnus-treat-wash-html nil
1589 Valid values are nil, t, `head', `first', `last', an integer or a
1590 predicate. See Info node `(gnus)Customizing Articles'."
1592 :group
'gnus-article-treat
1593 :link
'(custom-manual "(gnus)Customizing Articles")
1594 :type gnus-article-treat-custom
)
1596 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1598 Valid values are nil, t, `head', `first', `last', an integer or a
1599 predicate. See Info node `(gnus)Customizing Articles'."
1601 :group
'gnus-article-treat
1602 :link
'(custom-manual "(gnus)Customizing Articles")
1603 :type gnus-article-treat-custom
)
1605 (defcustom gnus-treat-x-pgp-sig nil
1607 To automatically treat X-PGP-Sig, set it to head.
1608 Valid values are nil, t, `head', `first', `last', an integer or a
1609 predicate. See Info node `(gnus)Customizing Articles'."
1611 :group
'gnus-article-treat
1612 :group
'mime-security
1613 :link
'(custom-manual "(gnus)Customizing Articles")
1614 :type gnus-article-treat-custom
)
1616 (defvar gnus-article-encrypt-protocol-alist
1617 '(("PGP" . mml2015-self-encrypt
)))
1619 ;; Set to nil if more than one protocol added to
1620 ;; gnus-article-encrypt-protocol-alist.
1621 (defcustom gnus-article-encrypt-protocol
"PGP"
1622 "The protocol used for encrypt articles.
1623 It is a string, such as \"PGP\". If nil, ask user."
1626 :group
'mime-security
)
1628 (defvar idna-program
)
1630 (defcustom gnus-use-idna
(and (mm-coding-system-p 'utf-8
)
1634 (invalid-operation))
1636 (executable-find idna-program
))
1637 "Whether IDNA decoding of headers is used when viewing messages.
1638 This requires GNU Libidn, and by default only enabled if it is found."
1640 :group
'gnus-article-headers
1643 (defcustom gnus-article-over-scroll nil
1644 "If non-nil, allow scrolling the article buffer even when there no more text."
1646 :group
'gnus-article
1649 (defcustom gnus-inhibit-images nil
1650 "Non-nil means inhibit displaying of images inline in the article body."
1652 :group
'gnus-article
1655 (defcustom gnus-blocked-images
'gnus-block-private-groups
1656 "Images that have URLs matching this regexp will be blocked.
1657 This can also be a function to be evaluated. If so, it will be
1658 called with the group name as the parameter, and should return a
1662 :type
'(choice regexp function
))
1664 ;;; Internal variables
1666 (defvar gnus-english-month-names
1667 '("January" "February" "March" "April" "May" "June" "July" "August"
1668 "September" "October" "November" "December"))
1670 (defvar article-goto-body-goes-to-point-min-p nil
)
1671 (defvar gnus-article-wash-types nil
)
1672 (defvar gnus-article-emphasis-alist nil
)
1673 (defvar gnus-article-image-alist nil
)
1675 (defvar gnus-article-mime-handle-alist-1 nil
)
1676 (defvar gnus-treatment-function-alist
1677 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1678 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1679 (gnus-treat-strip-banner gnus-article-strip-banner
)
1680 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1681 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1682 (gnus-treat-buttonize gnus-article-add-buttons
)
1683 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1684 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1685 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1686 (gnus-treat-display-x-face gnus-article-display-x-face
)
1687 (gnus-treat-display-face gnus-article-display-face
)
1688 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1689 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1690 (gnus-treat-hide-signature gnus-article-hide-signature
)
1691 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1692 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1693 (gnus-treat-from-picon gnus-treat-from-picon
)
1694 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1695 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1696 (gnus-treat-strip-pem gnus-article-hide-pem
)
1697 (gnus-treat-date gnus-article-treat-date
)
1698 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1699 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1700 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1701 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1702 (gnus-treat-strip-trailing-blank-lines
1703 gnus-article-remove-trailing-blank-lines
)
1704 (gnus-treat-strip-leading-blank-lines
1705 gnus-article-strip-leading-blank-lines
)
1706 (gnus-treat-strip-multiple-blank-lines
1707 gnus-article-strip-multiple-blank-lines
)
1708 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1709 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1710 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1711 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1712 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1713 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1714 (gnus-treat-display-smileys gnus-treat-smiley
)
1715 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1716 (gnus-treat-wash-html gnus-article-wash-html
)
1717 (gnus-treat-emphasize gnus-article-emphasize
)
1718 (gnus-treat-hide-citation gnus-article-hide-citation
)
1719 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1720 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1721 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1723 (defvar gnus-article-mime-handle-alist nil
)
1724 (defvar article-lapsed-timer nil
)
1725 (defvar gnus-article-current-summary nil
)
1727 (defvar gnus-article-mode-syntax-table
1728 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1729 ;; This causes the citation match run O(2^n).
1730 ;; (modify-syntax-entry ?- "w" table)
1731 (modify-syntax-entry ?
> ")<" table
)
1732 (modify-syntax-entry ?
< "(>" table
)
1733 ;; make M-. in article buffers work for `foo' strings
1734 (modify-syntax-entry ?
' " " table
)
1735 (modify-syntax-entry ?
` " " table
)
1737 "Syntax table used in article mode buffers.
1738 Initialized from `text-mode-syntax-table'.")
1740 (defvar gnus-save-article-buffer nil
)
1742 (defvar gnus-number-of-articles-to-be-saved nil
)
1744 (defvar gnus-inhibit-hiding nil
)
1746 (defvar gnus-article-edit-mode nil
)
1748 ;;; Macros for dealing with the article buffer.
1750 (defmacro gnus-with-article-headers
(&rest forms
)
1751 `(with-current-buffer gnus-article-buffer
1753 (let ((inhibit-read-only t
)
1754 (inhibit-point-motion-hooks t
)
1755 (case-fold-search t
))
1756 (article-narrow-to-head)
1759 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1760 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1762 (defmacro gnus-with-article-buffer
(&rest forms
)
1763 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1764 (with-current-buffer gnus-article-buffer
1765 (let ((inhibit-read-only t
))
1768 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1769 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1771 (defun gnus-article-goto-header (header)
1772 "Go to HEADER, which is a regular expression."
1773 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1775 (defsubst gnus-article-hide-text
(b e props
)
1776 "Set text PROPS on the B to E region."
1777 (gnus-add-text-properties-when 'article-type nil b e props
))
1779 (defsubst gnus-article-unhide-text
(b e
)
1780 "Remove hidden text properties from region between B and E."
1781 (remove-text-properties b e gnus-hidden-properties
))
1783 (defun gnus-article-hide-text-type (b e type
)
1784 "Hide text of TYPE between B and E."
1785 (gnus-add-wash-type type
)
1786 (gnus-article-hide-text
1787 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1789 (defun gnus-article-unhide-text-type (b e type
)
1790 "Unhide text of TYPE between B and E."
1791 (gnus-delete-wash-type type
)
1792 (remove-text-properties
1793 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1795 (defun gnus-article-delete-text-of-type (type)
1796 "Delete text of TYPE in the current buffer."
1798 (let ((b (point-min)))
1799 (if (eq type
'multipart
)
1800 ;; Remove MIME buttons associated with multipart/alternative parts.
1803 (while (if (get-text-property (point) 'gnus-part
)
1805 (when (setq b
(next-single-property-change (point)
1810 (skip-chars-forward "\n")
1811 (when (eq (get-text-property b
'article-type
) 'multipart
)
1812 (delete-region b
(point)))))
1813 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1815 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1818 (defun gnus-article-delete-invisible-text ()
1819 "Delete all invisible text in the current buffer."
1821 (let ((b (point-min)))
1822 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1824 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1827 (defsubst gnus-article-header-rank
()
1828 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1829 (let ((list gnus-sorted-header-list
)
1832 (if (looking-at (car list
))
1834 (setq list
(cdr list
))
1838 (defun article-hide-headers (&optional _arg _delete
)
1839 "Hide unwanted headers and possibly sort them as well."
1841 ;; This function might be inhibited.
1842 (unless gnus-inhibit-hiding
1843 (let ((inhibit-read-only t
)
1844 (case-fold-search t
)
1845 (max (1+ (length gnus-sorted-header-list
)))
1846 (inhibit-point-motion-hooks t
)
1847 (cur (current-buffer))
1848 ignored visible beg
)
1850 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1851 ;; group parameters, so we should go to the summary buffer.
1854 (progn (set-buffer gnus-summary-buffer
) t
)
1856 (setq ignored
(when (not gnus-visible-headers
)
1857 (cond ((stringp gnus-ignored-headers
)
1858 gnus-ignored-headers
)
1859 ((listp gnus-ignored-headers
)
1860 (mapconcat 'identity
1861 gnus-ignored-headers
1863 visible
(cond ((stringp gnus-visible-headers
)
1864 gnus-visible-headers
)
1865 ((and gnus-visible-headers
1866 (listp gnus-visible-headers
))
1867 (mapconcat 'identity
1868 gnus-visible-headers
1872 ;; First we narrow to just the headers.
1873 (article-narrow-to-head)
1874 ;; Hide any "From " lines at the beginning of (mail) articles.
1875 (while (looking-at "From ")
1878 (delete-region (point-min) (point)))
1879 ;; Then treat the rest of the header lines.
1880 ;; Then we use the two regular expressions
1881 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1882 ;; select which header lines is to remain visible in the
1884 (while (re-search-forward "^[^ \t:]*:" nil t
)
1886 ;; Mark the rank of the header.
1888 (point) (1+ (point)) 'message-rank
1889 (if (or (and visible
(looking-at visible
))
1891 (not (looking-at ignored
))))
1892 (gnus-article-header-rank)
1895 (message-sort-headers-1)
1896 (when (setq beg
(text-property-any
1897 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1898 ;; We delete the unwanted headers.
1899 (gnus-add-wash-type 'headers
)
1900 (add-text-properties (point-min) (+ 5 (point-min))
1901 '(article-type headers dummy-invisible t
))
1902 (delete-region beg
(point-max))))))))
1904 (defun article-hide-boring-headers (&optional arg
)
1905 "Toggle hiding of headers that aren't very interesting.
1906 If given a negative prefix, always show; if given a positive prefix,
1908 (interactive (gnus-article-hidden-arg))
1909 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1910 (not gnus-show-all-headers
))
1913 (let ((inhibit-read-only t
)
1914 (inhibit-point-motion-hooks t
))
1915 (article-narrow-to-head)
1916 (dolist (elem gnus-boring-article-headers
)
1917 (goto-char (point-min))
1919 ;; Hide empty headers.
1921 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1923 (gnus-article-hide-text-type
1927 (if (re-search-forward "^[^ \t]" nil t
)
1931 ;; Hide boring Newsgroups header.
1932 ((eq elem
'newsgroups
)
1933 (when (gnus-string-equal
1934 (gnus-fetch-field "newsgroups")
1935 (gnus-group-real-name
1936 (if (boundp 'gnus-newsgroup-name
)
1939 (gnus-article-hide-header "newsgroups")))
1940 ((eq elem
'to-address
)
1941 (let ((to (message-fetch-field "to"))
1943 (gnus-parameter-to-address
1944 (if (boundp 'gnus-newsgroup-name
)
1945 gnus-newsgroup-name
""))))
1946 (when (and to to-address
1949 ;; only one address in To
1950 (nth 1 (mail-extract-address-components to
))
1952 (gnus-article-hide-header "to"))))
1954 (let ((to (message-fetch-field "to"))
1956 (gnus-parameter-to-list
1957 (if (boundp 'gnus-newsgroup-name
)
1958 gnus-newsgroup-name
""))))
1959 (when (and to to-list
1962 ;; only one address in To
1963 (nth 1 (mail-extract-address-components to
))
1965 (gnus-article-hide-header "to"))))
1967 (let ((cc (message-fetch-field "cc"))
1969 (gnus-parameter-to-list
1970 (if (boundp 'gnus-newsgroup-name
)
1971 gnus-newsgroup-name
""))))
1972 (when (and cc to-list
1975 ;; only one address in CC
1976 (nth 1 (mail-extract-address-components cc
))
1978 (gnus-article-hide-header "cc"))))
1979 ((eq elem
'followup-to
)
1980 (when (gnus-string-equal
1981 (message-fetch-field "followup-to")
1982 (message-fetch-field "newsgroups"))
1983 (gnus-article-hide-header "followup-to")))
1984 ((eq elem
'reply-to
)
1985 (if (gnus-group-find-parameter
1986 gnus-newsgroup-name
'broken-reply-to
)
1987 (gnus-article-hide-header "reply-to")
1988 (let ((from (message-fetch-field "from"))
1989 (reply-to (message-fetch-field "reply-to")))
1996 (lambda (x) (downcase (cadr x
)))
1997 (mail-extract-address-components from t
))
2000 (lambda (x) (downcase (cadr x
)))
2001 (mail-extract-address-components reply-to t
))
2003 (gnus-article-hide-header "reply-to")))))
2005 (let ((date (with-current-buffer gnus-original-article-buffer
2006 ;; If date in `gnus-article-buffer' is localized
2007 ;; (`gnus-treat-date-user-defined'),
2008 ;; `days-between' might fail.
2009 (message-fetch-field "date"))))
2011 (< (days-between (current-time-string) date
)
2013 (gnus-article-hide-header "date"))))
2015 (let ((to (message-fetch-field "to"))
2016 (cc (message-fetch-field "cc")))
2017 (when (> (length to
) 1024)
2018 (gnus-article-hide-header "to"))
2019 (when (> (length cc
) 1024)
2020 (gnus-article-hide-header "cc"))))
2024 (goto-char (point-min))
2025 (while (re-search-forward "^to:" nil t
)
2026 (setq to-count
(1+ to-count
)))
2027 (when (> to-count
1)
2028 (while (> to-count
0)
2029 (goto-char (point-min))
2031 (re-search-forward "^to:" nil nil to-count
)
2033 (narrow-to-region (point) (point-max))
2034 (gnus-article-hide-header "to"))
2035 (setq to-count
(1- to-count
))))
2036 (goto-char (point-min))
2037 (while (re-search-forward "^cc:" nil t
)
2038 (setq cc-count
(1+ cc-count
)))
2039 (when (> cc-count
1)
2040 (while (> cc-count
0)
2041 (goto-char (point-min))
2043 (re-search-forward "^cc:" nil nil cc-count
)
2045 (narrow-to-region (point) (point-max))
2046 (gnus-article-hide-header "cc"))
2047 (setq cc-count
(1- cc-count
)))))))))))))
2049 (defun gnus-article-hide-header (header)
2051 (goto-char (point-min))
2052 (when (re-search-forward (concat "^" header
":") nil t
)
2053 (gnus-article-hide-text-type
2057 (if (re-search-forward "^[^ \t]" nil t
)
2062 (defvar gnus-article-normalized-header-length
40
2063 "Length of normalized headers.")
2065 (defun article-normalize-headers ()
2066 "Make all header lines 40 characters long."
2068 (let ((inhibit-read-only t
)
2072 (article-narrow-to-head)
2075 ((< (setq column
(- (point-at-eol) (point)))
2076 gnus-article-normalized-header-length
)
2078 (insert (make-string
2079 (- gnus-article-normalized-header-length column
)
2081 ((> column gnus-article-normalized-header-length
)
2082 (gnus-put-text-property
2084 (forward-char gnus-article-normalized-header-length
)
2091 (forward-line 1))))))
2093 (defun article-treat-dumbquotes ()
2094 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2095 Note that this function guesses whether a character is a sm*rtq**t* or
2096 not, so it should only be used interactively.
2098 Sm*rtq**t*s are M****s***'s unilateral extension to the
2099 iso-8859-1 character map in an attempt to provide more quoting
2100 characters. If you see something like \\222 or \\264 where
2101 you're expecting some kind of apostrophe or quotation mark, then
2104 (article-translate-strings gnus-article-dumbquotes-map
))
2106 (defvar org-entities
)
2108 (defun article-treat-non-ascii ()
2109 "Translate many Unicode characters into their ASCII equivalents."
2111 (require 'org-entities
)
2112 (let ((table (make-char-table (if (featurep 'xemacs
) 'generic
))))
2113 (dolist (elem org-entities
)
2114 (when (and (listp elem
)
2115 (= (length (nth 6 elem
)) 1))
2116 (if (featurep 'xemacs
)
2117 (put-char-table (aref (nth 6 elem
) 0) (nth 4 elem
) table
)
2118 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
)))))
2120 (when (article-goto-body)
2121 (let ((inhibit-read-only t
)
2124 (if (not (setq replace
(if (featurep 'xemacs
)
2125 (get-char-table (following-char) table
)
2126 (aref table
(following-char)))))
2129 (setq props
(text-properties-at (point)))
2131 (add-text-properties (point) (progn (insert replace
) (point))
2133 (insert replace
)))))))))
2135 (defun article-translate-strings (map)
2136 "Translate all string in the body of the article according to MAP.
2137 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2139 (when (article-goto-body)
2140 (let ((inhibit-read-only t
))
2142 (let ((from (car elem
))
2146 (while (search-forward from nil t
)
2149 (if (eq (following-char) from
)
2153 (forward-char 1)))))))))))
2155 (defun article-treat-overstrike ()
2156 "Translate overstrikes into bold text."
2159 (when (article-goto-body)
2160 (let ((inhibit-read-only t
))
2161 (while (search-forward "\b" nil t
)
2162 (let ((next (char-after))
2163 (previous (char-after (- (point) 2))))
2164 ;; We do the boldification/underlining by hiding the
2165 ;; overstrikes and putting the proper text property
2169 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2170 (put-text-property (point) (1+ (point)) 'face
'bold
))
2172 (gnus-article-hide-text-type
2173 (1- (point)) (1+ (point)) 'overstrike
)
2175 (- (point) 2) (1- (point)) 'face
'underline
))
2177 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2179 (point) (1+ (point)) 'face
'underline
)))))))))
2181 (defun article-treat-ansi-sequences ()
2182 "Translate ANSI SGR control sequences into overlays or extents."
2185 (when (article-goto-body)
2186 (let ((inhibit-read-only t
))
2187 (ansi-color-apply-on-region (point) (point-max))))))
2189 (defun gnus-article-treat-unfold-headers ()
2190 "Unfold folded message headers.
2191 Only the headers that fit into the current window width will be
2194 (gnus-with-article-headers
2198 (mail-header-narrow-to-field)
2199 (let* ((header (buffer-string))
2201 (or (equal gnus-article-unfold-long-headers t
)
2202 (and (stringp gnus-article-unfold-long-headers
)
2203 (string-match gnus-article-unfold-long-headers
2207 (goto-char (point-min))
2208 (while (re-search-forward "\n[\t ]" nil t
)
2209 (replace-match " " t t
)))
2210 (setq length
(- (point-max) (point-min) 1))
2211 (when (or unfoldable
2212 (< length
(window-width)))
2213 (while (re-search-forward "\n[\t ]" nil t
)
2214 (replace-match " " t t
))))
2215 (goto-char (point-max)))))))
2217 (defun gnus-article-treat-fold-headers ()
2218 "Fold message headers."
2220 (gnus-with-article-headers
2223 (mail-header-narrow-to-field)
2224 (mail-header-fold-field)
2225 (goto-char (point-max))))))
2227 (defun gnus-treat-smiley ()
2228 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2230 (gnus-with-article-buffer
2231 (if (memq 'smiley gnus-article-wash-types
)
2232 (gnus-delete-images 'smiley
)
2234 (let ((images (smiley-region (point) (point-max))))
2236 (gnus-add-wash-type 'smiley
)
2237 (dolist (image images
)
2238 (gnus-add-image 'smiley image
)))))))
2240 (defun gnus-article-remove-images ()
2241 "Remove all images from the article buffer."
2243 (gnus-with-article-buffer
2246 (dolist (elem gnus-article-image-alist
)
2247 (gnus-delete-images (car elem
))))))
2249 (autoload 'w3m-toggle-inline-images
"w3m")
2251 (defun gnus-article-show-images ()
2252 "Show any images that are in the HTML-rendered article buffer.
2253 This only works if the article in question is HTML."
2255 (gnus-with-article-buffer
2258 (if (eq mm-text-html-renderer
'w3m
)
2259 (let ((mm-inline-text-html-with-images nil
))
2260 (w3m-toggle-inline-images))
2261 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2263 (destructuring-bind (start end function
) region
2264 (funcall function
(get-text-property start
'image-url
)
2267 (defun gnus-article-treat-fold-newsgroups ()
2268 "Unfold folded message headers.
2269 Only the headers that fit into the current window width will be
2272 (gnus-with-article-headers
2273 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2275 (mail-header-narrow-to-field)
2276 (while (re-search-forward ", *" nil t
)
2277 (replace-match ", " t t
))
2278 (mail-header-fold-field)
2279 (goto-char (point-max))))))
2281 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2282 "Value of `truncate-lines' in Gnus Article buffer.
2283 Valid values are nil, t, `head', `first', `last', an integer or a
2284 predicate. See Info node `(gnus)Customizing Articles'."
2285 :version
"23.1" ;; No Gnus
2286 :group
'gnus-article
2287 ;; :link '(custom-manual "(gnus)Customizing Articles")
2290 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2291 "Toggle whether to fold or truncate long lines in article the buffer.
2292 If ARG is non-nil and not a number, toggle
2293 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2294 long lines if and only if arg is positive."
2297 ((and (numberp arg
) (> arg
0))
2298 (setq gnus-article-truncate-lines t
))
2300 (setq gnus-article-truncate-lines nil
))
2302 (setq gnus-article-truncate-lines
2303 (not gnus-article-truncate-lines
))))
2304 (gnus-with-article-buffer
2306 ((and (numberp arg
) (> arg
0))
2307 (setq truncate-lines nil
))
2309 (setq truncate-lines t
)))
2310 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2311 ;; `toggle-truncate-lines' needs an argument.
2312 (toggle-truncate-lines)))
2314 (defun gnus-article-treat-body-boundary ()
2315 "Place a boundary line at the end of the headers."
2317 (when (and gnus-body-boundary-delimiter
2318 (> (length gnus-body-boundary-delimiter
) 0))
2319 (gnus-with-article-headers
2320 (goto-char (point-max))
2321 (let ((start (point)))
2322 (insert "X-Boundary: ")
2323 (gnus-add-text-properties start
(point) gnus-hidden-properties
)
2324 (insert (let (str (max (window-width)))
2325 (if (featurep 'xemacs
)
2326 (setq max
(1- max
)))
2327 (while (>= max
(length str
))
2328 (setq str
(concat str gnus-body-boundary-delimiter
)))
2329 (substring str
0 max
))
2331 (gnus-put-text-property start
(point) 'gnus-decoration
'header
)))))
2333 (defun article-fill-long-lines ()
2334 "Fill lines that are wider than the window width."
2337 (let ((inhibit-read-only t
)
2338 (width (window-width (get-buffer-window (current-buffer)))))
2341 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2344 (when (>= (current-column) (min fill-column width
))
2345 (narrow-to-region (min (1+ (point)) (point-max))
2347 (let ((goback (point-marker)))
2348 (fill-paragraph nil
)
2349 (goto-char (marker-position goback
)))
2351 (forward-line 1)))))))
2353 (defun article-capitalize-sentences ()
2354 "Capitalize the first word in each sentence."
2357 (let ((inhibit-read-only t
)
2358 (paragraph-start "^[\n\^L]"))
2362 (forward-sentence)))))
2364 (defun article-remove-cr ()
2365 "Remove trailing CRs and then translate remaining CRs into LFs."
2368 (let ((inhibit-read-only t
))
2369 (goto-char (point-min))
2370 (while (re-search-forward "\r+$" nil t
)
2371 (replace-match "" t t
))
2372 (goto-char (point-min))
2373 (while (search-forward "\r" nil t
)
2374 (replace-match "\n" t t
)))))
2376 (defun article-remove-trailing-blank-lines ()
2377 "Remove all trailing blank lines from the article."
2380 (let ((inhibit-read-only t
))
2381 (goto-char (point-max))
2385 (while (and (not (bobp))
2386 (looking-at "^[ \t]*$")
2387 (not (gnus-annotation-in-region-p
2388 (point) (point-at-eol))))
2393 (defvar gnus-face-properties-alist
)
2395 (defun article-display-face (&optional force
)
2396 "Display any Face headers in the header."
2397 (interactive (list 'force
))
2398 (let ((wash-face-p buffer-read-only
))
2399 (gnus-with-article-headers
2400 ;; When displaying parts, this function can be called several times on
2401 ;; the same article, without any intended toggle semantic (as typing `W
2402 ;; D d' would have). So face deletion must occur only when we come from
2403 ;; an interactive command, that is when the *Article* buffer is
2405 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2406 (gnus-delete-images 'face
)
2407 (let ((from (message-fetch-field "from"))
2409 (save-current-buffer
2410 (when (and wash-face-p
2411 (gnus-buffer-live-p gnus-original-article-buffer
)
2412 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2413 (set-buffer gnus-original-article-buffer
))
2415 (mail-narrow-to-head)
2417 ;; Check whether this face is censored.
2418 (not (and gnus-article-x-face-too-ugly
2420 (setq from
(message-fetch-field "from")))
2421 (string-match gnus-article-x-face-too-ugly
2423 (while (gnus-article-goto-header "Face")
2424 (push (mail-header-field-value) faces
)))))
2426 (goto-char (point-min))
2428 (unless (setq from
(gnus-article-goto-header "from"))
2431 (insert " [no `from' set]\n"))
2433 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2435 (apply 'gnus-create-image png
'png t
2436 (cdr (assq 'png gnus-face-properties-alist
))))
2439 (gnus-add-wash-type 'face
)
2440 (gnus-add-image 'face image
)
2441 (gnus-put-image image nil
'face
)))))))))))
2443 (defun article-display-x-face (&optional force
)
2444 "Look for an X-Face header and display it if present."
2445 (interactive (list 'force
))
2446 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2447 (gnus-with-article-headers
2448 ;; Delete the old process, if any.
2449 (when (process-status "article-x-face")
2450 (delete-process "article-x-face"))
2451 ;; See the comment in `article-display-face'.
2452 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2453 ;; We have already displayed X-Faces, so we remove them
2455 (gnus-delete-images 'xface
)
2457 (let ((from (message-fetch-field "from"))
2459 (save-current-buffer
2460 (when (and wash-face-p
2461 (gnus-buffer-live-p gnus-original-article-buffer
)
2462 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2463 ;; If type `W f', use gnus-original-article-buffer,
2464 ;; otherwise use the current buffer because displaying
2465 ;; RFC822 parts calls this function too.
2466 (set-buffer gnus-original-article-buffer
))
2468 (mail-narrow-to-head)
2469 (and gnus-article-x-face-command
2471 ;; Check whether this face is censored.
2472 (not (and gnus-article-x-face-too-ugly
2474 (setq from
(message-fetch-field "from")))
2475 (string-match gnus-article-x-face-too-ugly
2477 (while (gnus-article-goto-header "X-Face")
2478 (push (mail-header-field-value) x-faces
)))))
2480 ;; We display the face.
2481 (cond ((functionp gnus-article-x-face-command
)
2482 ;; The command is a lisp function, so we call it.
2483 (mapc gnus-article-x-face-command x-faces
))
2484 ((stringp gnus-article-x-face-command
)
2485 ;; The command is a string, so we interpret the command
2486 ;; as a, well, command, and fork it off.
2487 (let ((process-connection-type nil
))
2488 (gnus-set-process-query-on-exit-flag
2490 "article-x-face" nil shell-file-name
2491 shell-command-switch gnus-article-x-face-command
)
2493 ;; Sending multiple EOFs to xv doesn't work,
2494 ;; so we only do a single external face.
2496 (insert (car x-faces
))
2497 (process-send-region "article-x-face"
2498 (point-min) (point-max)))
2499 (process-send-eof "article-x-face")))
2501 (error "`%s' set to `%s' is not a function"
2502 gnus-article-x-face-command
2503 'gnus-article-x-face-command
)))))))))
2505 (defun article-decode-mime-words ()
2506 "Decode all MIME-encoded words in the article."
2508 (gnus-with-article-buffer
2509 (let ((inhibit-point-motion-hooks t
)
2510 (mail-parse-charset gnus-newsgroup-charset
)
2511 (mail-parse-ignored-charsets
2512 (with-current-buffer gnus-summary-buffer
2513 gnus-newsgroup-ignored-charsets
)))
2514 (mail-decode-encoded-word-region (point-min) (point-max)))))
2516 (defun article-decode-charset (&optional prompt
)
2517 "Decode charset-encoded text in the article.
2518 If PROMPT (the prefix), prompt for a coding system to use."
2520 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2521 (inhibit-read-only t
)
2522 (mail-parse-charset gnus-newsgroup-charset
)
2523 (mail-parse-ignored-charsets
2524 (save-excursion (condition-case nil
2525 (set-buffer gnus-summary-buffer
)
2527 gnus-newsgroup-ignored-charsets
))
2528 ct cte ctl charset format
)
2531 (article-narrow-to-head)
2532 (setq ct
(message-fetch-field "Content-Type" t
)
2533 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2534 ctl
(and ct
(mail-header-parse-content-type ct
))
2537 (mm-read-coding-system "Charset to decode: "))
2539 (mail-content-type-get ctl
'charset
)))
2540 format
(and ctl
(mail-content-type-get ctl
'format
)))
2542 (setq cte
(mail-header-strip cte
)))
2543 (if (and ctl
(not (string-match "/" (car ctl
))))
2545 (goto-char (point-max)))
2548 (narrow-to-region (point) (point-max))
2549 (when (and (eq mail-parse-charset
'gnus-decoded
)
2550 (eq (mm-body-7-or-8) '8bit
))
2551 ;; The text code could have been decoded.
2552 (setq charset mail-parse-charset
))
2553 (when (and (or (not ctl
)
2554 (equal (car ctl
) "text/plain"))
2555 (not format
)) ;; article with format will decode later.
2557 charset
(and cte
(intern (downcase
2558 (gnus-strip-whitespace cte
))))
2561 (defun article-decode-encoded-words ()
2562 "Remove encoded-word encoding from headers."
2563 (let ((inhibit-point-motion-hooks t
)
2564 (mail-parse-charset gnus-newsgroup-charset
)
2565 (mail-parse-ignored-charsets
2566 (save-excursion (condition-case nil
2567 (set-buffer gnus-summary-buffer
)
2569 gnus-newsgroup-ignored-charsets
))
2570 (inhibit-read-only t
)
2572 (goto-char (point-min))
2573 (when (search-forward "\n\n" nil
'move
)
2580 (memq (char-after) '(?
\t ?
)))))
2581 (setq start
(point))
2583 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2584 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2585 (funcall gnus-decode-address-function start end
)
2586 (funcall gnus-decode-header-function start end
))
2587 (goto-char (setq end start
)))))
2589 (defun article-decode-group-name ()
2590 "Decode group names in Newsgroups, Followup-To and Xref headers."
2591 (let ((inhibit-point-motion-hooks t
)
2592 (inhibit-read-only t
)
2593 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2595 (when (and (or gnus-group-name-charset-method-alist
2596 gnus-group-name-charset-group-alist
)
2597 (gnus-buffer-live-p gnus-original-article-buffer
))
2599 (article-narrow-to-head)
2600 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2601 (with-current-buffer gnus-original-article-buffer
2602 (goto-char (point-min)))
2603 (setq regexp
(concat "^" header
2604 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2605 (while (re-search-forward regexp nil t
)
2606 (replace-match (save-match-data
2607 (gnus-decode-newsgroups
2608 ;; XXX how to use data in article buffer?
2609 (with-current-buffer gnus-original-article-buffer
2610 (re-search-forward regexp nil t
)
2612 gnus-newsgroup-name method
))
2614 (goto-char (point-min)))))))
2616 (autoload 'idna-to-unicode
"idna")
2618 (defun article-decode-idna-rhs ()
2619 "Decode IDNA strings in RHS in various headers in current buffer.
2620 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2621 Mail-Reply-To: and Mail-Followup-To:."
2624 (let ((inhibit-point-motion-hooks t
)
2625 (inhibit-read-only t
))
2626 (article-narrow-to-head)
2627 (goto-char (point-min))
2628 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2630 (when (save-match-data
2631 (and (setq ace
(match-string 1))
2633 (and (re-search-backward "^[^ \t]" nil t
)
2634 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2635 (setq unicode
(idna-to-unicode ace
))))
2636 (unless (string= ace unicode
)
2637 (replace-match unicode nil nil nil
1)))))))))
2639 (defun article-de-quoted-unreadable (&optional force read-charset
)
2640 "Translate a quoted-printable-encoded article.
2641 If FORCE, decode the article whether it is marked as quoted-printable
2643 If READ-CHARSET, ask for a coding system."
2644 (interactive (list 'force current-prefix-arg
))
2646 (let ((inhibit-read-only t
) type charset
)
2647 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2648 (with-current-buffer gnus-original-article-buffer
2650 (gnus-fetch-field "content-transfer-encoding"))
2651 (let* ((ct (gnus-fetch-field "content-type"))
2652 (ctl (and ct
(mail-header-parse-content-type ct
))))
2653 (setq charset
(and ctl
2654 (mail-content-type-get ctl
'charset
)))
2655 (if (stringp charset
)
2656 (setq charset
(intern (downcase charset
)))))))
2658 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2660 (setq charset gnus-newsgroup-charset
))
2662 (and type
(let ((case-fold-search t
))
2663 (string-match "quoted-printable" type
))))
2665 (quoted-printable-decode-region
2666 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2668 (defun article-de-base64-unreadable (&optional force read-charset
)
2669 "Translate a base64 article.
2670 If FORCE, decode the article whether it is marked as base64 not.
2671 If READ-CHARSET, ask for a coding system."
2672 (interactive (list 'force current-prefix-arg
))
2674 (let ((inhibit-read-only t
) type charset
)
2675 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2676 (with-current-buffer gnus-original-article-buffer
2678 (gnus-fetch-field "content-transfer-encoding"))
2679 (let* ((ct (gnus-fetch-field "content-type"))
2680 (ctl (and ct
(mail-header-parse-content-type ct
))))
2681 (setq charset
(and ctl
2682 (mail-content-type-get ctl
'charset
)))
2683 (if (stringp charset
)
2684 (setq charset
(intern (downcase charset
)))))))
2686 (setq charset
(mm-read-coding-system "Charset: " charset
)))
2688 (setq charset gnus-newsgroup-charset
))
2690 (and type
(let ((case-fold-search t
))
2691 (string-match "base64" type
))))
2694 (narrow-to-region (point) (point-max))
2695 (base64-decode-region (point-min) (point-max))
2696 (mm-decode-coding-region
2697 (point-min) (point-max)
2698 (mm-charset-to-coding-system charset nil t
)))))))
2703 (defun article-decode-HZ ()
2704 "Translate a HZ-encoded article."
2708 (let ((inhibit-read-only t
))
2709 (rfc1843-decode-region (point-min) (point-max)))))
2711 (defun article-unsplit-urls ()
2712 "Remove the newlines that some other mailers insert into URLs."
2715 (let ((inhibit-read-only t
))
2716 (goto-char (point-min))
2717 (while (re-search-forward
2718 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2719 (replace-match "\\1\\3" t
)))
2720 (when (gmm-called-interactively-p 'any
)
2721 (gnus-treat-article nil
))))
2723 (defun article-wash-html ()
2724 "Format an HTML article."
2727 (buffer-read-only nil
))
2728 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2729 (with-current-buffer gnus-original-article-buffer
2730 (setq handles
(mm-dissect-buffer t t
))))
2732 (delete-region (point) (point-max))
2733 (mm-enable-multibyte)
2734 (mm-inline-text-html handles
)))
2736 (defvar gnus-article-browse-html-temp-list nil
2737 "List of temporary files created by `gnus-article-browse-html-parts'.
2738 Internal variable.")
2740 (defcustom gnus-article-browse-delete-temp
'ask
2741 "What to do with temporary files from `gnus-article-browse-html-parts'.
2742 If nil, don't delete temporary files. If it is t, delete them on
2743 exit from the summary buffer. If it is the symbol `file', query
2744 on each file, if it is `ask' ask once when exiting from the
2746 :group
'gnus-article
2747 :version
"23.1" ;; No Gnus
2748 :type
'(choice (const :tag
"Don't delete" nil
)
2749 (const :tag
"Don't ask" t
)
2750 (const :tag
"Ask" ask
)
2751 (const :tag
"Ask for each file" file
)))
2753 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2755 (defun gnus-article-browse-delete-temp-files (&optional how
)
2756 "Delete temp-files created by `gnus-article-browse-html-parts'."
2757 (when (and gnus-article-browse-html-temp-list
2759 (or how
(setq how gnus-article-browse-delete-temp
))
2761 (let ((files (length gnus-article-browse-html-temp-list
)))
2764 "Delete the temporary HTML file? "
2765 (format "Delete all %s temporary HTML files? "
2767 (setq gnus-article-browse-html-temp-list nil
)))
2769 (dolist (file gnus-article-browse-html-temp-list
)
2770 (cond ((file-directory-p file
)
2771 (when (or (not (eq how
'file
))
2774 "Delete temporary HTML file(s) in directory `%s'? "
2775 (file-name-as-directory file
))))
2776 (gnus-delete-directory file
)))
2777 ((file-exists-p file
)
2778 (when (or (not (eq how
'file
))
2780 (format "Delete temporary HTML file `%s'? " file
)))
2781 (delete-file file
)))))
2782 ;; Also remove file from the list when not deleted or if file doesn't
2784 (setq gnus-article-browse-html-temp-list nil
))
2785 gnus-article-browse-html-temp-list
)
2787 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2788 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2789 Return file name relative to the parent of DIRECTORY."
2793 (dolist (handle handles
)
2795 ((not (listp handle
)))
2796 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2798 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2799 ((equal (mm-handle-media-supertype handle
) "multipart")
2800 (when (setq file
(gnus-article-browse-html-save-cid-content
2801 cid handle directory
))
2802 (throw 'found file
)))
2803 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2804 (setq file
(or (mm-handle-filename handle
)
2806 (make-temp-name "cid")
2807 (car (rassoc (car (mm-handle-type handle
))
2808 mailcap-mime-extensions
))))
2809 afile
(expand-file-name file directory
))
2810 (mm-save-part-to-file handle afile
)
2811 (throw 'found
(concat (file-name-nondirectory
2812 (directory-file-name directory
))
2815 (defun gnus-article-browse-html-parts (list &optional header
)
2816 "View all \"text/html\" parts from LIST.
2817 Recurse into multiparts. The optional HEADER that should be a decoded
2818 message header will be added to the bodies of the \"text/html\" parts."
2819 ;; Internal function used by `gnus-article-browse-html-article'.
2820 (let (type file charset content cid-dir tmp-file showed
)
2821 ;; Find and show the html-parts.
2822 (dolist (handle list
)
2823 ;; If HTML, show it:
2824 (cond ((not (listp handle
)))
2825 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2826 (and (equal (car type
) "message/external-body")
2828 (setq file
(mm-handle-filename handle
)))
2829 (or (mm-handle-cache handle
)
2830 (condition-case code
2831 (progn (mm-extern-cache-contents handle
) t
)
2833 (gnus-message 3 "%s" (error-message-string code
))
2834 (when (>= gnus-verbose
3) (sit-for 2))
2837 (setq handle
(mm-handle-cache handle
)
2838 type
(mm-handle-type handle
))
2839 (equal (car type
) "text/html"))))
2840 (setq charset
(mail-content-type-get type
'charset
)
2841 content
(mm-get-part handle
))
2843 (if (eq charset
'gnus-decoded
)
2844 (mm-enable-multibyte)
2845 (mm-disable-multibyte))
2847 ;; resolve cid contents
2848 (let ((case-fold-search t
)
2849 st base regexp cid-file
)
2850 (goto-char (point-min))
2851 (when (and (re-search-forward "<head[\t\n >]" nil t
)
2853 (setq st
(match-end 0))
2854 (re-search-forward "</head[\t\n >]" nil t
))
2855 (re-search-backward "<base\
2856 \\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+href=\"\\([^\"]+\\)\"[^>]*>" st t
))
2857 (setq base
(match-string 1))
2858 (replace-match "<!--\\&-->")
2860 (dolist (tag '(("a" .
"href") ("form" .
"action")
2862 (setq regexp
(concat "<" (car tag
)
2863 "\\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+"
2864 (cdr tag
) "=\"\\([^\"]+\\)"))
2865 (while (re-search-forward regexp nil t
)
2869 (url-expand-file-name (match-string 1)
2871 (error (match-string 1)))
2872 (delete-region (match-beginning 1)
2875 (while (re-search-forward "\
2876 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2879 (setq cid-dir
(mm-make-temp-file "cid" t
))
2880 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2883 (when (setq cid-file
2884 (gnus-article-browse-html-save-cid-content
2886 (with-current-buffer gnus-article-buffer
2887 gnus-article-mime-handles
)
2889 (replace-match cid-file nil nil nil
1))))
2890 (unless content
(setq content
(buffer-string))))
2891 (when (or charset header
(not file
))
2892 (setq tmp-file
(mm-make-temp-file
2893 ;; Do we need to care for 8.3 filenames?
2894 "mm-" nil
".html")))
2895 ;; Add a meta html tag to specify charset and a header.
2898 (let (title eheader body hcharset coding
)
2900 (mm-enable-multibyte)
2901 (setq case-fold-search t
)
2902 (insert header
"\n")
2903 (setq title
(message-fetch-field "subject"))
2904 (goto-char (point-min))
2905 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2907 (replace-match (cond ((match-beginning 1) "<")
2908 ((match-beginning 2) ">")
2909 ((match-beginning 3) "&")
2911 (goto-char (point-min))
2912 (while (re-search-forward "^[\t ]+" nil t
)
2915 (delete-region (match-beginning 0)
2918 (goto-char (point-min))
2919 (insert "<div align=\"left\">\n")
2920 (goto-char (point-max))
2921 (insert "</div>\n<hr>\n")
2922 ;; We have to examine charset one by one since
2923 ;; charset specified in parts might be different.
2924 (if (eq charset
'gnus-decoded
)
2925 (setq charset
'utf-8
2926 eheader
(mm-encode-coding-string (buffer-string)
2929 (mm-encode-coding-string title charset
))
2930 body
(mm-encode-coding-string content charset
))
2931 (setq hcharset
(mm-find-mime-charset-region (point-min)
2933 (cond ((= (length hcharset
) 1)
2934 (setq hcharset
(car hcharset
)
2935 coding
(mm-charset-to-coding-system
2937 ((> (length hcharset
) 1)
2938 (setq hcharset
'utf-8
2944 (mm-charset-to-coding-system charset
2946 (if (eq coding body
)
2947 (setq eheader
(mm-encode-coding-string
2948 (buffer-string) coding
)
2950 (mm-encode-coding-string
2953 (setq charset
'utf-8
2954 eheader
(mm-encode-coding-string
2955 (buffer-string) charset
)
2957 (mm-encode-coding-string
2959 body
(mm-encode-coding-string
2960 (mm-decode-coding-string
2963 (setq charset hcharset
2964 eheader
(mm-encode-coding-string
2965 (buffer-string) coding
)
2967 (mm-encode-coding-string
2970 (setq eheader
(mm-string-as-unibyte (buffer-string))
2973 (mm-disable-multibyte)
2976 (mm-add-meta-html-tag handle charset t
))
2978 (goto-char (point-min))
2979 (unless (search-forward "<title>" nil t
)
2980 (re-search-forward "<head>\\s-*" nil t
)
2981 (insert "<title>" title
"</title>\n")))
2982 (goto-char (point-min))
2983 (or (re-search-forward
2984 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2986 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2988 (mm-write-region (point-min) (point-max)
2989 tmp-file nil nil nil
'binary t
))))
2991 (mm-with-unibyte-buffer
2992 (insert (if (eq charset
'gnus-decoded
)
2993 (mm-encode-coding-string content
2994 (setq charset
'utf-8
))
2996 (if (or (mm-add-meta-html-tag handle charset
)
2998 (mm-write-region (point-min) (point-max)
2999 tmp-file nil nil nil
'binary t
)
3000 (setq tmp-file nil
))))
3002 (mm-save-part-to-file handle tmp-file
)))
3004 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
3005 (add-hook 'gnus-summary-prepare-exit-hook
3006 'gnus-article-browse-delete-temp-files
)
3007 (add-hook 'gnus-exit-gnus-hook
3009 (gnus-article-browse-delete-temp-files t
)))
3010 ;; FIXME: Warn if there's an <img> tag?
3011 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
3013 ;; If multipart, recurse
3014 ((equal (mm-handle-media-supertype handle
) "multipart")
3015 (when (gnus-article-browse-html-parts handle header
)
3017 ((equal (mm-handle-media-type handle
) "message/rfc822")
3018 (mm-with-multibyte-buffer
3019 (mm-insert-part handle
)
3020 (setq handle
(mm-dissect-buffer t t
))
3021 (when (and (bufferp (car handle
))
3022 (stringp (car (mm-handle-type handle
))))
3023 (setq handle
(list handle
)))
3025 (article-decode-encoded-words)
3026 (let ((gnus-visible-headers
3027 (or (get 'gnus-visible-headers
'standard-value
)
3028 gnus-visible-headers
)))
3029 (article-hide-headers))
3030 (goto-char (point-min))
3031 (search-forward "\n\n" nil
'move
)
3032 (skip-chars-backward "\t\n ")
3033 (setq header
(buffer-substring (point-min) (point)))))
3035 (gnus-article-browse-html-parts handle header
)
3036 (mm-destroy-parts handle
))
3040 (defun gnus-article-browse-html-article (&optional arg
)
3041 "View \"text/html\" parts of the current article with a WWW browser.
3042 Inline images embedded in a message using the cid scheme, as they are
3043 generally considered to be safe, will be processed properly.
3044 The message header is added to the beginning of every html part unless
3045 the prefix argument ARG is given.
3047 Warning: Spammers use links to images (using the http scheme) in HTML
3048 articles to verify whether you have read the message. As
3049 `gnus-article-browse-html-article' passes the HTML content to the
3050 browser without eliminating these \"web bugs\" you should only
3051 use it for mails from trusted senders.
3053 If you always want to display HTML parts in the browser, set
3054 `mm-text-html-renderer' to nil.
3056 This command creates temporary files to pass HTML contents including
3057 images if any to the browser, and deletes them when exiting the group
3059 ;; Cf. `mm-w3m-safe-url-regexp'
3062 (gnus-summary-show-article)
3063 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3064 gnus-visible-headers
))
3065 ;; As we insert a <hr>, there's no need for the body boundary.
3066 (gnus-treat-body-boundary nil
))
3067 (gnus-summary-show-article)))
3068 (with-current-buffer gnus-article-buffer
3069 (let ((header (unless arg
3072 (buffer-substring-no-properties
3073 (goto-char (point-min))
3074 (if (search-forward "\n\n" nil t
)
3076 (goto-char (point-max))
3077 (skip-chars-backward "\t\n ")
3080 (set-buffer gnus-original-article-buffer
)
3081 (setq parts
(mm-dissect-buffer t t
))
3082 ;; If singlepart, enforce a list.
3083 (when (and (bufferp (car parts
))
3084 (stringp (car (mm-handle-type parts
))))
3085 (setq parts
(list parts
)))
3087 (unless (gnus-article-browse-html-parts parts header
)
3088 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3089 (mm-destroy-parts parts
)
3091 (gnus-summary-show-article)))))
3093 (defun article-hide-list-identifiers ()
3094 "Remove list identifiers from the Subject header.
3095 The `gnus-list-identifiers' variable specifies what to do."
3097 (let ((inhibit-point-motion-hooks t
)
3098 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3099 (inhibit-read-only t
))
3103 (article-narrow-to-head)
3104 (goto-char (point-min))
3105 (while (re-search-forward
3106 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3108 (delete-region (match-beginning 2) (match-end 0))
3109 (beginning-of-line))
3110 (when (re-search-forward
3111 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3112 (delete-region (match-beginning 1) (match-end 1))))))))
3114 (defun article-hide-pem (&optional arg
)
3115 "Toggle hiding of any PEM headers and signatures in the current article.
3116 If given a negative prefix, always show; if given a positive prefix,
3118 (interactive (gnus-article-hidden-arg))
3119 (unless (gnus-article-check-hidden-text 'pem arg
)
3121 (let ((inhibit-read-only t
) end
)
3122 (goto-char (point-min))
3123 ;; Hide the horrendously ugly "header".
3124 (when (and (search-forward
3125 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3127 (setq end
(1+ (match-beginning 0))))
3128 (gnus-add-wash-type 'pem
)
3129 (gnus-article-hide-text-type
3131 (if (search-forward "\n\n" nil t
)
3135 ;; Hide the trailer as well
3136 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3138 (gnus-article-hide-text-type
3139 (match-beginning 0) (match-end 0) 'pem
)))))))
3141 (defun article-strip-banner ()
3142 "Strip the banners specified by the `banner' group parameter and by
3143 `gnus-article-address-banner-alist'."
3147 (let ((inhibit-point-motion-hooks t
))
3148 (when (gnus-parameter-banner gnus-newsgroup-name
)
3149 (article-really-strip-banner
3150 (gnus-parameter-banner gnus-newsgroup-name
)))
3151 (when gnus-article-address-banner-alist
3152 ;; Note that the From header is decoded here, so it is
3153 ;; required that the *-extract-address-components function
3154 ;; supports non-ASCII text.
3155 (let ((from (save-restriction
3157 (article-narrow-to-head)
3158 (mail-fetch-field "from"))))
3161 (cadr (funcall gnus-extract-address-components
3164 (dolist (pair gnus-article-address-banner-alist
)
3165 (when (string-match (car pair
) from
)
3167 (article-really-strip-banner (cdr pair
)))))))))))))
3169 (defun article-really-strip-banner (banner)
3170 "Strip the banner specified by the argument."
3173 (let ((inhibit-point-motion-hooks t
)
3174 (gnus-signature-limit nil
)
3175 (inhibit-read-only t
))
3178 ((eq banner
'signature
)
3179 (when (gnus-article-narrow-to-signature)
3182 (delete-region (point) (point-max))))
3184 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3185 (while (re-search-forward banner nil t
)
3186 (delete-region (match-beginning 0) (match-end 0)))))
3188 (while (re-search-forward banner nil t
)
3189 (delete-region (match-beginning 0) (match-end 0)))))))))
3191 (defun article-babel ()
3192 "Translate article using an online translation service."
3195 (gnus-with-article-buffer
3196 (when (article-goto-body)
3197 (let* ((start (point))
3199 (orig (buffer-substring start end
))
3200 (trans (babel-as-string orig
)))
3202 (narrow-to-region start end
)
3203 (delete-region start end
)
3206 (defun article-hide-signature (&optional arg
)
3207 "Hide the signature in the current article.
3208 If given a negative prefix, always show; if given a positive prefix,
3210 (interactive (gnus-article-hidden-arg))
3211 (unless (gnus-article-check-hidden-text 'signature arg
)
3214 (let ((inhibit-read-only t
))
3215 (when (gnus-article-narrow-to-signature)
3216 (gnus-article-hide-text-type
3217 (point-min) (point-max) 'signature
))))))
3218 (gnus-set-mode-line 'article
))
3220 (defun article-strip-headers-in-body ()
3221 "Strip offensive headers from bodies."
3225 (let ((case-fold-search t
))
3226 (when (looking-at "x-no-archive:")
3227 (gnus-delete-line)))))
3229 (defun article-strip-leading-blank-lines ()
3230 "Remove all blank lines from the beginning of the article."
3233 (let ((inhibit-point-motion-hooks t
)
3234 (inhibit-read-only t
))
3235 (when (article-goto-body)
3236 (while (and (not (eobp))
3237 (looking-at "[ \t]*$"))
3238 (gnus-delete-line))))))
3240 (defun article-narrow-to-head ()
3241 "Narrow the buffer to the head of the message.
3242 Point is left at the beginning of the narrowed-to region."
3244 (goto-char (point-min))
3246 ;; Absolutely no headers displayed.
3250 ((search-forward "\n\n" nil
1)
3252 ;; Nothing but headers.
3255 (goto-char (point-min)))
3257 (defun article-goto-body ()
3258 "Place point at the start of the body."
3259 (goto-char (point-min))
3261 ;; This variable is only bound when dealing with separate
3263 (article-goto-body-goes-to-point-min-p
3265 ((search-forward "\n\n" nil t
)
3268 (goto-char (point-max))
3271 (defun article-strip-multiple-blank-lines ()
3272 "Replace consecutive blank lines with one empty line."
3275 (let ((inhibit-point-motion-hooks t
)
3276 (inhibit-read-only t
))
3277 ;; First make all blank lines empty.
3279 (while (re-search-forward "^[ \t]+$" nil t
)
3280 (unless (gnus-annotation-in-region-p
3281 (match-beginning 0) (match-end 0))
3282 (replace-match "" nil t
)))
3283 ;; Then replace multiple empty lines with a single empty line.
3285 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3286 (unless (gnus-annotation-in-region-p
3287 (match-beginning 0) (match-end 0))
3288 (delete-region (match-beginning 1) (match-end 1)))))))
3290 (defun article-strip-leading-space ()
3291 "Remove all white space from the beginning of the lines in the article."
3294 (let ((inhibit-point-motion-hooks t
)
3295 (inhibit-read-only t
))
3297 (while (re-search-forward "^[ \t]+" nil t
)
3298 (replace-match "" t t
)))))
3300 (defun article-strip-trailing-space ()
3301 "Remove all white space from the end of the lines in the article."
3304 (let ((inhibit-point-motion-hooks t
)
3305 (inhibit-read-only t
))
3307 (while (re-search-forward "[ \t]+$" nil t
)
3308 (replace-match "" t t
)))))
3310 (defun article-strip-blank-lines ()
3311 "Strip leading, trailing and multiple blank lines."
3313 (article-strip-leading-blank-lines)
3314 (article-remove-trailing-blank-lines)
3315 (article-strip-multiple-blank-lines))
3317 (defun article-strip-all-blank-lines ()
3318 "Strip all blank lines."
3321 (let ((inhibit-point-motion-hooks t
)
3322 (inhibit-read-only t
))
3324 (while (re-search-forward "^[ \t]*\n" nil t
)
3325 (replace-match "" t t
)))))
3327 (defun gnus-article-narrow-to-signature ()
3328 "Narrow to the signature; return t if a signature is found, else nil."
3329 (let ((inhibit-point-motion-hooks t
))
3330 (when (gnus-article-search-signature)
3332 ;; Check whether we have some limits to what we consider
3333 ;; to be a signature.
3334 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3335 (list gnus-signature-limit
)))
3337 (while (setq limit
(pop limits
))
3338 (if (or (and (integerp limit
)
3339 (< (- (point-max) (point)) limit
))
3341 (< (count-lines (point) (point-max)) limit
))
3342 (and (functionp limit
)
3344 (and (stringp limit
)
3345 (not (re-search-forward limit nil t
))))
3346 () ; This limit did not succeed.
3350 (narrow-to-region (point) (point-max))
3353 (defun gnus-article-search-signature ()
3354 "Search the current buffer for the signature separator.
3355 Put point at the beginning of the signature separator."
3356 (let ((cur (point)))
3357 (goto-char (point-max))
3358 (if (if (stringp gnus-signature-separator
)
3359 (re-search-backward gnus-signature-separator nil t
)
3360 (let ((seps gnus-signature-separator
))
3362 (not (re-search-backward (car seps
) nil t
)))
3369 (defun gnus-article-hidden-arg ()
3370 "Return the current prefix arg as a number, or 0 if no prefix."
3371 (list (if current-prefix-arg
3372 (prefix-numeric-value current-prefix-arg
)
3375 (defun gnus-article-check-hidden-text (type arg
)
3376 "Return nil if hiding is necessary.
3377 Arg can be nil or a number. nil and positive means hide, negative
3378 means show, 0 means toggle."
3381 (let ((hide (gnus-article-hidden-text-p type
)))
3387 (gnus-article-show-hidden-text type
)
3390 (if (eq hide
'hidden
)
3392 (gnus-article-show-hidden-text type
)
3396 (defun gnus-article-hidden-text-p (type)
3397 "Say whether the current buffer contains hidden text of type TYPE."
3398 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3400 (not (get-text-property pos
'invisible
))
3401 (not (get-text-property pos
'dummy-invisible
)))
3403 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3408 (defun gnus-article-show-hidden-text (type &optional _dummy
)
3409 "Show all hidden text of type TYPE.
3410 Originally it is hide instead of DUMMY."
3411 (let ((inhibit-read-only t
)
3412 (inhibit-point-motion-hooks t
))
3413 (gnus-remove-text-properties-when
3415 (point-min) (point-max)
3416 (cons 'article-type
(cons type
3417 gnus-hidden-properties
)))
3418 (gnus-delete-wash-type type
)))
3420 (defconst article-time-units
3421 `((year .
,(* 365.25 24 60 60))
3422 (week .
,(* 7 24 60 60))
3423 (day .
,(* 24 60 60))
3427 "Mapping from time units to seconds.")
3429 (defun gnus-article-forward-header ()
3430 "Move point to the start of the next header.
3431 If the current header is a continuation header, this can be several
3436 (if (looking-at "[ \t]+[^ \t]")
3440 (defun article-treat-date ()
3441 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3442 (with-current-buffer gnus-summary-buffer
3443 gnus-article-date-headers
)
3444 gnus-article-date-headers
)
3447 (defun article-date-ut (&optional type _highlight date-position
)
3448 "Convert DATE date to TYPE in the current article.
3449 The default type is `ut'. See `gnus-article-date-headers' for
3451 (interactive (list 'ut t
))
3452 (let* ((case-fold-search t
)
3453 (inhibit-read-only t
)
3454 (inhibit-point-motion-hooks t
)
3455 (visible-date (mail-fetch-field "Date"))
3456 pos date bface eface
)
3460 (goto-char date-position
)
3461 (setq date
(get-text-property (point) 'original-date
))
3462 (when (looking-at "[^:]+:[\t ]*")
3463 (setq bface
(get-text-property (match-beginning 0) 'face
)
3464 eface
(get-text-property (match-end 0) 'face
)))
3465 (delete-region (point)
3467 (gnus-article-forward-header)
3469 (article-transform-date date type bface eface
))
3472 (goto-char (point-min))
3473 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3474 (and (setq pos
(next-single-property-change
3475 (point) 'original-date
))
3477 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3478 (1+ (match-beginning 0))
3480 (while (setq pos
(text-property-not-all pos
(point-max)
3481 'gnus-date-type nil
))
3482 (setq date
(get-text-property pos
'original-date
))
3484 (when (looking-at "[^:]+:[\t ]*")
3485 (setq bface
(get-text-property (match-beginning 0) 'face
)
3486 eface
(get-text-property (match-end 0) 'face
)))
3487 (delete-region pos
(or (text-property-any pos
(point-max)
3488 'gnus-date-type nil
)
3490 (unless date
;; the 1st time
3491 (goto-char (point-min))
3492 (while (re-search-forward "^Date:[\t ]*" nil t
)
3493 (setq date
(get-text-property (match-beginning 0)
3495 bface
(get-text-property (match-beginning 0) 'face
)
3496 eface
(get-text-property (match-end 0) 'face
))
3497 (delete-region (point-at-bol) (progn
3498 (gnus-article-forward-header)
3500 (when (and (not date
)
3502 (setq date visible-date
))
3504 (article-transform-date date type bface eface
))
3505 (goto-char (point-max))
3508 (defun article-transform-date (date type bface eface
)
3509 (dolist (this-type (cond
3519 (add-text-properties
3522 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3524 (list 'original-date date
'gnus-date-type this-type
))))
3527 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3528 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3529 (when (match-beginning 2)
3530 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3531 (while (and (zerop (forward-line 1))
3532 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3533 (when (match-beginning 1)
3534 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3536 (defun article-make-date-line (date type
)
3537 "Return a DATE line of TYPE."
3538 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3540 (error "Unknown conversion type: %s" type
))
3542 (let ((time (ignore-errors (date-to-time date
))))
3544 ;; Convert to the local timezone.
3546 (concat "Date: " (message-make-date time
)))
3547 ;; Convert to Universal Time.
3552 (let* ((e (parse-time-string date
))
3553 (tm (apply 'encode-time e
))
3555 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3556 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3557 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3561 ;; Get the original date from the article.
3562 ((eq type
'original
)
3563 (concat "Date: " (if (string-match "\n+$" date
)
3564 (substring date
0 (match-beginning 0))
3566 ;; Let the user define the format.
3567 ((eq type
'user-defined
)
3568 (let ((format (or (condition-case nil
3569 (with-current-buffer gnus-summary-buffer
3570 gnus-article-time-format
)
3572 gnus-article-time-format
)))
3573 (if (functionp format
)
3574 (funcall format time
)
3575 (concat "Date: " (format-time-string format time
)))))
3578 (let ((tz (car (current-time-zone time
))))
3581 (format-time-string "%Y%m%dT%H%M%S" time
)
3582 (format "%s%02d%02d"
3583 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3584 (/ (%
(abs tz
) 3600) 60)))))
3585 ;; Do a lapsed format.
3587 (concat "Date: " (article-lapsed-string time
)))
3588 ;; A combined date/lapsed format.
3589 ((eq type
'combined-lapsed
)
3590 (let ((date-string (article-make-date-line date
'original
))
3596 (concat " (" (article-lapsed-string time segments
) ")"))
3597 (> (+ (length date-string
)
3598 (length lapsed-string
))
3601 (setq segments
(1- segments
)))
3603 (concat date-string lapsed-string
)
3605 ;; Display the date in proper English
3607 (let ((dtime (decode-time time
)))
3610 (number-to-string (nth 3 dtime
))
3611 (let ((digit (%
(nth 3 dtime
) 10)))
3613 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3619 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3621 (number-to-string (nth 5 dtime
))
3623 (format "%02d" (nth 2 dtime
))
3625 (format "%02d" (nth 1 dtime
)))))))
3627 (format "Date: %s (from Gnus)" date
))))
3629 (defun article-lapsed-string (time &optional max-segments
)
3630 ;; If the date is seriously mangled, the timezone functions are
3631 ;; liable to bug out, so we ignore all errors.
3632 (let* ((now (current-time))
3633 (real-time (subtract-time now time
))
3634 (real-sec (and real-time
3635 (+ (* (float (car real-time
)) 65536)
3637 (sec (and real-time
(abs real-sec
)))
3640 (unless max-segments
3641 (setq max-segments
(length article-time-units
)))
3649 ;; This is a bit convoluted, but basically we go
3650 ;; through the time units for years, weeks, etc,
3651 ;; and divide things to see whether that results
3652 ;; in positive answers.
3655 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3656 (>= segments max-segments
))
3657 ;; The (remaining) seconds are too few to
3658 ;; be divided into this time unit.
3660 ;; It's big enough, so we output it.
3661 (setq sec
(- sec
(* num
(cdr unit
))))
3663 (concat (if prev
", " "") (int-to-string
3665 " " (symbol-name (car unit
))
3666 (if (> num
1) "s" ""))
3668 segments
(1+ segments
)))))
3669 article-time-units
"")
3670 ;; If dates are odd, then it might appear like the
3671 ;; article was sent in the future.
3674 " in the future"))))))
3676 (defun article-date-local (&optional highlight
)
3677 "Convert the current article date to the local timezone."
3678 (interactive (list t
))
3679 (article-date-ut 'local highlight
))
3681 (defun article-date-english (&optional highlight
)
3682 "Convert the current article date to something that is proper English."
3683 (interactive (list t
))
3684 (article-date-ut 'english highlight
))
3686 (defun article-date-original (&optional highlight
)
3687 "Convert the current article date to what it was originally.
3688 This is only useful if you have used some other date conversion
3689 function and want to see what the date was before converting."
3690 (interactive (list t
))
3691 (article-date-ut 'original highlight
))
3693 (defun article-date-lapsed (&optional highlight
)
3694 "Convert the current article date to time lapsed since it was sent."
3695 (interactive (list t
))
3696 (article-date-ut 'lapsed highlight
))
3698 (defun article-date-combined-lapsed (&optional highlight
)
3699 "Convert the current article date to time lapsed since it was sent."
3700 (interactive (list t
))
3701 (article-date-ut 'combined-lapsed highlight
))
3703 (defun article-update-date-lapsed ()
3704 "Function to be run from a timer to update the lapsed time line."
3706 (let ((buffer (current-buffer)))
3710 (set-buffer (window-buffer w
))
3711 (when (derived-mode-p 'gnus-article-mode
)
3712 (let ((old-line (count-lines (point-min) (point)))
3713 (old-column (- (point) (line-beginning-position)))
3714 (window-start (window-start w
))
3717 (while (setq pos
(text-property-not-all pos
(point-max)
3718 'gnus-date-type nil
))
3719 (setq next
(or (next-single-property-change pos
3722 (setq type
(get-text-property pos
'gnus-date-type
))
3723 (when (memq type
'(lapsed combined-lapsed user-defined
))
3724 (article-date-ut type t pos
)
3725 (setq end
(or (next-single-property-change pos
3729 (if (/= window-start next
)
3730 (setq window-start nil
)
3731 (set-window-start w end
)))
3734 (goto-char (point-min))
3735 (when (> old-column
0)
3736 (setq old-line
(1- old-line
)))
3737 (forward-line old-line
)
3739 (when (> (current-column) old-column
)
3741 (forward-char old-column
)))))
3743 (set-buffer buffer
))))
3745 (defun gnus-start-date-timer (&optional n
)
3746 "Start a timer to update the Date headers in the article buffers.
3747 The numerical prefix says how frequently (in seconds) the function
3752 (gnus-stop-date-timer)
3753 (setq article-lapsed-timer
3754 (run-at-time 1 n
'article-update-date-lapsed
)))
3756 (defun gnus-stop-date-timer ()
3757 "Stop the Date timer."
3759 (when article-lapsed-timer
3760 (nnheader-cancel-timer article-lapsed-timer
)
3761 (setq article-lapsed-timer nil
)))
3763 (defun article-date-user (&optional highlight
)
3764 "Convert the current article date to the user-defined format.
3765 This format is defined by the `gnus-article-time-format' variable."
3766 (interactive (list t
))
3767 (article-date-ut 'user highlight
))
3769 (defun article-date-iso8601 (&optional highlight
)
3770 "Convert the current article date to ISO8601."
3771 (interactive (list t
))
3772 (article-date-ut 'iso8601 highlight
))
3774 (defmacro gnus-article-save-original-date
(&rest forms
)
3775 "Save the original date as a text property and evaluate FORMS."
3776 `(let* ((case-fold-search t
)
3778 (goto-char (point-min))
3779 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3782 (date (when (and start
3783 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3785 (buffer-substring-no-properties start
3786 (match-beginning 0)))))
3787 (goto-char (point-max))
3788 (skip-chars-backward "\n")
3789 (put-text-property (point-min) (point) 'original-date date
)
3791 (goto-char (point-max))
3792 (skip-chars-backward "\n")
3793 (put-text-property (point-min) (point) 'original-date date
)))
3795 ;; (defun article-show-all ()
3796 ;; "Show all hidden text in the article buffer."
3799 ;; (let ((inhibit-read-only t))
3800 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3802 (defun article-remove-leading-whitespace ()
3803 "Remove excessive whitespace from all headers."
3807 (let ((inhibit-read-only t
))
3808 (article-narrow-to-head)
3809 (goto-char (point-min))
3810 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3811 (delete-region (match-beginning 1) (match-end 1)))))))
3813 (defun article-emphasize (&optional arg
)
3814 "Emphasize text according to `gnus-emphasis-alist'."
3815 (interactive (gnus-article-hidden-arg))
3816 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3820 (with-current-buffer gnus-summary-buffer
3821 gnus-article-emphasis-alist
)
3823 gnus-emphasis-alist
))
3824 (inhibit-read-only t
)
3825 (props (append '(article-type emphasis
)
3826 gnus-hidden-properties
))
3827 regexp elem beg invisible visible face
)
3830 (while (setq elem
(pop alist
))
3832 (setq regexp
(car elem
)
3833 invisible
(nth 1 elem
)
3834 visible
(nth 2 elem
)
3836 (while (re-search-forward regexp nil t
)
3837 (when (and (match-beginning visible
) (match-beginning invisible
))
3838 (gnus-article-hide-text
3839 (match-beginning invisible
) (match-end invisible
) props
)
3840 (gnus-article-unhide-text-type
3841 (match-beginning visible
) (match-end visible
) 'emphasis
)
3842 (gnus-put-overlay-excluding-newlines
3843 (match-beginning visible
) (match-end visible
) 'face face
)
3844 (gnus-add-wash-type 'emphasis
)
3845 (goto-char (match-end invisible
)))))))))
3847 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3848 "Setup newsgroup emphasis alist."
3849 (unless gnus-article-emphasis-alist
3850 (let ((name (and gnus-newsgroup-name
3851 (gnus-group-real-name gnus-newsgroup-name
))))
3852 (make-local-variable 'gnus-article-emphasis-alist
)
3853 (setq gnus-article-emphasis-alist
3855 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3856 (while (setq elem
(pop alist
))
3857 (when (and name
(string-match (car elem
) name
))
3859 highlight
(copy-sequence (cdr elem
)))))
3861 (copy-sequence highlight-words
)
3862 (if gnus-newsgroup-name
3863 (copy-sequence (gnus-group-find-parameter
3864 gnus-newsgroup-name
'highlight-words t
)))
3865 gnus-emphasis-alist
)))))
3867 (defvar gnus-summary-article-menu
)
3868 (defvar gnus-summary-post-menu
)
3870 ;;; Saving functions.
3872 (defun gnus-article-save (save-buffer file
&optional num
)
3873 "Save the currently selected article."
3874 (when (or (get gnus-default-article-saver
:headers
)
3875 (not gnus-save-all-headers
))
3876 ;; Remove headers according to `gnus-saved-headers' or the value
3877 ;; of the `:headers' property that the saver function might have.
3878 (let ((gnus-visible-headers
3879 (or (symbol-value (get gnus-default-article-saver
:headers
))
3880 gnus-saved-headers gnus-visible-headers
))
3881 ;; Ignore group parameter. See `article-hide-headers'.
3882 (gnus-summary-buffer nil
))
3883 (with-current-buffer save-buffer
3884 (article-hide-headers 1 t
))))
3885 (save-window-excursion
3886 (if (not gnus-default-article-saver
)
3887 (error "No default saver is defined")
3888 ;; !!! Magic! The saving functions all save
3889 ;; `gnus-save-article-buffer' (or so they think), but we
3890 ;; bind that variable to our save-buffer.
3891 (set-buffer gnus-article-buffer
)
3892 (let* ((gnus-save-article-buffer save-buffer
)
3895 ((not gnus-prompt-before-saving
) 'default
)
3896 ((eq gnus-prompt-before-saving
'always
) nil
)
3898 (gnus-number-of-articles-to-be-saved
3899 (when (eq gnus-prompt-before-saving t
)
3901 (set-buffer gnus-article-current-summary
)
3902 (funcall gnus-default-article-saver filename
)))))
3904 (defun gnus-read-save-file-name (prompt &optional filename
3905 function group headers variable
3908 (funcall function group headers
(symbol-value variable
)))
3913 ((eq filename
'default
)
3919 (when (symbol-value dir-var
)
3920 (setq default-name
(expand-file-name
3921 (file-name-nondirectory default-name
)
3922 (symbol-value dir-var
))))
3923 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3926 (if (and gnus-number-of-articles-to-be-saved
3927 (> gnus-number-of-articles-to-be-saved
1))
3928 (format "these %d articles"
3929 gnus-number-of-articles-to-be-saved
)
3932 ;; Let the split methods have their say.
3934 ;; No split name was found.
3937 (concat prompt
" (default "
3938 (file-name-nondirectory default-name
) "): ")
3939 (file-name-directory default-name
)
3941 ;; A single group name is returned.
3942 ((stringp split-name
)
3944 (funcall function split-name headers
3945 (symbol-value variable
)))
3947 (concat prompt
" (default "
3948 (file-name-nondirectory default-name
) "): ")
3949 (file-name-directory default-name
)
3951 ;; A single split name was found
3952 ((= 1 (length split-name
))
3953 (let* ((name (expand-file-name
3955 gnus-article-save-directory
))
3956 (dir (cond ((file-directory-p name
)
3957 (file-name-as-directory name
))
3958 ((file-exists-p name
) name
)
3959 (t gnus-article-save-directory
))))
3961 (concat prompt
" (default " name
"): ")
3963 ;; A list of splits was found.
3965 (setq split-name
(nreverse split-name
))
3967 (let ((file-name-history
3968 (nconc split-name file-name-history
)))
3972 (concat prompt
" (`M-p' for defaults): ")
3973 gnus-article-save-directory
3975 gnus-article-save-directory
)))
3976 (car (push result file-name-history
)))))))
3977 ;; Create the directory.
3978 (gnus-make-directory (file-name-directory file
))
3979 ;; If we have read a directory, we append the default file name.
3980 (when (file-directory-p file
)
3981 (setq file
(expand-file-name (file-name-nondirectory
3983 (file-name-as-directory file
))))
3984 ;; Possibly translate some characters.
3985 (nnheader-translate-file-chars file
))))))
3986 (gnus-make-directory (file-name-directory result
))
3988 (set variable result
))
3990 (set dir-var
(file-name-directory result
)))
3993 (defun gnus-article-archive-name (_group)
3994 "Return the first instance of an \"Archive-name\" in the current buffer."
3995 (let ((case-fold-search t
))
3996 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3997 (nnheader-concat gnus-article-save-directory
3998 (match-string 1)))))
4000 (defun gnus-article-nndoc-name (group)
4001 "If GROUP is an nndoc group, return the name of the parent group."
4002 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
4003 (gnus-group-get-parameter group
'save-article-group
)))
4005 (defun gnus-summary-save-in-rmail (&optional filename
)
4006 "Append this article to Rmail file.
4007 Optional argument FILENAME specifies file name.
4008 Directory to save to is default to `gnus-article-save-directory'."
4009 (setq filename
(gnus-read-save-file-name
4010 "Save %s in rmail file" filename
4011 gnus-rmail-save-name gnus-newsgroup-name
4012 gnus-current-headers
'gnus-newsgroup-last-rmail
))
4013 (with-current-buffer gnus-save-article-buffer
4017 ;; Note that unlike gnus-summary-save-in-mail, there is no
4018 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4020 (gnus-output-to-rmail filename
))))
4023 (defun gnus-summary-save-in-mail (&optional filename
)
4024 "Append this article to Unix mail file.
4025 Optional argument FILENAME specifies file name.
4026 Directory to save to is default to `gnus-article-save-directory'."
4027 (setq filename
(gnus-read-save-file-name
4028 "Save %s in Unix mail file" filename
4029 gnus-mail-save-name gnus-newsgroup-name
4030 gnus-current-headers
'gnus-newsgroup-last-mail
))
4031 (with-current-buffer gnus-save-article-buffer
4035 (if (and (file-readable-p filename
)
4036 (file-regular-p filename
)
4037 (mail-file-babyl-p filename
))
4038 (gnus-output-to-rmail filename
)
4039 (gnus-output-to-mail filename
)))))
4042 (put 'gnus-summary-save-in-file
:decode t
)
4043 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4044 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4045 "Append this article to file.
4046 Optional argument FILENAME specifies file name.
4047 Directory to save to is default to `gnus-article-save-directory'."
4048 (setq filename
(gnus-read-save-file-name
4049 "Save %s in file" filename
4050 gnus-file-save-name gnus-newsgroup-name
4051 gnus-current-headers
'gnus-newsgroup-last-file
))
4052 (with-current-buffer gnus-save-article-buffer
4056 (when (and overwrite
4057 (file-exists-p filename
))
4058 (delete-file filename
))
4059 (gnus-output-to-file filename
))))
4062 (put 'gnus-summary-write-to-file
:decode t
)
4063 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4064 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4065 (defun gnus-summary-write-to-file (&optional filename
)
4066 "Write this article to a file, overwriting it if the file exists.
4067 Optional argument FILENAME specifies file name.
4068 The directory to save in defaults to `gnus-article-save-directory'."
4069 (setq filename
(gnus-read-save-file-name
4070 "Save %s in file" filename
4071 gnus-file-save-name gnus-newsgroup-name
4072 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4073 (gnus-summary-save-in-file filename t
))
4075 (put 'gnus-summary-save-body-in-file
:decode t
)
4076 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4077 "Append this article body to a file.
4078 Optional argument FILENAME specifies file name.
4079 The directory to save in defaults to `gnus-article-save-directory'."
4080 (setq filename
(gnus-read-save-file-name
4081 "Save %s body in file" filename
4082 gnus-file-save-name gnus-newsgroup-name
4083 gnus-current-headers
'gnus-newsgroup-last-file
))
4084 (with-current-buffer gnus-save-article-buffer
4088 (when (article-goto-body)
4089 (narrow-to-region (point) (point-max)))
4090 (when (and overwrite
4091 (file-exists-p filename
))
4092 (delete-file filename
))
4093 (gnus-output-to-file filename
))))
4096 (put 'gnus-summary-write-body-to-file
:decode t
)
4097 (put 'gnus-summary-write-body-to-file
4098 :function
'gnus-summary-save-body-in-file
)
4099 (defun gnus-summary-write-body-to-file (&optional filename
)
4100 "Write this article body to a file, overwriting it if the file exists.
4101 Optional argument FILENAME specifies file name.
4102 The directory to save in defaults to `gnus-article-save-directory'."
4103 (setq filename
(gnus-read-save-file-name
4104 "Save %s body in file" filename
4105 gnus-file-save-name gnus-newsgroup-name
4106 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4107 (gnus-summary-save-body-in-file filename t
))
4109 (put 'gnus-summary-save-in-pipe
:decode t
)
4110 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4111 (defun gnus-summary-save-in-pipe (&optional command raw
)
4112 "Pipe this article to subprocess COMMAND.
4113 Valid values for COMMAND include:
4115 The executable command name and possibly arguments.
4117 You will be prompted for the command in the minibuffer.
4118 the symbol `default'
4119 It will be replaced with the command which the variable
4120 `gnus-summary-pipe-output-default-command' holds or the command
4121 last used for saving.
4122 Non-nil value for RAW overrides `:decode' and `:headers' properties
4123 and the raw article including all headers will be piped."
4124 (let ((article (gnus-summary-article-number))
4126 (get 'gnus-summary-save-in-pipe
:decode
)))
4127 save-buffer default
)
4129 (if (vectorp (gnus-summary-article-header article
))
4130 (save-current-buffer
4131 (gnus-summary-select-article decode decode nil article
)
4132 (insert-buffer-substring
4136 gnus-original-article-buffer
)
4138 (nnheader-set-temp-buffer " *Gnus Save*"))))
4139 ;; Remove unwanted headers.
4140 (when (and (not raw
)
4141 (or (get 'gnus-summary-save-in-pipe
:headers
)
4142 (not gnus-save-all-headers
)))
4143 (let ((gnus-visible-headers
4144 (or (symbol-value (get 'gnus-summary-save-in-pipe
4146 gnus-saved-headers gnus-visible-headers
))
4147 (gnus-summary-buffer nil
))
4148 (article-hide-headers 1 t
))))
4149 (error "%d is not a real article" article
))
4150 (error "No article to pipe"))
4151 (setq default
(or gnus-summary-pipe-output-default-command
4152 gnus-last-shell-command
))
4153 (unless (stringp command
)
4155 (if (and (eq command
'default
) default
)
4157 (gnus-read-shell-command "Shell command on this article: "
4159 (when (string-equal command
"")
4161 (setq command default
)
4162 (error "A command is required")))
4163 (with-current-buffer save-buffer
4166 (shell-command-on-region (point-min) (point-max) command nil
)))
4167 (gnus-kill-buffer save-buffer
))
4168 (setq gnus-summary-pipe-output-default-command command
))
4170 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4171 "Pipe this article to muttprint."
4172 (unless (stringp command
)
4173 (setq command
(read-string
4174 "Print using command: " gnus-summary-muttprint-program
4175 nil gnus-summary-muttprint-program
)))
4176 (let ((gnus-summary-pipe-output-default-command
4177 gnus-summary-pipe-output-default-command
))
4178 (gnus-summary-save-in-pipe command
))
4179 (setq gnus-summary-muttprint-program command
))
4181 ;;; Article file names when saving.
4183 (defun gnus-capitalize-newsgroup (newsgroup)
4184 "Capitalize NEWSGROUP name."
4185 (when (not (zerop (length newsgroup
)))
4186 (concat (char-to-string (upcase (aref newsgroup
0)))
4187 (substring newsgroup
1))))
4189 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4190 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4191 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4192 Otherwise, it is like ~/News/news/group/num."
4195 (concat (if (gnus-use-long-file-name 'not-save
)
4196 (gnus-capitalize-newsgroup newsgroup
)
4197 (gnus-newsgroup-directory-form newsgroup
))
4198 "/" (int-to-string (mail-header-number headers
)))
4199 gnus-article-save-directory
)))
4201 (string-equal (file-name-directory default
)
4202 (file-name-directory last-file
))
4203 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4205 (or last-file default
))))
4207 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4208 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4209 If variable `gnus-use-long-file-name' is non-nil, it is
4210 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4213 (concat (if (gnus-use-long-file-name 'not-save
)
4215 (gnus-newsgroup-directory-form newsgroup
))
4216 "/" (int-to-string (mail-header-number headers
)))
4217 gnus-article-save-directory
)))
4219 (string-equal (file-name-directory default
)
4220 (file-name-directory last-file
))
4221 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4223 (or last-file default
))))
4225 (defun gnus-plain-save-name (newsgroup _headers
&optional last-file
)
4226 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4227 If variable `gnus-use-long-file-name' is non-nil, it is
4228 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4231 (if (gnus-use-long-file-name 'not-save
)
4234 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4236 gnus-article-save-directory
)))
4238 (defun gnus-sender-save-name (_newsgroup headers
&optional _last-file
)
4239 "Generate file name from sender."
4240 (let ((from (mail-header-from headers
)))
4242 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4243 (match-string 1 from
)
4245 gnus-article-save-directory
)))
4247 (defun article-verify-x-pgp-sig ()
4249 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4251 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4252 (let ((sig (with-current-buffer gnus-original-article-buffer
4253 (gnus-fetch-field "X-PGP-Sig")))
4257 (mml2015-clear-verify-function))
4259 (insert-buffer-substring gnus-original-article-buffer
)
4260 (setq items
(split-string sig
))
4261 (message-narrow-to-head)
4262 (let ((inhibit-point-motion-hooks t
)
4263 (case-fold-search t
))
4264 ;; Don't verify multiple headers.
4265 (setq headers
(mapconcat (lambda (header)
4267 (mail-fetch-field header
)
4269 (split-string (nth 1 items
) ",") "")))
4270 (delete-region (point-min) (point-max))
4271 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4272 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4277 (if (looking-at "^-")
4280 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4281 (insert "Version: " (car items
) "\n\n")
4282 (insert (mapconcat 'identity
(cddr items
) "\n"))
4283 (insert "\n-----END PGP SIGNATURE-----\n")
4284 (let ((mm-security-handle (list (format "multipart/signed"))))
4285 (mml2015-clean-buffer)
4286 (let ((coding-system-for-write (or gnus-newsgroup-charset
4288 (funcall (mml2015-clear-verify-function)))
4290 (or (mm-handle-multipart-ctl-parameter
4291 mm-security-handle
'gnus-details
)
4292 (mm-handle-multipart-ctl-parameter
4293 mm-security-handle
'gnus-info
)))))
4295 (let ((inhibit-read-only t
) bface eface
)
4297 (message-narrow-to-head)
4298 (goto-char (point-max))
4300 (setq bface
(get-text-property (point-at-bol) 'face
)
4301 eface
(get-text-property (1- (point-at-eol)) 'face
))
4302 (message-remove-header "X-Gnus-PGP-Verify")
4303 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4305 (goto-char (point-max)))
4306 (narrow-to-region (point) (point))
4307 (insert "X-Gnus-PGP-Verify: " info
"\n")
4308 (goto-char (point-min))
4311 (if (not (looking-at "^[ \t]"))
4315 (goto-char (point-min))
4316 (when (looking-at "\\([^:]+\\): *")
4317 (put-text-property (match-beginning 1) (1+ (match-end 1))
4319 (put-text-property (match-end 0) (point-max)
4320 'face eface
)))))))))
4322 (autoload 'canlock-verify
"canlock" nil t
) ;; for XEmacs.
4324 (defun article-verify-cancel-lock ()
4325 "Verify Cancel-Lock header."
4327 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4328 (canlock-verify gnus-original-article-buffer
)))
4335 (setq afunc
(car func
)
4338 gfunc
(intern (format "gnus-%s" func
))))
4340 (when (fboundp afunc
)
4341 `(lambda (&optional interactive
&rest args
)
4342 ,(documentation afunc t
)
4343 (interactive (list t
))
4344 (with-current-buffer gnus-article-buffer
4346 (call-interactively ',afunc
)
4347 (apply ',afunc args
))))))))
4348 '(article-hide-headers
4349 article-verify-x-pgp-sig
4350 article-verify-cancel-lock
4351 article-hide-boring-headers
4352 article-treat-overstrike
4353 article-treat-ansi-sequences
4354 article-fill-long-lines
4355 article-capitalize-sentences
4357 article-remove-leading-whitespace
4358 article-display-x-face
4359 article-display-face
4360 article-de-quoted-unreadable
4361 article-de-base64-unreadable
4364 article-unsplit-urls
4365 article-hide-list-identifiers
4366 article-strip-banner
4369 article-hide-signature
4370 article-strip-headers-in-body
4371 article-remove-trailing-blank-lines
4372 article-strip-leading-blank-lines
4373 article-strip-multiple-blank-lines
4374 article-strip-leading-space
4375 article-strip-trailing-space
4376 article-strip-blank-lines
4377 article-strip-all-blank-lines
4379 article-date-english
4380 article-date-iso8601
4381 article-date-original
4384 article-decode-mime-words
4385 article-decode-charset
4386 article-decode-encoded-words
4389 article-date-combined-lapsed
4391 article-treat-dumbquotes
4392 article-treat-non-ascii
4393 article-normalize-headers
4394 ;;(article-show-all . gnus-article-show-all-headers)
4398 ;;; Gnus article mode
4401 (put 'gnus-article-mode
'mode-class
'special
)
4403 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4405 (gnus-define-keys gnus-article-mode-map
4406 " " gnus-article-goto-next-page
4407 [?\S-\
] gnus-article-goto-prev-page
4408 "\177" gnus-article-goto-prev-page
4409 [delete] gnus-article-goto-prev-page
4410 "\C-c^" gnus-article-refer-article
4411 "h" gnus-article-show-summary
4412 "s" gnus-article-show-summary
4413 "\C-c\C-m" gnus-article-mail
4414 "?" gnus-article-describe-briefly
4415 "<" beginning-of-buffer
4417 "\C-c\C-i" gnus-info-find-node
4419 "R" gnus-article-reply-with-original
4420 "F" gnus-article-followup-with-original
4421 "\C-hk" gnus-article-describe-key
4422 "\C-hc" gnus-article-describe-key-briefly
4423 "\C-hb" gnus-article-describe-bindings
4425 "e" gnus-article-read-summary-keys
4426 "\C-d" gnus-article-read-summary-keys
4427 "\M-*" gnus-article-read-summary-keys
4428 "\M-#" gnus-article-read-summary-keys
4429 "\M-^" gnus-article-read-summary-keys
4430 "\M-g" gnus-article-read-summary-keys)
4432 (substitute-key-definition
4433 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4435 (defvar gnus-article-send-map)
4437 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4438 "W" gnus-article-wide-reply-with-original)
4439 (if (featurep 'xemacs)
4440 (set-keymap-default-binding gnus-article-send-map
4441 'gnus-article-read-summary-send-keys)
4442 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4444 (defun gnus-article-make-menu-bar ()
4445 (unless (boundp 'gnus-article-commands-menu)
4446 (gnus-summary-make-menu-bar))
4447 (unless (boundp 'gnus-article-article-menu)
4449 gnus-article-article-menu gnus-article-mode-map ""
4451 ["Scroll forwards" gnus-article-goto-next-page t]
4452 ["Scroll backwards" gnus-article-goto-prev-page t]
4453 ["Show summary" gnus-article-show-summary t]
4454 ["Fetch Message-ID at point" gnus-article-refer-article t]
4455 ["Mail to address at point" gnus-article-mail t]
4456 ["Send a bug report" gnus-bug t]))
4459 gnus-article-treatment-menu gnus-article-mode-map ""
4460 ;; Fixme: this should use :active (and maybe :visible).
4462 ["Hide headers" gnus-article-hide-headers t]
4463 ["Hide signature" gnus-article-hide-signature t]
4464 ["Hide citation" gnus-article-hide-citation t]
4465 ["Treat overstrike" gnus-article-treat-overstrike t]
4466 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4467 ["Remove carriage return" gnus-article-remove-cr t]
4468 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4469 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4470 ["Remove base64" gnus-article-de-base64-unreadable t]
4471 ["Treat html" gnus-article-wash-html t]
4472 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4473 ["Decode HZ" gnus-article-decode-HZ t]))
4475 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4477 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4479 (gnus-run-hooks 'gnus-article-menu-hook)))
4481 (defvar bookmark-make-record-function)
4482 (defvar shr-put-image-function)
4484 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4485 "Major mode for displaying an article.
4487 All normal editing commands are switched off.
4489 The following commands are available in addition to all summary mode
4491 \\<gnus-article-mode-map>
4492 \\[gnus-article-next-page]\t Scroll the article one page forwards
4493 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4494 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4495 \\[gnus-article-show-summary]\t Display the summary buffer
4496 \\[gnus-article-mail]\t Send a reply to the address near point
4497 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4498 \\[gnus-info-find-node]\t Go to the Gnus info node"
4499 (gnus-simplify-mode-line)
4500 (make-local-variable 'minor-mode-alist)
4501 (when (gnus-visual-p 'article-menu 'menu)
4502 (gnus-article-make-menu-bar)
4503 (when gnus-summary-tool-bar-map
4504 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4505 (gnus-update-format-specifications nil 'article-mode)
4506 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4507 (set (make-local-variable 'gnus-page-broken) nil)
4508 (make-local-variable 'gnus-article-current-summary)
4509 (make-local-variable 'gnus-article-mime-handles)
4510 (make-local-variable 'gnus-article-decoded-p)
4511 (make-local-variable 'gnus-article-mime-handle-alist)
4512 (make-local-variable 'gnus-article-wash-types)
4513 (make-local-variable 'gnus-article-image-alist)
4514 (make-local-variable 'gnus-article-charset)
4515 (make-local-variable 'gnus-article-ignored-charsets)
4516 (set (make-local-variable 'bookmark-make-record-function)
4517 'gnus-summary-bookmark-make-record)
4518 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4520 (set (make-local-variable 'nobreak-char-display) nil)
4521 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4522 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4523 (setq cursor-in-non-selected-windows nil)
4524 (gnus-set-default-directory)
4525 (buffer-disable-undo)
4526 (setq buffer-read-only t
4527 show-trailing-whitespace nil)
4528 (mm-enable-multibyte))
4530 (defun gnus-article-setup-buffer ()
4531 "Initialize the article buffer."
4532 (let* ((name (if gnus-single-article-buffer "*Article*"
4534 (gnus-group-decoded-name gnus-newsgroup-name)
4537 (progn (string-match "\\*Article" name)
4538 (concat " *Original Article"
4539 (substring name (match-end 0))))))
4540 (setq gnus-article-buffer name)
4541 (setq gnus-original-article-buffer original)
4542 (setq gnus-article-mime-handle-alist nil)
4543 (with-current-buffer gnus-summary-buffer
4544 ;; This might be a variable local to the summary buffer.
4545 (unless gnus-single-article-buffer
4546 (setq gnus-article-buffer name)
4547 (setq gnus-original-article-buffer original)
4548 (gnus-set-global-variables)))
4549 (gnus-article-setup-highlight-words)
4550 ;; Init original article buffer.
4551 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4552 (mm-enable-multibyte)
4553 (setq major-mode 'gnus-original-article-mode)
4554 (make-local-variable 'gnus-original-article))
4555 (if (and (get-buffer name)
4556 (with-current-buffer name
4557 (if gnus-article-edit-mode
4558 (if (y-or-n-p "Article mode edit in progress; discard? ")
4560 (set-buffer-modified-p nil)
4561 (gnus-kill-buffer name)
4564 (error "Action aborted"))
4566 (let ((summary gnus-summary-buffer))
4567 (with-current-buffer name
4568 (set (make-local-variable 'gnus-article-edit-mode) nil)
4569 (gnus-article-stop-animations)
4570 (when gnus-article-mime-handles
4571 (mm-destroy-parts gnus-article-mime-handles)
4572 (setq gnus-article-mime-handles nil))
4573 ;; Set it to nil in article-buffer!
4574 (setq gnus-article-mime-handle-alist nil)
4575 (buffer-disable-undo)
4576 (setq buffer-read-only t)
4577 (unless (derived-mode-p 'gnus-article-mode)
4578 (gnus-article-mode))
4579 (set (make-local-variable 'gnus-summary-buffer) summary)
4580 (setq truncate-lines gnus-article-truncate-lines)
4582 (let ((summary gnus-summary-buffer))
4583 (with-current-buffer (gnus-get-buffer-create name)
4585 (setq truncate-lines gnus-article-truncate-lines)
4586 (set (make-local-variable 'gnus-summary-buffer) summary)
4587 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4588 (when article-lapsed-timer
4589 (gnus-stop-date-timer))
4590 (when gnus-article-update-date-headers
4591 (gnus-start-date-timer gnus-article-update-date-headers))
4592 (current-buffer))))))
4594 (defun gnus-article-stop-animations ()
4595 (dolist (timer (and (boundp 'timer-list)
4597 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4598 (cancel-timer timer))))
4600 (defun gnus-stop-downloads ()
4601 (when (boundp 'url-queue)
4602 (set (intern "url-queue" obarray) nil)))
4604 ;; Set article window start at LINE, where LINE is the number of lines
4605 ;; from the head of the article.
4606 (defun gnus-article-set-window-start (&optional line)
4607 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4608 (when article-window
4611 (with-current-buffer gnus-article-buffer
4612 (goto-char (point-min))
4615 (gnus-message 6 "Moved to bookmark")
4616 (search-forward "\n\n" nil t)
4620 (defvar gnus-tmp-internal-hook)
4622 (defun gnus-article-prepare (article &optional all-headers _header)
4623 "Prepare ARTICLE in article mode buffer.
4624 ARTICLE should either be an article number or a Message-ID.
4625 If ARTICLE is an id, HEADER should be the article headers.
4626 If ALL-HEADERS is non-nil, no headers are hidden."
4627 (save-excursion ;FIXME: Shouldn't that be save-current-buffer?
4628 ;; Make sure we start in a summary buffer.
4629 (unless (derived-mode-p 'gnus-summary-mode)
4630 (set-buffer gnus-summary-buffer))
4631 (setq gnus-summary-buffer (current-buffer))
4632 (let* ((summary-buffer (current-buffer))
4633 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4634 (group gnus-newsgroup-name)
4637 (gnus-article-setup-buffer)
4638 (set-buffer gnus-article-buffer)
4639 ;; Deactivate active regions.
4640 (when (and (boundp 'transient-mark-mode)
4641 transient-mark-mode)
4642 (setq mark-active nil))
4643 (if (not (setq result (let ((inhibit-read-only t))
4644 (gnus-request-article-this-buffer
4646 ;; There is no such article.
4648 (when (and (numberp article)
4649 (not (memq article gnus-newsgroup-sparse)))
4650 (setq gnus-article-current
4651 (cons gnus-newsgroup-name article))
4652 (set-buffer gnus-summary-buffer)
4653 (setq gnus-current-article article)
4654 (if (and (memq article gnus-newsgroup-undownloaded)
4655 (not (gnus-online (gnus-find-method-for-group
4656 gnus-newsgroup-name))))
4658 (gnus-summary-set-agent-mark article)
4659 (message "Message marked for downloading"))
4660 (gnus-summary-mark-article article gnus-canceled-mark)
4661 (unless (memq article gnus-newsgroup-sparse)
4662 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4663 (if (or (eq result 'pseudo)
4664 (eq result 'nneething))
4666 (with-current-buffer summary-buffer
4667 (push article gnus-newsgroup-history)
4668 (setq gnus-last-article gnus-current-article
4669 gnus-current-article 0
4670 gnus-current-headers nil
4671 gnus-article-current nil)
4672 (if (eq result 'nneething)
4673 (gnus-configure-windows 'summary)
4674 (gnus-configure-windows 'article))
4675 (gnus-set-global-variables))
4676 (let ((gnus-article-mime-handle-alist-1
4677 gnus-article-mime-handle-alist))
4678 (gnus-set-mode-line 'article)))
4679 ;; The result from the `request' was an actual article -
4680 ;; or at least some text that is now displayed in the
4682 (when (and (numberp article)
4683 (not (eq article gnus-current-article)))
4684 ;; Seems like a new article has been selected.
4685 ;; `gnus-current-article' must be an article number.
4686 (with-current-buffer summary-buffer
4687 (push article gnus-newsgroup-history)
4688 (setq gnus-last-article gnus-current-article
4689 gnus-current-article article
4690 gnus-current-headers
4691 (gnus-summary-article-header gnus-current-article)
4692 gnus-article-current
4693 (cons gnus-newsgroup-name gnus-current-article))
4694 (unless (vectorp gnus-current-headers)
4695 (setq gnus-current-headers nil))
4696 (gnus-summary-goto-subject gnus-current-article)
4697 (when (gnus-summary-show-thread)
4698 ;; If the summary buffer really was folded, the
4699 ;; previous goto may not actually have gone to
4700 ;; the right article, but the thread root instead.
4702 (gnus-summary-goto-subject gnus-current-article))
4703 (gnus-run-hooks 'gnus-mark-article-hook)
4704 (gnus-set-mode-line 'summary)
4705 (when (gnus-visual-p 'article-highlight 'highlight)
4706 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4707 ;; Set the global newsgroup variables here.
4708 (gnus-set-global-variables)
4709 (setq gnus-have-all-headers
4710 (or all-headers gnus-show-all-headers))))
4712 (gnus-configure-windows 'article))
4713 (when (or (numberp article)
4715 (gnus-article-prepare-display)
4717 (goto-char (point-min))
4718 (when gnus-break-pages
4719 (gnus-narrow-to-page)))
4720 (let ((gnus-article-mime-handle-alist-1
4721 gnus-article-mime-handle-alist))
4722 (gnus-set-mode-line 'article))
4726 (set-window-point (get-buffer-window (current-buffer)) (point))
4727 (gnus-configure-windows 'article)
4728 (gnus-run-hooks 'gnus-article-prepare-hook)
4731 (defvar gnus-mime-display-attachment-buttons-in-header)
4734 (defun gnus-article-prepare-display ()
4735 "Make the current buffer look like a nice article."
4736 ;; Hooks for getting information from the article.
4737 ;; This hook must be called before being narrowed.
4738 (let ((gnus-article-buffer (current-buffer))
4740 (inhibit-read-only t))
4741 (unless (derived-mode-p 'gnus-article-mode)
4742 (gnus-article-mode))
4743 (setq buffer-read-only nil
4744 gnus-article-wash-types nil
4745 gnus-article-image-alist nil)
4746 (gnus-run-hooks 'gnus-tmp-internal-hook)
4747 (when gnus-display-mime-function
4748 (funcall gnus-display-mime-function))
4749 ;; Add attachment buttons to the header.
4750 (when gnus-mime-display-attachment-buttons-in-header
4751 (gnus-mime-buttonize-attachments-in-header))))
4754 ;;; Gnus Sticky Article Mode
4757 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4758 "Mode for sticky articles."
4759 ;; Release bindings that won't work.
4760 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4761 gnus-sticky-article-mode-map)
4762 (substitute-key-definition 'gnus-article-refer-article 'undefined
4763 gnus-sticky-article-mode-map)
4764 (dolist (k '("e" "h" "s" "F" "R"))
4765 (define-key gnus-sticky-article-mode-map k nil))
4766 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4767 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4768 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4769 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4771 (defun gnus-sticky-article (arg)
4772 "Make the current article sticky.
4773 If a prefix ARG is given, ask for a name for this sticky article buffer."
4775 (gnus-summary-show-thread)
4776 (gnus-summary-select-article nil nil 'pseudo)
4777 (let (new-art-buf-name)
4778 (gnus-eval-in-buffer-window gnus-article-buffer
4779 (setq new-art-buf-name
4783 (read-from-minibuffer "Sticky article buffer name: ")
4784 (gnus-with-article-headers
4785 (gnus-article-goto-header "subject")
4786 (setq 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 "from")
4791 (setq new-art-buf-name
4793 new-art-buf-name ", "
4794 (buffer-substring-no-properties
4795 (line-beginning-position) (line-end-position))))
4796 (goto-char (point-min))
4797 (gnus-article-goto-header "date")
4798 (setq new-art-buf-name
4800 new-art-buf-name ", "
4801 (buffer-substring-no-properties
4802 (line-beginning-position) (line-end-position))))))
4804 (if (and (gnus-buffer-live-p new-art-buf-name)
4805 (with-current-buffer new-art-buf-name
4806 (derived-mode-p 'gnus-sticky-article-mode)))
4807 (switch-to-buffer new-art-buf-name)
4808 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4809 (gnus-sticky-article-mode))
4810 (setq gnus-article-buffer new-art-buf-name))
4811 (gnus-summary-recenter)
4812 (gnus-summary-position-point))
4814 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4815 "Kill the given sticky article BUFFER.
4816 If none is given, assume the current buffer and kill it if it has
4817 `gnus-sticky-article-mode'."
4820 (setq buffer (current-buffer)))
4821 (with-current-buffer buffer
4822 (when (derived-mode-p 'gnus-sticky-article-mode)
4823 (gnus-kill-buffer buffer))))
4825 (defun gnus-kill-sticky-article-buffers (arg)
4826 "Kill all sticky article buffers.
4827 If a prefix ARG is given, ask for confirmation."
4829 (dolist (buf (gnus-buffers))
4830 (with-current-buffer buf
4831 (when (derived-mode-p 'gnus-sticky-article-mode)
4833 (gnus-kill-buffer buf)
4834 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4835 (gnus-kill-buffer buf)))))))
4838 ;;; Gnus MIME viewing functions
4841 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4842 "Format of the MIME buttons.
4844 Valid specifiers include:
4846 %T MIME type, along with additional info
4847 %n The `name' parameter
4848 %d The description, if any
4849 %l The length of the encoded part
4850 %p The part identifier number
4851 %e Dots if the part isn't displayed
4853 General format specifiers can also be used. See Info node
4854 `(gnus)Formatting Variables'.")
4856 (defvar gnus-tmp-type)
4857 (defvar gnus-tmp-type-long)
4858 (defvar gnus-tmp-name)
4859 (defvar gnus-tmp-description)
4860 (defvar gnus-tmp-id)
4861 (defvar gnus-tmp-length)
4862 (defvar gnus-tmp-dots)
4863 (defvar gnus-tmp-info)
4864 (defvar gnus-tmp-pressed-details)
4866 (defvar gnus-mime-button-line-format-alist
4867 '((?t gnus-tmp-type ?s)
4868 (?T gnus-tmp-type-long ?s)
4869 (?n gnus-tmp-name ?s)
4870 (?d gnus-tmp-description ?s)
4872 (?l gnus-tmp-length ?d)
4873 (?e gnus-tmp-dots ?s)))
4875 (defvar gnus-mime-button-commands
4876 '((gnus-article-press-button "\r" "Toggle Display")
4877 (gnus-mime-view-part "v" "View Interactively...")
4878 (gnus-mime-view-part-as-type "t" "View As Type...")
4879 (gnus-mime-view-part-as-charset "C" "View As charset...")
4880 (gnus-mime-save-part "o" "Save...")
4881 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4882 (gnus-mime-replace-part "r" "Replace part")
4883 (gnus-mime-delete-part "d" "Delete part")
4884 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4885 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4886 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4887 (gnus-mime-view-part-externally "e" "View Externally")
4888 (gnus-mime-print-part "p" "Print")
4889 (gnus-mime-pipe-part "|" "Pipe To Command...")
4890 (gnus-mime-action-on-part "." "Take action on the part...")))
4892 (defun gnus-article-mime-part-status ()
4893 (if gnus-article-mime-handle-alist-1
4894 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4896 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4899 (defvar gnus-mime-button-map
4900 (let ((map (make-sparse-keymap)))
4901 (define-key map gnus-mouse-2 'gnus-article-push-button)
4902 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4903 (dolist (c gnus-mime-button-commands)
4904 (define-key map (cadr c) (car c)))
4908 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4910 ,@(mapcar (lambda (c)
4911 (vector (caddr c) (car c) :active t))
4912 gnus-mime-button-commands)))
4914 (defvar gnus-url-button-commands
4915 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4917 (defvar gnus-url-button-map
4918 (let ((map (make-sparse-keymap)))
4919 (dolist (c gnus-url-button-commands)
4920 (define-key map (cadr c) (car c)))
4924 gnus-url-button-menu gnus-url-button-map "URL button menu."
4926 ,@(mapcar (lambda (c)
4927 (vector (caddr c) (car c) :active t))
4928 gnus-url-button-commands)))
4930 (defmacro gnus-bind-safe-url-regexp (&rest body)
4931 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4932 `(let ((mm-w3m-safe-url-regexp
4933 (let ((group (if (and (derived-mode-p 'gnus-article-mode)
4935 gnus-article-current-summary))
4936 (with-current-buffer gnus-article-current-summary
4937 gnus-newsgroup-name)
4938 gnus-newsgroup-name)))
4939 (if (cond ((not group)
4940 ;; Maybe we're in a mml-preview buffer
4941 ;; and no group is selected.
4943 ((stringp gnus-safe-html-newsgroups)
4944 (string-match gnus-safe-html-newsgroups group))
4945 ((consp gnus-safe-html-newsgroups)
4946 (member group gnus-safe-html-newsgroups)))
4948 mm-w3m-safe-url-regexp))))
4951 (defun gnus-mime-button-menu (event prefix)
4952 "Construct a context-sensitive menu of MIME commands."
4953 (interactive "e\nP")
4954 (save-window-excursion
4955 (let ((pos (event-start event)))
4956 (select-window (posn-window pos))
4957 (goto-char (posn-point pos))
4958 (gnus-article-check-buffer)
4959 (popup-menu gnus-mime-button-menu nil prefix))))
4961 (defun gnus-mime-view-all-parts (&optional handles)
4962 "View all the MIME parts."
4964 (with-current-buffer gnus-article-buffer
4965 (let ((handles (or handles gnus-article-mime-handles))
4966 (mail-parse-charset gnus-newsgroup-charset)
4967 (mail-parse-ignored-charsets
4968 (with-current-buffer gnus-summary-buffer
4969 gnus-newsgroup-ignored-charsets)))
4971 (mm-remove-parts handles)
4972 (goto-char (point-min))
4973 (or (search-forward "\n\n") (goto-char (point-max)))
4974 (let ((inhibit-read-only t))
4975 (delete-region (point) (point-max))
4976 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4978 (defun gnus-article-jump-to-part (n)
4979 "Jump to MIME part N."
4981 (let ((parts (with-current-buffer gnus-article-buffer
4982 (length gnus-article-mime-handle-alist))))
4984 (error "No such part"))
4985 (pop-to-buffer gnus-article-buffer)
4987 (setq n (if (= parts 1)
4989 (read-number (format "Jump to part (1..%s): " parts)))))
4990 (unless (and (integerp n) (<= n parts) (>= n 1))
4993 (gnus-message 7 "Invalid part `%s', using %s instead."
4996 (gnus-message 9 "Jumping to part %s." n)
4997 (cond ((>= gnus-auto-select-part 1)
4998 (while (and (<= n parts)
4999 (not (gnus-article-goto-part n)))
5001 ((< gnus-auto-select-part 0)
5002 (while (and (>= n 1)
5003 (not (gnus-article-goto-part n)))
5006 (gnus-article-goto-part n)))))
5008 (defvar gnus-mime-buttonized-part-id nil
5009 "ID of a mime part that should be buttonized.
5010 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
5013 (defsubst gnus-article-edit-part (handles &optional current-id)
5014 "Edit an article in order to delete a mime part.
5015 This function is exclusively used by `gnus-mime-save-part-and-strip'
5016 and `gnus-mime-delete-part', and not provided at run-time normally."
5017 (gnus-article-edit-article
5019 (buffer-disable-undo)
5020 (let ((mail-parse-charset (or gnus-article-charset
5021 ',gnus-newsgroup-charset))
5022 (mail-parse-ignored-charsets
5023 (or gnus-article-ignored-charsets
5024 ',gnus-newsgroup-ignored-charsets))
5025 (mbl mml-buffer-list))
5026 (setq mml-buffer-list nil)
5027 ;; A new text must be inserted before deleting existing ones
5028 ;; at the end so as not to move existing markers of which
5029 ;; the insertion type is t.
5033 (goto-char (point-max))
5034 (insert-buffer-substring gnus-original-article-buffer)))
5035 (mime-to-mml ',handles)
5036 (setq gnus-article-mime-handles nil)
5037 (let ((mbl1 mml-buffer-list))
5038 (setq mml-buffer-list mbl)
5039 (set (make-local-variable 'mml-buffer-list) mbl1))
5040 (gnus-make-local-hook 'kill-buffer-hook)
5041 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5042 `(lambda (no-highlight)
5043 (let ((mail-parse-charset (or gnus-article-charset
5044 ',gnus-newsgroup-charset))
5045 (message-options message-options)
5046 (message-options-set-recipient)
5047 (mail-parse-ignored-charsets
5048 (or gnus-article-ignored-charsets
5049 ',gnus-newsgroup-ignored-charsets)))
5051 (mml-destroy-buffers)
5052 (remove-hook 'kill-buffer-hook
5053 'mml-destroy-buffers t)
5054 (kill-local-variable 'mml-buffer-list))
5055 (gnus-summary-edit-article-done
5056 ,(or (mail-header-references gnus-current-headers) "")
5057 ,(gnus-group-read-only-p)
5058 ,gnus-summary-buffer no-highlight))
5060 ;; Force buttonizing this part.
5061 (let ((gnus-mime-buttonized-part-id current-id))
5062 (gnus-article-edit-done))
5063 (gnus-configure-windows 'article)
5065 (when (and current-id (integerp gnus-auto-select-part))
5066 (gnus-article-jump-to-part
5067 (min (max (+ current-id gnus-auto-select-part) 1)
5068 (with-current-buffer gnus-article-buffer
5069 (length gnus-article-mime-handle-alist)))))))
5071 (defun gnus-mime-replace-part (file)
5072 "Replace MIME part under point with an external body."
5073 ;; Useful if file has already been saved to disk
5076 (read-file-name "Replace MIME part with file: "
5077 (or mm-default-directory default-directory)
5079 (gnus-mime-save-part-and-strip file))
5081 (defun gnus-mime-save-part-and-strip (&optional file)
5082 "Save the MIME part under point then replace it with an external body.
5083 If FILE is given, use it for the external part."
5085 (gnus-article-check-buffer)
5086 (when (gnus-group-read-only-p)
5087 (error "The current group does not support deleting of parts"))
5088 (when (mm-complicated-handles gnus-article-mime-handles)
5090 The current article has a complicated MIME structure, giving up..."))
5091 (let* ((data (get-text-property (point) 'gnus-data))
5092 (id (get-text-property (point) 'gnus-part))
5093 (handles gnus-article-mime-handles))
5096 (and data (mm-save-part data "Delete MIME part and save to: "))))
5098 (with-current-buffer (mm-handle-buffer data)
5100 (insert "Content-Type: " (mm-handle-media-type data))
5101 (mml-insert-parameter-string (cdr (mm-handle-type data))
5103 ;; Add a filename for the sake of saving the part again.
5104 (mml-insert-parameter
5105 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5107 (insert "Content-ID: " (message-make-message-id) "\n")
5108 (insert "Content-Transfer-Encoding: binary\n")
5111 (cdr (mm-make-handle nil
5112 `("message/external-body"
5113 (access-type . "LOCAL-FILE")
5115 ;; (set-buffer gnus-summary-buffer)
5116 (gnus-article-edit-part handles id))))
5118 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5119 ;; parts...>') but with stripping would be nice.
5121 (defun gnus-mime-delete-part ()
5122 "Delete the MIME part under point.
5123 Replace it with some information about the removed part."
5125 (gnus-article-check-buffer)
5126 (when (gnus-group-read-only-p)
5127 (error "The current group does not support deleting of parts"))
5128 (when (mm-complicated-handles gnus-article-mime-handles)
5130 The current article has a complicated MIME structure, giving up..."))
5131 (when (or gnus-expert-user
5132 (gnus-yes-or-no-p "\
5133 Deleting parts may malfunction or destroy the article; continue? "))
5134 (let* ((data (get-text-property (point) 'gnus-data))
5135 (id (get-text-property (point) 'gnus-part))
5136 (handles gnus-article-mime-handles)
5138 (let ((desc (mm-handle-description data)))
5140 (mail-decode-encoded-word-string desc))))
5141 (filename (or (mm-handle-filename data) "(none)"))
5142 (type (mm-handle-media-type data)))
5144 (error "No MIME part under point"))
5145 (with-current-buffer (mm-handle-buffer data)
5146 (let ((bsize (buffer-size)))
5151 "| The following attachment has been deleted:\n"
5153 "| Type: " type "\n"
5154 "| Filename: " filename "\n"
5155 "| Size (encoded): " (format "%s byte%s\n"
5156 bsize (if (= bsize 1)
5160 (concat "| Description: " description "\n"))
5163 (cdr (mm-make-handle
5164 nil `("text/plain" (charset . gnus-decoded)) nil nil
5166 (format "Deleted attachment (%s bytes)" bsize))))))
5167 ;; (set-buffer gnus-summary-buffer)
5168 (gnus-article-edit-part handles id))))
5170 (defun gnus-mime-save-part ()
5171 "Save the MIME part under point."
5173 (gnus-article-check-buffer)
5174 (let ((data (get-text-property (point) 'gnus-data)))
5176 (mm-save-part data))))
5178 (defun gnus-mime-pipe-part (&optional cmd)
5179 "Pipe the MIME part under point to a process.
5180 Use CMD as the process."
5182 (gnus-article-check-buffer)
5183 (let ((data (get-text-property (point) 'gnus-data)))
5185 (mm-pipe-part data cmd))))
5187 (defun gnus-mime-view-part ()
5188 "Interactively choose a viewing method for the MIME part under point."
5190 (gnus-article-check-buffer)
5191 (let ((data (get-text-property (point) 'gnus-data)))
5193 (setq gnus-article-mime-handles
5195 gnus-article-mime-handles (setq data (copy-sequence data))))
5196 (mm-interactively-view-part data))))
5198 (defun gnus-mime-view-part-as-type-internal ()
5199 (gnus-article-check-buffer)
5200 (let* ((handle (get-text-property (point) 'gnus-data))
5202 ;; Content-Type: foo/bar; name=...
5203 (mail-content-type-get (mm-handle-type handle) 'name)
5204 ;; Content-Disposition: attachment; filename=...
5205 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5206 (def-type (and name (mm-default-file-encoding name))))
5207 (or (and def-type (cons def-type 0))
5209 (equal (mm-handle-media-supertype handle) "text")
5210 '("text/plain" . 0))
5211 '("application/octet-stream" . 0))))
5213 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5214 "Choose a MIME media type, and view the part as such.
5215 If non-nil, PRED is a predicate to use during completion to limit the
5216 available media-types."
5220 (let ((default (gnus-mime-view-part-as-type-internal)))
5221 (gnus-completing-read
5224 (gnus-remove-if-not pred (mailcap-mime-types))
5225 (mailcap-mime-types))
5228 (gnus-article-check-buffer)
5229 (let ((handle (get-text-property (point) 'gnus-data)))
5231 (when (equal (mm-handle-media-type handle) "message/external-body")
5232 (unless (mm-handle-cache handle)
5233 (mm-extern-cache-contents handle))
5234 (setq handle (mm-handle-cache handle)))
5236 (mm-make-handle (mm-handle-buffer handle)
5237 (cons mime-type (cdr (mm-handle-type handle)))
5238 (mm-handle-encoding handle)
5239 (mm-handle-undisplayer handle)
5240 (mm-handle-disposition handle)
5241 (mm-handle-description handle)
5243 (mm-handle-id handle)))
5244 (setq gnus-article-mime-handles
5245 (mm-merge-handles gnus-article-mime-handles handle))
5246 (when (mm-handle-displayed-p handle)
5247 (mm-remove-part handle))
5248 (gnus-mm-display-part handle))))
5250 (defun gnus-mime-copy-part (&optional handle arg)
5251 "Put the MIME part under point into a new buffer.
5252 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5254 (interactive (list nil current-prefix-arg))
5255 (gnus-article-check-buffer)
5257 (setq handle (get-text-property (point) 'gnus-data)))
5259 (let ((filename (mm-handle-filename handle))
5260 contents dont-decode charset coding-system)
5261 (mm-with-unibyte-buffer
5262 (mm-insert-part handle)
5263 (setq contents (or (condition-case nil
5264 (mm-decompress-buffer filename nil 'sig)
5266 (setq dont-decode t)
5269 (setq filename (cond (filename (file-name-nondirectory filename))
5270 (dont-decode "*raw data*")
5275 (unless (setq charset (mail-content-type-get
5276 (mm-handle-type handle) 'charset))
5277 (unless (setq coding-system (mm-with-unibyte-buffer
5279 (mm-find-buffer-file-coding-system)))
5280 (setq charset gnus-newsgroup-charset))))
5282 (setq charset (or (cdr (assq arg
5283 gnus-summary-show-article-charset-alist))
5284 (mm-read-coding-system "Charset: ")))))
5285 (switch-to-buffer (generate-new-buffer filename))
5286 (if (or coding-system
5288 (setq coding-system (mm-charset-to-coding-system
5290 (not (eq coding-system 'ascii))))
5292 (mm-enable-multibyte)
5293 (insert (mm-decode-coding-string contents coding-system))
5294 (setq buffer-file-coding-system
5295 (if (boundp 'last-coding-system-used)
5296 (symbol-value 'last-coding-system-used)
5298 (mm-disable-multibyte)
5300 (setq buffer-file-coding-system mm-binary-coding-system))
5301 ;; We do it this way to make `normal-mode' set the appropriate mode.
5304 (setq buffer-file-name (expand-file-name filename))
5306 (setq buffer-file-name nil))
5307 (goto-char (point-min)))))
5309 (defun gnus-mime-print-part (&optional handle filename)
5310 "Print the MIME part under point."
5311 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5312 (gnus-article-check-buffer)
5313 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5314 (contents (and handle (mm-get-part handle)))
5315 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5316 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5321 (mm-save-part-to-file handle file)
5322 (call-process shell-file-name nil
5323 (generate-new-buffer " *mm*")
5325 shell-command-switch
5327 printer file (mm-handle-type handle))))
5331 (gnus-print-buffer))
5332 (ps-despool filename)))))
5334 (defun gnus-mime-inline-part (&optional handle arg)
5335 "Insert the MIME part under point into the current buffer.
5336 Compressed files like .gz and .bz2 are decompressed."
5337 (interactive (list nil current-prefix-arg))
5338 (gnus-article-check-buffer)
5339 (let* ((inhibit-read-only t)
5341 (btn ;; position where the MIME button exists
5343 (if (eq handle (get-text-property b 'gnus-data))
5346 (or (text-property-any (point) (point-max) 'gnus-data handle)
5347 (text-property-any (point-min) (point) 'gnus-data handle)))
5348 (setq handle (get-text-property b 'gnus-data))
5354 (setq start (next-single-property-change btn 'gnus-data
5356 btn (previous-single-property-change start
5359 (if (and (not arg) (mm-handle-undisplayer handle))
5361 (setq b (copy-marker b)
5362 btn (copy-marker btn))
5363 (mm-remove-part handle))
5367 (if (mm-handle-undisplayer handle)
5368 (mm-remove-part handle)))
5369 ((mm-handle-undisplayer handle)
5370 (mm-remove-part handle)))
5373 ;; This is a header button.
5375 (mm-display-inline handle))
5376 ;; Toggle the button appearance between `[button]...' and `[button]'.
5378 (setq btn (prog1 (marker-position btn)
5379 (set-marker btn nil))))
5381 (let ((displayed-p (mm-handle-displayed-p handle)))
5382 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5384 (if (featurep 'emacs)
5387 (next-single-property-change (point) 'gnus-data nil (point-max)))
5388 (let* ((end (next-single-property-change (point) 'gnus-data))
5389 (annots (annotations-at (or end (point-max)))))
5390 (delete-region (point)
5392 (if annots (1+ end) end)
5394 (dolist (annot annots)
5395 (set-extent-endpoints annot (point) (point)))))
5396 (setq start (point))
5397 (if (search-backward "\n\n" nil t)
5400 (unless (or displayed-p (eolp))
5401 ;; Add extra newline.
5402 (insert (propertize (buffer-substring (1- start) start)
5403 'gnus-undeletable t))))
5404 ;; We're in the article header.
5406 (dolist (ovl (gnus-overlays-in btn (point)))
5407 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5408 (gnus-overlay-put ovl 'face nil))
5410 (message-narrow-to-field)
5411 (let ((gnus-treatment-function-alist
5412 '((gnus-treat-highlight-headers
5413 gnus-article-highlight-headers))))
5414 (gnus-treat-article 'head)))))
5416 (setq b (prog1 (marker-position b)
5417 (set-marker b nil))))
5420 (defun gnus-mime-set-charset-parameters (handle charset)
5421 "Set CHARSET to parameters in HANDLE.
5422 CHARSET may either be a string or a symbol."
5423 (unless (stringp charset)
5424 (setq charset (symbol-name charset)))
5425 (if (stringp (car handle))
5426 (dolist (h (cdr handle))
5427 (gnus-mime-set-charset-parameters h charset))
5428 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5429 "message/external-body")
5431 (unless (mm-handle-cache handle)
5432 (mm-extern-cache-contents handle))
5433 (mm-handle-cache handle))
5435 (param (assq 'charset (cdr type))))
5437 (setcdr param charset)
5438 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5440 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5441 "Insert the MIME part under point into the current buffer using the
5443 (interactive (list nil current-prefix-arg))
5444 (gnus-article-check-buffer)
5445 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5446 (fun (get-text-property (point) 'gnus-callback))
5447 (gnus-newsgroup-ignored-charsets 'gnus-all)
5448 charset form preferred parts)
5455 gnus-summary-show-article-charset-alist))
5456 (mm-read-coding-system "Charset: "))))
5457 (if (mm-handle-undisplayer handle)
5458 (mm-remove-part handle)))
5459 (gnus-mime-set-charset-parameters handle charset)
5460 (when (and (consp (setq form (cdr-safe fun)))
5461 (setq form (ignore-errors
5462 (assq 'gnus-mime-display-alternative form)))
5463 (setq preferred (caddr form))
5465 (when (eq (car preferred) 'quote)
5466 (setq preferred (cadr preferred)))
5467 (not (equal preferred
5468 (get-text-property (point) 'gnus-data))))
5469 (setq parts (get-text-property (point) 'gnus-part))
5470 (setq parts (cdr (assq parts
5471 gnus-article-mime-handle-alist)))
5472 (equal (mm-handle-media-type parts) "multipart/alternative")
5473 (setq parts (reverse (cdr parts))))
5475 (list 'quote (or (cadr (member preferred parts))
5477 (funcall fun handle)))))
5479 (defun gnus-mime-view-part-externally (&optional handle)
5480 "View the MIME part under point with an external viewer."
5482 (gnus-article-check-buffer)
5483 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5484 (mm-inlined-types nil)
5485 (mail-parse-charset gnus-newsgroup-charset)
5486 (mail-parse-ignored-charsets
5487 (with-current-buffer gnus-summary-buffer
5488 gnus-newsgroup-ignored-charsets))
5489 (type (mm-handle-media-type handle))
5490 (method (mailcap-mime-info type))
5491 (mm-enable-external t))
5492 (if (not (stringp method))
5493 (gnus-mime-view-part-as-type
5494 nil (lambda (type) (stringp (mailcap-mime-info type))))
5496 (mm-display-part handle nil t)))))
5498 (defun gnus-mime-view-part-internally (&optional handle)
5499 "View the MIME part under point with an internal viewer.
5500 If no internal viewer is available, use an external viewer."
5502 (gnus-article-check-buffer)
5503 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5504 (mm-inlined-types '(".*"))
5505 (mm-inline-large-images t)
5506 (mail-parse-charset gnus-newsgroup-charset)
5507 (mail-parse-ignored-charsets
5508 (with-current-buffer gnus-summary-buffer
5509 gnus-newsgroup-ignored-charsets))
5510 (inhibit-read-only t))
5511 (if (not (mm-inlinable-p handle))
5512 (gnus-mime-view-part-as-type
5513 nil (lambda (type) (mm-inlinable-p handle type)))
5515 (gnus-bind-safe-url-regexp
5516 (mm-display-part handle nil t))))))
5518 (defun gnus-mime-action-on-part (&optional action)
5519 "Do something with the MIME attachment at \(point\)."
5521 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5522 (gnus-article-check-buffer)
5523 (let ((action-pair (assoc action gnus-mime-action-alist)))
5525 (funcall (cdr action-pair)))))
5527 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5528 "Call FUNCTION on MIME part N.
5529 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5530 If INTERACTIVE, call FUNCTION interactively."
5532 ;; Check whether the article is displayed.
5533 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5534 (setq window (get-buffer-window gnus-article-buffer t))
5535 (frame-visible-p (setq frame (window-frame window))))
5536 (error "No article is displayed"))
5537 (with-current-buffer gnus-article-buffer
5538 ;; Check whether the article displays the right contents.
5539 (unless (with-current-buffer gnus-summary-buffer
5540 (eq gnus-current-article (gnus-summary-article-number)))
5541 (error "You should select the right article first"))
5543 (setq n (prefix-numeric-value n))
5545 (setq n (or (get-text-property pt 'gnus-part)
5547 (get-text-property (1- pt) 'gnus-part))
5548 (get-text-property (prog2
5554 (or (and (setq pt (previous-single-property-change
5557 (next-single-property-change (point) 'gnus-part)
5561 ;; Check whether the specified part exists.
5562 (when (> n (length gnus-article-mime-handle-alist))
5563 (error "No such part")))
5566 ;; To select the window is needed so that the cursor
5567 ;; might be visible on the MIME button.
5568 (select-window (prog1
5570 (setq window (selected-window))
5571 ;; Article may be displayed in the other frame.
5572 (gnus-select-frame-set-input-focus
5575 (setq frame (selected-frame))))))
5576 (when (gnus-article-goto-part n)
5577 ;; We point the cursor and the arrow at the MIME button
5578 ;; when the `function' prompt the user for something.
5579 (unless (and (pos-visible-in-window-p)
5580 (> (count-lines (point) (window-end))
5581 (/ (1- (window-height)) 3)))
5582 (recenter (/ (1- (window-height)) 3)))
5583 (let ((cursor-in-non-selected-windows t)
5584 (overlay-arrow-string "=>")
5585 (overlay-arrow-position (point-marker)))
5588 ((and no-handle interactive)
5589 (call-interactively function))
5594 function (get-text-property (point) 'gnus-data)))
5597 (get-text-property (point) 'gnus-data))))
5598 (set-marker overlay-arrow-position nil)
5599 (unless gnus-auto-select-part
5600 (gnus-select-frame-set-input-focus frame)
5601 (select-window window))))
5603 (if gnus-inhibit-mime-unbuttonizing
5604 ;; This is the default though the program shouldn't reach here.
5605 (error "No such part")
5606 ;; The part which doesn't have the MIME button is selected.
5607 ;; So, we display all the buttons and redo it.
5608 (let ((gnus-inhibit-mime-unbuttonizing t))
5609 (gnus-summary-show-article)
5610 (gnus-article-part-wrapper n function no-handle))))))
5612 (defun gnus-article-pipe-part (n)
5613 "Pipe MIME part N, which is the numerical prefix."
5615 (gnus-article-part-wrapper n 'mm-pipe-part))
5617 (defun gnus-article-save-part (n)
5618 "Save MIME part N, which is the numerical prefix."
5620 (gnus-article-part-wrapper n 'mm-save-part))
5622 (defun gnus-article-interactively-view-part (n)
5623 "View MIME part N interactively, which is the numerical prefix."
5625 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5627 (defun gnus-article-copy-part (n)
5628 "Copy MIME part N, which is the numerical prefix."
5630 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5632 (defun gnus-article-view-part-as-charset (n)
5633 "View MIME part N using a specified charset.
5634 N is the numerical prefix."
5636 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5638 (defun gnus-article-view-part-externally (n)
5639 "View MIME part N externally, which is the numerical prefix."
5641 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5643 (defun gnus-article-inline-part (n)
5644 "Inline MIME part N, which is the numerical prefix."
5646 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5648 (defun gnus-article-save-part-and-strip (n)
5649 "Save MIME part N and replace it with an external body.
5650 N is the numerical prefix."
5652 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5654 (defun gnus-article-replace-part (n)
5655 "Replace MIME part N with an external body.
5656 N is the numerical prefix."
5658 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5660 (defun gnus-article-delete-part (n)
5661 "Delete MIME part N and add some information about the removed part.
5662 N is the numerical prefix."
5664 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5666 (defun gnus-article-view-part-as-type (n)
5667 "Choose a MIME media type, and view part N as such.
5668 N is the numerical prefix."
5670 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5672 (defun gnus-article-mime-match-handle-first (condition)
5675 (dolist (ihandle gnus-article-mime-handle-alist)
5677 ((functionp condition)
5678 (funcall condition (cdr ihandle)))
5679 ((eq condition 'undisplayed)
5680 (not (or (mm-handle-undisplayer (cdr ihandle))
5681 (equal (mm-handle-media-type (cdr ihandle))
5682 "multipart/alternative"))))
5683 ((eq condition 'undisplayed-alternative)
5684 (not (mm-handle-undisplayer (cdr ihandle))))
5686 (gnus-article-goto-part (car ihandle))
5687 (or (not n) (< (car ihandle) n)))
5688 (setq n (car ihandle))))
5692 (defun gnus-article-view-part (&optional n)
5693 "View MIME part N, which is the numerical prefix.
5694 If the part is already shown, hide the part. If N is nil, view
5697 (with-current-buffer gnus-article-buffer
5698 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5699 gnus-article-mime-match-handle-function)))
5700 (when (> n (length gnus-article-mime-handle-alist))
5701 (error "No such part"))
5702 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5703 (when (gnus-article-goto-part n)
5704 (if (equal (car handle) "multipart/alternative")
5706 (beginning-of-line) ;; Make it toggle subparts
5707 (gnus-article-press-button))
5708 (when (eq (gnus-mm-display-part handle) 'internal)
5709 (gnus-set-window-start)))))))
5711 (defsubst gnus-article-mime-total-parts ()
5712 (if (bufferp (car gnus-article-mime-handles))
5714 (1- (length gnus-article-mime-handles))))
5716 (defun gnus-mm-display-part (handle)
5717 "Display HANDLE and fix MIME button."
5718 (let ((id (get-text-property (point) 'gnus-part))
5720 (inhibit-read-only t)
5721 (window (selected-window))
5722 (mail-parse-charset gnus-newsgroup-charset)
5723 (mail-parse-ignored-charsets
5724 (if (gnus-buffer-live-p gnus-summary-buffer)
5725 (with-current-buffer gnus-summary-buffer
5726 gnus-newsgroup-ignored-charsets)
5731 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5735 (setq start (next-single-property-change point 'gnus-data
5737 point (previous-single-property-change start 'gnus-data))
5738 (if (mm-handle-displayed-p handle)
5739 ;; This will remove the part.
5740 (setq point (copy-marker point)
5741 retval (mm-display-part handle))
5742 (let ((part (or (and (mm-inlinable-p handle)
5743 (mm-inlined-p handle)
5746 (gnus-bind-safe-url-regexp
5747 (setq retval (mm-display-part handle)))
5748 (unless (zerop (buffer-size))
5749 (buffer-string))))))
5752 ;; This is a header button.
5754 (cond ((stringp part)
5756 (narrow-to-region (point)
5759 (unless (bolp) (insert "\n"))
5761 (gnus-treat-article nil id
5762 (gnus-article-mime-total-parts)
5763 (mm-handle-media-type handle))
5764 (mm-handle-set-undisplayer
5767 (let ((inhibit-read-only t))
5768 (delete-region ,(copy-marker (point-min) t)
5769 ,(point-max-marker)))))))
5771 (mm-display-inline handle))))))
5772 (when (markerp point)
5773 (setq point (prog1 (marker-position point)
5774 (set-marker point nil))))
5776 ;; Toggle the button appearance between `[button]...' and `[button]'.
5777 (let ((displayed-p (mm-handle-displayed-p handle)))
5778 (gnus-insert-mime-button handle id (list displayed-p))
5779 (if (featurep 'emacs)
5782 (next-single-property-change (point) 'gnus-data nil (point-max)))
5783 (let* ((end (next-single-property-change (point) 'gnus-data))
5784 (annots (annotations-at (or end (point-max)))))
5785 (delete-region (point)
5787 (if annots (1+ end) end)
5789 (dolist (annot annots)
5790 (set-extent-endpoints annot (point) (point)))))
5791 (setq start (point))
5792 (if (search-backward "\n\n" nil t)
5795 (unless (or displayed-p (eolp))
5796 ;; Add extra newline.
5797 (insert (propertize (buffer-substring (1- start) start)
5798 'gnus-undeletable t))))
5799 ;; We're in the article header.
5801 (dolist (ovl (gnus-overlays-in point (point)))
5802 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5803 (gnus-overlay-put ovl 'face nil))
5805 (message-narrow-to-field)
5806 (let ((gnus-treatment-function-alist
5807 '((gnus-treat-highlight-headers
5808 gnus-article-highlight-headers))))
5809 (gnus-treat-article 'head)))))
5811 (if (window-live-p window)
5812 (select-window window)))
5815 (defun gnus-article-goto-part (n)
5816 "Go to MIME part N."
5817 (when gnus-break-pages
5821 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5822 ;; There may be header buttons.
5823 (text-property-any (point-min) (point) 'gnus-part n)))
5824 part handle end next handles)
5827 (if (setq handle (get-text-property start 'gnus-data))
5829 ;; Go to the displayed subpart, assuming this is
5830 ;; multipart/alternative.
5833 (while (and (not handle)
5836 (setq next (text-property-not-all part end
5839 handle (get-text-property part 'gnus-data))
5840 (push (cons handle part) handles)
5841 (unless (mm-handle-displayed-p handle)
5843 part (text-property-any part end 'gnus-data nil))))
5845 ;; No subpart is displayed, so we find preferred one.
5847 (cdr (assq (mm-preferred-alternative
5848 (nreverse (mapcar 'car handles)))
5851 (goto-char (1+ part))
5853 (when gnus-break-pages
5854 (gnus-narrow-to-page))))
5856 (defun gnus-insert-mime-button (handle id &optional displayed)
5857 (let ((gnus-tmp-name
5858 (or (mm-handle-filename handle)
5859 (mail-content-type-get (mm-handle-type handle) 'url)
5862 (gnus-tmp-type (mm-handle-media-type handle))
5863 (gnus-tmp-description (or (mm-handle-description handle) ""))
5865 (if (if displayed (car displayed)
5866 (mm-handle-displayed-p handle))
5868 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5870 gnus-tmp-type-long b e)
5871 (when (string-match ".*/" gnus-tmp-name)
5872 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5873 (setq gnus-tmp-type-long (concat gnus-tmp-type
5874 (and (not (equal gnus-tmp-name ""))
5875 (concat "; " gnus-tmp-name))))
5876 (unless (equal gnus-tmp-description "")
5877 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5880 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5881 `(keymap ,gnus-mime-button-map
5882 gnus-callback gnus-mm-display-part
5883 gnus-part ,gnus-tmp-id
5884 article-type annotation
5888 ;; Exclude a newline.
5891 (when gnus-article-button-face
5892 (gnus-overlay-put (gnus-make-overlay b e nil t)
5893 'face gnus-article-button-face))
5894 (widget-convert-button
5897 :action 'gnus-widget-press-button
5898 :button-keymap gnus-mime-button-map
5901 ;; Needed to properly clear the message due to a bug in
5902 ;; wid-edit (XEmacs only).
5903 (if (boundp 'help-echo-owns-message)
5904 (setq help-echo-owns-message t))
5906 "%S: %s the MIME part; %S: more options"
5907 (aref gnus-mouse-2 0)
5908 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5910 (aref gnus-down-mouse-3 0))))))
5912 (defun gnus-widget-press-button (elems _el)
5913 (goto-char (widget-get elems :from))
5914 (gnus-article-press-button))
5916 (defvar gnus-displaying-mime nil)
5918 (defun gnus-display-mime (&optional ihandles)
5919 "Display the MIME parts."
5921 (save-selected-window
5922 (let ((window (get-buffer-window gnus-article-buffer))
5925 (select-window window)
5926 ;; We have to do this since selecting the window
5927 ;; may change the point. So we set the window point.
5928 (set-window-point window point)))
5929 (let ((handles ihandles)
5930 (inhibit-read-only t))
5932 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5933 (when gnus-article-emulate-mime
5934 (mm-uu-dissect-text-parts handles)))
5935 (gnus-article-emulate-mime
5936 (setq handles (mm-uu-dissect))))
5937 (when (and (not ihandles)
5938 (not gnus-displaying-mime))
5939 ;; Top-level call; we clean up.
5940 (when gnus-article-mime-handles
5941 (mm-destroy-parts gnus-article-mime-handles)
5942 (setq gnus-article-mime-handle-alist nil));; A trick.
5943 (setq gnus-article-mime-handles handles)
5944 ;; We allow users to glean info from the handles.
5945 (when gnus-article-mime-part-function
5946 (gnus-mime-part-function handles)))
5948 (or (not (stringp (car handles)))
5951 (when (and (not ihandles)
5952 (not gnus-displaying-mime))
5953 ;; Clean up for mime parts.
5955 (delete-region (point) (point-max)))
5956 (let ((gnus-displaying-mime t))
5957 (gnus-mime-display-part handles)))
5960 (narrow-to-region (point) (point-max))
5961 (gnus-treat-article nil 1 1 "text/plain")
5964 ;; Highlight the headers.
5968 (narrow-to-region (point-min) (point))
5969 (gnus-article-save-original-date
5970 (gnus-treat-article 'head)))))))
5971 ;; Cope with broken MIME messages.
5972 (goto-char (point-max))
5976 (defcustom gnus-mime-display-multipart-as-mixed nil
5977 "Display \"multipart\" parts as \"multipart/mixed\".
5979 If t, it overrides nil values of
5980 `gnus-mime-display-multipart-alternative-as-mixed' and
5981 `gnus-mime-display-multipart-related-as-mixed'."
5982 :group 'gnus-article-mime
5985 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5986 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5988 :group 'gnus-article-mime
5991 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5992 "Display \"multipart/related\" parts as \"multipart/mixed\".
5994 If displaying \"text/html\" is discouraged \(see
5995 `mm-discouraged-alternatives'\) images or other material inside a
5996 \"multipart/related\" part might be overlooked when this variable is nil."
5998 :group 'gnus-article-mime
6001 (defcustom gnus-mime-display-attachment-buttons-in-header t
6002 "Add attachment buttons in the end of the header of an article.
6003 Since MIME attachments tend to be put at the end of an article, we may
6004 overlook them if there is a huge body. This option offers you a copy
6005 of all non-inlinable MIME parts as buttons shown in front of an article.
6006 If nil, don't show those extra buttons."
6008 :group 'gnus-article-mime
6011 (defun gnus-mime-display-part (handle)
6013 ;; Maybe a broken MIME message.
6016 ((not (stringp (car handle)))
6017 (gnus-mime-display-single handle))
6018 ;; User-defined multipart
6019 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
6020 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
6022 ;; multipart/alternative
6023 ((and (equal (car handle) "multipart/alternative")
6024 (not (or gnus-mime-display-multipart-as-mixed
6025 gnus-mime-display-multipart-alternative-as-mixed)))
6026 (let ((id (1+ (length gnus-article-mime-handle-alist))))
6027 (push (cons id handle) gnus-article-mime-handle-alist)
6028 (gnus-mime-display-alternative (cdr handle) nil nil id)))
6029 ;; multipart/related
6030 ((and (equal (car handle) "multipart/related")
6031 (not (or gnus-mime-display-multipart-as-mixed
6032 gnus-mime-display-multipart-related-as-mixed)))
6033 (gnus-mime-display-part (cadr handle)))
6034 ((equal (car handle) "multipart/signed")
6035 (gnus-add-wash-type 'signed)
6036 (gnus-mime-display-security handle))
6037 ((equal (car handle) "multipart/encrypted")
6038 (gnus-add-wash-type 'encrypted)
6039 (gnus-mime-display-security handle))
6040 ;; Other multiparts are handled like multipart/mixed.
6042 (gnus-mime-display-mixed (cdr handle)))))
6044 (defun gnus-mime-part-function (handles)
6045 (if (stringp (car handles))
6046 (mapcar 'gnus-mime-part-function (cdr handles))
6047 (funcall gnus-article-mime-part-function handles)))
6049 (defun gnus-mime-display-mixed (handles)
6050 (mapcar 'gnus-mime-display-part handles))
6052 (defun gnus-mime-display-single (handle)
6053 (let ((type (mm-handle-media-type handle))
6054 (ignored gnus-ignored-mime-types)
6060 (when (string-match (pop ignored) type)
6061 (throw 'ignored nil)))
6062 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6063 (with-current-buffer gnus-summary-buffer
6064 gnus-inhibit-images)
6065 gnus-inhibit-images)
6066 (string-match "\\`image/" type)))
6067 (setq not-attachment
6068 (and (not (mm-inline-override-p handle))
6069 (or (not (mm-handle-disposition handle))
6070 (equal (car (mm-handle-disposition handle))
6072 (mm-attachment-override-p handle))))
6073 (mm-automatic-display-p handle)
6075 (mm-inlinable-p handle)
6076 (mm-inlined-p handle))
6077 (mm-automatic-external-display-p type)))
6079 (when (equal (mm-handle-media-supertype handle) "text")
6081 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6084 (setq id (1+ (length gnus-article-mime-handle-alist)))
6085 (push (cons id handle) gnus-article-mime-handle-alist))
6087 (equal (mm-handle-media-supertype handle) "message"))
6090 (cond ((not (bolp)) 2)
6091 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6093 (when (or (not display)
6094 (not (gnus-unbuttonized-mime-type-p type))
6095 (eq id gnus-mime-buttonized-part-id))
6096 (gnus-insert-mime-button
6097 handle id (list (or display (and not-attachment text)))))
6101 (let ((mail-parse-charset gnus-newsgroup-charset)
6102 (mail-parse-ignored-charsets
6103 (save-excursion (condition-case ()
6104 (set-buffer gnus-summary-buffer)
6106 gnus-newsgroup-ignored-charsets)))
6107 (gnus-bind-safe-url-regexp (mm-display-part handle t))))
6108 ((and text not-attachment)
6109 (mm-display-inline handle)))
6110 (goto-char (point-max))
6111 (if (string-match "\\`image/" type)
6112 (gnus-article-insert-newline)
6114 (= (skip-chars-backward "\n") -1)
6115 (unless (eobp) (forward-char 1)))
6116 (gnus-article-insert-newline)
6117 (put-text-property (point) (point-max) 'gnus-undeletable t))
6118 (goto-char (point-max)))
6122 (narrow-to-region beg (point))
6123 (if (eq handle gnus-article-mime-handles)
6124 ;; The format=flowed case.
6125 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6126 ;; Don't count signature parts that are never displayed.
6127 ;; The part number should be re-calculated supposing this
6128 ;; might be a message/rfc822 part.
6130 (dolist (part gnus-article-mime-handles)
6131 (unless (or (stringp part)
6132 (equal (car (mm-handle-type part))
6133 "application/pgp-signature"))
6134 (push part handles)))
6136 nil (length (memq handle handles)) (length handles)
6137 (mm-handle-media-type handle)))))))))))
6139 (defun gnus-unbuttonized-mime-type-p (type)
6140 "Say whether TYPE is to be unbuttonized."
6141 (unless gnus-inhibit-mime-unbuttonizing
6143 (let ((types gnus-unbuttonized-mime-types))
6145 (when (string-match (pop types) type)
6146 (throw 'found t)))))
6148 (let ((types gnus-buttonized-mime-types))
6150 (when (string-match (pop types) type)
6151 (throw 'found t)))))))))
6153 (defun gnus-article-insert-newline ()
6154 "Insert a newline, but mark it as undeletable."
6155 (gnus-put-text-property
6156 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6158 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6159 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6162 handle (inhibit-read-only t) from begend not-pref)
6163 (save-window-excursion
6166 (narrow-to-region (car ibegend)
6169 (goto-char (car ibegend))
6172 (delete-region (point-min) (point-max))
6173 (mm-remove-parts handles))
6174 (setq begend (list (point-marker)))
6176 (unless (setq not-pref (cadr (member preferred ihandles)))
6177 (setq not-pref (car ihandles)))
6180 (not (gnus-unbuttonized-mime-type-p
6181 "multipart/alternative")))
6182 (gnus-add-text-properties
6185 (insert (format "%d. " id))
6189 (unless ,(not ibegend)
6190 (setq gnus-article-mime-handle-alist
6191 ',gnus-article-mime-handle-alist))
6192 (gnus-mime-display-alternative
6193 ',ihandles ',not-pref ',begend ,id))
6194 keymap ,gnus-mime-button-map
6195 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6196 face ,gnus-article-button-face
6198 article-type multipart
6200 (widget-convert-button 'link from (point)
6201 :action 'gnus-widget-press-button
6202 :button-keymap gnus-widget-button-keymap)
6204 (while (setq handle (pop handles))
6205 (gnus-add-text-properties
6208 (insert (format "(%c) %-18s"
6209 (if (equal handle preferred) ?* ? )
6210 (mm-handle-media-type handle)))
6214 (unless ,(not ibegend)
6215 (setq gnus-article-mime-handle-alist
6216 ',gnus-article-mime-handle-alist))
6217 (gnus-mime-display-alternative
6218 ',ihandles ',handle ',begend ,id))
6219 keymap ,gnus-mime-button-map
6220 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6221 face ,gnus-article-button-face
6225 (widget-convert-button 'link from (point)
6226 :action 'gnus-widget-press-button
6227 :button-keymap gnus-widget-button-keymap)
6231 (if (stringp (car preferred))
6232 (gnus-display-mime preferred)
6233 (let ((mail-parse-charset gnus-newsgroup-charset)
6234 (mail-parse-ignored-charsets
6235 (with-current-buffer gnus-summary-buffer
6236 gnus-newsgroup-ignored-charsets)))
6237 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6241 (narrow-to-region (car begend) (point-max))
6243 nil (length gnus-article-mime-handle-alist)
6244 (gnus-article-mime-total-parts)
6245 (mm-handle-media-type preferred))))))
6246 (goto-char (point-max))
6247 (setcdr begend (point-marker)))))
6250 ;; Redraw attachment buttons in the header.
6251 (when gnus-mime-display-attachment-buttons-in-header
6252 (gnus-mime-buttonize-attachments-in-header)))
6254 (defconst gnus-article-wash-status-strings
6255 (let ((alist '((cite "c" "Possible hidden citation text"
6256 " " "All citation text visible")
6257 (headers "h" "Hidden headers"
6258 " " "All headers visible.")
6259 (pgp "p" "Encrypted or signed message status hidden"
6260 " " "No hidden encryption nor digital signature status")
6261 (signature "s" "Signature has been hidden"
6262 " " "Signature is visible")
6263 (overstrike "o" "Overstrike (^H) characters applied"
6264 " " "No overstrike characters applied")
6265 (emphasis "e" "/*_Emphasis_*/ characters applied"
6266 " " "No /*_emphasis_*/ characters applied")))
6268 (dolist (entry alist result)
6269 (let ((key (nth 0 entry))
6270 (on (copy-sequence (nth 1 entry)))
6271 (on-help (nth 2 entry))
6272 (off (copy-sequence (nth 3 entry)))
6273 (off-help (nth 4 entry)))
6274 (put-text-property 0 1 'help-echo on-help on)
6275 (put-text-property 0 1 'help-echo off-help off)
6276 (push (list key on off) result))))
6277 "Alist of strings describing wash status in the mode line.
6278 Each entry has the form (KEY ON OF), where the KEY is a symbol
6279 representing the particular washing function, ON is the string to use
6280 in the article mode line when the washing function is active, and OFF
6281 is the string to use when it is inactive.")
6283 (defun gnus-article-wash-status-entry (key value)
6284 (let ((entry (assoc key gnus-article-wash-status-strings)))
6285 (if value (nth 1 entry) (nth 2 entry))))
6287 (defun gnus-article-wash-status ()
6288 "Return a string which display status of article washing."
6289 (with-current-buffer gnus-article-buffer
6290 (let ((cite (memq 'cite gnus-article-wash-types))
6291 (headers (memq 'headers gnus-article-wash-types))
6292 (boring (memq 'boring-headers gnus-article-wash-types))
6293 (pgp (memq 'pgp gnus-article-wash-types))
6294 (pem (memq 'pem gnus-article-wash-types))
6295 (signed (memq 'signed gnus-article-wash-types))
6296 (encrypted (memq 'encrypted gnus-article-wash-types))
6297 (signature (memq 'signature gnus-article-wash-types))
6298 (overstrike (memq 'overstrike gnus-article-wash-types))
6299 (emphasis (memq 'emphasis gnus-article-wash-types)))
6301 (gnus-article-wash-status-entry 'cite cite)
6302 (gnus-article-wash-status-entry 'headers (or headers boring))
6303 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6304 (gnus-article-wash-status-entry 'signature signature)
6305 (gnus-article-wash-status-entry 'overstrike overstrike)
6306 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6308 (defun gnus-add-wash-type (type)
6309 "Add a washing of TYPE to the current status."
6310 (add-to-list 'gnus-article-wash-types type))
6312 (defun gnus-delete-wash-type (type)
6313 "Add a washing of TYPE to the current status."
6314 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6316 (defun gnus-add-image (category image)
6317 "Add IMAGE of CATEGORY to the list of displayed images."
6318 (let ((entry (assq category gnus-article-image-alist)))
6320 (setq entry (list category))
6321 (push entry gnus-article-image-alist))
6322 (nconc entry (list image))))
6324 (defun gnus-delete-images (category)
6325 "Delete all images in CATEGORY."
6326 (let ((entry (assq category gnus-article-image-alist)))
6327 (dolist (image (cdr entry))
6328 (gnus-remove-image image category))
6329 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6330 (gnus-delete-wash-type category)))
6332 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6334 (defun gnus-article-maybe-hide-headers ()
6335 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6336 Provided for backwards compatibility."
6337 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6338 (not (with-current-buffer gnus-summary-buffer
6339 gnus-have-all-headers)))
6340 (not gnus-inhibit-hiding))
6341 (gnus-article-hide-headers)))
6343 (declare-function shr-put-image "shr" (data alt &optional flags))
6345 (defun gnus-shr-put-image (data alt &optional flags)
6346 "Put image DATA with a string ALT. Enable image to be deleted."
6347 (let ((image (if flags
6348 (shr-put-image data (propertize (or alt "*")
6349 'gnus-image-category 'shr)
6351 ;; Old `shr-put-image' doesn't take the optional `flags'
6353 (shr-put-image data (propertize (or alt "*")
6354 'gnus-image-category 'shr)))))
6356 (gnus-add-image 'shr image))))
6358 (defun gnus-article-mime-handles (&optional alist id all)
6360 (let ((i 1) newid flat)
6361 (dolist (handle alist flat)
6362 (setq newid (append id (list i))
6364 (if (stringp (car handle))
6365 (setq flat (nconc flat (gnus-article-mime-handles
6366 (cdr handle) newid all)))
6367 (delq (rassq handle all) all)
6368 (setq flat (nconc flat (list (cons newid handle)))))))
6369 (let ((flat (list nil)))
6370 ;; Assume that elements of `gnus-article-mime-handle-alist'
6371 ;; are in the decreasing order, but unnumbered subsidiaries
6372 ;; in each element are in the increasing order.
6373 (dolist (handle (reverse gnus-article-mime-handle-alist))
6374 (if (stringp (cadr handle))
6375 (setq flat (nconc flat (gnus-article-mime-handles
6376 (cddr handle) (list (car handle)) flat)))
6377 (delq (rassq (cdr handle) flat) flat)
6378 (setq flat (nconc flat (list (cons (list (car handle))
6380 (setq flat (cdr flat))
6381 (mapc (lambda (handle)
6383 ;; This is a hidden (i.e. unnumbered) handle.
6386 (1+ (caar gnus-article-mime-handle-alist)))
6387 (push handle gnus-article-mime-handle-alist))
6388 (setcar handle (caar handle))))
6392 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6393 "Show attachments as buttons in the end of the header of an article.
6394 This function toggles the display when called interactively. Note that
6395 buttons to be added to the header are only the ones that aren't inlined
6396 in the body. Use `gnus-header-face-alist' to highlight buttons."
6397 (interactive (list t))
6398 (gnus-with-article-buffer
6399 (let ((case-fold-search t) buttons handle type st)
6403 (article-narrow-to-head)
6404 ;; Header buttons exist?
6405 (while (and (not buttons)
6406 (re-search-forward "^attachments?:[\n ]+" nil t))
6407 (when (get-char-property (match-end 0)
6408 'gnus-button-attachment-extra)
6409 (setq buttons (match-beginning 0))))
6412 ;; Delete header buttons.
6413 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6416 (unless (and interactive buttons)
6419 (dolist (button (gnus-article-mime-handles))
6420 (setq handle (cdr button)
6421 type (mm-handle-media-type handle))
6422 (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
6423 (with-current-buffer gnus-summary-buffer
6424 gnus-inhibit-images)
6425 gnus-inhibit-images)
6426 (string-match "\\`image/" type))
6427 (mm-inline-override-p handle)
6428 (and (mm-handle-disposition handle)
6429 (not (equal (car (mm-handle-disposition handle))
6431 (not (mm-attachment-override-p handle)))
6432 (not (mm-automatic-display-p handle))
6433 (not (or (and (mm-inlinable-p handle)
6434 (mm-inlined-p handle))
6435 (mm-automatic-external-display-p type))))
6436 (push button buttons)))
6438 ;; Add header buttons.
6441 (narrow-to-region (point) (point))
6442 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6443 (dolist (button (nreverse buttons))
6446 (mm-handle-set-undisplayer (setq handle (cdr button)) nil)
6447 (gnus-insert-mime-button handle (car button))
6448 (skip-chars-backward "\t\n ")
6449 (delete-region (point) (point-max))
6450 (when (> (current-column) (window-width))
6455 (dolist (ovl (gnus-overlays-in (point-min) (point)))
6456 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
6457 (gnus-overlay-put ovl 'face nil))
6458 (let ((gnus-treatment-function-alist
6459 '((gnus-treat-highlight-headers
6460 gnus-article-highlight-headers))))
6461 (gnus-treat-article 'head)))))))))
6465 (defun gnus-output-to-file (file-name)
6466 "Append the current article to a file named FILE-NAME.
6467 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6468 text and used as the value of the coding cookie which is added to the
6469 top of a file. Otherwise, this function saves a raw article without
6471 (let* ((artbuf (current-buffer))
6472 (file-name-coding-system nnmail-pathname-coding-system)
6473 (coding gnus-article-save-coding-system)
6474 (coding-system-for-read (if coding
6475 nil ;; Rely on the coding cookie.
6476 mm-text-coding-system))
6477 (coding-system-for-write (or coding
6478 mm-text-coding-system-for-write
6479 mm-text-coding-system))
6480 (exists (file-exists-p file-name)))
6483 (insert-file-contents file-name)
6484 (goto-char (point-min))
6485 ;; Remove the existing coding cookie.
6486 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6487 (delete-region (match-beginning 0) (match-end 0))))
6488 (goto-char (point-max))
6489 (insert-buffer-substring artbuf)
6490 ;; Append newline at end of the buffer as separator, and then
6492 (goto-char (point-max))
6495 ;; If the coding system is not suitable to encode the text,
6496 ;; ask a user for a proper one.
6497 (when (fboundp 'select-safe-coding-system)
6498 (setq coding (coding-system-base
6499 (save-window-excursion
6500 (select-safe-coding-system (point-min) (point-max)
6502 (setq coding-system-for-write
6503 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6505 (goto-char (point-min))
6506 ;; Add the coding cookie.
6507 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6508 coding-system-for-write)))
6511 (write-region (point-min) (point-max) file-name nil 'no-message)
6512 (message "Appended to %s" file-name))
6513 (write-region (point-min) (point-max) file-name))))
6516 (defun gnus-narrow-to-page (&optional arg)
6517 "Narrow the article buffer to a page.
6518 If given a numerical ARG, move forward ARG pages."
6520 (setq arg (if arg (prefix-numeric-value arg) 0))
6521 (with-current-buffer gnus-article-buffer
6523 ;; Remove any old next/prev buttons.
6524 (when (gnus-visual-p 'page-marker)
6525 (let ((inhibit-read-only t))
6526 (gnus-remove-text-with-property 'gnus-prev)
6527 (gnus-remove-text-with-property 'gnus-next)))
6529 (when (save-excursion
6531 (if (re-search-backward page-delimiter nil 'move (abs arg))
6533 (setq nd (match-beginning 0)
6535 (when (re-search-backward page-delimiter nil t)
6536 (setq st (match-end 0))))
6537 (when (re-search-forward page-delimiter nil t)
6538 (setq nd (match-beginning 0)
6541 (if (re-search-forward page-delimiter nil 'move arg)
6543 (setq st (match-end 0)
6545 (when (re-search-forward page-delimiter nil t)
6546 (setq nd (match-beginning 0))))
6547 (when (re-search-backward page-delimiter nil t)
6548 (setq st (match-end 0)
6551 (when (re-search-backward page-delimiter nil t)
6552 (goto-char (setq st (match-end 0))))
6553 (when (re-search-forward page-delimiter nil t)
6554 (setq nd (match-beginning 0)))
6556 (setq gnus-page-broken t)
6557 (when pt (goto-char pt))
6558 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6559 (when (gnus-visual-p 'page-marker)
6563 (gnus-insert-next-page-button))
6566 (gnus-insert-prev-page-button))))))))
6568 ;; Article mode commands
6570 (defun gnus-article-goto-next-page ()
6571 "Show the next page of the article."
6573 (when (gnus-article-next-page)
6574 (goto-char (point-min))
6575 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6578 (defun gnus-article-goto-prev-page ()
6579 "Show the previous page of the article."
6581 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6582 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6583 (gnus-article-prev-page nil)))
6585 ;; This is cleaner but currently breaks `gnus-pick-mode':
6587 ;; (defun gnus-article-goto-next-page ()
6588 ;; "Show the next page of the article."
6590 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6591 ;; (gnus-summary-next-page)))
6593 ;; (defun gnus-article-goto-prev-page ()
6594 ;; "Show the next page of the article."
6596 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6597 ;; (gnus-summary-prev-page)))
6599 (defun gnus-article-next-page (&optional lines)
6600 "Show the next page of the current article.
6601 If end of article, return non-nil. Otherwise return nil.
6602 Argument LINES specifies lines to be scrolled up."
6604 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6605 (if (and (not (and gnus-article-over-scroll
6606 (> (count-lines (window-start) (point-max))
6607 (if (featurep 'xemacs)
6608 (or lines (1- (window-height)))
6609 (+ (or lines (1- (window-height))) scroll-margin)))))
6612 (and (pos-visible-in-window-p) ;Not continuation line.
6613 (>= (point) (point-max)))))
6614 ;; Nothing in this page.
6615 (if (or (not gnus-page-broken)
6620 (eobp)))) ;Real end-of-buffer?
6622 (when gnus-article-over-scroll
6623 (gnus-article-next-page-1 lines))
6625 (gnus-narrow-to-page 1) ;Go to next page.
6627 ;; More in this page.
6628 (gnus-article-next-page-1 lines)
6631 (defun gnus-article-beginning-of-window ()
6632 "Move point to the beginning of the window.
6633 In Emacs, the point is placed at the line number which `scroll-margin'
6635 (if (featurep 'xemacs)
6636 (move-to-window-line 0)
6637 ;; There is an obscure bug in Emacs that makes it impossible to
6638 ;; scroll past big pictures in the article buffer. Try to fix
6639 ;; this by adding a sanity check by counting the lines visible.
6640 (when (> (count-lines (window-start) (window-end)) 30)
6641 (move-to-window-line
6642 (min (max 0 scroll-margin)
6643 (max 1 (- (window-height)
6644 (if mode-line-format 1 0)
6645 (if header-line-format 1 0)
6648 (defvar scroll-in-place)
6650 (defun gnus-article-next-page-1 (lines)
6652 (let ((scroll-in-place nil)
6653 (auto-window-vscroll nil))
6656 ;; Long lines may cause an end-of-buffer error.
6657 (goto-char (point-max))))
6658 (gnus-article-beginning-of-window))
6660 (defun gnus-article-prev-page (&optional lines)
6661 "Show previous page of current article.
6662 Argument LINES specifies lines to be scrolled down."
6664 (move-to-window-line 0)
6665 (if (and gnus-page-broken
6667 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6669 (gnus-narrow-to-page -1) ;Go to previous page.
6670 (goto-char (point-max))
6671 (recenter (if gnus-article-over-scroll
6673 (max (if (featurep 'xemacs)
6675 (+ lines scroll-margin))
6677 (- (window-height) 2))
6681 (let ((scroll-in-place nil))
6682 (scroll-down lines))
6683 (beginning-of-buffer
6684 (goto-char (point-min))))
6685 (gnus-article-beginning-of-window))))
6687 (defun gnus-article-only-boring-p ()
6688 "Decide whether there is only boring text remaining in the article.
6689 Something \"interesting\" is a word of at least two letters that does
6690 not have a face in `gnus-article-boring-faces'."
6691 (when (and gnus-article-skip-boring
6692 (boundp 'gnus-article-boring-faces)
6693 (symbol-value 'gnus-article-boring-faces))
6695 (let ((inhibit-point-motion-hooks t))
6697 (while (re-search-forward "\\b\\w\\w" nil t)
6699 (when (not (gnus-intersection
6700 (gnus-faces-at (point))
6701 (symbol-value 'gnus-article-boring-faces)))
6702 (throw 'only-boring nil)))
6703 (throw 'only-boring t))))))
6705 (defun gnus-article-refer-article ()
6706 "Read article specified by message-id around point."
6709 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6710 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6711 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6712 (let ((msg-id (concat "<" (match-string 0) ">")))
6713 (set-buffer gnus-summary-buffer)
6714 (gnus-summary-refer-article msg-id))
6715 (error "No references around point"))))
6717 (defun gnus-article-show-summary ()
6718 "Reconfigure windows to show summary buffer."
6720 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6721 (error "There is no summary buffer for this article buffer")
6722 (gnus-article-set-globals)
6723 (gnus-configure-windows 'article)
6724 (gnus-summary-goto-subject gnus-current-article)
6725 (gnus-summary-position-point)))
6727 (defun gnus-article-describe-briefly ()
6728 "Describe article mode commands briefly."
6730 (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")))
6732 (defun gnus-article-check-buffer ()
6733 "Beep if not in an article buffer."
6734 (unless (derived-mode-p 'gnus-article-mode)
6735 (error "Command invoked outside of a Gnus article buffer")))
6737 (defvar gnus-pick-mode)
6739 (defun gnus-article-read-summary-keys (&optional _arg key not-restore-window)
6740 "Read a summary buffer key sequence and execute it from the article buffer."
6742 (gnus-article-check-buffer)
6744 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6745 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6746 "=" "^" "\M-^" "|"))
6748 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6749 "An" "Ap" [?A (meta return)] [?A delete]))
6753 (with-current-buffer gnus-article-current-summary
6754 (let (gnus-pick-mode)
6755 (setq unread-command-events (nconc unread-command-events
6756 (list (or key last-command-event)))
6757 keys (if (featurep 'xemacs)
6758 (events-to-keys (read-key-sequence nil t))
6759 (read-key-sequence nil t)))))
6764 ((eq (aref keys (1- (length keys))) ?\C-h)
6765 (gnus-article-describe-bindings (substring keys 0 -1)))
6766 ((or (member keys nosaves)
6767 (member keys nosave-but-article)
6768 (member keys nosave-in-article))
6770 (save-window-excursion
6771 (pop-to-buffer gnus-article-current-summary)
6772 ;; We disable the pick minor mode commands.
6773 (let (gnus-pick-mode)
6774 (setq func (key-binding keys t))))
6778 (unless (member keys nosave-in-article)
6779 (set-buffer gnus-article-current-summary))
6780 (when (and (symbolp func)
6781 (get func 'disabled))
6782 (error "Function %s disabled" func))
6783 (call-interactively func)
6784 (setq new-sum-point (point)))
6785 (when (member keys nosave-but-article)
6786 (pop-to-buffer gnus-article-buffer))))
6788 ;; These commands should restore window configuration.
6789 (let ((obuf (current-buffer))
6790 (owin (current-window-configuration))
6791 win func in-buffer selected new-sum-start new-sum-hscroll err)
6792 (cond (not-restore-window
6793 (pop-to-buffer gnus-article-current-summary)
6794 (setq win (selected-window)))
6795 ((setq win (get-buffer-window gnus-article-current-summary))
6796 (select-window win))
6798 (let ((summary-buffer gnus-article-current-summary))
6799 (gnus-configure-windows 'article)
6800 (unless (setq win (get-buffer-window summary-buffer 'visible))
6801 (let ((gnus-buffer-configuration
6802 '((article ((vertical 1.0
6803 (summary 0.25 point)
6805 (gnus-configure-windows 'article))
6806 (setq win (get-buffer-window summary-buffer 'visible)))
6807 (gnus-select-frame-set-input-focus (window-frame win))
6808 (select-window win))))
6809 (setq in-buffer (current-buffer))
6810 ;; We disable the pick minor mode commands.
6811 (setq func (let (gnus-pick-mode)
6812 (key-binding keys t)))
6813 (when (get func 'disabled)
6814 (error "Function %s disabled" func))
6817 (condition-case code
6819 (call-interactively func)
6825 (when (eq win (selected-window))
6826 (setq new-sum-point (point)
6827 new-sum-start (window-start win)
6828 new-sum-hscroll (window-hscroll win)))
6829 (when (or (eq in-buffer (current-buffer))
6830 (when (eq obuf (current-buffer))
6831 (set-buffer in-buffer)
6833 (setq selected (ignore-errors (gnus-summary-select-article)))
6835 (unless not-restore-window
6836 (set-window-configuration owin))
6837 (when (and (eq selected 'old)
6839 (set-window-start (get-buffer-window (current-buffer))
6841 (set-window-point (get-buffer-window (current-buffer))
6842 (if (article-goto-body)
6845 (when (and (not not-restore-window)
6848 (with-current-buffer (window-buffer win)
6849 (derived-mode-p 'gnus-summary-mode)))
6850 (set-window-point win new-sum-point)
6851 (set-window-start win new-sum-start)
6852 (set-window-hscroll win new-sum-hscroll))))
6853 (set-window-configuration owin)
6855 (signal (car err) (cdr err))
6858 (defun gnus-article-read-summary-send-keys ()
6860 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6861 (gnus-article-read-summary-keys)))
6863 (defun gnus-article-describe-key (key)
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 (gnus-article-check-buffer)
6869 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6870 gnus-article-read-summary-send-keys))
6871 (with-current-buffer gnus-article-current-summary
6872 (setq unread-command-events
6873 (if (featurep 'xemacs)
6875 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6876 (list 'meta (- x 128))
6879 (let ((cursor-in-echo-area t)
6881 (describe-key (read-key-sequence nil t))))
6882 (describe-key key)))
6884 (defun gnus-article-describe-key-briefly (key &optional insert)
6885 "Display documentation of the function invoked by KEY.
6886 KEY is a string or a vector."
6887 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6888 (read-key-sequence "Describe key: "))
6889 current-prefix-arg))
6890 (gnus-article-check-buffer)
6891 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6892 gnus-article-read-summary-send-keys))
6893 (with-current-buffer gnus-article-current-summary
6894 (setq unread-command-events
6895 (if (featurep 'xemacs)
6897 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6898 (list 'meta (- x 128))
6901 (let ((cursor-in-echo-area t)
6903 (describe-key-briefly (read-key-sequence nil t) insert)))
6904 (describe-key-briefly key insert)))
6906 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6907 (defvar gnus-agent-summary-mode)
6908 (defvar gnus-draft-mode)
6909 (defvar help-xref-stack-item)
6910 (defvar help-xref-following)
6912 (defun gnus-article-describe-bindings (&optional prefix)
6913 "Show a list of all defined keys, and their definitions.
6914 The optional argument PREFIX, if non-nil, should be a key sequence;
6915 then we display only bindings that start with that prefix."
6917 (gnus-article-check-buffer)
6918 (let ((keymap (copy-keymap gnus-article-mode-map))
6919 (map (copy-keymap gnus-article-send-map))
6920 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6922 (define-key keymap "S" map)
6923 (define-key map [t] nil)
6924 (with-current-buffer gnus-article-current-summary
6927 (if (setq parent (keymap-parent gnus-article-mode-map))
6929 (setq parent (copy-keymap parent))
6930 (set-keymap-parent parent (current-local-map)))
6931 (current-local-map)))
6932 (set-keymap-parent map (key-binding "S"))
6933 (let (key def gnus-pick-mode)
6935 (setq key (pop sumkeys))
6936 (cond ((and (vectorp key) (= (length key) 1)
6937 (consp (setq def (aref key 0)))
6938 (numberp (car def)) (numberp (cdr def)))
6939 (when (< (max (car def) (cdr def)) 128)
6943 (nreverse (gnus-uncompress-range def)))
6945 ((setq def (key-binding key))
6946 (unless (eq def 'undefined)
6947 (define-key keymap key def))))))
6948 (when (boundp 'gnus-agent-summary-mode)
6949 (setq agent gnus-agent-summary-mode))
6950 (when (boundp 'gnus-draft-mode)
6951 (setq draft gnus-draft-mode)))
6953 (use-local-map keymap)
6954 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6955 (set (make-local-variable 'gnus-draft-mode) draft)
6956 (describe-bindings prefix))
6957 (let ((item `((lambda (prefix)
6958 (with-current-buffer ,(current-buffer)
6959 (gnus-article-describe-bindings prefix)))
6961 ;; Loading `help-mode' here is necessary if `describe-bindings'
6962 ;; is replaced with something, e.g. `helm-descbinds'.
6963 (require 'help-mode)
6964 (with-current-buffer (let (help-xref-following) (help-buffer))
6965 (setq help-xref-stack-item item)))))
6967 (defun gnus-article-reply-with-original (&optional wide)
6968 "Start composing a reply mail to the current message.
6969 The text in the region will be yanked. If the region isn't active,
6970 the entire article will be yanked."
6972 (let ((article (cdr gnus-article-current))
6974 (if (not (gnus-region-active-p))
6975 (with-current-buffer gnus-summary-buffer
6976 (gnus-summary-reply (list (list article)) wide))
6977 (setq contents (buffer-substring (point) (mark t)))
6978 ;; Deactivate active regions.
6979 (when (and (boundp 'transient-mark-mode)
6980 transient-mark-mode)
6981 (setq mark-active nil))
6982 (with-current-buffer gnus-summary-buffer
6984 (list (list article contents)) wide)))))
6986 (defun gnus-article-wide-reply-with-original ()
6987 "Start composing a wide reply mail to the current message.
6988 The text in the region will be yanked. If the region isn't active,
6989 the entire article will be yanked."
6991 (gnus-article-reply-with-original t))
6993 (defun gnus-article-followup-with-original ()
6994 "Compose a followup to the current article.
6995 The text in the region will be yanked. If the region isn't active,
6996 the entire article will be yanked."
6998 (let ((article (cdr gnus-article-current))
7000 (if (not (gnus-region-active-p))
7001 (with-current-buffer gnus-summary-buffer
7002 (gnus-summary-followup (list (list article))))
7003 (setq contents (buffer-substring (point) (mark t)))
7004 ;; Deactivate active regions.
7005 (when (and (boundp 'transient-mark-mode)
7006 transient-mark-mode)
7007 (setq mark-active nil))
7008 (with-current-buffer gnus-summary-buffer
7009 (gnus-summary-followup
7010 (list (list article contents)))))))
7012 (defun gnus-article-hide (&optional arg force)
7013 "Hide all the gruft in the current article.
7014 This means that signatures, cited text and (some) headers will be
7016 If given a prefix, show the hidden text instead."
7017 (interactive (append (gnus-article-hidden-arg) (list 'force)))
7018 (gnus-article-hide-headers arg)
7019 (gnus-article-hide-list-identifiers arg)
7020 (gnus-article-hide-citation-maybe arg force)
7021 (gnus-article-hide-signature arg))
7023 (defun gnus-check-group-server ()
7024 ;; Make sure the connection to the server is alive.
7025 (unless (gnus-server-opened
7026 (gnus-find-method-for-group gnus-newsgroup-name))
7027 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
7028 (gnus-request-group gnus-newsgroup-name t)))
7030 (declare-function nneething-get-file-name "nneething" (id))
7032 (defun gnus-request-article-this-buffer (article group)
7033 "Get an article and insert it into this buffer."
7034 (let (do-update-line sparse-header)
7038 (gnus-kill-all-overlays)
7039 (setq group (or group gnus-newsgroup-name))
7041 ;; Using `gnus-request-article' directly will insert the article into
7042 ;; `nntp-server-buffer' - so we'll save some time by not having to
7043 ;; copy it from the server buffer into the article buffer.
7045 ;; We only request an article by message-id when we do not have the
7046 ;; headers for it, so we'll have to get those.
7047 (when (stringp article)
7048 (gnus-read-header article))
7050 ;; If the article number is negative, that means that this article
7051 ;; doesn't belong in this newsgroup (possibly), so we find its
7052 ;; message-id and request it by id instead of number.
7053 (when (and (numberp article)
7055 (get-buffer gnus-summary-buffer)
7056 (gnus-buffer-exists-p gnus-summary-buffer))
7057 (with-current-buffer gnus-summary-buffer
7058 (let ((header (gnus-summary-article-header article)))
7061 ((memq article gnus-newsgroup-sparse)
7062 ;; This is a sparse gap article.
7063 (setq do-update-line article)
7064 (setq article (mail-header-id header))
7065 (setq sparse-header (gnus-read-header article))
7066 (setq gnus-newsgroup-sparse
7067 (delq article gnus-newsgroup-sparse)))
7069 ;; It's a real article.
7070 (setq article (mail-header-id header)))
7072 ;; It is an extracted pseudo-article.
7073 (setq article 'pseudo)
7074 (gnus-request-pseudo-article header))))
7076 (let ((method (gnus-find-method-for-group
7077 gnus-newsgroup-name)))
7078 (when (and (eq (car method) 'nneething)
7080 (let ((dir (nneething-get-file-name
7081 (mail-header-id header))))
7082 (when (and (stringp dir)
7083 (file-directory-p dir))
7084 (setq article 'nneething)
7085 (gnus-group-enter-directory dir))))))))
7088 ;; Refuse to select canceled articles.
7089 ((and (numberp article)
7091 (get-buffer gnus-summary-buffer)
7092 (gnus-buffer-exists-p gnus-summary-buffer)
7093 (eq (cdr (with-current-buffer gnus-summary-buffer
7094 (assq article gnus-newsgroup-reads)))
7095 gnus-canceled-mark))
7097 ;; We first check `gnus-original-article-buffer'.
7098 ((and (get-buffer gnus-original-article-buffer)
7100 (with-current-buffer gnus-original-article-buffer
7101 (and (equal (car gnus-original-article) group)
7102 (eq (cdr gnus-original-article) article))))
7103 ;; `insert-buffer-substring' would incorrectly use the
7104 ;; equivalent of string-make-multibyte which amount to decoding
7105 ;; with locale-coding-system, causing failure of
7106 ;; subsequent decoding.
7107 (insert (mm-string-to-multibyte
7108 (with-current-buffer gnus-original-article-buffer
7109 (buffer-substring (point-min) (point-max)))))
7111 ;; Check the backlog.
7112 ((and gnus-keep-backlog
7113 (gnus-backlog-request-article group article (current-buffer)))
7115 ;; Check asynchronous pre-fetch.
7116 ((gnus-async-request-fetched-article group article (current-buffer))
7117 (gnus-async-prefetch-next group article gnus-summary-buffer)
7118 (when (and (numberp article) gnus-keep-backlog)
7119 (gnus-backlog-enter-article group article (current-buffer)))
7122 ((and gnus-use-cache
7124 (gnus-cache-request-article article group))
7126 ;; Check the agent cache.
7127 ((gnus-agent-request-article article group)
7129 ;; Get the article and put into the article buffer.
7130 ((or (stringp article)
7132 (let ((gnus-override-method gnus-override-method)
7133 (methods (and (stringp article)
7134 (with-current-buffer gnus-summary-buffer
7135 (gnus-refer-article-methods))))
7136 (backend (car (gnus-find-method-for-group
7137 gnus-newsgroup-name)))
7139 (inhibit-read-only t))
7140 (when (and (null gnus-override-method)
7142 (setq gnus-override-method (pop methods)))
7145 (gnus-kill-all-overlays)
7146 (let ((gnus-newsgroup-name group))
7147 (gnus-check-group-server))
7149 ((gnus-request-article article group (current-buffer))
7150 (when (numberp article)
7151 (gnus-async-prefetch-next group article
7152 gnus-summary-buffer)
7153 (when gnus-keep-backlog
7154 (gnus-backlog-enter-article
7155 group article (current-buffer)))
7156 (when (and gnus-agent
7157 (gnus-agent-group-covered-p group))
7158 (gnus-agent-store-article article group)))
7159 (setq result 'article))
7161 (setq gnus-override-method (pop methods)))
7162 ((not (string-match "^400 "
7163 (nnheader-get-report backend)))
7164 ;; If we get 400 server disconnect, reconnect and
7165 ;; retry; otherwise, assume the article has expired.
7166 (setq result 'done))))
7167 (and (eq result 'article) 'article)))
7171 ;; Associate this article with the current summary buffer.
7172 (setq gnus-article-current-summary gnus-summary-buffer)
7174 ;; Take the article from the original article buffer
7175 ;; and place it in the buffer it's supposed to be in.
7176 (when (and (get-buffer gnus-article-buffer)
7177 (equal (buffer-name (current-buffer))
7178 (buffer-name (get-buffer gnus-article-buffer))))
7180 (if (get-buffer gnus-original-article-buffer)
7181 (set-buffer gnus-original-article-buffer)
7182 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7183 (buffer-disable-undo)
7184 (setq major-mode 'gnus-original-article-mode)
7185 (setq buffer-read-only t))
7186 (let ((inhibit-read-only t))
7188 (insert-buffer-substring gnus-article-buffer))
7189 (setq gnus-original-article (cons group article)))
7192 (run-hooks 'gnus-article-decode-hook)
7193 ;; Mark article as decoded or not.
7194 (setq gnus-article-decoded-p gnus-article-decode-hook))
7196 ;; Update sparse articles.
7197 (when (and do-update-line
7198 (or (numberp article)
7200 (let ((buf (current-buffer)))
7201 (set-buffer gnus-summary-buffer)
7202 (gnus-summary-update-article do-update-line sparse-header)
7203 (gnus-summary-goto-subject do-update-line nil t)
7204 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7206 (set-buffer buf))))))
7208 (defun gnus-block-private-groups (group)
7209 "Allows images in newsgroups to be shown, blocks images in all
7211 (if (or (gnus-news-group-p group)
7212 (gnus-member-of-valid 'global group))
7213 ;; Block nothing in news groups.
7215 ;; Block everything anywhere else.
7218 (defun gnus-blocked-images ()
7219 (if (functionp gnus-blocked-images)
7220 (funcall gnus-blocked-images gnus-newsgroup-name)
7221 gnus-blocked-images))
7227 (defcustom gnus-article-edit-mode-hook nil
7228 "Hook run in article edit mode buffers."
7229 :group 'gnus-article-various
7232 (defvar gnus-article-edit-done-function nil)
7234 (defvar gnus-article-edit-mode-map nil)
7236 ;; Should we be using derived.el for this?
7237 (unless gnus-article-edit-mode-map
7238 (setq gnus-article-edit-mode-map (make-keymap))
7239 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7241 (gnus-define-keys gnus-article-edit-mode-map
7242 "\C-c?" describe-mode
7243 "\C-c\C-c" gnus-article-edit-done
7244 "\C-c\C-k" gnus-article-edit-exit
7245 "\C-c\C-f\C-t" message-goto-to
7246 "\C-c\C-f\C-o" message-goto-from
7247 "\C-c\C-f\C-b" message-goto-bcc
7248 ;;"\C-c\C-f\C-w" message-goto-fcc
7249 "\C-c\C-f\C-c" message-goto-cc
7250 "\C-c\C-f\C-s" message-goto-subject
7251 "\C-c\C-f\C-r" message-goto-reply-to
7252 "\C-c\C-f\C-n" message-goto-newsgroups
7253 "\C-c\C-f\C-d" message-goto-distribution
7254 "\C-c\C-f\C-f" message-goto-followup-to
7255 "\C-c\C-f\C-m" message-goto-mail-followup-to
7256 "\C-c\C-f\C-k" message-goto-keywords
7257 "\C-c\C-f\C-u" message-goto-summary
7258 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7259 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7260 "\C-c\C-b" message-goto-body
7261 "\C-c\C-i" message-goto-signature
7263 "\C-c\C-t" message-insert-to
7264 "\C-c\C-n" message-insert-newsgroups
7265 "\C-c\C-o" message-sort-headers
7266 "\C-c\C-e" message-elide-region
7267 "\C-c\C-v" message-delete-not-region
7268 "\C-c\C-z" message-kill-to-signature
7269 "\M-\r" message-newline-and-reformat
7270 "\C-c\C-a" mml-attach-file
7271 "\C-a" message-beginning-of-line
7273 "\M-;" comment-region)
7275 (gnus-define-keys (gnus-article-edit-wash-map
7276 "\C-c\C-w" gnus-article-edit-mode-map)
7277 "f" gnus-article-edit-full-stops))
7280 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7282 ["Fetch To" message-insert-to t]
7283 ["Fetch Newsgroups" message-insert-newsgroups t]
7285 ["To" message-goto-to t]
7286 ["From" message-goto-from t]
7287 ["Subject" message-goto-subject t]
7288 ["Cc" message-goto-cc t]
7289 ["Reply-To" message-goto-reply-to t]
7290 ["Summary" message-goto-summary t]
7291 ["Keywords" message-goto-keywords t]
7292 ["Newsgroups" message-goto-newsgroups t]
7293 ["Followup-To" message-goto-followup-to t]
7294 ["Mail-Followup-To" message-goto-mail-followup-to t]
7295 ["Distribution" message-goto-distribution t]
7296 ["Body" message-goto-body t]
7297 ["Signature" message-goto-signature t]))
7299 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7300 "Major mode for editing articles.
7301 This is an extended text-mode.
7303 \\{gnus-article-edit-mode-map}"
7304 (make-local-variable 'gnus-article-edit-done-function)
7305 (make-local-variable 'gnus-prev-winconf)
7306 (set (make-local-variable 'font-lock-defaults)
7307 '(message-font-lock-keywords t))
7308 (set (make-local-variable 'mail-header-separator) "")
7309 (set (make-local-variable 'gnus-article-edit-mode) t)
7310 (easy-menu-add message-mode-field-menu message-mode-map)
7312 (setq buffer-read-only nil)
7313 (buffer-enable-undo)
7316 (defun gnus-article-edit (&optional force)
7317 "Edit the current article.
7318 This will have permanent effect only in mail groups.
7319 If FORCE is non-nil, allow editing of articles even in read-only
7322 (when (and (not force)
7323 (gnus-group-read-only-p))
7324 (error "The current newsgroup does not support article editing"))
7325 (gnus-article-date-original)
7326 (gnus-article-edit-article
7328 `(lambda (no-highlight)
7330 (gnus-summary-edit-article-done
7331 ,(or (mail-header-references gnus-current-headers) "")
7332 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7334 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7335 "Start editing the contents of the current article buffer."
7336 (let ((winconf (current-window-configuration)))
7337 (set-buffer gnus-article-buffer)
7338 (let ((message-auto-save-directory
7339 ;; Don't associate the article buffer with a draft file.
7341 (gnus-article-edit-mode))
7342 (funcall start-func)
7343 (set-buffer-modified-p nil)
7344 (gnus-configure-windows 'edit-article)
7345 (setq gnus-article-edit-done-function exit-func)
7346 (setq gnus-prev-winconf winconf)
7348 (gnus-message 6 "C-c C-c to end edits"))))
7350 (defun gnus-article-edit-done (&optional arg)
7351 "Update the article edits and exit."
7353 (let ((func gnus-article-edit-done-function)
7354 (buf (current-buffer))
7355 (start (window-start))
7356 (winconf gnus-prev-winconf))
7357 (widen) ;; Widen it in case that users narrowed the buffer.
7360 ;; The cache and backlog have to be flushed somewhat.
7361 (when gnus-keep-backlog
7362 (gnus-backlog-remove-article
7363 (car gnus-article-current) (cdr gnus-article-current)))
7364 ;; Flush original article as well.
7365 (gnus-flush-original-article-buffer)
7366 (when gnus-use-cache
7367 (gnus-cache-update-article
7368 (car gnus-article-current) (cdr gnus-article-current)))
7369 ;; We remove all text props from the article buffer.
7370 (kill-all-local-variables)
7371 (set-text-properties (point-min) (point-max) nil)
7373 (set-window-configuration winconf)
7375 (set-window-start (get-buffer-window buf) start)
7376 (set-window-point (get-buffer-window buf) (point)))
7377 (gnus-summary-show-article))
7379 (defun gnus-flush-original-article-buffer ()
7380 (when (get-buffer gnus-original-article-buffer)
7381 (with-current-buffer gnus-original-article-buffer
7382 (setq gnus-original-article nil))))
7384 (defun gnus-article-edit-exit ()
7385 "Exit the article editing without updating."
7387 (when (or (not (buffer-modified-p))
7388 (yes-or-no-p "Article modified; kill anyway? "))
7389 (let ((curbuf (current-buffer))
7391 (window-start (window-start)))
7393 (if (gnus-buffer-live-p gnus-original-article-buffer)
7394 (insert-buffer-substring gnus-original-article-buffer))
7395 (let ((winconf gnus-prev-winconf))
7396 (kill-all-local-variables)
7398 (set-window-configuration winconf)
7399 ;; Tippy-toe some to make sure that point remains where it was.
7400 (save-current-buffer
7402 (set-window-start (get-buffer-window (current-buffer)) window-start)
7404 (gnus-summary-show-article)))
7406 (defun gnus-article-edit-full-stops ()
7407 "Interactively repair spacing at end of sentences."
7410 (goto-char (point-min))
7411 (search-forward-regexp "^$" nil t)
7412 (let ((case-fold-search nil))
7413 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7416 ;;; Article highlights
7419 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7421 ;;; Internal Variables:
7423 (defcustom gnus-button-url-regexp
7425 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7426 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7427 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7428 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7429 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7433 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7434 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7435 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7436 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7438 "[" chars punct "]+" "[" chars "]"
7440 (concat ;; XEmacs 21.4 doesn't support POSIX.
7441 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7442 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7444 "Regular expression that matches URLs."
7446 :group 'gnus-article-buttons
7449 (defcustom gnus-button-valid-fqdn-regexp
7450 message-valid-fqdn-regexp
7451 "Regular expression that matches a valid FQDN."
7453 :group 'gnus-article-buttons
7456 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7457 (defcustom gnus-button-valid-localpart-regexp
7458 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7459 "Regular expression that matches a localpart of mail addresses or MIDs."
7461 :group 'gnus-article-buttons
7464 (defcustom gnus-button-man-handler 'manual-entry
7465 "Function to use for displaying man pages.
7466 The function must take at least one argument with a string naming the
7469 :type '(choice (function-item :tag "Man" manual-entry)
7470 (function-item :tag "Woman" woman)
7471 (function :tag "Other"))
7472 :group 'gnus-article-buttons)
7474 (defcustom gnus-button-mid-or-mail-regexp
7475 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7476 gnus-button-valid-fqdn-regexp
7478 "Regular expression that matches a message ID or a mail address."
7480 :group 'gnus-article-buttons
7483 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7484 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7485 Strings like this can be either a message ID or a mail address. If it is one
7486 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7487 message ID or a mail address, respectively. If this variable is set to the
7488 symbol `ask', always query the user what do do. If it is a function, this
7489 function will be called with the string as its only argument. The function
7490 must return `mid', `mail', `invalid' or `ask'."
7492 :group 'gnus-article-buttons
7493 :type '(choice (function-item :tag "Heuristic function"
7494 gnus-button-mid-or-mail-heuristic)
7499 (defcustom gnus-button-mid-or-mail-heuristic-alist
7500 '((-10.0 . ".+\\$.+@")
7503 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7504 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7505 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7506 (-1.0 . "^[^a-z]+@")
7508 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7509 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7510 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7511 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7514 (-1.0 . "^[0-9][0-9]")
7516 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7517 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7518 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7519 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7521 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7522 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7525 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7527 ;; compensation for TDMA dated mail addresses:
7528 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7530 (-20.0 . "\\.fsf@") ;; Gnus
7533 (-20.0 . "^alpine\\.")
7534 (-20.0 . "_-_") ;; Subject change in thread
7536 (-20.0 . "\\.ln@") ;; leafnode
7537 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7538 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7540 ;; (5.0 . "") ;; $local_part_len <= 7
7541 (10.0 . "^[^0-9]+@")
7542 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7543 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7546 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7548 (0.5 . "^[A-Z][a-z]")
7549 (0.5 . "^[A-Z][a-z][a-z]")
7550 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7551 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7552 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7554 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7555 address. The REGEXP is processed with `case-fold-search' set to nil."
7557 :group 'gnus-article-buttons
7558 :type '(repeat (cons (number :tag "Rate")
7559 (regexp :tag "Regexp"))))
7561 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7562 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7563 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7564 address, `ask' if unsure and `invalid' if the string is invalid."
7565 (let ((case-fold-search nil)
7566 (list gnus-button-mid-or-mail-heuristic-alist)
7567 (result 0) rate regexp lpartlen elem)
7569 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7570 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7571 ;; Certain special cases...
7574 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7575 "^[0-9]+\\.[0-9]+@compuserve\\|"
7576 "@public\\.gmane\\.org")
7578 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7579 (setq result 'mail))
7580 (when (string-match "@.*@\\| " mid-or-mail)
7581 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7582 (setq result 'invalid))
7583 ;; Nothing more to do, if result is not a number here...
7584 (when (numberp result)
7586 (setq elem (car list)
7590 (when (string-match regexp mid-or-mail)
7591 (setq result (+ result rate))
7593 9 "`%s' matched `%s', rate `%s', result `%s'."
7594 mid-or-mail regexp rate result)))
7595 (when (<= lpartlen 7)
7596 (setq result (+ result 5.0))
7597 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7598 mid-or-mail result))
7599 (when (>= lpartlen 12)
7600 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7602 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7603 ;; Long local part should contain realname if e-mail address,
7604 ;; too many digits: message-id.
7605 ;; $score -= 5.0 + 0.1 * $local_part_len;
7606 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7607 (setq result (+ result rate))
7609 9 "Many digits in `%s', rate `%s', result `%s'."
7610 mid-or-mail rate result))
7611 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7613 ;; Too few vowels [^aeiouy]{4,}.*\@
7614 (setq result (+ result -5.0))
7616 9 "Few vowels in `%s', rate `%s', result `%s'."
7617 mid-or-mail -5.0 result))
7619 (setq result (+ result 5.0))
7621 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7622 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7623 ;; Maybe we should make this a customizable alist: (condition . 'result)
7625 ((symbolp result) result)
7626 ;; Now convert number into proper results:
7627 ((< result -10.0) 'mid)
7628 ((> result 10.0) 'mail)
7631 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7632 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7633 (url-mid (concat "news" ":" mid-or-mail))
7634 (url-mailto (concat "mailto" ":" mid-or-mail)))
7635 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7636 (when (fboundp pref)
7638 ;; get rid of surrounding angles...
7640 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7641 (if (or (eq 'mid guessed) (eq 'mail guessed))
7645 (save-window-excursion
7646 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7649 (cond ((eq pref 'mid)
7650 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7651 (gnus-button-handle-news url-mid))
7653 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7654 (gnus-url-mailto url-mailto))
7655 (t (gnus-message 3 "Invalid string.")))))
7657 (defun gnus-button-handle-custom (fun arg)
7658 "Call function FUN on argument ARG.
7659 Both FUN and ARG are supposed to be strings. ARG will be passed
7660 as a symbol to FUN."
7661 (funcall (intern fun)
7662 (if (string-match "^customize-apropos" fun)
7666 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7668 (defun gnus-button-handle-describe-function (url)
7669 "Call `describe-function' when pushing the corresponding URL button."
7672 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7674 (defun gnus-button-handle-describe-variable (url)
7675 "Call `describe-variable' when pushing the corresponding URL button."
7678 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7680 (defun gnus-button-handle-symbol (url)
7681 "Display help on variable or function.
7682 Calls `describe-variable' or `describe-function'."
7683 (let ((sym (intern url)))
7685 ((fboundp sym) (describe-function sym))
7686 ((boundp sym) (describe-variable sym))
7687 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7689 (defun gnus-button-handle-describe-key (url)
7690 "Call `describe-key' when pushing the corresponding URL button."
7692 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7693 (keys (ignore-errors (eval `(kbd ,key-string)))))
7696 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7698 (defun gnus-button-handle-apropos (url)
7699 "Call `apropos' when pushing the corresponding URL button."
7700 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7702 (defun gnus-button-handle-apropos-command (url)
7703 "Call `apropos' when pushing the corresponding URL button."
7705 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7707 (defun gnus-button-handle-apropos-variable (url)
7708 "Call `apropos' when pushing the corresponding URL button."
7710 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7711 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7713 (defun gnus-button-handle-apropos-documentation (url)
7714 "Call `apropos' when pushing the corresponding URL button."
7716 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7717 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7719 (defun gnus-button-handle-library (url)
7720 "Call `locate-library' when pushing the corresponding URL button."
7721 (gnus-message 9 "url=`%s'" url)
7722 (let* ((lib (locate-library url))
7723 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7725 (gnus-message 1 "Cannot locale library `%s'." url)
7726 (find-file-read-only file))))
7728 (defcustom gnus-button-man-level 5
7729 "*Integer that says how many man-related buttons Gnus will show.
7730 The higher the number, the more buttons will appear and the more false
7731 positives are possible. Note that you can set this variable local to
7732 specific groups. Setting it higher in Unix groups is probably a good idea.
7733 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7734 how to set variables in specific groups."
7736 :group 'gnus-article-buttons
7737 :link '(custom-manual "(gnus)Group Parameters")
7740 (defcustom gnus-button-emacs-level 5
7741 "*Integer that says how many emacs-related buttons Gnus will show.
7742 The higher the number, the more buttons will appear and the more false
7743 positives are possible. Note that you can set this variable local to
7744 specific groups. Setting it higher in Emacs or Gnus related groups is
7745 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7746 `gnus-parameters' on how to set variables in specific groups."
7748 :group 'gnus-article-buttons
7749 :link '(custom-manual "(gnus)Group Parameters")
7752 (defcustom gnus-button-message-level 5
7753 "*Integer that says how many buttons for news or mail messages will appear.
7754 The higher the number, the more buttons will appear and the more false
7755 positives are possible."
7756 ;; mail addresses, MIDs, URLs for news, ...
7758 :group 'gnus-article-buttons
7761 (defcustom gnus-button-browse-level 5
7762 "*Integer that says how many buttons for browsing will appear.
7763 The higher the number, the more buttons will appear and the more false
7764 positives are possible."
7765 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7767 :group 'gnus-article-buttons
7770 (defcustom gnus-button-alist
7771 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7772 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7773 ((concat "\\b\\(nntp\\|news\\):\\("
7774 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7775 0 t gnus-button-handle-news 2)
7776 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7777 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7778 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7779 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7780 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7781 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7782 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7783 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7784 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7785 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7786 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7787 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7788 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7789 ;; RFC 2368 (The mailto URL scheme)
7790 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7791 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7792 ("\\bmailto:\\([^ \n\t]+\\)"
7793 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7794 ;; Info Konqueror style <info:/foo/bar baz>.
7795 ;; Must come before " Gnus home-grown style".
7796 ("\\binfo://?\\([^'\">\n\t]+\\)"
7797 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7798 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7799 ("\\binfo://\\([^'\">\n\t ]+\\)"
7800 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7801 ;; Info GNOME style <info:foo#bar_baz>
7802 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7803 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7804 ;; Info KDE style <info:(foo)bar baz>
7805 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7806 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7807 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7808 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7809 ("\\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,]*\\)\\)?"
7810 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7811 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7813 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7814 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7815 ;; Emacs help commands
7816 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7817 ;; regexp doesn't match arguments containing ` '.
7818 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7819 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7820 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7821 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7822 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7823 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7824 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7825 ;; The following entries may lead to many false positives so don't enable
7826 ;; them by default (use a high button level).
7827 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7828 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7829 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7830 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7831 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7832 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7833 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7834 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7835 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7836 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7837 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7838 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7839 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7840 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7841 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7842 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7843 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7844 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7845 ;; Unlike the other regexps we really have to require quoting
7846 ;; here to determine where it ends.
7847 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7848 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7849 ("<URL: *\\([^\n<>]*\\)>"
7850 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7851 ;; RFC 2396 (2.4.3., delims) ...
7852 ("\"URL: *\\([^\n\"]*\\)\""
7853 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7855 (gnus-button-url-regexp
7856 0 (>= gnus-button-browse-level 0) browse-url 0)
7858 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7859 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7860 gnus-button-handle-man 1)
7861 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7862 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7863 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7864 gnus-button-handle-man 1)
7865 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7866 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7867 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7868 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7869 ;; Recognizing patches to .el files. This is somewhat obscure,
7870 ;; but considering the percentage of Gnus users who hack Emacs
7872 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7873 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7874 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7875 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7876 ;; MID or mail: To avoid too many false positives we don't try to catch
7877 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7878 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7879 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7880 ;; so that non-ambiguous entries (see above) match first.
7881 (gnus-button-mid-or-mail-regexp
7882 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7883 "*Alist of regexps matching buttons in article bodies.
7885 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7886 REGEXP: is the string (case insensitive) matching text around the button (can
7887 also be Lisp expression evaluating to a string),
7888 BUTTON: is the number of the regexp grouping actually matching the button,
7889 FORM: is a Lisp expression which must eval to true for the button to
7891 CALLBACK: is the function to call when the user push this button, and each
7892 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7894 CALLBACK can also be a variable, in that case the value of that
7895 variable it the real callback function."
7896 :group 'gnus-article-buttons
7897 :type '(repeat (list (choice regexp variable sexp)
7898 (integer :tag "Button")
7900 (function :tag "Callback")
7903 (integer :tag "Regexp group")))))
7904 (put 'gnus-button-alist 'risky-local-variable t)
7906 (defcustom gnus-header-button-alist
7907 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7908 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7909 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7910 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7911 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7912 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7913 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7914 0 (>= gnus-button-browse-level 0) browse-url 0)
7915 ("^Subject:" gnus-button-url-regexp
7916 0 (>= gnus-button-browse-level 0) browse-url 0)
7917 ("^[^:]+:" gnus-button-url-regexp
7918 0 (>= gnus-button-browse-level 0) browse-url 0)
7919 ("^OpenPGP:.*url=" gnus-button-url-regexp
7920 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7921 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7922 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7923 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7924 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7925 "*Alist of headers and regexps to match buttons in article heads.
7927 This alist is very similar to `gnus-button-alist', except that each
7928 alist has an additional HEADER element first in each entry:
7930 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7932 HEADER is a regexp to match a header. For a fuller explanation, see
7933 `gnus-button-alist'."
7934 :group 'gnus-article-buttons
7935 :group 'gnus-article-headers
7936 :type '(repeat (list (regexp :tag "Header")
7937 (choice regexp variable)
7938 (integer :tag "Button")
7940 (function :tag "Callback")
7943 (integer :tag "Regexp group")))))
7944 (put 'gnus-header-button-alist 'risky-local-variable t)
7948 (defun gnus-article-push-button (event)
7949 "Check text under the mouse pointer for a callback function.
7950 If the text under the mouse pointer has a `gnus-callback' property,
7951 call it with the value of the `gnus-data' text property."
7953 (set-buffer (window-buffer (posn-window (event-start event))))
7954 (let* ((pos (posn-point (event-start event)))
7955 (data (get-text-property pos 'gnus-data))
7956 (fun (get-text-property pos 'gnus-callback)))
7959 (funcall fun data))))
7961 (defun gnus-article-press-button ()
7962 "Check text at point for a callback function.
7963 If the text at point has a `gnus-callback' property,
7964 call it with the value of the `gnus-data' text property."
7966 (let ((data (get-text-property (point) 'gnus-data))
7967 (fun (get-text-property (point) 'gnus-callback)))
7969 (funcall fun data))))
7971 (defun gnus-article-highlight (&optional force)
7972 "Highlight current article.
7973 This function calls `gnus-article-highlight-headers',
7974 `gnus-article-highlight-citation',
7975 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7976 do the highlighting. See the documentation for those functions."
7977 (interactive (list 'force))
7978 (gnus-article-highlight-headers)
7979 (gnus-article-highlight-citation force)
7980 (gnus-article-highlight-signature)
7981 (gnus-article-add-buttons)
7982 (gnus-article-add-buttons-to-head))
7984 (defun gnus-article-highlight-some (&optional _force)
7985 "Highlight current article.
7986 This function calls `gnus-article-highlight-headers',
7987 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7988 do the highlighting. See the documentation for those functions."
7989 (interactive (list 'force))
7990 (gnus-article-highlight-headers)
7991 (gnus-article-highlight-signature)
7992 (gnus-article-add-buttons))
7994 (defun gnus-article-highlight-headers ()
7995 "Highlight article headers as specified by `gnus-header-face-alist'."
7997 (gnus-with-article-headers
7998 (let (regexp header-face field-face from hpoints fpoints)
7999 (dolist (entry gnus-header-face-alist)
8000 (goto-char (point-min))
8001 (setq regexp (concat "^\\("
8002 (if (string-equal "" (nth 0 entry))
8006 header-face (nth 1 entry)
8007 field-face (nth 2 entry))
8008 (while (and (re-search-forward regexp nil t)
8012 (unless (search-forward ":" nil t)
8014 (when (and header-face
8015 (not (memq (point) hpoints)))
8016 (push (point) hpoints)
8017 (gnus-put-text-property from (point) 'face header-face))
8018 (when (and field-face
8019 (not (memq (setq from (point)) fpoints)))
8021 (if (re-search-forward "^[^ \t]" nil t)
8023 (goto-char (point-max)))
8024 (gnus-put-text-property from (point) 'face field-face)))))))
8026 (defun gnus-article-highlight-signature ()
8027 "Highlight the signature in an article.
8028 It does this by highlighting everything after
8029 `gnus-signature-separator' using the face `gnus-signature'."
8031 (gnus-with-article-buffer
8032 (let ((inhibit-point-motion-hooks t))
8034 (when (and gnus-signature-face
8035 (gnus-article-narrow-to-signature))
8036 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
8037 'face gnus-signature-face)
8039 (gnus-article-search-signature)
8040 (let ((start (match-beginning 0))
8041 (end (set-marker (make-marker) (1+ (match-end 0)))))
8042 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
8045 (defun gnus-button-in-region-p (b e prop)
8046 "Say whether PROP exists in the region."
8047 (text-property-not-all b e prop nil))
8049 (defun gnus-article-add-buttons ()
8050 "Find external references in the article and make buttons of them.
8051 \"External references\" are things like Message-IDs and URLs, as
8052 specified by `gnus-button-alist'."
8054 (gnus-with-article-buffer
8055 (let ((inhibit-point-motion-hooks t)
8056 (case-fold-search t)
8057 (alist gnus-button-alist)
8059 ;; We skip the headers.
8062 (while (setq entry (pop alist))
8063 (setq regexp (eval (car entry)))
8065 (while (re-search-forward regexp nil t)
8066 (let ((start (match-beginning (nth 1 entry)))
8067 (end (match-end (nth 1 entry)))
8068 (from (match-beginning 0)))
8069 (when (and (eval (nth 2 entry))
8070 (not (gnus-button-in-region-p
8071 start end 'gnus-callback)))
8072 ;; That optional form returned non-nil, so we add the
8074 (setq from (set-marker (make-marker) from))
8075 (unless (and (eq (car entry) 'gnus-button-url-regexp)
8076 (gnus-article-extend-url-button from start end))
8077 (gnus-article-add-button start end
8078 'gnus-button-push (list from entry))
8079 (gnus-put-text-property
8081 'gnus-string (buffer-substring-no-properties
8084 (defun gnus-article-extend-url-button (beg start end)
8085 "Extend url button if url is folded into two or more lines.
8086 Return non-nil if button is extended. BEG is a marker that points to
8087 the beginning position of a text containing url. START and END are
8088 the endpoints of a url button before it is extended. The concatenated
8089 url is put as the `gnus-button-url' overlay property on the button."
8090 (let ((opoint (point))
8091 (points (list start end))
8096 (not (looking-at "[\t ]*[\">]")))
8100 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8101 (buffer-substring (point-at-bol) start)))
8103 (setq url (list (buffer-substring start end))
8104 delim (if (match-beginning 1) ">" "\""))
8106 (setq regexp (concat
8107 (when (and (looking-at
8108 message-cite-prefix-regexp)
8109 (< (match-end 0) start))
8110 (regexp-quote (match-string 0)))
8112 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8116 (and (looking-at regexp)
8119 (push (or (match-string 2)
8122 (push (setq end (or (match-end 2)
8125 (push (or (match-beginning 2)
8126 (match-beginning 1))
8128 (match-beginning 2)))
8129 (let (gnus-article-mouse-face widget-mouse-face)
8131 (gnus-article-add-button (pop points) (pop points)
8133 (list beg (assq 'gnus-button-url-regexp
8134 gnus-button-alist)))))
8135 (let ((overlay (gnus-make-overlay start end)))
8136 (gnus-overlay-put overlay 'evaporate t)
8137 (gnus-overlay-put overlay 'gnus-button-url
8138 (list (mapconcat 'identity (nreverse url) "")))
8139 (when gnus-article-mouse-face
8140 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8142 (goto-char opoint))))
8144 ;; Add buttons to the head of an article.
8145 (defun gnus-article-add-buttons-to-head ()
8146 "Add buttons to the head of the article."
8148 (gnus-with-article-headers
8150 (dolist (entry gnus-header-button-alist)
8151 ;; Each alist entry.
8152 (goto-char (point-min))
8153 (while (re-search-forward (car entry) nil t)
8154 ;; Each header matching the entry.
8155 (setq beg (match-beginning 0))
8156 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8157 (match-beginning 0))
8160 (while (re-search-forward (eval (nth 1 entry)) end t)
8161 ;; Each match within a header.
8162 (let* ((entry (cdr entry))
8163 (start (match-beginning (nth 1 entry)))
8164 (end (match-end (nth 1 entry)))
8165 (form (nth 2 entry)))
8166 (goto-char (match-end 0))
8168 (gnus-article-add-button
8169 start end (nth 3 entry)
8170 (buffer-substring (match-beginning (nth 4 entry))
8171 (match-end (nth 4 entry)))))))
8172 (goto-char end))))))
8174 ;;; External functions:
8176 (defun gnus-article-add-button (from to fun &optional data text)
8177 "Create a button between FROM and TO with callback FUN and data DATA."
8178 (when gnus-article-button-face
8179 (gnus-overlay-put (gnus-make-overlay from to nil t)
8180 'face gnus-article-button-face))
8181 (gnus-add-text-properties
8183 (nconc (and gnus-article-mouse-face
8184 (list gnus-mouse-face-prop gnus-article-mouse-face))
8185 (list 'gnus-callback fun)
8186 (and data (list 'gnus-data data))))
8187 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8188 :help-echo (or text "Follow the link")
8189 :keymap gnus-url-button-map
8190 :button-keymap gnus-widget-button-keymap))
8192 (defun gnus-article-copy-string ()
8193 "Copy the string in the button to the kill ring."
8195 (gnus-article-check-buffer)
8196 (let ((data (get-text-property (point) 'gnus-string)))
8200 (copy-region-as-kill (point-min) (point-max))
8201 (message "Copied %s" data)))))
8203 ;;; Internal functions:
8205 (defun gnus-article-set-globals ()
8206 (with-current-buffer gnus-summary-buffer
8207 (gnus-set-global-variables)))
8209 (defun gnus-signature-toggle (end)
8210 (gnus-with-article-buffer
8211 (let ((inhibit-point-motion-hooks t))
8212 (if (text-property-any end (point-max) 'article-type 'signature)
8214 (gnus-delete-wash-type 'signature)
8215 (gnus-remove-text-properties-when
8216 'article-type 'signature end (point-max)
8217 (cons 'article-type (cons 'signature
8218 gnus-hidden-properties))))
8219 (gnus-add-wash-type 'signature)
8220 (gnus-add-text-properties-when
8221 'article-type nil end (point-max)
8222 (cons 'article-type (cons 'signature
8223 gnus-hidden-properties)))))
8224 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8225 (gnus-set-mode-line 'article))))
8227 (defun gnus-button-push (marker-and-entry)
8228 ;; Push button starting at MARKER.
8230 (let* ((marker (car marker-and-entry))
8231 (entry (cadr marker-and-entry))
8232 (regexp (car entry))
8233 (inhibit-point-motion-hooks t))
8235 ;; This is obviously true, or something bad is happening :)
8236 ;; But we need it to have the match-data
8237 (when (looking-at (or (if (symbolp regexp)
8238 (symbol-value regexp)
8240 (let ((fun (nth 3 entry))
8241 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8242 (get-char-property marker 'gnus-button-url))
8243 (mapcar (lambda (group)
8244 (let ((string (match-string group)))
8245 (set-text-properties
8246 0 (length string) nil string)
8248 (nthcdr 4 entry)))))
8254 (fboundp (symbol-value fun)))
8255 (apply (symbol-value fun) args))
8257 (gnus-message 1 "You must define `%S' to use this button"
8258 (cons fun args)))))))))
8260 (defun gnus-parse-news-url (url)
8261 (let (scheme server port group message-id articles)
8264 (goto-char (point-min))
8265 (when (looking-at "\\([A-Za-z]+\\):")
8266 (setq scheme (match-string 1))
8267 (goto-char (match-end 0)))
8268 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8269 (setq server (match-string 1))
8270 (setq port (if (stringp (match-string 3))
8271 (string-to-number (match-string 3))
8273 (goto-char (match-end 0)))
8276 ((looking-at "\\(.*@.*\\)")
8277 (setq message-id (match-string 1)))
8278 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8279 (setq group (match-string 1)
8280 articles (split-string (match-string 2) "-")))
8281 ((looking-at "\\([^/]+\\)/?")
8282 (setq group (match-string 1)))
8284 (error "Unknown news URL syntax"))))
8285 (list scheme server port group message-id articles)))
8287 (defvar nntp-port-number)
8289 (defun gnus-button-handle-news (url)
8291 (destructuring-bind (_scheme server port group message-id _articles)
8292 (gnus-parse-news-url url)
8295 (with-current-buffer gnus-summary-buffer
8297 (let ((gnus-refer-article-method
8298 (nconc (list (list 'nntp server))
8299 gnus-refer-article-method))
8300 (nntp-port-number (or port "nntp")))
8301 (gnus-message 7 "Fetching %s with %s"
8302 message-id gnus-refer-article-method)
8303 (gnus-summary-refer-article message-id))
8304 (gnus-summary-refer-article message-id))))
8306 (gnus-button-fetch-group url)))))
8308 (defun gnus-button-patch (library line)
8309 "Visit an Emacs Lisp library LIBRARY on line LINE."
8311 (let ((file (locate-library (file-name-nondirectory library))))
8313 (error "Couldn't find library %s" library))
8315 (goto-char (point-min))
8316 (forward-line (1- (string-to-number line)))))
8318 (defun gnus-button-handle-man (url)
8320 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8321 (when (eq gnus-button-man-handler 'woman)
8322 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8323 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8324 (funcall gnus-button-man-handler url))
8326 (defun gnus-button-handle-info-url (url)
8327 "Fetch an info URL."
8328 (setq url (mm-subst-char-in-string ?+ ?\ url))
8330 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8331 (gnus-info-find-node
8332 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8334 ")" (gnus-url-unhex-string (match-string 2 url)))))
8335 ((string-match "([^)\"]+)[^\"]+" url)
8337 (gnus-replace-in-string
8338 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8339 (gnus-info-find-node url))
8340 (t (error "Can't parse %s" url))))
8342 (defun gnus-button-handle-info-url-gnome (url)
8343 "Fetch GNOME style info URL."
8344 (setq url (mm-subst-char-in-string ?_ ?\ url))
8345 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8346 (gnus-info-find-node
8348 (gnus-url-unhex-string
8349 (match-string 1 url))
8351 (or (gnus-url-unhex-string
8352 (match-string 2 url))
8354 (error "Can't parse %s" url)))
8356 (defun gnus-button-handle-info-url-kde (url)
8357 "Fetch KDE style info URL."
8358 (gnus-info-find-node (gnus-url-unhex-string url)))
8360 ;; (info) will autoload info.el
8361 (declare-function Info-menu "info" (menu-item &optional fork))
8362 (declare-function Info-index-next "info" (num))
8364 (defun gnus-button-handle-info-keystrokes (url)
8365 "Call `info' when pushing the corresponding URL button."
8366 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8367 (let (node indx comma)
8369 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8370 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8371 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8372 "\\(?:[ \t\n,]*\\)\\)?")
8374 (setq node (match-string 2 url)
8375 indx (match-string 3 url))
8376 (error "Can't parse %s" url))
8380 (when (> (length indx) 0)
8381 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8384 (setq comma (match-string 2 indx))
8385 (setq indx (match-string 1 indx))
8388 (dotimes (i (with-temp-buffer
8390 ;; Note: the XEmacs version of `how-many' takes
8391 ;; no optional argument.
8392 (goto-char (point-min))
8394 (Info-index-next 1)))
8397 (autoload 'pgg-snarf-keys-region "pgg")
8398 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8399 (declare-function pgg-display-output-buffer "pgg" (start end status))
8401 (defun gnus-button-openpgp (url)
8402 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8404 (mm-url-insert-file-contents-external url)
8405 (pgg-snarf-keys-region (point-min) (point-max))
8406 (pgg-display-output-buffer nil nil nil)))
8408 (defun gnus-button-message-id (message-id)
8410 (with-current-buffer gnus-summary-buffer
8411 (gnus-summary-refer-article message-id)))
8413 (defun gnus-button-fetch-group (address &rest _ignore)
8414 "Fetch GROUP specified by ADDRESS."
8415 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8417 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8418 ;; for nntp:// and news://
8419 (setq address (match-string 3 address)))
8420 (if (not (string-match "[:/]" address))
8421 ;; This is just a simple group url.
8422 (gnus-group-read-ephemeral-group address gnus-select-method)
8425 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8427 (error "Can't parse %s" address)
8428 (gnus-group-read-ephemeral-group
8429 (match-string 4 address)
8430 `(nntp ,(match-string 1 address)
8431 (nntp-address ,(match-string 1 address))
8432 (nntp-port-number ,(if (match-end 3)
8433 (match-string 3 address)
8436 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8438 (defun gnus-url-parse-query-string (query &optional downcase)
8439 (let (retval pairs cur key val)
8440 (setq pairs (split-string query "&"))
8442 (setq cur (car pairs)
8444 (if (not (string-match "=" cur))
8446 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8447 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8449 (setq key (downcase key)))
8450 (setq cur (assoc key retval))
8452 (setcdr cur (cons val (cdr cur)))
8453 (setq retval (cons (list key val) retval)))))
8456 (defun gnus-url-mailto (url)
8457 ;; Send mail to someone
8458 (setq url (replace-regexp-in-string "\n" " " url))
8459 (when (string-match "mailto:/*\\(.*\\)" url)
8460 (setq url (substring url (match-beginning 1) nil)))
8461 (let* ((args (gnus-url-parse-query-string
8462 (if (string-match "^\\?" url)
8464 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8465 (concat "to=" (match-string 1 url) "&"
8466 (match-string 2 url))
8467 (concat "to=" url)))))
8468 (subject (cdr-safe (assoc "subject" args)))
8472 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8475 (message-position-on-field (caar args)))
8476 (insert (gnus-replace-in-string
8477 (mapconcat 'identity (reverse (cdar args)) ", ")
8479 (setq args (cdr args)))
8482 (message-goto-subject))))
8484 (defun gnus-button-embedded-url (address)
8485 "Activate ADDRESS with `browse-url'."
8486 (browse-url (gnus-strip-whitespace address)))
8488 ;;; Next/prev buttons in the article buffer.
8490 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8491 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8493 (defvar gnus-prev-page-map
8494 (let ((map (make-sparse-keymap)))
8495 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8496 (define-key map "\r" 'gnus-button-prev-page)
8499 (defvar gnus-next-page-map
8500 (let ((map (make-sparse-keymap)))
8501 (define-key map gnus-mouse-2 'gnus-button-next-page)
8502 (define-key map "\r" 'gnus-button-next-page)
8505 (defun gnus-insert-prev-page-button ()
8507 (inhibit-read-only t))
8509 gnus-prev-page-line-format nil
8510 `(keymap ,gnus-prev-page-map
8512 gnus-callback gnus-article-button-prev-page
8513 article-type annotation))
8515 ;; Exclude a newline.
8518 (when gnus-article-button-face
8519 (gnus-overlay-put (gnus-make-overlay b e nil t)
8520 'face gnus-article-button-face))
8521 (widget-convert-button
8523 :action 'gnus-button-prev-page
8524 :button-keymap gnus-prev-page-map)))
8526 (defun gnus-button-next-page (&optional _args _more-args)
8527 "Go to the next page."
8529 (let ((win (selected-window)))
8530 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8531 (gnus-article-next-page)
8532 (select-window win)))
8534 (defun gnus-button-prev-page (&optional _args _more-args)
8535 "Go to the prev page."
8537 (let ((win (selected-window)))
8538 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8539 (gnus-article-prev-page)
8540 (select-window win)))
8542 (defun gnus-insert-next-page-button ()
8544 (inhibit-read-only t))
8545 (gnus-eval-format gnus-next-page-line-format nil
8546 `(keymap ,gnus-next-page-map
8548 gnus-callback gnus-article-button-next-page
8549 article-type annotation))
8551 ;; Exclude a newline.
8554 (when gnus-article-button-face
8555 (gnus-overlay-put (gnus-make-overlay b e nil t)
8556 'face gnus-article-button-face))
8557 (widget-convert-button
8559 :action 'gnus-button-next-page
8560 :button-keymap gnus-next-page-map)))
8562 (defun gnus-article-button-next-page (_arg)
8563 "Go to the next page."
8565 (let ((win (selected-window)))
8566 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8567 (gnus-article-next-page)
8568 (select-window win)))
8570 (defun gnus-article-button-prev-page (_arg)
8571 "Go to the prev page."
8573 (let ((win (selected-window)))
8574 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8575 (gnus-article-prev-page)
8576 (select-window win)))
8578 (defvar gnus-decode-header-methods
8579 '(mail-decode-encoded-word-region)
8580 "List of methods used to decode headers.
8582 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8583 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8584 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8585 whose names match REGEXP.
8588 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8589 mail-decode-encoded-word-region
8590 (\"chinese\" . rfc1843-decode-region))
8593 (defvar gnus-decode-header-methods-cache nil)
8595 (defun gnus-multi-decode-header (start end)
8596 "Apply the functions from `gnus-encoded-word-methods' that match."
8597 (unless (and gnus-decode-header-methods-cache
8598 (eq gnus-newsgroup-name
8599 (car gnus-decode-header-methods-cache)))
8600 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8601 (dolist (x gnus-decode-header-methods)
8603 (nconc gnus-decode-header-methods-cache (list x))
8604 (if (and gnus-newsgroup-name
8605 (string-match (car x) gnus-newsgroup-name))
8606 (nconc gnus-decode-header-methods-cache
8608 (let ((xlist gnus-decode-header-methods-cache))
8611 (narrow-to-region start end)
8613 (funcall (pop xlist) (point-min) (point-max))))))
8616 ;;; Treatment top-level handling.
8619 (defvar gnus-inhibit-article-treatments nil)
8621 ;; Dynamic variables.
8622 (defvar part-number) ;FIXME: Lacks a "gnus-" prefix.
8623 (defvar total-parts) ;FIXME: Lacks a "gnus-" prefix.
8624 (defvar gnus-treat-type)
8625 (defvar gnus-treat-condition)
8626 (defvar gnus-treat-length)
8628 (defun gnus-treat-article (condition
8629 &optional part-num total type)
8630 (let ((gnus-treat-condition condition)
8631 (part-number part-num)
8633 (gnus-treat-type type)
8634 (gnus-treat-length (- (point-max) (point-min)))
8635 (alist gnus-treatment-function-alist)
8636 (article-goto-body-goes-to-point-min-p t)
8640 (let ((list gnus-article-treat-types))
8642 (when (string-match (pop list) type)
8643 (throw 'found t)))))))
8644 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8646 (gnus-run-hooks 'gnus-part-display-hook)
8647 (dolist (elem alist)
8650 (when (gnus-buffer-live-p gnus-summary-buffer)
8651 (set-buffer gnus-summary-buffer))
8652 (symbol-value (car elem))))
8653 (when (and (or (consp val)
8655 (or (not gnus-inhibit-article-treatments)
8656 (eq gnus-treat-condition 'head))
8657 (gnus-treat-predicate val)
8658 (or (not (get (car elem) 'highlight))
8661 (funcall (cadr elem)))))))
8663 (defun gnus-treat-predicate (val)
8667 (gnus-treat-condition
8668 (eq gnus-treat-condition val))
8670 (stringp (car val)))
8671 (apply 'gnus-or (mapcar `(lambda (s)
8672 (string-match s ,(or gnus-newsgroup-name "")))
8675 (let ((pred (pop val)))
8678 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8680 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8682 (not (gnus-treat-predicate (car val))))
8684 (equal (car val) gnus-treat-type))
8688 (error "%S is not a valid predicate" pred)))))
8696 (eq part-number total-parts))
8698 (< gnus-treat-length val))
8700 (error "%S is not a valid value" val))))
8702 (defun gnus-article-encrypt-body (protocol &optional n)
8703 "Encrypt the article body."
8706 (or gnus-article-encrypt-protocol
8707 (gnus-completing-read "Encrypt protocol"
8708 (mapcar 'car gnus-article-encrypt-protocol-alist)
8710 current-prefix-arg))
8711 ;; User might hit `K E' instead of `K e', so prompt once.
8712 (when (and gnus-article-encrypt-protocol
8714 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8715 (error "Encrypt aborted")))
8716 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8718 (error "Can't find the encrypt protocol %s" protocol))
8719 (if (member gnus-newsgroup-name '("nndraft:delayed"
8722 (error "Can't encrypt the article in group %s"
8723 gnus-newsgroup-name))
8724 (gnus-summary-iterate n
8725 (with-current-buffer gnus-summary-buffer
8726 (let ((mail-parse-charset gnus-newsgroup-charset)
8727 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8728 (summary-buffer gnus-summary-buffer)
8730 (gnus-set-global-variables)
8731 (when (gnus-group-read-only-p)
8732 (error "The current newsgroup does not support article encrypt"))
8733 (gnus-summary-show-article t)
8735 (or (mail-header-references gnus-current-headers) ""))
8736 (set-buffer gnus-article-buffer)
8737 (let* ((inhibit-read-only t)
8739 (mapcar (lambda (field)
8740 (and (save-restriction
8741 (message-narrow-to-head)
8742 (goto-char (point-min))
8743 (search-forward field nil t))
8745 (message-narrow-to-field)
8747 (delete-region (point-min) (point-max))
8749 '("Content-Type:" "Content-Transfer-Encoding:"
8750 "Content-Disposition:"))))
8751 (message-narrow-to-head)
8752 (message-remove-header "MIME-Version")
8753 (goto-char (point-max))
8754 (setq point (point))
8755 (insert (apply 'concat headers))
8757 (narrow-to-region point (point-max))
8758 (let ((message-options message-options))
8759 (message-options-set 'message-sender user-mail-address)
8760 (message-options-set 'message-recipients user-mail-address)
8761 (message-options-set 'message-sign-encrypt 'not)
8763 (goto-char (point-min))
8764 (insert "MIME-Version: 1.0\n")
8766 (gnus-summary-edit-article-done
8767 references nil summary-buffer t))
8768 (when gnus-keep-backlog
8769 (gnus-backlog-remove-article
8770 (car gnus-article-current) (cdr gnus-article-current)))
8771 (gnus-flush-original-article-buffer)
8772 (when gnus-use-cache
8773 (gnus-cache-update-article
8774 (car gnus-article-current) (cdr gnus-article-current))))))))
8776 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8777 "The following specs can be used:
8778 %t The security MIME type
8781 %D Details if button is pressed")
8783 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8784 "The following specs can be used:
8785 %t The security MIME type
8788 %D Details if button is pressed")
8790 (defvar gnus-mime-security-button-line-format-alist
8791 '((?t gnus-tmp-type ?s)
8792 (?i gnus-tmp-info ?s)
8793 (?d gnus-tmp-details ?s)
8794 (?D gnus-tmp-pressed-details ?s)))
8796 (defvar gnus-mime-security-button-commands
8797 '((gnus-article-press-button "\r" "Show Detail")
8801 (gnus-mime-security-save-part "o" "Save...")
8810 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8813 (defvar gnus-mime-security-button-map
8814 (let ((map (make-sparse-keymap)))
8815 (define-key map gnus-mouse-2 'gnus-article-push-button)
8816 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8817 (dolist (c gnus-mime-security-button-commands)
8818 (define-key map (cadr c) (car c)))
8822 gnus-mime-security-button-menu gnus-mime-security-button-map
8823 "Security button menu."
8827 (unless (eq (car c) 'undefined)
8828 (vector (caddr c) (car c) :active t)))
8829 gnus-mime-security-button-commands))))
8831 (defun gnus-mime-security-button-menu (event prefix)
8832 "Construct a context-sensitive menu of security commands."
8833 (interactive "e\nP")
8834 (save-window-excursion
8835 (let ((pos (event-start event)))
8836 (select-window (posn-window pos))
8837 (goto-char (posn-point pos))
8838 (gnus-article-check-buffer)
8839 (popup-menu gnus-mime-security-button-menu nil prefix))))
8841 (defvar gnus-mime-security-details-buffer nil)
8843 (defvar gnus-mime-security-button-pressed nil)
8845 (defvar gnus-mime-security-show-details-inline t
8846 "If non-nil, show details in the article buffer.")
8848 (defun gnus-mime-security-verify-or-decrypt (handle)
8849 (mm-remove-parts (cdr handle))
8850 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8851 point (inhibit-read-only t))
8853 (goto-char (car region)))
8854 (setq point (point))
8855 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8856 (let* ((mm-verify-option 'known)
8857 (mm-decrypt-option 'known)
8858 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8859 (unless (eq nparts (cdr handle))
8860 (mm-destroy-parts (cdr handle))
8861 (setcdr handle nparts))))
8862 (gnus-mime-display-security handle)
8864 (delete-region (point) (cdr region))
8865 (set-marker (car region) nil)
8866 (set-marker (cdr region) nil))
8869 (defun gnus-mime-security-show-details (handle)
8870 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8872 (gnus-message 5 "No details.")
8873 (if gnus-mime-security-show-details-inline
8874 (let ((gnus-mime-security-button-pressed
8875 (not (get-text-property (point) 'gnus-mime-details)))
8876 (gnus-mime-security-button-line-format
8877 (get-text-property (point) 'gnus-line-format))
8878 (inhibit-read-only t))
8880 (while (eq (get-text-property (point) 'gnus-line-format)
8881 gnus-mime-security-button-line-format)
8885 (narrow-to-region (point) (point))
8886 (gnus-insert-mime-security-button handle))
8887 (delete-region (point)
8888 (or (text-property-not-all
8891 gnus-mime-security-button-line-format)
8894 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8895 (with-current-buffer gnus-mime-security-details-buffer
8898 (setq gnus-mime-security-details-buffer
8899 (gnus-get-buffer-create "*MIME Security Details*")))
8900 (with-current-buffer gnus-mime-security-details-buffer
8902 (goto-char (point-min)))
8903 (pop-to-buffer gnus-mime-security-details-buffer)))))
8905 (defun gnus-mime-security-press-button (handle)
8907 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8908 (gnus-mime-security-show-details handle)
8909 (gnus-mime-security-verify-or-decrypt handle))))
8911 (defun gnus-insert-mime-security-button (handle &optional _displayed)
8912 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8915 (or (nth 2 (assoc protocol mm-verify-function-alist))
8916 (nth 2 (assoc protocol mm-decrypt-function-alist))
8918 (if (equal (car handle) "multipart/signed")
8919 " Signed" " Encrypted")
8922 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8925 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8926 gnus-tmp-pressed-details
8928 (setq gnus-tmp-details
8929 (if gnus-tmp-details
8930 (concat "\n" gnus-tmp-details)
8932 (setq gnus-tmp-pressed-details
8933 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8938 gnus-mime-security-button-line-format
8939 gnus-mime-security-button-line-format-alist
8940 `(keymap ,gnus-mime-security-button-map
8941 gnus-callback gnus-mime-security-press-button
8942 gnus-line-format ,gnus-mime-security-button-line-format
8943 gnus-mime-details ,gnus-mime-security-button-pressed
8944 article-type annotation
8947 ;; Exclude a newline.
8950 (when gnus-article-button-face
8951 (gnus-overlay-put (gnus-make-overlay b e nil t)
8952 'face gnus-article-button-face))
8953 (widget-convert-button
8956 :action 'gnus-widget-press-button
8957 :button-keymap gnus-mime-security-button-map
8960 ;; Needed to properly clear the message due to a bug in
8961 ;; wid-edit (XEmacs only).
8962 (when (boundp 'help-echo-owns-message)
8963 (setq help-echo-owns-message t))
8965 "%S: show detail; %S: more options"
8966 (aref gnus-mouse-2 0)
8967 (aref gnus-down-mouse-3 0))))))
8969 (defun gnus-mime-display-security (handle)
8971 (narrow-to-region (point) (point))
8972 (unless (gnus-unbuttonized-mime-type-p (car handle))
8973 (gnus-insert-mime-security-button handle))
8974 (gnus-mime-display-part (cadr handle))
8977 (unless (gnus-unbuttonized-mime-type-p (car handle))
8978 (let ((gnus-mime-security-button-line-format
8979 gnus-mime-security-button-end-line-format))
8980 (gnus-insert-mime-security-button handle)))
8981 (mm-set-handle-multipart-parameter
8982 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8983 (goto-char (point-max))))
8985 (defun gnus-mime-security-run-function (function)
8986 "Run FUNCTION with the security part under point."
8987 (gnus-article-check-buffer)
8988 (let ((data (get-text-property (point) 'gnus-data))
8990 (when (and (stringp (car-safe data))
8991 (setq buffer (mm-handle-multipart-original-buffer data))
8992 (setq handle (cadr data)))
8993 (if (bufferp (mm-handle-buffer handle))
8995 (setq handle (cons buffer (copy-sequence (cdr handle))))
8996 (mm-handle-set-undisplayer handle nil))
8997 (setq handle (mm-make-handle
8999 (mm-handle-multipart-ctl-parameter handle 'protocol)
9000 nil nil nil nil nil nil)))
9001 (funcall function handle))))
9003 (defun gnus-mime-security-save-part ()
9004 "Save the security part under point."
9006 (gnus-mime-security-run-function 'mm-save-part))
9008 (defun gnus-mime-security-pipe-part ()
9009 "Pipe the security part under point to a process."
9011 (gnus-mime-security-run-function 'mm-pipe-part))
9017 (run-hooks 'gnus-art-load-hook)
9019 ;;; gnus-art.el ends here