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))
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 ;; If the date is seriously mangled, the timezone functions are
3552 ;; liable to bug out, so we ignore all errors.
3553 (let* ((now (current-time))
3554 (real-time (subtract-time now time))
3555 (real-sec (and real-time
3556 (+ (* (float (car real-time)) 65536)
3558 (sec (and real-time (abs real-sec)))
3568 ;; This is a bit convoluted, but basically we go
3569 ;; through the time units for years, weeks, etc,
3570 ;; and divide things to see whether that results
3571 ;; in positive answers.
3574 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3575 ;; The (remaining) seconds are too few to
3576 ;; be divided into this time unit.
3578 ;; It's big enough, so we output it.
3579 (setq sec (- sec (* num (cdr unit))))
3581 (concat (if prev ", " "") (int-to-string
3583 " " (symbol-name (car unit))
3584 (if (> num 1) "s" ""))
3586 article-time-units "")
3587 ;; If dates are odd, then it might appear like the
3588 ;; article was sent in the future.
3591 " in the future"))))))
3592 ;; Display the date in proper English
3594 (let ((dtime (decode-time time)))
3597 (number-to-string (nth 3 dtime))
3598 (let ((digit (% (nth 3 dtime) 10)))
3600 ((memq (nth 3 dtime) '(11 12 13)) "th")
3606 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3608 (number-to-string (nth 5 dtime))
3610 (format "%02d" (nth 2 dtime))
3612 (format "%02d" (nth 1 dtime)))))))
3614 (format "Date: %s (from Gnus)" date))))
3616 (defun article-date-local (&optional highlight)
3617 "Convert the current article date to the local timezone."
3618 (interactive (list t))
3619 (article-date-ut 'local highlight))
3621 (defun article-date-english (&optional highlight)
3622 "Convert the current article date to something that is proper English."
3623 (interactive (list t))
3624 (article-date-ut 'english highlight))
3626 (defun article-date-original (&optional highlight)
3627 "Convert the current article date to what it was originally.
3628 This is only useful if you have used some other date conversion
3629 function and want to see what the date was before converting."
3630 (interactive (list t))
3631 (article-date-ut 'original highlight))
3633 (defun article-date-lapsed (&optional highlight)
3634 "Convert the current article date to time lapsed since it was sent."
3635 (interactive (list t))
3636 (article-date-ut 'lapsed highlight))
3638 (defun article-update-date-lapsed ()
3639 "Function to be run from a timer to update the lapsed time line."
3641 (let (deactivate-mark)
3646 (set-buffer (window-buffer w))
3647 (when (eq major-mode 'gnus-article-mode)
3648 (let ((mark (point-marker)))
3649 (goto-char (point-min))
3650 (when (re-search-forward "^X-Sent:" nil t)
3651 (article-date-lapsed t))
3652 (goto-char (marker-position mark))
3653 (move-marker mark nil))))
3656 (defun gnus-start-date-timer (&optional n)
3657 "Start a timer to update the X-Sent header in the article buffers.
3658 The numerical prefix says how frequently (in seconds) the function
3663 (gnus-stop-date-timer)
3664 (setq article-lapsed-timer
3665 (run-at-time 1 n 'article-update-date-lapsed)))
3667 (defun gnus-stop-date-timer ()
3668 "Stop the X-Sent timer."
3670 (when article-lapsed-timer
3671 (nnheader-cancel-timer article-lapsed-timer)
3672 (setq article-lapsed-timer nil)))
3674 (defun article-date-user (&optional highlight)
3675 "Convert the current article date to the user-defined format.
3676 This format is defined by the `gnus-article-time-format' variable."
3677 (interactive (list t))
3678 (article-date-ut 'user highlight))
3680 (defun article-date-iso8601 (&optional highlight)
3681 "Convert the current article date to ISO8601."
3682 (interactive (list t))
3683 (article-date-ut 'iso8601 highlight))
3685 (defmacro gnus-article-save-original-date (&rest forms)
3686 "Save the original date as a text property and evaluate FORMS."
3687 `(let* ((case-fold-search t)
3689 (goto-char (point-min))
3690 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3693 (date (when (and start
3694 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3696 (buffer-substring-no-properties start
3697 (match-beginning 0)))))
3698 (goto-char (point-max))
3699 (skip-chars-backward "\n")
3700 (put-text-property (point-min) (point) 'original-date date)
3702 (goto-char (point-max))
3703 (skip-chars-backward "\n")
3704 (put-text-property (point-min) (point) 'original-date date)))
3706 ;; (defun article-show-all ()
3707 ;; "Show all hidden text in the article buffer."
3710 ;; (let ((inhibit-read-only t))
3711 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3713 (defun article-remove-leading-whitespace ()
3714 "Remove excessive whitespace from all headers."
3718 (let ((inhibit-read-only t))
3719 (article-narrow-to-head)
3720 (goto-char (point-min))
3721 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3722 (delete-region (match-beginning 1) (match-end 1)))))))
3724 (defun article-emphasize (&optional arg)
3725 "Emphasize text according to `gnus-emphasis-alist'."
3726 (interactive (gnus-article-hidden-arg))
3727 (unless (gnus-article-check-hidden-text 'emphasis arg)
3731 (with-current-buffer gnus-summary-buffer
3732 gnus-article-emphasis-alist)
3734 gnus-emphasis-alist))
3735 (inhibit-read-only t)
3736 (props (append '(article-type emphasis)
3737 gnus-hidden-properties))
3738 regexp elem beg invisible visible face)
3741 (while (setq elem (pop alist))
3743 (setq regexp (car elem)
3744 invisible (nth 1 elem)
3745 visible (nth 2 elem)
3747 (while (re-search-forward regexp nil t)
3748 (when (and (match-beginning visible) (match-beginning invisible))
3749 (gnus-article-hide-text
3750 (match-beginning invisible) (match-end invisible) props)
3751 (gnus-article-unhide-text-type
3752 (match-beginning visible) (match-end visible) 'emphasis)
3753 (gnus-put-overlay-excluding-newlines
3754 (match-beginning visible) (match-end visible) 'face face)
3755 (gnus-add-wash-type 'emphasis)
3756 (goto-char (match-end invisible)))))))))
3758 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3759 "Setup newsgroup emphasis alist."
3760 (unless gnus-article-emphasis-alist
3761 (let ((name (and gnus-newsgroup-name
3762 (gnus-group-real-name gnus-newsgroup-name))))
3763 (make-local-variable 'gnus-article-emphasis-alist)
3764 (setq gnus-article-emphasis-alist
3766 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3767 (while (setq elem (pop alist))
3768 (when (and name (string-match (car elem) name))
3770 highlight (copy-sequence (cdr elem)))))
3772 (copy-sequence highlight-words)
3773 (if gnus-newsgroup-name
3774 (copy-sequence (gnus-group-find-parameter
3775 gnus-newsgroup-name 'highlight-words t)))
3776 gnus-emphasis-alist)))))
3778 (defvar gnus-summary-article-menu)
3779 (defvar gnus-summary-post-menu)
3781 ;;; Saving functions.
3783 (defun gnus-article-save (save-buffer file &optional num)
3784 "Save the currently selected article."
3785 (when (or (get gnus-default-article-saver :headers)
3786 (not gnus-save-all-headers))
3787 ;; Remove headers according to `gnus-saved-headers' or the value
3788 ;; of the `:headers' property that the saver function might have.
3789 (let ((gnus-visible-headers
3790 (or (symbol-value (get gnus-default-article-saver :headers))
3791 gnus-saved-headers gnus-visible-headers))
3792 ;; Ignore group parameter. See `article-hide-headers'.
3793 (gnus-summary-buffer nil))
3794 (with-current-buffer save-buffer
3795 (article-hide-headers 1 t))))
3796 (save-window-excursion
3797 (if (not gnus-default-article-saver)
3798 (error "No default saver is defined")
3799 ;; !!! Magic! The saving functions all save
3800 ;; `gnus-save-article-buffer' (or so they think), but we
3801 ;; bind that variable to our save-buffer.
3802 (set-buffer gnus-article-buffer)
3803 (let* ((gnus-save-article-buffer save-buffer)
3806 ((not gnus-prompt-before-saving) 'default)
3807 ((eq gnus-prompt-before-saving 'always) nil)
3809 (gnus-number-of-articles-to-be-saved
3810 (when (eq gnus-prompt-before-saving t)
3812 (set-buffer gnus-article-current-summary)
3813 (funcall gnus-default-article-saver filename)))))
3815 (defun gnus-read-save-file-name (prompt &optional filename
3816 function group headers variable
3819 (funcall function group headers (symbol-value variable)))
3824 ((eq filename 'default)
3830 (when (symbol-value dir-var)
3831 (setq default-name (expand-file-name
3832 (file-name-nondirectory default-name)
3833 (symbol-value dir-var))))
3834 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3837 (if (and gnus-number-of-articles-to-be-saved
3838 (> gnus-number-of-articles-to-be-saved 1))
3839 (format "these %d articles"
3840 gnus-number-of-articles-to-be-saved)
3843 ;; Let the split methods have their say.
3845 ;; No split name was found.
3848 (concat prompt " (default "
3849 (file-name-nondirectory default-name) "): ")
3850 (file-name-directory default-name)
3852 ;; A single group name is returned.
3853 ((stringp split-name)
3855 (funcall function split-name headers
3856 (symbol-value variable)))
3858 (concat prompt " (default "
3859 (file-name-nondirectory default-name) "): ")
3860 (file-name-directory default-name)
3862 ;; A single split name was found
3863 ((= 1 (length split-name))
3864 (let* ((name (expand-file-name
3866 gnus-article-save-directory))
3867 (dir (cond ((file-directory-p name)
3868 (file-name-as-directory name))
3869 ((file-exists-p name) name)
3870 (t gnus-article-save-directory))))
3872 (concat prompt " (default " name "): ")
3874 ;; A list of splits was found.
3876 (setq split-name (nreverse split-name))
3878 (let ((file-name-history
3879 (nconc split-name file-name-history)))
3883 (concat prompt " (`M-p' for defaults): ")
3884 gnus-article-save-directory
3886 gnus-article-save-directory)))
3887 (car (push result file-name-history)))))))
3888 ;; Create the directory.
3889 (gnus-make-directory (file-name-directory file))
3890 ;; If we have read a directory, we append the default file name.
3891 (when (file-directory-p file)
3892 (setq file (expand-file-name (file-name-nondirectory
3894 (file-name-as-directory file))))
3895 ;; Possibly translate some characters.
3896 (nnheader-translate-file-chars file))))))
3897 (gnus-make-directory (file-name-directory result))
3899 (set variable result))
3901 (set dir-var (file-name-directory result)))
3904 (defun gnus-article-archive-name (group)
3905 "Return the first instance of an \"Archive-name\" in the current buffer."
3906 (let ((case-fold-search t))
3907 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3908 (nnheader-concat gnus-article-save-directory
3909 (match-string 1)))))
3911 (defun gnus-article-nndoc-name (group)
3912 "If GROUP is an nndoc group, return the name of the parent group."
3913 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3914 (gnus-group-get-parameter group 'save-article-group)))
3916 (defun gnus-summary-save-in-rmail (&optional filename)
3917 "Append this article to Rmail file.
3918 Optional argument FILENAME specifies file name.
3919 Directory to save to is default to `gnus-article-save-directory'."
3920 (setq filename (gnus-read-save-file-name
3921 "Save %s in rmail file" filename
3922 gnus-rmail-save-name gnus-newsgroup-name
3923 gnus-current-headers 'gnus-newsgroup-last-rmail))
3924 (with-current-buffer gnus-save-article-buffer
3928 ;; Note that unlike gnus-summary-save-in-mail, there is no
3929 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3931 (gnus-output-to-rmail filename))))
3934 (defun gnus-summary-save-in-mail (&optional filename)
3935 "Append this article to Unix mail file.
3936 Optional argument FILENAME specifies file name.
3937 Directory to save to is default to `gnus-article-save-directory'."
3938 (setq filename (gnus-read-save-file-name
3939 "Save %s in Unix mail file" filename
3940 gnus-mail-save-name gnus-newsgroup-name
3941 gnus-current-headers 'gnus-newsgroup-last-mail))
3942 (with-current-buffer gnus-save-article-buffer
3946 (if (and (file-readable-p filename)
3947 (file-regular-p filename)
3948 (mail-file-babyl-p filename))
3949 (gnus-output-to-rmail filename)
3950 (gnus-output-to-mail filename)))))
3953 (put 'gnus-summary-save-in-file :decode t)
3954 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3955 (defun gnus-summary-save-in-file (&optional filename overwrite)
3956 "Append this article to file.
3957 Optional argument FILENAME specifies file name.
3958 Directory to save to is default to `gnus-article-save-directory'."
3959 (setq filename (gnus-read-save-file-name
3960 "Save %s in file" filename
3961 gnus-file-save-name gnus-newsgroup-name
3962 gnus-current-headers 'gnus-newsgroup-last-file))
3963 (with-current-buffer gnus-save-article-buffer
3967 (when (and overwrite
3968 (file-exists-p filename))
3969 (delete-file filename))
3970 (gnus-output-to-file filename))))
3973 (put 'gnus-summary-write-to-file :decode t)
3974 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3975 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3976 (defun gnus-summary-write-to-file (&optional filename)
3977 "Write this article to a file, overwriting it if the file exists.
3978 Optional argument FILENAME specifies file name.
3979 The directory to save in defaults to `gnus-article-save-directory'."
3980 (setq filename (gnus-read-save-file-name
3981 "Save %s in file" filename
3982 gnus-file-save-name gnus-newsgroup-name
3983 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3984 (gnus-summary-save-in-file filename t))
3986 (put 'gnus-summary-save-body-in-file :decode t)
3987 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3988 "Append this article body to a file.
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 body in file" filename
3993 gnus-file-save-name gnus-newsgroup-name
3994 gnus-current-headers 'gnus-newsgroup-last-file))
3995 (with-current-buffer gnus-save-article-buffer
3999 (when (article-goto-body)
4000 (narrow-to-region (point) (point-max)))
4001 (when (and overwrite
4002 (file-exists-p filename))
4003 (delete-file filename))
4004 (gnus-output-to-file filename))))
4007 (put 'gnus-summary-write-body-to-file :decode t)
4008 (put 'gnus-summary-write-body-to-file
4009 :function 'gnus-summary-save-body-in-file)
4010 (defun gnus-summary-write-body-to-file (&optional filename)
4011 "Write this article body to a file, overwriting it if the file exists.
4012 Optional argument FILENAME specifies file name.
4013 The directory to save in defaults to `gnus-article-save-directory'."
4014 (setq filename (gnus-read-save-file-name
4015 "Save %s body in file" filename
4016 gnus-file-save-name gnus-newsgroup-name
4017 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4018 (gnus-summary-save-body-in-file filename t))
4020 (put 'gnus-summary-save-in-pipe :decode t)
4021 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4022 (defun gnus-summary-save-in-pipe (&optional command raw)
4023 "Pipe this article to subprocess COMMAND.
4024 Valid values for COMMAND include:
4026 The executable command name and possibly arguments.
4028 You will be prompted for the command in the minibuffer.
4029 the symbol `default'
4030 It will be replaced with the command which the variable
4031 `gnus-summary-pipe-output-default-command' holds or the command
4032 last used for saving.
4033 Non-nil value for RAW overrides `:decode' and `:headers' properties
4034 and the raw article including all headers will be piped."
4035 (let ((article (gnus-summary-article-number))
4037 (get 'gnus-summary-save-in-pipe :decode)))
4038 save-buffer default)
4040 (if (vectorp (gnus-summary-article-header article))
4041 (save-current-buffer
4042 (gnus-summary-select-article decode decode nil article)
4043 (insert-buffer-substring
4047 gnus-original-article-buffer)
4049 (nnheader-set-temp-buffer " *Gnus Save*"))))
4050 ;; Remove unwanted headers.
4051 (when (and (not raw)
4052 (or (get 'gnus-summary-save-in-pipe :headers)
4053 (not gnus-save-all-headers)))
4054 (let ((gnus-visible-headers
4055 (or (symbol-value (get 'gnus-summary-save-in-pipe
4057 gnus-saved-headers gnus-visible-headers))
4058 (gnus-summary-buffer nil))
4059 (article-hide-headers 1 t))))
4060 (error "%d is not a real article" article))
4061 (error "No article to pipe"))
4062 (setq default (or gnus-summary-pipe-output-default-command
4063 gnus-last-shell-command))
4064 (unless (stringp command)
4066 (if (and (eq command 'default) default)
4068 (gnus-read-shell-command "Shell command on this article: "
4070 (when (string-equal command "")
4072 (setq command default)
4073 (error "A command is required")))
4074 (with-current-buffer save-buffer
4077 (shell-command-on-region (point-min) (point-max) command nil)))
4078 (gnus-kill-buffer save-buffer))
4079 (setq gnus-summary-pipe-output-default-command command))
4081 (defun gnus-summary-pipe-to-muttprint (&optional command)
4082 "Pipe this article to muttprint."
4083 (unless (stringp command)
4084 (setq command (read-string
4085 "Print using command: " gnus-summary-muttprint-program
4086 nil gnus-summary-muttprint-program)))
4087 (let ((gnus-summary-pipe-output-default-command
4088 gnus-summary-pipe-output-default-command))
4089 (gnus-summary-save-in-pipe command))
4090 (setq gnus-summary-muttprint-program command))
4092 ;;; Article file names when saving.
4094 (defun gnus-capitalize-newsgroup (newsgroup)
4095 "Capitalize NEWSGROUP name."
4096 (when (not (zerop (length newsgroup)))
4097 (concat (char-to-string (upcase (aref newsgroup 0)))
4098 (substring newsgroup 1))))
4100 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4101 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4102 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4103 Otherwise, it is like ~/News/news/group/num."
4106 (concat (if (gnus-use-long-file-name 'not-save)
4107 (gnus-capitalize-newsgroup newsgroup)
4108 (gnus-newsgroup-directory-form newsgroup))
4109 "/" (int-to-string (mail-header-number headers)))
4110 gnus-article-save-directory)))
4112 (string-equal (file-name-directory default)
4113 (file-name-directory last-file))
4114 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4116 (or last-file default))))
4118 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4119 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4120 If variable `gnus-use-long-file-name' is non-nil, it is
4121 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4124 (concat (if (gnus-use-long-file-name 'not-save)
4126 (gnus-newsgroup-directory-form newsgroup))
4127 "/" (int-to-string (mail-header-number headers)))
4128 gnus-article-save-directory)))
4130 (string-equal (file-name-directory default)
4131 (file-name-directory last-file))
4132 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4134 (or last-file default))))
4136 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4137 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4138 If variable `gnus-use-long-file-name' is non-nil, it is
4139 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4142 (if (gnus-use-long-file-name 'not-save)
4145 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4147 gnus-article-save-directory)))
4149 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4150 "Generate file name from sender."
4151 (let ((from (mail-header-from headers)))
4153 (if (and from (string-match "\\([^ <]+\\)@" from))
4154 (match-string 1 from)
4156 gnus-article-save-directory)))
4158 (defun article-verify-x-pgp-sig ()
4160 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4162 (if (gnus-buffer-live-p gnus-original-article-buffer)
4163 (let ((sig (with-current-buffer gnus-original-article-buffer
4164 (gnus-fetch-field "X-PGP-Sig")))
4168 (mml2015-clear-verify-function))
4170 (insert-buffer-substring gnus-original-article-buffer)
4171 (setq items (split-string sig))
4172 (message-narrow-to-head)
4173 (let ((inhibit-point-motion-hooks t)
4174 (case-fold-search t))
4175 ;; Don't verify multiple headers.
4176 (setq headers (mapconcat (lambda (header)
4178 (mail-fetch-field header)
4180 (split-string (nth 1 items) ",") "")))
4181 (delete-region (point-min) (point-max))
4182 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4183 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4188 (if (looking-at "^-")
4191 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4192 (insert "Version: " (car items) "\n\n")
4193 (insert (mapconcat 'identity (cddr items) "\n"))
4194 (insert "\n-----END PGP SIGNATURE-----\n")
4195 (let ((mm-security-handle (list (format "multipart/signed"))))
4196 (mml2015-clean-buffer)
4197 (let ((coding-system-for-write (or gnus-newsgroup-charset
4199 (funcall (mml2015-clear-verify-function)))
4201 (or (mm-handle-multipart-ctl-parameter
4202 mm-security-handle 'gnus-details)
4203 (mm-handle-multipart-ctl-parameter
4204 mm-security-handle 'gnus-info)))))
4206 (let ((inhibit-read-only t) bface eface)
4208 (message-narrow-to-head)
4209 (goto-char (point-max))
4211 (setq bface (get-text-property (point-at-bol) 'face)
4212 eface (get-text-property (1- (point-at-eol)) 'face))
4213 (message-remove-header "X-Gnus-PGP-Verify")
4214 (if (re-search-forward "^X-PGP-Sig:" nil t)
4216 (goto-char (point-max)))
4217 (narrow-to-region (point) (point))
4218 (insert "X-Gnus-PGP-Verify: " info "\n")
4219 (goto-char (point-min))
4222 (if (not (looking-at "^[ \t]"))
4226 (goto-char (point-min))
4227 (when (looking-at "\\([^:]+\\): *")
4228 (put-text-property (match-beginning 1) (1+ (match-end 1))
4230 (put-text-property (match-end 0) (point-max)
4231 'face eface)))))))))
4233 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4235 (defun article-verify-cancel-lock ()
4236 "Verify Cancel-Lock header."
4238 (if (gnus-buffer-live-p gnus-original-article-buffer)
4239 (canlock-verify gnus-original-article-buffer)))
4246 (setq afunc (car func)
4249 gfunc (intern (format "gnus-%s" func))))
4251 (when (fboundp afunc)
4252 `(lambda (&optional interactive &rest args)
4253 ,(documentation afunc t)
4254 (interactive (list t))
4255 (with-current-buffer gnus-article-buffer
4257 (call-interactively ',afunc)
4258 (apply ',afunc args))))))))
4259 '(article-hide-headers
4260 article-verify-x-pgp-sig
4261 article-verify-cancel-lock
4262 article-hide-boring-headers
4263 article-treat-overstrike
4264 article-treat-ansi-sequences
4265 article-fill-long-lines
4266 article-capitalize-sentences
4268 article-remove-leading-whitespace
4269 article-display-x-face
4270 article-display-face
4271 article-de-quoted-unreadable
4272 article-de-base64-unreadable
4275 article-unsplit-urls
4276 article-hide-list-identifiers
4277 article-strip-banner
4280 article-hide-signature
4281 article-strip-headers-in-body
4282 article-remove-trailing-blank-lines
4283 article-strip-leading-blank-lines
4284 article-strip-multiple-blank-lines
4285 article-strip-leading-space
4286 article-strip-trailing-space
4287 article-strip-blank-lines
4288 article-strip-all-blank-lines
4290 article-date-english
4291 article-date-iso8601
4292 article-date-original
4294 article-decode-mime-words
4295 article-decode-charset
4296 article-decode-encoded-words
4300 article-treat-dumbquotes
4301 article-treat-non-ascii
4302 article-normalize-headers
4303 ;;(article-show-all . gnus-article-show-all-headers)
4307 ;;; Gnus article mode
4310 (put 'gnus-article-mode 'mode-class 'special)
4312 (set-keymap-parent gnus-article-mode-map widget-keymap)
4314 (gnus-define-keys gnus-article-mode-map
4315 " " gnus-article-goto-next-page
4316 "\177" gnus-article-goto-prev-page
4317 [delete] gnus-article-goto-prev-page
4318 [backspace] gnus-article-goto-prev-page
4319 "\C-c^" gnus-article-refer-article
4320 "h" gnus-article-show-summary
4321 "s" gnus-article-show-summary
4322 "\C-c\C-m" gnus-article-mail
4323 "?" gnus-article-describe-briefly
4324 "<" beginning-of-buffer
4326 "\C-c\C-i" gnus-info-find-node
4328 "R" gnus-article-reply-with-original
4329 "F" gnus-article-followup-with-original
4330 "\C-hk" gnus-article-describe-key
4331 "\C-hc" gnus-article-describe-key-briefly
4332 "\C-hb" gnus-article-describe-bindings
4334 "e" gnus-article-read-summary-keys
4335 "\C-d" gnus-article-read-summary-keys
4336 "\M-*" gnus-article-read-summary-keys
4337 "\M-#" gnus-article-read-summary-keys
4338 "\M-^" gnus-article-read-summary-keys
4339 "\M-g" gnus-article-read-summary-keys)
4341 (substitute-key-definition
4342 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4344 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4345 "W" gnus-article-wide-reply-with-original)
4346 (if (featurep 'xemacs)
4347 (set-keymap-default-binding gnus-article-send-map
4348 'gnus-article-read-summary-send-keys)
4349 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4351 (defun gnus-article-make-menu-bar ()
4352 (unless (boundp 'gnus-article-commands-menu)
4353 (gnus-summary-make-menu-bar))
4354 (unless (boundp 'gnus-article-article-menu)
4356 gnus-article-article-menu gnus-article-mode-map ""
4358 ["Scroll forwards" gnus-article-goto-next-page t]
4359 ["Scroll backwards" gnus-article-goto-prev-page t]
4360 ["Show summary" gnus-article-show-summary t]
4361 ["Fetch Message-ID at point" gnus-article-refer-article t]
4362 ["Mail to address at point" gnus-article-mail t]
4363 ["Send a bug report" gnus-bug t]))
4366 gnus-article-treatment-menu gnus-article-mode-map ""
4367 ;; Fixme: this should use :active (and maybe :visible).
4369 ["Hide headers" gnus-article-hide-headers t]
4370 ["Hide signature" gnus-article-hide-signature t]
4371 ["Hide citation" gnus-article-hide-citation t]
4372 ["Treat overstrike" gnus-article-treat-overstrike t]
4373 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4374 ["Remove carriage return" gnus-article-remove-cr t]
4375 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4376 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4377 ["Remove base64" gnus-article-de-base64-unreadable t]
4378 ["Treat html" gnus-article-wash-html t]
4379 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4380 ["Decode HZ" gnus-article-decode-HZ t]))
4382 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4384 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4386 (gnus-run-hooks 'gnus-article-menu-hook)))
4388 (defvar bookmark-make-record-function)
4390 (defun gnus-article-mode ()
4391 "Major mode for displaying an article.
4393 All normal editing commands are switched off.
4395 The following commands are available in addition to all summary mode
4397 \\<gnus-article-mode-map>
4398 \\[gnus-article-next-page]\t Scroll the article one page forwards
4399 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4400 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4401 \\[gnus-article-show-summary]\t Display the summary buffer
4402 \\[gnus-article-mail]\t Send a reply to the address near point
4403 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4404 \\[gnus-info-find-node]\t Go to the Gnus info node"
4406 (kill-all-local-variables)
4407 (gnus-simplify-mode-line)
4408 (setq mode-name "Article")
4409 (setq major-mode 'gnus-article-mode)
4410 (make-local-variable 'minor-mode-alist)
4411 (use-local-map gnus-article-mode-map)
4412 (when (gnus-visual-p 'article-menu 'menu)
4413 (gnus-article-make-menu-bar)
4414 (when gnus-summary-tool-bar-map
4415 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4416 (gnus-update-format-specifications nil 'article-mode)
4417 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4418 (set (make-local-variable 'gnus-page-broken) nil)
4419 (make-local-variable 'gnus-article-current-summary)
4420 (make-local-variable 'gnus-article-mime-handles)
4421 (make-local-variable 'gnus-article-decoded-p)
4422 (make-local-variable 'gnus-article-mime-handle-alist)
4423 (make-local-variable 'gnus-article-wash-types)
4424 (make-local-variable 'gnus-article-image-alist)
4425 (make-local-variable 'gnus-article-charset)
4426 (make-local-variable 'gnus-article-ignored-charsets)
4427 (set (make-local-variable 'bookmark-make-record-function)
4428 'gnus-summary-bookmark-make-record)
4429 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4431 (set (make-local-variable 'nobreak-char-display) nil)
4432 (setq cursor-in-non-selected-windows nil)
4433 (gnus-set-default-directory)
4434 (buffer-disable-undo)
4435 (setq buffer-read-only t
4436 show-trailing-whitespace nil)
4437 (set-syntax-table gnus-article-mode-syntax-table)
4438 (mm-enable-multibyte)
4439 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4441 (defun gnus-article-setup-buffer ()
4442 "Initialize the article buffer."
4443 (let* ((name (if gnus-single-article-buffer "*Article*"
4444 (concat "*Article " gnus-newsgroup-name "*")))
4446 (progn (string-match "\\*Article" name)
4447 (concat " *Original Article"
4448 (substring name (match-end 0))))))
4449 (setq gnus-article-buffer name)
4450 (setq gnus-original-article-buffer original)
4451 (setq gnus-article-mime-handle-alist nil)
4452 (with-current-buffer gnus-summary-buffer
4453 ;; This might be a variable local to the summary buffer.
4454 (unless gnus-single-article-buffer
4455 (setq gnus-article-buffer name)
4456 (setq gnus-original-article-buffer original)
4457 (gnus-set-global-variables)))
4458 (gnus-article-setup-highlight-words)
4459 ;; Init original article buffer.
4460 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4461 (mm-enable-multibyte)
4462 (setq major-mode 'gnus-original-article-mode)
4463 (make-local-variable 'gnus-original-article))
4464 (if (and (get-buffer name)
4465 (with-current-buffer name
4466 (if gnus-article-edit-mode
4467 (if (y-or-n-p "Article mode edit in progress; discard? ")
4469 (set-buffer-modified-p nil)
4470 (gnus-kill-buffer name)
4473 (error "Action aborted"))
4475 (with-current-buffer name
4476 (set (make-local-variable 'gnus-article-edit-mode) nil)
4477 (when gnus-article-mime-handles
4478 (mm-destroy-parts gnus-article-mime-handles)
4479 (setq gnus-article-mime-handles nil))
4480 ;; Set it to nil in article-buffer!
4481 (setq gnus-article-mime-handle-alist nil)
4482 (buffer-disable-undo)
4483 (setq buffer-read-only t)
4484 (unless (eq major-mode 'gnus-article-mode)
4485 (gnus-article-mode))
4486 (setq truncate-lines gnus-article-truncate-lines)
4488 (with-current-buffer (gnus-get-buffer-create name)
4490 (setq truncate-lines gnus-article-truncate-lines)
4491 (make-local-variable 'gnus-summary-buffer)
4492 (setq gnus-summary-buffer
4493 (gnus-summary-buffer-name gnus-newsgroup-name))
4494 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4495 (current-buffer)))))
4497 ;; Set article window start at LINE, where LINE is the number of lines
4498 ;; from the head of the article.
4499 (defun gnus-article-set-window-start (&optional line)
4500 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4501 (when article-window
4504 (with-current-buffer gnus-article-buffer
4505 (goto-char (point-min))
4508 (gnus-message 6 "Moved to bookmark")
4509 (search-forward "\n\n" nil t)
4513 (defun gnus-article-prepare (article &optional all-headers header)
4514 "Prepare ARTICLE in article mode buffer.
4515 ARTICLE should either be an article number or a Message-ID.
4516 If ARTICLE is an id, HEADER should be the article headers.
4517 If ALL-HEADERS is non-nil, no headers are hidden."
4519 ;; Make sure we start in a summary buffer.
4520 (unless (eq major-mode 'gnus-summary-mode)
4521 (set-buffer gnus-summary-buffer))
4522 (setq gnus-summary-buffer (current-buffer))
4523 (let* ((gnus-article (if header (mail-header-number header) article))
4524 (summary-buffer (current-buffer))
4525 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4526 (group gnus-newsgroup-name)
4529 (gnus-article-setup-buffer)
4530 (set-buffer gnus-article-buffer)
4531 ;; Deactivate active regions.
4532 (when (and (boundp 'transient-mark-mode)
4533 transient-mark-mode)
4534 (setq mark-active nil))
4535 (if (not (setq result (let ((inhibit-read-only t))
4536 (gnus-request-article-this-buffer
4538 ;; There is no such article.
4540 (when (and (numberp article)
4541 (not (memq article gnus-newsgroup-sparse)))
4542 (setq gnus-article-current
4543 (cons gnus-newsgroup-name article))
4544 (set-buffer gnus-summary-buffer)
4545 (setq gnus-current-article article)
4546 (if (and (memq article gnus-newsgroup-undownloaded)
4547 (not (gnus-online (gnus-find-method-for-group
4548 gnus-newsgroup-name))))
4550 (gnus-summary-set-agent-mark article)
4551 (message "Message marked for downloading"))
4552 (gnus-summary-mark-article article gnus-canceled-mark)
4553 (unless (memq article gnus-newsgroup-sparse)
4554 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4555 (if (or (eq result 'pseudo)
4556 (eq result 'nneething))
4558 (with-current-buffer summary-buffer
4559 (push article gnus-newsgroup-history)
4560 (setq gnus-last-article gnus-current-article
4561 gnus-current-article 0
4562 gnus-current-headers nil
4563 gnus-article-current nil)
4564 (if (eq result 'nneething)
4565 (gnus-configure-windows 'summary)
4566 (gnus-configure-windows 'article))
4567 (gnus-set-global-variables))
4568 (let ((gnus-article-mime-handle-alist-1
4569 gnus-article-mime-handle-alist))
4570 (gnus-set-mode-line 'article)))
4571 ;; The result from the `request' was an actual article -
4572 ;; or at least some text that is now displayed in the
4574 (when (and (numberp article)
4575 (not (eq article gnus-current-article)))
4576 ;; Seems like a new article has been selected.
4577 ;; `gnus-current-article' must be an article number.
4578 (with-current-buffer summary-buffer
4579 (push article gnus-newsgroup-history)
4580 (setq gnus-last-article gnus-current-article
4581 gnus-current-article article
4582 gnus-current-headers
4583 (gnus-summary-article-header gnus-current-article)
4584 gnus-article-current
4585 (cons gnus-newsgroup-name gnus-current-article))
4586 (unless (vectorp gnus-current-headers)
4587 (setq gnus-current-headers nil))
4588 (gnus-summary-goto-subject gnus-current-article)
4589 (when (gnus-summary-show-thread)
4590 ;; If the summary buffer really was folded, the
4591 ;; previous goto may not actually have gone to
4592 ;; the right article, but the thread root instead.
4594 (gnus-summary-goto-subject gnus-current-article))
4595 (gnus-run-hooks 'gnus-mark-article-hook)
4596 (gnus-set-mode-line 'summary)
4597 (when (gnus-visual-p 'article-highlight 'highlight)
4598 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4599 ;; Set the global newsgroup variables here.
4600 (gnus-set-global-variables)
4601 (setq gnus-have-all-headers
4602 (or all-headers gnus-show-all-headers))))
4604 (gnus-configure-windows 'article))
4605 (when (or (numberp article)
4607 (gnus-article-prepare-display)
4609 (goto-char (point-min))
4610 (when gnus-break-pages
4611 (gnus-narrow-to-page)))
4612 (let ((gnus-article-mime-handle-alist-1
4613 gnus-article-mime-handle-alist))
4614 (gnus-set-mode-line 'article))
4618 (set-window-point (get-buffer-window (current-buffer)) (point))
4619 (gnus-configure-windows 'article)
4623 (defun gnus-article-prepare-display ()
4624 "Make the current buffer look like a nice article."
4625 ;; Hooks for getting information from the article.
4626 ;; This hook must be called before being narrowed.
4627 (let ((gnus-article-buffer (current-buffer))
4629 (inhibit-read-only t))
4630 (unless (eq major-mode 'gnus-article-mode)
4631 (gnus-article-mode))
4632 (setq buffer-read-only nil
4633 gnus-article-wash-types nil
4634 gnus-article-image-alist nil)
4635 (gnus-run-hooks 'gnus-tmp-internal-hook)
4636 (when gnus-display-mime-function
4637 (funcall gnus-display-mime-function))
4638 (gnus-run-hooks 'gnus-article-prepare-hook)))
4641 ;;; Gnus Sticky Article Mode
4644 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4645 "Mode for sticky articles."
4646 ;; Release bindings that won't work.
4647 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4648 gnus-sticky-article-mode-map)
4649 (substitute-key-definition 'gnus-article-refer-article 'undefined
4650 gnus-sticky-article-mode-map)
4651 (dolist (k '("e" "h" "s" "F" "R"))
4652 (define-key gnus-sticky-article-mode-map k nil))
4653 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4654 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4655 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4656 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4658 (defun gnus-sticky-article (arg)
4659 "Make the current article sticky.
4660 If a prefix ARG is given, ask for a name for this sticky article buffer."
4662 (gnus-summary-show-thread)
4663 (gnus-summary-select-article nil nil 'pseudo)
4664 (let (new-art-buf-name)
4665 (gnus-eval-in-buffer-window gnus-article-buffer
4666 (setq new-art-buf-name
4670 (read-from-minibuffer "Sticky article buffer name: ")
4671 (gnus-with-article-headers
4672 (gnus-article-goto-header "subject")
4673 (setq new-art-buf-name
4674 (buffer-substring-no-properties
4675 (line-beginning-position) (line-end-position)))
4676 (goto-char (point-min))
4677 (gnus-article-goto-header "from")
4678 (setq new-art-buf-name
4680 new-art-buf-name ", "
4681 (buffer-substring-no-properties
4682 (line-beginning-position) (line-end-position))))
4683 (goto-char (point-min))
4684 (gnus-article-goto-header "date")
4685 (setq new-art-buf-name
4687 new-art-buf-name ", "
4688 (buffer-substring-no-properties
4689 (line-beginning-position) (line-end-position))))))
4691 (if (and (gnus-buffer-live-p new-art-buf-name)
4692 (with-current-buffer new-art-buf-name
4693 (eq major-mode 'gnus-sticky-article-mode)))
4694 (switch-to-buffer new-art-buf-name)
4695 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4696 (gnus-sticky-article-mode))
4697 (setq gnus-article-buffer new-art-buf-name))
4698 (gnus-summary-recenter)
4699 (gnus-summary-position-point))
4701 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4702 "Kill the given sticky article BUFFER.
4703 If none is given, assume the current buffer and kill it if it has
4704 `gnus-sticky-article-mode'."
4707 (setq buffer (current-buffer)))
4708 (with-current-buffer buffer
4709 (when (eq major-mode 'gnus-sticky-article-mode)
4710 (gnus-kill-buffer buffer))))
4712 (defun gnus-kill-sticky-article-buffers (arg)
4713 "Kill all sticky article buffers.
4714 If a prefix ARG is given, ask for confirmation."
4716 (dolist (buf (gnus-buffers))
4717 (with-current-buffer buf
4718 (when (eq major-mode 'gnus-sticky-article-mode)
4720 (gnus-kill-buffer buf)
4721 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4722 (gnus-kill-buffer buf)))))))
4725 ;;; Gnus MIME viewing functions
4728 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4729 "Format of the MIME buttons.
4731 Valid specifiers include:
4733 %T MIME type, along with additional info
4734 %n The `name' parameter
4735 %d The description, if any
4736 %l The length of the encoded part
4737 %p The part identifier number
4738 %e Dots if the part isn't displayed
4740 General format specifiers can also be used. See Info node
4741 `(gnus)Formatting Variables'.")
4743 (defvar gnus-mime-button-line-format-alist
4744 '((?t gnus-tmp-type ?s)
4745 (?T gnus-tmp-type-long ?s)
4746 (?n gnus-tmp-name ?s)
4747 (?d gnus-tmp-description ?s)
4749 (?l gnus-tmp-length ?d)
4750 (?e gnus-tmp-dots ?s)))
4752 (defvar gnus-mime-button-commands
4753 '((gnus-article-press-button "\r" "Toggle Display")
4754 (gnus-mime-view-part "v" "View Interactively...")
4755 (gnus-mime-view-part-as-type "t" "View As Type...")
4756 (gnus-mime-view-part-as-charset "C" "View As charset...")
4757 (gnus-mime-save-part "o" "Save...")
4758 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4759 (gnus-mime-replace-part "r" "Replace part")
4760 (gnus-mime-delete-part "d" "Delete part")
4761 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4762 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4763 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4764 (gnus-mime-view-part-externally "e" "View Externally")
4765 (gnus-mime-print-part "p" "Print")
4766 (gnus-mime-pipe-part "|" "Pipe To Command...")
4767 (gnus-mime-action-on-part "." "Take action on the part...")))
4769 (defun gnus-article-mime-part-status ()
4770 (if gnus-article-mime-handle-alist-1
4771 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4773 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4776 (defvar gnus-mime-button-map
4777 (let ((map (make-sparse-keymap)))
4778 (define-key map gnus-mouse-2 'gnus-article-push-button)
4779 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4780 (dolist (c gnus-mime-button-commands)
4781 (define-key map (cadr c) (car c)))
4785 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4787 ,@(mapcar (lambda (c)
4788 (vector (caddr c) (car c) :active t))
4789 gnus-mime-button-commands)))
4791 (defvar gnus-url-button-commands
4792 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4794 (defvar gnus-url-button-map
4795 (let ((map (make-sparse-keymap)))
4796 (dolist (c gnus-url-button-commands)
4797 (define-key map (cadr c) (car c)))
4801 gnus-url-button-menu gnus-url-button-map "URL button menu."
4803 ,@(mapcar (lambda (c)
4804 (vector (caddr c) (car c) :active t))
4805 gnus-url-button-commands)))
4807 (defmacro gnus-bind-safe-url-regexp (&rest body)
4808 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4809 `(let ((mm-w3m-safe-url-regexp
4810 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4812 gnus-article-current-summary))
4813 (with-current-buffer gnus-article-current-summary
4814 gnus-newsgroup-name)
4815 gnus-newsgroup-name)))
4816 (if (cond ((not group)
4817 ;; Maybe we're in a mml-preview buffer
4818 ;; and no group is selected.
4820 ((stringp gnus-safe-html-newsgroups)
4821 (string-match gnus-safe-html-newsgroups group))
4822 ((consp gnus-safe-html-newsgroups)
4823 (member group gnus-safe-html-newsgroups)))
4825 mm-w3m-safe-url-regexp))))
4828 (defun gnus-mime-button-menu (event prefix)
4829 "Construct a context-sensitive menu of MIME commands."
4830 (interactive "e\nP")
4831 (save-window-excursion
4832 (let ((pos (event-start event)))
4833 (select-window (posn-window pos))
4834 (goto-char (posn-point pos))
4835 (gnus-article-check-buffer)
4836 (popup-menu gnus-mime-button-menu nil prefix))))
4838 (defun gnus-mime-view-all-parts (&optional handles)
4839 "View all the MIME parts."
4841 (with-current-buffer gnus-article-buffer
4842 (let ((handles (or handles gnus-article-mime-handles))
4843 (mail-parse-charset gnus-newsgroup-charset)
4844 (mail-parse-ignored-charsets
4845 (with-current-buffer gnus-summary-buffer
4846 gnus-newsgroup-ignored-charsets)))
4848 (mm-remove-parts handles)
4849 (goto-char (point-min))
4850 (or (search-forward "\n\n") (goto-char (point-max)))
4851 (let ((inhibit-read-only t))
4852 (delete-region (point) (point-max))
4853 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4855 (defun gnus-article-jump-to-part (n)
4856 "Jump to MIME part N."
4858 (let ((parts (with-current-buffer gnus-article-buffer
4859 (length gnus-article-mime-handle-alist))))
4861 (error "No such part"))
4862 (pop-to-buffer gnus-article-buffer)
4863 ;; FIXME: why is it necessary?
4866 (setq n (if (= parts 1)
4868 (read-number (format "Jump to part (1..%s): " parts)))))
4869 (unless (and (integerp n) (<= n parts) (>= n 1))
4872 (gnus-message 7 "Invalid part `%s', using %s instead."
4875 (gnus-message 9 "Jumping to part %s." n)
4876 (cond ((>= gnus-auto-select-part 1)
4877 (while (and (<= n parts)
4878 (not (gnus-article-goto-part n)))
4880 ((< gnus-auto-select-part 0)
4881 (while (and (>= n 1)
4882 (not (gnus-article-goto-part n)))
4885 (gnus-article-goto-part n)))))
4887 (defvar gnus-mime-buttonized-part-id nil
4888 "ID of a mime part that should be buttonized.
4889 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4892 (defsubst gnus-article-edit-part (handles &optional current-id)
4893 "Edit an article in order to delete a mime part.
4894 This function is exclusively used by `gnus-mime-save-part-and-strip'
4895 and `gnus-mime-delete-part', and not provided at run-time normally."
4896 (gnus-article-edit-article
4898 (buffer-disable-undo)
4900 (let ((mail-parse-charset (or gnus-article-charset
4901 ',gnus-newsgroup-charset))
4902 (mail-parse-ignored-charsets
4903 (or gnus-article-ignored-charsets
4904 ',gnus-newsgroup-ignored-charsets))
4905 (mbl mml-buffer-list))
4906 (setq mml-buffer-list nil)
4907 (insert-buffer-substring gnus-original-article-buffer)
4908 (mime-to-mml ',handles)
4909 (setq gnus-article-mime-handles nil)
4910 (let ((mbl1 mml-buffer-list))
4911 (setq mml-buffer-list mbl)
4912 (set (make-local-variable 'mml-buffer-list) mbl1))
4913 (gnus-make-local-hook 'kill-buffer-hook)
4914 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4915 `(lambda (no-highlight)
4916 (let ((mail-parse-charset (or gnus-article-charset
4917 ',gnus-newsgroup-charset))
4918 (message-options message-options)
4919 (message-options-set-recipient)
4920 (mail-parse-ignored-charsets
4921 (or gnus-article-ignored-charsets
4922 ',gnus-newsgroup-ignored-charsets)))
4924 (mml-destroy-buffers)
4925 (remove-hook 'kill-buffer-hook
4926 'mml-destroy-buffers t)
4927 (kill-local-variable 'mml-buffer-list))
4928 (gnus-summary-edit-article-done
4929 ,(or (mail-header-references gnus-current-headers) "")
4930 ,(gnus-group-read-only-p)
4931 ,gnus-summary-buffer no-highlight))
4933 ;; Force buttonizing this part.
4934 (let ((gnus-mime-buttonized-part-id current-id))
4935 (gnus-article-edit-done))
4936 (gnus-configure-windows 'article)
4937 (when (and current-id (integerp gnus-auto-select-part))
4938 (gnus-article-jump-to-part
4939 (min (max (+ current-id gnus-auto-select-part) 1)
4940 (with-current-buffer gnus-article-buffer
4941 (length gnus-article-mime-handle-alist)))))))
4943 (defun gnus-mime-replace-part (file)
4944 "Replace MIME part under point with an external body."
4945 ;; Useful if file has already been saved to disk
4948 (read-file-name "Replace MIME part with file: "
4949 (or mm-default-directory default-directory)
4951 (gnus-mime-save-part-and-strip file))
4953 (defun gnus-mime-save-part-and-strip (&optional file)
4954 "Save the MIME part under point then replace it with an external body.
4955 If FILE is given, use it for the external part."
4957 (gnus-article-check-buffer)
4958 (when (gnus-group-read-only-p)
4959 (error "The current group does not support deleting of parts"))
4960 (when (mm-complicated-handles gnus-article-mime-handles)
4962 The current article has a complicated MIME structure, giving up..."))
4963 (let* ((data (get-text-property (point) 'gnus-data))
4964 (id (get-text-property (point) 'gnus-part))
4966 (handles gnus-article-mime-handles))
4969 (and data (mm-save-part data "Delete MIME part and save to: "))))
4971 (with-current-buffer (mm-handle-buffer data)
4973 (insert "Content-Type: " (mm-handle-media-type data))
4974 (mml-insert-parameter-string (cdr (mm-handle-type data))
4976 ;; Add a filename for the sake of saving the part again.
4977 (mml-insert-parameter
4978 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4980 (insert "Content-ID: " (message-make-message-id) "\n")
4981 (insert "Content-Transfer-Encoding: binary\n")
4984 (cdr (mm-make-handle nil
4985 `("message/external-body"
4986 (access-type . "LOCAL-FILE")
4988 ;; (set-buffer gnus-summary-buffer)
4989 (gnus-article-edit-part handles id))))
4991 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4992 ;; parts...>') but with stripping would be nice.
4994 (defun gnus-mime-delete-part ()
4995 "Delete the MIME part under point.
4996 Replace it with some information about the removed part."
4998 (gnus-article-check-buffer)
4999 (when (gnus-group-read-only-p)
5000 (error "The current group does not support deleting of parts"))
5001 (when (mm-complicated-handles gnus-article-mime-handles)
5003 The current article has a complicated MIME structure, giving up..."))
5004 (when (or gnus-expert-user
5005 (gnus-yes-or-no-p "\
5006 Deleting parts may malfunction or destroy the article; continue? "))
5007 (let* ((data (get-text-property (point) 'gnus-data))
5008 (id (get-text-property (point) 'gnus-part))
5009 (handles gnus-article-mime-handles)
5012 (let ((desc (mm-handle-description data)))
5014 (mail-decode-encoded-word-string desc))))
5016 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
5018 (type (mm-handle-media-type data)))
5020 (error "No MIME part under point"))
5021 (with-current-buffer (mm-handle-buffer data)
5022 (let ((bsize (buffer-size)))
5027 "| The following attachment has been deleted:\n"
5029 "| Type: " type "\n"
5030 "| Filename: " filename "\n"
5031 "| Size (encoded): " (format "%s byte%s\n"
5032 bsize (if (= bsize 1)
5036 (concat "| Description: " description "\n"))
5039 (cdr (mm-make-handle
5040 nil `("text/plain" (charset . gnus-decoded)) nil nil
5042 (format "Deleted attachment (%s bytes)" bsize))))))
5043 ;; (set-buffer gnus-summary-buffer)
5044 (gnus-article-edit-part handles id))))
5046 (defun gnus-mime-save-part ()
5047 "Save the MIME part under point."
5049 (gnus-article-check-buffer)
5050 (let ((data (get-text-property (point) 'gnus-data)))
5052 (mm-save-part data))))
5054 (defun gnus-mime-pipe-part (&optional cmd)
5055 "Pipe the MIME part under point to a process.
5056 Use CMD as the process."
5058 (gnus-article-check-buffer)
5059 (let ((data (get-text-property (point) 'gnus-data)))
5061 (mm-pipe-part data cmd))))
5063 (defun gnus-mime-view-part ()
5064 "Interactively choose a viewing method for the MIME part under point."
5066 (gnus-article-check-buffer)
5067 (let ((data (get-text-property (point) 'gnus-data)))
5069 (setq gnus-article-mime-handles
5071 gnus-article-mime-handles (setq data (copy-sequence data))))
5072 (mm-interactively-view-part data))))
5074 (defun gnus-mime-view-part-as-type-internal ()
5075 (gnus-article-check-buffer)
5076 (let* ((handle (get-text-property (point) 'gnus-data))
5078 ;; Content-Type: foo/bar; name=...
5079 (mail-content-type-get (mm-handle-type handle) 'name)
5080 ;; Content-Disposition: attachment; filename=...
5081 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5082 (def-type (and name (mm-default-file-encoding name))))
5083 (or (and def-type (cons def-type 0))
5085 (equal (mm-handle-media-supertype handle) "text")
5086 '("text/plain" . 0))
5087 '("application/octet-stream" . 0))))
5089 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5090 "Choose a MIME media type, and view the part as such.
5091 If non-nil, PRED is a predicate to use during completion to limit the
5092 available media-types."
5096 (let ((default (gnus-mime-view-part-as-type-internal)))
5097 (gnus-completing-read
5100 (gnus-remove-if-not pred (mailcap-mime-types))
5101 (mailcap-mime-types))
5104 (gnus-article-check-buffer)
5105 (let ((handle (get-text-property (point) 'gnus-data)))
5107 (when (equal (mm-handle-media-type handle) "message/external-body")
5108 (unless (mm-handle-cache handle)
5109 (mm-extern-cache-contents handle))
5110 (setq handle (mm-handle-cache handle)))
5112 (mm-make-handle (mm-handle-buffer handle)
5113 (cons mime-type (cdr (mm-handle-type handle)))
5114 (mm-handle-encoding handle)
5115 (mm-handle-undisplayer handle)
5116 (mm-handle-disposition handle)
5117 (mm-handle-description handle)
5119 (mm-handle-id handle)))
5120 (setq gnus-article-mime-handles
5121 (mm-merge-handles gnus-article-mime-handles handle))
5122 (when (mm-handle-displayed-p handle)
5123 (mm-remove-part handle))
5124 (gnus-mm-display-part handle))))
5126 (defun gnus-mime-copy-part (&optional handle arg)
5127 "Put the MIME part under point into a new buffer.
5128 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5130 (interactive (list nil current-prefix-arg))
5131 (gnus-article-check-buffer)
5133 (setq handle (get-text-property (point) 'gnus-data)))
5135 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5137 (mail-content-type-get (mm-handle-disposition handle)
5139 contents dont-decode charset coding-system)
5140 (mm-with-unibyte-buffer
5141 (mm-insert-part handle)
5142 (setq contents (or (condition-case nil
5143 (mm-decompress-buffer filename nil 'sig)
5145 (setq dont-decode t)
5148 (setq filename (cond (filename (file-name-nondirectory filename))
5149 (dont-decode "*raw data*")
5154 (unless (setq charset (mail-content-type-get
5155 (mm-handle-type handle) 'charset))
5156 (unless (setq coding-system (mm-with-unibyte-buffer
5158 (mm-find-buffer-file-coding-system)))
5159 (setq charset gnus-newsgroup-charset))))
5161 (setq charset (or (cdr (assq arg
5162 gnus-summary-show-article-charset-alist))
5163 (mm-read-coding-system "Charset: ")))))
5164 (switch-to-buffer (generate-new-buffer filename))
5165 (if (or coding-system
5167 (setq coding-system (mm-charset-to-coding-system charset))
5168 (not (eq coding-system 'ascii))))
5170 (mm-enable-multibyte)
5171 (insert (mm-decode-coding-string contents coding-system))
5172 (setq buffer-file-coding-system
5173 (if (boundp 'last-coding-system-used)
5174 (symbol-value 'last-coding-system-used)
5176 (mm-disable-multibyte)
5178 (setq buffer-file-coding-system mm-binary-coding-system))
5179 ;; We do it this way to make `normal-mode' set the appropriate mode.
5182 (setq buffer-file-name (expand-file-name filename))
5184 (setq buffer-file-name nil))
5185 (goto-char (point-min)))))
5187 (defun gnus-mime-print-part (&optional handle filename)
5188 "Print the MIME part under point."
5189 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5190 (gnus-article-check-buffer)
5191 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5192 (contents (and handle (mm-get-part handle)))
5193 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5194 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5199 (mm-save-part-to-file handle file)
5200 (call-process shell-file-name nil
5201 (generate-new-buffer " *mm*")
5203 shell-command-switch
5205 printer file (mm-handle-type handle))))
5209 (gnus-print-buffer))
5210 (ps-despool filename)))))
5212 (defun gnus-mime-inline-part (&optional handle arg)
5213 "Insert the MIME part under point into the current buffer.
5214 Compressed files like .gz and .bz2 are decompressed."
5215 (interactive (list nil current-prefix-arg))
5216 (gnus-article-check-buffer)
5218 (setq handle (get-text-property (point) 'gnus-data)))
5221 (inhibit-read-only t)
5222 contents charset coding-system)
5223 (if (and (not arg) (mm-handle-undisplayer handle))
5224 (mm-remove-part handle)
5225 (mm-with-unibyte-buffer
5226 (mm-insert-part handle)
5228 (or (mm-decompress-buffer
5229 (or (mail-content-type-get (mm-handle-type handle)
5231 (mail-content-type-get (mm-handle-disposition handle)
5237 (unless (setq charset (mail-content-type-get
5238 (mm-handle-type handle) 'charset))
5239 (unless (setq coding-system
5240 (mm-with-unibyte-buffer
5242 (mm-find-buffer-file-coding-system)))
5243 (setq charset gnus-newsgroup-charset))))
5245 (if (mm-handle-undisplayer handle)
5246 (mm-remove-part handle))
5249 gnus-summary-show-article-charset-alist))
5250 (mm-read-coding-system "Charset: "))))
5252 (if (mm-handle-undisplayer handle)
5253 (mm-remove-part handle))))
5255 (mm-display-inline handle)
5258 (defun gnus-mime-set-charset-parameters (handle charset)
5259 "Set CHARSET to parameters in HANDLE.
5260 CHARSET may either be a string or a symbol."
5261 (unless (stringp charset)
5262 (setq charset (symbol-name charset)))
5263 (if (stringp (car handle))
5264 (dolist (h (cdr handle))
5265 (gnus-mime-set-charset-parameters h charset))
5266 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5267 "message/external-body")
5269 (unless (mm-handle-cache handle)
5270 (mm-extern-cache-contents handle))
5271 (mm-handle-cache handle))
5273 (param (assq 'charset (cdr type))))
5275 (setcdr param charset)
5276 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5278 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5279 "Insert the MIME part under point into the current buffer using the
5281 (interactive (list nil current-prefix-arg))
5282 (gnus-article-check-buffer)
5283 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5284 (fun (get-text-property (point) 'gnus-callback))
5285 (gnus-newsgroup-ignored-charsets 'gnus-all)
5286 charset form preferred parts)
5293 gnus-summary-show-article-charset-alist))
5294 (mm-read-coding-system "Charset: "))))
5295 (if (mm-handle-undisplayer handle)
5296 (mm-remove-part handle)))
5297 (gnus-mime-set-charset-parameters handle charset)
5298 (when (and (consp (setq form (cdr-safe fun)))
5299 (setq form (ignore-errors
5300 (assq 'gnus-mime-display-alternative form)))
5301 (setq preferred (caddr form))
5303 (when (eq (car preferred) 'quote)
5304 (setq preferred (cadr preferred)))
5305 (not (equal preferred
5306 (get-text-property (point) 'gnus-data))))
5307 (setq parts (get-text-property (point) 'gnus-part))
5308 (setq parts (cdr (assq parts
5309 gnus-article-mime-handle-alist)))
5310 (equal (mm-handle-media-type parts) "multipart/alternative")
5311 (setq parts (reverse (cdr parts))))
5313 (list 'quote (or (cadr (member preferred parts))
5315 (funcall fun handle)))))
5317 (defun gnus-mime-view-part-externally (&optional handle)
5318 "View the MIME part under point with an external viewer."
5320 (gnus-article-check-buffer)
5321 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5322 (mm-user-display-methods nil)
5323 (mm-inlined-types nil)
5324 (mail-parse-charset gnus-newsgroup-charset)
5325 (mail-parse-ignored-charsets
5326 (with-current-buffer gnus-summary-buffer
5327 gnus-newsgroup-ignored-charsets))
5328 (type (mm-handle-media-type handle))
5329 (method (mailcap-mime-info type))
5330 (mm-enable-external t))
5331 (if (not (stringp method))
5332 (gnus-mime-view-part-as-type
5333 nil (lambda (type) (stringp (mailcap-mime-info type))))
5335 (mm-display-part handle nil t)))))
5337 (defun gnus-mime-view-part-internally (&optional handle)
5338 "View the MIME part under point with an internal viewer.
5339 If no internal viewer is available, use an external viewer."
5341 (gnus-article-check-buffer)
5342 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5343 (mm-inlined-types '(".*"))
5344 (mm-inline-large-images t)
5345 (mail-parse-charset gnus-newsgroup-charset)
5346 (mail-parse-ignored-charsets
5347 (with-current-buffer gnus-summary-buffer
5348 gnus-newsgroup-ignored-charsets))
5349 (inhibit-read-only t))
5350 (if (not (mm-inlinable-p handle))
5351 (gnus-mime-view-part-as-type
5352 nil (lambda (type) (mm-inlinable-p handle type)))
5354 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5356 (defun gnus-mime-action-on-part (&optional action)
5357 "Do something with the MIME attachment at \(point\)."
5359 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5360 (gnus-article-check-buffer)
5361 (let ((action-pair (assoc action gnus-mime-action-alist)))
5363 (funcall (cdr action-pair)))))
5365 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5366 "Call FUNCTION on MIME part N.
5367 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5368 If INTERACTIVE, call FUNCTION interactivly."
5370 ;; Check whether the article is displayed.
5371 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5372 (setq window (get-buffer-window gnus-article-buffer t))
5373 (frame-visible-p (setq frame (window-frame window))))
5374 (error "No article is displayed"))
5375 (with-current-buffer gnus-article-buffer
5376 ;; Check whether the article displays the right contents.
5377 (unless (with-current-buffer gnus-summary-buffer
5378 (eq gnus-current-article (gnus-summary-article-number)))
5379 (error "You should select the right article first"))
5381 (setq n (prefix-numeric-value n))
5383 (setq n (or (get-text-property pt 'gnus-part)
5385 (get-text-property (1- pt) 'gnus-part))
5386 (get-text-property (prog2
5392 (or (and (setq pt (previous-single-property-change
5395 (next-single-property-change (point) 'gnus-part)
5399 ;; Check whether the specified part exists.
5400 (when (> n (length gnus-article-mime-handle-alist))
5401 (error "No such part")))
5404 ;; To select the window is needed so that the cursor
5405 ;; might be visible on the MIME button.
5406 (select-window (prog1
5408 (setq window (selected-window))
5409 ;; Article may be displayed in the other frame.
5410 (gnus-select-frame-set-input-focus
5413 (setq frame (selected-frame))))))
5414 (when (gnus-article-goto-part n)
5415 ;; We point the cursor and the arrow at the MIME button
5416 ;; when the `function' prompt the user for something.
5417 (unless (and (pos-visible-in-window-p)
5418 (> (count-lines (point) (window-end))
5419 (/ (1- (window-height)) 3)))
5420 (recenter (/ (1- (window-height)) 3)))
5421 (let ((cursor-in-non-selected-windows t)
5422 (overlay-arrow-string "=>")
5423 (overlay-arrow-position (point-marker)))
5426 ((and no-handle interactive)
5427 (call-interactively function))
5432 function (get-text-property (point) 'gnus-data)))
5435 (get-text-property (point) 'gnus-data))))
5436 (set-marker overlay-arrow-position nil)
5437 (unless gnus-auto-select-part
5438 (gnus-select-frame-set-input-focus frame)
5439 (select-window window))))
5441 (if gnus-inhibit-mime-unbuttonizing
5442 ;; This is the default though the program shouldn't reach here.
5443 (error "No such part")
5444 ;; The part which doesn't have the MIME button is selected.
5445 ;; So, we display all the buttons and redo it.
5446 (let ((gnus-inhibit-mime-unbuttonizing t))
5447 (gnus-summary-show-article)
5448 (gnus-article-part-wrapper n function no-handle))))))
5450 (defun gnus-article-pipe-part (n)
5451 "Pipe MIME part N, which is the numerical prefix."
5453 (gnus-article-part-wrapper n 'mm-pipe-part))
5455 (defun gnus-article-save-part (n)
5456 "Save MIME part N, which is the numerical prefix."
5458 (gnus-article-part-wrapper n 'mm-save-part))
5460 (defun gnus-article-interactively-view-part (n)
5461 "View MIME part N interactively, which is the numerical prefix."
5463 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5465 (defun gnus-article-copy-part (n)
5466 "Copy MIME part N, which is the numerical prefix."
5468 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5470 (defun gnus-article-view-part-as-charset (n)
5471 "View MIME part N using a specified charset.
5472 N is the numerical prefix."
5474 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5476 (defun gnus-article-view-part-externally (n)
5477 "View MIME part N externally, which is the numerical prefix."
5479 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5481 (defun gnus-article-inline-part (n)
5482 "Inline MIME part N, which is the numerical prefix."
5484 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5486 (defun gnus-article-save-part-and-strip (n)
5487 "Save MIME part N and replace it with an external body.
5488 N is the numerical prefix."
5490 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5492 (defun gnus-article-replace-part (n)
5493 "Replace MIME part N with an external body.
5494 N is the numerical prefix."
5496 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5498 (defun gnus-article-delete-part (n)
5499 "Delete MIME part N and add some information about the removed part.
5500 N is the numerical prefix."
5502 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5504 (defun gnus-article-view-part-as-type (n)
5505 "Choose a MIME media type, and view part N as such.
5506 N is the numerical prefix."
5508 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5510 (defun gnus-article-mime-match-handle-first (condition)
5513 (dolist (ihandle gnus-article-mime-handle-alist)
5515 ((functionp condition)
5516 (funcall condition (cdr ihandle)))
5517 ((eq condition 'undisplayed)
5518 (not (or (mm-handle-undisplayer (cdr ihandle))
5519 (equal (mm-handle-media-type (cdr ihandle))
5520 "multipart/alternative"))))
5521 ((eq condition 'undisplayed-alternative)
5522 (not (mm-handle-undisplayer (cdr ihandle))))
5524 (gnus-article-goto-part (car ihandle))
5525 (or (not n) (< (car ihandle) n)))
5526 (setq n (car ihandle))))
5530 (defun gnus-article-view-part (&optional n)
5531 "View MIME part N, which is the numerical prefix.
5532 If the part is already shown, hide the part. If N is nil, view
5535 (with-current-buffer gnus-article-buffer
5536 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5537 gnus-article-mime-match-handle-function)))
5538 (when (> n (length gnus-article-mime-handle-alist))
5539 (error "No such part"))
5540 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5541 (when (gnus-article-goto-part n)
5542 (if (equal (car handle) "multipart/alternative")
5543 (gnus-article-press-button)
5544 (when (eq (gnus-mm-display-part handle) 'internal)
5545 (gnus-set-window-start)))))))
5547 (defsubst gnus-article-mime-total-parts ()
5548 (if (bufferp (car gnus-article-mime-handles))
5550 (1- (length gnus-article-mime-handles))))
5552 (defun gnus-mm-display-part (handle)
5553 "Display HANDLE and fix MIME button."
5554 (let ((id (get-text-property (point) 'gnus-part))
5556 (inhibit-read-only t))
5559 (let ((window (selected-window))
5560 (mail-parse-charset gnus-newsgroup-charset)
5561 (mail-parse-ignored-charsets
5562 (if (gnus-buffer-live-p gnus-summary-buffer)
5563 (with-current-buffer gnus-summary-buffer
5564 gnus-newsgroup-ignored-charsets)
5568 (let ((win (gnus-get-buffer-window (current-buffer) t))
5571 (select-window win))
5574 (if (mm-handle-displayed-p handle)
5575 ;; This will remove the part.
5576 (mm-display-part handle)
5578 (narrow-to-region (point)
5579 (if (eobp) (point) (1+ (point))))
5580 (gnus-bind-safe-url-regexp (mm-display-part handle))
5581 ;; We narrow to the part itself and
5582 ;; then call the treatment functions.
5583 (goto-char (point-min))
5585 (narrow-to-region (point) (point-max))
5588 (gnus-article-mime-total-parts)
5589 (mm-handle-media-type handle)))))
5590 (if (window-live-p window)
5591 (select-window window)))))
5594 (gnus-insert-mime-button
5595 handle id (list (mm-handle-displayed-p handle)))
5596 (goto-char point))))
5598 (defun gnus-article-goto-part (n)
5599 "Go to MIME part N."
5600 (when gnus-break-pages
5603 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5604 part handle end next handles)
5607 (if (setq handle (get-text-property start 'gnus-data))
5609 ;; Go to the displayed subpart, assuming this is
5610 ;; multipart/alternative.
5613 (while (and (not handle)
5616 (setq next (text-property-not-all part end
5619 handle (get-text-property part 'gnus-data))
5620 (push (cons handle part) handles)
5621 (unless (mm-handle-displayed-p handle)
5623 part (text-property-any part end 'gnus-data nil))))
5625 ;; No subpart is displayed, so we find preferred one.
5627 (cdr (assq (mm-preferred-alternative
5628 (nreverse (mapcar 'car handles)))
5631 (goto-char (1+ part))
5633 (when gnus-break-pages
5634 (gnus-narrow-to-page))))
5636 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5637 (let ((gnus-tmp-name
5638 (or (mail-content-type-get (mm-handle-type handle) 'name)
5639 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5640 (mail-content-type-get (mm-handle-type handle) 'url)
5642 (gnus-tmp-type (mm-handle-media-type handle))
5643 (gnus-tmp-description (or (mm-handle-description handle) ""))
5645 (if (if displayed (car displayed)
5646 (mm-handle-displayed-p handle))
5648 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5650 gnus-tmp-type-long b e)
5651 (when (string-match ".*/" gnus-tmp-name)
5652 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5653 (setq gnus-tmp-type-long (concat gnus-tmp-type
5654 (and (not (equal gnus-tmp-name ""))
5655 (concat "; " gnus-tmp-name))))
5656 (unless (equal gnus-tmp-description "")
5657 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5662 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5663 `(keymap ,gnus-mime-button-map
5664 gnus-callback gnus-mm-display-part
5665 gnus-part ,gnus-tmp-id
5666 article-type annotation
5669 ;; Exclude a newline.
5672 (when gnus-article-button-face
5673 (gnus-overlay-put (gnus-make-overlay b e nil t)
5674 'face gnus-article-button-face))
5675 (widget-convert-button
5678 :action 'gnus-widget-press-button
5679 :button-keymap gnus-mime-button-map
5682 ;; Needed to properly clear the message due to a bug in
5683 ;; wid-edit (XEmacs only).
5684 (if (boundp 'help-echo-owns-message)
5685 (setq help-echo-owns-message t))
5687 "%S: %s the MIME part; %S: more options"
5688 (aref gnus-mouse-2 0)
5689 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5691 (aref gnus-down-mouse-3 0))))))
5693 (defun gnus-widget-press-button (elems el)
5694 (goto-char (widget-get elems :from))
5695 (gnus-article-press-button))
5697 (defvar gnus-displaying-mime nil)
5699 (defun gnus-display-mime (&optional ihandles)
5700 "Display the MIME parts."
5702 (save-selected-window
5703 (let ((window (get-buffer-window gnus-article-buffer))
5706 (select-window window)
5707 ;; We have to do this since selecting the window
5708 ;; may change the point. So we set the window point.
5709 (set-window-point window point)))
5710 (let ((handles ihandles)
5711 (inhibit-read-only t)
5714 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5715 (when gnus-article-emulate-mime
5716 (mm-uu-dissect-text-parts handles)))
5717 (gnus-article-emulate-mime
5718 (setq handles (mm-uu-dissect))))
5719 (when (and (not ihandles)
5720 (not gnus-displaying-mime))
5721 ;; Top-level call; we clean up.
5722 (when gnus-article-mime-handles
5723 (mm-destroy-parts gnus-article-mime-handles)
5724 (setq gnus-article-mime-handle-alist nil));; A trick.
5725 (setq gnus-article-mime-handles handles)
5726 ;; We allow users to glean info from the handles.
5727 (when gnus-article-mime-part-function
5728 (gnus-mime-part-function handles)))
5730 (or (not (stringp (car handles)))
5733 (when (and (not ihandles)
5734 (not gnus-displaying-mime))
5735 ;; Clean up for mime parts.
5737 (delete-region (point) (point-max)))
5738 (let ((gnus-displaying-mime t))
5739 (gnus-mime-display-part handles)))
5742 (narrow-to-region (point) (point-max))
5743 (gnus-treat-article nil 1 1 "text/plain")
5746 ;; Highlight the headers.
5750 (narrow-to-region (point-min) (point))
5751 (gnus-article-save-original-date
5752 (gnus-treat-article 'head)))))))
5753 ;; Cope with broken MIME messages.
5754 (goto-char (point-max))
5758 (defcustom gnus-mime-display-multipart-as-mixed nil
5759 "Display \"multipart\" parts as \"multipart/mixed\".
5761 If t, it overrides nil values of
5762 `gnus-mime-display-multipart-alternative-as-mixed' and
5763 `gnus-mime-display-multipart-related-as-mixed'."
5764 :group 'gnus-article-mime
5767 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5768 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5770 :group 'gnus-article-mime
5773 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5774 "Display \"multipart/related\" parts as \"multipart/mixed\".
5776 If displaying \"text/html\" is discouraged \(see
5777 `mm-discouraged-alternatives'\) images or other material inside a
5778 \"multipart/related\" part might be overlooked when this variable is nil."
5780 :group 'gnus-article-mime
5783 (defun gnus-mime-display-part (handle)
5785 ;; Maybe a broken MIME message.
5788 ((not (stringp (car handle)))
5789 (gnus-mime-display-single handle))
5790 ;; User-defined multipart
5791 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5792 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5794 ;; multipart/alternative
5795 ((and (equal (car handle) "multipart/alternative")
5796 (not (or gnus-mime-display-multipart-as-mixed
5797 gnus-mime-display-multipart-alternative-as-mixed)))
5798 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5799 (push (cons id handle) gnus-article-mime-handle-alist)
5800 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5801 ;; multipart/related
5802 ((and (equal (car handle) "multipart/related")
5803 (not (or gnus-mime-display-multipart-as-mixed
5804 gnus-mime-display-multipart-related-as-mixed)))
5805 ;;;!!!We should find the start part, but we just default
5806 ;;;!!!to the first part.
5807 ;;(gnus-mime-display-part (cadr handle))
5808 ;;;!!! Most multipart/related is an HTML message plus images.
5809 ;;;!!! Unfortunately we are unable to let W3 display those
5810 ;;;!!! included images, so we just display it as a mixed multipart.
5811 ;;(gnus-mime-display-mixed (cdr handle))
5812 ;;;!!! No, w3 can display everything just fine.
5813 (gnus-mime-display-part (cadr handle)))
5814 ((equal (car handle) "multipart/signed")
5815 (gnus-add-wash-type 'signed)
5816 (gnus-mime-display-security handle))
5817 ((equal (car handle) "multipart/encrypted")
5818 (gnus-add-wash-type 'encrypted)
5819 (gnus-mime-display-security handle))
5820 ;; Other multiparts are handled like multipart/mixed.
5822 (gnus-mime-display-mixed (cdr handle)))))
5824 (defun gnus-mime-part-function (handles)
5825 (if (stringp (car handles))
5826 (mapcar 'gnus-mime-part-function (cdr handles))
5827 (funcall gnus-article-mime-part-function handles)))
5829 (defun gnus-mime-display-mixed (handles)
5830 (mapcar 'gnus-mime-display-part handles))
5832 (defun gnus-mime-display-single (handle)
5833 (let ((type (mm-handle-media-type handle))
5834 (ignored gnus-ignored-mime-types)
5841 (when (string-match (pop ignored) type)
5842 (throw 'ignored nil)))
5843 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5844 (with-current-buffer gnus-summary-buffer
5845 gnus-inhibit-images)
5846 gnus-inhibit-images)
5847 (string-match "\\`image/" type)))
5848 (setq not-attachment
5849 (and (not (mm-inline-override-p handle))
5850 (or (not (mm-handle-disposition handle))
5851 (equal (car (mm-handle-disposition handle))
5853 (mm-attachment-override-p handle))))
5854 (mm-automatic-display-p handle)
5856 (mm-inlinable-p handle)
5857 (mm-inlined-p handle))
5858 (mm-automatic-external-display-p type)))
5860 (when (equal (mm-handle-media-supertype handle) "text")
5862 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5864 (push (cons id handle) gnus-article-mime-handle-alist)
5866 (equal (mm-handle-media-supertype handle) "message"))
5869 (cond ((not (bolp)) 2)
5870 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5872 (when (or (not display)
5873 (not (gnus-unbuttonized-mime-type-p type))
5874 (eq id gnus-mime-buttonized-part-id))
5875 (gnus-insert-mime-button
5876 handle id (list (or display (and not-attachment text))))
5877 (gnus-article-insert-newline)
5878 ;; Remember modify the number of forward lines.
5886 (let ((mail-parse-charset gnus-newsgroup-charset)
5887 (mail-parse-ignored-charsets
5888 (save-excursion (condition-case ()
5889 (set-buffer gnus-summary-buffer)
5891 gnus-newsgroup-ignored-charsets)))
5892 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5893 (goto-char (point-max)))
5894 ((and text not-attachment)
5898 (gnus-article-insert-newline)
5899 (mm-display-inline handle)
5900 (goto-char (point-max))))
5904 (narrow-to-region beg (point))
5905 (if (eq handle gnus-article-mime-handles)
5906 ;; The format=flowed case.
5907 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5908 ;; Don't count signature parts that are never displayed.
5909 ;; The part number should be re-calculated supposing this
5910 ;; might be a message/rfc822 part.
5912 (dolist (part gnus-article-mime-handles)
5913 (unless (or (stringp part)
5914 (equal (car (mm-handle-type part))
5915 "application/pgp-signature"))
5916 (push part handles)))
5918 nil (length (memq handle handles)) (length handles)
5919 (mm-handle-media-type handle)))))))))))
5921 (defun gnus-unbuttonized-mime-type-p (type)
5922 "Say whether TYPE is to be unbuttonized."
5923 (unless gnus-inhibit-mime-unbuttonizing
5925 (let ((types gnus-unbuttonized-mime-types))
5927 (when (string-match (pop types) type)
5928 (throw 'found t)))))
5930 (let ((types gnus-buttonized-mime-types))
5932 (when (string-match (pop types) type)
5933 (throw 'found t)))))))))
5935 (defun gnus-article-insert-newline ()
5936 "Insert a newline, but mark it as undeletable."
5937 (gnus-put-text-property
5938 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5940 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5941 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5944 handle (inhibit-read-only t) from props begend not-pref)
5945 (save-window-excursion
5948 (narrow-to-region (car ibegend)
5951 (goto-char (car ibegend))
5954 (delete-region (point-min) (point-max))
5955 (mm-remove-parts handles))
5956 (setq begend (list (point-marker)))
5958 (unless (setq not-pref (cadr (member preferred ihandles)))
5959 (setq not-pref (car ihandles)))
5962 (not (gnus-unbuttonized-mime-type-p
5963 "multipart/alternative")))
5964 (gnus-add-text-properties
5967 (insert (format "%d. " id))
5971 (unless ,(not ibegend)
5972 (setq gnus-article-mime-handle-alist
5973 ',gnus-article-mime-handle-alist))
5974 (gnus-mime-display-alternative
5975 ',ihandles ',not-pref ',begend ,id))
5976 keymap ,gnus-mime-button-map
5977 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5978 face ,gnus-article-button-face
5980 article-type multipart))
5981 (widget-convert-button 'link from (point)
5982 :action 'gnus-widget-press-button
5983 :button-keymap gnus-widget-button-keymap)
5985 (while (setq handle (pop handles))
5986 (gnus-add-text-properties
5989 (insert (format "(%c) %-18s"
5990 (if (equal handle preferred) ?* ? )
5991 (mm-handle-media-type handle)))
5995 (unless ,(not ibegend)
5996 (setq gnus-article-mime-handle-alist
5997 ',gnus-article-mime-handle-alist))
5998 (gnus-mime-display-alternative
5999 ',ihandles ',handle ',begend ,id))
6000 keymap ,gnus-mime-button-map
6001 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6002 face ,gnus-article-button-face
6005 (widget-convert-button 'link from (point)
6006 :action 'gnus-widget-press-button
6007 :button-keymap gnus-widget-button-keymap)
6011 (if (stringp (car preferred))
6012 (gnus-display-mime preferred)
6013 (let ((mail-parse-charset gnus-newsgroup-charset)
6014 (mail-parse-ignored-charsets
6015 (with-current-buffer gnus-summary-buffer
6016 gnus-newsgroup-ignored-charsets)))
6017 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6021 (narrow-to-region (car begend) (point-max))
6023 nil (length gnus-article-mime-handle-alist)
6024 (gnus-article-mime-total-parts)
6025 (mm-handle-media-type preferred))))))
6026 (goto-char (point-max))
6027 (setcdr begend (point-marker)))))
6029 (goto-char point))))
6031 (defconst gnus-article-wash-status-strings
6032 (let ((alist '((cite "c" "Possible hidden citation text"
6033 " " "All citation text visible")
6034 (headers "h" "Hidden headers"
6035 " " "All headers visible.")
6036 (pgp "p" "Encrypted or signed message status hidden"
6037 " " "No hidden encryption nor digital signature status")
6038 (signature "s" "Signature has been hidden"
6039 " " "Signature is visible")
6040 (overstrike "o" "Overstrike (^H) characters applied"
6041 " " "No overstrike characters applied")
6042 (emphasis "e" "/*_Emphasis_*/ characters applied"
6043 " " "No /*_emphasis_*/ characters applied")))
6045 (dolist (entry alist result)
6046 (let ((key (nth 0 entry))
6047 (on (copy-sequence (nth 1 entry)))
6048 (on-help (nth 2 entry))
6049 (off (copy-sequence (nth 3 entry)))
6050 (off-help (nth 4 entry)))
6051 (put-text-property 0 1 'help-echo on-help on)
6052 (put-text-property 0 1 'help-echo off-help off)
6053 (push (list key on off) result))))
6054 "Alist of strings describing wash status in the mode line.
6055 Each entry has the form (KEY ON OF), where the KEY is a symbol
6056 representing the particular washing function, ON is the string to use
6057 in the article mode line when the washing function is active, and OFF
6058 is the string to use when it is inactive.")
6060 (defun gnus-article-wash-status-entry (key value)
6061 (let ((entry (assoc key gnus-article-wash-status-strings)))
6062 (if value (nth 1 entry) (nth 2 entry))))
6064 (defun gnus-article-wash-status ()
6065 "Return a string which display status of article washing."
6066 (with-current-buffer gnus-article-buffer
6067 (let ((cite (memq 'cite gnus-article-wash-types))
6068 (headers (memq 'headers gnus-article-wash-types))
6069 (boring (memq 'boring-headers gnus-article-wash-types))
6070 (pgp (memq 'pgp gnus-article-wash-types))
6071 (pem (memq 'pem gnus-article-wash-types))
6072 (signed (memq 'signed gnus-article-wash-types))
6073 (encrypted (memq 'encrypted gnus-article-wash-types))
6074 (signature (memq 'signature gnus-article-wash-types))
6075 (overstrike (memq 'overstrike gnus-article-wash-types))
6076 (emphasis (memq 'emphasis gnus-article-wash-types)))
6078 (gnus-article-wash-status-entry 'cite cite)
6079 (gnus-article-wash-status-entry 'headers (or headers boring))
6080 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6081 (gnus-article-wash-status-entry 'signature signature)
6082 (gnus-article-wash-status-entry 'overstrike overstrike)
6083 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6085 (defun gnus-add-wash-type (type)
6086 "Add a washing of TYPE to the current status."
6087 (add-to-list 'gnus-article-wash-types type))
6089 (defun gnus-delete-wash-type (type)
6090 "Add a washing of TYPE to the current status."
6091 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6093 (defun gnus-add-image (category image)
6094 "Add IMAGE of CATEGORY to the list of displayed images."
6095 (let ((entry (assq category gnus-article-image-alist)))
6097 (setq entry (list category))
6098 (push entry gnus-article-image-alist))
6099 (nconc entry (list image))))
6101 (defun gnus-delete-images (category)
6102 "Delete all images in CATEGORY."
6103 (let ((entry (assq category gnus-article-image-alist)))
6104 (dolist (image (cdr entry))
6105 (gnus-remove-image image category))
6106 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6107 (gnus-delete-wash-type category)))
6109 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6111 (defun gnus-article-maybe-hide-headers ()
6112 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6113 Provided for backwards compatibility."
6114 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6115 (not (with-current-buffer gnus-summary-buffer
6116 gnus-have-all-headers)))
6117 (not gnus-inhibit-hiding))
6118 (gnus-article-hide-headers)))
6122 (defun gnus-output-to-file (file-name)
6123 "Append the current article to a file named FILE-NAME.
6124 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6125 text and used as the value of the coding cookie which is added to the
6126 top of a file. Otherwise, this function saves a raw article without
6128 (let* ((artbuf (current-buffer))
6129 (file-name-coding-system nnmail-pathname-coding-system)
6130 (coding gnus-article-save-coding-system)
6131 (coding-system-for-read (if coding
6132 nil ;; Rely on the coding cookie.
6133 mm-text-coding-system))
6134 (coding-system-for-write (or coding
6135 mm-text-coding-system-for-write
6136 mm-text-coding-system))
6137 (exists (file-exists-p file-name)))
6140 (insert-file-contents file-name)
6141 (goto-char (point-min))
6142 ;; Remove the existing coding cookie.
6143 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6144 (delete-region (match-beginning 0) (match-end 0))))
6145 (goto-char (point-max))
6146 (insert-buffer-substring artbuf)
6147 ;; Append newline at end of the buffer as separator, and then
6149 (goto-char (point-max))
6152 ;; If the coding system is not suitable to encode the text,
6153 ;; ask a user for a proper one.
6154 (when (fboundp 'select-safe-coding-system)
6155 (setq coding (coding-system-base
6156 (save-window-excursion
6157 (select-safe-coding-system (point-min) (point-max)
6159 (setq coding-system-for-write
6160 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6162 (goto-char (point-min))
6163 ;; Add the coding cookie.
6164 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6165 coding-system-for-write)))
6168 (write-region (point-min) (point-max) file-name nil 'no-message)
6169 (message "Appended to %s" file-name))
6170 (write-region (point-min) (point-max) file-name))))
6173 (defun gnus-narrow-to-page (&optional arg)
6174 "Narrow the article buffer to a page.
6175 If given a numerical ARG, move forward ARG pages."
6177 (setq arg (if arg (prefix-numeric-value arg) 0))
6178 (with-current-buffer gnus-article-buffer
6180 ;; Remove any old next/prev buttons.
6181 (when (gnus-visual-p 'page-marker)
6182 (let ((inhibit-read-only t))
6183 (gnus-remove-text-with-property 'gnus-prev)
6184 (gnus-remove-text-with-property 'gnus-next)))
6186 (when (save-excursion
6188 (if (re-search-backward page-delimiter nil 'move (abs arg))
6190 (setq nd (match-beginning 0)
6192 (when (re-search-backward page-delimiter nil t)
6193 (setq st (match-end 0))))
6194 (when (re-search-forward page-delimiter nil t)
6195 (setq nd (match-beginning 0)
6198 (if (re-search-forward page-delimiter nil 'move arg)
6200 (setq st (match-end 0)
6202 (when (re-search-forward page-delimiter nil t)
6203 (setq nd (match-beginning 0))))
6204 (when (re-search-backward page-delimiter nil t)
6205 (setq st (match-end 0)
6208 (when (re-search-backward page-delimiter nil t)
6209 (goto-char (setq st (match-end 0))))
6210 (when (re-search-forward page-delimiter nil t)
6211 (setq nd (match-beginning 0)))
6213 (setq gnus-page-broken t)
6214 (when pt (goto-char pt))
6215 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6216 (when (gnus-visual-p 'page-marker)
6220 (gnus-insert-next-page-button))
6223 (gnus-insert-prev-page-button))))))))
6225 ;; Article mode commands
6227 (defun gnus-article-goto-next-page ()
6228 "Show the next page of the article."
6230 (when (gnus-article-next-page)
6231 (goto-char (point-min))
6232 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6235 (defun gnus-article-goto-prev-page ()
6236 "Show the previous page of the article."
6238 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6239 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6240 (gnus-article-prev-page nil)))
6242 ;; This is cleaner but currently breaks `gnus-pick-mode':
6244 ;; (defun gnus-article-goto-next-page ()
6245 ;; "Show the next page of the article."
6247 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6248 ;; (gnus-summary-next-page)))
6250 ;; (defun gnus-article-goto-prev-page ()
6251 ;; "Show the next page of the article."
6253 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6254 ;; (gnus-summary-prev-page)))
6256 (defun gnus-article-next-page (&optional lines)
6257 "Show the next page of the current article.
6258 If end of article, return non-nil. Otherwise return nil.
6259 Argument LINES specifies lines to be scrolled up."
6261 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6262 (if (and (not (and gnus-article-over-scroll
6263 (> (count-lines (window-start) (point-max))
6264 (if (featurep 'xemacs)
6265 (or lines (1- (window-height)))
6266 (+ (or lines (1- (window-height))) scroll-margin)))))
6269 (and (pos-visible-in-window-p) ;Not continuation line.
6270 (>= (point) (point-max)))))
6271 ;; Nothing in this page.
6272 (if (or (not gnus-page-broken)
6277 (eobp)))) ;Real end-of-buffer?
6279 (when gnus-article-over-scroll
6280 (gnus-article-next-page-1 lines))
6282 (gnus-narrow-to-page 1) ;Go to next page.
6284 ;; More in this page.
6285 (gnus-article-next-page-1 lines)
6288 (defun gnus-article-beginning-of-window ()
6289 "Move point to the beginning of the window.
6290 In Emacs, the point is placed at the line number which `scroll-margin'
6292 (if (featurep 'xemacs)
6293 (move-to-window-line 0)
6294 ;; There is an obscure bug in Emacs that makes it impossible to
6295 ;; scroll past big pictures in the article buffer. Try to fix
6296 ;; this by adding a sanity check by counting the lines visible.
6297 (when (> (count-lines (window-start) (window-end)) 30)
6298 (move-to-window-line
6299 (min (max 0 scroll-margin)
6300 (max 1 (- (window-height)
6301 (if mode-line-format 1 0)
6302 (if header-line-format 1 0)
6305 (defun gnus-article-next-page-1 (lines)
6307 (let ((scroll-in-place nil))
6310 ;; Long lines may cause an end-of-buffer error.
6311 (goto-char (point-max))))
6312 (gnus-article-beginning-of-window))
6314 (defun gnus-article-prev-page (&optional lines)
6315 "Show previous page of current article.
6316 Argument LINES specifies lines to be scrolled down."
6318 (move-to-window-line 0)
6319 (if (and gnus-page-broken
6321 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6323 (gnus-narrow-to-page -1) ;Go to previous page.
6324 (goto-char (point-max))
6325 (recenter (if gnus-article-over-scroll
6327 (max (if (featurep 'xemacs)
6329 (+ lines scroll-margin))
6331 (- (window-height) 2))
6335 (let ((scroll-in-place nil))
6336 (scroll-down lines))
6337 (beginning-of-buffer
6338 (goto-char (point-min))))
6339 (gnus-article-beginning-of-window))))
6341 (defun gnus-article-only-boring-p ()
6342 "Decide whether there is only boring text remaining in the article.
6343 Something \"interesting\" is a word of at least two letters that does
6344 not have a face in `gnus-article-boring-faces'."
6345 (when (and gnus-article-skip-boring
6346 (boundp 'gnus-article-boring-faces)
6347 (symbol-value 'gnus-article-boring-faces))
6349 (let ((inhibit-point-motion-hooks t))
6351 (while (re-search-forward "\\b\\w\\w" nil t)
6353 (when (not (gnus-intersection
6354 (gnus-faces-at (point))
6355 (symbol-value 'gnus-article-boring-faces)))
6356 (throw 'only-boring nil)))
6357 (throw 'only-boring t))))))
6359 (defun gnus-article-refer-article ()
6360 "Read article specified by message-id around point."
6363 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6364 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6365 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6366 (let ((msg-id (concat "<" (match-string 0) ">")))
6367 (set-buffer gnus-summary-buffer)
6368 (gnus-summary-refer-article msg-id))
6369 (error "No references around point"))))
6371 (defun gnus-article-show-summary ()
6372 "Reconfigure windows to show summary buffer."
6374 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6375 (error "There is no summary buffer for this article buffer")
6376 (gnus-article-set-globals)
6377 (gnus-configure-windows 'article)
6378 (gnus-summary-goto-subject gnus-current-article)
6379 (gnus-summary-position-point)))
6381 (defun gnus-article-describe-briefly ()
6382 "Describe article mode commands briefly."
6384 (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")))
6386 (defun gnus-article-check-buffer ()
6387 "Beep if not in an article buffer."
6388 (unless (equal major-mode 'gnus-article-mode)
6389 (error "Command invoked outside of a Gnus article buffer")))
6391 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6392 "Read a summary buffer key sequence and execute it from the article buffer."
6394 (gnus-article-check-buffer)
6396 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6397 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6398 "=" "^" "\M-^" "|"))
6400 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6401 "An" "Ap" [?A (meta return)] [?A delete]))
6405 '("n" "Gn" "p" "Gp"))
6407 (with-current-buffer gnus-article-current-summary
6408 (let (gnus-pick-mode)
6409 (setq unread-command-events (nconc unread-command-events
6410 (list (or key last-command-event)))
6411 keys (if (featurep 'xemacs)
6412 (events-to-keys (read-key-sequence nil t))
6413 (read-key-sequence nil t)))))
6418 ((eq (aref keys (1- (length keys))) ?\C-h)
6419 (gnus-article-describe-bindings (substring keys 0 -1)))
6420 ((or (member keys nosaves)
6421 (member keys nosave-but-article)
6422 (member keys nosave-in-article))
6424 (save-window-excursion
6425 (pop-to-buffer gnus-article-current-summary)
6426 ;; We disable the pick minor mode commands.
6427 (let (gnus-pick-mode)
6428 (setq func (key-binding keys t))))
6432 (unless (member keys nosave-in-article)
6433 (set-buffer gnus-article-current-summary))
6434 (when (get func 'disabled)
6435 (error "Function %s disabled" func))
6436 (call-interactively func)
6437 (setq new-sum-point (point)))
6438 (when (member keys nosave-but-article)
6439 (pop-to-buffer gnus-article-buffer))))
6441 ;; These commands should restore window configuration.
6442 (let ((obuf (current-buffer))
6443 (owin (current-window-configuration))
6444 win func in-buffer selected new-sum-start new-sum-hscroll err)
6445 (cond (not-restore-window
6446 (pop-to-buffer gnus-article-current-summary)
6447 (setq win (selected-window)))
6448 ((setq win (get-buffer-window gnus-article-current-summary))
6449 (select-window win))
6451 (let ((summary-buffer gnus-article-current-summary))
6452 (gnus-configure-windows 'article)
6453 (unless (setq win (get-buffer-window summary-buffer 'visible))
6454 (let ((gnus-buffer-configuration
6455 '((article ((vertical 1.0
6456 (summary 0.25 point)
6458 (gnus-configure-windows 'article))
6459 (setq win (get-buffer-window summary-buffer 'visible)))
6460 (gnus-select-frame-set-input-focus (window-frame win))
6461 (select-window win))))
6462 (setq in-buffer (current-buffer))
6463 ;; We disable the pick minor mode commands.
6464 (setq func (let (gnus-pick-mode)
6465 (key-binding keys t)))
6466 (when (get func 'disabled)
6467 (error "Function %s disabled" func))
6470 (condition-case code
6472 (call-interactively func)
6478 (when (eq win (selected-window))
6479 (setq new-sum-point (point)
6480 new-sum-start (window-start win)
6481 new-sum-hscroll (window-hscroll win)))
6482 (when (or (eq in-buffer (current-buffer))
6483 (when (eq obuf (current-buffer))
6484 (set-buffer in-buffer)
6486 (setq selected (gnus-summary-select-article))
6488 (unless not-restore-window
6489 (set-window-configuration owin))
6490 (when (and (eq selected 'old)
6492 (set-window-start (get-buffer-window (current-buffer))
6494 (set-window-point (get-buffer-window (current-buffer))
6495 (if (article-goto-body)
6498 (when (and (not not-restore-window)
6501 (with-current-buffer (window-buffer win)
6502 (eq major-mode 'gnus-summary-mode)))
6503 (set-window-point win new-sum-point)
6504 (set-window-start win new-sum-start)
6505 (set-window-hscroll win new-sum-hscroll))))
6506 (set-window-configuration owin)
6508 (signal (car err) (cdr err))
6511 (defun gnus-article-read-summary-send-keys ()
6513 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6514 (gnus-article-read-summary-keys)))
6516 (defun gnus-article-describe-key (key)
6517 "Display documentation of the function invoked by KEY.
6518 KEY is a string or a vector."
6519 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6520 (read-key-sequence "Describe key: "))))
6521 (gnus-article-check-buffer)
6522 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6523 gnus-article-read-summary-send-keys))
6524 (with-current-buffer gnus-article-current-summary
6525 (setq unread-command-events
6526 (if (featurep 'xemacs)
6528 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6529 (list 'meta (- x 128))
6532 (let ((cursor-in-echo-area t)
6534 (describe-key (read-key-sequence nil t))))
6535 (describe-key key)))
6537 (defun gnus-article-describe-key-briefly (key &optional insert)
6538 "Display documentation of the function invoked by KEY.
6539 KEY is a string or a vector."
6540 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6541 (read-key-sequence "Describe key: "))
6542 current-prefix-arg))
6543 (gnus-article-check-buffer)
6544 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6545 gnus-article-read-summary-send-keys))
6546 (with-current-buffer gnus-article-current-summary
6547 (setq unread-command-events
6548 (if (featurep 'xemacs)
6550 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6551 (list 'meta (- x 128))
6554 (let ((cursor-in-echo-area t)
6556 (describe-key-briefly (read-key-sequence nil t) insert)))
6557 (describe-key-briefly key insert)))
6559 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6560 (defvar gnus-agent-summary-mode)
6561 (defvar gnus-draft-mode)
6562 ;; Calling help-buffer will autoload help-mode.
6563 (defvar help-xref-stack-item)
6564 ;; Emacs 22 doesn't load it in the batch mode.
6566 (autoload 'help-buffer "help-mode"))
6568 (defun gnus-article-describe-bindings (&optional prefix)
6569 "Show a list of all defined keys, and their definitions.
6570 The optional argument PREFIX, if non-nil, should be a key sequence;
6571 then we display only bindings that start with that prefix."
6573 (gnus-article-check-buffer)
6574 (let ((keymap (copy-keymap gnus-article-mode-map))
6575 (map (copy-keymap gnus-article-send-map))
6576 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6578 (define-key keymap "S" map)
6579 (define-key map [t] nil)
6580 (with-current-buffer gnus-article-current-summary
6583 (if (setq parent (keymap-parent gnus-article-mode-map))
6585 (setq parent (copy-keymap parent))
6586 (set-keymap-parent parent (current-local-map)))
6587 (current-local-map)))
6588 (set-keymap-parent map (key-binding "S"))
6589 (let (key def gnus-pick-mode)
6591 (setq key (pop sumkeys))
6592 (cond ((and (vectorp key) (= (length key) 1)
6593 (consp (setq def (aref key 0)))
6594 (numberp (car def)) (numberp (cdr def)))
6595 (when (< (max (car def) (cdr def)) 128)
6599 (nreverse (gnus-uncompress-range def)))
6601 ((setq def (key-binding key))
6602 (unless (eq def 'undefined)
6603 (define-key keymap key def))))))
6604 (when (boundp 'gnus-agent-summary-mode)
6605 (setq agent gnus-agent-summary-mode))
6606 (when (boundp 'gnus-draft-mode)
6607 (setq draft gnus-draft-mode)))
6609 (use-local-map keymap)
6610 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6611 (set (make-local-variable 'gnus-draft-mode) draft)
6612 (describe-bindings prefix))
6613 (let ((item `((lambda (prefix)
6614 (with-current-buffer ,(current-buffer)
6615 (gnus-article-describe-bindings prefix)))
6617 (with-current-buffer (let (help-xref-following) (help-buffer))
6618 (setq help-xref-stack-item item)))))
6620 (defun gnus-article-reply-with-original (&optional wide)
6621 "Start composing a reply mail to the current message.
6622 The text in the region will be yanked. If the region isn't active,
6623 the entire article will be yanked."
6625 (let ((article (cdr gnus-article-current))
6627 (if (not (gnus-region-active-p))
6628 (with-current-buffer gnus-summary-buffer
6629 (gnus-summary-reply (list (list article)) wide))
6630 (setq contents (buffer-substring (point) (mark t)))
6631 ;; Deactivate active regions.
6632 (when (and (boundp 'transient-mark-mode)
6633 transient-mark-mode)
6634 (setq mark-active nil))
6635 (with-current-buffer gnus-summary-buffer
6637 (list (list article contents)) wide)))))
6639 (defun gnus-article-wide-reply-with-original ()
6640 "Start composing a wide reply mail to the current message.
6641 The text in the region will be yanked. If the region isn't active,
6642 the entire article will be yanked."
6644 (gnus-article-reply-with-original t))
6646 (defun gnus-article-followup-with-original ()
6647 "Compose a followup to the current article.
6648 The text in the region will be yanked. If the region isn't active,
6649 the entire article will be yanked."
6651 (let ((article (cdr gnus-article-current))
6653 (if (not (gnus-region-active-p))
6654 (with-current-buffer gnus-summary-buffer
6655 (gnus-summary-followup (list (list article))))
6656 (setq contents (buffer-substring (point) (mark t)))
6657 ;; Deactivate active regions.
6658 (when (and (boundp 'transient-mark-mode)
6659 transient-mark-mode)
6660 (setq mark-active nil))
6661 (with-current-buffer gnus-summary-buffer
6662 (gnus-summary-followup
6663 (list (list article contents)))))))
6665 (defun gnus-article-hide (&optional arg force)
6666 "Hide all the gruft in the current article.
6667 This means that signatures, cited text and (some) headers will be
6669 If given a prefix, show the hidden text instead."
6670 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6671 (gnus-article-hide-headers arg)
6672 (gnus-article-hide-list-identifiers arg)
6673 (gnus-article-hide-citation-maybe arg force)
6674 (gnus-article-hide-signature arg))
6676 (defun gnus-article-maybe-highlight ()
6677 "Do some article highlighting if article highlighting is requested."
6678 (when (gnus-visual-p 'article-highlight 'highlight)
6679 (gnus-article-highlight-some)))
6681 (defun gnus-check-group-server ()
6682 ;; Make sure the connection to the server is alive.
6683 (unless (gnus-server-opened
6684 (gnus-find-method-for-group gnus-newsgroup-name))
6685 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6686 (gnus-request-group gnus-newsgroup-name t)))
6689 (autoload 'nneething-get-file-name "nneething"))
6691 (defun gnus-request-article-this-buffer (article group)
6692 "Get an article and insert it into this buffer."
6693 (let (do-update-line sparse-header)
6697 (gnus-kill-all-overlays)
6698 (setq group (or group gnus-newsgroup-name))
6700 ;; Using `gnus-request-article' directly will insert the article into
6701 ;; `nntp-server-buffer' - so we'll save some time by not having to
6702 ;; copy it from the server buffer into the article buffer.
6704 ;; We only request an article by message-id when we do not have the
6705 ;; headers for it, so we'll have to get those.
6706 (when (stringp article)
6707 (gnus-read-header article))
6709 ;; If the article number is negative, that means that this article
6710 ;; doesn't belong in this newsgroup (possibly), so we find its
6711 ;; message-id and request it by id instead of number.
6712 (when (and (numberp article)
6714 (get-buffer gnus-summary-buffer)
6715 (gnus-buffer-exists-p gnus-summary-buffer))
6716 (with-current-buffer gnus-summary-buffer
6717 (let ((header (gnus-summary-article-header article)))
6720 ((memq article gnus-newsgroup-sparse)
6721 ;; This is a sparse gap article.
6722 (setq do-update-line article)
6723 (setq article (mail-header-id header))
6724 (setq sparse-header (gnus-read-header article))
6725 (setq gnus-newsgroup-sparse
6726 (delq article gnus-newsgroup-sparse)))
6728 ;; It's a real article.
6729 (setq article (mail-header-id header)))
6731 ;; It is an extracted pseudo-article.
6732 (setq article 'pseudo)
6733 (gnus-request-pseudo-article header))))
6735 (let ((method (gnus-find-method-for-group
6736 gnus-newsgroup-name)))
6737 (when (and (eq (car method) 'nneething)
6739 (let ((dir (nneething-get-file-name
6740 (mail-header-id header))))
6741 (when (and (stringp dir)
6742 (file-directory-p dir))
6743 (setq article 'nneething)
6744 (gnus-group-enter-directory dir))))))))
6747 ;; Refuse to select canceled articles.
6748 ((and (numberp article)
6750 (get-buffer gnus-summary-buffer)
6751 (gnus-buffer-exists-p gnus-summary-buffer)
6752 (eq (cdr (with-current-buffer gnus-summary-buffer
6753 (assq article gnus-newsgroup-reads)))
6754 gnus-canceled-mark))
6756 ;; We first check `gnus-original-article-buffer'.
6757 ((and (get-buffer gnus-original-article-buffer)
6759 (with-current-buffer gnus-original-article-buffer
6760 (and (equal (car gnus-original-article) group)
6761 (eq (cdr gnus-original-article) article))))
6762 ;; `insert-buffer-substring' would incorrectly use the
6763 ;; equivalent of string-make-multibyte which amount to decoding
6764 ;; with locale-coding-system, causing failure of
6765 ;; subsequent decoding.
6766 (insert (mm-string-to-multibyte
6767 (with-current-buffer gnus-original-article-buffer
6768 (buffer-substring (point-min) (point-max)))))
6770 ;; Check the backlog.
6771 ((and gnus-keep-backlog
6772 (gnus-backlog-request-article group article (current-buffer)))
6774 ;; Check asynchronous pre-fetch.
6775 ((gnus-async-request-fetched-article group article (current-buffer))
6776 (gnus-async-prefetch-next group article gnus-summary-buffer)
6777 (when (and (numberp article) gnus-keep-backlog)
6778 (gnus-backlog-enter-article group article (current-buffer)))
6781 ((and gnus-use-cache
6783 (gnus-cache-request-article article group))
6785 ;; Check the agent cache.
6786 ((gnus-agent-request-article article group)
6788 ;; Get the article and put into the article buffer.
6789 ((or (stringp article)
6791 (let ((gnus-override-method gnus-override-method)
6792 (methods (and (stringp article)
6793 gnus-refer-article-method))
6794 (backend (car (gnus-find-method-for-group
6795 gnus-newsgroup-name)))
6797 (inhibit-read-only t))
6798 (if (or (not (listp methods))
6799 (and (symbolp (car methods))
6800 (assq (car methods) nnoo-definition-alist)))
6801 (setq methods (list methods)))
6802 (when (and (null gnus-override-method)
6804 (setq gnus-override-method (pop methods)))
6806 (when (eq gnus-override-method 'current)
6807 (setq gnus-override-method
6808 (with-current-buffer gnus-summary-buffer
6809 gnus-current-select-method)))
6811 (gnus-kill-all-overlays)
6812 (let ((gnus-newsgroup-name group))
6813 (gnus-check-group-server))
6815 ((gnus-request-article article group (current-buffer))
6816 (when (numberp article)
6817 (gnus-async-prefetch-next group article
6818 gnus-summary-buffer)
6819 (when gnus-keep-backlog
6820 (gnus-backlog-enter-article
6821 group article (current-buffer))))
6822 (setq result 'article))
6824 (setq gnus-override-method (pop methods)))
6825 ((not (string-match "^400 "
6826 (nnheader-get-report backend)))
6827 ;; If we get 400 server disconnect, reconnect and
6828 ;; retry; otherwise, assume the article has expired.
6829 (setq result 'done))))
6830 (and (eq result 'article) 'article)))
6834 ;; Associate this article with the current summary buffer.
6835 (setq gnus-article-current-summary gnus-summary-buffer)
6837 ;; Take the article from the original article buffer
6838 ;; and place it in the buffer it's supposed to be in.
6839 (when (and (get-buffer gnus-article-buffer)
6840 (equal (buffer-name (current-buffer))
6841 (buffer-name (get-buffer gnus-article-buffer))))
6843 (if (get-buffer gnus-original-article-buffer)
6844 (set-buffer gnus-original-article-buffer)
6845 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6846 (buffer-disable-undo)
6847 (setq major-mode 'gnus-original-article-mode)
6848 (setq buffer-read-only t))
6849 (let ((inhibit-read-only t))
6851 (insert-buffer-substring gnus-article-buffer))
6852 (setq gnus-original-article (cons group article)))
6855 (run-hooks 'gnus-article-decode-hook)
6856 ;; Mark article as decoded or not.
6857 (setq gnus-article-decoded-p gnus-article-decode-hook))
6859 ;; Update sparse articles.
6860 (when (and do-update-line
6861 (or (numberp article)
6863 (let ((buf (current-buffer)))
6864 (set-buffer gnus-summary-buffer)
6865 (gnus-summary-update-article do-update-line sparse-header)
6866 (gnus-summary-goto-subject do-update-line nil t)
6867 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6869 (set-buffer buf))))))
6871 (defun gnus-block-private-groups (group)
6872 (if (gnus-news-group-p group)
6873 ;; Block nothing in news groups.
6875 ;; Block everything anywhere else.
6878 (defun gnus-blocked-images ()
6879 (if (functionp gnus-blocked-images)
6880 (funcall gnus-blocked-images gnus-newsgroup-name)
6881 gnus-blocked-images))
6887 (defcustom gnus-article-edit-mode-hook nil
6888 "Hook run in article edit mode buffers."
6889 :group 'gnus-article-various
6892 (defvar gnus-article-edit-done-function nil)
6894 (defvar gnus-article-edit-mode-map nil)
6896 ;; Should we be using derived.el for this?
6897 (unless gnus-article-edit-mode-map
6898 (setq gnus-article-edit-mode-map (make-keymap))
6899 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6901 (gnus-define-keys gnus-article-edit-mode-map
6902 "\C-c?" describe-mode
6903 "\C-c\C-c" gnus-article-edit-done
6904 "\C-c\C-k" gnus-article-edit-exit
6905 "\C-c\C-f\C-t" message-goto-to
6906 "\C-c\C-f\C-o" message-goto-from
6907 "\C-c\C-f\C-b" message-goto-bcc
6908 ;;"\C-c\C-f\C-w" message-goto-fcc
6909 "\C-c\C-f\C-c" message-goto-cc
6910 "\C-c\C-f\C-s" message-goto-subject
6911 "\C-c\C-f\C-r" message-goto-reply-to
6912 "\C-c\C-f\C-n" message-goto-newsgroups
6913 "\C-c\C-f\C-d" message-goto-distribution
6914 "\C-c\C-f\C-f" message-goto-followup-to
6915 "\C-c\C-f\C-m" message-goto-mail-followup-to
6916 "\C-c\C-f\C-k" message-goto-keywords
6917 "\C-c\C-f\C-u" message-goto-summary
6918 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6919 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6920 "\C-c\C-b" message-goto-body
6921 "\C-c\C-i" message-goto-signature
6923 "\C-c\C-t" message-insert-to
6924 "\C-c\C-n" message-insert-newsgroups
6925 "\C-c\C-o" message-sort-headers
6926 "\C-c\C-e" message-elide-region
6927 "\C-c\C-v" message-delete-not-region
6928 "\C-c\C-z" message-kill-to-signature
6929 "\M-\r" message-newline-and-reformat
6930 "\C-c\C-a" mml-attach-file
6931 "\C-a" message-beginning-of-line
6933 "\M-;" comment-region)
6935 (gnus-define-keys (gnus-article-edit-wash-map
6936 "\C-c\C-w" gnus-article-edit-mode-map)
6937 "f" gnus-article-edit-full-stops))
6940 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6942 ["Fetch To" message-insert-to t]
6943 ["Fetch Newsgroups" message-insert-newsgroups t]
6945 ["To" message-goto-to t]
6946 ["From" message-goto-from t]
6947 ["Subject" message-goto-subject t]
6948 ["Cc" message-goto-cc t]
6949 ["Reply-To" message-goto-reply-to t]
6950 ["Summary" message-goto-summary t]
6951 ["Keywords" message-goto-keywords t]
6952 ["Newsgroups" message-goto-newsgroups t]
6953 ["Followup-To" message-goto-followup-to t]
6954 ["Mail-Followup-To" message-goto-mail-followup-to t]
6955 ["Distribution" message-goto-distribution t]
6956 ["Body" message-goto-body t]
6957 ["Signature" message-goto-signature t]))
6959 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6960 "Major mode for editing articles.
6961 This is an extended text-mode.
6963 \\{gnus-article-edit-mode-map}"
6964 (make-local-variable 'gnus-article-edit-done-function)
6965 (make-local-variable 'gnus-prev-winconf)
6966 (set (make-local-variable 'font-lock-defaults)
6967 '(message-font-lock-keywords t))
6968 (set (make-local-variable 'mail-header-separator) "")
6969 (set (make-local-variable 'gnus-article-edit-mode) t)
6970 (easy-menu-add message-mode-field-menu message-mode-map)
6972 (setq buffer-read-only nil)
6973 (buffer-enable-undo)
6976 (defun gnus-article-edit (&optional force)
6977 "Edit the current article.
6978 This will have permanent effect only in mail groups.
6979 If FORCE is non-nil, allow editing of articles even in read-only
6982 (when (and (not force)
6983 (gnus-group-read-only-p))
6984 (error "The current newsgroup does not support article editing"))
6985 (gnus-article-date-original)
6986 (gnus-article-edit-article
6988 `(lambda (no-highlight)
6990 (gnus-summary-edit-article-done
6991 ,(or (mail-header-references gnus-current-headers) "")
6992 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6994 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6995 "Start editing the contents of the current article buffer."
6996 (let ((winconf (current-window-configuration)))
6997 (set-buffer gnus-article-buffer)
6998 (let ((message-auto-save-directory
6999 ;; Don't associate the article buffer with a draft file.
7001 (gnus-article-edit-mode))
7002 (funcall start-func)
7003 (set-buffer-modified-p nil)
7004 (gnus-configure-windows 'edit-article)
7005 (setq gnus-article-edit-done-function exit-func)
7006 (setq gnus-prev-winconf winconf)
7008 (gnus-message 6 "C-c C-c to end edits"))))
7010 (defun gnus-article-edit-done (&optional arg)
7011 "Update the article edits and exit."
7013 (let ((func gnus-article-edit-done-function)
7014 (buf (current-buffer))
7015 (start (window-start))
7017 (winconf gnus-prev-winconf))
7018 (widen) ;; Widen it in case that users narrowed the buffer.
7021 ;; The cache and backlog have to be flushed somewhat.
7022 (when gnus-keep-backlog
7023 (gnus-backlog-remove-article
7024 (car gnus-article-current) (cdr gnus-article-current)))
7025 ;; Flush original article as well.
7026 (gnus-flush-original-article-buffer)
7027 (when gnus-use-cache
7028 (gnus-cache-update-article
7029 (car gnus-article-current) (cdr gnus-article-current)))
7030 ;; We remove all text props from the article buffer.
7031 (kill-all-local-variables)
7032 (set-text-properties (point-min) (point-max) nil)
7034 (set-window-configuration winconf)
7036 (set-window-start (get-buffer-window buf) start)
7037 (set-window-point (get-buffer-window buf) (point)))
7038 (gnus-summary-show-article))
7040 (defun gnus-flush-original-article-buffer ()
7041 (when (get-buffer gnus-original-article-buffer)
7042 (with-current-buffer gnus-original-article-buffer
7043 (setq gnus-original-article nil))))
7045 (defun gnus-article-edit-exit ()
7046 "Exit the article editing without updating."
7048 (when (or (not (buffer-modified-p))
7049 (yes-or-no-p "Article modified; kill anyway? "))
7050 (let ((curbuf (current-buffer))
7052 (window-start (window-start)))
7054 (if (gnus-buffer-live-p gnus-original-article-buffer)
7055 (insert-buffer-substring gnus-original-article-buffer))
7056 (let ((winconf gnus-prev-winconf))
7057 (kill-all-local-variables)
7059 (set-window-configuration winconf)
7060 ;; Tippy-toe some to make sure that point remains where it was.
7061 (save-current-buffer
7063 (set-window-start (get-buffer-window (current-buffer)) window-start)
7065 (gnus-summary-show-article)))
7067 (defun gnus-article-edit-full-stops ()
7068 "Interactively repair spacing at end of sentences."
7071 (goto-char (point-min))
7072 (search-forward-regexp "^$" nil t)
7073 (let ((case-fold-search nil))
7074 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7077 ;;; Article highlights
7080 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7082 ;;; Internal Variables:
7084 (defcustom gnus-button-url-regexp
7086 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7087 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7088 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7089 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7090 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7094 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7095 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7096 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7098 "[" chars punct "]+" "[" chars "]"
7100 (concat ;; XEmacs 21.4 doesn't support POSIX.
7101 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7102 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7104 "Regular expression that matches URLs."
7105 :group 'gnus-article-buttons
7108 (defcustom gnus-button-valid-fqdn-regexp
7109 message-valid-fqdn-regexp
7110 "Regular expression that matches a valid FQDN."
7112 :group 'gnus-article-buttons
7115 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7116 (defcustom gnus-button-valid-localpart-regexp
7117 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7118 "Regular expression that matches a localpart of mail addresses or MIDs."
7120 :group 'gnus-article-buttons
7123 (defcustom gnus-button-man-handler 'manual-entry
7124 "Function to use for displaying man pages.
7125 The function must take at least one argument with a string naming the
7128 :type '(choice (function-item :tag "Man" manual-entry)
7129 (function-item :tag "Woman" woman)
7130 (function :tag "Other"))
7131 :group 'gnus-article-buttons)
7133 (defcustom gnus-button-mid-or-mail-regexp
7134 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7135 gnus-button-valid-fqdn-regexp
7137 "Regular expression that matches a message ID or a mail address."
7139 :group 'gnus-article-buttons
7142 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7143 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7144 Strings like this can be either a message ID or a mail address. If it is one
7145 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7146 message ID or a mail address, respectively. If this variable is set to the
7147 symbol `ask', always query the user what do do. If it is a function, this
7148 function will be called with the string as its only argument. The function
7149 must return `mid', `mail', `invalid' or `ask'."
7151 :group 'gnus-article-buttons
7152 :type '(choice (function-item :tag "Heuristic function"
7153 gnus-button-mid-or-mail-heuristic)
7158 (defcustom gnus-button-mid-or-mail-heuristic-alist
7159 '((-10.0 . ".+\\$.+@")
7162 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7163 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7164 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7165 (-1.0 . "^[^a-z]+@")
7167 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7168 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7169 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7170 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7173 (-1.0 . "^[0-9][0-9]")
7175 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7176 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7177 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7178 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7180 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7181 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7184 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7186 ;; compensation for TDMA dated mail addresses:
7187 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7189 (-20.0 . "\\.fsf@") ;; Gnus
7192 (-20.0 . "^alpine\\.")
7193 (-20.0 . "_-_") ;; Subject change in thread
7195 (-20.0 . "\\.ln@") ;; leafnode
7196 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7197 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7199 ;; (5.0 . "") ;; $local_part_len <= 7
7200 (10.0 . "^[^0-9]+@")
7201 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7202 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7205 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7207 (0.5 . "^[A-Z][a-z]")
7208 (0.5 . "^[A-Z][a-z][a-z]")
7209 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7210 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7211 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7213 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7214 address. The REGEXP is processed with `case-fold-search' set to nil."
7216 :group 'gnus-article-buttons
7217 :type '(repeat (cons (number :tag "Rate")
7218 (regexp :tag "Regexp"))))
7220 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7221 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7222 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7223 address, `ask' if unsure and `invalid' if the string is invalid."
7224 (let ((case-fold-search nil)
7225 (list gnus-button-mid-or-mail-heuristic-alist)
7226 (result 0) rate regexp lpartlen elem)
7228 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7229 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7230 ;; Certain special cases...
7233 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7234 "^[0-9]+\\.[0-9]+@compuserve\\|"
7235 "@public\\.gmane\\.org")
7237 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7238 (setq result 'mail))
7239 (when (string-match "@.*@\\| " mid-or-mail)
7240 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7241 (setq result 'invalid))
7242 ;; Nothing more to do, if result is not a number here...
7243 (when (numberp result)
7245 (setq elem (car list)
7249 (when (string-match regexp mid-or-mail)
7250 (setq result (+ result rate))
7252 9 "`%s' matched `%s', rate `%s', result `%s'."
7253 mid-or-mail regexp rate result)))
7254 (when (<= lpartlen 7)
7255 (setq result (+ result 5.0))
7256 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7257 mid-or-mail result))
7258 (when (>= lpartlen 12)
7259 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7261 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7262 ;; Long local part should contain realname if e-mail address,
7263 ;; too many digits: message-id.
7264 ;; $score -= 5.0 + 0.1 * $local_part_len;
7265 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7266 (setq result (+ result rate))
7268 9 "Many digits in `%s', rate `%s', result `%s'."
7269 mid-or-mail rate result))
7270 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7272 ;; Too few vowels [^aeiouy]{4,}.*\@
7273 (setq result (+ result -5.0))
7275 9 "Few vowels in `%s', rate `%s', result `%s'."
7276 mid-or-mail -5.0 result))
7278 (setq result (+ result 5.0))
7280 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7281 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7282 ;; Maybe we should make this a customizable alist: (condition . 'result)
7284 ((symbolp result) result)
7285 ;; Now convert number into proper results:
7286 ((< result -10.0) 'mid)
7287 ((> result 10.0) 'mail)
7290 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7291 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7292 (url-mid (concat "news" ":" mid-or-mail))
7293 (url-mailto (concat "mailto" ":" mid-or-mail)))
7294 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7295 (when (fboundp pref)
7297 ;; get rid of surrounding angles...
7299 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7300 (if (or (eq 'mid guessed) (eq 'mail guessed))
7304 (save-window-excursion
7305 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7308 (cond ((eq pref 'mid)
7309 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7310 (gnus-button-handle-news url-mid))
7312 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7313 (gnus-url-mailto url-mailto))
7314 (t (gnus-message 3 "Invalid string.")))))
7316 (defun gnus-button-handle-custom (fun arg)
7317 "Call function FUN on argument ARG.
7318 Both FUN and ARG are supposed to be strings. ARG will be passed
7319 as a symbol to FUN."
7320 (funcall (intern fun)
7321 (if (string-match "^customize-apropos" fun)
7325 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7327 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7330 (defun gnus-button-handle-describe-function (url)
7331 "Call `describe-function' when pushing the corresponding URL button."
7334 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7336 (defun gnus-button-handle-describe-variable (url)
7337 "Call `describe-variable' when pushing the corresponding URL button."
7340 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7342 (defun gnus-button-handle-symbol (url)
7343 "Display help on variable or function.
7344 Calls `describe-variable' or `describe-function'."
7345 (let ((sym (intern url)))
7347 ((fboundp sym) (describe-function sym))
7348 ((boundp sym) (describe-variable sym))
7349 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7351 (defun gnus-button-handle-describe-key (url)
7352 "Call `describe-key' when pushing the corresponding URL button."
7354 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7355 (keys (ignore-errors (eval `(kbd ,key-string)))))
7358 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7360 (defun gnus-button-handle-apropos (url)
7361 "Call `apropos' when pushing the corresponding URL button."
7362 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7364 (defun gnus-button-handle-apropos-command (url)
7365 "Call `apropos' when pushing the corresponding URL button."
7367 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7369 (defun gnus-button-handle-apropos-variable (url)
7370 "Call `apropos' when pushing the corresponding URL button."
7372 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7373 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7375 (defun gnus-button-handle-apropos-documentation (url)
7376 "Call `apropos' when pushing the corresponding URL button."
7378 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7379 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7381 (defun gnus-button-handle-library (url)
7382 "Call `locate-library' when pushing the corresponding URL button."
7383 (gnus-message 9 "url=`%s'" url)
7384 (let* ((lib (locate-library url))
7385 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7387 (gnus-message 1 "Cannot locale library `%s'." url)
7388 (find-file-read-only file))))
7390 (defcustom gnus-button-man-level 5
7391 "*Integer that says how many man-related buttons Gnus will show.
7392 The higher the number, the more buttons will appear and the more false
7393 positives are possible. Note that you can set this variable local to
7394 specific groups. Setting it higher in Unix groups is probably a good idea.
7395 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7396 how to set variables in specific groups."
7398 :group 'gnus-article-buttons
7399 :link '(custom-manual "(gnus)Group Parameters")
7402 (defcustom gnus-button-emacs-level 5
7403 "*Integer that says how many emacs-related buttons Gnus will show.
7404 The higher the number, the more buttons will appear and the more false
7405 positives are possible. Note that you can set this variable local to
7406 specific groups. Setting it higher in Emacs or Gnus related groups is
7407 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7408 `gnus-parameters' on how to set variables in specific groups."
7410 :group 'gnus-article-buttons
7411 :link '(custom-manual "(gnus)Group Parameters")
7414 (defcustom gnus-button-message-level 5
7415 "*Integer that says how many buttons for news or mail messages will appear.
7416 The higher the number, the more buttons will appear and the more false
7417 positives are possible."
7418 ;; mail addresses, MIDs, URLs for news, ...
7420 :group 'gnus-article-buttons
7423 (defcustom gnus-button-browse-level 5
7424 "*Integer that says how many buttons for browsing will appear.
7425 The higher the number, the more buttons will appear and the more false
7426 positives are possible."
7427 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7429 :group 'gnus-article-buttons
7432 (defcustom gnus-button-alist
7433 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7434 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7435 ((concat "\\b\\(nntp\\|news\\):\\("
7436 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7437 0 t gnus-button-handle-news 2)
7438 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7439 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7440 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7441 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7442 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7443 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7444 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7445 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7446 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7447 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7448 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7449 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7450 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7451 ;; RFC 2368 (The mailto URL scheme)
7452 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7453 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7454 ("\\bmailto:\\([^ \n\t]+\\)"
7455 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7456 ;; Info Konqueror style <info:/foo/bar baz>.
7457 ;; Must come before " Gnus home-grown style".
7458 ("\\binfo://?\\([^'\">\n\t]+\\)"
7459 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7460 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7461 ("\\binfo://\\([^'\">\n\t ]+\\)"
7462 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7463 ;; Info GNOME style <info:foo#bar_baz>
7464 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7465 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7466 ;; Info KDE style <info:(foo)bar baz>
7467 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7468 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7469 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7470 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7471 ("\\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,]*\\)\\)?"
7472 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7473 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7475 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7476 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7477 ;; Emacs help commands
7478 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7479 ;; regexp doesn't match arguments containing ` '.
7480 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7481 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7482 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7483 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7484 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7485 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7486 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7487 ;; The following entries may lead to many false positives so don't enable
7488 ;; them by default (use a high button level).
7489 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7490 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7491 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7492 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7493 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7494 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7495 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7496 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7497 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7498 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7499 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7500 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7501 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7502 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7503 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7504 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7505 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7506 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7507 ;; Unlike the other regexps we really have to require quoting
7508 ;; here to determine where it ends.
7509 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7510 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7511 ("<URL: *\\([^\n<>]*\\)>"
7512 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7513 ;; RFC 2396 (2.4.3., delims) ...
7514 ("\"URL: *\\([^\n\"]*\\)\""
7515 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7517 (gnus-button-url-regexp
7518 0 (>= gnus-button-browse-level 0) browse-url 0)
7520 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7521 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7522 gnus-button-handle-man 1)
7523 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7524 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7525 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7526 gnus-button-handle-man 1)
7527 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7528 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7529 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7530 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7531 ;; Recognizing patches to .el files. This is somewhat obscure,
7532 ;; but considering the percentage of Gnus users who hack Emacs
7534 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7535 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7536 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7537 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7538 ;; MID or mail: To avoid too many false positives we don't try to catch
7539 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7540 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7541 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7542 ;; so that non-ambiguous entries (see above) match first.
7543 (gnus-button-mid-or-mail-regexp
7544 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7545 "*Alist of regexps matching buttons in article bodies.
7547 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7548 REGEXP: is the string (case insensitive) matching text around the button (can
7549 also be Lisp expression evaluating to a string),
7550 BUTTON: is the number of the regexp grouping actually matching the button,
7551 FORM: is a Lisp expression which must eval to true for the button to
7553 CALLBACK: is the function to call when the user push this button, and each
7554 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7556 CALLBACK can also be a variable, in that case the value of that
7557 variable it the real callback function."
7558 :group 'gnus-article-buttons
7559 :type '(repeat (list (choice regexp variable sexp)
7560 (integer :tag "Button")
7562 (function :tag "Callback")
7565 (integer :tag "Regexp group")))))
7566 (put 'gnus-button-alist 'risky-local-variable t)
7568 (defcustom gnus-header-button-alist
7569 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7570 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7571 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7572 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7573 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7574 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7575 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7576 0 (>= gnus-button-browse-level 0) browse-url 0)
7577 ("^Subject:" gnus-button-url-regexp
7578 0 (>= gnus-button-browse-level 0) browse-url 0)
7579 ("^[^:]+:" gnus-button-url-regexp
7580 0 (>= gnus-button-browse-level 0) browse-url 0)
7581 ("^OpenPGP:.*url=" gnus-button-url-regexp
7582 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7583 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7584 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7585 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7586 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7587 "*Alist of headers and regexps to match buttons in article heads.
7589 This alist is very similar to `gnus-button-alist', except that each
7590 alist has an additional HEADER element first in each entry:
7592 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7594 HEADER is a regexp to match a header. For a fuller explanation, see
7595 `gnus-button-alist'."
7596 :group 'gnus-article-buttons
7597 :group 'gnus-article-headers
7598 :type '(repeat (list (regexp :tag "Header")
7599 (choice regexp variable)
7600 (integer :tag "Button")
7602 (function :tag "Callback")
7605 (integer :tag "Regexp group")))))
7606 (put 'gnus-header-button-alist 'risky-local-variable t)
7610 (defun gnus-article-push-button (event)
7611 "Check text under the mouse pointer for a callback function.
7612 If the text under the mouse pointer has a `gnus-callback' property,
7613 call it with the value of the `gnus-data' text property."
7615 (set-buffer (window-buffer (posn-window (event-start event))))
7616 (let* ((pos (posn-point (event-start event)))
7617 (data (get-text-property pos 'gnus-data))
7618 (fun (get-text-property pos 'gnus-callback)))
7621 (funcall fun data))))
7623 (defun gnus-article-press-button ()
7624 "Check text at point for a callback function.
7625 If the text at point has a `gnus-callback' property,
7626 call it with the value of the `gnus-data' text property."
7628 (let ((data (get-text-property (point) 'gnus-data))
7629 (fun (get-text-property (point) 'gnus-callback)))
7631 (funcall fun data))))
7633 (defun gnus-article-highlight (&optional force)
7634 "Highlight current article.
7635 This function calls `gnus-article-highlight-headers',
7636 `gnus-article-highlight-citation',
7637 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7638 do the highlighting. See the documentation for those functions."
7639 (interactive (list 'force))
7640 (gnus-article-highlight-headers)
7641 (gnus-article-highlight-citation force)
7642 (gnus-article-highlight-signature)
7643 (gnus-article-add-buttons)
7644 (gnus-article-add-buttons-to-head))
7646 (defun gnus-article-highlight-some (&optional force)
7647 "Highlight current article.
7648 This function calls `gnus-article-highlight-headers',
7649 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7650 do the highlighting. See the documentation for those functions."
7651 (interactive (list 'force))
7652 (gnus-article-highlight-headers)
7653 (gnus-article-highlight-signature)
7654 (gnus-article-add-buttons))
7656 (defun gnus-article-highlight-headers ()
7657 "Highlight article headers as specified by `gnus-header-face-alist'."
7659 (gnus-with-article-headers
7660 (let (regexp header-face field-face from hpoints fpoints)
7661 (dolist (entry gnus-header-face-alist)
7662 (goto-char (point-min))
7663 (setq regexp (concat "^\\("
7664 (if (string-equal "" (nth 0 entry))
7668 header-face (nth 1 entry)
7669 field-face (nth 2 entry))
7670 (while (and (re-search-forward regexp nil t)
7674 (unless (search-forward ":" nil t)
7676 (when (and header-face
7677 (not (memq (point) hpoints)))
7678 (push (point) hpoints)
7679 (gnus-put-text-property from (point) 'face header-face))
7680 (when (and field-face
7681 (not (memq (setq from (point)) fpoints)))
7683 (if (re-search-forward "^[^ \t]" nil t)
7685 (goto-char (point-max)))
7686 (gnus-put-text-property from (point) 'face field-face)))))))
7688 (defun gnus-article-highlight-signature ()
7689 "Highlight the signature in an article.
7690 It does this by highlighting everything after
7691 `gnus-signature-separator' using the face `gnus-signature'."
7693 (gnus-with-article-buffer
7694 (let ((inhibit-point-motion-hooks t))
7696 (when (and gnus-signature-face
7697 (gnus-article-narrow-to-signature))
7698 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7699 'face gnus-signature-face)
7701 (gnus-article-search-signature)
7702 (let ((start (match-beginning 0))
7703 (end (set-marker (make-marker) (1+ (match-end 0)))))
7704 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7707 (defun gnus-button-in-region-p (b e prop)
7708 "Say whether PROP exists in the region."
7709 (text-property-not-all b e prop nil))
7711 (defun gnus-article-add-buttons ()
7712 "Find external references in the article and make buttons of them.
7713 \"External references\" are things like Message-IDs and URLs, as
7714 specified by `gnus-button-alist'."
7716 (gnus-with-article-buffer
7717 (let ((inhibit-point-motion-hooks t)
7718 (case-fold-search t)
7719 (alist gnus-button-alist)
7721 ;; We skip the headers.
7724 (while (setq entry (pop alist))
7725 (setq regexp (eval (car entry)))
7727 (while (re-search-forward regexp nil t)
7728 (let ((start (match-beginning (nth 1 entry)))
7729 (end (match-end (nth 1 entry)))
7730 (from (match-beginning 0)))
7731 (when (and (eval (nth 2 entry))
7732 (not (gnus-button-in-region-p
7733 start end 'gnus-callback)))
7734 ;; That optional form returned non-nil, so we add the
7736 (setq from (set-marker (make-marker) from))
7737 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7738 (gnus-article-extend-url-button from start end))
7739 (gnus-article-add-button start end
7740 'gnus-button-push (list from entry))
7741 (gnus-put-text-property
7743 'gnus-string (buffer-substring-no-properties
7746 (defun gnus-article-extend-url-button (beg start end)
7747 "Extend url button if url is folded into two or more lines.
7748 Return non-nil if button is extended. BEG is a marker that points to
7749 the beginning position of a text containing url. START and END are
7750 the endpoints of a url button before it is extended. The concatenated
7751 url is put as the `gnus-button-url' overlay property on the button."
7752 (let ((opoint (point))
7753 (points (list start end))
7758 (not (looking-at "[\t ]*[\">]")))
7762 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7763 (buffer-substring (point-at-bol) start)))
7765 (setq url (list (buffer-substring start end))
7766 delim (if (match-beginning 1) ">" "\""))
7768 (setq regexp (concat
7769 (when (and (looking-at
7770 message-cite-prefix-regexp)
7771 (< (match-end 0) start))
7772 (regexp-quote (match-string 0)))
7774 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7778 (and (looking-at regexp)
7781 (push (or (match-string 2)
7784 (push (setq end (or (match-end 2)
7787 (push (or (match-beginning 2)
7788 (match-beginning 1))
7790 (match-beginning 2)))
7791 (let (gnus-article-mouse-face widget-mouse-face)
7793 (gnus-article-add-button (pop points) (pop points)
7794 'gnus-button-push beg)))
7795 (let ((overlay (gnus-make-overlay start end)))
7796 (gnus-overlay-put overlay 'evaporate t)
7797 (gnus-overlay-put overlay 'gnus-button-url
7798 (list (mapconcat 'identity (nreverse url) "")))
7799 (when gnus-article-mouse-face
7800 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7802 (goto-char opoint))))
7804 ;; Add buttons to the head of an article.
7805 (defun gnus-article-add-buttons-to-head ()
7806 "Add buttons to the head of the article."
7808 (gnus-with-article-headers
7810 (dolist (entry gnus-header-button-alist)
7811 ;; Each alist entry.
7812 (goto-char (point-min))
7813 (while (re-search-forward (car entry) nil t)
7814 ;; Each header matching the entry.
7815 (setq beg (match-beginning 0))
7816 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7817 (match-beginning 0))
7820 (while (re-search-forward (eval (nth 1 entry)) end t)
7821 ;; Each match within a header.
7822 (let* ((entry (cdr entry))
7823 (start (match-beginning (nth 1 entry)))
7824 (end (match-end (nth 1 entry)))
7825 (form (nth 2 entry)))
7826 (goto-char (match-end 0))
7828 (gnus-article-add-button
7829 start end (nth 3 entry)
7830 (buffer-substring (match-beginning (nth 4 entry))
7831 (match-end (nth 4 entry)))))))
7832 (goto-char end))))))
7834 ;;; External functions:
7836 (defun gnus-article-add-button (from to fun &optional data text)
7837 "Create a button between FROM and TO with callback FUN and data DATA."
7838 (when gnus-article-button-face
7839 (gnus-overlay-put (gnus-make-overlay from to nil t)
7840 'face gnus-article-button-face))
7841 (gnus-add-text-properties
7843 (nconc (and gnus-article-mouse-face
7844 (list gnus-mouse-face-prop gnus-article-mouse-face))
7845 (list 'gnus-callback fun)
7846 (and data (list 'gnus-data data))))
7847 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7848 :help-echo (or text "Follow the link")
7849 :keymap gnus-url-button-map
7850 :button-keymap gnus-widget-button-keymap))
7852 (defun gnus-article-copy-string ()
7853 "Copy the string in the button to the kill ring."
7855 (gnus-article-check-buffer)
7856 (let ((data (get-text-property (point) 'gnus-string)))
7860 (copy-region-as-kill (point-min) (point-max))
7861 (message "Copied %s" data)))))
7863 ;;; Internal functions:
7865 (defun gnus-article-set-globals ()
7866 (with-current-buffer gnus-summary-buffer
7867 (gnus-set-global-variables)))
7869 (defun gnus-signature-toggle (end)
7870 (gnus-with-article-buffer
7871 (let ((inhibit-point-motion-hooks t))
7872 (if (text-property-any end (point-max) 'article-type 'signature)
7874 (gnus-delete-wash-type 'signature)
7875 (gnus-remove-text-properties-when
7876 'article-type 'signature end (point-max)
7877 (cons 'article-type (cons 'signature
7878 gnus-hidden-properties))))
7879 (gnus-add-wash-type 'signature)
7880 (gnus-add-text-properties-when
7881 'article-type nil end (point-max)
7882 (cons 'article-type (cons 'signature
7883 gnus-hidden-properties)))))
7884 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7885 (gnus-set-mode-line 'article))))
7887 (defun gnus-button-push (marker-and-entry)
7888 ;; Push button starting at MARKER.
7890 (let* ((marker (car marker-and-entry))
7891 (entry (cadr marker-and-entry))
7892 (regexp (car entry))
7893 (inhibit-point-motion-hooks t))
7895 ;; This is obviously true, or something bad is happening :)
7896 ;; But we need it to have the match-data
7897 (when (looking-at (or (if (symbolp regexp)
7898 (symbol-value regexp)
7900 (let ((fun (nth 3 entry))
7901 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7902 (get-char-property marker 'gnus-button-url))
7903 (mapcar (lambda (group)
7904 (let ((string (match-string group)))
7905 (set-text-properties
7906 0 (length string) nil string)
7908 (nthcdr 4 entry)))))
7914 (fboundp (symbol-value fun)))
7915 (apply (symbol-value fun) args))
7917 (gnus-message 1 "You must define `%S' to use this button"
7918 (cons fun args)))))))))
7920 (defun gnus-parse-news-url (url)
7921 (let (scheme server port group message-id articles)
7924 (goto-char (point-min))
7925 (when (looking-at "\\([A-Za-z]+\\):")
7926 (setq scheme (match-string 1))
7927 (goto-char (match-end 0)))
7928 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7929 (setq server (match-string 1))
7930 (setq port (if (stringp (match-string 3))
7931 (string-to-number (match-string 3))
7933 (goto-char (match-end 0)))
7936 ((looking-at "\\(.*@.*\\)")
7937 (setq message-id (match-string 1)))
7938 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7939 (setq group (match-string 1)
7940 articles (split-string (match-string 2) "-")))
7941 ((looking-at "\\([^/]+\\)/?")
7942 (setq group (match-string 1)))
7944 (error "Unknown news URL syntax"))))
7945 (list scheme server port group message-id articles)))
7947 (defun gnus-button-handle-news (url)
7949 (destructuring-bind (scheme server port group message-id articles)
7950 (gnus-parse-news-url url)
7953 (with-current-buffer gnus-summary-buffer
7955 (let ((gnus-refer-article-method
7956 (nconc (list (list 'nntp server))
7957 gnus-refer-article-method))
7958 (nntp-port-number (or port "nntp")))
7959 (gnus-message 7 "Fetching %s with %s"
7960 message-id gnus-refer-article-method)
7961 (gnus-summary-refer-article message-id))
7962 (gnus-summary-refer-article message-id))))
7964 (gnus-button-fetch-group url)))))
7966 (defun gnus-button-patch (library line)
7967 "Visit an Emacs Lisp library LIBRARY on line LINE."
7969 (let ((file (locate-library (file-name-nondirectory library))))
7971 (error "Couldn't find library %s" library))
7973 (goto-char (point-min))
7974 (forward-line (1- (string-to-number line)))))
7976 (defun gnus-button-handle-man (url)
7978 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7979 (when (eq gnus-button-man-handler 'woman)
7980 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7981 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7982 (funcall gnus-button-man-handler url))
7984 (defun gnus-button-handle-info-url (url)
7985 "Fetch an info URL."
7986 (setq url (mm-subst-char-in-string ?+ ?\ url))
7988 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7989 (gnus-info-find-node
7990 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7992 ")" (gnus-url-unhex-string (match-string 2 url)))))
7993 ((string-match "([^)\"]+)[^\"]+" url)
7995 (gnus-replace-in-string
7996 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7997 (gnus-info-find-node url))
7998 (t (error "Can't parse %s" url))))
8000 (defun gnus-button-handle-info-url-gnome (url)
8001 "Fetch GNOME style info URL."
8002 (setq url (mm-subst-char-in-string ?_ ?\ url))
8003 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8004 (gnus-info-find-node
8006 (gnus-url-unhex-string
8007 (match-string 1 url))
8009 (or (gnus-url-unhex-string
8010 (match-string 2 url))
8012 (error "Can't parse %s" url)))
8014 (defun gnus-button-handle-info-url-kde (url)
8015 "Fetch KDE style info URL."
8016 (gnus-info-find-node (gnus-url-unhex-string url)))
8018 ;; (info) will autoload info.el
8019 (declare-function Info-menu "info" (menu-item &optional fork))
8020 (declare-function Info-index-next "info" (num))
8022 (defun gnus-button-handle-info-keystrokes (url)
8023 "Call `info' when pushing the corresponding URL button."
8024 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8025 (let (node indx comma)
8027 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8028 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8029 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8030 "\\(?:[ \t\n,]*\\)\\)?")
8032 (setq node (match-string 2 url)
8033 indx (match-string 3 url))
8034 (error "Can't parse %s" url))
8038 (when (> (length indx) 0)
8039 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8042 (setq comma (match-string 2 indx))
8043 (setq indx (match-string 1 indx))
8046 (dotimes (i (with-temp-buffer
8048 ;; Note: the XEmacs version of `how-many' takes
8049 ;; no optional argument.
8050 (goto-char (point-min))
8052 (Info-index-next 1)))
8055 (autoload 'pgg-snarf-keys-region "pgg")
8056 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8057 (declare-function pgg-display-output-buffer "pgg" (start end status))
8059 (defun gnus-button-openpgp (url)
8060 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8062 (mm-url-insert-file-contents-external url)
8063 (pgg-snarf-keys-region (point-min) (point-max))
8064 (pgg-display-output-buffer nil nil nil)))
8066 (defun gnus-button-message-id (message-id)
8068 (with-current-buffer gnus-summary-buffer
8069 (gnus-summary-refer-article message-id)))
8071 (defun gnus-button-fetch-group (address &rest ignore)
8072 "Fetch GROUP specified by ADDRESS."
8073 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8075 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8076 ;; for nntp:// and news://
8077 (setq address (match-string 3 address)))
8078 (if (not (string-match "[:/]" address))
8079 ;; This is just a simple group url.
8080 (gnus-group-read-ephemeral-group address gnus-select-method)
8083 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8085 (error "Can't parse %s" address)
8086 (gnus-group-read-ephemeral-group
8087 (match-string 4 address)
8088 `(nntp ,(match-string 1 address)
8089 (nntp-address ,(match-string 1 address))
8090 (nntp-port-number ,(if (match-end 3)
8091 (match-string 3 address)
8094 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8096 (defun gnus-url-parse-query-string (query &optional downcase)
8097 (let (retval pairs cur key val)
8098 (setq pairs (split-string query "&"))
8100 (setq cur (car pairs)
8102 (if (not (string-match "=" cur))
8104 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8105 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8107 (setq key (downcase key)))
8108 (setq cur (assoc key retval))
8110 (setcdr cur (cons val (cdr cur)))
8111 (setq retval (cons (list key val) retval)))))
8114 (defun gnus-url-mailto (url)
8115 ;; Send mail to someone
8116 (setq url (replace-regexp-in-string "\n" " " url))
8117 (when (string-match "mailto:/*\\(.*\\)" url)
8118 (setq url (substring url (match-beginning 1) nil)))
8119 (let (to args subject func)
8120 (setq args (gnus-url-parse-query-string
8121 (if (string-match "^\\?" url)
8123 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8124 (concat "to=" (match-string 1 url) "&"
8125 (match-string 2 url))
8126 (concat "to=" url))))
8127 subject (cdr-safe (assoc "subject" args)))
8130 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8133 (message-position-on-field (caar args)))
8134 (insert (gnus-replace-in-string
8135 (mapconcat 'identity (reverse (cdar args)) ", ")
8137 (setq args (cdr args)))
8140 (message-goto-subject))))
8142 (defun gnus-button-embedded-url (address)
8143 "Activate ADDRESS with `browse-url'."
8144 (browse-url (gnus-strip-whitespace address)))
8146 ;;; Next/prev buttons in the article buffer.
8148 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8149 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8151 (defvar gnus-prev-page-map
8152 (let ((map (make-sparse-keymap)))
8153 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8154 (define-key map "\r" 'gnus-button-prev-page)
8157 (defvar gnus-next-page-map
8158 (let ((map (make-sparse-keymap)))
8159 (define-key map gnus-mouse-2 'gnus-button-next-page)
8160 (define-key map "\r" 'gnus-button-next-page)
8163 (defun gnus-insert-prev-page-button ()
8165 (inhibit-read-only t))
8167 gnus-prev-page-line-format nil
8168 `(keymap ,gnus-prev-page-map
8170 gnus-callback gnus-article-button-prev-page
8171 article-type annotation))
8173 ;; Exclude a newline.
8176 (when gnus-article-button-face
8177 (gnus-overlay-put (gnus-make-overlay b e nil t)
8178 'face gnus-article-button-face))
8179 (widget-convert-button
8181 :action 'gnus-button-prev-page
8182 :button-keymap gnus-prev-page-map)))
8184 (defun gnus-button-next-page (&optional args more-args)
8185 "Go to the next page."
8187 (let ((win (selected-window)))
8188 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8189 (gnus-article-next-page)
8190 (select-window win)))
8192 (defun gnus-button-prev-page (&optional args more-args)
8193 "Go to the prev page."
8195 (let ((win (selected-window)))
8196 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8197 (gnus-article-prev-page)
8198 (select-window win)))
8200 (defun gnus-insert-next-page-button ()
8202 (inhibit-read-only t))
8203 (gnus-eval-format gnus-next-page-line-format nil
8204 `(keymap ,gnus-next-page-map
8206 gnus-callback gnus-article-button-next-page
8207 article-type annotation))
8209 ;; Exclude a newline.
8212 (when gnus-article-button-face
8213 (gnus-overlay-put (gnus-make-overlay b e nil t)
8214 'face gnus-article-button-face))
8215 (widget-convert-button
8217 :action 'gnus-button-next-page
8218 :button-keymap gnus-next-page-map)))
8220 (defun gnus-article-button-next-page (arg)
8221 "Go to the next page."
8223 (let ((win (selected-window)))
8224 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8225 (gnus-article-next-page)
8226 (select-window win)))
8228 (defun gnus-article-button-prev-page (arg)
8229 "Go to the prev page."
8231 (let ((win (selected-window)))
8232 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8233 (gnus-article-prev-page)
8234 (select-window win)))
8236 (defvar gnus-decode-header-methods
8237 '(mail-decode-encoded-word-region)
8238 "List of methods used to decode headers.
8240 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8241 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8242 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8243 whose names match REGEXP.
8246 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8247 mail-decode-encoded-word-region
8248 (\"chinese\" . rfc1843-decode-region))
8251 (defvar gnus-decode-header-methods-cache nil)
8253 (defun gnus-multi-decode-header (start end)
8254 "Apply the functions from `gnus-encoded-word-methods' that match."
8255 (unless (and gnus-decode-header-methods-cache
8256 (eq gnus-newsgroup-name
8257 (car gnus-decode-header-methods-cache)))
8258 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8259 (dolist (x gnus-decode-header-methods)
8261 (nconc gnus-decode-header-methods-cache (list x))
8262 (if (and gnus-newsgroup-name
8263 (string-match (car x) gnus-newsgroup-name))
8264 (nconc gnus-decode-header-methods-cache
8266 (let ((xlist gnus-decode-header-methods-cache))
8269 (narrow-to-region start end)
8271 (funcall (pop xlist) (point-min) (point-max))))))
8274 ;;; Treatment top-level handling.
8277 (defvar gnus-inhibit-article-treatments nil)
8279 (defun gnus-treat-article (gnus-treat-condition
8280 &optional part-number total-parts gnus-treat-type)
8281 (let ((gnus-treat-length (- (point-max) (point-min)))
8282 (alist gnus-treatment-function-alist)
8283 (article-goto-body-goes-to-point-min-p t)
8285 (or (not gnus-treat-type)
8287 (let ((list gnus-article-treat-types))
8289 (when (string-match (pop list) gnus-treat-type)
8290 (throw 'found t)))))))
8291 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8293 (gnus-run-hooks 'gnus-part-display-hook)
8294 (dolist (elem alist)
8297 (when (gnus-buffer-live-p gnus-summary-buffer)
8298 (set-buffer gnus-summary-buffer))
8299 (symbol-value (car elem))))
8300 (when (and (or (consp val)
8302 (or (not gnus-inhibit-article-treatments)
8303 (eq gnus-treat-condition 'head))
8304 (gnus-treat-predicate val)
8305 (or (not (get (car elem) 'highlight))
8308 (funcall (cadr elem)))))))
8310 ;; Dynamic variables.
8311 (defvar part-number)
8312 (defvar total-parts)
8313 (defvar gnus-treat-type)
8314 (defvar gnus-treat-condition)
8315 (defvar gnus-treat-length)
8317 (defun gnus-treat-predicate (val)
8321 (gnus-treat-condition
8322 (eq gnus-treat-condition val))
8324 (stringp (car val)))
8325 (apply 'gnus-or (mapcar `(lambda (s)
8326 (string-match s ,(or gnus-newsgroup-name "")))
8329 (let ((pred (pop val)))
8332 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8334 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8336 (not (gnus-treat-predicate (car val))))
8338 (equal (car val) gnus-treat-type))
8340 (error "%S is not a valid predicate" pred)))))
8348 (eq part-number total-parts))
8350 (< gnus-treat-length val))
8352 (error "%S is not a valid value" val))))
8354 (defun gnus-article-encrypt-body (protocol &optional n)
8355 "Encrypt the article body."
8358 (or gnus-article-encrypt-protocol
8359 (gnus-completing-read "Encrypt protocol"
8360 (mapcar 'car gnus-article-encrypt-protocol-alist)
8362 current-prefix-arg))
8363 ;; User might hit `K E' instead of `K e', so prompt once.
8364 (when (and gnus-article-encrypt-protocol
8366 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8367 (error "Encrypt aborted")))
8368 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8370 (error "Can't find the encrypt protocol %s" protocol))
8371 (if (member gnus-newsgroup-name '("nndraft:delayed"
8374 (error "Can't encrypt the article in group %s"
8375 gnus-newsgroup-name))
8376 (gnus-summary-iterate n
8377 (with-current-buffer gnus-summary-buffer
8378 (let ((mail-parse-charset gnus-newsgroup-charset)
8379 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8380 (summary-buffer gnus-summary-buffer)
8382 (gnus-set-global-variables)
8383 (when (gnus-group-read-only-p)
8384 (error "The current newsgroup does not support article encrypt"))
8385 (gnus-summary-show-article t)
8387 (or (mail-header-references gnus-current-headers) ""))
8388 (set-buffer gnus-article-buffer)
8389 (let* ((inhibit-read-only t)
8391 (mapcar (lambda (field)
8392 (and (save-restriction
8393 (message-narrow-to-head)
8394 (goto-char (point-min))
8395 (search-forward field nil t))
8397 (message-narrow-to-field)
8399 (delete-region (point-min) (point-max))
8401 '("Content-Type:" "Content-Transfer-Encoding:"
8402 "Content-Disposition:"))))
8403 (message-narrow-to-head)
8404 (message-remove-header "MIME-Version")
8405 (goto-char (point-max))
8406 (setq point (point))
8407 (insert (apply 'concat headers))
8409 (narrow-to-region point (point-max))
8410 (let ((message-options message-options))
8411 (message-options-set 'message-sender user-mail-address)
8412 (message-options-set 'message-recipients user-mail-address)
8413 (message-options-set 'message-sign-encrypt 'not)
8415 (goto-char (point-min))
8416 (insert "MIME-Version: 1.0\n")
8418 (gnus-summary-edit-article-done
8419 references nil summary-buffer t))
8420 (when gnus-keep-backlog
8421 (gnus-backlog-remove-article
8422 (car gnus-article-current) (cdr gnus-article-current)))
8423 (gnus-flush-original-article-buffer)
8424 (when gnus-use-cache
8425 (gnus-cache-update-article
8426 (car gnus-article-current) (cdr gnus-article-current))))))))
8428 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8429 "The following specs can be used:
8430 %t The security MIME type
8433 %D Details if button is pressed")
8435 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8436 "The following specs can be used:
8437 %t The security MIME type
8440 %D Details if button is pressed")
8442 (defvar gnus-mime-security-button-line-format-alist
8443 '((?t gnus-tmp-type ?s)
8444 (?i gnus-tmp-info ?s)
8445 (?d gnus-tmp-details ?s)
8446 (?D gnus-tmp-pressed-details ?s)))
8448 (defvar gnus-mime-security-button-commands
8449 '((gnus-article-press-button "\r" "Show Detail")
8453 (gnus-mime-security-save-part "o" "Save...")
8462 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8465 (defvar gnus-mime-security-button-map
8466 (let ((map (make-sparse-keymap)))
8467 (define-key map gnus-mouse-2 'gnus-article-push-button)
8468 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8469 (dolist (c gnus-mime-security-button-commands)
8470 (define-key map (cadr c) (car c)))
8474 gnus-mime-security-button-menu gnus-mime-security-button-map
8475 "Security button menu."
8479 (unless (eq (car c) 'undefined)
8480 (vector (caddr c) (car c) :active t)))
8481 gnus-mime-security-button-commands))))
8483 (defun gnus-mime-security-button-menu (event prefix)
8484 "Construct a context-sensitive menu of security commands."
8485 (interactive "e\nP")
8486 (save-window-excursion
8487 (let ((pos (event-start event)))
8488 (select-window (posn-window pos))
8489 (goto-char (posn-point pos))
8490 (gnus-article-check-buffer)
8491 (popup-menu gnus-mime-security-button-menu nil prefix))))
8493 (defvar gnus-mime-security-details-buffer nil)
8495 (defvar gnus-mime-security-button-pressed nil)
8497 (defvar gnus-mime-security-show-details-inline t
8498 "If non-nil, show details in the article buffer.")
8500 (defun gnus-mime-security-verify-or-decrypt (handle)
8501 (mm-remove-parts (cdr handle))
8502 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8503 point (inhibit-read-only t))
8505 (goto-char (car region)))
8506 (setq point (point))
8507 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8508 (let* ((mm-verify-option 'known)
8509 (mm-decrypt-option 'known)
8510 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8511 (unless (eq nparts (cdr handle))
8512 (mm-destroy-parts (cdr handle))
8513 (setcdr handle nparts))))
8514 (gnus-mime-display-security handle)
8516 (delete-region (point) (cdr region))
8517 (set-marker (car region) nil)
8518 (set-marker (cdr region) nil))
8521 (defun gnus-mime-security-show-details (handle)
8522 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8524 (gnus-message 5 "No details.")
8525 (if gnus-mime-security-show-details-inline
8526 (let ((gnus-mime-security-button-pressed
8527 (not (get-text-property (point) 'gnus-mime-details)))
8528 (gnus-mime-security-button-line-format
8529 (get-text-property (point) 'gnus-line-format))
8530 (inhibit-read-only t))
8532 (while (eq (get-text-property (point) 'gnus-line-format)
8533 gnus-mime-security-button-line-format)
8537 (narrow-to-region (point) (point))
8538 (gnus-insert-mime-security-button handle))
8539 (delete-region (point)
8540 (or (text-property-not-all
8543 gnus-mime-security-button-line-format)
8546 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8547 (with-current-buffer gnus-mime-security-details-buffer
8550 (setq gnus-mime-security-details-buffer
8551 (gnus-get-buffer-create "*MIME Security Details*")))
8552 (with-current-buffer gnus-mime-security-details-buffer
8554 (goto-char (point-min)))
8555 (pop-to-buffer gnus-mime-security-details-buffer)))))
8557 (defun gnus-mime-security-press-button (handle)
8559 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8560 (gnus-mime-security-show-details handle)
8561 (gnus-mime-security-verify-or-decrypt handle))))
8563 (defun gnus-insert-mime-security-button (handle &optional displayed)
8564 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8567 (or (nth 2 (assoc protocol mm-verify-function-alist))
8568 (nth 2 (assoc protocol mm-decrypt-function-alist))
8570 (if (equal (car handle) "multipart/signed")
8571 " Signed" " Encrypted")
8574 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8577 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8578 gnus-tmp-pressed-details
8580 (setq gnus-tmp-details
8581 (if gnus-tmp-details
8582 (concat "\n" gnus-tmp-details)
8584 (setq gnus-tmp-pressed-details
8585 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8590 gnus-mime-security-button-line-format
8591 gnus-mime-security-button-line-format-alist
8592 `(keymap ,gnus-mime-security-button-map
8593 gnus-callback gnus-mime-security-press-button
8594 gnus-line-format ,gnus-mime-security-button-line-format
8595 gnus-mime-details ,gnus-mime-security-button-pressed
8596 article-type annotation
8599 ;; Exclude a newline.
8602 (when gnus-article-button-face
8603 (gnus-overlay-put (gnus-make-overlay b e nil t)
8604 'face gnus-article-button-face))
8605 (widget-convert-button
8608 :action 'gnus-widget-press-button
8609 :button-keymap gnus-mime-security-button-map
8612 ;; Needed to properly clear the message due to a bug in
8613 ;; wid-edit (XEmacs only).
8614 (when (boundp 'help-echo-owns-message)
8615 (setq help-echo-owns-message t))
8617 "%S: show detail; %S: more options"
8618 (aref gnus-mouse-2 0)
8619 (aref gnus-down-mouse-3 0))))))
8621 (defun gnus-mime-display-security (handle)
8623 (narrow-to-region (point) (point))
8624 (unless (gnus-unbuttonized-mime-type-p (car handle))
8625 (gnus-insert-mime-security-button handle))
8626 (gnus-mime-display-part (cadr handle))
8629 (unless (gnus-unbuttonized-mime-type-p (car handle))
8630 (let ((gnus-mime-security-button-line-format
8631 gnus-mime-security-button-end-line-format))
8632 (gnus-insert-mime-security-button handle)))
8633 (mm-set-handle-multipart-parameter
8635 (cons (set-marker (make-marker) (point-min))
8636 (set-marker (make-marker) (point-max))))
8637 (goto-char (point-max))))
8639 (defun gnus-mime-security-run-function (function)
8640 "Run FUNCTION with the security part under point."
8641 (gnus-article-check-buffer)
8642 (let ((data (get-text-property (point) 'gnus-data))
8644 (when (and (stringp (car-safe data))
8645 (setq buffer (mm-handle-multipart-original-buffer data))
8646 (setq handle (cadr data)))
8647 (if (bufferp (mm-handle-buffer handle))
8649 (setq handle (cons buffer (copy-sequence (cdr handle))))
8650 (mm-handle-set-undisplayer handle nil))
8651 (setq handle (mm-make-handle
8653 (mm-handle-multipart-ctl-parameter handle 'protocol)
8654 nil nil nil nil nil nil)))
8655 (funcall function handle))))
8657 (defun gnus-mime-security-save-part ()
8658 "Save the security part under point."
8660 (gnus-mime-security-run-function 'mm-save-part))
8662 (defun gnus-mime-security-pipe-part ()
8663 "Pipe the security part under point to a process."
8665 (gnus-mime-security-run-function 'mm-pipe-part))
8671 (run-hooks 'gnus-art-load-hook)
8673 ;;; gnus-art.el ends here