1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (defvar w3m-minor-mode-map)
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
52 (autoload 'ansi-color-apply-on-region "ansi-color")
53 (autoload 'mm-url-insert-file-contents-external "mm-url")
54 (autoload 'mm-extern-cache-contents "mm-extern")
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
159 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
160 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
161 "Envelope-Sender" "Envelope-Recipients"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type '(choice :custom-show nil
168 :group 'gnus-article-hiding)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 (repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 (const :tag "Use gnus-ignored-headers" nil)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group 'gnus-article-saving
512 (defcustom gnus-prompt-before-saving 'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group 'gnus-article-saving
521 :type '(choice (item always)
522 (item :tag "never" nil)
523 (sexp :tag "once" :format "%t\n" :value t)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group 'gnus-article-saving
536 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
537 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
538 "A function to save articles in your favourite format.
539 The function will be called by way of the `gnus-summary-save-article'
540 command, and friends such as `gnus-summary-save-article-rmail'.
542 Gnus provides the following functions:
544 * gnus-summary-save-in-rmail (Rmail format)
545 * gnus-summary-save-in-mail (Unix mail format)
546 * gnus-summary-save-in-folder (MH folder)
547 * gnus-summary-save-in-file (article format)
548 * gnus-summary-save-body-in-file (article body)
549 * gnus-summary-save-in-vm (use VM's folder format)
550 * gnus-summary-write-to-file (article format -- overwrite)
551 * gnus-summary-write-body-to-file (article body -- overwrite)
552 * gnus-summary-save-in-pipe (article format)
554 The symbol of each function may have the following properties:
557 The value non-nil means save decoded articles. This is meaningful
558 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
559 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
560 `gnus-summary-save-in-pipe'.
563 The value specifies an alternative function which appends, not
564 overwrites, articles to a file. This implies that when saving many
565 articles at a time, `gnus-prompt-before-saving' is bound to t and all
566 articles are saved in a single file. This is meaningful only with
567 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
570 The value specifies the symbol of a variable of which the value
571 specifies headers to be saved. If it is omitted,
572 `gnus-save-all-headers' and `gnus-saved-headers' control what
573 headers should be saved."
574 :group 'gnus-article-saving
575 :type '(radio (function-item gnus-summary-save-in-rmail)
576 (function-item gnus-summary-save-in-mail)
577 (function-item gnus-summary-save-in-folder)
578 (function-item gnus-summary-save-in-file)
579 (function-item gnus-summary-save-body-in-file)
580 (function-item gnus-summary-save-in-vm)
581 (function-item gnus-summary-write-to-file)
582 (function-item gnus-summary-write-body-to-file)
583 (function-item gnus-summary-save-in-pipe)
586 (defcustom gnus-article-save-coding-system
587 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
588 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
589 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
590 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
591 "Coding system used to save decoded articles to a file.
593 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
594 which can safely encode any characters in text. This is used by the
597 * gnus-summary-save-article-file
598 * gnus-summary-save-article-body-file
599 * gnus-summary-write-article-file
600 * gnus-summary-write-article-body-file
602 and the functions to which you may set `gnus-default-article-saver':
604 * gnus-summary-save-in-file
605 * gnus-summary-save-body-in-file
606 * gnus-summary-write-to-file
607 * gnus-summary-write-body-to-file
609 Those commands and functions save just text displayed in the article
610 buffer to a file if the value of this variable is non-nil. Note that
611 buttonized MIME parts will be lost in a saved file in that case.
612 Otherwise, raw articles will be saved."
613 :group 'gnus-article-saving
615 :format "%{%t%}:\n %[Value Menu%] %v"
616 (const :tag "Save raw articles" nil)
619 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
620 '((const :tag "UTF-8" utf-8)
621 (const :tag "iso-2022-7bit" iso-2022-7bit)
622 (const :tag "Emacs internal" emacs-mule)
623 (const :tag "escape-quoted" escape-quoted))))
624 (symbol :tag "Coding system")))
626 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
627 "A function generating a file name to save articles in Rmail format.
628 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
629 :group 'gnus-article-saving
632 (defcustom gnus-mail-save-name 'gnus-plain-save-name
633 "A function generating a file name to save articles in Unix mail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group 'gnus-article-saving
638 (defcustom gnus-folder-save-name 'gnus-folder-save-name
639 "A function generating a file name to save articles in MH folder.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
641 :group 'gnus-article-saving
644 (defcustom gnus-file-save-name 'gnus-numeric-save-name
645 "A function generating a file name to save articles in article format.
646 The function is called with NEWSGROUP, HEADERS, and optional
648 :group 'gnus-article-saving
651 (defcustom gnus-split-methods
652 '((gnus-article-archive-name)
653 (gnus-article-nndoc-name))
654 "*Variable used to suggest where articles are to be saved.
655 For instance, if you would like to save articles related to Gnus in
656 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
657 you could set this variable to something like:
659 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
660 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
662 This variable is an alist where the key is the match and the
663 value is a list of possible files to save in if the match is
666 If the match is a string, it is used as a regexp match on the
667 article. If the match is a symbol, that symbol will be funcalled
668 from the buffer of the article to be saved with the newsgroup as the
669 parameter. If it is a list, it will be evaled in the same buffer.
671 If this form or function returns a string, this string will be used as a
672 possible file name; and if it returns a non-nil list, that list will be
673 used as possible file names."
674 :group 'gnus-article-saving
675 :type '(repeat (choice (list :value (fun) function)
676 (cons :value ("" "") regexp (repeat string))
679 (defcustom gnus-page-delimiter "^\^L"
680 "*Regexp describing what to use as article page delimiters.
681 The default value is \"^\^L\", which is a form linefeed at the
682 beginning of a line."
684 :group 'gnus-article-various)
686 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
687 "*The format specification for the article mode line.
688 See `gnus-summary-mode-line-format' for a closer description.
690 The following additional specs are available:
692 %w The article washing status.
693 %m The number of MIME parts in the article."
695 :group 'gnus-article-various)
697 (defcustom gnus-article-mode-hook nil
698 "*A hook for Gnus article mode."
700 :group 'gnus-article-various)
702 (when (featurep 'xemacs)
703 ;; Extracted from gnus-xmas-define in order to preserve user settings
704 (when (fboundp 'turn-off-scroll-in-place)
705 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
706 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
707 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
709 (defcustom gnus-article-menu-hook nil
710 "*Hook run after the creation of the article mode menu."
712 :group 'gnus-article-various)
714 (defcustom gnus-article-prepare-hook nil
715 "*A hook called after an article has been prepared in the article buffer."
717 :group 'gnus-article-various)
719 (defcustom gnus-copy-article-ignored-headers nil
720 "List of headers to be removed when copying an article.
721 Each element is a regular expression."
722 :version "23.1" ;; No Gnus
723 :type '(repeat regexp)
724 :group 'gnus-article-various)
726 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
727 "Gnus 5.10 (Emacs 22.1)")
730 '((t (:weight bold)))
731 "Face used for highlighting a button in the article buffer."
732 :group 'gnus-article-buttons)
734 (defcustom gnus-article-button-face 'gnus-button
735 "Face used for highlighting buttons in the article buffer.
737 An article button is a piece of text that you can activate by pressing
738 `RET' or `mouse-2' above it."
740 :group 'gnus-article-buttons)
742 (defcustom gnus-article-mouse-face 'highlight
743 "Face used for mouse highlighting in the article buffer.
745 Article buttons will be displayed in this face when the cursor is
748 :group 'gnus-article-buttons)
750 (defcustom gnus-signature-face 'gnus-signature
751 "Face used for highlighting a signature in the article buffer.
752 Obsolete; use the face `gnus-signature' for customizations instead."
754 :group 'gnus-article-highlight
755 :group 'gnus-article-signature)
757 (defface gnus-signature
760 "Face used for highlighting a signature in the article buffer."
761 :group 'gnus-article-highlight
762 :group 'gnus-article-signature)
763 ;; backward-compatibility alias
764 (put 'gnus-signature-face 'face-alias 'gnus-signature)
765 (put 'gnus-signature-face 'obsolete-face "22.1")
767 (defface gnus-header-from
770 (:foreground "PaleGreen1"))
773 (:foreground "red3"))
776 "Face used for displaying from headers."
777 :group 'gnus-article-headers
778 :group 'gnus-article-highlight)
779 ;; backward-compatibility alias
780 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
781 (put 'gnus-header-from-face 'obsolete-face "22.1")
783 (defface gnus-header-subject
786 (:foreground "SeaGreen1"))
789 (:foreground "red4"))
791 (:bold t :italic t)))
792 "Face used for displaying subject headers."
793 :group 'gnus-article-headers
794 :group 'gnus-article-highlight)
795 ;; backward-compatibility alias
796 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
797 (put 'gnus-header-subject-face 'obsolete-face "22.1")
799 (defface gnus-header-newsgroups
802 (:foreground "yellow" :italic t))
805 (:foreground "MidnightBlue" :italic t))
808 "Face used for displaying newsgroups headers.
809 In the default setup this face is only used for crossposted
811 :group 'gnus-article-headers
812 :group 'gnus-article-highlight)
813 ;; backward-compatibility alias
814 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
815 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
817 (defface gnus-header-name
820 (:foreground "SpringGreen2"))
823 (:foreground "maroon"))
826 "Face used for displaying header names."
827 :group 'gnus-article-headers
828 :group 'gnus-article-highlight)
829 ;; backward-compatibility alias
830 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
831 (put 'gnus-header-name-face 'obsolete-face "22.1")
833 (defface gnus-header-content
836 (:foreground "SpringGreen1" :italic t))
839 (:foreground "indianred4" :italic t))
841 (:italic t))) "Face used for displaying header content."
842 :group 'gnus-article-headers
843 :group 'gnus-article-highlight)
844 ;; backward-compatibility alias
845 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
846 (put 'gnus-header-content-face 'obsolete-face "22.1")
848 (defcustom gnus-header-face-alist
849 '(("From" nil gnus-header-from)
850 ("Subject" nil gnus-header-subject)
851 ("Newsgroups:.*," nil gnus-header-newsgroups)
852 ("" gnus-header-name gnus-header-content))
853 "*Controls highlighting of article headers.
855 An alist of the form (HEADER NAME CONTENT).
857 HEADER is a regular expression which should match the name of a
858 header and NAME and CONTENT are either face names or nil.
860 The name of each header field will be displayed using the face
861 specified by the first element in the list where HEADER matches
862 the header name and NAME is non-nil. Similarly, the content will
863 be displayed by the first non-nil matching CONTENT face."
864 :group 'gnus-article-headers
865 :group 'gnus-article-highlight
866 :type '(repeat (list (regexp :tag "Header")
868 (item :tag "skip" nil)
869 (face :value default))
870 (choice :tag "Content"
871 (item :tag "skip" nil)
872 (face :value default)))))
874 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
875 '((xface . (:face gnus-x-face)))
876 '((pbm . (:face gnus-x-face))
878 "Alist of image types and properties applied to Face and X-Face images.
881 ;; Specify the altitude of Face images in the From header.
882 \(setq gnus-face-properties-alist
883 '((pbm . (:face gnus-x-face :ascent 80))
884 (png . (:ascent 80))))
886 ;; Show Face images as pressed buttons.
887 \(setq gnus-face-properties-alist
888 '((pbm . (:face gnus-x-face :relief -2))
889 (png . (:relief -2))))
891 See the manual for the valid properties for various image types.
892 Currently, `pbm' is used for X-Face images and `png' is used for Face
893 images in Emacs. Only the `:face' property is effective on the `xface'
894 image type in XEmacs if it is built with the libcompface library."
895 :version "23.1" ;; No Gnus
896 :group 'gnus-article-headers
897 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
899 (defcustom gnus-article-decode-hook
900 '(article-decode-charset article-decode-encoded-words
901 article-decode-group-name article-decode-idna-rhs)
902 "*Hook run to decode charsets in articles."
903 :group 'gnus-article-headers
906 (defcustom gnus-display-mime-function 'gnus-display-mime
907 "Function to display MIME articles."
908 :group 'gnus-article-mime
911 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
912 "Function used to decode headers.")
914 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
915 "Function used to decode addresses.")
917 (defvar gnus-article-dumbquotes-map
937 "Table for MS-to-Latin1 translation.")
939 (defcustom gnus-ignored-mime-types nil
940 "List of MIME types that should be ignored by Gnus."
942 :group 'gnus-article-mime
943 :type '(repeat regexp))
945 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
946 "List of MIME types that should not be given buttons when rendered inline.
947 See also `gnus-buttonized-mime-types' which may override this variable.
948 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
950 :group 'gnus-article-mime
951 :type '(repeat regexp))
953 (defcustom gnus-buttonized-mime-types nil
954 "List of MIME types that should be given buttons when rendered inline.
955 If set, this variable overrides `gnus-unbuttonized-mime-types'.
956 To see e.g. security buttons you could set this to
957 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
958 this list to display radio buttons that allow you to choose one of two
959 media types those mails include. See also `mm-discouraged-alternatives'.
960 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
962 :group 'gnus-article-mime
963 :type '(repeat regexp))
965 (defcustom gnus-inhibit-mime-unbuttonizing nil
966 "If non-nil, all MIME parts get buttons.
967 When nil (the default value), then some MIME parts do not get buttons,
968 as described by the variables `gnus-buttonized-mime-types' and
969 `gnus-unbuttonized-mime-types'."
971 :group 'gnus-article-mime
974 (defcustom gnus-body-boundary-delimiter "_"
975 "String used to delimit header and body.
976 This variable is used by `gnus-article-treat-body-boundary' which can
977 be controlled by `gnus-treat-body-boundary'."
979 :group 'gnus-article-various
980 :type '(choice (item :tag "None" :value nil)
983 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
985 "Defines the location of the faces database.
986 For information on obtaining this database of pretty pictures, please
987 see http://www.cs.indiana.edu/picons/ftp/index.html"
989 :type '(repeat directory)
990 :link '(url-link :tag "download"
991 "http://www.cs.indiana.edu/picons/ftp/index.html")
992 :link '(custom-manual "(gnus)Picons")
995 (defun gnus-picons-installed-p ()
996 "Say whether picons are installed on your machine."
997 (let ((installed nil))
998 (dolist (database gnus-picon-databases)
999 (when (file-exists-p database)
1000 (setq installed t)))
1003 (defcustom gnus-article-mime-part-function nil
1004 "Function called with a MIME handle as the argument.
1005 This is meant for people who want to do something automatic based
1006 on parts -- for instance, adding Vcard info to a database."
1007 :group 'gnus-article-mime
1008 :type '(choice (const nil)
1011 (defcustom gnus-mime-multipart-functions nil
1012 "An alist of MIME types to functions to display them."
1014 :group 'gnus-article-mime
1015 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1017 (defcustom gnus-article-date-lapsed-new-header nil
1018 "Whether the X-Sent and Date headers can coexist.
1019 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1020 either replace the old \"Date:\" header (if this variable is nil), or
1021 be added below it (otherwise)."
1023 :group 'gnus-article-headers
1026 (defcustom gnus-article-update-lapsed-header 1
1027 "How often to update the lapsed date header.
1028 If nil, don't update it at all."
1030 :group 'gnus-article-headers
1032 (item :tag "Don't update" :value nil)
1035 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1036 "Function called with a MIME handle as the argument.
1037 This is meant for people who want to view first matched part.
1038 For `undisplayed-alternative' (default), the first undisplayed
1039 part or alternative part is used. For `undisplayed', the first
1040 undisplayed part is used. For a function, the first part which
1041 the function return t is used. For nil, the first part is
1044 :group 'gnus-article-mime
1046 (item :tag "first" :value nil)
1047 (item :tag "undisplayed" :value undisplayed)
1048 (item :tag "undisplayed or alternative"
1049 :value undisplayed-alternative)
1052 (defcustom gnus-mime-action-alist
1053 '(("save to file" . gnus-mime-save-part)
1054 ("save and strip" . gnus-mime-save-part-and-strip)
1055 ("replace with file" . gnus-mime-replace-part)
1056 ("delete part" . gnus-mime-delete-part)
1057 ("display as text" . gnus-mime-inline-part)
1058 ("view the part" . gnus-mime-view-part)
1059 ("pipe to command" . gnus-mime-pipe-part)
1060 ("toggle display" . gnus-article-press-button)
1061 ("toggle display" . gnus-article-view-part-as-charset)
1062 ("view as type" . gnus-mime-view-part-as-type)
1063 ("view internally" . gnus-mime-view-part-internally)
1064 ("view externally" . gnus-mime-view-part-externally))
1065 "An alist of actions that run on the MIME attachment."
1066 :group 'gnus-article-mime
1067 :type '(repeat (cons (string :tag "name")
1070 (defcustom gnus-auto-select-part 1
1071 "Advance to next MIME part when deleting or stripping parts.
1073 When 0, point will be placed on the same part as before. When
1074 positive (negative), move point forward (backwards) this many
1075 parts. When nil, redisplay article."
1076 :version "23.1" ;; No Gnus
1077 :group 'gnus-article-mime
1078 :type '(choice (const nil :tag "Redisplay article.")
1079 (const 1 :tag "Next part.")
1080 (const 0 :tag "Current part.")
1084 ;;; The treatment variables
1087 (defvar gnus-part-display-hook nil
1088 "Hook called on parts that are to receive treatment.")
1090 (defvar gnus-article-treat-custom
1091 '(choice (const :tag "Off" nil)
1093 (const :tag "Header" head)
1094 (const :tag "First" first)
1095 (const :tag "Last" last)
1096 (integer :tag "Less")
1097 (repeat :tag "Groups" regexp)
1098 (sexp :tag "Predicate")))
1100 (defvar gnus-article-treat-head-custom
1101 '(choice (const :tag "Off" nil)
1102 (const :tag "Header" head)))
1104 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1108 (defvar gnus-inhibit-treatment nil
1109 "Whether to inhibit treatment.")
1111 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1112 "Highlight the signature.
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1118 (put 'gnus-treat-highlight-signature 'highlight t)
1120 (defcustom gnus-treat-buttonize 100000
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1127 (put 'gnus-treat-buttonize 'highlight t)
1129 (defcustom gnus-treat-buttonize-head 'head
1130 "Add buttons to the head.
1131 Valid values are nil, t, `head', `first', `last', an integer or a
1132 predicate. See Info node `(gnus)Customizing Articles'."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-head-custom)
1136 (put 'gnus-treat-buttonize-head 'highlight t)
1138 (defcustom gnus-treat-emphasize 50000
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1145 (put 'gnus-treat-emphasize 'highlight t)
1147 (defcustom gnus-treat-strip-cr nil
1148 "Remove carriage returns.
1149 Valid values are nil, t, `head', `first', `last', an integer or a
1150 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-unsplit-urls nil
1157 "Remove newlines from within URLs.
1158 Valid values are nil, t, `head', `first', `last', an integer or a
1159 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-leading-whitespace nil
1166 "Remove leading whitespace in headers.
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-hide-headers 'head
1176 Valid values are nil, t, `head', `first', `last', an integer or a
1177 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom)
1182 (defcustom gnus-treat-hide-boring-headers nil
1183 "Hide boring headers.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-head-custom)
1190 (defcustom gnus-treat-hide-signature nil
1191 "Hide the signature.
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-fill-article nil
1200 Valid values are nil, t, `head', `first', `last', an integer or a
1201 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-hide-citation nil
1208 Valid values are nil, t, `head', `first', `last', an integer or a
1209 predicate. See Info node `(gnus)Customizing Articles'."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-custom)
1214 (defcustom gnus-treat-hide-citation-maybe nil
1216 Valid values are nil, t, `head', `first', `last', an integer or a
1217 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom)
1222 (defcustom gnus-treat-strip-list-identifiers 'head
1223 "Strip list identifiers from `gnus-list-identifiers`.
1224 Valid values are nil, t, `head', `first', `last', an integer or a
1225 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom)
1231 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1232 "Gnus 5.10 (Emacs 22.1)")
1234 (defcustom gnus-treat-strip-pem nil
1235 "Strip PEM signatures.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-strip-banner t
1243 "Strip banners from articles.
1244 The banner to be stripped is specified in the `banner' group parameter.
1245 Valid values are nil, t, `head', `first', `last', an integer or a
1246 predicate. See Info node `(gnus)Customizing Articles'."
1247 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom)
1251 (defcustom gnus-treat-highlight-headers 'head
1252 "Highlight the headers.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-head-custom)
1258 (put 'gnus-treat-highlight-headers 'highlight t)
1260 (defcustom gnus-treat-highlight-citation t
1261 "Highlight cited text.
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1267 (put 'gnus-treat-highlight-citation 'highlight t)
1269 (defcustom gnus-treat-date-ut nil
1270 "Display the Date in UT (GMT).
1271 Valid values are nil, t, `head', `first', `last', an integer or a
1272 predicate. See Info node `(gnus)Customizing Articles'."
1273 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :type gnus-article-treat-head-custom)
1277 (defcustom gnus-treat-date-local nil
1278 "Display the Date in the local timezone.
1279 Valid values are nil, t, `head', `first', `last', an integer or a
1280 predicate. See Info node `(gnus)Customizing Articles'."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-head-custom)
1285 (defcustom gnus-treat-date-english nil
1286 "Display the Date in a format that can be read aloud in English.
1287 Valid values are nil, t, `head', `first', `last', an integer or a
1288 predicate. See Info node `(gnus)Customizing Articles'."
1290 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-head-custom)
1294 (defcustom gnus-treat-date-lapsed nil
1295 "Display the Date header in a way that says how much time has elapsed.
1296 Valid values are nil, t, `head', `first', `last', an integer or a
1297 predicate. See Info node `(gnus)Customizing Articles'."
1298 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :type gnus-article-treat-head-custom)
1302 (defcustom gnus-treat-date-combined-lapsed 'head
1303 "Display the Date header in a way that says how much time has elapsed.
1304 Valid values are nil, t, `head', `first', `last', an integer or a
1305 predicate. See Info node `(gnus)Customizing Articles'."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom)
1310 (defcustom gnus-treat-date-original nil
1311 "Display the date in the original timezone.
1312 Valid values are nil, t, `head', `first', `last', an integer or a
1313 predicate. See Info node `(gnus)Customizing Articles'."
1314 :group 'gnus-article-treat
1315 :link '(custom-manual "(gnus)Customizing Articles")
1316 :type gnus-article-treat-head-custom)
1318 (defcustom gnus-treat-date-iso8601 nil
1319 "Display the date in the ISO8601 format.
1320 Valid values are nil, t, `head', `first', `last', an integer or a
1321 predicate. See Info node `(gnus)Customizing Articles'."
1323 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :type gnus-article-treat-head-custom)
1327 (defcustom gnus-treat-date-user-defined nil
1328 "Display the date in a user-defined format.
1329 The format is defined by the `gnus-article-time-format' variable.
1330 Valid values are nil, t, `head', `first', `last', an integer or a
1331 predicate. See Info node `(gnus)Customizing Articles'."
1332 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-head-custom)
1336 (defcustom gnus-treat-strip-headers-in-body t
1337 "Strip the X-No-Archive header line from the beginning of the body.
1338 Valid values are nil, t, `head', `first', `last', an integer or a
1339 predicate. See Info node `(gnus)Customizing Articles'."
1341 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom)
1345 (defcustom gnus-treat-strip-trailing-blank-lines nil
1346 "Strip trailing blank lines.
1347 Valid values are nil, t, `head', `first', `last', an integer or a
1348 predicate. See Info node `(gnus)Customizing Articles'.
1350 When set to t, it also strips trailing blanks in all MIME parts.
1351 Consider to use `last' instead."
1352 :group 'gnus-article-treat
1353 :link '(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom)
1356 (defcustom gnus-treat-strip-leading-blank-lines nil
1357 "Strip leading blank lines.
1358 Valid values are nil, t, `head', `first', `last', an integer or a
1359 predicate. See Info node `(gnus)Customizing Articles'.
1361 When set to t, it also strips trailing blanks in all MIME parts."
1362 :group 'gnus-article-treat
1363 :link '(custom-manual "(gnus)Customizing Articles")
1364 :type gnus-article-treat-custom)
1366 (defcustom gnus-treat-strip-multiple-blank-lines nil
1367 "Strip multiple blank lines.
1368 Valid values are nil, t, `head', `first', `last', an integer or a
1369 predicate. See Info node `(gnus)Customizing Articles'."
1370 :group 'gnus-article-treat
1371 :link '(custom-manual "(gnus)Customizing Articles")
1372 :type gnus-article-treat-custom)
1374 (defcustom gnus-treat-unfold-headers 'head
1375 "Unfold folded header lines.
1376 Valid values are nil, t, `head', `first', `last', an integer or a
1377 predicate. See Info node `(gnus)Customizing Articles'."
1379 :group 'gnus-article-treat
1380 :link '(custom-manual "(gnus)Customizing Articles")
1381 :type gnus-article-treat-custom)
1383 (defcustom gnus-article-unfold-long-headers nil
1384 "If non-nil, allow unfolding headers even if the header is long.
1385 If it is a regexp, only long headers matching this regexp are unfolded.
1386 If it is t, all long headers are unfolded.
1388 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1389 :version "23.1" ;; No Gnus
1390 :group 'gnus-article-treat
1391 :type '(choice (const nil)
1392 (const :tag "all" t)
1395 (defcustom gnus-treat-fold-headers nil
1397 Valid values are nil, t, `head', `first', `last', an integer or a
1398 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 (defcustom gnus-treat-fold-newsgroups 'head
1405 "Fold the Newsgroups and Followup-To headers.
1406 Valid values are nil, t, `head', `first', `last', an integer or a
1407 predicate. See Info node `(gnus)Customizing Articles'."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (defcustom gnus-treat-overstrike t
1414 "Treat overstrike highlighting.
1415 Valid values are nil, t, `head', `first', `last', an integer or a
1416 predicate. See Info node `(gnus)Customizing Articles'."
1417 :group 'gnus-article-treat
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1420 (put 'gnus-treat-overstrike 'highlight t)
1422 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1423 "Treat ANSI SGR control sequences.
1424 Valid values are nil, t, `head', `first', `last', an integer or a
1425 predicate. See Info node `(gnus)Customizing Articles'."
1426 :group 'gnus-article-treat
1427 :link '(custom-manual "(gnus)Customizing Articles")
1428 :type gnus-article-treat-custom)
1430 (make-obsolete-variable 'gnus-treat-display-xface
1431 'gnus-treat-display-x-face "Emacs 22.1")
1433 (defcustom gnus-treat-display-x-face
1434 (and (not noninteractive)
1435 (gnus-image-type-available-p 'xbm)
1436 (if (featurep 'xemacs)
1439 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1440 (executable-find "icontopbm"))
1441 ;; shell-command-to-string may signal an error, e.g. if
1442 ;; shell-file-name is not found.
1445 "Display X-Face headers.
1446 Valid values are nil and `head'.
1447 See Info node `(gnus)Customizing Articles' and Info node
1448 `(gnus)X-Face' for details."
1449 :group 'gnus-article-treat
1451 :link '(custom-manual "(gnus)Customizing Articles")
1452 :link '(custom-manual "(gnus)X-Face")
1453 :type gnus-article-treat-head-custom
1454 :set (lambda (symbol value)
1457 (cond ((or (boundp symbol) (get symbol 'saved-value))
1459 ((boundp 'gnus-treat-display-xface)
1461 ** gnus-treat-display-xface is an obsolete variable;\
1462 use gnus-treat-display-x-face instead")
1463 (default-value 'gnus-treat-display-xface))
1464 ((get 'gnus-treat-display-xface 'saved-value)
1466 ** gnus-treat-display-xface is an obsolete variable;\
1467 use gnus-treat-display-x-face instead")
1468 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1471 (put 'gnus-treat-display-x-face 'highlight t)
1473 (defcustom gnus-treat-display-face
1474 (and (not noninteractive)
1475 (gnus-image-type-available-p 'png)
1477 "Display Face headers.
1478 Valid values are nil, t, `head', `first', `last', an integer or a
1479 predicate. See Info node `(gnus)Customizing Articles' and Info
1480 node `(gnus)Face' for details."
1481 :group 'gnus-article-treat
1483 :link '(custom-manual "(gnus)Customizing Articles")
1484 :link '(custom-manual "(gnus)X-Face")
1485 :type gnus-article-treat-head-custom)
1486 (put 'gnus-treat-display-face 'highlight t)
1488 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1490 Valid values are nil, t, `head', `first', `last', an integer or a
1491 predicate. See Info node `(gnus)Customizing Articles' and Info
1492 node `(gnus)Smileys' for details."
1493 :group 'gnus-article-treat
1495 :link '(custom-manual "(gnus)Customizing Articles")
1496 :link '(custom-manual "(gnus)Smileys")
1497 :type gnus-article-treat-custom)
1498 (put 'gnus-treat-display-smileys 'highlight t)
1500 (defcustom gnus-treat-from-picon
1501 (if (and (gnus-image-type-available-p 'xpm)
1502 (gnus-picons-installed-p))
1504 "Display picons in the From header.
1505 Valid values are nil, t, `head', `first', `last', an integer or a
1506 predicate. See Info node `(gnus)Customizing Articles' and Info
1507 node `(gnus)Picons' for details."
1509 :group 'gnus-article-treat
1511 :link '(custom-manual "(gnus)Customizing Articles")
1512 :link '(custom-manual "(gnus)Picons")
1513 :type gnus-article-treat-head-custom)
1514 (put 'gnus-treat-from-picon 'highlight t)
1516 (defcustom gnus-treat-mail-picon
1517 (if (and (gnus-image-type-available-p 'xpm)
1518 (gnus-picons-installed-p))
1520 "Display picons in To and Cc headers.
1521 Valid values are nil, t, `head', `first', `last', an integer or a
1522 predicate. See Info node `(gnus)Customizing Articles' and Info
1523 node `(gnus)Picons' for details."
1525 :group 'gnus-article-treat
1527 :link '(custom-manual "(gnus)Customizing Articles")
1528 :link '(custom-manual "(gnus)Picons")
1529 :type gnus-article-treat-head-custom)
1530 (put 'gnus-treat-mail-picon 'highlight t)
1532 (defcustom gnus-treat-newsgroups-picon
1533 (if (and (gnus-image-type-available-p 'xpm)
1534 (gnus-picons-installed-p))
1536 "Display picons in the Newsgroups and Followup-To 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)Picons' for details."
1541 :group 'gnus-article-treat
1543 :link '(custom-manual "(gnus)Customizing Articles")
1544 :link '(custom-manual "(gnus)Picons")
1545 :type gnus-article-treat-head-custom)
1546 (put 'gnus-treat-newsgroups-picon 'highlight t)
1548 (defcustom gnus-treat-from-gravatar nil
1549 "Display gravatars in the From header.
1550 Valid values are nil, t, `head', `first', `last', an integer or a
1551 predicate. See Info node `(gnus)Customizing Articles' and Info
1552 node `(gnus)Gravatars' for details."
1554 :group 'gnus-article-treat
1555 :group 'gnus-gravatar
1556 :link '(custom-manual "(gnus)Customizing Articles")
1557 :link '(custom-manual "(gnus)Gravatars")
1558 :type gnus-article-treat-head-custom)
1559 (put 'gnus-treat-from-gravatar 'highlight t)
1561 (defcustom gnus-treat-mail-gravatar nil
1562 "Display gravatars in To and Cc headers.
1563 Valid values are nil, t, `head', `first', `last', an integer or a
1564 predicate. See Info node `(gnus)Customizing Articles' and Info
1565 node `(gnus)Gravatars' for details."
1567 :group 'gnus-article-treat
1568 :group 'gnus-gravatar
1569 :link '(custom-manual "(gnus)Customizing Articles")
1570 :link '(custom-manual "(gnus)Gravatars")
1571 :type gnus-article-treat-head-custom)
1572 (put 'gnus-treat-mail-gravatar 'highlight t)
1574 (defcustom gnus-treat-body-boundary
1575 (if (or gnus-treat-newsgroups-picon
1576 gnus-treat-mail-picon
1577 gnus-treat-from-picon
1578 gnus-treat-from-gravatar
1579 gnus-treat-mail-gravatar)
1580 ;; If there's much decoration, the user might prefer a boundery.
1583 "Draw a boundary at the end of the headers.
1584 Valid values are nil and `head'.
1585 See Info node `(gnus)Customizing Articles' for details."
1587 :group 'gnus-article-treat
1588 :link '(custom-manual "(gnus)Customizing Articles")
1589 :type gnus-article-treat-head-custom)
1591 (defcustom gnus-treat-capitalize-sentences nil
1592 "Capitalize sentence-starting words.
1593 Valid values are nil, t, `head', `first', `last', an integer or a
1594 predicate. See Info node `(gnus)Customizing Articles'."
1596 :group 'gnus-article-treat
1597 :link '(custom-manual "(gnus)Customizing Articles")
1598 :type gnus-article-treat-custom)
1600 (defcustom gnus-treat-wash-html nil
1602 Valid values are nil, t, `head', `first', `last', an integer or a
1603 predicate. See Info node `(gnus)Customizing Articles'."
1605 :group 'gnus-article-treat
1606 :link '(custom-manual "(gnus)Customizing Articles")
1607 :type gnus-article-treat-custom)
1609 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1611 Valid values are nil, t, `head', `first', `last', an integer or a
1612 predicate. See Info node `(gnus)Customizing Articles'."
1614 :group 'gnus-article-treat
1615 :link '(custom-manual "(gnus)Customizing Articles")
1616 :type gnus-article-treat-custom)
1618 (defcustom gnus-treat-x-pgp-sig nil
1620 To automatically treat X-PGP-Sig, set it to head.
1621 Valid values are nil, t, `head', `first', `last', an integer or a
1622 predicate. See Info node `(gnus)Customizing Articles'."
1624 :group 'gnus-article-treat
1625 :group 'mime-security
1626 :link '(custom-manual "(gnus)Customizing Articles")
1627 :type gnus-article-treat-custom)
1629 (defvar gnus-article-encrypt-protocol-alist
1630 '(("PGP" . mml2015-self-encrypt)))
1632 ;; Set to nil if more than one protocol added to
1633 ;; gnus-article-encrypt-protocol-alist.
1634 (defcustom gnus-article-encrypt-protocol "PGP"
1635 "The protocol used for encrypt articles.
1636 It is a string, such as \"PGP\". If nil, ask user."
1639 :group 'mime-security)
1641 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1642 (mm-coding-system-p 'utf-8)
1643 (executable-find idna-program))
1644 "Whether IDNA decoding of headers is used when viewing messages.
1645 This requires GNU Libidn, and by default only enabled if it is found."
1647 :group 'gnus-article-headers
1650 (defcustom gnus-article-over-scroll nil
1651 "If non-nil, allow scrolling the article buffer even when there no more text."
1653 :group 'gnus-article
1656 (defcustom gnus-inhibit-images nil
1657 "Non-nil means inhibit displaying of images inline in the article body."
1659 :group 'gnus-article
1662 (defcustom gnus-blocked-images 'gnus-block-private-groups
1663 "Images that have URLs matching this regexp will be blocked.
1664 This can also be a function to be evaluated. If so, it will be
1665 called with the group name as the parameter, and should return a
1671 ;;; Internal variables
1673 (defvar gnus-english-month-names
1674 '("January" "February" "March" "April" "May" "June" "July" "August"
1675 "September" "October" "November" "December"))
1677 (defvar article-goto-body-goes-to-point-min-p nil)
1678 (defvar gnus-article-wash-types nil)
1679 (defvar gnus-article-emphasis-alist nil)
1680 (defvar gnus-article-image-alist nil)
1682 (defvar gnus-article-mime-handle-alist-1 nil)
1683 (defvar gnus-treatment-function-alist
1684 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1685 (gnus-treat-strip-banner gnus-article-strip-banner)
1686 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1687 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1688 (gnus-treat-buttonize gnus-article-add-buttons)
1689 (gnus-treat-fill-article gnus-article-fill-cited-article)
1690 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1691 (gnus-treat-strip-cr gnus-article-remove-cr)
1692 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1693 (gnus-treat-date-ut gnus-article-date-ut)
1694 (gnus-treat-date-local gnus-article-date-local)
1695 (gnus-treat-date-english gnus-article-date-english)
1696 (gnus-treat-date-original gnus-article-date-original)
1697 (gnus-treat-date-user-defined gnus-article-date-user)
1698 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1699 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1700 (gnus-treat-date-combined-lapsed gnus-article-date-combined-lapsed)
1701 (gnus-treat-display-x-face gnus-article-display-x-face)
1702 (gnus-treat-display-face gnus-article-display-face)
1703 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1704 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1705 (gnus-treat-hide-signature gnus-article-hide-signature)
1706 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1707 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1708 (gnus-treat-from-picon gnus-treat-from-picon)
1709 (gnus-treat-mail-picon gnus-treat-mail-picon)
1710 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1711 (gnus-treat-strip-pem gnus-article-hide-pem)
1712 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1713 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1714 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1715 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1716 (gnus-treat-strip-trailing-blank-lines
1717 gnus-article-remove-trailing-blank-lines)
1718 (gnus-treat-strip-leading-blank-lines
1719 gnus-article-strip-leading-blank-lines)
1720 (gnus-treat-strip-multiple-blank-lines
1721 gnus-article-strip-multiple-blank-lines)
1722 (gnus-treat-overstrike gnus-article-treat-overstrike)
1723 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1724 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1725 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1726 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1727 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1728 (gnus-treat-display-smileys gnus-treat-smiley)
1729 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1730 (gnus-treat-wash-html gnus-article-wash-html)
1731 (gnus-treat-emphasize gnus-article-emphasize)
1732 (gnus-treat-hide-citation gnus-article-hide-citation)
1733 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1734 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1735 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1737 (defvar gnus-article-mime-handle-alist nil)
1738 (defvar article-lapsed-timer nil)
1739 (defvar gnus-article-current-summary nil)
1741 (defvar gnus-article-mode-syntax-table
1742 (let ((table (copy-syntax-table text-mode-syntax-table)))
1743 ;; This causes the citation match run O(2^n).
1744 ;; (modify-syntax-entry ?- "w" table)
1745 (modify-syntax-entry ?> ")<" table)
1746 (modify-syntax-entry ?< "(>" table)
1747 ;; make M-. in article buffers work for `foo' strings
1748 (modify-syntax-entry ?' " " table)
1749 (modify-syntax-entry ?` " " table)
1751 "Syntax table used in article mode buffers.
1752 Initialized from `text-mode-syntax-table.")
1754 (defvar gnus-save-article-buffer nil)
1756 (defvar gnus-number-of-articles-to-be-saved nil)
1758 (defvar gnus-inhibit-hiding nil)
1760 (defvar gnus-article-edit-mode nil)
1762 ;;; Macros for dealing with the article buffer.
1764 (defmacro gnus-with-article-headers (&rest forms)
1765 `(with-current-buffer gnus-article-buffer
1767 (let ((inhibit-read-only t)
1768 (inhibit-point-motion-hooks t)
1769 (case-fold-search t))
1770 (article-narrow-to-head)
1773 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1774 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1776 (defmacro gnus-with-article-buffer (&rest forms)
1777 `(with-current-buffer gnus-article-buffer
1778 (let ((inhibit-read-only t))
1781 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1782 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1784 (defun gnus-article-goto-header (header)
1785 "Go to HEADER, which is a regular expression."
1786 (re-search-forward (concat "^\\(" header "\\):") nil t))
1788 (defsubst gnus-article-hide-text (b e props)
1789 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1790 (gnus-add-text-properties-when 'article-type nil b e props)
1791 (when (memq 'intangible props)
1793 (max (1- b) (point-min))
1794 b 'intangible (cddr (memq 'intangible props)))))
1796 (defsubst gnus-article-unhide-text (b e)
1797 "Remove hidden text properties from region between B and E."
1798 (remove-text-properties b e gnus-hidden-properties)
1799 (when (memq 'intangible gnus-hidden-properties)
1800 (put-text-property (max (1- b) (point-min))
1801 b 'intangible nil)))
1803 (defun gnus-article-hide-text-type (b e type)
1804 "Hide text of TYPE between B and E."
1805 (gnus-add-wash-type type)
1806 (gnus-article-hide-text
1807 b e (cons 'article-type (cons type gnus-hidden-properties))))
1809 (defun gnus-article-unhide-text-type (b e type)
1810 "Unhide text of TYPE between B and E."
1811 (gnus-delete-wash-type type)
1812 (remove-text-properties
1813 b e (cons 'article-type (cons type gnus-hidden-properties)))
1814 (when (memq 'intangible gnus-hidden-properties)
1815 (put-text-property (max (1- b) (point-min))
1816 b 'intangible nil)))
1818 (defun gnus-article-hide-text-of-type (type)
1819 "Hide text of TYPE in the current buffer."
1821 (let ((b (point-min))
1823 (while (setq b (text-property-any b e 'article-type type))
1824 (add-text-properties b (incf b) gnus-hidden-properties)))))
1826 (defun gnus-article-delete-text-of-type (type)
1827 "Delete text of TYPE in the current buffer."
1829 (let ((b (point-min)))
1830 (if (eq type 'multipart)
1831 ;; Remove MIME buttons associated with multipart/alternative parts.
1834 (while (if (get-text-property (point) 'gnus-part)
1836 (when (setq b (next-single-property-change (point)
1841 (skip-chars-forward "\n")
1842 (when (eq (get-text-property b 'article-type) 'multipart)
1843 (delete-region b (point)))))
1844 (while (setq b (text-property-any b (point-max) 'article-type type))
1846 b (or (text-property-not-all b (point-max) 'article-type type)
1849 (defun gnus-article-delete-invisible-text ()
1850 "Delete all invisible text in the current buffer."
1852 (let ((b (point-min)))
1853 (while (setq b (text-property-any b (point-max) 'invisible t))
1855 b (or (text-property-not-all b (point-max) 'invisible t)
1858 (defun gnus-article-text-type-exists-p (type)
1859 "Say whether any text of type TYPE exists in the buffer."
1860 (text-property-any (point-min) (point-max) 'article-type type))
1862 (defsubst gnus-article-header-rank ()
1863 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1864 (let ((list gnus-sorted-header-list)
1867 (if (looking-at (car list))
1869 (setq list (cdr list))
1873 (defun article-hide-headers (&optional arg delete)
1874 "Hide unwanted headers and possibly sort them as well."
1876 ;; This function might be inhibited.
1877 (unless gnus-inhibit-hiding
1878 (let ((inhibit-read-only t)
1879 (case-fold-search t)
1880 (max (1+ (length gnus-sorted-header-list)))
1881 (inhibit-point-motion-hooks t)
1882 (cur (current-buffer))
1883 ignored visible beg)
1885 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1886 ;; group parameters, so we should go to the summary buffer.
1889 (progn (set-buffer gnus-summary-buffer) t)
1891 (setq ignored (when (not gnus-visible-headers)
1892 (cond ((stringp gnus-ignored-headers)
1893 gnus-ignored-headers)
1894 ((listp gnus-ignored-headers)
1895 (mapconcat 'identity
1896 gnus-ignored-headers
1898 visible (cond ((stringp gnus-visible-headers)
1899 gnus-visible-headers)
1900 ((and gnus-visible-headers
1901 (listp gnus-visible-headers))
1902 (mapconcat 'identity
1903 gnus-visible-headers
1907 ;; First we narrow to just the headers.
1908 (article-narrow-to-head)
1909 ;; Hide any "From " lines at the beginning of (mail) articles.
1910 (while (looking-at "From ")
1913 (delete-region (point-min) (point)))
1914 ;; Then treat the rest of the header lines.
1915 ;; Then we use the two regular expressions
1916 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1917 ;; select which header lines is to remain visible in the
1919 (while (re-search-forward "^[^ \t:]*:" nil t)
1921 ;; Mark the rank of the header.
1923 (point) (1+ (point)) 'message-rank
1924 (if (or (and visible (looking-at visible))
1926 (not (looking-at ignored))))
1927 (gnus-article-header-rank)
1930 (message-sort-headers-1)
1931 (when (setq beg (text-property-any
1932 (point-min) (point-max) 'message-rank (+ 2 max)))
1933 ;; We delete the unwanted headers.
1934 (gnus-add-wash-type 'headers)
1935 (add-text-properties (point-min) (+ 5 (point-min))
1936 '(article-type headers dummy-invisible t))
1937 (delete-region beg (point-max))))))))
1939 (defun article-hide-boring-headers (&optional arg)
1940 "Toggle hiding of headers that aren't very interesting.
1941 If given a negative prefix, always show; if given a positive prefix,
1943 (interactive (gnus-article-hidden-arg))
1944 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1945 (not gnus-show-all-headers))
1948 (let ((inhibit-read-only t)
1949 (inhibit-point-motion-hooks t))
1950 (article-narrow-to-head)
1951 (dolist (elem gnus-boring-article-headers)
1952 (goto-char (point-min))
1954 ;; Hide empty headers.
1956 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1958 (gnus-article-hide-text-type
1962 (if (re-search-forward "^[^ \t]" nil t)
1966 ;; Hide boring Newsgroups header.
1967 ((eq elem 'newsgroups)
1968 (when (gnus-string-equal
1969 (gnus-fetch-field "newsgroups")
1970 (gnus-group-real-name
1971 (if (boundp 'gnus-newsgroup-name)
1974 (gnus-article-hide-header "newsgroups")))
1975 ((eq elem 'to-address)
1976 (let ((to (message-fetch-field "to"))
1978 (gnus-parameter-to-address
1979 (if (boundp 'gnus-newsgroup-name)
1980 gnus-newsgroup-name ""))))
1981 (when (and to to-address
1984 ;; only one address in To
1985 (nth 1 (mail-extract-address-components to))
1987 (gnus-article-hide-header "to"))))
1989 (let ((to (message-fetch-field "to"))
1991 (gnus-parameter-to-list
1992 (if (boundp 'gnus-newsgroup-name)
1993 gnus-newsgroup-name ""))))
1994 (when (and to to-list
1997 ;; only one address in To
1998 (nth 1 (mail-extract-address-components to))
2000 (gnus-article-hide-header "to"))))
2002 (let ((cc (message-fetch-field "cc"))
2004 (gnus-parameter-to-list
2005 (if (boundp 'gnus-newsgroup-name)
2006 gnus-newsgroup-name ""))))
2007 (when (and cc to-list
2010 ;; only one address in CC
2011 (nth 1 (mail-extract-address-components cc))
2013 (gnus-article-hide-header "cc"))))
2014 ((eq elem 'followup-to)
2015 (when (gnus-string-equal
2016 (message-fetch-field "followup-to")
2017 (message-fetch-field "newsgroups"))
2018 (gnus-article-hide-header "followup-to")))
2019 ((eq elem 'reply-to)
2020 (if (gnus-group-find-parameter
2021 gnus-newsgroup-name 'broken-reply-to)
2022 (gnus-article-hide-header "reply-to")
2023 (let ((from (message-fetch-field "from"))
2024 (reply-to (message-fetch-field "reply-to")))
2031 (lambda (x) (downcase (cadr x)))
2032 (mail-extract-address-components from t))
2035 (lambda (x) (downcase (cadr x)))
2036 (mail-extract-address-components reply-to t))
2038 (gnus-article-hide-header "reply-to")))))
2040 (let ((date (with-current-buffer gnus-original-article-buffer
2041 ;; If date in `gnus-article-buffer' is localized
2042 ;; (`gnus-treat-date-user-defined'),
2043 ;; `days-between' might fail.
2044 (message-fetch-field "date"))))
2046 (< (days-between (current-time-string) date)
2048 (gnus-article-hide-header "date"))))
2050 (let ((to (message-fetch-field "to"))
2051 (cc (message-fetch-field "cc")))
2052 (when (> (length to) 1024)
2053 (gnus-article-hide-header "to"))
2054 (when (> (length cc) 1024)
2055 (gnus-article-hide-header "cc"))))
2059 (goto-char (point-min))
2060 (while (re-search-forward "^to:" nil t)
2061 (setq to-count (1+ to-count)))
2062 (when (> to-count 1)
2063 (while (> to-count 0)
2064 (goto-char (point-min))
2066 (re-search-forward "^to:" nil nil to-count)
2068 (narrow-to-region (point) (point-max))
2069 (gnus-article-hide-header "to"))
2070 (setq to-count (1- to-count))))
2071 (goto-char (point-min))
2072 (while (re-search-forward "^cc:" nil t)
2073 (setq cc-count (1+ cc-count)))
2074 (when (> cc-count 1)
2075 (while (> cc-count 0)
2076 (goto-char (point-min))
2078 (re-search-forward "^cc:" nil nil cc-count)
2080 (narrow-to-region (point) (point-max))
2081 (gnus-article-hide-header "cc"))
2082 (setq cc-count (1- cc-count)))))))))))))
2084 (defun gnus-article-hide-header (header)
2086 (goto-char (point-min))
2087 (when (re-search-forward (concat "^" header ":") nil t)
2088 (gnus-article-hide-text-type
2092 (if (re-search-forward "^[^ \t]" nil t)
2097 (defvar gnus-article-normalized-header-length 40
2098 "Length of normalized headers.")
2100 (defun article-normalize-headers ()
2101 "Make all header lines 40 characters long."
2103 (let ((inhibit-read-only t)
2107 (article-narrow-to-head)
2110 ((< (setq column (- (point-at-eol) (point)))
2111 gnus-article-normalized-header-length)
2113 (insert (make-string
2114 (- gnus-article-normalized-header-length column)
2116 ((> column gnus-article-normalized-header-length)
2117 (gnus-put-text-property
2119 (forward-char gnus-article-normalized-header-length)
2126 (forward-line 1))))))
2128 (defun article-treat-dumbquotes ()
2129 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2130 Note that this function guesses whether a character is a sm*rtq**t* or
2131 not, so it should only be used interactively.
2133 Sm*rtq**t*s are M****s***'s unilateral extension to the
2134 iso-8859-1 character map in an attempt to provide more quoting
2135 characters. If you see something like \\222 or \\264 where
2136 you're expecting some kind of apostrophe or quotation mark, then
2139 (article-translate-strings gnus-article-dumbquotes-map))
2141 (defvar org-entities)
2143 (defun article-treat-non-ascii ()
2144 "Translate many Unicode characters into their ASCII equivalents."
2146 (require 'org-entities)
2147 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2148 (dolist (elem org-entities)
2149 (when (and (listp elem)
2150 (= (length (nth 6 elem)) 1))
2151 (if (featurep 'xemacs)
2152 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2153 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2155 (when (article-goto-body)
2156 (let ((inhibit-read-only t)
2159 (if (not (setq replace (if (featurep 'xemacs)
2160 (get-char-table (following-char) table)
2161 (aref table (following-char)))))
2164 (setq props (text-properties-at (point)))
2166 (add-text-properties (point) (progn (insert replace) (point))
2168 (insert replace)))))))))
2170 (defun article-translate-characters (from to)
2171 "Translate all characters in the body of the article according to FROM and TO.
2172 FROM is a string of characters to translate from; to is a string of
2173 characters to translate to."
2175 (when (article-goto-body)
2176 (let ((inhibit-read-only t)
2177 (x (make-string 225 ?x))
2179 (while (< (incf i) (length x))
2182 (while (< i (length from))
2183 (aset x (aref from i) (aref to i))
2185 (translate-region (point) (point-max) x)))))
2187 (defun article-translate-strings (map)
2188 "Translate all string in the body of the article according to MAP.
2189 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2191 (when (article-goto-body)
2192 (let ((inhibit-read-only t))
2194 (let ((from (car elem))
2198 (while (search-forward from nil t)
2201 (if (eq (following-char) from)
2205 (forward-char 1)))))))))))
2207 (defun article-treat-overstrike ()
2208 "Translate overstrikes into bold text."
2211 (when (article-goto-body)
2212 (let ((inhibit-read-only t))
2213 (while (search-forward "\b" nil t)
2214 (let ((next (char-after))
2215 (previous (char-after (- (point) 2))))
2216 ;; We do the boldification/underlining by hiding the
2217 ;; overstrikes and putting the proper text property
2221 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2222 (put-text-property (point) (1+ (point)) 'face 'bold))
2224 (gnus-article-hide-text-type
2225 (1- (point)) (1+ (point)) 'overstrike)
2227 (- (point) 2) (1- (point)) 'face 'underline))
2229 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2231 (point) (1+ (point)) 'face 'underline)))))))))
2233 (defun article-treat-ansi-sequences ()
2234 "Translate ANSI SGR control sequences into overlays or extents."
2237 (when (article-goto-body)
2238 (let ((inhibit-read-only t))
2239 (ansi-color-apply-on-region (point) (point-max))))))
2241 (defun gnus-article-treat-unfold-headers ()
2242 "Unfold folded message headers.
2243 Only the headers that fit into the current window width will be
2246 (gnus-with-article-headers
2250 (mail-header-narrow-to-field)
2251 (let* ((header (buffer-string))
2253 (or (equal gnus-article-unfold-long-headers t)
2254 (and (stringp gnus-article-unfold-long-headers)
2255 (string-match gnus-article-unfold-long-headers header)))))
2258 (goto-char (point-min))
2259 (while (re-search-forward "\n[\t ]" nil t)
2260 (replace-match " " t t)))
2261 (setq length (- (point-max) (point-min) 1))
2262 (when (or unfoldable
2263 (< length (window-width)))
2264 (while (re-search-forward "\n[\t ]" nil t)
2265 (replace-match " " t t))))
2266 (goto-char (point-max)))))))
2268 (defun gnus-article-treat-fold-headers ()
2269 "Fold message headers."
2271 (gnus-with-article-headers
2274 (mail-header-narrow-to-field)
2275 (mail-header-fold-field)
2276 (goto-char (point-max))))))
2278 (defun gnus-treat-smiley ()
2279 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2281 (gnus-with-article-buffer
2282 (if (memq 'smiley gnus-article-wash-types)
2283 (gnus-delete-images 'smiley)
2285 (let ((images (smiley-region (point) (point-max))))
2287 (gnus-add-wash-type 'smiley)
2288 (dolist (image images)
2289 (gnus-add-image 'smiley image)))))))
2291 (defun gnus-article-remove-images ()
2292 "Remove all images from the article buffer."
2294 (gnus-with-article-buffer
2297 (dolist (elem gnus-article-image-alist)
2298 (gnus-delete-images (car elem))))))
2300 (defun gnus-article-show-images ()
2301 "Show any images that are in the HTML-rendered article buffer.
2302 This only works if the article in question is HTML."
2304 (gnus-with-article-buffer
2307 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2309 (destructuring-bind (start end function) region
2310 (funcall function (get-text-property start 'image-url)
2313 (defun gnus-article-treat-fold-newsgroups ()
2314 "Unfold folded message headers.
2315 Only the headers that fit into the current window width will be
2318 (gnus-with-article-headers
2319 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2321 (mail-header-narrow-to-field)
2322 (while (re-search-forward ", *" nil t)
2323 (replace-match ", " t t))
2324 (mail-header-fold-field)
2325 (goto-char (point-max))))))
2327 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2328 "Value of `truncate-lines' in Gnus Article buffer.
2329 Valid values are nil, t, `head', `first', `last', an integer or a
2330 predicate. See Info node `(gnus)Customizing Articles'."
2331 :version "23.1" ;; No Gnus
2332 :group 'gnus-article
2333 ;; :link '(custom-manual "(gnus)Customizing Articles")
2336 (defun gnus-article-toggle-truncate-lines (&optional arg)
2337 "Toggle whether to fold or truncate long lines in article the buffer.
2338 If ARG is non-nil and not a number, toggle
2339 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2340 long lines if and only if arg is positive."
2343 ((and (numberp arg) (> arg 0))
2344 (setq gnus-article-truncate-lines t))
2346 (setq gnus-article-truncate-lines nil))
2348 (setq gnus-article-truncate-lines
2349 (not gnus-article-truncate-lines))))
2350 (gnus-with-article-buffer
2352 ((and (numberp arg) (> arg 0))
2353 (setq truncate-lines nil))
2355 (setq truncate-lines t)))
2356 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2357 ;; `toggle-truncate-lines' needs an argument.
2358 (toggle-truncate-lines)))
2360 (defun gnus-article-treat-body-boundary ()
2361 "Place a boundary line at the end of the headers."
2363 (when (and gnus-body-boundary-delimiter
2364 (> (length gnus-body-boundary-delimiter) 0))
2365 (gnus-with-article-headers
2366 (goto-char (point-max))
2367 (let ((start (point)))
2368 (insert "X-Boundary: ")
2369 (gnus-add-text-properties start (point) '(invisible t intangible t))
2371 (while (>= (window-width) (length str))
2372 (setq str (concat str gnus-body-boundary-delimiter)))
2373 (substring str 0 (window-width)))
2375 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2377 (defun article-fill-long-lines ()
2378 "Fill lines that are wider than the window width."
2381 (let ((inhibit-read-only t)
2382 (width (window-width (get-buffer-window (current-buffer)))))
2385 (let ((adaptive-fill-mode nil)) ;Why? -sm
2388 (when (>= (current-column) (min fill-column width))
2389 (narrow-to-region (min (1+ (point)) (point-max))
2391 (let ((goback (point-marker)))
2392 (fill-paragraph nil)
2393 (goto-char (marker-position goback)))
2395 (forward-line 1)))))))
2397 (defun article-capitalize-sentences ()
2398 "Capitalize the first word in each sentence."
2401 (let ((inhibit-read-only t)
2402 (paragraph-start "^[\n\^L]"))
2406 (forward-sentence)))))
2408 (defun article-remove-cr ()
2409 "Remove trailing CRs and then translate remaining CRs into LFs."
2412 (let ((inhibit-read-only t))
2413 (goto-char (point-min))
2414 (while (re-search-forward "\r+$" nil t)
2415 (replace-match "" t t))
2416 (goto-char (point-min))
2417 (while (search-forward "\r" nil t)
2418 (replace-match "\n" t t)))))
2420 (defun article-remove-trailing-blank-lines ()
2421 "Remove all trailing blank lines from the article."
2424 (let ((inhibit-read-only t))
2425 (goto-char (point-max))
2429 (while (and (not (bobp))
2430 (looking-at "^[ \t]*$")
2431 (not (gnus-annotation-in-region-p
2432 (point) (point-at-eol))))
2437 (defvar gnus-face-properties-alist)
2439 (defun article-display-face (&optional force)
2440 "Display any Face headers in the header."
2441 (interactive (list 'force))
2442 (let ((wash-face-p buffer-read-only))
2443 (gnus-with-article-headers
2444 ;; When displaying parts, this function can be called several times on
2445 ;; the same article, without any intended toggle semantic (as typing `W
2446 ;; D d' would have). So face deletion must occur only when we come from
2447 ;; an interactive command, that is when the *Article* buffer is
2449 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2450 (gnus-delete-images 'face)
2451 (let ((from (message-fetch-field "from"))
2453 (save-current-buffer
2454 (when (and wash-face-p
2455 (gnus-buffer-live-p gnus-original-article-buffer)
2456 (not (re-search-forward "^Face:[\t ]*" nil t)))
2457 (set-buffer gnus-original-article-buffer))
2459 (mail-narrow-to-head)
2461 ;; Check whether this face is censored.
2462 (not (and gnus-article-x-face-too-ugly
2464 (setq from (message-fetch-field "from")))
2465 (string-match gnus-article-x-face-too-ugly
2467 (while (gnus-article-goto-header "Face")
2468 (push (mail-header-field-value) faces)))))
2470 (goto-char (point-min))
2472 (unless (setq from (gnus-article-goto-header "from"))
2475 (insert " [no `from' set]\n"))
2477 (when (setq png (gnus-convert-face-to-png (pop faces)))
2479 (apply 'gnus-create-image png 'png t
2480 (cdr (assq 'png gnus-face-properties-alist))))
2482 (gnus-add-wash-type 'face)
2483 (gnus-add-image 'face image)
2484 (gnus-put-image image nil 'face))))))))))
2486 (defun article-display-x-face (&optional force)
2487 "Look for an X-Face header and display it if present."
2488 (interactive (list 'force))
2489 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2490 (gnus-with-article-headers
2491 ;; Delete the old process, if any.
2492 (when (process-status "article-x-face")
2493 (delete-process "article-x-face"))
2494 ;; See the comment in `article-display-face'.
2495 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2496 ;; We have already displayed X-Faces, so we remove them
2498 (gnus-delete-images 'xface)
2500 (let ((from (message-fetch-field "from"))
2502 (save-current-buffer
2503 (when (and wash-face-p
2504 (gnus-buffer-live-p gnus-original-article-buffer)
2505 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2506 ;; If type `W f', use gnus-original-article-buffer,
2507 ;; otherwise use the current buffer because displaying
2508 ;; RFC822 parts calls this function too.
2509 (set-buffer gnus-original-article-buffer))
2511 (mail-narrow-to-head)
2512 (and gnus-article-x-face-command
2514 ;; Check whether this face is censored.
2515 (not (and gnus-article-x-face-too-ugly
2517 (setq from (message-fetch-field "from")))
2518 (string-match gnus-article-x-face-too-ugly
2520 (while (gnus-article-goto-header "X-Face")
2521 (push (mail-header-field-value) x-faces)))))
2523 ;; We display the face.
2524 (cond ((functionp gnus-article-x-face-command)
2525 ;; The command is a lisp function, so we call it.
2526 (mapc gnus-article-x-face-command x-faces))
2527 ((stringp gnus-article-x-face-command)
2528 ;; The command is a string, so we interpret the command
2529 ;; as a, well, command, and fork it off.
2530 (let ((process-connection-type nil))
2531 (gnus-set-process-query-on-exit-flag
2533 "article-x-face" nil shell-file-name
2534 shell-command-switch gnus-article-x-face-command)
2536 ;; Sending multiple EOFs to xv doesn't work,
2537 ;; so we only do a single external face.
2539 (insert (car x-faces))
2540 (process-send-region "article-x-face"
2541 (point-min) (point-max)))
2542 (process-send-eof "article-x-face")))
2544 (error "`%s' set to `%s' is not a function"
2545 gnus-article-x-face-command
2546 'gnus-article-x-face-command)))))))))
2548 (defun article-decode-mime-words ()
2549 "Decode all MIME-encoded words in the article."
2551 (gnus-with-article-buffer
2552 (let ((inhibit-point-motion-hooks t)
2553 (mail-parse-charset gnus-newsgroup-charset)
2554 (mail-parse-ignored-charsets
2555 (with-current-buffer gnus-summary-buffer
2556 gnus-newsgroup-ignored-charsets)))
2557 (mail-decode-encoded-word-region (point-min) (point-max)))))
2559 (defun article-decode-charset (&optional prompt)
2560 "Decode charset-encoded text in the article.
2561 If PROMPT (the prefix), prompt for a coding system to use."
2563 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2564 (inhibit-read-only t)
2565 (mail-parse-charset gnus-newsgroup-charset)
2566 (mail-parse-ignored-charsets
2567 (save-excursion (condition-case nil
2568 (set-buffer gnus-summary-buffer)
2570 gnus-newsgroup-ignored-charsets))
2571 ct cte ctl charset format)
2574 (article-narrow-to-head)
2575 (setq ct (message-fetch-field "Content-Type" t)
2576 cte (message-fetch-field "Content-Transfer-Encoding" t)
2577 ctl (and ct (mail-header-parse-content-type ct))
2580 (mm-read-coding-system "Charset to decode: "))
2582 (mail-content-type-get ctl 'charset)))
2583 format (and ctl (mail-content-type-get ctl 'format)))
2585 (setq cte (mail-header-strip cte)))
2586 (if (and ctl (not (string-match "/" (car ctl))))
2588 (goto-char (point-max)))
2591 (narrow-to-region (point) (point-max))
2592 (when (and (eq mail-parse-charset 'gnus-decoded)
2593 (eq (mm-body-7-or-8) '8bit))
2594 ;; The text code could have been decoded.
2595 (setq charset mail-parse-charset))
2596 (when (and (or (not ctl)
2597 (equal (car ctl) "text/plain"))
2598 (not format)) ;; article with format will decode later.
2600 charset (and cte (intern (downcase
2601 (gnus-strip-whitespace cte))))
2604 (defun article-decode-encoded-words ()
2605 "Remove encoded-word encoding from headers."
2606 (let ((inhibit-point-motion-hooks t)
2607 (mail-parse-charset gnus-newsgroup-charset)
2608 (mail-parse-ignored-charsets
2609 (save-excursion (condition-case nil
2610 (set-buffer gnus-summary-buffer)
2612 gnus-newsgroup-ignored-charsets))
2613 (inhibit-read-only t)
2615 (goto-char (point-min))
2616 (when (search-forward "\n\n" nil 'move)
2623 (memq (char-after) '(?\t ? )))))
2624 (setq start (point))
2626 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2627 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2628 (funcall gnus-decode-address-function start end)
2629 (funcall gnus-decode-header-function start end))
2630 (goto-char (setq end start)))))
2632 (defun article-decode-group-name ()
2633 "Decode group names in Newsgroups, Followup-To and Xref headers."
2634 (let ((inhibit-point-motion-hooks t)
2635 (inhibit-read-only t)
2636 (method (gnus-find-method-for-group gnus-newsgroup-name))
2638 (when (and (or gnus-group-name-charset-method-alist
2639 gnus-group-name-charset-group-alist)
2640 (gnus-buffer-live-p gnus-original-article-buffer))
2642 (article-narrow-to-head)
2643 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2644 (with-current-buffer gnus-original-article-buffer
2645 (goto-char (point-min)))
2646 (setq regexp (concat "^" header
2647 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2648 (while (re-search-forward regexp nil t)
2649 (replace-match (save-match-data
2650 (gnus-decode-newsgroups
2651 ;; XXX how to use data in article buffer?
2652 (with-current-buffer gnus-original-article-buffer
2653 (re-search-forward regexp nil t)
2655 gnus-newsgroup-name method))
2657 (goto-char (point-min)))))))
2659 (autoload 'idna-to-unicode "idna")
2661 (defun article-decode-idna-rhs ()
2662 "Decode IDNA strings in RHS in various headers in current buffer.
2663 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2664 Mail-Reply-To: and Mail-Followup-To:."
2667 (let ((inhibit-point-motion-hooks t)
2668 (inhibit-read-only t))
2669 (article-narrow-to-head)
2670 (goto-char (point-min))
2671 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2673 (when (save-match-data
2674 (and (setq ace (match-string 1))
2676 (and (re-search-backward "^[^ \t]" nil t)
2677 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2678 (setq unicode (idna-to-unicode ace))))
2679 (unless (string= ace unicode)
2680 (replace-match unicode nil nil nil 1)))))))))
2682 (defun article-de-quoted-unreadable (&optional force read-charset)
2683 "Translate a quoted-printable-encoded article.
2684 If FORCE, decode the article whether it is marked as quoted-printable
2686 If READ-CHARSET, ask for a coding system."
2687 (interactive (list 'force current-prefix-arg))
2689 (let ((inhibit-read-only t) type charset)
2690 (if (gnus-buffer-live-p gnus-original-article-buffer)
2691 (with-current-buffer gnus-original-article-buffer
2693 (gnus-fetch-field "content-transfer-encoding"))
2694 (let* ((ct (gnus-fetch-field "content-type"))
2695 (ctl (and ct (mail-header-parse-content-type ct))))
2696 (setq charset (and ctl
2697 (mail-content-type-get ctl 'charset)))
2698 (if (stringp charset)
2699 (setq charset (intern (downcase charset)))))))
2701 (setq charset (mm-read-coding-system "Charset: " charset)))
2703 (setq charset gnus-newsgroup-charset))
2705 (and type (let ((case-fold-search t))
2706 (string-match "quoted-printable" type))))
2708 (quoted-printable-decode-region
2709 (point) (point-max) (mm-charset-to-coding-system charset))))))
2711 (defun article-de-base64-unreadable (&optional force read-charset)
2712 "Translate a base64 article.
2713 If FORCE, decode the article whether it is marked as base64 not.
2714 If READ-CHARSET, ask for a coding system."
2715 (interactive (list 'force current-prefix-arg))
2717 (let ((inhibit-read-only t) type charset)
2718 (if (gnus-buffer-live-p gnus-original-article-buffer)
2719 (with-current-buffer gnus-original-article-buffer
2721 (gnus-fetch-field "content-transfer-encoding"))
2722 (let* ((ct (gnus-fetch-field "content-type"))
2723 (ctl (and ct (mail-header-parse-content-type ct))))
2724 (setq charset (and ctl
2725 (mail-content-type-get ctl 'charset)))
2726 (if (stringp charset)
2727 (setq charset (intern (downcase charset)))))))
2729 (setq charset (mm-read-coding-system "Charset: " charset)))
2731 (setq charset gnus-newsgroup-charset))
2733 (and type (let ((case-fold-search t))
2734 (string-match "base64" type))))
2737 (narrow-to-region (point) (point-max))
2738 (base64-decode-region (point-min) (point-max))
2739 (mm-decode-coding-region
2740 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2745 (defun article-decode-HZ ()
2746 "Translate a HZ-encoded article."
2750 (let ((inhibit-read-only t))
2751 (rfc1843-decode-region (point-min) (point-max)))))
2753 (defun article-unsplit-urls ()
2754 "Remove the newlines that some other mailers insert into URLs."
2757 (let ((inhibit-read-only t))
2758 (goto-char (point-min))
2759 (while (re-search-forward
2760 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2761 (replace-match "\\1\\3" t)))
2762 (when (interactive-p)
2763 (gnus-treat-article nil))))
2765 (defun article-wash-html ()
2766 "Format an HTML article."
2769 (buffer-read-only nil))
2770 (when (gnus-buffer-live-p gnus-original-article-buffer)
2771 (setq handles (mm-dissect-buffer t t)))
2773 (delete-region (point) (point-max))
2774 (mm-inline-text-html handles)))
2776 (defvar gnus-article-browse-html-temp-list nil
2777 "List of temporary files created by `gnus-article-browse-html-parts'.
2778 Internal variable.")
2780 (defcustom gnus-article-browse-delete-temp 'ask
2781 "What to do with temporary files from `gnus-article-browse-html-parts'.
2782 If nil, don't delete temporary files. If it is t, delete them on
2783 exit from the summary buffer. If it is the symbol `file', query
2784 on each file, if it is `ask' ask once when exiting from the
2786 :group 'gnus-article
2787 :version "23.1" ;; No Gnus
2788 :type '(choice (const :tag "Don't delete" nil)
2789 (const :tag "Don't ask" t)
2790 (const :tag "Ask" ask)
2791 (const :tag "Ask for each file" file)))
2793 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2795 (defun gnus-article-browse-delete-temp-files (&optional how)
2796 "Delete temp-files created by `gnus-article-browse-html-parts'."
2797 (when (and gnus-article-browse-html-temp-list
2799 (or how (setq how gnus-article-browse-delete-temp))
2801 (let ((files (length gnus-article-browse-html-temp-list)))
2802 (gnus-y-or-n-p (format
2803 "Delete all %s temporary HTML file%s? "
2805 (if (> files 1) "s" ""))))
2807 (dolist (file gnus-article-browse-html-temp-list)
2808 (cond ((file-directory-p file)
2809 (when (or (not (eq how 'file))
2812 "Delete temporary HTML file(s) in directory `%s'? "
2813 (file-name-as-directory file))))
2814 (gnus-delete-directory file)))
2815 ((file-exists-p file)
2816 (when (or (not (eq how 'file))
2818 (format "Delete temporary HTML file `%s'? " file)))
2819 (delete-file file)))))
2820 ;; Also remove file from the list when not deleted or if file doesn't
2822 (setq gnus-article-browse-html-temp-list nil))
2823 gnus-article-browse-html-temp-list)
2825 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2826 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2831 (dolist (handle handles)
2833 ((not (listp handle)))
2834 ((equal (mm-handle-media-supertype handle) "multipart")
2835 (when (setq file (gnus-article-browse-html-save-cid-content
2836 cid handle directory))
2837 (throw 'found file)))
2838 ((equal (concat "<" cid ">") (mm-handle-id handle))
2841 (or (mail-content-type-get
2842 (mm-handle-disposition handle) 'filename)
2843 (mail-content-type-get
2844 (setq type (mm-handle-type handle)) 'name)
2846 (make-temp-name "cid")
2847 (car (rassoc (car type) mailcap-mime-extensions))))
2849 (mm-save-part-to-file handle file)
2850 (throw 'found file))))))))
2852 (defun gnus-article-browse-html-parts (list &optional header)
2853 "View all \"text/html\" parts from LIST.
2854 Recurse into multiparts. The optional HEADER that should be a decoded
2855 message header will be added to the bodies of the \"text/html\" parts."
2856 ;; Internal function used by `gnus-article-browse-html-article'.
2857 (let (type file charset content cid-dir tmp-file showed)
2858 ;; Find and show the html-parts.
2859 (dolist (handle list)
2860 ;; If HTML, show it:
2861 (cond ((not (listp handle)))
2862 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2863 (and (equal (car type) "message/external-body")
2865 (setq file (or (mail-content-type-get type 'name)
2866 (mail-content-type-get
2867 (mm-handle-disposition handle)
2869 (or (mm-handle-cache handle)
2870 (condition-case code
2871 (progn (mm-extern-cache-contents handle) t)
2873 (gnus-message 3 "%s" (error-message-string code))
2874 (when (>= gnus-verbose 3) (sit-for 2))
2877 (setq handle (mm-handle-cache handle)
2878 type (mm-handle-type handle))
2879 (equal (car type) "text/html"))))
2880 (setq charset (mail-content-type-get type 'charset)
2881 content (mm-get-part handle))
2883 (if (eq charset 'gnus-decoded)
2884 (mm-enable-multibyte)
2885 (mm-disable-multibyte))
2887 ;; resolve cid contents
2888 (let ((case-fold-search t)
2890 (goto-char (point-min))
2891 (while (re-search-forward "\
2892 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2895 (setq cid-dir (mm-make-temp-file "cid" t))
2896 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2899 (when (setq cid-file
2900 (gnus-article-browse-html-save-cid-content
2902 (with-current-buffer gnus-article-buffer
2903 gnus-article-mime-handles)
2905 (replace-match (concat "file://" cid-file)
2907 (unless content (setq content (buffer-string))))
2908 (when (or charset header (not file))
2909 (setq tmp-file (mm-make-temp-file
2910 ;; Do we need to care for 8.3 filenames?
2911 "mm-" nil ".html")))
2912 ;; Add a meta html tag to specify charset and a header.
2915 (let (title eheader body hcharset coding force-charset)
2917 (mm-enable-multibyte)
2918 (setq case-fold-search t)
2919 (insert header "\n")
2920 (setq title (message-fetch-field "subject"))
2921 (goto-char (point-min))
2922 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2923 (replace-match (cond ((match-beginning 1) "<")
2924 ((match-beginning 2) ">")
2926 (goto-char (point-min))
2928 (goto-char (point-max))
2929 (insert "</pre>\n<hr>\n")
2930 ;; We have to examine charset one by one since
2931 ;; charset specified in parts might be different.
2932 (if (eq charset 'gnus-decoded)
2933 (setq charset 'utf-8
2934 eheader (mm-encode-coding-string (buffer-string)
2937 (mm-encode-coding-string title charset))
2938 body (mm-encode-coding-string content charset)
2940 (setq hcharset (mm-find-mime-charset-region (point-min)
2942 (cond ((= (length hcharset) 1)
2943 (setq hcharset (car hcharset)
2944 coding (mm-charset-to-coding-system
2946 ((> (length hcharset) 1)
2947 (setq hcharset 'utf-8
2953 (mm-charset-to-coding-system charset))
2954 (if (eq coding body)
2955 (setq eheader (mm-encode-coding-string
2956 (buffer-string) coding)
2958 (mm-encode-coding-string
2961 (setq charset 'utf-8
2962 eheader (mm-encode-coding-string
2963 (buffer-string) charset)
2965 (mm-encode-coding-string
2967 body (mm-encode-coding-string
2968 (mm-decode-coding-string
2972 (setq charset hcharset
2973 eheader (mm-encode-coding-string
2974 (buffer-string) coding)
2976 (mm-encode-coding-string
2979 (setq eheader (mm-string-as-unibyte (buffer-string))
2982 (mm-disable-multibyte)
2985 (mm-add-meta-html-tag handle charset force-charset))
2987 (goto-char (point-min))
2988 (unless (search-forward "<title>" nil t)
2989 (re-search-forward "<head>\\s-*" nil t)
2990 (insert "<title>" title "</title>\n")))
2991 (goto-char (point-min))
2992 (or (re-search-forward
2993 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2995 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2997 (mm-write-region (point-min) (point-max)
2998 tmp-file nil nil nil 'binary t))))
3000 (mm-with-unibyte-buffer
3001 (insert (if (eq charset 'gnus-decoded)
3002 (mm-encode-coding-string content
3003 (setq charset 'utf-8))
3005 (if (or (mm-add-meta-html-tag handle charset)
3007 (mm-write-region (point-min) (point-max)
3008 tmp-file nil nil nil 'binary t)
3009 (setq tmp-file nil))))
3011 (mm-save-part-to-file handle tmp-file)))
3013 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
3014 (add-hook 'gnus-summary-prepare-exit-hook
3015 'gnus-article-browse-delete-temp-files)
3016 (add-hook 'gnus-exit-gnus-hook
3018 (gnus-article-browse-delete-temp-files t)))
3019 ;; FIXME: Warn if there's an <img> tag?
3020 (browse-url-of-file (or tmp-file (expand-file-name file)))
3022 ;; If multipart, recurse
3023 ((equal (mm-handle-media-supertype handle) "multipart")
3024 (when (gnus-article-browse-html-parts handle header)
3026 ((equal (mm-handle-media-type handle) "message/rfc822")
3027 (mm-with-multibyte-buffer
3028 (mm-insert-part handle)
3029 (setq handle (mm-dissect-buffer t t))
3030 (when (and (bufferp (car handle))
3031 (stringp (car (mm-handle-type handle))))
3032 (setq handle (list handle)))
3034 (article-decode-encoded-words)
3035 (let ((gnus-visible-headers
3036 (or (get 'gnus-visible-headers 'standard-value)
3037 gnus-visible-headers)))
3038 (article-hide-headers))
3039 (goto-char (point-min))
3040 (search-forward "\n\n" nil 'move)
3041 (skip-chars-backward "\t\n ")
3042 (setq header (buffer-substring (point-min) (point)))))
3044 (gnus-article-browse-html-parts handle header)
3045 (mm-destroy-parts handle))
3049 (defun gnus-article-browse-html-article (&optional arg)
3050 "View \"text/html\" parts of the current article with a WWW browser.
3051 Inline images embedded in a message using the cid scheme, as they are
3052 generally considered to be safe, will be processed properly.
3053 The message header is added to the beginning of every html part unless
3054 the prefix argument ARG is given.
3056 Warning: Spammers use links to images (using the http scheme) in HTML
3057 articles to verify whether you have read the message. As
3058 `gnus-article-browse-html-article' passes the HTML content to the
3059 browser without eliminating these \"web bugs\" you should only
3060 use it for mails from trusted senders.
3062 If you always want to display HTML parts in the browser, set
3063 `mm-text-html-renderer' to nil.
3065 This command creates temporary files to pass HTML contents including
3066 images if any to the browser, and deletes them when exiting the group
3068 ;; Cf. `mm-w3m-safe-url-regexp'
3071 (gnus-summary-show-article)
3072 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3073 gnus-visible-headers))
3074 ;; As we insert a <hr>, there's no need for the body boundary.
3075 (gnus-treat-body-boundary nil))
3076 (gnus-summary-show-article)))
3077 (with-current-buffer gnus-article-buffer
3078 (let ((header (unless arg
3081 (buffer-substring-no-properties
3082 (goto-char (point-min))
3083 (if (search-forward "\n\n" nil t)
3085 (goto-char (point-max))
3086 (skip-chars-backward "\t\n ")
3089 (set-buffer gnus-original-article-buffer)
3090 (setq parts (mm-dissect-buffer t t))
3091 ;; If singlepart, enforce a list.
3092 (when (and (bufferp (car parts))
3093 (stringp (car (mm-handle-type parts))))
3094 (setq parts (list parts)))
3096 (unless (gnus-article-browse-html-parts parts header)
3097 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3098 (mm-destroy-parts parts)
3100 (gnus-summary-show-article)))))
3102 (defun article-hide-list-identifiers ()
3103 "Remove list identifies from the Subject header.
3104 The `gnus-list-identifiers' variable specifies what to do."
3106 (let ((inhibit-point-motion-hooks t)
3107 (regexp (if (consp gnus-list-identifiers)
3108 (mapconcat 'identity gnus-list-identifiers " *\\|")
3109 gnus-list-identifiers))
3110 (inhibit-read-only t))
3114 (article-narrow-to-head)
3115 (goto-char (point-min))
3116 (while (re-search-forward
3117 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3119 (delete-region (match-beginning 2) (match-end 0))
3120 (beginning-of-line))
3121 (when (re-search-forward
3122 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3123 (delete-region (match-beginning 1) (match-end 1))))))))
3125 (defun article-hide-pem (&optional arg)
3126 "Toggle hiding of any PEM headers and signatures in the current article.
3127 If given a negative prefix, always show; if given a positive prefix,
3129 (interactive (gnus-article-hidden-arg))
3130 (unless (gnus-article-check-hidden-text 'pem arg)
3132 (let ((inhibit-read-only t) end)
3133 (goto-char (point-min))
3134 ;; Hide the horrendously ugly "header".
3135 (when (and (search-forward
3136 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3138 (setq end (1+ (match-beginning 0))))
3139 (gnus-add-wash-type 'pem)
3140 (gnus-article-hide-text-type
3142 (if (search-forward "\n\n" nil t)
3146 ;; Hide the trailer as well
3147 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3149 (gnus-article-hide-text-type
3150 (match-beginning 0) (match-end 0) 'pem)))))))
3152 (defun article-strip-banner ()
3153 "Strip the banners specified by the `banner' group parameter and by
3154 `gnus-article-address-banner-alist'."
3158 (let ((inhibit-point-motion-hooks t))
3159 (when (gnus-parameter-banner gnus-newsgroup-name)
3160 (article-really-strip-banner
3161 (gnus-parameter-banner gnus-newsgroup-name)))
3162 (when gnus-article-address-banner-alist
3163 ;; Note that the From header is decoded here, so it is
3164 ;; required that the *-extract-address-components function
3165 ;; supports non-ASCII text.
3166 (let ((from (save-restriction
3168 (article-narrow-to-head)
3169 (mail-fetch-field "from"))))
3172 (cadr (funcall gnus-extract-address-components
3175 (dolist (pair gnus-article-address-banner-alist)
3176 (when (string-match (car pair) from)
3178 (article-really-strip-banner (cdr pair)))))))))))))
3180 (defun article-really-strip-banner (banner)
3181 "Strip the banner specified by the argument."
3184 (let ((inhibit-point-motion-hooks t)
3185 (gnus-signature-limit nil)
3186 (inhibit-read-only t))
3189 ((eq banner 'signature)
3190 (when (gnus-article-narrow-to-signature)
3193 (delete-region (point) (point-max))))
3195 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3196 (while (re-search-forward banner nil t)
3197 (delete-region (match-beginning 0) (match-end 0)))))
3199 (while (re-search-forward banner nil t)
3200 (delete-region (match-beginning 0) (match-end 0)))))))))
3202 (defun article-babel ()
3203 "Translate article using an online translation service."
3206 (gnus-with-article-buffer
3207 (when (article-goto-body)
3208 (let* ((start (point))
3210 (orig (buffer-substring start end))
3211 (trans (babel-as-string orig)))
3213 (narrow-to-region start end)
3214 (delete-region start end)
3217 (defun article-hide-signature (&optional arg)
3218 "Hide the signature in the current article.
3219 If given a negative prefix, always show; if given a positive prefix,
3221 (interactive (gnus-article-hidden-arg))
3222 (unless (gnus-article-check-hidden-text 'signature arg)
3225 (let ((inhibit-read-only t))
3226 (when (gnus-article-narrow-to-signature)
3227 (gnus-article-hide-text-type
3228 (point-min) (point-max) 'signature))))))
3229 (gnus-set-mode-line 'article))
3231 (defun article-strip-headers-in-body ()
3232 "Strip offensive headers from bodies."
3236 (let ((case-fold-search t))
3237 (when (looking-at "x-no-archive:")
3238 (gnus-delete-line)))))
3240 (defun article-strip-leading-blank-lines ()
3241 "Remove all blank lines from the beginning of the article."
3244 (let ((inhibit-point-motion-hooks t)
3245 (inhibit-read-only t))
3246 (when (article-goto-body)
3247 (while (and (not (eobp))
3248 (looking-at "[ \t]*$"))
3249 (gnus-delete-line))))))
3251 (defun article-narrow-to-head ()
3252 "Narrow the buffer to the head of the message.
3253 Point is left at the beginning of the narrowed-to region."
3255 (goto-char (point-min))
3256 (if (search-forward "\n\n" nil 1)
3259 (goto-char (point-min)))
3261 (defun article-goto-body ()
3262 "Place point at the start of the body."
3263 (goto-char (point-min))
3265 ;; This variable is only bound when dealing with separate
3267 (article-goto-body-goes-to-point-min-p
3269 ((search-forward "\n\n" nil t)
3272 (goto-char (point-max))
3275 (defun article-strip-multiple-blank-lines ()
3276 "Replace consecutive blank lines with one empty line."
3279 (let ((inhibit-point-motion-hooks t)
3280 (inhibit-read-only t))
3281 ;; First make all blank lines empty.
3283 (while (re-search-forward "^[ \t]+$" nil t)
3284 (unless (gnus-annotation-in-region-p
3285 (match-beginning 0) (match-end 0))
3286 (replace-match "" nil t)))
3287 ;; Then replace multiple empty lines with a single empty line.
3289 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3290 (unless (gnus-annotation-in-region-p
3291 (match-beginning 0) (match-end 0))
3292 (delete-region (match-beginning 1) (match-end 1)))))))
3294 (defun article-strip-leading-space ()
3295 "Remove all white space from the beginning of the lines in the article."
3298 (let ((inhibit-point-motion-hooks t)
3299 (inhibit-read-only t))
3301 (while (re-search-forward "^[ \t]+" nil t)
3302 (replace-match "" t t)))))
3304 (defun article-strip-trailing-space ()
3305 "Remove all white space from the end of the lines in the article."
3308 (let ((inhibit-point-motion-hooks t)
3309 (inhibit-read-only t))
3311 (while (re-search-forward "[ \t]+$" nil t)
3312 (replace-match "" t t)))))
3314 (defun article-strip-blank-lines ()
3315 "Strip leading, trailing and multiple blank lines."
3317 (article-strip-leading-blank-lines)
3318 (article-remove-trailing-blank-lines)
3319 (article-strip-multiple-blank-lines))
3321 (defun article-strip-all-blank-lines ()
3322 "Strip all blank lines."
3325 (let ((inhibit-point-motion-hooks t)
3326 (inhibit-read-only t))
3328 (while (re-search-forward "^[ \t]*\n" nil t)
3329 (replace-match "" t t)))))
3331 (defun gnus-article-narrow-to-signature ()
3332 "Narrow to the signature; return t if a signature is found, else nil."
3333 (let ((inhibit-point-motion-hooks t))
3334 (when (gnus-article-search-signature)
3336 ;; Check whether we have some limits to what we consider
3337 ;; to be a signature.
3338 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3339 (list gnus-signature-limit)))
3341 (while (setq limit (pop limits))
3342 (if (or (and (integerp limit)
3343 (< (- (point-max) (point)) limit))
3345 (< (count-lines (point) (point-max)) limit))
3346 (and (functionp limit)
3348 (and (stringp limit)
3349 (not (re-search-forward limit nil t))))
3350 () ; This limit did not succeed.
3354 (narrow-to-region (point) (point-max))
3357 (defun gnus-article-search-signature ()
3358 "Search the current buffer for the signature separator.
3359 Put point at the beginning of the signature separator."
3360 (let ((cur (point)))
3361 (goto-char (point-max))
3362 (if (if (stringp gnus-signature-separator)
3363 (re-search-backward gnus-signature-separator nil t)
3364 (let ((seps gnus-signature-separator))
3366 (not (re-search-backward (car seps) nil t)))
3373 (defun gnus-article-hidden-arg ()
3374 "Return the current prefix arg as a number, or 0 if no prefix."
3375 (list (if current-prefix-arg
3376 (prefix-numeric-value current-prefix-arg)
3379 (defun gnus-article-check-hidden-text (type arg)
3380 "Return nil if hiding is necessary.
3381 Arg can be nil or a number. nil and positive means hide, negative
3382 means show, 0 means toggle."
3385 (let ((hide (gnus-article-hidden-text-p type)))
3391 (gnus-article-show-hidden-text type)
3394 (if (eq hide 'hidden)
3396 (gnus-article-show-hidden-text type)
3400 (defun gnus-article-hidden-text-p (type)
3401 "Say whether the current buffer contains hidden text of type TYPE."
3402 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3404 (not (get-text-property pos 'invisible))
3405 (not (get-text-property pos 'dummy-invisible)))
3407 (text-property-any (1+ pos) (point-max) 'article-type type)))
3412 (defun gnus-article-show-hidden-text (type &optional dummy)
3413 "Show all hidden text of type TYPE.
3414 Originally it is hide instead of DUMMY."
3415 (let ((inhibit-read-only t)
3416 (inhibit-point-motion-hooks t))
3417 (gnus-remove-text-properties-when
3419 (point-min) (point-max)
3420 (cons 'article-type (cons type
3421 gnus-hidden-properties)))
3422 (gnus-delete-wash-type type)))
3424 (defconst article-time-units
3425 `((year . ,(* 365.25 24 60 60))
3426 (week . ,(* 7 24 60 60))
3427 (day . ,(* 24 60 60))
3431 "Mapping from time units to seconds.")
3433 (defun gnus-article-forward-header ()
3434 "Move point to the start of the next header.
3435 If the current header is a continuation header, this can be several
3440 (if (looking-at "[ \t]+[^ \t]")
3444 (defun article-date-ut (&optional type highlight)
3445 "Convert DATE date to universal time in the current article.
3446 If TYPE is `local', convert to local time; if it is `lapsed', output
3447 how much time has lapsed since DATE. For `lapsed', the value of
3448 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3449 should replace the \"Date:\" one, or should be added below it."
3450 (interactive (list 'ut t))
3451 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3452 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3456 (article-lapsed-timer
3460 (case-fold-search t)
3461 (inhibit-read-only t)
3462 (inhibit-point-motion-hooks t)
3463 pos date bface eface)
3467 (goto-char (point-min))
3468 (while (or (setq date (get-text-property (setq pos (point))
3470 (when (setq pos (next-single-property-change
3471 (point) 'original-date))
3472 (setq date (get-text-property pos 'original-date))
3475 pos (if (setq pos (text-property-any pos (point-max)
3476 'original-date nil))
3479 (if (or (bolp) (eobp))
3483 (goto-char (point-min))
3484 (when (re-search-forward tdate-regexp nil t)
3485 (setq bface (get-text-property (point-at-bol) 'face)
3486 eface (get-text-property (1- (point-at-eol)) 'face)))
3487 (goto-char (point-min))
3489 ;; Delete any old Date headers.
3490 (while (re-search-forward date-regexp nil t)
3492 (delete-region (point-at-bol) (progn
3493 (gnus-article-forward-header)
3495 (delete-region (point-at-bol) (progn
3496 (gnus-article-forward-header)
3499 (setq pos (point))))
3500 (when (and (not pos)
3501 (re-search-forward tdate-regexp nil t))
3503 (gnus-goto-char pos)
3504 (insert (article-make-date-line date (or type 'ut)))
3510 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3511 (put-text-property (match-beginning 1) (1+ (match-end 1))
3513 (put-text-property (match-beginning 2) (match-end 2)
3515 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3516 (goto-char (point-max))
3519 (defun article-make-date-line (date type)
3520 "Return a DATE line of TYPE."
3521 (unless (memq type '(local ut original user iso8601 lapsed english
3523 (error "Unknown conversion type: %s" type))
3525 (let ((time (date-to-time date)))
3527 ;; Convert to the local timezone.
3529 (concat "Date: " (message-make-date time)))
3530 ;; Convert to Universal Time.
3535 (let* ((e (parse-time-string date))
3536 (tm (apply 'encode-time e))
3538 (ls (- (cadr tm) (car (current-time-zone time)))))
3539 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3540 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3544 ;; Get the original date from the article.
3545 ((eq type 'original)
3546 (concat "Date: " (if (string-match "\n+$" date)
3547 (substring date 0 (match-beginning 0))
3549 ;; Let the user define the format.
3551 (let ((format (or (condition-case nil
3552 (with-current-buffer gnus-summary-buffer
3553 gnus-article-time-format)
3555 gnus-article-time-format)))
3556 (if (functionp format)
3557 (funcall format time)
3558 (concat "Date: " (format-time-string format time)))))
3561 (let ((tz (car (current-time-zone time))))
3564 (format-time-string "%Y%m%dT%H%M%S" time)
3565 (format "%s%02d%02d"
3566 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3567 (/ (% (abs tz) 3600) 60)))))
3568 ;; Do an X-Sent lapsed format.
3570 (concat "X-Sent: " (article-lapsed-string time)))
3571 ;; A combined date/lapsed format.
3572 ((eq type 'combined-lapsed)
3573 (concat (article-make-date-line date 'original)
3574 " (" (article-lapsed-string time 3) ")"))
3575 ;; Display the date in proper English
3577 (let ((dtime (decode-time time)))
3580 (number-to-string (nth 3 dtime))
3581 (let ((digit (% (nth 3 dtime) 10)))
3583 ((memq (nth 3 dtime) '(11 12 13)) "th")
3589 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3591 (number-to-string (nth 5 dtime))
3593 (format "%02d" (nth 2 dtime))
3595 (format "%02d" (nth 1 dtime)))))))
3597 (format "Date: %s (from Gnus)" date))))
3599 (defun article-lapsed-string (time &optional max-segments)
3600 ;; If the date is seriously mangled, the timezone functions are
3601 ;; liable to bug out, so we ignore all errors.
3602 (let* ((now (current-time))
3603 (real-time (subtract-time now time))
3604 (real-sec (and real-time
3605 (+ (* (float (car real-time)) 65536)
3607 (sec (and real-time (abs real-sec)))
3610 (unless max-segments
3611 (setq max-segments (length article-time-units)))
3619 ;; This is a bit convoluted, but basically we go
3620 ;; through the time units for years, weeks, etc,
3621 ;; and divide things to see whether that results
3622 ;; in positive answers.
3625 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3626 (>= segments max-segments))
3627 ;; The (remaining) seconds are too few to
3628 ;; be divided into this time unit.
3630 ;; It's big enough, so we output it.
3631 (setq sec (- sec (* num (cdr unit))))
3633 (concat (if prev ", " "") (int-to-string
3635 " " (symbol-name (car unit))
3636 (if (> num 1) "s" ""))
3638 segments (1+ segments)))))
3639 article-time-units "")
3640 ;; If dates are odd, then it might appear like the
3641 ;; article was sent in the future.
3644 " in the future"))))))
3646 (defun article-date-local (&optional highlight)
3647 "Convert the current article date to the local timezone."
3648 (interactive (list t))
3649 (article-date-ut 'local highlight))
3651 (defun article-date-english (&optional highlight)
3652 "Convert the current article date to something that is proper English."
3653 (interactive (list t))
3654 (article-date-ut 'english highlight))
3656 (defun article-date-original (&optional highlight)
3657 "Convert the current article date to what it was originally.
3658 This is only useful if you have used some other date conversion
3659 function and want to see what the date was before converting."
3660 (interactive (list t))
3661 (article-date-ut 'original highlight))
3663 (defun article-date-lapsed (&optional highlight)
3664 "Convert the current article date to time lapsed since it was sent."
3665 (interactive (list t))
3666 (article-date-ut 'lapsed highlight))
3668 (defun article-date-combined-lapsed (&optional highlight)
3669 "Convert the current article date to time lapsed since it was sent."
3670 (interactive (list t))
3671 (article-date-ut 'combined-lapsed highlight))
3673 (defun article-update-date-lapsed ()
3674 "Function to be run from a timer to update the lapsed time line."
3676 (let (deactivate-mark)
3677 (save-window-excursion
3681 (set-buffer (window-buffer w))
3682 (when (eq major-mode 'gnus-article-mode)
3683 (let ((mark (point-marker))
3684 (old-point (point)))
3685 (goto-char (point-min))
3686 (when (re-search-forward "^X-Sent:\\|^Date:" nil t)
3687 ;; If the point is on the Date line, then use that
3688 ;; absolute position. Otherwise, use the mark.
3689 ;; This will ensure that point stays at the "same
3691 (when (or (< old-point (match-beginning 0))
3694 (while (and (not (eobp))
3695 (looking-at "X-Sent:\\|Date:"))
3698 (setq old-point nil))
3699 (when gnus-treat-date-combined-lapsed
3700 (article-date-combined-lapsed t))
3701 (when gnus-treat-date-lapsed
3702 (article-date-lapsed t)))
3703 (goto-char (or old-point (marker-position mark)))
3704 (move-marker mark nil))))
3707 (defun gnus-start-date-timer (&optional n)
3708 "Start a timer to update the X-Sent header in the article buffers.
3709 The numerical prefix says how frequently (in seconds) the function
3714 (gnus-stop-date-timer)
3715 (setq article-lapsed-timer
3716 (run-at-time 1 n 'article-update-date-lapsed)))
3718 (defun gnus-stop-date-timer ()
3719 "Stop the X-Sent timer."
3721 (when article-lapsed-timer
3722 (nnheader-cancel-timer article-lapsed-timer)
3723 (setq article-lapsed-timer nil)))
3725 (defun article-date-user (&optional highlight)
3726 "Convert the current article date to the user-defined format.
3727 This format is defined by the `gnus-article-time-format' variable."
3728 (interactive (list t))
3729 (article-date-ut 'user highlight))
3731 (defun article-date-iso8601 (&optional highlight)
3732 "Convert the current article date to ISO8601."
3733 (interactive (list t))
3734 (article-date-ut 'iso8601 highlight))
3736 (defmacro gnus-article-save-original-date (&rest forms)
3737 "Save the original date as a text property and evaluate FORMS."
3738 `(let* ((case-fold-search t)
3740 (goto-char (point-min))
3741 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3744 (date (when (and start
3745 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3747 (buffer-substring-no-properties start
3748 (match-beginning 0)))))
3749 (goto-char (point-max))
3750 (skip-chars-backward "\n")
3751 (put-text-property (point-min) (point) 'original-date date)
3753 (goto-char (point-max))
3754 (skip-chars-backward "\n")
3755 (put-text-property (point-min) (point) 'original-date date)))
3757 ;; (defun article-show-all ()
3758 ;; "Show all hidden text in the article buffer."
3761 ;; (let ((inhibit-read-only t))
3762 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3764 (defun article-remove-leading-whitespace ()
3765 "Remove excessive whitespace from all headers."
3769 (let ((inhibit-read-only t))
3770 (article-narrow-to-head)
3771 (goto-char (point-min))
3772 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3773 (delete-region (match-beginning 1) (match-end 1)))))))
3775 (defun article-emphasize (&optional arg)
3776 "Emphasize text according to `gnus-emphasis-alist'."
3777 (interactive (gnus-article-hidden-arg))
3778 (unless (gnus-article-check-hidden-text 'emphasis arg)
3782 (with-current-buffer gnus-summary-buffer
3783 gnus-article-emphasis-alist)
3785 gnus-emphasis-alist))
3786 (inhibit-read-only t)
3787 (props (append '(article-type emphasis)
3788 gnus-hidden-properties))
3789 regexp elem beg invisible visible face)
3792 (while (setq elem (pop alist))
3794 (setq regexp (car elem)
3795 invisible (nth 1 elem)
3796 visible (nth 2 elem)
3798 (while (re-search-forward regexp nil t)
3799 (when (and (match-beginning visible) (match-beginning invisible))
3800 (gnus-article-hide-text
3801 (match-beginning invisible) (match-end invisible) props)
3802 (gnus-article-unhide-text-type
3803 (match-beginning visible) (match-end visible) 'emphasis)
3804 (gnus-put-overlay-excluding-newlines
3805 (match-beginning visible) (match-end visible) 'face face)
3806 (gnus-add-wash-type 'emphasis)
3807 (goto-char (match-end invisible)))))))))
3809 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3810 "Setup newsgroup emphasis alist."
3811 (unless gnus-article-emphasis-alist
3812 (let ((name (and gnus-newsgroup-name
3813 (gnus-group-real-name gnus-newsgroup-name))))
3814 (make-local-variable 'gnus-article-emphasis-alist)
3815 (setq gnus-article-emphasis-alist
3817 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3818 (while (setq elem (pop alist))
3819 (when (and name (string-match (car elem) name))
3821 highlight (copy-sequence (cdr elem)))))
3823 (copy-sequence highlight-words)
3824 (if gnus-newsgroup-name
3825 (copy-sequence (gnus-group-find-parameter
3826 gnus-newsgroup-name 'highlight-words t)))
3827 gnus-emphasis-alist)))))
3829 (defvar gnus-summary-article-menu)
3830 (defvar gnus-summary-post-menu)
3832 ;;; Saving functions.
3834 (defun gnus-article-save (save-buffer file &optional num)
3835 "Save the currently selected article."
3836 (when (or (get gnus-default-article-saver :headers)
3837 (not gnus-save-all-headers))
3838 ;; Remove headers according to `gnus-saved-headers' or the value
3839 ;; of the `:headers' property that the saver function might have.
3840 (let ((gnus-visible-headers
3841 (or (symbol-value (get gnus-default-article-saver :headers))
3842 gnus-saved-headers gnus-visible-headers))
3843 ;; Ignore group parameter. See `article-hide-headers'.
3844 (gnus-summary-buffer nil))
3845 (with-current-buffer save-buffer
3846 (article-hide-headers 1 t))))
3847 (save-window-excursion
3848 (if (not gnus-default-article-saver)
3849 (error "No default saver is defined")
3850 ;; !!! Magic! The saving functions all save
3851 ;; `gnus-save-article-buffer' (or so they think), but we
3852 ;; bind that variable to our save-buffer.
3853 (set-buffer gnus-article-buffer)
3854 (let* ((gnus-save-article-buffer save-buffer)
3857 ((not gnus-prompt-before-saving) 'default)
3858 ((eq gnus-prompt-before-saving 'always) nil)
3860 (gnus-number-of-articles-to-be-saved
3861 (when (eq gnus-prompt-before-saving t)
3863 (set-buffer gnus-article-current-summary)
3864 (funcall gnus-default-article-saver filename)))))
3866 (defun gnus-read-save-file-name (prompt &optional filename
3867 function group headers variable
3870 (funcall function group headers (symbol-value variable)))
3875 ((eq filename 'default)
3881 (when (symbol-value dir-var)
3882 (setq default-name (expand-file-name
3883 (file-name-nondirectory default-name)
3884 (symbol-value dir-var))))
3885 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3888 (if (and gnus-number-of-articles-to-be-saved
3889 (> gnus-number-of-articles-to-be-saved 1))
3890 (format "these %d articles"
3891 gnus-number-of-articles-to-be-saved)
3894 ;; Let the split methods have their say.
3896 ;; No split name was found.
3899 (concat prompt " (default "
3900 (file-name-nondirectory default-name) "): ")
3901 (file-name-directory default-name)
3903 ;; A single group name is returned.
3904 ((stringp split-name)
3906 (funcall function split-name headers
3907 (symbol-value variable)))
3909 (concat prompt " (default "
3910 (file-name-nondirectory default-name) "): ")
3911 (file-name-directory default-name)
3913 ;; A single split name was found
3914 ((= 1 (length split-name))
3915 (let* ((name (expand-file-name
3917 gnus-article-save-directory))
3918 (dir (cond ((file-directory-p name)
3919 (file-name-as-directory name))
3920 ((file-exists-p name) name)
3921 (t gnus-article-save-directory))))
3923 (concat prompt " (default " name "): ")
3925 ;; A list of splits was found.
3927 (setq split-name (nreverse split-name))
3929 (let ((file-name-history
3930 (nconc split-name file-name-history)))
3934 (concat prompt " (`M-p' for defaults): ")
3935 gnus-article-save-directory
3937 gnus-article-save-directory)))
3938 (car (push result file-name-history)))))))
3939 ;; Create the directory.
3940 (gnus-make-directory (file-name-directory file))
3941 ;; If we have read a directory, we append the default file name.
3942 (when (file-directory-p file)
3943 (setq file (expand-file-name (file-name-nondirectory
3945 (file-name-as-directory file))))
3946 ;; Possibly translate some characters.
3947 (nnheader-translate-file-chars file))))))
3948 (gnus-make-directory (file-name-directory result))
3950 (set variable result))
3952 (set dir-var (file-name-directory result)))
3955 (defun gnus-article-archive-name (group)
3956 "Return the first instance of an \"Archive-name\" in the current buffer."
3957 (let ((case-fold-search t))
3958 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3959 (nnheader-concat gnus-article-save-directory
3960 (match-string 1)))))
3962 (defun gnus-article-nndoc-name (group)
3963 "If GROUP is an nndoc group, return the name of the parent group."
3964 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3965 (gnus-group-get-parameter group 'save-article-group)))
3967 (defun gnus-summary-save-in-rmail (&optional filename)
3968 "Append this article to Rmail file.
3969 Optional argument FILENAME specifies file name.
3970 Directory to save to is default to `gnus-article-save-directory'."
3971 (setq filename (gnus-read-save-file-name
3972 "Save %s in rmail file" filename
3973 gnus-rmail-save-name gnus-newsgroup-name
3974 gnus-current-headers 'gnus-newsgroup-last-rmail))
3975 (with-current-buffer gnus-save-article-buffer
3979 ;; Note that unlike gnus-summary-save-in-mail, there is no
3980 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3982 (gnus-output-to-rmail filename))))
3985 (defun gnus-summary-save-in-mail (&optional filename)
3986 "Append this article to Unix mail file.
3987 Optional argument FILENAME specifies file name.
3988 Directory to save to is default to `gnus-article-save-directory'."
3989 (setq filename (gnus-read-save-file-name
3990 "Save %s in Unix mail file" filename
3991 gnus-mail-save-name gnus-newsgroup-name
3992 gnus-current-headers 'gnus-newsgroup-last-mail))
3993 (with-current-buffer gnus-save-article-buffer
3997 (if (and (file-readable-p filename)
3998 (file-regular-p filename)
3999 (mail-file-babyl-p filename))
4000 (gnus-output-to-rmail filename)
4001 (gnus-output-to-mail filename)))))
4004 (put 'gnus-summary-save-in-file :decode t)
4005 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
4006 (defun gnus-summary-save-in-file (&optional filename overwrite)
4007 "Append this article to file.
4008 Optional argument FILENAME specifies file name.
4009 Directory to save to is default to `gnus-article-save-directory'."
4010 (setq filename (gnus-read-save-file-name
4011 "Save %s in file" filename
4012 gnus-file-save-name gnus-newsgroup-name
4013 gnus-current-headers 'gnus-newsgroup-last-file))
4014 (with-current-buffer gnus-save-article-buffer
4018 (when (and overwrite
4019 (file-exists-p filename))
4020 (delete-file filename))
4021 (gnus-output-to-file filename))))
4024 (put 'gnus-summary-write-to-file :decode t)
4025 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4026 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4027 (defun gnus-summary-write-to-file (&optional filename)
4028 "Write this article to a file, overwriting it if the file exists.
4029 Optional argument FILENAME specifies file name.
4030 The directory to save in defaults to `gnus-article-save-directory'."
4031 (setq filename (gnus-read-save-file-name
4032 "Save %s in file" filename
4033 gnus-file-save-name gnus-newsgroup-name
4034 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4035 (gnus-summary-save-in-file filename t))
4037 (put 'gnus-summary-save-body-in-file :decode t)
4038 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4039 "Append this article body to a file.
4040 Optional argument FILENAME specifies file name.
4041 The directory to save in defaults to `gnus-article-save-directory'."
4042 (setq filename (gnus-read-save-file-name
4043 "Save %s body in file" filename
4044 gnus-file-save-name gnus-newsgroup-name
4045 gnus-current-headers 'gnus-newsgroup-last-file))
4046 (with-current-buffer gnus-save-article-buffer
4050 (when (article-goto-body)
4051 (narrow-to-region (point) (point-max)))
4052 (when (and overwrite
4053 (file-exists-p filename))
4054 (delete-file filename))
4055 (gnus-output-to-file filename))))
4058 (put 'gnus-summary-write-body-to-file :decode t)
4059 (put 'gnus-summary-write-body-to-file
4060 :function 'gnus-summary-save-body-in-file)
4061 (defun gnus-summary-write-body-to-file (&optional filename)
4062 "Write this article body to a file, overwriting it if the file exists.
4063 Optional argument FILENAME specifies file name.
4064 The directory to save in defaults to `gnus-article-save-directory'."
4065 (setq filename (gnus-read-save-file-name
4066 "Save %s body in file" filename
4067 gnus-file-save-name gnus-newsgroup-name
4068 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4069 (gnus-summary-save-body-in-file filename t))
4071 (put 'gnus-summary-save-in-pipe :decode t)
4072 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4073 (defun gnus-summary-save-in-pipe (&optional command raw)
4074 "Pipe this article to subprocess COMMAND.
4075 Valid values for COMMAND include:
4077 The executable command name and possibly arguments.
4079 You will be prompted for the command in the minibuffer.
4080 the symbol `default'
4081 It will be replaced with the command which the variable
4082 `gnus-summary-pipe-output-default-command' holds or the command
4083 last used for saving.
4084 Non-nil value for RAW overrides `:decode' and `:headers' properties
4085 and the raw article including all headers will be piped."
4086 (let ((article (gnus-summary-article-number))
4088 (get 'gnus-summary-save-in-pipe :decode)))
4089 save-buffer default)
4091 (if (vectorp (gnus-summary-article-header article))
4092 (save-current-buffer
4093 (gnus-summary-select-article decode decode nil article)
4094 (insert-buffer-substring
4098 gnus-original-article-buffer)
4100 (nnheader-set-temp-buffer " *Gnus Save*"))))
4101 ;; Remove unwanted headers.
4102 (when (and (not raw)
4103 (or (get 'gnus-summary-save-in-pipe :headers)
4104 (not gnus-save-all-headers)))
4105 (let ((gnus-visible-headers
4106 (or (symbol-value (get 'gnus-summary-save-in-pipe
4108 gnus-saved-headers gnus-visible-headers))
4109 (gnus-summary-buffer nil))
4110 (article-hide-headers 1 t))))
4111 (error "%d is not a real article" article))
4112 (error "No article to pipe"))
4113 (setq default (or gnus-summary-pipe-output-default-command
4114 gnus-last-shell-command))
4115 (unless (stringp command)
4117 (if (and (eq command 'default) default)
4119 (gnus-read-shell-command "Shell command on this article: "
4121 (when (string-equal command "")
4123 (setq command default)
4124 (error "A command is required")))
4125 (with-current-buffer save-buffer
4128 (shell-command-on-region (point-min) (point-max) command nil)))
4129 (gnus-kill-buffer save-buffer))
4130 (setq gnus-summary-pipe-output-default-command command))
4132 (defun gnus-summary-pipe-to-muttprint (&optional command)
4133 "Pipe this article to muttprint."
4134 (unless (stringp command)
4135 (setq command (read-string
4136 "Print using command: " gnus-summary-muttprint-program
4137 nil gnus-summary-muttprint-program)))
4138 (let ((gnus-summary-pipe-output-default-command
4139 gnus-summary-pipe-output-default-command))
4140 (gnus-summary-save-in-pipe command))
4141 (setq gnus-summary-muttprint-program command))
4143 ;;; Article file names when saving.
4145 (defun gnus-capitalize-newsgroup (newsgroup)
4146 "Capitalize NEWSGROUP name."
4147 (when (not (zerop (length newsgroup)))
4148 (concat (char-to-string (upcase (aref newsgroup 0)))
4149 (substring newsgroup 1))))
4151 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4152 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4153 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4154 Otherwise, it is like ~/News/news/group/num."
4157 (concat (if (gnus-use-long-file-name 'not-save)
4158 (gnus-capitalize-newsgroup newsgroup)
4159 (gnus-newsgroup-directory-form newsgroup))
4160 "/" (int-to-string (mail-header-number headers)))
4161 gnus-article-save-directory)))
4163 (string-equal (file-name-directory default)
4164 (file-name-directory last-file))
4165 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4167 (or last-file default))))
4169 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4170 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4171 If variable `gnus-use-long-file-name' is non-nil, it is
4172 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4175 (concat (if (gnus-use-long-file-name 'not-save)
4177 (gnus-newsgroup-directory-form newsgroup))
4178 "/" (int-to-string (mail-header-number headers)))
4179 gnus-article-save-directory)))
4181 (string-equal (file-name-directory default)
4182 (file-name-directory last-file))
4183 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4185 (or last-file default))))
4187 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4188 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4189 If variable `gnus-use-long-file-name' is non-nil, it is
4190 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4193 (if (gnus-use-long-file-name 'not-save)
4196 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4198 gnus-article-save-directory)))
4200 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4201 "Generate file name from sender."
4202 (let ((from (mail-header-from headers)))
4204 (if (and from (string-match "\\([^ <]+\\)@" from))
4205 (match-string 1 from)
4207 gnus-article-save-directory)))
4209 (defun article-verify-x-pgp-sig ()
4211 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4213 (if (gnus-buffer-live-p gnus-original-article-buffer)
4214 (let ((sig (with-current-buffer gnus-original-article-buffer
4215 (gnus-fetch-field "X-PGP-Sig")))
4219 (mml2015-clear-verify-function))
4221 (insert-buffer-substring gnus-original-article-buffer)
4222 (setq items (split-string sig))
4223 (message-narrow-to-head)
4224 (let ((inhibit-point-motion-hooks t)
4225 (case-fold-search t))
4226 ;; Don't verify multiple headers.
4227 (setq headers (mapconcat (lambda (header)
4229 (mail-fetch-field header)
4231 (split-string (nth 1 items) ",") "")))
4232 (delete-region (point-min) (point-max))
4233 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4234 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4239 (if (looking-at "^-")
4242 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4243 (insert "Version: " (car items) "\n\n")
4244 (insert (mapconcat 'identity (cddr items) "\n"))
4245 (insert "\n-----END PGP SIGNATURE-----\n")
4246 (let ((mm-security-handle (list (format "multipart/signed"))))
4247 (mml2015-clean-buffer)
4248 (let ((coding-system-for-write (or gnus-newsgroup-charset
4250 (funcall (mml2015-clear-verify-function)))
4252 (or (mm-handle-multipart-ctl-parameter
4253 mm-security-handle 'gnus-details)
4254 (mm-handle-multipart-ctl-parameter
4255 mm-security-handle 'gnus-info)))))
4257 (let ((inhibit-read-only t) bface eface)
4259 (message-narrow-to-head)
4260 (goto-char (point-max))
4262 (setq bface (get-text-property (point-at-bol) 'face)
4263 eface (get-text-property (1- (point-at-eol)) 'face))
4264 (message-remove-header "X-Gnus-PGP-Verify")
4265 (if (re-search-forward "^X-PGP-Sig:" nil t)
4267 (goto-char (point-max)))
4268 (narrow-to-region (point) (point))
4269 (insert "X-Gnus-PGP-Verify: " info "\n")
4270 (goto-char (point-min))
4273 (if (not (looking-at "^[ \t]"))
4277 (goto-char (point-min))
4278 (when (looking-at "\\([^:]+\\): *")
4279 (put-text-property (match-beginning 1) (1+ (match-end 1))
4281 (put-text-property (match-end 0) (point-max)
4282 'face eface)))))))))
4284 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4286 (defun article-verify-cancel-lock ()
4287 "Verify Cancel-Lock header."
4289 (if (gnus-buffer-live-p gnus-original-article-buffer)
4290 (canlock-verify gnus-original-article-buffer)))
4297 (setq afunc (car func)
4300 gfunc (intern (format "gnus-%s" func))))
4302 (when (fboundp afunc)
4303 `(lambda (&optional interactive &rest args)
4304 ,(documentation afunc t)
4305 (interactive (list t))
4306 (with-current-buffer gnus-article-buffer
4308 (call-interactively ',afunc)
4309 (apply ',afunc args))))))))
4310 '(article-hide-headers
4311 article-verify-x-pgp-sig
4312 article-verify-cancel-lock
4313 article-hide-boring-headers
4314 article-treat-overstrike
4315 article-treat-ansi-sequences
4316 article-fill-long-lines
4317 article-capitalize-sentences
4319 article-remove-leading-whitespace
4320 article-display-x-face
4321 article-display-face
4322 article-de-quoted-unreadable
4323 article-de-base64-unreadable
4326 article-unsplit-urls
4327 article-hide-list-identifiers
4328 article-strip-banner
4331 article-hide-signature
4332 article-strip-headers-in-body
4333 article-remove-trailing-blank-lines
4334 article-strip-leading-blank-lines
4335 article-strip-multiple-blank-lines
4336 article-strip-leading-space
4337 article-strip-trailing-space
4338 article-strip-blank-lines
4339 article-strip-all-blank-lines
4341 article-date-english
4342 article-date-iso8601
4343 article-date-original
4345 article-decode-mime-words
4346 article-decode-charset
4347 article-decode-encoded-words
4350 article-date-combined-lapsed
4352 article-treat-dumbquotes
4353 article-treat-non-ascii
4354 article-normalize-headers
4355 ;;(article-show-all . gnus-article-show-all-headers)
4359 ;;; Gnus article mode
4362 (put 'gnus-article-mode 'mode-class 'special)
4364 (set-keymap-parent gnus-article-mode-map widget-keymap)
4366 (gnus-define-keys gnus-article-mode-map
4367 " " gnus-article-goto-next-page
4368 "\177" gnus-article-goto-prev-page
4369 [delete] gnus-article-goto-prev-page
4370 [backspace] gnus-article-goto-prev-page
4371 "\C-c^" gnus-article-refer-article
4372 "h" gnus-article-show-summary
4373 "s" gnus-article-show-summary
4374 "\C-c\C-m" gnus-article-mail
4375 "?" gnus-article-describe-briefly
4376 "<" beginning-of-buffer
4378 "\C-c\C-i" gnus-info-find-node
4380 "R" gnus-article-reply-with-original
4381 "F" gnus-article-followup-with-original
4382 "\C-hk" gnus-article-describe-key
4383 "\C-hc" gnus-article-describe-key-briefly
4384 "\C-hb" gnus-article-describe-bindings
4386 "e" gnus-article-read-summary-keys
4387 "\C-d" gnus-article-read-summary-keys
4388 "\M-*" gnus-article-read-summary-keys
4389 "\M-#" gnus-article-read-summary-keys
4390 "\M-^" gnus-article-read-summary-keys
4391 "\M-g" gnus-article-read-summary-keys)
4393 (substitute-key-definition
4394 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4396 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4397 "W" gnus-article-wide-reply-with-original)
4398 (if (featurep 'xemacs)
4399 (set-keymap-default-binding gnus-article-send-map
4400 'gnus-article-read-summary-send-keys)
4401 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4403 (defun gnus-article-make-menu-bar ()
4404 (unless (boundp 'gnus-article-commands-menu)
4405 (gnus-summary-make-menu-bar))
4406 (unless (boundp 'gnus-article-article-menu)
4408 gnus-article-article-menu gnus-article-mode-map ""
4410 ["Scroll forwards" gnus-article-goto-next-page t]
4411 ["Scroll backwards" gnus-article-goto-prev-page t]
4412 ["Show summary" gnus-article-show-summary t]
4413 ["Fetch Message-ID at point" gnus-article-refer-article t]
4414 ["Mail to address at point" gnus-article-mail t]
4415 ["Send a bug report" gnus-bug t]))
4418 gnus-article-treatment-menu gnus-article-mode-map ""
4419 ;; Fixme: this should use :active (and maybe :visible).
4421 ["Hide headers" gnus-article-hide-headers t]
4422 ["Hide signature" gnus-article-hide-signature t]
4423 ["Hide citation" gnus-article-hide-citation t]
4424 ["Treat overstrike" gnus-article-treat-overstrike t]
4425 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4426 ["Remove carriage return" gnus-article-remove-cr t]
4427 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4428 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4429 ["Remove base64" gnus-article-de-base64-unreadable t]
4430 ["Treat html" gnus-article-wash-html t]
4431 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4432 ["Decode HZ" gnus-article-decode-HZ t]))
4434 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4436 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4438 (gnus-run-hooks 'gnus-article-menu-hook)))
4440 (defvar bookmark-make-record-function)
4442 (defun gnus-article-mode ()
4443 "Major mode for displaying an article.
4445 All normal editing commands are switched off.
4447 The following commands are available in addition to all summary mode
4449 \\<gnus-article-mode-map>
4450 \\[gnus-article-next-page]\t Scroll the article one page forwards
4451 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4452 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4453 \\[gnus-article-show-summary]\t Display the summary buffer
4454 \\[gnus-article-mail]\t Send a reply to the address near point
4455 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4456 \\[gnus-info-find-node]\t Go to the Gnus info node"
4458 (kill-all-local-variables)
4459 (gnus-simplify-mode-line)
4460 (setq mode-name "Article")
4461 (setq major-mode 'gnus-article-mode)
4462 (make-local-variable 'minor-mode-alist)
4463 (use-local-map gnus-article-mode-map)
4464 (when (gnus-visual-p 'article-menu 'menu)
4465 (gnus-article-make-menu-bar)
4466 (when gnus-summary-tool-bar-map
4467 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4468 (gnus-update-format-specifications nil 'article-mode)
4469 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4470 (set (make-local-variable 'gnus-page-broken) nil)
4471 (make-local-variable 'gnus-article-current-summary)
4472 (make-local-variable 'gnus-article-mime-handles)
4473 (make-local-variable 'gnus-article-decoded-p)
4474 (make-local-variable 'gnus-article-mime-handle-alist)
4475 (make-local-variable 'gnus-article-wash-types)
4476 (make-local-variable 'gnus-article-image-alist)
4477 (make-local-variable 'gnus-article-charset)
4478 (make-local-variable 'gnus-article-ignored-charsets)
4479 (set (make-local-variable 'bookmark-make-record-function)
4480 'gnus-summary-bookmark-make-record)
4481 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4483 (set (make-local-variable 'nobreak-char-display) nil)
4484 (setq cursor-in-non-selected-windows nil)
4485 (gnus-set-default-directory)
4486 (buffer-disable-undo)
4487 (setq buffer-read-only t
4488 show-trailing-whitespace nil)
4489 (set-syntax-table gnus-article-mode-syntax-table)
4490 (mm-enable-multibyte)
4491 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4493 (defun gnus-article-setup-buffer ()
4494 "Initialize the article buffer."
4495 (let* ((name (if gnus-single-article-buffer "*Article*"
4496 (concat "*Article " gnus-newsgroup-name "*")))
4498 (progn (string-match "\\*Article" name)
4499 (concat " *Original Article"
4500 (substring name (match-end 0))))))
4501 (setq gnus-article-buffer name)
4502 (setq gnus-original-article-buffer original)
4503 (setq gnus-article-mime-handle-alist nil)
4504 (with-current-buffer gnus-summary-buffer
4505 ;; This might be a variable local to the summary buffer.
4506 (unless gnus-single-article-buffer
4507 (setq gnus-article-buffer name)
4508 (setq gnus-original-article-buffer original)
4509 (gnus-set-global-variables)))
4510 (gnus-article-setup-highlight-words)
4511 ;; Init original article buffer.
4512 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4513 (mm-enable-multibyte)
4514 (setq major-mode 'gnus-original-article-mode)
4515 (make-local-variable 'gnus-original-article))
4516 (if (and (get-buffer name)
4517 (with-current-buffer name
4518 (if gnus-article-edit-mode
4519 (if (y-or-n-p "Article mode edit in progress; discard? ")
4521 (set-buffer-modified-p nil)
4522 (gnus-kill-buffer name)
4525 (error "Action aborted"))
4527 (with-current-buffer name
4528 (set (make-local-variable 'gnus-article-edit-mode) nil)
4529 (when gnus-article-mime-handles
4530 (mm-destroy-parts gnus-article-mime-handles)
4531 (setq gnus-article-mime-handles nil))
4532 ;; Set it to nil in article-buffer!
4533 (setq gnus-article-mime-handle-alist nil)
4534 (buffer-disable-undo)
4535 (setq buffer-read-only t)
4536 (unless (eq major-mode 'gnus-article-mode)
4537 (gnus-article-mode))
4538 (setq truncate-lines gnus-article-truncate-lines)
4540 (with-current-buffer (gnus-get-buffer-create name)
4542 (setq truncate-lines gnus-article-truncate-lines)
4543 (make-local-variable 'gnus-summary-buffer)
4544 (setq gnus-summary-buffer
4545 (gnus-summary-buffer-name gnus-newsgroup-name))
4546 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4547 (when (and gnus-article-update-lapsed-header
4548 (not article-lapsed-timer))
4549 (gnus-start-date-timer gnus-article-update-lapsed-header))
4550 (current-buffer)))))
4552 ;; Set article window start at LINE, where LINE is the number of lines
4553 ;; from the head of the article.
4554 (defun gnus-article-set-window-start (&optional line)
4555 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4556 (when article-window
4559 (with-current-buffer gnus-article-buffer
4560 (goto-char (point-min))
4563 (gnus-message 6 "Moved to bookmark")
4564 (search-forward "\n\n" nil t)
4568 (defun gnus-article-prepare (article &optional all-headers header)
4569 "Prepare ARTICLE in article mode buffer.
4570 ARTICLE should either be an article number or a Message-ID.
4571 If ARTICLE is an id, HEADER should be the article headers.
4572 If ALL-HEADERS is non-nil, no headers are hidden."
4574 ;; Make sure we start in a summary buffer.
4575 (unless (eq major-mode 'gnus-summary-mode)
4576 (set-buffer gnus-summary-buffer))
4577 (setq gnus-summary-buffer (current-buffer))
4578 (let* ((gnus-article (if header (mail-header-number header) article))
4579 (summary-buffer (current-buffer))
4580 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4581 (group gnus-newsgroup-name)
4584 (gnus-article-setup-buffer)
4585 (set-buffer gnus-article-buffer)
4586 ;; Deactivate active regions.
4587 (when (and (boundp 'transient-mark-mode)
4588 transient-mark-mode)
4589 (setq mark-active nil))
4590 (if (not (setq result (let ((inhibit-read-only t))
4591 (gnus-request-article-this-buffer
4593 ;; There is no such article.
4595 (when (and (numberp article)
4596 (not (memq article gnus-newsgroup-sparse)))
4597 (setq gnus-article-current
4598 (cons gnus-newsgroup-name article))
4599 (set-buffer gnus-summary-buffer)
4600 (setq gnus-current-article article)
4601 (if (and (memq article gnus-newsgroup-undownloaded)
4602 (not (gnus-online (gnus-find-method-for-group
4603 gnus-newsgroup-name))))
4605 (gnus-summary-set-agent-mark article)
4606 (message "Message marked for downloading"))
4607 (gnus-summary-mark-article article gnus-canceled-mark)
4608 (unless (memq article gnus-newsgroup-sparse)
4609 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4610 (if (or (eq result 'pseudo)
4611 (eq result 'nneething))
4613 (with-current-buffer summary-buffer
4614 (push article gnus-newsgroup-history)
4615 (setq gnus-last-article gnus-current-article
4616 gnus-current-article 0
4617 gnus-current-headers nil
4618 gnus-article-current nil)
4619 (if (eq result 'nneething)
4620 (gnus-configure-windows 'summary)
4621 (gnus-configure-windows 'article))
4622 (gnus-set-global-variables))
4623 (let ((gnus-article-mime-handle-alist-1
4624 gnus-article-mime-handle-alist))
4625 (gnus-set-mode-line 'article)))
4626 ;; The result from the `request' was an actual article -
4627 ;; or at least some text that is now displayed in the
4629 (when (and (numberp article)
4630 (not (eq article gnus-current-article)))
4631 ;; Seems like a new article has been selected.
4632 ;; `gnus-current-article' must be an article number.
4633 (with-current-buffer summary-buffer
4634 (push article gnus-newsgroup-history)
4635 (setq gnus-last-article gnus-current-article
4636 gnus-current-article article
4637 gnus-current-headers
4638 (gnus-summary-article-header gnus-current-article)
4639 gnus-article-current
4640 (cons gnus-newsgroup-name gnus-current-article))
4641 (unless (vectorp gnus-current-headers)
4642 (setq gnus-current-headers nil))
4643 (gnus-summary-goto-subject gnus-current-article)
4644 (when (gnus-summary-show-thread)
4645 ;; If the summary buffer really was folded, the
4646 ;; previous goto may not actually have gone to
4647 ;; the right article, but the thread root instead.
4649 (gnus-summary-goto-subject gnus-current-article))
4650 (gnus-run-hooks 'gnus-mark-article-hook)
4651 (gnus-set-mode-line 'summary)
4652 (when (gnus-visual-p 'article-highlight 'highlight)
4653 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4654 ;; Set the global newsgroup variables here.
4655 (gnus-set-global-variables)
4656 (setq gnus-have-all-headers
4657 (or all-headers gnus-show-all-headers))))
4659 (gnus-configure-windows 'article))
4660 (when (or (numberp article)
4662 (gnus-article-prepare-display)
4664 (goto-char (point-min))
4665 (when gnus-break-pages
4666 (gnus-narrow-to-page)))
4667 (let ((gnus-article-mime-handle-alist-1
4668 gnus-article-mime-handle-alist))
4669 (gnus-set-mode-line 'article))
4673 (set-window-point (get-buffer-window (current-buffer)) (point))
4674 (gnus-configure-windows 'article)
4678 (defun gnus-article-prepare-display ()
4679 "Make the current buffer look like a nice article."
4680 ;; Hooks for getting information from the article.
4681 ;; This hook must be called before being narrowed.
4682 (let ((gnus-article-buffer (current-buffer))
4684 (inhibit-read-only t))
4685 (unless (eq major-mode 'gnus-article-mode)
4686 (gnus-article-mode))
4687 (setq buffer-read-only nil
4688 gnus-article-wash-types nil
4689 gnus-article-image-alist nil)
4690 (gnus-run-hooks 'gnus-tmp-internal-hook)
4691 (when gnus-display-mime-function
4692 (funcall gnus-display-mime-function))
4693 (gnus-run-hooks 'gnus-article-prepare-hook)))
4696 ;;; Gnus Sticky Article Mode
4699 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4700 "Mode for sticky articles."
4701 ;; Release bindings that won't work.
4702 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4703 gnus-sticky-article-mode-map)
4704 (substitute-key-definition 'gnus-article-refer-article 'undefined
4705 gnus-sticky-article-mode-map)
4706 (dolist (k '("e" "h" "s" "F" "R"))
4707 (define-key gnus-sticky-article-mode-map k nil))
4708 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4709 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4710 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4711 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4713 (defun gnus-sticky-article (arg)
4714 "Make the current article sticky.
4715 If a prefix ARG is given, ask for a name for this sticky article buffer."
4717 (gnus-summary-show-thread)
4718 (gnus-summary-select-article nil nil 'pseudo)
4719 (let (new-art-buf-name)
4720 (gnus-eval-in-buffer-window gnus-article-buffer
4721 (setq new-art-buf-name
4725 (read-from-minibuffer "Sticky article buffer name: ")
4726 (gnus-with-article-headers
4727 (gnus-article-goto-header "subject")
4728 (setq new-art-buf-name
4729 (buffer-substring-no-properties
4730 (line-beginning-position) (line-end-position)))
4731 (goto-char (point-min))
4732 (gnus-article-goto-header "from")
4733 (setq new-art-buf-name
4735 new-art-buf-name ", "
4736 (buffer-substring-no-properties
4737 (line-beginning-position) (line-end-position))))
4738 (goto-char (point-min))
4739 (gnus-article-goto-header "date")
4740 (setq new-art-buf-name
4742 new-art-buf-name ", "
4743 (buffer-substring-no-properties
4744 (line-beginning-position) (line-end-position))))))
4746 (if (and (gnus-buffer-live-p new-art-buf-name)
4747 (with-current-buffer new-art-buf-name
4748 (eq major-mode 'gnus-sticky-article-mode)))
4749 (switch-to-buffer new-art-buf-name)
4750 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4751 (gnus-sticky-article-mode))
4752 (setq gnus-article-buffer new-art-buf-name))
4753 (gnus-summary-recenter)
4754 (gnus-summary-position-point))
4756 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4757 "Kill the given sticky article BUFFER.
4758 If none is given, assume the current buffer and kill it if it has
4759 `gnus-sticky-article-mode'."
4762 (setq buffer (current-buffer)))
4763 (with-current-buffer buffer
4764 (when (eq major-mode 'gnus-sticky-article-mode)
4765 (gnus-kill-buffer buffer))))
4767 (defun gnus-kill-sticky-article-buffers (arg)
4768 "Kill all sticky article buffers.
4769 If a prefix ARG is given, ask for confirmation."
4771 (dolist (buf (gnus-buffers))
4772 (with-current-buffer buf
4773 (when (eq major-mode 'gnus-sticky-article-mode)
4775 (gnus-kill-buffer buf)
4776 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4777 (gnus-kill-buffer buf)))))))
4780 ;;; Gnus MIME viewing functions
4783 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4784 "Format of the MIME buttons.
4786 Valid specifiers include:
4788 %T MIME type, along with additional info
4789 %n The `name' parameter
4790 %d The description, if any
4791 %l The length of the encoded part
4792 %p The part identifier number
4793 %e Dots if the part isn't displayed
4795 General format specifiers can also be used. See Info node
4796 `(gnus)Formatting Variables'.")
4798 (defvar gnus-mime-button-line-format-alist
4799 '((?t gnus-tmp-type ?s)
4800 (?T gnus-tmp-type-long ?s)
4801 (?n gnus-tmp-name ?s)
4802 (?d gnus-tmp-description ?s)
4804 (?l gnus-tmp-length ?d)
4805 (?e gnus-tmp-dots ?s)))
4807 (defvar gnus-mime-button-commands
4808 '((gnus-article-press-button "\r" "Toggle Display")
4809 (gnus-mime-view-part "v" "View Interactively...")
4810 (gnus-mime-view-part-as-type "t" "View As Type...")
4811 (gnus-mime-view-part-as-charset "C" "View As charset...")
4812 (gnus-mime-save-part "o" "Save...")
4813 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4814 (gnus-mime-replace-part "r" "Replace part")
4815 (gnus-mime-delete-part "d" "Delete part")
4816 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4817 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4818 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4819 (gnus-mime-view-part-externally "e" "View Externally")
4820 (gnus-mime-print-part "p" "Print")
4821 (gnus-mime-pipe-part "|" "Pipe To Command...")
4822 (gnus-mime-action-on-part "." "Take action on the part...")))
4824 (defun gnus-article-mime-part-status ()
4825 (if gnus-article-mime-handle-alist-1
4826 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4828 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4831 (defvar gnus-mime-button-map
4832 (let ((map (make-sparse-keymap)))
4833 (define-key map gnus-mouse-2 'gnus-article-push-button)
4834 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4835 (dolist (c gnus-mime-button-commands)
4836 (define-key map (cadr c) (car c)))
4840 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4842 ,@(mapcar (lambda (c)
4843 (vector (caddr c) (car c) :active t))
4844 gnus-mime-button-commands)))
4846 (defvar gnus-url-button-commands
4847 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4849 (defvar gnus-url-button-map
4850 (let ((map (make-sparse-keymap)))
4851 (dolist (c gnus-url-button-commands)
4852 (define-key map (cadr c) (car c)))
4856 gnus-url-button-menu gnus-url-button-map "URL button menu."
4858 ,@(mapcar (lambda (c)
4859 (vector (caddr c) (car c) :active t))
4860 gnus-url-button-commands)))
4862 (defmacro gnus-bind-safe-url-regexp (&rest body)
4863 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4864 `(let ((mm-w3m-safe-url-regexp
4865 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4867 gnus-article-current-summary))
4868 (with-current-buffer gnus-article-current-summary
4869 gnus-newsgroup-name)
4870 gnus-newsgroup-name)))
4871 (if (cond ((not group)
4872 ;; Maybe we're in a mml-preview buffer
4873 ;; and no group is selected.
4875 ((stringp gnus-safe-html-newsgroups)
4876 (string-match gnus-safe-html-newsgroups group))
4877 ((consp gnus-safe-html-newsgroups)
4878 (member group gnus-safe-html-newsgroups)))
4880 mm-w3m-safe-url-regexp))))
4883 (defun gnus-mime-button-menu (event prefix)
4884 "Construct a context-sensitive menu of MIME commands."
4885 (interactive "e\nP")
4886 (save-window-excursion
4887 (let ((pos (event-start event)))
4888 (select-window (posn-window pos))
4889 (goto-char (posn-point pos))
4890 (gnus-article-check-buffer)
4891 (popup-menu gnus-mime-button-menu nil prefix))))
4893 (defun gnus-mime-view-all-parts (&optional handles)
4894 "View all the MIME parts."
4896 (with-current-buffer gnus-article-buffer
4897 (let ((handles (or handles gnus-article-mime-handles))
4898 (mail-parse-charset gnus-newsgroup-charset)
4899 (mail-parse-ignored-charsets
4900 (with-current-buffer gnus-summary-buffer
4901 gnus-newsgroup-ignored-charsets)))
4903 (mm-remove-parts handles)
4904 (goto-char (point-min))
4905 (or (search-forward "\n\n") (goto-char (point-max)))
4906 (let ((inhibit-read-only t))
4907 (delete-region (point) (point-max))
4908 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4910 (defun gnus-article-jump-to-part (n)
4911 "Jump to MIME part N."
4913 (let ((parts (with-current-buffer gnus-article-buffer
4914 (length gnus-article-mime-handle-alist))))
4916 (error "No such part"))
4917 (pop-to-buffer gnus-article-buffer)
4918 ;; FIXME: why is it necessary?
4921 (setq n (if (= parts 1)
4923 (read-number (format "Jump to part (1..%s): " parts)))))
4924 (unless (and (integerp n) (<= n parts) (>= n 1))
4927 (gnus-message 7 "Invalid part `%s', using %s instead."
4930 (gnus-message 9 "Jumping to part %s." n)
4931 (cond ((>= gnus-auto-select-part 1)
4932 (while (and (<= n parts)
4933 (not (gnus-article-goto-part n)))
4935 ((< gnus-auto-select-part 0)
4936 (while (and (>= n 1)
4937 (not (gnus-article-goto-part n)))
4940 (gnus-article-goto-part n)))))
4942 (defvar gnus-mime-buttonized-part-id nil
4943 "ID of a mime part that should be buttonized.
4944 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4947 (defsubst gnus-article-edit-part (handles &optional current-id)
4948 "Edit an article in order to delete a mime part.
4949 This function is exclusively used by `gnus-mime-save-part-and-strip'
4950 and `gnus-mime-delete-part', and not provided at run-time normally."
4951 (gnus-article-edit-article
4953 (buffer-disable-undo)
4955 (let ((mail-parse-charset (or gnus-article-charset
4956 ',gnus-newsgroup-charset))
4957 (mail-parse-ignored-charsets
4958 (or gnus-article-ignored-charsets
4959 ',gnus-newsgroup-ignored-charsets))
4960 (mbl mml-buffer-list))
4961 (setq mml-buffer-list nil)
4962 (insert-buffer-substring gnus-original-article-buffer)
4963 (mime-to-mml ',handles)
4964 (setq gnus-article-mime-handles nil)
4965 (let ((mbl1 mml-buffer-list))
4966 (setq mml-buffer-list mbl)
4967 (set (make-local-variable 'mml-buffer-list) mbl1))
4968 (gnus-make-local-hook 'kill-buffer-hook)
4969 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4970 `(lambda (no-highlight)
4971 (let ((mail-parse-charset (or gnus-article-charset
4972 ',gnus-newsgroup-charset))
4973 (message-options message-options)
4974 (message-options-set-recipient)
4975 (mail-parse-ignored-charsets
4976 (or gnus-article-ignored-charsets
4977 ',gnus-newsgroup-ignored-charsets)))
4979 (mml-destroy-buffers)
4980 (remove-hook 'kill-buffer-hook
4981 'mml-destroy-buffers t)
4982 (kill-local-variable 'mml-buffer-list))
4983 (gnus-summary-edit-article-done
4984 ,(or (mail-header-references gnus-current-headers) "")
4985 ,(gnus-group-read-only-p)
4986 ,gnus-summary-buffer no-highlight))
4988 ;; Force buttonizing this part.
4989 (let ((gnus-mime-buttonized-part-id current-id))
4990 (gnus-article-edit-done))
4991 (gnus-configure-windows 'article)
4992 (when (and current-id (integerp gnus-auto-select-part))
4993 (gnus-article-jump-to-part
4994 (min (max (+ current-id gnus-auto-select-part) 1)
4995 (with-current-buffer gnus-article-buffer
4996 (length gnus-article-mime-handle-alist)))))))
4998 (defun gnus-mime-replace-part (file)
4999 "Replace MIME part under point with an external body."
5000 ;; Useful if file has already been saved to disk
5003 (read-file-name "Replace MIME part with file: "
5004 (or mm-default-directory default-directory)
5006 (gnus-mime-save-part-and-strip file))
5008 (defun gnus-mime-save-part-and-strip (&optional file)
5009 "Save the MIME part under point then replace it with an external body.
5010 If FILE is given, use it for the external part."
5012 (gnus-article-check-buffer)
5013 (when (gnus-group-read-only-p)
5014 (error "The current group does not support deleting of parts"))
5015 (when (mm-complicated-handles gnus-article-mime-handles)
5017 The current article has a complicated MIME structure, giving up..."))
5018 (let* ((data (get-text-property (point) 'gnus-data))
5019 (id (get-text-property (point) 'gnus-part))
5021 (handles gnus-article-mime-handles))
5024 (and data (mm-save-part data "Delete MIME part and save to: "))))
5026 (with-current-buffer (mm-handle-buffer data)
5028 (insert "Content-Type: " (mm-handle-media-type data))
5029 (mml-insert-parameter-string (cdr (mm-handle-type data))
5031 ;; Add a filename for the sake of saving the part again.
5032 (mml-insert-parameter
5033 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5035 (insert "Content-ID: " (message-make-message-id) "\n")
5036 (insert "Content-Transfer-Encoding: binary\n")
5039 (cdr (mm-make-handle nil
5040 `("message/external-body"
5041 (access-type . "LOCAL-FILE")
5043 ;; (set-buffer gnus-summary-buffer)
5044 (gnus-article-edit-part handles id))))
5046 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5047 ;; parts...>') but with stripping would be nice.
5049 (defun gnus-mime-delete-part ()
5050 "Delete the MIME part under point.
5051 Replace it with some information about the removed part."
5053 (gnus-article-check-buffer)
5054 (when (gnus-group-read-only-p)
5055 (error "The current group does not support deleting of parts"))
5056 (when (mm-complicated-handles gnus-article-mime-handles)
5058 The current article has a complicated MIME structure, giving up..."))
5059 (when (or gnus-expert-user
5060 (gnus-yes-or-no-p "\
5061 Deleting parts may malfunction or destroy the article; continue? "))
5062 (let* ((data (get-text-property (point) 'gnus-data))
5063 (id (get-text-property (point) 'gnus-part))
5064 (handles gnus-article-mime-handles)
5067 (let ((desc (mm-handle-description data)))
5069 (mail-decode-encoded-word-string desc))))
5071 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
5073 (type (mm-handle-media-type data)))
5075 (error "No MIME part under point"))
5076 (with-current-buffer (mm-handle-buffer data)
5077 (let ((bsize (buffer-size)))
5082 "| The following attachment has been deleted:\n"
5084 "| Type: " type "\n"
5085 "| Filename: " filename "\n"
5086 "| Size (encoded): " (format "%s byte%s\n"
5087 bsize (if (= bsize 1)
5091 (concat "| Description: " description "\n"))
5094 (cdr (mm-make-handle
5095 nil `("text/plain" (charset . gnus-decoded)) nil nil
5097 (format "Deleted attachment (%s bytes)" bsize))))))
5098 ;; (set-buffer gnus-summary-buffer)
5099 (gnus-article-edit-part handles id))))
5101 (defun gnus-mime-save-part ()
5102 "Save the MIME part under point."
5104 (gnus-article-check-buffer)
5105 (let ((data (get-text-property (point) 'gnus-data)))
5107 (mm-save-part data))))
5109 (defun gnus-mime-pipe-part (&optional cmd)
5110 "Pipe the MIME part under point to a process.
5111 Use CMD as the process."
5113 (gnus-article-check-buffer)
5114 (let ((data (get-text-property (point) 'gnus-data)))
5116 (mm-pipe-part data cmd))))
5118 (defun gnus-mime-view-part ()
5119 "Interactively choose a viewing method for the MIME part under point."
5121 (gnus-article-check-buffer)
5122 (let ((data (get-text-property (point) 'gnus-data)))
5124 (setq gnus-article-mime-handles
5126 gnus-article-mime-handles (setq data (copy-sequence data))))
5127 (mm-interactively-view-part data))))
5129 (defun gnus-mime-view-part-as-type-internal ()
5130 (gnus-article-check-buffer)
5131 (let* ((handle (get-text-property (point) 'gnus-data))
5133 ;; Content-Type: foo/bar; name=...
5134 (mail-content-type-get (mm-handle-type handle) 'name)
5135 ;; Content-Disposition: attachment; filename=...
5136 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5137 (def-type (and name (mm-default-file-encoding name))))
5138 (or (and def-type (cons def-type 0))
5140 (equal (mm-handle-media-supertype handle) "text")
5141 '("text/plain" . 0))
5142 '("application/octet-stream" . 0))))
5144 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5145 "Choose a MIME media type, and view the part as such.
5146 If non-nil, PRED is a predicate to use during completion to limit the
5147 available media-types."
5151 (let ((default (gnus-mime-view-part-as-type-internal)))
5152 (gnus-completing-read
5155 (gnus-remove-if-not pred (mailcap-mime-types))
5156 (mailcap-mime-types))
5159 (gnus-article-check-buffer)
5160 (let ((handle (get-text-property (point) 'gnus-data)))
5162 (when (equal (mm-handle-media-type handle) "message/external-body")
5163 (unless (mm-handle-cache handle)
5164 (mm-extern-cache-contents handle))
5165 (setq handle (mm-handle-cache handle)))
5167 (mm-make-handle (mm-handle-buffer handle)
5168 (cons mime-type (cdr (mm-handle-type handle)))
5169 (mm-handle-encoding handle)
5170 (mm-handle-undisplayer handle)
5171 (mm-handle-disposition handle)
5172 (mm-handle-description handle)
5174 (mm-handle-id handle)))
5175 (setq gnus-article-mime-handles
5176 (mm-merge-handles gnus-article-mime-handles handle))
5177 (when (mm-handle-displayed-p handle)
5178 (mm-remove-part handle))
5179 (gnus-mm-display-part handle))))
5181 (defun gnus-mime-copy-part (&optional handle arg)
5182 "Put the MIME part under point into a new buffer.
5183 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5185 (interactive (list nil current-prefix-arg))
5186 (gnus-article-check-buffer)
5188 (setq handle (get-text-property (point) 'gnus-data)))
5190 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
5192 (mail-content-type-get (mm-handle-disposition handle)
5194 contents dont-decode charset coding-system)
5195 (mm-with-unibyte-buffer
5196 (mm-insert-part handle)
5197 (setq contents (or (condition-case nil
5198 (mm-decompress-buffer filename nil 'sig)
5200 (setq dont-decode t)
5203 (setq filename (cond (filename (file-name-nondirectory filename))
5204 (dont-decode "*raw data*")
5209 (unless (setq charset (mail-content-type-get
5210 (mm-handle-type handle) 'charset))
5211 (unless (setq coding-system (mm-with-unibyte-buffer
5213 (mm-find-buffer-file-coding-system)))
5214 (setq charset gnus-newsgroup-charset))))
5216 (setq charset (or (cdr (assq arg
5217 gnus-summary-show-article-charset-alist))
5218 (mm-read-coding-system "Charset: ")))))
5219 (switch-to-buffer (generate-new-buffer filename))
5220 (if (or coding-system
5222 (setq coding-system (mm-charset-to-coding-system charset))
5223 (not (eq coding-system 'ascii))))
5225 (mm-enable-multibyte)
5226 (insert (mm-decode-coding-string contents coding-system))
5227 (setq buffer-file-coding-system
5228 (if (boundp 'last-coding-system-used)
5229 (symbol-value 'last-coding-system-used)
5231 (mm-disable-multibyte)
5233 (setq buffer-file-coding-system mm-binary-coding-system))
5234 ;; We do it this way to make `normal-mode' set the appropriate mode.
5237 (setq buffer-file-name (expand-file-name filename))
5239 (setq buffer-file-name nil))
5240 (goto-char (point-min)))))
5242 (defun gnus-mime-print-part (&optional handle filename)
5243 "Print the MIME part under point."
5244 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5245 (gnus-article-check-buffer)
5246 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5247 (contents (and handle (mm-get-part handle)))
5248 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5249 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5254 (mm-save-part-to-file handle file)
5255 (call-process shell-file-name nil
5256 (generate-new-buffer " *mm*")
5258 shell-command-switch
5260 printer file (mm-handle-type handle))))
5264 (gnus-print-buffer))
5265 (ps-despool filename)))))
5267 (defun gnus-mime-inline-part (&optional handle arg)
5268 "Insert the MIME part under point into the current buffer.
5269 Compressed files like .gz and .bz2 are decompressed."
5270 (interactive (list nil current-prefix-arg))
5271 (gnus-article-check-buffer)
5273 (setq handle (get-text-property (point) 'gnus-data)))
5276 (inhibit-read-only t)
5277 contents charset coding-system)
5278 (if (and (not arg) (mm-handle-undisplayer handle))
5279 (mm-remove-part handle)
5280 (mm-with-unibyte-buffer
5281 (mm-insert-part handle)
5283 (or (mm-decompress-buffer
5284 (or (mail-content-type-get (mm-handle-type handle)
5286 (mail-content-type-get (mm-handle-disposition handle)
5292 (unless (setq charset (mail-content-type-get
5293 (mm-handle-type handle) 'charset))
5294 (unless (setq coding-system
5295 (mm-with-unibyte-buffer
5297 (mm-find-buffer-file-coding-system)))
5298 (setq charset gnus-newsgroup-charset))))
5300 (if (mm-handle-undisplayer handle)
5301 (mm-remove-part handle))
5304 gnus-summary-show-article-charset-alist))
5305 (mm-read-coding-system "Charset: "))))
5307 (if (mm-handle-undisplayer handle)
5308 (mm-remove-part handle))))
5310 (mm-display-inline handle)
5313 (defun gnus-mime-set-charset-parameters (handle charset)
5314 "Set CHARSET to parameters in HANDLE.
5315 CHARSET may either be a string or a symbol."
5316 (unless (stringp charset)
5317 (setq charset (symbol-name charset)))
5318 (if (stringp (car handle))
5319 (dolist (h (cdr handle))
5320 (gnus-mime-set-charset-parameters h charset))
5321 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5322 "message/external-body")
5324 (unless (mm-handle-cache handle)
5325 (mm-extern-cache-contents handle))
5326 (mm-handle-cache handle))
5328 (param (assq 'charset (cdr type))))
5330 (setcdr param charset)
5331 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5333 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5334 "Insert the MIME part under point into the current buffer using the
5336 (interactive (list nil current-prefix-arg))
5337 (gnus-article-check-buffer)
5338 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5339 (fun (get-text-property (point) 'gnus-callback))
5340 (gnus-newsgroup-ignored-charsets 'gnus-all)
5341 charset form preferred parts)
5348 gnus-summary-show-article-charset-alist))
5349 (mm-read-coding-system "Charset: "))))
5350 (if (mm-handle-undisplayer handle)
5351 (mm-remove-part handle)))
5352 (gnus-mime-set-charset-parameters handle charset)
5353 (when (and (consp (setq form (cdr-safe fun)))
5354 (setq form (ignore-errors
5355 (assq 'gnus-mime-display-alternative form)))
5356 (setq preferred (caddr form))
5358 (when (eq (car preferred) 'quote)
5359 (setq preferred (cadr preferred)))
5360 (not (equal preferred
5361 (get-text-property (point) 'gnus-data))))
5362 (setq parts (get-text-property (point) 'gnus-part))
5363 (setq parts (cdr (assq parts
5364 gnus-article-mime-handle-alist)))
5365 (equal (mm-handle-media-type parts) "multipart/alternative")
5366 (setq parts (reverse (cdr parts))))
5368 (list 'quote (or (cadr (member preferred parts))
5370 (funcall fun handle)))))
5372 (defun gnus-mime-view-part-externally (&optional handle)
5373 "View the MIME part under point with an external viewer."
5375 (gnus-article-check-buffer)
5376 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5377 (mm-user-display-methods nil)
5378 (mm-inlined-types nil)
5379 (mail-parse-charset gnus-newsgroup-charset)
5380 (mail-parse-ignored-charsets
5381 (with-current-buffer gnus-summary-buffer
5382 gnus-newsgroup-ignored-charsets))
5383 (type (mm-handle-media-type handle))
5384 (method (mailcap-mime-info type))
5385 (mm-enable-external t))
5386 (if (not (stringp method))
5387 (gnus-mime-view-part-as-type
5388 nil (lambda (type) (stringp (mailcap-mime-info type))))
5390 (mm-display-part handle nil t)))))
5392 (defun gnus-mime-view-part-internally (&optional handle)
5393 "View the MIME part under point with an internal viewer.
5394 If no internal viewer is available, use an external viewer."
5396 (gnus-article-check-buffer)
5397 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5398 (mm-inlined-types '(".*"))
5399 (mm-inline-large-images t)
5400 (mail-parse-charset gnus-newsgroup-charset)
5401 (mail-parse-ignored-charsets
5402 (with-current-buffer gnus-summary-buffer
5403 gnus-newsgroup-ignored-charsets))
5404 (inhibit-read-only t))
5405 (if (not (mm-inlinable-p handle))
5406 (gnus-mime-view-part-as-type
5407 nil (lambda (type) (mm-inlinable-p handle type)))
5409 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5411 (defun gnus-mime-action-on-part (&optional action)
5412 "Do something with the MIME attachment at \(point\)."
5414 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5415 (gnus-article-check-buffer)
5416 (let ((action-pair (assoc action gnus-mime-action-alist)))
5418 (funcall (cdr action-pair)))))
5420 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5421 "Call FUNCTION on MIME part N.
5422 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5423 If INTERACTIVE, call FUNCTION interactivly."
5425 ;; Check whether the article is displayed.
5426 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5427 (setq window (get-buffer-window gnus-article-buffer t))
5428 (frame-visible-p (setq frame (window-frame window))))
5429 (error "No article is displayed"))
5430 (with-current-buffer gnus-article-buffer
5431 ;; Check whether the article displays the right contents.
5432 (unless (with-current-buffer gnus-summary-buffer
5433 (eq gnus-current-article (gnus-summary-article-number)))
5434 (error "You should select the right article first"))
5436 (setq n (prefix-numeric-value n))
5438 (setq n (or (get-text-property pt 'gnus-part)
5440 (get-text-property (1- pt) 'gnus-part))
5441 (get-text-property (prog2
5447 (or (and (setq pt (previous-single-property-change
5450 (next-single-property-change (point) 'gnus-part)
5454 ;; Check whether the specified part exists.
5455 (when (> n (length gnus-article-mime-handle-alist))
5456 (error "No such part")))
5459 ;; To select the window is needed so that the cursor
5460 ;; might be visible on the MIME button.
5461 (select-window (prog1
5463 (setq window (selected-window))
5464 ;; Article may be displayed in the other frame.
5465 (gnus-select-frame-set-input-focus
5468 (setq frame (selected-frame))))))
5469 (when (gnus-article-goto-part n)
5470 ;; We point the cursor and the arrow at the MIME button
5471 ;; when the `function' prompt the user for something.
5472 (unless (and (pos-visible-in-window-p)
5473 (> (count-lines (point) (window-end))
5474 (/ (1- (window-height)) 3)))
5475 (recenter (/ (1- (window-height)) 3)))
5476 (let ((cursor-in-non-selected-windows t)
5477 (overlay-arrow-string "=>")
5478 (overlay-arrow-position (point-marker)))
5481 ((and no-handle interactive)
5482 (call-interactively function))
5487 function (get-text-property (point) 'gnus-data)))
5490 (get-text-property (point) 'gnus-data))))
5491 (set-marker overlay-arrow-position nil)
5492 (unless gnus-auto-select-part
5493 (gnus-select-frame-set-input-focus frame)
5494 (select-window window))))
5496 (if gnus-inhibit-mime-unbuttonizing
5497 ;; This is the default though the program shouldn't reach here.
5498 (error "No such part")
5499 ;; The part which doesn't have the MIME button is selected.
5500 ;; So, we display all the buttons and redo it.
5501 (let ((gnus-inhibit-mime-unbuttonizing t))
5502 (gnus-summary-show-article)
5503 (gnus-article-part-wrapper n function no-handle))))))
5505 (defun gnus-article-pipe-part (n)
5506 "Pipe MIME part N, which is the numerical prefix."
5508 (gnus-article-part-wrapper n 'mm-pipe-part))
5510 (defun gnus-article-save-part (n)
5511 "Save MIME part N, which is the numerical prefix."
5513 (gnus-article-part-wrapper n 'mm-save-part))
5515 (defun gnus-article-interactively-view-part (n)
5516 "View MIME part N interactively, which is the numerical prefix."
5518 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5520 (defun gnus-article-copy-part (n)
5521 "Copy MIME part N, which is the numerical prefix."
5523 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5525 (defun gnus-article-view-part-as-charset (n)
5526 "View MIME part N using a specified charset.
5527 N is the numerical prefix."
5529 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5531 (defun gnus-article-view-part-externally (n)
5532 "View MIME part N externally, which is the numerical prefix."
5534 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5536 (defun gnus-article-inline-part (n)
5537 "Inline MIME part N, which is the numerical prefix."
5539 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5541 (defun gnus-article-save-part-and-strip (n)
5542 "Save MIME part N and replace it with an external body.
5543 N is the numerical prefix."
5545 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5547 (defun gnus-article-replace-part (n)
5548 "Replace MIME part N with an external body.
5549 N is the numerical prefix."
5551 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5553 (defun gnus-article-delete-part (n)
5554 "Delete MIME part N and add some information about the removed part.
5555 N is the numerical prefix."
5557 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5559 (defun gnus-article-view-part-as-type (n)
5560 "Choose a MIME media type, and view part N as such.
5561 N is the numerical prefix."
5563 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5565 (defun gnus-article-mime-match-handle-first (condition)
5568 (dolist (ihandle gnus-article-mime-handle-alist)
5570 ((functionp condition)
5571 (funcall condition (cdr ihandle)))
5572 ((eq condition 'undisplayed)
5573 (not (or (mm-handle-undisplayer (cdr ihandle))
5574 (equal (mm-handle-media-type (cdr ihandle))
5575 "multipart/alternative"))))
5576 ((eq condition 'undisplayed-alternative)
5577 (not (mm-handle-undisplayer (cdr ihandle))))
5579 (gnus-article-goto-part (car ihandle))
5580 (or (not n) (< (car ihandle) n)))
5581 (setq n (car ihandle))))
5585 (defun gnus-article-view-part (&optional n)
5586 "View MIME part N, which is the numerical prefix.
5587 If the part is already shown, hide the part. If N is nil, view
5590 (with-current-buffer gnus-article-buffer
5591 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5592 gnus-article-mime-match-handle-function)))
5593 (when (> n (length gnus-article-mime-handle-alist))
5594 (error "No such part"))
5595 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5596 (when (gnus-article-goto-part n)
5597 (if (equal (car handle) "multipart/alternative")
5598 (gnus-article-press-button)
5599 (when (eq (gnus-mm-display-part handle) 'internal)
5600 (gnus-set-window-start)))))))
5602 (defsubst gnus-article-mime-total-parts ()
5603 (if (bufferp (car gnus-article-mime-handles))
5605 (1- (length gnus-article-mime-handles))))
5607 (defun gnus-mm-display-part (handle)
5608 "Display HANDLE and fix MIME button."
5609 (let ((id (get-text-property (point) 'gnus-part))
5611 (inhibit-read-only t))
5614 (let ((window (selected-window))
5615 (mail-parse-charset gnus-newsgroup-charset)
5616 (mail-parse-ignored-charsets
5617 (if (gnus-buffer-live-p gnus-summary-buffer)
5618 (with-current-buffer gnus-summary-buffer
5619 gnus-newsgroup-ignored-charsets)
5623 (let ((win (gnus-get-buffer-window (current-buffer) t))
5626 (select-window win))
5629 (if (mm-handle-displayed-p handle)
5630 ;; This will remove the part.
5631 (mm-display-part handle)
5633 (narrow-to-region (point)
5634 (if (eobp) (point) (1+ (point))))
5635 (gnus-bind-safe-url-regexp (mm-display-part handle))
5636 ;; We narrow to the part itself and
5637 ;; then call the treatment functions.
5638 (goto-char (point-min))
5640 (narrow-to-region (point) (point-max))
5643 (gnus-article-mime-total-parts)
5644 (mm-handle-media-type handle)))))
5645 (if (window-live-p window)
5646 (select-window window)))))
5649 (gnus-insert-mime-button
5650 handle id (list (mm-handle-displayed-p handle)))
5651 (goto-char point))))
5653 (defun gnus-article-goto-part (n)
5654 "Go to MIME part N."
5655 (when gnus-break-pages
5658 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5659 part handle end next handles)
5662 (if (setq handle (get-text-property start 'gnus-data))
5664 ;; Go to the displayed subpart, assuming this is
5665 ;; multipart/alternative.
5668 (while (and (not handle)
5671 (setq next (text-property-not-all part end
5674 handle (get-text-property part 'gnus-data))
5675 (push (cons handle part) handles)
5676 (unless (mm-handle-displayed-p handle)
5678 part (text-property-any part end 'gnus-data nil))))
5680 ;; No subpart is displayed, so we find preferred one.
5682 (cdr (assq (mm-preferred-alternative
5683 (nreverse (mapcar 'car handles)))
5686 (goto-char (1+ part))
5688 (when gnus-break-pages
5689 (gnus-narrow-to-page))))
5691 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5692 (let ((gnus-tmp-name
5693 (or (mail-content-type-get (mm-handle-type handle) 'name)
5694 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5695 (mail-content-type-get (mm-handle-type handle) 'url)
5697 (gnus-tmp-type (mm-handle-media-type handle))
5698 (gnus-tmp-description (or (mm-handle-description handle) ""))
5700 (if (if displayed (car displayed)
5701 (mm-handle-displayed-p handle))
5703 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5705 gnus-tmp-type-long b e)
5706 (when (string-match ".*/" gnus-tmp-name)
5707 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5708 (setq gnus-tmp-type-long (concat gnus-tmp-type
5709 (and (not (equal gnus-tmp-name ""))
5710 (concat "; " gnus-tmp-name))))
5711 (unless (equal gnus-tmp-description "")
5712 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5717 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5718 `(keymap ,gnus-mime-button-map
5719 gnus-callback gnus-mm-display-part
5720 gnus-part ,gnus-tmp-id
5721 article-type annotation
5724 ;; Exclude a newline.
5727 (when gnus-article-button-face
5728 (gnus-overlay-put (gnus-make-overlay b e nil t)
5729 'face gnus-article-button-face))
5730 (widget-convert-button
5733 :action 'gnus-widget-press-button
5734 :button-keymap gnus-mime-button-map
5737 ;; Needed to properly clear the message due to a bug in
5738 ;; wid-edit (XEmacs only).
5739 (if (boundp 'help-echo-owns-message)
5740 (setq help-echo-owns-message t))
5742 "%S: %s the MIME part; %S: more options"
5743 (aref gnus-mouse-2 0)
5744 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5746 (aref gnus-down-mouse-3 0))))))
5748 (defun gnus-widget-press-button (elems el)
5749 (goto-char (widget-get elems :from))
5750 (gnus-article-press-button))
5752 (defvar gnus-displaying-mime nil)
5754 (defun gnus-display-mime (&optional ihandles)
5755 "Display the MIME parts."
5757 (save-selected-window
5758 (let ((window (get-buffer-window gnus-article-buffer))
5761 (select-window window)
5762 ;; We have to do this since selecting the window
5763 ;; may change the point. So we set the window point.
5764 (set-window-point window point)))
5765 (let ((handles ihandles)
5766 (inhibit-read-only t)
5769 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5770 (when gnus-article-emulate-mime
5771 (mm-uu-dissect-text-parts handles)))
5772 (gnus-article-emulate-mime
5773 (setq handles (mm-uu-dissect))))
5774 (when (and (not ihandles)
5775 (not gnus-displaying-mime))
5776 ;; Top-level call; we clean up.
5777 (when gnus-article-mime-handles
5778 (mm-destroy-parts gnus-article-mime-handles)
5779 (setq gnus-article-mime-handle-alist nil));; A trick.
5780 (setq gnus-article-mime-handles handles)
5781 ;; We allow users to glean info from the handles.
5782 (when gnus-article-mime-part-function
5783 (gnus-mime-part-function handles)))
5785 (or (not (stringp (car handles)))
5788 (when (and (not ihandles)
5789 (not gnus-displaying-mime))
5790 ;; Clean up for mime parts.
5792 (delete-region (point) (point-max)))
5793 (let ((gnus-displaying-mime t))
5794 (gnus-mime-display-part handles)))
5797 (narrow-to-region (point) (point-max))
5798 (gnus-treat-article nil 1 1 "text/plain")
5801 ;; Highlight the headers.
5805 (narrow-to-region (point-min) (point))
5806 (gnus-article-save-original-date
5807 (gnus-treat-article 'head)))))))
5808 ;; Cope with broken MIME messages.
5809 (goto-char (point-max))
5813 (defcustom gnus-mime-display-multipart-as-mixed nil
5814 "Display \"multipart\" parts as \"multipart/mixed\".
5816 If t, it overrides nil values of
5817 `gnus-mime-display-multipart-alternative-as-mixed' and
5818 `gnus-mime-display-multipart-related-as-mixed'."
5819 :group 'gnus-article-mime
5822 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5823 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5825 :group 'gnus-article-mime
5828 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5829 "Display \"multipart/related\" parts as \"multipart/mixed\".
5831 If displaying \"text/html\" is discouraged \(see
5832 `mm-discouraged-alternatives'\) images or other material inside a
5833 \"multipart/related\" part might be overlooked when this variable is nil."
5835 :group 'gnus-article-mime
5838 (defun gnus-mime-display-part (handle)
5840 ;; Maybe a broken MIME message.
5843 ((not (stringp (car handle)))
5844 (gnus-mime-display-single handle))
5845 ;; User-defined multipart
5846 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5847 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5849 ;; multipart/alternative
5850 ((and (equal (car handle) "multipart/alternative")
5851 (not (or gnus-mime-display-multipart-as-mixed
5852 gnus-mime-display-multipart-alternative-as-mixed)))
5853 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5854 (push (cons id handle) gnus-article-mime-handle-alist)
5855 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5856 ;; multipart/related
5857 ((and (equal (car handle) "multipart/related")
5858 (not (or gnus-mime-display-multipart-as-mixed
5859 gnus-mime-display-multipart-related-as-mixed)))
5860 ;;;!!!We should find the start part, but we just default
5861 ;;;!!!to the first part.
5862 ;;(gnus-mime-display-part (cadr handle))
5863 ;;;!!! Most multipart/related is an HTML message plus images.
5864 ;;;!!! Unfortunately we are unable to let W3 display those
5865 ;;;!!! included images, so we just display it as a mixed multipart.
5866 ;;(gnus-mime-display-mixed (cdr handle))
5867 ;;;!!! No, w3 can display everything just fine.
5868 (gnus-mime-display-part (cadr handle)))
5869 ((equal (car handle) "multipart/signed")
5870 (gnus-add-wash-type 'signed)
5871 (gnus-mime-display-security handle))
5872 ((equal (car handle) "multipart/encrypted")
5873 (gnus-add-wash-type 'encrypted)
5874 (gnus-mime-display-security handle))
5875 ;; Other multiparts are handled like multipart/mixed.
5877 (gnus-mime-display-mixed (cdr handle)))))
5879 (defun gnus-mime-part-function (handles)
5880 (if (stringp (car handles))
5881 (mapcar 'gnus-mime-part-function (cdr handles))
5882 (funcall gnus-article-mime-part-function handles)))
5884 (defun gnus-mime-display-mixed (handles)
5885 (mapcar 'gnus-mime-display-part handles))
5887 (defun gnus-mime-display-single (handle)
5888 (let ((type (mm-handle-media-type handle))
5889 (ignored gnus-ignored-mime-types)
5896 (when (string-match (pop ignored) type)
5897 (throw 'ignored nil)))
5898 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5899 (with-current-buffer gnus-summary-buffer
5900 gnus-inhibit-images)
5901 gnus-inhibit-images)
5902 (string-match "\\`image/" type)))
5903 (setq not-attachment
5904 (and (not (mm-inline-override-p handle))
5905 (or (not (mm-handle-disposition handle))
5906 (equal (car (mm-handle-disposition handle))
5908 (mm-attachment-override-p handle))))
5909 (mm-automatic-display-p handle)
5911 (mm-inlinable-p handle)
5912 (mm-inlined-p handle))
5913 (mm-automatic-external-display-p type)))
5915 (when (equal (mm-handle-media-supertype handle) "text")
5917 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5919 (push (cons id handle) gnus-article-mime-handle-alist)
5921 (equal (mm-handle-media-supertype handle) "message"))
5924 (cond ((not (bolp)) 2)
5925 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5927 (when (or (not display)
5928 (not (gnus-unbuttonized-mime-type-p type))
5929 (eq id gnus-mime-buttonized-part-id))
5930 (gnus-insert-mime-button
5931 handle id (list (or display (and not-attachment text))))
5932 (gnus-article-insert-newline)
5933 ;; Remember modify the number of forward lines.
5941 (let ((mail-parse-charset gnus-newsgroup-charset)
5942 (mail-parse-ignored-charsets
5943 (save-excursion (condition-case ()
5944 (set-buffer gnus-summary-buffer)
5946 gnus-newsgroup-ignored-charsets)))
5947 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5948 (goto-char (point-max)))
5949 ((and text not-attachment)
5953 (gnus-article-insert-newline)
5954 (mm-display-inline handle)
5955 (goto-char (point-max))))
5959 (narrow-to-region beg (point))
5960 (if (eq handle gnus-article-mime-handles)
5961 ;; The format=flowed case.
5962 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5963 ;; Don't count signature parts that are never displayed.
5964 ;; The part number should be re-calculated supposing this
5965 ;; might be a message/rfc822 part.
5967 (dolist (part gnus-article-mime-handles)
5968 (unless (or (stringp part)
5969 (equal (car (mm-handle-type part))
5970 "application/pgp-signature"))
5971 (push part handles)))
5973 nil (length (memq handle handles)) (length handles)
5974 (mm-handle-media-type handle)))))))))))
5976 (defun gnus-unbuttonized-mime-type-p (type)
5977 "Say whether TYPE is to be unbuttonized."
5978 (unless gnus-inhibit-mime-unbuttonizing
5980 (let ((types gnus-unbuttonized-mime-types))
5982 (when (string-match (pop types) type)
5983 (throw 'found t)))))
5985 (let ((types gnus-buttonized-mime-types))
5987 (when (string-match (pop types) type)
5988 (throw 'found t)))))))))
5990 (defun gnus-article-insert-newline ()
5991 "Insert a newline, but mark it as undeletable."
5992 (gnus-put-text-property
5993 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5995 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5996 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5999 handle (inhibit-read-only t) from props begend not-pref)
6000 (save-window-excursion
6003 (narrow-to-region (car ibegend)
6006 (goto-char (car ibegend))
6009 (delete-region (point-min) (point-max))
6010 (mm-remove-parts handles))
6011 (setq begend (list (point-marker)))
6013 (unless (setq not-pref (cadr (member preferred ihandles)))
6014 (setq not-pref (car ihandles)))
6017 (not (gnus-unbuttonized-mime-type-p
6018 "multipart/alternative")))
6019 (gnus-add-text-properties
6022 (insert (format "%d. " id))
6026 (unless ,(not ibegend)
6027 (setq gnus-article-mime-handle-alist
6028 ',gnus-article-mime-handle-alist))
6029 (gnus-mime-display-alternative
6030 ',ihandles ',not-pref ',begend ,id))
6031 keymap ,gnus-mime-button-map
6032 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6033 face ,gnus-article-button-face
6035 article-type multipart))
6036 (widget-convert-button 'link from (point)
6037 :action 'gnus-widget-press-button
6038 :button-keymap gnus-widget-button-keymap)
6040 (while (setq handle (pop handles))
6041 (gnus-add-text-properties
6044 (insert (format "(%c) %-18s"
6045 (if (equal handle preferred) ?* ? )
6046 (mm-handle-media-type handle)))
6050 (unless ,(not ibegend)
6051 (setq gnus-article-mime-handle-alist
6052 ',gnus-article-mime-handle-alist))
6053 (gnus-mime-display-alternative
6054 ',ihandles ',handle ',begend ,id))
6055 keymap ,gnus-mime-button-map
6056 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6057 face ,gnus-article-button-face
6060 (widget-convert-button 'link from (point)
6061 :action 'gnus-widget-press-button
6062 :button-keymap gnus-widget-button-keymap)
6066 (if (stringp (car preferred))
6067 (gnus-display-mime preferred)
6068 (let ((mail-parse-charset gnus-newsgroup-charset)
6069 (mail-parse-ignored-charsets
6070 (with-current-buffer gnus-summary-buffer
6071 gnus-newsgroup-ignored-charsets)))
6072 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6076 (narrow-to-region (car begend) (point-max))
6078 nil (length gnus-article-mime-handle-alist)
6079 (gnus-article-mime-total-parts)
6080 (mm-handle-media-type preferred))))))
6081 (goto-char (point-max))
6082 (setcdr begend (point-marker)))))
6084 (goto-char point))))
6086 (defconst gnus-article-wash-status-strings
6087 (let ((alist '((cite "c" "Possible hidden citation text"
6088 " " "All citation text visible")
6089 (headers "h" "Hidden headers"
6090 " " "All headers visible.")
6091 (pgp "p" "Encrypted or signed message status hidden"
6092 " " "No hidden encryption nor digital signature status")
6093 (signature "s" "Signature has been hidden"
6094 " " "Signature is visible")
6095 (overstrike "o" "Overstrike (^H) characters applied"
6096 " " "No overstrike characters applied")
6097 (emphasis "e" "/*_Emphasis_*/ characters applied"
6098 " " "No /*_emphasis_*/ characters applied")))
6100 (dolist (entry alist result)
6101 (let ((key (nth 0 entry))
6102 (on (copy-sequence (nth 1 entry)))
6103 (on-help (nth 2 entry))
6104 (off (copy-sequence (nth 3 entry)))
6105 (off-help (nth 4 entry)))
6106 (put-text-property 0 1 'help-echo on-help on)
6107 (put-text-property 0 1 'help-echo off-help off)
6108 (push (list key on off) result))))
6109 "Alist of strings describing wash status in the mode line.
6110 Each entry has the form (KEY ON OF), where the KEY is a symbol
6111 representing the particular washing function, ON is the string to use
6112 in the article mode line when the washing function is active, and OFF
6113 is the string to use when it is inactive.")
6115 (defun gnus-article-wash-status-entry (key value)
6116 (let ((entry (assoc key gnus-article-wash-status-strings)))
6117 (if value (nth 1 entry) (nth 2 entry))))
6119 (defun gnus-article-wash-status ()
6120 "Return a string which display status of article washing."
6121 (with-current-buffer gnus-article-buffer
6122 (let ((cite (memq 'cite gnus-article-wash-types))
6123 (headers (memq 'headers gnus-article-wash-types))
6124 (boring (memq 'boring-headers gnus-article-wash-types))
6125 (pgp (memq 'pgp gnus-article-wash-types))
6126 (pem (memq 'pem gnus-article-wash-types))
6127 (signed (memq 'signed gnus-article-wash-types))
6128 (encrypted (memq 'encrypted gnus-article-wash-types))
6129 (signature (memq 'signature gnus-article-wash-types))
6130 (overstrike (memq 'overstrike gnus-article-wash-types))
6131 (emphasis (memq 'emphasis gnus-article-wash-types)))
6133 (gnus-article-wash-status-entry 'cite cite)
6134 (gnus-article-wash-status-entry 'headers (or headers boring))
6135 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6136 (gnus-article-wash-status-entry 'signature signature)
6137 (gnus-article-wash-status-entry 'overstrike overstrike)
6138 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6140 (defun gnus-add-wash-type (type)
6141 "Add a washing of TYPE to the current status."
6142 (add-to-list 'gnus-article-wash-types type))
6144 (defun gnus-delete-wash-type (type)
6145 "Add a washing of TYPE to the current status."
6146 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6148 (defun gnus-add-image (category image)
6149 "Add IMAGE of CATEGORY to the list of displayed images."
6150 (let ((entry (assq category gnus-article-image-alist)))
6152 (setq entry (list category))
6153 (push entry gnus-article-image-alist))
6154 (nconc entry (list image))))
6156 (defun gnus-delete-images (category)
6157 "Delete all images in CATEGORY."
6158 (let ((entry (assq category gnus-article-image-alist)))
6159 (dolist (image (cdr entry))
6160 (gnus-remove-image image category))
6161 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6162 (gnus-delete-wash-type category)))
6164 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6166 (defun gnus-article-maybe-hide-headers ()
6167 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6168 Provided for backwards compatibility."
6169 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6170 (not (with-current-buffer gnus-summary-buffer
6171 gnus-have-all-headers)))
6172 (not gnus-inhibit-hiding))
6173 (gnus-article-hide-headers)))
6177 (defun gnus-output-to-file (file-name)
6178 "Append the current article to a file named FILE-NAME.
6179 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6180 text and used as the value of the coding cookie which is added to the
6181 top of a file. Otherwise, this function saves a raw article without
6183 (let* ((artbuf (current-buffer))
6184 (file-name-coding-system nnmail-pathname-coding-system)
6185 (coding gnus-article-save-coding-system)
6186 (coding-system-for-read (if coding
6187 nil ;; Rely on the coding cookie.
6188 mm-text-coding-system))
6189 (coding-system-for-write (or coding
6190 mm-text-coding-system-for-write
6191 mm-text-coding-system))
6192 (exists (file-exists-p file-name)))
6195 (insert-file-contents file-name)
6196 (goto-char (point-min))
6197 ;; Remove the existing coding cookie.
6198 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6199 (delete-region (match-beginning 0) (match-end 0))))
6200 (goto-char (point-max))
6201 (insert-buffer-substring artbuf)
6202 ;; Append newline at end of the buffer as separator, and then
6204 (goto-char (point-max))
6207 ;; If the coding system is not suitable to encode the text,
6208 ;; ask a user for a proper one.
6209 (when (fboundp 'select-safe-coding-system)
6210 (setq coding (coding-system-base
6211 (save-window-excursion
6212 (select-safe-coding-system (point-min) (point-max)
6214 (setq coding-system-for-write
6215 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6217 (goto-char (point-min))
6218 ;; Add the coding cookie.
6219 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6220 coding-system-for-write)))
6223 (write-region (point-min) (point-max) file-name nil 'no-message)
6224 (message "Appended to %s" file-name))
6225 (write-region (point-min) (point-max) file-name))))
6228 (defun gnus-narrow-to-page (&optional arg)
6229 "Narrow the article buffer to a page.
6230 If given a numerical ARG, move forward ARG pages."
6232 (setq arg (if arg (prefix-numeric-value arg) 0))
6233 (with-current-buffer gnus-article-buffer
6235 ;; Remove any old next/prev buttons.
6236 (when (gnus-visual-p 'page-marker)
6237 (let ((inhibit-read-only t))
6238 (gnus-remove-text-with-property 'gnus-prev)
6239 (gnus-remove-text-with-property 'gnus-next)))
6241 (when (save-excursion
6243 (if (re-search-backward page-delimiter nil 'move (abs arg))
6245 (setq nd (match-beginning 0)
6247 (when (re-search-backward page-delimiter nil t)
6248 (setq st (match-end 0))))
6249 (when (re-search-forward page-delimiter nil t)
6250 (setq nd (match-beginning 0)
6253 (if (re-search-forward page-delimiter nil 'move arg)
6255 (setq st (match-end 0)
6257 (when (re-search-forward page-delimiter nil t)
6258 (setq nd (match-beginning 0))))
6259 (when (re-search-backward page-delimiter nil t)
6260 (setq st (match-end 0)
6263 (when (re-search-backward page-delimiter nil t)
6264 (goto-char (setq st (match-end 0))))
6265 (when (re-search-forward page-delimiter nil t)
6266 (setq nd (match-beginning 0)))
6268 (setq gnus-page-broken t)
6269 (when pt (goto-char pt))
6270 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6271 (when (gnus-visual-p 'page-marker)
6275 (gnus-insert-next-page-button))
6278 (gnus-insert-prev-page-button))))))))
6280 ;; Article mode commands
6282 (defun gnus-article-goto-next-page ()
6283 "Show the next page of the article."
6285 (when (gnus-article-next-page)
6286 (goto-char (point-min))
6287 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6290 (defun gnus-article-goto-prev-page ()
6291 "Show the previous page of the article."
6293 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6294 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6295 (gnus-article-prev-page nil)))
6297 ;; This is cleaner but currently breaks `gnus-pick-mode':
6299 ;; (defun gnus-article-goto-next-page ()
6300 ;; "Show the next page of the article."
6302 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6303 ;; (gnus-summary-next-page)))
6305 ;; (defun gnus-article-goto-prev-page ()
6306 ;; "Show the next page of the article."
6308 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6309 ;; (gnus-summary-prev-page)))
6311 (defun gnus-article-next-page (&optional lines)
6312 "Show the next page of the current article.
6313 If end of article, return non-nil. Otherwise return nil.
6314 Argument LINES specifies lines to be scrolled up."
6316 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6317 (if (and (not (and gnus-article-over-scroll
6318 (> (count-lines (window-start) (point-max))
6319 (if (featurep 'xemacs)
6320 (or lines (1- (window-height)))
6321 (+ (or lines (1- (window-height))) scroll-margin)))))
6324 (and (pos-visible-in-window-p) ;Not continuation line.
6325 (>= (point) (point-max)))))
6326 ;; Nothing in this page.
6327 (if (or (not gnus-page-broken)
6332 (eobp)))) ;Real end-of-buffer?
6334 (when gnus-article-over-scroll
6335 (gnus-article-next-page-1 lines))
6337 (gnus-narrow-to-page 1) ;Go to next page.
6339 ;; More in this page.
6340 (gnus-article-next-page-1 lines)
6343 (defun gnus-article-beginning-of-window ()
6344 "Move point to the beginning of the window.
6345 In Emacs, the point is placed at the line number which `scroll-margin'
6347 (if (featurep 'xemacs)
6348 (move-to-window-line 0)
6349 ;; There is an obscure bug in Emacs that makes it impossible to
6350 ;; scroll past big pictures in the article buffer. Try to fix
6351 ;; this by adding a sanity check by counting the lines visible.
6352 (when (> (count-lines (window-start) (window-end)) 30)
6353 (move-to-window-line
6354 (min (max 0 scroll-margin)
6355 (max 1 (- (window-height)
6356 (if mode-line-format 1 0)
6357 (if header-line-format 1 0)
6360 (defun gnus-article-next-page-1 (lines)
6362 (let ((scroll-in-place nil))
6365 ;; Long lines may cause an end-of-buffer error.
6366 (goto-char (point-max))))
6367 (gnus-article-beginning-of-window))
6369 (defun gnus-article-prev-page (&optional lines)
6370 "Show previous page of current article.
6371 Argument LINES specifies lines to be scrolled down."
6373 (move-to-window-line 0)
6374 (if (and gnus-page-broken
6376 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6378 (gnus-narrow-to-page -1) ;Go to previous page.
6379 (goto-char (point-max))
6380 (recenter (if gnus-article-over-scroll
6382 (max (if (featurep 'xemacs)
6384 (+ lines scroll-margin))
6386 (- (window-height) 2))
6390 (let ((scroll-in-place nil))
6391 (scroll-down lines))
6392 (beginning-of-buffer
6393 (goto-char (point-min))))
6394 (gnus-article-beginning-of-window))))
6396 (defun gnus-article-only-boring-p ()
6397 "Decide whether there is only boring text remaining in the article.
6398 Something \"interesting\" is a word of at least two letters that does
6399 not have a face in `gnus-article-boring-faces'."
6400 (when (and gnus-article-skip-boring
6401 (boundp 'gnus-article-boring-faces)
6402 (symbol-value 'gnus-article-boring-faces))
6404 (let ((inhibit-point-motion-hooks t))
6406 (while (re-search-forward "\\b\\w\\w" nil t)
6408 (when (not (gnus-intersection
6409 (gnus-faces-at (point))
6410 (symbol-value 'gnus-article-boring-faces)))
6411 (throw 'only-boring nil)))
6412 (throw 'only-boring t))))))
6414 (defun gnus-article-refer-article ()
6415 "Read article specified by message-id around point."
6418 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6419 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6420 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6421 (let ((msg-id (concat "<" (match-string 0) ">")))
6422 (set-buffer gnus-summary-buffer)
6423 (gnus-summary-refer-article msg-id))
6424 (error "No references around point"))))
6426 (defun gnus-article-show-summary ()
6427 "Reconfigure windows to show summary buffer."
6429 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6430 (error "There is no summary buffer for this article buffer")
6431 (gnus-article-set-globals)
6432 (gnus-configure-windows 'article)
6433 (gnus-summary-goto-subject gnus-current-article)
6434 (gnus-summary-position-point)))
6436 (defun gnus-article-describe-briefly ()
6437 "Describe article mode commands briefly."
6439 (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")))
6441 (defun gnus-article-check-buffer ()
6442 "Beep if not in an article buffer."
6443 (unless (equal major-mode 'gnus-article-mode)
6444 (error "Command invoked outside of a Gnus article buffer")))
6446 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6447 "Read a summary buffer key sequence and execute it from the article buffer."
6449 (gnus-article-check-buffer)
6451 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6452 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6453 "=" "^" "\M-^" "|"))
6455 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6456 "An" "Ap" [?A (meta return)] [?A delete]))
6460 '("n" "Gn" "p" "Gp"))
6462 (with-current-buffer gnus-article-current-summary
6463 (let (gnus-pick-mode)
6464 (setq unread-command-events (nconc unread-command-events
6465 (list (or key last-command-event)))
6466 keys (if (featurep 'xemacs)
6467 (events-to-keys (read-key-sequence nil t))
6468 (read-key-sequence nil t)))))
6473 ((eq (aref keys (1- (length keys))) ?\C-h)
6474 (gnus-article-describe-bindings (substring keys 0 -1)))
6475 ((or (member keys nosaves)
6476 (member keys nosave-but-article)
6477 (member keys nosave-in-article))
6479 (save-window-excursion
6480 (pop-to-buffer gnus-article-current-summary)
6481 ;; We disable the pick minor mode commands.
6482 (let (gnus-pick-mode)
6483 (setq func (key-binding keys t))))
6487 (unless (member keys nosave-in-article)
6488 (set-buffer gnus-article-current-summary))
6489 (when (get func 'disabled)
6490 (error "Function %s disabled" func))
6491 (call-interactively func)
6492 (setq new-sum-point (point)))
6493 (when (member keys nosave-but-article)
6494 (pop-to-buffer gnus-article-buffer))))
6496 ;; These commands should restore window configuration.
6497 (let ((obuf (current-buffer))
6498 (owin (current-window-configuration))
6499 win func in-buffer selected new-sum-start new-sum-hscroll err)
6500 (cond (not-restore-window
6501 (pop-to-buffer gnus-article-current-summary)
6502 (setq win (selected-window)))
6503 ((setq win (get-buffer-window gnus-article-current-summary))
6504 (select-window win))
6506 (let ((summary-buffer gnus-article-current-summary))
6507 (gnus-configure-windows 'article)
6508 (unless (setq win (get-buffer-window summary-buffer 'visible))
6509 (let ((gnus-buffer-configuration
6510 '((article ((vertical 1.0
6511 (summary 0.25 point)
6513 (gnus-configure-windows 'article))
6514 (setq win (get-buffer-window summary-buffer 'visible)))
6515 (gnus-select-frame-set-input-focus (window-frame win))
6516 (select-window win))))
6517 (setq in-buffer (current-buffer))
6518 ;; We disable the pick minor mode commands.
6519 (setq func (let (gnus-pick-mode)
6520 (key-binding keys t)))
6521 (when (get func 'disabled)
6522 (error "Function %s disabled" func))
6525 (condition-case code
6527 (call-interactively func)
6533 (when (eq win (selected-window))
6534 (setq new-sum-point (point)
6535 new-sum-start (window-start win)
6536 new-sum-hscroll (window-hscroll win)))
6537 (when (or (eq in-buffer (current-buffer))
6538 (when (eq obuf (current-buffer))
6539 (set-buffer in-buffer)
6541 (setq selected (gnus-summary-select-article))
6543 (unless not-restore-window
6544 (set-window-configuration owin))
6545 (when (and (eq selected 'old)
6547 (set-window-start (get-buffer-window (current-buffer))
6549 (set-window-point (get-buffer-window (current-buffer))
6550 (if (article-goto-body)
6553 (when (and (not not-restore-window)
6556 (with-current-buffer (window-buffer win)
6557 (eq major-mode 'gnus-summary-mode)))
6558 (set-window-point win new-sum-point)
6559 (set-window-start win new-sum-start)
6560 (set-window-hscroll win new-sum-hscroll))))
6561 (set-window-configuration owin)
6563 (signal (car err) (cdr err))
6566 (defun gnus-article-read-summary-send-keys ()
6568 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6569 (gnus-article-read-summary-keys)))
6571 (defun gnus-article-describe-key (key)
6572 "Display documentation of the function invoked by KEY.
6573 KEY is a string or a vector."
6574 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6575 (read-key-sequence "Describe key: "))))
6576 (gnus-article-check-buffer)
6577 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6578 gnus-article-read-summary-send-keys))
6579 (with-current-buffer gnus-article-current-summary
6580 (setq unread-command-events
6581 (if (featurep 'xemacs)
6583 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6584 (list 'meta (- x 128))
6587 (let ((cursor-in-echo-area t)
6589 (describe-key (read-key-sequence nil t))))
6590 (describe-key key)))
6592 (defun gnus-article-describe-key-briefly (key &optional insert)
6593 "Display documentation of the function invoked by KEY.
6594 KEY is a string or a vector."
6595 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6596 (read-key-sequence "Describe key: "))
6597 current-prefix-arg))
6598 (gnus-article-check-buffer)
6599 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6600 gnus-article-read-summary-send-keys))
6601 (with-current-buffer gnus-article-current-summary
6602 (setq unread-command-events
6603 (if (featurep 'xemacs)
6605 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6606 (list 'meta (- x 128))
6609 (let ((cursor-in-echo-area t)
6611 (describe-key-briefly (read-key-sequence nil t) insert)))
6612 (describe-key-briefly key insert)))
6614 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6615 (defvar gnus-agent-summary-mode)
6616 (defvar gnus-draft-mode)
6617 ;; Calling help-buffer will autoload help-mode.
6618 (defvar help-xref-stack-item)
6619 ;; Emacs 22 doesn't load it in the batch mode.
6621 (autoload 'help-buffer "help-mode"))
6623 (defun gnus-article-describe-bindings (&optional prefix)
6624 "Show a list of all defined keys, and their definitions.
6625 The optional argument PREFIX, if non-nil, should be a key sequence;
6626 then we display only bindings that start with that prefix."
6628 (gnus-article-check-buffer)
6629 (let ((keymap (copy-keymap gnus-article-mode-map))
6630 (map (copy-keymap gnus-article-send-map))
6631 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6633 (define-key keymap "S" map)
6634 (define-key map [t] nil)
6635 (with-current-buffer gnus-article-current-summary
6638 (if (setq parent (keymap-parent gnus-article-mode-map))
6640 (setq parent (copy-keymap parent))
6641 (set-keymap-parent parent (current-local-map)))
6642 (current-local-map)))
6643 (set-keymap-parent map (key-binding "S"))
6644 (let (key def gnus-pick-mode)
6646 (setq key (pop sumkeys))
6647 (cond ((and (vectorp key) (= (length key) 1)
6648 (consp (setq def (aref key 0)))
6649 (numberp (car def)) (numberp (cdr def)))
6650 (when (< (max (car def) (cdr def)) 128)
6654 (nreverse (gnus-uncompress-range def)))
6656 ((setq def (key-binding key))
6657 (unless (eq def 'undefined)
6658 (define-key keymap key def))))))
6659 (when (boundp 'gnus-agent-summary-mode)
6660 (setq agent gnus-agent-summary-mode))
6661 (when (boundp 'gnus-draft-mode)
6662 (setq draft gnus-draft-mode)))
6664 (use-local-map keymap)
6665 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6666 (set (make-local-variable 'gnus-draft-mode) draft)
6667 (describe-bindings prefix))
6668 (let ((item `((lambda (prefix)
6669 (with-current-buffer ,(current-buffer)
6670 (gnus-article-describe-bindings prefix)))
6672 (with-current-buffer (let (help-xref-following) (help-buffer))
6673 (setq help-xref-stack-item item)))))
6675 (defun gnus-article-reply-with-original (&optional wide)
6676 "Start composing a reply mail to the current message.
6677 The text in the region will be yanked. If the region isn't active,
6678 the entire article will be yanked."
6680 (let ((article (cdr gnus-article-current))
6682 (if (not (gnus-region-active-p))
6683 (with-current-buffer gnus-summary-buffer
6684 (gnus-summary-reply (list (list article)) wide))
6685 (setq contents (buffer-substring (point) (mark t)))
6686 ;; Deactivate active regions.
6687 (when (and (boundp 'transient-mark-mode)
6688 transient-mark-mode)
6689 (setq mark-active nil))
6690 (with-current-buffer gnus-summary-buffer
6692 (list (list article contents)) wide)))))
6694 (defun gnus-article-wide-reply-with-original ()
6695 "Start composing a wide reply mail to the current message.
6696 The text in the region will be yanked. If the region isn't active,
6697 the entire article will be yanked."
6699 (gnus-article-reply-with-original t))
6701 (defun gnus-article-followup-with-original ()
6702 "Compose a followup to the current article.
6703 The text in the region will be yanked. If the region isn't active,
6704 the entire article will be yanked."
6706 (let ((article (cdr gnus-article-current))
6708 (if (not (gnus-region-active-p))
6709 (with-current-buffer gnus-summary-buffer
6710 (gnus-summary-followup (list (list article))))
6711 (setq contents (buffer-substring (point) (mark t)))
6712 ;; Deactivate active regions.
6713 (when (and (boundp 'transient-mark-mode)
6714 transient-mark-mode)
6715 (setq mark-active nil))
6716 (with-current-buffer gnus-summary-buffer
6717 (gnus-summary-followup
6718 (list (list article contents)))))))
6720 (defun gnus-article-hide (&optional arg force)
6721 "Hide all the gruft in the current article.
6722 This means that signatures, cited text and (some) headers will be
6724 If given a prefix, show the hidden text instead."
6725 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6726 (gnus-article-hide-headers arg)
6727 (gnus-article-hide-list-identifiers arg)
6728 (gnus-article-hide-citation-maybe arg force)
6729 (gnus-article-hide-signature arg))
6731 (defun gnus-article-maybe-highlight ()
6732 "Do some article highlighting if article highlighting is requested."
6733 (when (gnus-visual-p 'article-highlight 'highlight)
6734 (gnus-article-highlight-some)))
6736 (defun gnus-check-group-server ()
6737 ;; Make sure the connection to the server is alive.
6738 (unless (gnus-server-opened
6739 (gnus-find-method-for-group gnus-newsgroup-name))
6740 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6741 (gnus-request-group gnus-newsgroup-name t)))
6744 (autoload 'nneething-get-file-name "nneething"))
6746 (defun gnus-request-article-this-buffer (article group)
6747 "Get an article and insert it into this buffer."
6748 (let (do-update-line sparse-header)
6752 (gnus-kill-all-overlays)
6753 (setq group (or group gnus-newsgroup-name))
6755 ;; Using `gnus-request-article' directly will insert the article into
6756 ;; `nntp-server-buffer' - so we'll save some time by not having to
6757 ;; copy it from the server buffer into the article buffer.
6759 ;; We only request an article by message-id when we do not have the
6760 ;; headers for it, so we'll have to get those.
6761 (when (stringp article)
6762 (gnus-read-header article))
6764 ;; If the article number is negative, that means that this article
6765 ;; doesn't belong in this newsgroup (possibly), so we find its
6766 ;; message-id and request it by id instead of number.
6767 (when (and (numberp article)
6769 (get-buffer gnus-summary-buffer)
6770 (gnus-buffer-exists-p gnus-summary-buffer))
6771 (with-current-buffer gnus-summary-buffer
6772 (let ((header (gnus-summary-article-header article)))
6775 ((memq article gnus-newsgroup-sparse)
6776 ;; This is a sparse gap article.
6777 (setq do-update-line article)
6778 (setq article (mail-header-id header))
6779 (setq sparse-header (gnus-read-header article))
6780 (setq gnus-newsgroup-sparse
6781 (delq article gnus-newsgroup-sparse)))
6783 ;; It's a real article.
6784 (setq article (mail-header-id header)))
6786 ;; It is an extracted pseudo-article.
6787 (setq article 'pseudo)
6788 (gnus-request-pseudo-article header))))
6790 (let ((method (gnus-find-method-for-group
6791 gnus-newsgroup-name)))
6792 (when (and (eq (car method) 'nneething)
6794 (let ((dir (nneething-get-file-name
6795 (mail-header-id header))))
6796 (when (and (stringp dir)
6797 (file-directory-p dir))
6798 (setq article 'nneething)
6799 (gnus-group-enter-directory dir))))))))
6802 ;; Refuse to select canceled articles.
6803 ((and (numberp article)
6805 (get-buffer gnus-summary-buffer)
6806 (gnus-buffer-exists-p gnus-summary-buffer)
6807 (eq (cdr (with-current-buffer gnus-summary-buffer
6808 (assq article gnus-newsgroup-reads)))
6809 gnus-canceled-mark))
6811 ;; We first check `gnus-original-article-buffer'.
6812 ((and (get-buffer gnus-original-article-buffer)
6814 (with-current-buffer gnus-original-article-buffer
6815 (and (equal (car gnus-original-article) group)
6816 (eq (cdr gnus-original-article) article))))
6817 ;; `insert-buffer-substring' would incorrectly use the
6818 ;; equivalent of string-make-multibyte which amount to decoding
6819 ;; with locale-coding-system, causing failure of
6820 ;; subsequent decoding.
6821 (insert (mm-string-to-multibyte
6822 (with-current-buffer gnus-original-article-buffer
6823 (buffer-substring (point-min) (point-max)))))
6825 ;; Check the backlog.
6826 ((and gnus-keep-backlog
6827 (gnus-backlog-request-article group article (current-buffer)))
6829 ;; Check asynchronous pre-fetch.
6830 ((gnus-async-request-fetched-article group article (current-buffer))
6831 (gnus-async-prefetch-next group article gnus-summary-buffer)
6832 (when (and (numberp article) gnus-keep-backlog)
6833 (gnus-backlog-enter-article group article (current-buffer)))
6836 ((and gnus-use-cache
6838 (gnus-cache-request-article article group))
6840 ;; Check the agent cache.
6841 ((gnus-agent-request-article article group)
6843 ;; Get the article and put into the article buffer.
6844 ((or (stringp article)
6846 (let ((gnus-override-method gnus-override-method)
6847 (methods (and (stringp article)
6848 gnus-refer-article-method))
6849 (backend (car (gnus-find-method-for-group
6850 gnus-newsgroup-name)))
6852 (inhibit-read-only t))
6853 (if (or (not (listp methods))
6854 (and (symbolp (car methods))
6855 (assq (car methods) nnoo-definition-alist)))
6856 (setq methods (list methods)))
6857 (when (and (null gnus-override-method)
6859 (setq gnus-override-method (pop methods)))
6861 (when (eq gnus-override-method 'current)
6862 (setq gnus-override-method
6863 (with-current-buffer gnus-summary-buffer
6864 gnus-current-select-method)))
6866 (gnus-kill-all-overlays)
6867 (let ((gnus-newsgroup-name group))
6868 (gnus-check-group-server))
6870 ((gnus-request-article article group (current-buffer))
6871 (when (numberp article)
6872 (gnus-async-prefetch-next group article
6873 gnus-summary-buffer)
6874 (when gnus-keep-backlog
6875 (gnus-backlog-enter-article
6876 group article (current-buffer))))
6877 (setq result 'article))
6879 (setq gnus-override-method (pop methods)))
6880 ((not (string-match "^400 "
6881 (nnheader-get-report backend)))
6882 ;; If we get 400 server disconnect, reconnect and
6883 ;; retry; otherwise, assume the article has expired.
6884 (setq result 'done))))
6885 (and (eq result 'article) 'article)))
6889 ;; Associate this article with the current summary buffer.
6890 (setq gnus-article-current-summary gnus-summary-buffer)
6892 ;; Take the article from the original article buffer
6893 ;; and place it in the buffer it's supposed to be in.
6894 (when (and (get-buffer gnus-article-buffer)
6895 (equal (buffer-name (current-buffer))
6896 (buffer-name (get-buffer gnus-article-buffer))))
6898 (if (get-buffer gnus-original-article-buffer)
6899 (set-buffer gnus-original-article-buffer)
6900 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6901 (buffer-disable-undo)
6902 (setq major-mode 'gnus-original-article-mode)
6903 (setq buffer-read-only t))
6904 (let ((inhibit-read-only t))
6906 (insert-buffer-substring gnus-article-buffer))
6907 (setq gnus-original-article (cons group article)))
6910 (run-hooks 'gnus-article-decode-hook)
6911 ;; Mark article as decoded or not.
6912 (setq gnus-article-decoded-p gnus-article-decode-hook))
6914 ;; Update sparse articles.
6915 (when (and do-update-line
6916 (or (numberp article)
6918 (let ((buf (current-buffer)))
6919 (set-buffer gnus-summary-buffer)
6920 (gnus-summary-update-article do-update-line sparse-header)
6921 (gnus-summary-goto-subject do-update-line nil t)
6922 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6924 (set-buffer buf))))))
6926 (defun gnus-block-private-groups (group)
6927 (if (gnus-news-group-p group)
6928 ;; Block nothing in news groups.
6930 ;; Block everything anywhere else.
6933 (defun gnus-blocked-images ()
6934 (if (functionp gnus-blocked-images)
6935 (funcall gnus-blocked-images gnus-newsgroup-name)
6936 gnus-blocked-images))
6942 (defcustom gnus-article-edit-mode-hook nil
6943 "Hook run in article edit mode buffers."
6944 :group 'gnus-article-various
6947 (defvar gnus-article-edit-done-function nil)
6949 (defvar gnus-article-edit-mode-map nil)
6951 ;; Should we be using derived.el for this?
6952 (unless gnus-article-edit-mode-map
6953 (setq gnus-article-edit-mode-map (make-keymap))
6954 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6956 (gnus-define-keys gnus-article-edit-mode-map
6957 "\C-c?" describe-mode
6958 "\C-c\C-c" gnus-article-edit-done
6959 "\C-c\C-k" gnus-article-edit-exit
6960 "\C-c\C-f\C-t" message-goto-to
6961 "\C-c\C-f\C-o" message-goto-from
6962 "\C-c\C-f\C-b" message-goto-bcc
6963 ;;"\C-c\C-f\C-w" message-goto-fcc
6964 "\C-c\C-f\C-c" message-goto-cc
6965 "\C-c\C-f\C-s" message-goto-subject
6966 "\C-c\C-f\C-r" message-goto-reply-to
6967 "\C-c\C-f\C-n" message-goto-newsgroups
6968 "\C-c\C-f\C-d" message-goto-distribution
6969 "\C-c\C-f\C-f" message-goto-followup-to
6970 "\C-c\C-f\C-m" message-goto-mail-followup-to
6971 "\C-c\C-f\C-k" message-goto-keywords
6972 "\C-c\C-f\C-u" message-goto-summary
6973 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6974 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6975 "\C-c\C-b" message-goto-body
6976 "\C-c\C-i" message-goto-signature
6978 "\C-c\C-t" message-insert-to
6979 "\C-c\C-n" message-insert-newsgroups
6980 "\C-c\C-o" message-sort-headers
6981 "\C-c\C-e" message-elide-region
6982 "\C-c\C-v" message-delete-not-region
6983 "\C-c\C-z" message-kill-to-signature
6984 "\M-\r" message-newline-and-reformat
6985 "\C-c\C-a" mml-attach-file
6986 "\C-a" message-beginning-of-line
6988 "\M-;" comment-region)
6990 (gnus-define-keys (gnus-article-edit-wash-map
6991 "\C-c\C-w" gnus-article-edit-mode-map)
6992 "f" gnus-article-edit-full-stops))
6995 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6997 ["Fetch To" message-insert-to t]
6998 ["Fetch Newsgroups" message-insert-newsgroups t]
7000 ["To" message-goto-to t]
7001 ["From" message-goto-from t]
7002 ["Subject" message-goto-subject t]
7003 ["Cc" message-goto-cc t]
7004 ["Reply-To" message-goto-reply-to t]
7005 ["Summary" message-goto-summary t]
7006 ["Keywords" message-goto-keywords t]
7007 ["Newsgroups" message-goto-newsgroups t]
7008 ["Followup-To" message-goto-followup-to t]
7009 ["Mail-Followup-To" message-goto-mail-followup-to t]
7010 ["Distribution" message-goto-distribution t]
7011 ["Body" message-goto-body t]
7012 ["Signature" message-goto-signature t]))
7014 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7015 "Major mode for editing articles.
7016 This is an extended text-mode.
7018 \\{gnus-article-edit-mode-map}"
7019 (make-local-variable 'gnus-article-edit-done-function)
7020 (make-local-variable 'gnus-prev-winconf)
7021 (set (make-local-variable 'font-lock-defaults)
7022 '(message-font-lock-keywords t))
7023 (set (make-local-variable 'mail-header-separator) "")
7024 (set (make-local-variable 'gnus-article-edit-mode) t)
7025 (easy-menu-add message-mode-field-menu message-mode-map)
7027 (setq buffer-read-only nil)
7028 (buffer-enable-undo)
7031 (defun gnus-article-edit (&optional force)
7032 "Edit the current article.
7033 This will have permanent effect only in mail groups.
7034 If FORCE is non-nil, allow editing of articles even in read-only
7037 (when (and (not force)
7038 (gnus-group-read-only-p))
7039 (error "The current newsgroup does not support article editing"))
7040 (gnus-article-date-original)
7041 (gnus-article-edit-article
7043 `(lambda (no-highlight)
7045 (gnus-summary-edit-article-done
7046 ,(or (mail-header-references gnus-current-headers) "")
7047 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7049 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7050 "Start editing the contents of the current article buffer."
7051 (let ((winconf (current-window-configuration)))
7052 (set-buffer gnus-article-buffer)
7053 (let ((message-auto-save-directory
7054 ;; Don't associate the article buffer with a draft file.
7056 (gnus-article-edit-mode))
7057 (funcall start-func)
7058 (set-buffer-modified-p nil)
7059 (gnus-configure-windows 'edit-article)
7060 (setq gnus-article-edit-done-function exit-func)
7061 (setq gnus-prev-winconf winconf)
7063 (gnus-message 6 "C-c C-c to end edits"))))
7065 (defun gnus-article-edit-done (&optional arg)
7066 "Update the article edits and exit."
7068 (let ((func gnus-article-edit-done-function)
7069 (buf (current-buffer))
7070 (start (window-start))
7072 (winconf gnus-prev-winconf))
7073 (widen) ;; Widen it in case that users narrowed the buffer.
7076 ;; The cache and backlog have to be flushed somewhat.
7077 (when gnus-keep-backlog
7078 (gnus-backlog-remove-article
7079 (car gnus-article-current) (cdr gnus-article-current)))
7080 ;; Flush original article as well.
7081 (gnus-flush-original-article-buffer)
7082 (when gnus-use-cache
7083 (gnus-cache-update-article
7084 (car gnus-article-current) (cdr gnus-article-current)))
7085 ;; We remove all text props from the article buffer.
7086 (kill-all-local-variables)
7087 (set-text-properties (point-min) (point-max) nil)
7089 (set-window-configuration winconf)
7091 (set-window-start (get-buffer-window buf) start)
7092 (set-window-point (get-buffer-window buf) (point)))
7093 (gnus-summary-show-article))
7095 (defun gnus-flush-original-article-buffer ()
7096 (when (get-buffer gnus-original-article-buffer)
7097 (with-current-buffer gnus-original-article-buffer
7098 (setq gnus-original-article nil))))
7100 (defun gnus-article-edit-exit ()
7101 "Exit the article editing without updating."
7103 (when (or (not (buffer-modified-p))
7104 (yes-or-no-p "Article modified; kill anyway? "))
7105 (let ((curbuf (current-buffer))
7107 (window-start (window-start)))
7109 (if (gnus-buffer-live-p gnus-original-article-buffer)
7110 (insert-buffer-substring gnus-original-article-buffer))
7111 (let ((winconf gnus-prev-winconf))
7112 (kill-all-local-variables)
7114 (set-window-configuration winconf)
7115 ;; Tippy-toe some to make sure that point remains where it was.
7116 (save-current-buffer
7118 (set-window-start (get-buffer-window (current-buffer)) window-start)
7120 (gnus-summary-show-article)))
7122 (defun gnus-article-edit-full-stops ()
7123 "Interactively repair spacing at end of sentences."
7126 (goto-char (point-min))
7127 (search-forward-regexp "^$" nil t)
7128 (let ((case-fold-search nil))
7129 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7132 ;;; Article highlights
7135 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7137 ;;; Internal Variables:
7139 (defcustom gnus-button-url-regexp
7141 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7142 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7143 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7144 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7145 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7149 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7150 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7151 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7153 "[" chars punct "]+" "[" chars "]"
7155 (concat ;; XEmacs 21.4 doesn't support POSIX.
7156 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7157 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7159 "Regular expression that matches URLs."
7160 :group 'gnus-article-buttons
7163 (defcustom gnus-button-valid-fqdn-regexp
7164 message-valid-fqdn-regexp
7165 "Regular expression that matches a valid FQDN."
7167 :group 'gnus-article-buttons
7170 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7171 (defcustom gnus-button-valid-localpart-regexp
7172 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7173 "Regular expression that matches a localpart of mail addresses or MIDs."
7175 :group 'gnus-article-buttons
7178 (defcustom gnus-button-man-handler 'manual-entry
7179 "Function to use for displaying man pages.
7180 The function must take at least one argument with a string naming the
7183 :type '(choice (function-item :tag "Man" manual-entry)
7184 (function-item :tag "Woman" woman)
7185 (function :tag "Other"))
7186 :group 'gnus-article-buttons)
7188 (defcustom gnus-button-mid-or-mail-regexp
7189 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7190 gnus-button-valid-fqdn-regexp
7192 "Regular expression that matches a message ID or a mail address."
7194 :group 'gnus-article-buttons
7197 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7198 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7199 Strings like this can be either a message ID or a mail address. If it is one
7200 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7201 message ID or a mail address, respectively. If this variable is set to the
7202 symbol `ask', always query the user what do do. If it is a function, this
7203 function will be called with the string as its only argument. The function
7204 must return `mid', `mail', `invalid' or `ask'."
7206 :group 'gnus-article-buttons
7207 :type '(choice (function-item :tag "Heuristic function"
7208 gnus-button-mid-or-mail-heuristic)
7213 (defcustom gnus-button-mid-or-mail-heuristic-alist
7214 '((-10.0 . ".+\\$.+@")
7217 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7218 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7219 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7220 (-1.0 . "^[^a-z]+@")
7222 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7223 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7224 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7225 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7228 (-1.0 . "^[0-9][0-9]")
7230 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7231 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7232 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7233 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7235 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7236 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7239 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7241 ;; compensation for TDMA dated mail addresses:
7242 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7244 (-20.0 . "\\.fsf@") ;; Gnus
7247 (-20.0 . "^alpine\\.")
7248 (-20.0 . "_-_") ;; Subject change in thread
7250 (-20.0 . "\\.ln@") ;; leafnode
7251 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7252 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7254 ;; (5.0 . "") ;; $local_part_len <= 7
7255 (10.0 . "^[^0-9]+@")
7256 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7257 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7260 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7262 (0.5 . "^[A-Z][a-z]")
7263 (0.5 . "^[A-Z][a-z][a-z]")
7264 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7265 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7266 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7268 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7269 address. The REGEXP is processed with `case-fold-search' set to nil."
7271 :group 'gnus-article-buttons
7272 :type '(repeat (cons (number :tag "Rate")
7273 (regexp :tag "Regexp"))))
7275 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7276 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7277 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7278 address, `ask' if unsure and `invalid' if the string is invalid."
7279 (let ((case-fold-search nil)
7280 (list gnus-button-mid-or-mail-heuristic-alist)
7281 (result 0) rate regexp lpartlen elem)
7283 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7284 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7285 ;; Certain special cases...
7288 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7289 "^[0-9]+\\.[0-9]+@compuserve\\|"
7290 "@public\\.gmane\\.org")
7292 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7293 (setq result 'mail))
7294 (when (string-match "@.*@\\| " mid-or-mail)
7295 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7296 (setq result 'invalid))
7297 ;; Nothing more to do, if result is not a number here...
7298 (when (numberp result)
7300 (setq elem (car list)
7304 (when (string-match regexp mid-or-mail)
7305 (setq result (+ result rate))
7307 9 "`%s' matched `%s', rate `%s', result `%s'."
7308 mid-or-mail regexp rate result)))
7309 (when (<= lpartlen 7)
7310 (setq result (+ result 5.0))
7311 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7312 mid-or-mail result))
7313 (when (>= lpartlen 12)
7314 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7316 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7317 ;; Long local part should contain realname if e-mail address,
7318 ;; too many digits: message-id.
7319 ;; $score -= 5.0 + 0.1 * $local_part_len;
7320 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7321 (setq result (+ result rate))
7323 9 "Many digits in `%s', rate `%s', result `%s'."
7324 mid-or-mail rate result))
7325 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7327 ;; Too few vowels [^aeiouy]{4,}.*\@
7328 (setq result (+ result -5.0))
7330 9 "Few vowels in `%s', rate `%s', result `%s'."
7331 mid-or-mail -5.0 result))
7333 (setq result (+ result 5.0))
7335 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7336 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7337 ;; Maybe we should make this a customizable alist: (condition . 'result)
7339 ((symbolp result) result)
7340 ;; Now convert number into proper results:
7341 ((< result -10.0) 'mid)
7342 ((> result 10.0) 'mail)
7345 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7346 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7347 (url-mid (concat "news" ":" mid-or-mail))
7348 (url-mailto (concat "mailto" ":" mid-or-mail)))
7349 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7350 (when (fboundp pref)
7352 ;; get rid of surrounding angles...
7354 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7355 (if (or (eq 'mid guessed) (eq 'mail guessed))
7359 (save-window-excursion
7360 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7363 (cond ((eq pref 'mid)
7364 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7365 (gnus-button-handle-news url-mid))
7367 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7368 (gnus-url-mailto url-mailto))
7369 (t (gnus-message 3 "Invalid string.")))))
7371 (defun gnus-button-handle-custom (fun arg)
7372 "Call function FUN on argument ARG.
7373 Both FUN and ARG are supposed to be strings. ARG will be passed
7374 as a symbol to FUN."
7375 (funcall (intern fun)
7376 (if (string-match "^customize-apropos" fun)
7380 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7382 ;; FIXME: Maybe we should merge some of the functions that do quite similar
7385 (defun gnus-button-handle-describe-function (url)
7386 "Call `describe-function' when pushing the corresponding URL button."
7389 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7391 (defun gnus-button-handle-describe-variable (url)
7392 "Call `describe-variable' when pushing the corresponding URL button."
7395 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7397 (defun gnus-button-handle-symbol (url)
7398 "Display help on variable or function.
7399 Calls `describe-variable' or `describe-function'."
7400 (let ((sym (intern url)))
7402 ((fboundp sym) (describe-function sym))
7403 ((boundp sym) (describe-variable sym))
7404 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7406 (defun gnus-button-handle-describe-key (url)
7407 "Call `describe-key' when pushing the corresponding URL button."
7409 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7410 (keys (ignore-errors (eval `(kbd ,key-string)))))
7413 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7415 (defun gnus-button-handle-apropos (url)
7416 "Call `apropos' when pushing the corresponding URL button."
7417 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7419 (defun gnus-button-handle-apropos-command (url)
7420 "Call `apropos' when pushing the corresponding URL button."
7422 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7424 (defun gnus-button-handle-apropos-variable (url)
7425 "Call `apropos' when pushing the corresponding URL button."
7427 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7428 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7430 (defun gnus-button-handle-apropos-documentation (url)
7431 "Call `apropos' when pushing the corresponding URL button."
7433 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7434 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7436 (defun gnus-button-handle-library (url)
7437 "Call `locate-library' when pushing the corresponding URL button."
7438 (gnus-message 9 "url=`%s'" url)
7439 (let* ((lib (locate-library url))
7440 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7442 (gnus-message 1 "Cannot locale library `%s'." url)
7443 (find-file-read-only file))))
7445 (defcustom gnus-button-man-level 5
7446 "*Integer that says how many man-related buttons Gnus will show.
7447 The higher the number, the more buttons will appear and the more false
7448 positives are possible. Note that you can set this variable local to
7449 specific groups. Setting it higher in Unix groups is probably a good idea.
7450 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7451 how to set variables in specific groups."
7453 :group 'gnus-article-buttons
7454 :link '(custom-manual "(gnus)Group Parameters")
7457 (defcustom gnus-button-emacs-level 5
7458 "*Integer that says how many emacs-related buttons Gnus will show.
7459 The higher the number, the more buttons will appear and the more false
7460 positives are possible. Note that you can set this variable local to
7461 specific groups. Setting it higher in Emacs or Gnus related groups is
7462 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7463 `gnus-parameters' on how to set variables in specific groups."
7465 :group 'gnus-article-buttons
7466 :link '(custom-manual "(gnus)Group Parameters")
7469 (defcustom gnus-button-message-level 5
7470 "*Integer that says how many buttons for news or mail messages will appear.
7471 The higher the number, the more buttons will appear and the more false
7472 positives are possible."
7473 ;; mail addresses, MIDs, URLs for news, ...
7475 :group 'gnus-article-buttons
7478 (defcustom gnus-button-browse-level 5
7479 "*Integer that says how many buttons for browsing will appear.
7480 The higher the number, the more buttons will appear and the more false
7481 positives are possible."
7482 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7484 :group 'gnus-article-buttons
7487 (defcustom gnus-button-alist
7488 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7489 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7490 ((concat "\\b\\(nntp\\|news\\):\\("
7491 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7492 0 t gnus-button-handle-news 2)
7493 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7494 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7495 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7496 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7497 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7498 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7499 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7500 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7501 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7502 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7503 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7504 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7505 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7506 ;; RFC 2368 (The mailto URL scheme)
7507 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7508 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7509 ("\\bmailto:\\([^ \n\t]+\\)"
7510 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7511 ;; Info Konqueror style <info:/foo/bar baz>.
7512 ;; Must come before " Gnus home-grown style".
7513 ("\\binfo://?\\([^'\">\n\t]+\\)"
7514 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7515 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7516 ("\\binfo://\\([^'\">\n\t ]+\\)"
7517 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7518 ;; Info GNOME style <info:foo#bar_baz>
7519 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7520 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7521 ;; Info KDE style <info:(foo)bar baz>
7522 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7523 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7524 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7525 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7526 ("\\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,]*\\)\\)?"
7527 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7528 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7530 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7531 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7532 ;; Emacs help commands
7533 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7534 ;; regexp doesn't match arguments containing ` '.
7535 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7536 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7537 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7538 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7539 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7540 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7541 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7542 ;; The following entries may lead to many false positives so don't enable
7543 ;; them by default (use a high button level).
7544 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7545 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7546 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7547 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7548 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7549 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7550 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7551 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7552 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7553 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7554 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7555 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7556 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7557 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7558 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7559 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7560 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7561 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7562 ;; Unlike the other regexps we really have to require quoting
7563 ;; here to determine where it ends.
7564 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7565 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7566 ("<URL: *\\([^\n<>]*\\)>"
7567 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7568 ;; RFC 2396 (2.4.3., delims) ...
7569 ("\"URL: *\\([^\n\"]*\\)\""
7570 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7572 (gnus-button-url-regexp
7573 0 (>= gnus-button-browse-level 0) browse-url 0)
7575 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7576 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7577 gnus-button-handle-man 1)
7578 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7579 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7580 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7581 gnus-button-handle-man 1)
7582 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7583 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7584 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7585 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7586 ;; Recognizing patches to .el files. This is somewhat obscure,
7587 ;; but considering the percentage of Gnus users who hack Emacs
7589 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7590 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7591 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7592 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7593 ;; MID or mail: To avoid too many false positives we don't try to catch
7594 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7595 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7596 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7597 ;; so that non-ambiguous entries (see above) match first.
7598 (gnus-button-mid-or-mail-regexp
7599 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7600 "*Alist of regexps matching buttons in article bodies.
7602 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7603 REGEXP: is the string (case insensitive) matching text around the button (can
7604 also be Lisp expression evaluating to a string),
7605 BUTTON: is the number of the regexp grouping actually matching the button,
7606 FORM: is a Lisp expression which must eval to true for the button to
7608 CALLBACK: is the function to call when the user push this button, and each
7609 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7611 CALLBACK can also be a variable, in that case the value of that
7612 variable it the real callback function."
7613 :group 'gnus-article-buttons
7614 :type '(repeat (list (choice regexp variable sexp)
7615 (integer :tag "Button")
7617 (function :tag "Callback")
7620 (integer :tag "Regexp group")))))
7621 (put 'gnus-button-alist 'risky-local-variable t)
7623 (defcustom gnus-header-button-alist
7624 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7625 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7626 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7627 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7628 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7629 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7630 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7631 0 (>= gnus-button-browse-level 0) browse-url 0)
7632 ("^Subject:" gnus-button-url-regexp
7633 0 (>= gnus-button-browse-level 0) browse-url 0)
7634 ("^[^:]+:" gnus-button-url-regexp
7635 0 (>= gnus-button-browse-level 0) browse-url 0)
7636 ("^OpenPGP:.*url=" gnus-button-url-regexp
7637 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7638 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7639 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7640 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7641 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7642 "*Alist of headers and regexps to match buttons in article heads.
7644 This alist is very similar to `gnus-button-alist', except that each
7645 alist has an additional HEADER element first in each entry:
7647 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7649 HEADER is a regexp to match a header. For a fuller explanation, see
7650 `gnus-button-alist'."
7651 :group 'gnus-article-buttons
7652 :group 'gnus-article-headers
7653 :type '(repeat (list (regexp :tag "Header")
7654 (choice regexp variable)
7655 (integer :tag "Button")
7657 (function :tag "Callback")
7660 (integer :tag "Regexp group")))))
7661 (put 'gnus-header-button-alist 'risky-local-variable t)
7665 (defun gnus-article-push-button (event)
7666 "Check text under the mouse pointer for a callback function.
7667 If the text under the mouse pointer has a `gnus-callback' property,
7668 call it with the value of the `gnus-data' text property."
7670 (set-buffer (window-buffer (posn-window (event-start event))))
7671 (let* ((pos (posn-point (event-start event)))
7672 (data (get-text-property pos 'gnus-data))
7673 (fun (get-text-property pos 'gnus-callback)))
7676 (funcall fun data))))
7678 (defun gnus-article-press-button ()
7679 "Check text at point for a callback function.
7680 If the text at point has a `gnus-callback' property,
7681 call it with the value of the `gnus-data' text property."
7683 (let ((data (get-text-property (point) 'gnus-data))
7684 (fun (get-text-property (point) 'gnus-callback)))
7686 (funcall fun data))))
7688 (defun gnus-article-highlight (&optional force)
7689 "Highlight current article.
7690 This function calls `gnus-article-highlight-headers',
7691 `gnus-article-highlight-citation',
7692 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7693 do the highlighting. See the documentation for those functions."
7694 (interactive (list 'force))
7695 (gnus-article-highlight-headers)
7696 (gnus-article-highlight-citation force)
7697 (gnus-article-highlight-signature)
7698 (gnus-article-add-buttons)
7699 (gnus-article-add-buttons-to-head))
7701 (defun gnus-article-highlight-some (&optional force)
7702 "Highlight current article.
7703 This function calls `gnus-article-highlight-headers',
7704 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7705 do the highlighting. See the documentation for those functions."
7706 (interactive (list 'force))
7707 (gnus-article-highlight-headers)
7708 (gnus-article-highlight-signature)
7709 (gnus-article-add-buttons))
7711 (defun gnus-article-highlight-headers ()
7712 "Highlight article headers as specified by `gnus-header-face-alist'."
7714 (gnus-with-article-headers
7715 (let (regexp header-face field-face from hpoints fpoints)
7716 (dolist (entry gnus-header-face-alist)
7717 (goto-char (point-min))
7718 (setq regexp (concat "^\\("
7719 (if (string-equal "" (nth 0 entry))
7723 header-face (nth 1 entry)
7724 field-face (nth 2 entry))
7725 (while (and (re-search-forward regexp nil t)
7729 (unless (search-forward ":" nil t)
7731 (when (and header-face
7732 (not (memq (point) hpoints)))
7733 (push (point) hpoints)
7734 (gnus-put-text-property from (point) 'face header-face))
7735 (when (and field-face
7736 (not (memq (setq from (point)) fpoints)))
7738 (if (re-search-forward "^[^ \t]" nil t)
7740 (goto-char (point-max)))
7741 (gnus-put-text-property from (point) 'face field-face)))))))
7743 (defun gnus-article-highlight-signature ()
7744 "Highlight the signature in an article.
7745 It does this by highlighting everything after
7746 `gnus-signature-separator' using the face `gnus-signature'."
7748 (gnus-with-article-buffer
7749 (let ((inhibit-point-motion-hooks t))
7751 (when (and gnus-signature-face
7752 (gnus-article-narrow-to-signature))
7753 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7754 'face gnus-signature-face)
7756 (gnus-article-search-signature)
7757 (let ((start (match-beginning 0))
7758 (end (set-marker (make-marker) (1+ (match-end 0)))))
7759 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7762 (defun gnus-button-in-region-p (b e prop)
7763 "Say whether PROP exists in the region."
7764 (text-property-not-all b e prop nil))
7766 (defun gnus-article-add-buttons ()
7767 "Find external references in the article and make buttons of them.
7768 \"External references\" are things like Message-IDs and URLs, as
7769 specified by `gnus-button-alist'."
7771 (gnus-with-article-buffer
7772 (let ((inhibit-point-motion-hooks t)
7773 (case-fold-search t)
7774 (alist gnus-button-alist)
7776 ;; We skip the headers.
7779 (while (setq entry (pop alist))
7780 (setq regexp (eval (car entry)))
7782 (while (re-search-forward regexp nil t)
7783 (let ((start (match-beginning (nth 1 entry)))
7784 (end (match-end (nth 1 entry)))
7785 (from (match-beginning 0)))
7786 (when (and (eval (nth 2 entry))
7787 (not (gnus-button-in-region-p
7788 start end 'gnus-callback)))
7789 ;; That optional form returned non-nil, so we add the
7791 (setq from (set-marker (make-marker) from))
7792 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7793 (gnus-article-extend-url-button from start end))
7794 (gnus-article-add-button start end
7795 'gnus-button-push (list from entry))
7796 (gnus-put-text-property
7798 'gnus-string (buffer-substring-no-properties
7801 (defun gnus-article-extend-url-button (beg start end)
7802 "Extend url button if url is folded into two or more lines.
7803 Return non-nil if button is extended. BEG is a marker that points to
7804 the beginning position of a text containing url. START and END are
7805 the endpoints of a url button before it is extended. The concatenated
7806 url is put as the `gnus-button-url' overlay property on the button."
7807 (let ((opoint (point))
7808 (points (list start end))
7813 (not (looking-at "[\t ]*[\">]")))
7817 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7818 (buffer-substring (point-at-bol) start)))
7820 (setq url (list (buffer-substring start end))
7821 delim (if (match-beginning 1) ">" "\""))
7823 (setq regexp (concat
7824 (when (and (looking-at
7825 message-cite-prefix-regexp)
7826 (< (match-end 0) start))
7827 (regexp-quote (match-string 0)))
7829 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7833 (and (looking-at regexp)
7836 (push (or (match-string 2)
7839 (push (setq end (or (match-end 2)
7842 (push (or (match-beginning 2)
7843 (match-beginning 1))
7845 (match-beginning 2)))
7846 (let (gnus-article-mouse-face widget-mouse-face)
7848 (gnus-article-add-button (pop points) (pop points)
7849 'gnus-button-push beg)))
7850 (let ((overlay (gnus-make-overlay start end)))
7851 (gnus-overlay-put overlay 'evaporate t)
7852 (gnus-overlay-put overlay 'gnus-button-url
7853 (list (mapconcat 'identity (nreverse url) "")))
7854 (when gnus-article-mouse-face
7855 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7857 (goto-char opoint))))
7859 ;; Add buttons to the head of an article.
7860 (defun gnus-article-add-buttons-to-head ()
7861 "Add buttons to the head of the article."
7863 (gnus-with-article-headers
7865 (dolist (entry gnus-header-button-alist)
7866 ;; Each alist entry.
7867 (goto-char (point-min))
7868 (while (re-search-forward (car entry) nil t)
7869 ;; Each header matching the entry.
7870 (setq beg (match-beginning 0))
7871 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7872 (match-beginning 0))
7875 (while (re-search-forward (eval (nth 1 entry)) end t)
7876 ;; Each match within a header.
7877 (let* ((entry (cdr entry))
7878 (start (match-beginning (nth 1 entry)))
7879 (end (match-end (nth 1 entry)))
7880 (form (nth 2 entry)))
7881 (goto-char (match-end 0))
7883 (gnus-article-add-button
7884 start end (nth 3 entry)
7885 (buffer-substring (match-beginning (nth 4 entry))
7886 (match-end (nth 4 entry)))))))
7887 (goto-char end))))))
7889 ;;; External functions:
7891 (defun gnus-article-add-button (from to fun &optional data text)
7892 "Create a button between FROM and TO with callback FUN and data DATA."
7893 (when gnus-article-button-face
7894 (gnus-overlay-put (gnus-make-overlay from to nil t)
7895 'face gnus-article-button-face))
7896 (gnus-add-text-properties
7898 (nconc (and gnus-article-mouse-face
7899 (list gnus-mouse-face-prop gnus-article-mouse-face))
7900 (list 'gnus-callback fun)
7901 (and data (list 'gnus-data data))))
7902 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7903 :help-echo (or text "Follow the link")
7904 :keymap gnus-url-button-map
7905 :button-keymap gnus-widget-button-keymap))
7907 (defun gnus-article-copy-string ()
7908 "Copy the string in the button to the kill ring."
7910 (gnus-article-check-buffer)
7911 (let ((data (get-text-property (point) 'gnus-string)))
7915 (copy-region-as-kill (point-min) (point-max))
7916 (message "Copied %s" data)))))
7918 ;;; Internal functions:
7920 (defun gnus-article-set-globals ()
7921 (with-current-buffer gnus-summary-buffer
7922 (gnus-set-global-variables)))
7924 (defun gnus-signature-toggle (end)
7925 (gnus-with-article-buffer
7926 (let ((inhibit-point-motion-hooks t))
7927 (if (text-property-any end (point-max) 'article-type 'signature)
7929 (gnus-delete-wash-type 'signature)
7930 (gnus-remove-text-properties-when
7931 'article-type 'signature end (point-max)
7932 (cons 'article-type (cons 'signature
7933 gnus-hidden-properties))))
7934 (gnus-add-wash-type 'signature)
7935 (gnus-add-text-properties-when
7936 'article-type nil end (point-max)
7937 (cons 'article-type (cons 'signature
7938 gnus-hidden-properties)))))
7939 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7940 (gnus-set-mode-line 'article))))
7942 (defun gnus-button-push (marker-and-entry)
7943 ;; Push button starting at MARKER.
7945 (let* ((marker (car marker-and-entry))
7946 (entry (cadr marker-and-entry))
7947 (regexp (car entry))
7948 (inhibit-point-motion-hooks t))
7950 ;; This is obviously true, or something bad is happening :)
7951 ;; But we need it to have the match-data
7952 (when (looking-at (or (if (symbolp regexp)
7953 (symbol-value regexp)
7955 (let ((fun (nth 3 entry))
7956 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7957 (get-char-property marker 'gnus-button-url))
7958 (mapcar (lambda (group)
7959 (let ((string (match-string group)))
7960 (set-text-properties
7961 0 (length string) nil string)
7963 (nthcdr 4 entry)))))
7969 (fboundp (symbol-value fun)))
7970 (apply (symbol-value fun) args))
7972 (gnus-message 1 "You must define `%S' to use this button"
7973 (cons fun args)))))))))
7975 (defun gnus-parse-news-url (url)
7976 (let (scheme server port group message-id articles)
7979 (goto-char (point-min))
7980 (when (looking-at "\\([A-Za-z]+\\):")
7981 (setq scheme (match-string 1))
7982 (goto-char (match-end 0)))
7983 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7984 (setq server (match-string 1))
7985 (setq port (if (stringp (match-string 3))
7986 (string-to-number (match-string 3))
7988 (goto-char (match-end 0)))
7991 ((looking-at "\\(.*@.*\\)")
7992 (setq message-id (match-string 1)))
7993 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7994 (setq group (match-string 1)
7995 articles (split-string (match-string 2) "-")))
7996 ((looking-at "\\([^/]+\\)/?")
7997 (setq group (match-string 1)))
7999 (error "Unknown news URL syntax"))))
8000 (list scheme server port group message-id articles)))
8002 (defun gnus-button-handle-news (url)
8004 (destructuring-bind (scheme server port group message-id articles)
8005 (gnus-parse-news-url url)
8008 (with-current-buffer gnus-summary-buffer
8010 (let ((gnus-refer-article-method
8011 (nconc (list (list 'nntp server))
8012 gnus-refer-article-method))
8013 (nntp-port-number (or port "nntp")))
8014 (gnus-message 7 "Fetching %s with %s"
8015 message-id gnus-refer-article-method)
8016 (gnus-summary-refer-article message-id))
8017 (gnus-summary-refer-article message-id))))
8019 (gnus-button-fetch-group url)))))
8021 (defun gnus-button-patch (library line)
8022 "Visit an Emacs Lisp library LIBRARY on line LINE."
8024 (let ((file (locate-library (file-name-nondirectory library))))
8026 (error "Couldn't find library %s" library))
8028 (goto-char (point-min))
8029 (forward-line (1- (string-to-number line)))))
8031 (defun gnus-button-handle-man (url)
8033 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8034 (when (eq gnus-button-man-handler 'woman)
8035 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8036 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8037 (funcall gnus-button-man-handler url))
8039 (defun gnus-button-handle-info-url (url)
8040 "Fetch an info URL."
8041 (setq url (mm-subst-char-in-string ?+ ?\ url))
8043 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8044 (gnus-info-find-node
8045 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8047 ")" (gnus-url-unhex-string (match-string 2 url)))))
8048 ((string-match "([^)\"]+)[^\"]+" url)
8050 (gnus-replace-in-string
8051 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8052 (gnus-info-find-node url))
8053 (t (error "Can't parse %s" url))))
8055 (defun gnus-button-handle-info-url-gnome (url)
8056 "Fetch GNOME style info URL."
8057 (setq url (mm-subst-char-in-string ?_ ?\ url))
8058 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8059 (gnus-info-find-node
8061 (gnus-url-unhex-string
8062 (match-string 1 url))
8064 (or (gnus-url-unhex-string
8065 (match-string 2 url))
8067 (error "Can't parse %s" url)))
8069 (defun gnus-button-handle-info-url-kde (url)
8070 "Fetch KDE style info URL."
8071 (gnus-info-find-node (gnus-url-unhex-string url)))
8073 ;; (info) will autoload info.el
8074 (declare-function Info-menu "info" (menu-item &optional fork))
8075 (declare-function Info-index-next "info" (num))
8077 (defun gnus-button-handle-info-keystrokes (url)
8078 "Call `info' when pushing the corresponding URL button."
8079 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8080 (let (node indx comma)
8082 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8083 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8084 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8085 "\\(?:[ \t\n,]*\\)\\)?")
8087 (setq node (match-string 2 url)
8088 indx (match-string 3 url))
8089 (error "Can't parse %s" url))
8093 (when (> (length indx) 0)
8094 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8097 (setq comma (match-string 2 indx))
8098 (setq indx (match-string 1 indx))
8101 (dotimes (i (with-temp-buffer
8103 ;; Note: the XEmacs version of `how-many' takes
8104 ;; no optional argument.
8105 (goto-char (point-min))
8107 (Info-index-next 1)))
8110 (autoload 'pgg-snarf-keys-region "pgg")
8111 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8112 (declare-function pgg-display-output-buffer "pgg" (start end status))
8114 (defun gnus-button-openpgp (url)
8115 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8117 (mm-url-insert-file-contents-external url)
8118 (pgg-snarf-keys-region (point-min) (point-max))
8119 (pgg-display-output-buffer nil nil nil)))
8121 (defun gnus-button-message-id (message-id)
8123 (with-current-buffer gnus-summary-buffer
8124 (gnus-summary-refer-article message-id)))
8126 (defun gnus-button-fetch-group (address &rest ignore)
8127 "Fetch GROUP specified by ADDRESS."
8128 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8130 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8131 ;; for nntp:// and news://
8132 (setq address (match-string 3 address)))
8133 (if (not (string-match "[:/]" address))
8134 ;; This is just a simple group url.
8135 (gnus-group-read-ephemeral-group address gnus-select-method)
8138 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8140 (error "Can't parse %s" address)
8141 (gnus-group-read-ephemeral-group
8142 (match-string 4 address)
8143 `(nntp ,(match-string 1 address)
8144 (nntp-address ,(match-string 1 address))
8145 (nntp-port-number ,(if (match-end 3)
8146 (match-string 3 address)
8149 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8151 (defun gnus-url-parse-query-string (query &optional downcase)
8152 (let (retval pairs cur key val)
8153 (setq pairs (split-string query "&"))
8155 (setq cur (car pairs)
8157 (if (not (string-match "=" cur))
8159 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8160 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8162 (setq key (downcase key)))
8163 (setq cur (assoc key retval))
8165 (setcdr cur (cons val (cdr cur)))
8166 (setq retval (cons (list key val) retval)))))
8169 (defun gnus-url-mailto (url)
8170 ;; Send mail to someone
8171 (setq url (replace-regexp-in-string "\n" " " url))
8172 (when (string-match "mailto:/*\\(.*\\)" url)
8173 (setq url (substring url (match-beginning 1) nil)))
8174 (let (to args subject func)
8175 (setq args (gnus-url-parse-query-string
8176 (if (string-match "^\\?" url)
8178 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8179 (concat "to=" (match-string 1 url) "&"
8180 (match-string 2 url))
8181 (concat "to=" url))))
8182 subject (cdr-safe (assoc "subject" args)))
8185 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8188 (message-position-on-field (caar args)))
8189 (insert (gnus-replace-in-string
8190 (mapconcat 'identity (reverse (cdar args)) ", ")
8192 (setq args (cdr args)))
8195 (message-goto-subject))))
8197 (defun gnus-button-embedded-url (address)
8198 "Activate ADDRESS with `browse-url'."
8199 (browse-url (gnus-strip-whitespace address)))
8201 ;;; Next/prev buttons in the article buffer.
8203 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8204 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8206 (defvar gnus-prev-page-map
8207 (let ((map (make-sparse-keymap)))
8208 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8209 (define-key map "\r" 'gnus-button-prev-page)
8212 (defvar gnus-next-page-map
8213 (let ((map (make-sparse-keymap)))
8214 (define-key map gnus-mouse-2 'gnus-button-next-page)
8215 (define-key map "\r" 'gnus-button-next-page)
8218 (defun gnus-insert-prev-page-button ()
8220 (inhibit-read-only t))
8222 gnus-prev-page-line-format nil
8223 `(keymap ,gnus-prev-page-map
8225 gnus-callback gnus-article-button-prev-page
8226 article-type annotation))
8228 ;; Exclude a newline.
8231 (when gnus-article-button-face
8232 (gnus-overlay-put (gnus-make-overlay b e nil t)
8233 'face gnus-article-button-face))
8234 (widget-convert-button
8236 :action 'gnus-button-prev-page
8237 :button-keymap gnus-prev-page-map)))
8239 (defun gnus-button-next-page (&optional args more-args)
8240 "Go to the next page."
8242 (let ((win (selected-window)))
8243 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8244 (gnus-article-next-page)
8245 (select-window win)))
8247 (defun gnus-button-prev-page (&optional args more-args)
8248 "Go to the prev page."
8250 (let ((win (selected-window)))
8251 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8252 (gnus-article-prev-page)
8253 (select-window win)))
8255 (defun gnus-insert-next-page-button ()
8257 (inhibit-read-only t))
8258 (gnus-eval-format gnus-next-page-line-format nil
8259 `(keymap ,gnus-next-page-map
8261 gnus-callback gnus-article-button-next-page
8262 article-type annotation))
8264 ;; Exclude a newline.
8267 (when gnus-article-button-face
8268 (gnus-overlay-put (gnus-make-overlay b e nil t)
8269 'face gnus-article-button-face))
8270 (widget-convert-button
8272 :action 'gnus-button-next-page
8273 :button-keymap gnus-next-page-map)))
8275 (defun gnus-article-button-next-page (arg)
8276 "Go to the next page."
8278 (let ((win (selected-window)))
8279 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8280 (gnus-article-next-page)
8281 (select-window win)))
8283 (defun gnus-article-button-prev-page (arg)
8284 "Go to the prev page."
8286 (let ((win (selected-window)))
8287 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8288 (gnus-article-prev-page)
8289 (select-window win)))
8291 (defvar gnus-decode-header-methods
8292 '(mail-decode-encoded-word-region)
8293 "List of methods used to decode headers.
8295 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8296 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8297 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8298 whose names match REGEXP.
8301 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8302 mail-decode-encoded-word-region
8303 (\"chinese\" . rfc1843-decode-region))
8306 (defvar gnus-decode-header-methods-cache nil)
8308 (defun gnus-multi-decode-header (start end)
8309 "Apply the functions from `gnus-encoded-word-methods' that match."
8310 (unless (and gnus-decode-header-methods-cache
8311 (eq gnus-newsgroup-name
8312 (car gnus-decode-header-methods-cache)))
8313 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8314 (dolist (x gnus-decode-header-methods)
8316 (nconc gnus-decode-header-methods-cache (list x))
8317 (if (and gnus-newsgroup-name
8318 (string-match (car x) gnus-newsgroup-name))
8319 (nconc gnus-decode-header-methods-cache
8321 (let ((xlist gnus-decode-header-methods-cache))
8324 (narrow-to-region start end)
8326 (funcall (pop xlist) (point-min) (point-max))))))
8329 ;;; Treatment top-level handling.
8332 (defvar gnus-inhibit-article-treatments nil)
8334 (defun gnus-treat-article (gnus-treat-condition
8335 &optional part-number total-parts gnus-treat-type)
8336 (let ((gnus-treat-length (- (point-max) (point-min)))
8337 (alist gnus-treatment-function-alist)
8338 (article-goto-body-goes-to-point-min-p t)
8340 (or (not gnus-treat-type)
8342 (let ((list gnus-article-treat-types))
8344 (when (string-match (pop list) gnus-treat-type)
8345 (throw 'found t)))))))
8346 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8348 (gnus-run-hooks 'gnus-part-display-hook)
8349 (dolist (elem alist)
8352 (when (gnus-buffer-live-p gnus-summary-buffer)
8353 (set-buffer gnus-summary-buffer))
8354 (symbol-value (car elem))))
8355 (when (and (or (consp val)
8357 (or (not gnus-inhibit-article-treatments)
8358 (eq gnus-treat-condition 'head))
8359 (gnus-treat-predicate val)
8360 (or (not (get (car elem) 'highlight))
8363 (funcall (cadr elem)))))))
8365 ;; Dynamic variables.
8366 (defvar part-number)
8367 (defvar total-parts)
8368 (defvar gnus-treat-type)
8369 (defvar gnus-treat-condition)
8370 (defvar gnus-treat-length)
8372 (defun gnus-treat-predicate (val)
8376 (gnus-treat-condition
8377 (eq gnus-treat-condition val))
8379 (stringp (car val)))
8380 (apply 'gnus-or (mapcar `(lambda (s)
8381 (string-match s ,(or gnus-newsgroup-name "")))
8384 (let ((pred (pop val)))
8387 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8389 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8391 (not (gnus-treat-predicate (car val))))
8393 (equal (car val) gnus-treat-type))
8395 (error "%S is not a valid predicate" pred)))))
8403 (eq part-number total-parts))
8405 (< gnus-treat-length val))
8407 (error "%S is not a valid value" val))))
8409 (defun gnus-article-encrypt-body (protocol &optional n)
8410 "Encrypt the article body."
8413 (or gnus-article-encrypt-protocol
8414 (gnus-completing-read "Encrypt protocol"
8415 (mapcar 'car gnus-article-encrypt-protocol-alist)
8417 current-prefix-arg))
8418 ;; User might hit `K E' instead of `K e', so prompt once.
8419 (when (and gnus-article-encrypt-protocol
8421 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8422 (error "Encrypt aborted")))
8423 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8425 (error "Can't find the encrypt protocol %s" protocol))
8426 (if (member gnus-newsgroup-name '("nndraft:delayed"
8429 (error "Can't encrypt the article in group %s"
8430 gnus-newsgroup-name))
8431 (gnus-summary-iterate n
8432 (with-current-buffer gnus-summary-buffer
8433 (let ((mail-parse-charset gnus-newsgroup-charset)
8434 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8435 (summary-buffer gnus-summary-buffer)
8437 (gnus-set-global-variables)
8438 (when (gnus-group-read-only-p)
8439 (error "The current newsgroup does not support article encrypt"))
8440 (gnus-summary-show-article t)
8442 (or (mail-header-references gnus-current-headers) ""))
8443 (set-buffer gnus-article-buffer)
8444 (let* ((inhibit-read-only t)
8446 (mapcar (lambda (field)
8447 (and (save-restriction
8448 (message-narrow-to-head)
8449 (goto-char (point-min))
8450 (search-forward field nil t))
8452 (message-narrow-to-field)
8454 (delete-region (point-min) (point-max))
8456 '("Content-Type:" "Content-Transfer-Encoding:"
8457 "Content-Disposition:"))))
8458 (message-narrow-to-head)
8459 (message-remove-header "MIME-Version")
8460 (goto-char (point-max))
8461 (setq point (point))
8462 (insert (apply 'concat headers))
8464 (narrow-to-region point (point-max))
8465 (let ((message-options message-options))
8466 (message-options-set 'message-sender user-mail-address)
8467 (message-options-set 'message-recipients user-mail-address)
8468 (message-options-set 'message-sign-encrypt 'not)
8470 (goto-char (point-min))
8471 (insert "MIME-Version: 1.0\n")
8473 (gnus-summary-edit-article-done
8474 references nil summary-buffer t))
8475 (when gnus-keep-backlog
8476 (gnus-backlog-remove-article
8477 (car gnus-article-current) (cdr gnus-article-current)))
8478 (gnus-flush-original-article-buffer)
8479 (when gnus-use-cache
8480 (gnus-cache-update-article
8481 (car gnus-article-current) (cdr gnus-article-current))))))))
8483 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8484 "The following specs can be used:
8485 %t The security MIME type
8488 %D Details if button is pressed")
8490 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8491 "The following specs can be used:
8492 %t The security MIME type
8495 %D Details if button is pressed")
8497 (defvar gnus-mime-security-button-line-format-alist
8498 '((?t gnus-tmp-type ?s)
8499 (?i gnus-tmp-info ?s)
8500 (?d gnus-tmp-details ?s)
8501 (?D gnus-tmp-pressed-details ?s)))
8503 (defvar gnus-mime-security-button-commands
8504 '((gnus-article-press-button "\r" "Show Detail")
8508 (gnus-mime-security-save-part "o" "Save...")
8517 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8520 (defvar gnus-mime-security-button-map
8521 (let ((map (make-sparse-keymap)))
8522 (define-key map gnus-mouse-2 'gnus-article-push-button)
8523 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8524 (dolist (c gnus-mime-security-button-commands)
8525 (define-key map (cadr c) (car c)))
8529 gnus-mime-security-button-menu gnus-mime-security-button-map
8530 "Security button menu."
8534 (unless (eq (car c) 'undefined)
8535 (vector (caddr c) (car c) :active t)))
8536 gnus-mime-security-button-commands))))
8538 (defun gnus-mime-security-button-menu (event prefix)
8539 "Construct a context-sensitive menu of security commands."
8540 (interactive "e\nP")
8541 (save-window-excursion
8542 (let ((pos (event-start event)))
8543 (select-window (posn-window pos))
8544 (goto-char (posn-point pos))
8545 (gnus-article-check-buffer)
8546 (popup-menu gnus-mime-security-button-menu nil prefix))))
8548 (defvar gnus-mime-security-details-buffer nil)
8550 (defvar gnus-mime-security-button-pressed nil)
8552 (defvar gnus-mime-security-show-details-inline t
8553 "If non-nil, show details in the article buffer.")
8555 (defun gnus-mime-security-verify-or-decrypt (handle)
8556 (mm-remove-parts (cdr handle))
8557 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8558 point (inhibit-read-only t))
8560 (goto-char (car region)))
8561 (setq point (point))
8562 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8563 (let* ((mm-verify-option 'known)
8564 (mm-decrypt-option 'known)
8565 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8566 (unless (eq nparts (cdr handle))
8567 (mm-destroy-parts (cdr handle))
8568 (setcdr handle nparts))))
8569 (gnus-mime-display-security handle)
8571 (delete-region (point) (cdr region))
8572 (set-marker (car region) nil)
8573 (set-marker (cdr region) nil))
8576 (defun gnus-mime-security-show-details (handle)
8577 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8579 (gnus-message 5 "No details.")
8580 (if gnus-mime-security-show-details-inline
8581 (let ((gnus-mime-security-button-pressed
8582 (not (get-text-property (point) 'gnus-mime-details)))
8583 (gnus-mime-security-button-line-format
8584 (get-text-property (point) 'gnus-line-format))
8585 (inhibit-read-only t))
8587 (while (eq (get-text-property (point) 'gnus-line-format)
8588 gnus-mime-security-button-line-format)
8592 (narrow-to-region (point) (point))
8593 (gnus-insert-mime-security-button handle))
8594 (delete-region (point)
8595 (or (text-property-not-all
8598 gnus-mime-security-button-line-format)
8601 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8602 (with-current-buffer gnus-mime-security-details-buffer
8605 (setq gnus-mime-security-details-buffer
8606 (gnus-get-buffer-create "*MIME Security Details*")))
8607 (with-current-buffer gnus-mime-security-details-buffer
8609 (goto-char (point-min)))
8610 (pop-to-buffer gnus-mime-security-details-buffer)))))
8612 (defun gnus-mime-security-press-button (handle)
8614 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8615 (gnus-mime-security-show-details handle)
8616 (gnus-mime-security-verify-or-decrypt handle))))
8618 (defun gnus-insert-mime-security-button (handle &optional displayed)
8619 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8622 (or (nth 2 (assoc protocol mm-verify-function-alist))
8623 (nth 2 (assoc protocol mm-decrypt-function-alist))
8625 (if (equal (car handle) "multipart/signed")
8626 " Signed" " Encrypted")
8629 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8632 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8633 gnus-tmp-pressed-details
8635 (setq gnus-tmp-details
8636 (if gnus-tmp-details
8637 (concat "\n" gnus-tmp-details)
8639 (setq gnus-tmp-pressed-details
8640 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8645 gnus-mime-security-button-line-format
8646 gnus-mime-security-button-line-format-alist
8647 `(keymap ,gnus-mime-security-button-map
8648 gnus-callback gnus-mime-security-press-button
8649 gnus-line-format ,gnus-mime-security-button-line-format
8650 gnus-mime-details ,gnus-mime-security-button-pressed
8651 article-type annotation
8654 ;; Exclude a newline.
8657 (when gnus-article-button-face
8658 (gnus-overlay-put (gnus-make-overlay b e nil t)
8659 'face gnus-article-button-face))
8660 (widget-convert-button
8663 :action 'gnus-widget-press-button
8664 :button-keymap gnus-mime-security-button-map
8667 ;; Needed to properly clear the message due to a bug in
8668 ;; wid-edit (XEmacs only).
8669 (when (boundp 'help-echo-owns-message)
8670 (setq help-echo-owns-message t))
8672 "%S: show detail; %S: more options"
8673 (aref gnus-mouse-2 0)
8674 (aref gnus-down-mouse-3 0))))))
8676 (defun gnus-mime-display-security (handle)
8678 (narrow-to-region (point) (point))
8679 (unless (gnus-unbuttonized-mime-type-p (car handle))
8680 (gnus-insert-mime-security-button handle))
8681 (gnus-mime-display-part (cadr handle))
8684 (unless (gnus-unbuttonized-mime-type-p (car handle))
8685 (let ((gnus-mime-security-button-line-format
8686 gnus-mime-security-button-end-line-format))
8687 (gnus-insert-mime-security-button handle)))
8688 (mm-set-handle-multipart-parameter
8690 (cons (set-marker (make-marker) (point-min))
8691 (set-marker (make-marker) (point-max))))
8692 (goto-char (point-max))))
8694 (defun gnus-mime-security-run-function (function)
8695 "Run FUNCTION with the security part under point."
8696 (gnus-article-check-buffer)
8697 (let ((data (get-text-property (point) 'gnus-data))
8699 (when (and (stringp (car-safe data))
8700 (setq buffer (mm-handle-multipart-original-buffer data))
8701 (setq handle (cadr data)))
8702 (if (bufferp (mm-handle-buffer handle))
8704 (setq handle (cons buffer (copy-sequence (cdr handle))))
8705 (mm-handle-set-undisplayer handle nil))
8706 (setq handle (mm-make-handle
8708 (mm-handle-multipart-ctl-parameter handle 'protocol)
8709 nil nil nil nil nil nil)))
8710 (funcall function handle))))
8712 (defun gnus-mime-security-save-part ()
8713 "Save the security part under point."
8715 (gnus-mime-security-run-function 'mm-save-part))
8717 (defun gnus-mime-security-pipe-part ()
8718 "Pipe the security part under point to a process."
8720 (gnus-mime-security-run-function 'mm-pipe-part))
8726 (run-hooks 'gnus-art-load-hook)
8728 ;;; gnus-art.el ends here