1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2011 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/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (defvar w3m-minor-mode-map)
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
52 (autoload 'ansi-color-apply-on-region "ansi-color")
53 (autoload 'mm-url-insert-file-contents-external "mm-url")
54 (autoload 'mm-extern-cache-contents "mm-extern")
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
159 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
160 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
161 "Envelope-Sender" "Envelope-Recipients"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type '(choice :custom-show nil
168 :group 'gnus-article-hiding)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 (repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 (const :tag "Use gnus-ignored-headers" nil)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group 'gnus-article-saving
512 (defcustom gnus-prompt-before-saving 'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group 'gnus-article-saving
521 :type '(choice (item always)
522 (item :tag "never" nil)
523 (sexp :tag "once" :format "%t\n" :value t)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group 'gnus-article-saving
536 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
537 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
538 "A function to save articles in your favourite format.
539 The function will be called by way of the `gnus-summary-save-article'
540 command, and friends such as `gnus-summary-save-article-rmail'.
542 Gnus provides the following functions:
544 * gnus-summary-save-in-rmail (Rmail format)
545 * gnus-summary-save-in-mail (Unix mail format)
546 * gnus-summary-save-in-folder (MH folder)
547 * gnus-summary-save-in-file (article format)
548 * gnus-summary-save-body-in-file (article body)
549 * gnus-summary-save-in-vm (use VM's folder format)
550 * gnus-summary-write-to-file (article format -- overwrite)
551 * gnus-summary-write-body-to-file (article body -- overwrite)
552 * gnus-summary-save-in-pipe (article format)
554 The symbol of each function may have the following properties:
557 The value non-nil means save decoded articles. This is meaningful
558 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
559 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
560 `gnus-summary-save-in-pipe'.
563 The value specifies an alternative function which appends, not
564 overwrites, articles to a file. This implies that when saving many
565 articles at a time, `gnus-prompt-before-saving' is bound to t and all
566 articles are saved in a single file. This is meaningful only with
567 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
570 The value specifies the symbol of a variable of which the value
571 specifies headers to be saved. If it is omitted,
572 `gnus-save-all-headers' and `gnus-saved-headers' control what
573 headers should be saved."
574 :group 'gnus-article-saving
575 :type '(radio (function-item gnus-summary-save-in-rmail)
576 (function-item gnus-summary-save-in-mail)
577 (function-item gnus-summary-save-in-folder)
578 (function-item gnus-summary-save-in-file)
579 (function-item gnus-summary-save-body-in-file)
580 (function-item gnus-summary-save-in-vm)
581 (function-item gnus-summary-write-to-file)
582 (function-item gnus-summary-write-body-to-file)
583 (function-item gnus-summary-save-in-pipe)
586 (defcustom gnus-article-save-coding-system
587 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
588 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
589 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
590 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
591 "Coding system used to save decoded articles to a file.
593 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
594 which can safely encode any characters in text. This is used by the
597 * gnus-summary-save-article-file
598 * gnus-summary-save-article-body-file
599 * gnus-summary-write-article-file
600 * gnus-summary-write-article-body-file
602 and the functions to which you may set `gnus-default-article-saver':
604 * gnus-summary-save-in-file
605 * gnus-summary-save-body-in-file
606 * gnus-summary-write-to-file
607 * gnus-summary-write-body-to-file
609 Those commands and functions save just text displayed in the article
610 buffer to a file if the value of this variable is non-nil. Note that
611 buttonized MIME parts will be lost in a saved file in that case.
612 Otherwise, raw articles will be saved."
613 :group 'gnus-article-saving
615 :format "%{%t%}:\n %[Value Menu%] %v"
616 (const :tag "Save raw articles" nil)
619 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
620 '((const :tag "UTF-8" utf-8)
621 (const :tag "iso-2022-7bit" iso-2022-7bit)
622 (const :tag "Emacs internal" emacs-mule)
623 (const :tag "escape-quoted" escape-quoted))))
624 (symbol :tag "Coding system")))
626 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
627 "A function generating a file name to save articles in Rmail format.
628 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
629 :group 'gnus-article-saving
632 (defcustom gnus-mail-save-name 'gnus-plain-save-name
633 "A function generating a file name to save articles in Unix mail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group 'gnus-article-saving
638 (defcustom gnus-folder-save-name 'gnus-folder-save-name
639 "A function generating a file name to save articles in MH folder.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
641 :group 'gnus-article-saving
644 (defcustom gnus-file-save-name 'gnus-numeric-save-name
645 "A function generating a file name to save articles in article format.
646 The function is called with NEWSGROUP, HEADERS, and optional
648 :group 'gnus-article-saving
651 (defcustom gnus-split-methods
652 '((gnus-article-archive-name)
653 (gnus-article-nndoc-name))
654 "*Variable used to suggest where articles are to be saved.
655 For instance, if you would like to save articles related to Gnus in
656 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
657 you could set this variable to something like:
659 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
660 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
662 This variable is an alist where the key is the match and the
663 value is a list of possible files to save in if the match is
666 If the match is a string, it is used as a regexp match on the
667 article. If the match is a symbol, that symbol will be funcalled
668 from the buffer of the article to be saved with the newsgroup as the
669 parameter. If it is a list, it will be evaled in the same buffer.
671 If this form or function returns a string, this string will be used as a
672 possible file name; and if it returns a non-nil list, that list will be
673 used as possible file names."
674 :group 'gnus-article-saving
675 :type '(repeat (choice (list :value (fun) function)
676 (cons :value ("" "") regexp (repeat string))
679 (defcustom gnus-page-delimiter "^\^L"
680 "*Regexp describing what to use as article page delimiters.
681 The default value is \"^\^L\", which is a form linefeed at the
682 beginning of a line."
684 :group 'gnus-article-various)
686 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
687 "*The format specification for the article mode line.
688 See `gnus-summary-mode-line-format' for a closer description.
690 The following additional specs are available:
692 %w The article washing status.
693 %m The number of MIME parts in the article."
695 :group 'gnus-article-various)
697 (defcustom gnus-article-mode-hook nil
698 "*A hook for Gnus article mode."
700 :group 'gnus-article-various)
702 (when (featurep 'xemacs)
703 ;; Extracted from gnus-xmas-define in order to preserve user settings
704 (when (fboundp 'turn-off-scroll-in-place)
705 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
706 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
707 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
709 (defcustom gnus-article-menu-hook nil
710 "*Hook run after the creation of the article mode menu."
712 :group 'gnus-article-various)
714 (defcustom gnus-article-prepare-hook nil
715 "*A hook called after an article has been prepared in the article buffer."
717 :group 'gnus-article-various)
719 (defcustom gnus-copy-article-ignored-headers nil
720 "List of headers to be removed when copying an article.
721 Each element is a regular expression."
722 :version "23.1" ;; No Gnus
723 :type '(repeat regexp)
724 :group 'gnus-article-various)
726 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
727 "Gnus 5.10 (Emacs 22.1)")
730 '((t (:weight bold)))
731 "Face used for highlighting a button in the article buffer."
732 :group 'gnus-article-buttons)
734 (defcustom gnus-article-button-face 'gnus-button
735 "Face used for highlighting buttons in the article buffer.
737 An article button is a piece of text that you can activate by pressing
738 `RET' or `mouse-2' above it."
740 :group 'gnus-article-buttons)
742 (defcustom gnus-article-mouse-face 'highlight
743 "Face used for mouse highlighting in the article buffer.
745 Article buttons will be displayed in this face when the cursor is
748 :group 'gnus-article-buttons)
750 (defcustom gnus-signature-face 'gnus-signature
751 "Face used for highlighting a signature in the article buffer.
752 Obsolete; use the face `gnus-signature' for customizations instead."
754 :group 'gnus-article-highlight
755 :group 'gnus-article-signature)
757 (defface gnus-signature
760 "Face used for highlighting a signature in the article buffer."
761 :group 'gnus-article-highlight
762 :group 'gnus-article-signature)
763 ;; backward-compatibility alias
764 (put 'gnus-signature-face 'face-alias 'gnus-signature)
765 (put 'gnus-signature-face 'obsolete-face "22.1")
767 (defface gnus-header-from
770 (:foreground "PaleGreen1"))
773 (:foreground "red3"))
776 "Face used for displaying from headers."
777 :group 'gnus-article-headers
778 :group 'gnus-article-highlight)
779 ;; backward-compatibility alias
780 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
781 (put 'gnus-header-from-face 'obsolete-face "22.1")
783 (defface gnus-header-subject
786 (:foreground "SeaGreen1"))
789 (:foreground "red4"))
791 (:bold t :italic t)))
792 "Face used for displaying subject headers."
793 :group 'gnus-article-headers
794 :group 'gnus-article-highlight)
795 ;; backward-compatibility alias
796 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
797 (put 'gnus-header-subject-face 'obsolete-face "22.1")
799 (defface gnus-header-newsgroups
802 (:foreground "yellow" :italic t))
805 (:foreground "MidnightBlue" :italic t))
808 "Face used for displaying newsgroups headers.
809 In the default setup this face is only used for crossposted
811 :group 'gnus-article-headers
812 :group 'gnus-article-highlight)
813 ;; backward-compatibility alias
814 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
815 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
817 (defface gnus-header-name
820 (:foreground "SpringGreen2"))
823 (:foreground "maroon"))
826 "Face used for displaying header names."
827 :group 'gnus-article-headers
828 :group 'gnus-article-highlight)
829 ;; backward-compatibility alias
830 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
831 (put 'gnus-header-name-face 'obsolete-face "22.1")
833 (defface gnus-header-content
836 (:foreground "SpringGreen1" :italic t))
839 (:foreground "indianred4" :italic t))
841 (:italic t))) "Face used for displaying header content."
842 :group 'gnus-article-headers
843 :group 'gnus-article-highlight)
844 ;; backward-compatibility alias
845 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
846 (put 'gnus-header-content-face 'obsolete-face "22.1")
848 (defcustom gnus-header-face-alist
849 '(("From" nil gnus-header-from)
850 ("Subject" nil gnus-header-subject)
851 ("Newsgroups:.*," nil gnus-header-newsgroups)
852 ("" gnus-header-name gnus-header-content))
853 "*Controls highlighting of article headers.
855 An alist of the form (HEADER NAME CONTENT).
857 HEADER is a regular expression which should match the name of a
858 header and NAME and CONTENT are either face names or nil.
860 The name of each header field will be displayed using the face
861 specified by the first element in the list where HEADER matches
862 the header name and NAME is non-nil. Similarly, the content will
863 be displayed by the first non-nil matching CONTENT face."
864 :group 'gnus-article-headers
865 :group 'gnus-article-highlight
866 :type '(repeat (list (regexp :tag "Header")
868 (item :tag "skip" nil)
869 (face :value default))
870 (choice :tag "Content"
871 (item :tag "skip" nil)
872 (face :value default)))))
874 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
875 '((xface . (:face gnus-x-face)))
876 '((pbm . (:face gnus-x-face))
878 "Alist of image types and properties applied to Face and X-Face images.
881 ;; Specify the altitude of Face images in the From header.
882 \(setq gnus-face-properties-alist
883 '((pbm . (:face gnus-x-face :ascent 80))
884 (png . (:ascent 80))))
886 ;; Show Face images as pressed buttons.
887 \(setq gnus-face-properties-alist
888 '((pbm . (:face gnus-x-face :relief -2))
889 (png . (:relief -2))))
891 See the manual for the valid properties for various image types.
892 Currently, `pbm' is used for X-Face images and `png' is used for Face
893 images in Emacs. Only the `:face' property is effective on the `xface'
894 image type in XEmacs if it is built with the libcompface library."
895 :version "23.1" ;; No Gnus
896 :group 'gnus-article-headers
897 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
899 (defcustom gnus-article-decode-hook
900 '(article-decode-charset article-decode-encoded-words
901 article-decode-group-name article-decode-idna-rhs)
902 "*Hook run to decode charsets in articles."
903 :group 'gnus-article-headers
906 (defcustom gnus-display-mime-function 'gnus-display-mime
907 "Function to display MIME articles."
908 :group 'gnus-article-mime
911 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
912 "Function used to decode headers.")
914 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
915 "Function used to decode addresses.")
917 (defvar gnus-article-dumbquotes-map
937 "Table for MS-to-Latin1 translation.")
939 (defcustom gnus-ignored-mime-types nil
940 "List of MIME types that should be ignored by Gnus."
942 :group 'gnus-article-mime
943 :type '(repeat regexp))
945 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
946 "List of MIME types that should not be given buttons when rendered inline.
947 See also `gnus-buttonized-mime-types' which may override this variable.
948 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
950 :group 'gnus-article-mime
951 :type '(repeat regexp))
953 (defcustom gnus-buttonized-mime-types nil
954 "List of MIME types that should be given buttons when rendered inline.
955 If set, this variable overrides `gnus-unbuttonized-mime-types'.
956 To see e.g. security buttons you could set this to
957 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
958 this list to display radio buttons that allow you to choose one of two
959 media types those mails include. See also `mm-discouraged-alternatives'.
960 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
962 :group 'gnus-article-mime
963 :type '(repeat regexp))
965 (defcustom gnus-inhibit-mime-unbuttonizing nil
966 "If non-nil, all MIME parts get buttons.
967 When nil (the default value), then some MIME parts do not get buttons,
968 as described by the variables `gnus-buttonized-mime-types' and
969 `gnus-unbuttonized-mime-types'."
971 :group 'gnus-article-mime
974 (defcustom gnus-body-boundary-delimiter "_"
975 "String used to delimit header and body.
976 This variable is used by `gnus-article-treat-body-boundary' which can
977 be controlled by `gnus-treat-body-boundary'."
979 :group 'gnus-article-various
980 :type '(choice (item :tag "None" :value nil)
983 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
985 "Defines the location of the faces database.
986 For information on obtaining this database of pretty pictures, please
987 see http://www.cs.indiana.edu/picons/ftp/index.html"
989 :type '(repeat directory)
990 :link '(url-link :tag "download"
991 "http://www.cs.indiana.edu/picons/ftp/index.html")
992 :link '(custom-manual "(gnus)Picons")
995 (defun gnus-picons-installed-p ()
996 "Say whether picons are installed on your machine."
997 (let ((installed nil))
998 (dolist (database gnus-picon-databases)
999 (when (file-exists-p database)
1000 (setq installed t)))
1003 (defcustom gnus-article-mime-part-function nil
1004 "Function called with a MIME handle as the argument.
1005 This is meant for people who want to do something automatic based
1006 on parts -- for instance, adding Vcard info to a database."
1007 :group 'gnus-article-mime
1008 :type '(choice (const nil)
1011 (defcustom gnus-mime-multipart-functions nil
1012 "An alist of MIME types to functions to display them."
1014 :group 'gnus-article-mime
1015 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1017 (defcustom gnus-article-date-lapsed-new-header nil
1018 "Whether the X-Sent and Date headers can coexist.
1019 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1020 either replace the old \"Date:\" header (if this variable is nil), or
1021 be added below it (otherwise)."
1023 :group 'gnus-article-headers
1026 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1027 "Function called with a MIME handle as the argument.
1028 This is meant for people who want to view first matched part.
1029 For `undisplayed-alternative' (default), the first undisplayed
1030 part or alternative part is used. For `undisplayed', the first
1031 undisplayed part is used. For a function, the first part which
1032 the function return t is used. For nil, the first part is
1035 :group 'gnus-article-mime
1037 (item :tag "first" :value nil)
1038 (item :tag "undisplayed" :value undisplayed)
1039 (item :tag "undisplayed or alternative"
1040 :value undisplayed-alternative)
1043 (defcustom gnus-mime-action-alist
1044 '(("save to file" . gnus-mime-save-part)
1045 ("save and strip" . gnus-mime-save-part-and-strip)
1046 ("replace with file" . gnus-mime-replace-part)
1047 ("delete part" . gnus-mime-delete-part)
1048 ("display as text" . gnus-mime-inline-part)
1049 ("view the part" . gnus-mime-view-part)
1050 ("pipe to command" . gnus-mime-pipe-part)
1051 ("toggle display" . gnus-article-press-button)
1052 ("toggle display" . gnus-article-view-part-as-charset)
1053 ("view as type" . gnus-mime-view-part-as-type)
1054 ("view internally" . gnus-mime-view-part-internally)
1055 ("view externally" . gnus-mime-view-part-externally))
1056 "An alist of actions that run on the MIME attachment."
1057 :group 'gnus-article-mime
1058 :type '(repeat (cons (string :tag "name")
1061 (defcustom gnus-auto-select-part 1
1062 "Advance to next MIME part when deleting or stripping parts.
1064 When 0, point will be placed on the same part as before. When
1065 positive (negative), move point forward (backwards) this many
1066 parts. When nil, redisplay article."
1067 :version "23.1" ;; No Gnus
1068 :group 'gnus-article-mime
1069 :type '(choice (const nil :tag "Redisplay article.")
1070 (const 1 :tag "Next part.")
1071 (const 0 :tag "Current part.")
1075 ;;; The treatment variables
1078 (defvar gnus-part-display-hook nil
1079 "Hook called on parts that are to receive treatment.")
1081 (defvar gnus-article-treat-custom
1082 '(choice (const :tag "Off" nil)
1084 (const :tag "Header" head)
1085 (const :tag "First" first)
1086 (const :tag "Last" last)
1087 (integer :tag "Less")
1088 (repeat :tag "Groups" regexp)
1089 (sexp :tag "Predicate")))
1091 (defvar gnus-article-treat-head-custom
1092 '(choice (const :tag "Off" nil)
1093 (const :tag "Header" head)))
1095 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1099 (defvar gnus-inhibit-treatment nil
1100 "Whether to inhibit treatment.")
1102 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1103 "Highlight the signature.
1104 Valid values are nil, t, `head', `first', `last', an integer or a
1105 predicate. See Info node `(gnus)Customizing Articles'."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1109 (put 'gnus-treat-highlight-signature 'highlight t)
1111 (defcustom gnus-treat-buttonize 100000
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1118 (put 'gnus-treat-buttonize 'highlight t)
1120 (defcustom gnus-treat-buttonize-head 'head
1121 "Add buttons to the head.
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-head-custom)
1127 (put 'gnus-treat-buttonize-head 'highlight t)
1129 (defcustom gnus-treat-emphasize 50000
1131 Valid values are nil, t, `head', `first', `last', an integer or a
1132 predicate. See Info node `(gnus)Customizing Articles'."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-custom)
1136 (put 'gnus-treat-emphasize 'highlight t)
1138 (defcustom gnus-treat-strip-cr nil
1139 "Remove carriage returns.
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (defcustom gnus-treat-unsplit-urls nil
1148 "Remove newlines from within URLs.
1149 Valid values are nil, t, `head', `first', `last', an integer or a
1150 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-leading-whitespace nil
1157 "Remove leading whitespace in headers.
1158 Valid values are nil, t, `head', `first', `last', an integer or a
1159 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-hide-headers 'head
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-head-custom)
1173 (defcustom gnus-treat-hide-boring-headers nil
1174 "Hide boring headers.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-head-custom)
1181 (defcustom gnus-treat-hide-signature nil
1182 "Hide the signature.
1183 Valid values are nil, t, `head', `first', `last', an integer or a
1184 predicate. See Info node `(gnus)Customizing Articles'."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-fill-article nil
1191 Valid values are nil, t, `head', `first', `last', an integer or a
1192 predicate. See Info node `(gnus)Customizing Articles'."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1197 (defcustom gnus-treat-hide-citation nil
1199 Valid values are nil, t, `head', `first', `last', an integer or a
1200 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1205 (defcustom gnus-treat-hide-citation-maybe nil
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-custom)
1213 (defcustom gnus-treat-strip-list-identifiers 'head
1214 "Strip list identifiers from `gnus-list-identifiers`.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom)
1222 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1223 "Gnus 5.10 (Emacs 22.1)")
1225 (defcustom gnus-treat-strip-pem nil
1226 "Strip PEM signatures.
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-strip-banner t
1234 "Strip banners from articles.
1235 The banner to be stripped is specified in the `banner' group parameter.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-highlight-headers 'head
1243 "Highlight the headers.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-head-custom)
1249 (put 'gnus-treat-highlight-headers 'highlight t)
1251 (defcustom gnus-treat-highlight-citation t
1252 "Highlight cited text.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1258 (put 'gnus-treat-highlight-citation 'highlight t)
1260 (defcustom gnus-treat-date-ut nil
1261 "Display the Date in UT (GMT).
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-head-custom)
1268 (defcustom gnus-treat-date-local nil
1269 "Display the Date in the local timezone.
1270 Valid values are nil, t, `head', `first', `last', an integer or a
1271 predicate. See Info node `(gnus)Customizing Articles'."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-head-custom)
1276 (defcustom gnus-treat-date-english nil
1277 "Display the Date in a format that can be read aloud in English.
1278 Valid values are nil, t, `head', `first', `last', an integer or a
1279 predicate. See Info node `(gnus)Customizing Articles'."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-head-custom)
1285 (defcustom gnus-treat-date-lapsed nil
1286 "Display the Date header in a way that says how much time has elapsed.
1287 Valid values are nil, t, `head', `first', `last', an integer or a
1288 predicate. See Info node `(gnus)Customizing Articles'."
1289 :group 'gnus-article-treat
1290 :link '(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-head-custom)
1293 (defcustom gnus-treat-date-original nil
1294 "Display the date in the original timezone.
1295 Valid values are nil, t, `head', `first', `last', an integer or a
1296 predicate. See Info node `(gnus)Customizing Articles'."
1297 :group 'gnus-article-treat
1298 :link '(custom-manual "(gnus)Customizing Articles")
1299 :type gnus-article-treat-head-custom)
1301 (defcustom gnus-treat-date-iso8601 nil
1302 "Display the date in the ISO8601 format.
1303 Valid values are nil, t, `head', `first', `last', an integer or a
1304 predicate. See Info node `(gnus)Customizing Articles'."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom)
1310 (defcustom gnus-treat-date-user-defined nil
1311 "Display the date in a user-defined format.
1312 The format is defined by the `gnus-article-time-format' variable.
1313 Valid values are nil, t, `head', `first', `last', an integer or a
1314 predicate. See Info node `(gnus)Customizing Articles'."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-head-custom)
1319 (defcustom gnus-treat-strip-headers-in-body t
1320 "Strip the X-No-Archive header line from the beginning of the body.
1321 Valid values are nil, t, `head', `first', `last', an integer or a
1322 predicate. See Info node `(gnus)Customizing Articles'."
1324 :group 'gnus-article-treat
1325 :link '(custom-manual "(gnus)Customizing Articles")
1326 :type gnus-article-treat-custom)
1328 (defcustom gnus-treat-strip-trailing-blank-lines nil
1329 "Strip trailing blank lines.
1330 Valid values are nil, t, `head', `first', `last', an integer or a
1331 predicate. See Info node `(gnus)Customizing Articles'.
1333 When set to t, it also strips trailing blanks in all MIME parts.
1334 Consider to use `last' instead."
1335 :group 'gnus-article-treat
1336 :link '(custom-manual "(gnus)Customizing Articles")
1337 :type gnus-article-treat-custom)
1339 (defcustom gnus-treat-strip-leading-blank-lines nil
1340 "Strip leading blank lines.
1341 Valid values are nil, t, `head', `first', `last', an integer or a
1342 predicate. See Info node `(gnus)Customizing Articles'.
1344 When set to t, it also strips trailing blanks in all MIME parts."
1345 :group 'gnus-article-treat
1346 :link '(custom-manual "(gnus)Customizing Articles")
1347 :type gnus-article-treat-custom)
1349 (defcustom gnus-treat-strip-multiple-blank-lines nil
1350 "Strip multiple blank lines.
1351 Valid values are nil, t, `head', `first', `last', an integer or a
1352 predicate. See Info node `(gnus)Customizing Articles'."
1353 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-custom)
1357 (defcustom gnus-treat-unfold-headers 'head
1358 "Unfold folded header lines.
1359 Valid values are nil, t, `head', `first', `last', an integer or a
1360 predicate. See Info node `(gnus)Customizing Articles'."
1362 :group 'gnus-article-treat
1363 :link '(custom-manual "(gnus)Customizing Articles")
1364 :type gnus-article-treat-custom)
1366 (defcustom gnus-article-unfold-long-headers nil
1367 "If non-nil, allow unfolding headers even if the header is long.
1368 If it is a regexp, only long headers matching this regexp are unfolded.
1369 If it is t, all long headers are unfolded.
1371 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1372 :version "23.1" ;; No Gnus
1373 :group 'gnus-article-treat
1374 :type '(choice (const nil)
1375 (const :tag "all" t)
1378 (defcustom gnus-treat-fold-headers nil
1380 Valid values are nil, t, `head', `first', `last', an integer or a
1381 predicate. See Info node `(gnus)Customizing Articles'."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-fold-newsgroups 'head
1388 "Fold the Newsgroups and Followup-To headers.
1389 Valid values are nil, t, `head', `first', `last', an integer or a
1390 predicate. See Info node `(gnus)Customizing Articles'."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-overstrike t
1397 "Treat overstrike highlighting.
1398 Valid values are nil, t, `head', `first', `last', an integer or a
1399 predicate. See Info node `(gnus)Customizing Articles'."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1403 (put 'gnus-treat-overstrike 'highlight t)
1405 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1406 "Treat ANSI SGR control sequences.
1407 Valid values are nil, t, `head', `first', `last', an integer or a
1408 predicate. See Info node `(gnus)Customizing Articles'."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (make-obsolete-variable 'gnus-treat-display-xface
1414 'gnus-treat-display-x-face "Emacs 22.1")
1416 (defcustom gnus-treat-display-x-face
1417 (and (not noninteractive)
1418 (gnus-image-type-available-p 'xbm)
1419 (if (featurep 'xemacs)
1422 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1423 (executable-find "icontopbm"))
1424 ;; shell-command-to-string may signal an error, e.g. if
1425 ;; shell-file-name is not found.
1428 "Display X-Face headers.
1429 Valid values are nil and `head'.
1430 See Info node `(gnus)Customizing Articles' and Info node
1431 `(gnus)X-Face' for details."
1432 :group 'gnus-article-treat
1434 :link '(custom-manual "(gnus)Customizing Articles")
1435 :link '(custom-manual "(gnus)X-Face")
1436 :type gnus-article-treat-head-custom
1437 :set (lambda (symbol value)
1440 (cond ((or (boundp symbol) (get symbol 'saved-value))
1442 ((boundp 'gnus-treat-display-xface)
1444 ** gnus-treat-display-xface is an obsolete variable;\
1445 use gnus-treat-display-x-face instead")
1446 (default-value 'gnus-treat-display-xface))
1447 ((get 'gnus-treat-display-xface 'saved-value)
1449 ** gnus-treat-display-xface is an obsolete variable;\
1450 use gnus-treat-display-x-face instead")
1451 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1454 (put 'gnus-treat-display-x-face 'highlight t)
1456 (defcustom gnus-treat-display-face
1457 (and (not noninteractive)
1458 (gnus-image-type-available-p 'png)
1460 "Display Face headers.
1461 Valid values are nil, t, `head', `first', `last', an integer or a
1462 predicate. See Info node `(gnus)Customizing Articles' and Info
1463 node `(gnus)Face' for details."
1464 :group 'gnus-article-treat
1466 :link '(custom-manual "(gnus)Customizing Articles")
1467 :link '(custom-manual "(gnus)X-Face")
1468 :type gnus-article-treat-head-custom)
1469 (put 'gnus-treat-display-face 'highlight t)
1471 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1473 Valid values are nil, t, `head', `first', `last', an integer or a
1474 predicate. See Info node `(gnus)Customizing Articles' and Info
1475 node `(gnus)Smileys' for details."
1476 :group 'gnus-article-treat
1478 :link '(custom-manual "(gnus)Customizing Articles")
1479 :link '(custom-manual "(gnus)Smileys")
1480 :type gnus-article-treat-custom)
1481 (put 'gnus-treat-display-smileys 'highlight t)
1483 (defcustom gnus-treat-from-picon
1484 (if (and (gnus-image-type-available-p 'xpm)
1485 (gnus-picons-installed-p))
1487 "Display picons in the From header.
1488 Valid values are nil, t, `head', `first', `last', an integer or a
1489 predicate. See Info node `(gnus)Customizing Articles' and Info
1490 node `(gnus)Picons' for details."
1492 :group 'gnus-article-treat
1494 :link '(custom-manual "(gnus)Customizing Articles")
1495 :link '(custom-manual "(gnus)Picons")
1496 :type gnus-article-treat-head-custom)
1497 (put 'gnus-treat-from-picon 'highlight t)
1499 (defcustom gnus-treat-mail-picon
1500 (if (and (gnus-image-type-available-p 'xpm)
1501 (gnus-picons-installed-p))
1503 "Display picons in To and Cc headers.
1504 Valid values are nil, t, `head', `first', `last', an integer or a
1505 predicate. See Info node `(gnus)Customizing Articles' and Info
1506 node `(gnus)Picons' for details."
1508 :group 'gnus-article-treat
1510 :link '(custom-manual "(gnus)Customizing Articles")
1511 :link '(custom-manual "(gnus)Picons")
1512 :type gnus-article-treat-head-custom)
1513 (put 'gnus-treat-mail-picon 'highlight t)
1515 (defcustom gnus-treat-newsgroups-picon
1516 (if (and (gnus-image-type-available-p 'xpm)
1517 (gnus-picons-installed-p))
1519 "Display picons in the Newsgroups and Followup-To headers.
1520 Valid values are nil, t, `head', `first', `last', an integer or a
1521 predicate. See Info node `(gnus)Customizing Articles' and Info
1522 node `(gnus)Picons' for details."
1524 :group 'gnus-article-treat
1526 :link '(custom-manual "(gnus)Customizing Articles")
1527 :link '(custom-manual "(gnus)Picons")
1528 :type gnus-article-treat-head-custom)
1529 (put 'gnus-treat-newsgroups-picon 'highlight t)
1531 (defcustom gnus-treat-from-gravatar nil
1532 "Display gravatars in the From header.
1533 Valid values are nil, t, `head', `first', `last', an integer or a
1534 predicate. See Info node `(gnus)Customizing Articles' and Info
1535 node `(gnus)Gravatars' for details."
1537 :group 'gnus-article-treat
1538 :group 'gnus-gravatar
1539 :link '(custom-manual "(gnus)Customizing Articles")
1540 :link '(custom-manual "(gnus)Gravatars")
1541 :type gnus-article-treat-head-custom)
1542 (put 'gnus-treat-from-gravatar 'highlight t)
1544 (defcustom gnus-treat-mail-gravatar nil
1545 "Display gravatars in To and Cc headers.
1546 Valid values are nil, t, `head', `first', `last', an integer or a
1547 predicate. See Info node `(gnus)Customizing Articles' and Info
1548 node `(gnus)Gravatars' for details."
1550 :group 'gnus-article-treat
1551 :group 'gnus-gravatar
1552 :link '(custom-manual "(gnus)Customizing Articles")
1553 :link '(custom-manual "(gnus)Gravatars")
1554 :type gnus-article-treat-head-custom)
1555 (put 'gnus-treat-mail-gravatar 'highlight t)
1557 (defcustom gnus-treat-body-boundary
1558 (if (or gnus-treat-newsgroups-picon
1559 gnus-treat-mail-picon
1560 gnus-treat-from-picon
1561 gnus-treat-from-gravatar
1562 gnus-treat-mail-gravatar)
1563 ;; If there's much decoration, the user might prefer a boundery.
1566 "Draw a boundary at the end of the headers.
1567 Valid values are nil and `head'.
1568 See Info node `(gnus)Customizing Articles' for details."
1570 :group 'gnus-article-treat
1571 :link '(custom-manual "(gnus)Customizing Articles")
1572 :type gnus-article-treat-head-custom)
1574 (defcustom gnus-treat-capitalize-sentences nil
1575 "Capitalize sentence-starting words.
1576 Valid values are nil, t, `head', `first', `last', an integer or a
1577 predicate. See Info node `(gnus)Customizing Articles'."
1579 :group 'gnus-article-treat
1580 :link '(custom-manual "(gnus)Customizing Articles")
1581 :type gnus-article-treat-custom)
1583 (defcustom gnus-treat-wash-html nil
1585 Valid values are nil, t, `head', `first', `last', an integer or a
1586 predicate. See Info node `(gnus)Customizing Articles'."
1588 :group 'gnus-article-treat
1589 :link '(custom-manual "(gnus)Customizing Articles")
1590 :type gnus-article-treat-custom)
1592 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1594 Valid values are nil, t, `head', `first', `last', an integer or a
1595 predicate. See Info node `(gnus)Customizing Articles'."
1597 :group 'gnus-article-treat
1598 :link '(custom-manual "(gnus)Customizing Articles")
1599 :type gnus-article-treat-custom)
1601 (defcustom gnus-treat-x-pgp-sig nil
1603 To automatically treat X-PGP-Sig, set it to head.
1604 Valid values are nil, t, `head', `first', `last', an integer or a
1605 predicate. See Info node `(gnus)Customizing Articles'."
1607 :group 'gnus-article-treat
1608 :group 'mime-security
1609 :link '(custom-manual "(gnus)Customizing Articles")
1610 :type gnus-article-treat-custom)
1612 (defvar gnus-article-encrypt-protocol-alist
1613 '(("PGP" . mml2015-self-encrypt)))
1615 ;; Set to nil if more than one protocol added to
1616 ;; gnus-article-encrypt-protocol-alist.
1617 (defcustom gnus-article-encrypt-protocol "PGP"
1618 "The protocol used for encrypt articles.
1619 It is a string, such as \"PGP\". If nil, ask user."
1622 :group 'mime-security)
1624 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1625 (mm-coding-system-p 'utf-8)
1626 (executable-find idna-program))
1627 "Whether IDNA decoding of headers is used when viewing messages.
1628 This requires GNU Libidn, and by default only enabled if it is found."
1630 :group 'gnus-article-headers
1633 (defcustom gnus-article-over-scroll nil
1634 "If non-nil, allow scrolling the article buffer even when there no more text."
1636 :group 'gnus-article
1639 (defcustom gnus-inhibit-images nil
1640 "Non-nil means inhibit displaying of images inline in the article body."
1642 :group 'gnus-article
1645 (defcustom gnus-blocked-images 'gnus-block-private-groups
1646 "Images that have URLs matching this regexp will be blocked.
1647 This can also be a function to be evaluated. If so, it will be
1648 called with the group name as the parameter, and should return a
1654 ;;; Internal variables
1656 (defvar gnus-english-month-names
1657 '("January" "February" "March" "April" "May" "June" "July" "August"
1658 "September" "October" "November" "December"))
1660 (defvar article-goto-body-goes-to-point-min-p nil)
1661 (defvar gnus-article-wash-types nil)
1662 (defvar gnus-article-emphasis-alist nil)
1663 (defvar gnus-article-image-alist nil)
1665 (defvar gnus-article-mime-handle-alist-1 nil)
1666 (defvar gnus-treatment-function-alist
1667 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1668 (gnus-treat-strip-banner gnus-article-strip-banner)
1669 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1670 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1671 (gnus-treat-buttonize gnus-article-add-buttons)
1672 (gnus-treat-fill-article gnus-article-fill-cited-article)
1673 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1674 (gnus-treat-strip-cr gnus-article-remove-cr)
1675 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1676 (gnus-treat-date-ut gnus-article-date-ut)
1677 (gnus-treat-date-local gnus-article-date-local)
1678 (gnus-treat-date-english gnus-article-date-english)
1679 (gnus-treat-date-original gnus-article-date-original)
1680 (gnus-treat-date-user-defined gnus-article-date-user)
1681 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1682 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1683 (gnus-treat-display-x-face gnus-article-display-x-face)
1684 (gnus-treat-display-face gnus-article-display-face)
1685 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1686 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1687 (gnus-treat-hide-signature gnus-article-hide-signature)
1688 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1689 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1690 (gnus-treat-from-picon gnus-treat-from-picon)
1691 (gnus-treat-mail-picon gnus-treat-mail-picon)
1692 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1693 (gnus-treat-strip-pem gnus-article-hide-pem)
1694 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1695 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1696 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1697 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1698 (gnus-treat-strip-trailing-blank-lines
1699 gnus-article-remove-trailing-blank-lines)
1700 (gnus-treat-strip-leading-blank-lines
1701 gnus-article-strip-leading-blank-lines)
1702 (gnus-treat-strip-multiple-blank-lines
1703 gnus-article-strip-multiple-blank-lines)
1704 (gnus-treat-overstrike gnus-article-treat-overstrike)
1705 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1706 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1707 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1708 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1709 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1710 (gnus-treat-display-smileys gnus-treat-smiley)
1711 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1712 (gnus-treat-wash-html gnus-article-wash-html)
1713 (gnus-treat-emphasize gnus-article-emphasize)
1714 (gnus-treat-hide-citation gnus-article-hide-citation)
1715 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1716 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1717 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1719 (defvar gnus-article-mime-handle-alist nil)
1720 (defvar article-lapsed-timer nil)
1721 (defvar gnus-article-current-summary nil)
1723 (defvar gnus-article-mode-syntax-table
1724 (let ((table (copy-syntax-table text-mode-syntax-table)))
1725 ;; This causes the citation match run O(2^n).
1726 ;; (modify-syntax-entry ?- "w" table)
1727 (modify-syntax-entry ?> ")<" table)
1728 (modify-syntax-entry ?< "(>" table)
1729 ;; make M-. in article buffers work for `foo' strings
1730 (modify-syntax-entry ?' " " table)
1731 (modify-syntax-entry ?` " " table)
1733 "Syntax table used in article mode buffers.
1734 Initialized from `text-mode-syntax-table.")
1736 (defvar gnus-save-article-buffer nil)
1738 (defvar gnus-number-of-articles-to-be-saved nil)
1740 (defvar gnus-inhibit-hiding nil)
1742 (defvar gnus-article-edit-mode nil)
1744 ;;; Macros for dealing with the article buffer.
1746 (defmacro gnus-with-article-headers (&rest forms)
1747 `(with-current-buffer gnus-article-buffer
1749 (let ((inhibit-read-only t)
1750 (inhibit-point-motion-hooks t)
1751 (case-fold-search t))
1752 (article-narrow-to-head)
1755 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1756 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1758 (defmacro gnus-with-article-buffer (&rest forms)
1759 `(with-current-buffer gnus-article-buffer
1760 (let ((inhibit-read-only t))
1763 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1764 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1766 (defun gnus-article-goto-header (header)
1767 "Go to HEADER, which is a regular expression."
1768 (re-search-forward (concat "^\\(" header "\\):") nil t))
1770 (defsubst gnus-article-hide-text (b e props)
1771 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1772 (gnus-add-text-properties-when 'article-type nil b e props)
1773 (when (memq 'intangible props)
1775 (max (1- b) (point-min))
1776 b 'intangible (cddr (memq 'intangible props)))))
1778 (defsubst gnus-article-unhide-text (b e)
1779 "Remove hidden text properties from region between B and E."
1780 (remove-text-properties b e gnus-hidden-properties)
1781 (when (memq 'intangible gnus-hidden-properties)
1782 (put-text-property (max (1- b) (point-min))
1783 b 'intangible nil)))
1785 (defun gnus-article-hide-text-type (b e type)
1786 "Hide text of TYPE between B and E."
1787 (gnus-add-wash-type type)
1788 (gnus-article-hide-text
1789 b e (cons 'article-type (cons type gnus-hidden-properties))))
1791 (defun gnus-article-unhide-text-type (b e type)
1792 "Unhide text of TYPE between B and E."
1793 (gnus-delete-wash-type type)
1794 (remove-text-properties
1795 b e (cons 'article-type (cons type gnus-hidden-properties)))
1796 (when (memq 'intangible gnus-hidden-properties)
1797 (put-text-property (max (1- b) (point-min))
1798 b 'intangible nil)))
1800 (defun gnus-article-hide-text-of-type (type)
1801 "Hide text of TYPE in the current buffer."
1803 (let ((b (point-min))
1805 (while (setq b (text-property-any b e 'article-type type))
1806 (add-text-properties b (incf b) gnus-hidden-properties)))))
1808 (defun gnus-article-delete-text-of-type (type)
1809 "Delete text of TYPE in the current buffer."
1811 (let ((b (point-min)))
1812 (if (eq type 'multipart)
1813 ;; Remove MIME buttons associated with multipart/alternative parts.
1816 (while (if (get-text-property (point) 'gnus-part)
1818 (when (setq b (next-single-property-change (point)
1823 (skip-chars-forward "\n")
1824 (when (eq (get-text-property b 'article-type) 'multipart)
1825 (delete-region b (point)))))
1826 (while (setq b (text-property-any b (point-max) 'article-type type))
1828 b (or (text-property-not-all b (point-max) 'article-type type)
1831 (defun gnus-article-delete-invisible-text ()
1832 "Delete all invisible text in the current buffer."
1834 (let ((b (point-min)))
1835 (while (setq b (text-property-any b (point-max) 'invisible t))
1837 b (or (text-property-not-all b (point-max) 'invisible t)
1840 (defun gnus-article-text-type-exists-p (type)
1841 "Say whether any text of type TYPE exists in the buffer."
1842 (text-property-any (point-min) (point-max) 'article-type type))
1844 (defsubst gnus-article-header-rank ()
1845 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1846 (let ((list gnus-sorted-header-list)
1849 (if (looking-at (car list))
1851 (setq list (cdr list))
1855 (defun article-hide-headers (&optional arg delete)
1856 "Hide unwanted headers and possibly sort them as well."
1858 ;; This function might be inhibited.
1859 (unless gnus-inhibit-hiding
1860 (let ((inhibit-read-only t)
1861 (case-fold-search t)
1862 (max (1+ (length gnus-sorted-header-list)))
1863 (inhibit-point-motion-hooks t)
1864 (cur (current-buffer))
1865 ignored visible beg)
1867 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1868 ;; group parameters, so we should go to the summary buffer.
1871 (progn (set-buffer gnus-summary-buffer) t)
1873 (setq ignored (when (not gnus-visible-headers)
1874 (cond ((stringp gnus-ignored-headers)
1875 gnus-ignored-headers)
1876 ((listp gnus-ignored-headers)
1877 (mapconcat 'identity
1878 gnus-ignored-headers
1880 visible (cond ((stringp gnus-visible-headers)
1881 gnus-visible-headers)
1882 ((and gnus-visible-headers
1883 (listp gnus-visible-headers))
1884 (mapconcat 'identity
1885 gnus-visible-headers
1889 ;; First we narrow to just the headers.
1890 (article-narrow-to-head)
1891 ;; Hide any "From " lines at the beginning of (mail) articles.
1892 (while (looking-at "From ")
1895 (delete-region (point-min) (point)))
1896 ;; Then treat the rest of the header lines.
1897 ;; Then we use the two regular expressions
1898 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1899 ;; select which header lines is to remain visible in the
1901 (while (re-search-forward "^[^ \t:]*:" nil t)
1903 ;; Mark the rank of the header.
1905 (point) (1+ (point)) 'message-rank
1906 (if (or (and visible (looking-at visible))
1908 (not (looking-at ignored))))
1909 (gnus-article-header-rank)
1912 (message-sort-headers-1)
1913 (when (setq beg (text-property-any
1914 (point-min) (point-max) 'message-rank (+ 2 max)))
1915 ;; We delete the unwanted headers.
1916 (gnus-add-wash-type 'headers)
1917 (add-text-properties (point-min) (+ 5 (point-min))
1918 '(article-type headers dummy-invisible t))
1919 (delete-region beg (point-max))))))))
1921 (defun article-hide-boring-headers (&optional arg)
1922 "Toggle hiding of headers that aren't very interesting.
1923 If given a negative prefix, always show; if given a positive prefix,
1925 (interactive (gnus-article-hidden-arg))
1926 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1927 (not gnus-show-all-headers))
1930 (let ((inhibit-read-only t)
1931 (inhibit-point-motion-hooks t))
1932 (article-narrow-to-head)
1933 (dolist (elem gnus-boring-article-headers)
1934 (goto-char (point-min))
1936 ;; Hide empty headers.
1938 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1940 (gnus-article-hide-text-type
1944 (if (re-search-forward "^[^ \t]" nil t)
1948 ;; Hide boring Newsgroups header.
1949 ((eq elem 'newsgroups)
1950 (when (gnus-string-equal
1951 (gnus-fetch-field "newsgroups")
1952 (gnus-group-real-name
1953 (if (boundp 'gnus-newsgroup-name)
1956 (gnus-article-hide-header "newsgroups")))
1957 ((eq elem 'to-address)
1958 (let ((to (message-fetch-field "to"))
1960 (gnus-parameter-to-address
1961 (if (boundp 'gnus-newsgroup-name)
1962 gnus-newsgroup-name ""))))
1963 (when (and to to-address
1966 ;; only one address in To
1967 (nth 1 (mail-extract-address-components to))
1969 (gnus-article-hide-header "to"))))
1971 (let ((to (message-fetch-field "to"))
1973 (gnus-parameter-to-list
1974 (if (boundp 'gnus-newsgroup-name)
1975 gnus-newsgroup-name ""))))
1976 (when (and to to-list
1979 ;; only one address in To
1980 (nth 1 (mail-extract-address-components to))
1982 (gnus-article-hide-header "to"))))
1984 (let ((cc (message-fetch-field "cc"))
1986 (gnus-parameter-to-list
1987 (if (boundp 'gnus-newsgroup-name)
1988 gnus-newsgroup-name ""))))
1989 (when (and cc to-list
1992 ;; only one address in CC
1993 (nth 1 (mail-extract-address-components cc))
1995 (gnus-article-hide-header "cc"))))
1996 ((eq elem 'followup-to)
1997 (when (gnus-string-equal
1998 (message-fetch-field "followup-to")
1999 (message-fetch-field "newsgroups"))
2000 (gnus-article-hide-header "followup-to")))
2001 ((eq elem 'reply-to)
2002 (if (gnus-group-find-parameter
2003 gnus-newsgroup-name 'broken-reply-to)
2004 (gnus-article-hide-header "reply-to")
2005 (let ((from (message-fetch-field "from"))
2006 (reply-to (message-fetch-field "reply-to")))
2013 (lambda (x) (downcase (cadr x)))
2014 (mail-extract-address-components from t))
2017 (lambda (x) (downcase (cadr x)))
2018 (mail-extract-address-components reply-to t))
2020 (gnus-article-hide-header "reply-to")))))
2022 (let ((date (with-current-buffer gnus-original-article-buffer
2023 ;; If date in `gnus-article-buffer' is localized
2024 ;; (`gnus-treat-date-user-defined'),
2025 ;; `days-between' might fail.
2026 (message-fetch-field "date"))))
2028 (< (days-between (current-time-string) date)
2030 (gnus-article-hide-header "date"))))
2032 (let ((to (message-fetch-field "to"))
2033 (cc (message-fetch-field "cc")))
2034 (when (> (length to) 1024)
2035 (gnus-article-hide-header "to"))
2036 (when (> (length cc) 1024)
2037 (gnus-article-hide-header "cc"))))
2041 (goto-char (point-min))
2042 (while (re-search-forward "^to:" nil t)
2043 (setq to-count (1+ to-count)))
2044 (when (> to-count 1)
2045 (while (> to-count 0)
2046 (goto-char (point-min))
2048 (re-search-forward "^to:" nil nil to-count)
2050 (narrow-to-region (point) (point-max))
2051 (gnus-article-hide-header "to"))
2052 (setq to-count (1- to-count))))
2053 (goto-char (point-min))
2054 (while (re-search-forward "^cc:" nil t)
2055 (setq cc-count (1+ cc-count)))
2056 (when (> cc-count 1)
2057 (while (> cc-count 0)
2058 (goto-char (point-min))
2060 (re-search-forward "^cc:" nil nil cc-count)
2062 (narrow-to-region (point) (point-max))
2063 (gnus-article-hide-header "cc"))
2064 (setq cc-count (1- cc-count)))))))))))))
2066 (defun gnus-article-hide-header (header)
2068 (goto-char (point-min))
2069 (when (re-search-forward (concat "^" header ":") nil t)
2070 (gnus-article-hide-text-type
2074 (if (re-search-forward "^[^ \t]" nil t)
2079 (defvar gnus-article-normalized-header-length 40
2080 "Length of normalized headers.")
2082 (defun article-normalize-headers ()
2083 "Make all header lines 40 characters long."
2085 (let ((inhibit-read-only t)
2089 (article-narrow-to-head)
2092 ((< (setq column (- (point-at-eol) (point)))
2093 gnus-article-normalized-header-length)
2095 (insert (make-string
2096 (- gnus-article-normalized-header-length column)
2098 ((> column gnus-article-normalized-header-length)
2099 (gnus-put-text-property
2101 (forward-char gnus-article-normalized-header-length)
2108 (forward-line 1))))))
2110 (defun article-treat-dumbquotes ()
2111 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2112 Note that this function guesses whether a character is a sm*rtq**t* or
2113 not, so it should only be used interactively.
2115 Sm*rtq**t*s are M****s***'s unilateral extension to the
2116 iso-8859-1 character map in an attempt to provide more quoting
2117 characters. If you see something like \\222 or \\264 where
2118 you're expecting some kind of apostrophe or quotation mark, then
2121 (article-translate-strings gnus-article-dumbquotes-map))
2123 (defvar org-entities)
2125 (defun article-treat-non-ascii ()
2126 "Translate many Unicode characters into their ASCII equivalents."
2128 (require 'org-entities)
2129 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2130 (dolist (elem org-entities)
2131 (when (and (listp elem)
2132 (= (length (nth 6 elem)) 1))
2133 (if (featurep 'xemacs)
2134 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2135 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2137 (when (article-goto-body)
2138 (let ((inhibit-read-only t)
2141 (if (not (setq replace (if (featurep 'xemacs)
2142 (get-char-table (following-char) table)
2143 (aref table (following-char)))))
2146 (setq props (text-properties-at (point)))
2148 (add-text-properties (point) (progn (insert replace) (point))
2150 (insert replace)))))))))
2152 (defun article-translate-characters (from to)
2153 "Translate all characters in the body of the article according to FROM and TO.
2154 FROM is a string of characters to translate from; to is a string of
2155 characters to translate to."
2157 (when (article-goto-body)
2158 (let ((inhibit-read-only t)
2159 (x (make-string 225 ?x))
2161 (while (< (incf i) (length x))
2164 (while (< i (length from))
2165 (aset x (aref from i) (aref to i))
2167 (translate-region (point) (point-max) x)))))
2169 (defun article-translate-strings (map)
2170 "Translate all string in the body of the article according to MAP.
2171 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2173 (when (article-goto-body)
2174 (let ((inhibit-read-only t))
2176 (let ((from (car elem))
2180 (while (search-forward from nil t)
2183 (if (eq (following-char) from)
2187 (forward-char 1)))))))))))
2189 (defun article-treat-overstrike ()
2190 "Translate overstrikes into bold text."
2193 (when (article-goto-body)
2194 (let ((inhibit-read-only t))
2195 (while (search-forward "\b" nil t)
2196 (let ((next (char-after))
2197 (previous (char-after (- (point) 2))))
2198 ;; We do the boldification/underlining by hiding the
2199 ;; overstrikes and putting the proper text property
2203 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2204 (put-text-property (point) (1+ (point)) 'face 'bold))
2206 (gnus-article-hide-text-type
2207 (1- (point)) (1+ (point)) 'overstrike)
2209 (- (point) 2) (1- (point)) 'face 'underline))
2211 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2213 (point) (1+ (point)) 'face 'underline)))))))))
2215 (defun article-treat-ansi-sequences ()
2216 "Translate ANSI SGR control sequences into overlays or extents."
2219 (when (article-goto-body)
2220 (let ((inhibit-read-only t))
2221 (ansi-color-apply-on-region (point) (point-max))))))
2223 (defun gnus-article-treat-unfold-headers ()
2224 "Unfold folded message headers.
2225 Only the headers that fit into the current window width will be
2228 (gnus-with-article-headers
2232 (mail-header-narrow-to-field)
2233 (let* ((header (buffer-string))
2235 (or (equal gnus-article-unfold-long-headers t)
2236 (and (stringp gnus-article-unfold-long-headers)
2237 (string-match gnus-article-unfold-long-headers header)))))
2240 (goto-char (point-min))
2241 (while (re-search-forward "\n[\t ]" nil t)
2242 (replace-match " " t t)))
2243 (setq length (- (point-max) (point-min) 1))
2244 (when (or unfoldable
2245 (< length (window-width)))
2246 (while (re-search-forward "\n[\t ]" nil t)
2247 (replace-match " " t t))))
2248 (goto-char (point-max)))))))
2250 (defun gnus-article-treat-fold-headers ()
2251 "Fold message headers."
2253 (gnus-with-article-headers
2256 (mail-header-narrow-to-field)
2257 (mail-header-fold-field)
2258 (goto-char (point-max))))))
2260 (defun gnus-treat-smiley ()
2261 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2263 (gnus-with-article-buffer
2264 (if (memq 'smiley gnus-article-wash-types)
2265 (gnus-delete-images 'smiley)
2267 (let ((images (smiley-region (point) (point-max))))
2269 (gnus-add-wash-type 'smiley)
2270 (dolist (image images)
2271 (gnus-add-image 'smiley image)))))))
2273 (defun gnus-article-remove-images ()
2274 "Remove all images from the article buffer."
2276 (gnus-with-article-buffer
2279 (dolist (elem gnus-article-image-alist)
2280 (gnus-delete-images (car elem))))))
2282 (defun gnus-article-show-images ()
2283 "Show any images that are in the HTML-rendered article buffer.
2284 This only works if the article in question is HTML."
2286 (gnus-with-article-buffer
2289 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2291 (destructuring-bind (start end function) region
2292 (funcall function (get-text-property start 'image-url)
2295 (defun gnus-article-treat-fold-newsgroups ()
2296 "Unfold folded message headers.
2297 Only the headers that fit into the current window width will be
2300 (gnus-with-article-headers
2301 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2303 (mail-header-narrow-to-field)
2304 (while (re-search-forward ", *" nil t)
2305 (replace-match ", " t t))
2306 (mail-header-fold-field)
2307 (goto-char (point-max))))))
2309 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2310 "Value of `truncate-lines' in Gnus Article buffer.
2311 Valid values are nil, t, `head', `first', `last', an integer or a
2312 predicate. See Info node `(gnus)Customizing Articles'."
2313 :version "23.1" ;; No Gnus
2314 :group 'gnus-article
2315 ;; :link '(custom-manual "(gnus)Customizing Articles")
2318 (defun gnus-article-toggle-truncate-lines (&optional arg)
2319 "Toggle whether to fold or truncate long lines in article the buffer.
2320 If ARG is non-nil and not a number, toggle
2321 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2322 long lines if and only if arg is positive."
2325 ((and (numberp arg) (> arg 0))
2326 (setq gnus-article-truncate-lines t))
2328 (setq gnus-article-truncate-lines nil))
2330 (setq gnus-article-truncate-lines
2331 (not gnus-article-truncate-lines))))
2332 (gnus-with-article-buffer
2334 ((and (numberp arg) (> arg 0))
2335 (setq truncate-lines nil))
2337 (setq truncate-lines t)))
2338 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2339 ;; `toggle-truncate-lines' needs an argument.
2340 (toggle-truncate-lines)))
2342 (defun gnus-article-treat-body-boundary ()
2343 "Place a boundary line at the end of the headers."
2345 (when (and gnus-body-boundary-delimiter
2346 (> (length gnus-body-boundary-delimiter) 0))
2347 (gnus-with-article-headers
2348 (goto-char (point-max))
2349 (let ((start (point)))
2350 (insert "X-Boundary: ")
2351 (gnus-add-text-properties start (point) '(invisible t intangible t))
2353 (while (>= (window-width) (length str))
2354 (setq str (concat str gnus-body-boundary-delimiter)))
2355 (substring str 0 (window-width)))
2357 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2359 (defun article-fill-long-lines ()
2360 "Fill lines that are wider than the window width."
2363 (let ((inhibit-read-only t)
2364 (width (window-width (get-buffer-window (current-buffer)))))
2367 (let ((adaptive-fill-mode nil)) ;Why? -sm
2370 (when (>= (current-column) (min fill-column width))
2371 (narrow-to-region (min (1+ (point)) (point-max))
2373 (let ((goback (point-marker)))
2374 (fill-paragraph nil)
2375 (goto-char (marker-position goback)))
2377 (forward-line 1)))))))
2379 (defun article-capitalize-sentences ()
2380 "Capitalize the first word in each sentence."
2383 (let ((inhibit-read-only t)
2384 (paragraph-start "^[\n\^L]"))
2388 (forward-sentence)))))
2390 (defun article-remove-cr ()
2391 "Remove trailing CRs and then translate remaining CRs into LFs."
2394 (let ((inhibit-read-only t))
2395 (goto-char (point-min))
2396 (while (re-search-forward "\r+$" nil t)
2397 (replace-match "" t t))
2398 (goto-char (point-min))
2399 (while (search-forward "\r" nil t)
2400 (replace-match "\n" t t)))))
2402 (defun article-remove-trailing-blank-lines ()
2403 "Remove all trailing blank lines from the article."
2406 (let ((inhibit-read-only t))
2407 (goto-char (point-max))
2411 (while (and (not (bobp))
2412 (looking-at "^[ \t]*$")
2413 (not (gnus-annotation-in-region-p
2414 (point) (point-at-eol))))
2419 (defvar gnus-face-properties-alist)
2421 (defun article-display-face (&optional force)
2422 "Display any Face headers in the header."
2423 (interactive (list 'force))
2424 (let ((wash-face-p buffer-read-only))
2425 (gnus-with-article-headers
2426 ;; When displaying parts, this function can be called several times on
2427 ;; the same article, without any intended toggle semantic (as typing `W
2428 ;; D d' would have). So face deletion must occur only when we come from
2429 ;; an interactive command, that is when the *Article* buffer is
2431 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2432 (gnus-delete-images 'face)
2433 (let ((from (message-fetch-field "from"))
2435 (save-current-buffer
2436 (when (and wash-face-p
2437 (gnus-buffer-live-p gnus-original-article-buffer)
2438 (not (re-search-forward "^Face:[\t ]*" nil t)))
2439 (set-buffer gnus-original-article-buffer))
2441 (mail-narrow-to-head)
2443 ;; Check whether this face is censored.
2444 (not (and gnus-article-x-face-too-ugly
2446 (setq from (message-fetch-field "from")))
2447 (string-match gnus-article-x-face-too-ugly
2449 (while (gnus-article-goto-header "Face")
2450 (push (mail-header-field-value) faces)))))
2452 (goto-char (point-min))
2454 (unless (setq from (gnus-article-goto-header "from"))
2457 (insert " [no `from' set]\n"))
2459 (when (setq png (gnus-convert-face-to-png (pop faces)))
2461 (apply 'gnus-create-image png 'png t
2462 (cdr (assq 'png gnus-face-properties-alist))))
2464 (gnus-add-wash-type 'face)
2465 (gnus-add-image 'face image)
2466 (gnus-put-image image nil 'face))))))))))
2468 (defun article-display-x-face (&optional force)
2469 "Look for an X-Face header and display it if present."
2470 (interactive (list 'force))
2471 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2472 (gnus-with-article-headers
2473 ;; Delete the old process, if any.
2474 (when (process-status "article-x-face")
2475 (delete-process "article-x-face"))
2476 ;; See the comment in `article-display-face'.
2477 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2478 ;; We have already displayed X-Faces, so we remove them
2480 (gnus-delete-images 'xface)
2482 (let ((from (message-fetch-field "from"))
2484 (save-current-buffer
2485 (when (and wash-face-p
2486 (gnus-buffer-live-p gnus-original-article-buffer)
2487 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2488 ;; If type `W f', use gnus-original-article-buffer,
2489 ;; otherwise use the current buffer because displaying
2490 ;; RFC822 parts calls this function too.
2491 (set-buffer gnus-original-article-buffer))
2493 (mail-narrow-to-head)
2494 (and gnus-article-x-face-command
2496 ;; Check whether this face is censored.
2497 (not (and gnus-article-x-face-too-ugly
2499 (setq from (message-fetch-field "from")))
2500 (string-match gnus-article-x-face-too-ugly
2502 (while (gnus-article-goto-header "X-Face")
2503 (push (mail-header-field-value) x-faces)))))
2505 ;; We display the face.
2506 (cond ((functionp gnus-article-x-face-command)
2507 ;; The command is a lisp function, so we call it.
2508 (mapc gnus-article-x-face-command x-faces))
2509 ((stringp gnus-article-x-face-command)
2510 ;; The command is a string, so we interpret the command
2511 ;; as a, well, command, and fork it off.
2512 (let ((process-connection-type nil))
2513 (gnus-set-process-query-on-exit-flag
2515 "article-x-face" nil shell-file-name
2516 shell-command-switch gnus-article-x-face-command)
2518 ;; Sending multiple EOFs to xv doesn't work,
2519 ;; so we only do a single external face.
2521 (insert (car x-faces))
2522 (process-send-region "article-x-face"
2523 (point-min) (point-max)))
2524 (process-send-eof "article-x-face")))
2526 (error "`%s' set to `%s' is not a function"
2527 gnus-article-x-face-command
2528 'gnus-article-x-face-command)))))))))
2530 (defun article-decode-mime-words ()
2531 "Decode all MIME-encoded words in the article."
2533 (gnus-with-article-buffer
2534 (let ((inhibit-point-motion-hooks t)
2535 (mail-parse-charset gnus-newsgroup-charset)
2536 (mail-parse-ignored-charsets
2537 (with-current-buffer gnus-summary-buffer
2538 gnus-newsgroup-ignored-charsets)))
2539 (mail-decode-encoded-word-region (point-min) (point-max)))))
2541 (defun article-decode-charset (&optional prompt)
2542 "Decode charset-encoded text in the article.
2543 If PROMPT (the prefix), prompt for a coding system to use."
2545 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2546 (inhibit-read-only t)
2547 (mail-parse-charset gnus-newsgroup-charset)
2548 (mail-parse-ignored-charsets
2549 (save-excursion (condition-case nil
2550 (set-buffer gnus-summary-buffer)
2552 gnus-newsgroup-ignored-charsets))
2553 ct cte ctl charset format)
2556 (article-narrow-to-head)
2557 (setq ct (message-fetch-field "Content-Type" t)
2558 cte (message-fetch-field "Content-Transfer-Encoding" t)
2559 ctl (and ct (mail-header-parse-content-type ct))
2562 (mm-read-coding-system "Charset to decode: "))
2564 (mail-content-type-get ctl 'charset)))
2565 format (and ctl (mail-content-type-get ctl 'format)))
2567 (setq cte (mail-header-strip cte)))
2568 (if (and ctl (not (string-match "/" (car ctl))))
2570 (goto-char (point-max)))
2573 (narrow-to-region (point) (point-max))
2574 (when (and (eq mail-parse-charset 'gnus-decoded)
2575 (eq (mm-body-7-or-8) '8bit))
2576 ;; The text code could have been decoded.
2577 (setq charset mail-parse-charset))
2578 (when (and (or (not ctl)
2579 (equal (car ctl) "text/plain"))
2580 (not format)) ;; article with format will decode later.
2582 charset (and cte (intern (downcase
2583 (gnus-strip-whitespace cte))))
2586 (defun article-decode-encoded-words ()
2587 "Remove encoded-word encoding from headers."
2588 (let ((inhibit-point-motion-hooks t)
2589 (mail-parse-charset gnus-newsgroup-charset)
2590 (mail-parse-ignored-charsets
2591 (save-excursion (condition-case nil
2592 (set-buffer gnus-summary-buffer)
2594 gnus-newsgroup-ignored-charsets))
2595 (inhibit-read-only t)
2597 (goto-char (point-min))
2598 (when (search-forward "\n\n" nil 'move)
2605 (memq (char-after) '(?\t ? )))))
2606 (setq start (point))
2608 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2609 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2610 (funcall gnus-decode-address-function start end)
2611 (funcall gnus-decode-header-function start end))
2612 (goto-char (setq end start)))))
2614 (defun article-decode-group-name ()
2615 "Decode group names in Newsgroups, Followup-To and Xref headers."
2616 (let ((inhibit-point-motion-hooks t)
2617 (inhibit-read-only t)
2618 (method (gnus-find-method-for-group gnus-newsgroup-name))
2620 (when (and (or gnus-group-name-charset-method-alist
2621 gnus-group-name-charset-group-alist)
2622 (gnus-buffer-live-p gnus-original-article-buffer))
2624 (article-narrow-to-head)
2625 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2626 (with-current-buffer gnus-original-article-buffer
2627 (goto-char (point-min)))
2628 (setq regexp (concat "^" header
2629 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2630 (while (re-search-forward regexp nil t)
2631 (replace-match (save-match-data
2632 (gnus-decode-newsgroups
2633 ;; XXX how to use data in article buffer?
2634 (with-current-buffer gnus-original-article-buffer
2635 (re-search-forward regexp nil t)
2637 gnus-newsgroup-name method))
2639 (goto-char (point-min)))))))
2641 (autoload 'idna-to-unicode "idna")
2643 (defun article-decode-idna-rhs ()
2644 "Decode IDNA strings in RHS in various headers in current buffer.
2645 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2646 Mail-Reply-To: and Mail-Followup-To:."
2649 (let ((inhibit-point-motion-hooks t)
2650 (inhibit-read-only t))
2651 (article-narrow-to-head)
2652 (goto-char (point-min))
2653 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2655 (when (save-match-data
2656 (and (setq ace (match-string 1))
2658 (and (re-search-backward "^[^ \t]" nil t)
2659 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2660 (setq unicode (idna-to-unicode ace))))
2661 (unless (string= ace unicode)
2662 (replace-match unicode nil nil nil 1)))))))))
2664 (defun article-de-quoted-unreadable (&optional force read-charset)
2665 "Translate a quoted-printable-encoded article.
2666 If FORCE, decode the article whether it is marked as quoted-printable
2668 If READ-CHARSET, ask for a coding system."
2669 (interactive (list 'force current-prefix-arg))
2671 (let ((inhibit-read-only t) type charset)
2672 (if (gnus-buffer-live-p gnus-original-article-buffer)
2673 (with-current-buffer gnus-original-article-buffer
2675 (gnus-fetch-field "content-transfer-encoding"))
2676 (let* ((ct (gnus-fetch-field "content-type"))
2677 (ctl (and ct (mail-header-parse-content-type ct))))
2678 (setq charset (and ctl
2679 (mail-content-type-get ctl 'charset)))
2680 (if (stringp charset)
2681 (setq charset (intern (downcase charset)))))))
2683 (setq charset (mm-read-coding-system "Charset: " charset)))
2685 (setq charset gnus-newsgroup-charset))
2687 (and type (let ((case-fold-search t))
2688 (string-match "quoted-printable" type))))
2690 (quoted-printable-decode-region
2691 (point) (point-max) (mm-charset-to-coding-system charset))))))
2693 (defun article-de-base64-unreadable (&optional force read-charset)
2694 "Translate a base64 article.
2695 If FORCE, decode the article whether it is marked as base64 not.
2696 If READ-CHARSET, ask for a coding system."
2697 (interactive (list 'force current-prefix-arg))
2699 (let ((inhibit-read-only t) type charset)
2700 (if (gnus-buffer-live-p gnus-original-article-buffer)
2701 (with-current-buffer gnus-original-article-buffer
2703 (gnus-fetch-field "content-transfer-encoding"))
2704 (let* ((ct (gnus-fetch-field "content-type"))
2705 (ctl (and ct (mail-header-parse-content-type ct))))
2706 (setq charset (and ctl
2707 (mail-content-type-get ctl 'charset)))
2708 (if (stringp charset)
2709 (setq charset (intern (downcase charset)))))))
2711 (setq charset (mm-read-coding-system "Charset: " charset)))
2713 (setq charset gnus-newsgroup-charset))
2715 (and type (let ((case-fold-search t))
2716 (string-match "base64" type))))
2719 (narrow-to-region (point) (point-max))
2720 (base64-decode-region (point-min) (point-max))
2721 (mm-decode-coding-region
2722 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2727 (defun article-decode-HZ ()
2728 "Translate a HZ-encoded article."
2732 (let ((inhibit-read-only t))
2733 (rfc1843-decode-region (point-min) (point-max)))))
2735 (defun article-unsplit-urls ()
2736 "Remove the newlines that some other mailers insert into URLs."
2739 (let ((inhibit-read-only t))
2740 (goto-char (point-min))
2741 (while (re-search-forward
2742 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2743 (replace-match "\\1\\3" t)))
2744 (when (interactive-p)
2745 (gnus-treat-article nil))))
2747 (defun article-wash-html ()
2748 "Format an HTML article."
2751 (buffer-read-only nil))
2752 (when (gnus-buffer-live-p gnus-original-article-buffer)
2753 (setq handles (mm-dissect-buffer t t)))
2755 (delete-region (point) (point-max))
2756 (mm-inline-text-html handles)))
2758 (defvar gnus-article-browse-html-temp-list nil
2759 "List of temporary files created by `gnus-article-browse-html-parts'.
2760 Internal variable.")
2762 (defcustom gnus-article-browse-delete-temp 'ask
2763 "What to do with temporary files from `gnus-article-browse-html-parts'.
2764 If nil, don't delete temporary files. If it is t, delete them on
2765 exit from the summary buffer. If it is the symbol `file', query
2766 on each file, if it is `ask' ask once when exiting from the
2768 :group 'gnus-article
2769 :version "23.1" ;; No Gnus
2770 :type '(choice (const :tag "Don't delete" nil)
2771 (const :tag "Don't ask" t)
2772 (const :tag "Ask" ask)
2773 (const :tag "Ask for each file" file)))
2775 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2777 (defun gnus-article-browse-delete-temp-files (&optional how)
2778 "Delete temp-files created by `gnus-article-browse-html-parts'."
2779 (when (and gnus-article-browse-html-temp-list
2781 (or how (setq how gnus-article-browse-delete-temp))
2783 (let ((files (length gnus-article-browse-html-temp-list)))
2784 (gnus-y-or-n-p (format
2785 "Delete all %s temporary HTML file%s? "
2787 (if (> files 1) "s" ""))))
2789 (dolist (file gnus-article-browse-html-temp-list)
2790 (cond ((file-directory-p file)
2791 (when (or (not (eq how 'file))
2794 "Delete temporary HTML file(s) in directory `%s'? "
2795 (file-name-as-directory file))))
2796 (gnus-delete-directory file)))
2797 ((file-exists-p file)
2798 (when (or (not (eq how 'file))
2800 (format "Delete temporary HTML file `%s'? " file)))
2801 (delete-file file)))))
2802 ;; Also remove file from the list when not deleted or if file doesn't
2804 (setq gnus-article-browse-html-temp-list nil))
2805 gnus-article-browse-html-temp-list)
2807 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2808 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2813 (dolist (handle handles)
2815 ((not (listp handle)))
2816 ((equal (mm-handle-media-supertype handle) "multipart")
2817 (when (setq file (gnus-article-browse-html-save-cid-content
2818 cid handle directory))
2819 (throw 'found file)))
2820 ((equal (concat "<" cid ">") (mm-handle-id handle))
2823 (or (mail-content-type-get
2824 (mm-handle-disposition handle) 'filename)
2825 (mail-content-type-get
2826 (setq type (mm-handle-type handle)) 'name)
2828 (make-temp-name "cid")
2829 (car (rassoc (car type) mailcap-mime-extensions))))
2831 (mm-save-part-to-file handle file)
2832 (throw 'found file))))))))
2834 (defun gnus-article-browse-html-parts (list &optional header)
2835 "View all \"text/html\" parts from LIST.
2836 Recurse into multiparts. The optional HEADER that should be a decoded
2837 message header will be added to the bodies of the \"text/html\" parts."
2838 ;; Internal function used by `gnus-article-browse-html-article'.
2839 (let (type file charset content cid-dir tmp-file showed)
2840 ;; Find and show the html-parts.
2841 (dolist (handle list)
2842 ;; If HTML, show it:
2843 (cond ((not (listp handle)))
2844 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2845 (and (equal (car type) "message/external-body")
2847 (setq file (or (mail-content-type-get type 'name)
2848 (mail-content-type-get
2849 (mm-handle-disposition handle)
2851 (or (mm-handle-cache handle)
2852 (condition-case code
2853 (progn (mm-extern-cache-contents handle) t)
2855 (gnus-message 3 "%s" (error-message-string code))
2856 (when (>= gnus-verbose 3) (sit-for 2))
2859 (setq handle (mm-handle-cache handle)
2860 type (mm-handle-type handle))
2861 (equal (car type) "text/html"))))
2862 (setq charset (mail-content-type-get type 'charset)
2863 content (mm-get-part handle))
2865 (if (eq charset 'gnus-decoded)
2866 (mm-enable-multibyte)
2867 (mm-disable-multibyte))
2869 ;; resolve cid contents
2870 (let ((case-fold-search t)
2872 (goto-char (point-min))
2873 (while (re-search-forward "\
2874 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2877 (setq cid-dir (mm-make-temp-file "cid" t))
2878 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2881 (when (setq cid-file
2882 (gnus-article-browse-html-save-cid-content
2884 (with-current-buffer gnus-article-buffer
2885 gnus-article-mime-handles)
2887 (replace-match (concat "file://" cid-file)
2889 (unless content (setq content (buffer-string))))
2890 (when (or charset header (not file))
2891 (setq tmp-file (mm-make-temp-file
2892 ;; Do we need to care for 8.3 filenames?
2893 "mm-" nil ".html")))
2894 ;; Add a meta html tag to specify charset and a header.
2897 (let (title eheader body hcharset coding force-charset)
2899 (mm-enable-multibyte)
2900 (setq case-fold-search t)
2901 (insert header "\n")
2902 (setq title (message-fetch-field "subject"))
2903 (goto-char (point-min))
2904 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2905 (replace-match (cond ((match-beginning 1) "<")
2906 ((match-beginning 2) ">")
2908 (goto-char (point-min))
2910 (goto-char (point-max))
2911 (insert "</pre>\n<hr>\n")
2912 ;; We have to examine charset one by one since
2913 ;; charset specified in parts might be different.
2914 (if (eq charset 'gnus-decoded)
2915 (setq charset 'utf-8
2916 eheader (mm-encode-coding-string (buffer-string)
2919 (mm-encode-coding-string title charset))
2920 body (mm-encode-coding-string content charset)
2922 (setq hcharset (mm-find-mime-charset-region (point-min)
2924 (cond ((= (length hcharset) 1)
2925 (setq hcharset (car hcharset)
2926 coding (mm-charset-to-coding-system
2928 ((> (length hcharset) 1)
2929 (setq hcharset 'utf-8
2935 (mm-charset-to-coding-system charset))
2936 (if (eq coding body)
2937 (setq eheader (mm-encode-coding-string
2938 (buffer-string) coding)
2940 (mm-encode-coding-string
2943 (setq charset 'utf-8
2944 eheader (mm-encode-coding-string
2945 (buffer-string) charset)
2947 (mm-encode-coding-string
2949 body (mm-encode-coding-string
2950 (mm-decode-coding-string
2954 (setq charset hcharset
2955 eheader (mm-encode-coding-string
2956 (buffer-string) coding)
2958 (mm-encode-coding-string
2961 (setq eheader (mm-string-as-unibyte (buffer-string))
2964 (mm-disable-multibyte)
2967 (mm-add-meta-html-tag handle charset force-charset))
2969 (goto-char (point-min))
2970 (unless (search-forward "<title>" nil t)
2971 (re-search-forward "<head>\\s-*" nil t)
2972 (insert "<title>" title "</title>\n")))
2973 (goto-char (point-min))
2974 (or (re-search-forward
2975 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2977 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2979 (mm-write-region (point-min) (point-max)
2980 tmp-file nil nil nil 'binary t))))
2982 (mm-with-unibyte-buffer
2983 (insert (if (eq charset 'gnus-decoded)
2984 (mm-encode-coding-string content
2985 (setq charset 'utf-8))
2987 (if (or (mm-add-meta-html-tag handle charset)
2989 (mm-write-region (point-min) (point-max)
2990 tmp-file nil nil nil 'binary t)
2991 (setq tmp-file nil))))
2993 (mm-save-part-to-file handle tmp-file)))
2995 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2996 (add-hook 'gnus-summary-prepare-exit-hook
2997 'gnus-article-browse-delete-temp-files)
2998 (add-hook 'gnus-exit-gnus-hook
3000 (gnus-article-browse-delete-temp-files t)))
3001 ;; FIXME: Warn if there's an <img> tag?
3002 (browse-url-of-file (or tmp-file (expand-file-name file)))
3004 ;; If multipart, recurse
3005 ((equal (mm-handle-media-supertype handle) "multipart")
3006 (when (gnus-article-browse-html-parts handle header)
3008 ((equal (mm-handle-media-type handle) "message/rfc822")
3009 (mm-with-multibyte-buffer
3010 (mm-insert-part handle)
3011 (setq handle (mm-dissect-buffer t t))
3012 (when (and (bufferp (car handle))
3013 (stringp (car (mm-handle-type handle))))
3014 (setq handle (list handle)))
3016 (article-decode-encoded-words)
3017 (let ((gnus-visible-headers
3018 (or (get 'gnus-visible-headers 'standard-value)
3019 gnus-visible-headers)))
3020 (article-hide-headers))
3021 (goto-char (point-min))
3022 (search-forward "\n\n" nil 'move)
3023 (skip-chars-backward "\t\n ")
3024 (setq header (buffer-substring (point-min) (point)))))
3026 (gnus-article-browse-html-parts handle header)
3027 (mm-destroy-parts handle))
3031 (defun gnus-article-browse-html-article (&optional arg)
3032 "View \"text/html\" parts of the current article with a WWW browser.
3033 Inline images embedded in a message using the cid scheme, as they are
3034 generally considered to be safe, will be processed properly.
3035 The message header is added to the beginning of every html part unless
3036 the prefix argument ARG is given.
3038 Warning: Spammers use links to images (using the http scheme) in HTML
3039 articles to verify whether you have read the message. As
3040 `gnus-article-browse-html-article' passes the HTML content to the
3041 browser without eliminating these \"web bugs\" you should only
3042 use it for mails from trusted senders.
3044 If you always want to display HTML parts in the browser, set
3045 `mm-text-html-renderer' to nil.
3047 This command creates temporary files to pass HTML contents including
3048 images if any to the browser, and deletes them when exiting the group
3050 ;; Cf. `mm-w3m-safe-url-regexp'
3053 (gnus-summary-show-article)
3054 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3055 gnus-visible-headers))
3056 ;; As we insert a <hr>, there's no need for the body boundary.
3057 (gnus-treat-body-boundary nil))
3058 (gnus-summary-show-article)))
3059 (with-current-buffer gnus-article-buffer
3060 (let ((header (unless arg
3063 (buffer-substring-no-properties
3064 (goto-char (point-min))
3065 (if (search-forward "\n\n" nil t)
3067 (goto-char (point-max))
3068 (skip-chars-backward "\t\n ")
3071 (set-buffer gnus-original-article-buffer)
3072 (setq parts (mm-dissect-buffer t t))
3073 ;; If singlepart, enforce a list.
3074 (when (and (bufferp (car parts))
3075 (stringp (car (mm-handle-type parts))))
3076 (setq parts (list parts)))
3078 (unless (gnus-article-browse-html-parts parts header)
3079 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3080 (mm-destroy-parts parts)
3082 (gnus-summary-show-article)))))
3084 (defun article-hide-list-identifiers ()
3085 "Remove list identifies from the Subject header.
3086 The `gnus-list-identifiers' variable specifies what to do."
3088 (let ((inhibit-point-motion-hooks t)
3089 (regexp (if (consp gnus-list-identifiers)
3090 (mapconcat 'identity gnus-list-identifiers " *\\|")
3091 gnus-list-identifiers))
3092 (inhibit-read-only t))
3096 (article-narrow-to-head)
3097 (goto-char (point-min))
3098 (while (re-search-forward
3099 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3101 (delete-region (match-beginning 2) (match-end 0))
3102 (beginning-of-line))
3103 (when (re-search-forward
3104 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3105 (delete-region (match-beginning 1) (match-end 1))))))))
3107 (defun article-hide-pem (&optional arg)
3108 "Toggle hiding of any PEM headers and signatures in the current article.
3109 If given a negative prefix, always show; if given a positive prefix,
3111 (interactive (gnus-article-hidden-arg))
3112 (unless (gnus-article-check-hidden-text 'pem arg)
3114 (let ((inhibit-read-only t) end)
3115 (goto-char (point-min))
3116 ;; Hide the horrendously ugly "header".
3117 (when (and (search-forward
3118 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3120 (setq end (1+ (match-beginning 0))))
3121 (gnus-add-wash-type 'pem)
3122 (gnus-article-hide-text-type
3124 (if (search-forward "\n\n" nil t)
3128 ;; Hide the trailer as well
3129 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3131 (gnus-article-hide-text-type
3132 (match-beginning 0) (match-end 0) 'pem)))))))
3134 (defun article-strip-banner ()
3135 "Strip the banners specified by the `banner' group parameter and by
3136 `gnus-article-address-banner-alist'."
3140 (let ((inhibit-point-motion-hooks t))
3141 (when (gnus-parameter-banner gnus-newsgroup-name)
3142 (article-really-strip-banner
3143 (gnus-parameter-banner gnus-newsgroup-name)))
3144 (when gnus-article-address-banner-alist
3145 ;; Note that the From header is decoded here, so it is
3146 ;; required that the *-extract-address-components function
3147 ;; supports non-ASCII text.
3148 (let ((from (save-restriction
3150 (article-narrow-to-head)
3151 (mail-fetch-field "from"))))
3154 (cadr (funcall gnus-extract-address-components
3157 (dolist (pair gnus-article-address-banner-alist)
3158 (when (string-match (car pair) from)
3160 (article-really-strip-banner (cdr pair)))))))))))))
3162 (defun article-really-strip-banner (banner)
3163 "Strip the banner specified by the argument."
3166 (let ((inhibit-point-motion-hooks t)
3167 (gnus-signature-limit nil)
3168 (inhibit-read-only t))
3171 ((eq banner 'signature)
3172 (when (gnus-article-narrow-to-signature)
3175 (delete-region (point) (point-max))))
3177 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3178 (while (re-search-forward banner nil t)
3179 (delete-region (match-beginning 0) (match-end 0)))))
3181 (while (re-search-forward banner nil t)
3182 (delete-region (match-beginning 0) (match-end 0)))))))))
3184 (defun article-babel ()
3185 "Translate article using an online translation service."
3188 (gnus-with-article-buffer
3189 (when (article-goto-body)
3190 (let* ((start (point))
3192 (orig (buffer-substring start end))
3193 (trans (babel-as-string orig)))
3195 (narrow-to-region start end)
3196 (delete-region start end)
3199 (defun article-hide-signature (&optional arg)
3200 "Hide the signature in the current article.
3201 If given a negative prefix, always show; if given a positive prefix,
3203 (interactive (gnus-article-hidden-arg))
3204 (unless (gnus-article-check-hidden-text 'signature arg)
3207 (let ((inhibit-read-only t))
3208 (when (gnus-article-narrow-to-signature)
3209 (gnus-article-hide-text-type
3210 (point-min) (point-max) 'signature))))))
3211 (gnus-set-mode-line 'article))
3213 (defun article-strip-headers-in-body ()
3214 "Strip offensive headers from bodies."
3218 (let ((case-fold-search t))
3219 (when (looking-at "x-no-archive:")
3220 (gnus-delete-line)))))
3222 (defun article-strip-leading-blank-lines ()
3223 "Remove all blank lines from the beginning of the article."
3226 (let ((inhibit-point-motion-hooks t)
3227 (inhibit-read-only t))
3228 (when (article-goto-body)
3229 (while (and (not (eobp))
3230 (looking-at "[ \t]*$"))
3231 (gnus-delete-line))))))
3233 (defun article-narrow-to-head ()
3234 "Narrow the buffer to the head of the message.
3235 Point is left at the beginning of the narrowed-to region."
3237 (goto-char (point-min))
3238 (if (search-forward "\n\n" nil 1)
3241 (goto-char (point-min)))
3243 (defun article-goto-body ()
3244 "Place point at the start of the body."
3245 (goto-char (point-min))
3247 ;; This variable is only bound when dealing with separate
3249 (article-goto-body-goes-to-point-min-p
3251 ((search-forward "\n\n" nil t)
3254 (goto-char (point-max))
3257 (defun article-strip-multiple-blank-lines ()
3258 "Replace consecutive blank lines with one empty line."
3261 (let ((inhibit-point-motion-hooks t)
3262 (inhibit-read-only t))
3263 ;; First make all blank lines empty.
3265 (while (re-search-forward "^[ \t]+$" nil t)
3266 (unless (gnus-annotation-in-region-p
3267 (match-beginning 0) (match-end 0))
3268 (replace-match "" nil t)))
3269 ;; Then replace multiple empty lines with a single empty line.
3271 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3272 (unless (gnus-annotation-in-region-p
3273 (match-beginning 0) (match-end 0))
3274 (delete-region (match-beginning 1) (match-end 1)))))))
3276 (defun article-strip-leading-space ()
3277 "Remove all white space from the beginning of the lines in the article."
3280 (let ((inhibit-point-motion-hooks t)
3281 (inhibit-read-only t))
3283 (while (re-search-forward "^[ \t]+" nil t)
3284 (replace-match "" t t)))))
3286 (defun article-strip-trailing-space ()
3287 "Remove all white space from the end of the lines in the article."
3290 (let ((inhibit-point-motion-hooks t)
3291 (inhibit-read-only t))
3293 (while (re-search-forward "[ \t]+$" nil t)
3294 (replace-match "" t t)))))
3296 (defun article-strip-blank-lines ()
3297 "Strip leading, trailing and multiple blank lines."
3299 (article-strip-leading-blank-lines)
3300 (article-remove-trailing-blank-lines)
3301 (article-strip-multiple-blank-lines))
3303 (defun article-strip-all-blank-lines ()
3304 "Strip all blank lines."
3307 (let ((inhibit-point-motion-hooks t)
3308 (inhibit-read-only t))
3310 (while (re-search-forward "^[ \t]*\n" nil t)
3311 (replace-match "" t t)))))
3313 (defun gnus-article-narrow-to-signature ()
3314 "Narrow to the signature; return t if a signature is found, else nil."
3315 (let ((inhibit-point-motion-hooks t))
3316 (when (gnus-article-search-signature)
3318 ;; Check whether we have some limits to what we consider
3319 ;; to be a signature.
3320 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3321 (list gnus-signature-limit)))
3323 (while (setq limit (pop limits))
3324 (if (or (and (integerp limit)
3325 (< (- (point-max) (point)) limit))
3327 (< (count-lines (point) (point-max)) limit))
3328 (and (functionp limit)
3330 (and (stringp limit)
3331 (not (re-search-forward limit nil t))))
3332 () ; This limit did not succeed.
3336 (narrow-to-region (point) (point-max))
3339 (defun gnus-article-search-signature ()
3340 "Search the current buffer for the signature separator.
3341 Put point at the beginning of the signature separator."
3342 (let ((cur (point)))
3343 (goto-char (point-max))
3344 (if (if (stringp gnus-signature-separator)
3345 (re-search-backward gnus-signature-separator nil t)
3346 (let ((seps gnus-signature-separator))
3348 (not (re-search-backward (car seps) nil t)))
3355 (defun gnus-article-hidden-arg ()
3356 "Return the current prefix arg as a number, or 0 if no prefix."
3357 (list (if current-prefix-arg
3358 (prefix-numeric-value current-prefix-arg)
3361 (defun gnus-article-check-hidden-text (type arg)
3362 "Return nil if hiding is necessary.
3363 Arg can be nil or a number. nil and positive means hide, negative
3364 means show, 0 means toggle."
3367 (let ((hide (gnus-article-hidden-text-p type)))
3373 (gnus-article-show-hidden-text type)
3376 (if (eq hide 'hidden)
3378 (gnus-article-show-hidden-text type)
3382 (defun gnus-article-hidden-text-p (type)
3383 "Say whether the current buffer contains hidden text of type TYPE."
3384 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3386 (not (get-text-property pos 'invisible))
3387 (not (get-text-property pos 'dummy-invisible)))
3389 (text-property-any (1+ pos) (point-max) 'article-type type)))
3394 (defun gnus-article-show-hidden-text (type &optional dummy)
3395 "Show all hidden text of type TYPE.
3396 Originally it is hide instead of DUMMY."
3397 (let ((inhibit-read-only t)
3398 (inhibit-point-motion-hooks t))
3399 (gnus-remove-text-properties-when
3401 (point-min) (point-max)
3402 (cons 'article-type (cons type
3403 gnus-hidden-properties)))
3404 (gnus-delete-wash-type type)))
3406 (defconst article-time-units
3407 `((year . ,(* 365.25 24 60 60))
3408 (week . ,(* 7 24 60 60))
3409 (day . ,(* 24 60 60))
3413 "Mapping from time units to seconds.")
3415 (defun gnus-article-forward-header ()
3416 "Move point to the start of the next header.
3417 If the current header is a continuation header, this can be several
3422 (if (looking-at "[ \t]+[^ \t]")
3426 (defun article-date-ut (&optional type highlight)
3427 "Convert DATE date to universal time in the current article.
3428 If TYPE is `local', convert to local time; if it is `lapsed', output
3429 how much time has lapsed since DATE. For `lapsed', the value of
3430 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3431 should replace the \"Date:\" one, or should be added below it."
3432 (interactive (list 'ut t))
3433 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3434 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3438 (article-lapsed-timer
3442 (case-fold-search t)
3443 (inhibit-read-only t)
3444 (inhibit-point-motion-hooks t)
3445 pos date bface eface)
3449 (goto-char (point-min))
3450 (while (or (setq date (get-text-property (setq pos (point))
3452 (when (setq pos (next-single-property-change
3453 (point) 'original-date))
3454 (setq date (get-text-property pos 'original-date))
3457 pos (if (setq pos (text-property-any pos (point-max)
3458 'original-date nil))
3461 (if (or (bolp) (eobp))
3465 (goto-char (point-min))
3466 (when (re-search-forward tdate-regexp nil t)
3467 (setq bface (get-text-property (point-at-bol) 'face)
3468 eface (get-text-property (1- (point-at-eol)) 'face)))
3469 (goto-char (point-min))
3471 ;; Delete any old Date headers.
3472 (while (re-search-forward date-regexp nil t)
3474 (delete-region (point-at-bol) (progn
3475 (gnus-article-forward-header)
3477 (delete-region (point-at-bol) (progn
3478 (gnus-article-forward-header)
3481 (setq pos (point))))
3482 (when (and (not pos)
3483 (re-search-forward tdate-regexp nil t))
3485 (gnus-goto-char pos)
3486 (insert (article-make-date-line date (or type 'ut)))
3492 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3493 (put-text-property (match-beginning 1) (1+ (match-end 1))
3495 (put-text-property (match-beginning 2) (match-end 2)
3497 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3498 (goto-char (point-max))
3501 (defun article-make-date-line (date type)
3502 "Return a DATE line of TYPE."
3503 (unless (memq type '(local ut original user iso8601 lapsed english date-lapsed))
3504 (error "Unknown conversion type: %s" type))
3506 (let ((time (date-to-time date)))
3508 ;; Convert to the local timezone.
3510 (concat "Date: " (message-make-date time)))
3511 ;; Convert to Universal Time.
3516 (let* ((e (parse-time-string date))
3517 (tm (apply 'encode-time e))
3519 (ls (- (cadr tm) (car (current-time-zone time)))))
3520 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3521 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3525 ;; Get the original date from the article.
3526 ((eq type 'original)
3527 (concat "Date: " (if (string-match "\n+$" date)
3528 (substring date 0 (match-beginning 0))
3530 ;; Let the user define the format.
3532 (let ((format (or (condition-case nil
3533 (with-current-buffer gnus-summary-buffer
3534 gnus-article-time-format)
3536 gnus-article-time-format)))
3537 (if (functionp format)
3538 (funcall format time)
3539 (concat "Date: " (format-time-string format time)))))
3542 (let ((tz (car (current-time-zone time))))
3545 (format-time-string "%Y%m%dT%H%M%S" time)
3546 (format "%s%02d%02d"
3547 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3548 (/ (% (abs tz) 3600) 60)))))
3549 ;; Do an X-Sent lapsed format.
3551 (concat "X-Sent: " (article-lapsed-string time)))
3552 ;; A combined date/lapsed format.
3553 ((eq type 'date-lapsed)
3554 (concat "Date: " (article-lapsed-string time 3)))
3555 ;; Display the date in proper English
3557 (let ((dtime (decode-time time)))
3560 (number-to-string (nth 3 dtime))
3561 (let ((digit (% (nth 3 dtime) 10)))
3563 ((memq (nth 3 dtime) '(11 12 13)) "th")
3569 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3571 (number-to-string (nth 5 dtime))
3573 (format "%02d" (nth 2 dtime))
3575 (format "%02d" (nth 1 dtime)))))))
3577 (format "Date: %s (from Gnus)" date))))
3579 (defun article-lapsed-string (time &optional max-segments)
3580 ;; If the date is seriously mangled, the timezone functions are
3581 ;; liable to bug out, so we ignore all errors.
3582 (let* ((now (current-time))
3583 (real-time (subtract-time now time))
3584 (real-sec (and real-time
3585 (+ (* (float (car real-time)) 65536)
3587 (sec (and real-time (abs real-sec)))
3590 (unless max-segments
3591 (setq max-segments (length article-time-units)))
3600 ;; This is a bit convoluted, but basically we go
3601 ;; through the time units for years, weeks, etc,
3602 ;; and divide things to see whether that results
3603 ;; in positive answers.
3606 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3607 (>= segments max-segments))
3608 ;; The (remaining) seconds are too few to
3609 ;; be divided into this time unit.
3611 ;; It's big enough, so we output it.
3612 (setq sec (- sec (* num (cdr unit))))
3614 (concat (if prev ", " "") (int-to-string
3616 " " (symbol-name (car unit))
3617 (if (> num 1) "s" ""))
3619 segments (1+ segments)))))
3620 article-time-units "")
3621 ;; If dates are odd, then it might appear like the
3622 ;; article was sent in the future.
3625 " in the future"))))))
3627 (defun article-date-local (&optional highlight)
3628 "Convert the current article date to the local timezone."
3629 (interactive (list t))
3630 (article-date-ut 'local highlight))
3632 (defun article-date-english (&optional highlight)
3633 "Convert the current article date to something that is proper English."
3634 (interactive (list t))
3635 (article-date-ut 'english highlight))
3637 (defun article-date-original (&optional highlight)
3638 "Convert the current article date to what it was originally.
3639 This is only useful if you have used some other date conversion
3640 function and want to see what the date was before converting."
3641 (interactive (list t))
3642 (article-date-ut 'original highlight))
3644 (defun article-date-lapsed (&optional highlight)
3645 "Convert the current article date to time lapsed since it was sent."
3646 (interactive (list t))
3647 (article-date-ut 'lapsed highlight))
3649 (defun article-update-date-lapsed ()
3650 "Function to be run from a timer to update the lapsed time line."
3652 (let (deactivate-mark)
3657 (set-buffer (window-buffer w))
3658 (when (eq major-mode 'gnus-article-mode)
3659 (let ((mark (point-marker)))
3660 (goto-char (point-min))
3661 (when (re-search-forward "^X-Sent:" nil t)
3662 (article-date-lapsed t))
3663 (goto-char (marker-position mark))
3664 (move-marker mark nil))))
3667 (defun gnus-start-date-timer (&optional n)
3668 "Start a timer to update the X-Sent header in the article buffers.
3669 The numerical prefix says how frequently (in seconds) the function
3674 (gnus-stop-date-timer)
3675 (setq article-lapsed-timer
3676 (run-at-time 1 n 'article-update-date-lapsed)))
3678 (defun gnus-stop-date-timer ()
3679 "Stop the X-Sent timer."
3681 (when article-lapsed-timer
3682 (nnheader-cancel-timer article-lapsed-timer)
3683 (setq article-lapsed-timer nil)))
3685 (defun article-date-user (&optional highlight)
3686 "Convert the current article date to the user-defined format.
3687 This format is defined by the `gnus-article-time-format' variable."
3688 (interactive (list t))
3689 (article-date-ut 'user highlight))
3691 (defun article-date-iso8601 (&optional highlight)
3692 "Convert the current article date to ISO8601."
3693 (interactive (list t))
3694 (article-date-ut 'iso8601 highlight))
3696 (defmacro gnus-article-save-original-date (&rest forms)
3697 "Save the original date as a text property and evaluate FORMS."
3698 `(let* ((case-fold-search t)
3700 (goto-char (point-min))
3701 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3704 (date (when (and start
3705 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3707 (buffer-substring-no-properties start
3708 (match-beginning 0)))))
3709 (goto-char (point-max))
3710 (skip-chars-backward "\n")
3711 (put-text-property (point-min) (point) 'original-date date)
3713 (goto-char (point-max))
3714 (skip-chars-backward "\n")
3715 (put-text-property (point-min) (point) 'original-date date)))
3717 ;; (defun article-show-all ()
3718 ;; "Show all hidden text in the article buffer."
3721 ;; (let ((inhibit-read-only t))
3722 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3724 (defun article-remove-leading-whitespace ()
3725 "Remove excessive whitespace from all headers."
3729 (let ((inhibit-read-only t))
3730 (article-narrow-to-head)
3731 (goto-char (point-min))
3732 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3733 (delete-region (match-beginning 1) (match-end 1)))))))
3735 (defun article-emphasize (&optional arg)
3736 "Emphasize text according to `gnus-emphasis-alist'."
3737 (interactive (gnus-article-hidden-arg))
3738 (unless (gnus-article-check-hidden-text 'emphasis arg)
3742 (with-current-buffer gnus-summary-buffer
3743 gnus-article-emphasis-alist)
3745 gnus-emphasis-alist))
3746 (inhibit-read-only t)
3747 (props (append '(article-type emphasis)
3748 gnus-hidden-properties))
3749 regexp elem beg invisible visible face)
3752 (while (setq elem (pop alist))
3754 (setq regexp (car elem)
3755 invisible (nth 1 elem)
3756 visible (nth 2 elem)
3758 (while (re-search-forward regexp nil t)
3759 (when (and (match-beginning visible) (match-beginning invisible))
3760 (gnus-article-hide-text
3761 (match-beginning invisible) (match-end invisible) props)
3762 (gnus-article-unhide-text-type
3763 (match-beginning visible) (match-end visible) 'emphasis)
3764 (gnus-put-overlay-excluding-newlines
3765 (match-beginning visible) (match-end visible) 'face face)
3766 (gnus-add-wash-type 'emphasis)
3767 (goto-char (match-end invisible)))))))))
3769 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3770 "Setup newsgroup emphasis alist."
3771 (unless gnus-article-emphasis-alist
3772 (let ((name (and gnus-newsgroup-name
3773 (gnus-group-real-name gnus-newsgroup-name))))
3774 (make-local-variable 'gnus-article-emphasis-alist)
3775 (setq gnus-article-emphasis-alist
3777 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3778 (while (setq elem (pop alist))
3779 (when (and name (string-match (car elem) name))
3781 highlight (copy-sequence (cdr elem)))))
3783 (copy-sequence highlight-words)
3784 (if gnus-newsgroup-name
3785 (copy-sequence (gnus-group-find-parameter
3786 gnus-newsgroup-name 'highlight-words t)))
3787 gnus-emphasis-alist)))))
3789 (defvar gnus-summary-article-menu)
3790 (defvar gnus-summary-post-menu)
3792 ;;; Saving functions.
3794 (defun gnus-article-save (save-buffer file &optional num)
3795 "Save the currently selected article."
3796 (when (or (get gnus-default-article-saver :headers)
3797 (not gnus-save-all-headers))
3798 ;; Remove headers according to `gnus-saved-headers' or the value
3799 ;; of the `:headers' property that the saver function might have.
3800 (let ((gnus-visible-headers
3801 (or (symbol-value (get gnus-default-article-saver :headers))
3802 gnus-saved-headers gnus-visible-headers))
3803 ;; Ignore group parameter. See `article-hide-headers'.
3804 (gnus-summary-buffer nil))
3805 (with-current-buffer save-buffer
3806 (article-hide-headers 1 t))))
3807 (save-window-excursion
3808 (if (not gnus-default-article-saver)
3809 (error "No default saver is defined")
3810 ;; !!! Magic! The saving functions all save
3811 ;; `gnus-save-article-buffer' (or so they think), but we
3812 ;; bind that variable to our save-buffer.
3813 (set-buffer gnus-article-buffer)
3814 (let* ((gnus-save-article-buffer save-buffer)
3817 ((not gnus-prompt-before-saving) 'default)
3818 ((eq gnus-prompt-before-saving 'always) nil)
3820 (gnus-number-of-articles-to-be-saved
3821 (when (eq gnus-prompt-before-saving t)
3823 (set-buffer gnus-article-current-summary)
3824 (funcall gnus-default-article-saver filename)))))
3826 (defun gnus-read-save-file-name (prompt &optional filename
3827 function group headers variable
3830 (funcall function group headers (symbol-value variable)))
3835 ((eq filename 'default)
3841 (when (symbol-value dir-var)
3842 (setq default-name (expand-file-name
3843 (file-name-nondirectory default-name)
3844 (symbol-value dir-var))))
3845 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3848 (if (and gnus-number-of-articles-to-be-saved
3849 (> gnus-number-of-articles-to-be-saved 1))
3850 (format "these %d articles"
3851 gnus-number-of-articles-to-be-saved)
3854 ;; Let the split methods have their say.
3856 ;; No split name was found.
3859 (concat prompt " (default "
3860 (file-name-nondirectory default-name) "): ")
3861 (file-name-directory default-name)
3863 ;; A single group name is returned.
3864 ((stringp split-name)
3866 (funcall function split-name headers
3867 (symbol-value variable)))
3869 (concat prompt " (default "
3870 (file-name-nondirectory default-name) "): ")
3871 (file-name-directory default-name)
3873 ;; A single split name was found
3874 ((= 1 (length split-name))
3875 (let* ((name (expand-file-name
3877 gnus-article-save-directory))
3878 (dir (cond ((file-directory-p name)
3879 (file-name-as-directory name))
3880 ((file-exists-p name) name)
3881 (t gnus-article-save-directory))))
3883 (concat prompt " (default " name "): ")
3885 ;; A list of splits was found.
3887 (setq split-name (nreverse split-name))
3889 (let ((file-name-history
3890 (nconc split-name file-name-history)))
3894 (concat prompt " (`M-p' for defaults): ")
3895 gnus-article-save-directory
3897 gnus-article-save-directory)))
3898 (car (push result file-name-history)))))))
3899 ;; Create the directory.
3900 (gnus-make-directory (file-name-directory file))
3901 ;; If we have read a directory, we append the default file name.
3902 (when (file-directory-p file)
3903 (setq file (expand-file-name (file-name-nondirectory
3905 (file-name-as-directory file))))
3906 ;; Possibly translate some characters.
3907 (nnheader-translate-file-chars file))))))
3908 (gnus-make-directory (file-name-directory result))
3910 (set variable result))
3912 (set dir-var (file-name-directory result)))
3915 (defun gnus-article-archive-name (group)
3916 "Return the first instance of an \"Archive-name\" in the current buffer."
3917 (let ((case-fold-search t))
3918 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3919 (nnheader-concat gnus-article-save-directory
3920 (match-string 1)))))
3922 (defun gnus-article-nndoc-name (group)
3923 "If GROUP is an nndoc group, return the name of the parent group."
3924 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3925 (gnus-group-get-parameter group 'save-article-group)))
3927 (defun gnus-summary-save-in-rmail (&optional filename)
3928 "Append this article to Rmail file.
3929 Optional argument FILENAME specifies file name.
3930 Directory to save to is default to `gnus-article-save-directory'."
3931 (setq filename (gnus-read-save-file-name
3932 "Save %s in rmail file" filename
3933 gnus-rmail-save-name gnus-newsgroup-name
3934 gnus-current-headers 'gnus-newsgroup-last-rmail))
3935 (with-current-buffer gnus-save-article-buffer
3939 ;; Note that unlike gnus-summary-save-in-mail, there is no
3940 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3942 (gnus-output-to-rmail filename))))
3945 (defun gnus-summary-save-in-mail (&optional filename)
3946 "Append this article to Unix mail file.
3947 Optional argument FILENAME specifies file name.
3948 Directory to save to is default to `gnus-article-save-directory'."
3949 (setq filename (gnus-read-save-file-name
3950 "Save %s in Unix mail file" filename
3951 gnus-mail-save-name gnus-newsgroup-name
3952 gnus-current-headers 'gnus-newsgroup-last-mail))
3953 (with-current-buffer gnus-save-article-buffer
3957 (if (and (file-readable-p filename)
3958 (file-regular-p filename)
3959 (mail-file-babyl-p filename))
3960 (gnus-output-to-rmail filename)
3961 (gnus-output-to-mail filename)))))
3964 (put 'gnus-summary-save-in-file :decode t)
3965 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3966 (defun gnus-summary-save-in-file (&optional filename overwrite)
3967 "Append this article to file.
3968 Optional argument FILENAME specifies file name.
3969 Directory to save to is default to `gnus-article-save-directory'."
3970 (setq filename (gnus-read-save-file-name
3971 "Save %s in file" filename
3972 gnus-file-save-name gnus-newsgroup-name
3973 gnus-current-headers 'gnus-newsgroup-last-file))
3974 (with-current-buffer gnus-save-article-buffer
3978 (when (and overwrite
3979 (file-exists-p filename))
3980 (delete-file filename))
3981 (gnus-output-to-file filename))))
3984 (put 'gnus-summary-write-to-file :decode t)
3985 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3986 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3987 (defun gnus-summary-write-to-file (&optional filename)
3988 "Write this article to a file, overwriting it if the file exists.
3989 Optional argument FILENAME specifies file name.
3990 The directory to save in defaults to `gnus-article-save-directory'."
3991 (setq filename (gnus-read-save-file-name
3992 "Save %s in file" filename
3993 gnus-file-save-name gnus-newsgroup-name
3994 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3995 (gnus-summary-save-in-file filename t))
3997 (put 'gnus-summary-save-body-in-file :decode t)
3998 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3999 "Append this article body to a file.
4000 Optional argument FILENAME specifies file name.
4001 The directory to save in defaults to `gnus-article-save-directory'."
4002 (setq filename (gnus-read-save-file-name
4003 "Save %s body in file" filename
4004 gnus-file-save-name gnus-newsgroup-name
4005 gnus-current-headers 'gnus-newsgroup-last-file))
4006 (with-current-buffer gnus-save-article-buffer
4010 (when (article-goto-body)
4011 (narrow-to-region (point) (point-max)))
4012 (when (and overwrite
4013 (file-exists-p filename))
4014 (delete-file filename))
4015 (gnus-output-to-file filename))))
4018 (put 'gnus-summary-write-body-to-file :decode t)
4019 (put 'gnus-summary-write-body-to-file
4020 :function 'gnus-summary-save-body-in-file)
4021 (defun gnus-summary-write-body-to-file (&optional filename)
4022 "Write this article body to a file, overwriting it if the file exists.
4023 Optional argument FILENAME specifies file name.
4024 The directory to save in defaults to `gnus-article-save-directory'."
4025 (setq filename (gnus-read-save-file-name
4026 "Save %s body in file" filename
4027 gnus-file-save-name gnus-newsgroup-name
4028 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4029 (gnus-summary-save-body-in-file filename t))
4031 (put 'gnus-summary-save-in-pipe :decode t)
4032 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4033 (defun gnus-summary-save-in-pipe (&optional command raw)
4034 "Pipe this article to subprocess COMMAND.
4035 Valid values for COMMAND include:
4037 The executable command name and possibly arguments.
4039 You will be prompted for the command in the minibuffer.
4040 the symbol `default'
4041 It will be replaced with the command which the variable
4042 `gnus-summary-pipe-output-default-command' holds or the command
4043 last used for saving.
4044 Non-nil value for RAW overrides `:decode' and `:headers' properties
4045 and the raw article including all headers will be piped."
4046 (let ((article (gnus-summary-article-number))
4048 (get 'gnus-summary-save-in-pipe :decode)))
4049 save-buffer default)
4051 (if (vectorp (gnus-summary-article-header article))
4052 (save-current-buffer
4053 (gnus-summary-select-article decode decode nil article)
4054 (insert-buffer-substring
4058 gnus-original-article-buffer)
4060 (nnheader-set-temp-buffer " *Gnus Save*"))))
4061 ;; Remove unwanted headers.
4062 (when (and (not raw)
4063 (or (get 'gnus-summary-save-in-pipe :headers)
4064 (not gnus-save-all-headers)))
4065 (let ((gnus-visible-headers
4066 (or (symbol-value (get 'gnus-summary-save-in-pipe
4068 gnus-saved-headers gnus-visible-headers))
4069 (gnus-summary-buffer nil))
4070 (article-hide-headers 1 t))))
4071 (error "%d is not a real article" article))
4072 (error "No article to pipe"))
4073 (setq default (or gnus-summary-pipe-output-default-command
4074 gnus-last-shell-command))
4075 (unless (stringp command)
4077 (if (and (eq command 'default) default)
4079 (gnus-read-shell-command "Shell command on this article: "
4081 (when (string-equal command "")
4083 (setq command default)
4084 (error "A command is required")))
4085 (with-current-buffer save-buffer
4088 (shell-command-on-region (point-min) (point-max) command nil)))
4089 (gnus-kill-buffer save-buffer))
4090 (setq gnus-summary-pipe-output-default-command command))
4092 (defun gnus-summary-pipe-to-muttprint (&optional command)
4093 "Pipe this article to muttprint."
4094 (unless (stringp command)
4095 (setq command (read-string
4096 "Print using command: " gnus-summary-muttprint-program
4097 nil gnus-summary-muttprint-program)))
4098 (let ((gnus-summary-pipe-output-default-command
4099 gnus-summary-pipe-output-default-command))
4100 (gnus-summary-save-in-pipe command))
4101 (setq gnus-summary-muttprint-program command))
4103 ;;; Article file names when saving.
4105 (defun gnus-capitalize-newsgroup (newsgroup)
4106 "Capitalize NEWSGROUP name."
4107 (when (not (zerop (length newsgroup)))
4108 (concat (char-to-string (upcase (aref newsgroup 0)))
4109 (substring newsgroup 1))))
4111 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4112 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4113 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4114 Otherwise, it is like ~/News/news/group/num."
4117 (concat (if (gnus-use-long-file-name 'not-save)
4118 (gnus-capitalize-newsgroup newsgroup)
4119 (gnus-newsgroup-directory-form newsgroup))
4120 "/" (int-to-string (mail-header-number headers)))
4121 gnus-article-save-directory)))
4123 (string-equal (file-name-directory default)
4124 (file-name-directory last-file))
4125 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4127 (or last-file default))))
4129 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4130 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4131 If variable `gnus-use-long-file-name' is non-nil, it is
4132 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4135 (concat (if (gnus-use-long-file-name 'not-save)
4137 (gnus-newsgroup-directory-form newsgroup))
4138 "/" (int-to-string (mail-header-number headers)))
4139 gnus-article-save-directory)))
4141 (string-equal (file-name-directory default)
4142 (file-name-directory last-file))
4143 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4145 (or last-file default))))
4147 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4148 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4149 If variable `gnus-use-long-file-name' is non-nil, it is
4150 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4153 (if (gnus-use-long-file-name 'not-save)
4156 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4158 gnus-article-save-directory)))
4160 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4161 "Generate file name from sender."
4162 (let ((from (mail-header-from headers)))
4164 (if (and from (string-match "\\([^ <]+\\)@" from))
4165 (match-string 1 from)
4167 gnus-article-save-directory)))
4169 (defun article-verify-x-pgp-sig ()
4171 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4173 (if (gnus-buffer-live-p gnus-original-article-buffer)
4174 (let ((sig (with-current-buffer gnus-original-article-buffer
4175 (gnus-fetch-field "X-PGP-Sig")))
4179 (mml2015-clear-verify-function))
4181 (insert-buffer-substring gnus-original-article-buffer)
4182 (setq items (split-string sig))
4183 (message-narrow-to-head)
4184 (let ((inhibit-point-motion-hooks t)
4185 (case-fold-search t))
4186 ;; Don't verify multiple headers.
4187 (setq headers (mapconcat (lambda (header)
4189 (mail-fetch-field header)
4191 (split-string (nth 1 items) ",") "")))
4192 (delete-region (point-min) (point-max))
4193 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4194 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4199 (if (looking-at "^-")
4202 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4203 (insert "Version: " (car items) "\n\n")
4204 (insert (mapconcat 'identity (cddr items) "\n"))
4205 (insert "\n-----END PGP SIGNATURE-----\n")
4206 (let ((mm-security-handle (list (format "multipart/signed"))))
4207 (mml2015-clean-buffer)
4208 (let ((coding-system-for-write (or gnus-newsgroup-charset
4210 (funcall (mml2015-clear-verify-function)))
4212 (or (mm-handle-multipart-ctl-parameter
4213 mm-security-handle 'gnus-details)
4214 (mm-handle-multipart-ctl-parameter
4215 mm-security-handle 'gnus-info)))))
4217 (let ((inhibit-read-only t) bface eface)
4219 (message-narrow-to-head)
4220 (goto-char (point-max))
4222 (setq bface (get-text-property (point-at-bol) 'face)
4223 eface (get-text-property (1- (point-at-eol)) 'face))
4224 (message-remove-header "X-Gnus-PGP-Verify")
4225 (if (re-search-forward "^X-PGP-Sig:" nil t)
4227 (goto-char (point-max)))
4228 (narrow-to-region (point) (point))
4229 (insert "X-Gnus-PGP-Verify: " info "\n")
4230 (goto-char (point-min))
4233 (if (not (looking-at "^[ \t]"))
4237 (goto-char (point-min))
4238 (when (looking-at "\\([^:]+\\): *")
4239 (put-text-property (match-beginning 1) (1+ (match-end 1))
4241 (put-text-property (match-end 0) (point-max)
4242 'face eface)))))))))
4244 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4246 (defun article-verify-cancel-lock ()
4247 "Verify Cancel-Lock header."
4249 (if (gnus-buffer-live-p gnus-original-article-buffer)
4250 (canlock-verify gnus-original-article-buffer)))
4257 (setq afunc (car func)
4260 gfunc (intern (format "gnus-%s" func))))
4262 (when (fboundp afunc)
4263 `(lambda (&optional interactive &rest args)
4264 ,(documentation afunc t)
4265 (interactive (list t))
4266 (with-current-buffer gnus-article-buffer
4268 (call-interactively ',afunc)
4269 (apply ',afunc args))))))))
4270 '(article-hide-headers
4271 article-verify-x-pgp-sig
4272 article-verify-cancel-lock
4273 article-hide-boring-headers
4274 article-treat-overstrike
4275 article-treat-ansi-sequences
4276 article-fill-long-lines
4277 article-capitalize-sentences
4279 article-remove-leading-whitespace
4280 article-display-x-face
4281 article-display-face
4282 article-de-quoted-unreadable
4283 article-de-base64-unreadable
4286 article-unsplit-urls
4287 article-hide-list-identifiers
4288 article-strip-banner
4291 article-hide-signature
4292 article-strip-headers-in-body
4293 article-remove-trailing-blank-lines
4294 article-strip-leading-blank-lines
4295 article-strip-multiple-blank-lines
4296 article-strip-leading-space
4297 article-strip-trailing-space
4298 article-strip-blank-lines
4299 article-strip-all-blank-lines
4301 article-date-english
4302 article-date-iso8601
4303 article-date-original
4305 article-decode-mime-words
4306 article-decode-charset
4307 article-decode-encoded-words
4311 article-treat-dumbquotes
4312 article-treat-non-ascii
4313 article-normalize-headers
4314 ;;(article-show-all . gnus-article-show-all-headers)
4318 ;;; Gnus article mode
4321 (put 'gnus-article-mode 'mode-class 'special)
4323 (set-keymap-parent gnus-article-mode-map widget-keymap)
4325 (gnus-define-keys gnus-article-mode-map
4326 " " gnus-article-goto-next-page
4327 "\177" gnus-article-goto-prev-page
4328 [delete] gnus-article-goto-prev-page
4329 [backspace] gnus-article-goto-prev-page
4330 "\C-c^" gnus-article-refer-article
4331 "h" gnus-article-show-summary
4332 "s" gnus-article-show-summary
4333 "\C-c\C-m" gnus-article-mail
4334 "?" gnus-article-describe-briefly
4335 "<" beginning-of-buffer
4337 "\C-c\C-i" gnus-info-find-node
4339 "R" gnus-article-reply-with-original
4340 "F" gnus-article-followup-with-original
4341 "\C-hk" gnus-article-describe-key
4342 "\C-hc" gnus-article-describe-key-briefly
4343 "\C-hb" gnus-article-describe-bindings
4345 "e" gnus-article-read-summary-keys
4346 "\C-d" gnus-article-read-summary-keys
4347 "\M-*" gnus-article-read-summary-keys
4348 "\M-#" gnus-article-read-summary-keys
4349 "\M-^" gnus-article-read-summary-keys
4350 "\M-g" gnus-article-read-summary-keys)
4352 (substitute-key-definition
4353 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4355 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4356 "W" gnus-article-wide-reply-with-original)
4357 (if (featurep 'xemacs)
4358 (set-keymap-default-binding gnus-article-send-map
4359 'gnus-article-read-summary-send-keys)
4360 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4362 (defun gnus-article-make-menu-bar ()
4363 (unless (boundp 'gnus-article-commands-menu)
4364 (gnus-summary-make-menu-bar))
4365 (unless (boundp 'gnus-article-article-menu)
4367 gnus-article-article-menu gnus-article-mode-map ""
4369 ["Scroll forwards" gnus-article-goto-next-page t]
4370 ["Scroll backwards" gnus-article-goto-prev-page t]
4371 ["Show summary" gnus-article-show-summary t]
4372 ["Fetch Message-ID at point" gnus-article-refer-article t]
4373 ["Mail to address at point" gnus-article-mail t]
4374 ["Send a bug report" gnus-bug t]))
4377 gnus-article-treatment-menu gnus-article-mode-map ""
4378 ;; Fixme: this should use :active (and maybe :visible).
4380 ["Hide headers" gnus-article-hide-headers t]
4381 ["Hide signature" gnus-article-hide-signature t]
4382 ["Hide citation" gnus-article-hide-citation t]
4383 ["Treat overstrike" gnus-article-treat-overstrike t]
4384 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4385 ["Remove carriage return" gnus-article-remove-cr t]
4386 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4387 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4388 ["Remove base64" gnus-article-de-base64-unreadable t]
4389 ["Treat html" gnus-article-wash-html t]
4390 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4391 ["Decode HZ" gnus-article-decode-HZ t]))
4393 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4395 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4397 (gnus-run-hooks 'gnus-article-menu-hook)))
4399 (defvar bookmark-make-record-function)
4401 (defun gnus-article-mode ()
4402 "Major mode for displaying an article.
4404 All normal editing commands are switched off.
4406 The following commands are available in addition to all summary mode
4408 \\<gnus-article-mode-map>
4409 \\[gnus-article-next-page]\t Scroll the article one page forwards
4410 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4411 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4412 \\[gnus-article-show-summary]\t Display the summary buffer
4413 \\[gnus-article-mail]\t Send a reply to the address near point
4414 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4415 \\[gnus-info-find-node]\t Go to the Gnus info node"
4417 (kill-all-local-variables)
4418 (gnus-simplify-mode-line)
4419 (setq mode-name "Article")
4420 (setq major-mode 'gnus-article-mode)
4421 (make-local-variable 'minor-mode-alist)
4422 (use-local-map gnus-article-mode-map)
4423 (when (gnus-visual-p 'article-menu 'menu)
4424 (gnus-article-make-menu-bar)
4425 (when gnus-summary-tool-bar-map
4426 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4427 (gnus-update-format-specifications nil 'article-mode)
4428 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4429 (set (make-local-variable 'gnus-page-broken) nil)
4430 (make-local-variable 'gnus-article-current-summary)
4431 (make-local-variable 'gnus-article-mime-handles)
4432 (make-local-variable 'gnus-article-decoded-p)
4433 (make-local-variable 'gnus-article-mime-handle-alist)
4434 (make-local-variable 'gnus-article-wash-types)
4435 (make-local-variable 'gnus-article-image-alist)
4436 (make-local-variable 'gnus-article-charset)
4437 (make-local-variable 'gnus-article-ignored-charsets)
4438 (set (make-local-variable 'bookmark-make-record-function)
4439 'gnus-summary-bookmark-make-record)
4440 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4442 (set (make-local-variable 'nobreak-char-display) nil)
4443 (setq cursor-in-non-selected-windows nil)
4444 (gnus-set-default-directory)
4445 (buffer-disable-undo)
4446 (setq buffer-read-only t
4447 show-trailing-whitespace nil)
4448 (set-syntax-table gnus-article-mode-syntax-table)
4449 (mm-enable-multibyte)
4450 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4452 (defun gnus-article-setup-buffer ()
4453 "Initialize the article buffer."
4454 (let* ((name (if gnus-single-article-buffer "*Article*"
4455 (concat "*Article " gnus-newsgroup-name "*")))
4457 (progn (string-match "\\*Article" name)
4458 (concat " *Original Article"
4459 (substring name (match-end 0))))))
4460 (setq gnus-article-buffer name)
4461 (setq gnus-original-article-buffer original)
4462 (setq gnus-article-mime-handle-alist nil)
4463 (with-current-buffer gnus-summary-buffer
4464 ;; This might be a variable local to the summary buffer.
4465 (unless gnus-single-article-buffer
4466 (setq gnus-article-buffer name)
4467 (setq gnus-original-article-buffer original)
4468 (gnus-set-global-variables)))
4469 (gnus-article-setup-highlight-words)
4470 ;; Init original article buffer.
4471 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4472 (mm-enable-multibyte)
4473 (setq major-mode 'gnus-original-article-mode)
4474 (make-local-variable 'gnus-original-article))
4475 (if (and (get-buffer name)
4476 (with-current-buffer name
4477 (if gnus-article-edit-mode
4478 (if (y-or-n-p "Article mode edit in progress; discard? ")
4480 (set-buffer-modified-p nil)
4481 (gnus-kill-buffer name)
4484 (error "Action aborted"))
4486 (with-current-buffer name
4487 (set (make-local-variable 'gnus-article-edit-mode) nil)
4488 (when gnus-article-mime-handles
4489 (mm-destroy-parts gnus-article-mime-handles)
4490 (setq gnus-article-mime-handles nil))
4491 ;; Set it to nil in article-buffer!
4492 (setq gnus-article-mime-handle-alist nil)
4493 (buffer-disable-undo)
4494 (setq buffer-read-only t)
4495 (unless (eq major-mode 'gnus-article-mode)
4496 (gnus-article-mode))
4497 (setq truncate-lines gnus-article-truncate-lines)
4499 (with-current-buffer (gnus-get-buffer-create name)
4501 (setq truncate-lines gnus-article-truncate-lines)
4502 (make-local-variable 'gnus-summary-buffer)
4503 (setq gnus-summary-buffer
4504 (gnus-summary-buffer-name gnus-newsgroup-name))
4505 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4506 (current-buffer)))))
4508 ;; Set article window start at LINE, where LINE is the number of lines
4509 ;; from the head of the article.
4510 (defun gnus-article-set-window-start (&optional line)
4511 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4512 (when article-window
4515 (with-current-buffer gnus-article-buffer
4516 (goto-char (point-min))
4519 (gnus-message 6 "Moved to bookmark")
4520 (search-forward "\n\n" nil t)
4524 (defun gnus-article-prepare (article &optional all-headers header)
4525 "Prepare ARTICLE in article mode buffer.
4526 ARTICLE should either be an article number or a Message-ID.
4527 If ARTICLE is an id, HEADER should be the article headers.
4528 If ALL-HEADERS is non-nil, no headers are hidden."
4530 ;; Make sure we start in a summary buffer.
4531 (unless (eq major-mode 'gnus-summary-mode)
4532 (set-buffer gnus-summary-buffer))
4533 (setq gnus-summary-buffer (current-buffer))
4534 (let* ((gnus-article (if header (mail-header-number header) article))
4535 (summary-buffer (current-buffer))
4536 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4537 (group gnus-newsgroup-name)
4540 (gnus-article-setup-buffer)
4541 (set-buffer gnus-article-buffer)
4542 ;; Deactivate active regions.
4543 (when (and (boundp 'transient-mark-mode)
4544 transient-mark-mode)
4545 (setq mark-active nil))
4546 (if (not (setq result (let ((inhibit-read-only t))
4547 (gnus-request-article-this-buffer
4549 ;; There is no such article.
4551 (when (and (numberp article)
4552 (not (memq article gnus-newsgroup-sparse)))
4553 (setq gnus-article-current
4554 (cons gnus-newsgroup-name article))
4555 (set-buffer gnus-summary-buffer)
4556 (setq gnus-current-article article)
4557 (if (and (memq article gnus-newsgroup-undownloaded)
4558 (not (gnus-online (gnus-find-method-for-group
4559 gnus-newsgroup-name))))
4561 (gnus-summary-set-agent-mark article)
4562 (message "Message marked for downloading"))
4563 (gnus-summary-mark-article article gnus-canceled-mark)
4564 (unless (memq article gnus-newsgroup-sparse)
4565 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4566 (if (or (eq result 'pseudo)
4567 (eq result 'nneething))
4569 (with-current-buffer summary-buffer
4570 (push article gnus-newsgroup-history)
4571 (setq gnus-last-article gnus-current-article
4572 gnus-current-article 0
4573 gnus-current-headers nil
4574 gnus-article-current nil)
4575 (if (eq result 'nneething)
4576 (gnus-configure-windows 'summary)
4577 (gnus-configure-windows 'article))
4578 (gnus-set-global-variables))
4579 (let ((gnus-article-mime-handle-alist-1
4580 gnus-article-mime-handle-alist))
4581 (gnus-set-mode-line 'article)))
4582 ;; The result from the `request' was an actual article -
4583 ;; or at least some text that is now displayed in the
4585 (when (and (numberp article)
4586 (not (eq article gnus-current-article)))
4587 ;; Seems like a new article has been selected.
4588 ;; `gnus-current-article' must be an article number.
4589 (with-current-buffer summary-buffer
4590 (push article gnus-newsgroup-history)
4591 (setq gnus-last-article gnus-current-article
4592 gnus-current-article article
4593 gnus-current-headers
4594 (gnus-summary-article-header gnus-current-article)
4595 gnus-article-current
4596 (cons gnus-newsgroup-name gnus-current-article))
4597 (unless (vectorp gnus-current-headers)
4598 (setq gnus-current-headers nil))
4599 (gnus-summary-goto-subject gnus-current-article)
4600 (when (gnus-summary-show-thread)
4601 ;; If the summary buffer really was folded, the
4602 ;; previous goto may not actually have gone to
4603 ;; the right article, but the thread root instead.
4605 (gnus-summary-goto-subject gnus-current-article))
4606 (gnus-run-hooks 'gnus-mark-article-hook)
4607 (gnus-set-mode-line 'summary)
4608 (when (gnus-visual-p 'article-highlight 'highlight)
4609 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4610 ;; Set the global newsgroup variables here.
4611 (gnus-set-global-variables)
4612 (setq gnus-have-all-headers
4613 (or all-headers gnus-show-all-headers))))
4615 (gnus-configure-windows 'article))
4616 (when (or (numberp article)
4618 (gnus-article-prepare-display)
4620 (goto-char (point-min))
4621 (when gnus-break-pages
4622 (gnus-narrow-to-page)))
4623 (let ((gnus-article-mime-handle-alist-1
4624 gnus-article-mime-handle-alist))
4625 (gnus-set-mode-line 'article))
4629 (set-window-point (get-buffer-window (current-buffer)) (point))
4630 (gnus-configure-windows 'article)
4634 (defun gnus-article-prepare-display ()
4635 "Make the current buffer look like a nice article."
4636 ;; Hooks for getting information from the article.
4637 ;; This hook must be called before being narrowed.
4638 (let ((gnus-article-buffer (current-buffer))
4640 (inhibit-read-only t))
4641 (unless (eq major-mode 'gnus-article-mode)
4642 (gnus-article-mode))
4643 (setq buffer-read-only nil
4644 gnus-article-wash-types nil
4645 gnus-article-image-alist nil)
4646 (gnus-run-hooks 'gnus-tmp-internal-hook)
4647 (when gnus-display-mime-function
4648 (funcall gnus-display-mime-function))
4649 (gnus-run-hooks 'gnus-article-prepare-hook)))
4652 ;;; Gnus Sticky Article Mode
4655 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4656 "Mode for sticky articles."
4657 ;; Release bindings that won't work.
4658 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4659 gnus-sticky-article-mode-map)
4660 (substitute-key-definition 'gnus-article-refer-article 'undefined
4661 gnus-sticky-article-mode-map)
4662 (dolist (k '("e" "h" "s" "F" "R"))
4663 (define-key gnus-sticky-article-mode-map k nil))
4664 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4665 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4666 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4667 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4669 (defun gnus-sticky-article (arg)
4670 "Make the current article sticky.
4671 If a prefix ARG is given, ask for a name for this sticky article buffer."
4673 (gnus-summary-show-thread)
4674 (gnus-summary-select-article nil nil 'pseudo)
4675 (let (new-art-buf-name)
4676 (gnus-eval-in-buffer-window gnus-article-buffer
4677 (setq new-art-buf-name
4681 (read-from-minibuffer "Sticky article buffer name: ")
4682 (gnus-with-article-headers
4683 (gnus-article-goto-header "subject")
4684 (setq new-art-buf-name
4685 (buffer-substring-no-properties
4686 (line-beginning-position) (line-end-position)))
4687 (goto-char (point-min))
4688 (gnus-article-goto-header "from")
4689 (setq new-art-buf-name
4691 new-art-buf-name ", "
4692 (buffer-substring-no-properties
4693 (line-beginning-position) (line-end-position))))
4694 (goto-char (point-min))
4695 (gnus-article-goto-header "date")
4696 (setq new-art-buf-name
4698 new-art-buf-name ", "
4699 (buffer-substring-no-properties
4700 (line-beginning-position) (line-end-position))))))
4702 (if (and (gnus-buffer-live-p new-art-buf-name)
4703 (with-current-buffer new-art-buf-name
4704 (eq major-mode 'gnus-sticky-article-mode)))
4705 (switch-to-buffer new-art-buf-name)
4706 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4707 (gnus-sticky-article-mode))
4708 (setq gnus-article-buffer new-art-buf-name))
4709 (gnus-summary-recenter)
4710 (gnus-summary-position-point))
4712 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4713 "Kill the given sticky article BUFFER.
4714 If none is given, assume the current buffer and kill it if it has
4715 `gnus-sticky-article-mode'."
4718 (setq buffer (current-buffer)))
4719 (with-current-buffer buffer
4720 (when (eq major-mode 'gnus-sticky-article-mode)
4721 (gnus-kill-buffer buffer))))
4723 (defun gnus-kill-sticky-article-buffers (arg)
4724 "Kill all sticky article buffers.
4725 If a prefix ARG is given, ask for confirmation."
4727 (dolist (buf (gnus-buffers))
4728 (with-current-buffer buf
4729 (when (eq major-mode 'gnus-sticky-article-mode)
4731 (gnus-kill-buffer buf)
4732 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4733 (gnus-kill-buffer buf)))))))
4736 ;;; Gnus MIME viewing functions
4739 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4740 "Format of the MIME buttons.
4742 Valid specifiers include:
4744 %T MIME type, along with additional info
4745 %n The `name' parameter
4746 %d The description, if any
4747 %l The length of the encoded part
4748 %p The part identifier number
4749 %e Dots if the part isn't displayed
4751 General format specifiers can also be used. See Info node
4752 `(gnus)Formatting Variables'.")
4754 (defvar gnus-mime-button-line-format-alist
4755 '((?t gnus-tmp-type ?s)
4756 (?T gnus-tmp-type-long ?s)
4757 (?n gnus-tmp-name ?s)
4758 (?d gnus-tmp-description ?s)
4760 (?l gnus-tmp-length ?d)
4761 (?e gnus-tmp-dots ?s)))
4763 (defvar gnus-mime-button-commands
4764 '((gnus-article-press-button "\r" "Toggle Display")
4765 (gnus-mime-view-part "v" "View Interactively...")
4766 (gnus-mime-view-part-as-type "t" "View As Type...")
4767 (gnus-mime-view-part-as-charset "C" "View As charset...")
4768 (gnus-mime-save-part "o" "Save...")
4769 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4770 (gnus-mime-replace-part "r" "Replace part")
4771 (gnus-mime-delete-part "d" "Delete part")
4772 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4773 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4774 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4775 (gnus-mime-view-part-externally "e" "View Externally")
4776 (gnus-mime-print-part "p" "Print")
4777 (gnus-mime-pipe-part "|" "Pipe To Command...")
4778 (gnus-mime-action-on-part "." "Take action on the part...")))
4780 (defun gnus-article-mime-part-status ()
4781 (if gnus-article-mime-handle-alist-1
4782 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4784 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4787 (defvar gnus-mime-button-map
4788 (let ((map (make-sparse-keymap)))
4789 (define-key map gnus-mouse-2 'gnus-article-push-button)
4790 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4791 (dolist (c gnus-mime-button-commands)
4792 (define-key map (cadr c) (car c)))
4796 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4798 ,@(mapcar (lambda (c)
4799 (vector (caddr c) (car c) :active t))
4800 gnus-mime-button-commands)))
4802 (defvar gnus-url-button-commands
4803 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4805 (defvar gnus-url-button-map
4806 (let ((map (make-sparse-keymap)))
4807 (dolist (c gnus-url-button-commands)
4808 (define-key map (cadr c) (car c)))
4812 gnus-url-button-menu gnus-url-button-map "URL button menu."
4814 ,@(mapcar (lambda (c)
4815 (vector (caddr c) (car c) :active t))
4816 gnus-url-button-commands)))
4818 (defmacro gnus-bind-safe-url-regexp (&rest body)
4819 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4820 `(let ((mm-w3m-safe-url-regexp
4821 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4823 gnus-article-current-summary))
4824 (with-current-buffer gnus-article-current-summary
4825 gnus-newsgroup-name)
4826 gnus-newsgroup-name)))
4827 (if (cond ((not group)
4828 ;; Maybe we're in a mml-preview buffer
4829 ;; and no group is selected.
4831 ((stringp gnus-safe-html-newsgroups)
4832 (string-match gnus-safe-html-newsgroups group))
4833 ((consp gnus-safe-html-newsgroups)
4834 (member group gnus-safe-html-newsgroups)))
4836 mm-w3m-safe-url-regexp))))
4839 (defun gnus-mime-button-menu (event prefix)
4840 "Construct a context-sensitive menu of MIME commands."
4841 (interactive "e\nP")
4842 (save-window-excursion
4843 (let ((pos (event-start event)))
4844 (select-window (posn-window pos))
4845 (goto-char (posn-point pos))
4846 (gnus-article-check-buffer)
4847 (popup-menu gnus-mime-button-menu nil prefix))))
4849 (defun gnus-mime-view-all-parts (&optional handles)
4850 "View all the MIME parts."
4852 (with-current-buffer gnus-article-buffer
4853 (let ((handles (or handles gnus-article-mime-handles))
4854 (mail-parse-charset gnus-newsgroup-charset)
4855 (mail-parse-ignored-charsets
4856 (with-current-buffer gnus-summary-buffer
4857 gnus-newsgroup-ignored-charsets)))
4859 (mm-remove-parts handles)
4860 (goto-char (point-min))
4861 (or (search-forward "\n\n") (goto-char (point-max)))
4862 (let ((inhibit-read-only t))
4863 (delete-region (point) (point-max))
4864 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4866 (defun gnus-article-jump-to-part (n)
4867 "Jump to MIME part N."
4869 (let ((parts (with-current-buffer gnus-article-buffer
4870 (length gnus-article-mime-handle-alist))))
4872 (error "No such part"))
4873 (pop-to-buffer gnus-article-buffer)
4874 ;; FIXME: why is it necessary?
4877 (setq n (if (= parts 1)
4879 (read-number (format "Jump to part (1..%s): " parts)))))
4880 (unless (and (integerp n) (<= n parts) (>= n 1))
4883 (gnus-message 7 "Invalid part `%s', using %s instead."
4886 (gnus-message 9 "Jumping to part %s." n)
4887 (cond ((>= gnus-auto-select-part 1)
4888 (while (and (<= n parts)
4889 (not (gnus-article-goto-part n)))
4891 ((< gnus-auto-select-part 0)
4892 (while (and (>= n 1)
4893 (not (gnus-article-goto-part n)))
4896 (gnus-article-goto-part n)))))
4898 (defvar gnus-mime-buttonized-part-id nil
4899 "ID of a mime part that should be buttonized.
4900 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4903 (defsubst gnus-article-edit-part (handles &optional current-id)
4904 "Edit an article in order to delete a mime part.
4905 This function is exclusively used by `gnus-mime-save-part-and-strip'
4906 and `gnus-mime-delete-part', and not provided at run-time normally."
4907 (gnus-article-edit-article
4909 (buffer-disable-undo)
4911 (let ((mail-parse-charset (or gnus-article-charset
4912 ',gnus-newsgroup-charset))
4913 (mail-parse-ignored-charsets
4914 (or gnus-article-ignored-charsets
4915 ',gnus-newsgroup-ignored-charsets))
4916 (mbl mml-buffer-list))
4917 (setq mml-buffer-list nil)
4918 (insert-buffer-substring gnus-original-article-buffer)
4919 (mime-to-mml ',handles)
4920 (setq gnus-article-mime-handles nil)
4921 (let ((mbl1 mml-buffer-list))
4922 (setq mml-buffer-list mbl)
4923 (set (make-local-variable 'mml-buffer-list) mbl1))
4924 (gnus-make-local-hook 'kill-buffer-hook)
4925 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4926 `(lambda (no-highlight)
4927 (let ((mail-parse-charset (or gnus-article-charset
4928 ',gnus-newsgroup-charset))
4929 (message-options message-options)
4930 (message-options-set-recipient)
4931 (mail-parse-ignored-charsets
4932 (or gnus-article-ignored-charsets
4933 ',gnus-newsgroup-ignored-charsets)))
4935 (mml-destroy-buffers)
4936 (remove-hook 'kill-buffer-hook
4937 'mml-destroy-buffers t)
4938 (kill-local-variable 'mml-buffer-list))
4939 (gnus-summary-edit-article-done
4940 ,(or (mail-header-references gnus-current-headers) "")
4941 ,(gnus-group-read-only-p)
4942 ,gnus-summary-buffer no-highlight))
4944 ;; Force buttonizing this part.
4945 (let ((gnus-mime-buttonized-part-id current-id))
4946 (gnus-article-edit-done))
4947 (gnus-configure-windows 'article)
4948 (when (and current-id (integerp gnus-auto-select-part))
4949 (gnus-article-jump-to-part
4950 (min (max (+ current-id gnus-auto-select-part) 1)
4951 (with-current-buffer gnus-article-buffer
4952 (length gnus-article-mime-handle-alist)))))))
4954 (defun gnus-mime-replace-part (file)
4955 "Replace MIME part under point with an external body."
4956 ;; Useful if file has already been saved to disk
4959 (read-file-name "Replace MIME part with file: "
4960 (or mm-default-directory default-directory)
4962 (gnus-mime-save-part-and-strip file))
4964 (defun gnus-mime-save-part-and-strip (&optional file)
4965 "Save the MIME part under point then replace it with an external body.
4966 If FILE is given, use it for the external part."
4968 (gnus-article-check-buffer)
4969 (when (gnus-group-read-only-p)
4970 (error "The current group does not support deleting of parts"))
4971 (when (mm-complicated-handles gnus-article-mime-handles)
4973 The current article has a complicated MIME structure, giving up..."))
4974 (let* ((data (get-text-property (point) 'gnus-data))
4975 (id (get-text-property (point) 'gnus-part))
4977 (handles gnus-article-mime-handles))
4980 (and data (mm-save-part data "Delete MIME part and save to: "))))
4982 (with-current-buffer (mm-handle-buffer data)
4984 (insert "Content-Type: " (mm-handle-media-type data))
4985 (mml-insert-parameter-string (cdr (mm-handle-type data))
4987 ;; Add a filename for the sake of saving the part again.
4988 (mml-insert-parameter
4989 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4991 (insert "Content-ID: " (message-make-message-id) "\n")
4992 (insert "Content-Transfer-Encoding: binary\n")
4995 (cdr (mm-make-handle nil
4996 `("message/external-body"
4997 (access-type . "LOCAL-FILE")
4999 ;; (set-buffer gnus-summary-buffer)
5000 (gnus-article-edit-part handles id))))
5002 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5003 ;; parts...>') but with stripping would be nice.
5005 (defun gnus-mime-delete-part ()
5006 "Delete the MIME part under point.
5007 Replace it with some information about the removed part."
5009 (gnus-article-check-buffer)
5010 (when (gnus-group-read-only-p)
5011 (error "The current group does not support deleting of parts"))
5012 (when (mm-complicated-handles gnus-article-mime-handles)
5014 The current article has a complicated MIME structure, giving up..."))
5015 (when (or gnus-expert-user
5016 (gnus-yes-or-no-p "\
5017 Deleting parts may malfunction or destroy the article; continue? "))
5018 (let* ((data (get-text-property (point) 'gnus-data))
5019 (id (get-text-property (point) 'gnus-part))
5020 (handles gnus-article-mime-handles)
5023 (let ((desc (mm-handle-description data)))
5025 (mail-decode-encoded-word-string desc))))
5027 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
5029 (type (mm-handle-media-type data)))
5031 (error "No MIME part under point"))
5032 (with-current-buffer (mm-handle-buffer data)
5033 (let ((bsize (buffer-size)))
5038 "| The following attachment has been deleted:\n"
5040 "| Type: " type "\n"
5041 "| Filename: " filename "\n"
5042 "| Size (encoded): " (format "%s byte%s\n"
5043 bsize (if (= bsize 1)
5047 (concat "| Description: " description "\n"))
5050 (cdr (mm-make-handle
5051 nil `("text/plain" (charset . gnus-decoded)) nil nil
5053 (format "Deleted attachment (%s bytes)" bsize))))))
5054 ;; (set-buffer gnus-summary-buffer)
5055 (gnus-article-edit-part handles id))))
5057 (defun gnus-mime-save-part ()
5058 "Save the MIME part under point."
5060 (gnus-article-check-buffer)
5061 (let ((data (get-text-property (point) 'gnus-data)))
5063 (mm-save-part data))))
5065 (defun gnus-mime-pipe-part (&optional cmd)
5066 "Pipe the MIME part under point to a process.
5067 Use CMD as the process."
5069 (gnus-article-check-buffer)
5070 (let ((data (get-text-property (point) 'gnus-data)))
5072 (mm-pipe-part data cmd))))
5074 (defun gnus-mime-view-part ()
5075 "Interactively choose a viewing method for the MIME part under point."
5077 (gnus-article-check-buffer)
5078 (let ((data (get-text-property (point) 'gnus-data)))
5080 (setq gnus-article-mime-handles
5082 gnus-article-mime-handles (setq data (copy-sequence data))))
5083 (mm-interactively-view-part data))))
5085 (defun gnus-mime-view-part-as-type-internal ()
5086 (gnus-article-check-buffer)
5087 (let* ((handle (get-text-property (point) 'gnus-data))
5089 ;; Content-Type: foo/bar; name=...
5090 (mail-content-type-get (mm-handle-type handle) 'name)
5091 ;; Content-Disposition: attachment; filename=...
5092 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5093 (def-type (and name (mm-default-file-encoding name))))
5094 (or (and def-type (cons def-type 0))
5096 (equal (mm-handle-media-supertype handle) "text")
5097 '("text/plain" . 0))
5098 '("application/octet-stream" . 0))))
5100 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5101 "Choose a MIME media type, and view the part as such.
5102 If non-nil, PRED is a predicate to use during completion to limit the
5103 available media-types."
5107 (let ((default (gnus-mime-view-part-as-type-internal)))
5108 (gnus-completing-read
5111 (gnus-remove-if-not pred (mailcap-mime-types))
5112 (mailcap-mime-types))
5115 (gnus-article-check-buffer)
5116 (let ((handle (get-text-property (point) 'gnus-data)))
5118 (when (equal (mm-handle-media-type handle) "message/external-body")
5119 (unless (mm-handle-cache handle)
5120 (mm-extern-cache-contents handle))
5121 (setq handle (mm-handle-cache handle)))
5123 (mm-make-handle (mm-handle-buffer handle)
5124 (cons mime-type (cdr (mm-handle-type handle)))
5125 (mm-handle-encoding handle)
5126 (mm-handle-undisplayer handle)
5127 (mm-handle-disposition handle)
5128 (mm-handle-description handle)
5130 (mm-handle-id handle)))
5131 (setq gnus-article-mime-handles
5132 (mm-merge-handles gnus-article-mime-handles handle))
5133 (when (mm-handle-displayed-p handle)
5134 (mm-remove-part handle))
5135 (gnus-mm-display-part handle))))
5137 (defun gnus-mime-copy-part (&optional handle arg)
5138 "Put the MIME part under point into a new buffer.
5139 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5141 (interactive (list nil current-prefix-arg))
5142 (gnus-article-check-buffer)
5144 (setq handle (get-text-property (point) 'gnus-data)))
5146 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5148 (mail-content-type-get (mm-handle-disposition handle)
5150 contents dont-decode charset coding-system)
5151 (mm-with-unibyte-buffer
5152 (mm-insert-part handle)
5153 (setq contents (or (condition-case nil
5154 (mm-decompress-buffer filename nil 'sig)
5156 (setq dont-decode t)
5159 (setq filename (cond (filename (file-name-nondirectory filename))
5160 (dont-decode "*raw data*")
5165 (unless (setq charset (mail-content-type-get
5166 (mm-handle-type handle) 'charset))
5167 (unless (setq coding-system (mm-with-unibyte-buffer
5169 (mm-find-buffer-file-coding-system)))
5170 (setq charset gnus-newsgroup-charset))))
5172 (setq charset (or (cdr (assq arg
5173 gnus-summary-show-article-charset-alist))
5174 (mm-read-coding-system "Charset: ")))))
5175 (switch-to-buffer (generate-new-buffer filename))
5176 (if (or coding-system
5178 (setq coding-system (mm-charset-to-coding-system charset))
5179 (not (eq coding-system 'ascii))))
5181 (mm-enable-multibyte)
5182 (insert (mm-decode-coding-string contents coding-system))
5183 (setq buffer-file-coding-system
5184 (if (boundp 'last-coding-system-used)
5185 (symbol-value 'last-coding-system-used)
5187 (mm-disable-multibyte)
5189 (setq buffer-file-coding-system mm-binary-coding-system))
5190 ;; We do it this way to make `normal-mode' set the appropriate mode.
5193 (setq buffer-file-name (expand-file-name filename))
5195 (setq buffer-file-name nil))
5196 (goto-char (point-min)))))
5198 (defun gnus-mime-print-part (&optional handle filename)
5199 "Print the MIME part under point."
5200 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5201 (gnus-article-check-buffer)
5202 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5203 (contents (and handle (mm-get-part handle)))
5204 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5205 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5210 (mm-save-part-to-file handle file)
5211 (call-process shell-file-name nil
5212 (generate-new-buffer " *mm*")
5214 shell-command-switch
5216 printer file (mm-handle-type handle))))
5220 (gnus-print-buffer))
5221 (ps-despool filename)))))
5223 (defun gnus-mime-inline-part (&optional handle arg)
5224 "Insert the MIME part under point into the current buffer.
5225 Compressed files like .gz and .bz2 are decompressed."
5226 (interactive (list nil current-prefix-arg))
5227 (gnus-article-check-buffer)
5229 (setq handle (get-text-property (point) 'gnus-data)))
5232 (inhibit-read-only t)
5233 contents charset coding-system)
5234 (if (and (not arg) (mm-handle-undisplayer handle))
5235 (mm-remove-part handle)
5236 (mm-with-unibyte-buffer
5237 (mm-insert-part handle)
5239 (or (mm-decompress-buffer
5240 (or (mail-content-type-get (mm-handle-type handle)
5242 (mail-content-type-get (mm-handle-disposition handle)
5248 (unless (setq charset (mail-content-type-get
5249 (mm-handle-type handle) 'charset))
5250 (unless (setq coding-system
5251 (mm-with-unibyte-buffer
5253 (mm-find-buffer-file-coding-system)))
5254 (setq charset gnus-newsgroup-charset))))
5256 (if (mm-handle-undisplayer handle)
5257 (mm-remove-part handle))
5260 gnus-summary-show-article-charset-alist))
5261 (mm-read-coding-system "Charset: "))))
5263 (if (mm-handle-undisplayer handle)
5264 (mm-remove-part handle))))
5266 (mm-display-inline handle)
5269 (defun gnus-mime-set-charset-parameters (handle charset)
5270 "Set CHARSET to parameters in HANDLE.
5271 CHARSET may either be a string or a symbol."
5272 (unless (stringp charset)
5273 (setq charset (symbol-name charset)))
5274 (if (stringp (car handle))
5275 (dolist (h (cdr handle))
5276 (gnus-mime-set-charset-parameters h charset))
5277 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5278 "message/external-body")
5280 (unless (mm-handle-cache handle)
5281 (mm-extern-cache-contents handle))
5282 (mm-handle-cache handle))
5284 (param (assq 'charset (cdr type))))
5286 (setcdr param charset)
5287 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5289 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5290 "Insert the MIME part under point into the current buffer using the
5292 (interactive (list nil current-prefix-arg))
5293 (gnus-article-check-buffer)
5294 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5295 (fun (get-text-property (point) 'gnus-callback))
5296 (gnus-newsgroup-ignored-charsets 'gnus-all)
5297 charset form preferred parts)
5304 gnus-summary-show-article-charset-alist))
5305 (mm-read-coding-system "Charset: "))))
5306 (if (mm-handle-undisplayer handle)
5307 (mm-remove-part handle)))
5308 (gnus-mime-set-charset-parameters handle charset)
5309 (when (and (consp (setq form (cdr-safe fun)))
5310 (setq form (ignore-errors
5311 (assq 'gnus-mime-display-alternative form)))
5312 (setq preferred (caddr form))
5314 (when (eq (car preferred) 'quote)
5315 (setq preferred (cadr preferred)))
5316 (not (equal preferred
5317 (get-text-property (point) 'gnus-data))))
5318 (setq parts (get-text-property (point) 'gnus-part))
5319 (setq parts (cdr (assq parts
5320 gnus-article-mime-handle-alist)))
5321 (equal (mm-handle-media-type parts) "multipart/alternative")
5322 (setq parts (reverse (cdr parts))))
5324 (list 'quote (or (cadr (member preferred parts))
5326 (funcall fun handle)))))
5328 (defun gnus-mime-view-part-externally (&optional handle)
5329 "View the MIME part under point with an external viewer."
5331 (gnus-article-check-buffer)
5332 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5333 (mm-user-display-methods nil)
5334 (mm-inlined-types nil)
5335 (mail-parse-charset gnus-newsgroup-charset)
5336 (mail-parse-ignored-charsets
5337 (with-current-buffer gnus-summary-buffer
5338 gnus-newsgroup-ignored-charsets))
5339 (type (mm-handle-media-type handle))
5340 (method (mailcap-mime-info type))
5341 (mm-enable-external t))
5342 (if (not (stringp method))
5343 (gnus-mime-view-part-as-type
5344 nil (lambda (type) (stringp (mailcap-mime-info type))))
5346 (mm-display-part handle nil t)))))
5348 (defun gnus-mime-view-part-internally (&optional handle)
5349 "View the MIME part under point with an internal viewer.
5350 If no internal viewer is available, use an external viewer."
5352 (gnus-article-check-buffer)
5353 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5354 (mm-inlined-types '(".*"))
5355 (mm-inline-large-images t)
5356 (mail-parse-charset gnus-newsgroup-charset)
5357 (mail-parse-ignored-charsets
5358 (with-current-buffer gnus-summary-buffer
5359 gnus-newsgroup-ignored-charsets))
5360 (inhibit-read-only t))
5361 (if (not (mm-inlinable-p handle))
5362 (gnus-mime-view-part-as-type
5363 nil (lambda (type) (mm-inlinable-p handle type)))
5365 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5367 (defun gnus-mime-action-on-part (&optional action)
5368 "Do something with the MIME attachment at \(point\)."
5370 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5371 (gnus-article-check-buffer)
5372 (let ((action-pair (assoc action gnus-mime-action-alist)))
5374 (funcall (cdr action-pair)))))
5376 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5377 "Call FUNCTION on MIME part N.
5378 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5379 If INTERACTIVE, call FUNCTION interactivly."
5381 ;; Check whether the article is displayed.
5382 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5383 (setq window (get-buffer-window gnus-article-buffer t))
5384 (frame-visible-p (setq frame (window-frame window))))
5385 (error "No article is displayed"))
5386 (with-current-buffer gnus-article-buffer
5387 ;; Check whether the article displays the right contents.
5388 (unless (with-current-buffer gnus-summary-buffer
5389 (eq gnus-current-article (gnus-summary-article-number)))
5390 (error "You should select the right article first"))
5392 (setq n (prefix-numeric-value n))
5394 (setq n (or (get-text-property pt 'gnus-part)
5396 (get-text-property (1- pt) 'gnus-part))
5397 (get-text-property (prog2
5403 (or (and (setq pt (previous-single-property-change
5406 (next-single-property-change (point) 'gnus-part)
5410 ;; Check whether the specified part exists.
5411 (when (> n (length gnus-article-mime-handle-alist))
5412 (error "No such part")))
5415 ;; To select the window is needed so that the cursor
5416 ;; might be visible on the MIME button.
5417 (select-window (prog1
5419 (setq window (selected-window))
5420 ;; Article may be displayed in the other frame.
5421 (gnus-select-frame-set-input-focus
5424 (setq frame (selected-frame))))))
5425 (when (gnus-article-goto-part n)
5426 ;; We point the cursor and the arrow at the MIME button
5427 ;; when the `function' prompt the user for something.
5428 (unless (and (pos-visible-in-window-p)
5429 (> (count-lines (point) (window-end))
5430 (/ (1- (window-height)) 3)))
5431 (recenter (/ (1- (window-height)) 3)))
5432 (let ((cursor-in-non-selected-windows t)
5433 (overlay-arrow-string "=>")
5434 (overlay-arrow-position (point-marker)))
5437 ((and no-handle interactive)
5438 (call-interactively function))
5443 function (get-text-property (point) 'gnus-data)))
5446 (get-text-property (point) 'gnus-data))))
5447 (set-marker overlay-arrow-position nil)
5448 (unless gnus-auto-select-part
5449 (gnus-select-frame-set-input-focus frame)
5450 (select-window window))))
5452 (if gnus-inhibit-mime-unbuttonizing
5453 ;; This is the default though the program shouldn't reach here.
5454 (error "No such part")
5455 ;; The part which doesn't have the MIME button is selected.
5456 ;; So, we display all the buttons and redo it.
5457 (let ((gnus-inhibit-mime-unbuttonizing t))
5458 (gnus-summary-show-article)
5459 (gnus-article-part-wrapper n function no-handle))))))
5461 (defun gnus-article-pipe-part (n)
5462 "Pipe MIME part N, which is the numerical prefix."
5464 (gnus-article-part-wrapper n 'mm-pipe-part))
5466 (defun gnus-article-save-part (n)
5467 "Save MIME part N, which is the numerical prefix."
5469 (gnus-article-part-wrapper n 'mm-save-part))
5471 (defun gnus-article-interactively-view-part (n)
5472 "View MIME part N interactively, which is the numerical prefix."
5474 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5476 (defun gnus-article-copy-part (n)
5477 "Copy MIME part N, which is the numerical prefix."
5479 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5481 (defun gnus-article-view-part-as-charset (n)
5482 "View MIME part N using a specified charset.
5483 N is the numerical prefix."
5485 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5487 (defun gnus-article-view-part-externally (n)
5488 "View MIME part N externally, which is the numerical prefix."
5490 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5492 (defun gnus-article-inline-part (n)
5493 "Inline MIME part N, which is the numerical prefix."
5495 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5497 (defun gnus-article-save-part-and-strip (n)
5498 "Save MIME part N and replace it with an external body.
5499 N is the numerical prefix."
5501 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5503 (defun gnus-article-replace-part (n)
5504 "Replace MIME part N with an external body.
5505 N is the numerical prefix."
5507 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5509 (defun gnus-article-delete-part (n)
5510 "Delete MIME part N and add some information about the removed part.
5511 N is the numerical prefix."
5513 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5515 (defun gnus-article-view-part-as-type (n)
5516 "Choose a MIME media type, and view part N as such.
5517 N is the numerical prefix."
5519 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5521 (defun gnus-article-mime-match-handle-first (condition)
5524 (dolist (ihandle gnus-article-mime-handle-alist)
5526 ((functionp condition)
5527 (funcall condition (cdr ihandle)))
5528 ((eq condition 'undisplayed)
5529 (not (or (mm-handle-undisplayer (cdr ihandle))
5530 (equal (mm-handle-media-type (cdr ihandle))
5531 "multipart/alternative"))))
5532 ((eq condition 'undisplayed-alternative)
5533 (not (mm-handle-undisplayer (cdr ihandle))))
5535 (gnus-article-goto-part (car ihandle))
5536 (or (not n) (< (car ihandle) n)))
5537 (setq n (car ihandle))))
5541 (defun gnus-article-view-part (&optional n)
5542 "View MIME part N, which is the numerical prefix.
5543 If the part is already shown, hide the part. If N is nil, view
5546 (with-current-buffer gnus-article-buffer
5547 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5548 gnus-article-mime-match-handle-function)))
5549 (when (> n (length gnus-article-mime-handle-alist))
5550 (error "No such part"))
5551 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5552 (when (gnus-article-goto-part n)
5553 (if (equal (car handle) "multipart/alternative")
5554 (gnus-article-press-button)
5555 (when (eq (gnus-mm-display-part handle) 'internal)
5556 (gnus-set-window-start)))))))
5558 (defsubst gnus-article-mime-total-parts ()
5559 (if (bufferp (car gnus-article-mime-handles))
5561 (1- (length gnus-article-mime-handles))))
5563 (defun gnus-mm-display-part (handle)
5564 "Display HANDLE and fix MIME button."
5565 (let ((id (get-text-property (point) 'gnus-part))
5567 (inhibit-read-only t))
5570 (let ((window (selected-window))
5571 (mail-parse-charset gnus-newsgroup-charset)
5572 (mail-parse-ignored-charsets
5573 (if (gnus-buffer-live-p gnus-summary-buffer)
5574 (with-current-buffer gnus-summary-buffer
5575 gnus-newsgroup-ignored-charsets)
5579 (let ((win (gnus-get-buffer-window (current-buffer) t))
5582 (select-window win))
5585 (if (mm-handle-displayed-p handle)
5586 ;; This will remove the part.
5587 (mm-display-part handle)
5589 (narrow-to-region (point)
5590 (if (eobp) (point) (1+ (point))))
5591 (gnus-bind-safe-url-regexp (mm-display-part handle))
5592 ;; We narrow to the part itself and
5593 ;; then call the treatment functions.
5594 (goto-char (point-min))
5596 (narrow-to-region (point) (point-max))
5599 (gnus-article-mime-total-parts)
5600 (mm-handle-media-type handle)))))
5601 (if (window-live-p window)
5602 (select-window window)))))
5605 (gnus-insert-mime-button
5606 handle id (list (mm-handle-displayed-p handle)))
5607 (goto-char point))))
5609 (defun gnus-article-goto-part (n)
5610 "Go to MIME part N."
5611 (when gnus-break-pages
5614 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5615 part handle end next handles)
5618 (if (setq handle (get-text-property start 'gnus-data))
5620 ;; Go to the displayed subpart, assuming this is
5621 ;; multipart/alternative.
5624 (while (and (not handle)
5627 (setq next (text-property-not-all part end
5630 handle (get-text-property part 'gnus-data))
5631 (push (cons handle part) handles)
5632 (unless (mm-handle-displayed-p handle)
5634 part (text-property-any part end 'gnus-data nil))))
5636 ;; No subpart is displayed, so we find preferred one.
5638 (cdr (assq (mm-preferred-alternative
5639 (nreverse (mapcar 'car handles)))
5642 (goto-char (1+ part))
5644 (when gnus-break-pages
5645 (gnus-narrow-to-page))))
5647 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5648 (let ((gnus-tmp-name
5649 (or (mail-content-type-get (mm-handle-type handle) 'name)
5650 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5651 (mail-content-type-get (mm-handle-type handle) 'url)
5653 (gnus-tmp-type (mm-handle-media-type handle))
5654 (gnus-tmp-description (or (mm-handle-description handle) ""))
5656 (if (if displayed (car displayed)
5657 (mm-handle-displayed-p handle))
5659 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5661 gnus-tmp-type-long b e)
5662 (when (string-match ".*/" gnus-tmp-name)
5663 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5664 (setq gnus-tmp-type-long (concat gnus-tmp-type
5665 (and (not (equal gnus-tmp-name ""))
5666 (concat "; " gnus-tmp-name))))
5667 (unless (equal gnus-tmp-description "")
5668 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5673 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5674 `(keymap ,gnus-mime-button-map
5675 gnus-callback gnus-mm-display-part
5676 gnus-part ,gnus-tmp-id
5677 article-type annotation
5680 ;; Exclude a newline.
5683 (when gnus-article-button-face
5684 (gnus-overlay-put (gnus-make-overlay b e nil t)
5685 'face gnus-article-button-face))
5686 (widget-convert-button
5689 :action 'gnus-widget-press-button
5690 :button-keymap gnus-mime-button-map
5693 ;; Needed to properly clear the message due to a bug in
5694 ;; wid-edit (XEmacs only).
5695 (if (boundp 'help-echo-owns-message)
5696 (setq help-echo-owns-message t))
5698 "%S: %s the MIME part; %S: more options"
5699 (aref gnus-mouse-2 0)
5700 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5702 (aref gnus-down-mouse-3 0))))))
5704 (defun gnus-widget-press-button (elems el)
5705 (goto-char (widget-get elems :from))
5706 (gnus-article-press-button))
5708 (defvar gnus-displaying-mime nil)
5710 (defun gnus-display-mime (&optional ihandles)
5711 "Display the MIME parts."
5713 (save-selected-window
5714 (let ((window (get-buffer-window gnus-article-buffer))
5717 (select-window window)
5718 ;; We have to do this since selecting the window
5719 ;; may change the point. So we set the window point.
5720 (set-window-point window point)))
5721 (let ((handles ihandles)
5722 (inhibit-read-only t)
5725 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5726 (when gnus-article-emulate-mime
5727 (mm-uu-dissect-text-parts handles)))
5728 (gnus-article-emulate-mime
5729 (setq handles (mm-uu-dissect))))
5730 (when (and (not ihandles)
5731 (not gnus-displaying-mime))
5732 ;; Top-level call; we clean up.
5733 (when gnus-article-mime-handles
5734 (mm-destroy-parts gnus-article-mime-handles)
5735 (setq gnus-article-mime-handle-alist nil));; A trick.
5736 (setq gnus-article-mime-handles handles)
5737 ;; We allow users to glean info from the handles.
5738 (when gnus-article-mime-part-function
5739 (gnus-mime-part-function handles)))
5741 (or (not (stringp (car handles)))
5744 (when (and (not ihandles)
5745 (not gnus-displaying-mime))
5746 ;; Clean up for mime parts.
5748 (delete-region (point) (point-max)))
5749 (let ((gnus-displaying-mime t))
5750 (gnus-mime-display-part handles)))
5753 (narrow-to-region (point) (point-max))
5754 (gnus-treat-article nil 1 1 "text/plain")
5757 ;; Highlight the headers.
5761 (narrow-to-region (point-min) (point))
5762 (gnus-article-save-original-date
5763 (gnus-treat-article 'head)))))))
5764 ;; Cope with broken MIME messages.
5765 (goto-char (point-max))
5769 (defcustom gnus-mime-display-multipart-as-mixed nil
5770 "Display \"multipart\" parts as \"multipart/mixed\".
5772 If t, it overrides nil values of
5773 `gnus-mime-display-multipart-alternative-as-mixed' and
5774 `gnus-mime-display-multipart-related-as-mixed'."
5775 :group 'gnus-article-mime
5778 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5779 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5781 :group 'gnus-article-mime
5784 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5785 "Display \"multipart/related\" parts as \"multipart/mixed\".
5787 If displaying \"text/html\" is discouraged \(see
5788 `mm-discouraged-alternatives'\) images or other material inside a
5789 \"multipart/related\" part might be overlooked when this variable is nil."
5791 :group 'gnus-article-mime
5794 (defun gnus-mime-display-part (handle)
5796 ;; Maybe a broken MIME message.
5799 ((not (stringp (car handle)))
5800 (gnus-mime-display-single handle))
5801 ;; User-defined multipart
5802 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5803 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5805 ;; multipart/alternative
5806 ((and (equal (car handle) "multipart/alternative")
5807 (not (or gnus-mime-display-multipart-as-mixed
5808 gnus-mime-display-multipart-alternative-as-mixed)))
5809 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5810 (push (cons id handle) gnus-article-mime-handle-alist)
5811 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5812 ;; multipart/related
5813 ((and (equal (car handle) "multipart/related")
5814 (not (or gnus-mime-display-multipart-as-mixed
5815 gnus-mime-display-multipart-related-as-mixed)))
5816 ;;;!!!We should find the start part, but we just default
5817 ;;;!!!to the first part.
5818 ;;(gnus-mime-display-part (cadr handle))
5819 ;;;!!! Most multipart/related is an HTML message plus images.
5820 ;;;!!! Unfortunately we are unable to let W3 display those
5821 ;;;!!! included images, so we just display it as a mixed multipart.
5822 ;;(gnus-mime-display-mixed (cdr handle))
5823 ;;;!!! No, w3 can display everything just fine.
5824 (gnus-mime-display-part (cadr handle)))
5825 ((equal (car handle) "multipart/signed")
5826 (gnus-add-wash-type 'signed)
5827 (gnus-mime-display-security handle))
5828 ((equal (car handle) "multipart/encrypted")
5829 (gnus-add-wash-type 'encrypted)
5830 (gnus-mime-display-security handle))
5831 ;; Other multiparts are handled like multipart/mixed.
5833 (gnus-mime-display-mixed (cdr handle)))))
5835 (defun gnus-mime-part-function (handles)
5836 (if (stringp (car handles))
5837 (mapcar 'gnus-mime-part-function (cdr handles))
5838 (funcall gnus-article-mime-part-function handles)))
5840 (defun gnus-mime-display-mixed (handles)
5841 (mapcar 'gnus-mime-display-part handles))
5843 (defun gnus-mime-display-single (handle)
5844 (let ((type (mm-handle-media-type handle))
5845 (ignored gnus-ignored-mime-types)
5852 (when (string-match (pop ignored) type)
5853 (throw 'ignored nil)))
5854 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5855 (with-current-buffer gnus-summary-buffer
5856 gnus-inhibit-images)
5857 gnus-inhibit-images)
5858 (string-match "\\`image/" type)))
5859 (setq not-attachment
5860 (and (not (mm-inline-override-p handle))
5861 (or (not (mm-handle-disposition handle))
5862 (equal (car (mm-handle-disposition handle))
5864 (mm-attachment-override-p handle))))
5865 (mm-automatic-display-p handle)
5867 (mm-inlinable-p handle)
5868 (mm-inlined-p handle))
5869 (mm-automatic-external-display-p type)))
5871 (when (equal (mm-handle-media-supertype handle) "text")
5873 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5875 (push (cons id handle) gnus-article-mime-handle-alist)
5877 (equal (mm-handle-media-supertype handle) "message"))
5880 (cond ((not (bolp)) 2)
5881 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5883 (when (or (not display)
5884 (not (gnus-unbuttonized-mime-type-p type))
5885 (eq id gnus-mime-buttonized-part-id))
5886 (gnus-insert-mime-button
5887 handle id (list (or display (and not-attachment text))))
5888 (gnus-article-insert-newline)
5889 ;; Remember modify the number of forward lines.
5897 (let ((mail-parse-charset gnus-newsgroup-charset)
5898 (mail-parse-ignored-charsets
5899 (save-excursion (condition-case ()
5900 (set-buffer gnus-summary-buffer)
5902 gnus-newsgroup-ignored-charsets)))
5903 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5904 (goto-char (point-max)))
5905 ((and text not-attachment)
5909 (gnus-article-insert-newline)
5910 (mm-display-inline handle)
5911 (goto-char (point-max))))
5915 (narrow-to-region beg (point))
5916 (if (eq handle gnus-article-mime-handles)
5917 ;; The format=flowed case.
5918 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5919 ;; Don't count signature parts that are never displayed.
5920 ;; The part number should be re-calculated supposing this
5921 ;; might be a message/rfc822 part.
5923 (dolist (part gnus-article-mime-handles)
5924 (unless (or (stringp part)
5925 (equal (car (mm-handle-type part))
5926 "application/pgp-signature"))
5927 (push part handles)))
5929 nil (length (memq handle handles)) (length handles)
5930 (mm-handle-media-type handle)))))))))))
5932 (defun gnus-unbuttonized-mime-type-p (type)
5933 "Say whether TYPE is to be unbuttonized."
5934 (unless gnus-inhibit-mime-unbuttonizing
5936 (let ((types gnus-unbuttonized-mime-types))
5938 (when (string-match (pop types) type)
5939 (throw 'found t)))))
5941 (let ((types gnus-buttonized-mime-types))
5943 (when (string-match (pop types) type)
5944 (throw 'found t)))))))))
5946 (defun gnus-article-insert-newline ()
5947 "Insert a newline, but mark it as undeletable."
5948 (gnus-put-text-property
5949 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5951 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5952 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5955 handle (inhibit-read-only t) from props begend not-pref)
5956 (save-window-excursion
5959 (narrow-to-region (car ibegend)
5962 (goto-char (car ibegend))
5965 (delete-region (point-min) (point-max))
5966 (mm-remove-parts handles))
5967 (setq begend (list (point-marker)))
5969 (unless (setq not-pref (cadr (member preferred ihandles)))
5970 (setq not-pref (car ihandles)))
5973 (not (gnus-unbuttonized-mime-type-p
5974 "multipart/alternative")))
5975 (gnus-add-text-properties
5978 (insert (format "%d. " id))
5982 (unless ,(not ibegend)
5983 (setq gnus-article-mime-handle-alist
5984 ',gnus-article-mime-handle-alist))
5985 (gnus-mime-display-alternative
5986 ',ihandles ',not-pref ',begend ,id))
5987 keymap ,gnus-mime-button-map
5988 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5989 face ,gnus-article-button-face
5991 article-type multipart))
5992 (widget-convert-button 'link from (point)
5993 :action 'gnus-widget-press-button
5994 :button-keymap gnus-widget-button-keymap)
5996 (while (setq handle (pop handles))
5997 (gnus-add-text-properties
6000 (insert (format "(%c) %-18s"
6001 (if (equal handle preferred) ?* ? )
6002 (mm-handle-media-type handle)))
6006 (unless ,(not ibegend)
6007 (setq gnus-article-mime-handle-alist
6008 ',gnus-article-mime-handle-alist))
6009 (gnus-mime-display-alternative
6010 ',ihandles ',handle ',begend ,id))
6011 keymap ,gnus-mime-button-map
6012 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6013 face ,gnus-article-button-face
6016 (widget-convert-button 'link from (point)
6017 :action 'gnus-widget-press-button
6018 :button-keymap gnus-widget-button-keymap)
6022 (if (stringp (car preferred))
6023 (gnus-display-mime preferred)
6024 (let ((mail-parse-charset gnus-newsgroup-charset)
6025 (mail-parse-ignored-charsets
6026 (with-current-buffer gnus-summary-buffer
6027 gnus-newsgroup-ignored-charsets)))
6028 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6032 (narrow-to-region (car begend) (point-max))
6034 nil (length gnus-article-mime-handle-alist)
6035 (gnus-article-mime-total-parts)
6036 (mm-handle-media-type preferred))))))
6037 (goto-char (point-max))
6038 (setcdr begend (point-marker)))))
6040 (goto-char point))))
6042 (defconst gnus-article-wash-status-strings
6043 (let ((alist '((cite "c" "Possible hidden citation text"
6044 " " "All citation text visible")
6045 (headers "h" "Hidden headers"
6046 " " "All headers visible.")
6047 (pgp "p" "Encrypted or signed message status hidden"
6048 " " "No hidden encryption nor digital signature status")
6049 (signature "s" "Signature has been hidden"
6050 " " "Signature is visible")
6051 (overstrike "o" "Overstrike (^H) characters applied"
6052 " " "No overstrike characters applied")
6053 (emphasis "e" "/*_Emphasis_*/ characters applied"
6054 " " "No /*_emphasis_*/ characters applied")))
6056 (dolist (entry alist result)
6057 (let ((key (nth 0 entry))
6058 (on (copy-sequence (nth 1 entry)))
6059 (on-help (nth 2 entry))
6060 (off (copy-sequence (nth 3 entry)))
6061 (off-help (nth 4 entry)))
6062 (put-text-property 0 1 'help-echo on-help on)
6063 (put-text-property 0 1 'help-echo off-help off)
6064 (push (list key on off) result))))
6065 "Alist of strings describing wash status in the mode line.
6066 Each entry has the form (KEY ON OF), where the KEY is a symbol
6067 representing the particular washing function, ON is the string to use
6068 in the article mode line when the washing function is active, and OFF
6069 is the string to use when it is inactive.")
6071 (defun gnus-article-wash-status-entry (key value)
6072 (let ((entry (assoc key gnus-article-wash-status-strings)))
6073 (if value (nth 1 entry) (nth 2 entry))))
6075 (defun gnus-article-wash-status ()
6076 "Return a string which display status of article washing."
6077 (with-current-buffer gnus-article-buffer
6078 (let ((cite (memq 'cite gnus-article-wash-types))
6079 (headers (memq 'headers gnus-article-wash-types))
6080 (boring (memq 'boring-headers gnus-article-wash-types))
6081 (pgp (memq 'pgp gnus-article-wash-types))
6082 (pem (memq 'pem gnus-article-wash-types))
6083 (signed (memq 'signed gnus-article-wash-types))
6084 (encrypted (memq 'encrypted gnus-article-wash-types))
6085 (signature (memq 'signature gnus-article-wash-types))
6086 (overstrike (memq 'overstrike gnus-article-wash-types))
6087 (emphasis (memq 'emphasis gnus-article-wash-types)))
6089 (gnus-article-wash-status-entry 'cite cite)
6090 (gnus-article-wash-status-entry 'headers (or headers boring))
6091 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6092 (gnus-article-wash-status-entry 'signature signature)
6093 (gnus-article-wash-status-entry 'overstrike overstrike)
6094 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6096 (defun gnus-add-wash-type (type)
6097 "Add a washing of TYPE to the current status."
6098 (add-to-list 'gnus-article-wash-types type))
6100 (defun gnus-delete-wash-type (type)
6101 "Add a washing of TYPE to the current status."
6102 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6104 (defun gnus-add-image (category image)
6105 "Add IMAGE of CATEGORY to the list of displayed images."
6106 (let ((entry (assq category gnus-article-image-alist)))
6108 (setq entry (list category))
6109 (push entry gnus-article-image-alist))
6110 (nconc entry (list image))))
6112 (defun gnus-delete-images (category)
6113 "Delete all images in CATEGORY."
6114 (let ((entry (assq category gnus-article-image-alist)))
6115 (dolist (image (cdr entry))
6116 (gnus-remove-image image category))
6117 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6118 (gnus-delete-wash-type category)))
6120 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6122 (defun gnus-article-maybe-hide-headers ()
6123 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6124 Provided for backwards compatibility."
6125 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6126 (not (with-current-buffer gnus-summary-buffer
6127 gnus-have-all-headers)))
6128 (not gnus-inhibit-hiding))
6129 (gnus-article-hide-headers)))
6133 (defun gnus-output-to-file (file-name)
6134 "Append the current article to a file named FILE-NAME.
6135 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6136 text and used as the value of the coding cookie which is added to the
6137 top of a file. Otherwise, this function saves a raw article without
6139 (let* ((artbuf (current-buffer))
6140 (file-name-coding-system nnmail-pathname-coding-system)
6141 (coding gnus-article-save-coding-system)
6142 (coding-system-for-read (if coding
6143 nil ;; Rely on the coding cookie.
6144 mm-text-coding-system))
6145 (coding-system-for-write (or coding
6146 mm-text-coding-system-for-write
6147 mm-text-coding-system))
6148 (exists (file-exists-p file-name)))
6151 (insert-file-contents file-name)
6152 (goto-char (point-min))
6153 ;; Remove the existing coding cookie.
6154 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6155 (delete-region (match-beginning 0) (match-end 0))))
6156 (goto-char (point-max))
6157 (insert-buffer-substring artbuf)
6158 ;; Append newline at end of the buffer as separator, and then
6160 (goto-char (point-max))
6163 ;; If the coding system is not suitable to encode the text,
6164 ;; ask a user for a proper one.
6165 (when (fboundp 'select-safe-coding-system)
6166 (setq coding (coding-system-base
6167 (save-window-excursion
6168 (select-safe-coding-system (point-min) (point-max)
6170 (setq coding-system-for-write
6171 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6173 (goto-char (point-min))
6174 ;; Add the coding cookie.
6175 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6176 coding-system-for-write)))
6179 (write-region (point-min) (point-max) file-name nil 'no-message)
6180 (message "Appended to %s" file-name))
6181 (write-region (point-min) (point-max) file-name))))
6184 (defun gnus-narrow-to-page (&optional arg)
6185 "Narrow the article buffer to a page.
6186 If given a numerical ARG, move forward ARG pages."
6188 (setq arg (if arg (prefix-numeric-value arg) 0))
6189 (with-current-buffer gnus-article-buffer
6191 ;; Remove any old next/prev buttons.
6192 (when (gnus-visual-p 'page-marker)
6193 (let ((inhibit-read-only t))
6194 (gnus-remove-text-with-property 'gnus-prev)
6195 (gnus-remove-text-with-property 'gnus-next)))
6197 (when (save-excursion
6199 (if (re-search-backward page-delimiter nil 'move (abs arg))
6201 (setq nd (match-beginning 0)
6203 (when (re-search-backward page-delimiter nil t)
6204 (setq st (match-end 0))))
6205 (when (re-search-forward page-delimiter nil t)
6206 (setq nd (match-beginning 0)
6209 (if (re-search-forward page-delimiter nil 'move arg)
6211 (setq st (match-end 0)
6213 (when (re-search-forward page-delimiter nil t)
6214 (setq nd (match-beginning 0))))
6215 (when (re-search-backward page-delimiter nil t)
6216 (setq st (match-end 0)
6219 (when (re-search-backward page-delimiter nil t)
6220 (goto-char (setq st (match-end 0))))
6221 (when (re-search-forward page-delimiter nil t)
6222 (setq nd (match-beginning 0)))
6224 (setq gnus-page-broken t)
6225 (when pt (goto-char pt))
6226 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6227 (when (gnus-visual-p 'page-marker)
6231 (gnus-insert-next-page-button))
6234 (gnus-insert-prev-page-button))))))))
6236 ;; Article mode commands
6238 (defun gnus-article-goto-next-page ()
6239 "Show the next page of the article."
6241 (when (gnus-article-next-page)
6242 (goto-char (point-min))
6243 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6246 (defun gnus-article-goto-prev-page ()
6247 "Show the previous page of the article."
6249 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6250 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6251 (gnus-article-prev-page nil)))
6253 ;; This is cleaner but currently breaks `gnus-pick-mode':
6255 ;; (defun gnus-article-goto-next-page ()
6256 ;; "Show the next page of the article."
6258 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6259 ;; (gnus-summary-next-page)))
6261 ;; (defun gnus-article-goto-prev-page ()
6262 ;; "Show the next page of the article."
6264 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6265 ;; (gnus-summary-prev-page)))
6267 (defun gnus-article-next-page (&optional lines)
6268 "Show the next page of the current article.
6269 If end of article, return non-nil. Otherwise return nil.
6270 Argument LINES specifies lines to be scrolled up."
6272 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6273 (if (and (not (and gnus-article-over-scroll
6274 (> (count-lines (window-start) (point-max))
6275 (if (featurep 'xemacs)
6276 (or lines (1- (window-height)))
6277 (+ (or lines (1- (window-height))) scroll-margin)))))
6280 (and (pos-visible-in-window-p) ;Not continuation line.
6281 (>= (point) (point-max)))))
6282 ;; Nothing in this page.
6283 (if (or (not gnus-page-broken)
6288 (eobp)))) ;Real end-of-buffer?
6290 (when gnus-article-over-scroll
6291 (gnus-article-next-page-1 lines))
6293 (gnus-narrow-to-page 1) ;Go to next page.
6295 ;; More in this page.
6296 (gnus-article-next-page-1 lines)
6299 (defun gnus-article-beginning-of-window ()
6300 "Move point to the beginning of the window.
6301 In Emacs, the point is placed at the line number which `scroll-margin'
6303 (if (featurep 'xemacs)
6304 (move-to-window-line 0)
6305 ;; There is an obscure bug in Emacs that makes it impossible to
6306 ;; scroll past big pictures in the article buffer. Try to fix
6307 ;; this by adding a sanity check by counting the lines visible.
6308 (when (> (count-lines (window-start) (window-end)) 30)
6309 (move-to-window-line
6310 (min (max 0 scroll-margin)
6311 (max 1 (- (window-height)
6312 (if mode-line-format 1 0)
6313 (if header-line-format 1 0)
6316 (defun gnus-article-next-page-1 (lines)
6318 (let ((scroll-in-place nil))
6321 ;; Long lines may cause an end-of-buffer error.
6322 (goto-char (point-max))))
6323 (gnus-article-beginning-of-window))
6325 (defun gnus-article-prev-page (&optional lines)
6326 "Show previous page of current article.
6327 Argument LINES specifies lines to be scrolled down."
6329 (move-to-window-line 0)
6330 (if (and gnus-page-broken
6332 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6334 (gnus-narrow-to-page -1) ;Go to previous page.
6335 (goto-char (point-max))
6336 (recenter (if gnus-article-over-scroll
6338 (max (if (featurep 'xemacs)
6340 (+ lines scroll-margin))
6342 (- (window-height) 2))
6346 (let ((scroll-in-place nil))
6347 (scroll-down lines))
6348 (beginning-of-buffer
6349 (goto-char (point-min))))
6350 (gnus-article-beginning-of-window))))
6352 (defun gnus-article-only-boring-p ()
6353 "Decide whether there is only boring text remaining in the article.
6354 Something \"interesting\" is a word of at least two letters that does
6355 not have a face in `gnus-article-boring-faces'."
6356 (when (and gnus-article-skip-boring
6357 (boundp 'gnus-article-boring-faces)
6358 (symbol-value 'gnus-article-boring-faces))
6360 (let ((inhibit-point-motion-hooks t))
6362 (while (re-search-forward "\\b\\w\\w" nil t)
6364 (when (not (gnus-intersection
6365 (gnus-faces-at (point))
6366 (symbol-value 'gnus-article-boring-faces)))
6367 (throw 'only-boring nil)))
6368 (throw 'only-boring t))))))
6370 (defun gnus-article-refer-article ()
6371 "Read article specified by message-id around point."
6374 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6375 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6376 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6377 (let ((msg-id (concat "<" (match-string 0) ">")))
6378 (set-buffer gnus-summary-buffer)
6379 (gnus-summary-refer-article msg-id))
6380 (error "No references around point"))))
6382 (defun gnus-article-show-summary ()
6383 "Reconfigure windows to show summary buffer."
6385 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6386 (error "There is no summary buffer for this article buffer")
6387 (gnus-article-set-globals)
6388 (gnus-configure-windows 'article)
6389 (gnus-summary-goto-subject gnus-current-article)
6390 (gnus-summary-position-point)))
6392 (defun gnus-article-describe-briefly ()
6393 "Describe article mode commands briefly."
6395 (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")))
6397 (defun gnus-article-check-buffer ()
6398 "Beep if not in an article buffer."
6399 (unless (equal major-mode 'gnus-article-mode)
6400 (error "Command invoked outside of a Gnus article buffer")))
6402 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6403 "Read a summary buffer key sequence and execute it from the article buffer."
6405 (gnus-article-check-buffer)
6407 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6408 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6409 "=" "^" "\M-^" "|"))
6411 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6412 "An" "Ap" [?A (meta return)] [?A delete]))
6416 '("n" "Gn" "p" "Gp"))
6418 (with-current-buffer gnus-article-current-summary
6419 (let (gnus-pick-mode)
6420 (setq unread-command-events (nconc unread-command-events
6421 (list (or key last-command-event)))
6422 keys (if (featurep 'xemacs)
6423 (events-to-keys (read-key-sequence nil t))
6424 (read-key-sequence nil t)))))
6429 ((eq (aref keys (1- (length keys))) ?\C-h)
6430 (gnus-article-describe-bindings (substring keys 0 -1)))
6431 ((or (member keys nosaves)
6432 (member keys nosave-but-article)
6433 (member keys nosave-in-article))
6435 (save-window-excursion
6436 (pop-to-buffer gnus-article-current-summary)
6437 ;; We disable the pick minor mode commands.
6438 (let (gnus-pick-mode)
6439 (setq func (key-binding keys t))))
6443 (unless (member keys nosave-in-article)
6444 (set-buffer gnus-article-current-summary))
6445 (when (get func 'disabled)
6446 (error "Function %s disabled" func))
6447 (call-interactively func)
6448 (setq new-sum-point (point)))
6449 (when (member keys nosave-but-article)
6450 (pop-to-buffer gnus-article-buffer))))
6452 ;; These commands should restore window configuration.
6453 (let ((obuf (current-buffer))
6454 (owin (current-window-configuration))
6455 win func in-buffer selected new-sum-start new-sum-hscroll err)
6456 (cond (not-restore-window
6457 (pop-to-buffer gnus-article-current-summary)
6458 (setq win (selected-window)))
6459 ((setq win (get-buffer-window gnus-article-current-summary))
6460 (select-window win))
6462 (let ((summary-buffer gnus-article-current-summary))
6463 (gnus-configure-windows 'article)
6464 (unless (setq win (get-buffer-window summary-buffer 'visible))
6465 (let ((gnus-buffer-configuration
6466 '((article ((vertical 1.0
6467 (summary 0.25 point)
6469 (gnus-configure-windows 'article))
6470 (setq win (get-buffer-window summary-buffer 'visible)))
6471 (gnus-select-frame-set-input-focus (window-frame win))
6472 (select-window win))))
6473 (setq in-buffer (current-buffer))
6474 ;; We disable the pick minor mode commands.
6475 (setq func (let (gnus-pick-mode)
6476 (key-binding keys t)))
6477 (when (get func 'disabled)
6478 (error "Function %s disabled" func))
6481 (condition-case code
6483 (call-interactively func)
6489 (when (eq win (selected-window))
6490 (setq new-sum-point (point)
6491 new-sum-start (window-start win)
6492 new-sum-hscroll (window-hscroll win)))
6493 (when (or (eq in-buffer (current-buffer))
6494 (when (eq obuf (current-buffer))
6495 (set-buffer in-buffer)
6497 (setq selected (gnus-summary-select-article))
6499 (unless not-restore-window
6500 (set-window-configuration owin))
6501 (when (and (eq selected 'old)
6503 (set-window-start (get-buffer-window (current-buffer))
6505 (set-window-point (get-buffer-window (current-buffer))
6506 (if (article-goto-body)
6509 (when (and (not not-restore-window)
6512 (with-current-buffer (window-buffer win)
6513 (eq major-mode 'gnus-summary-mode)))
6514 (set-window-point win new-sum-point)
6515 (set-window-start win new-sum-start)
6516 (set-window-hscroll win new-sum-hscroll))))
6517 (set-window-configuration owin)
6519 (signal (car err) (cdr err))
6522 (defun gnus-article-read-summary-send-keys ()
6524 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6525 (gnus-article-read-summary-keys)))
6527 (defun gnus-article-describe-key (key)
6528 "Display documentation of the function invoked by KEY.
6529 KEY is a string or a vector."
6530 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6531 (read-key-sequence "Describe key: "))))
6532 (gnus-article-check-buffer)
6533 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6534 gnus-article-read-summary-send-keys))
6535 (with-current-buffer gnus-article-current-summary
6536 (setq unread-command-events
6537 (if (featurep 'xemacs)
6539 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6540 (list 'meta (- x 128))
6543 (let ((cursor-in-echo-area t)
6545 (describe-key (read-key-sequence nil t))))
6546 (describe-key key)))
6548 (defun gnus-article-describe-key-briefly (key &optional insert)
6549 "Display documentation of the function invoked by KEY.
6550 KEY is a string or a vector."
6551 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6552 (read-key-sequence "Describe key: "))
6553 current-prefix-arg))
6554 (gnus-article-check-buffer)
6555 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6556 gnus-article-read-summary-send-keys))
6557 (with-current-buffer gnus-article-current-summary
6558 (setq unread-command-events
6559 (if (featurep 'xemacs)
6561 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6562 (list 'meta (- x 128))
6565 (let ((cursor-in-echo-area t)
6567 (describe-key-briefly (read-key-sequence nil t) insert)))
6568 (describe-key-briefly key insert)))
6570 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6571 (defvar gnus-agent-summary-mode)
6572 (defvar gnus-draft-mode)
6573 ;; Calling help-buffer will autoload help-mode.
6574 (defvar help-xref-stack-item)
6575 ;; Emacs 22 doesn't load it in the batch mode.
6577 (autoload 'help-buffer "help-mode"))
6579 (defun gnus-article-describe-bindings (&optional prefix)
6580 "Show a list of all defined keys, and their definitions.
6581 The optional argument PREFIX, if non-nil, should be a key sequence;
6582 then we display only bindings that start with that prefix."
6584 (gnus-article-check-buffer)
6585 (let ((keymap (copy-keymap gnus-article-mode-map))
6586 (map (copy-keymap gnus-article-send-map))
6587 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6589 (define-key keymap "S" map)
6590 (define-key map [t] nil)
6591 (with-current-buffer gnus-article-current-summary
6594 (if (setq parent (keymap-parent gnus-article-mode-map))
6596 (setq parent (copy-keymap parent))
6597 (set-keymap-parent parent (current-local-map)))
6598 (current-local-map)))
6599 (set-keymap-parent map (key-binding "S"))
6600 (let (key def gnus-pick-mode)
6602 (setq key (pop sumkeys))
6603 (cond ((and (vectorp key) (= (length key) 1)
6604 (consp (setq def (aref key 0)))
6605 (numberp (car def)) (numberp (cdr def)))
6606 (when (< (max (car def) (cdr def)) 128)
6610 (nreverse (gnus-uncompress-range def)))
6612 ((setq def (key-binding key))
6613 (unless (eq def 'undefined)
6614 (define-key keymap key def))))))
6615 (when (boundp 'gnus-agent-summary-mode)
6616 (setq agent gnus-agent-summary-mode))
6617 (when (boundp 'gnus-draft-mode)
6618 (setq draft gnus-draft-mode)))
6620 (use-local-map keymap)
6621 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6622 (set (make-local-variable 'gnus-draft-mode) draft)
6623 (describe-bindings prefix))
6624 (let ((item `((lambda (prefix)
6625 (with-current-buffer ,(current-buffer)
6626 (gnus-article-describe-bindings prefix)))
6628 (with-current-buffer (let (help-xref-following) (help-buffer))
6629 (setq help-xref-stack-item item)))))
6631 (defun gnus-article-reply-with-original (&optional wide)
6632 "Start composing a reply mail to the current message.
6633 The text in the region will be yanked. If the region isn't active,
6634 the entire article will be yanked."
6636 (let ((article (cdr gnus-article-current))
6638 (if (not (gnus-region-active-p))
6639 (with-current-buffer gnus-summary-buffer
6640 (gnus-summary-reply (list (list article)) wide))
6641 (setq contents (buffer-substring (point) (mark t)))
6642 ;; Deactivate active regions.
6643 (when (and (boundp 'transient-mark-mode)
6644 transient-mark-mode)
6645 (setq mark-active nil))
6646 (with-current-buffer gnus-summary-buffer
6648 (list (list article contents)) wide)))))
6650 (defun gnus-article-wide-reply-with-original ()
6651 "Start composing a wide reply mail to the current message.
6652 The text in the region will be yanked. If the region isn't active,
6653 the entire article will be yanked."
6655 (gnus-article-reply-with-original t))
6657 (defun gnus-article-followup-with-original ()
6658 "Compose a followup to the current article.
6659 The text in the region will be yanked. If the region isn't active,
6660 the entire article will be yanked."
6662 (let ((article (cdr gnus-article-current))
6664 (if (not (gnus-region-active-p))
6665 (with-current-buffer gnus-summary-buffer
6666 (gnus-summary-followup (list (list article))))
6667 (setq contents (buffer-substring (point) (mark t)))
6668 ;; Deactivate active regions.
6669 (when (and (boundp 'transient-mark-mode)
6670 transient-mark-mode)
6671 (setq mark-active nil))
6672 (with-current-buffer gnus-summary-buffer
6673 (gnus-summary-followup
6674 (list (list article contents)))))))
6676 (defun gnus-article-hide (&optional arg force)
6677 "Hide all the gruft in the current article.
6678 This means that signatures, cited text and (some) headers will be
6680 If given a prefix, show the hidden text instead."
6681 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6682 (gnus-article-hide-headers arg)
6683 (gnus-article-hide-list-identifiers arg)
6684 (gnus-article-hide-citation-maybe arg force)
6685 (gnus-article-hide-signature arg))
6687 (defun gnus-article-maybe-highlight ()
6688 "Do some article highlighting if article highlighting is requested."
6689 (when (gnus-visual-p 'article-highlight 'highlight)
6690 (gnus-article-highlight-some)))
6692 (defun gnus-check-group-server ()
6693 ;; Make sure the connection to the server is alive.
6694 (unless (gnus-server-opened
6695 (gnus-find-method-for-group gnus-newsgroup-name))
6696 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6697 (gnus-request-group gnus-newsgroup-name t)))
6700 (autoload 'nneething-get-file-name "nneething"))
6702 (defun gnus-request-article-this-buffer (article group)
6703 "Get an article and insert it into this buffer."
6704 (let (do-update-line sparse-header)
6708 (gnus-kill-all-overlays)
6709 (setq group (or group gnus-newsgroup-name))
6711 ;; Using `gnus-request-article' directly will insert the article into
6712 ;; `nntp-server-buffer' - so we'll save some time by not having to
6713 ;; copy it from the server buffer into the article buffer.
6715 ;; We only request an article by message-id when we do not have the
6716 ;; headers for it, so we'll have to get those.
6717 (when (stringp article)
6718 (gnus-read-header article))
6720 ;; If the article number is negative, that means that this article
6721 ;; doesn't belong in this newsgroup (possibly), so we find its
6722 ;; message-id and request it by id instead of number.
6723 (when (and (numberp article)
6725 (get-buffer gnus-summary-buffer)
6726 (gnus-buffer-exists-p gnus-summary-buffer))
6727 (with-current-buffer gnus-summary-buffer
6728 (let ((header (gnus-summary-article-header article)))
6731 ((memq article gnus-newsgroup-sparse)
6732 ;; This is a sparse gap article.
6733 (setq do-update-line article)
6734 (setq article (mail-header-id header))
6735 (setq sparse-header (gnus-read-header article))
6736 (setq gnus-newsgroup-sparse
6737 (delq article gnus-newsgroup-sparse)))
6739 ;; It's a real article.
6740 (setq article (mail-header-id header)))
6742 ;; It is an extracted pseudo-article.
6743 (setq article 'pseudo)
6744 (gnus-request-pseudo-article header))))
6746 (let ((method (gnus-find-method-for-group
6747 gnus-newsgroup-name)))
6748 (when (and (eq (car method) 'nneething)
6750 (let ((dir (nneething-get-file-name
6751 (mail-header-id header))))
6752 (when (and (stringp dir)
6753 (file-directory-p dir))
6754 (setq article 'nneething)
6755 (gnus-group-enter-directory dir))))))))
6758 ;; Refuse to select canceled articles.
6759 ((and (numberp article)
6761 (get-buffer gnus-summary-buffer)
6762 (gnus-buffer-exists-p gnus-summary-buffer)
6763 (eq (cdr (with-current-buffer gnus-summary-buffer
6764 (assq article gnus-newsgroup-reads)))
6765 gnus-canceled-mark))
6767 ;; We first check `gnus-original-article-buffer'.
6768 ((and (get-buffer gnus-original-article-buffer)
6770 (with-current-buffer gnus-original-article-buffer
6771 (and (equal (car gnus-original-article) group)
6772 (eq (cdr gnus-original-article) article))))
6773 ;; `insert-buffer-substring' would incorrectly use the
6774 ;; equivalent of string-make-multibyte which amount to decoding
6775 ;; with locale-coding-system, causing failure of
6776 ;; subsequent decoding.
6777 (insert (mm-string-to-multibyte
6778 (with-current-buffer gnus-original-article-buffer
6779 (buffer-substring (point-min) (point-max)))))
6781 ;; Check the backlog.
6782 ((and gnus-keep-backlog
6783 (gnus-backlog-request-article group article (current-buffer)))
6785 ;; Check asynchronous pre-fetch.
6786 ((gnus-async-request-fetched-article group article (current-buffer))
6787 (gnus-async-prefetch-next group article gnus-summary-buffer)
6788 (when (and (numberp article) gnus-keep-backlog)
6789 (gnus-backlog-enter-article group article (current-buffer)))
6792 ((and gnus-use-cache
6794 (gnus-cache-request-article article group))
6796 ;; Check the agent cache.
6797 ((gnus-agent-request-article article group)
6799 ;; Get the article and put into the article buffer.
6800 ((or (stringp article)
6802 (let ((gnus-override-method gnus-override-method)
6803 (methods (and (stringp article)
6804 gnus-refer-article-method))
6805 (backend (car (gnus-find-method-for-group
6806 gnus-newsgroup-name)))
6808 (inhibit-read-only t))
6809 (if (or (not (listp methods))
6810 (and (symbolp (car methods))
6811 (assq (car methods) nnoo-definition-alist)))
6812 (setq methods (list methods)))
6813 (when (and (null gnus-override-method)
6815 (setq gnus-override-method (pop methods)))
6817 (when (eq gnus-override-method 'current)
6818 (setq gnus-override-method
6819 (with-current-buffer gnus-summary-buffer
6820 gnus-current-select-method)))
6822 (gnus-kill-all-overlays)
6823 (let ((gnus-newsgroup-name group))
6824 (gnus-check-group-server))
6826 ((gnus-request-article article group (current-buffer))
6827 (when (numberp article)
6828 (gnus-async-prefetch-next group article
6829 gnus-summary-buffer)
6830 (when gnus-keep-backlog
6831 (gnus-backlog-enter-article
6832 group article (current-buffer))))
6833 (setq result 'article))
6835 (setq gnus-override-method (pop methods)))
6836 ((not (string-match "^400 "
6837 (nnheader-get-report backend)))
6838 ;; If we get 400 server disconnect, reconnect and
6839 ;; retry; otherwise, assume the article has expired.
6840 (setq result 'done))))
6841 (and (eq result 'article) 'article)))
6845 ;; Associate this article with the current summary buffer.
6846 (setq gnus-article-current-summary gnus-summary-buffer)
6848 ;; Take the article from the original article buffer
6849 ;; and place it in the buffer it's supposed to be in.
6850 (when (and (get-buffer gnus-article-buffer)
6851 (equal (buffer-name (current-buffer))
6852 (buffer-name (get-buffer gnus-article-buffer))))
6854 (if (get-buffer gnus-original-article-buffer)
6855 (set-buffer gnus-original-article-buffer)
6856 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6857 (buffer-disable-undo)
6858 (setq major-mode 'gnus-original-article-mode)
6859 (setq buffer-read-only t))
6860 (let ((inhibit-read-only t))
6862 (insert-buffer-substring gnus-article-buffer))
6863 (setq gnus-original-article (cons group article)))
6866 (run-hooks 'gnus-article-decode-hook)
6867 ;; Mark article as decoded or not.
6868 (setq gnus-article-decoded-p gnus-article-decode-hook))
6870 ;; Update sparse articles.
6871 (when (and do-update-line
6872 (or (numberp article)
6874 (let ((buf (current-buffer)))
6875 (set-buffer gnus-summary-buffer)
6876 (gnus-summary-update-article do-update-line sparse-header)
6877 (gnus-summary-goto-subject do-update-line nil t)
6878 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6880 (set-buffer buf))))))
6882 (defun gnus-block-private-groups (group)
6883 (if (gnus-news-group-p group)
6884 ;; Block nothing in news groups.
6886 ;; Block everything anywhere else.
6889 (defun gnus-blocked-images ()
6890 (if (functionp gnus-blocked-images)
6891 (funcall gnus-blocked-images gnus-newsgroup-name)
6892 gnus-blocked-images))
6898 (defcustom gnus-article-edit-mode-hook nil
6899 "Hook run in article edit mode buffers."
6900 :group 'gnus-article-various
6903 (defvar gnus-article-edit-done-function nil)
6905 (defvar gnus-article-edit-mode-map nil)
6907 ;; Should we be using derived.el for this?
6908 (unless gnus-article-edit-mode-map
6909 (setq gnus-article-edit-mode-map (make-keymap))
6910 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6912 (gnus-define-keys gnus-article-edit-mode-map
6913 "\C-c?" describe-mode
6914 "\C-c\C-c" gnus-article-edit-done
6915 "\C-c\C-k" gnus-article-edit-exit
6916 "\C-c\C-f\C-t" message-goto-to
6917 "\C-c\C-f\C-o" message-goto-from
6918 "\C-c\C-f\C-b" message-goto-bcc
6919 ;;"\C-c\C-f\C-w" message-goto-fcc
6920 "\C-c\C-f\C-c" message-goto-cc
6921 "\C-c\C-f\C-s" message-goto-subject
6922 "\C-c\C-f\C-r" message-goto-reply-to
6923 "\C-c\C-f\C-n" message-goto-newsgroups
6924 "\C-c\C-f\C-d" message-goto-distribution
6925 "\C-c\C-f\C-f" message-goto-followup-to
6926 "\C-c\C-f\C-m" message-goto-mail-followup-to
6927 "\C-c\C-f\C-k" message-goto-keywords
6928 "\C-c\C-f\C-u" message-goto-summary
6929 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6930 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6931 "\C-c\C-b" message-goto-body
6932 "\C-c\C-i" message-goto-signature
6934 "\C-c\C-t" message-insert-to
6935 "\C-c\C-n" message-insert-newsgroups
6936 "\C-c\C-o" message-sort-headers
6937 "\C-c\C-e" message-elide-region
6938 "\C-c\C-v" message-delete-not-region
6939 "\C-c\C-z" message-kill-to-signature
6940 "\M-\r" message-newline-and-reformat
6941 "\C-c\C-a" mml-attach-file
6942 "\C-a" message-beginning-of-line
6944 "\M-;" comment-region)
6946 (gnus-define-keys (gnus-article-edit-wash-map
6947 "\C-c\C-w" gnus-article-edit-mode-map)
6948 "f" gnus-article-edit-full-stops))
6951 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6953 ["Fetch To" message-insert-to t]
6954 ["Fetch Newsgroups" message-insert-newsgroups t]
6956 ["To" message-goto-to t]
6957 ["From" message-goto-from t]
6958 ["Subject" message-goto-subject t]
6959 ["Cc" message-goto-cc t]
6960 ["Reply-To" message-goto-reply-to t]
6961 ["Summary" message-goto-summary t]
6962 ["Keywords" message-goto-keywords t]
6963 ["Newsgroups" message-goto-newsgroups t]
6964 ["Followup-To" message-goto-followup-to t]
6965 ["Mail-Followup-To" message-goto-mail-followup-to t]
6966 ["Distribution" message-goto-distribution t]
6967 ["Body" message-goto-body t]
6968 ["Signature" message-goto-signature t]))
6970 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6971 "Major mode for editing articles.
6972 This is an extended text-mode.
6974 \\{gnus-article-edit-mode-map}"
6975 (make-local-variable 'gnus-article-edit-done-function)
6976 (make-local-variable 'gnus-prev-winconf)
6977 (set (make-local-variable 'font-lock-defaults)
6978 '(message-font-lock-keywords t))
6979 (set (make-local-variable 'mail-header-separator) "")
6980 (set (make-local-variable 'gnus-article-edit-mode) t)
6981 (easy-menu-add message-mode-field-menu message-mode-map)
6983 (setq buffer-read-only nil)
6984 (buffer-enable-undo)
6987 (defun gnus-article-edit (&optional force)
6988 "Edit the current article.
6989 This will have permanent effect only in mail groups.
6990 If FORCE is non-nil, allow editing of articles even in read-only
6993 (when (and (not force)
6994 (gnus-group-read-only-p))
6995 (error "The current newsgroup does not support article editing"))
6996 (gnus-article-date-original)
6997 (gnus-article-edit-article
6999 `(lambda (no-highlight)
7001 (gnus-summary-edit-article-done
7002 ,(or (mail-header-references gnus-current-headers) "")
7003 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7005 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7006 "Start editing the contents of the current article buffer."
7007 (let ((winconf (current-window-configuration)))
7008 (set-buffer gnus-article-buffer)
7009 (let ((message-auto-save-directory
7010 ;; Don't associate the article buffer with a draft file.
7012 (gnus-article-edit-mode))
7013 (funcall start-func)
7014 (set-buffer-modified-p nil)
7015 (gnus-configure-windows 'edit-article)
7016 (setq gnus-article-edit-done-function exit-func)
7017 (setq gnus-prev-winconf winconf)
7019 (gnus-message 6 "C-c C-c to end edits"))))
7021 (defun gnus-article-edit-done (&optional arg)
7022 "Update the article edits and exit."
7024 (let ((func gnus-article-edit-done-function)
7025 (buf (current-buffer))
7026 (start (window-start))
7028 (winconf gnus-prev-winconf))
7029 (widen) ;; Widen it in case that users narrowed the buffer.
7032 ;; The cache and backlog have to be flushed somewhat.
7033 (when gnus-keep-backlog
7034 (gnus-backlog-remove-article
7035 (car gnus-article-current) (cdr gnus-article-current)))
7036 ;; Flush original article as well.
7037 (gnus-flush-original-article-buffer)
7038 (when gnus-use-cache
7039 (gnus-cache-update-article
7040 (car gnus-article-current) (cdr gnus-article-current)))
7041 ;; We remove all text props from the article buffer.
7042 (kill-all-local-variables)
7043 (set-text-properties (point-min) (point-max) nil)
7045 (set-window-configuration winconf)
7047 (set-window-start (get-buffer-window buf) start)
7048 (set-window-point (get-buffer-window buf) (point)))
7049 (gnus-summary-show-article))
7051 (defun gnus-flush-original-article-buffer ()
7052 (when (get-buffer gnus-original-article-buffer)
7053 (with-current-buffer gnus-original-article-buffer
7054 (setq gnus-original-article nil))))
7056 (defun gnus-article-edit-exit ()
7057 "Exit the article editing without updating."
7059 (when (or (not (buffer-modified-p))
7060 (yes-or-no-p "Article modified; kill anyway? "))
7061 (let ((curbuf (current-buffer))
7063 (window-start (window-start)))
7065 (if (gnus-buffer-live-p gnus-original-article-buffer)
7066 (insert-buffer-substring gnus-original-article-buffer))
7067 (let ((winconf gnus-prev-winconf))
7068 (kill-all-local-variables)
7070 (set-window-configuration winconf)
7071 ;; Tippy-toe some to make sure that point remains where it was.
7072 (save-current-buffer
7074 (set-window-start (get-buffer-window (current-buffer)) window-start)
7076 (gnus-summary-show-article)))
7078 (defun gnus-article-edit-full-stops ()
7079 "Interactively repair spacing at end of sentences."
7082 (goto-char (point-min))
7083 (search-forward-regexp "^$" nil t)
7084 (let ((case-fold-search nil))
7085 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7088 ;;; Article highlights
7091 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7093 ;;; Internal Variables:
7095 (defcustom gnus-button-url-regexp
7097 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7098 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7099 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7100 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7101 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7105 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7106 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7107 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7109 "[" chars punct "]+" "[" chars "]"
7111 (concat ;; XEmacs 21.4 doesn't support POSIX.
7112 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7113 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7115 "Regular expression that matches URLs."
7116 :group 'gnus-article-buttons
7119 (defcustom gnus-button-valid-fqdn-regexp
7120 message-valid-fqdn-regexp
7121 "Regular expression that matches a valid FQDN."
7123 :group 'gnus-article-buttons
7126 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7127 (defcustom gnus-button-valid-localpart-regexp
7128 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7129 "Regular expression that matches a localpart of mail addresses or MIDs."
7131 :group 'gnus-article-buttons
7134 (defcustom gnus-button-man-handler 'manual-entry
7135 "Function to use for displaying man pages.
7136 The function must take at least one argument with a string naming the
7139 :type '(choice (function-item :tag "Man" manual-entry)
7140 (function-item :tag "Woman" woman)
7141 (function :tag "Other"))
7142 :group 'gnus-article-buttons)
7144 (defcustom gnus-button-mid-or-mail-regexp
7145 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7146 gnus-button-valid-fqdn-regexp
7148 "Regular expression that matches a message ID or a mail address."
7150 :group 'gnus-article-buttons
7153 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7154 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7155 Strings like this can be either a message ID or a mail address. If it is one
7156 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7157 message ID or a mail address, respectively. If this variable is set to the
7158 symbol `ask', always query the user what do do. If it is a function, this
7159 function will be called with the string as its only argument. The function
7160 must return `mid', `mail', `invalid' or `ask'."
7162 :group 'gnus-article-buttons
7163 :type '(choice (function-item :tag "Heuristic function"
7164 gnus-button-mid-or-mail-heuristic)
7169 (defcustom gnus-button-mid-or-mail-heuristic-alist
7170 '((-10.0 . ".+\\$.+@")
7173 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7174 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7175 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7176 (-1.0 . "^[^a-z]+@")
7178 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7179 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7180 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7181 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7184 (-1.0 . "^[0-9][0-9]")
7186 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7187 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7188 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7189 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7191 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7192 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7195 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7197 ;; compensation for TDMA dated mail addresses:
7198 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7200 (-20.0 . "\\.fsf@") ;; Gnus
7203 (-20.0 . "^alpine\\.")
7204 (-20.0 . "_-_") ;; Subject change in thread
7206 (-20.0 . "\\.ln@") ;; leafnode
7207 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7208 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7210 ;; (5.0 . "") ;; $local_part_len <= 7
7211 (10.0 . "^[^0-9]+@")
7212 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7213 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7216 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7218 (0.5 . "^[A-Z][a-z]")
7219 (0.5 . "^[A-Z][a-z][a-z]")
7220 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7221 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7222 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7224 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7225 address. The REGEXP is processed with `case-fold-search' set to nil."
7227 :group 'gnus-article-buttons
7228 :type '(repeat (cons (number :tag "Rate")
7229 (regexp :tag "Regexp"))))
7231 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7232 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7233 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7234 address, `ask' if unsure and `invalid' if the string is invalid."
7235 (let ((case-fold-search nil)
7236 (list gnus-button-mid-or-mail-heuristic-alist)
7237 (result 0) rate regexp lpartlen elem)
7239 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7240 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7241 ;; Certain special cases...
7244 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7245 "^[0-9]+\\.[0-9]+@compuserve\\|"
7246 "@public\\.gmane\\.org")
7248 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7249 (setq result 'mail))
7250 (when (string-match "@.*@\\| " mid-or-mail)
7251 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7252 (setq result 'invalid))
7253 ;; Nothing more to do, if result is not a number here...
7254 (when (numberp result)
7256 (setq elem (car list)
7260 (when (string-match regexp mid-or-mail)
7261 (setq result (+ result rate))
7263 9 "`%s' matched `%s', rate `%s', result `%s'."
7264 mid-or-mail regexp rate result)))
7265 (when (<= lpartlen 7)
7266 (setq result (+ result 5.0))
7267 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7268 mid-or-mail result))
7269 (when (>= lpartlen 12)
7270 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7272 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7273 ;; Long local part should contain realname if e-mail address,
7274 ;; too many digits: message-id.
7275 ;; $score -= 5.0 + 0.1 * $local_part_len;
7276 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7277 (setq result (+ result rate))
7279 9 "Many digits in `%s', rate `%s', result `%s'."
7280 mid-or-mail rate result))
7281 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7283 ;; Too few vowels [^aeiouy]{4,}.*\@
7284 (setq result (+ result -5.0))
7286 9 "Few vowels in `%s', rate `%s', result `%s'."
7287 mid-or-mail -5.0 result))
7289 (setq result (+ result 5.0))
7291 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7292 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7293 ;; Maybe we should make this a customizable alist: (condition . 'result)
7295 ((symbolp result) result)
7296 ;; Now convert number into proper results:
7297 ((< result -10.0) 'mid)
7298 ((> result 10.0) 'mail)
7301 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7302 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7303 (url-mid (concat "news" ":" mid-or-mail))
7304 (url-mailto (concat "mailto" ":" mid-or-mail)))
7305 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7306 (when (fboundp pref)
7308 ;; get rid of surrounding angles...
7310 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7311 (if (or (eq 'mid guessed) (eq 'mail guessed))
7315 (save-window-excursion
7316 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7319 (cond ((eq pref 'mid)
7320 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7321 (gnus-button-handle-news url-mid))
7323 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7324 (gnus-url-mailto url-mailto))
7325 (t (gnus-message 3 "Invalid string.")))))
7327 (defun gnus-button-handle-custom (fun arg)
7328 "Call function FUN on argument ARG.
7329 Both FUN and ARG are supposed to be strings. ARG will be passed
7330 as a symbol to FUN."
7331 (funcall (intern fun)
7332 (if (string-match "^customize-apropos" fun)
7336 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7338 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7341 (defun gnus-button-handle-describe-function (url)
7342 "Call `describe-function' when pushing the corresponding URL button."
7345 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7347 (defun gnus-button-handle-describe-variable (url)
7348 "Call `describe-variable' when pushing the corresponding URL button."
7351 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7353 (defun gnus-button-handle-symbol (url)
7354 "Display help on variable or function.
7355 Calls `describe-variable' or `describe-function'."
7356 (let ((sym (intern url)))
7358 ((fboundp sym) (describe-function sym))
7359 ((boundp sym) (describe-variable sym))
7360 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7362 (defun gnus-button-handle-describe-key (url)
7363 "Call `describe-key' when pushing the corresponding URL button."
7365 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7366 (keys (ignore-errors (eval `(kbd ,key-string)))))
7369 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7371 (defun gnus-button-handle-apropos (url)
7372 "Call `apropos' when pushing the corresponding URL button."
7373 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7375 (defun gnus-button-handle-apropos-command (url)
7376 "Call `apropos' when pushing the corresponding URL button."
7378 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7380 (defun gnus-button-handle-apropos-variable (url)
7381 "Call `apropos' when pushing the corresponding URL button."
7383 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7384 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7386 (defun gnus-button-handle-apropos-documentation (url)
7387 "Call `apropos' when pushing the corresponding URL button."
7389 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7390 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7392 (defun gnus-button-handle-library (url)
7393 "Call `locate-library' when pushing the corresponding URL button."
7394 (gnus-message 9 "url=`%s'" url)
7395 (let* ((lib (locate-library url))
7396 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7398 (gnus-message 1 "Cannot locale library `%s'." url)
7399 (find-file-read-only file))))
7401 (defcustom gnus-button-man-level 5
7402 "*Integer that says how many man-related buttons Gnus will show.
7403 The higher the number, the more buttons will appear and the more false
7404 positives are possible. Note that you can set this variable local to
7405 specific groups. Setting it higher in Unix groups is probably a good idea.
7406 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7407 how to set variables in specific groups."
7409 :group 'gnus-article-buttons
7410 :link '(custom-manual "(gnus)Group Parameters")
7413 (defcustom gnus-button-emacs-level 5
7414 "*Integer that says how many emacs-related buttons Gnus will show.
7415 The higher the number, the more buttons will appear and the more false
7416 positives are possible. Note that you can set this variable local to
7417 specific groups. Setting it higher in Emacs or Gnus related groups is
7418 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7419 `gnus-parameters' on how to set variables in specific groups."
7421 :group 'gnus-article-buttons
7422 :link '(custom-manual "(gnus)Group Parameters")
7425 (defcustom gnus-button-message-level 5
7426 "*Integer that says how many buttons for news or mail messages will appear.
7427 The higher the number, the more buttons will appear and the more false
7428 positives are possible."
7429 ;; mail addresses, MIDs, URLs for news, ...
7431 :group 'gnus-article-buttons
7434 (defcustom gnus-button-browse-level 5
7435 "*Integer that says how many buttons for browsing will appear.
7436 The higher the number, the more buttons will appear and the more false
7437 positives are possible."
7438 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7440 :group 'gnus-article-buttons
7443 (defcustom gnus-button-alist
7444 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7445 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7446 ((concat "\\b\\(nntp\\|news\\):\\("
7447 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7448 0 t gnus-button-handle-news 2)
7449 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7450 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7451 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7452 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7453 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7454 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7455 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7456 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7457 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7458 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7459 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7460 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7461 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7462 ;; RFC 2368 (The mailto URL scheme)
7463 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7464 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7465 ("\\bmailto:\\([^ \n\t]+\\)"
7466 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7467 ;; Info Konqueror style <info:/foo/bar baz>.
7468 ;; Must come before " Gnus home-grown style".
7469 ("\\binfo://?\\([^'\">\n\t]+\\)"
7470 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7471 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7472 ("\\binfo://\\([^'\">\n\t ]+\\)"
7473 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7474 ;; Info GNOME style <info:foo#bar_baz>
7475 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7476 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7477 ;; Info KDE style <info:(foo)bar baz>
7478 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7479 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7480 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7481 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7482 ("\\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,]*\\)\\)?"
7483 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7484 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7486 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7487 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7488 ;; Emacs help commands
7489 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7490 ;; regexp doesn't match arguments containing ` '.
7491 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7492 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7493 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7494 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7495 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7496 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7497 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7498 ;; The following entries may lead to many false positives so don't enable
7499 ;; them by default (use a high button level).
7500 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7501 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7502 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7503 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7504 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7505 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7506 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7507 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7508 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7509 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7510 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7511 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7512 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7513 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7514 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7515 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7516 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7517 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7518 ;; Unlike the other regexps we really have to require quoting
7519 ;; here to determine where it ends.
7520 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7521 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7522 ("<URL: *\\([^\n<>]*\\)>"
7523 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7524 ;; RFC 2396 (2.4.3., delims) ...
7525 ("\"URL: *\\([^\n\"]*\\)\""
7526 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7528 (gnus-button-url-regexp
7529 0 (>= gnus-button-browse-level 0) browse-url 0)
7531 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7532 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7533 gnus-button-handle-man 1)
7534 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7535 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7536 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7537 gnus-button-handle-man 1)
7538 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7539 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7540 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7541 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7542 ;; Recognizing patches to .el files. This is somewhat obscure,
7543 ;; but considering the percentage of Gnus users who hack Emacs
7545 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7546 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7547 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7548 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7549 ;; MID or mail: To avoid too many false positives we don't try to catch
7550 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7551 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7552 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7553 ;; so that non-ambiguous entries (see above) match first.
7554 (gnus-button-mid-or-mail-regexp
7555 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7556 "*Alist of regexps matching buttons in article bodies.
7558 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7559 REGEXP: is the string (case insensitive) matching text around the button (can
7560 also be Lisp expression evaluating to a string),
7561 BUTTON: is the number of the regexp grouping actually matching the button,
7562 FORM: is a Lisp expression which must eval to true for the button to
7564 CALLBACK: is the function to call when the user push this button, and each
7565 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7567 CALLBACK can also be a variable, in that case the value of that
7568 variable it the real callback function."
7569 :group 'gnus-article-buttons
7570 :type '(repeat (list (choice regexp variable sexp)
7571 (integer :tag "Button")
7573 (function :tag "Callback")
7576 (integer :tag "Regexp group")))))
7577 (put 'gnus-button-alist 'risky-local-variable t)
7579 (defcustom gnus-header-button-alist
7580 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7581 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7582 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7583 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7584 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7585 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7586 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7587 0 (>= gnus-button-browse-level 0) browse-url 0)
7588 ("^Subject:" gnus-button-url-regexp
7589 0 (>= gnus-button-browse-level 0) browse-url 0)
7590 ("^[^:]+:" gnus-button-url-regexp
7591 0 (>= gnus-button-browse-level 0) browse-url 0)
7592 ("^OpenPGP:.*url=" gnus-button-url-regexp
7593 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7594 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7595 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7596 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7597 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7598 "*Alist of headers and regexps to match buttons in article heads.
7600 This alist is very similar to `gnus-button-alist', except that each
7601 alist has an additional HEADER element first in each entry:
7603 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7605 HEADER is a regexp to match a header. For a fuller explanation, see
7606 `gnus-button-alist'."
7607 :group 'gnus-article-buttons
7608 :group 'gnus-article-headers
7609 :type '(repeat (list (regexp :tag "Header")
7610 (choice regexp variable)
7611 (integer :tag "Button")
7613 (function :tag "Callback")
7616 (integer :tag "Regexp group")))))
7617 (put 'gnus-header-button-alist 'risky-local-variable t)
7621 (defun gnus-article-push-button (event)
7622 "Check text under the mouse pointer for a callback function.
7623 If the text under the mouse pointer has a `gnus-callback' property,
7624 call it with the value of the `gnus-data' text property."
7626 (set-buffer (window-buffer (posn-window (event-start event))))
7627 (let* ((pos (posn-point (event-start event)))
7628 (data (get-text-property pos 'gnus-data))
7629 (fun (get-text-property pos 'gnus-callback)))
7632 (funcall fun data))))
7634 (defun gnus-article-press-button ()
7635 "Check text at point for a callback function.
7636 If the text at point has a `gnus-callback' property,
7637 call it with the value of the `gnus-data' text property."
7639 (let ((data (get-text-property (point) 'gnus-data))
7640 (fun (get-text-property (point) 'gnus-callback)))
7642 (funcall fun data))))
7644 (defun gnus-article-highlight (&optional force)
7645 "Highlight current article.
7646 This function calls `gnus-article-highlight-headers',
7647 `gnus-article-highlight-citation',
7648 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7649 do the highlighting. See the documentation for those functions."
7650 (interactive (list 'force))
7651 (gnus-article-highlight-headers)
7652 (gnus-article-highlight-citation force)
7653 (gnus-article-highlight-signature)
7654 (gnus-article-add-buttons)
7655 (gnus-article-add-buttons-to-head))
7657 (defun gnus-article-highlight-some (&optional force)
7658 "Highlight current article.
7659 This function calls `gnus-article-highlight-headers',
7660 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7661 do the highlighting. See the documentation for those functions."
7662 (interactive (list 'force))
7663 (gnus-article-highlight-headers)
7664 (gnus-article-highlight-signature)
7665 (gnus-article-add-buttons))
7667 (defun gnus-article-highlight-headers ()
7668 "Highlight article headers as specified by `gnus-header-face-alist'."
7670 (gnus-with-article-headers
7671 (let (regexp header-face field-face from hpoints fpoints)
7672 (dolist (entry gnus-header-face-alist)
7673 (goto-char (point-min))
7674 (setq regexp (concat "^\\("
7675 (if (string-equal "" (nth 0 entry))
7679 header-face (nth 1 entry)
7680 field-face (nth 2 entry))
7681 (while (and (re-search-forward regexp nil t)
7685 (unless (search-forward ":" nil t)
7687 (when (and header-face
7688 (not (memq (point) hpoints)))
7689 (push (point) hpoints)
7690 (gnus-put-text-property from (point) 'face header-face))
7691 (when (and field-face
7692 (not (memq (setq from (point)) fpoints)))
7694 (if (re-search-forward "^[^ \t]" nil t)
7696 (goto-char (point-max)))
7697 (gnus-put-text-property from (point) 'face field-face)))))))
7699 (defun gnus-article-highlight-signature ()
7700 "Highlight the signature in an article.
7701 It does this by highlighting everything after
7702 `gnus-signature-separator' using the face `gnus-signature'."
7704 (gnus-with-article-buffer
7705 (let ((inhibit-point-motion-hooks t))
7707 (when (and gnus-signature-face
7708 (gnus-article-narrow-to-signature))
7709 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7710 'face gnus-signature-face)
7712 (gnus-article-search-signature)
7713 (let ((start (match-beginning 0))
7714 (end (set-marker (make-marker) (1+ (match-end 0)))))
7715 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7718 (defun gnus-button-in-region-p (b e prop)
7719 "Say whether PROP exists in the region."
7720 (text-property-not-all b e prop nil))
7722 (defun gnus-article-add-buttons ()
7723 "Find external references in the article and make buttons of them.
7724 \"External references\" are things like Message-IDs and URLs, as
7725 specified by `gnus-button-alist'."
7727 (gnus-with-article-buffer
7728 (let ((inhibit-point-motion-hooks t)
7729 (case-fold-search t)
7730 (alist gnus-button-alist)
7732 ;; We skip the headers.
7735 (while (setq entry (pop alist))
7736 (setq regexp (eval (car entry)))
7738 (while (re-search-forward regexp nil t)
7739 (let ((start (match-beginning (nth 1 entry)))
7740 (end (match-end (nth 1 entry)))
7741 (from (match-beginning 0)))
7742 (when (and (eval (nth 2 entry))
7743 (not (gnus-button-in-region-p
7744 start end 'gnus-callback)))
7745 ;; That optional form returned non-nil, so we add the
7747 (setq from (set-marker (make-marker) from))
7748 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7749 (gnus-article-extend-url-button from start end))
7750 (gnus-article-add-button start end
7751 'gnus-button-push (list from entry))
7752 (gnus-put-text-property
7754 'gnus-string (buffer-substring-no-properties
7757 (defun gnus-article-extend-url-button (beg start end)
7758 "Extend url button if url is folded into two or more lines.
7759 Return non-nil if button is extended. BEG is a marker that points to
7760 the beginning position of a text containing url. START and END are
7761 the endpoints of a url button before it is extended. The concatenated
7762 url is put as the `gnus-button-url' overlay property on the button."
7763 (let ((opoint (point))
7764 (points (list start end))
7769 (not (looking-at "[\t ]*[\">]")))
7773 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7774 (buffer-substring (point-at-bol) start)))
7776 (setq url (list (buffer-substring start end))
7777 delim (if (match-beginning 1) ">" "\""))
7779 (setq regexp (concat
7780 (when (and (looking-at
7781 message-cite-prefix-regexp)
7782 (< (match-end 0) start))
7783 (regexp-quote (match-string 0)))
7785 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7789 (and (looking-at regexp)
7792 (push (or (match-string 2)
7795 (push (setq end (or (match-end 2)
7798 (push (or (match-beginning 2)
7799 (match-beginning 1))
7801 (match-beginning 2)))
7802 (let (gnus-article-mouse-face widget-mouse-face)
7804 (gnus-article-add-button (pop points) (pop points)
7805 'gnus-button-push beg)))
7806 (let ((overlay (gnus-make-overlay start end)))
7807 (gnus-overlay-put overlay 'evaporate t)
7808 (gnus-overlay-put overlay 'gnus-button-url
7809 (list (mapconcat 'identity (nreverse url) "")))
7810 (when gnus-article-mouse-face
7811 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7813 (goto-char opoint))))
7815 ;; Add buttons to the head of an article.
7816 (defun gnus-article-add-buttons-to-head ()
7817 "Add buttons to the head of the article."
7819 (gnus-with-article-headers
7821 (dolist (entry gnus-header-button-alist)
7822 ;; Each alist entry.
7823 (goto-char (point-min))
7824 (while (re-search-forward (car entry) nil t)
7825 ;; Each header matching the entry.
7826 (setq beg (match-beginning 0))
7827 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7828 (match-beginning 0))
7831 (while (re-search-forward (eval (nth 1 entry)) end t)
7832 ;; Each match within a header.
7833 (let* ((entry (cdr entry))
7834 (start (match-beginning (nth 1 entry)))
7835 (end (match-end (nth 1 entry)))
7836 (form (nth 2 entry)))
7837 (goto-char (match-end 0))
7839 (gnus-article-add-button
7840 start end (nth 3 entry)
7841 (buffer-substring (match-beginning (nth 4 entry))
7842 (match-end (nth 4 entry)))))))
7843 (goto-char end))))))
7845 ;;; External functions:
7847 (defun gnus-article-add-button (from to fun &optional data text)
7848 "Create a button between FROM and TO with callback FUN and data DATA."
7849 (when gnus-article-button-face
7850 (gnus-overlay-put (gnus-make-overlay from to nil t)
7851 'face gnus-article-button-face))
7852 (gnus-add-text-properties
7854 (nconc (and gnus-article-mouse-face
7855 (list gnus-mouse-face-prop gnus-article-mouse-face))
7856 (list 'gnus-callback fun)
7857 (and data (list 'gnus-data data))))
7858 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7859 :help-echo (or text "Follow the link")
7860 :keymap gnus-url-button-map
7861 :button-keymap gnus-widget-button-keymap))
7863 (defun gnus-article-copy-string ()
7864 "Copy the string in the button to the kill ring."
7866 (gnus-article-check-buffer)
7867 (let ((data (get-text-property (point) 'gnus-string)))
7871 (copy-region-as-kill (point-min) (point-max))
7872 (message "Copied %s" data)))))
7874 ;;; Internal functions:
7876 (defun gnus-article-set-globals ()
7877 (with-current-buffer gnus-summary-buffer
7878 (gnus-set-global-variables)))
7880 (defun gnus-signature-toggle (end)
7881 (gnus-with-article-buffer
7882 (let ((inhibit-point-motion-hooks t))
7883 (if (text-property-any end (point-max) 'article-type 'signature)
7885 (gnus-delete-wash-type 'signature)
7886 (gnus-remove-text-properties-when
7887 'article-type 'signature end (point-max)
7888 (cons 'article-type (cons 'signature
7889 gnus-hidden-properties))))
7890 (gnus-add-wash-type 'signature)
7891 (gnus-add-text-properties-when
7892 'article-type nil end (point-max)
7893 (cons 'article-type (cons 'signature
7894 gnus-hidden-properties)))))
7895 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7896 (gnus-set-mode-line 'article))))
7898 (defun gnus-button-push (marker-and-entry)
7899 ;; Push button starting at MARKER.
7901 (let* ((marker (car marker-and-entry))
7902 (entry (cadr marker-and-entry))
7903 (regexp (car entry))
7904 (inhibit-point-motion-hooks t))
7906 ;; This is obviously true, or something bad is happening :)
7907 ;; But we need it to have the match-data
7908 (when (looking-at (or (if (symbolp regexp)
7909 (symbol-value regexp)
7911 (let ((fun (nth 3 entry))
7912 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7913 (get-char-property marker 'gnus-button-url))
7914 (mapcar (lambda (group)
7915 (let ((string (match-string group)))
7916 (set-text-properties
7917 0 (length string) nil string)
7919 (nthcdr 4 entry)))))
7925 (fboundp (symbol-value fun)))
7926 (apply (symbol-value fun) args))
7928 (gnus-message 1 "You must define `%S' to use this button"
7929 (cons fun args)))))))))
7931 (defun gnus-parse-news-url (url)
7932 (let (scheme server port group message-id articles)
7935 (goto-char (point-min))
7936 (when (looking-at "\\([A-Za-z]+\\):")
7937 (setq scheme (match-string 1))
7938 (goto-char (match-end 0)))
7939 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7940 (setq server (match-string 1))
7941 (setq port (if (stringp (match-string 3))
7942 (string-to-number (match-string 3))
7944 (goto-char (match-end 0)))
7947 ((looking-at "\\(.*@.*\\)")
7948 (setq message-id (match-string 1)))
7949 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7950 (setq group (match-string 1)
7951 articles (split-string (match-string 2) "-")))
7952 ((looking-at "\\([^/]+\\)/?")
7953 (setq group (match-string 1)))
7955 (error "Unknown news URL syntax"))))
7956 (list scheme server port group message-id articles)))
7958 (defun gnus-button-handle-news (url)
7960 (destructuring-bind (scheme server port group message-id articles)
7961 (gnus-parse-news-url url)
7964 (with-current-buffer gnus-summary-buffer
7966 (let ((gnus-refer-article-method
7967 (nconc (list (list 'nntp server))
7968 gnus-refer-article-method))
7969 (nntp-port-number (or port "nntp")))
7970 (gnus-message 7 "Fetching %s with %s"
7971 message-id gnus-refer-article-method)
7972 (gnus-summary-refer-article message-id))
7973 (gnus-summary-refer-article message-id))))
7975 (gnus-button-fetch-group url)))))
7977 (defun gnus-button-patch (library line)
7978 "Visit an Emacs Lisp library LIBRARY on line LINE."
7980 (let ((file (locate-library (file-name-nondirectory library))))
7982 (error "Couldn't find library %s" library))
7984 (goto-char (point-min))
7985 (forward-line (1- (string-to-number line)))))
7987 (defun gnus-button-handle-man (url)
7989 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7990 (when (eq gnus-button-man-handler 'woman)
7991 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7992 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7993 (funcall gnus-button-man-handler url))
7995 (defun gnus-button-handle-info-url (url)
7996 "Fetch an info URL."
7997 (setq url (mm-subst-char-in-string ?+ ?\ url))
7999 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8000 (gnus-info-find-node
8001 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8003 ")" (gnus-url-unhex-string (match-string 2 url)))))
8004 ((string-match "([^)\"]+)[^\"]+" url)
8006 (gnus-replace-in-string
8007 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8008 (gnus-info-find-node url))
8009 (t (error "Can't parse %s" url))))
8011 (defun gnus-button-handle-info-url-gnome (url)
8012 "Fetch GNOME style info URL."
8013 (setq url (mm-subst-char-in-string ?_ ?\ url))
8014 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8015 (gnus-info-find-node
8017 (gnus-url-unhex-string
8018 (match-string 1 url))
8020 (or (gnus-url-unhex-string
8021 (match-string 2 url))
8023 (error "Can't parse %s" url)))
8025 (defun gnus-button-handle-info-url-kde (url)
8026 "Fetch KDE style info URL."
8027 (gnus-info-find-node (gnus-url-unhex-string url)))
8029 ;; (info) will autoload info.el
8030 (declare-function Info-menu "info" (menu-item &optional fork))
8031 (declare-function Info-index-next "info" (num))
8033 (defun gnus-button-handle-info-keystrokes (url)
8034 "Call `info' when pushing the corresponding URL button."
8035 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8036 (let (node indx comma)
8038 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8039 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8040 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8041 "\\(?:[ \t\n,]*\\)\\)?")
8043 (setq node (match-string 2 url)
8044 indx (match-string 3 url))
8045 (error "Can't parse %s" url))
8049 (when (> (length indx) 0)
8050 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8053 (setq comma (match-string 2 indx))
8054 (setq indx (match-string 1 indx))
8057 (dotimes (i (with-temp-buffer
8059 ;; Note: the XEmacs version of `how-many' takes
8060 ;; no optional argument.
8061 (goto-char (point-min))
8063 (Info-index-next 1)))
8066 (autoload 'pgg-snarf-keys-region "pgg")
8067 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8068 (declare-function pgg-display-output-buffer "pgg" (start end status))
8070 (defun gnus-button-openpgp (url)
8071 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8073 (mm-url-insert-file-contents-external url)
8074 (pgg-snarf-keys-region (point-min) (point-max))
8075 (pgg-display-output-buffer nil nil nil)))
8077 (defun gnus-button-message-id (message-id)
8079 (with-current-buffer gnus-summary-buffer
8080 (gnus-summary-refer-article message-id)))
8082 (defun gnus-button-fetch-group (address &rest ignore)
8083 "Fetch GROUP specified by ADDRESS."
8084 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8086 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8087 ;; for nntp:// and news://
8088 (setq address (match-string 3 address)))
8089 (if (not (string-match "[:/]" address))
8090 ;; This is just a simple group url.
8091 (gnus-group-read-ephemeral-group address gnus-select-method)
8094 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8096 (error "Can't parse %s" address)
8097 (gnus-group-read-ephemeral-group
8098 (match-string 4 address)
8099 `(nntp ,(match-string 1 address)
8100 (nntp-address ,(match-string 1 address))
8101 (nntp-port-number ,(if (match-end 3)
8102 (match-string 3 address)
8105 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8107 (defun gnus-url-parse-query-string (query &optional downcase)
8108 (let (retval pairs cur key val)
8109 (setq pairs (split-string query "&"))
8111 (setq cur (car pairs)
8113 (if (not (string-match "=" cur))
8115 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8116 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8118 (setq key (downcase key)))
8119 (setq cur (assoc key retval))
8121 (setcdr cur (cons val (cdr cur)))
8122 (setq retval (cons (list key val) retval)))))
8125 (defun gnus-url-mailto (url)
8126 ;; Send mail to someone
8127 (setq url (replace-regexp-in-string "\n" " " url))
8128 (when (string-match "mailto:/*\\(.*\\)" url)
8129 (setq url (substring url (match-beginning 1) nil)))
8130 (let (to args subject func)
8131 (setq args (gnus-url-parse-query-string
8132 (if (string-match "^\\?" url)
8134 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8135 (concat "to=" (match-string 1 url) "&"
8136 (match-string 2 url))
8137 (concat "to=" url))))
8138 subject (cdr-safe (assoc "subject" args)))
8141 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8144 (message-position-on-field (caar args)))
8145 (insert (gnus-replace-in-string
8146 (mapconcat 'identity (reverse (cdar args)) ", ")
8148 (setq args (cdr args)))
8151 (message-goto-subject))))
8153 (defun gnus-button-embedded-url (address)
8154 "Activate ADDRESS with `browse-url'."
8155 (browse-url (gnus-strip-whitespace address)))
8157 ;;; Next/prev buttons in the article buffer.
8159 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8160 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8162 (defvar gnus-prev-page-map
8163 (let ((map (make-sparse-keymap)))
8164 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8165 (define-key map "\r" 'gnus-button-prev-page)
8168 (defvar gnus-next-page-map
8169 (let ((map (make-sparse-keymap)))
8170 (define-key map gnus-mouse-2 'gnus-button-next-page)
8171 (define-key map "\r" 'gnus-button-next-page)
8174 (defun gnus-insert-prev-page-button ()
8176 (inhibit-read-only t))
8178 gnus-prev-page-line-format nil
8179 `(keymap ,gnus-prev-page-map
8181 gnus-callback gnus-article-button-prev-page
8182 article-type annotation))
8184 ;; Exclude a newline.
8187 (when gnus-article-button-face
8188 (gnus-overlay-put (gnus-make-overlay b e nil t)
8189 'face gnus-article-button-face))
8190 (widget-convert-button
8192 :action 'gnus-button-prev-page
8193 :button-keymap gnus-prev-page-map)))
8195 (defun gnus-button-next-page (&optional args more-args)
8196 "Go to the next page."
8198 (let ((win (selected-window)))
8199 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8200 (gnus-article-next-page)
8201 (select-window win)))
8203 (defun gnus-button-prev-page (&optional args more-args)
8204 "Go to the prev page."
8206 (let ((win (selected-window)))
8207 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8208 (gnus-article-prev-page)
8209 (select-window win)))
8211 (defun gnus-insert-next-page-button ()
8213 (inhibit-read-only t))
8214 (gnus-eval-format gnus-next-page-line-format nil
8215 `(keymap ,gnus-next-page-map
8217 gnus-callback gnus-article-button-next-page
8218 article-type annotation))
8220 ;; Exclude a newline.
8223 (when gnus-article-button-face
8224 (gnus-overlay-put (gnus-make-overlay b e nil t)
8225 'face gnus-article-button-face))
8226 (widget-convert-button
8228 :action 'gnus-button-next-page
8229 :button-keymap gnus-next-page-map)))
8231 (defun gnus-article-button-next-page (arg)
8232 "Go to the next page."
8234 (let ((win (selected-window)))
8235 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8236 (gnus-article-next-page)
8237 (select-window win)))
8239 (defun gnus-article-button-prev-page (arg)
8240 "Go to the prev page."
8242 (let ((win (selected-window)))
8243 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8244 (gnus-article-prev-page)
8245 (select-window win)))
8247 (defvar gnus-decode-header-methods
8248 '(mail-decode-encoded-word-region)
8249 "List of methods used to decode headers.
8251 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8252 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8253 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8254 whose names match REGEXP.
8257 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8258 mail-decode-encoded-word-region
8259 (\"chinese\" . rfc1843-decode-region))
8262 (defvar gnus-decode-header-methods-cache nil)
8264 (defun gnus-multi-decode-header (start end)
8265 "Apply the functions from `gnus-encoded-word-methods' that match."
8266 (unless (and gnus-decode-header-methods-cache
8267 (eq gnus-newsgroup-name
8268 (car gnus-decode-header-methods-cache)))
8269 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8270 (dolist (x gnus-decode-header-methods)
8272 (nconc gnus-decode-header-methods-cache (list x))
8273 (if (and gnus-newsgroup-name
8274 (string-match (car x) gnus-newsgroup-name))
8275 (nconc gnus-decode-header-methods-cache
8277 (let ((xlist gnus-decode-header-methods-cache))
8280 (narrow-to-region start end)
8282 (funcall (pop xlist) (point-min) (point-max))))))
8285 ;;; Treatment top-level handling.
8288 (defvar gnus-inhibit-article-treatments nil)
8290 (defun gnus-treat-article (gnus-treat-condition
8291 &optional part-number total-parts gnus-treat-type)
8292 (let ((gnus-treat-length (- (point-max) (point-min)))
8293 (alist gnus-treatment-function-alist)
8294 (article-goto-body-goes-to-point-min-p t)
8296 (or (not gnus-treat-type)
8298 (let ((list gnus-article-treat-types))
8300 (when (string-match (pop list) gnus-treat-type)
8301 (throw 'found t)))))))
8302 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8304 (gnus-run-hooks 'gnus-part-display-hook)
8305 (dolist (elem alist)
8308 (when (gnus-buffer-live-p gnus-summary-buffer)
8309 (set-buffer gnus-summary-buffer))
8310 (symbol-value (car elem))))
8311 (when (and (or (consp val)
8313 (or (not gnus-inhibit-article-treatments)
8314 (eq gnus-treat-condition 'head))
8315 (gnus-treat-predicate val)
8316 (or (not (get (car elem) 'highlight))
8319 (funcall (cadr elem)))))))
8321 ;; Dynamic variables.
8322 (defvar part-number)
8323 (defvar total-parts)
8324 (defvar gnus-treat-type)
8325 (defvar gnus-treat-condition)
8326 (defvar gnus-treat-length)
8328 (defun gnus-treat-predicate (val)
8332 (gnus-treat-condition
8333 (eq gnus-treat-condition val))
8335 (stringp (car val)))
8336 (apply 'gnus-or (mapcar `(lambda (s)
8337 (string-match s ,(or gnus-newsgroup-name "")))
8340 (let ((pred (pop val)))
8343 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8345 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8347 (not (gnus-treat-predicate (car val))))
8349 (equal (car val) gnus-treat-type))
8351 (error "%S is not a valid predicate" pred)))))
8359 (eq part-number total-parts))
8361 (< gnus-treat-length val))
8363 (error "%S is not a valid value" val))))
8365 (defun gnus-article-encrypt-body (protocol &optional n)
8366 "Encrypt the article body."
8369 (or gnus-article-encrypt-protocol
8370 (gnus-completing-read "Encrypt protocol"
8371 (mapcar 'car gnus-article-encrypt-protocol-alist)
8373 current-prefix-arg))
8374 ;; User might hit `K E' instead of `K e', so prompt once.
8375 (when (and gnus-article-encrypt-protocol
8377 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8378 (error "Encrypt aborted")))
8379 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8381 (error "Can't find the encrypt protocol %s" protocol))
8382 (if (member gnus-newsgroup-name '("nndraft:delayed"
8385 (error "Can't encrypt the article in group %s"
8386 gnus-newsgroup-name))
8387 (gnus-summary-iterate n
8388 (with-current-buffer gnus-summary-buffer
8389 (let ((mail-parse-charset gnus-newsgroup-charset)
8390 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8391 (summary-buffer gnus-summary-buffer)
8393 (gnus-set-global-variables)
8394 (when (gnus-group-read-only-p)
8395 (error "The current newsgroup does not support article encrypt"))
8396 (gnus-summary-show-article t)
8398 (or (mail-header-references gnus-current-headers) ""))
8399 (set-buffer gnus-article-buffer)
8400 (let* ((inhibit-read-only t)
8402 (mapcar (lambda (field)
8403 (and (save-restriction
8404 (message-narrow-to-head)
8405 (goto-char (point-min))
8406 (search-forward field nil t))
8408 (message-narrow-to-field)
8410 (delete-region (point-min) (point-max))
8412 '("Content-Type:" "Content-Transfer-Encoding:"
8413 "Content-Disposition:"))))
8414 (message-narrow-to-head)
8415 (message-remove-header "MIME-Version")
8416 (goto-char (point-max))
8417 (setq point (point))
8418 (insert (apply 'concat headers))
8420 (narrow-to-region point (point-max))
8421 (let ((message-options message-options))
8422 (message-options-set 'message-sender user-mail-address)
8423 (message-options-set 'message-recipients user-mail-address)
8424 (message-options-set 'message-sign-encrypt 'not)
8426 (goto-char (point-min))
8427 (insert "MIME-Version: 1.0\n")
8429 (gnus-summary-edit-article-done
8430 references nil summary-buffer t))
8431 (when gnus-keep-backlog
8432 (gnus-backlog-remove-article
8433 (car gnus-article-current) (cdr gnus-article-current)))
8434 (gnus-flush-original-article-buffer)
8435 (when gnus-use-cache
8436 (gnus-cache-update-article
8437 (car gnus-article-current) (cdr gnus-article-current))))))))
8439 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8440 "The following specs can be used:
8441 %t The security MIME type
8444 %D Details if button is pressed")
8446 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8447 "The following specs can be used:
8448 %t The security MIME type
8451 %D Details if button is pressed")
8453 (defvar gnus-mime-security-button-line-format-alist
8454 '((?t gnus-tmp-type ?s)
8455 (?i gnus-tmp-info ?s)
8456 (?d gnus-tmp-details ?s)
8457 (?D gnus-tmp-pressed-details ?s)))
8459 (defvar gnus-mime-security-button-commands
8460 '((gnus-article-press-button "\r" "Show Detail")
8464 (gnus-mime-security-save-part "o" "Save...")
8473 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8476 (defvar gnus-mime-security-button-map
8477 (let ((map (make-sparse-keymap)))
8478 (define-key map gnus-mouse-2 'gnus-article-push-button)
8479 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8480 (dolist (c gnus-mime-security-button-commands)
8481 (define-key map (cadr c) (car c)))
8485 gnus-mime-security-button-menu gnus-mime-security-button-map
8486 "Security button menu."
8490 (unless (eq (car c) 'undefined)
8491 (vector (caddr c) (car c) :active t)))
8492 gnus-mime-security-button-commands))))
8494 (defun gnus-mime-security-button-menu (event prefix)
8495 "Construct a context-sensitive menu of security commands."
8496 (interactive "e\nP")
8497 (save-window-excursion
8498 (let ((pos (event-start event)))
8499 (select-window (posn-window pos))
8500 (goto-char (posn-point pos))
8501 (gnus-article-check-buffer)
8502 (popup-menu gnus-mime-security-button-menu nil prefix))))
8504 (defvar gnus-mime-security-details-buffer nil)
8506 (defvar gnus-mime-security-button-pressed nil)
8508 (defvar gnus-mime-security-show-details-inline t
8509 "If non-nil, show details in the article buffer.")
8511 (defun gnus-mime-security-verify-or-decrypt (handle)
8512 (mm-remove-parts (cdr handle))
8513 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8514 point (inhibit-read-only t))
8516 (goto-char (car region)))
8517 (setq point (point))
8518 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8519 (let* ((mm-verify-option 'known)
8520 (mm-decrypt-option 'known)
8521 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8522 (unless (eq nparts (cdr handle))
8523 (mm-destroy-parts (cdr handle))
8524 (setcdr handle nparts))))
8525 (gnus-mime-display-security handle)
8527 (delete-region (point) (cdr region))
8528 (set-marker (car region) nil)
8529 (set-marker (cdr region) nil))
8532 (defun gnus-mime-security-show-details (handle)
8533 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8535 (gnus-message 5 "No details.")
8536 (if gnus-mime-security-show-details-inline
8537 (let ((gnus-mime-security-button-pressed
8538 (not (get-text-property (point) 'gnus-mime-details)))
8539 (gnus-mime-security-button-line-format
8540 (get-text-property (point) 'gnus-line-format))
8541 (inhibit-read-only t))
8543 (while (eq (get-text-property (point) 'gnus-line-format)
8544 gnus-mime-security-button-line-format)
8548 (narrow-to-region (point) (point))
8549 (gnus-insert-mime-security-button handle))
8550 (delete-region (point)
8551 (or (text-property-not-all
8554 gnus-mime-security-button-line-format)
8557 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8558 (with-current-buffer gnus-mime-security-details-buffer
8561 (setq gnus-mime-security-details-buffer
8562 (gnus-get-buffer-create "*MIME Security Details*")))
8563 (with-current-buffer gnus-mime-security-details-buffer
8565 (goto-char (point-min)))
8566 (pop-to-buffer gnus-mime-security-details-buffer)))))
8568 (defun gnus-mime-security-press-button (handle)
8570 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8571 (gnus-mime-security-show-details handle)
8572 (gnus-mime-security-verify-or-decrypt handle))))
8574 (defun gnus-insert-mime-security-button (handle &optional displayed)
8575 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8578 (or (nth 2 (assoc protocol mm-verify-function-alist))
8579 (nth 2 (assoc protocol mm-decrypt-function-alist))
8581 (if (equal (car handle) "multipart/signed")
8582 " Signed" " Encrypted")
8585 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8588 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8589 gnus-tmp-pressed-details
8591 (setq gnus-tmp-details
8592 (if gnus-tmp-details
8593 (concat "\n" gnus-tmp-details)
8595 (setq gnus-tmp-pressed-details
8596 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8601 gnus-mime-security-button-line-format
8602 gnus-mime-security-button-line-format-alist
8603 `(keymap ,gnus-mime-security-button-map
8604 gnus-callback gnus-mime-security-press-button
8605 gnus-line-format ,gnus-mime-security-button-line-format
8606 gnus-mime-details ,gnus-mime-security-button-pressed
8607 article-type annotation
8610 ;; Exclude a newline.
8613 (when gnus-article-button-face
8614 (gnus-overlay-put (gnus-make-overlay b e nil t)
8615 'face gnus-article-button-face))
8616 (widget-convert-button
8619 :action 'gnus-widget-press-button
8620 :button-keymap gnus-mime-security-button-map
8623 ;; Needed to properly clear the message due to a bug in
8624 ;; wid-edit (XEmacs only).
8625 (when (boundp 'help-echo-owns-message)
8626 (setq help-echo-owns-message t))
8628 "%S: show detail; %S: more options"
8629 (aref gnus-mouse-2 0)
8630 (aref gnus-down-mouse-3 0))))))
8632 (defun gnus-mime-display-security (handle)
8634 (narrow-to-region (point) (point))
8635 (unless (gnus-unbuttonized-mime-type-p (car handle))
8636 (gnus-insert-mime-security-button handle))
8637 (gnus-mime-display-part (cadr handle))
8640 (unless (gnus-unbuttonized-mime-type-p (car handle))
8641 (let ((gnus-mime-security-button-line-format
8642 gnus-mime-security-button-end-line-format))
8643 (gnus-insert-mime-security-button handle)))
8644 (mm-set-handle-multipart-parameter
8646 (cons (set-marker (make-marker) (point-min))
8647 (set-marker (make-marker) (point-max))))
8648 (goto-char (point-max))))
8650 (defun gnus-mime-security-run-function (function)
8651 "Run FUNCTION with the security part under point."
8652 (gnus-article-check-buffer)
8653 (let ((data (get-text-property (point) 'gnus-data))
8655 (when (and (stringp (car-safe data))
8656 (setq buffer (mm-handle-multipart-original-buffer data))
8657 (setq handle (cadr data)))
8658 (if (bufferp (mm-handle-buffer handle))
8660 (setq handle (cons buffer (copy-sequence (cdr handle))))
8661 (mm-handle-set-undisplayer handle nil))
8662 (setq handle (mm-make-handle
8664 (mm-handle-multipart-ctl-parameter handle 'protocol)
8665 nil nil nil nil nil nil)))
8666 (funcall function handle))))
8668 (defun gnus-mime-security-save-part ()
8669 "Save the security part under point."
8671 (gnus-mime-security-run-function 'mm-save-part))
8673 (defun gnus-mime-security-pipe-part ()
8674 "Pipe the security part under point to a process."
8676 (gnus-mime-security-run-function 'mm-pipe-part))
8682 (run-hooks 'gnus-art-load-hook)
8684 ;;; gnus-art.el ends here