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:"
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-headers
1018 (let ((types '(ut local english lapsed combined-lapsed
1019 iso8601 original user-defined))
1021 ;; Try to respect the legacy `gnus-treat-date-*' variables, if
1023 (dolist (type types)
1024 (let ((variable (intern (format "gnus-treat-date-%s" type))))
1025 (when (and (boundp variable)
1026 (symbol-value variable))
1027 (push type default))))
1028 (when (and (or (not (boundp (intern "gnus-article-date-lapsed-new-header")))
1029 (not (symbol-value (intern "gnus-article-date-lapsed-new-header"))))
1030 (memq 'lapsed default))
1031 (setq default (delq 'lapsed default)))
1033 ;; If they weren't set, we default to `combined-lapsed'.
1034 '(combined-lapsed)))
1035 "A list of Date header formats to display.
1036 Valid formats are `ut' (universal time), `local' (local time
1037 zone), `english' (readable English), `lapsed' (elapsed time),
1038 `combined-lapsed' (both the original date and the elapsed time),
1039 `original' (the original date header), `iso8601' (ISO8601
1040 format), and `user-defined' (a user-defined format defined by the
1041 `gnus-article-time-format' variable).
1043 You have as many date headers as you want in the article buffer.
1044 Some of these headers are updated automatically. See
1045 `gnus-article-update-date-headers' for details."
1047 :group 'gnus-article-headers
1049 (item :tag "Universal time (UT)" :value 'ut)
1050 (item :tag "Local time zone" :value 'local)
1051 (item :tag "Readable English" :value 'english)
1052 (item :tag "Elapsed time" :value 'lapsed)
1053 (item :tag "Original and elapsed time" :value 'combined-lapsed)
1054 (item :tag "Original date header" :value 'original)
1055 (item :tag "ISO8601 format" :value 'iso8601)
1056 (item :tag "User-defined" :value 'user-defined)))
1058 (defcustom gnus-article-update-date-headers 1
1059 "How often to update the date header.
1060 If nil, don't update it at all."
1062 :group 'gnus-article-headers
1064 (item :tag "Don't update" :value nil)
1067 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1068 "Function called with a MIME handle as the argument.
1069 This is meant for people who want to view first matched part.
1070 For `undisplayed-alternative' (default), the first undisplayed
1071 part or alternative part is used. For `undisplayed', the first
1072 undisplayed part is used. For a function, the first part which
1073 the function return t is used. For nil, the first part is
1076 :group 'gnus-article-mime
1078 (item :tag "first" :value nil)
1079 (item :tag "undisplayed" :value undisplayed)
1080 (item :tag "undisplayed or alternative"
1081 :value undisplayed-alternative)
1084 (defcustom gnus-mime-action-alist
1085 '(("save to file" . gnus-mime-save-part)
1086 ("save and strip" . gnus-mime-save-part-and-strip)
1087 ("replace with file" . gnus-mime-replace-part)
1088 ("delete part" . gnus-mime-delete-part)
1089 ("display as text" . gnus-mime-inline-part)
1090 ("view the part" . gnus-mime-view-part)
1091 ("pipe to command" . gnus-mime-pipe-part)
1092 ("toggle display" . gnus-article-press-button)
1093 ("toggle display" . gnus-article-view-part-as-charset)
1094 ("view as type" . gnus-mime-view-part-as-type)
1095 ("view internally" . gnus-mime-view-part-internally)
1096 ("view externally" . gnus-mime-view-part-externally))
1097 "An alist of actions that run on the MIME attachment."
1098 :group 'gnus-article-mime
1099 :type '(repeat (cons (string :tag "name")
1102 (defcustom gnus-auto-select-part 1
1103 "Advance to next MIME part when deleting or stripping parts.
1105 When 0, point will be placed on the same part as before. When
1106 positive (negative), move point forward (backwards) this many
1107 parts. When nil, redisplay article."
1108 :version "23.1" ;; No Gnus
1109 :group 'gnus-article-mime
1110 :type '(choice (const nil :tag "Redisplay article.")
1111 (const 1 :tag "Next part.")
1112 (const 0 :tag "Current part.")
1116 ;;; The treatment variables
1119 (defvar gnus-part-display-hook nil
1120 "Hook called on parts that are to receive treatment.")
1122 (defvar gnus-article-treat-custom
1123 '(choice (const :tag "Off" nil)
1125 (const :tag "Header" head)
1126 (const :tag "First" first)
1127 (const :tag "Last" last)
1128 (integer :tag "Less")
1129 (repeat :tag "Groups" regexp)
1130 (sexp :tag "Predicate")))
1132 (defvar gnus-article-treat-head-custom
1133 '(choice (const :tag "Off" nil)
1134 (const :tag "Header" head)))
1136 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1140 (defvar gnus-inhibit-treatment nil
1141 "Whether to inhibit treatment.")
1143 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1144 "Highlight the signature.
1145 Valid values are nil, t, `head', `first', `last', an integer or a
1146 predicate. See Info node `(gnus)Customizing Articles'."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom)
1150 (put 'gnus-treat-highlight-signature 'highlight t)
1152 (defcustom gnus-treat-buttonize 100000
1154 Valid values are nil, t, `head', `first', `last', an integer or a
1155 predicate. See Info node `(gnus)Customizing Articles'."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom)
1159 (put 'gnus-treat-buttonize 'highlight t)
1161 (defcustom gnus-treat-buttonize-head 'head
1162 "Add buttons to the head.
1163 Valid values are nil, t, `head', `first', `last', an integer or a
1164 predicate. See Info node `(gnus)Customizing Articles'."
1165 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-head-custom)
1168 (put 'gnus-treat-buttonize-head 'highlight t)
1170 (defcustom gnus-treat-date 'head
1171 "Display dates according to the `gnus-article-date-headers' variable.
1172 Valid values are nil, t, `head', `first', `last', an integer or a
1173 predicate. See Info node `(gnus)Customizing Articles'."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom)
1179 (defcustom gnus-treat-emphasize 50000
1181 Valid values are nil, t, `head', `first', `last', an integer or a
1182 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1186 (put 'gnus-treat-emphasize 'highlight t)
1188 (defcustom gnus-treat-strip-cr nil
1189 "Remove carriage returns.
1190 Valid values are nil, t, `head', `first', `last', an integer or a
1191 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-unsplit-urls nil
1198 "Remove newlines from within URLs.
1199 Valid values are nil, t, `head', `first', `last', an integer or a
1200 predicate. See Info node `(gnus)Customizing Articles'."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1206 (defcustom gnus-treat-leading-whitespace nil
1207 "Remove leading whitespace in headers.
1208 Valid values are nil, t, `head', `first', `last', an integer or a
1209 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (defcustom gnus-treat-hide-headers 'head
1217 Valid values are nil, t, `head', `first', `last', an integer or a
1218 predicate. See Info node `(gnus)Customizing Articles'."
1219 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-head-custom)
1223 (defcustom gnus-treat-hide-boring-headers nil
1224 "Hide boring headers.
1225 Valid values are nil, t, `head', `first', `last', an integer or a
1226 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-head-custom)
1231 (defcustom gnus-treat-hide-signature nil
1232 "Hide the signature.
1233 Valid values are nil, t, `head', `first', `last', an integer or a
1234 predicate. See Info node `(gnus)Customizing Articles'."
1235 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :type gnus-article-treat-custom)
1239 (defcustom gnus-treat-fill-article nil
1241 Valid values are nil, t, `head', `first', `last', an integer or a
1242 predicate. See Info node `(gnus)Customizing Articles'."
1243 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-hide-citation nil
1249 Valid values are nil, t, `head', `first', `last', an integer or a
1250 predicate. See Info node `(gnus)Customizing Articles'."
1251 :group 'gnus-article-treat
1252 :link '(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-hide-citation-maybe nil
1257 Valid values are nil, t, `head', `first', `last', an integer or a
1258 predicate. See Info node `(gnus)Customizing Articles'."
1259 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :type gnus-article-treat-custom)
1263 (defcustom gnus-treat-strip-list-identifiers 'head
1264 "Strip list identifiers from `gnus-list-identifiers`.
1265 Valid values are nil, t, `head', `first', `last', an integer or a
1266 predicate. See Info node `(gnus)Customizing Articles'."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1273 "Gnus 5.10 (Emacs 22.1)")
1275 (defcustom gnus-treat-strip-pem nil
1276 "Strip PEM signatures.
1277 Valid values are nil, t, `head', `first', `last', an integer or a
1278 predicate. See Info node `(gnus)Customizing Articles'."
1279 :group 'gnus-article-treat
1280 :link '(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-custom)
1283 (defcustom gnus-treat-strip-banner t
1284 "Strip banners from articles.
1285 The banner to be stripped is specified in the `banner' group parameter.
1286 Valid values are nil, t, `head', `first', `last', an integer or a
1287 predicate. See Info node `(gnus)Customizing Articles'."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-custom)
1292 (defcustom gnus-treat-highlight-headers 'head
1293 "Highlight the headers.
1294 Valid values are nil, t, `head', `first', `last', an integer or a
1295 predicate. See Info node `(gnus)Customizing Articles'."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-head-custom)
1299 (put 'gnus-treat-highlight-headers 'highlight t)
1301 (defcustom gnus-treat-highlight-citation t
1302 "Highlight cited text.
1303 Valid values are nil, t, `head', `first', `last', an integer or a
1304 predicate. See Info node `(gnus)Customizing Articles'."
1305 :group 'gnus-article-treat
1306 :link '(custom-manual "(gnus)Customizing Articles")
1307 :type gnus-article-treat-custom)
1308 (put 'gnus-treat-highlight-citation 'highlight t)
1310 (defcustom gnus-treat-strip-headers-in-body t
1311 "Strip the X-No-Archive header line from the beginning of the body.
1312 Valid values are nil, t, `head', `first', `last', an integer or a
1313 predicate. See Info node `(gnus)Customizing Articles'."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom)
1319 (defcustom gnus-treat-strip-trailing-blank-lines nil
1320 "Strip trailing blank lines.
1321 Valid values are nil, t, `head', `first', `last', an integer or a
1322 predicate. See Info node `(gnus)Customizing Articles'.
1324 When set to t, it also strips trailing blanks in all MIME parts.
1325 Consider to use `last' instead."
1326 :group 'gnus-article-treat
1327 :link '(custom-manual "(gnus)Customizing Articles")
1328 :type gnus-article-treat-custom)
1330 (defcustom gnus-treat-strip-leading-blank-lines nil
1331 "Strip leading blank lines.
1332 Valid values are nil, t, `head', `first', `last', an integer or a
1333 predicate. See Info node `(gnus)Customizing Articles'.
1335 When set to t, it also strips trailing blanks in all MIME parts."
1336 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :type gnus-article-treat-custom)
1340 (defcustom gnus-treat-strip-multiple-blank-lines nil
1341 "Strip multiple blank lines.
1342 Valid values are nil, t, `head', `first', `last', an integer or a
1343 predicate. See Info node `(gnus)Customizing Articles'."
1344 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom)
1348 (defcustom gnus-treat-unfold-headers 'head
1349 "Unfold folded header lines.
1350 Valid values are nil, t, `head', `first', `last', an integer or a
1351 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-article-unfold-long-headers nil
1358 "If non-nil, allow unfolding headers even if the header is long.
1359 If it is a regexp, only long headers matching this regexp are unfolded.
1360 If it is t, all long headers are unfolded.
1362 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1363 :version "23.1" ;; No Gnus
1364 :group 'gnus-article-treat
1365 :type '(choice (const nil)
1366 (const :tag "all" t)
1369 (defcustom gnus-treat-fold-headers nil
1371 Valid values are nil, t, `head', `first', `last', an integer or a
1372 predicate. See Info node `(gnus)Customizing Articles'."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-custom)
1378 (defcustom gnus-treat-fold-newsgroups 'head
1379 "Fold the Newsgroups and Followup-To headers.
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-overstrike t
1388 "Treat overstrike highlighting.
1389 Valid values are nil, t, `head', `first', `last', an integer or a
1390 predicate. See Info node `(gnus)Customizing Articles'."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1394 (put 'gnus-treat-overstrike 'highlight t)
1396 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1397 "Treat ANSI SGR control sequences.
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)
1404 (make-obsolete-variable 'gnus-treat-display-xface
1405 'gnus-treat-display-x-face "Emacs 22.1")
1407 (defcustom gnus-treat-display-x-face
1408 (and (not noninteractive)
1409 (gnus-image-type-available-p 'xbm)
1410 (if (featurep 'xemacs)
1413 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1414 (executable-find "icontopbm"))
1415 ;; shell-command-to-string may signal an error, e.g. if
1416 ;; shell-file-name is not found.
1419 "Display X-Face headers.
1420 Valid values are nil and `head'.
1421 See Info node `(gnus)Customizing Articles' and Info node
1422 `(gnus)X-Face' for details."
1423 :group 'gnus-article-treat
1425 :link '(custom-manual "(gnus)Customizing Articles")
1426 :link '(custom-manual "(gnus)X-Face")
1427 :type gnus-article-treat-head-custom
1428 :set (lambda (symbol value)
1431 (cond ((or (boundp symbol) (get symbol 'saved-value))
1433 ((boundp 'gnus-treat-display-xface)
1435 ** gnus-treat-display-xface is an obsolete variable;\
1436 use gnus-treat-display-x-face instead")
1437 (default-value 'gnus-treat-display-xface))
1438 ((get 'gnus-treat-display-xface 'saved-value)
1440 ** gnus-treat-display-xface is an obsolete variable;\
1441 use gnus-treat-display-x-face instead")
1442 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1445 (put 'gnus-treat-display-x-face 'highlight t)
1447 (defcustom gnus-treat-display-face
1448 (and (not noninteractive)
1449 (gnus-image-type-available-p 'png)
1451 "Display Face headers.
1452 Valid values are nil, t, `head', `first', `last', an integer or a
1453 predicate. See Info node `(gnus)Customizing Articles' and Info
1454 node `(gnus)Face' for details."
1455 :group 'gnus-article-treat
1457 :link '(custom-manual "(gnus)Customizing Articles")
1458 :link '(custom-manual "(gnus)X-Face")
1459 :type gnus-article-treat-head-custom)
1460 (put 'gnus-treat-display-face 'highlight t)
1462 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1464 Valid values are nil, t, `head', `first', `last', an integer or a
1465 predicate. See Info node `(gnus)Customizing Articles' and Info
1466 node `(gnus)Smileys' for details."
1467 :group 'gnus-article-treat
1469 :link '(custom-manual "(gnus)Customizing Articles")
1470 :link '(custom-manual "(gnus)Smileys")
1471 :type gnus-article-treat-custom)
1472 (put 'gnus-treat-display-smileys 'highlight t)
1474 (defcustom gnus-treat-from-picon
1475 (if (and (gnus-image-type-available-p 'xpm)
1476 (gnus-picons-installed-p))
1478 "Display picons in the From header.
1479 Valid values are nil, t, `head', `first', `last', an integer or a
1480 predicate. See Info node `(gnus)Customizing Articles' and Info
1481 node `(gnus)Picons' for details."
1483 :group 'gnus-article-treat
1485 :link '(custom-manual "(gnus)Customizing Articles")
1486 :link '(custom-manual "(gnus)Picons")
1487 :type gnus-article-treat-head-custom)
1488 (put 'gnus-treat-from-picon 'highlight t)
1490 (defcustom gnus-treat-mail-picon
1491 (if (and (gnus-image-type-available-p 'xpm)
1492 (gnus-picons-installed-p))
1494 "Display picons in To and Cc headers.
1495 Valid values are nil, t, `head', `first', `last', an integer or a
1496 predicate. See Info node `(gnus)Customizing Articles' and Info
1497 node `(gnus)Picons' for details."
1499 :group 'gnus-article-treat
1501 :link '(custom-manual "(gnus)Customizing Articles")
1502 :link '(custom-manual "(gnus)Picons")
1503 :type gnus-article-treat-head-custom)
1504 (put 'gnus-treat-mail-picon 'highlight t)
1506 (defcustom gnus-treat-newsgroups-picon
1507 (if (and (gnus-image-type-available-p 'xpm)
1508 (gnus-picons-installed-p))
1510 "Display picons in the Newsgroups and Followup-To headers.
1511 Valid values are nil, t, `head', `first', `last', an integer or a
1512 predicate. See Info node `(gnus)Customizing Articles' and Info
1513 node `(gnus)Picons' for details."
1515 :group 'gnus-article-treat
1517 :link '(custom-manual "(gnus)Customizing Articles")
1518 :link '(custom-manual "(gnus)Picons")
1519 :type gnus-article-treat-head-custom)
1520 (put 'gnus-treat-newsgroups-picon 'highlight t)
1522 (defcustom gnus-treat-from-gravatar nil
1523 "Display gravatars in the From header.
1524 Valid values are nil, t, `head', `first', `last', an integer or a
1525 predicate. See Info node `(gnus)Customizing Articles' and Info
1526 node `(gnus)Gravatars' for details."
1528 :group 'gnus-article-treat
1529 :group 'gnus-gravatar
1530 :link '(custom-manual "(gnus)Customizing Articles")
1531 :link '(custom-manual "(gnus)Gravatars")
1532 :type gnus-article-treat-head-custom)
1533 (put 'gnus-treat-from-gravatar 'highlight t)
1535 (defcustom gnus-treat-mail-gravatar nil
1536 "Display gravatars in To and Cc headers.
1537 Valid values are nil, t, `head', `first', `last', an integer or a
1538 predicate. See Info node `(gnus)Customizing Articles' and Info
1539 node `(gnus)Gravatars' for details."
1541 :group 'gnus-article-treat
1542 :group 'gnus-gravatar
1543 :link '(custom-manual "(gnus)Customizing Articles")
1544 :link '(custom-manual "(gnus)Gravatars")
1545 :type gnus-article-treat-head-custom)
1546 (put 'gnus-treat-mail-gravatar 'highlight t)
1548 (defcustom gnus-treat-body-boundary
1549 (if (or gnus-treat-newsgroups-picon
1550 gnus-treat-mail-picon
1551 gnus-treat-from-picon
1552 gnus-treat-from-gravatar
1553 gnus-treat-mail-gravatar)
1554 ;; If there's much decoration, the user might prefer a boundery.
1557 "Draw a boundary at the end of the headers.
1558 Valid values are nil and `head'.
1559 See Info node `(gnus)Customizing Articles' for details."
1561 :group 'gnus-article-treat
1562 :link '(custom-manual "(gnus)Customizing Articles")
1563 :type gnus-article-treat-head-custom)
1565 (defcustom gnus-treat-capitalize-sentences nil
1566 "Capitalize sentence-starting words.
1567 Valid values are nil, t, `head', `first', `last', an integer or a
1568 predicate. See Info node `(gnus)Customizing Articles'."
1570 :group 'gnus-article-treat
1571 :link '(custom-manual "(gnus)Customizing Articles")
1572 :type gnus-article-treat-custom)
1574 (defcustom gnus-treat-wash-html nil
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-fill-long-lines '(typep "text/plain")
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-x-pgp-sig nil
1594 To automatically treat X-PGP-Sig, set it to head.
1595 Valid values are nil, t, `head', `first', `last', an integer or a
1596 predicate. See Info node `(gnus)Customizing Articles'."
1598 :group 'gnus-article-treat
1599 :group 'mime-security
1600 :link '(custom-manual "(gnus)Customizing Articles")
1601 :type gnus-article-treat-custom)
1603 (defvar gnus-article-encrypt-protocol-alist
1604 '(("PGP" . mml2015-self-encrypt)))
1606 ;; Set to nil if more than one protocol added to
1607 ;; gnus-article-encrypt-protocol-alist.
1608 (defcustom gnus-article-encrypt-protocol "PGP"
1609 "The protocol used for encrypt articles.
1610 It is a string, such as \"PGP\". If nil, ask user."
1613 :group 'mime-security)
1615 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1616 (mm-coding-system-p 'utf-8)
1617 (executable-find idna-program))
1618 "Whether IDNA decoding of headers is used when viewing messages.
1619 This requires GNU Libidn, and by default only enabled if it is found."
1621 :group 'gnus-article-headers
1624 (defcustom gnus-article-over-scroll nil
1625 "If non-nil, allow scrolling the article buffer even when there no more text."
1627 :group 'gnus-article
1630 (defcustom gnus-inhibit-images nil
1631 "Non-nil means inhibit displaying of images inline in the article body."
1633 :group 'gnus-article
1636 (defcustom gnus-blocked-images 'gnus-block-private-groups
1637 "Images that have URLs matching this regexp will be blocked.
1638 This can also be a function to be evaluated. If so, it will be
1639 called with the group name as the parameter, and should return a
1645 ;;; Internal variables
1647 (defvar gnus-english-month-names
1648 '("January" "February" "March" "April" "May" "June" "July" "August"
1649 "September" "October" "November" "December"))
1651 (defvar article-goto-body-goes-to-point-min-p nil)
1652 (defvar gnus-article-wash-types nil)
1653 (defvar gnus-article-emphasis-alist nil)
1654 (defvar gnus-article-image-alist nil)
1656 (defvar gnus-article-mime-handle-alist-1 nil)
1657 (defvar gnus-treatment-function-alist
1658 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1659 (gnus-treat-strip-banner gnus-article-strip-banner)
1660 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1661 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1662 (gnus-treat-buttonize gnus-article-add-buttons)
1663 (gnus-treat-fill-article gnus-article-fill-cited-article)
1664 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1665 (gnus-treat-strip-cr gnus-article-remove-cr)
1666 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1667 (gnus-treat-display-x-face gnus-article-display-x-face)
1668 (gnus-treat-display-face gnus-article-display-face)
1669 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1670 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1671 (gnus-treat-hide-signature gnus-article-hide-signature)
1672 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1673 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1674 (gnus-treat-from-picon gnus-treat-from-picon)
1675 (gnus-treat-mail-picon gnus-treat-mail-picon)
1676 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1677 (gnus-treat-strip-pem gnus-article-hide-pem)
1678 (gnus-treat-date gnus-article-treat-date)
1679 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1680 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1681 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1682 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1683 (gnus-treat-strip-trailing-blank-lines
1684 gnus-article-remove-trailing-blank-lines)
1685 (gnus-treat-strip-leading-blank-lines
1686 gnus-article-strip-leading-blank-lines)
1687 (gnus-treat-strip-multiple-blank-lines
1688 gnus-article-strip-multiple-blank-lines)
1689 (gnus-treat-overstrike gnus-article-treat-overstrike)
1690 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1691 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1692 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1693 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1694 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1695 (gnus-treat-display-smileys gnus-treat-smiley)
1696 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1697 (gnus-treat-wash-html gnus-article-wash-html)
1698 (gnus-treat-emphasize gnus-article-emphasize)
1699 (gnus-treat-hide-citation gnus-article-hide-citation)
1700 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1701 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1702 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1704 (defvar gnus-article-mime-handle-alist nil)
1705 (defvar article-lapsed-timer nil)
1706 (defvar gnus-article-current-summary nil)
1708 (defvar gnus-article-mode-syntax-table
1709 (let ((table (copy-syntax-table text-mode-syntax-table)))
1710 ;; This causes the citation match run O(2^n).
1711 ;; (modify-syntax-entry ?- "w" table)
1712 (modify-syntax-entry ?> ")<" table)
1713 (modify-syntax-entry ?< "(>" table)
1714 ;; make M-. in article buffers work for `foo' strings
1715 (modify-syntax-entry ?' " " table)
1716 (modify-syntax-entry ?` " " table)
1718 "Syntax table used in article mode buffers.
1719 Initialized from `text-mode-syntax-table.")
1721 (defvar gnus-save-article-buffer nil)
1723 (defvar gnus-number-of-articles-to-be-saved nil)
1725 (defvar gnus-inhibit-hiding nil)
1727 (defvar gnus-article-edit-mode nil)
1729 ;;; Macros for dealing with the article buffer.
1731 (defmacro gnus-with-article-headers (&rest forms)
1732 `(with-current-buffer gnus-article-buffer
1734 (let ((inhibit-read-only t)
1735 (inhibit-point-motion-hooks t)
1736 (case-fold-search t))
1737 (article-narrow-to-head)
1740 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1741 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1743 (defmacro gnus-with-article-buffer (&rest forms)
1744 `(with-current-buffer gnus-article-buffer
1745 (let ((inhibit-read-only t))
1748 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1749 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1751 (defun gnus-article-goto-header (header)
1752 "Go to HEADER, which is a regular expression."
1753 (re-search-forward (concat "^\\(" header "\\):") nil t))
1755 (defsubst gnus-article-hide-text (b e props)
1756 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1757 (gnus-add-text-properties-when 'article-type nil b e props)
1758 (when (memq 'intangible props)
1760 (max (1- b) (point-min))
1761 b 'intangible (cddr (memq 'intangible props)))))
1763 (defsubst gnus-article-unhide-text (b e)
1764 "Remove hidden text properties from region between B and E."
1765 (remove-text-properties b e gnus-hidden-properties)
1766 (when (memq 'intangible gnus-hidden-properties)
1767 (put-text-property (max (1- b) (point-min))
1768 b 'intangible nil)))
1770 (defun gnus-article-hide-text-type (b e type)
1771 "Hide text of TYPE between B and E."
1772 (gnus-add-wash-type type)
1773 (gnus-article-hide-text
1774 b e (cons 'article-type (cons type gnus-hidden-properties))))
1776 (defun gnus-article-unhide-text-type (b e type)
1777 "Unhide text of TYPE between B and E."
1778 (gnus-delete-wash-type type)
1779 (remove-text-properties
1780 b e (cons 'article-type (cons type 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-of-type (type)
1786 "Hide text of TYPE in the current buffer."
1788 (let ((b (point-min))
1790 (while (setq b (text-property-any b e 'article-type type))
1791 (add-text-properties b (incf b) gnus-hidden-properties)))))
1793 (defun gnus-article-delete-text-of-type (type)
1794 "Delete text of TYPE in the current buffer."
1796 (let ((b (point-min)))
1797 (if (eq type 'multipart)
1798 ;; Remove MIME buttons associated with multipart/alternative parts.
1801 (while (if (get-text-property (point) 'gnus-part)
1803 (when (setq b (next-single-property-change (point)
1808 (skip-chars-forward "\n")
1809 (when (eq (get-text-property b 'article-type) 'multipart)
1810 (delete-region b (point)))))
1811 (while (setq b (text-property-any b (point-max) 'article-type type))
1813 b (or (text-property-not-all b (point-max) 'article-type type)
1816 (defun gnus-article-delete-invisible-text ()
1817 "Delete all invisible text in the current buffer."
1819 (let ((b (point-min)))
1820 (while (setq b (text-property-any b (point-max) 'invisible t))
1822 b (or (text-property-not-all b (point-max) 'invisible t)
1825 (defun gnus-article-text-type-exists-p (type)
1826 "Say whether any text of type TYPE exists in the buffer."
1827 (text-property-any (point-min) (point-max) 'article-type type))
1829 (defsubst gnus-article-header-rank ()
1830 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1831 (let ((list gnus-sorted-header-list)
1834 (if (looking-at (car list))
1836 (setq list (cdr list))
1840 (defun article-hide-headers (&optional arg delete)
1841 "Hide unwanted headers and possibly sort them as well."
1843 ;; This function might be inhibited.
1844 (unless gnus-inhibit-hiding
1845 (let ((inhibit-read-only t)
1846 (case-fold-search t)
1847 (max (1+ (length gnus-sorted-header-list)))
1848 (inhibit-point-motion-hooks t)
1849 (cur (current-buffer))
1850 ignored visible beg)
1852 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1853 ;; group parameters, so we should go to the summary buffer.
1856 (progn (set-buffer gnus-summary-buffer) t)
1858 (setq ignored (when (not gnus-visible-headers)
1859 (cond ((stringp gnus-ignored-headers)
1860 gnus-ignored-headers)
1861 ((listp gnus-ignored-headers)
1862 (mapconcat 'identity
1863 gnus-ignored-headers
1865 visible (cond ((stringp gnus-visible-headers)
1866 gnus-visible-headers)
1867 ((and gnus-visible-headers
1868 (listp gnus-visible-headers))
1869 (mapconcat 'identity
1870 gnus-visible-headers
1874 ;; First we narrow to just the headers.
1875 (article-narrow-to-head)
1876 ;; Hide any "From " lines at the beginning of (mail) articles.
1877 (while (looking-at "From ")
1880 (delete-region (point-min) (point)))
1881 ;; Then treat the rest of the header lines.
1882 ;; Then we use the two regular expressions
1883 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1884 ;; select which header lines is to remain visible in the
1886 (while (re-search-forward "^[^ \t:]*:" nil t)
1888 ;; Mark the rank of the header.
1890 (point) (1+ (point)) 'message-rank
1891 (if (or (and visible (looking-at visible))
1893 (not (looking-at ignored))))
1894 (gnus-article-header-rank)
1897 (message-sort-headers-1)
1898 (when (setq beg (text-property-any
1899 (point-min) (point-max) 'message-rank (+ 2 max)))
1900 ;; We delete the unwanted headers.
1901 (gnus-add-wash-type 'headers)
1902 (add-text-properties (point-min) (+ 5 (point-min))
1903 '(article-type headers dummy-invisible t))
1904 (delete-region beg (point-max))))))))
1906 (defun article-hide-boring-headers (&optional arg)
1907 "Toggle hiding of headers that aren't very interesting.
1908 If given a negative prefix, always show; if given a positive prefix,
1910 (interactive (gnus-article-hidden-arg))
1911 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1912 (not gnus-show-all-headers))
1915 (let ((inhibit-read-only t)
1916 (inhibit-point-motion-hooks t))
1917 (article-narrow-to-head)
1918 (dolist (elem gnus-boring-article-headers)
1919 (goto-char (point-min))
1921 ;; Hide empty headers.
1923 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1925 (gnus-article-hide-text-type
1929 (if (re-search-forward "^[^ \t]" nil t)
1933 ;; Hide boring Newsgroups header.
1934 ((eq elem 'newsgroups)
1935 (when (gnus-string-equal
1936 (gnus-fetch-field "newsgroups")
1937 (gnus-group-real-name
1938 (if (boundp 'gnus-newsgroup-name)
1941 (gnus-article-hide-header "newsgroups")))
1942 ((eq elem 'to-address)
1943 (let ((to (message-fetch-field "to"))
1945 (gnus-parameter-to-address
1946 (if (boundp 'gnus-newsgroup-name)
1947 gnus-newsgroup-name ""))))
1948 (when (and to to-address
1951 ;; only one address in To
1952 (nth 1 (mail-extract-address-components to))
1954 (gnus-article-hide-header "to"))))
1956 (let ((to (message-fetch-field "to"))
1958 (gnus-parameter-to-list
1959 (if (boundp 'gnus-newsgroup-name)
1960 gnus-newsgroup-name ""))))
1961 (when (and to to-list
1964 ;; only one address in To
1965 (nth 1 (mail-extract-address-components to))
1967 (gnus-article-hide-header "to"))))
1969 (let ((cc (message-fetch-field "cc"))
1971 (gnus-parameter-to-list
1972 (if (boundp 'gnus-newsgroup-name)
1973 gnus-newsgroup-name ""))))
1974 (when (and cc to-list
1977 ;; only one address in CC
1978 (nth 1 (mail-extract-address-components cc))
1980 (gnus-article-hide-header "cc"))))
1981 ((eq elem 'followup-to)
1982 (when (gnus-string-equal
1983 (message-fetch-field "followup-to")
1984 (message-fetch-field "newsgroups"))
1985 (gnus-article-hide-header "followup-to")))
1986 ((eq elem 'reply-to)
1987 (if (gnus-group-find-parameter
1988 gnus-newsgroup-name 'broken-reply-to)
1989 (gnus-article-hide-header "reply-to")
1990 (let ((from (message-fetch-field "from"))
1991 (reply-to (message-fetch-field "reply-to")))
1998 (lambda (x) (downcase (cadr x)))
1999 (mail-extract-address-components from t))
2002 (lambda (x) (downcase (cadr x)))
2003 (mail-extract-address-components reply-to t))
2005 (gnus-article-hide-header "reply-to")))))
2007 (let ((date (with-current-buffer gnus-original-article-buffer
2008 ;; If date in `gnus-article-buffer' is localized
2009 ;; (`gnus-treat-date-user-defined'),
2010 ;; `days-between' might fail.
2011 (message-fetch-field "date"))))
2013 (< (days-between (current-time-string) date)
2015 (gnus-article-hide-header "date"))))
2017 (let ((to (message-fetch-field "to"))
2018 (cc (message-fetch-field "cc")))
2019 (when (> (length to) 1024)
2020 (gnus-article-hide-header "to"))
2021 (when (> (length cc) 1024)
2022 (gnus-article-hide-header "cc"))))
2026 (goto-char (point-min))
2027 (while (re-search-forward "^to:" nil t)
2028 (setq to-count (1+ to-count)))
2029 (when (> to-count 1)
2030 (while (> to-count 0)
2031 (goto-char (point-min))
2033 (re-search-forward "^to:" nil nil to-count)
2035 (narrow-to-region (point) (point-max))
2036 (gnus-article-hide-header "to"))
2037 (setq to-count (1- to-count))))
2038 (goto-char (point-min))
2039 (while (re-search-forward "^cc:" nil t)
2040 (setq cc-count (1+ cc-count)))
2041 (when (> cc-count 1)
2042 (while (> cc-count 0)
2043 (goto-char (point-min))
2045 (re-search-forward "^cc:" nil nil cc-count)
2047 (narrow-to-region (point) (point-max))
2048 (gnus-article-hide-header "cc"))
2049 (setq cc-count (1- cc-count)))))))))))))
2051 (defun gnus-article-hide-header (header)
2053 (goto-char (point-min))
2054 (when (re-search-forward (concat "^" header ":") nil t)
2055 (gnus-article-hide-text-type
2059 (if (re-search-forward "^[^ \t]" nil t)
2064 (defvar gnus-article-normalized-header-length 40
2065 "Length of normalized headers.")
2067 (defun article-normalize-headers ()
2068 "Make all header lines 40 characters long."
2070 (let ((inhibit-read-only t)
2074 (article-narrow-to-head)
2077 ((< (setq column (- (point-at-eol) (point)))
2078 gnus-article-normalized-header-length)
2080 (insert (make-string
2081 (- gnus-article-normalized-header-length column)
2083 ((> column gnus-article-normalized-header-length)
2084 (gnus-put-text-property
2086 (forward-char gnus-article-normalized-header-length)
2093 (forward-line 1))))))
2095 (defun article-treat-dumbquotes ()
2096 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2097 Note that this function guesses whether a character is a sm*rtq**t* or
2098 not, so it should only be used interactively.
2100 Sm*rtq**t*s are M****s***'s unilateral extension to the
2101 iso-8859-1 character map in an attempt to provide more quoting
2102 characters. If you see something like \\222 or \\264 where
2103 you're expecting some kind of apostrophe or quotation mark, then
2106 (article-translate-strings gnus-article-dumbquotes-map))
2108 (defvar org-entities)
2110 (defun article-treat-non-ascii ()
2111 "Translate many Unicode characters into their ASCII equivalents."
2113 (require 'org-entities)
2114 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2115 (dolist (elem org-entities)
2116 (when (and (listp elem)
2117 (= (length (nth 6 elem)) 1))
2118 (if (featurep 'xemacs)
2119 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2120 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2122 (when (article-goto-body)
2123 (let ((inhibit-read-only t)
2126 (if (not (setq replace (if (featurep 'xemacs)
2127 (get-char-table (following-char) table)
2128 (aref table (following-char)))))
2131 (setq props (text-properties-at (point)))
2133 (add-text-properties (point) (progn (insert replace) (point))
2135 (insert replace)))))))))
2137 (defun article-translate-characters (from to)
2138 "Translate all characters in the body of the article according to FROM and TO.
2139 FROM is a string of characters to translate from; to is a string of
2140 characters to translate to."
2142 (when (article-goto-body)
2143 (let ((inhibit-read-only t)
2144 (x (make-string 225 ?x))
2146 (while (< (incf i) (length x))
2149 (while (< i (length from))
2150 (aset x (aref from i) (aref to i))
2152 (translate-region (point) (point-max) x)))))
2154 (defun article-translate-strings (map)
2155 "Translate all string in the body of the article according to MAP.
2156 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2158 (when (article-goto-body)
2159 (let ((inhibit-read-only t))
2161 (let ((from (car elem))
2165 (while (search-forward from nil t)
2168 (if (eq (following-char) from)
2172 (forward-char 1)))))))))))
2174 (defun article-treat-overstrike ()
2175 "Translate overstrikes into bold text."
2178 (when (article-goto-body)
2179 (let ((inhibit-read-only t))
2180 (while (search-forward "\b" nil t)
2181 (let ((next (char-after))
2182 (previous (char-after (- (point) 2))))
2183 ;; We do the boldification/underlining by hiding the
2184 ;; overstrikes and putting the proper text property
2188 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2189 (put-text-property (point) (1+ (point)) 'face 'bold))
2191 (gnus-article-hide-text-type
2192 (1- (point)) (1+ (point)) 'overstrike)
2194 (- (point) 2) (1- (point)) 'face 'underline))
2196 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2198 (point) (1+ (point)) 'face 'underline)))))))))
2200 (defun article-treat-ansi-sequences ()
2201 "Translate ANSI SGR control sequences into overlays or extents."
2204 (when (article-goto-body)
2205 (let ((inhibit-read-only t))
2206 (ansi-color-apply-on-region (point) (point-max))))))
2208 (defun gnus-article-treat-unfold-headers ()
2209 "Unfold folded message headers.
2210 Only the headers that fit into the current window width will be
2213 (gnus-with-article-headers
2217 (mail-header-narrow-to-field)
2218 (let* ((header (buffer-string))
2220 (or (equal gnus-article-unfold-long-headers t)
2221 (and (stringp gnus-article-unfold-long-headers)
2222 (string-match gnus-article-unfold-long-headers header)))))
2225 (goto-char (point-min))
2226 (while (re-search-forward "\n[\t ]" nil t)
2227 (replace-match " " t t)))
2228 (setq length (- (point-max) (point-min) 1))
2229 (when (or unfoldable
2230 (< length (window-width)))
2231 (while (re-search-forward "\n[\t ]" nil t)
2232 (replace-match " " t t))))
2233 (goto-char (point-max)))))))
2235 (defun gnus-article-treat-fold-headers ()
2236 "Fold message headers."
2238 (gnus-with-article-headers
2241 (mail-header-narrow-to-field)
2242 (mail-header-fold-field)
2243 (goto-char (point-max))))))
2245 (defun gnus-treat-smiley ()
2246 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2248 (gnus-with-article-buffer
2249 (if (memq 'smiley gnus-article-wash-types)
2250 (gnus-delete-images 'smiley)
2252 (let ((images (smiley-region (point) (point-max))))
2254 (gnus-add-wash-type 'smiley)
2255 (dolist (image images)
2256 (gnus-add-image 'smiley image)))))))
2258 (defun gnus-article-remove-images ()
2259 "Remove all images from the article buffer."
2261 (gnus-with-article-buffer
2264 (dolist (elem gnus-article-image-alist)
2265 (gnus-delete-images (car elem))))))
2267 (defun gnus-article-show-images ()
2268 "Show any images that are in the HTML-rendered article buffer.
2269 This only works if the article in question is HTML."
2271 (gnus-with-article-buffer
2274 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2276 (destructuring-bind (start end function) region
2277 (funcall function (get-text-property start 'image-url)
2280 (defun gnus-article-treat-fold-newsgroups ()
2281 "Unfold folded message headers.
2282 Only the headers that fit into the current window width will be
2285 (gnus-with-article-headers
2286 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2288 (mail-header-narrow-to-field)
2289 (while (re-search-forward ", *" nil t)
2290 (replace-match ", " t t))
2291 (mail-header-fold-field)
2292 (goto-char (point-max))))))
2294 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2295 "Value of `truncate-lines' in Gnus Article buffer.
2296 Valid values are nil, t, `head', `first', `last', an integer or a
2297 predicate. See Info node `(gnus)Customizing Articles'."
2298 :version "23.1" ;; No Gnus
2299 :group 'gnus-article
2300 ;; :link '(custom-manual "(gnus)Customizing Articles")
2303 (defun gnus-article-toggle-truncate-lines (&optional arg)
2304 "Toggle whether to fold or truncate long lines in article the buffer.
2305 If ARG is non-nil and not a number, toggle
2306 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2307 long lines if and only if arg is positive."
2310 ((and (numberp arg) (> arg 0))
2311 (setq gnus-article-truncate-lines t))
2313 (setq gnus-article-truncate-lines nil))
2315 (setq gnus-article-truncate-lines
2316 (not gnus-article-truncate-lines))))
2317 (gnus-with-article-buffer
2319 ((and (numberp arg) (> arg 0))
2320 (setq truncate-lines nil))
2322 (setq truncate-lines t)))
2323 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2324 ;; `toggle-truncate-lines' needs an argument.
2325 (toggle-truncate-lines)))
2327 (defun gnus-article-treat-body-boundary ()
2328 "Place a boundary line at the end of the headers."
2330 (when (and gnus-body-boundary-delimiter
2331 (> (length gnus-body-boundary-delimiter) 0))
2332 (gnus-with-article-headers
2333 (goto-char (point-max))
2334 (let ((start (point)))
2335 (insert "X-Boundary: ")
2336 (gnus-add-text-properties start (point) '(invisible t intangible t))
2338 (while (>= (window-width) (length str))
2339 (setq str (concat str gnus-body-boundary-delimiter)))
2340 (substring str 0 (window-width)))
2342 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2344 (defun article-fill-long-lines ()
2345 "Fill lines that are wider than the window width."
2348 (let ((inhibit-read-only t)
2349 (width (window-width (get-buffer-window (current-buffer)))))
2352 (let ((adaptive-fill-mode nil)) ;Why? -sm
2355 (when (>= (current-column) (min fill-column width))
2356 (narrow-to-region (min (1+ (point)) (point-max))
2358 (let ((goback (point-marker)))
2359 (fill-paragraph nil)
2360 (goto-char (marker-position goback)))
2362 (forward-line 1)))))))
2364 (defun article-capitalize-sentences ()
2365 "Capitalize the first word in each sentence."
2368 (let ((inhibit-read-only t)
2369 (paragraph-start "^[\n\^L]"))
2373 (forward-sentence)))))
2375 (defun article-remove-cr ()
2376 "Remove trailing CRs and then translate remaining CRs into LFs."
2379 (let ((inhibit-read-only t))
2380 (goto-char (point-min))
2381 (while (re-search-forward "\r+$" nil t)
2382 (replace-match "" t t))
2383 (goto-char (point-min))
2384 (while (search-forward "\r" nil t)
2385 (replace-match "\n" t t)))))
2387 (defun article-remove-trailing-blank-lines ()
2388 "Remove all trailing blank lines from the article."
2391 (let ((inhibit-read-only t))
2392 (goto-char (point-max))
2396 (while (and (not (bobp))
2397 (looking-at "^[ \t]*$")
2398 (not (gnus-annotation-in-region-p
2399 (point) (point-at-eol))))
2404 (defvar gnus-face-properties-alist)
2406 (defun article-display-face (&optional force)
2407 "Display any Face headers in the header."
2408 (interactive (list 'force))
2409 (let ((wash-face-p buffer-read-only))
2410 (gnus-with-article-headers
2411 ;; When displaying parts, this function can be called several times on
2412 ;; the same article, without any intended toggle semantic (as typing `W
2413 ;; D d' would have). So face deletion must occur only when we come from
2414 ;; an interactive command, that is when the *Article* buffer is
2416 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2417 (gnus-delete-images 'face)
2418 (let ((from (message-fetch-field "from"))
2420 (save-current-buffer
2421 (when (and wash-face-p
2422 (gnus-buffer-live-p gnus-original-article-buffer)
2423 (not (re-search-forward "^Face:[\t ]*" nil t)))
2424 (set-buffer gnus-original-article-buffer))
2426 (mail-narrow-to-head)
2428 ;; Check whether this face is censored.
2429 (not (and gnus-article-x-face-too-ugly
2431 (setq from (message-fetch-field "from")))
2432 (string-match gnus-article-x-face-too-ugly
2434 (while (gnus-article-goto-header "Face")
2435 (push (mail-header-field-value) faces)))))
2437 (goto-char (point-min))
2439 (unless (setq from (gnus-article-goto-header "from"))
2442 (insert " [no `from' set]\n"))
2444 (when (setq png (gnus-convert-face-to-png (pop faces)))
2446 (apply 'gnus-create-image png 'png t
2447 (cdr (assq 'png gnus-face-properties-alist))))
2449 (gnus-add-wash-type 'face)
2450 (gnus-add-image 'face image)
2451 (gnus-put-image image nil 'face))))))))))
2453 (defun article-display-x-face (&optional force)
2454 "Look for an X-Face header and display it if present."
2455 (interactive (list 'force))
2456 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2457 (gnus-with-article-headers
2458 ;; Delete the old process, if any.
2459 (when (process-status "article-x-face")
2460 (delete-process "article-x-face"))
2461 ;; See the comment in `article-display-face'.
2462 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2463 ;; We have already displayed X-Faces, so we remove them
2465 (gnus-delete-images 'xface)
2467 (let ((from (message-fetch-field "from"))
2469 (save-current-buffer
2470 (when (and wash-face-p
2471 (gnus-buffer-live-p gnus-original-article-buffer)
2472 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2473 ;; If type `W f', use gnus-original-article-buffer,
2474 ;; otherwise use the current buffer because displaying
2475 ;; RFC822 parts calls this function too.
2476 (set-buffer gnus-original-article-buffer))
2478 (mail-narrow-to-head)
2479 (and gnus-article-x-face-command
2481 ;; Check whether this face is censored.
2482 (not (and gnus-article-x-face-too-ugly
2484 (setq from (message-fetch-field "from")))
2485 (string-match gnus-article-x-face-too-ugly
2487 (while (gnus-article-goto-header "X-Face")
2488 (push (mail-header-field-value) x-faces)))))
2490 ;; We display the face.
2491 (cond ((functionp gnus-article-x-face-command)
2492 ;; The command is a lisp function, so we call it.
2493 (mapc gnus-article-x-face-command x-faces))
2494 ((stringp gnus-article-x-face-command)
2495 ;; The command is a string, so we interpret the command
2496 ;; as a, well, command, and fork it off.
2497 (let ((process-connection-type nil))
2498 (gnus-set-process-query-on-exit-flag
2500 "article-x-face" nil shell-file-name
2501 shell-command-switch gnus-article-x-face-command)
2503 ;; Sending multiple EOFs to xv doesn't work,
2504 ;; so we only do a single external face.
2506 (insert (car x-faces))
2507 (process-send-region "article-x-face"
2508 (point-min) (point-max)))
2509 (process-send-eof "article-x-face")))
2511 (error "`%s' set to `%s' is not a function"
2512 gnus-article-x-face-command
2513 'gnus-article-x-face-command)))))))))
2515 (defun article-decode-mime-words ()
2516 "Decode all MIME-encoded words in the article."
2518 (gnus-with-article-buffer
2519 (let ((inhibit-point-motion-hooks t)
2520 (mail-parse-charset gnus-newsgroup-charset)
2521 (mail-parse-ignored-charsets
2522 (with-current-buffer gnus-summary-buffer
2523 gnus-newsgroup-ignored-charsets)))
2524 (mail-decode-encoded-word-region (point-min) (point-max)))))
2526 (defun article-decode-charset (&optional prompt)
2527 "Decode charset-encoded text in the article.
2528 If PROMPT (the prefix), prompt for a coding system to use."
2530 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2531 (inhibit-read-only t)
2532 (mail-parse-charset gnus-newsgroup-charset)
2533 (mail-parse-ignored-charsets
2534 (save-excursion (condition-case nil
2535 (set-buffer gnus-summary-buffer)
2537 gnus-newsgroup-ignored-charsets))
2538 ct cte ctl charset format)
2541 (article-narrow-to-head)
2542 (setq ct (message-fetch-field "Content-Type" t)
2543 cte (message-fetch-field "Content-Transfer-Encoding" t)
2544 ctl (and ct (mail-header-parse-content-type ct))
2547 (mm-read-coding-system "Charset to decode: "))
2549 (mail-content-type-get ctl 'charset)))
2550 format (and ctl (mail-content-type-get ctl 'format)))
2552 (setq cte (mail-header-strip cte)))
2553 (if (and ctl (not (string-match "/" (car ctl))))
2555 (goto-char (point-max)))
2558 (narrow-to-region (point) (point-max))
2559 (when (and (eq mail-parse-charset 'gnus-decoded)
2560 (eq (mm-body-7-or-8) '8bit))
2561 ;; The text code could have been decoded.
2562 (setq charset mail-parse-charset))
2563 (when (and (or (not ctl)
2564 (equal (car ctl) "text/plain"))
2565 (not format)) ;; article with format will decode later.
2567 charset (and cte (intern (downcase
2568 (gnus-strip-whitespace cte))))
2571 (defun article-decode-encoded-words ()
2572 "Remove encoded-word encoding from headers."
2573 (let ((inhibit-point-motion-hooks t)
2574 (mail-parse-charset gnus-newsgroup-charset)
2575 (mail-parse-ignored-charsets
2576 (save-excursion (condition-case nil
2577 (set-buffer gnus-summary-buffer)
2579 gnus-newsgroup-ignored-charsets))
2580 (inhibit-read-only t)
2582 (goto-char (point-min))
2583 (when (search-forward "\n\n" nil 'move)
2590 (memq (char-after) '(?\t ? )))))
2591 (setq start (point))
2593 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2594 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2595 (funcall gnus-decode-address-function start end)
2596 (funcall gnus-decode-header-function start end))
2597 (goto-char (setq end start)))))
2599 (defun article-decode-group-name ()
2600 "Decode group names in Newsgroups, Followup-To and Xref headers."
2601 (let ((inhibit-point-motion-hooks t)
2602 (inhibit-read-only t)
2603 (method (gnus-find-method-for-group gnus-newsgroup-name))
2605 (when (and (or gnus-group-name-charset-method-alist
2606 gnus-group-name-charset-group-alist)
2607 (gnus-buffer-live-p gnus-original-article-buffer))
2609 (article-narrow-to-head)
2610 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2611 (with-current-buffer gnus-original-article-buffer
2612 (goto-char (point-min)))
2613 (setq regexp (concat "^" header
2614 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2615 (while (re-search-forward regexp nil t)
2616 (replace-match (save-match-data
2617 (gnus-decode-newsgroups
2618 ;; XXX how to use data in article buffer?
2619 (with-current-buffer gnus-original-article-buffer
2620 (re-search-forward regexp nil t)
2622 gnus-newsgroup-name method))
2624 (goto-char (point-min)))))))
2626 (autoload 'idna-to-unicode "idna")
2628 (defun article-decode-idna-rhs ()
2629 "Decode IDNA strings in RHS in various headers in current buffer.
2630 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2631 Mail-Reply-To: and Mail-Followup-To:."
2634 (let ((inhibit-point-motion-hooks t)
2635 (inhibit-read-only t))
2636 (article-narrow-to-head)
2637 (goto-char (point-min))
2638 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2640 (when (save-match-data
2641 (and (setq ace (match-string 1))
2643 (and (re-search-backward "^[^ \t]" nil t)
2644 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2645 (setq unicode (idna-to-unicode ace))))
2646 (unless (string= ace unicode)
2647 (replace-match unicode nil nil nil 1)))))))))
2649 (defun article-de-quoted-unreadable (&optional force read-charset)
2650 "Translate a quoted-printable-encoded article.
2651 If FORCE, decode the article whether it is marked as quoted-printable
2653 If READ-CHARSET, ask for a coding system."
2654 (interactive (list 'force current-prefix-arg))
2656 (let ((inhibit-read-only t) type charset)
2657 (if (gnus-buffer-live-p gnus-original-article-buffer)
2658 (with-current-buffer gnus-original-article-buffer
2660 (gnus-fetch-field "content-transfer-encoding"))
2661 (let* ((ct (gnus-fetch-field "content-type"))
2662 (ctl (and ct (mail-header-parse-content-type ct))))
2663 (setq charset (and ctl
2664 (mail-content-type-get ctl 'charset)))
2665 (if (stringp charset)
2666 (setq charset (intern (downcase charset)))))))
2668 (setq charset (mm-read-coding-system "Charset: " charset)))
2670 (setq charset gnus-newsgroup-charset))
2672 (and type (let ((case-fold-search t))
2673 (string-match "quoted-printable" type))))
2675 (quoted-printable-decode-region
2676 (point) (point-max) (mm-charset-to-coding-system charset))))))
2678 (defun article-de-base64-unreadable (&optional force read-charset)
2679 "Translate a base64 article.
2680 If FORCE, decode the article whether it is marked as base64 not.
2681 If READ-CHARSET, ask for a coding system."
2682 (interactive (list 'force current-prefix-arg))
2684 (let ((inhibit-read-only t) type charset)
2685 (if (gnus-buffer-live-p gnus-original-article-buffer)
2686 (with-current-buffer gnus-original-article-buffer
2688 (gnus-fetch-field "content-transfer-encoding"))
2689 (let* ((ct (gnus-fetch-field "content-type"))
2690 (ctl (and ct (mail-header-parse-content-type ct))))
2691 (setq charset (and ctl
2692 (mail-content-type-get ctl 'charset)))
2693 (if (stringp charset)
2694 (setq charset (intern (downcase charset)))))))
2696 (setq charset (mm-read-coding-system "Charset: " charset)))
2698 (setq charset gnus-newsgroup-charset))
2700 (and type (let ((case-fold-search t))
2701 (string-match "base64" type))))
2704 (narrow-to-region (point) (point-max))
2705 (base64-decode-region (point-min) (point-max))
2706 (mm-decode-coding-region
2707 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2712 (defun article-decode-HZ ()
2713 "Translate a HZ-encoded article."
2717 (let ((inhibit-read-only t))
2718 (rfc1843-decode-region (point-min) (point-max)))))
2720 (defun article-unsplit-urls ()
2721 "Remove the newlines that some other mailers insert into URLs."
2724 (let ((inhibit-read-only t))
2725 (goto-char (point-min))
2726 (while (re-search-forward
2727 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2728 (replace-match "\\1\\3" t)))
2729 (when (interactive-p)
2730 (gnus-treat-article nil))))
2732 (defun article-wash-html ()
2733 "Format an HTML article."
2736 (buffer-read-only nil))
2737 (when (gnus-buffer-live-p gnus-original-article-buffer)
2738 (setq handles (mm-dissect-buffer t t)))
2740 (delete-region (point) (point-max))
2741 (mm-inline-text-html handles)))
2743 (defvar gnus-article-browse-html-temp-list nil
2744 "List of temporary files created by `gnus-article-browse-html-parts'.
2745 Internal variable.")
2747 (defcustom gnus-article-browse-delete-temp 'ask
2748 "What to do with temporary files from `gnus-article-browse-html-parts'.
2749 If nil, don't delete temporary files. If it is t, delete them on
2750 exit from the summary buffer. If it is the symbol `file', query
2751 on each file, if it is `ask' ask once when exiting from the
2753 :group 'gnus-article
2754 :version "23.1" ;; No Gnus
2755 :type '(choice (const :tag "Don't delete" nil)
2756 (const :tag "Don't ask" t)
2757 (const :tag "Ask" ask)
2758 (const :tag "Ask for each file" file)))
2760 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2762 (defun gnus-article-browse-delete-temp-files (&optional how)
2763 "Delete temp-files created by `gnus-article-browse-html-parts'."
2764 (when (and gnus-article-browse-html-temp-list
2766 (or how (setq how gnus-article-browse-delete-temp))
2768 (let ((files (length gnus-article-browse-html-temp-list)))
2769 (gnus-y-or-n-p (format
2770 "Delete all %s temporary HTML file%s? "
2772 (if (> files 1) "s" ""))))
2774 (dolist (file gnus-article-browse-html-temp-list)
2775 (cond ((file-directory-p file)
2776 (when (or (not (eq how 'file))
2779 "Delete temporary HTML file(s) in directory `%s'? "
2780 (file-name-as-directory file))))
2781 (gnus-delete-directory file)))
2782 ((file-exists-p file)
2783 (when (or (not (eq how 'file))
2785 (format "Delete temporary HTML file `%s'? " file)))
2786 (delete-file file)))))
2787 ;; Also remove file from the list when not deleted or if file doesn't
2789 (setq gnus-article-browse-html-temp-list nil))
2790 gnus-article-browse-html-temp-list)
2792 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2793 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2798 (dolist (handle handles)
2800 ((not (listp handle)))
2801 ((equal (mm-handle-media-supertype handle) "multipart")
2802 (when (setq file (gnus-article-browse-html-save-cid-content
2803 cid handle directory))
2804 (throw 'found file)))
2805 ((equal (concat "<" cid ">") (mm-handle-id handle))
2808 (or (mail-content-type-get
2809 (mm-handle-disposition handle) 'filename)
2810 (mail-content-type-get
2811 (setq type (mm-handle-type handle)) 'name)
2813 (make-temp-name "cid")
2814 (car (rassoc (car type) mailcap-mime-extensions))))
2816 (mm-save-part-to-file handle file)
2817 (throw 'found file))))))))
2819 (defun gnus-article-browse-html-parts (list &optional header)
2820 "View all \"text/html\" parts from LIST.
2821 Recurse into multiparts. The optional HEADER that should be a decoded
2822 message header will be added to the bodies of the \"text/html\" parts."
2823 ;; Internal function used by `gnus-article-browse-html-article'.
2824 (let (type file charset content cid-dir tmp-file showed)
2825 ;; Find and show the html-parts.
2826 (dolist (handle list)
2827 ;; If HTML, show it:
2828 (cond ((not (listp handle)))
2829 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2830 (and (equal (car type) "message/external-body")
2832 (setq file (or (mail-content-type-get type 'name)
2833 (mail-content-type-get
2834 (mm-handle-disposition handle)
2836 (or (mm-handle-cache handle)
2837 (condition-case code
2838 (progn (mm-extern-cache-contents handle) t)
2840 (gnus-message 3 "%s" (error-message-string code))
2841 (when (>= gnus-verbose 3) (sit-for 2))
2844 (setq handle (mm-handle-cache handle)
2845 type (mm-handle-type handle))
2846 (equal (car type) "text/html"))))
2847 (setq charset (mail-content-type-get type 'charset)
2848 content (mm-get-part handle))
2850 (if (eq charset 'gnus-decoded)
2851 (mm-enable-multibyte)
2852 (mm-disable-multibyte))
2854 ;; resolve cid contents
2855 (let ((case-fold-search t)
2857 (goto-char (point-min))
2858 (while (re-search-forward "\
2859 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2862 (setq cid-dir (mm-make-temp-file "cid" t))
2863 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2866 (when (setq cid-file
2867 (gnus-article-browse-html-save-cid-content
2869 (with-current-buffer gnus-article-buffer
2870 gnus-article-mime-handles)
2872 (replace-match (concat "file://" cid-file)
2874 (unless content (setq content (buffer-string))))
2875 (when (or charset header (not file))
2876 (setq tmp-file (mm-make-temp-file
2877 ;; Do we need to care for 8.3 filenames?
2878 "mm-" nil ".html")))
2879 ;; Add a meta html tag to specify charset and a header.
2882 (let (title eheader body hcharset coding force-charset)
2884 (mm-enable-multibyte)
2885 (setq case-fold-search t)
2886 (insert header "\n")
2887 (setq title (message-fetch-field "subject"))
2888 (goto-char (point-min))
2889 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2890 (replace-match (cond ((match-beginning 1) "<")
2891 ((match-beginning 2) ">")
2893 (goto-char (point-min))
2895 (goto-char (point-max))
2896 (insert "</pre>\n<hr>\n")
2897 ;; We have to examine charset one by one since
2898 ;; charset specified in parts might be different.
2899 (if (eq charset 'gnus-decoded)
2900 (setq charset 'utf-8
2901 eheader (mm-encode-coding-string (buffer-string)
2904 (mm-encode-coding-string title charset))
2905 body (mm-encode-coding-string content charset)
2907 (setq hcharset (mm-find-mime-charset-region (point-min)
2909 (cond ((= (length hcharset) 1)
2910 (setq hcharset (car hcharset)
2911 coding (mm-charset-to-coding-system
2913 ((> (length hcharset) 1)
2914 (setq hcharset 'utf-8
2920 (mm-charset-to-coding-system charset))
2921 (if (eq coding body)
2922 (setq eheader (mm-encode-coding-string
2923 (buffer-string) coding)
2925 (mm-encode-coding-string
2928 (setq charset 'utf-8
2929 eheader (mm-encode-coding-string
2930 (buffer-string) charset)
2932 (mm-encode-coding-string
2934 body (mm-encode-coding-string
2935 (mm-decode-coding-string
2939 (setq charset hcharset
2940 eheader (mm-encode-coding-string
2941 (buffer-string) coding)
2943 (mm-encode-coding-string
2946 (setq eheader (mm-string-as-unibyte (buffer-string))
2949 (mm-disable-multibyte)
2952 (mm-add-meta-html-tag handle charset force-charset))
2954 (goto-char (point-min))
2955 (unless (search-forward "<title>" nil t)
2956 (re-search-forward "<head>\\s-*" nil t)
2957 (insert "<title>" title "</title>\n")))
2958 (goto-char (point-min))
2959 (or (re-search-forward
2960 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2962 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2964 (mm-write-region (point-min) (point-max)
2965 tmp-file nil nil nil 'binary t))))
2967 (mm-with-unibyte-buffer
2968 (insert (if (eq charset 'gnus-decoded)
2969 (mm-encode-coding-string content
2970 (setq charset 'utf-8))
2972 (if (or (mm-add-meta-html-tag handle charset)
2974 (mm-write-region (point-min) (point-max)
2975 tmp-file nil nil nil 'binary t)
2976 (setq tmp-file nil))))
2978 (mm-save-part-to-file handle tmp-file)))
2980 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2981 (add-hook 'gnus-summary-prepare-exit-hook
2982 'gnus-article-browse-delete-temp-files)
2983 (add-hook 'gnus-exit-gnus-hook
2985 (gnus-article-browse-delete-temp-files t)))
2986 ;; FIXME: Warn if there's an <img> tag?
2987 (browse-url-of-file (or tmp-file (expand-file-name file)))
2989 ;; If multipart, recurse
2990 ((equal (mm-handle-media-supertype handle) "multipart")
2991 (when (gnus-article-browse-html-parts handle header)
2993 ((equal (mm-handle-media-type handle) "message/rfc822")
2994 (mm-with-multibyte-buffer
2995 (mm-insert-part handle)
2996 (setq handle (mm-dissect-buffer t t))
2997 (when (and (bufferp (car handle))
2998 (stringp (car (mm-handle-type handle))))
2999 (setq handle (list handle)))
3001 (article-decode-encoded-words)
3002 (let ((gnus-visible-headers
3003 (or (get 'gnus-visible-headers 'standard-value)
3004 gnus-visible-headers)))
3005 (article-hide-headers))
3006 (goto-char (point-min))
3007 (search-forward "\n\n" nil 'move)
3008 (skip-chars-backward "\t\n ")
3009 (setq header (buffer-substring (point-min) (point)))))
3011 (gnus-article-browse-html-parts handle header)
3012 (mm-destroy-parts handle))
3016 (defun gnus-article-browse-html-article (&optional arg)
3017 "View \"text/html\" parts of the current article with a WWW browser.
3018 Inline images embedded in a message using the cid scheme, as they are
3019 generally considered to be safe, will be processed properly.
3020 The message header is added to the beginning of every html part unless
3021 the prefix argument ARG is given.
3023 Warning: Spammers use links to images (using the http scheme) in HTML
3024 articles to verify whether you have read the message. As
3025 `gnus-article-browse-html-article' passes the HTML content to the
3026 browser without eliminating these \"web bugs\" you should only
3027 use it for mails from trusted senders.
3029 If you always want to display HTML parts in the browser, set
3030 `mm-text-html-renderer' to nil.
3032 This command creates temporary files to pass HTML contents including
3033 images if any to the browser, and deletes them when exiting the group
3035 ;; Cf. `mm-w3m-safe-url-regexp'
3038 (gnus-summary-show-article)
3039 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3040 gnus-visible-headers))
3041 ;; As we insert a <hr>, there's no need for the body boundary.
3042 (gnus-treat-body-boundary nil))
3043 (gnus-summary-show-article)))
3044 (with-current-buffer gnus-article-buffer
3045 (let ((header (unless arg
3048 (buffer-substring-no-properties
3049 (goto-char (point-min))
3050 (if (search-forward "\n\n" nil t)
3052 (goto-char (point-max))
3053 (skip-chars-backward "\t\n ")
3056 (set-buffer gnus-original-article-buffer)
3057 (setq parts (mm-dissect-buffer t t))
3058 ;; If singlepart, enforce a list.
3059 (when (and (bufferp (car parts))
3060 (stringp (car (mm-handle-type parts))))
3061 (setq parts (list parts)))
3063 (unless (gnus-article-browse-html-parts parts header)
3064 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3065 (mm-destroy-parts parts)
3067 (gnus-summary-show-article)))))
3069 (defun article-hide-list-identifiers ()
3070 "Remove list identifies from the Subject header.
3071 The `gnus-list-identifiers' variable specifies what to do."
3073 (let ((inhibit-point-motion-hooks t)
3074 (regexp (if (consp gnus-list-identifiers)
3075 (mapconcat 'identity gnus-list-identifiers " *\\|")
3076 gnus-list-identifiers))
3077 (inhibit-read-only t))
3081 (article-narrow-to-head)
3082 (goto-char (point-min))
3083 (while (re-search-forward
3084 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3086 (delete-region (match-beginning 2) (match-end 0))
3087 (beginning-of-line))
3088 (when (re-search-forward
3089 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3090 (delete-region (match-beginning 1) (match-end 1))))))))
3092 (defun article-hide-pem (&optional arg)
3093 "Toggle hiding of any PEM headers and signatures in the current article.
3094 If given a negative prefix, always show; if given a positive prefix,
3096 (interactive (gnus-article-hidden-arg))
3097 (unless (gnus-article-check-hidden-text 'pem arg)
3099 (let ((inhibit-read-only t) end)
3100 (goto-char (point-min))
3101 ;; Hide the horrendously ugly "header".
3102 (when (and (search-forward
3103 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3105 (setq end (1+ (match-beginning 0))))
3106 (gnus-add-wash-type 'pem)
3107 (gnus-article-hide-text-type
3109 (if (search-forward "\n\n" nil t)
3113 ;; Hide the trailer as well
3114 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3116 (gnus-article-hide-text-type
3117 (match-beginning 0) (match-end 0) 'pem)))))))
3119 (defun article-strip-banner ()
3120 "Strip the banners specified by the `banner' group parameter and by
3121 `gnus-article-address-banner-alist'."
3125 (let ((inhibit-point-motion-hooks t))
3126 (when (gnus-parameter-banner gnus-newsgroup-name)
3127 (article-really-strip-banner
3128 (gnus-parameter-banner gnus-newsgroup-name)))
3129 (when gnus-article-address-banner-alist
3130 ;; Note that the From header is decoded here, so it is
3131 ;; required that the *-extract-address-components function
3132 ;; supports non-ASCII text.
3133 (let ((from (save-restriction
3135 (article-narrow-to-head)
3136 (mail-fetch-field "from"))))
3139 (cadr (funcall gnus-extract-address-components
3142 (dolist (pair gnus-article-address-banner-alist)
3143 (when (string-match (car pair) from)
3145 (article-really-strip-banner (cdr pair)))))))))))))
3147 (defun article-really-strip-banner (banner)
3148 "Strip the banner specified by the argument."
3151 (let ((inhibit-point-motion-hooks t)
3152 (gnus-signature-limit nil)
3153 (inhibit-read-only t))
3156 ((eq banner 'signature)
3157 (when (gnus-article-narrow-to-signature)
3160 (delete-region (point) (point-max))))
3162 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3163 (while (re-search-forward banner nil t)
3164 (delete-region (match-beginning 0) (match-end 0)))))
3166 (while (re-search-forward banner nil t)
3167 (delete-region (match-beginning 0) (match-end 0)))))))))
3169 (defun article-babel ()
3170 "Translate article using an online translation service."
3173 (gnus-with-article-buffer
3174 (when (article-goto-body)
3175 (let* ((start (point))
3177 (orig (buffer-substring start end))
3178 (trans (babel-as-string orig)))
3180 (narrow-to-region start end)
3181 (delete-region start end)
3184 (defun article-hide-signature (&optional arg)
3185 "Hide the signature in the current article.
3186 If given a negative prefix, always show; if given a positive prefix,
3188 (interactive (gnus-article-hidden-arg))
3189 (unless (gnus-article-check-hidden-text 'signature arg)
3192 (let ((inhibit-read-only t))
3193 (when (gnus-article-narrow-to-signature)
3194 (gnus-article-hide-text-type
3195 (point-min) (point-max) 'signature))))))
3196 (gnus-set-mode-line 'article))
3198 (defun article-strip-headers-in-body ()
3199 "Strip offensive headers from bodies."
3203 (let ((case-fold-search t))
3204 (when (looking-at "x-no-archive:")
3205 (gnus-delete-line)))))
3207 (defun article-strip-leading-blank-lines ()
3208 "Remove all blank lines from the beginning of the article."
3211 (let ((inhibit-point-motion-hooks t)
3212 (inhibit-read-only t))
3213 (when (article-goto-body)
3214 (while (and (not (eobp))
3215 (looking-at "[ \t]*$"))
3216 (gnus-delete-line))))))
3218 (defun article-narrow-to-head ()
3219 "Narrow the buffer to the head of the message.
3220 Point is left at the beginning of the narrowed-to region."
3222 (goto-char (point-min))
3223 (if (search-forward "\n\n" nil 1)
3226 (goto-char (point-min)))
3228 (defun article-goto-body ()
3229 "Place point at the start of the body."
3230 (goto-char (point-min))
3232 ;; This variable is only bound when dealing with separate
3234 (article-goto-body-goes-to-point-min-p
3236 ((search-forward "\n\n" nil t)
3239 (goto-char (point-max))
3242 (defun article-strip-multiple-blank-lines ()
3243 "Replace consecutive blank lines with one empty line."
3246 (let ((inhibit-point-motion-hooks t)
3247 (inhibit-read-only t))
3248 ;; First make all blank lines empty.
3250 (while (re-search-forward "^[ \t]+$" nil t)
3251 (unless (gnus-annotation-in-region-p
3252 (match-beginning 0) (match-end 0))
3253 (replace-match "" nil t)))
3254 ;; Then replace multiple empty lines with a single empty line.
3256 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3257 (unless (gnus-annotation-in-region-p
3258 (match-beginning 0) (match-end 0))
3259 (delete-region (match-beginning 1) (match-end 1)))))))
3261 (defun article-strip-leading-space ()
3262 "Remove all white space from the beginning of the lines in the article."
3265 (let ((inhibit-point-motion-hooks t)
3266 (inhibit-read-only t))
3268 (while (re-search-forward "^[ \t]+" nil t)
3269 (replace-match "" t t)))))
3271 (defun article-strip-trailing-space ()
3272 "Remove all white space from the end of the lines in the article."
3275 (let ((inhibit-point-motion-hooks t)
3276 (inhibit-read-only t))
3278 (while (re-search-forward "[ \t]+$" nil t)
3279 (replace-match "" t t)))))
3281 (defun article-strip-blank-lines ()
3282 "Strip leading, trailing and multiple blank lines."
3284 (article-strip-leading-blank-lines)
3285 (article-remove-trailing-blank-lines)
3286 (article-strip-multiple-blank-lines))
3288 (defun article-strip-all-blank-lines ()
3289 "Strip all blank lines."
3292 (let ((inhibit-point-motion-hooks t)
3293 (inhibit-read-only t))
3295 (while (re-search-forward "^[ \t]*\n" nil t)
3296 (replace-match "" t t)))))
3298 (defun gnus-article-narrow-to-signature ()
3299 "Narrow to the signature; return t if a signature is found, else nil."
3300 (let ((inhibit-point-motion-hooks t))
3301 (when (gnus-article-search-signature)
3303 ;; Check whether we have some limits to what we consider
3304 ;; to be a signature.
3305 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3306 (list gnus-signature-limit)))
3308 (while (setq limit (pop limits))
3309 (if (or (and (integerp limit)
3310 (< (- (point-max) (point)) limit))
3312 (< (count-lines (point) (point-max)) limit))
3313 (and (functionp limit)
3315 (and (stringp limit)
3316 (not (re-search-forward limit nil t))))
3317 () ; This limit did not succeed.
3321 (narrow-to-region (point) (point-max))
3324 (defun gnus-article-search-signature ()
3325 "Search the current buffer for the signature separator.
3326 Put point at the beginning of the signature separator."
3327 (let ((cur (point)))
3328 (goto-char (point-max))
3329 (if (if (stringp gnus-signature-separator)
3330 (re-search-backward gnus-signature-separator nil t)
3331 (let ((seps gnus-signature-separator))
3333 (not (re-search-backward (car seps) nil t)))
3340 (defun gnus-article-hidden-arg ()
3341 "Return the current prefix arg as a number, or 0 if no prefix."
3342 (list (if current-prefix-arg
3343 (prefix-numeric-value current-prefix-arg)
3346 (defun gnus-article-check-hidden-text (type arg)
3347 "Return nil if hiding is necessary.
3348 Arg can be nil or a number. nil and positive means hide, negative
3349 means show, 0 means toggle."
3352 (let ((hide (gnus-article-hidden-text-p type)))
3358 (gnus-article-show-hidden-text type)
3361 (if (eq hide 'hidden)
3363 (gnus-article-show-hidden-text type)
3367 (defun gnus-article-hidden-text-p (type)
3368 "Say whether the current buffer contains hidden text of type TYPE."
3369 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3371 (not (get-text-property pos 'invisible))
3372 (not (get-text-property pos 'dummy-invisible)))
3374 (text-property-any (1+ pos) (point-max) 'article-type type)))
3379 (defun gnus-article-show-hidden-text (type &optional dummy)
3380 "Show all hidden text of type TYPE.
3381 Originally it is hide instead of DUMMY."
3382 (let ((inhibit-read-only t)
3383 (inhibit-point-motion-hooks t))
3384 (gnus-remove-text-properties-when
3386 (point-min) (point-max)
3387 (cons 'article-type (cons type
3388 gnus-hidden-properties)))
3389 (gnus-delete-wash-type type)))
3391 (defconst article-time-units
3392 `((year . ,(* 365.25 24 60 60))
3393 (week . ,(* 7 24 60 60))
3394 (day . ,(* 24 60 60))
3398 "Mapping from time units to seconds.")
3400 (defun gnus-article-forward-header ()
3401 "Move point to the start of the next header.
3402 If the current header is a continuation header, this can be several
3407 (if (looking-at "[ \t]+[^ \t]")
3411 (defun article-treat-date ()
3412 (article-date-ut gnus-article-date-headers t))
3414 (defun article-date-ut (&optional type highlight date-position)
3415 "Convert DATE date to TYPE in the current article.
3416 The default type is `ut'. See `gnus-article-date-headers' for
3418 (interactive (list 'ut t))
3419 (let* ((case-fold-search t)
3420 (inhibit-read-only t)
3421 (inhibit-point-motion-hooks t)
3423 pos date bface eface)
3426 (goto-char (point-min))
3427 (when (re-search-forward "^Date:" nil t)
3428 (setq bface (get-text-property (point-at-bol) 'face)
3429 eface (get-text-property (1- (point-at-eol)) 'face)))
3430 (goto-char (point-min))
3431 ;; Delete any old Date headers.
3434 (goto-char date-position)
3435 (setq date (get-text-property (point) 'original-date))
3436 (delete-region (point)
3438 (gnus-article-forward-header)
3440 (article-transform-date date type bface eface))
3441 (while (re-search-forward "^Date:" nil t)
3442 (setq date (get-text-property (match-beginning 0) 'original-date))
3443 (delete-region (point-at-bol) (progn
3444 (gnus-article-forward-header)
3447 (article-transform-date date type bface eface)))))))
3449 (defun article-transform-date (date type bface eface)
3450 (dolist (this-type (cond
3457 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3460 (put-text-property (point) (1+ (point))
3461 'original-date date)
3462 (put-text-property (point) (1+ (point))
3463 'gnus-date-type this-type)
3465 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3466 (put-text-property (match-beginning 1) (1+ (match-end 1))
3468 (put-text-property (match-beginning 2) (match-end 2)
3472 (defun article-make-date-line (date type)
3473 "Return a DATE line of TYPE."
3474 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3476 (error "Unknown conversion type: %s" type))
3478 (let ((time (date-to-time date)))
3480 ;; Convert to the local timezone.
3482 (concat "Date: " (message-make-date time)))
3483 ;; Convert to Universal Time.
3488 (let* ((e (parse-time-string date))
3489 (tm (apply 'encode-time e))
3491 (ls (- (cadr tm) (car (current-time-zone time)))))
3492 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3493 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3497 ;; Get the original date from the article.
3498 ((eq type 'original)
3499 (concat "Date: " (if (string-match "\n+$" date)
3500 (substring date 0 (match-beginning 0))
3502 ;; Let the user define the format.
3503 ((eq type 'user-defined)
3504 (let ((format (or (condition-case nil
3505 (with-current-buffer gnus-summary-buffer
3506 gnus-article-time-format)
3508 gnus-article-time-format)))
3509 (if (functionp format)
3510 (funcall format time)
3511 (concat "Date: " (format-time-string format time)))))
3514 (let ((tz (car (current-time-zone time))))
3517 (format-time-string "%Y%m%dT%H%M%S" time)
3518 (format "%s%02d%02d"
3519 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3520 (/ (% (abs tz) 3600) 60)))))
3521 ;; Do a lapsed format.
3523 (concat "Date: " (article-lapsed-string time)))
3524 ;; A combined date/lapsed format.
3525 ((eq type 'combined-lapsed)
3526 (let ((date-string (article-make-date-line date 'original))
3531 (concat " (" (article-lapsed-string time segments) ")"))
3532 (> (+ (length date-string)
3533 (length lapsed-string))
3536 (setq segments (1- segments)))
3538 (concat date-string lapsed-string)
3540 ;; Display the date in proper English
3542 (let ((dtime (decode-time time)))
3545 (number-to-string (nth 3 dtime))
3546 (let ((digit (% (nth 3 dtime) 10)))
3548 ((memq (nth 3 dtime) '(11 12 13)) "th")
3554 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3556 (number-to-string (nth 5 dtime))
3558 (format "%02d" (nth 2 dtime))
3560 (format "%02d" (nth 1 dtime)))))))
3562 (format "Date: %s (from Gnus)" date))))
3564 (defun article-lapsed-string (time &optional max-segments)
3565 ;; If the date is seriously mangled, the timezone functions are
3566 ;; liable to bug out, so we ignore all errors.
3567 (let* ((now (current-time))
3568 (real-time (subtract-time now time))
3569 (real-sec (and real-time
3570 (+ (* (float (car real-time)) 65536)
3572 (sec (and real-time (abs real-sec)))
3575 (unless max-segments
3576 (setq max-segments (length article-time-units)))
3584 ;; This is a bit convoluted, but basically we go
3585 ;; through the time units for years, weeks, etc,
3586 ;; and divide things to see whether that results
3587 ;; in positive answers.
3590 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3591 (>= segments max-segments))
3592 ;; The (remaining) seconds are too few to
3593 ;; be divided into this time unit.
3595 ;; It's big enough, so we output it.
3596 (setq sec (- sec (* num (cdr unit))))
3598 (concat (if prev ", " "") (int-to-string
3600 " " (symbol-name (car unit))
3601 (if (> num 1) "s" ""))
3603 segments (1+ segments)))))
3604 article-time-units "")
3605 ;; If dates are odd, then it might appear like the
3606 ;; article was sent in the future.
3609 " in the future"))))))
3611 (defun article-date-local (&optional highlight)
3612 "Convert the current article date to the local timezone."
3613 (interactive (list t))
3614 (article-date-ut 'local highlight))
3616 (defun article-date-english (&optional highlight)
3617 "Convert the current article date to something that is proper English."
3618 (interactive (list t))
3619 (article-date-ut 'english highlight))
3621 (defun article-date-original (&optional highlight)
3622 "Convert the current article date to what it was originally.
3623 This is only useful if you have used some other date conversion
3624 function and want to see what the date was before converting."
3625 (interactive (list t))
3626 (article-date-ut 'original highlight))
3628 (defun article-date-lapsed (&optional highlight)
3629 "Convert the current article date to time lapsed since it was sent."
3630 (interactive (list t))
3631 (article-date-ut 'lapsed highlight))
3633 (defun article-date-combined-lapsed (&optional highlight)
3634 "Convert the current article date to time lapsed since it was sent."
3635 (interactive (list t))
3636 (article-date-ut 'combined-lapsed highlight))
3638 (defun article-update-date-lapsed ()
3639 "Function to be run from a timer to update the lapsed time line."
3641 (let ((buffer (current-buffer)))
3645 (set-buffer (window-buffer w))
3646 (when (eq major-mode 'gnus-article-mode)
3647 (let ((old-line (count-lines (point-min) (point)))
3648 (old-column (- (point) (line-beginning-position))))
3649 (goto-char (point-min))
3650 (while (re-search-forward "^Date:" nil t)
3651 (let ((type (get-text-property (match-beginning 0) 'gnus-date-type)))
3652 (when (memq type '(lapsed combined-lapsed user-format))
3654 (article-date-ut type t (match-beginning 0)))
3656 (goto-char (point-min))
3657 (when (> old-column 0)
3658 (setq old-line (1- old-line)))
3659 (forward-line old-line)
3661 (when (> (current-column) old-column)
3663 (forward-char old-column)))))
3665 (set-buffer buffer))))
3667 (defun gnus-start-date-timer (&optional n)
3668 "Start a timer to update the Date headers in the article buffers.
3669 The numerical prefix says how frequently (in seconds) the function
3674 (gnus-stop-date-timer)
3675 (setq article-lapsed-timer
3676 (run-at-time 1 n 'article-update-date-lapsed)))
3678 (defun gnus-stop-date-timer ()
3679 "Stop the Date timer."
3681 (when article-lapsed-timer
3682 (nnheader-cancel-timer article-lapsed-timer)
3683 (setq article-lapsed-timer nil)))
3685 (defun article-date-user (&optional highlight)
3686 "Convert the current article date to the user-defined format.
3687 This format is defined by the `gnus-article-time-format' variable."
3688 (interactive (list t))
3689 (article-date-ut 'user highlight))
3691 (defun article-date-iso8601 (&optional highlight)
3692 "Convert the current article date to ISO8601."
3693 (interactive (list t))
3694 (article-date-ut 'iso8601 highlight))
3696 (defmacro gnus-article-save-original-date (&rest forms)
3697 "Save the original date as a text property and evaluate FORMS."
3698 `(let* ((case-fold-search t)
3700 (goto-char (point-min))
3701 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3704 (date (when (and start
3705 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3707 (buffer-substring-no-properties start
3708 (match-beginning 0)))))
3709 (goto-char (point-max))
3710 (skip-chars-backward "\n")
3711 (put-text-property (point-min) (point) 'original-date date)
3713 (goto-char (point-max))
3714 (skip-chars-backward "\n")
3715 (put-text-property (point-min) (point) 'original-date date)))
3717 ;; (defun article-show-all ()
3718 ;; "Show all hidden text in the article buffer."
3721 ;; (let ((inhibit-read-only t))
3722 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3724 (defun article-remove-leading-whitespace ()
3725 "Remove excessive whitespace from all headers."
3729 (let ((inhibit-read-only t))
3730 (article-narrow-to-head)
3731 (goto-char (point-min))
3732 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3733 (delete-region (match-beginning 1) (match-end 1)))))))
3735 (defun article-emphasize (&optional arg)
3736 "Emphasize text according to `gnus-emphasis-alist'."
3737 (interactive (gnus-article-hidden-arg))
3738 (unless (gnus-article-check-hidden-text 'emphasis arg)
3742 (with-current-buffer gnus-summary-buffer
3743 gnus-article-emphasis-alist)
3745 gnus-emphasis-alist))
3746 (inhibit-read-only t)
3747 (props (append '(article-type emphasis)
3748 gnus-hidden-properties))
3749 regexp elem beg invisible visible face)
3752 (while (setq elem (pop alist))
3754 (setq regexp (car elem)
3755 invisible (nth 1 elem)
3756 visible (nth 2 elem)
3758 (while (re-search-forward regexp nil t)
3759 (when (and (match-beginning visible) (match-beginning invisible))
3760 (gnus-article-hide-text
3761 (match-beginning invisible) (match-end invisible) props)
3762 (gnus-article-unhide-text-type
3763 (match-beginning visible) (match-end visible) 'emphasis)
3764 (gnus-put-overlay-excluding-newlines
3765 (match-beginning visible) (match-end visible) 'face face)
3766 (gnus-add-wash-type 'emphasis)
3767 (goto-char (match-end invisible)))))))))
3769 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3770 "Setup newsgroup emphasis alist."
3771 (unless gnus-article-emphasis-alist
3772 (let ((name (and gnus-newsgroup-name
3773 (gnus-group-real-name gnus-newsgroup-name))))
3774 (make-local-variable 'gnus-article-emphasis-alist)
3775 (setq gnus-article-emphasis-alist
3777 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3778 (while (setq elem (pop alist))
3779 (when (and name (string-match (car elem) name))
3781 highlight (copy-sequence (cdr elem)))))
3783 (copy-sequence highlight-words)
3784 (if gnus-newsgroup-name
3785 (copy-sequence (gnus-group-find-parameter
3786 gnus-newsgroup-name 'highlight-words t)))
3787 gnus-emphasis-alist)))))
3789 (defvar gnus-summary-article-menu)
3790 (defvar gnus-summary-post-menu)
3792 ;;; Saving functions.
3794 (defun gnus-article-save (save-buffer file &optional num)
3795 "Save the currently selected article."
3796 (when (or (get gnus-default-article-saver :headers)
3797 (not gnus-save-all-headers))
3798 ;; Remove headers according to `gnus-saved-headers' or the value
3799 ;; of the `:headers' property that the saver function might have.
3800 (let ((gnus-visible-headers
3801 (or (symbol-value (get gnus-default-article-saver :headers))
3802 gnus-saved-headers gnus-visible-headers))
3803 ;; Ignore group parameter. See `article-hide-headers'.
3804 (gnus-summary-buffer nil))
3805 (with-current-buffer save-buffer
3806 (article-hide-headers 1 t))))
3807 (save-window-excursion
3808 (if (not gnus-default-article-saver)
3809 (error "No default saver is defined")
3810 ;; !!! Magic! The saving functions all save
3811 ;; `gnus-save-article-buffer' (or so they think), but we
3812 ;; bind that variable to our save-buffer.
3813 (set-buffer gnus-article-buffer)
3814 (let* ((gnus-save-article-buffer save-buffer)
3817 ((not gnus-prompt-before-saving) 'default)
3818 ((eq gnus-prompt-before-saving 'always) nil)
3820 (gnus-number-of-articles-to-be-saved
3821 (when (eq gnus-prompt-before-saving t)
3823 (set-buffer gnus-article-current-summary)
3824 (funcall gnus-default-article-saver filename)))))
3826 (defun gnus-read-save-file-name (prompt &optional filename
3827 function group headers variable
3830 (funcall function group headers (symbol-value variable)))
3835 ((eq filename 'default)
3841 (when (symbol-value dir-var)
3842 (setq default-name (expand-file-name
3843 (file-name-nondirectory default-name)
3844 (symbol-value dir-var))))
3845 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3848 (if (and gnus-number-of-articles-to-be-saved
3849 (> gnus-number-of-articles-to-be-saved 1))
3850 (format "these %d articles"
3851 gnus-number-of-articles-to-be-saved)
3854 ;; Let the split methods have their say.
3856 ;; No split name was found.
3859 (concat prompt " (default "
3860 (file-name-nondirectory default-name) "): ")
3861 (file-name-directory default-name)
3863 ;; A single group name is returned.
3864 ((stringp split-name)
3866 (funcall function split-name headers
3867 (symbol-value variable)))
3869 (concat prompt " (default "
3870 (file-name-nondirectory default-name) "): ")
3871 (file-name-directory default-name)
3873 ;; A single split name was found
3874 ((= 1 (length split-name))
3875 (let* ((name (expand-file-name
3877 gnus-article-save-directory))
3878 (dir (cond ((file-directory-p name)
3879 (file-name-as-directory name))
3880 ((file-exists-p name) name)
3881 (t gnus-article-save-directory))))
3883 (concat prompt " (default " name "): ")
3885 ;; A list of splits was found.
3887 (setq split-name (nreverse split-name))
3889 (let ((file-name-history
3890 (nconc split-name file-name-history)))
3894 (concat prompt " (`M-p' for defaults): ")
3895 gnus-article-save-directory
3897 gnus-article-save-directory)))
3898 (car (push result file-name-history)))))))
3899 ;; Create the directory.
3900 (gnus-make-directory (file-name-directory file))
3901 ;; If we have read a directory, we append the default file name.
3902 (when (file-directory-p file)
3903 (setq file (expand-file-name (file-name-nondirectory
3905 (file-name-as-directory file))))
3906 ;; Possibly translate some characters.
3907 (nnheader-translate-file-chars file))))))
3908 (gnus-make-directory (file-name-directory result))
3910 (set variable result))
3912 (set dir-var (file-name-directory result)))
3915 (defun gnus-article-archive-name (group)
3916 "Return the first instance of an \"Archive-name\" in the current buffer."
3917 (let ((case-fold-search t))
3918 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3919 (nnheader-concat gnus-article-save-directory
3920 (match-string 1)))))
3922 (defun gnus-article-nndoc-name (group)
3923 "If GROUP is an nndoc group, return the name of the parent group."
3924 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3925 (gnus-group-get-parameter group 'save-article-group)))
3927 (defun gnus-summary-save-in-rmail (&optional filename)
3928 "Append this article to Rmail file.
3929 Optional argument FILENAME specifies file name.
3930 Directory to save to is default to `gnus-article-save-directory'."
3931 (setq filename (gnus-read-save-file-name
3932 "Save %s in rmail file" filename
3933 gnus-rmail-save-name gnus-newsgroup-name
3934 gnus-current-headers 'gnus-newsgroup-last-rmail))
3935 (with-current-buffer gnus-save-article-buffer
3939 ;; Note that unlike gnus-summary-save-in-mail, there is no
3940 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3942 (gnus-output-to-rmail filename))))
3945 (defun gnus-summary-save-in-mail (&optional filename)
3946 "Append this article to Unix mail file.
3947 Optional argument FILENAME specifies file name.
3948 Directory to save to is default to `gnus-article-save-directory'."
3949 (setq filename (gnus-read-save-file-name
3950 "Save %s in Unix mail file" filename
3951 gnus-mail-save-name gnus-newsgroup-name
3952 gnus-current-headers 'gnus-newsgroup-last-mail))
3953 (with-current-buffer gnus-save-article-buffer
3957 (if (and (file-readable-p filename)
3958 (file-regular-p filename)
3959 (mail-file-babyl-p filename))
3960 (gnus-output-to-rmail filename)
3961 (gnus-output-to-mail filename)))))
3964 (put 'gnus-summary-save-in-file :decode t)
3965 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3966 (defun gnus-summary-save-in-file (&optional filename overwrite)
3967 "Append this article to file.
3968 Optional argument FILENAME specifies file name.
3969 Directory to save to is default to `gnus-article-save-directory'."
3970 (setq filename (gnus-read-save-file-name
3971 "Save %s in file" filename
3972 gnus-file-save-name gnus-newsgroup-name
3973 gnus-current-headers 'gnus-newsgroup-last-file))
3974 (with-current-buffer gnus-save-article-buffer
3978 (when (and overwrite
3979 (file-exists-p filename))
3980 (delete-file filename))
3981 (gnus-output-to-file filename))))
3984 (put 'gnus-summary-write-to-file :decode t)
3985 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3986 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3987 (defun gnus-summary-write-to-file (&optional filename)
3988 "Write this article to a file, overwriting it if the file exists.
3989 Optional argument FILENAME specifies file name.
3990 The directory to save in defaults to `gnus-article-save-directory'."
3991 (setq filename (gnus-read-save-file-name
3992 "Save %s in file" filename
3993 gnus-file-save-name gnus-newsgroup-name
3994 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3995 (gnus-summary-save-in-file filename t))
3997 (put 'gnus-summary-save-body-in-file :decode t)
3998 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3999 "Append this article body to a file.
4000 Optional argument FILENAME specifies file name.
4001 The directory to save in defaults to `gnus-article-save-directory'."
4002 (setq filename (gnus-read-save-file-name
4003 "Save %s body in file" filename
4004 gnus-file-save-name gnus-newsgroup-name
4005 gnus-current-headers 'gnus-newsgroup-last-file))
4006 (with-current-buffer gnus-save-article-buffer
4010 (when (article-goto-body)
4011 (narrow-to-region (point) (point-max)))
4012 (when (and overwrite
4013 (file-exists-p filename))
4014 (delete-file filename))
4015 (gnus-output-to-file filename))))
4018 (put 'gnus-summary-write-body-to-file :decode t)
4019 (put 'gnus-summary-write-body-to-file
4020 :function 'gnus-summary-save-body-in-file)
4021 (defun gnus-summary-write-body-to-file (&optional filename)
4022 "Write this article body to a file, overwriting it if the file exists.
4023 Optional argument FILENAME specifies file name.
4024 The directory to save in defaults to `gnus-article-save-directory'."
4025 (setq filename (gnus-read-save-file-name
4026 "Save %s body in file" filename
4027 gnus-file-save-name gnus-newsgroup-name
4028 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4029 (gnus-summary-save-body-in-file filename t))
4031 (put 'gnus-summary-save-in-pipe :decode t)
4032 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4033 (defun gnus-summary-save-in-pipe (&optional command raw)
4034 "Pipe this article to subprocess COMMAND.
4035 Valid values for COMMAND include:
4037 The executable command name and possibly arguments.
4039 You will be prompted for the command in the minibuffer.
4040 the symbol `default'
4041 It will be replaced with the command which the variable
4042 `gnus-summary-pipe-output-default-command' holds or the command
4043 last used for saving.
4044 Non-nil value for RAW overrides `:decode' and `:headers' properties
4045 and the raw article including all headers will be piped."
4046 (let ((article (gnus-summary-article-number))
4048 (get 'gnus-summary-save-in-pipe :decode)))
4049 save-buffer default)
4051 (if (vectorp (gnus-summary-article-header article))
4052 (save-current-buffer
4053 (gnus-summary-select-article decode decode nil article)
4054 (insert-buffer-substring
4058 gnus-original-article-buffer)
4060 (nnheader-set-temp-buffer " *Gnus Save*"))))
4061 ;; Remove unwanted headers.
4062 (when (and (not raw)
4063 (or (get 'gnus-summary-save-in-pipe :headers)
4064 (not gnus-save-all-headers)))
4065 (let ((gnus-visible-headers
4066 (or (symbol-value (get 'gnus-summary-save-in-pipe
4068 gnus-saved-headers gnus-visible-headers))
4069 (gnus-summary-buffer nil))
4070 (article-hide-headers 1 t))))
4071 (error "%d is not a real article" article))
4072 (error "No article to pipe"))
4073 (setq default (or gnus-summary-pipe-output-default-command
4074 gnus-last-shell-command))
4075 (unless (stringp command)
4077 (if (and (eq command 'default) default)
4079 (gnus-read-shell-command "Shell command on this article: "
4081 (when (string-equal command "")
4083 (setq command default)
4084 (error "A command is required")))
4085 (with-current-buffer save-buffer
4088 (shell-command-on-region (point-min) (point-max) command nil)))
4089 (gnus-kill-buffer save-buffer))
4090 (setq gnus-summary-pipe-output-default-command command))
4092 (defun gnus-summary-pipe-to-muttprint (&optional command)
4093 "Pipe this article to muttprint."
4094 (unless (stringp command)
4095 (setq command (read-string
4096 "Print using command: " gnus-summary-muttprint-program
4097 nil gnus-summary-muttprint-program)))
4098 (let ((gnus-summary-pipe-output-default-command
4099 gnus-summary-pipe-output-default-command))
4100 (gnus-summary-save-in-pipe command))
4101 (setq gnus-summary-muttprint-program command))
4103 ;;; Article file names when saving.
4105 (defun gnus-capitalize-newsgroup (newsgroup)
4106 "Capitalize NEWSGROUP name."
4107 (when (not (zerop (length newsgroup)))
4108 (concat (char-to-string (upcase (aref newsgroup 0)))
4109 (substring newsgroup 1))))
4111 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4112 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4113 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4114 Otherwise, it is like ~/News/news/group/num."
4117 (concat (if (gnus-use-long-file-name 'not-save)
4118 (gnus-capitalize-newsgroup newsgroup)
4119 (gnus-newsgroup-directory-form newsgroup))
4120 "/" (int-to-string (mail-header-number headers)))
4121 gnus-article-save-directory)))
4123 (string-equal (file-name-directory default)
4124 (file-name-directory last-file))
4125 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4127 (or last-file default))))
4129 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4130 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4131 If variable `gnus-use-long-file-name' is non-nil, it is
4132 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4135 (concat (if (gnus-use-long-file-name 'not-save)
4137 (gnus-newsgroup-directory-form newsgroup))
4138 "/" (int-to-string (mail-header-number headers)))
4139 gnus-article-save-directory)))
4141 (string-equal (file-name-directory default)
4142 (file-name-directory last-file))
4143 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4145 (or last-file default))))
4147 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4148 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4149 If variable `gnus-use-long-file-name' is non-nil, it is
4150 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4153 (if (gnus-use-long-file-name 'not-save)
4156 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4158 gnus-article-save-directory)))
4160 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4161 "Generate file name from sender."
4162 (let ((from (mail-header-from headers)))
4164 (if (and from (string-match "\\([^ <]+\\)@" from))
4165 (match-string 1 from)
4167 gnus-article-save-directory)))
4169 (defun article-verify-x-pgp-sig ()
4171 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4173 (if (gnus-buffer-live-p gnus-original-article-buffer)
4174 (let ((sig (with-current-buffer gnus-original-article-buffer
4175 (gnus-fetch-field "X-PGP-Sig")))
4179 (mml2015-clear-verify-function))
4181 (insert-buffer-substring gnus-original-article-buffer)
4182 (setq items (split-string sig))
4183 (message-narrow-to-head)
4184 (let ((inhibit-point-motion-hooks t)
4185 (case-fold-search t))
4186 ;; Don't verify multiple headers.
4187 (setq headers (mapconcat (lambda (header)
4189 (mail-fetch-field header)
4191 (split-string (nth 1 items) ",") "")))
4192 (delete-region (point-min) (point-max))
4193 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4194 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4199 (if (looking-at "^-")
4202 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4203 (insert "Version: " (car items) "\n\n")
4204 (insert (mapconcat 'identity (cddr items) "\n"))
4205 (insert "\n-----END PGP SIGNATURE-----\n")
4206 (let ((mm-security-handle (list (format "multipart/signed"))))
4207 (mml2015-clean-buffer)
4208 (let ((coding-system-for-write (or gnus-newsgroup-charset
4210 (funcall (mml2015-clear-verify-function)))
4212 (or (mm-handle-multipart-ctl-parameter
4213 mm-security-handle 'gnus-details)
4214 (mm-handle-multipart-ctl-parameter
4215 mm-security-handle 'gnus-info)))))
4217 (let ((inhibit-read-only t) bface eface)
4219 (message-narrow-to-head)
4220 (goto-char (point-max))
4222 (setq bface (get-text-property (point-at-bol) 'face)
4223 eface (get-text-property (1- (point-at-eol)) 'face))
4224 (message-remove-header "X-Gnus-PGP-Verify")
4225 (if (re-search-forward "^X-PGP-Sig:" nil t)
4227 (goto-char (point-max)))
4228 (narrow-to-region (point) (point))
4229 (insert "X-Gnus-PGP-Verify: " info "\n")
4230 (goto-char (point-min))
4233 (if (not (looking-at "^[ \t]"))
4237 (goto-char (point-min))
4238 (when (looking-at "\\([^:]+\\): *")
4239 (put-text-property (match-beginning 1) (1+ (match-end 1))
4241 (put-text-property (match-end 0) (point-max)
4242 'face eface)))))))))
4244 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4246 (defun article-verify-cancel-lock ()
4247 "Verify Cancel-Lock header."
4249 (if (gnus-buffer-live-p gnus-original-article-buffer)
4250 (canlock-verify gnus-original-article-buffer)))
4257 (setq afunc (car func)
4260 gfunc (intern (format "gnus-%s" func))))
4262 (when (fboundp afunc)
4263 `(lambda (&optional interactive &rest args)
4264 ,(documentation afunc t)
4265 (interactive (list t))
4266 (with-current-buffer gnus-article-buffer
4268 (call-interactively ',afunc)
4269 (apply ',afunc args))))))))
4270 '(article-hide-headers
4271 article-verify-x-pgp-sig
4272 article-verify-cancel-lock
4273 article-hide-boring-headers
4274 article-treat-overstrike
4275 article-treat-ansi-sequences
4276 article-fill-long-lines
4277 article-capitalize-sentences
4279 article-remove-leading-whitespace
4280 article-display-x-face
4281 article-display-face
4282 article-de-quoted-unreadable
4283 article-de-base64-unreadable
4286 article-unsplit-urls
4287 article-hide-list-identifiers
4288 article-strip-banner
4291 article-hide-signature
4292 article-strip-headers-in-body
4293 article-remove-trailing-blank-lines
4294 article-strip-leading-blank-lines
4295 article-strip-multiple-blank-lines
4296 article-strip-leading-space
4297 article-strip-trailing-space
4298 article-strip-blank-lines
4299 article-strip-all-blank-lines
4301 article-date-english
4302 article-date-iso8601
4303 article-date-original
4306 article-decode-mime-words
4307 article-decode-charset
4308 article-decode-encoded-words
4311 article-date-combined-lapsed
4313 article-treat-dumbquotes
4314 article-treat-non-ascii
4315 article-normalize-headers
4316 ;;(article-show-all . gnus-article-show-all-headers)
4320 ;;; Gnus article mode
4323 (put 'gnus-article-mode 'mode-class 'special)
4325 (set-keymap-parent gnus-article-mode-map widget-keymap)
4327 (gnus-define-keys gnus-article-mode-map
4328 " " gnus-article-goto-next-page
4329 "\177" gnus-article-goto-prev-page
4330 [delete] gnus-article-goto-prev-page
4331 [backspace] gnus-article-goto-prev-page
4332 "\C-c^" gnus-article-refer-article
4333 "h" gnus-article-show-summary
4334 "s" gnus-article-show-summary
4335 "\C-c\C-m" gnus-article-mail
4336 "?" gnus-article-describe-briefly
4337 "<" beginning-of-buffer
4339 "\C-c\C-i" gnus-info-find-node
4341 "R" gnus-article-reply-with-original
4342 "F" gnus-article-followup-with-original
4343 "\C-hk" gnus-article-describe-key
4344 "\C-hc" gnus-article-describe-key-briefly
4345 "\C-hb" gnus-article-describe-bindings
4347 "e" gnus-article-read-summary-keys
4348 "\C-d" gnus-article-read-summary-keys
4349 "\M-*" gnus-article-read-summary-keys
4350 "\M-#" gnus-article-read-summary-keys
4351 "\M-^" gnus-article-read-summary-keys
4352 "\M-g" gnus-article-read-summary-keys)
4354 (substitute-key-definition
4355 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4357 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4358 "W" gnus-article-wide-reply-with-original)
4359 (if (featurep 'xemacs)
4360 (set-keymap-default-binding gnus-article-send-map
4361 'gnus-article-read-summary-send-keys)
4362 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4364 (defun gnus-article-make-menu-bar ()
4365 (unless (boundp 'gnus-article-commands-menu)
4366 (gnus-summary-make-menu-bar))
4367 (unless (boundp 'gnus-article-article-menu)
4369 gnus-article-article-menu gnus-article-mode-map ""
4371 ["Scroll forwards" gnus-article-goto-next-page t]
4372 ["Scroll backwards" gnus-article-goto-prev-page t]
4373 ["Show summary" gnus-article-show-summary t]
4374 ["Fetch Message-ID at point" gnus-article-refer-article t]
4375 ["Mail to address at point" gnus-article-mail t]
4376 ["Send a bug report" gnus-bug t]))
4379 gnus-article-treatment-menu gnus-article-mode-map ""
4380 ;; Fixme: this should use :active (and maybe :visible).
4382 ["Hide headers" gnus-article-hide-headers t]
4383 ["Hide signature" gnus-article-hide-signature t]
4384 ["Hide citation" gnus-article-hide-citation t]
4385 ["Treat overstrike" gnus-article-treat-overstrike t]
4386 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4387 ["Remove carriage return" gnus-article-remove-cr t]
4388 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4389 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4390 ["Remove base64" gnus-article-de-base64-unreadable t]
4391 ["Treat html" gnus-article-wash-html t]
4392 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4393 ["Decode HZ" gnus-article-decode-HZ t]))
4395 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4397 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4399 (gnus-run-hooks 'gnus-article-menu-hook)))
4401 (defvar bookmark-make-record-function)
4403 (defun gnus-article-mode ()
4404 "Major mode for displaying an article.
4406 All normal editing commands are switched off.
4408 The following commands are available in addition to all summary mode
4410 \\<gnus-article-mode-map>
4411 \\[gnus-article-next-page]\t Scroll the article one page forwards
4412 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4413 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4414 \\[gnus-article-show-summary]\t Display the summary buffer
4415 \\[gnus-article-mail]\t Send a reply to the address near point
4416 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4417 \\[gnus-info-find-node]\t Go to the Gnus info node"
4419 (kill-all-local-variables)
4420 (gnus-simplify-mode-line)
4421 (setq mode-name "Article")
4422 (setq major-mode 'gnus-article-mode)
4423 (make-local-variable 'minor-mode-alist)
4424 (use-local-map gnus-article-mode-map)
4425 (when (gnus-visual-p 'article-menu 'menu)
4426 (gnus-article-make-menu-bar)
4427 (when gnus-summary-tool-bar-map
4428 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4429 (gnus-update-format-specifications nil 'article-mode)
4430 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4431 (set (make-local-variable 'gnus-page-broken) nil)
4432 (make-local-variable 'gnus-article-current-summary)
4433 (make-local-variable 'gnus-article-mime-handles)
4434 (make-local-variable 'gnus-article-decoded-p)
4435 (make-local-variable 'gnus-article-mime-handle-alist)
4436 (make-local-variable 'gnus-article-wash-types)
4437 (make-local-variable 'gnus-article-image-alist)
4438 (make-local-variable 'gnus-article-charset)
4439 (make-local-variable 'gnus-article-ignored-charsets)
4440 (set (make-local-variable 'bookmark-make-record-function)
4441 'gnus-summary-bookmark-make-record)
4442 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4444 (set (make-local-variable 'nobreak-char-display) nil)
4445 (setq cursor-in-non-selected-windows nil)
4446 (gnus-set-default-directory)
4447 (buffer-disable-undo)
4448 (setq buffer-read-only t
4449 show-trailing-whitespace nil)
4450 (set-syntax-table gnus-article-mode-syntax-table)
4451 (mm-enable-multibyte)
4452 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4454 (defun gnus-article-setup-buffer ()
4455 "Initialize the article buffer."
4456 (let* ((name (if gnus-single-article-buffer "*Article*"
4457 (concat "*Article " gnus-newsgroup-name "*")))
4459 (progn (string-match "\\*Article" name)
4460 (concat " *Original Article"
4461 (substring name (match-end 0))))))
4462 (setq gnus-article-buffer name)
4463 (setq gnus-original-article-buffer original)
4464 (setq gnus-article-mime-handle-alist nil)
4465 (with-current-buffer gnus-summary-buffer
4466 ;; This might be a variable local to the summary buffer.
4467 (unless gnus-single-article-buffer
4468 (setq gnus-article-buffer name)
4469 (setq gnus-original-article-buffer original)
4470 (gnus-set-global-variables)))
4471 (gnus-article-setup-highlight-words)
4472 ;; Init original article buffer.
4473 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4474 (mm-enable-multibyte)
4475 (setq major-mode 'gnus-original-article-mode)
4476 (make-local-variable 'gnus-original-article))
4477 (if (and (get-buffer name)
4478 (with-current-buffer name
4479 (if gnus-article-edit-mode
4480 (if (y-or-n-p "Article mode edit in progress; discard? ")
4482 (set-buffer-modified-p nil)
4483 (gnus-kill-buffer name)
4486 (error "Action aborted"))
4488 (with-current-buffer name
4489 (set (make-local-variable 'gnus-article-edit-mode) nil)
4490 (when gnus-article-mime-handles
4491 (mm-destroy-parts gnus-article-mime-handles)
4492 (setq gnus-article-mime-handles nil))
4493 ;; Set it to nil in article-buffer!
4494 (setq gnus-article-mime-handle-alist nil)
4495 (buffer-disable-undo)
4496 (setq buffer-read-only t)
4497 (unless (eq major-mode 'gnus-article-mode)
4498 (gnus-article-mode))
4499 (setq truncate-lines gnus-article-truncate-lines)
4501 (with-current-buffer (gnus-get-buffer-create name)
4503 (setq truncate-lines gnus-article-truncate-lines)
4504 (make-local-variable 'gnus-summary-buffer)
4505 (setq gnus-summary-buffer
4506 (gnus-summary-buffer-name gnus-newsgroup-name))
4507 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4509 ((and gnus-article-update-date-headers
4510 (not article-lapsed-timer))
4511 (gnus-start-date-timer gnus-article-update-date-headers))
4512 ((and (not gnus-article-update-date-headers)
4513 article-lapsed-timer)
4514 (gnus-stop-date-timer)))
4515 (current-buffer)))))
4517 ;; Set article window start at LINE, where LINE is the number of lines
4518 ;; from the head of the article.
4519 (defun gnus-article-set-window-start (&optional line)
4520 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4521 (when article-window
4524 (with-current-buffer gnus-article-buffer
4525 (goto-char (point-min))
4528 (gnus-message 6 "Moved to bookmark")
4529 (search-forward "\n\n" nil t)
4533 (defun gnus-article-prepare (article &optional all-headers header)
4534 "Prepare ARTICLE in article mode buffer.
4535 ARTICLE should either be an article number or a Message-ID.
4536 If ARTICLE is an id, HEADER should be the article headers.
4537 If ALL-HEADERS is non-nil, no headers are hidden."
4539 ;; Make sure we start in a summary buffer.
4540 (unless (eq major-mode 'gnus-summary-mode)
4541 (set-buffer gnus-summary-buffer))
4542 (setq gnus-summary-buffer (current-buffer))
4543 (let* ((gnus-article (if header (mail-header-number header) article))
4544 (summary-buffer (current-buffer))
4545 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4546 (group gnus-newsgroup-name)
4549 (gnus-article-setup-buffer)
4550 (set-buffer gnus-article-buffer)
4551 ;; Deactivate active regions.
4552 (when (and (boundp 'transient-mark-mode)
4553 transient-mark-mode)
4554 (setq mark-active nil))
4555 (if (not (setq result (let ((inhibit-read-only t))
4556 (gnus-request-article-this-buffer
4558 ;; There is no such article.
4560 (when (and (numberp article)
4561 (not (memq article gnus-newsgroup-sparse)))
4562 (setq gnus-article-current
4563 (cons gnus-newsgroup-name article))
4564 (set-buffer gnus-summary-buffer)
4565 (setq gnus-current-article article)
4566 (if (and (memq article gnus-newsgroup-undownloaded)
4567 (not (gnus-online (gnus-find-method-for-group
4568 gnus-newsgroup-name))))
4570 (gnus-summary-set-agent-mark article)
4571 (message "Message marked for downloading"))
4572 (gnus-summary-mark-article article gnus-canceled-mark)
4573 (unless (memq article gnus-newsgroup-sparse)
4574 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4575 (if (or (eq result 'pseudo)
4576 (eq result 'nneething))
4578 (with-current-buffer summary-buffer
4579 (push article gnus-newsgroup-history)
4580 (setq gnus-last-article gnus-current-article
4581 gnus-current-article 0
4582 gnus-current-headers nil
4583 gnus-article-current nil)
4584 (if (eq result 'nneething)
4585 (gnus-configure-windows 'summary)
4586 (gnus-configure-windows 'article))
4587 (gnus-set-global-variables))
4588 (let ((gnus-article-mime-handle-alist-1
4589 gnus-article-mime-handle-alist))
4590 (gnus-set-mode-line 'article)))
4591 ;; The result from the `request' was an actual article -
4592 ;; or at least some text that is now displayed in the
4594 (when (and (numberp article)
4595 (not (eq article gnus-current-article)))
4596 ;; Seems like a new article has been selected.
4597 ;; `gnus-current-article' must be an article number.
4598 (with-current-buffer summary-buffer
4599 (push article gnus-newsgroup-history)
4600 (setq gnus-last-article gnus-current-article
4601 gnus-current-article article
4602 gnus-current-headers
4603 (gnus-summary-article-header gnus-current-article)
4604 gnus-article-current
4605 (cons gnus-newsgroup-name gnus-current-article))
4606 (unless (vectorp gnus-current-headers)
4607 (setq gnus-current-headers nil))
4608 (gnus-summary-goto-subject gnus-current-article)
4609 (when (gnus-summary-show-thread)
4610 ;; If the summary buffer really was folded, the
4611 ;; previous goto may not actually have gone to
4612 ;; the right article, but the thread root instead.
4614 (gnus-summary-goto-subject gnus-current-article))
4615 (gnus-run-hooks 'gnus-mark-article-hook)
4616 (gnus-set-mode-line 'summary)
4617 (when (gnus-visual-p 'article-highlight 'highlight)
4618 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4619 ;; Set the global newsgroup variables here.
4620 (gnus-set-global-variables)
4621 (setq gnus-have-all-headers
4622 (or all-headers gnus-show-all-headers))))
4624 (gnus-configure-windows 'article))
4625 (when (or (numberp article)
4627 (gnus-article-prepare-display)
4629 (goto-char (point-min))
4630 (when gnus-break-pages
4631 (gnus-narrow-to-page)))
4632 (let ((gnus-article-mime-handle-alist-1
4633 gnus-article-mime-handle-alist))
4634 (gnus-set-mode-line 'article))
4638 (set-window-point (get-buffer-window (current-buffer)) (point))
4639 (gnus-configure-windows 'article)
4643 (defun gnus-article-prepare-display ()
4644 "Make the current buffer look like a nice article."
4645 ;; Hooks for getting information from the article.
4646 ;; This hook must be called before being narrowed.
4647 (let ((gnus-article-buffer (current-buffer))
4649 (inhibit-read-only t))
4650 (unless (eq major-mode 'gnus-article-mode)
4651 (gnus-article-mode))
4652 (setq buffer-read-only nil
4653 gnus-article-wash-types nil
4654 gnus-article-image-alist nil)
4655 (gnus-run-hooks 'gnus-tmp-internal-hook)
4656 (when gnus-display-mime-function
4657 (funcall gnus-display-mime-function))
4658 (gnus-run-hooks 'gnus-article-prepare-hook)))
4661 ;;; Gnus Sticky Article Mode
4664 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4665 "Mode for sticky articles."
4666 ;; Release bindings that won't work.
4667 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4668 gnus-sticky-article-mode-map)
4669 (substitute-key-definition 'gnus-article-refer-article 'undefined
4670 gnus-sticky-article-mode-map)
4671 (dolist (k '("e" "h" "s" "F" "R"))
4672 (define-key gnus-sticky-article-mode-map k nil))
4673 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4674 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4675 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4676 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4678 (defun gnus-sticky-article (arg)
4679 "Make the current article sticky.
4680 If a prefix ARG is given, ask for a name for this sticky article buffer."
4682 (gnus-summary-show-thread)
4683 (gnus-summary-select-article nil nil 'pseudo)
4684 (let (new-art-buf-name)
4685 (gnus-eval-in-buffer-window gnus-article-buffer
4686 (setq new-art-buf-name
4690 (read-from-minibuffer "Sticky article buffer name: ")
4691 (gnus-with-article-headers
4692 (gnus-article-goto-header "subject")
4693 (setq new-art-buf-name
4694 (buffer-substring-no-properties
4695 (line-beginning-position) (line-end-position)))
4696 (goto-char (point-min))
4697 (gnus-article-goto-header "from")
4698 (setq new-art-buf-name
4700 new-art-buf-name ", "
4701 (buffer-substring-no-properties
4702 (line-beginning-position) (line-end-position))))
4703 (goto-char (point-min))
4704 (gnus-article-goto-header "date")
4705 (setq new-art-buf-name
4707 new-art-buf-name ", "
4708 (buffer-substring-no-properties
4709 (line-beginning-position) (line-end-position))))))
4711 (if (and (gnus-buffer-live-p new-art-buf-name)
4712 (with-current-buffer new-art-buf-name
4713 (eq major-mode 'gnus-sticky-article-mode)))
4714 (switch-to-buffer new-art-buf-name)
4715 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4716 (gnus-sticky-article-mode))
4717 (setq gnus-article-buffer new-art-buf-name))
4718 (gnus-summary-recenter)
4719 (gnus-summary-position-point))
4721 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4722 "Kill the given sticky article BUFFER.
4723 If none is given, assume the current buffer and kill it if it has
4724 `gnus-sticky-article-mode'."
4727 (setq buffer (current-buffer)))
4728 (with-current-buffer buffer
4729 (when (eq major-mode 'gnus-sticky-article-mode)
4730 (gnus-kill-buffer buffer))))
4732 (defun gnus-kill-sticky-article-buffers (arg)
4733 "Kill all sticky article buffers.
4734 If a prefix ARG is given, ask for confirmation."
4736 (dolist (buf (gnus-buffers))
4737 (with-current-buffer buf
4738 (when (eq major-mode 'gnus-sticky-article-mode)
4740 (gnus-kill-buffer buf)
4741 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4742 (gnus-kill-buffer buf)))))))
4745 ;;; Gnus MIME viewing functions
4748 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4749 "Format of the MIME buttons.
4751 Valid specifiers include:
4753 %T MIME type, along with additional info
4754 %n The `name' parameter
4755 %d The description, if any
4756 %l The length of the encoded part
4757 %p The part identifier number
4758 %e Dots if the part isn't displayed
4760 General format specifiers can also be used. See Info node
4761 `(gnus)Formatting Variables'.")
4763 (defvar gnus-mime-button-line-format-alist
4764 '((?t gnus-tmp-type ?s)
4765 (?T gnus-tmp-type-long ?s)
4766 (?n gnus-tmp-name ?s)
4767 (?d gnus-tmp-description ?s)
4769 (?l gnus-tmp-length ?d)
4770 (?e gnus-tmp-dots ?s)))
4772 (defvar gnus-mime-button-commands
4773 '((gnus-article-press-button "\r" "Toggle Display")
4774 (gnus-mime-view-part "v" "View Interactively...")
4775 (gnus-mime-view-part-as-type "t" "View As Type...")
4776 (gnus-mime-view-part-as-charset "C" "View As charset...")
4777 (gnus-mime-save-part "o" "Save...")
4778 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4779 (gnus-mime-replace-part "r" "Replace part")
4780 (gnus-mime-delete-part "d" "Delete part")
4781 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4782 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4783 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4784 (gnus-mime-view-part-externally "e" "View Externally")
4785 (gnus-mime-print-part "p" "Print")
4786 (gnus-mime-pipe-part "|" "Pipe To Command...")
4787 (gnus-mime-action-on-part "." "Take action on the part...")))
4789 (defun gnus-article-mime-part-status ()
4790 (if gnus-article-mime-handle-alist-1
4791 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4793 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4796 (defvar gnus-mime-button-map
4797 (let ((map (make-sparse-keymap)))
4798 (define-key map gnus-mouse-2 'gnus-article-push-button)
4799 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4800 (dolist (c gnus-mime-button-commands)
4801 (define-key map (cadr c) (car c)))
4805 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4807 ,@(mapcar (lambda (c)
4808 (vector (caddr c) (car c) :active t))
4809 gnus-mime-button-commands)))
4811 (defvar gnus-url-button-commands
4812 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4814 (defvar gnus-url-button-map
4815 (let ((map (make-sparse-keymap)))
4816 (dolist (c gnus-url-button-commands)
4817 (define-key map (cadr c) (car c)))
4821 gnus-url-button-menu gnus-url-button-map "URL button menu."
4823 ,@(mapcar (lambda (c)
4824 (vector (caddr c) (car c) :active t))
4825 gnus-url-button-commands)))
4827 (defmacro gnus-bind-safe-url-regexp (&rest body)
4828 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4829 `(let ((mm-w3m-safe-url-regexp
4830 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4832 gnus-article-current-summary))
4833 (with-current-buffer gnus-article-current-summary
4834 gnus-newsgroup-name)
4835 gnus-newsgroup-name)))
4836 (if (cond ((not group)
4837 ;; Maybe we're in a mml-preview buffer
4838 ;; and no group is selected.
4840 ((stringp gnus-safe-html-newsgroups)
4841 (string-match gnus-safe-html-newsgroups group))
4842 ((consp gnus-safe-html-newsgroups)
4843 (member group gnus-safe-html-newsgroups)))
4845 mm-w3m-safe-url-regexp))))
4848 (defun gnus-mime-button-menu (event prefix)
4849 "Construct a context-sensitive menu of MIME commands."
4850 (interactive "e\nP")
4851 (save-window-excursion
4852 (let ((pos (event-start event)))
4853 (select-window (posn-window pos))
4854 (goto-char (posn-point pos))
4855 (gnus-article-check-buffer)
4856 (popup-menu gnus-mime-button-menu nil prefix))))
4858 (defun gnus-mime-view-all-parts (&optional handles)
4859 "View all the MIME parts."
4861 (with-current-buffer gnus-article-buffer
4862 (let ((handles (or handles gnus-article-mime-handles))
4863 (mail-parse-charset gnus-newsgroup-charset)
4864 (mail-parse-ignored-charsets
4865 (with-current-buffer gnus-summary-buffer
4866 gnus-newsgroup-ignored-charsets)))
4868 (mm-remove-parts handles)
4869 (goto-char (point-min))
4870 (or (search-forward "\n\n") (goto-char (point-max)))
4871 (let ((inhibit-read-only t))
4872 (delete-region (point) (point-max))
4873 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4875 (defun gnus-article-jump-to-part (n)
4876 "Jump to MIME part N."
4878 (let ((parts (with-current-buffer gnus-article-buffer
4879 (length gnus-article-mime-handle-alist))))
4881 (error "No such part"))
4882 (pop-to-buffer gnus-article-buffer)
4883 ;; FIXME: why is it necessary?
4886 (setq n (if (= parts 1)
4888 (read-number (format "Jump to part (1..%s): " parts)))))
4889 (unless (and (integerp n) (<= n parts) (>= n 1))
4892 (gnus-message 7 "Invalid part `%s', using %s instead."
4895 (gnus-message 9 "Jumping to part %s." n)
4896 (cond ((>= gnus-auto-select-part 1)
4897 (while (and (<= n parts)
4898 (not (gnus-article-goto-part n)))
4900 ((< gnus-auto-select-part 0)
4901 (while (and (>= n 1)
4902 (not (gnus-article-goto-part n)))
4905 (gnus-article-goto-part n)))))
4907 (defvar gnus-mime-buttonized-part-id nil
4908 "ID of a mime part that should be buttonized.
4909 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4912 (defsubst gnus-article-edit-part (handles &optional current-id)
4913 "Edit an article in order to delete a mime part.
4914 This function is exclusively used by `gnus-mime-save-part-and-strip'
4915 and `gnus-mime-delete-part', and not provided at run-time normally."
4916 (gnus-article-edit-article
4918 (buffer-disable-undo)
4920 (let ((mail-parse-charset (or gnus-article-charset
4921 ',gnus-newsgroup-charset))
4922 (mail-parse-ignored-charsets
4923 (or gnus-article-ignored-charsets
4924 ',gnus-newsgroup-ignored-charsets))
4925 (mbl mml-buffer-list))
4926 (setq mml-buffer-list nil)
4927 (insert-buffer-substring gnus-original-article-buffer)
4928 (mime-to-mml ',handles)
4929 (setq gnus-article-mime-handles nil)
4930 (let ((mbl1 mml-buffer-list))
4931 (setq mml-buffer-list mbl)
4932 (set (make-local-variable 'mml-buffer-list) mbl1))
4933 (gnus-make-local-hook 'kill-buffer-hook)
4934 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4935 `(lambda (no-highlight)
4936 (let ((mail-parse-charset (or gnus-article-charset
4937 ',gnus-newsgroup-charset))
4938 (message-options message-options)
4939 (message-options-set-recipient)
4940 (mail-parse-ignored-charsets
4941 (or gnus-article-ignored-charsets
4942 ',gnus-newsgroup-ignored-charsets)))
4944 (mml-destroy-buffers)
4945 (remove-hook 'kill-buffer-hook
4946 'mml-destroy-buffers t)
4947 (kill-local-variable 'mml-buffer-list))
4948 (gnus-summary-edit-article-done
4949 ,(or (mail-header-references gnus-current-headers) "")
4950 ,(gnus-group-read-only-p)
4951 ,gnus-summary-buffer no-highlight))
4953 ;; Force buttonizing this part.
4954 (let ((gnus-mime-buttonized-part-id current-id))
4955 (gnus-article-edit-done))
4956 (gnus-configure-windows 'article)
4957 (when (and current-id (integerp gnus-auto-select-part))
4958 (gnus-article-jump-to-part
4959 (min (max (+ current-id gnus-auto-select-part) 1)
4960 (with-current-buffer gnus-article-buffer
4961 (length gnus-article-mime-handle-alist)))))))
4963 (defun gnus-mime-replace-part (file)
4964 "Replace MIME part under point with an external body."
4965 ;; Useful if file has already been saved to disk
4968 (read-file-name "Replace MIME part with file: "
4969 (or mm-default-directory default-directory)
4971 (gnus-mime-save-part-and-strip file))
4973 (defun gnus-mime-save-part-and-strip (&optional file)
4974 "Save the MIME part under point then replace it with an external body.
4975 If FILE is given, use it for the external part."
4977 (gnus-article-check-buffer)
4978 (when (gnus-group-read-only-p)
4979 (error "The current group does not support deleting of parts"))
4980 (when (mm-complicated-handles gnus-article-mime-handles)
4982 The current article has a complicated MIME structure, giving up..."))
4983 (let* ((data (get-text-property (point) 'gnus-data))
4984 (id (get-text-property (point) 'gnus-part))
4986 (handles gnus-article-mime-handles))
4989 (and data (mm-save-part data "Delete MIME part and save to: "))))
4991 (with-current-buffer (mm-handle-buffer data)
4993 (insert "Content-Type: " (mm-handle-media-type data))
4994 (mml-insert-parameter-string (cdr (mm-handle-type data))
4996 ;; Add a filename for the sake of saving the part again.
4997 (mml-insert-parameter
4998 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5000 (insert "Content-ID: " (message-make-message-id) "\n")
5001 (insert "Content-Transfer-Encoding: binary\n")
5004 (cdr (mm-make-handle nil
5005 `("message/external-body"
5006 (access-type . "LOCAL-FILE")
5008 ;; (set-buffer gnus-summary-buffer)
5009 (gnus-article-edit-part handles id))))
5011 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5012 ;; parts...>') but with stripping would be nice.
5014 (defun gnus-mime-delete-part ()
5015 "Delete the MIME part under point.
5016 Replace it with some information about the removed part."
5018 (gnus-article-check-buffer)
5019 (when (gnus-group-read-only-p)
5020 (error "The current group does not support deleting of parts"))
5021 (when (mm-complicated-handles gnus-article-mime-handles)
5023 The current article has a complicated MIME structure, giving up..."))
5024 (when (or gnus-expert-user
5025 (gnus-yes-or-no-p "\
5026 Deleting parts may malfunction or destroy the article; continue? "))
5027 (let* ((data (get-text-property (point) 'gnus-data))
5028 (id (get-text-property (point) 'gnus-part))
5029 (handles gnus-article-mime-handles)
5032 (let ((desc (mm-handle-description data)))
5034 (mail-decode-encoded-word-string desc))))
5036 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
5038 (type (mm-handle-media-type data)))
5040 (error "No MIME part under point"))
5041 (with-current-buffer (mm-handle-buffer data)
5042 (let ((bsize (buffer-size)))
5047 "| The following attachment has been deleted:\n"
5049 "| Type: " type "\n"
5050 "| Filename: " filename "\n"
5051 "| Size (encoded): " (format "%s byte%s\n"
5052 bsize (if (= bsize 1)
5056 (concat "| Description: " description "\n"))
5059 (cdr (mm-make-handle
5060 nil `("text/plain" (charset . gnus-decoded)) nil nil
5062 (format "Deleted attachment (%s bytes)" bsize))))))
5063 ;; (set-buffer gnus-summary-buffer)
5064 (gnus-article-edit-part handles id))))
5066 (defun gnus-mime-save-part ()
5067 "Save the MIME part under point."
5069 (gnus-article-check-buffer)
5070 (let ((data (get-text-property (point) 'gnus-data)))
5072 (mm-save-part data))))
5074 (defun gnus-mime-pipe-part (&optional cmd)
5075 "Pipe the MIME part under point to a process.
5076 Use CMD as the process."
5078 (gnus-article-check-buffer)
5079 (let ((data (get-text-property (point) 'gnus-data)))
5081 (mm-pipe-part data cmd))))
5083 (defun gnus-mime-view-part ()
5084 "Interactively choose a viewing method for the MIME part under point."
5086 (gnus-article-check-buffer)
5087 (let ((data (get-text-property (point) 'gnus-data)))
5089 (setq gnus-article-mime-handles
5091 gnus-article-mime-handles (setq data (copy-sequence data))))
5092 (mm-interactively-view-part data))))
5094 (defun gnus-mime-view-part-as-type-internal ()
5095 (gnus-article-check-buffer)
5096 (let* ((handle (get-text-property (point) 'gnus-data))
5098 ;; Content-Type: foo/bar; name=...
5099 (mail-content-type-get (mm-handle-type handle) 'name)
5100 ;; Content-Disposition: attachment; filename=...
5101 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5102 (def-type (and name (mm-default-file-encoding name))))
5103 (or (and def-type (cons def-type 0))
5105 (equal (mm-handle-media-supertype handle) "text")
5106 '("text/plain" . 0))
5107 '("application/octet-stream" . 0))))
5109 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5110 "Choose a MIME media type, and view the part as such.
5111 If non-nil, PRED is a predicate to use during completion to limit the
5112 available media-types."
5116 (let ((default (gnus-mime-view-part-as-type-internal)))
5117 (gnus-completing-read
5120 (gnus-remove-if-not pred (mailcap-mime-types))
5121 (mailcap-mime-types))
5124 (gnus-article-check-buffer)
5125 (let ((handle (get-text-property (point) 'gnus-data)))
5127 (when (equal (mm-handle-media-type handle) "message/external-body")
5128 (unless (mm-handle-cache handle)
5129 (mm-extern-cache-contents handle))
5130 (setq handle (mm-handle-cache handle)))
5132 (mm-make-handle (mm-handle-buffer handle)
5133 (cons mime-type (cdr (mm-handle-type handle)))
5134 (mm-handle-encoding handle)
5135 (mm-handle-undisplayer handle)
5136 (mm-handle-disposition handle)
5137 (mm-handle-description handle)
5139 (mm-handle-id handle)))
5140 (setq gnus-article-mime-handles
5141 (mm-merge-handles gnus-article-mime-handles handle))
5142 (when (mm-handle-displayed-p handle)
5143 (mm-remove-part handle))
5144 (gnus-mm-display-part handle))))
5146 (defun gnus-mime-copy-part (&optional handle arg)
5147 "Put the MIME part under point into a new buffer.
5148 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5150 (interactive (list nil current-prefix-arg))
5151 (gnus-article-check-buffer)
5153 (setq handle (get-text-property (point) 'gnus-data)))
5155 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5157 (mail-content-type-get (mm-handle-disposition handle)
5159 contents dont-decode charset coding-system)
5160 (mm-with-unibyte-buffer
5161 (mm-insert-part handle)
5162 (setq contents (or (condition-case nil
5163 (mm-decompress-buffer filename nil 'sig)
5165 (setq dont-decode t)
5168 (setq filename (cond (filename (file-name-nondirectory filename))
5169 (dont-decode "*raw data*")
5174 (unless (setq charset (mail-content-type-get
5175 (mm-handle-type handle) 'charset))
5176 (unless (setq coding-system (mm-with-unibyte-buffer
5178 (mm-find-buffer-file-coding-system)))
5179 (setq charset gnus-newsgroup-charset))))
5181 (setq charset (or (cdr (assq arg
5182 gnus-summary-show-article-charset-alist))
5183 (mm-read-coding-system "Charset: ")))))
5184 (switch-to-buffer (generate-new-buffer filename))
5185 (if (or coding-system
5187 (setq coding-system (mm-charset-to-coding-system charset))
5188 (not (eq coding-system 'ascii))))
5190 (mm-enable-multibyte)
5191 (insert (mm-decode-coding-string contents coding-system))
5192 (setq buffer-file-coding-system
5193 (if (boundp 'last-coding-system-used)
5194 (symbol-value 'last-coding-system-used)
5196 (mm-disable-multibyte)
5198 (setq buffer-file-coding-system mm-binary-coding-system))
5199 ;; We do it this way to make `normal-mode' set the appropriate mode.
5202 (setq buffer-file-name (expand-file-name filename))
5204 (setq buffer-file-name nil))
5205 (goto-char (point-min)))))
5207 (defun gnus-mime-print-part (&optional handle filename)
5208 "Print the MIME part under point."
5209 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5210 (gnus-article-check-buffer)
5211 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5212 (contents (and handle (mm-get-part handle)))
5213 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5214 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5219 (mm-save-part-to-file handle file)
5220 (call-process shell-file-name nil
5221 (generate-new-buffer " *mm*")
5223 shell-command-switch
5225 printer file (mm-handle-type handle))))
5229 (gnus-print-buffer))
5230 (ps-despool filename)))))
5232 (defun gnus-mime-inline-part (&optional handle arg)
5233 "Insert the MIME part under point into the current buffer.
5234 Compressed files like .gz and .bz2 are decompressed."
5235 (interactive (list nil current-prefix-arg))
5236 (gnus-article-check-buffer)
5238 (setq handle (get-text-property (point) 'gnus-data)))
5241 (inhibit-read-only t)
5242 contents charset coding-system)
5243 (if (and (not arg) (mm-handle-undisplayer handle))
5244 (mm-remove-part handle)
5245 (mm-with-unibyte-buffer
5246 (mm-insert-part handle)
5248 (or (mm-decompress-buffer
5249 (or (mail-content-type-get (mm-handle-type handle)
5251 (mail-content-type-get (mm-handle-disposition handle)
5257 (unless (setq charset (mail-content-type-get
5258 (mm-handle-type handle) 'charset))
5259 (unless (setq coding-system
5260 (mm-with-unibyte-buffer
5262 (mm-find-buffer-file-coding-system)))
5263 (setq charset gnus-newsgroup-charset))))
5265 (if (mm-handle-undisplayer handle)
5266 (mm-remove-part handle))
5269 gnus-summary-show-article-charset-alist))
5270 (mm-read-coding-system "Charset: "))))
5272 (if (mm-handle-undisplayer handle)
5273 (mm-remove-part handle))))
5275 (mm-display-inline handle)
5278 (defun gnus-mime-set-charset-parameters (handle charset)
5279 "Set CHARSET to parameters in HANDLE.
5280 CHARSET may either be a string or a symbol."
5281 (unless (stringp charset)
5282 (setq charset (symbol-name charset)))
5283 (if (stringp (car handle))
5284 (dolist (h (cdr handle))
5285 (gnus-mime-set-charset-parameters h charset))
5286 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5287 "message/external-body")
5289 (unless (mm-handle-cache handle)
5290 (mm-extern-cache-contents handle))
5291 (mm-handle-cache handle))
5293 (param (assq 'charset (cdr type))))
5295 (setcdr param charset)
5296 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5298 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5299 "Insert the MIME part under point into the current buffer using the
5301 (interactive (list nil current-prefix-arg))
5302 (gnus-article-check-buffer)
5303 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5304 (fun (get-text-property (point) 'gnus-callback))
5305 (gnus-newsgroup-ignored-charsets 'gnus-all)
5306 charset form preferred parts)
5313 gnus-summary-show-article-charset-alist))
5314 (mm-read-coding-system "Charset: "))))
5315 (if (mm-handle-undisplayer handle)
5316 (mm-remove-part handle)))
5317 (gnus-mime-set-charset-parameters handle charset)
5318 (when (and (consp (setq form (cdr-safe fun)))
5319 (setq form (ignore-errors
5320 (assq 'gnus-mime-display-alternative form)))
5321 (setq preferred (caddr form))
5323 (when (eq (car preferred) 'quote)
5324 (setq preferred (cadr preferred)))
5325 (not (equal preferred
5326 (get-text-property (point) 'gnus-data))))
5327 (setq parts (get-text-property (point) 'gnus-part))
5328 (setq parts (cdr (assq parts
5329 gnus-article-mime-handle-alist)))
5330 (equal (mm-handle-media-type parts) "multipart/alternative")
5331 (setq parts (reverse (cdr parts))))
5333 (list 'quote (or (cadr (member preferred parts))
5335 (funcall fun handle)))))
5337 (defun gnus-mime-view-part-externally (&optional handle)
5338 "View the MIME part under point with an external viewer."
5340 (gnus-article-check-buffer)
5341 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5342 (mm-user-display-methods nil)
5343 (mm-inlined-types nil)
5344 (mail-parse-charset gnus-newsgroup-charset)
5345 (mail-parse-ignored-charsets
5346 (with-current-buffer gnus-summary-buffer
5347 gnus-newsgroup-ignored-charsets))
5348 (type (mm-handle-media-type handle))
5349 (method (mailcap-mime-info type))
5350 (mm-enable-external t))
5351 (if (not (stringp method))
5352 (gnus-mime-view-part-as-type
5353 nil (lambda (type) (stringp (mailcap-mime-info type))))
5355 (mm-display-part handle nil t)))))
5357 (defun gnus-mime-view-part-internally (&optional handle)
5358 "View the MIME part under point with an internal viewer.
5359 If no internal viewer is available, use an external viewer."
5361 (gnus-article-check-buffer)
5362 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5363 (mm-inlined-types '(".*"))
5364 (mm-inline-large-images t)
5365 (mail-parse-charset gnus-newsgroup-charset)
5366 (mail-parse-ignored-charsets
5367 (with-current-buffer gnus-summary-buffer
5368 gnus-newsgroup-ignored-charsets))
5369 (inhibit-read-only t))
5370 (if (not (mm-inlinable-p handle))
5371 (gnus-mime-view-part-as-type
5372 nil (lambda (type) (mm-inlinable-p handle type)))
5374 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5376 (defun gnus-mime-action-on-part (&optional action)
5377 "Do something with the MIME attachment at \(point\)."
5379 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5380 (gnus-article-check-buffer)
5381 (let ((action-pair (assoc action gnus-mime-action-alist)))
5383 (funcall (cdr action-pair)))))
5385 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5386 "Call FUNCTION on MIME part N.
5387 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5388 If INTERACTIVE, call FUNCTION interactivly."
5390 ;; Check whether the article is displayed.
5391 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5392 (setq window (get-buffer-window gnus-article-buffer t))
5393 (frame-visible-p (setq frame (window-frame window))))
5394 (error "No article is displayed"))
5395 (with-current-buffer gnus-article-buffer
5396 ;; Check whether the article displays the right contents.
5397 (unless (with-current-buffer gnus-summary-buffer
5398 (eq gnus-current-article (gnus-summary-article-number)))
5399 (error "You should select the right article first"))
5401 (setq n (prefix-numeric-value n))
5403 (setq n (or (get-text-property pt 'gnus-part)
5405 (get-text-property (1- pt) 'gnus-part))
5406 (get-text-property (prog2
5412 (or (and (setq pt (previous-single-property-change
5415 (next-single-property-change (point) 'gnus-part)
5419 ;; Check whether the specified part exists.
5420 (when (> n (length gnus-article-mime-handle-alist))
5421 (error "No such part")))
5424 ;; To select the window is needed so that the cursor
5425 ;; might be visible on the MIME button.
5426 (select-window (prog1
5428 (setq window (selected-window))
5429 ;; Article may be displayed in the other frame.
5430 (gnus-select-frame-set-input-focus
5433 (setq frame (selected-frame))))))
5434 (when (gnus-article-goto-part n)
5435 ;; We point the cursor and the arrow at the MIME button
5436 ;; when the `function' prompt the user for something.
5437 (unless (and (pos-visible-in-window-p)
5438 (> (count-lines (point) (window-end))
5439 (/ (1- (window-height)) 3)))
5440 (recenter (/ (1- (window-height)) 3)))
5441 (let ((cursor-in-non-selected-windows t)
5442 (overlay-arrow-string "=>")
5443 (overlay-arrow-position (point-marker)))
5446 ((and no-handle interactive)
5447 (call-interactively function))
5452 function (get-text-property (point) 'gnus-data)))
5455 (get-text-property (point) 'gnus-data))))
5456 (set-marker overlay-arrow-position nil)
5457 (unless gnus-auto-select-part
5458 (gnus-select-frame-set-input-focus frame)
5459 (select-window window))))
5461 (if gnus-inhibit-mime-unbuttonizing
5462 ;; This is the default though the program shouldn't reach here.
5463 (error "No such part")
5464 ;; The part which doesn't have the MIME button is selected.
5465 ;; So, we display all the buttons and redo it.
5466 (let ((gnus-inhibit-mime-unbuttonizing t))
5467 (gnus-summary-show-article)
5468 (gnus-article-part-wrapper n function no-handle))))))
5470 (defun gnus-article-pipe-part (n)
5471 "Pipe MIME part N, which is the numerical prefix."
5473 (gnus-article-part-wrapper n 'mm-pipe-part))
5475 (defun gnus-article-save-part (n)
5476 "Save MIME part N, which is the numerical prefix."
5478 (gnus-article-part-wrapper n 'mm-save-part))
5480 (defun gnus-article-interactively-view-part (n)
5481 "View MIME part N interactively, which is the numerical prefix."
5483 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5485 (defun gnus-article-copy-part (n)
5486 "Copy MIME part N, which is the numerical prefix."
5488 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5490 (defun gnus-article-view-part-as-charset (n)
5491 "View MIME part N using a specified charset.
5492 N is the numerical prefix."
5494 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5496 (defun gnus-article-view-part-externally (n)
5497 "View MIME part N externally, which is the numerical prefix."
5499 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5501 (defun gnus-article-inline-part (n)
5502 "Inline MIME part N, which is the numerical prefix."
5504 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5506 (defun gnus-article-save-part-and-strip (n)
5507 "Save MIME part N and replace it with an external body.
5508 N is the numerical prefix."
5510 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5512 (defun gnus-article-replace-part (n)
5513 "Replace MIME part N with an external body.
5514 N is the numerical prefix."
5516 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5518 (defun gnus-article-delete-part (n)
5519 "Delete MIME part N and add some information about the removed part.
5520 N is the numerical prefix."
5522 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5524 (defun gnus-article-view-part-as-type (n)
5525 "Choose a MIME media type, and view part N as such.
5526 N is the numerical prefix."
5528 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5530 (defun gnus-article-mime-match-handle-first (condition)
5533 (dolist (ihandle gnus-article-mime-handle-alist)
5535 ((functionp condition)
5536 (funcall condition (cdr ihandle)))
5537 ((eq condition 'undisplayed)
5538 (not (or (mm-handle-undisplayer (cdr ihandle))
5539 (equal (mm-handle-media-type (cdr ihandle))
5540 "multipart/alternative"))))
5541 ((eq condition 'undisplayed-alternative)
5542 (not (mm-handle-undisplayer (cdr ihandle))))
5544 (gnus-article-goto-part (car ihandle))
5545 (or (not n) (< (car ihandle) n)))
5546 (setq n (car ihandle))))
5550 (defun gnus-article-view-part (&optional n)
5551 "View MIME part N, which is the numerical prefix.
5552 If the part is already shown, hide the part. If N is nil, view
5555 (with-current-buffer gnus-article-buffer
5556 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5557 gnus-article-mime-match-handle-function)))
5558 (when (> n (length gnus-article-mime-handle-alist))
5559 (error "No such part"))
5560 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5561 (when (gnus-article-goto-part n)
5562 (if (equal (car handle) "multipart/alternative")
5563 (gnus-article-press-button)
5564 (when (eq (gnus-mm-display-part handle) 'internal)
5565 (gnus-set-window-start)))))))
5567 (defsubst gnus-article-mime-total-parts ()
5568 (if (bufferp (car gnus-article-mime-handles))
5570 (1- (length gnus-article-mime-handles))))
5572 (defun gnus-mm-display-part (handle)
5573 "Display HANDLE and fix MIME button."
5574 (let ((id (get-text-property (point) 'gnus-part))
5576 (inhibit-read-only t))
5579 (let ((window (selected-window))
5580 (mail-parse-charset gnus-newsgroup-charset)
5581 (mail-parse-ignored-charsets
5582 (if (gnus-buffer-live-p gnus-summary-buffer)
5583 (with-current-buffer gnus-summary-buffer
5584 gnus-newsgroup-ignored-charsets)
5588 (let ((win (gnus-get-buffer-window (current-buffer) t))
5591 (select-window win))
5594 (if (mm-handle-displayed-p handle)
5595 ;; This will remove the part.
5596 (mm-display-part handle)
5598 (narrow-to-region (point)
5599 (if (eobp) (point) (1+ (point))))
5600 (gnus-bind-safe-url-regexp (mm-display-part handle))
5601 ;; We narrow to the part itself and
5602 ;; then call the treatment functions.
5603 (goto-char (point-min))
5605 (narrow-to-region (point) (point-max))
5608 (gnus-article-mime-total-parts)
5609 (mm-handle-media-type handle)))))
5610 (if (window-live-p window)
5611 (select-window window)))))
5614 (gnus-insert-mime-button
5615 handle id (list (mm-handle-displayed-p handle)))
5616 (goto-char point))))
5618 (defun gnus-article-goto-part (n)
5619 "Go to MIME part N."
5620 (when gnus-break-pages
5623 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5624 part handle end next handles)
5627 (if (setq handle (get-text-property start 'gnus-data))
5629 ;; Go to the displayed subpart, assuming this is
5630 ;; multipart/alternative.
5633 (while (and (not handle)
5636 (setq next (text-property-not-all part end
5639 handle (get-text-property part 'gnus-data))
5640 (push (cons handle part) handles)
5641 (unless (mm-handle-displayed-p handle)
5643 part (text-property-any part end 'gnus-data nil))))
5645 ;; No subpart is displayed, so we find preferred one.
5647 (cdr (assq (mm-preferred-alternative
5648 (nreverse (mapcar 'car handles)))
5651 (goto-char (1+ part))
5653 (when gnus-break-pages
5654 (gnus-narrow-to-page))))
5656 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5657 (let ((gnus-tmp-name
5658 (or (mail-content-type-get (mm-handle-type handle) 'name)
5659 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5660 (mail-content-type-get (mm-handle-type handle) 'url)
5662 (gnus-tmp-type (mm-handle-media-type handle))
5663 (gnus-tmp-description (or (mm-handle-description handle) ""))
5665 (if (if displayed (car displayed)
5666 (mm-handle-displayed-p handle))
5668 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5670 gnus-tmp-type-long b e)
5671 (when (string-match ".*/" gnus-tmp-name)
5672 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5673 (setq gnus-tmp-type-long (concat gnus-tmp-type
5674 (and (not (equal gnus-tmp-name ""))
5675 (concat "; " gnus-tmp-name))))
5676 (unless (equal gnus-tmp-description "")
5677 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5682 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5683 `(keymap ,gnus-mime-button-map
5684 gnus-callback gnus-mm-display-part
5685 gnus-part ,gnus-tmp-id
5686 article-type annotation
5689 ;; Exclude a newline.
5692 (when gnus-article-button-face
5693 (gnus-overlay-put (gnus-make-overlay b e nil t)
5694 'face gnus-article-button-face))
5695 (widget-convert-button
5698 :action 'gnus-widget-press-button
5699 :button-keymap gnus-mime-button-map
5702 ;; Needed to properly clear the message due to a bug in
5703 ;; wid-edit (XEmacs only).
5704 (if (boundp 'help-echo-owns-message)
5705 (setq help-echo-owns-message t))
5707 "%S: %s the MIME part; %S: more options"
5708 (aref gnus-mouse-2 0)
5709 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5711 (aref gnus-down-mouse-3 0))))))
5713 (defun gnus-widget-press-button (elems el)
5714 (goto-char (widget-get elems :from))
5715 (gnus-article-press-button))
5717 (defvar gnus-displaying-mime nil)
5719 (defun gnus-display-mime (&optional ihandles)
5720 "Display the MIME parts."
5722 (save-selected-window
5723 (let ((window (get-buffer-window gnus-article-buffer))
5726 (select-window window)
5727 ;; We have to do this since selecting the window
5728 ;; may change the point. So we set the window point.
5729 (set-window-point window point)))
5730 (let ((handles ihandles)
5731 (inhibit-read-only t)
5734 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5735 (when gnus-article-emulate-mime
5736 (mm-uu-dissect-text-parts handles)))
5737 (gnus-article-emulate-mime
5738 (setq handles (mm-uu-dissect))))
5739 (when (and (not ihandles)
5740 (not gnus-displaying-mime))
5741 ;; Top-level call; we clean up.
5742 (when gnus-article-mime-handles
5743 (mm-destroy-parts gnus-article-mime-handles)
5744 (setq gnus-article-mime-handle-alist nil));; A trick.
5745 (setq gnus-article-mime-handles handles)
5746 ;; We allow users to glean info from the handles.
5747 (when gnus-article-mime-part-function
5748 (gnus-mime-part-function handles)))
5750 (or (not (stringp (car handles)))
5753 (when (and (not ihandles)
5754 (not gnus-displaying-mime))
5755 ;; Clean up for mime parts.
5757 (delete-region (point) (point-max)))
5758 (let ((gnus-displaying-mime t))
5759 (gnus-mime-display-part handles)))
5762 (narrow-to-region (point) (point-max))
5763 (gnus-treat-article nil 1 1 "text/plain")
5766 ;; Highlight the headers.
5770 (narrow-to-region (point-min) (point))
5771 (gnus-article-save-original-date
5772 (gnus-treat-article 'head)))))))
5773 ;; Cope with broken MIME messages.
5774 (goto-char (point-max))
5778 (defcustom gnus-mime-display-multipart-as-mixed nil
5779 "Display \"multipart\" parts as \"multipart/mixed\".
5781 If t, it overrides nil values of
5782 `gnus-mime-display-multipart-alternative-as-mixed' and
5783 `gnus-mime-display-multipart-related-as-mixed'."
5784 :group 'gnus-article-mime
5787 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5788 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5790 :group 'gnus-article-mime
5793 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5794 "Display \"multipart/related\" parts as \"multipart/mixed\".
5796 If displaying \"text/html\" is discouraged \(see
5797 `mm-discouraged-alternatives'\) images or other material inside a
5798 \"multipart/related\" part might be overlooked when this variable is nil."
5800 :group 'gnus-article-mime
5803 (defun gnus-mime-display-part (handle)
5805 ;; Maybe a broken MIME message.
5808 ((not (stringp (car handle)))
5809 (gnus-mime-display-single handle))
5810 ;; User-defined multipart
5811 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5812 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5814 ;; multipart/alternative
5815 ((and (equal (car handle) "multipart/alternative")
5816 (not (or gnus-mime-display-multipart-as-mixed
5817 gnus-mime-display-multipart-alternative-as-mixed)))
5818 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5819 (push (cons id handle) gnus-article-mime-handle-alist)
5820 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5821 ;; multipart/related
5822 ((and (equal (car handle) "multipart/related")
5823 (not (or gnus-mime-display-multipart-as-mixed
5824 gnus-mime-display-multipart-related-as-mixed)))
5825 ;;;!!!We should find the start part, but we just default
5826 ;;;!!!to the first part.
5827 ;;(gnus-mime-display-part (cadr handle))
5828 ;;;!!! Most multipart/related is an HTML message plus images.
5829 ;;;!!! Unfortunately we are unable to let W3 display those
5830 ;;;!!! included images, so we just display it as a mixed multipart.
5831 ;;(gnus-mime-display-mixed (cdr handle))
5832 ;;;!!! No, w3 can display everything just fine.
5833 (gnus-mime-display-part (cadr handle)))
5834 ((equal (car handle) "multipart/signed")
5835 (gnus-add-wash-type 'signed)
5836 (gnus-mime-display-security handle))
5837 ((equal (car handle) "multipart/encrypted")
5838 (gnus-add-wash-type 'encrypted)
5839 (gnus-mime-display-security handle))
5840 ;; Other multiparts are handled like multipart/mixed.
5842 (gnus-mime-display-mixed (cdr handle)))))
5844 (defun gnus-mime-part-function (handles)
5845 (if (stringp (car handles))
5846 (mapcar 'gnus-mime-part-function (cdr handles))
5847 (funcall gnus-article-mime-part-function handles)))
5849 (defun gnus-mime-display-mixed (handles)
5850 (mapcar 'gnus-mime-display-part handles))
5852 (defun gnus-mime-display-single (handle)
5853 (let ((type (mm-handle-media-type handle))
5854 (ignored gnus-ignored-mime-types)
5861 (when (string-match (pop ignored) type)
5862 (throw 'ignored nil)))
5863 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5864 (with-current-buffer gnus-summary-buffer
5865 gnus-inhibit-images)
5866 gnus-inhibit-images)
5867 (string-match "\\`image/" type)))
5868 (setq not-attachment
5869 (and (not (mm-inline-override-p handle))
5870 (or (not (mm-handle-disposition handle))
5871 (equal (car (mm-handle-disposition handle))
5873 (mm-attachment-override-p handle))))
5874 (mm-automatic-display-p handle)
5876 (mm-inlinable-p handle)
5877 (mm-inlined-p handle))
5878 (mm-automatic-external-display-p type)))
5880 (when (equal (mm-handle-media-supertype handle) "text")
5882 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5884 (push (cons id handle) gnus-article-mime-handle-alist)
5886 (equal (mm-handle-media-supertype handle) "message"))
5889 (cond ((not (bolp)) 2)
5890 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5892 (when (or (not display)
5893 (not (gnus-unbuttonized-mime-type-p type))
5894 (eq id gnus-mime-buttonized-part-id))
5895 (gnus-insert-mime-button
5896 handle id (list (or display (and not-attachment text))))
5897 (gnus-article-insert-newline)
5898 ;; Remember modify the number of forward lines.
5906 (let ((mail-parse-charset gnus-newsgroup-charset)
5907 (mail-parse-ignored-charsets
5908 (save-excursion (condition-case ()
5909 (set-buffer gnus-summary-buffer)
5911 gnus-newsgroup-ignored-charsets)))
5912 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5913 (goto-char (point-max)))
5914 ((and text not-attachment)
5918 (gnus-article-insert-newline)
5919 (mm-display-inline handle)
5920 (goto-char (point-max))))
5924 (narrow-to-region beg (point))
5925 (if (eq handle gnus-article-mime-handles)
5926 ;; The format=flowed case.
5927 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5928 ;; Don't count signature parts that are never displayed.
5929 ;; The part number should be re-calculated supposing this
5930 ;; might be a message/rfc822 part.
5932 (dolist (part gnus-article-mime-handles)
5933 (unless (or (stringp part)
5934 (equal (car (mm-handle-type part))
5935 "application/pgp-signature"))
5936 (push part handles)))
5938 nil (length (memq handle handles)) (length handles)
5939 (mm-handle-media-type handle)))))))))))
5941 (defun gnus-unbuttonized-mime-type-p (type)
5942 "Say whether TYPE is to be unbuttonized."
5943 (unless gnus-inhibit-mime-unbuttonizing
5945 (let ((types gnus-unbuttonized-mime-types))
5947 (when (string-match (pop types) type)
5948 (throw 'found t)))))
5950 (let ((types gnus-buttonized-mime-types))
5952 (when (string-match (pop types) type)
5953 (throw 'found t)))))))))
5955 (defun gnus-article-insert-newline ()
5956 "Insert a newline, but mark it as undeletable."
5957 (gnus-put-text-property
5958 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5960 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5961 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5964 handle (inhibit-read-only t) from props begend not-pref)
5965 (save-window-excursion
5968 (narrow-to-region (car ibegend)
5971 (goto-char (car ibegend))
5974 (delete-region (point-min) (point-max))
5975 (mm-remove-parts handles))
5976 (setq begend (list (point-marker)))
5978 (unless (setq not-pref (cadr (member preferred ihandles)))
5979 (setq not-pref (car ihandles)))
5982 (not (gnus-unbuttonized-mime-type-p
5983 "multipart/alternative")))
5984 (gnus-add-text-properties
5987 (insert (format "%d. " id))
5991 (unless ,(not ibegend)
5992 (setq gnus-article-mime-handle-alist
5993 ',gnus-article-mime-handle-alist))
5994 (gnus-mime-display-alternative
5995 ',ihandles ',not-pref ',begend ,id))
5996 keymap ,gnus-mime-button-map
5997 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5998 face ,gnus-article-button-face
6000 article-type multipart))
6001 (widget-convert-button 'link from (point)
6002 :action 'gnus-widget-press-button
6003 :button-keymap gnus-widget-button-keymap)
6005 (while (setq handle (pop handles))
6006 (gnus-add-text-properties
6009 (insert (format "(%c) %-18s"
6010 (if (equal handle preferred) ?* ? )
6011 (mm-handle-media-type handle)))
6015 (unless ,(not ibegend)
6016 (setq gnus-article-mime-handle-alist
6017 ',gnus-article-mime-handle-alist))
6018 (gnus-mime-display-alternative
6019 ',ihandles ',handle ',begend ,id))
6020 keymap ,gnus-mime-button-map
6021 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6022 face ,gnus-article-button-face
6025 (widget-convert-button 'link from (point)
6026 :action 'gnus-widget-press-button
6027 :button-keymap gnus-widget-button-keymap)
6031 (if (stringp (car preferred))
6032 (gnus-display-mime preferred)
6033 (let ((mail-parse-charset gnus-newsgroup-charset)
6034 (mail-parse-ignored-charsets
6035 (with-current-buffer gnus-summary-buffer
6036 gnus-newsgroup-ignored-charsets)))
6037 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6041 (narrow-to-region (car begend) (point-max))
6043 nil (length gnus-article-mime-handle-alist)
6044 (gnus-article-mime-total-parts)
6045 (mm-handle-media-type preferred))))))
6046 (goto-char (point-max))
6047 (setcdr begend (point-marker)))))
6049 (goto-char point))))
6051 (defconst gnus-article-wash-status-strings
6052 (let ((alist '((cite "c" "Possible hidden citation text"
6053 " " "All citation text visible")
6054 (headers "h" "Hidden headers"
6055 " " "All headers visible.")
6056 (pgp "p" "Encrypted or signed message status hidden"
6057 " " "No hidden encryption nor digital signature status")
6058 (signature "s" "Signature has been hidden"
6059 " " "Signature is visible")
6060 (overstrike "o" "Overstrike (^H) characters applied"
6061 " " "No overstrike characters applied")
6062 (emphasis "e" "/*_Emphasis_*/ characters applied"
6063 " " "No /*_emphasis_*/ characters applied")))
6065 (dolist (entry alist result)
6066 (let ((key (nth 0 entry))
6067 (on (copy-sequence (nth 1 entry)))
6068 (on-help (nth 2 entry))
6069 (off (copy-sequence (nth 3 entry)))
6070 (off-help (nth 4 entry)))
6071 (put-text-property 0 1 'help-echo on-help on)
6072 (put-text-property 0 1 'help-echo off-help off)
6073 (push (list key on off) result))))
6074 "Alist of strings describing wash status in the mode line.
6075 Each entry has the form (KEY ON OF), where the KEY is a symbol
6076 representing the particular washing function, ON is the string to use
6077 in the article mode line when the washing function is active, and OFF
6078 is the string to use when it is inactive.")
6080 (defun gnus-article-wash-status-entry (key value)
6081 (let ((entry (assoc key gnus-article-wash-status-strings)))
6082 (if value (nth 1 entry) (nth 2 entry))))
6084 (defun gnus-article-wash-status ()
6085 "Return a string which display status of article washing."
6086 (with-current-buffer gnus-article-buffer
6087 (let ((cite (memq 'cite gnus-article-wash-types))
6088 (headers (memq 'headers gnus-article-wash-types))
6089 (boring (memq 'boring-headers gnus-article-wash-types))
6090 (pgp (memq 'pgp gnus-article-wash-types))
6091 (pem (memq 'pem gnus-article-wash-types))
6092 (signed (memq 'signed gnus-article-wash-types))
6093 (encrypted (memq 'encrypted gnus-article-wash-types))
6094 (signature (memq 'signature gnus-article-wash-types))
6095 (overstrike (memq 'overstrike gnus-article-wash-types))
6096 (emphasis (memq 'emphasis gnus-article-wash-types)))
6098 (gnus-article-wash-status-entry 'cite cite)
6099 (gnus-article-wash-status-entry 'headers (or headers boring))
6100 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6101 (gnus-article-wash-status-entry 'signature signature)
6102 (gnus-article-wash-status-entry 'overstrike overstrike)
6103 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6105 (defun gnus-add-wash-type (type)
6106 "Add a washing of TYPE to the current status."
6107 (add-to-list 'gnus-article-wash-types type))
6109 (defun gnus-delete-wash-type (type)
6110 "Add a washing of TYPE to the current status."
6111 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6113 (defun gnus-add-image (category image)
6114 "Add IMAGE of CATEGORY to the list of displayed images."
6115 (let ((entry (assq category gnus-article-image-alist)))
6117 (setq entry (list category))
6118 (push entry gnus-article-image-alist))
6119 (nconc entry (list image))))
6121 (defun gnus-delete-images (category)
6122 "Delete all images in CATEGORY."
6123 (let ((entry (assq category gnus-article-image-alist)))
6124 (dolist (image (cdr entry))
6125 (gnus-remove-image image category))
6126 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6127 (gnus-delete-wash-type category)))
6129 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6131 (defun gnus-article-maybe-hide-headers ()
6132 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6133 Provided for backwards compatibility."
6134 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6135 (not (with-current-buffer gnus-summary-buffer
6136 gnus-have-all-headers)))
6137 (not gnus-inhibit-hiding))
6138 (gnus-article-hide-headers)))
6142 (defun gnus-output-to-file (file-name)
6143 "Append the current article to a file named FILE-NAME.
6144 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6145 text and used as the value of the coding cookie which is added to the
6146 top of a file. Otherwise, this function saves a raw article without
6148 (let* ((artbuf (current-buffer))
6149 (file-name-coding-system nnmail-pathname-coding-system)
6150 (coding gnus-article-save-coding-system)
6151 (coding-system-for-read (if coding
6152 nil ;; Rely on the coding cookie.
6153 mm-text-coding-system))
6154 (coding-system-for-write (or coding
6155 mm-text-coding-system-for-write
6156 mm-text-coding-system))
6157 (exists (file-exists-p file-name)))
6160 (insert-file-contents file-name)
6161 (goto-char (point-min))
6162 ;; Remove the existing coding cookie.
6163 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6164 (delete-region (match-beginning 0) (match-end 0))))
6165 (goto-char (point-max))
6166 (insert-buffer-substring artbuf)
6167 ;; Append newline at end of the buffer as separator, and then
6169 (goto-char (point-max))
6172 ;; If the coding system is not suitable to encode the text,
6173 ;; ask a user for a proper one.
6174 (when (fboundp 'select-safe-coding-system)
6175 (setq coding (coding-system-base
6176 (save-window-excursion
6177 (select-safe-coding-system (point-min) (point-max)
6179 (setq coding-system-for-write
6180 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6182 (goto-char (point-min))
6183 ;; Add the coding cookie.
6184 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6185 coding-system-for-write)))
6188 (write-region (point-min) (point-max) file-name nil 'no-message)
6189 (message "Appended to %s" file-name))
6190 (write-region (point-min) (point-max) file-name))))
6193 (defun gnus-narrow-to-page (&optional arg)
6194 "Narrow the article buffer to a page.
6195 If given a numerical ARG, move forward ARG pages."
6197 (setq arg (if arg (prefix-numeric-value arg) 0))
6198 (with-current-buffer gnus-article-buffer
6200 ;; Remove any old next/prev buttons.
6201 (when (gnus-visual-p 'page-marker)
6202 (let ((inhibit-read-only t))
6203 (gnus-remove-text-with-property 'gnus-prev)
6204 (gnus-remove-text-with-property 'gnus-next)))
6206 (when (save-excursion
6208 (if (re-search-backward page-delimiter nil 'move (abs arg))
6210 (setq nd (match-beginning 0)
6212 (when (re-search-backward page-delimiter nil t)
6213 (setq st (match-end 0))))
6214 (when (re-search-forward page-delimiter nil t)
6215 (setq nd (match-beginning 0)
6218 (if (re-search-forward page-delimiter nil 'move arg)
6220 (setq st (match-end 0)
6222 (when (re-search-forward page-delimiter nil t)
6223 (setq nd (match-beginning 0))))
6224 (when (re-search-backward page-delimiter nil t)
6225 (setq st (match-end 0)
6228 (when (re-search-backward page-delimiter nil t)
6229 (goto-char (setq st (match-end 0))))
6230 (when (re-search-forward page-delimiter nil t)
6231 (setq nd (match-beginning 0)))
6233 (setq gnus-page-broken t)
6234 (when pt (goto-char pt))
6235 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6236 (when (gnus-visual-p 'page-marker)
6240 (gnus-insert-next-page-button))
6243 (gnus-insert-prev-page-button))))))))
6245 ;; Article mode commands
6247 (defun gnus-article-goto-next-page ()
6248 "Show the next page of the article."
6250 (when (gnus-article-next-page)
6251 (goto-char (point-min))
6252 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6255 (defun gnus-article-goto-prev-page ()
6256 "Show the previous page of the article."
6258 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6259 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6260 (gnus-article-prev-page nil)))
6262 ;; This is cleaner but currently breaks `gnus-pick-mode':
6264 ;; (defun gnus-article-goto-next-page ()
6265 ;; "Show the next page of the article."
6267 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6268 ;; (gnus-summary-next-page)))
6270 ;; (defun gnus-article-goto-prev-page ()
6271 ;; "Show the next page of the article."
6273 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6274 ;; (gnus-summary-prev-page)))
6276 (defun gnus-article-next-page (&optional lines)
6277 "Show the next page of the current article.
6278 If end of article, return non-nil. Otherwise return nil.
6279 Argument LINES specifies lines to be scrolled up."
6281 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6282 (if (and (not (and gnus-article-over-scroll
6283 (> (count-lines (window-start) (point-max))
6284 (if (featurep 'xemacs)
6285 (or lines (1- (window-height)))
6286 (+ (or lines (1- (window-height))) scroll-margin)))))
6289 (and (pos-visible-in-window-p) ;Not continuation line.
6290 (>= (point) (point-max)))))
6291 ;; Nothing in this page.
6292 (if (or (not gnus-page-broken)
6297 (eobp)))) ;Real end-of-buffer?
6299 (when gnus-article-over-scroll
6300 (gnus-article-next-page-1 lines))
6302 (gnus-narrow-to-page 1) ;Go to next page.
6304 ;; More in this page.
6305 (gnus-article-next-page-1 lines)
6308 (defun gnus-article-beginning-of-window ()
6309 "Move point to the beginning of the window.
6310 In Emacs, the point is placed at the line number which `scroll-margin'
6312 (if (featurep 'xemacs)
6313 (move-to-window-line 0)
6314 ;; There is an obscure bug in Emacs that makes it impossible to
6315 ;; scroll past big pictures in the article buffer. Try to fix
6316 ;; this by adding a sanity check by counting the lines visible.
6317 (when (> (count-lines (window-start) (window-end)) 30)
6318 (move-to-window-line
6319 (min (max 0 scroll-margin)
6320 (max 1 (- (window-height)
6321 (if mode-line-format 1 0)
6322 (if header-line-format 1 0)
6325 (defun gnus-article-next-page-1 (lines)
6327 (let ((scroll-in-place nil))
6330 ;; Long lines may cause an end-of-buffer error.
6331 (goto-char (point-max))))
6332 (gnus-article-beginning-of-window))
6334 (defun gnus-article-prev-page (&optional lines)
6335 "Show previous page of current article.
6336 Argument LINES specifies lines to be scrolled down."
6338 (move-to-window-line 0)
6339 (if (and gnus-page-broken
6341 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6343 (gnus-narrow-to-page -1) ;Go to previous page.
6344 (goto-char (point-max))
6345 (recenter (if gnus-article-over-scroll
6347 (max (if (featurep 'xemacs)
6349 (+ lines scroll-margin))
6351 (- (window-height) 2))
6355 (let ((scroll-in-place nil))
6356 (scroll-down lines))
6357 (beginning-of-buffer
6358 (goto-char (point-min))))
6359 (gnus-article-beginning-of-window))))
6361 (defun gnus-article-only-boring-p ()
6362 "Decide whether there is only boring text remaining in the article.
6363 Something \"interesting\" is a word of at least two letters that does
6364 not have a face in `gnus-article-boring-faces'."
6365 (when (and gnus-article-skip-boring
6366 (boundp 'gnus-article-boring-faces)
6367 (symbol-value 'gnus-article-boring-faces))
6369 (let ((inhibit-point-motion-hooks t))
6371 (while (re-search-forward "\\b\\w\\w" nil t)
6373 (when (not (gnus-intersection
6374 (gnus-faces-at (point))
6375 (symbol-value 'gnus-article-boring-faces)))
6376 (throw 'only-boring nil)))
6377 (throw 'only-boring t))))))
6379 (defun gnus-article-refer-article ()
6380 "Read article specified by message-id around point."
6383 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6384 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6385 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6386 (let ((msg-id (concat "<" (match-string 0) ">")))
6387 (set-buffer gnus-summary-buffer)
6388 (gnus-summary-refer-article msg-id))
6389 (error "No references around point"))))
6391 (defun gnus-article-show-summary ()
6392 "Reconfigure windows to show summary buffer."
6394 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6395 (error "There is no summary buffer for this article buffer")
6396 (gnus-article-set-globals)
6397 (gnus-configure-windows 'article)
6398 (gnus-summary-goto-subject gnus-current-article)
6399 (gnus-summary-position-point)))
6401 (defun gnus-article-describe-briefly ()
6402 "Describe article mode commands briefly."
6404 (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")))
6406 (defun gnus-article-check-buffer ()
6407 "Beep if not in an article buffer."
6408 (unless (equal major-mode 'gnus-article-mode)
6409 (error "Command invoked outside of a Gnus article buffer")))
6411 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6412 "Read a summary buffer key sequence and execute it from the article buffer."
6414 (gnus-article-check-buffer)
6416 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6417 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6418 "=" "^" "\M-^" "|"))
6420 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6421 "An" "Ap" [?A (meta return)] [?A delete]))
6425 '("n" "Gn" "p" "Gp"))
6427 (with-current-buffer gnus-article-current-summary
6428 (let (gnus-pick-mode)
6429 (setq unread-command-events (nconc unread-command-events
6430 (list (or key last-command-event)))
6431 keys (if (featurep 'xemacs)
6432 (events-to-keys (read-key-sequence nil t))
6433 (read-key-sequence nil t)))))
6438 ((eq (aref keys (1- (length keys))) ?\C-h)
6439 (gnus-article-describe-bindings (substring keys 0 -1)))
6440 ((or (member keys nosaves)
6441 (member keys nosave-but-article)
6442 (member keys nosave-in-article))
6444 (save-window-excursion
6445 (pop-to-buffer gnus-article-current-summary)
6446 ;; We disable the pick minor mode commands.
6447 (let (gnus-pick-mode)
6448 (setq func (key-binding keys t))))
6452 (unless (member keys nosave-in-article)
6453 (set-buffer gnus-article-current-summary))
6454 (when (get func 'disabled)
6455 (error "Function %s disabled" func))
6456 (call-interactively func)
6457 (setq new-sum-point (point)))
6458 (when (member keys nosave-but-article)
6459 (pop-to-buffer gnus-article-buffer))))
6461 ;; These commands should restore window configuration.
6462 (let ((obuf (current-buffer))
6463 (owin (current-window-configuration))
6464 win func in-buffer selected new-sum-start new-sum-hscroll err)
6465 (cond (not-restore-window
6466 (pop-to-buffer gnus-article-current-summary)
6467 (setq win (selected-window)))
6468 ((setq win (get-buffer-window gnus-article-current-summary))
6469 (select-window win))
6471 (let ((summary-buffer gnus-article-current-summary))
6472 (gnus-configure-windows 'article)
6473 (unless (setq win (get-buffer-window summary-buffer 'visible))
6474 (let ((gnus-buffer-configuration
6475 '((article ((vertical 1.0
6476 (summary 0.25 point)
6478 (gnus-configure-windows 'article))
6479 (setq win (get-buffer-window summary-buffer 'visible)))
6480 (gnus-select-frame-set-input-focus (window-frame win))
6481 (select-window win))))
6482 (setq in-buffer (current-buffer))
6483 ;; We disable the pick minor mode commands.
6484 (setq func (let (gnus-pick-mode)
6485 (key-binding keys t)))
6486 (when (get func 'disabled)
6487 (error "Function %s disabled" func))
6490 (condition-case code
6492 (call-interactively func)
6498 (when (eq win (selected-window))
6499 (setq new-sum-point (point)
6500 new-sum-start (window-start win)
6501 new-sum-hscroll (window-hscroll win)))
6502 (when (or (eq in-buffer (current-buffer))
6503 (when (eq obuf (current-buffer))
6504 (set-buffer in-buffer)
6506 (setq selected (gnus-summary-select-article))
6508 (unless not-restore-window
6509 (set-window-configuration owin))
6510 (when (and (eq selected 'old)
6512 (set-window-start (get-buffer-window (current-buffer))
6514 (set-window-point (get-buffer-window (current-buffer))
6515 (if (article-goto-body)
6518 (when (and (not not-restore-window)
6521 (with-current-buffer (window-buffer win)
6522 (eq major-mode 'gnus-summary-mode)))
6523 (set-window-point win new-sum-point)
6524 (set-window-start win new-sum-start)
6525 (set-window-hscroll win new-sum-hscroll))))
6526 (set-window-configuration owin)
6528 (signal (car err) (cdr err))
6531 (defun gnus-article-read-summary-send-keys ()
6533 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6534 (gnus-article-read-summary-keys)))
6536 (defun gnus-article-describe-key (key)
6537 "Display documentation of the function invoked by KEY.
6538 KEY is a string or a vector."
6539 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6540 (read-key-sequence "Describe key: "))))
6541 (gnus-article-check-buffer)
6542 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6543 gnus-article-read-summary-send-keys))
6544 (with-current-buffer gnus-article-current-summary
6545 (setq unread-command-events
6546 (if (featurep 'xemacs)
6548 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6549 (list 'meta (- x 128))
6552 (let ((cursor-in-echo-area t)
6554 (describe-key (read-key-sequence nil t))))
6555 (describe-key key)))
6557 (defun gnus-article-describe-key-briefly (key &optional insert)
6558 "Display documentation of the function invoked by KEY.
6559 KEY is a string or a vector."
6560 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6561 (read-key-sequence "Describe key: "))
6562 current-prefix-arg))
6563 (gnus-article-check-buffer)
6564 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6565 gnus-article-read-summary-send-keys))
6566 (with-current-buffer gnus-article-current-summary
6567 (setq unread-command-events
6568 (if (featurep 'xemacs)
6570 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6571 (list 'meta (- x 128))
6574 (let ((cursor-in-echo-area t)
6576 (describe-key-briefly (read-key-sequence nil t) insert)))
6577 (describe-key-briefly key insert)))
6579 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6580 (defvar gnus-agent-summary-mode)
6581 (defvar gnus-draft-mode)
6582 ;; Calling help-buffer will autoload help-mode.
6583 (defvar help-xref-stack-item)
6584 ;; Emacs 22 doesn't load it in the batch mode.
6586 (autoload 'help-buffer "help-mode"))
6588 (defun gnus-article-describe-bindings (&optional prefix)
6589 "Show a list of all defined keys, and their definitions.
6590 The optional argument PREFIX, if non-nil, should be a key sequence;
6591 then we display only bindings that start with that prefix."
6593 (gnus-article-check-buffer)
6594 (let ((keymap (copy-keymap gnus-article-mode-map))
6595 (map (copy-keymap gnus-article-send-map))
6596 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6598 (define-key keymap "S" map)
6599 (define-key map [t] nil)
6600 (with-current-buffer gnus-article-current-summary
6603 (if (setq parent (keymap-parent gnus-article-mode-map))
6605 (setq parent (copy-keymap parent))
6606 (set-keymap-parent parent (current-local-map)))
6607 (current-local-map)))
6608 (set-keymap-parent map (key-binding "S"))
6609 (let (key def gnus-pick-mode)
6611 (setq key (pop sumkeys))
6612 (cond ((and (vectorp key) (= (length key) 1)
6613 (consp (setq def (aref key 0)))
6614 (numberp (car def)) (numberp (cdr def)))
6615 (when (< (max (car def) (cdr def)) 128)
6619 (nreverse (gnus-uncompress-range def)))
6621 ((setq def (key-binding key))
6622 (unless (eq def 'undefined)
6623 (define-key keymap key def))))))
6624 (when (boundp 'gnus-agent-summary-mode)
6625 (setq agent gnus-agent-summary-mode))
6626 (when (boundp 'gnus-draft-mode)
6627 (setq draft gnus-draft-mode)))
6629 (use-local-map keymap)
6630 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6631 (set (make-local-variable 'gnus-draft-mode) draft)
6632 (describe-bindings prefix))
6633 (let ((item `((lambda (prefix)
6634 (with-current-buffer ,(current-buffer)
6635 (gnus-article-describe-bindings prefix)))
6637 (with-current-buffer (let (help-xref-following) (help-buffer))
6638 (setq help-xref-stack-item item)))))
6640 (defun gnus-article-reply-with-original (&optional wide)
6641 "Start composing a reply mail to the current message.
6642 The text in the region will be yanked. If the region isn't active,
6643 the entire article will be yanked."
6645 (let ((article (cdr gnus-article-current))
6647 (if (not (gnus-region-active-p))
6648 (with-current-buffer gnus-summary-buffer
6649 (gnus-summary-reply (list (list article)) wide))
6650 (setq contents (buffer-substring (point) (mark t)))
6651 ;; Deactivate active regions.
6652 (when (and (boundp 'transient-mark-mode)
6653 transient-mark-mode)
6654 (setq mark-active nil))
6655 (with-current-buffer gnus-summary-buffer
6657 (list (list article contents)) wide)))))
6659 (defun gnus-article-wide-reply-with-original ()
6660 "Start composing a wide reply mail to the current message.
6661 The text in the region will be yanked. If the region isn't active,
6662 the entire article will be yanked."
6664 (gnus-article-reply-with-original t))
6666 (defun gnus-article-followup-with-original ()
6667 "Compose a followup to the current article.
6668 The text in the region will be yanked. If the region isn't active,
6669 the entire article will be yanked."
6671 (let ((article (cdr gnus-article-current))
6673 (if (not (gnus-region-active-p))
6674 (with-current-buffer gnus-summary-buffer
6675 (gnus-summary-followup (list (list article))))
6676 (setq contents (buffer-substring (point) (mark t)))
6677 ;; Deactivate active regions.
6678 (when (and (boundp 'transient-mark-mode)
6679 transient-mark-mode)
6680 (setq mark-active nil))
6681 (with-current-buffer gnus-summary-buffer
6682 (gnus-summary-followup
6683 (list (list article contents)))))))
6685 (defun gnus-article-hide (&optional arg force)
6686 "Hide all the gruft in the current article.
6687 This means that signatures, cited text and (some) headers will be
6689 If given a prefix, show the hidden text instead."
6690 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6691 (gnus-article-hide-headers arg)
6692 (gnus-article-hide-list-identifiers arg)
6693 (gnus-article-hide-citation-maybe arg force)
6694 (gnus-article-hide-signature arg))
6696 (defun gnus-article-maybe-highlight ()
6697 "Do some article highlighting if article highlighting is requested."
6698 (when (gnus-visual-p 'article-highlight 'highlight)
6699 (gnus-article-highlight-some)))
6701 (defun gnus-check-group-server ()
6702 ;; Make sure the connection to the server is alive.
6703 (unless (gnus-server-opened
6704 (gnus-find-method-for-group gnus-newsgroup-name))
6705 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6706 (gnus-request-group gnus-newsgroup-name t)))
6709 (autoload 'nneething-get-file-name "nneething"))
6711 (defun gnus-request-article-this-buffer (article group)
6712 "Get an article and insert it into this buffer."
6713 (let (do-update-line sparse-header)
6717 (gnus-kill-all-overlays)
6718 (setq group (or group gnus-newsgroup-name))
6720 ;; Using `gnus-request-article' directly will insert the article into
6721 ;; `nntp-server-buffer' - so we'll save some time by not having to
6722 ;; copy it from the server buffer into the article buffer.
6724 ;; We only request an article by message-id when we do not have the
6725 ;; headers for it, so we'll have to get those.
6726 (when (stringp article)
6727 (gnus-read-header article))
6729 ;; If the article number is negative, that means that this article
6730 ;; doesn't belong in this newsgroup (possibly), so we find its
6731 ;; message-id and request it by id instead of number.
6732 (when (and (numberp article)
6734 (get-buffer gnus-summary-buffer)
6735 (gnus-buffer-exists-p gnus-summary-buffer))
6736 (with-current-buffer gnus-summary-buffer
6737 (let ((header (gnus-summary-article-header article)))
6740 ((memq article gnus-newsgroup-sparse)
6741 ;; This is a sparse gap article.
6742 (setq do-update-line article)
6743 (setq article (mail-header-id header))
6744 (setq sparse-header (gnus-read-header article))
6745 (setq gnus-newsgroup-sparse
6746 (delq article gnus-newsgroup-sparse)))
6748 ;; It's a real article.
6749 (setq article (mail-header-id header)))
6751 ;; It is an extracted pseudo-article.
6752 (setq article 'pseudo)
6753 (gnus-request-pseudo-article header))))
6755 (let ((method (gnus-find-method-for-group
6756 gnus-newsgroup-name)))
6757 (when (and (eq (car method) 'nneething)
6759 (let ((dir (nneething-get-file-name
6760 (mail-header-id header))))
6761 (when (and (stringp dir)
6762 (file-directory-p dir))
6763 (setq article 'nneething)
6764 (gnus-group-enter-directory dir))))))))
6767 ;; Refuse to select canceled articles.
6768 ((and (numberp article)
6770 (get-buffer gnus-summary-buffer)
6771 (gnus-buffer-exists-p gnus-summary-buffer)
6772 (eq (cdr (with-current-buffer gnus-summary-buffer
6773 (assq article gnus-newsgroup-reads)))
6774 gnus-canceled-mark))
6776 ;; We first check `gnus-original-article-buffer'.
6777 ((and (get-buffer gnus-original-article-buffer)
6779 (with-current-buffer gnus-original-article-buffer
6780 (and (equal (car gnus-original-article) group)
6781 (eq (cdr gnus-original-article) article))))
6782 ;; `insert-buffer-substring' would incorrectly use the
6783 ;; equivalent of string-make-multibyte which amount to decoding
6784 ;; with locale-coding-system, causing failure of
6785 ;; subsequent decoding.
6786 (insert (mm-string-to-multibyte
6787 (with-current-buffer gnus-original-article-buffer
6788 (buffer-substring (point-min) (point-max)))))
6790 ;; Check the backlog.
6791 ((and gnus-keep-backlog
6792 (gnus-backlog-request-article group article (current-buffer)))
6794 ;; Check asynchronous pre-fetch.
6795 ((gnus-async-request-fetched-article group article (current-buffer))
6796 (gnus-async-prefetch-next group article gnus-summary-buffer)
6797 (when (and (numberp article) gnus-keep-backlog)
6798 (gnus-backlog-enter-article group article (current-buffer)))
6801 ((and gnus-use-cache
6803 (gnus-cache-request-article article group))
6805 ;; Check the agent cache.
6806 ((gnus-agent-request-article article group)
6808 ;; Get the article and put into the article buffer.
6809 ((or (stringp article)
6811 (let ((gnus-override-method gnus-override-method)
6812 (methods (and (stringp article)
6813 gnus-refer-article-method))
6814 (backend (car (gnus-find-method-for-group
6815 gnus-newsgroup-name)))
6817 (inhibit-read-only t))
6818 (if (or (not (listp methods))
6819 (and (symbolp (car methods))
6820 (assq (car methods) nnoo-definition-alist)))
6821 (setq methods (list methods)))
6822 (when (and (null gnus-override-method)
6824 (setq gnus-override-method (pop methods)))
6826 (when (eq gnus-override-method 'current)
6827 (setq gnus-override-method
6828 (with-current-buffer gnus-summary-buffer
6829 gnus-current-select-method)))
6831 (gnus-kill-all-overlays)
6832 (let ((gnus-newsgroup-name group))
6833 (gnus-check-group-server))
6835 ((gnus-request-article article group (current-buffer))
6836 (when (numberp article)
6837 (gnus-async-prefetch-next group article
6838 gnus-summary-buffer)
6839 (when gnus-keep-backlog
6840 (gnus-backlog-enter-article
6841 group article (current-buffer))))
6842 (setq result 'article))
6844 (setq gnus-override-method (pop methods)))
6845 ((not (string-match "^400 "
6846 (nnheader-get-report backend)))
6847 ;; If we get 400 server disconnect, reconnect and
6848 ;; retry; otherwise, assume the article has expired.
6849 (setq result 'done))))
6850 (and (eq result 'article) 'article)))
6854 ;; Associate this article with the current summary buffer.
6855 (setq gnus-article-current-summary gnus-summary-buffer)
6857 ;; Take the article from the original article buffer
6858 ;; and place it in the buffer it's supposed to be in.
6859 (when (and (get-buffer gnus-article-buffer)
6860 (equal (buffer-name (current-buffer))
6861 (buffer-name (get-buffer gnus-article-buffer))))
6863 (if (get-buffer gnus-original-article-buffer)
6864 (set-buffer gnus-original-article-buffer)
6865 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6866 (buffer-disable-undo)
6867 (setq major-mode 'gnus-original-article-mode)
6868 (setq buffer-read-only t))
6869 (let ((inhibit-read-only t))
6871 (insert-buffer-substring gnus-article-buffer))
6872 (setq gnus-original-article (cons group article)))
6875 (run-hooks 'gnus-article-decode-hook)
6876 ;; Mark article as decoded or not.
6877 (setq gnus-article-decoded-p gnus-article-decode-hook))
6879 ;; Update sparse articles.
6880 (when (and do-update-line
6881 (or (numberp article)
6883 (let ((buf (current-buffer)))
6884 (set-buffer gnus-summary-buffer)
6885 (gnus-summary-update-article do-update-line sparse-header)
6886 (gnus-summary-goto-subject do-update-line nil t)
6887 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6889 (set-buffer buf))))))
6891 (defun gnus-block-private-groups (group)
6892 (if (gnus-news-group-p group)
6893 ;; Block nothing in news groups.
6895 ;; Block everything anywhere else.
6898 (defun gnus-blocked-images ()
6899 (if (functionp gnus-blocked-images)
6900 (funcall gnus-blocked-images gnus-newsgroup-name)
6901 gnus-blocked-images))
6907 (defcustom gnus-article-edit-mode-hook nil
6908 "Hook run in article edit mode buffers."
6909 :group 'gnus-article-various
6912 (defvar gnus-article-edit-done-function nil)
6914 (defvar gnus-article-edit-mode-map nil)
6916 ;; Should we be using derived.el for this?
6917 (unless gnus-article-edit-mode-map
6918 (setq gnus-article-edit-mode-map (make-keymap))
6919 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6921 (gnus-define-keys gnus-article-edit-mode-map
6922 "\C-c?" describe-mode
6923 "\C-c\C-c" gnus-article-edit-done
6924 "\C-c\C-k" gnus-article-edit-exit
6925 "\C-c\C-f\C-t" message-goto-to
6926 "\C-c\C-f\C-o" message-goto-from
6927 "\C-c\C-f\C-b" message-goto-bcc
6928 ;;"\C-c\C-f\C-w" message-goto-fcc
6929 "\C-c\C-f\C-c" message-goto-cc
6930 "\C-c\C-f\C-s" message-goto-subject
6931 "\C-c\C-f\C-r" message-goto-reply-to
6932 "\C-c\C-f\C-n" message-goto-newsgroups
6933 "\C-c\C-f\C-d" message-goto-distribution
6934 "\C-c\C-f\C-f" message-goto-followup-to
6935 "\C-c\C-f\C-m" message-goto-mail-followup-to
6936 "\C-c\C-f\C-k" message-goto-keywords
6937 "\C-c\C-f\C-u" message-goto-summary
6938 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6939 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6940 "\C-c\C-b" message-goto-body
6941 "\C-c\C-i" message-goto-signature
6943 "\C-c\C-t" message-insert-to
6944 "\C-c\C-n" message-insert-newsgroups
6945 "\C-c\C-o" message-sort-headers
6946 "\C-c\C-e" message-elide-region
6947 "\C-c\C-v" message-delete-not-region
6948 "\C-c\C-z" message-kill-to-signature
6949 "\M-\r" message-newline-and-reformat
6950 "\C-c\C-a" mml-attach-file
6951 "\C-a" message-beginning-of-line
6953 "\M-;" comment-region)
6955 (gnus-define-keys (gnus-article-edit-wash-map
6956 "\C-c\C-w" gnus-article-edit-mode-map)
6957 "f" gnus-article-edit-full-stops))
6960 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6962 ["Fetch To" message-insert-to t]
6963 ["Fetch Newsgroups" message-insert-newsgroups t]
6965 ["To" message-goto-to t]
6966 ["From" message-goto-from t]
6967 ["Subject" message-goto-subject t]
6968 ["Cc" message-goto-cc t]
6969 ["Reply-To" message-goto-reply-to t]
6970 ["Summary" message-goto-summary t]
6971 ["Keywords" message-goto-keywords t]
6972 ["Newsgroups" message-goto-newsgroups t]
6973 ["Followup-To" message-goto-followup-to t]
6974 ["Mail-Followup-To" message-goto-mail-followup-to t]
6975 ["Distribution" message-goto-distribution t]
6976 ["Body" message-goto-body t]
6977 ["Signature" message-goto-signature t]))
6979 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6980 "Major mode for editing articles.
6981 This is an extended text-mode.
6983 \\{gnus-article-edit-mode-map}"
6984 (make-local-variable 'gnus-article-edit-done-function)
6985 (make-local-variable 'gnus-prev-winconf)
6986 (set (make-local-variable 'font-lock-defaults)
6987 '(message-font-lock-keywords t))
6988 (set (make-local-variable 'mail-header-separator) "")
6989 (set (make-local-variable 'gnus-article-edit-mode) t)
6990 (easy-menu-add message-mode-field-menu message-mode-map)
6992 (setq buffer-read-only nil)
6993 (buffer-enable-undo)
6996 (defun gnus-article-edit (&optional force)
6997 "Edit the current article.
6998 This will have permanent effect only in mail groups.
6999 If FORCE is non-nil, allow editing of articles even in read-only
7002 (when (and (not force)
7003 (gnus-group-read-only-p))
7004 (error "The current newsgroup does not support article editing"))
7005 (gnus-article-date-original)
7006 (gnus-article-edit-article
7008 `(lambda (no-highlight)
7010 (gnus-summary-edit-article-done
7011 ,(or (mail-header-references gnus-current-headers) "")
7012 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7014 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7015 "Start editing the contents of the current article buffer."
7016 (let ((winconf (current-window-configuration)))
7017 (set-buffer gnus-article-buffer)
7018 (let ((message-auto-save-directory
7019 ;; Don't associate the article buffer with a draft file.
7021 (gnus-article-edit-mode))
7022 (funcall start-func)
7023 (set-buffer-modified-p nil)
7024 (gnus-configure-windows 'edit-article)
7025 (setq gnus-article-edit-done-function exit-func)
7026 (setq gnus-prev-winconf winconf)
7028 (gnus-message 6 "C-c C-c to end edits"))))
7030 (defun gnus-article-edit-done (&optional arg)
7031 "Update the article edits and exit."
7033 (let ((func gnus-article-edit-done-function)
7034 (buf (current-buffer))
7035 (start (window-start))
7037 (winconf gnus-prev-winconf))
7038 (widen) ;; Widen it in case that users narrowed the buffer.
7041 ;; The cache and backlog have to be flushed somewhat.
7042 (when gnus-keep-backlog
7043 (gnus-backlog-remove-article
7044 (car gnus-article-current) (cdr gnus-article-current)))
7045 ;; Flush original article as well.
7046 (gnus-flush-original-article-buffer)
7047 (when gnus-use-cache
7048 (gnus-cache-update-article
7049 (car gnus-article-current) (cdr gnus-article-current)))
7050 ;; We remove all text props from the article buffer.
7051 (kill-all-local-variables)
7052 (set-text-properties (point-min) (point-max) nil)
7054 (set-window-configuration winconf)
7056 (set-window-start (get-buffer-window buf) start)
7057 (set-window-point (get-buffer-window buf) (point)))
7058 (gnus-summary-show-article))
7060 (defun gnus-flush-original-article-buffer ()
7061 (when (get-buffer gnus-original-article-buffer)
7062 (with-current-buffer gnus-original-article-buffer
7063 (setq gnus-original-article nil))))
7065 (defun gnus-article-edit-exit ()
7066 "Exit the article editing without updating."
7068 (when (or (not (buffer-modified-p))
7069 (yes-or-no-p "Article modified; kill anyway? "))
7070 (let ((curbuf (current-buffer))
7072 (window-start (window-start)))
7074 (if (gnus-buffer-live-p gnus-original-article-buffer)
7075 (insert-buffer-substring gnus-original-article-buffer))
7076 (let ((winconf gnus-prev-winconf))
7077 (kill-all-local-variables)
7079 (set-window-configuration winconf)
7080 ;; Tippy-toe some to make sure that point remains where it was.
7081 (save-current-buffer
7083 (set-window-start (get-buffer-window (current-buffer)) window-start)
7085 (gnus-summary-show-article)))
7087 (defun gnus-article-edit-full-stops ()
7088 "Interactively repair spacing at end of sentences."
7091 (goto-char (point-min))
7092 (search-forward-regexp "^$" nil t)
7093 (let ((case-fold-search nil))
7094 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7097 ;;; Article highlights
7100 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7102 ;;; Internal Variables:
7104 (defcustom gnus-button-url-regexp
7106 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7107 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7108 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7109 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7110 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7114 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7115 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7116 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7118 "[" chars punct "]+" "[" chars "]"
7120 (concat ;; XEmacs 21.4 doesn't support POSIX.
7121 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7122 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7124 "Regular expression that matches URLs."
7125 :group 'gnus-article-buttons
7128 (defcustom gnus-button-valid-fqdn-regexp
7129 message-valid-fqdn-regexp
7130 "Regular expression that matches a valid FQDN."
7132 :group 'gnus-article-buttons
7135 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7136 (defcustom gnus-button-valid-localpart-regexp
7137 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7138 "Regular expression that matches a localpart of mail addresses or MIDs."
7140 :group 'gnus-article-buttons
7143 (defcustom gnus-button-man-handler 'manual-entry
7144 "Function to use for displaying man pages.
7145 The function must take at least one argument with a string naming the
7148 :type '(choice (function-item :tag "Man" manual-entry)
7149 (function-item :tag "Woman" woman)
7150 (function :tag "Other"))
7151 :group 'gnus-article-buttons)
7153 (defcustom gnus-button-mid-or-mail-regexp
7154 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7155 gnus-button-valid-fqdn-regexp
7157 "Regular expression that matches a message ID or a mail address."
7159 :group 'gnus-article-buttons
7162 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7163 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7164 Strings like this can be either a message ID or a mail address. If it is one
7165 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7166 message ID or a mail address, respectively. If this variable is set to the
7167 symbol `ask', always query the user what do do. If it is a function, this
7168 function will be called with the string as its only argument. The function
7169 must return `mid', `mail', `invalid' or `ask'."
7171 :group 'gnus-article-buttons
7172 :type '(choice (function-item :tag "Heuristic function"
7173 gnus-button-mid-or-mail-heuristic)
7178 (defcustom gnus-button-mid-or-mail-heuristic-alist
7179 '((-10.0 . ".+\\$.+@")
7182 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7183 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7184 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7185 (-1.0 . "^[^a-z]+@")
7187 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7188 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7189 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7190 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7193 (-1.0 . "^[0-9][0-9]")
7195 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7196 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7197 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7198 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7200 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7201 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7204 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7206 ;; compensation for TDMA dated mail addresses:
7207 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7209 (-20.0 . "\\.fsf@") ;; Gnus
7212 (-20.0 . "^alpine\\.")
7213 (-20.0 . "_-_") ;; Subject change in thread
7215 (-20.0 . "\\.ln@") ;; leafnode
7216 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7217 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7219 ;; (5.0 . "") ;; $local_part_len <= 7
7220 (10.0 . "^[^0-9]+@")
7221 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7222 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7225 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7227 (0.5 . "^[A-Z][a-z]")
7228 (0.5 . "^[A-Z][a-z][a-z]")
7229 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7230 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7231 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7233 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7234 address. The REGEXP is processed with `case-fold-search' set to nil."
7236 :group 'gnus-article-buttons
7237 :type '(repeat (cons (number :tag "Rate")
7238 (regexp :tag "Regexp"))))
7240 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7241 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7242 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7243 address, `ask' if unsure and `invalid' if the string is invalid."
7244 (let ((case-fold-search nil)
7245 (list gnus-button-mid-or-mail-heuristic-alist)
7246 (result 0) rate regexp lpartlen elem)
7248 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7249 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7250 ;; Certain special cases...
7253 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7254 "^[0-9]+\\.[0-9]+@compuserve\\|"
7255 "@public\\.gmane\\.org")
7257 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7258 (setq result 'mail))
7259 (when (string-match "@.*@\\| " mid-or-mail)
7260 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7261 (setq result 'invalid))
7262 ;; Nothing more to do, if result is not a number here...
7263 (when (numberp result)
7265 (setq elem (car list)
7269 (when (string-match regexp mid-or-mail)
7270 (setq result (+ result rate))
7272 9 "`%s' matched `%s', rate `%s', result `%s'."
7273 mid-or-mail regexp rate result)))
7274 (when (<= lpartlen 7)
7275 (setq result (+ result 5.0))
7276 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7277 mid-or-mail result))
7278 (when (>= lpartlen 12)
7279 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7281 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7282 ;; Long local part should contain realname if e-mail address,
7283 ;; too many digits: message-id.
7284 ;; $score -= 5.0 + 0.1 * $local_part_len;
7285 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7286 (setq result (+ result rate))
7288 9 "Many digits in `%s', rate `%s', result `%s'."
7289 mid-or-mail rate result))
7290 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7292 ;; Too few vowels [^aeiouy]{4,}.*\@
7293 (setq result (+ result -5.0))
7295 9 "Few vowels in `%s', rate `%s', result `%s'."
7296 mid-or-mail -5.0 result))
7298 (setq result (+ result 5.0))
7300 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7301 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7302 ;; Maybe we should make this a customizable alist: (condition . 'result)
7304 ((symbolp result) result)
7305 ;; Now convert number into proper results:
7306 ((< result -10.0) 'mid)
7307 ((> result 10.0) 'mail)
7310 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7311 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7312 (url-mid (concat "news" ":" mid-or-mail))
7313 (url-mailto (concat "mailto" ":" mid-or-mail)))
7314 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7315 (when (fboundp pref)
7317 ;; get rid of surrounding angles...
7319 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7320 (if (or (eq 'mid guessed) (eq 'mail guessed))
7324 (save-window-excursion
7325 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7328 (cond ((eq pref 'mid)
7329 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7330 (gnus-button-handle-news url-mid))
7332 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7333 (gnus-url-mailto url-mailto))
7334 (t (gnus-message 3 "Invalid string.")))))
7336 (defun gnus-button-handle-custom (fun arg)
7337 "Call function FUN on argument ARG.
7338 Both FUN and ARG are supposed to be strings. ARG will be passed
7339 as a symbol to FUN."
7340 (funcall (intern fun)
7341 (if (string-match "^customize-apropos" fun)
7345 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7347 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7350 (defun gnus-button-handle-describe-function (url)
7351 "Call `describe-function' when pushing the corresponding URL button."
7354 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7356 (defun gnus-button-handle-describe-variable (url)
7357 "Call `describe-variable' when pushing the corresponding URL button."
7360 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7362 (defun gnus-button-handle-symbol (url)
7363 "Display help on variable or function.
7364 Calls `describe-variable' or `describe-function'."
7365 (let ((sym (intern url)))
7367 ((fboundp sym) (describe-function sym))
7368 ((boundp sym) (describe-variable sym))
7369 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7371 (defun gnus-button-handle-describe-key (url)
7372 "Call `describe-key' when pushing the corresponding URL button."
7374 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7375 (keys (ignore-errors (eval `(kbd ,key-string)))))
7378 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7380 (defun gnus-button-handle-apropos (url)
7381 "Call `apropos' when pushing the corresponding URL button."
7382 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7384 (defun gnus-button-handle-apropos-command (url)
7385 "Call `apropos' when pushing the corresponding URL button."
7387 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7389 (defun gnus-button-handle-apropos-variable (url)
7390 "Call `apropos' when pushing the corresponding URL button."
7392 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7393 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7395 (defun gnus-button-handle-apropos-documentation (url)
7396 "Call `apropos' when pushing the corresponding URL button."
7398 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7399 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7401 (defun gnus-button-handle-library (url)
7402 "Call `locate-library' when pushing the corresponding URL button."
7403 (gnus-message 9 "url=`%s'" url)
7404 (let* ((lib (locate-library url))
7405 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7407 (gnus-message 1 "Cannot locale library `%s'." url)
7408 (find-file-read-only file))))
7410 (defcustom gnus-button-man-level 5
7411 "*Integer that says how many man-related buttons Gnus will show.
7412 The higher the number, the more buttons will appear and the more false
7413 positives are possible. Note that you can set this variable local to
7414 specific groups. Setting it higher in Unix groups is probably a good idea.
7415 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7416 how to set variables in specific groups."
7418 :group 'gnus-article-buttons
7419 :link '(custom-manual "(gnus)Group Parameters")
7422 (defcustom gnus-button-emacs-level 5
7423 "*Integer that says how many emacs-related buttons Gnus will show.
7424 The higher the number, the more buttons will appear and the more false
7425 positives are possible. Note that you can set this variable local to
7426 specific groups. Setting it higher in Emacs or Gnus related groups is
7427 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7428 `gnus-parameters' on how to set variables in specific groups."
7430 :group 'gnus-article-buttons
7431 :link '(custom-manual "(gnus)Group Parameters")
7434 (defcustom gnus-button-message-level 5
7435 "*Integer that says how many buttons for news or mail messages will appear.
7436 The higher the number, the more buttons will appear and the more false
7437 positives are possible."
7438 ;; mail addresses, MIDs, URLs for news, ...
7440 :group 'gnus-article-buttons
7443 (defcustom gnus-button-browse-level 5
7444 "*Integer that says how many buttons for browsing will appear.
7445 The higher the number, the more buttons will appear and the more false
7446 positives are possible."
7447 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7449 :group 'gnus-article-buttons
7452 (defcustom gnus-button-alist
7453 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7454 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7455 ((concat "\\b\\(nntp\\|news\\):\\("
7456 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7457 0 t gnus-button-handle-news 2)
7458 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7459 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7460 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7461 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7462 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7463 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7464 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7465 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7466 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7467 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7468 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7469 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7470 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7471 ;; RFC 2368 (The mailto URL scheme)
7472 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7473 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7474 ("\\bmailto:\\([^ \n\t]+\\)"
7475 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7476 ;; Info Konqueror style <info:/foo/bar baz>.
7477 ;; Must come before " Gnus home-grown style".
7478 ("\\binfo://?\\([^'\">\n\t]+\\)"
7479 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7480 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7481 ("\\binfo://\\([^'\">\n\t ]+\\)"
7482 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7483 ;; Info GNOME style <info:foo#bar_baz>
7484 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7485 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7486 ;; Info KDE style <info:(foo)bar baz>
7487 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7488 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7489 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7490 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7491 ("\\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,]*\\)\\)?"
7492 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7493 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7495 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7496 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7497 ;; Emacs help commands
7498 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7499 ;; regexp doesn't match arguments containing ` '.
7500 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7501 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7502 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7503 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7504 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7505 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7506 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7507 ;; The following entries may lead to many false positives so don't enable
7508 ;; them by default (use a high button level).
7509 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7510 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7511 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7512 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7513 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7514 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7515 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7516 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7517 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7518 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7519 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7520 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7521 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7522 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7523 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7524 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7525 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7526 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7527 ;; Unlike the other regexps we really have to require quoting
7528 ;; here to determine where it ends.
7529 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7530 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7531 ("<URL: *\\([^\n<>]*\\)>"
7532 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7533 ;; RFC 2396 (2.4.3., delims) ...
7534 ("\"URL: *\\([^\n\"]*\\)\""
7535 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7537 (gnus-button-url-regexp
7538 0 (>= gnus-button-browse-level 0) browse-url 0)
7540 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7541 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7542 gnus-button-handle-man 1)
7543 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7544 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7545 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7546 gnus-button-handle-man 1)
7547 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7548 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7549 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7550 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7551 ;; Recognizing patches to .el files. This is somewhat obscure,
7552 ;; but considering the percentage of Gnus users who hack Emacs
7554 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7555 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7556 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7557 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7558 ;; MID or mail: To avoid too many false positives we don't try to catch
7559 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7560 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7561 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7562 ;; so that non-ambiguous entries (see above) match first.
7563 (gnus-button-mid-or-mail-regexp
7564 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7565 "*Alist of regexps matching buttons in article bodies.
7567 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7568 REGEXP: is the string (case insensitive) matching text around the button (can
7569 also be Lisp expression evaluating to a string),
7570 BUTTON: is the number of the regexp grouping actually matching the button,
7571 FORM: is a Lisp expression which must eval to true for the button to
7573 CALLBACK: is the function to call when the user push this button, and each
7574 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7576 CALLBACK can also be a variable, in that case the value of that
7577 variable it the real callback function."
7578 :group 'gnus-article-buttons
7579 :type '(repeat (list (choice regexp variable sexp)
7580 (integer :tag "Button")
7582 (function :tag "Callback")
7585 (integer :tag "Regexp group")))))
7586 (put 'gnus-button-alist 'risky-local-variable t)
7588 (defcustom gnus-header-button-alist
7589 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7590 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7591 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7592 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7593 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7594 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7595 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7596 0 (>= gnus-button-browse-level 0) browse-url 0)
7597 ("^Subject:" gnus-button-url-regexp
7598 0 (>= gnus-button-browse-level 0) browse-url 0)
7599 ("^[^:]+:" gnus-button-url-regexp
7600 0 (>= gnus-button-browse-level 0) browse-url 0)
7601 ("^OpenPGP:.*url=" gnus-button-url-regexp
7602 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7603 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7604 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7605 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7606 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7607 "*Alist of headers and regexps to match buttons in article heads.
7609 This alist is very similar to `gnus-button-alist', except that each
7610 alist has an additional HEADER element first in each entry:
7612 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7614 HEADER is a regexp to match a header. For a fuller explanation, see
7615 `gnus-button-alist'."
7616 :group 'gnus-article-buttons
7617 :group 'gnus-article-headers
7618 :type '(repeat (list (regexp :tag "Header")
7619 (choice regexp variable)
7620 (integer :tag "Button")
7622 (function :tag "Callback")
7625 (integer :tag "Regexp group")))))
7626 (put 'gnus-header-button-alist 'risky-local-variable t)
7630 (defun gnus-article-push-button (event)
7631 "Check text under the mouse pointer for a callback function.
7632 If the text under the mouse pointer has a `gnus-callback' property,
7633 call it with the value of the `gnus-data' text property."
7635 (set-buffer (window-buffer (posn-window (event-start event))))
7636 (let* ((pos (posn-point (event-start event)))
7637 (data (get-text-property pos 'gnus-data))
7638 (fun (get-text-property pos 'gnus-callback)))
7641 (funcall fun data))))
7643 (defun gnus-article-press-button ()
7644 "Check text at point for a callback function.
7645 If the text at point has a `gnus-callback' property,
7646 call it with the value of the `gnus-data' text property."
7648 (let ((data (get-text-property (point) 'gnus-data))
7649 (fun (get-text-property (point) 'gnus-callback)))
7651 (funcall fun data))))
7653 (defun gnus-article-highlight (&optional force)
7654 "Highlight current article.
7655 This function calls `gnus-article-highlight-headers',
7656 `gnus-article-highlight-citation',
7657 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7658 do the highlighting. See the documentation for those functions."
7659 (interactive (list 'force))
7660 (gnus-article-highlight-headers)
7661 (gnus-article-highlight-citation force)
7662 (gnus-article-highlight-signature)
7663 (gnus-article-add-buttons)
7664 (gnus-article-add-buttons-to-head))
7666 (defun gnus-article-highlight-some (&optional force)
7667 "Highlight current article.
7668 This function calls `gnus-article-highlight-headers',
7669 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7670 do the highlighting. See the documentation for those functions."
7671 (interactive (list 'force))
7672 (gnus-article-highlight-headers)
7673 (gnus-article-highlight-signature)
7674 (gnus-article-add-buttons))
7676 (defun gnus-article-highlight-headers ()
7677 "Highlight article headers as specified by `gnus-header-face-alist'."
7679 (gnus-with-article-headers
7680 (let (regexp header-face field-face from hpoints fpoints)
7681 (dolist (entry gnus-header-face-alist)
7682 (goto-char (point-min))
7683 (setq regexp (concat "^\\("
7684 (if (string-equal "" (nth 0 entry))
7688 header-face (nth 1 entry)
7689 field-face (nth 2 entry))
7690 (while (and (re-search-forward regexp nil t)
7694 (unless (search-forward ":" nil t)
7696 (when (and header-face
7697 (not (memq (point) hpoints)))
7698 (push (point) hpoints)
7699 (gnus-put-text-property from (point) 'face header-face))
7700 (when (and field-face
7701 (not (memq (setq from (point)) fpoints)))
7703 (if (re-search-forward "^[^ \t]" nil t)
7705 (goto-char (point-max)))
7706 (gnus-put-text-property from (point) 'face field-face)))))))
7708 (defun gnus-article-highlight-signature ()
7709 "Highlight the signature in an article.
7710 It does this by highlighting everything after
7711 `gnus-signature-separator' using the face `gnus-signature'."
7713 (gnus-with-article-buffer
7714 (let ((inhibit-point-motion-hooks t))
7716 (when (and gnus-signature-face
7717 (gnus-article-narrow-to-signature))
7718 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7719 'face gnus-signature-face)
7721 (gnus-article-search-signature)
7722 (let ((start (match-beginning 0))
7723 (end (set-marker (make-marker) (1+ (match-end 0)))))
7724 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7727 (defun gnus-button-in-region-p (b e prop)
7728 "Say whether PROP exists in the region."
7729 (text-property-not-all b e prop nil))
7731 (defun gnus-article-add-buttons ()
7732 "Find external references in the article and make buttons of them.
7733 \"External references\" are things like Message-IDs and URLs, as
7734 specified by `gnus-button-alist'."
7736 (gnus-with-article-buffer
7737 (let ((inhibit-point-motion-hooks t)
7738 (case-fold-search t)
7739 (alist gnus-button-alist)
7741 ;; We skip the headers.
7744 (while (setq entry (pop alist))
7745 (setq regexp (eval (car entry)))
7747 (while (re-search-forward regexp nil t)
7748 (let ((start (match-beginning (nth 1 entry)))
7749 (end (match-end (nth 1 entry)))
7750 (from (match-beginning 0)))
7751 (when (and (eval (nth 2 entry))
7752 (not (gnus-button-in-region-p
7753 start end 'gnus-callback)))
7754 ;; That optional form returned non-nil, so we add the
7756 (setq from (set-marker (make-marker) from))
7757 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7758 (gnus-article-extend-url-button from start end))
7759 (gnus-article-add-button start end
7760 'gnus-button-push (list from entry))
7761 (gnus-put-text-property
7763 'gnus-string (buffer-substring-no-properties
7766 (defun gnus-article-extend-url-button (beg start end)
7767 "Extend url button if url is folded into two or more lines.
7768 Return non-nil if button is extended. BEG is a marker that points to
7769 the beginning position of a text containing url. START and END are
7770 the endpoints of a url button before it is extended. The concatenated
7771 url is put as the `gnus-button-url' overlay property on the button."
7772 (let ((opoint (point))
7773 (points (list start end))
7778 (not (looking-at "[\t ]*[\">]")))
7782 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7783 (buffer-substring (point-at-bol) start)))
7785 (setq url (list (buffer-substring start end))
7786 delim (if (match-beginning 1) ">" "\""))
7788 (setq regexp (concat
7789 (when (and (looking-at
7790 message-cite-prefix-regexp)
7791 (< (match-end 0) start))
7792 (regexp-quote (match-string 0)))
7794 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7798 (and (looking-at regexp)
7801 (push (or (match-string 2)
7804 (push (setq end (or (match-end 2)
7807 (push (or (match-beginning 2)
7808 (match-beginning 1))
7810 (match-beginning 2)))
7811 (let (gnus-article-mouse-face widget-mouse-face)
7813 (gnus-article-add-button (pop points) (pop points)
7814 'gnus-button-push beg)))
7815 (let ((overlay (gnus-make-overlay start end)))
7816 (gnus-overlay-put overlay 'evaporate t)
7817 (gnus-overlay-put overlay 'gnus-button-url
7818 (list (mapconcat 'identity (nreverse url) "")))
7819 (when gnus-article-mouse-face
7820 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7822 (goto-char opoint))))
7824 ;; Add buttons to the head of an article.
7825 (defun gnus-article-add-buttons-to-head ()
7826 "Add buttons to the head of the article."
7828 (gnus-with-article-headers
7830 (dolist (entry gnus-header-button-alist)
7831 ;; Each alist entry.
7832 (goto-char (point-min))
7833 (while (re-search-forward (car entry) nil t)
7834 ;; Each header matching the entry.
7835 (setq beg (match-beginning 0))
7836 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7837 (match-beginning 0))
7840 (while (re-search-forward (eval (nth 1 entry)) end t)
7841 ;; Each match within a header.
7842 (let* ((entry (cdr entry))
7843 (start (match-beginning (nth 1 entry)))
7844 (end (match-end (nth 1 entry)))
7845 (form (nth 2 entry)))
7846 (goto-char (match-end 0))
7848 (gnus-article-add-button
7849 start end (nth 3 entry)
7850 (buffer-substring (match-beginning (nth 4 entry))
7851 (match-end (nth 4 entry)))))))
7852 (goto-char end))))))
7854 ;;; External functions:
7856 (defun gnus-article-add-button (from to fun &optional data text)
7857 "Create a button between FROM and TO with callback FUN and data DATA."
7858 (when gnus-article-button-face
7859 (gnus-overlay-put (gnus-make-overlay from to nil t)
7860 'face gnus-article-button-face))
7861 (gnus-add-text-properties
7863 (nconc (and gnus-article-mouse-face
7864 (list gnus-mouse-face-prop gnus-article-mouse-face))
7865 (list 'gnus-callback fun)
7866 (and data (list 'gnus-data data))))
7867 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7868 :help-echo (or text "Follow the link")
7869 :keymap gnus-url-button-map
7870 :button-keymap gnus-widget-button-keymap))
7872 (defun gnus-article-copy-string ()
7873 "Copy the string in the button to the kill ring."
7875 (gnus-article-check-buffer)
7876 (let ((data (get-text-property (point) 'gnus-string)))
7880 (copy-region-as-kill (point-min) (point-max))
7881 (message "Copied %s" data)))))
7883 ;;; Internal functions:
7885 (defun gnus-article-set-globals ()
7886 (with-current-buffer gnus-summary-buffer
7887 (gnus-set-global-variables)))
7889 (defun gnus-signature-toggle (end)
7890 (gnus-with-article-buffer
7891 (let ((inhibit-point-motion-hooks t))
7892 (if (text-property-any end (point-max) 'article-type 'signature)
7894 (gnus-delete-wash-type 'signature)
7895 (gnus-remove-text-properties-when
7896 'article-type 'signature end (point-max)
7897 (cons 'article-type (cons 'signature
7898 gnus-hidden-properties))))
7899 (gnus-add-wash-type 'signature)
7900 (gnus-add-text-properties-when
7901 'article-type nil end (point-max)
7902 (cons 'article-type (cons 'signature
7903 gnus-hidden-properties)))))
7904 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7905 (gnus-set-mode-line 'article))))
7907 (defun gnus-button-push (marker-and-entry)
7908 ;; Push button starting at MARKER.
7910 (let* ((marker (car marker-and-entry))
7911 (entry (cadr marker-and-entry))
7912 (regexp (car entry))
7913 (inhibit-point-motion-hooks t))
7915 ;; This is obviously true, or something bad is happening :)
7916 ;; But we need it to have the match-data
7917 (when (looking-at (or (if (symbolp regexp)
7918 (symbol-value regexp)
7920 (let ((fun (nth 3 entry))
7921 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7922 (get-char-property marker 'gnus-button-url))
7923 (mapcar (lambda (group)
7924 (let ((string (match-string group)))
7925 (set-text-properties
7926 0 (length string) nil string)
7928 (nthcdr 4 entry)))))
7934 (fboundp (symbol-value fun)))
7935 (apply (symbol-value fun) args))
7937 (gnus-message 1 "You must define `%S' to use this button"
7938 (cons fun args)))))))))
7940 (defun gnus-parse-news-url (url)
7941 (let (scheme server port group message-id articles)
7944 (goto-char (point-min))
7945 (when (looking-at "\\([A-Za-z]+\\):")
7946 (setq scheme (match-string 1))
7947 (goto-char (match-end 0)))
7948 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7949 (setq server (match-string 1))
7950 (setq port (if (stringp (match-string 3))
7951 (string-to-number (match-string 3))
7953 (goto-char (match-end 0)))
7956 ((looking-at "\\(.*@.*\\)")
7957 (setq message-id (match-string 1)))
7958 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7959 (setq group (match-string 1)
7960 articles (split-string (match-string 2) "-")))
7961 ((looking-at "\\([^/]+\\)/?")
7962 (setq group (match-string 1)))
7964 (error "Unknown news URL syntax"))))
7965 (list scheme server port group message-id articles)))
7967 (defun gnus-button-handle-news (url)
7969 (destructuring-bind (scheme server port group message-id articles)
7970 (gnus-parse-news-url url)
7973 (with-current-buffer gnus-summary-buffer
7975 (let ((gnus-refer-article-method
7976 (nconc (list (list 'nntp server))
7977 gnus-refer-article-method))
7978 (nntp-port-number (or port "nntp")))
7979 (gnus-message 7 "Fetching %s with %s"
7980 message-id gnus-refer-article-method)
7981 (gnus-summary-refer-article message-id))
7982 (gnus-summary-refer-article message-id))))
7984 (gnus-button-fetch-group url)))))
7986 (defun gnus-button-patch (library line)
7987 "Visit an Emacs Lisp library LIBRARY on line LINE."
7989 (let ((file (locate-library (file-name-nondirectory library))))
7991 (error "Couldn't find library %s" library))
7993 (goto-char (point-min))
7994 (forward-line (1- (string-to-number line)))))
7996 (defun gnus-button-handle-man (url)
7998 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7999 (when (eq gnus-button-man-handler 'woman)
8000 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8001 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8002 (funcall gnus-button-man-handler url))
8004 (defun gnus-button-handle-info-url (url)
8005 "Fetch an info URL."
8006 (setq url (mm-subst-char-in-string ?+ ?\ url))
8008 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8009 (gnus-info-find-node
8010 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8012 ")" (gnus-url-unhex-string (match-string 2 url)))))
8013 ((string-match "([^)\"]+)[^\"]+" url)
8015 (gnus-replace-in-string
8016 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8017 (gnus-info-find-node url))
8018 (t (error "Can't parse %s" url))))
8020 (defun gnus-button-handle-info-url-gnome (url)
8021 "Fetch GNOME style info URL."
8022 (setq url (mm-subst-char-in-string ?_ ?\ url))
8023 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8024 (gnus-info-find-node
8026 (gnus-url-unhex-string
8027 (match-string 1 url))
8029 (or (gnus-url-unhex-string
8030 (match-string 2 url))
8032 (error "Can't parse %s" url)))
8034 (defun gnus-button-handle-info-url-kde (url)
8035 "Fetch KDE style info URL."
8036 (gnus-info-find-node (gnus-url-unhex-string url)))
8038 ;; (info) will autoload info.el
8039 (declare-function Info-menu "info" (menu-item &optional fork))
8040 (declare-function Info-index-next "info" (num))
8042 (defun gnus-button-handle-info-keystrokes (url)
8043 "Call `info' when pushing the corresponding URL button."
8044 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8045 (let (node indx comma)
8047 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8048 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8049 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8050 "\\(?:[ \t\n,]*\\)\\)?")
8052 (setq node (match-string 2 url)
8053 indx (match-string 3 url))
8054 (error "Can't parse %s" url))
8058 (when (> (length indx) 0)
8059 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8062 (setq comma (match-string 2 indx))
8063 (setq indx (match-string 1 indx))
8066 (dotimes (i (with-temp-buffer
8068 ;; Note: the XEmacs version of `how-many' takes
8069 ;; no optional argument.
8070 (goto-char (point-min))
8072 (Info-index-next 1)))
8075 (autoload 'pgg-snarf-keys-region "pgg")
8076 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8077 (declare-function pgg-display-output-buffer "pgg" (start end status))
8079 (defun gnus-button-openpgp (url)
8080 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8082 (mm-url-insert-file-contents-external url)
8083 (pgg-snarf-keys-region (point-min) (point-max))
8084 (pgg-display-output-buffer nil nil nil)))
8086 (defun gnus-button-message-id (message-id)
8088 (with-current-buffer gnus-summary-buffer
8089 (gnus-summary-refer-article message-id)))
8091 (defun gnus-button-fetch-group (address &rest ignore)
8092 "Fetch GROUP specified by ADDRESS."
8093 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8095 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8096 ;; for nntp:// and news://
8097 (setq address (match-string 3 address)))
8098 (if (not (string-match "[:/]" address))
8099 ;; This is just a simple group url.
8100 (gnus-group-read-ephemeral-group address gnus-select-method)
8103 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8105 (error "Can't parse %s" address)
8106 (gnus-group-read-ephemeral-group
8107 (match-string 4 address)
8108 `(nntp ,(match-string 1 address)
8109 (nntp-address ,(match-string 1 address))
8110 (nntp-port-number ,(if (match-end 3)
8111 (match-string 3 address)
8114 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8116 (defun gnus-url-parse-query-string (query &optional downcase)
8117 (let (retval pairs cur key val)
8118 (setq pairs (split-string query "&"))
8120 (setq cur (car pairs)
8122 (if (not (string-match "=" cur))
8124 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8125 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8127 (setq key (downcase key)))
8128 (setq cur (assoc key retval))
8130 (setcdr cur (cons val (cdr cur)))
8131 (setq retval (cons (list key val) retval)))))
8134 (defun gnus-url-mailto (url)
8135 ;; Send mail to someone
8136 (setq url (replace-regexp-in-string "\n" " " url))
8137 (when (string-match "mailto:/*\\(.*\\)" url)
8138 (setq url (substring url (match-beginning 1) nil)))
8139 (let (to args subject func)
8140 (setq args (gnus-url-parse-query-string
8141 (if (string-match "^\\?" url)
8143 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8144 (concat "to=" (match-string 1 url) "&"
8145 (match-string 2 url))
8146 (concat "to=" url))))
8147 subject (cdr-safe (assoc "subject" args)))
8150 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8153 (message-position-on-field (caar args)))
8154 (insert (gnus-replace-in-string
8155 (mapconcat 'identity (reverse (cdar args)) ", ")
8157 (setq args (cdr args)))
8160 (message-goto-subject))))
8162 (defun gnus-button-embedded-url (address)
8163 "Activate ADDRESS with `browse-url'."
8164 (browse-url (gnus-strip-whitespace address)))
8166 ;;; Next/prev buttons in the article buffer.
8168 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8169 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8171 (defvar gnus-prev-page-map
8172 (let ((map (make-sparse-keymap)))
8173 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8174 (define-key map "\r" 'gnus-button-prev-page)
8177 (defvar gnus-next-page-map
8178 (let ((map (make-sparse-keymap)))
8179 (define-key map gnus-mouse-2 'gnus-button-next-page)
8180 (define-key map "\r" 'gnus-button-next-page)
8183 (defun gnus-insert-prev-page-button ()
8185 (inhibit-read-only t))
8187 gnus-prev-page-line-format nil
8188 `(keymap ,gnus-prev-page-map
8190 gnus-callback gnus-article-button-prev-page
8191 article-type annotation))
8193 ;; Exclude a newline.
8196 (when gnus-article-button-face
8197 (gnus-overlay-put (gnus-make-overlay b e nil t)
8198 'face gnus-article-button-face))
8199 (widget-convert-button
8201 :action 'gnus-button-prev-page
8202 :button-keymap gnus-prev-page-map)))
8204 (defun gnus-button-next-page (&optional args more-args)
8205 "Go to the next page."
8207 (let ((win (selected-window)))
8208 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8209 (gnus-article-next-page)
8210 (select-window win)))
8212 (defun gnus-button-prev-page (&optional args more-args)
8213 "Go to the prev page."
8215 (let ((win (selected-window)))
8216 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8217 (gnus-article-prev-page)
8218 (select-window win)))
8220 (defun gnus-insert-next-page-button ()
8222 (inhibit-read-only t))
8223 (gnus-eval-format gnus-next-page-line-format nil
8224 `(keymap ,gnus-next-page-map
8226 gnus-callback gnus-article-button-next-page
8227 article-type annotation))
8229 ;; Exclude a newline.
8232 (when gnus-article-button-face
8233 (gnus-overlay-put (gnus-make-overlay b e nil t)
8234 'face gnus-article-button-face))
8235 (widget-convert-button
8237 :action 'gnus-button-next-page
8238 :button-keymap gnus-next-page-map)))
8240 (defun gnus-article-button-next-page (arg)
8241 "Go to the next page."
8243 (let ((win (selected-window)))
8244 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8245 (gnus-article-next-page)
8246 (select-window win)))
8248 (defun gnus-article-button-prev-page (arg)
8249 "Go to the prev page."
8251 (let ((win (selected-window)))
8252 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8253 (gnus-article-prev-page)
8254 (select-window win)))
8256 (defvar gnus-decode-header-methods
8257 '(mail-decode-encoded-word-region)
8258 "List of methods used to decode headers.
8260 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8261 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8262 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8263 whose names match REGEXP.
8266 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8267 mail-decode-encoded-word-region
8268 (\"chinese\" . rfc1843-decode-region))
8271 (defvar gnus-decode-header-methods-cache nil)
8273 (defun gnus-multi-decode-header (start end)
8274 "Apply the functions from `gnus-encoded-word-methods' that match."
8275 (unless (and gnus-decode-header-methods-cache
8276 (eq gnus-newsgroup-name
8277 (car gnus-decode-header-methods-cache)))
8278 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8279 (dolist (x gnus-decode-header-methods)
8281 (nconc gnus-decode-header-methods-cache (list x))
8282 (if (and gnus-newsgroup-name
8283 (string-match (car x) gnus-newsgroup-name))
8284 (nconc gnus-decode-header-methods-cache
8286 (let ((xlist gnus-decode-header-methods-cache))
8289 (narrow-to-region start end)
8291 (funcall (pop xlist) (point-min) (point-max))))))
8294 ;;; Treatment top-level handling.
8297 (defvar gnus-inhibit-article-treatments nil)
8299 (defun gnus-treat-article (gnus-treat-condition
8300 &optional part-number total-parts gnus-treat-type)
8301 (let ((gnus-treat-length (- (point-max) (point-min)))
8302 (alist gnus-treatment-function-alist)
8303 (article-goto-body-goes-to-point-min-p t)
8305 (or (not gnus-treat-type)
8307 (let ((list gnus-article-treat-types))
8309 (when (string-match (pop list) gnus-treat-type)
8310 (throw 'found t)))))))
8311 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8313 (gnus-run-hooks 'gnus-part-display-hook)
8314 (dolist (elem alist)
8317 (when (gnus-buffer-live-p gnus-summary-buffer)
8318 (set-buffer gnus-summary-buffer))
8319 (symbol-value (car elem))))
8320 (when (and (or (consp val)
8322 (or (not gnus-inhibit-article-treatments)
8323 (eq gnus-treat-condition 'head))
8324 (gnus-treat-predicate val)
8325 (or (not (get (car elem) 'highlight))
8328 (funcall (cadr elem)))))))
8330 ;; Dynamic variables.
8331 (defvar part-number)
8332 (defvar total-parts)
8333 (defvar gnus-treat-type)
8334 (defvar gnus-treat-condition)
8335 (defvar gnus-treat-length)
8337 (defun gnus-treat-predicate (val)
8341 (gnus-treat-condition
8342 (eq gnus-treat-condition val))
8344 (stringp (car val)))
8345 (apply 'gnus-or (mapcar `(lambda (s)
8346 (string-match s ,(or gnus-newsgroup-name "")))
8349 (let ((pred (pop val)))
8352 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8354 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8356 (not (gnus-treat-predicate (car val))))
8358 (equal (car val) gnus-treat-type))
8360 (error "%S is not a valid predicate" pred)))))
8368 (eq part-number total-parts))
8370 (< gnus-treat-length val))
8372 (error "%S is not a valid value" val))))
8374 (defun gnus-article-encrypt-body (protocol &optional n)
8375 "Encrypt the article body."
8378 (or gnus-article-encrypt-protocol
8379 (gnus-completing-read "Encrypt protocol"
8380 (mapcar 'car gnus-article-encrypt-protocol-alist)
8382 current-prefix-arg))
8383 ;; User might hit `K E' instead of `K e', so prompt once.
8384 (when (and gnus-article-encrypt-protocol
8386 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8387 (error "Encrypt aborted")))
8388 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8390 (error "Can't find the encrypt protocol %s" protocol))
8391 (if (member gnus-newsgroup-name '("nndraft:delayed"
8394 (error "Can't encrypt the article in group %s"
8395 gnus-newsgroup-name))
8396 (gnus-summary-iterate n
8397 (with-current-buffer gnus-summary-buffer
8398 (let ((mail-parse-charset gnus-newsgroup-charset)
8399 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8400 (summary-buffer gnus-summary-buffer)
8402 (gnus-set-global-variables)
8403 (when (gnus-group-read-only-p)
8404 (error "The current newsgroup does not support article encrypt"))
8405 (gnus-summary-show-article t)
8407 (or (mail-header-references gnus-current-headers) ""))
8408 (set-buffer gnus-article-buffer)
8409 (let* ((inhibit-read-only t)
8411 (mapcar (lambda (field)
8412 (and (save-restriction
8413 (message-narrow-to-head)
8414 (goto-char (point-min))
8415 (search-forward field nil t))
8417 (message-narrow-to-field)
8419 (delete-region (point-min) (point-max))
8421 '("Content-Type:" "Content-Transfer-Encoding:"
8422 "Content-Disposition:"))))
8423 (message-narrow-to-head)
8424 (message-remove-header "MIME-Version")
8425 (goto-char (point-max))
8426 (setq point (point))
8427 (insert (apply 'concat headers))
8429 (narrow-to-region point (point-max))
8430 (let ((message-options message-options))
8431 (message-options-set 'message-sender user-mail-address)
8432 (message-options-set 'message-recipients user-mail-address)
8433 (message-options-set 'message-sign-encrypt 'not)
8435 (goto-char (point-min))
8436 (insert "MIME-Version: 1.0\n")
8438 (gnus-summary-edit-article-done
8439 references nil summary-buffer t))
8440 (when gnus-keep-backlog
8441 (gnus-backlog-remove-article
8442 (car gnus-article-current) (cdr gnus-article-current)))
8443 (gnus-flush-original-article-buffer)
8444 (when gnus-use-cache
8445 (gnus-cache-update-article
8446 (car gnus-article-current) (cdr gnus-article-current))))))))
8448 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8449 "The following specs can be used:
8450 %t The security MIME type
8453 %D Details if button is pressed")
8455 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8456 "The following specs can be used:
8457 %t The security MIME type
8460 %D Details if button is pressed")
8462 (defvar gnus-mime-security-button-line-format-alist
8463 '((?t gnus-tmp-type ?s)
8464 (?i gnus-tmp-info ?s)
8465 (?d gnus-tmp-details ?s)
8466 (?D gnus-tmp-pressed-details ?s)))
8468 (defvar gnus-mime-security-button-commands
8469 '((gnus-article-press-button "\r" "Show Detail")
8473 (gnus-mime-security-save-part "o" "Save...")
8482 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8485 (defvar gnus-mime-security-button-map
8486 (let ((map (make-sparse-keymap)))
8487 (define-key map gnus-mouse-2 'gnus-article-push-button)
8488 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8489 (dolist (c gnus-mime-security-button-commands)
8490 (define-key map (cadr c) (car c)))
8494 gnus-mime-security-button-menu gnus-mime-security-button-map
8495 "Security button menu."
8499 (unless (eq (car c) 'undefined)
8500 (vector (caddr c) (car c) :active t)))
8501 gnus-mime-security-button-commands))))
8503 (defun gnus-mime-security-button-menu (event prefix)
8504 "Construct a context-sensitive menu of security commands."
8505 (interactive "e\nP")
8506 (save-window-excursion
8507 (let ((pos (event-start event)))
8508 (select-window (posn-window pos))
8509 (goto-char (posn-point pos))
8510 (gnus-article-check-buffer)
8511 (popup-menu gnus-mime-security-button-menu nil prefix))))
8513 (defvar gnus-mime-security-details-buffer nil)
8515 (defvar gnus-mime-security-button-pressed nil)
8517 (defvar gnus-mime-security-show-details-inline t
8518 "If non-nil, show details in the article buffer.")
8520 (defun gnus-mime-security-verify-or-decrypt (handle)
8521 (mm-remove-parts (cdr handle))
8522 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8523 point (inhibit-read-only t))
8525 (goto-char (car region)))
8526 (setq point (point))
8527 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8528 (let* ((mm-verify-option 'known)
8529 (mm-decrypt-option 'known)
8530 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8531 (unless (eq nparts (cdr handle))
8532 (mm-destroy-parts (cdr handle))
8533 (setcdr handle nparts))))
8534 (gnus-mime-display-security handle)
8536 (delete-region (point) (cdr region))
8537 (set-marker (car region) nil)
8538 (set-marker (cdr region) nil))
8541 (defun gnus-mime-security-show-details (handle)
8542 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8544 (gnus-message 5 "No details.")
8545 (if gnus-mime-security-show-details-inline
8546 (let ((gnus-mime-security-button-pressed
8547 (not (get-text-property (point) 'gnus-mime-details)))
8548 (gnus-mime-security-button-line-format
8549 (get-text-property (point) 'gnus-line-format))
8550 (inhibit-read-only t))
8552 (while (eq (get-text-property (point) 'gnus-line-format)
8553 gnus-mime-security-button-line-format)
8557 (narrow-to-region (point) (point))
8558 (gnus-insert-mime-security-button handle))
8559 (delete-region (point)
8560 (or (text-property-not-all
8563 gnus-mime-security-button-line-format)
8566 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8567 (with-current-buffer gnus-mime-security-details-buffer
8570 (setq gnus-mime-security-details-buffer
8571 (gnus-get-buffer-create "*MIME Security Details*")))
8572 (with-current-buffer gnus-mime-security-details-buffer
8574 (goto-char (point-min)))
8575 (pop-to-buffer gnus-mime-security-details-buffer)))))
8577 (defun gnus-mime-security-press-button (handle)
8579 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8580 (gnus-mime-security-show-details handle)
8581 (gnus-mime-security-verify-or-decrypt handle))))
8583 (defun gnus-insert-mime-security-button (handle &optional displayed)
8584 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8587 (or (nth 2 (assoc protocol mm-verify-function-alist))
8588 (nth 2 (assoc protocol mm-decrypt-function-alist))
8590 (if (equal (car handle) "multipart/signed")
8591 " Signed" " Encrypted")
8594 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8597 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8598 gnus-tmp-pressed-details
8600 (setq gnus-tmp-details
8601 (if gnus-tmp-details
8602 (concat "\n" gnus-tmp-details)
8604 (setq gnus-tmp-pressed-details
8605 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8610 gnus-mime-security-button-line-format
8611 gnus-mime-security-button-line-format-alist
8612 `(keymap ,gnus-mime-security-button-map
8613 gnus-callback gnus-mime-security-press-button
8614 gnus-line-format ,gnus-mime-security-button-line-format
8615 gnus-mime-details ,gnus-mime-security-button-pressed
8616 article-type annotation
8619 ;; Exclude a newline.
8622 (when gnus-article-button-face
8623 (gnus-overlay-put (gnus-make-overlay b e nil t)
8624 'face gnus-article-button-face))
8625 (widget-convert-button
8628 :action 'gnus-widget-press-button
8629 :button-keymap gnus-mime-security-button-map
8632 ;; Needed to properly clear the message due to a bug in
8633 ;; wid-edit (XEmacs only).
8634 (when (boundp 'help-echo-owns-message)
8635 (setq help-echo-owns-message t))
8637 "%S: show detail; %S: more options"
8638 (aref gnus-mouse-2 0)
8639 (aref gnus-down-mouse-3 0))))))
8641 (defun gnus-mime-display-security (handle)
8643 (narrow-to-region (point) (point))
8644 (unless (gnus-unbuttonized-mime-type-p (car handle))
8645 (gnus-insert-mime-security-button handle))
8646 (gnus-mime-display-part (cadr handle))
8649 (unless (gnus-unbuttonized-mime-type-p (car handle))
8650 (let ((gnus-mime-security-button-line-format
8651 gnus-mime-security-button-end-line-format))
8652 (gnus-insert-mime-security-button handle)))
8653 (mm-set-handle-multipart-parameter
8655 (cons (set-marker (make-marker) (point-min))
8656 (set-marker (make-marker) (point-max))))
8657 (goto-char (point-max))))
8659 (defun gnus-mime-security-run-function (function)
8660 "Run FUNCTION with the security part under point."
8661 (gnus-article-check-buffer)
8662 (let ((data (get-text-property (point) 'gnus-data))
8664 (when (and (stringp (car-safe data))
8665 (setq buffer (mm-handle-multipart-original-buffer data))
8666 (setq handle (cadr data)))
8667 (if (bufferp (mm-handle-buffer handle))
8669 (setq handle (cons buffer (copy-sequence (cdr handle))))
8670 (mm-handle-set-undisplayer handle nil))
8671 (setq handle (mm-make-handle
8673 (mm-handle-multipart-ctl-parameter handle 'protocol)
8674 nil nil nil nil nil nil)))
8675 (funcall function handle))))
8677 (defun gnus-mime-security-save-part ()
8678 "Save the security part under point."
8680 (gnus-mime-security-run-function 'mm-save-part))
8682 (defun gnus-mime-security-pipe-part ()
8683 "Pipe the security part under point to a process."
8685 (gnus-mime-security-run-function 'mm-pipe-part))
8691 (run-hooks 'gnus-art-load-hook)
8693 ;;; gnus-art.el ends here