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)
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'parse-time-string "parse-time" nil nil)
53 (autoload 'ansi-color-apply-on-region "ansi-color")
54 (autoload 'mm-url-insert-file-contents-external "mm-url")
55 (autoload 'mm-extern-cache-contents "mm-extern")
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
121 (concat "^" header ":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
160 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
161 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
162 "Envelope-Sender" "Envelope-Recipients"))
163 "*All headers that start with this regexp will be hidden.
164 This variable can also be a list of regexps of headers to be ignored.
165 If `gnus-visible-headers' is non-nil, this variable will be ignored."
166 :type '(choice regexp
168 :group 'gnus-article-hiding)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 (repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 (const :tag "Use gnus-ignored-headers" nil)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group 'gnus-article-saving
512 (defcustom gnus-prompt-before-saving 'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group 'gnus-article-saving
521 :type '(choice (item always)
522 (item :tag "never" nil)
523 (sexp :tag "once" :format "%t\n" :value t)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group 'gnus-article-saving
536 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
537 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
538 "A function to save articles in your favorite 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 %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."
696 :group 'gnus-article-various)
698 (defcustom gnus-article-mode-hook nil
699 "*A hook for Gnus article mode."
701 :group 'gnus-article-various)
703 (when (featurep 'xemacs)
704 ;; Extracted from gnus-xmas-define in order to preserve user settings
705 (when (fboundp 'turn-off-scroll-in-place)
706 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
707 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
708 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
710 (defcustom gnus-article-menu-hook nil
711 "*Hook run after the creation of the article mode menu."
713 :group 'gnus-article-various)
715 (defcustom gnus-article-prepare-hook nil
716 "*A hook called after an article has been prepared in the article buffer."
718 :group 'gnus-article-various)
720 (defcustom gnus-copy-article-ignored-headers nil
721 "List of headers to be removed when copying an article.
722 Each element is a regular expression."
723 :version "23.1" ;; No Gnus
724 :type '(repeat regexp)
725 :group 'gnus-article-various)
727 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
728 "Gnus 5.10 (Emacs 22.1)")
731 '((t (:weight bold)))
732 "Face used for highlighting a button in the article buffer."
733 :group 'gnus-article-buttons)
735 (defcustom gnus-article-button-face 'gnus-button
736 "Face used for highlighting buttons in the article buffer.
738 An article button is a piece of text that you can activate by pressing
739 `RET' or `mouse-2' above it."
741 :group 'gnus-article-buttons)
743 (defcustom gnus-article-mouse-face 'highlight
744 "Face used for mouse highlighting in the article buffer.
746 Article buttons will be displayed in this face when the cursor is
749 :group 'gnus-article-buttons)
751 (defcustom gnus-signature-face 'gnus-signature
752 "Face used for highlighting a signature in the article buffer.
753 Obsolete; use the face `gnus-signature' for customizations instead."
755 :group 'gnus-article-highlight
756 :group 'gnus-article-signature)
758 (defface gnus-signature
761 "Face used for highlighting a signature in the article buffer."
762 :group 'gnus-article-highlight
763 :group 'gnus-article-signature)
764 ;; backward-compatibility alias
765 (put 'gnus-signature-face 'face-alias 'gnus-signature)
766 (put 'gnus-signature-face 'obsolete-face "22.1")
768 (defface gnus-header-from
771 (:foreground "PaleGreen1"))
774 (:foreground "red3"))
777 "Face used for displaying from headers."
778 :group 'gnus-article-headers
779 :group 'gnus-article-highlight)
780 ;; backward-compatibility alias
781 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
782 (put 'gnus-header-from-face 'obsolete-face "22.1")
784 (defface gnus-header-subject
787 (:foreground "SeaGreen1"))
790 (:foreground "red4"))
792 (:bold t :italic t)))
793 "Face used for displaying subject headers."
794 :group 'gnus-article-headers
795 :group 'gnus-article-highlight)
796 ;; backward-compatibility alias
797 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
798 (put 'gnus-header-subject-face 'obsolete-face "22.1")
800 (defface gnus-header-newsgroups
803 (:foreground "yellow" :italic t))
806 (:foreground "MidnightBlue" :italic t))
809 "Face used for displaying newsgroups headers.
810 In the default setup this face is only used for crossposted
812 :group 'gnus-article-headers
813 :group 'gnus-article-highlight)
814 ;; backward-compatibility alias
815 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
816 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
818 (defface gnus-header-name
821 (:foreground "SpringGreen2"))
824 (:foreground "maroon"))
827 "Face used for displaying header names."
828 :group 'gnus-article-headers
829 :group 'gnus-article-highlight)
830 ;; backward-compatibility alias
831 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
832 (put 'gnus-header-name-face 'obsolete-face "22.1")
834 (defface gnus-header-content
837 (:foreground "SpringGreen1" :italic t))
840 (:foreground "indianred4" :italic t))
842 (:italic t))) "Face used for displaying header content."
843 :group 'gnus-article-headers
844 :group 'gnus-article-highlight)
845 ;; backward-compatibility alias
846 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
847 (put 'gnus-header-content-face 'obsolete-face "22.1")
849 (defcustom gnus-header-face-alist
850 '(("From" nil gnus-header-from)
851 ("Subject" nil gnus-header-subject)
852 ("Newsgroups:.*," nil gnus-header-newsgroups)
853 ("" gnus-header-name gnus-header-content))
854 "*Controls highlighting of article headers.
856 An alist of the form (HEADER NAME CONTENT).
858 HEADER is a regular expression which should match the name of a
859 header and NAME and CONTENT are either face names or nil.
861 The name of each header field will be displayed using the face
862 specified by the first element in the list where HEADER matches
863 the header name and NAME is non-nil. Similarly, the content will
864 be displayed by the first non-nil matching CONTENT face."
865 :group 'gnus-article-headers
866 :group 'gnus-article-highlight
867 :type '(repeat (list (regexp :tag "Header")
869 (item :tag "skip" nil)
870 (face :value default))
871 (choice :tag "Content"
872 (item :tag "skip" nil)
873 (face :value default)))))
875 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
876 '((xface . (:face gnus-x-face)))
877 '((pbm . (:face gnus-x-face))
879 "Alist of image types and properties applied to Face and X-Face images.
882 ;; Specify the altitude of Face images in the From header.
883 \(setq gnus-face-properties-alist
884 '((pbm . (:face gnus-x-face :ascent 80))
885 (png . (:ascent 80))))
887 ;; Show Face images as pressed buttons.
888 \(setq gnus-face-properties-alist
889 '((pbm . (:face gnus-x-face :relief -2))
890 (png . (:relief -2))))
892 See the manual for the valid properties for various image types.
893 Currently, `pbm' is used for X-Face images and `png' is used for Face
894 images in Emacs. Only the `:face' property is effective on the `xface'
895 image type in XEmacs if it is built with the libcompface library."
896 :version "23.1" ;; No Gnus
897 :group 'gnus-article-headers
898 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
900 (defcustom gnus-article-decode-hook
901 '(article-decode-charset article-decode-encoded-words
902 article-decode-group-name article-decode-idna-rhs)
903 "*Hook run to decode charsets in articles."
904 :group 'gnus-article-headers
907 (defcustom gnus-display-mime-function 'gnus-display-mime
908 "Function to display MIME articles."
909 :group 'gnus-article-mime
912 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
913 "Function used to decode headers.")
915 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
916 "Function used to decode addresses.")
918 (defvar gnus-article-dumbquotes-map
938 "Table for MS-to-Latin1 translation.")
940 (defcustom gnus-ignored-mime-types nil
941 "List of MIME types that should be ignored by Gnus."
943 :group 'gnus-article-mime
944 :type '(repeat regexp))
946 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
947 "List of MIME types that should not be given buttons when rendered inline.
948 See also `gnus-buttonized-mime-types' which may override this variable.
949 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
951 :group 'gnus-article-mime
952 :type '(repeat regexp))
954 (defcustom gnus-buttonized-mime-types nil
955 "List of MIME types that should be given buttons when rendered inline.
956 If set, this variable overrides `gnus-unbuttonized-mime-types'.
957 To see e.g. security buttons you could set this to
958 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
959 this list to display radio buttons that allow you to choose one of two
960 media types those mails include. See also `mm-discouraged-alternatives'.
961 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
963 :group 'gnus-article-mime
964 :type '(repeat regexp))
966 (defcustom gnus-inhibit-mime-unbuttonizing nil
967 "If non-nil, all MIME parts get buttons.
968 When nil (the default value), then some MIME parts do not get buttons,
969 as described by the variables `gnus-buttonized-mime-types' and
970 `gnus-unbuttonized-mime-types'."
972 :group 'gnus-article-mime
975 (defcustom gnus-body-boundary-delimiter "_"
976 "String used to delimit header and body.
977 This variable is used by `gnus-article-treat-body-boundary' which can
978 be controlled by `gnus-treat-body-boundary'."
980 :group 'gnus-article-various
981 :type '(choice (item :tag "None" :value nil)
984 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
986 "Defines the location of the faces database.
987 For information on obtaining this database of pretty pictures, please
988 see http://www.cs.indiana.edu/picons/ftp/index.html"
990 :type '(repeat directory)
991 :link '(url-link :tag "download"
992 "http://www.cs.indiana.edu/picons/ftp/index.html")
993 :link '(custom-manual "(gnus)Picons")
996 (defun gnus-picons-installed-p ()
997 "Say whether picons are installed on your machine."
998 (let ((installed nil))
999 (dolist (database gnus-picon-databases)
1000 (when (file-exists-p database)
1001 (setq installed t)))
1004 (defcustom gnus-article-mime-part-function nil
1005 "Function called with a MIME handle as the argument.
1006 This is meant for people who want to do something automatic based
1007 on parts -- for instance, adding Vcard info to a database."
1008 :group 'gnus-article-mime
1009 :type '(choice (const nil)
1012 (defcustom gnus-mime-multipart-functions nil
1013 "An alist of MIME types to functions to display them."
1015 :group 'gnus-article-mime
1016 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1018 (defcustom gnus-article-date-headers '(combined-lapsed)
1019 "A list of Date header formats to display.
1020 Valid formats are `ut' (universal time), `local' (local time
1021 zone), `english' (readable English), `lapsed' (elapsed time),
1022 `combined-lapsed' (both the original date and the elapsed time),
1023 `original' (the original date header), `iso8601' (ISO8601
1024 format), and `user-defined' (a user-defined format defined by the
1025 `gnus-article-time-format' variable).
1027 You have as many date headers as you want in the article buffer.
1028 Some of these headers are updated automatically. See
1029 `gnus-article-update-date-headers' for details."
1031 :group 'gnus-article-headers
1033 (item :tag "Universal time (UT)" :value 'ut)
1034 (item :tag "Local time zone" :value 'local)
1035 (item :tag "Readable English" :value 'english)
1036 (item :tag "Elapsed time" :value 'lapsed)
1037 (item :tag "Original and elapsed time" :value 'combined-lapsed)
1038 (item :tag "Original date header" :value 'original)
1039 (item :tag "ISO8601 format" :value 'iso8601)
1040 (item :tag "User-defined" :value 'user-defined)))
1042 (defcustom gnus-article-update-date-headers nil
1043 "A number that says how often to update the date header (in seconds).
1044 If nil, don't update it at all."
1046 :group 'gnus-article-headers
1048 (item :tag "Don't update" :value nil)
1051 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1052 "Function called with a MIME handle as the argument.
1053 This is meant for people who want to view first matched part.
1054 For `undisplayed-alternative' (default), the first undisplayed
1055 part or alternative part is used. For `undisplayed', the first
1056 undisplayed part is used. For a function, the first part which
1057 the function return t is used. For nil, the first part is
1060 :group 'gnus-article-mime
1062 (item :tag "first" :value nil)
1063 (item :tag "undisplayed" :value undisplayed)
1064 (item :tag "undisplayed or alternative"
1065 :value undisplayed-alternative)
1068 (defcustom gnus-mime-action-alist
1069 '(("save to file" . gnus-mime-save-part)
1070 ("save and strip" . gnus-mime-save-part-and-strip)
1071 ("replace with file" . gnus-mime-replace-part)
1072 ("delete part" . gnus-mime-delete-part)
1073 ("display as text" . gnus-mime-inline-part)
1074 ("view the part" . gnus-mime-view-part)
1075 ("pipe to command" . gnus-mime-pipe-part)
1076 ("toggle display" . gnus-article-press-button)
1077 ("toggle display" . gnus-article-view-part-as-charset)
1078 ("view as type" . gnus-mime-view-part-as-type)
1079 ("view internally" . gnus-mime-view-part-internally)
1080 ("view externally" . gnus-mime-view-part-externally))
1081 "An alist of actions that run on the MIME attachment."
1082 :group 'gnus-article-mime
1083 :type '(repeat (cons (string :tag "name")
1086 (defcustom gnus-auto-select-part 1
1087 "Advance to next MIME part when deleting or stripping parts.
1089 When 0, point will be placed on the same part as before. When
1090 positive (negative), move point forward (backwards) this many
1091 parts. When nil, redisplay article."
1092 :version "23.1" ;; No Gnus
1093 :group 'gnus-article-mime
1094 :type '(choice (const nil :tag "Redisplay article.")
1095 (const 1 :tag "Next part.")
1096 (const 0 :tag "Current part.")
1100 ;;; The treatment variables
1103 (defvar gnus-part-display-hook nil
1104 "Hook called on parts that are to receive treatment.")
1106 (defvar gnus-article-treat-custom
1107 '(choice (const :tag "Off" nil)
1109 (const :tag "Header" head)
1110 (const :tag "First" first)
1111 (const :tag "Last" last)
1112 (integer :tag "Less")
1113 (repeat :tag "Groups" regexp)
1114 (sexp :tag "Predicate")))
1116 (defvar gnus-article-treat-head-custom
1117 '(choice (const :tag "Off" nil)
1118 (const :tag "Header" head)))
1120 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1124 (defvar gnus-inhibit-treatment nil
1125 "Whether to inhibit treatment.")
1127 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1128 "Highlight the signature.
1129 Valid values are nil, t, `head', `first', `last', an integer or a
1130 predicate. See Info node `(gnus)Customizing Articles'."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom)
1134 (put 'gnus-treat-highlight-signature 'highlight t)
1136 (defcustom gnus-treat-buttonize 100000
1138 Valid values are nil, t, `head', `first', `last', an integer or a
1139 predicate. See Info node `(gnus)Customizing Articles'."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-custom)
1143 (put 'gnus-treat-buttonize 'highlight t)
1145 (defcustom gnus-treat-buttonize-head 'head
1146 "Add buttons to the head.
1147 Valid values are nil, t, `head', `first', `last', an integer or a
1148 predicate. See Info node `(gnus)Customizing Articles'."
1149 :group 'gnus-article-treat
1150 :link '(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-head-custom)
1152 (put 'gnus-treat-buttonize-head 'highlight t)
1154 (defcustom gnus-treat-date 'head
1155 "Display dates according to the `gnus-article-date-headers' variable.
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-head-custom)
1163 (defcustom gnus-treat-emphasize 50000
1165 Valid values are nil, t, `head', `first', `last', an integer or a
1166 predicate. See Info node `(gnus)Customizing Articles'."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-custom)
1170 (put 'gnus-treat-emphasize 'highlight t)
1172 (defcustom gnus-treat-strip-cr nil
1173 "Remove carriage returns.
1174 Valid values are nil, t, `head', `first', `last', an integer or a
1175 predicate. See Info node `(gnus)Customizing Articles'."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-unsplit-urls nil
1182 "Remove newlines from within URLs.
1183 Valid values are nil, t, `head', `first', `last', an integer or a
1184 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-leading-whitespace nil
1191 "Remove leading whitespace in headers.
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-custom)
1199 (defcustom gnus-treat-hide-headers 'head
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-head-custom)
1207 (defcustom gnus-treat-hide-boring-headers nil
1208 "Hide boring headers.
1209 Valid values are nil, t, `head', `first', `last', an integer or a
1210 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-head-custom)
1215 (defcustom gnus-treat-hide-signature nil
1216 "Hide the signature.
1217 Valid values are nil, t, `head', `first', `last', an integer or a
1218 predicate. See Info node `(gnus)Customizing Articles'."
1219 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-custom)
1223 (defcustom gnus-treat-fill-article nil
1225 Valid values are nil, t, `head', `first', `last', an integer or a
1226 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom)
1231 (defcustom gnus-treat-hide-citation nil
1233 Valid values are nil, t, `head', `first', `last', an integer or a
1234 predicate. See Info node `(gnus)Customizing Articles'.
1236 See `gnus-article-highlight-citation' for variables used to
1237 control what it hides."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-hide-citation-maybe nil
1243 "Hide cited text according to certain conditions.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'.
1247 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1248 how to control what it hides."
1249 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom)
1253 (defcustom gnus-treat-strip-list-identifiers 'head
1254 "Strip list identifiers from `gnus-list-identifiers`.
1255 Valid values are nil, t, `head', `first', `last', an integer or a
1256 predicate. See Info node `(gnus)Customizing Articles'."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom)
1262 (gnus-define-group-parameter
1265 "Alist of regexps and correspondent identifiers."
1266 :variable-group gnus-article-washing
1268 '(choice :tag "Identifier"
1270 (symbol :tag "Item in `gnus-list-identifiers'" none)
1272 (const :tag "None" nil))
1274 "If non-nil, specify how to remove `identifiers' from articles' subject.
1276 Any symbol is used to look up a regular expression to match the
1277 banner in `gnus-list-identifiers'. A string is used as a regular
1278 expression to match the identifier directly.")
1280 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1281 "Gnus 5.10 (Emacs 22.1)")
1283 (defcustom gnus-treat-strip-pem nil
1284 "Strip PEM signatures.
1285 Valid values are nil, t, `head', `first', `last', an integer or a
1286 predicate. See Info node `(gnus)Customizing Articles'."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-custom)
1291 (defcustom gnus-treat-strip-banner t
1292 "Strip banners from articles.
1293 The banner to be stripped is specified in the `banner' group parameter.
1294 Valid values are nil, t, `head', `first', `last', an integer or a
1295 predicate. See Info node `(gnus)Customizing Articles'."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-highlight-headers 'head
1301 "Highlight the headers.
1302 Valid values are nil, t, `head', `first', `last', an integer or a
1303 predicate. See Info node `(gnus)Customizing Articles'."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-head-custom)
1307 (put 'gnus-treat-highlight-headers 'highlight t)
1309 (defcustom gnus-treat-highlight-citation t
1310 "Highlight cited text.
1311 Valid values are nil, t, `head', `first', `last', an integer or a
1312 predicate. See Info node `(gnus)Customizing Articles'."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1316 (put 'gnus-treat-highlight-citation 'highlight t)
1318 (defcustom gnus-treat-strip-headers-in-body t
1319 "Strip the X-No-Archive header line from the beginning of the body.
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-custom)
1327 (defcustom gnus-treat-strip-trailing-blank-lines nil
1328 "Strip trailing blank lines.
1329 Valid values are nil, t, `head', `first', `last', an integer or a
1330 predicate. See Info node `(gnus)Customizing Articles'.
1332 When set to t, it also strips trailing blanks in all MIME parts.
1333 Consider to use `last' instead."
1334 :group 'gnus-article-treat
1335 :link '(custom-manual "(gnus)Customizing Articles")
1336 :type gnus-article-treat-custom)
1338 (defcustom gnus-treat-strip-leading-blank-lines nil
1339 "Strip leading blank lines.
1340 Valid values are nil, t, `head', `first', `last', an integer or a
1341 predicate. See Info node `(gnus)Customizing Articles'.
1343 When set to t, it also strips trailing blanks in all MIME parts."
1344 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom)
1348 (defcustom gnus-treat-strip-multiple-blank-lines nil
1349 "Strip multiple blank lines.
1350 Valid values are nil, t, `head', `first', `last', an integer or a
1351 predicate. See Info node `(gnus)Customizing Articles'."
1352 :group 'gnus-article-treat
1353 :link '(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom)
1356 (defcustom gnus-treat-unfold-headers 'head
1357 "Unfold folded header lines.
1358 Valid values are nil, t, `head', `first', `last', an integer or a
1359 predicate. See Info node `(gnus)Customizing Articles'."
1361 :group 'gnus-article-treat
1362 :link '(custom-manual "(gnus)Customizing Articles")
1363 :type gnus-article-treat-custom)
1365 (defcustom gnus-article-unfold-long-headers nil
1366 "If non-nil, allow unfolding headers even if the header is long.
1367 If it is a regexp, only long headers matching this regexp are unfolded.
1368 If it is t, all long headers are unfolded.
1370 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1371 :version "23.1" ;; No Gnus
1372 :group 'gnus-article-treat
1373 :type '(choice (const nil)
1374 (const :tag "all" t)
1377 (defcustom gnus-treat-fold-headers nil
1379 Valid values are nil, t, `head', `first', `last', an integer or a
1380 predicate. See Info node `(gnus)Customizing Articles'."
1382 :group 'gnus-article-treat
1383 :link '(custom-manual "(gnus)Customizing Articles")
1384 :type gnus-article-treat-custom)
1386 (defcustom gnus-treat-fold-newsgroups 'head
1387 "Fold the Newsgroups and Followup-To headers.
1388 Valid values are nil, t, `head', `first', `last', an integer or a
1389 predicate. See Info node `(gnus)Customizing Articles'."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1395 (defcustom gnus-treat-overstrike t
1396 "Treat overstrike highlighting.
1397 Valid values are nil, t, `head', `first', `last', an integer or a
1398 predicate. See Info node `(gnus)Customizing Articles'."
1399 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom)
1402 (put 'gnus-treat-overstrike 'highlight t)
1404 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1405 "Treat ANSI SGR control sequences.
1406 Valid values are nil, t, `head', `first', `last', an integer or a
1407 predicate. See Info node `(gnus)Customizing Articles'."
1408 :group 'gnus-article-treat
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (make-obsolete-variable 'gnus-treat-display-xface
1413 'gnus-treat-display-x-face "Emacs 22.1")
1415 (defcustom gnus-treat-display-x-face
1416 (and (not noninteractive)
1417 (gnus-image-type-available-p 'xbm)
1418 (if (featurep 'xemacs)
1421 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1422 (executable-find "icontopbm"))
1423 ;; shell-command-to-string may signal an error, e.g. if
1424 ;; shell-file-name is not found.
1427 "Display X-Face headers.
1428 Valid values are nil and `head'.
1429 See Info node `(gnus)Customizing Articles' and Info node
1430 `(gnus)X-Face' for details."
1431 :group 'gnus-article-treat
1433 :link '(custom-manual "(gnus)Customizing Articles")
1434 :link '(custom-manual "(gnus)X-Face")
1435 :type gnus-article-treat-head-custom
1436 :set (lambda (symbol value)
1439 (cond ((or (boundp symbol) (get symbol 'saved-value))
1441 ((boundp 'gnus-treat-display-xface)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (default-value 'gnus-treat-display-xface))
1446 ((get 'gnus-treat-display-xface 'saved-value)
1448 ** gnus-treat-display-xface is an obsolete variable;\
1449 use gnus-treat-display-x-face instead")
1450 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1453 (put 'gnus-treat-display-x-face 'highlight t)
1455 (defcustom gnus-treat-display-face
1456 (and (not noninteractive)
1457 (gnus-image-type-available-p 'png)
1459 "Display Face headers.
1460 Valid values are nil, t, `head', `first', `last', an integer or a
1461 predicate. See Info node `(gnus)Customizing Articles' and Info
1462 node `(gnus)Face' for details."
1463 :group 'gnus-article-treat
1465 :link '(custom-manual "(gnus)Customizing Articles")
1466 :link '(custom-manual "(gnus)X-Face")
1467 :type gnus-article-treat-head-custom)
1468 (put 'gnus-treat-display-face 'highlight t)
1470 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1472 Valid values are nil, t, `head', `first', `last', an integer or a
1473 predicate. See Info node `(gnus)Customizing Articles' and Info
1474 node `(gnus)Smileys' for details."
1475 :group 'gnus-article-treat
1477 :link '(custom-manual "(gnus)Customizing Articles")
1478 :link '(custom-manual "(gnus)Smileys")
1479 :type gnus-article-treat-custom)
1480 (put 'gnus-treat-display-smileys 'highlight t)
1482 (defcustom gnus-treat-from-picon
1483 (if (and (gnus-image-type-available-p 'xpm)
1484 (gnus-picons-installed-p))
1486 "Display picons in the From header.
1487 Valid values are nil, t, `head', `first', `last', an integer or a
1488 predicate. See Info node `(gnus)Customizing Articles' and Info
1489 node `(gnus)Picons' for details."
1491 :group 'gnus-article-treat
1493 :link '(custom-manual "(gnus)Customizing Articles")
1494 :link '(custom-manual "(gnus)Picons")
1495 :type gnus-article-treat-head-custom)
1496 (put 'gnus-treat-from-picon 'highlight t)
1498 (defcustom gnus-treat-mail-picon
1499 (if (and (gnus-image-type-available-p 'xpm)
1500 (gnus-picons-installed-p))
1502 "Display picons in To and Cc headers.
1503 Valid values are nil, t, `head', `first', `last', an integer or a
1504 predicate. See Info node `(gnus)Customizing Articles' and Info
1505 node `(gnus)Picons' for details."
1507 :group 'gnus-article-treat
1509 :link '(custom-manual "(gnus)Customizing Articles")
1510 :link '(custom-manual "(gnus)Picons")
1511 :type gnus-article-treat-head-custom)
1512 (put 'gnus-treat-mail-picon 'highlight t)
1514 (defcustom gnus-treat-newsgroups-picon
1515 (if (and (gnus-image-type-available-p 'xpm)
1516 (gnus-picons-installed-p))
1518 "Display picons in the Newsgroups and Followup-To headers.
1519 Valid values are nil, t, `head', `first', `last', an integer or a
1520 predicate. See Info node `(gnus)Customizing Articles' and Info
1521 node `(gnus)Picons' for details."
1523 :group 'gnus-article-treat
1525 :link '(custom-manual "(gnus)Customizing Articles")
1526 :link '(custom-manual "(gnus)Picons")
1527 :type gnus-article-treat-head-custom)
1528 (put 'gnus-treat-newsgroups-picon 'highlight t)
1530 (defcustom gnus-treat-from-gravatar nil
1531 "Display gravatars in the From header.
1532 Valid values are nil, t, `head', `first', `last', an integer or a
1533 predicate. See Info node `(gnus)Customizing Articles' and Info
1534 node `(gnus)Gravatars' for details."
1536 :group 'gnus-article-treat
1537 :group 'gnus-gravatar
1538 :link '(custom-manual "(gnus)Customizing Articles")
1539 :link '(custom-manual "(gnus)Gravatars")
1540 :type gnus-article-treat-head-custom)
1541 (put 'gnus-treat-from-gravatar 'highlight t)
1543 (defcustom gnus-treat-mail-gravatar nil
1544 "Display gravatars in To and Cc headers.
1545 Valid values are nil, t, `head', `first', `last', an integer or a
1546 predicate. See Info node `(gnus)Customizing Articles' and Info
1547 node `(gnus)Gravatars' for details."
1549 :group 'gnus-article-treat
1550 :group 'gnus-gravatar
1551 :link '(custom-manual "(gnus)Customizing Articles")
1552 :link '(custom-manual "(gnus)Gravatars")
1553 :type gnus-article-treat-head-custom)
1554 (put 'gnus-treat-mail-gravatar 'highlight t)
1556 (defcustom gnus-treat-body-boundary
1557 (if (or gnus-treat-newsgroups-picon
1558 gnus-treat-mail-picon
1559 gnus-treat-from-picon
1560 gnus-treat-from-gravatar
1561 gnus-treat-mail-gravatar)
1562 ;; If there's much decoration, the user might prefer a boundary.
1565 "Draw a boundary at the end of the headers.
1566 Valid values are nil and `head'.
1567 See Info node `(gnus)Customizing Articles' for details."
1569 :group 'gnus-article-treat
1570 :link '(custom-manual "(gnus)Customizing Articles")
1571 :type gnus-article-treat-head-custom)
1573 (defcustom gnus-treat-capitalize-sentences nil
1574 "Capitalize sentence-starting words.
1575 Valid values are nil, t, `head', `first', `last', an integer or a
1576 predicate. See Info node `(gnus)Customizing Articles'."
1578 :group 'gnus-article-treat
1579 :link '(custom-manual "(gnus)Customizing Articles")
1580 :type gnus-article-treat-custom)
1582 (defcustom gnus-treat-wash-html nil
1584 Valid values are nil, t, `head', `first', `last', an integer or a
1585 predicate. See Info node `(gnus)Customizing Articles'."
1587 :group 'gnus-article-treat
1588 :link '(custom-manual "(gnus)Customizing Articles")
1589 :type gnus-article-treat-custom)
1591 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
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-x-pgp-sig nil
1602 To automatically treat X-PGP-Sig, set it to head.
1603 Valid values are nil, t, `head', `first', `last', an integer or a
1604 predicate. See Info node `(gnus)Customizing Articles'."
1606 :group 'gnus-article-treat
1607 :group 'mime-security
1608 :link '(custom-manual "(gnus)Customizing Articles")
1609 :type gnus-article-treat-custom)
1611 (defvar gnus-article-encrypt-protocol-alist
1612 '(("PGP" . mml2015-self-encrypt)))
1614 ;; Set to nil if more than one protocol added to
1615 ;; gnus-article-encrypt-protocol-alist.
1616 (defcustom gnus-article-encrypt-protocol "PGP"
1617 "The protocol used for encrypt articles.
1618 It is a string, such as \"PGP\". If nil, ask user."
1621 :group 'mime-security)
1623 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1624 (mm-coding-system-p 'utf-8)
1625 (executable-find idna-program))
1626 "Whether IDNA decoding of headers is used when viewing messages.
1627 This requires GNU Libidn, and by default only enabled if it is found."
1629 :group 'gnus-article-headers
1632 (defcustom gnus-article-over-scroll nil
1633 "If non-nil, allow scrolling the article buffer even when there no more text."
1635 :group 'gnus-article
1638 (defcustom gnus-inhibit-images nil
1639 "Non-nil means inhibit displaying of images inline in the article body."
1641 :group 'gnus-article
1644 (defcustom gnus-blocked-images 'gnus-block-private-groups
1645 "Images that have URLs matching this regexp will be blocked.
1646 This can also be a function to be evaluated. If so, it will be
1647 called with the group name as the parameter, and should return a
1653 ;;; Internal variables
1655 (defvar gnus-english-month-names
1656 '("January" "February" "March" "April" "May" "June" "July" "August"
1657 "September" "October" "November" "December"))
1659 (defvar article-goto-body-goes-to-point-min-p nil)
1660 (defvar gnus-article-wash-types nil)
1661 (defvar gnus-article-emphasis-alist nil)
1662 (defvar gnus-article-image-alist nil)
1664 (defvar gnus-article-mime-handle-alist-1 nil)
1665 (defvar gnus-treatment-function-alist
1666 '((gnus-treat-strip-cr gnus-article-remove-cr)
1667 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1668 (gnus-treat-strip-banner gnus-article-strip-banner)
1669 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1670 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1671 (gnus-treat-buttonize gnus-article-add-buttons)
1672 (gnus-treat-fill-article gnus-article-fill-cited-article)
1673 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1674 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1675 (gnus-treat-display-x-face gnus-article-display-x-face)
1676 (gnus-treat-display-face gnus-article-display-face)
1677 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1678 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1679 (gnus-treat-hide-signature gnus-article-hide-signature)
1680 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1681 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1682 (gnus-treat-from-picon gnus-treat-from-picon)
1683 (gnus-treat-mail-picon gnus-treat-mail-picon)
1684 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1685 (gnus-treat-strip-pem gnus-article-hide-pem)
1686 (gnus-treat-date gnus-article-treat-date)
1687 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1688 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1689 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1690 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1691 (gnus-treat-strip-trailing-blank-lines
1692 gnus-article-remove-trailing-blank-lines)
1693 (gnus-treat-strip-leading-blank-lines
1694 gnus-article-strip-leading-blank-lines)
1695 (gnus-treat-strip-multiple-blank-lines
1696 gnus-article-strip-multiple-blank-lines)
1697 (gnus-treat-overstrike gnus-article-treat-overstrike)
1698 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1699 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1700 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1701 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1702 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1703 (gnus-treat-display-smileys gnus-treat-smiley)
1704 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1705 (gnus-treat-wash-html gnus-article-wash-html)
1706 (gnus-treat-emphasize gnus-article-emphasize)
1707 (gnus-treat-hide-citation gnus-article-hide-citation)
1708 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1709 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1710 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1712 (defvar gnus-article-mime-handle-alist nil)
1713 (defvar article-lapsed-timer nil)
1714 (defvar gnus-article-current-summary nil)
1716 (defvar gnus-article-mode-syntax-table
1717 (let ((table (copy-syntax-table text-mode-syntax-table)))
1718 ;; This causes the citation match run O(2^n).
1719 ;; (modify-syntax-entry ?- "w" table)
1720 (modify-syntax-entry ?> ")<" table)
1721 (modify-syntax-entry ?< "(>" table)
1722 ;; make M-. in article buffers work for `foo' strings
1723 (modify-syntax-entry ?' " " table)
1724 (modify-syntax-entry ?` " " table)
1726 "Syntax table used in article mode buffers.
1727 Initialized from `text-mode-syntax-table.")
1729 (defvar gnus-save-article-buffer nil)
1731 (defvar gnus-number-of-articles-to-be-saved nil)
1733 (defvar gnus-inhibit-hiding nil)
1735 (defvar gnus-article-edit-mode nil)
1737 ;;; Macros for dealing with the article buffer.
1739 (defmacro gnus-with-article-headers (&rest forms)
1740 `(with-current-buffer gnus-article-buffer
1742 (let ((inhibit-read-only t)
1743 (inhibit-point-motion-hooks t)
1744 (case-fold-search t))
1745 (article-narrow-to-head)
1748 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1749 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1751 (defmacro gnus-with-article-buffer (&rest forms)
1752 `(when (buffer-live-p (get-buffer gnus-article-buffer))
1753 (with-current-buffer gnus-article-buffer
1754 (let ((inhibit-read-only t))
1757 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1758 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1760 (defun gnus-article-goto-header (header)
1761 "Go to HEADER, which is a regular expression."
1762 (re-search-forward (concat "^\\(" header "\\):") nil t))
1764 (defsubst gnus-article-hide-text (b e props)
1765 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1766 (gnus-add-text-properties-when 'article-type nil b e props)
1767 (when (memq 'intangible props)
1769 (max (1- b) (point-min))
1770 b 'intangible (cddr (memq 'intangible props)))))
1772 (defsubst gnus-article-unhide-text (b e)
1773 "Remove hidden text properties from region between B and E."
1774 (remove-text-properties b e gnus-hidden-properties)
1775 (when (memq 'intangible gnus-hidden-properties)
1776 (put-text-property (max (1- b) (point-min))
1777 b 'intangible nil)))
1779 (defun gnus-article-hide-text-type (b e type)
1780 "Hide text of TYPE between B and E."
1781 (gnus-add-wash-type type)
1782 (gnus-article-hide-text
1783 b e (cons 'article-type (cons type gnus-hidden-properties))))
1785 (defun gnus-article-unhide-text-type (b e type)
1786 "Unhide text of TYPE between B and E."
1787 (gnus-delete-wash-type type)
1788 (remove-text-properties
1789 b e (cons 'article-type (cons type gnus-hidden-properties)))
1790 (when (memq 'intangible gnus-hidden-properties)
1791 (put-text-property (max (1- b) (point-min))
1792 b 'intangible nil)))
1794 (defun gnus-article-hide-text-of-type (type)
1795 "Hide text of TYPE in the current buffer."
1797 (let ((b (point-min))
1799 (while (setq b (text-property-any b e 'article-type type))
1800 (add-text-properties b (incf b) gnus-hidden-properties)))))
1802 (defun gnus-article-delete-text-of-type (type)
1803 "Delete text of TYPE in the current buffer."
1805 (let ((b (point-min)))
1806 (if (eq type 'multipart)
1807 ;; Remove MIME buttons associated with multipart/alternative parts.
1810 (while (if (get-text-property (point) 'gnus-part)
1812 (when (setq b (next-single-property-change (point)
1817 (skip-chars-forward "\n")
1818 (when (eq (get-text-property b 'article-type) 'multipart)
1819 (delete-region b (point)))))
1820 (while (setq b (text-property-any b (point-max) 'article-type type))
1822 b (or (text-property-not-all b (point-max) 'article-type type)
1825 (defun gnus-article-delete-invisible-text ()
1826 "Delete all invisible text in the current buffer."
1828 (let ((b (point-min)))
1829 (while (setq b (text-property-any b (point-max) 'invisible t))
1831 b (or (text-property-not-all b (point-max) 'invisible t)
1834 (defun gnus-article-text-type-exists-p (type)
1835 "Say whether any text of type TYPE exists in the buffer."
1836 (text-property-any (point-min) (point-max) 'article-type type))
1838 (defsubst gnus-article-header-rank ()
1839 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1840 (let ((list gnus-sorted-header-list)
1843 (if (looking-at (car list))
1845 (setq list (cdr list))
1849 (defun article-hide-headers (&optional arg delete)
1850 "Hide unwanted headers and possibly sort them as well."
1852 ;; This function might be inhibited.
1853 (unless gnus-inhibit-hiding
1854 (let ((inhibit-read-only t)
1855 (case-fold-search t)
1856 (max (1+ (length gnus-sorted-header-list)))
1857 (inhibit-point-motion-hooks t)
1858 (cur (current-buffer))
1859 ignored visible beg)
1861 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1862 ;; group parameters, so we should go to the summary buffer.
1865 (progn (set-buffer gnus-summary-buffer) t)
1867 (setq ignored (when (not gnus-visible-headers)
1868 (cond ((stringp gnus-ignored-headers)
1869 gnus-ignored-headers)
1870 ((listp gnus-ignored-headers)
1871 (mapconcat 'identity
1872 gnus-ignored-headers
1874 visible (cond ((stringp gnus-visible-headers)
1875 gnus-visible-headers)
1876 ((and gnus-visible-headers
1877 (listp gnus-visible-headers))
1878 (mapconcat 'identity
1879 gnus-visible-headers
1883 ;; First we narrow to just the headers.
1884 (article-narrow-to-head)
1885 ;; Hide any "From " lines at the beginning of (mail) articles.
1886 (while (looking-at "From ")
1889 (delete-region (point-min) (point)))
1890 ;; Then treat the rest of the header lines.
1891 ;; Then we use the two regular expressions
1892 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1893 ;; select which header lines is to remain visible in the
1895 (while (re-search-forward "^[^ \t:]*:" nil t)
1897 ;; Mark the rank of the header.
1899 (point) (1+ (point)) 'message-rank
1900 (if (or (and visible (looking-at visible))
1902 (not (looking-at ignored))))
1903 (gnus-article-header-rank)
1906 (message-sort-headers-1)
1907 (when (setq beg (text-property-any
1908 (point-min) (point-max) 'message-rank (+ 2 max)))
1909 ;; We delete the unwanted headers.
1910 (gnus-add-wash-type 'headers)
1911 (add-text-properties (point-min) (+ 5 (point-min))
1912 '(article-type headers dummy-invisible t))
1913 (delete-region beg (point-max))))))))
1915 (defun article-hide-boring-headers (&optional arg)
1916 "Toggle hiding of headers that aren't very interesting.
1917 If given a negative prefix, always show; if given a positive prefix,
1919 (interactive (gnus-article-hidden-arg))
1920 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1921 (not gnus-show-all-headers))
1924 (let ((inhibit-read-only t)
1925 (inhibit-point-motion-hooks t))
1926 (article-narrow-to-head)
1927 (dolist (elem gnus-boring-article-headers)
1928 (goto-char (point-min))
1930 ;; Hide empty headers.
1932 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1934 (gnus-article-hide-text-type
1938 (if (re-search-forward "^[^ \t]" nil t)
1942 ;; Hide boring Newsgroups header.
1943 ((eq elem 'newsgroups)
1944 (when (gnus-string-equal
1945 (gnus-fetch-field "newsgroups")
1946 (gnus-group-real-name
1947 (if (boundp 'gnus-newsgroup-name)
1950 (gnus-article-hide-header "newsgroups")))
1951 ((eq elem 'to-address)
1952 (let ((to (message-fetch-field "to"))
1954 (gnus-parameter-to-address
1955 (if (boundp 'gnus-newsgroup-name)
1956 gnus-newsgroup-name ""))))
1957 (when (and to to-address
1960 ;; only one address in To
1961 (nth 1 (mail-extract-address-components to))
1963 (gnus-article-hide-header "to"))))
1965 (let ((to (message-fetch-field "to"))
1967 (gnus-parameter-to-list
1968 (if (boundp 'gnus-newsgroup-name)
1969 gnus-newsgroup-name ""))))
1970 (when (and to to-list
1973 ;; only one address in To
1974 (nth 1 (mail-extract-address-components to))
1976 (gnus-article-hide-header "to"))))
1978 (let ((cc (message-fetch-field "cc"))
1980 (gnus-parameter-to-list
1981 (if (boundp 'gnus-newsgroup-name)
1982 gnus-newsgroup-name ""))))
1983 (when (and cc to-list
1986 ;; only one address in CC
1987 (nth 1 (mail-extract-address-components cc))
1989 (gnus-article-hide-header "cc"))))
1990 ((eq elem 'followup-to)
1991 (when (gnus-string-equal
1992 (message-fetch-field "followup-to")
1993 (message-fetch-field "newsgroups"))
1994 (gnus-article-hide-header "followup-to")))
1995 ((eq elem 'reply-to)
1996 (if (gnus-group-find-parameter
1997 gnus-newsgroup-name 'broken-reply-to)
1998 (gnus-article-hide-header "reply-to")
1999 (let ((from (message-fetch-field "from"))
2000 (reply-to (message-fetch-field "reply-to")))
2007 (lambda (x) (downcase (cadr x)))
2008 (mail-extract-address-components from t))
2011 (lambda (x) (downcase (cadr x)))
2012 (mail-extract-address-components reply-to t))
2014 (gnus-article-hide-header "reply-to")))))
2016 (let ((date (with-current-buffer gnus-original-article-buffer
2017 ;; If date in `gnus-article-buffer' is localized
2018 ;; (`gnus-treat-date-user-defined'),
2019 ;; `days-between' might fail.
2020 (message-fetch-field "date"))))
2022 (< (days-between (current-time-string) date)
2024 (gnus-article-hide-header "date"))))
2026 (let ((to (message-fetch-field "to"))
2027 (cc (message-fetch-field "cc")))
2028 (when (> (length to) 1024)
2029 (gnus-article-hide-header "to"))
2030 (when (> (length cc) 1024)
2031 (gnus-article-hide-header "cc"))))
2035 (goto-char (point-min))
2036 (while (re-search-forward "^to:" nil t)
2037 (setq to-count (1+ to-count)))
2038 (when (> to-count 1)
2039 (while (> to-count 0)
2040 (goto-char (point-min))
2042 (re-search-forward "^to:" nil nil to-count)
2044 (narrow-to-region (point) (point-max))
2045 (gnus-article-hide-header "to"))
2046 (setq to-count (1- to-count))))
2047 (goto-char (point-min))
2048 (while (re-search-forward "^cc:" nil t)
2049 (setq cc-count (1+ cc-count)))
2050 (when (> cc-count 1)
2051 (while (> cc-count 0)
2052 (goto-char (point-min))
2054 (re-search-forward "^cc:" nil nil cc-count)
2056 (narrow-to-region (point) (point-max))
2057 (gnus-article-hide-header "cc"))
2058 (setq cc-count (1- cc-count)))))))))))))
2060 (defun gnus-article-hide-header (header)
2062 (goto-char (point-min))
2063 (when (re-search-forward (concat "^" header ":") nil t)
2064 (gnus-article-hide-text-type
2068 (if (re-search-forward "^[^ \t]" nil t)
2073 (defvar gnus-article-normalized-header-length 40
2074 "Length of normalized headers.")
2076 (defun article-normalize-headers ()
2077 "Make all header lines 40 characters long."
2079 (let ((inhibit-read-only t)
2083 (article-narrow-to-head)
2086 ((< (setq column (- (point-at-eol) (point)))
2087 gnus-article-normalized-header-length)
2089 (insert (make-string
2090 (- gnus-article-normalized-header-length column)
2092 ((> column gnus-article-normalized-header-length)
2093 (gnus-put-text-property
2095 (forward-char gnus-article-normalized-header-length)
2102 (forward-line 1))))))
2104 (defun article-treat-dumbquotes ()
2105 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2106 Note that this function guesses whether a character is a sm*rtq**t* or
2107 not, so it should only be used interactively.
2109 Sm*rtq**t*s are M****s***'s unilateral extension to the
2110 iso-8859-1 character map in an attempt to provide more quoting
2111 characters. If you see something like \\222 or \\264 where
2112 you're expecting some kind of apostrophe or quotation mark, then
2115 (article-translate-strings gnus-article-dumbquotes-map))
2117 (defvar org-entities)
2119 (defun article-treat-non-ascii ()
2120 "Translate many Unicode characters into their ASCII equivalents."
2122 (require 'org-entities)
2123 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2124 (dolist (elem org-entities)
2125 (when (and (listp elem)
2126 (= (length (nth 6 elem)) 1))
2127 (if (featurep 'xemacs)
2128 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2129 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2131 (when (article-goto-body)
2132 (let ((inhibit-read-only t)
2135 (if (not (setq replace (if (featurep 'xemacs)
2136 (get-char-table (following-char) table)
2137 (aref table (following-char)))))
2140 (setq props (text-properties-at (point)))
2142 (add-text-properties (point) (progn (insert replace) (point))
2144 (insert replace)))))))))
2146 (defun article-translate-characters (from to)
2147 "Translate all characters in the body of the article according to FROM and TO.
2148 FROM is a string of characters to translate from; to is a string of
2149 characters to translate to."
2151 (when (article-goto-body)
2152 (let ((inhibit-read-only t)
2153 (x (make-string 225 ?x))
2155 (while (< (incf i) (length x))
2158 (while (< i (length from))
2159 (aset x (aref from i) (aref to i))
2161 (translate-region (point) (point-max) x)))))
2163 (defun article-translate-strings (map)
2164 "Translate all string in the body of the article according to MAP.
2165 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2167 (when (article-goto-body)
2168 (let ((inhibit-read-only t))
2170 (let ((from (car elem))
2174 (while (search-forward from nil t)
2177 (if (eq (following-char) from)
2181 (forward-char 1)))))))))))
2183 (defun article-treat-overstrike ()
2184 "Translate overstrikes into bold text."
2187 (when (article-goto-body)
2188 (let ((inhibit-read-only t))
2189 (while (search-forward "\b" nil t)
2190 (let ((next (char-after))
2191 (previous (char-after (- (point) 2))))
2192 ;; We do the boldification/underlining by hiding the
2193 ;; overstrikes and putting the proper text property
2197 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2198 (put-text-property (point) (1+ (point)) 'face 'bold))
2200 (gnus-article-hide-text-type
2201 (1- (point)) (1+ (point)) 'overstrike)
2203 (- (point) 2) (1- (point)) 'face 'underline))
2205 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2207 (point) (1+ (point)) 'face 'underline)))))))))
2209 (defun article-treat-ansi-sequences ()
2210 "Translate ANSI SGR control sequences into overlays or extents."
2213 (when (article-goto-body)
2214 (let ((inhibit-read-only t))
2215 (ansi-color-apply-on-region (point) (point-max))))))
2217 (defun gnus-article-treat-unfold-headers ()
2218 "Unfold folded message headers.
2219 Only the headers that fit into the current window width will be
2222 (gnus-with-article-headers
2226 (mail-header-narrow-to-field)
2227 (let* ((header (buffer-string))
2229 (or (equal gnus-article-unfold-long-headers t)
2230 (and (stringp gnus-article-unfold-long-headers)
2231 (string-match gnus-article-unfold-long-headers header)))))
2234 (goto-char (point-min))
2235 (while (re-search-forward "\n[\t ]" nil t)
2236 (replace-match " " t t)))
2237 (setq length (- (point-max) (point-min) 1))
2238 (when (or unfoldable
2239 (< length (window-width)))
2240 (while (re-search-forward "\n[\t ]" nil t)
2241 (replace-match " " t t))))
2242 (goto-char (point-max)))))))
2244 (defun gnus-article-treat-fold-headers ()
2245 "Fold message headers."
2247 (gnus-with-article-headers
2250 (mail-header-narrow-to-field)
2251 (mail-header-fold-field)
2252 (goto-char (point-max))))))
2254 (defun gnus-treat-smiley ()
2255 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2257 (gnus-with-article-buffer
2258 (if (memq 'smiley gnus-article-wash-types)
2259 (gnus-delete-images 'smiley)
2261 (let ((images (smiley-region (point) (point-max))))
2263 (gnus-add-wash-type 'smiley)
2264 (dolist (image images)
2265 (gnus-add-image 'smiley image)))))))
2267 (defun gnus-article-remove-images ()
2268 "Remove all images from the article buffer."
2270 (gnus-with-article-buffer
2273 (dolist (elem gnus-article-image-alist)
2274 (gnus-delete-images (car elem))))))
2276 (autoload 'w3m-toggle-inline-images "w3m")
2278 (defun gnus-article-show-images ()
2279 "Show any images that are in the HTML-rendered article buffer.
2280 This only works if the article in question is HTML."
2282 (gnus-with-article-buffer
2285 (if (eq mm-text-html-renderer 'w3m)
2286 (let ((mm-inline-text-html-with-images nil))
2287 (w3m-toggle-inline-images))
2288 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2290 (destructuring-bind (start end function) region
2291 (funcall function (get-text-property start 'image-url)
2294 (defun gnus-article-treat-fold-newsgroups ()
2295 "Unfold folded message headers.
2296 Only the headers that fit into the current window width will be
2299 (gnus-with-article-headers
2300 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2302 (mail-header-narrow-to-field)
2303 (while (re-search-forward ", *" nil t)
2304 (replace-match ", " t t))
2305 (mail-header-fold-field)
2306 (goto-char (point-max))))))
2308 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2309 "Value of `truncate-lines' in Gnus Article buffer.
2310 Valid values are nil, t, `head', `first', `last', an integer or a
2311 predicate. See Info node `(gnus)Customizing Articles'."
2312 :version "23.1" ;; No Gnus
2313 :group 'gnus-article
2314 ;; :link '(custom-manual "(gnus)Customizing Articles")
2317 (defun gnus-article-toggle-truncate-lines (&optional arg)
2318 "Toggle whether to fold or truncate long lines in article the buffer.
2319 If ARG is non-nil and not a number, toggle
2320 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2321 long lines if and only if arg is positive."
2324 ((and (numberp arg) (> arg 0))
2325 (setq gnus-article-truncate-lines t))
2327 (setq gnus-article-truncate-lines nil))
2329 (setq gnus-article-truncate-lines
2330 (not gnus-article-truncate-lines))))
2331 (gnus-with-article-buffer
2333 ((and (numberp arg) (> arg 0))
2334 (setq truncate-lines nil))
2336 (setq truncate-lines t)))
2337 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2338 ;; `toggle-truncate-lines' needs an argument.
2339 (toggle-truncate-lines)))
2341 (defun gnus-article-treat-body-boundary ()
2342 "Place a boundary line at the end of the headers."
2344 (when (and gnus-body-boundary-delimiter
2345 (> (length gnus-body-boundary-delimiter) 0))
2346 (gnus-with-article-headers
2347 (goto-char (point-max))
2348 (let ((start (point)))
2349 (insert "X-Boundary: ")
2350 (gnus-add-text-properties start (point) '(invisible t intangible t))
2351 (insert (let (str (max (window-width)))
2352 (if (featurep 'xemacs)
2353 (setq max (1- max)))
2354 (while (>= max (length str))
2355 (setq str (concat str gnus-body-boundary-delimiter)))
2356 (substring str 0 max))
2358 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2360 (defun article-fill-long-lines ()
2361 "Fill lines that are wider than the window width."
2364 (let ((inhibit-read-only t)
2365 (width (window-width (get-buffer-window (current-buffer)))))
2368 (let ((adaptive-fill-mode nil)) ;Why? -sm
2371 (when (>= (current-column) (min fill-column width))
2372 (narrow-to-region (min (1+ (point)) (point-max))
2374 (let ((goback (point-marker)))
2375 (fill-paragraph nil)
2376 (goto-char (marker-position goback)))
2378 (forward-line 1)))))))
2380 (defun article-capitalize-sentences ()
2381 "Capitalize the first word in each sentence."
2384 (let ((inhibit-read-only t)
2385 (paragraph-start "^[\n\^L]"))
2389 (forward-sentence)))))
2391 (defun article-remove-cr ()
2392 "Remove trailing CRs and then translate remaining CRs into LFs."
2395 (let ((inhibit-read-only t))
2396 (goto-char (point-min))
2397 (while (re-search-forward "\r+$" nil t)
2398 (replace-match "" t t))
2399 (goto-char (point-min))
2400 (while (search-forward "\r" nil t)
2401 (replace-match "\n" t t)))))
2403 (defun article-remove-trailing-blank-lines ()
2404 "Remove all trailing blank lines from the article."
2407 (let ((inhibit-read-only t))
2408 (goto-char (point-max))
2412 (while (and (not (bobp))
2413 (looking-at "^[ \t]*$")
2414 (not (gnus-annotation-in-region-p
2415 (point) (point-at-eol))))
2420 (defvar gnus-face-properties-alist)
2422 (defun article-display-face (&optional force)
2423 "Display any Face headers in the header."
2424 (interactive (list 'force))
2425 (let ((wash-face-p buffer-read-only))
2426 (gnus-with-article-headers
2427 ;; When displaying parts, this function can be called several times on
2428 ;; the same article, without any intended toggle semantic (as typing `W
2429 ;; D d' would have). So face deletion must occur only when we come from
2430 ;; an interactive command, that is when the *Article* buffer is
2432 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2433 (gnus-delete-images 'face)
2434 (let ((from (message-fetch-field "from"))
2436 (save-current-buffer
2437 (when (and wash-face-p
2438 (gnus-buffer-live-p gnus-original-article-buffer)
2439 (not (re-search-forward "^Face:[\t ]*" nil t)))
2440 (set-buffer gnus-original-article-buffer))
2442 (mail-narrow-to-head)
2444 ;; Check whether this face is censored.
2445 (not (and gnus-article-x-face-too-ugly
2447 (setq from (message-fetch-field "from")))
2448 (string-match gnus-article-x-face-too-ugly
2450 (while (gnus-article-goto-header "Face")
2451 (push (mail-header-field-value) faces)))))
2453 (goto-char (point-min))
2455 (unless (setq from (gnus-article-goto-header "from"))
2458 (insert " [no `from' set]\n"))
2460 (when (setq png (gnus-convert-face-to-png (pop faces)))
2462 (apply 'gnus-create-image png 'png t
2463 (cdr (assq 'png gnus-face-properties-alist))))
2465 (gnus-add-wash-type 'face)
2466 (gnus-add-image 'face image)
2467 (gnus-put-image image nil 'face))))))))))
2469 (defun article-display-x-face (&optional force)
2470 "Look for an X-Face header and display it if present."
2471 (interactive (list 'force))
2472 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2473 (gnus-with-article-headers
2474 ;; Delete the old process, if any.
2475 (when (process-status "article-x-face")
2476 (delete-process "article-x-face"))
2477 ;; See the comment in `article-display-face'.
2478 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2479 ;; We have already displayed X-Faces, so we remove them
2481 (gnus-delete-images 'xface)
2483 (let ((from (message-fetch-field "from"))
2485 (save-current-buffer
2486 (when (and wash-face-p
2487 (gnus-buffer-live-p gnus-original-article-buffer)
2488 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2489 ;; If type `W f', use gnus-original-article-buffer,
2490 ;; otherwise use the current buffer because displaying
2491 ;; RFC822 parts calls this function too.
2492 (set-buffer gnus-original-article-buffer))
2494 (mail-narrow-to-head)
2495 (and gnus-article-x-face-command
2497 ;; Check whether this face is censored.
2498 (not (and gnus-article-x-face-too-ugly
2500 (setq from (message-fetch-field "from")))
2501 (string-match gnus-article-x-face-too-ugly
2503 (while (gnus-article-goto-header "X-Face")
2504 (push (mail-header-field-value) x-faces)))))
2506 ;; We display the face.
2507 (cond ((functionp gnus-article-x-face-command)
2508 ;; The command is a lisp function, so we call it.
2509 (mapc gnus-article-x-face-command x-faces))
2510 ((stringp gnus-article-x-face-command)
2511 ;; The command is a string, so we interpret the command
2512 ;; as a, well, command, and fork it off.
2513 (let ((process-connection-type nil))
2514 (gnus-set-process-query-on-exit-flag
2516 "article-x-face" nil shell-file-name
2517 shell-command-switch gnus-article-x-face-command)
2519 ;; Sending multiple EOFs to xv doesn't work,
2520 ;; so we only do a single external face.
2522 (insert (car x-faces))
2523 (process-send-region "article-x-face"
2524 (point-min) (point-max)))
2525 (process-send-eof "article-x-face")))
2527 (error "`%s' set to `%s' is not a function"
2528 gnus-article-x-face-command
2529 'gnus-article-x-face-command)))))))))
2531 (defun article-decode-mime-words ()
2532 "Decode all MIME-encoded words in the article."
2534 (gnus-with-article-buffer
2535 (let ((inhibit-point-motion-hooks t)
2536 (mail-parse-charset gnus-newsgroup-charset)
2537 (mail-parse-ignored-charsets
2538 (with-current-buffer gnus-summary-buffer
2539 gnus-newsgroup-ignored-charsets)))
2540 (mail-decode-encoded-word-region (point-min) (point-max)))))
2542 (defun article-decode-charset (&optional prompt)
2543 "Decode charset-encoded text in the article.
2544 If PROMPT (the prefix), prompt for a coding system to use."
2546 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2547 (inhibit-read-only t)
2548 (mail-parse-charset gnus-newsgroup-charset)
2549 (mail-parse-ignored-charsets
2550 (save-excursion (condition-case nil
2551 (set-buffer gnus-summary-buffer)
2553 gnus-newsgroup-ignored-charsets))
2554 ct cte ctl charset format)
2557 (article-narrow-to-head)
2558 (setq ct (message-fetch-field "Content-Type" t)
2559 cte (message-fetch-field "Content-Transfer-Encoding" t)
2560 ctl (and ct (mail-header-parse-content-type ct))
2563 (mm-read-coding-system "Charset to decode: "))
2565 (mail-content-type-get ctl 'charset)))
2566 format (and ctl (mail-content-type-get ctl 'format)))
2568 (setq cte (mail-header-strip cte)))
2569 (if (and ctl (not (string-match "/" (car ctl))))
2571 (goto-char (point-max)))
2574 (narrow-to-region (point) (point-max))
2575 (when (and (eq mail-parse-charset 'gnus-decoded)
2576 (eq (mm-body-7-or-8) '8bit))
2577 ;; The text code could have been decoded.
2578 (setq charset mail-parse-charset))
2579 (when (and (or (not ctl)
2580 (equal (car ctl) "text/plain"))
2581 (not format)) ;; article with format will decode later.
2583 charset (and cte (intern (downcase
2584 (gnus-strip-whitespace cte))))
2587 (defun article-decode-encoded-words ()
2588 "Remove encoded-word encoding from headers."
2589 (let ((inhibit-point-motion-hooks t)
2590 (mail-parse-charset gnus-newsgroup-charset)
2591 (mail-parse-ignored-charsets
2592 (save-excursion (condition-case nil
2593 (set-buffer gnus-summary-buffer)
2595 gnus-newsgroup-ignored-charsets))
2596 (inhibit-read-only t)
2598 (goto-char (point-min))
2599 (when (search-forward "\n\n" nil 'move)
2606 (memq (char-after) '(?\t ? )))))
2607 (setq start (point))
2609 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2610 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2611 (funcall gnus-decode-address-function start end)
2612 (funcall gnus-decode-header-function start end))
2613 (goto-char (setq end start)))))
2615 (defun article-decode-group-name ()
2616 "Decode group names in Newsgroups, Followup-To and Xref headers."
2617 (let ((inhibit-point-motion-hooks t)
2618 (inhibit-read-only t)
2619 (method (gnus-find-method-for-group gnus-newsgroup-name))
2621 (when (and (or gnus-group-name-charset-method-alist
2622 gnus-group-name-charset-group-alist)
2623 (gnus-buffer-live-p gnus-original-article-buffer))
2625 (article-narrow-to-head)
2626 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2627 (with-current-buffer gnus-original-article-buffer
2628 (goto-char (point-min)))
2629 (setq regexp (concat "^" header
2630 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2631 (while (re-search-forward regexp nil t)
2632 (replace-match (save-match-data
2633 (gnus-decode-newsgroups
2634 ;; XXX how to use data in article buffer?
2635 (with-current-buffer gnus-original-article-buffer
2636 (re-search-forward regexp nil t)
2638 gnus-newsgroup-name method))
2640 (goto-char (point-min)))))))
2642 (autoload 'idna-to-unicode "idna")
2644 (defun article-decode-idna-rhs ()
2645 "Decode IDNA strings in RHS in various headers in current buffer.
2646 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2647 Mail-Reply-To: and Mail-Followup-To:."
2650 (let ((inhibit-point-motion-hooks t)
2651 (inhibit-read-only t))
2652 (article-narrow-to-head)
2653 (goto-char (point-min))
2654 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2656 (when (save-match-data
2657 (and (setq ace (match-string 1))
2659 (and (re-search-backward "^[^ \t]" nil t)
2660 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2661 (setq unicode (idna-to-unicode ace))))
2662 (unless (string= ace unicode)
2663 (replace-match unicode nil nil nil 1)))))))))
2665 (defun article-de-quoted-unreadable (&optional force read-charset)
2666 "Translate a quoted-printable-encoded article.
2667 If FORCE, decode the article whether it is marked as quoted-printable
2669 If READ-CHARSET, ask for a coding system."
2670 (interactive (list 'force current-prefix-arg))
2672 (let ((inhibit-read-only t) type charset)
2673 (if (gnus-buffer-live-p gnus-original-article-buffer)
2674 (with-current-buffer gnus-original-article-buffer
2676 (gnus-fetch-field "content-transfer-encoding"))
2677 (let* ((ct (gnus-fetch-field "content-type"))
2678 (ctl (and ct (mail-header-parse-content-type ct))))
2679 (setq charset (and ctl
2680 (mail-content-type-get ctl 'charset)))
2681 (if (stringp charset)
2682 (setq charset (intern (downcase charset)))))))
2684 (setq charset (mm-read-coding-system "Charset: " charset)))
2686 (setq charset gnus-newsgroup-charset))
2688 (and type (let ((case-fold-search t))
2689 (string-match "quoted-printable" type))))
2691 (quoted-printable-decode-region
2692 (point) (point-max) (mm-charset-to-coding-system charset))))))
2694 (defun article-de-base64-unreadable (&optional force read-charset)
2695 "Translate a base64 article.
2696 If FORCE, decode the article whether it is marked as base64 not.
2697 If READ-CHARSET, ask for a coding system."
2698 (interactive (list 'force current-prefix-arg))
2700 (let ((inhibit-read-only t) type charset)
2701 (if (gnus-buffer-live-p gnus-original-article-buffer)
2702 (with-current-buffer gnus-original-article-buffer
2704 (gnus-fetch-field "content-transfer-encoding"))
2705 (let* ((ct (gnus-fetch-field "content-type"))
2706 (ctl (and ct (mail-header-parse-content-type ct))))
2707 (setq charset (and ctl
2708 (mail-content-type-get ctl 'charset)))
2709 (if (stringp charset)
2710 (setq charset (intern (downcase charset)))))))
2712 (setq charset (mm-read-coding-system "Charset: " charset)))
2714 (setq charset gnus-newsgroup-charset))
2716 (and type (let ((case-fold-search t))
2717 (string-match "base64" type))))
2720 (narrow-to-region (point) (point-max))
2721 (base64-decode-region (point-min) (point-max))
2722 (mm-decode-coding-region
2723 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2728 (defun article-decode-HZ ()
2729 "Translate a HZ-encoded article."
2733 (let ((inhibit-read-only t))
2734 (rfc1843-decode-region (point-min) (point-max)))))
2736 (defun article-unsplit-urls ()
2737 "Remove the newlines that some other mailers insert into URLs."
2740 (let ((inhibit-read-only t))
2741 (goto-char (point-min))
2742 (while (re-search-forward
2743 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2744 (replace-match "\\1\\3" t)))
2745 (when (interactive-p)
2746 (gnus-treat-article nil))))
2748 (defun article-wash-html ()
2749 "Format an HTML article."
2752 (buffer-read-only nil))
2753 (when (gnus-buffer-live-p gnus-original-article-buffer)
2754 (setq handles (mm-dissect-buffer t t)))
2756 (delete-region (point) (point-max))
2757 (mm-inline-text-html handles)))
2759 (defvar gnus-article-browse-html-temp-list nil
2760 "List of temporary files created by `gnus-article-browse-html-parts'.
2761 Internal variable.")
2763 (defcustom gnus-article-browse-delete-temp 'ask
2764 "What to do with temporary files from `gnus-article-browse-html-parts'.
2765 If nil, don't delete temporary files. If it is t, delete them on
2766 exit from the summary buffer. If it is the symbol `file', query
2767 on each file, if it is `ask' ask once when exiting from the
2769 :group 'gnus-article
2770 :version "23.1" ;; No Gnus
2771 :type '(choice (const :tag "Don't delete" nil)
2772 (const :tag "Don't ask" t)
2773 (const :tag "Ask" ask)
2774 (const :tag "Ask for each file" file)))
2776 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2778 (defun gnus-article-browse-delete-temp-files (&optional how)
2779 "Delete temp-files created by `gnus-article-browse-html-parts'."
2780 (when (and gnus-article-browse-html-temp-list
2782 (or how (setq how gnus-article-browse-delete-temp))
2784 (let ((files (length gnus-article-browse-html-temp-list)))
2785 (gnus-y-or-n-p (format
2786 "Delete all %s temporary HTML file%s? "
2788 (if (> files 1) "s" ""))))
2790 (dolist (file gnus-article-browse-html-temp-list)
2791 (cond ((file-directory-p file)
2792 (when (or (not (eq how 'file))
2795 "Delete temporary HTML file(s) in directory `%s'? "
2796 (file-name-as-directory file))))
2797 (gnus-delete-directory file)))
2798 ((file-exists-p file)
2799 (when (or (not (eq how 'file))
2801 (format "Delete temporary HTML file `%s'? " file)))
2802 (delete-file file)))))
2803 ;; Also remove file from the list when not deleted or if file doesn't
2805 (setq gnus-article-browse-html-temp-list nil))
2806 gnus-article-browse-html-temp-list)
2808 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2809 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2814 (dolist (handle handles)
2816 ((not (listp handle)))
2817 ((equal (mm-handle-media-supertype handle) "multipart")
2818 (when (setq file (gnus-article-browse-html-save-cid-content
2819 cid handle directory))
2820 (throw 'found file)))
2821 ((equal (concat "<" cid ">") (mm-handle-id handle))
2824 (or (mm-handle-filename handle)
2826 (make-temp-name "cid")
2827 (car (rassoc (car (mm-handle-type handle)) mailcap-mime-extensions))))
2829 (mm-save-part-to-file handle file)
2830 (throw 'found file))))))))
2832 (defun gnus-article-browse-html-parts (list &optional header)
2833 "View all \"text/html\" parts from LIST.
2834 Recurse into multiparts. The optional HEADER that should be a decoded
2835 message header will be added to the bodies of the \"text/html\" parts."
2836 ;; Internal function used by `gnus-article-browse-html-article'.
2837 (let (type file charset content cid-dir tmp-file showed)
2838 ;; Find and show the html-parts.
2839 (dolist (handle list)
2840 ;; If HTML, show it:
2841 (cond ((not (listp handle)))
2842 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2843 (and (equal (car type) "message/external-body")
2845 (setq file (mm-handle-filename handle)))
2846 (or (mm-handle-cache handle)
2847 (condition-case code
2848 (progn (mm-extern-cache-contents handle) t)
2850 (gnus-message 3 "%s" (error-message-string code))
2851 (when (>= gnus-verbose 3) (sit-for 2))
2854 (setq handle (mm-handle-cache handle)
2855 type (mm-handle-type handle))
2856 (equal (car type) "text/html"))))
2857 (setq charset (mail-content-type-get type 'charset)
2858 content (mm-get-part handle))
2860 (if (eq charset 'gnus-decoded)
2861 (mm-enable-multibyte)
2862 (mm-disable-multibyte))
2864 ;; resolve cid contents
2865 (let ((case-fold-search t)
2867 (goto-char (point-min))
2868 (while (re-search-forward "\
2869 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2872 (setq cid-dir (mm-make-temp-file "cid" t))
2873 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2876 (when (setq cid-file
2877 (gnus-article-browse-html-save-cid-content
2879 (with-current-buffer gnus-article-buffer
2880 gnus-article-mime-handles)
2882 (when (eq system-type 'cygwin)
2884 (concat "/" (substring
2885 (with-output-to-string
2886 (call-process "cygpath" nil
2890 (replace-match (concat "file://" cid-file)
2892 (unless content (setq content (buffer-string))))
2893 (when (or charset header (not file))
2894 (setq tmp-file (mm-make-temp-file
2895 ;; Do we need to care for 8.3 filenames?
2896 "mm-" nil ".html")))
2897 ;; Add a meta html tag to specify charset and a header.
2900 (let (title eheader body hcharset coding force-charset)
2902 (mm-enable-multibyte)
2903 (setq case-fold-search t)
2904 (insert header "\n")
2905 (setq title (message-fetch-field "subject"))
2906 (goto-char (point-min))
2907 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2908 (replace-match (cond ((match-beginning 1) "<")
2909 ((match-beginning 2) ">")
2911 (goto-char (point-min))
2913 (goto-char (point-max))
2914 (insert "</pre>\n<hr>\n")
2915 ;; We have to examine charset one by one since
2916 ;; charset specified in parts might be different.
2917 (if (eq charset 'gnus-decoded)
2918 (setq charset 'utf-8
2919 eheader (mm-encode-coding-string (buffer-string)
2922 (mm-encode-coding-string title charset))
2923 body (mm-encode-coding-string content charset)
2925 (setq hcharset (mm-find-mime-charset-region (point-min)
2927 (cond ((= (length hcharset) 1)
2928 (setq hcharset (car hcharset)
2929 coding (mm-charset-to-coding-system
2931 ((> (length hcharset) 1)
2932 (setq hcharset 'utf-8
2938 (mm-charset-to-coding-system charset))
2939 (if (eq coding body)
2940 (setq eheader (mm-encode-coding-string
2941 (buffer-string) coding)
2943 (mm-encode-coding-string
2946 (setq charset 'utf-8
2947 eheader (mm-encode-coding-string
2948 (buffer-string) charset)
2950 (mm-encode-coding-string
2952 body (mm-encode-coding-string
2953 (mm-decode-coding-string
2957 (setq charset hcharset
2958 eheader (mm-encode-coding-string
2959 (buffer-string) coding)
2961 (mm-encode-coding-string
2964 (setq eheader (mm-string-as-unibyte (buffer-string))
2967 (mm-disable-multibyte)
2970 (mm-add-meta-html-tag handle charset force-charset))
2972 (goto-char (point-min))
2973 (unless (search-forward "<title>" nil t)
2974 (re-search-forward "<head>\\s-*" nil t)
2975 (insert "<title>" title "</title>\n")))
2976 (goto-char (point-min))
2977 (or (re-search-forward
2978 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2980 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2982 (mm-write-region (point-min) (point-max)
2983 tmp-file nil nil nil 'binary t))))
2985 (mm-with-unibyte-buffer
2986 (insert (if (eq charset 'gnus-decoded)
2987 (mm-encode-coding-string content
2988 (setq charset 'utf-8))
2990 (if (or (mm-add-meta-html-tag handle charset)
2992 (mm-write-region (point-min) (point-max)
2993 tmp-file nil nil nil 'binary t)
2994 (setq tmp-file nil))))
2996 (mm-save-part-to-file handle tmp-file)))
2998 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2999 (add-hook 'gnus-summary-prepare-exit-hook
3000 'gnus-article-browse-delete-temp-files)
3001 (add-hook 'gnus-exit-gnus-hook
3003 (gnus-article-browse-delete-temp-files t)))
3004 ;; FIXME: Warn if there's an <img> tag?
3005 (browse-url-of-file (or tmp-file (expand-file-name file)))
3007 ;; If multipart, recurse
3008 ((equal (mm-handle-media-supertype handle) "multipart")
3009 (when (gnus-article-browse-html-parts handle header)
3011 ((equal (mm-handle-media-type handle) "message/rfc822")
3012 (mm-with-multibyte-buffer
3013 (mm-insert-part handle)
3014 (setq handle (mm-dissect-buffer t t))
3015 (when (and (bufferp (car handle))
3016 (stringp (car (mm-handle-type handle))))
3017 (setq handle (list handle)))
3019 (article-decode-encoded-words)
3020 (let ((gnus-visible-headers
3021 (or (get 'gnus-visible-headers 'standard-value)
3022 gnus-visible-headers)))
3023 (article-hide-headers))
3024 (goto-char (point-min))
3025 (search-forward "\n\n" nil 'move)
3026 (skip-chars-backward "\t\n ")
3027 (setq header (buffer-substring (point-min) (point)))))
3029 (gnus-article-browse-html-parts handle header)
3030 (mm-destroy-parts handle))
3034 (defun gnus-article-browse-html-article (&optional arg)
3035 "View \"text/html\" parts of the current article with a WWW browser.
3036 Inline images embedded in a message using the cid scheme, as they are
3037 generally considered to be safe, will be processed properly.
3038 The message header is added to the beginning of every html part unless
3039 the prefix argument ARG is given.
3041 Warning: Spammers use links to images (using the http scheme) in HTML
3042 articles to verify whether you have read the message. As
3043 `gnus-article-browse-html-article' passes the HTML content to the
3044 browser without eliminating these \"web bugs\" you should only
3045 use it for mails from trusted senders.
3047 If you always want to display HTML parts in the browser, set
3048 `mm-text-html-renderer' to nil.
3050 This command creates temporary files to pass HTML contents including
3051 images if any to the browser, and deletes them when exiting the group
3053 ;; Cf. `mm-w3m-safe-url-regexp'
3056 (gnus-summary-show-article)
3057 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3058 gnus-visible-headers))
3059 ;; As we insert a <hr>, there's no need for the body boundary.
3060 (gnus-treat-body-boundary nil))
3061 (gnus-summary-show-article)))
3062 (with-current-buffer gnus-article-buffer
3063 (let ((header (unless arg
3066 (buffer-substring-no-properties
3067 (goto-char (point-min))
3068 (if (search-forward "\n\n" nil t)
3070 (goto-char (point-max))
3071 (skip-chars-backward "\t\n ")
3074 (set-buffer gnus-original-article-buffer)
3075 (setq parts (mm-dissect-buffer t t))
3076 ;; If singlepart, enforce a list.
3077 (when (and (bufferp (car parts))
3078 (stringp (car (mm-handle-type parts))))
3079 (setq parts (list parts)))
3081 (unless (gnus-article-browse-html-parts parts header)
3082 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3083 (mm-destroy-parts parts)
3085 (gnus-summary-show-article)))))
3087 (defun article-hide-list-identifiers ()
3088 "Remove list identifies from the Subject header.
3089 The `gnus-list-identifiers' variable specifies what to do."
3091 (let ((inhibit-point-motion-hooks t)
3092 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
3093 (inhibit-read-only t))
3097 (article-narrow-to-head)
3098 (goto-char (point-min))
3099 (while (re-search-forward
3100 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3102 (delete-region (match-beginning 2) (match-end 0))
3103 (beginning-of-line))
3104 (when (re-search-forward
3105 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3106 (delete-region (match-beginning 1) (match-end 1))))))))
3108 (defun article-hide-pem (&optional arg)
3109 "Toggle hiding of any PEM headers and signatures in the current article.
3110 If given a negative prefix, always show; if given a positive prefix,
3112 (interactive (gnus-article-hidden-arg))
3113 (unless (gnus-article-check-hidden-text 'pem arg)
3115 (let ((inhibit-read-only t) end)
3116 (goto-char (point-min))
3117 ;; Hide the horrendously ugly "header".
3118 (when (and (search-forward
3119 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3121 (setq end (1+ (match-beginning 0))))
3122 (gnus-add-wash-type 'pem)
3123 (gnus-article-hide-text-type
3125 (if (search-forward "\n\n" nil t)
3129 ;; Hide the trailer as well
3130 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3132 (gnus-article-hide-text-type
3133 (match-beginning 0) (match-end 0) 'pem)))))))
3135 (defun article-strip-banner ()
3136 "Strip the banners specified by the `banner' group parameter and by
3137 `gnus-article-address-banner-alist'."
3141 (let ((inhibit-point-motion-hooks t))
3142 (when (gnus-parameter-banner gnus-newsgroup-name)
3143 (article-really-strip-banner
3144 (gnus-parameter-banner gnus-newsgroup-name)))
3145 (when gnus-article-address-banner-alist
3146 ;; Note that the From header is decoded here, so it is
3147 ;; required that the *-extract-address-components function
3148 ;; supports non-ASCII text.
3149 (let ((from (save-restriction
3151 (article-narrow-to-head)
3152 (mail-fetch-field "from"))))
3155 (cadr (funcall gnus-extract-address-components
3158 (dolist (pair gnus-article-address-banner-alist)
3159 (when (string-match (car pair) from)
3161 (article-really-strip-banner (cdr pair)))))))))))))
3163 (defun article-really-strip-banner (banner)
3164 "Strip the banner specified by the argument."
3167 (let ((inhibit-point-motion-hooks t)
3168 (gnus-signature-limit nil)
3169 (inhibit-read-only t))
3172 ((eq banner 'signature)
3173 (when (gnus-article-narrow-to-signature)
3176 (delete-region (point) (point-max))))
3178 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3179 (while (re-search-forward banner nil t)
3180 (delete-region (match-beginning 0) (match-end 0)))))
3182 (while (re-search-forward banner nil t)
3183 (delete-region (match-beginning 0) (match-end 0)))))))))
3185 (defun article-babel ()
3186 "Translate article using an online translation service."
3189 (gnus-with-article-buffer
3190 (when (article-goto-body)
3191 (let* ((start (point))
3193 (orig (buffer-substring start end))
3194 (trans (babel-as-string orig)))
3196 (narrow-to-region start end)
3197 (delete-region start end)
3200 (defun article-hide-signature (&optional arg)
3201 "Hide the signature in the current article.
3202 If given a negative prefix, always show; if given a positive prefix,
3204 (interactive (gnus-article-hidden-arg))
3205 (unless (gnus-article-check-hidden-text 'signature arg)
3208 (let ((inhibit-read-only t))
3209 (when (gnus-article-narrow-to-signature)
3210 (gnus-article-hide-text-type
3211 (point-min) (point-max) 'signature))))))
3212 (gnus-set-mode-line 'article))
3214 (defun article-strip-headers-in-body ()
3215 "Strip offensive headers from bodies."
3219 (let ((case-fold-search t))
3220 (when (looking-at "x-no-archive:")
3221 (gnus-delete-line)))))
3223 (defun article-strip-leading-blank-lines ()
3224 "Remove all blank lines from the beginning of the article."
3227 (let ((inhibit-point-motion-hooks t)
3228 (inhibit-read-only t))
3229 (when (article-goto-body)
3230 (while (and (not (eobp))
3231 (looking-at "[ \t]*$"))
3232 (gnus-delete-line))))))
3234 (defun article-narrow-to-head ()
3235 "Narrow the buffer to the head of the message.
3236 Point is left at the beginning of the narrowed-to region."
3238 (goto-char (point-min))
3239 (if (search-forward "\n\n" nil 1)
3242 (goto-char (point-min)))
3244 (defun article-goto-body ()
3245 "Place point at the start of the body."
3246 (goto-char (point-min))
3248 ;; This variable is only bound when dealing with separate
3250 (article-goto-body-goes-to-point-min-p
3252 ((search-forward "\n\n" nil t)
3255 (goto-char (point-max))
3258 (defun article-strip-multiple-blank-lines ()
3259 "Replace consecutive blank lines with one empty line."
3262 (let ((inhibit-point-motion-hooks t)
3263 (inhibit-read-only t))
3264 ;; First make all blank lines empty.
3266 (while (re-search-forward "^[ \t]+$" nil t)
3267 (unless (gnus-annotation-in-region-p
3268 (match-beginning 0) (match-end 0))
3269 (replace-match "" nil t)))
3270 ;; Then replace multiple empty lines with a single empty line.
3272 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3273 (unless (gnus-annotation-in-region-p
3274 (match-beginning 0) (match-end 0))
3275 (delete-region (match-beginning 1) (match-end 1)))))))
3277 (defun article-strip-leading-space ()
3278 "Remove all white space from the beginning of the lines in the article."
3281 (let ((inhibit-point-motion-hooks t)
3282 (inhibit-read-only t))
3284 (while (re-search-forward "^[ \t]+" nil t)
3285 (replace-match "" t t)))))
3287 (defun article-strip-trailing-space ()
3288 "Remove all white space from the end of the lines in the article."
3291 (let ((inhibit-point-motion-hooks t)
3292 (inhibit-read-only t))
3294 (while (re-search-forward "[ \t]+$" nil t)
3295 (replace-match "" t t)))))
3297 (defun article-strip-blank-lines ()
3298 "Strip leading, trailing and multiple blank lines."
3300 (article-strip-leading-blank-lines)
3301 (article-remove-trailing-blank-lines)
3302 (article-strip-multiple-blank-lines))
3304 (defun article-strip-all-blank-lines ()
3305 "Strip all blank lines."
3308 (let ((inhibit-point-motion-hooks t)
3309 (inhibit-read-only t))
3311 (while (re-search-forward "^[ \t]*\n" nil t)
3312 (replace-match "" t t)))))
3314 (defun gnus-article-narrow-to-signature ()
3315 "Narrow to the signature; return t if a signature is found, else nil."
3316 (let ((inhibit-point-motion-hooks t))
3317 (when (gnus-article-search-signature)
3319 ;; Check whether we have some limits to what we consider
3320 ;; to be a signature.
3321 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3322 (list gnus-signature-limit)))
3324 (while (setq limit (pop limits))
3325 (if (or (and (integerp limit)
3326 (< (- (point-max) (point)) limit))
3328 (< (count-lines (point) (point-max)) limit))
3329 (and (functionp limit)
3331 (and (stringp limit)
3332 (not (re-search-forward limit nil t))))
3333 () ; This limit did not succeed.
3337 (narrow-to-region (point) (point-max))
3340 (defun gnus-article-search-signature ()
3341 "Search the current buffer for the signature separator.
3342 Put point at the beginning of the signature separator."
3343 (let ((cur (point)))
3344 (goto-char (point-max))
3345 (if (if (stringp gnus-signature-separator)
3346 (re-search-backward gnus-signature-separator nil t)
3347 (let ((seps gnus-signature-separator))
3349 (not (re-search-backward (car seps) nil t)))
3356 (defun gnus-article-hidden-arg ()
3357 "Return the current prefix arg as a number, or 0 if no prefix."
3358 (list (if current-prefix-arg
3359 (prefix-numeric-value current-prefix-arg)
3362 (defun gnus-article-check-hidden-text (type arg)
3363 "Return nil if hiding is necessary.
3364 Arg can be nil or a number. nil and positive means hide, negative
3365 means show, 0 means toggle."
3368 (let ((hide (gnus-article-hidden-text-p type)))
3374 (gnus-article-show-hidden-text type)
3377 (if (eq hide 'hidden)
3379 (gnus-article-show-hidden-text type)
3383 (defun gnus-article-hidden-text-p (type)
3384 "Say whether the current buffer contains hidden text of type TYPE."
3385 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3387 (not (get-text-property pos 'invisible))
3388 (not (get-text-property pos 'dummy-invisible)))
3390 (text-property-any (1+ pos) (point-max) 'article-type type)))
3395 (defun gnus-article-show-hidden-text (type &optional dummy)
3396 "Show all hidden text of type TYPE.
3397 Originally it is hide instead of DUMMY."
3398 (let ((inhibit-read-only t)
3399 (inhibit-point-motion-hooks t))
3400 (gnus-remove-text-properties-when
3402 (point-min) (point-max)
3403 (cons 'article-type (cons type
3404 gnus-hidden-properties)))
3405 (gnus-delete-wash-type type)))
3407 (defconst article-time-units
3408 `((year . ,(* 365.25 24 60 60))
3409 (week . ,(* 7 24 60 60))
3410 (day . ,(* 24 60 60))
3414 "Mapping from time units to seconds.")
3416 (defun gnus-article-forward-header ()
3417 "Move point to the start of the next header.
3418 If the current header is a continuation header, this can be several
3423 (if (looking-at "[ \t]+[^ \t]")
3427 (defun article-treat-date ()
3428 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer)
3429 (with-current-buffer gnus-summary-buffer
3430 gnus-article-date-headers)
3431 gnus-article-date-headers)
3434 (defun article-date-ut (&optional type highlight date-position)
3435 "Convert DATE date to TYPE in the current article.
3436 The default type is `ut'. See `gnus-article-date-headers' for
3438 (interactive (list 'ut t))
3439 (let* ((case-fold-search t)
3440 (inhibit-read-only t)
3441 (inhibit-point-motion-hooks t)
3443 (visible-date (mail-fetch-field "Date"))
3444 pos date bface eface)
3446 (goto-char (point-min))
3447 (when (re-search-forward "^Date:" nil t)
3448 (setq bface (get-text-property (point-at-bol) 'face)
3449 eface (get-text-property (1- (point-at-eol)) 'face)))
3450 ;; Delete any old Date headers.
3453 (goto-char date-position)
3454 (setq date (get-text-property (point) 'original-date))
3455 (delete-region (point)
3457 (gnus-article-forward-header)
3459 (article-transform-date date type bface eface))
3462 (goto-char (point-min))
3463 (while (or (get-text-property (setq pos (point)) 'original-date)
3464 (and (setq pos (next-single-property-change
3465 (point) 'original-date))
3467 (narrow-to-region pos (if (search-forward "\n\n" nil t)
3468 (1+ (match-beginning 0))
3470 (goto-char (point-min))
3471 (while (re-search-forward "^Date:" nil t)
3472 (setq date (get-text-property (match-beginning 0) 'original-date))
3473 (delete-region (point-at-bol) (progn
3474 (gnus-article-forward-header)
3476 (when (and (not date)
3478 (setq date visible-date))
3480 (article-transform-date date type bface eface))
3481 (goto-char (point-max))
3484 (defun article-transform-date (date type bface eface)
3485 (dolist (this-type (cond
3492 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3495 (put-text-property (point) (1+ (point))
3496 'original-date date)
3497 (put-text-property (point) (1+ (point))
3498 'gnus-date-type this-type)
3500 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3501 (put-text-property (match-beginning 1) (1+ (match-end 1))
3503 (put-text-property (match-beginning 2) (match-end 2)
3507 (defun article-make-date-line (date type)
3508 "Return a DATE line of TYPE."
3509 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3511 (error "Unknown conversion type: %s" type))
3513 (let ((time (ignore-errors (date-to-time date))))
3515 ;; Convert to the local timezone.
3517 (concat "Date: " (message-make-date time)))
3518 ;; Convert to Universal Time.
3523 (let* ((e (parse-time-string date))
3524 (tm (apply 'encode-time e))
3526 (ls (- (cadr tm) (car (current-time-zone time)))))
3527 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3528 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3532 ;; Get the original date from the article.
3533 ((eq type 'original)
3534 (concat "Date: " (if (string-match "\n+$" date)
3535 (substring date 0 (match-beginning 0))
3537 ;; Let the user define the format.
3538 ((eq type 'user-defined)
3539 (let ((format (or (condition-case nil
3540 (with-current-buffer gnus-summary-buffer
3541 gnus-article-time-format)
3543 gnus-article-time-format)))
3544 (if (functionp format)
3545 (funcall format time)
3546 (concat "Date: " (format-time-string format time)))))
3549 (let ((tz (car (current-time-zone time))))
3552 (format-time-string "%Y%m%dT%H%M%S" time)
3553 (format "%s%02d%02d"
3554 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3555 (/ (% (abs tz) 3600) 60)))))
3556 ;; Do a lapsed format.
3558 (concat "Date: " (article-lapsed-string time)))
3559 ;; A combined date/lapsed format.
3560 ((eq type 'combined-lapsed)
3561 (let ((date-string (article-make-date-line date 'original))
3567 (concat " (" (article-lapsed-string time segments) ")"))
3568 (> (+ (length date-string)
3569 (length lapsed-string))
3572 (setq segments (1- segments)))
3574 (concat date-string lapsed-string)
3576 ;; Display the date in proper English
3578 (let ((dtime (decode-time time)))
3581 (number-to-string (nth 3 dtime))
3582 (let ((digit (% (nth 3 dtime) 10)))
3584 ((memq (nth 3 dtime) '(11 12 13)) "th")
3590 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3592 (number-to-string (nth 5 dtime))
3594 (format "%02d" (nth 2 dtime))
3596 (format "%02d" (nth 1 dtime)))))))
3598 (format "Date: %s (from Gnus)" date))))
3600 (defun article-lapsed-string (time &optional max-segments)
3601 ;; If the date is seriously mangled, the timezone functions are
3602 ;; liable to bug out, so we ignore all errors.
3603 (let* ((now (current-time))
3604 (real-time (subtract-time now time))
3605 (real-sec (and real-time
3606 (+ (* (float (car real-time)) 65536)
3608 (sec (and real-time (abs real-sec)))
3611 (unless max-segments
3612 (setq max-segments (length article-time-units)))
3620 ;; This is a bit convoluted, but basically we go
3621 ;; through the time units for years, weeks, etc,
3622 ;; and divide things to see whether that results
3623 ;; in positive answers.
3626 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3627 (>= segments max-segments))
3628 ;; The (remaining) seconds are too few to
3629 ;; be divided into this time unit.
3631 ;; It's big enough, so we output it.
3632 (setq sec (- sec (* num (cdr unit))))
3634 (concat (if prev ", " "") (int-to-string
3636 " " (symbol-name (car unit))
3637 (if (> num 1) "s" ""))
3639 segments (1+ segments)))))
3640 article-time-units "")
3641 ;; If dates are odd, then it might appear like the
3642 ;; article was sent in the future.
3645 " in the future"))))))
3647 (defun article-date-local (&optional highlight)
3648 "Convert the current article date to the local timezone."
3649 (interactive (list t))
3650 (article-date-ut 'local highlight))
3652 (defun article-date-english (&optional highlight)
3653 "Convert the current article date to something that is proper English."
3654 (interactive (list t))
3655 (article-date-ut 'english highlight))
3657 (defun article-date-original (&optional highlight)
3658 "Convert the current article date to what it was originally.
3659 This is only useful if you have used some other date conversion
3660 function and want to see what the date was before converting."
3661 (interactive (list t))
3662 (article-date-ut 'original highlight))
3664 (defun article-date-lapsed (&optional highlight)
3665 "Convert the current article date to time lapsed since it was sent."
3666 (interactive (list t))
3667 (article-date-ut 'lapsed highlight))
3669 (defun article-date-combined-lapsed (&optional highlight)
3670 "Convert the current article date to time lapsed since it was sent."
3671 (interactive (list t))
3672 (article-date-ut 'combined-lapsed highlight))
3674 (defun article-update-date-lapsed ()
3675 "Function to be run from a timer to update the lapsed time line."
3677 (let ((buffer (current-buffer)))
3681 (set-buffer (window-buffer w))
3682 (when (eq major-mode 'gnus-article-mode)
3683 (let ((old-line (count-lines (point-min) (point)))
3684 (old-column (- (point) (line-beginning-position)))
3686 (window-start (get-buffer-window (current-buffer)))))
3687 (goto-char (point-min))
3688 (while (re-search-forward "^Date:" nil t)
3689 (let ((type (get-text-property (match-beginning 0)
3691 (when (memq type '(lapsed combined-lapsed user-format))
3692 (when (and window-start
3693 (not (= window-start
3697 (setq window-start nil))
3699 (article-date-ut type t (match-beginning 0)))
3702 (set-window-start (get-buffer-window (current-buffer))
3704 (goto-char (point-min))
3705 (when (> old-column 0)
3706 (setq old-line (1- old-line)))
3707 (forward-line old-line)
3709 (when (> (current-column) old-column)
3711 (forward-char old-column)))))
3713 (set-buffer buffer))))
3715 (defun gnus-start-date-timer (&optional n)
3716 "Start a timer to update the Date headers in the article buffers.
3717 The numerical prefix says how frequently (in seconds) the function
3722 (gnus-stop-date-timer)
3723 (setq article-lapsed-timer
3724 (run-at-time 1 n 'article-update-date-lapsed)))
3726 (defun gnus-stop-date-timer ()
3727 "Stop the Date timer."
3729 (when article-lapsed-timer
3730 (nnheader-cancel-timer article-lapsed-timer)
3731 (setq article-lapsed-timer nil)))
3733 (defun article-date-user (&optional highlight)
3734 "Convert the current article date to the user-defined format.
3735 This format is defined by the `gnus-article-time-format' variable."
3736 (interactive (list t))
3737 (article-date-ut 'user highlight))
3739 (defun article-date-iso8601 (&optional highlight)
3740 "Convert the current article date to ISO8601."
3741 (interactive (list t))
3742 (article-date-ut 'iso8601 highlight))
3744 (defmacro gnus-article-save-original-date (&rest forms)
3745 "Save the original date as a text property and evaluate FORMS."
3746 `(let* ((case-fold-search t)
3748 (goto-char (point-min))
3749 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3752 (date (when (and start
3753 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3755 (buffer-substring-no-properties start
3756 (match-beginning 0)))))
3757 (goto-char (point-max))
3758 (skip-chars-backward "\n")
3759 (put-text-property (point-min) (point) 'original-date date)
3761 (goto-char (point-max))
3762 (skip-chars-backward "\n")
3763 (put-text-property (point-min) (point) 'original-date date)))
3765 ;; (defun article-show-all ()
3766 ;; "Show all hidden text in the article buffer."
3769 ;; (let ((inhibit-read-only t))
3770 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3772 (defun article-remove-leading-whitespace ()
3773 "Remove excessive whitespace from all headers."
3777 (let ((inhibit-read-only t))
3778 (article-narrow-to-head)
3779 (goto-char (point-min))
3780 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3781 (delete-region (match-beginning 1) (match-end 1)))))))
3783 (defun article-emphasize (&optional arg)
3784 "Emphasize text according to `gnus-emphasis-alist'."
3785 (interactive (gnus-article-hidden-arg))
3786 (unless (gnus-article-check-hidden-text 'emphasis arg)
3790 (with-current-buffer gnus-summary-buffer
3791 gnus-article-emphasis-alist)
3793 gnus-emphasis-alist))
3794 (inhibit-read-only t)
3795 (props (append '(article-type emphasis)
3796 gnus-hidden-properties))
3797 regexp elem beg invisible visible face)
3800 (while (setq elem (pop alist))
3802 (setq regexp (car elem)
3803 invisible (nth 1 elem)
3804 visible (nth 2 elem)
3806 (while (re-search-forward regexp nil t)
3807 (when (and (match-beginning visible) (match-beginning invisible))
3808 (gnus-article-hide-text
3809 (match-beginning invisible) (match-end invisible) props)
3810 (gnus-article-unhide-text-type
3811 (match-beginning visible) (match-end visible) 'emphasis)
3812 (gnus-put-overlay-excluding-newlines
3813 (match-beginning visible) (match-end visible) 'face face)
3814 (gnus-add-wash-type 'emphasis)
3815 (goto-char (match-end invisible)))))))))
3817 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3818 "Setup newsgroup emphasis alist."
3819 (unless gnus-article-emphasis-alist
3820 (let ((name (and gnus-newsgroup-name
3821 (gnus-group-real-name gnus-newsgroup-name))))
3822 (make-local-variable 'gnus-article-emphasis-alist)
3823 (setq gnus-article-emphasis-alist
3825 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3826 (while (setq elem (pop alist))
3827 (when (and name (string-match (car elem) name))
3829 highlight (copy-sequence (cdr elem)))))
3831 (copy-sequence highlight-words)
3832 (if gnus-newsgroup-name
3833 (copy-sequence (gnus-group-find-parameter
3834 gnus-newsgroup-name 'highlight-words t)))
3835 gnus-emphasis-alist)))))
3837 (defvar gnus-summary-article-menu)
3838 (defvar gnus-summary-post-menu)
3840 ;;; Saving functions.
3842 (defun gnus-article-save (save-buffer file &optional num)
3843 "Save the currently selected article."
3844 (when (or (get gnus-default-article-saver :headers)
3845 (not gnus-save-all-headers))
3846 ;; Remove headers according to `gnus-saved-headers' or the value
3847 ;; of the `:headers' property that the saver function might have.
3848 (let ((gnus-visible-headers
3849 (or (symbol-value (get gnus-default-article-saver :headers))
3850 gnus-saved-headers gnus-visible-headers))
3851 ;; Ignore group parameter. See `article-hide-headers'.
3852 (gnus-summary-buffer nil))
3853 (with-current-buffer save-buffer
3854 (article-hide-headers 1 t))))
3855 (save-window-excursion
3856 (if (not gnus-default-article-saver)
3857 (error "No default saver is defined")
3858 ;; !!! Magic! The saving functions all save
3859 ;; `gnus-save-article-buffer' (or so they think), but we
3860 ;; bind that variable to our save-buffer.
3861 (set-buffer gnus-article-buffer)
3862 (let* ((gnus-save-article-buffer save-buffer)
3865 ((not gnus-prompt-before-saving) 'default)
3866 ((eq gnus-prompt-before-saving 'always) nil)
3868 (gnus-number-of-articles-to-be-saved
3869 (when (eq gnus-prompt-before-saving t)
3871 (set-buffer gnus-article-current-summary)
3872 (funcall gnus-default-article-saver filename)))))
3874 (defun gnus-read-save-file-name (prompt &optional filename
3875 function group headers variable
3878 (funcall function group headers (symbol-value variable)))
3883 ((eq filename 'default)
3889 (when (symbol-value dir-var)
3890 (setq default-name (expand-file-name
3891 (file-name-nondirectory default-name)
3892 (symbol-value dir-var))))
3893 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3896 (if (and gnus-number-of-articles-to-be-saved
3897 (> gnus-number-of-articles-to-be-saved 1))
3898 (format "these %d articles"
3899 gnus-number-of-articles-to-be-saved)
3902 ;; Let the split methods have their say.
3904 ;; No split name was found.
3907 (concat prompt " (default "
3908 (file-name-nondirectory default-name) "): ")
3909 (file-name-directory default-name)
3911 ;; A single group name is returned.
3912 ((stringp split-name)
3914 (funcall function split-name headers
3915 (symbol-value variable)))
3917 (concat prompt " (default "
3918 (file-name-nondirectory default-name) "): ")
3919 (file-name-directory default-name)
3921 ;; A single split name was found
3922 ((= 1 (length split-name))
3923 (let* ((name (expand-file-name
3925 gnus-article-save-directory))
3926 (dir (cond ((file-directory-p name)
3927 (file-name-as-directory name))
3928 ((file-exists-p name) name)
3929 (t gnus-article-save-directory))))
3931 (concat prompt " (default " name "): ")
3933 ;; A list of splits was found.
3935 (setq split-name (nreverse split-name))
3937 (let ((file-name-history
3938 (nconc split-name file-name-history)))
3942 (concat prompt " (`M-p' for defaults): ")
3943 gnus-article-save-directory
3945 gnus-article-save-directory)))
3946 (car (push result file-name-history)))))))
3947 ;; Create the directory.
3948 (gnus-make-directory (file-name-directory file))
3949 ;; If we have read a directory, we append the default file name.
3950 (when (file-directory-p file)
3951 (setq file (expand-file-name (file-name-nondirectory
3953 (file-name-as-directory file))))
3954 ;; Possibly translate some characters.
3955 (nnheader-translate-file-chars file))))))
3956 (gnus-make-directory (file-name-directory result))
3958 (set variable result))
3960 (set dir-var (file-name-directory result)))
3963 (defun gnus-article-archive-name (group)
3964 "Return the first instance of an \"Archive-name\" in the current buffer."
3965 (let ((case-fold-search t))
3966 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3967 (nnheader-concat gnus-article-save-directory
3968 (match-string 1)))))
3970 (defun gnus-article-nndoc-name (group)
3971 "If GROUP is an nndoc group, return the name of the parent group."
3972 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3973 (gnus-group-get-parameter group 'save-article-group)))
3975 (defun gnus-summary-save-in-rmail (&optional filename)
3976 "Append this article to Rmail file.
3977 Optional argument FILENAME specifies file name.
3978 Directory to save to is default to `gnus-article-save-directory'."
3979 (setq filename (gnus-read-save-file-name
3980 "Save %s in rmail file" filename
3981 gnus-rmail-save-name gnus-newsgroup-name
3982 gnus-current-headers 'gnus-newsgroup-last-rmail))
3983 (with-current-buffer gnus-save-article-buffer
3987 ;; Note that unlike gnus-summary-save-in-mail, there is no
3988 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3990 (gnus-output-to-rmail filename))))
3993 (defun gnus-summary-save-in-mail (&optional filename)
3994 "Append this article to Unix mail file.
3995 Optional argument FILENAME specifies file name.
3996 Directory to save to is default to `gnus-article-save-directory'."
3997 (setq filename (gnus-read-save-file-name
3998 "Save %s in Unix mail file" filename
3999 gnus-mail-save-name gnus-newsgroup-name
4000 gnus-current-headers 'gnus-newsgroup-last-mail))
4001 (with-current-buffer gnus-save-article-buffer
4005 (if (and (file-readable-p filename)
4006 (file-regular-p filename)
4007 (mail-file-babyl-p filename))
4008 (gnus-output-to-rmail filename)
4009 (gnus-output-to-mail filename)))))
4012 (put 'gnus-summary-save-in-file :decode t)
4013 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
4014 (defun gnus-summary-save-in-file (&optional filename overwrite)
4015 "Append this article to file.
4016 Optional argument FILENAME specifies file name.
4017 Directory to save to is default to `gnus-article-save-directory'."
4018 (setq filename (gnus-read-save-file-name
4019 "Save %s in file" filename
4020 gnus-file-save-name gnus-newsgroup-name
4021 gnus-current-headers 'gnus-newsgroup-last-file))
4022 (with-current-buffer gnus-save-article-buffer
4026 (when (and overwrite
4027 (file-exists-p filename))
4028 (delete-file filename))
4029 (gnus-output-to-file filename))))
4032 (put 'gnus-summary-write-to-file :decode t)
4033 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4034 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4035 (defun gnus-summary-write-to-file (&optional filename)
4036 "Write this article to a file, overwriting it if the file exists.
4037 Optional argument FILENAME specifies file name.
4038 The directory to save in defaults to `gnus-article-save-directory'."
4039 (setq filename (gnus-read-save-file-name
4040 "Save %s in file" filename
4041 gnus-file-save-name gnus-newsgroup-name
4042 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4043 (gnus-summary-save-in-file filename t))
4045 (put 'gnus-summary-save-body-in-file :decode t)
4046 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4047 "Append this article body to a file.
4048 Optional argument FILENAME specifies file name.
4049 The directory to save in defaults to `gnus-article-save-directory'."
4050 (setq filename (gnus-read-save-file-name
4051 "Save %s body in file" filename
4052 gnus-file-save-name gnus-newsgroup-name
4053 gnus-current-headers 'gnus-newsgroup-last-file))
4054 (with-current-buffer gnus-save-article-buffer
4058 (when (article-goto-body)
4059 (narrow-to-region (point) (point-max)))
4060 (when (and overwrite
4061 (file-exists-p filename))
4062 (delete-file filename))
4063 (gnus-output-to-file filename))))
4066 (put 'gnus-summary-write-body-to-file :decode t)
4067 (put 'gnus-summary-write-body-to-file
4068 :function 'gnus-summary-save-body-in-file)
4069 (defun gnus-summary-write-body-to-file (&optional filename)
4070 "Write this article body to a file, overwriting it if the file exists.
4071 Optional argument FILENAME specifies file name.
4072 The directory to save in defaults to `gnus-article-save-directory'."
4073 (setq filename (gnus-read-save-file-name
4074 "Save %s body in file" filename
4075 gnus-file-save-name gnus-newsgroup-name
4076 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4077 (gnus-summary-save-body-in-file filename t))
4079 (put 'gnus-summary-save-in-pipe :decode t)
4080 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4081 (defun gnus-summary-save-in-pipe (&optional command raw)
4082 "Pipe this article to subprocess COMMAND.
4083 Valid values for COMMAND include:
4085 The executable command name and possibly arguments.
4087 You will be prompted for the command in the minibuffer.
4088 the symbol `default'
4089 It will be replaced with the command which the variable
4090 `gnus-summary-pipe-output-default-command' holds or the command
4091 last used for saving.
4092 Non-nil value for RAW overrides `:decode' and `:headers' properties
4093 and the raw article including all headers will be piped."
4094 (let ((article (gnus-summary-article-number))
4096 (get 'gnus-summary-save-in-pipe :decode)))
4097 save-buffer default)
4099 (if (vectorp (gnus-summary-article-header article))
4100 (save-current-buffer
4101 (gnus-summary-select-article decode decode nil article)
4102 (insert-buffer-substring
4106 gnus-original-article-buffer)
4108 (nnheader-set-temp-buffer " *Gnus Save*"))))
4109 ;; Remove unwanted headers.
4110 (when (and (not raw)
4111 (or (get 'gnus-summary-save-in-pipe :headers)
4112 (not gnus-save-all-headers)))
4113 (let ((gnus-visible-headers
4114 (or (symbol-value (get 'gnus-summary-save-in-pipe
4116 gnus-saved-headers gnus-visible-headers))
4117 (gnus-summary-buffer nil))
4118 (article-hide-headers 1 t))))
4119 (error "%d is not a real article" article))
4120 (error "No article to pipe"))
4121 (setq default (or gnus-summary-pipe-output-default-command
4122 gnus-last-shell-command))
4123 (unless (stringp command)
4125 (if (and (eq command 'default) default)
4127 (gnus-read-shell-command "Shell command on this article: "
4129 (when (string-equal command "")
4131 (setq command default)
4132 (error "A command is required")))
4133 (with-current-buffer save-buffer
4136 (shell-command-on-region (point-min) (point-max) command nil)))
4137 (gnus-kill-buffer save-buffer))
4138 (setq gnus-summary-pipe-output-default-command command))
4140 (defun gnus-summary-pipe-to-muttprint (&optional command)
4141 "Pipe this article to muttprint."
4142 (unless (stringp command)
4143 (setq command (read-string
4144 "Print using command: " gnus-summary-muttprint-program
4145 nil gnus-summary-muttprint-program)))
4146 (let ((gnus-summary-pipe-output-default-command
4147 gnus-summary-pipe-output-default-command))
4148 (gnus-summary-save-in-pipe command))
4149 (setq gnus-summary-muttprint-program command))
4151 ;;; Article file names when saving.
4153 (defun gnus-capitalize-newsgroup (newsgroup)
4154 "Capitalize NEWSGROUP name."
4155 (when (not (zerop (length newsgroup)))
4156 (concat (char-to-string (upcase (aref newsgroup 0)))
4157 (substring newsgroup 1))))
4159 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4160 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4161 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4162 Otherwise, it is like ~/News/news/group/num."
4165 (concat (if (gnus-use-long-file-name 'not-save)
4166 (gnus-capitalize-newsgroup newsgroup)
4167 (gnus-newsgroup-directory-form newsgroup))
4168 "/" (int-to-string (mail-header-number headers)))
4169 gnus-article-save-directory)))
4171 (string-equal (file-name-directory default)
4172 (file-name-directory last-file))
4173 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4175 (or last-file default))))
4177 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4178 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4179 If variable `gnus-use-long-file-name' is non-nil, it is
4180 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4183 (concat (if (gnus-use-long-file-name 'not-save)
4185 (gnus-newsgroup-directory-form newsgroup))
4186 "/" (int-to-string (mail-header-number headers)))
4187 gnus-article-save-directory)))
4189 (string-equal (file-name-directory default)
4190 (file-name-directory last-file))
4191 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4193 (or last-file default))))
4195 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4196 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4197 If variable `gnus-use-long-file-name' is non-nil, it is
4198 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4201 (if (gnus-use-long-file-name 'not-save)
4204 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4206 gnus-article-save-directory)))
4208 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4209 "Generate file name from sender."
4210 (let ((from (mail-header-from headers)))
4212 (if (and from (string-match "\\([^ <]+\\)@" from))
4213 (match-string 1 from)
4215 gnus-article-save-directory)))
4217 (defun article-verify-x-pgp-sig ()
4219 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4221 (if (gnus-buffer-live-p gnus-original-article-buffer)
4222 (let ((sig (with-current-buffer gnus-original-article-buffer
4223 (gnus-fetch-field "X-PGP-Sig")))
4227 (mml2015-clear-verify-function))
4229 (insert-buffer-substring gnus-original-article-buffer)
4230 (setq items (split-string sig))
4231 (message-narrow-to-head)
4232 (let ((inhibit-point-motion-hooks t)
4233 (case-fold-search t))
4234 ;; Don't verify multiple headers.
4235 (setq headers (mapconcat (lambda (header)
4237 (mail-fetch-field header)
4239 (split-string (nth 1 items) ",") "")))
4240 (delete-region (point-min) (point-max))
4241 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4242 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4247 (if (looking-at "^-")
4250 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4251 (insert "Version: " (car items) "\n\n")
4252 (insert (mapconcat 'identity (cddr items) "\n"))
4253 (insert "\n-----END PGP SIGNATURE-----\n")
4254 (let ((mm-security-handle (list (format "multipart/signed"))))
4255 (mml2015-clean-buffer)
4256 (let ((coding-system-for-write (or gnus-newsgroup-charset
4258 (funcall (mml2015-clear-verify-function)))
4260 (or (mm-handle-multipart-ctl-parameter
4261 mm-security-handle 'gnus-details)
4262 (mm-handle-multipart-ctl-parameter
4263 mm-security-handle 'gnus-info)))))
4265 (let ((inhibit-read-only t) bface eface)
4267 (message-narrow-to-head)
4268 (goto-char (point-max))
4270 (setq bface (get-text-property (point-at-bol) 'face)
4271 eface (get-text-property (1- (point-at-eol)) 'face))
4272 (message-remove-header "X-Gnus-PGP-Verify")
4273 (if (re-search-forward "^X-PGP-Sig:" nil t)
4275 (goto-char (point-max)))
4276 (narrow-to-region (point) (point))
4277 (insert "X-Gnus-PGP-Verify: " info "\n")
4278 (goto-char (point-min))
4281 (if (not (looking-at "^[ \t]"))
4285 (goto-char (point-min))
4286 (when (looking-at "\\([^:]+\\): *")
4287 (put-text-property (match-beginning 1) (1+ (match-end 1))
4289 (put-text-property (match-end 0) (point-max)
4290 'face eface)))))))))
4292 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4294 (defun article-verify-cancel-lock ()
4295 "Verify Cancel-Lock header."
4297 (if (gnus-buffer-live-p gnus-original-article-buffer)
4298 (canlock-verify gnus-original-article-buffer)))
4305 (setq afunc (car func)
4308 gfunc (intern (format "gnus-%s" func))))
4310 (when (fboundp afunc)
4311 `(lambda (&optional interactive &rest args)
4312 ,(documentation afunc t)
4313 (interactive (list t))
4314 (with-current-buffer gnus-article-buffer
4316 (call-interactively ',afunc)
4317 (apply ',afunc args))))))))
4318 '(article-hide-headers
4319 article-verify-x-pgp-sig
4320 article-verify-cancel-lock
4321 article-hide-boring-headers
4322 article-treat-overstrike
4323 article-treat-ansi-sequences
4324 article-fill-long-lines
4325 article-capitalize-sentences
4327 article-remove-leading-whitespace
4328 article-display-x-face
4329 article-display-face
4330 article-de-quoted-unreadable
4331 article-de-base64-unreadable
4334 article-unsplit-urls
4335 article-hide-list-identifiers
4336 article-strip-banner
4339 article-hide-signature
4340 article-strip-headers-in-body
4341 article-remove-trailing-blank-lines
4342 article-strip-leading-blank-lines
4343 article-strip-multiple-blank-lines
4344 article-strip-leading-space
4345 article-strip-trailing-space
4346 article-strip-blank-lines
4347 article-strip-all-blank-lines
4349 article-date-english
4350 article-date-iso8601
4351 article-date-original
4354 article-decode-mime-words
4355 article-decode-charset
4356 article-decode-encoded-words
4359 article-date-combined-lapsed
4361 article-treat-dumbquotes
4362 article-treat-non-ascii
4363 article-normalize-headers
4364 ;;(article-show-all . gnus-article-show-all-headers)
4368 ;;; Gnus article mode
4371 (put 'gnus-article-mode 'mode-class 'special)
4373 (set-keymap-parent gnus-article-mode-map widget-keymap)
4375 (gnus-define-keys gnus-article-mode-map
4376 " " gnus-article-goto-next-page
4377 "\177" gnus-article-goto-prev-page
4378 [delete] gnus-article-goto-prev-page
4379 [backspace] gnus-article-goto-prev-page
4380 "\C-c^" gnus-article-refer-article
4381 "h" gnus-article-show-summary
4382 "s" gnus-article-show-summary
4383 "\C-c\C-m" gnus-article-mail
4384 "?" gnus-article-describe-briefly
4385 "<" beginning-of-buffer
4387 "\C-c\C-i" gnus-info-find-node
4389 "R" gnus-article-reply-with-original
4390 "F" gnus-article-followup-with-original
4391 "\C-hk" gnus-article-describe-key
4392 "\C-hc" gnus-article-describe-key-briefly
4393 "\C-hb" gnus-article-describe-bindings
4395 "e" gnus-article-read-summary-keys
4396 "\C-d" gnus-article-read-summary-keys
4397 "\M-*" gnus-article-read-summary-keys
4398 "\M-#" gnus-article-read-summary-keys
4399 "\M-^" gnus-article-read-summary-keys
4400 "\M-g" gnus-article-read-summary-keys)
4402 (substitute-key-definition
4403 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4405 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4406 "W" gnus-article-wide-reply-with-original)
4407 (if (featurep 'xemacs)
4408 (set-keymap-default-binding gnus-article-send-map
4409 'gnus-article-read-summary-send-keys)
4410 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4412 (defun gnus-article-make-menu-bar ()
4413 (unless (boundp 'gnus-article-commands-menu)
4414 (gnus-summary-make-menu-bar))
4415 (unless (boundp 'gnus-article-article-menu)
4417 gnus-article-article-menu gnus-article-mode-map ""
4419 ["Scroll forwards" gnus-article-goto-next-page t]
4420 ["Scroll backwards" gnus-article-goto-prev-page t]
4421 ["Show summary" gnus-article-show-summary t]
4422 ["Fetch Message-ID at point" gnus-article-refer-article t]
4423 ["Mail to address at point" gnus-article-mail t]
4424 ["Send a bug report" gnus-bug t]))
4427 gnus-article-treatment-menu gnus-article-mode-map ""
4428 ;; Fixme: this should use :active (and maybe :visible).
4430 ["Hide headers" gnus-article-hide-headers t]
4431 ["Hide signature" gnus-article-hide-signature t]
4432 ["Hide citation" gnus-article-hide-citation t]
4433 ["Treat overstrike" gnus-article-treat-overstrike t]
4434 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4435 ["Remove carriage return" gnus-article-remove-cr t]
4436 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4437 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4438 ["Remove base64" gnus-article-de-base64-unreadable t]
4439 ["Treat html" gnus-article-wash-html t]
4440 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4441 ["Decode HZ" gnus-article-decode-HZ t]))
4443 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4445 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4447 (gnus-run-hooks 'gnus-article-menu-hook)))
4449 (defvar bookmark-make-record-function)
4450 (defvar shr-put-image-function)
4452 (defun gnus-article-mode ()
4453 "Major mode for displaying an article.
4455 All normal editing commands are switched off.
4457 The following commands are available in addition to all summary mode
4459 \\<gnus-article-mode-map>
4460 \\[gnus-article-next-page]\t Scroll the article one page forwards
4461 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4462 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4463 \\[gnus-article-show-summary]\t Display the summary buffer
4464 \\[gnus-article-mail]\t Send a reply to the address near point
4465 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4466 \\[gnus-info-find-node]\t Go to the Gnus info node"
4468 (kill-all-local-variables)
4469 (gnus-simplify-mode-line)
4470 (setq mode-name "Article")
4471 (setq major-mode 'gnus-article-mode)
4472 (make-local-variable 'minor-mode-alist)
4473 (use-local-map gnus-article-mode-map)
4474 (when (gnus-visual-p 'article-menu 'menu)
4475 (gnus-article-make-menu-bar)
4476 (when gnus-summary-tool-bar-map
4477 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4478 (gnus-update-format-specifications nil 'article-mode)
4479 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4480 (set (make-local-variable 'gnus-page-broken) nil)
4481 (make-local-variable 'gnus-article-current-summary)
4482 (make-local-variable 'gnus-article-mime-handles)
4483 (make-local-variable 'gnus-article-decoded-p)
4484 (make-local-variable 'gnus-article-mime-handle-alist)
4485 (make-local-variable 'gnus-article-wash-types)
4486 (make-local-variable 'gnus-article-image-alist)
4487 (make-local-variable 'gnus-article-charset)
4488 (make-local-variable 'gnus-article-ignored-charsets)
4489 (set (make-local-variable 'bookmark-make-record-function)
4490 'gnus-summary-bookmark-make-record)
4491 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4493 (set (make-local-variable 'nobreak-char-display) nil)
4494 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4495 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4496 (setq cursor-in-non-selected-windows nil)
4497 (gnus-set-default-directory)
4498 (buffer-disable-undo)
4499 (setq buffer-read-only t
4500 show-trailing-whitespace nil)
4501 (set-syntax-table gnus-article-mode-syntax-table)
4502 (mm-enable-multibyte)
4503 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4505 (defun gnus-article-setup-buffer ()
4506 "Initialize the article buffer."
4507 (let* ((name (if gnus-single-article-buffer "*Article*"
4509 (gnus-group-decoded-name gnus-newsgroup-name)
4512 (progn (string-match "\\*Article" name)
4513 (concat " *Original Article"
4514 (substring name (match-end 0))))))
4515 (setq gnus-article-buffer name)
4516 (setq gnus-original-article-buffer original)
4517 (setq gnus-article-mime-handle-alist nil)
4518 (with-current-buffer gnus-summary-buffer
4519 ;; This might be a variable local to the summary buffer.
4520 (unless gnus-single-article-buffer
4521 (setq gnus-article-buffer name)
4522 (setq gnus-original-article-buffer original)
4523 (gnus-set-global-variables)))
4524 (gnus-article-setup-highlight-words)
4525 ;; Init original article buffer.
4526 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4527 (mm-enable-multibyte)
4528 (setq major-mode 'gnus-original-article-mode)
4529 (make-local-variable 'gnus-original-article))
4530 (if (and (get-buffer name)
4531 (with-current-buffer name
4532 (if gnus-article-edit-mode
4533 (if (y-or-n-p "Article mode edit in progress; discard? ")
4535 (set-buffer-modified-p nil)
4536 (gnus-kill-buffer name)
4539 (error "Action aborted"))
4541 (with-current-buffer name
4542 (set (make-local-variable 'gnus-article-edit-mode) nil)
4543 (gnus-article-stop-animations)
4544 (when gnus-article-mime-handles
4545 (mm-destroy-parts gnus-article-mime-handles)
4546 (setq gnus-article-mime-handles nil))
4547 ;; Set it to nil in article-buffer!
4548 (setq gnus-article-mime-handle-alist nil)
4549 (buffer-disable-undo)
4550 (setq buffer-read-only t)
4551 (unless (eq major-mode 'gnus-article-mode)
4552 (gnus-article-mode))
4553 (setq truncate-lines gnus-article-truncate-lines)
4555 (with-current-buffer (gnus-get-buffer-create name)
4557 (setq truncate-lines gnus-article-truncate-lines)
4558 (make-local-variable 'gnus-summary-buffer)
4559 (setq gnus-summary-buffer
4560 (gnus-summary-buffer-name gnus-newsgroup-name))
4561 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4562 (when article-lapsed-timer
4563 (gnus-stop-date-timer))
4564 (when gnus-article-update-date-headers
4565 (gnus-start-date-timer gnus-article-update-date-headers))
4566 (current-buffer)))))
4568 (defun gnus-article-stop-animations ()
4569 (dolist (timer (and (boundp 'timer-list)
4571 (when (eq (elt timer 5) 'image-animate-timeout)
4572 (cancel-timer timer))))
4574 ;; Set article window start at LINE, where LINE is the number of lines
4575 ;; from the head of the article.
4576 (defun gnus-article-set-window-start (&optional line)
4577 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4578 (when article-window
4581 (with-current-buffer gnus-article-buffer
4582 (goto-char (point-min))
4585 (gnus-message 6 "Moved to bookmark")
4586 (search-forward "\n\n" nil t)
4590 (defun gnus-article-prepare (article &optional all-headers header)
4591 "Prepare ARTICLE in article mode buffer.
4592 ARTICLE should either be an article number or a Message-ID.
4593 If ARTICLE is an id, HEADER should be the article headers.
4594 If ALL-HEADERS is non-nil, no headers are hidden."
4596 ;; Make sure we start in a summary buffer.
4597 (unless (eq major-mode 'gnus-summary-mode)
4598 (set-buffer gnus-summary-buffer))
4599 (setq gnus-summary-buffer (current-buffer))
4600 (let* ((gnus-article (if header (mail-header-number header) article))
4601 (summary-buffer (current-buffer))
4602 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4603 (group gnus-newsgroup-name)
4606 (gnus-article-setup-buffer)
4607 (set-buffer gnus-article-buffer)
4608 ;; Deactivate active regions.
4609 (when (and (boundp 'transient-mark-mode)
4610 transient-mark-mode)
4611 (setq mark-active nil))
4612 (if (not (setq result (let ((inhibit-read-only t))
4613 (gnus-request-article-this-buffer
4615 ;; There is no such article.
4617 (when (and (numberp article)
4618 (not (memq article gnus-newsgroup-sparse)))
4619 (setq gnus-article-current
4620 (cons gnus-newsgroup-name article))
4621 (set-buffer gnus-summary-buffer)
4622 (setq gnus-current-article article)
4623 (if (and (memq article gnus-newsgroup-undownloaded)
4624 (not (gnus-online (gnus-find-method-for-group
4625 gnus-newsgroup-name))))
4627 (gnus-summary-set-agent-mark article)
4628 (message "Message marked for downloading"))
4629 (gnus-summary-mark-article article gnus-canceled-mark)
4630 (unless (memq article gnus-newsgroup-sparse)
4631 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4632 (if (or (eq result 'pseudo)
4633 (eq result 'nneething))
4635 (with-current-buffer summary-buffer
4636 (push article gnus-newsgroup-history)
4637 (setq gnus-last-article gnus-current-article
4638 gnus-current-article 0
4639 gnus-current-headers nil
4640 gnus-article-current nil)
4641 (if (eq result 'nneething)
4642 (gnus-configure-windows 'summary)
4643 (gnus-configure-windows 'article))
4644 (gnus-set-global-variables))
4645 (let ((gnus-article-mime-handle-alist-1
4646 gnus-article-mime-handle-alist))
4647 (gnus-set-mode-line 'article)))
4648 ;; The result from the `request' was an actual article -
4649 ;; or at least some text that is now displayed in the
4651 (when (and (numberp article)
4652 (not (eq article gnus-current-article)))
4653 ;; Seems like a new article has been selected.
4654 ;; `gnus-current-article' must be an article number.
4655 (with-current-buffer summary-buffer
4656 (push article gnus-newsgroup-history)
4657 (setq gnus-last-article gnus-current-article
4658 gnus-current-article article
4659 gnus-current-headers
4660 (gnus-summary-article-header gnus-current-article)
4661 gnus-article-current
4662 (cons gnus-newsgroup-name gnus-current-article))
4663 (unless (vectorp gnus-current-headers)
4664 (setq gnus-current-headers nil))
4665 (gnus-summary-goto-subject gnus-current-article)
4666 (when (gnus-summary-show-thread)
4667 ;; If the summary buffer really was folded, the
4668 ;; previous goto may not actually have gone to
4669 ;; the right article, but the thread root instead.
4671 (gnus-summary-goto-subject gnus-current-article))
4672 (gnus-run-hooks 'gnus-mark-article-hook)
4673 (gnus-set-mode-line 'summary)
4674 (when (gnus-visual-p 'article-highlight 'highlight)
4675 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4676 ;; Set the global newsgroup variables here.
4677 (gnus-set-global-variables)
4678 (setq gnus-have-all-headers
4679 (or all-headers gnus-show-all-headers))))
4681 (gnus-configure-windows 'article))
4682 (when (or (numberp article)
4684 (gnus-article-prepare-display)
4686 (goto-char (point-min))
4687 (when gnus-break-pages
4688 (gnus-narrow-to-page)))
4689 (let ((gnus-article-mime-handle-alist-1
4690 gnus-article-mime-handle-alist))
4691 (gnus-set-mode-line 'article))
4695 (set-window-point (get-buffer-window (current-buffer)) (point))
4696 (gnus-configure-windows 'article)
4697 (gnus-run-hooks 'gnus-article-prepare-hook)
4701 (defun gnus-article-prepare-display ()
4702 "Make the current buffer look like a nice article."
4703 ;; Hooks for getting information from the article.
4704 ;; This hook must be called before being narrowed.
4705 (let ((gnus-article-buffer (current-buffer))
4707 (inhibit-read-only t))
4708 (unless (eq major-mode 'gnus-article-mode)
4709 (gnus-article-mode))
4710 (setq buffer-read-only nil
4711 gnus-article-wash-types nil
4712 gnus-article-image-alist nil)
4713 (gnus-run-hooks 'gnus-tmp-internal-hook)
4714 (when gnus-display-mime-function
4715 (funcall gnus-display-mime-function))))
4718 ;;; Gnus Sticky Article Mode
4721 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4722 "Mode for sticky articles."
4723 ;; Release bindings that won't work.
4724 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4725 gnus-sticky-article-mode-map)
4726 (substitute-key-definition 'gnus-article-refer-article 'undefined
4727 gnus-sticky-article-mode-map)
4728 (dolist (k '("e" "h" "s" "F" "R"))
4729 (define-key gnus-sticky-article-mode-map k nil))
4730 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4731 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4732 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4733 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4735 (defun gnus-sticky-article (arg)
4736 "Make the current article sticky.
4737 If a prefix ARG is given, ask for a name for this sticky article buffer."
4739 (gnus-summary-show-thread)
4740 (gnus-summary-select-article nil nil 'pseudo)
4741 (let (new-art-buf-name)
4742 (gnus-eval-in-buffer-window gnus-article-buffer
4743 (setq new-art-buf-name
4747 (read-from-minibuffer "Sticky article buffer name: ")
4748 (gnus-with-article-headers
4749 (gnus-article-goto-header "subject")
4750 (setq new-art-buf-name
4751 (buffer-substring-no-properties
4752 (line-beginning-position) (line-end-position)))
4753 (goto-char (point-min))
4754 (gnus-article-goto-header "from")
4755 (setq new-art-buf-name
4757 new-art-buf-name ", "
4758 (buffer-substring-no-properties
4759 (line-beginning-position) (line-end-position))))
4760 (goto-char (point-min))
4761 (gnus-article-goto-header "date")
4762 (setq new-art-buf-name
4764 new-art-buf-name ", "
4765 (buffer-substring-no-properties
4766 (line-beginning-position) (line-end-position))))))
4768 (if (and (gnus-buffer-live-p new-art-buf-name)
4769 (with-current-buffer new-art-buf-name
4770 (eq major-mode 'gnus-sticky-article-mode)))
4771 (switch-to-buffer new-art-buf-name)
4772 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4773 (gnus-sticky-article-mode))
4774 (setq gnus-article-buffer new-art-buf-name))
4775 (gnus-summary-recenter)
4776 (gnus-summary-position-point))
4778 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4779 "Kill the given sticky article BUFFER.
4780 If none is given, assume the current buffer and kill it if it has
4781 `gnus-sticky-article-mode'."
4784 (setq buffer (current-buffer)))
4785 (with-current-buffer buffer
4786 (when (eq major-mode 'gnus-sticky-article-mode)
4787 (gnus-kill-buffer buffer))))
4789 (defun gnus-kill-sticky-article-buffers (arg)
4790 "Kill all sticky article buffers.
4791 If a prefix ARG is given, ask for confirmation."
4793 (dolist (buf (gnus-buffers))
4794 (with-current-buffer buf
4795 (when (eq major-mode 'gnus-sticky-article-mode)
4797 (gnus-kill-buffer buf)
4798 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4799 (gnus-kill-buffer buf)))))))
4802 ;;; Gnus MIME viewing functions
4805 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4806 "Format of the MIME buttons.
4808 Valid specifiers include:
4810 %T MIME type, along with additional info
4811 %n The `name' parameter
4812 %d The description, if any
4813 %l The length of the encoded part
4814 %p The part identifier number
4815 %e Dots if the part isn't displayed
4817 General format specifiers can also be used. See Info node
4818 `(gnus)Formatting Variables'.")
4820 (defvar gnus-mime-button-line-format-alist
4821 '((?t gnus-tmp-type ?s)
4822 (?T gnus-tmp-type-long ?s)
4823 (?n gnus-tmp-name ?s)
4824 (?d gnus-tmp-description ?s)
4826 (?l gnus-tmp-length ?d)
4827 (?e gnus-tmp-dots ?s)))
4829 (defvar gnus-mime-button-commands
4830 '((gnus-article-press-button "\r" "Toggle Display")
4831 (gnus-mime-view-part "v" "View Interactively...")
4832 (gnus-mime-view-part-as-type "t" "View As Type...")
4833 (gnus-mime-view-part-as-charset "C" "View As charset...")
4834 (gnus-mime-save-part "o" "Save...")
4835 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4836 (gnus-mime-replace-part "r" "Replace part")
4837 (gnus-mime-delete-part "d" "Delete part")
4838 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4839 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4840 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4841 (gnus-mime-view-part-externally "e" "View Externally")
4842 (gnus-mime-print-part "p" "Print")
4843 (gnus-mime-pipe-part "|" "Pipe To Command...")
4844 (gnus-mime-action-on-part "." "Take action on the part...")))
4846 (defun gnus-article-mime-part-status ()
4847 (if gnus-article-mime-handle-alist-1
4848 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4850 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4853 (defvar gnus-mime-button-map
4854 (let ((map (make-sparse-keymap)))
4855 (define-key map gnus-mouse-2 'gnus-article-push-button)
4856 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4857 (dolist (c gnus-mime-button-commands)
4858 (define-key map (cadr c) (car c)))
4862 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4864 ,@(mapcar (lambda (c)
4865 (vector (caddr c) (car c) :active t))
4866 gnus-mime-button-commands)))
4868 (defvar gnus-url-button-commands
4869 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4871 (defvar gnus-url-button-map
4872 (let ((map (make-sparse-keymap)))
4873 (dolist (c gnus-url-button-commands)
4874 (define-key map (cadr c) (car c)))
4878 gnus-url-button-menu gnus-url-button-map "URL button menu."
4880 ,@(mapcar (lambda (c)
4881 (vector (caddr c) (car c) :active t))
4882 gnus-url-button-commands)))
4884 (defmacro gnus-bind-safe-url-regexp (&rest body)
4885 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4886 `(let ((mm-w3m-safe-url-regexp
4887 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4889 gnus-article-current-summary))
4890 (with-current-buffer gnus-article-current-summary
4891 gnus-newsgroup-name)
4892 gnus-newsgroup-name)))
4893 (if (cond ((not group)
4894 ;; Maybe we're in a mml-preview buffer
4895 ;; and no group is selected.
4897 ((stringp gnus-safe-html-newsgroups)
4898 (string-match gnus-safe-html-newsgroups group))
4899 ((consp gnus-safe-html-newsgroups)
4900 (member group gnus-safe-html-newsgroups)))
4902 mm-w3m-safe-url-regexp))))
4905 (defun gnus-mime-button-menu (event prefix)
4906 "Construct a context-sensitive menu of MIME commands."
4907 (interactive "e\nP")
4908 (save-window-excursion
4909 (let ((pos (event-start event)))
4910 (select-window (posn-window pos))
4911 (goto-char (posn-point pos))
4912 (gnus-article-check-buffer)
4913 (popup-menu gnus-mime-button-menu nil prefix))))
4915 (defun gnus-mime-view-all-parts (&optional handles)
4916 "View all the MIME parts."
4918 (with-current-buffer gnus-article-buffer
4919 (let ((handles (or handles gnus-article-mime-handles))
4920 (mail-parse-charset gnus-newsgroup-charset)
4921 (mail-parse-ignored-charsets
4922 (with-current-buffer gnus-summary-buffer
4923 gnus-newsgroup-ignored-charsets)))
4925 (mm-remove-parts handles)
4926 (goto-char (point-min))
4927 (or (search-forward "\n\n") (goto-char (point-max)))
4928 (let ((inhibit-read-only t))
4929 (delete-region (point) (point-max))
4930 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4932 (defun gnus-article-jump-to-part (n)
4933 "Jump to MIME part N."
4935 (let ((parts (with-current-buffer gnus-article-buffer
4936 (length gnus-article-mime-handle-alist))))
4938 (error "No such part"))
4939 (pop-to-buffer gnus-article-buffer)
4941 (setq n (if (= parts 1)
4943 (read-number (format "Jump to part (1..%s): " parts)))))
4944 (unless (and (integerp n) (<= n parts) (>= n 1))
4947 (gnus-message 7 "Invalid part `%s', using %s instead."
4950 (gnus-message 9 "Jumping to part %s." n)
4951 (cond ((>= gnus-auto-select-part 1)
4952 (while (and (<= n parts)
4953 (not (gnus-article-goto-part n)))
4955 ((< gnus-auto-select-part 0)
4956 (while (and (>= n 1)
4957 (not (gnus-article-goto-part n)))
4960 (gnus-article-goto-part n)))))
4962 (defvar gnus-mime-buttonized-part-id nil
4963 "ID of a mime part that should be buttonized.
4964 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4967 (defsubst gnus-article-edit-part (handles &optional current-id)
4968 "Edit an article in order to delete a mime part.
4969 This function is exclusively used by `gnus-mime-save-part-and-strip'
4970 and `gnus-mime-delete-part', and not provided at run-time normally."
4971 (gnus-article-edit-article
4973 (buffer-disable-undo)
4975 (let ((mail-parse-charset (or gnus-article-charset
4976 ',gnus-newsgroup-charset))
4977 (mail-parse-ignored-charsets
4978 (or gnus-article-ignored-charsets
4979 ',gnus-newsgroup-ignored-charsets))
4980 (mbl mml-buffer-list))
4981 (setq mml-buffer-list nil)
4982 (insert-buffer-substring gnus-original-article-buffer)
4983 (mime-to-mml ',handles)
4984 (setq gnus-article-mime-handles nil)
4985 (let ((mbl1 mml-buffer-list))
4986 (setq mml-buffer-list mbl)
4987 (set (make-local-variable 'mml-buffer-list) mbl1))
4988 (gnus-make-local-hook 'kill-buffer-hook)
4989 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4990 `(lambda (no-highlight)
4991 (let ((mail-parse-charset (or gnus-article-charset
4992 ',gnus-newsgroup-charset))
4993 (message-options message-options)
4994 (message-options-set-recipient)
4995 (mail-parse-ignored-charsets
4996 (or gnus-article-ignored-charsets
4997 ',gnus-newsgroup-ignored-charsets)))
4999 (mml-destroy-buffers)
5000 (remove-hook 'kill-buffer-hook
5001 'mml-destroy-buffers t)
5002 (kill-local-variable 'mml-buffer-list))
5003 (gnus-summary-edit-article-done
5004 ,(or (mail-header-references gnus-current-headers) "")
5005 ,(gnus-group-read-only-p)
5006 ,gnus-summary-buffer no-highlight))
5008 ;; Force buttonizing this part.
5009 (let ((gnus-mime-buttonized-part-id current-id))
5010 (gnus-article-edit-done))
5011 (gnus-configure-windows 'article)
5012 (when (and current-id (integerp gnus-auto-select-part))
5013 (gnus-article-jump-to-part
5014 (min (max (+ current-id gnus-auto-select-part) 1)
5015 (with-current-buffer gnus-article-buffer
5016 (length gnus-article-mime-handle-alist)))))))
5018 (defun gnus-mime-replace-part (file)
5019 "Replace MIME part under point with an external body."
5020 ;; Useful if file has already been saved to disk
5023 (read-file-name "Replace MIME part with file: "
5024 (or mm-default-directory default-directory)
5026 (gnus-mime-save-part-and-strip file))
5028 (defun gnus-mime-save-part-and-strip (&optional file)
5029 "Save the MIME part under point then replace it with an external body.
5030 If FILE is given, use it for the external part."
5032 (gnus-article-check-buffer)
5033 (when (gnus-group-read-only-p)
5034 (error "The current group does not support deleting of parts"))
5035 (when (mm-complicated-handles gnus-article-mime-handles)
5037 The current article has a complicated MIME structure, giving up..."))
5038 (let* ((data (get-text-property (point) 'gnus-data))
5039 (id (get-text-property (point) 'gnus-part))
5041 (handles gnus-article-mime-handles))
5044 (and data (mm-save-part data "Delete MIME part and save to: "))))
5046 (with-current-buffer (mm-handle-buffer data)
5048 (insert "Content-Type: " (mm-handle-media-type data))
5049 (mml-insert-parameter-string (cdr (mm-handle-type data))
5051 ;; Add a filename for the sake of saving the part again.
5052 (mml-insert-parameter
5053 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5055 (insert "Content-ID: " (message-make-message-id) "\n")
5056 (insert "Content-Transfer-Encoding: binary\n")
5059 (cdr (mm-make-handle nil
5060 `("message/external-body"
5061 (access-type . "LOCAL-FILE")
5063 ;; (set-buffer gnus-summary-buffer)
5064 (gnus-article-edit-part handles id))))
5066 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5067 ;; parts...>') but with stripping would be nice.
5069 (defun gnus-mime-delete-part ()
5070 "Delete the MIME part under point.
5071 Replace it with some information about the removed part."
5073 (gnus-article-check-buffer)
5074 (when (gnus-group-read-only-p)
5075 (error "The current group does not support deleting of parts"))
5076 (when (mm-complicated-handles gnus-article-mime-handles)
5078 The current article has a complicated MIME structure, giving up..."))
5079 (when (or gnus-expert-user
5080 (gnus-yes-or-no-p "\
5081 Deleting parts may malfunction or destroy the article; continue? "))
5082 (let* ((data (get-text-property (point) 'gnus-data))
5083 (id (get-text-property (point) 'gnus-part))
5084 (handles gnus-article-mime-handles)
5086 (let ((desc (mm-handle-description data)))
5088 (mail-decode-encoded-word-string desc))))
5089 (filename (or (mm-handle-filename data) "(none)"))
5090 (type (mm-handle-media-type data)))
5092 (error "No MIME part under point"))
5093 (with-current-buffer (mm-handle-buffer data)
5094 (let ((bsize (buffer-size)))
5099 "| The following attachment has been deleted:\n"
5101 "| Type: " type "\n"
5102 "| Filename: " filename "\n"
5103 "| Size (encoded): " (format "%s byte%s\n"
5104 bsize (if (= bsize 1)
5108 (concat "| Description: " description "\n"))
5111 (cdr (mm-make-handle
5112 nil `("text/plain" (charset . gnus-decoded)) nil nil
5114 (format "Deleted attachment (%s bytes)" bsize))))))
5115 ;; (set-buffer gnus-summary-buffer)
5116 (gnus-article-edit-part handles id))))
5118 (defun gnus-mime-save-part ()
5119 "Save the MIME part under point."
5121 (gnus-article-check-buffer)
5122 (let ((data (get-text-property (point) 'gnus-data)))
5124 (mm-save-part data))))
5126 (defun gnus-mime-pipe-part (&optional cmd)
5127 "Pipe the MIME part under point to a process.
5128 Use CMD as the process."
5130 (gnus-article-check-buffer)
5131 (let ((data (get-text-property (point) 'gnus-data)))
5133 (mm-pipe-part data cmd))))
5135 (defun gnus-mime-view-part ()
5136 "Interactively choose a viewing method for the MIME part under point."
5138 (gnus-article-check-buffer)
5139 (let ((data (get-text-property (point) 'gnus-data)))
5141 (setq gnus-article-mime-handles
5143 gnus-article-mime-handles (setq data (copy-sequence data))))
5144 (mm-interactively-view-part data))))
5146 (defun gnus-mime-view-part-as-type-internal ()
5147 (gnus-article-check-buffer)
5148 (let* ((handle (get-text-property (point) 'gnus-data))
5150 ;; Content-Type: foo/bar; name=...
5151 (mail-content-type-get (mm-handle-type handle) 'name)
5152 ;; Content-Disposition: attachment; filename=...
5153 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5154 (def-type (and name (mm-default-file-encoding name))))
5155 (or (and def-type (cons def-type 0))
5157 (equal (mm-handle-media-supertype handle) "text")
5158 '("text/plain" . 0))
5159 '("application/octet-stream" . 0))))
5161 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5162 "Choose a MIME media type, and view the part as such.
5163 If non-nil, PRED is a predicate to use during completion to limit the
5164 available media-types."
5168 (let ((default (gnus-mime-view-part-as-type-internal)))
5169 (gnus-completing-read
5172 (gnus-remove-if-not pred (mailcap-mime-types))
5173 (mailcap-mime-types))
5176 (gnus-article-check-buffer)
5177 (let ((handle (get-text-property (point) 'gnus-data)))
5179 (when (equal (mm-handle-media-type handle) "message/external-body")
5180 (unless (mm-handle-cache handle)
5181 (mm-extern-cache-contents handle))
5182 (setq handle (mm-handle-cache handle)))
5184 (mm-make-handle (mm-handle-buffer handle)
5185 (cons mime-type (cdr (mm-handle-type handle)))
5186 (mm-handle-encoding handle)
5187 (mm-handle-undisplayer handle)
5188 (mm-handle-disposition handle)
5189 (mm-handle-description handle)
5191 (mm-handle-id handle)))
5192 (setq gnus-article-mime-handles
5193 (mm-merge-handles gnus-article-mime-handles handle))
5194 (when (mm-handle-displayed-p handle)
5195 (mm-remove-part handle))
5196 (gnus-mm-display-part handle))))
5198 (defun gnus-mime-copy-part (&optional handle arg)
5199 "Put the MIME part under point into a new buffer.
5200 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5202 (interactive (list nil current-prefix-arg))
5203 (gnus-article-check-buffer)
5205 (setq handle (get-text-property (point) 'gnus-data)))
5207 (let ((filename (mm-handle-filename handle))
5208 contents dont-decode charset coding-system)
5209 (mm-with-unibyte-buffer
5210 (mm-insert-part handle)
5211 (setq contents (or (condition-case nil
5212 (mm-decompress-buffer filename nil 'sig)
5214 (setq dont-decode t)
5217 (setq filename (cond (filename (file-name-nondirectory filename))
5218 (dont-decode "*raw data*")
5223 (unless (setq charset (mail-content-type-get
5224 (mm-handle-type handle) 'charset))
5225 (unless (setq coding-system (mm-with-unibyte-buffer
5227 (mm-find-buffer-file-coding-system)))
5228 (setq charset gnus-newsgroup-charset))))
5230 (setq charset (or (cdr (assq arg
5231 gnus-summary-show-article-charset-alist))
5232 (mm-read-coding-system "Charset: ")))))
5233 (switch-to-buffer (generate-new-buffer filename))
5234 (if (or coding-system
5236 (setq coding-system (mm-charset-to-coding-system charset))
5237 (not (eq coding-system 'ascii))))
5239 (mm-enable-multibyte)
5240 (insert (mm-decode-coding-string contents coding-system))
5241 (setq buffer-file-coding-system
5242 (if (boundp 'last-coding-system-used)
5243 (symbol-value 'last-coding-system-used)
5245 (mm-disable-multibyte)
5247 (setq buffer-file-coding-system mm-binary-coding-system))
5248 ;; We do it this way to make `normal-mode' set the appropriate mode.
5251 (setq buffer-file-name (expand-file-name filename))
5253 (setq buffer-file-name nil))
5254 (goto-char (point-min)))))
5256 (defun gnus-mime-print-part (&optional handle filename)
5257 "Print the MIME part under point."
5258 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5259 (gnus-article-check-buffer)
5260 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5261 (contents (and handle (mm-get-part handle)))
5262 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5263 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5268 (mm-save-part-to-file handle file)
5269 (call-process shell-file-name nil
5270 (generate-new-buffer " *mm*")
5272 shell-command-switch
5274 printer file (mm-handle-type handle))))
5278 (gnus-print-buffer))
5279 (ps-despool filename)))))
5281 (defun gnus-mime-inline-part (&optional handle arg)
5282 "Insert the MIME part under point into the current buffer.
5283 Compressed files like .gz and .bz2 are decompressed."
5284 (interactive (list nil current-prefix-arg))
5285 (gnus-article-check-buffer)
5287 (setq handle (get-text-property (point) 'gnus-data)))
5290 (inhibit-read-only t)
5291 contents charset coding-system)
5292 (if (and (not arg) (mm-handle-undisplayer handle))
5293 (mm-remove-part handle)
5294 (mm-with-unibyte-buffer
5295 (mm-insert-part handle)
5297 (or (mm-decompress-buffer (mm-handle-filename handle) nil t)
5301 (unless (setq charset (mail-content-type-get
5302 (mm-handle-type handle) 'charset))
5303 (unless (setq coding-system
5304 (mm-with-unibyte-buffer
5306 (mm-find-buffer-file-coding-system)))
5307 (setq charset gnus-newsgroup-charset))))
5309 (if (mm-handle-undisplayer handle)
5310 (mm-remove-part handle))
5313 gnus-summary-show-article-charset-alist))
5314 (mm-read-coding-system "Charset: "))))
5316 (if (mm-handle-undisplayer handle)
5317 (mm-remove-part handle))))
5319 (mm-display-inline handle)
5322 (defun gnus-mime-set-charset-parameters (handle charset)
5323 "Set CHARSET to parameters in HANDLE.
5324 CHARSET may either be a string or a symbol."
5325 (unless (stringp charset)
5326 (setq charset (symbol-name charset)))
5327 (if (stringp (car handle))
5328 (dolist (h (cdr handle))
5329 (gnus-mime-set-charset-parameters h charset))
5330 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5331 "message/external-body")
5333 (unless (mm-handle-cache handle)
5334 (mm-extern-cache-contents handle))
5335 (mm-handle-cache handle))
5337 (param (assq 'charset (cdr type))))
5339 (setcdr param charset)
5340 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5342 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5343 "Insert the MIME part under point into the current buffer using the
5345 (interactive (list nil current-prefix-arg))
5346 (gnus-article-check-buffer)
5347 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5348 (fun (get-text-property (point) 'gnus-callback))
5349 (gnus-newsgroup-ignored-charsets 'gnus-all)
5350 charset form preferred parts)
5357 gnus-summary-show-article-charset-alist))
5358 (mm-read-coding-system "Charset: "))))
5359 (if (mm-handle-undisplayer handle)
5360 (mm-remove-part handle)))
5361 (gnus-mime-set-charset-parameters handle charset)
5362 (when (and (consp (setq form (cdr-safe fun)))
5363 (setq form (ignore-errors
5364 (assq 'gnus-mime-display-alternative form)))
5365 (setq preferred (caddr form))
5367 (when (eq (car preferred) 'quote)
5368 (setq preferred (cadr preferred)))
5369 (not (equal preferred
5370 (get-text-property (point) 'gnus-data))))
5371 (setq parts (get-text-property (point) 'gnus-part))
5372 (setq parts (cdr (assq parts
5373 gnus-article-mime-handle-alist)))
5374 (equal (mm-handle-media-type parts) "multipart/alternative")
5375 (setq parts (reverse (cdr parts))))
5377 (list 'quote (or (cadr (member preferred parts))
5379 (funcall fun handle)))))
5381 (defun gnus-mime-view-part-externally (&optional handle)
5382 "View the MIME part under point with an external viewer."
5384 (gnus-article-check-buffer)
5385 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5386 (mm-user-display-methods nil)
5387 (mm-inlined-types nil)
5388 (mail-parse-charset gnus-newsgroup-charset)
5389 (mail-parse-ignored-charsets
5390 (with-current-buffer gnus-summary-buffer
5391 gnus-newsgroup-ignored-charsets))
5392 (type (mm-handle-media-type handle))
5393 (method (mailcap-mime-info type))
5394 (mm-enable-external t))
5395 (if (not (stringp method))
5396 (gnus-mime-view-part-as-type
5397 nil (lambda (type) (stringp (mailcap-mime-info type))))
5399 (mm-display-part handle nil t)))))
5401 (defun gnus-mime-view-part-internally (&optional handle)
5402 "View the MIME part under point with an internal viewer.
5403 If no internal viewer is available, use an external viewer."
5405 (gnus-article-check-buffer)
5406 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5407 (mm-inlined-types '(".*"))
5408 (mm-inline-large-images t)
5409 (mail-parse-charset gnus-newsgroup-charset)
5410 (mail-parse-ignored-charsets
5411 (with-current-buffer gnus-summary-buffer
5412 gnus-newsgroup-ignored-charsets))
5413 (inhibit-read-only t))
5414 (if (not (mm-inlinable-p handle))
5415 (gnus-mime-view-part-as-type
5416 nil (lambda (type) (mm-inlinable-p handle type)))
5418 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5420 (defun gnus-mime-action-on-part (&optional action)
5421 "Do something with the MIME attachment at \(point\)."
5423 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5424 (gnus-article-check-buffer)
5425 (let ((action-pair (assoc action gnus-mime-action-alist)))
5427 (funcall (cdr action-pair)))))
5429 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5430 "Call FUNCTION on MIME part N.
5431 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5432 If INTERACTIVE, call FUNCTION interactively."
5434 ;; Check whether the article is displayed.
5435 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5436 (setq window (get-buffer-window gnus-article-buffer t))
5437 (frame-visible-p (setq frame (window-frame window))))
5438 (error "No article is displayed"))
5439 (with-current-buffer gnus-article-buffer
5440 ;; Check whether the article displays the right contents.
5441 (unless (with-current-buffer gnus-summary-buffer
5442 (eq gnus-current-article (gnus-summary-article-number)))
5443 (error "You should select the right article first"))
5445 (setq n (prefix-numeric-value n))
5447 (setq n (or (get-text-property pt 'gnus-part)
5449 (get-text-property (1- pt) 'gnus-part))
5450 (get-text-property (prog2
5456 (or (and (setq pt (previous-single-property-change
5459 (next-single-property-change (point) 'gnus-part)
5463 ;; Check whether the specified part exists.
5464 (when (> n (length gnus-article-mime-handle-alist))
5465 (error "No such part")))
5468 ;; To select the window is needed so that the cursor
5469 ;; might be visible on the MIME button.
5470 (select-window (prog1
5472 (setq window (selected-window))
5473 ;; Article may be displayed in the other frame.
5474 (gnus-select-frame-set-input-focus
5477 (setq frame (selected-frame))))))
5478 (when (gnus-article-goto-part n)
5479 ;; We point the cursor and the arrow at the MIME button
5480 ;; when the `function' prompt the user for something.
5481 (unless (and (pos-visible-in-window-p)
5482 (> (count-lines (point) (window-end))
5483 (/ (1- (window-height)) 3)))
5484 (recenter (/ (1- (window-height)) 3)))
5485 (let ((cursor-in-non-selected-windows t)
5486 (overlay-arrow-string "=>")
5487 (overlay-arrow-position (point-marker)))
5490 ((and no-handle interactive)
5491 (call-interactively function))
5496 function (get-text-property (point) 'gnus-data)))
5499 (get-text-property (point) 'gnus-data))))
5500 (set-marker overlay-arrow-position nil)
5501 (unless gnus-auto-select-part
5502 (gnus-select-frame-set-input-focus frame)
5503 (select-window window))))
5505 (if gnus-inhibit-mime-unbuttonizing
5506 ;; This is the default though the program shouldn't reach here.
5507 (error "No such part")
5508 ;; The part which doesn't have the MIME button is selected.
5509 ;; So, we display all the buttons and redo it.
5510 (let ((gnus-inhibit-mime-unbuttonizing t))
5511 (gnus-summary-show-article)
5512 (gnus-article-part-wrapper n function no-handle))))))
5514 (defun gnus-article-pipe-part (n)
5515 "Pipe MIME part N, which is the numerical prefix."
5517 (gnus-article-part-wrapper n 'mm-pipe-part))
5519 (defun gnus-article-save-part (n)
5520 "Save MIME part N, which is the numerical prefix."
5522 (gnus-article-part-wrapper n 'mm-save-part))
5524 (defun gnus-article-interactively-view-part (n)
5525 "View MIME part N interactively, which is the numerical prefix."
5527 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5529 (defun gnus-article-copy-part (n)
5530 "Copy MIME part N, which is the numerical prefix."
5532 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5534 (defun gnus-article-view-part-as-charset (n)
5535 "View MIME part N using a specified charset.
5536 N is the numerical prefix."
5538 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5540 (defun gnus-article-view-part-externally (n)
5541 "View MIME part N externally, which is the numerical prefix."
5543 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5545 (defun gnus-article-inline-part (n)
5546 "Inline MIME part N, which is the numerical prefix."
5548 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5550 (defun gnus-article-save-part-and-strip (n)
5551 "Save MIME part N and replace it with an external body.
5552 N is the numerical prefix."
5554 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5556 (defun gnus-article-replace-part (n)
5557 "Replace MIME part N with an external body.
5558 N is the numerical prefix."
5560 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5562 (defun gnus-article-delete-part (n)
5563 "Delete MIME part N and add some information about the removed part.
5564 N is the numerical prefix."
5566 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5568 (defun gnus-article-view-part-as-type (n)
5569 "Choose a MIME media type, and view part N as such.
5570 N is the numerical prefix."
5572 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5574 (defun gnus-article-mime-match-handle-first (condition)
5577 (dolist (ihandle gnus-article-mime-handle-alist)
5579 ((functionp condition)
5580 (funcall condition (cdr ihandle)))
5581 ((eq condition 'undisplayed)
5582 (not (or (mm-handle-undisplayer (cdr ihandle))
5583 (equal (mm-handle-media-type (cdr ihandle))
5584 "multipart/alternative"))))
5585 ((eq condition 'undisplayed-alternative)
5586 (not (mm-handle-undisplayer (cdr ihandle))))
5588 (gnus-article-goto-part (car ihandle))
5589 (or (not n) (< (car ihandle) n)))
5590 (setq n (car ihandle))))
5594 (defun gnus-article-view-part (&optional n)
5595 "View MIME part N, which is the numerical prefix.
5596 If the part is already shown, hide the part. If N is nil, view
5599 (with-current-buffer gnus-article-buffer
5600 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5601 gnus-article-mime-match-handle-function)))
5602 (when (> n (length gnus-article-mime-handle-alist))
5603 (error "No such part"))
5604 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5605 (when (gnus-article-goto-part n)
5606 (if (equal (car handle) "multipart/alternative")
5607 (gnus-article-press-button)
5608 (when (eq (gnus-mm-display-part handle) 'internal)
5609 (gnus-set-window-start)))))))
5611 (defsubst gnus-article-mime-total-parts ()
5612 (if (bufferp (car gnus-article-mime-handles))
5614 (1- (length gnus-article-mime-handles))))
5616 (defun gnus-mm-display-part (handle)
5617 "Display HANDLE and fix MIME button."
5618 (let ((id (get-text-property (point) 'gnus-part))
5620 (inhibit-read-only t))
5623 (let ((window (selected-window))
5624 (mail-parse-charset gnus-newsgroup-charset)
5625 (mail-parse-ignored-charsets
5626 (if (gnus-buffer-live-p gnus-summary-buffer)
5627 (with-current-buffer gnus-summary-buffer
5628 gnus-newsgroup-ignored-charsets)
5632 (let ((win (gnus-get-buffer-window (current-buffer) t))
5635 (select-window win))
5638 (if (mm-handle-displayed-p handle)
5639 ;; This will remove the part.
5640 (mm-display-part handle)
5642 (narrow-to-region (point)
5643 (if (eobp) (point) (1+ (point))))
5644 (gnus-bind-safe-url-regexp (mm-display-part handle))
5645 ;; We narrow to the part itself and
5646 ;; then call the treatment functions.
5647 (goto-char (point-min))
5649 (narrow-to-region (point) (point-max))
5652 (gnus-article-mime-total-parts)
5653 (mm-handle-media-type handle)))))
5654 (if (window-live-p window)
5655 (select-window window)))))
5658 (gnus-insert-mime-button
5659 handle id (list (mm-handle-displayed-p handle)))
5660 (goto-char point))))
5662 (defun gnus-article-goto-part (n)
5663 "Go to MIME part N."
5664 (when gnus-break-pages
5667 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5668 part handle end next handles)
5671 (if (setq handle (get-text-property start 'gnus-data))
5673 ;; Go to the displayed subpart, assuming this is
5674 ;; multipart/alternative.
5677 (while (and (not handle)
5680 (setq next (text-property-not-all part end
5683 handle (get-text-property part 'gnus-data))
5684 (push (cons handle part) handles)
5685 (unless (mm-handle-displayed-p handle)
5687 part (text-property-any part end 'gnus-data nil))))
5689 ;; No subpart is displayed, so we find preferred one.
5691 (cdr (assq (mm-preferred-alternative
5692 (nreverse (mapcar 'car handles)))
5695 (goto-char (1+ part))
5697 (when gnus-break-pages
5698 (gnus-narrow-to-page))))
5700 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5701 (let ((gnus-tmp-name
5702 (or (mm-handle-filename handle)
5703 (mail-content-type-get (mm-handle-type handle) 'url)
5705 (gnus-tmp-type (mm-handle-media-type handle))
5706 (gnus-tmp-description (or (mm-handle-description handle) ""))
5708 (if (if displayed (car displayed)
5709 (mm-handle-displayed-p handle))
5711 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5713 gnus-tmp-type-long b e)
5714 (when (string-match ".*/" gnus-tmp-name)
5715 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5716 (setq gnus-tmp-type-long (concat gnus-tmp-type
5717 (and (not (equal gnus-tmp-name ""))
5718 (concat "; " gnus-tmp-name))))
5719 (unless (equal gnus-tmp-description "")
5720 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5725 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5726 `(keymap ,gnus-mime-button-map
5727 gnus-callback gnus-mm-display-part
5728 gnus-part ,gnus-tmp-id
5729 article-type annotation
5733 ;; Exclude a newline.
5736 (when gnus-article-button-face
5737 (gnus-overlay-put (gnus-make-overlay b e nil t)
5738 'face gnus-article-button-face))
5739 (widget-convert-button
5742 :action 'gnus-widget-press-button
5743 :button-keymap gnus-mime-button-map
5746 ;; Needed to properly clear the message due to a bug in
5747 ;; wid-edit (XEmacs only).
5748 (if (boundp 'help-echo-owns-message)
5749 (setq help-echo-owns-message t))
5751 "%S: %s the MIME part; %S: more options"
5752 (aref gnus-mouse-2 0)
5753 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5755 (aref gnus-down-mouse-3 0))))))
5757 (defun gnus-widget-press-button (elems el)
5758 (goto-char (widget-get elems :from))
5759 (gnus-article-press-button))
5761 (defvar gnus-displaying-mime nil)
5763 (defun gnus-display-mime (&optional ihandles)
5764 "Display the MIME parts."
5766 (save-selected-window
5767 (let ((window (get-buffer-window gnus-article-buffer))
5770 (select-window window)
5771 ;; We have to do this since selecting the window
5772 ;; may change the point. So we set the window point.
5773 (set-window-point window point)))
5774 (let ((handles ihandles)
5775 (inhibit-read-only t)
5778 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5779 (when gnus-article-emulate-mime
5780 (mm-uu-dissect-text-parts handles)))
5781 (gnus-article-emulate-mime
5782 (setq handles (mm-uu-dissect))))
5783 (when (and (not ihandles)
5784 (not gnus-displaying-mime))
5785 ;; Top-level call; we clean up.
5786 (when gnus-article-mime-handles
5787 (mm-destroy-parts gnus-article-mime-handles)
5788 (setq gnus-article-mime-handle-alist nil));; A trick.
5789 (setq gnus-article-mime-handles handles)
5790 ;; We allow users to glean info from the handles.
5791 (when gnus-article-mime-part-function
5792 (gnus-mime-part-function handles)))
5794 (or (not (stringp (car handles)))
5797 (when (and (not ihandles)
5798 (not gnus-displaying-mime))
5799 ;; Clean up for mime parts.
5801 (delete-region (point) (point-max)))
5802 (let ((gnus-displaying-mime t))
5803 (gnus-mime-display-part handles)))
5806 (narrow-to-region (point) (point-max))
5807 (gnus-treat-article nil 1 1 "text/plain")
5810 ;; Highlight the headers.
5814 (narrow-to-region (point-min) (point))
5815 (gnus-article-save-original-date
5816 (gnus-treat-article 'head)))))))
5817 ;; Cope with broken MIME messages.
5818 (goto-char (point-max))
5822 (defcustom gnus-mime-display-multipart-as-mixed nil
5823 "Display \"multipart\" parts as \"multipart/mixed\".
5825 If t, it overrides nil values of
5826 `gnus-mime-display-multipart-alternative-as-mixed' and
5827 `gnus-mime-display-multipart-related-as-mixed'."
5828 :group 'gnus-article-mime
5831 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5832 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5834 :group 'gnus-article-mime
5837 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5838 "Display \"multipart/related\" parts as \"multipart/mixed\".
5840 If displaying \"text/html\" is discouraged \(see
5841 `mm-discouraged-alternatives'\) images or other material inside a
5842 \"multipart/related\" part might be overlooked when this variable is nil."
5844 :group 'gnus-article-mime
5847 (defun gnus-mime-display-part (handle)
5849 ;; Maybe a broken MIME message.
5852 ((not (stringp (car handle)))
5853 (gnus-mime-display-single handle))
5854 ;; User-defined multipart
5855 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5856 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5858 ;; multipart/alternative
5859 ((and (equal (car handle) "multipart/alternative")
5860 (not (or gnus-mime-display-multipart-as-mixed
5861 gnus-mime-display-multipart-alternative-as-mixed)))
5862 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5863 (push (cons id handle) gnus-article-mime-handle-alist)
5864 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5865 ;; multipart/related
5866 ((and (equal (car handle) "multipart/related")
5867 (not (or gnus-mime-display-multipart-as-mixed
5868 gnus-mime-display-multipart-related-as-mixed)))
5869 ;;;!!!We should find the start part, but we just default
5870 ;;;!!!to the first part.
5871 ;;(gnus-mime-display-part (cadr handle))
5872 ;;;!!! Most multipart/related is an HTML message plus images.
5873 ;;;!!! Unfortunately we are unable to let W3 display those
5874 ;;;!!! included images, so we just display it as a mixed multipart.
5875 ;;(gnus-mime-display-mixed (cdr handle))
5876 ;;;!!! No, w3 can display everything just fine.
5877 (gnus-mime-display-part (cadr handle)))
5878 ((equal (car handle) "multipart/signed")
5879 (gnus-add-wash-type 'signed)
5880 (gnus-mime-display-security handle))
5881 ((equal (car handle) "multipart/encrypted")
5882 (gnus-add-wash-type 'encrypted)
5883 (gnus-mime-display-security handle))
5884 ;; Other multiparts are handled like multipart/mixed.
5886 (gnus-mime-display-mixed (cdr handle)))))
5888 (defun gnus-mime-part-function (handles)
5889 (if (stringp (car handles))
5890 (mapcar 'gnus-mime-part-function (cdr handles))
5891 (funcall gnus-article-mime-part-function handles)))
5893 (defun gnus-mime-display-mixed (handles)
5894 (mapcar 'gnus-mime-display-part handles))
5896 (defun gnus-mime-display-single (handle)
5897 (let ((type (mm-handle-media-type handle))
5898 (ignored gnus-ignored-mime-types)
5905 (when (string-match (pop ignored) type)
5906 (throw 'ignored nil)))
5907 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
5908 (with-current-buffer gnus-summary-buffer
5909 gnus-inhibit-images)
5910 gnus-inhibit-images)
5911 (string-match "\\`image/" type)))
5912 (setq not-attachment
5913 (and (not (mm-inline-override-p handle))
5914 (or (not (mm-handle-disposition handle))
5915 (equal (car (mm-handle-disposition handle))
5917 (mm-attachment-override-p handle))))
5918 (mm-automatic-display-p handle)
5920 (mm-inlinable-p handle)
5921 (mm-inlined-p handle))
5922 (mm-automatic-external-display-p type)))
5924 (when (equal (mm-handle-media-supertype handle) "text")
5926 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5928 (push (cons id handle) gnus-article-mime-handle-alist)
5930 (equal (mm-handle-media-supertype handle) "message"))
5933 (cond ((not (bolp)) 2)
5934 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5936 (when (or (not display)
5937 (not (gnus-unbuttonized-mime-type-p type))
5938 (eq id gnus-mime-buttonized-part-id))
5939 (gnus-insert-mime-button
5940 handle id (list (or display (and not-attachment text))))
5941 (gnus-article-insert-newline)
5942 ;; Remember modify the number of forward lines.
5950 (let ((mail-parse-charset gnus-newsgroup-charset)
5951 (mail-parse-ignored-charsets
5952 (save-excursion (condition-case ()
5953 (set-buffer gnus-summary-buffer)
5955 gnus-newsgroup-ignored-charsets)))
5956 (gnus-bind-safe-url-regexp (mm-display-part handle t)))
5957 (goto-char (point-max)))
5958 ((and text not-attachment)
5962 (gnus-article-insert-newline)
5963 (mm-display-inline handle)
5964 (goto-char (point-max))))
5968 (narrow-to-region beg (point))
5969 (if (eq handle gnus-article-mime-handles)
5970 ;; The format=flowed case.
5971 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5972 ;; Don't count signature parts that are never displayed.
5973 ;; The part number should be re-calculated supposing this
5974 ;; might be a message/rfc822 part.
5976 (dolist (part gnus-article-mime-handles)
5977 (unless (or (stringp part)
5978 (equal (car (mm-handle-type part))
5979 "application/pgp-signature"))
5980 (push part handles)))
5982 nil (length (memq handle handles)) (length handles)
5983 (mm-handle-media-type handle)))))))))))
5985 (defun gnus-unbuttonized-mime-type-p (type)
5986 "Say whether TYPE is to be unbuttonized."
5987 (unless gnus-inhibit-mime-unbuttonizing
5989 (let ((types gnus-unbuttonized-mime-types))
5991 (when (string-match (pop types) type)
5992 (throw 'found t)))))
5994 (let ((types gnus-buttonized-mime-types))
5996 (when (string-match (pop types) type)
5997 (throw 'found t)))))))))
5999 (defun gnus-article-insert-newline ()
6000 "Insert a newline, but mark it as undeletable."
6001 (gnus-put-text-property
6002 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6004 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6005 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6008 handle (inhibit-read-only t) from props begend not-pref)
6009 (save-window-excursion
6012 (narrow-to-region (car ibegend)
6015 (goto-char (car ibegend))
6018 (delete-region (point-min) (point-max))
6019 (mm-remove-parts handles))
6020 (setq begend (list (point-marker)))
6022 (unless (setq not-pref (cadr (member preferred ihandles)))
6023 (setq not-pref (car ihandles)))
6026 (not (gnus-unbuttonized-mime-type-p
6027 "multipart/alternative")))
6028 (gnus-add-text-properties
6031 (insert (format "%d. " id))
6035 (unless ,(not ibegend)
6036 (setq gnus-article-mime-handle-alist
6037 ',gnus-article-mime-handle-alist))
6038 (gnus-mime-display-alternative
6039 ',ihandles ',not-pref ',begend ,id))
6040 keymap ,gnus-mime-button-map
6041 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6042 face ,gnus-article-button-face
6044 article-type multipart
6046 (widget-convert-button 'link from (point)
6047 :action 'gnus-widget-press-button
6048 :button-keymap gnus-widget-button-keymap)
6050 (while (setq handle (pop handles))
6051 (gnus-add-text-properties
6054 (insert (format "(%c) %-18s"
6055 (if (equal handle preferred) ?* ? )
6056 (mm-handle-media-type handle)))
6060 (unless ,(not ibegend)
6061 (setq gnus-article-mime-handle-alist
6062 ',gnus-article-mime-handle-alist))
6063 (gnus-mime-display-alternative
6064 ',ihandles ',handle ',begend ,id))
6065 keymap ,gnus-mime-button-map
6066 ,gnus-mouse-face-prop ,gnus-article-mouse-face
6067 face ,gnus-article-button-face
6071 (widget-convert-button 'link from (point)
6072 :action 'gnus-widget-press-button
6073 :button-keymap gnus-widget-button-keymap)
6077 (if (stringp (car preferred))
6078 (gnus-display-mime preferred)
6079 (let ((mail-parse-charset gnus-newsgroup-charset)
6080 (mail-parse-ignored-charsets
6081 (with-current-buffer gnus-summary-buffer
6082 gnus-newsgroup-ignored-charsets)))
6083 (gnus-bind-safe-url-regexp (mm-display-part preferred))
6087 (narrow-to-region (car begend) (point-max))
6089 nil (length gnus-article-mime-handle-alist)
6090 (gnus-article-mime-total-parts)
6091 (mm-handle-media-type preferred))))))
6092 (goto-char (point-max))
6093 (setcdr begend (point-marker)))))
6095 (goto-char point))))
6097 (defconst gnus-article-wash-status-strings
6098 (let ((alist '((cite "c" "Possible hidden citation text"
6099 " " "All citation text visible")
6100 (headers "h" "Hidden headers"
6101 " " "All headers visible.")
6102 (pgp "p" "Encrypted or signed message status hidden"
6103 " " "No hidden encryption nor digital signature status")
6104 (signature "s" "Signature has been hidden"
6105 " " "Signature is visible")
6106 (overstrike "o" "Overstrike (^H) characters applied"
6107 " " "No overstrike characters applied")
6108 (emphasis "e" "/*_Emphasis_*/ characters applied"
6109 " " "No /*_emphasis_*/ characters applied")))
6111 (dolist (entry alist result)
6112 (let ((key (nth 0 entry))
6113 (on (copy-sequence (nth 1 entry)))
6114 (on-help (nth 2 entry))
6115 (off (copy-sequence (nth 3 entry)))
6116 (off-help (nth 4 entry)))
6117 (put-text-property 0 1 'help-echo on-help on)
6118 (put-text-property 0 1 'help-echo off-help off)
6119 (push (list key on off) result))))
6120 "Alist of strings describing wash status in the mode line.
6121 Each entry has the form (KEY ON OF), where the KEY is a symbol
6122 representing the particular washing function, ON is the string to use
6123 in the article mode line when the washing function is active, and OFF
6124 is the string to use when it is inactive.")
6126 (defun gnus-article-wash-status-entry (key value)
6127 (let ((entry (assoc key gnus-article-wash-status-strings)))
6128 (if value (nth 1 entry) (nth 2 entry))))
6130 (defun gnus-article-wash-status ()
6131 "Return a string which display status of article washing."
6132 (with-current-buffer gnus-article-buffer
6133 (let ((cite (memq 'cite gnus-article-wash-types))
6134 (headers (memq 'headers gnus-article-wash-types))
6135 (boring (memq 'boring-headers gnus-article-wash-types))
6136 (pgp (memq 'pgp gnus-article-wash-types))
6137 (pem (memq 'pem gnus-article-wash-types))
6138 (signed (memq 'signed gnus-article-wash-types))
6139 (encrypted (memq 'encrypted gnus-article-wash-types))
6140 (signature (memq 'signature gnus-article-wash-types))
6141 (overstrike (memq 'overstrike gnus-article-wash-types))
6142 (emphasis (memq 'emphasis gnus-article-wash-types)))
6144 (gnus-article-wash-status-entry 'cite cite)
6145 (gnus-article-wash-status-entry 'headers (or headers boring))
6146 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6147 (gnus-article-wash-status-entry 'signature signature)
6148 (gnus-article-wash-status-entry 'overstrike overstrike)
6149 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6151 (defun gnus-add-wash-type (type)
6152 "Add a washing of TYPE to the current status."
6153 (add-to-list 'gnus-article-wash-types type))
6155 (defun gnus-delete-wash-type (type)
6156 "Add a washing of TYPE to the current status."
6157 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6159 (defun gnus-add-image (category image)
6160 "Add IMAGE of CATEGORY to the list of displayed images."
6161 (let ((entry (assq category gnus-article-image-alist)))
6163 (setq entry (list category))
6164 (push entry gnus-article-image-alist))
6165 (nconc entry (list image))))
6167 (defun gnus-delete-images (category)
6168 "Delete all images in CATEGORY."
6169 (let ((entry (assq category gnus-article-image-alist)))
6170 (dolist (image (cdr entry))
6171 (gnus-remove-image image category))
6172 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6173 (gnus-delete-wash-type category)))
6175 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6177 (defun gnus-article-maybe-hide-headers ()
6178 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6179 Provided for backwards compatibility."
6180 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6181 (not (with-current-buffer gnus-summary-buffer
6182 gnus-have-all-headers)))
6183 (not gnus-inhibit-hiding))
6184 (gnus-article-hide-headers)))
6186 (declare-function shr-put-image "shr" (data alt))
6188 (defun gnus-shr-put-image (data alt)
6189 "Put image DATA with a string ALT. Enable image to be deleted."
6190 (let ((image (shr-put-image data (propertize (or alt "*")
6191 'gnus-image-category 'shr))))
6193 (gnus-add-image 'shr image))))
6197 (defun gnus-output-to-file (file-name)
6198 "Append the current article to a file named FILE-NAME.
6199 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6200 text and used as the value of the coding cookie which is added to the
6201 top of a file. Otherwise, this function saves a raw article without
6203 (let* ((artbuf (current-buffer))
6204 (file-name-coding-system nnmail-pathname-coding-system)
6205 (coding gnus-article-save-coding-system)
6206 (coding-system-for-read (if coding
6207 nil ;; Rely on the coding cookie.
6208 mm-text-coding-system))
6209 (coding-system-for-write (or coding
6210 mm-text-coding-system-for-write
6211 mm-text-coding-system))
6212 (exists (file-exists-p file-name)))
6215 (insert-file-contents file-name)
6216 (goto-char (point-min))
6217 ;; Remove the existing coding cookie.
6218 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6219 (delete-region (match-beginning 0) (match-end 0))))
6220 (goto-char (point-max))
6221 (insert-buffer-substring artbuf)
6222 ;; Append newline at end of the buffer as separator, and then
6224 (goto-char (point-max))
6227 ;; If the coding system is not suitable to encode the text,
6228 ;; ask a user for a proper one.
6229 (when (fboundp 'select-safe-coding-system)
6230 (setq coding (coding-system-base
6231 (save-window-excursion
6232 (select-safe-coding-system (point-min) (point-max)
6234 (setq coding-system-for-write
6235 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6237 (goto-char (point-min))
6238 ;; Add the coding cookie.
6239 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6240 coding-system-for-write)))
6243 (write-region (point-min) (point-max) file-name nil 'no-message)
6244 (message "Appended to %s" file-name))
6245 (write-region (point-min) (point-max) file-name))))
6248 (defun gnus-narrow-to-page (&optional arg)
6249 "Narrow the article buffer to a page.
6250 If given a numerical ARG, move forward ARG pages."
6252 (setq arg (if arg (prefix-numeric-value arg) 0))
6253 (with-current-buffer gnus-article-buffer
6255 ;; Remove any old next/prev buttons.
6256 (when (gnus-visual-p 'page-marker)
6257 (let ((inhibit-read-only t))
6258 (gnus-remove-text-with-property 'gnus-prev)
6259 (gnus-remove-text-with-property 'gnus-next)))
6261 (when (save-excursion
6263 (if (re-search-backward page-delimiter nil 'move (abs arg))
6265 (setq nd (match-beginning 0)
6267 (when (re-search-backward page-delimiter nil t)
6268 (setq st (match-end 0))))
6269 (when (re-search-forward page-delimiter nil t)
6270 (setq nd (match-beginning 0)
6273 (if (re-search-forward page-delimiter nil 'move arg)
6275 (setq st (match-end 0)
6277 (when (re-search-forward page-delimiter nil t)
6278 (setq nd (match-beginning 0))))
6279 (when (re-search-backward page-delimiter nil t)
6280 (setq st (match-end 0)
6283 (when (re-search-backward page-delimiter nil t)
6284 (goto-char (setq st (match-end 0))))
6285 (when (re-search-forward page-delimiter nil t)
6286 (setq nd (match-beginning 0)))
6288 (setq gnus-page-broken t)
6289 (when pt (goto-char pt))
6290 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6291 (when (gnus-visual-p 'page-marker)
6295 (gnus-insert-next-page-button))
6298 (gnus-insert-prev-page-button))))))))
6300 ;; Article mode commands
6302 (defun gnus-article-goto-next-page ()
6303 "Show the next page of the article."
6305 (when (gnus-article-next-page)
6306 (goto-char (point-min))
6307 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
6310 (defun gnus-article-goto-prev-page ()
6311 "Show the previous page of the article."
6313 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6314 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
6315 (gnus-article-prev-page nil)))
6317 ;; This is cleaner but currently breaks `gnus-pick-mode':
6319 ;; (defun gnus-article-goto-next-page ()
6320 ;; "Show the next page of the article."
6322 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6323 ;; (gnus-summary-next-page)))
6325 ;; (defun gnus-article-goto-prev-page ()
6326 ;; "Show the next page of the article."
6328 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6329 ;; (gnus-summary-prev-page)))
6331 (defun gnus-article-next-page (&optional lines)
6332 "Show the next page of the current article.
6333 If end of article, return non-nil. Otherwise return nil.
6334 Argument LINES specifies lines to be scrolled up."
6336 (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin)))
6337 (if (and (not (and gnus-article-over-scroll
6338 (> (count-lines (window-start) (point-max))
6339 (if (featurep 'xemacs)
6340 (or lines (1- (window-height)))
6341 (+ (or lines (1- (window-height))) scroll-margin)))))
6344 (and (pos-visible-in-window-p) ;Not continuation line.
6345 (>= (point) (point-max)))))
6346 ;; Nothing in this page.
6347 (if (or (not gnus-page-broken)
6352 (eobp)))) ;Real end-of-buffer?
6354 (when gnus-article-over-scroll
6355 (gnus-article-next-page-1 lines))
6357 (gnus-narrow-to-page 1) ;Go to next page.
6359 ;; More in this page.
6360 (gnus-article-next-page-1 lines)
6363 (defun gnus-article-beginning-of-window ()
6364 "Move point to the beginning of the window.
6365 In Emacs, the point is placed at the line number which `scroll-margin'
6367 (if (featurep 'xemacs)
6368 (move-to-window-line 0)
6369 ;; There is an obscure bug in Emacs that makes it impossible to
6370 ;; scroll past big pictures in the article buffer. Try to fix
6371 ;; this by adding a sanity check by counting the lines visible.
6372 (when (> (count-lines (window-start) (window-end)) 30)
6373 (move-to-window-line
6374 (min (max 0 scroll-margin)
6375 (max 1 (- (window-height)
6376 (if mode-line-format 1 0)
6377 (if header-line-format 1 0)
6380 (defun gnus-article-next-page-1 (lines)
6382 (let ((scroll-in-place nil)
6383 (auto-window-vscroll nil))
6386 ;; Long lines may cause an end-of-buffer error.
6387 (goto-char (point-max))))
6388 (gnus-article-beginning-of-window))
6390 (defun gnus-article-prev-page (&optional lines)
6391 "Show previous page of current article.
6392 Argument LINES specifies lines to be scrolled down."
6394 (move-to-window-line 0)
6395 (if (and gnus-page-broken
6397 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6399 (gnus-narrow-to-page -1) ;Go to previous page.
6400 (goto-char (point-max))
6401 (recenter (if gnus-article-over-scroll
6403 (max (if (featurep 'xemacs)
6405 (+ lines scroll-margin))
6407 (- (window-height) 2))
6411 (let ((scroll-in-place nil))
6412 (scroll-down lines))
6413 (beginning-of-buffer
6414 (goto-char (point-min))))
6415 (gnus-article-beginning-of-window))))
6417 (defun gnus-article-only-boring-p ()
6418 "Decide whether there is only boring text remaining in the article.
6419 Something \"interesting\" is a word of at least two letters that does
6420 not have a face in `gnus-article-boring-faces'."
6421 (when (and gnus-article-skip-boring
6422 (boundp 'gnus-article-boring-faces)
6423 (symbol-value 'gnus-article-boring-faces))
6425 (let ((inhibit-point-motion-hooks t))
6427 (while (re-search-forward "\\b\\w\\w" nil t)
6429 (when (not (gnus-intersection
6430 (gnus-faces-at (point))
6431 (symbol-value 'gnus-article-boring-faces)))
6432 (throw 'only-boring nil)))
6433 (throw 'only-boring t))))))
6435 (defun gnus-article-refer-article ()
6436 "Read article specified by message-id around point."
6439 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6440 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6441 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6442 (let ((msg-id (concat "<" (match-string 0) ">")))
6443 (set-buffer gnus-summary-buffer)
6444 (gnus-summary-refer-article msg-id))
6445 (error "No references around point"))))
6447 (defun gnus-article-show-summary ()
6448 "Reconfigure windows to show summary buffer."
6450 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6451 (error "There is no summary buffer for this article buffer")
6452 (gnus-article-set-globals)
6453 (gnus-configure-windows 'article)
6454 (gnus-summary-goto-subject gnus-current-article)
6455 (gnus-summary-position-point)))
6457 (defun gnus-article-describe-briefly ()
6458 "Describe article mode commands briefly."
6460 (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")))
6462 (defun gnus-article-check-buffer ()
6463 "Beep if not in an article buffer."
6464 (unless (equal major-mode 'gnus-article-mode)
6465 (error "Command invoked outside of a Gnus article buffer")))
6467 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6468 "Read a summary buffer key sequence and execute it from the article buffer."
6470 (gnus-article-check-buffer)
6472 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6473 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6474 "=" "^" "\M-^" "|"))
6476 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6477 "An" "Ap" [?A (meta return)] [?A delete]))
6481 '("n" "Gn" "p" "Gp"))
6483 (with-current-buffer gnus-article-current-summary
6484 (let (gnus-pick-mode)
6485 (setq unread-command-events (nconc unread-command-events
6486 (list (or key last-command-event)))
6487 keys (if (featurep 'xemacs)
6488 (events-to-keys (read-key-sequence nil t))
6489 (read-key-sequence nil t)))))
6494 ((eq (aref keys (1- (length keys))) ?\C-h)
6495 (gnus-article-describe-bindings (substring keys 0 -1)))
6496 ((or (member keys nosaves)
6497 (member keys nosave-but-article)
6498 (member keys nosave-in-article))
6500 (save-window-excursion
6501 (pop-to-buffer gnus-article-current-summary)
6502 ;; We disable the pick minor mode commands.
6503 (let (gnus-pick-mode)
6504 (setq func (key-binding keys t))))
6508 (unless (member keys nosave-in-article)
6509 (set-buffer gnus-article-current-summary))
6510 (when (get func 'disabled)
6511 (error "Function %s disabled" func))
6512 (call-interactively func)
6513 (setq new-sum-point (point)))
6514 (when (member keys nosave-but-article)
6515 (pop-to-buffer gnus-article-buffer))))
6517 ;; These commands should restore window configuration.
6518 (let ((obuf (current-buffer))
6519 (owin (current-window-configuration))
6520 win func in-buffer selected new-sum-start new-sum-hscroll err)
6521 (cond (not-restore-window
6522 (pop-to-buffer gnus-article-current-summary)
6523 (setq win (selected-window)))
6524 ((setq win (get-buffer-window gnus-article-current-summary))
6525 (select-window win))
6527 (let ((summary-buffer gnus-article-current-summary))
6528 (gnus-configure-windows 'article)
6529 (unless (setq win (get-buffer-window summary-buffer 'visible))
6530 (let ((gnus-buffer-configuration
6531 '((article ((vertical 1.0
6532 (summary 0.25 point)
6534 (gnus-configure-windows 'article))
6535 (setq win (get-buffer-window summary-buffer 'visible)))
6536 (gnus-select-frame-set-input-focus (window-frame win))
6537 (select-window win))))
6538 (setq in-buffer (current-buffer))
6539 ;; We disable the pick minor mode commands.
6540 (setq func (let (gnus-pick-mode)
6541 (key-binding keys t)))
6542 (when (get func 'disabled)
6543 (error "Function %s disabled" func))
6546 (condition-case code
6548 (call-interactively func)
6554 (when (eq win (selected-window))
6555 (setq new-sum-point (point)
6556 new-sum-start (window-start win)
6557 new-sum-hscroll (window-hscroll win)))
6558 (when (or (eq in-buffer (current-buffer))
6559 (when (eq obuf (current-buffer))
6560 (set-buffer in-buffer)
6562 (setq selected (gnus-summary-select-article))
6564 (unless not-restore-window
6565 (set-window-configuration owin))
6566 (when (and (eq selected 'old)
6568 (set-window-start (get-buffer-window (current-buffer))
6570 (set-window-point (get-buffer-window (current-buffer))
6571 (if (article-goto-body)
6574 (when (and (not not-restore-window)
6577 (with-current-buffer (window-buffer win)
6578 (eq major-mode 'gnus-summary-mode)))
6579 (set-window-point win new-sum-point)
6580 (set-window-start win new-sum-start)
6581 (set-window-hscroll win new-sum-hscroll))))
6582 (set-window-configuration owin)
6584 (signal (car err) (cdr err))
6587 (defun gnus-article-read-summary-send-keys ()
6589 (let ((unread-command-events (list (gnus-character-to-event ?S))))
6590 (gnus-article-read-summary-keys)))
6592 (defun gnus-article-describe-key (key)
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 (gnus-article-check-buffer)
6598 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6599 gnus-article-read-summary-send-keys))
6600 (with-current-buffer gnus-article-current-summary
6601 (setq unread-command-events
6602 (if (featurep 'xemacs)
6604 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6605 (list 'meta (- x 128))
6608 (let ((cursor-in-echo-area t)
6610 (describe-key (read-key-sequence nil t))))
6611 (describe-key key)))
6613 (defun gnus-article-describe-key-briefly (key &optional insert)
6614 "Display documentation of the function invoked by KEY.
6615 KEY is a string or a vector."
6616 (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs.
6617 (read-key-sequence "Describe key: "))
6618 current-prefix-arg))
6619 (gnus-article-check-buffer)
6620 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6621 gnus-article-read-summary-send-keys))
6622 (with-current-buffer gnus-article-current-summary
6623 (setq unread-command-events
6624 (if (featurep 'xemacs)
6626 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6627 (list 'meta (- x 128))
6630 (let ((cursor-in-echo-area t)
6632 (describe-key-briefly (read-key-sequence nil t) insert)))
6633 (describe-key-briefly key insert)))
6635 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6636 (defvar gnus-agent-summary-mode)
6637 (defvar gnus-draft-mode)
6638 ;; Calling help-buffer will autoload help-mode.
6639 (defvar help-xref-stack-item)
6640 ;; Emacs 22 doesn't load it in the batch mode.
6642 (autoload 'help-buffer "help-mode"))
6644 (defun gnus-article-describe-bindings (&optional prefix)
6645 "Show a list of all defined keys, and their definitions.
6646 The optional argument PREFIX, if non-nil, should be a key sequence;
6647 then we display only bindings that start with that prefix."
6649 (gnus-article-check-buffer)
6650 (let ((keymap (copy-keymap gnus-article-mode-map))
6651 (map (copy-keymap gnus-article-send-map))
6652 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6654 (define-key keymap "S" map)
6655 (define-key map [t] nil)
6656 (with-current-buffer gnus-article-current-summary
6659 (if (setq parent (keymap-parent gnus-article-mode-map))
6661 (setq parent (copy-keymap parent))
6662 (set-keymap-parent parent (current-local-map)))
6663 (current-local-map)))
6664 (set-keymap-parent map (key-binding "S"))
6665 (let (key def gnus-pick-mode)
6667 (setq key (pop sumkeys))
6668 (cond ((and (vectorp key) (= (length key) 1)
6669 (consp (setq def (aref key 0)))
6670 (numberp (car def)) (numberp (cdr def)))
6671 (when (< (max (car def) (cdr def)) 128)
6675 (nreverse (gnus-uncompress-range def)))
6677 ((setq def (key-binding key))
6678 (unless (eq def 'undefined)
6679 (define-key keymap key def))))))
6680 (when (boundp 'gnus-agent-summary-mode)
6681 (setq agent gnus-agent-summary-mode))
6682 (when (boundp 'gnus-draft-mode)
6683 (setq draft gnus-draft-mode)))
6685 (use-local-map keymap)
6686 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6687 (set (make-local-variable 'gnus-draft-mode) draft)
6688 (describe-bindings prefix))
6689 (let ((item `((lambda (prefix)
6690 (with-current-buffer ,(current-buffer)
6691 (gnus-article-describe-bindings prefix)))
6693 (with-current-buffer (let (help-xref-following) (help-buffer))
6694 (setq help-xref-stack-item item)))))
6696 (defun gnus-article-reply-with-original (&optional wide)
6697 "Start composing a reply mail to the current message.
6698 The text in the region will be yanked. If the region isn't active,
6699 the entire article will be yanked."
6701 (let ((article (cdr gnus-article-current))
6703 (if (not (gnus-region-active-p))
6704 (with-current-buffer gnus-summary-buffer
6705 (gnus-summary-reply (list (list article)) wide))
6706 (setq contents (buffer-substring (point) (mark t)))
6707 ;; Deactivate active regions.
6708 (when (and (boundp 'transient-mark-mode)
6709 transient-mark-mode)
6710 (setq mark-active nil))
6711 (with-current-buffer gnus-summary-buffer
6713 (list (list article contents)) wide)))))
6715 (defun gnus-article-wide-reply-with-original ()
6716 "Start composing a wide reply mail to the current message.
6717 The text in the region will be yanked. If the region isn't active,
6718 the entire article will be yanked."
6720 (gnus-article-reply-with-original t))
6722 (defun gnus-article-followup-with-original ()
6723 "Compose a followup to the current article.
6724 The text in the region will be yanked. If the region isn't active,
6725 the entire article will be yanked."
6727 (let ((article (cdr gnus-article-current))
6729 (if (not (gnus-region-active-p))
6730 (with-current-buffer gnus-summary-buffer
6731 (gnus-summary-followup (list (list article))))
6732 (setq contents (buffer-substring (point) (mark t)))
6733 ;; Deactivate active regions.
6734 (when (and (boundp 'transient-mark-mode)
6735 transient-mark-mode)
6736 (setq mark-active nil))
6737 (with-current-buffer gnus-summary-buffer
6738 (gnus-summary-followup
6739 (list (list article contents)))))))
6741 (defun gnus-article-hide (&optional arg force)
6742 "Hide all the gruft in the current article.
6743 This means that signatures, cited text and (some) headers will be
6745 If given a prefix, show the hidden text instead."
6746 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6747 (gnus-article-hide-headers arg)
6748 (gnus-article-hide-list-identifiers arg)
6749 (gnus-article-hide-citation-maybe arg force)
6750 (gnus-article-hide-signature arg))
6752 (defun gnus-article-maybe-highlight ()
6753 "Do some article highlighting if article highlighting is requested."
6754 (when (gnus-visual-p 'article-highlight 'highlight)
6755 (gnus-article-highlight-some)))
6757 (defun gnus-check-group-server ()
6758 ;; Make sure the connection to the server is alive.
6759 (unless (gnus-server-opened
6760 (gnus-find-method-for-group gnus-newsgroup-name))
6761 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6762 (gnus-request-group gnus-newsgroup-name t)))
6765 (autoload 'nneething-get-file-name "nneething"))
6767 (defun gnus-request-article-this-buffer (article group)
6768 "Get an article and insert it into this buffer."
6769 (let (do-update-line sparse-header)
6773 (gnus-kill-all-overlays)
6774 (setq group (or group gnus-newsgroup-name))
6776 ;; Using `gnus-request-article' directly will insert the article into
6777 ;; `nntp-server-buffer' - so we'll save some time by not having to
6778 ;; copy it from the server buffer into the article buffer.
6780 ;; We only request an article by message-id when we do not have the
6781 ;; headers for it, so we'll have to get those.
6782 (when (stringp article)
6783 (gnus-read-header article))
6785 ;; If the article number is negative, that means that this article
6786 ;; doesn't belong in this newsgroup (possibly), so we find its
6787 ;; message-id and request it by id instead of number.
6788 (when (and (numberp article)
6790 (get-buffer gnus-summary-buffer)
6791 (gnus-buffer-exists-p gnus-summary-buffer))
6792 (with-current-buffer gnus-summary-buffer
6793 (let ((header (gnus-summary-article-header article)))
6796 ((memq article gnus-newsgroup-sparse)
6797 ;; This is a sparse gap article.
6798 (setq do-update-line article)
6799 (setq article (mail-header-id header))
6800 (setq sparse-header (gnus-read-header article))
6801 (setq gnus-newsgroup-sparse
6802 (delq article gnus-newsgroup-sparse)))
6804 ;; It's a real article.
6805 (setq article (mail-header-id header)))
6807 ;; It is an extracted pseudo-article.
6808 (setq article 'pseudo)
6809 (gnus-request-pseudo-article header))))
6811 (let ((method (gnus-find-method-for-group
6812 gnus-newsgroup-name)))
6813 (when (and (eq (car method) 'nneething)
6815 (let ((dir (nneething-get-file-name
6816 (mail-header-id header))))
6817 (when (and (stringp dir)
6818 (file-directory-p dir))
6819 (setq article 'nneething)
6820 (gnus-group-enter-directory dir))))))))
6823 ;; Refuse to select canceled articles.
6824 ((and (numberp article)
6826 (get-buffer gnus-summary-buffer)
6827 (gnus-buffer-exists-p gnus-summary-buffer)
6828 (eq (cdr (with-current-buffer gnus-summary-buffer
6829 (assq article gnus-newsgroup-reads)))
6830 gnus-canceled-mark))
6832 ;; We first check `gnus-original-article-buffer'.
6833 ((and (get-buffer gnus-original-article-buffer)
6835 (with-current-buffer gnus-original-article-buffer
6836 (and (equal (car gnus-original-article) group)
6837 (eq (cdr gnus-original-article) article))))
6838 ;; `insert-buffer-substring' would incorrectly use the
6839 ;; equivalent of string-make-multibyte which amount to decoding
6840 ;; with locale-coding-system, causing failure of
6841 ;; subsequent decoding.
6842 (insert (mm-string-to-multibyte
6843 (with-current-buffer gnus-original-article-buffer
6844 (buffer-substring (point-min) (point-max)))))
6846 ;; Check the backlog.
6847 ((and gnus-keep-backlog
6848 (gnus-backlog-request-article group article (current-buffer)))
6850 ;; Check asynchronous pre-fetch.
6851 ((gnus-async-request-fetched-article group article (current-buffer))
6852 (gnus-async-prefetch-next group article gnus-summary-buffer)
6853 (when (and (numberp article) gnus-keep-backlog)
6854 (gnus-backlog-enter-article group article (current-buffer)))
6857 ((and gnus-use-cache
6859 (gnus-cache-request-article article group))
6861 ;; Check the agent cache.
6862 ((gnus-agent-request-article article group)
6864 ;; Get the article and put into the article buffer.
6865 ((or (stringp article)
6867 (let ((gnus-override-method gnus-override-method)
6868 (methods (and (stringp article)
6869 (with-current-buffer gnus-summary-buffer
6870 (gnus-refer-article-methods))))
6871 (backend (car (gnus-find-method-for-group
6872 gnus-newsgroup-name)))
6874 (inhibit-read-only t))
6875 (when (and (null gnus-override-method)
6877 (setq gnus-override-method (pop methods)))
6880 (gnus-kill-all-overlays)
6881 (let ((gnus-newsgroup-name group))
6882 (gnus-check-group-server))
6884 ((gnus-request-article article group (current-buffer))
6885 (when (numberp article)
6886 (gnus-async-prefetch-next group article
6887 gnus-summary-buffer)
6888 (when gnus-keep-backlog
6889 (gnus-backlog-enter-article
6890 group article (current-buffer)))
6891 (when (and gnus-agent
6892 (gnus-agent-group-covered-p group))
6893 (gnus-agent-store-article article group)))
6894 (setq result 'article))
6896 (setq gnus-override-method (pop methods)))
6897 ((not (string-match "^400 "
6898 (nnheader-get-report backend)))
6899 ;; If we get 400 server disconnect, reconnect and
6900 ;; retry; otherwise, assume the article has expired.
6901 (setq result 'done))))
6902 (and (eq result 'article) 'article)))
6906 ;; Associate this article with the current summary buffer.
6907 (setq gnus-article-current-summary gnus-summary-buffer)
6909 ;; Take the article from the original article buffer
6910 ;; and place it in the buffer it's supposed to be in.
6911 (when (and (get-buffer gnus-article-buffer)
6912 (equal (buffer-name (current-buffer))
6913 (buffer-name (get-buffer gnus-article-buffer))))
6915 (if (get-buffer gnus-original-article-buffer)
6916 (set-buffer gnus-original-article-buffer)
6917 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6918 (buffer-disable-undo)
6919 (setq major-mode 'gnus-original-article-mode)
6920 (setq buffer-read-only t))
6921 (let ((inhibit-read-only t))
6923 (insert-buffer-substring gnus-article-buffer))
6924 (setq gnus-original-article (cons group article)))
6927 (run-hooks 'gnus-article-decode-hook)
6928 ;; Mark article as decoded or not.
6929 (setq gnus-article-decoded-p gnus-article-decode-hook))
6931 ;; Update sparse articles.
6932 (when (and do-update-line
6933 (or (numberp article)
6935 (let ((buf (current-buffer)))
6936 (set-buffer gnus-summary-buffer)
6937 (gnus-summary-update-article do-update-line sparse-header)
6938 (gnus-summary-goto-subject do-update-line nil t)
6939 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6941 (set-buffer buf))))))
6943 (defun gnus-block-private-groups (group)
6944 (if (gnus-news-group-p group)
6945 ;; Block nothing in news groups.
6947 ;; Block everything anywhere else.
6950 (defun gnus-blocked-images ()
6951 (if (functionp gnus-blocked-images)
6952 (funcall gnus-blocked-images gnus-newsgroup-name)
6953 gnus-blocked-images))
6959 (defcustom gnus-article-edit-mode-hook nil
6960 "Hook run in article edit mode buffers."
6961 :group 'gnus-article-various
6964 (defvar gnus-article-edit-done-function nil)
6966 (defvar gnus-article-edit-mode-map nil)
6968 ;; Should we be using derived.el for this?
6969 (unless gnus-article-edit-mode-map
6970 (setq gnus-article-edit-mode-map (make-keymap))
6971 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6973 (gnus-define-keys gnus-article-edit-mode-map
6974 "\C-c?" describe-mode
6975 "\C-c\C-c" gnus-article-edit-done
6976 "\C-c\C-k" gnus-article-edit-exit
6977 "\C-c\C-f\C-t" message-goto-to
6978 "\C-c\C-f\C-o" message-goto-from
6979 "\C-c\C-f\C-b" message-goto-bcc
6980 ;;"\C-c\C-f\C-w" message-goto-fcc
6981 "\C-c\C-f\C-c" message-goto-cc
6982 "\C-c\C-f\C-s" message-goto-subject
6983 "\C-c\C-f\C-r" message-goto-reply-to
6984 "\C-c\C-f\C-n" message-goto-newsgroups
6985 "\C-c\C-f\C-d" message-goto-distribution
6986 "\C-c\C-f\C-f" message-goto-followup-to
6987 "\C-c\C-f\C-m" message-goto-mail-followup-to
6988 "\C-c\C-f\C-k" message-goto-keywords
6989 "\C-c\C-f\C-u" message-goto-summary
6990 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6991 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6992 "\C-c\C-b" message-goto-body
6993 "\C-c\C-i" message-goto-signature
6995 "\C-c\C-t" message-insert-to
6996 "\C-c\C-n" message-insert-newsgroups
6997 "\C-c\C-o" message-sort-headers
6998 "\C-c\C-e" message-elide-region
6999 "\C-c\C-v" message-delete-not-region
7000 "\C-c\C-z" message-kill-to-signature
7001 "\M-\r" message-newline-and-reformat
7002 "\C-c\C-a" mml-attach-file
7003 "\C-a" message-beginning-of-line
7005 "\M-;" comment-region)
7007 (gnus-define-keys (gnus-article-edit-wash-map
7008 "\C-c\C-w" gnus-article-edit-mode-map)
7009 "f" gnus-article-edit-full-stops))
7012 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7014 ["Fetch To" message-insert-to t]
7015 ["Fetch Newsgroups" message-insert-newsgroups t]
7017 ["To" message-goto-to t]
7018 ["From" message-goto-from t]
7019 ["Subject" message-goto-subject t]
7020 ["Cc" message-goto-cc t]
7021 ["Reply-To" message-goto-reply-to t]
7022 ["Summary" message-goto-summary t]
7023 ["Keywords" message-goto-keywords t]
7024 ["Newsgroups" message-goto-newsgroups t]
7025 ["Followup-To" message-goto-followup-to t]
7026 ["Mail-Followup-To" message-goto-mail-followup-to t]
7027 ["Distribution" message-goto-distribution t]
7028 ["Body" message-goto-body t]
7029 ["Signature" message-goto-signature t]))
7031 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7032 "Major mode for editing articles.
7033 This is an extended text-mode.
7035 \\{gnus-article-edit-mode-map}"
7036 (make-local-variable 'gnus-article-edit-done-function)
7037 (make-local-variable 'gnus-prev-winconf)
7038 (set (make-local-variable 'font-lock-defaults)
7039 '(message-font-lock-keywords t))
7040 (set (make-local-variable 'mail-header-separator) "")
7041 (set (make-local-variable 'gnus-article-edit-mode) t)
7042 (easy-menu-add message-mode-field-menu message-mode-map)
7044 (setq buffer-read-only nil)
7045 (buffer-enable-undo)
7048 (defun gnus-article-edit (&optional force)
7049 "Edit the current article.
7050 This will have permanent effect only in mail groups.
7051 If FORCE is non-nil, allow editing of articles even in read-only
7054 (when (and (not force)
7055 (gnus-group-read-only-p))
7056 (error "The current newsgroup does not support article editing"))
7057 (gnus-article-date-original)
7058 (gnus-article-edit-article
7060 `(lambda (no-highlight)
7062 (gnus-summary-edit-article-done
7063 ,(or (mail-header-references gnus-current-headers) "")
7064 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7066 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7067 "Start editing the contents of the current article buffer."
7068 (let ((winconf (current-window-configuration)))
7069 (set-buffer gnus-article-buffer)
7070 (let ((message-auto-save-directory
7071 ;; Don't associate the article buffer with a draft file.
7073 (gnus-article-edit-mode))
7074 (funcall start-func)
7075 (set-buffer-modified-p nil)
7076 (gnus-configure-windows 'edit-article)
7077 (setq gnus-article-edit-done-function exit-func)
7078 (setq gnus-prev-winconf winconf)
7080 (gnus-message 6 "C-c C-c to end edits"))))
7082 (defun gnus-article-edit-done (&optional arg)
7083 "Update the article edits and exit."
7085 (let ((func gnus-article-edit-done-function)
7086 (buf (current-buffer))
7087 (start (window-start))
7089 (winconf gnus-prev-winconf))
7090 (widen) ;; Widen it in case that users narrowed the buffer.
7093 ;; The cache and backlog have to be flushed somewhat.
7094 (when gnus-keep-backlog
7095 (gnus-backlog-remove-article
7096 (car gnus-article-current) (cdr gnus-article-current)))
7097 ;; Flush original article as well.
7098 (gnus-flush-original-article-buffer)
7099 (when gnus-use-cache
7100 (gnus-cache-update-article
7101 (car gnus-article-current) (cdr gnus-article-current)))
7102 ;; We remove all text props from the article buffer.
7103 (kill-all-local-variables)
7104 (set-text-properties (point-min) (point-max) nil)
7106 (set-window-configuration winconf)
7108 (set-window-start (get-buffer-window buf) start)
7109 (set-window-point (get-buffer-window buf) (point)))
7110 (gnus-summary-show-article))
7112 (defun gnus-flush-original-article-buffer ()
7113 (when (get-buffer gnus-original-article-buffer)
7114 (with-current-buffer gnus-original-article-buffer
7115 (setq gnus-original-article nil))))
7117 (defun gnus-article-edit-exit ()
7118 "Exit the article editing without updating."
7120 (when (or (not (buffer-modified-p))
7121 (yes-or-no-p "Article modified; kill anyway? "))
7122 (let ((curbuf (current-buffer))
7124 (window-start (window-start)))
7126 (if (gnus-buffer-live-p gnus-original-article-buffer)
7127 (insert-buffer-substring gnus-original-article-buffer))
7128 (let ((winconf gnus-prev-winconf))
7129 (kill-all-local-variables)
7131 (set-window-configuration winconf)
7132 ;; Tippy-toe some to make sure that point remains where it was.
7133 (save-current-buffer
7135 (set-window-start (get-buffer-window (current-buffer)) window-start)
7137 (gnus-summary-show-article)))
7139 (defun gnus-article-edit-full-stops ()
7140 "Interactively repair spacing at end of sentences."
7143 (goto-char (point-min))
7144 (search-forward-regexp "^$" nil t)
7145 (let ((case-fold-search nil))
7146 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7149 ;;; Article highlights
7152 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7154 ;;; Internal Variables:
7156 (defcustom gnus-button-url-regexp
7158 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7159 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7160 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7161 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
7162 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7166 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7167 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7168 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*"
7170 "[" chars punct "]+" "[" chars "]"
7172 (concat ;; XEmacs 21.4 doesn't support POSIX.
7173 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
7174 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
7176 "Regular expression that matches URLs."
7177 :group 'gnus-article-buttons
7180 (defcustom gnus-button-valid-fqdn-regexp
7181 message-valid-fqdn-regexp
7182 "Regular expression that matches a valid FQDN."
7184 :group 'gnus-article-buttons
7187 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7188 (defcustom gnus-button-valid-localpart-regexp
7189 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7190 "Regular expression that matches a localpart of mail addresses or MIDs."
7192 :group 'gnus-article-buttons
7195 (defcustom gnus-button-man-handler 'manual-entry
7196 "Function to use for displaying man pages.
7197 The function must take at least one argument with a string naming the
7200 :type '(choice (function-item :tag "Man" manual-entry)
7201 (function-item :tag "Woman" woman)
7202 (function :tag "Other"))
7203 :group 'gnus-article-buttons)
7205 (defcustom gnus-button-mid-or-mail-regexp
7206 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7207 gnus-button-valid-fqdn-regexp
7209 "Regular expression that matches a message ID or a mail address."
7211 :group 'gnus-article-buttons
7214 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7215 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7216 Strings like this can be either a message ID or a mail address. If it is one
7217 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7218 message ID or a mail address, respectively. If this variable is set to the
7219 symbol `ask', always query the user what do do. If it is a function, this
7220 function will be called with the string as its only argument. The function
7221 must return `mid', `mail', `invalid' or `ask'."
7223 :group 'gnus-article-buttons
7224 :type '(choice (function-item :tag "Heuristic function"
7225 gnus-button-mid-or-mail-heuristic)
7230 (defcustom gnus-button-mid-or-mail-heuristic-alist
7231 '((-10.0 . ".+\\$.+@")
7234 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7235 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7236 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7237 (-1.0 . "^[^a-z]+@")
7239 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7240 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7241 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7242 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7245 (-1.0 . "^[0-9][0-9]")
7247 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7248 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7249 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7250 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7252 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7253 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7256 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7258 ;; compensation for TDMA dated mail addresses:
7259 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7261 (-20.0 . "\\.fsf@") ;; Gnus
7264 (-20.0 . "^alpine\\.")
7265 (-20.0 . "_-_") ;; Subject change in thread
7267 (-20.0 . "\\.ln@") ;; leafnode
7268 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7269 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7271 ;; (5.0 . "") ;; $local_part_len <= 7
7272 (10.0 . "^[^0-9]+@")
7273 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7274 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7277 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7279 (0.5 . "^[A-Z][a-z]")
7280 (0.5 . "^[A-Z][a-z][a-z]")
7281 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7282 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7283 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
7285 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7286 address. The REGEXP is processed with `case-fold-search' set to nil."
7288 :group 'gnus-article-buttons
7289 :type '(repeat (cons (number :tag "Rate")
7290 (regexp :tag "Regexp"))))
7292 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7293 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7294 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7295 address, `ask' if unsure and `invalid' if the string is invalid."
7296 (let ((case-fold-search nil)
7297 (list gnus-button-mid-or-mail-heuristic-alist)
7298 (result 0) rate regexp lpartlen elem)
7300 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
7301 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7302 ;; Certain special cases...
7305 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7306 "^[0-9]+\\.[0-9]+@compuserve\\|"
7307 "@public\\.gmane\\.org")
7309 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7310 (setq result 'mail))
7311 (when (string-match "@.*@\\| " mid-or-mail)
7312 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7313 (setq result 'invalid))
7314 ;; Nothing more to do, if result is not a number here...
7315 (when (numberp result)
7317 (setq elem (car list)
7321 (when (string-match regexp mid-or-mail)
7322 (setq result (+ result rate))
7324 9 "`%s' matched `%s', rate `%s', result `%s'."
7325 mid-or-mail regexp rate result)))
7326 (when (<= lpartlen 7)
7327 (setq result (+ result 5.0))
7328 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7329 mid-or-mail result))
7330 (when (>= lpartlen 12)
7331 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7333 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7334 ;; Long local part should contain realname if e-mail address,
7335 ;; too many digits: message-id.
7336 ;; $score -= 5.0 + 0.1 * $local_part_len;
7337 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7338 (setq result (+ result rate))
7340 9 "Many digits in `%s', rate `%s', result `%s'."
7341 mid-or-mail rate result))
7342 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
7344 ;; Too few vowels [^aeiouy]{4,}.*\@
7345 (setq result (+ result -5.0))
7347 9 "Few vowels in `%s', rate `%s', result `%s'."
7348 mid-or-mail -5.0 result))
7350 (setq result (+ result 5.0))
7352 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7353 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7354 ;; Maybe we should make this a customizable alist: (condition . 'result)
7356 ((symbolp result) result)
7357 ;; Now convert number into proper results:
7358 ((< result -10.0) 'mid)
7359 ((> result 10.0) 'mail)
7362 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7363 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7364 (url-mid (concat "news" ":" mid-or-mail))
7365 (url-mailto (concat "mailto" ":" mid-or-mail)))
7366 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7367 (when (fboundp pref)
7369 ;; get rid of surrounding angles...
7371 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
7372 (if (or (eq 'mid guessed) (eq 'mail guessed))
7376 (save-window-excursion
7377 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7380 (cond ((eq pref 'mid)
7381 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7382 (gnus-button-handle-news url-mid))
7384 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7385 (gnus-url-mailto url-mailto))
7386 (t (gnus-message 3 "Invalid string.")))))
7388 (defun gnus-button-handle-custom (fun arg)
7389 "Call function FUN on argument ARG.
7390 Both FUN and ARG are supposed to be strings. ARG will be passed
7391 as a symbol to FUN."
7392 (funcall (intern fun)
7393 (if (string-match "^customize-apropos" fun)
7397 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7399 (defun gnus-button-handle-describe-function (url)
7400 "Call `describe-function' when pushing the corresponding URL button."
7403 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7405 (defun gnus-button-handle-describe-variable (url)
7406 "Call `describe-variable' when pushing the corresponding URL button."
7409 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
7411 (defun gnus-button-handle-symbol (url)
7412 "Display help on variable or function.
7413 Calls `describe-variable' or `describe-function'."
7414 (let ((sym (intern url)))
7416 ((fboundp sym) (describe-function sym))
7417 ((boundp sym) (describe-variable sym))
7418 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7420 (defun gnus-button-handle-describe-key (url)
7421 "Call `describe-key' when pushing the corresponding URL button."
7423 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
7424 (keys (ignore-errors (eval `(kbd ,key-string)))))
7427 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7429 (defun gnus-button-handle-apropos (url)
7430 "Call `apropos' when pushing the corresponding URL button."
7431 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7433 (defun gnus-button-handle-apropos-command (url)
7434 "Call `apropos' when pushing the corresponding URL button."
7436 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7438 (defun gnus-button-handle-apropos-variable (url)
7439 "Call `apropos' when pushing the corresponding URL button."
7441 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
7442 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7444 (defun gnus-button-handle-apropos-documentation (url)
7445 "Call `apropos' when pushing the corresponding URL button."
7447 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
7448 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
7450 (defun gnus-button-handle-library (url)
7451 "Call `locate-library' when pushing the corresponding URL button."
7452 (gnus-message 9 "url=`%s'" url)
7453 (let* ((lib (locate-library url))
7454 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
7456 (gnus-message 1 "Cannot locale library `%s'." url)
7457 (find-file-read-only file))))
7459 (defcustom gnus-button-man-level 5
7460 "*Integer that says how many man-related buttons Gnus will show.
7461 The higher the number, the more buttons will appear and the more false
7462 positives are possible. Note that you can set this variable local to
7463 specific groups. Setting it higher in Unix groups is probably a good idea.
7464 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7465 how to set variables in specific groups."
7467 :group 'gnus-article-buttons
7468 :link '(custom-manual "(gnus)Group Parameters")
7471 (defcustom gnus-button-emacs-level 5
7472 "*Integer that says how many emacs-related buttons Gnus will show.
7473 The higher the number, the more buttons will appear and the more false
7474 positives are possible. Note that you can set this variable local to
7475 specific groups. Setting it higher in Emacs or Gnus related groups is
7476 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7477 `gnus-parameters' on how to set variables in specific groups."
7479 :group 'gnus-article-buttons
7480 :link '(custom-manual "(gnus)Group Parameters")
7483 (defcustom gnus-button-message-level 5
7484 "*Integer that says how many buttons for news or mail messages will appear.
7485 The higher the number, the more buttons will appear and the more false
7486 positives are possible."
7487 ;; mail addresses, MIDs, URLs for news, ...
7489 :group 'gnus-article-buttons
7492 (defcustom gnus-button-browse-level 5
7493 "*Integer that says how many buttons for browsing will appear.
7494 The higher the number, the more buttons will appear and the more false
7495 positives are possible."
7496 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7498 :group 'gnus-article-buttons
7501 (defcustom gnus-button-alist
7502 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7503 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7504 ((concat "\\b\\(nntp\\|news\\):\\("
7505 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7506 0 t gnus-button-handle-news 2)
7507 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7508 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7509 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7510 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7511 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7512 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7513 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7514 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7515 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7516 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7517 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7518 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7519 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7520 ;; RFC 2368 (The mailto URL scheme)
7521 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7522 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7523 ("\\bmailto:\\([^ \n\t]+\\)"
7524 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7525 ;; Info Konqueror style <info:/foo/bar baz>.
7526 ;; Must come before " Gnus home-grown style".
7527 ("\\binfo://?\\([^'\">\n\t]+\\)"
7528 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7529 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7530 ("\\binfo://\\([^'\">\n\t ]+\\)"
7531 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7532 ;; Info GNOME style <info:foo#bar_baz>
7533 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7534 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7535 ;; Info KDE style <info:(foo)bar baz>
7536 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7537 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7538 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7539 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7540 ("\\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,]*\\)\\)?"
7541 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7542 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7544 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7545 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7546 ;; Emacs help commands
7547 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7548 ;; regexp doesn't match arguments containing ` '.
7549 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7550 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7551 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7552 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7553 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7554 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7555 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7556 ;; The following entries may lead to many false positives so don't enable
7557 ;; them by default (use a high button level).
7558 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7559 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7560 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7561 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7562 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7563 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7564 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7565 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7566 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7567 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7568 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7569 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7570 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7571 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7572 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7573 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7574 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7575 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7576 ;; Unlike the other regexps we really have to require quoting
7577 ;; here to determine where it ends.
7578 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7579 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7580 ("<URL: *\\([^\n<>]*\\)>"
7581 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7582 ;; RFC 2396 (2.4.3., delims) ...
7583 ("\"URL: *\\([^\n\"]*\\)\""
7584 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7586 (gnus-button-url-regexp
7587 0 (>= gnus-button-browse-level 0) browse-url 0)
7589 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7590 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7591 gnus-button-handle-man 1)
7592 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7593 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7594 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7595 gnus-button-handle-man 1)
7596 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7597 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7598 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7599 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7600 ;; Recognizing patches to .el files. This is somewhat obscure,
7601 ;; but considering the percentage of Gnus users who hack Emacs
7603 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7604 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7605 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7606 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7607 ;; MID or mail: To avoid too many false positives we don't try to catch
7608 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7609 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7610 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7611 ;; so that non-ambiguous entries (see above) match first.
7612 (gnus-button-mid-or-mail-regexp
7613 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7614 "*Alist of regexps matching buttons in article bodies.
7616 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7617 REGEXP: is the string (case insensitive) matching text around the button (can
7618 also be Lisp expression evaluating to a string),
7619 BUTTON: is the number of the regexp grouping actually matching the button,
7620 FORM: is a Lisp expression which must eval to true for the button to
7622 CALLBACK: is the function to call when the user push this button, and each
7623 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7625 CALLBACK can also be a variable, in that case the value of that
7626 variable it the real callback function."
7627 :group 'gnus-article-buttons
7628 :type '(repeat (list (choice regexp variable sexp)
7629 (integer :tag "Button")
7631 (function :tag "Callback")
7634 (integer :tag "Regexp group")))))
7635 (put 'gnus-button-alist 'risky-local-variable t)
7637 (defcustom gnus-header-button-alist
7638 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7639 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7640 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7641 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7642 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7643 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7644 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7645 0 (>= gnus-button-browse-level 0) browse-url 0)
7646 ("^Subject:" gnus-button-url-regexp
7647 0 (>= gnus-button-browse-level 0) browse-url 0)
7648 ("^[^:]+:" gnus-button-url-regexp
7649 0 (>= gnus-button-browse-level 0) browse-url 0)
7650 ("^OpenPGP:.*url=" gnus-button-url-regexp
7651 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7652 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7653 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7654 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7655 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7656 "*Alist of headers and regexps to match buttons in article heads.
7658 This alist is very similar to `gnus-button-alist', except that each
7659 alist has an additional HEADER element first in each entry:
7661 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7663 HEADER is a regexp to match a header. For a fuller explanation, see
7664 `gnus-button-alist'."
7665 :group 'gnus-article-buttons
7666 :group 'gnus-article-headers
7667 :type '(repeat (list (regexp :tag "Header")
7668 (choice regexp variable)
7669 (integer :tag "Button")
7671 (function :tag "Callback")
7674 (integer :tag "Regexp group")))))
7675 (put 'gnus-header-button-alist 'risky-local-variable t)
7679 (defun gnus-article-push-button (event)
7680 "Check text under the mouse pointer for a callback function.
7681 If the text under the mouse pointer has a `gnus-callback' property,
7682 call it with the value of the `gnus-data' text property."
7684 (set-buffer (window-buffer (posn-window (event-start event))))
7685 (let* ((pos (posn-point (event-start event)))
7686 (data (get-text-property pos 'gnus-data))
7687 (fun (get-text-property pos 'gnus-callback)))
7690 (funcall fun data))))
7692 (defun gnus-article-press-button ()
7693 "Check text at point for a callback function.
7694 If the text at point has a `gnus-callback' property,
7695 call it with the value of the `gnus-data' text property."
7697 (let ((data (get-text-property (point) 'gnus-data))
7698 (fun (get-text-property (point) 'gnus-callback)))
7700 (funcall fun data))))
7702 (defun gnus-article-highlight (&optional force)
7703 "Highlight current article.
7704 This function calls `gnus-article-highlight-headers',
7705 `gnus-article-highlight-citation',
7706 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7707 do the highlighting. See the documentation for those functions."
7708 (interactive (list 'force))
7709 (gnus-article-highlight-headers)
7710 (gnus-article-highlight-citation force)
7711 (gnus-article-highlight-signature)
7712 (gnus-article-add-buttons)
7713 (gnus-article-add-buttons-to-head))
7715 (defun gnus-article-highlight-some (&optional force)
7716 "Highlight current article.
7717 This function calls `gnus-article-highlight-headers',
7718 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7719 do the highlighting. See the documentation for those functions."
7720 (interactive (list 'force))
7721 (gnus-article-highlight-headers)
7722 (gnus-article-highlight-signature)
7723 (gnus-article-add-buttons))
7725 (defun gnus-article-highlight-headers ()
7726 "Highlight article headers as specified by `gnus-header-face-alist'."
7728 (gnus-with-article-headers
7729 (let (regexp header-face field-face from hpoints fpoints)
7730 (dolist (entry gnus-header-face-alist)
7731 (goto-char (point-min))
7732 (setq regexp (concat "^\\("
7733 (if (string-equal "" (nth 0 entry))
7737 header-face (nth 1 entry)
7738 field-face (nth 2 entry))
7739 (while (and (re-search-forward regexp nil t)
7743 (unless (search-forward ":" nil t)
7745 (when (and header-face
7746 (not (memq (point) hpoints)))
7747 (push (point) hpoints)
7748 (gnus-put-text-property from (point) 'face header-face))
7749 (when (and field-face
7750 (not (memq (setq from (point)) fpoints)))
7752 (if (re-search-forward "^[^ \t]" nil t)
7754 (goto-char (point-max)))
7755 (gnus-put-text-property from (point) 'face field-face)))))))
7757 (defun gnus-article-highlight-signature ()
7758 "Highlight the signature in an article.
7759 It does this by highlighting everything after
7760 `gnus-signature-separator' using the face `gnus-signature'."
7762 (gnus-with-article-buffer
7763 (let ((inhibit-point-motion-hooks t))
7765 (when (and gnus-signature-face
7766 (gnus-article-narrow-to-signature))
7767 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
7768 'face gnus-signature-face)
7770 (gnus-article-search-signature)
7771 (let ((start (match-beginning 0))
7772 (end (set-marker (make-marker) (1+ (match-end 0)))))
7773 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7776 (defun gnus-button-in-region-p (b e prop)
7777 "Say whether PROP exists in the region."
7778 (text-property-not-all b e prop nil))
7780 (defun gnus-article-add-buttons ()
7781 "Find external references in the article and make buttons of them.
7782 \"External references\" are things like Message-IDs and URLs, as
7783 specified by `gnus-button-alist'."
7785 (gnus-with-article-buffer
7786 (let ((inhibit-point-motion-hooks t)
7787 (case-fold-search t)
7788 (alist gnus-button-alist)
7790 ;; We skip the headers.
7793 (while (setq entry (pop alist))
7794 (setq regexp (eval (car entry)))
7796 (while (re-search-forward regexp nil t)
7797 (let ((start (match-beginning (nth 1 entry)))
7798 (end (match-end (nth 1 entry)))
7799 (from (match-beginning 0)))
7800 (when (and (eval (nth 2 entry))
7801 (not (gnus-button-in-region-p
7802 start end 'gnus-callback)))
7803 ;; That optional form returned non-nil, so we add the
7805 (setq from (set-marker (make-marker) from))
7806 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7807 (gnus-article-extend-url-button from start end))
7808 (gnus-article-add-button start end
7809 'gnus-button-push (list from entry))
7810 (gnus-put-text-property
7812 'gnus-string (buffer-substring-no-properties
7815 (defun gnus-article-extend-url-button (beg start end)
7816 "Extend url button if url is folded into two or more lines.
7817 Return non-nil if button is extended. BEG is a marker that points to
7818 the beginning position of a text containing url. START and END are
7819 the endpoints of a url button before it is extended. The concatenated
7820 url is put as the `gnus-button-url' overlay property on the button."
7821 (let ((opoint (point))
7822 (points (list start end))
7827 (not (looking-at "[\t ]*[\">]")))
7831 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7832 (buffer-substring (point-at-bol) start)))
7834 (setq url (list (buffer-substring start end))
7835 delim (if (match-beginning 1) ">" "\""))
7837 (setq regexp (concat
7838 (when (and (looking-at
7839 message-cite-prefix-regexp)
7840 (< (match-end 0) start))
7841 (regexp-quote (match-string 0)))
7843 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7847 (and (looking-at regexp)
7850 (push (or (match-string 2)
7853 (push (setq end (or (match-end 2)
7856 (push (or (match-beginning 2)
7857 (match-beginning 1))
7859 (match-beginning 2)))
7860 (let (gnus-article-mouse-face widget-mouse-face)
7862 (gnus-article-add-button (pop points) (pop points)
7863 'gnus-button-push beg)))
7864 (let ((overlay (gnus-make-overlay start end)))
7865 (gnus-overlay-put overlay 'evaporate t)
7866 (gnus-overlay-put overlay 'gnus-button-url
7867 (list (mapconcat 'identity (nreverse url) "")))
7868 (when gnus-article-mouse-face
7869 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7871 (goto-char opoint))))
7873 ;; Add buttons to the head of an article.
7874 (defun gnus-article-add-buttons-to-head ()
7875 "Add buttons to the head of the article."
7877 (gnus-with-article-headers
7879 (dolist (entry gnus-header-button-alist)
7880 ;; Each alist entry.
7881 (goto-char (point-min))
7882 (while (re-search-forward (car entry) nil t)
7883 ;; Each header matching the entry.
7884 (setq beg (match-beginning 0))
7885 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7886 (match-beginning 0))
7889 (while (re-search-forward (eval (nth 1 entry)) end t)
7890 ;; Each match within a header.
7891 (let* ((entry (cdr entry))
7892 (start (match-beginning (nth 1 entry)))
7893 (end (match-end (nth 1 entry)))
7894 (form (nth 2 entry)))
7895 (goto-char (match-end 0))
7897 (gnus-article-add-button
7898 start end (nth 3 entry)
7899 (buffer-substring (match-beginning (nth 4 entry))
7900 (match-end (nth 4 entry)))))))
7901 (goto-char end))))))
7903 ;;; External functions:
7905 (defun gnus-article-add-button (from to fun &optional data text)
7906 "Create a button between FROM and TO with callback FUN and data DATA."
7907 (when gnus-article-button-face
7908 (gnus-overlay-put (gnus-make-overlay from to nil t)
7909 'face gnus-article-button-face))
7910 (gnus-add-text-properties
7912 (nconc (and gnus-article-mouse-face
7913 (list gnus-mouse-face-prop gnus-article-mouse-face))
7914 (list 'gnus-callback fun)
7915 (and data (list 'gnus-data data))))
7916 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7917 :help-echo (or text "Follow the link")
7918 :keymap gnus-url-button-map
7919 :button-keymap gnus-widget-button-keymap))
7921 (defun gnus-article-copy-string ()
7922 "Copy the string in the button to the kill ring."
7924 (gnus-article-check-buffer)
7925 (let ((data (get-text-property (point) 'gnus-string)))
7929 (copy-region-as-kill (point-min) (point-max))
7930 (message "Copied %s" data)))))
7932 ;;; Internal functions:
7934 (defun gnus-article-set-globals ()
7935 (with-current-buffer gnus-summary-buffer
7936 (gnus-set-global-variables)))
7938 (defun gnus-signature-toggle (end)
7939 (gnus-with-article-buffer
7940 (let ((inhibit-point-motion-hooks t))
7941 (if (text-property-any end (point-max) 'article-type 'signature)
7943 (gnus-delete-wash-type 'signature)
7944 (gnus-remove-text-properties-when
7945 'article-type 'signature end (point-max)
7946 (cons 'article-type (cons 'signature
7947 gnus-hidden-properties))))
7948 (gnus-add-wash-type 'signature)
7949 (gnus-add-text-properties-when
7950 'article-type nil end (point-max)
7951 (cons 'article-type (cons 'signature
7952 gnus-hidden-properties)))))
7953 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7954 (gnus-set-mode-line 'article))))
7956 (defun gnus-button-push (marker-and-entry)
7957 ;; Push button starting at MARKER.
7959 (let* ((marker (car marker-and-entry))
7960 (entry (cadr marker-and-entry))
7961 (regexp (car entry))
7962 (inhibit-point-motion-hooks t))
7964 ;; This is obviously true, or something bad is happening :)
7965 ;; But we need it to have the match-data
7966 (when (looking-at (or (if (symbolp regexp)
7967 (symbol-value regexp)
7969 (let ((fun (nth 3 entry))
7970 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7971 (get-char-property marker 'gnus-button-url))
7972 (mapcar (lambda (group)
7973 (let ((string (match-string group)))
7974 (set-text-properties
7975 0 (length string) nil string)
7977 (nthcdr 4 entry)))))
7983 (fboundp (symbol-value fun)))
7984 (apply (symbol-value fun) args))
7986 (gnus-message 1 "You must define `%S' to use this button"
7987 (cons fun args)))))))))
7989 (defun gnus-parse-news-url (url)
7990 (let (scheme server port group message-id articles)
7993 (goto-char (point-min))
7994 (when (looking-at "\\([A-Za-z]+\\):")
7995 (setq scheme (match-string 1))
7996 (goto-char (match-end 0)))
7997 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7998 (setq server (match-string 1))
7999 (setq port (if (stringp (match-string 3))
8000 (string-to-number (match-string 3))
8002 (goto-char (match-end 0)))
8005 ((looking-at "\\(.*@.*\\)")
8006 (setq message-id (match-string 1)))
8007 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8008 (setq group (match-string 1)
8009 articles (split-string (match-string 2) "-")))
8010 ((looking-at "\\([^/]+\\)/?")
8011 (setq group (match-string 1)))
8013 (error "Unknown news URL syntax"))))
8014 (list scheme server port group message-id articles)))
8016 (defun gnus-button-handle-news (url)
8018 (destructuring-bind (scheme server port group message-id articles)
8019 (gnus-parse-news-url url)
8022 (with-current-buffer gnus-summary-buffer
8024 (let ((gnus-refer-article-method
8025 (nconc (list (list 'nntp server))
8026 gnus-refer-article-method))
8027 (nntp-port-number (or port "nntp")))
8028 (gnus-message 7 "Fetching %s with %s"
8029 message-id gnus-refer-article-method)
8030 (gnus-summary-refer-article message-id))
8031 (gnus-summary-refer-article message-id))))
8033 (gnus-button-fetch-group url)))))
8035 (defun gnus-button-patch (library line)
8036 "Visit an Emacs Lisp library LIBRARY on line LINE."
8038 (let ((file (locate-library (file-name-nondirectory library))))
8040 (error "Couldn't find library %s" library))
8042 (goto-char (point-min))
8043 (forward-line (1- (string-to-number line)))))
8045 (defun gnus-button-handle-man (url)
8047 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8048 (when (eq gnus-button-man-handler 'woman)
8049 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
8050 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8051 (funcall gnus-button-man-handler url))
8053 (defun gnus-button-handle-info-url (url)
8054 "Fetch an info URL."
8055 (setq url (mm-subst-char-in-string ?+ ?\ url))
8057 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8058 (gnus-info-find-node
8059 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8061 ")" (gnus-url-unhex-string (match-string 2 url)))))
8062 ((string-match "([^)\"]+)[^\"]+" url)
8064 (gnus-replace-in-string
8065 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
8066 (gnus-info-find-node url))
8067 (t (error "Can't parse %s" url))))
8069 (defun gnus-button-handle-info-url-gnome (url)
8070 "Fetch GNOME style info URL."
8071 (setq url (mm-subst-char-in-string ?_ ?\ url))
8072 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8073 (gnus-info-find-node
8075 (gnus-url-unhex-string
8076 (match-string 1 url))
8078 (or (gnus-url-unhex-string
8079 (match-string 2 url))
8081 (error "Can't parse %s" url)))
8083 (defun gnus-button-handle-info-url-kde (url)
8084 "Fetch KDE style info URL."
8085 (gnus-info-find-node (gnus-url-unhex-string url)))
8087 ;; (info) will autoload info.el
8088 (declare-function Info-menu "info" (menu-item &optional fork))
8089 (declare-function Info-index-next "info" (num))
8091 (defun gnus-button-handle-info-keystrokes (url)
8092 "Call `info' when pushing the corresponding URL button."
8093 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8094 (let (node indx comma)
8096 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8097 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8098 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8099 "\\(?:[ \t\n,]*\\)\\)?")
8101 (setq node (match-string 2 url)
8102 indx (match-string 3 url))
8103 (error "Can't parse %s" url))
8107 (when (> (length indx) 0)
8108 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8111 (setq comma (match-string 2 indx))
8112 (setq indx (match-string 1 indx))
8115 (dotimes (i (with-temp-buffer
8117 ;; Note: the XEmacs version of `how-many' takes
8118 ;; no optional argument.
8119 (goto-char (point-min))
8121 (Info-index-next 1)))
8124 (autoload 'pgg-snarf-keys-region "pgg")
8125 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8126 (declare-function pgg-display-output-buffer "pgg" (start end status))
8128 (defun gnus-button-openpgp (url)
8129 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8131 (mm-url-insert-file-contents-external url)
8132 (pgg-snarf-keys-region (point-min) (point-max))
8133 (pgg-display-output-buffer nil nil nil)))
8135 (defun gnus-button-message-id (message-id)
8137 (with-current-buffer gnus-summary-buffer
8138 (gnus-summary-refer-article message-id)))
8140 (defun gnus-button-fetch-group (address &rest ignore)
8141 "Fetch GROUP specified by ADDRESS."
8142 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8144 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8145 ;; for nntp:// and news://
8146 (setq address (match-string 3 address)))
8147 (if (not (string-match "[:/]" address))
8148 ;; This is just a simple group url.
8149 (gnus-group-read-ephemeral-group address gnus-select-method)
8152 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8154 (error "Can't parse %s" address)
8155 (gnus-group-read-ephemeral-group
8156 (match-string 4 address)
8157 `(nntp ,(match-string 1 address)
8158 (nntp-address ,(match-string 1 address))
8159 (nntp-port-number ,(if (match-end 3)
8160 (match-string 3 address)
8163 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8165 (defun gnus-url-parse-query-string (query &optional downcase)
8166 (let (retval pairs cur key val)
8167 (setq pairs (split-string query "&"))
8169 (setq cur (car pairs)
8171 (if (not (string-match "=" cur))
8173 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8174 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8176 (setq key (downcase key)))
8177 (setq cur (assoc key retval))
8179 (setcdr cur (cons val (cdr cur)))
8180 (setq retval (cons (list key val) retval)))))
8183 (defun gnus-url-mailto (url)
8184 ;; Send mail to someone
8185 (setq url (replace-regexp-in-string "\n" " " url))
8186 (when (string-match "mailto:/*\\(.*\\)" url)
8187 (setq url (substring url (match-beginning 1) nil)))
8188 (let (to args subject func)
8189 (setq args (gnus-url-parse-query-string
8190 (if (string-match "^\\?" url)
8192 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8193 (concat "to=" (match-string 1 url) "&"
8194 (match-string 2 url))
8195 (concat "to=" url))))
8196 subject (cdr-safe (assoc "subject" args)))
8199 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8202 (message-position-on-field (caar args)))
8203 (insert (gnus-replace-in-string
8204 (mapconcat 'identity (reverse (cdar args)) ", ")
8206 (setq args (cdr args)))
8209 (message-goto-subject))))
8211 (defun gnus-button-embedded-url (address)
8212 "Activate ADDRESS with `browse-url'."
8213 (browse-url (gnus-strip-whitespace address)))
8215 ;;; Next/prev buttons in the article buffer.
8217 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8218 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8220 (defvar gnus-prev-page-map
8221 (let ((map (make-sparse-keymap)))
8222 (define-key map gnus-mouse-2 'gnus-button-prev-page)
8223 (define-key map "\r" 'gnus-button-prev-page)
8226 (defvar gnus-next-page-map
8227 (let ((map (make-sparse-keymap)))
8228 (define-key map gnus-mouse-2 'gnus-button-next-page)
8229 (define-key map "\r" 'gnus-button-next-page)
8232 (defun gnus-insert-prev-page-button ()
8234 (inhibit-read-only t))
8236 gnus-prev-page-line-format nil
8237 `(keymap ,gnus-prev-page-map
8239 gnus-callback gnus-article-button-prev-page
8240 article-type annotation))
8242 ;; Exclude a newline.
8245 (when gnus-article-button-face
8246 (gnus-overlay-put (gnus-make-overlay b e nil t)
8247 'face gnus-article-button-face))
8248 (widget-convert-button
8250 :action 'gnus-button-prev-page
8251 :button-keymap gnus-prev-page-map)))
8253 (defun gnus-button-next-page (&optional args more-args)
8254 "Go to the next page."
8256 (let ((win (selected-window)))
8257 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8258 (gnus-article-next-page)
8259 (select-window win)))
8261 (defun gnus-button-prev-page (&optional args more-args)
8262 "Go to the prev page."
8264 (let ((win (selected-window)))
8265 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8266 (gnus-article-prev-page)
8267 (select-window win)))
8269 (defun gnus-insert-next-page-button ()
8271 (inhibit-read-only t))
8272 (gnus-eval-format gnus-next-page-line-format nil
8273 `(keymap ,gnus-next-page-map
8275 gnus-callback gnus-article-button-next-page
8276 article-type annotation))
8278 ;; Exclude a newline.
8281 (when gnus-article-button-face
8282 (gnus-overlay-put (gnus-make-overlay b e nil t)
8283 'face gnus-article-button-face))
8284 (widget-convert-button
8286 :action 'gnus-button-next-page
8287 :button-keymap gnus-next-page-map)))
8289 (defun gnus-article-button-next-page (arg)
8290 "Go to the next page."
8292 (let ((win (selected-window)))
8293 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8294 (gnus-article-next-page)
8295 (select-window win)))
8297 (defun gnus-article-button-prev-page (arg)
8298 "Go to the prev page."
8300 (let ((win (selected-window)))
8301 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8302 (gnus-article-prev-page)
8303 (select-window win)))
8305 (defvar gnus-decode-header-methods
8306 '(mail-decode-encoded-word-region)
8307 "List of methods used to decode headers.
8309 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8310 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8311 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8312 whose names match REGEXP.
8315 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8316 mail-decode-encoded-word-region
8317 (\"chinese\" . rfc1843-decode-region))
8320 (defvar gnus-decode-header-methods-cache nil)
8322 (defun gnus-multi-decode-header (start end)
8323 "Apply the functions from `gnus-encoded-word-methods' that match."
8324 (unless (and gnus-decode-header-methods-cache
8325 (eq gnus-newsgroup-name
8326 (car gnus-decode-header-methods-cache)))
8327 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8328 (dolist (x gnus-decode-header-methods)
8330 (nconc gnus-decode-header-methods-cache (list x))
8331 (if (and gnus-newsgroup-name
8332 (string-match (car x) gnus-newsgroup-name))
8333 (nconc gnus-decode-header-methods-cache
8335 (let ((xlist gnus-decode-header-methods-cache))
8338 (narrow-to-region start end)
8340 (funcall (pop xlist) (point-min) (point-max))))))
8343 ;;; Treatment top-level handling.
8346 (defvar gnus-inhibit-article-treatments nil)
8348 (defun gnus-treat-article (gnus-treat-condition
8349 &optional part-number total-parts gnus-treat-type)
8350 (let ((gnus-treat-length (- (point-max) (point-min)))
8351 (alist gnus-treatment-function-alist)
8352 (article-goto-body-goes-to-point-min-p t)
8354 (or (not gnus-treat-type)
8356 (let ((list gnus-article-treat-types))
8358 (when (string-match (pop list) gnus-treat-type)
8359 (throw 'found t)))))))
8360 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8362 (gnus-run-hooks 'gnus-part-display-hook)
8363 (dolist (elem alist)
8366 (when (gnus-buffer-live-p gnus-summary-buffer)
8367 (set-buffer gnus-summary-buffer))
8368 (symbol-value (car elem))))
8369 (when (and (or (consp val)
8371 (or (not gnus-inhibit-article-treatments)
8372 (eq gnus-treat-condition 'head))
8373 (gnus-treat-predicate val)
8374 (or (not (get (car elem) 'highlight))
8377 (funcall (cadr elem)))))))
8379 ;; Dynamic variables.
8380 (defvar part-number)
8381 (defvar total-parts)
8382 (defvar gnus-treat-type)
8383 (defvar gnus-treat-condition)
8384 (defvar gnus-treat-length)
8386 (defun gnus-treat-predicate (val)
8390 (gnus-treat-condition
8391 (eq gnus-treat-condition val))
8393 (stringp (car val)))
8394 (apply 'gnus-or (mapcar `(lambda (s)
8395 (string-match s ,(or gnus-newsgroup-name "")))
8398 (let ((pred (pop val)))
8401 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8403 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8405 (not (gnus-treat-predicate (car val))))
8407 (equal (car val) gnus-treat-type))
8409 (error "%S is not a valid predicate" pred)))))
8417 (eq part-number total-parts))
8419 (< gnus-treat-length val))
8421 (error "%S is not a valid value" val))))
8423 (defun gnus-article-encrypt-body (protocol &optional n)
8424 "Encrypt the article body."
8427 (or gnus-article-encrypt-protocol
8428 (gnus-completing-read "Encrypt protocol"
8429 (mapcar 'car gnus-article-encrypt-protocol-alist)
8431 current-prefix-arg))
8432 ;; User might hit `K E' instead of `K e', so prompt once.
8433 (when (and gnus-article-encrypt-protocol
8435 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8436 (error "Encrypt aborted")))
8437 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8439 (error "Can't find the encrypt protocol %s" protocol))
8440 (if (member gnus-newsgroup-name '("nndraft:delayed"
8443 (error "Can't encrypt the article in group %s"
8444 gnus-newsgroup-name))
8445 (gnus-summary-iterate n
8446 (with-current-buffer gnus-summary-buffer
8447 (let ((mail-parse-charset gnus-newsgroup-charset)
8448 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8449 (summary-buffer gnus-summary-buffer)
8451 (gnus-set-global-variables)
8452 (when (gnus-group-read-only-p)
8453 (error "The current newsgroup does not support article encrypt"))
8454 (gnus-summary-show-article t)
8456 (or (mail-header-references gnus-current-headers) ""))
8457 (set-buffer gnus-article-buffer)
8458 (let* ((inhibit-read-only t)
8460 (mapcar (lambda (field)
8461 (and (save-restriction
8462 (message-narrow-to-head)
8463 (goto-char (point-min))
8464 (search-forward field nil t))
8466 (message-narrow-to-field)
8468 (delete-region (point-min) (point-max))
8470 '("Content-Type:" "Content-Transfer-Encoding:"
8471 "Content-Disposition:"))))
8472 (message-narrow-to-head)
8473 (message-remove-header "MIME-Version")
8474 (goto-char (point-max))
8475 (setq point (point))
8476 (insert (apply 'concat headers))
8478 (narrow-to-region point (point-max))
8479 (let ((message-options message-options))
8480 (message-options-set 'message-sender user-mail-address)
8481 (message-options-set 'message-recipients user-mail-address)
8482 (message-options-set 'message-sign-encrypt 'not)
8484 (goto-char (point-min))
8485 (insert "MIME-Version: 1.0\n")
8487 (gnus-summary-edit-article-done
8488 references nil summary-buffer t))
8489 (when gnus-keep-backlog
8490 (gnus-backlog-remove-article
8491 (car gnus-article-current) (cdr gnus-article-current)))
8492 (gnus-flush-original-article-buffer)
8493 (when gnus-use-cache
8494 (gnus-cache-update-article
8495 (car gnus-article-current) (cdr gnus-article-current))))))))
8497 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8498 "The following specs can be used:
8499 %t The security MIME type
8502 %D Details if button is pressed")
8504 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8505 "The following specs can be used:
8506 %t The security MIME type
8509 %D Details if button is pressed")
8511 (defvar gnus-mime-security-button-line-format-alist
8512 '((?t gnus-tmp-type ?s)
8513 (?i gnus-tmp-info ?s)
8514 (?d gnus-tmp-details ?s)
8515 (?D gnus-tmp-pressed-details ?s)))
8517 (defvar gnus-mime-security-button-commands
8518 '((gnus-article-press-button "\r" "Show Detail")
8522 (gnus-mime-security-save-part "o" "Save...")
8531 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8534 (defvar gnus-mime-security-button-map
8535 (let ((map (make-sparse-keymap)))
8536 (define-key map gnus-mouse-2 'gnus-article-push-button)
8537 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8538 (dolist (c gnus-mime-security-button-commands)
8539 (define-key map (cadr c) (car c)))
8543 gnus-mime-security-button-menu gnus-mime-security-button-map
8544 "Security button menu."
8548 (unless (eq (car c) 'undefined)
8549 (vector (caddr c) (car c) :active t)))
8550 gnus-mime-security-button-commands))))
8552 (defun gnus-mime-security-button-menu (event prefix)
8553 "Construct a context-sensitive menu of security commands."
8554 (interactive "e\nP")
8555 (save-window-excursion
8556 (let ((pos (event-start event)))
8557 (select-window (posn-window pos))
8558 (goto-char (posn-point pos))
8559 (gnus-article-check-buffer)
8560 (popup-menu gnus-mime-security-button-menu nil prefix))))
8562 (defvar gnus-mime-security-details-buffer nil)
8564 (defvar gnus-mime-security-button-pressed nil)
8566 (defvar gnus-mime-security-show-details-inline t
8567 "If non-nil, show details in the article buffer.")
8569 (defun gnus-mime-security-verify-or-decrypt (handle)
8570 (mm-remove-parts (cdr handle))
8571 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8572 point (inhibit-read-only t))
8574 (goto-char (car region)))
8575 (setq point (point))
8576 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8577 (let* ((mm-verify-option 'known)
8578 (mm-decrypt-option 'known)
8579 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8580 (unless (eq nparts (cdr handle))
8581 (mm-destroy-parts (cdr handle))
8582 (setcdr handle nparts))))
8583 (gnus-mime-display-security handle)
8585 (delete-region (point) (cdr region))
8586 (set-marker (car region) nil)
8587 (set-marker (cdr region) nil))
8590 (defun gnus-mime-security-show-details (handle)
8591 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8593 (gnus-message 5 "No details.")
8594 (if gnus-mime-security-show-details-inline
8595 (let ((gnus-mime-security-button-pressed
8596 (not (get-text-property (point) 'gnus-mime-details)))
8597 (gnus-mime-security-button-line-format
8598 (get-text-property (point) 'gnus-line-format))
8599 (inhibit-read-only t))
8601 (while (eq (get-text-property (point) 'gnus-line-format)
8602 gnus-mime-security-button-line-format)
8606 (narrow-to-region (point) (point))
8607 (gnus-insert-mime-security-button handle))
8608 (delete-region (point)
8609 (or (text-property-not-all
8612 gnus-mime-security-button-line-format)
8615 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8616 (with-current-buffer gnus-mime-security-details-buffer
8619 (setq gnus-mime-security-details-buffer
8620 (gnus-get-buffer-create "*MIME Security Details*")))
8621 (with-current-buffer gnus-mime-security-details-buffer
8623 (goto-char (point-min)))
8624 (pop-to-buffer gnus-mime-security-details-buffer)))))
8626 (defun gnus-mime-security-press-button (handle)
8628 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8629 (gnus-mime-security-show-details handle)
8630 (gnus-mime-security-verify-or-decrypt handle))))
8632 (defun gnus-insert-mime-security-button (handle &optional displayed)
8633 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8636 (or (nth 2 (assoc protocol mm-verify-function-alist))
8637 (nth 2 (assoc protocol mm-decrypt-function-alist))
8639 (if (equal (car handle) "multipart/signed")
8640 " Signed" " Encrypted")
8643 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8646 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8647 gnus-tmp-pressed-details
8649 (setq gnus-tmp-details
8650 (if gnus-tmp-details
8651 (concat "\n" gnus-tmp-details)
8653 (setq gnus-tmp-pressed-details
8654 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8659 gnus-mime-security-button-line-format
8660 gnus-mime-security-button-line-format-alist
8661 `(keymap ,gnus-mime-security-button-map
8662 gnus-callback gnus-mime-security-press-button
8663 gnus-line-format ,gnus-mime-security-button-line-format
8664 gnus-mime-details ,gnus-mime-security-button-pressed
8665 article-type annotation
8668 ;; Exclude a newline.
8671 (when gnus-article-button-face
8672 (gnus-overlay-put (gnus-make-overlay b e nil t)
8673 'face gnus-article-button-face))
8674 (widget-convert-button
8677 :action 'gnus-widget-press-button
8678 :button-keymap gnus-mime-security-button-map
8681 ;; Needed to properly clear the message due to a bug in
8682 ;; wid-edit (XEmacs only).
8683 (when (boundp 'help-echo-owns-message)
8684 (setq help-echo-owns-message t))
8686 "%S: show detail; %S: more options"
8687 (aref gnus-mouse-2 0)
8688 (aref gnus-down-mouse-3 0))))))
8690 (defun gnus-mime-display-security (handle)
8692 (narrow-to-region (point) (point))
8693 (unless (gnus-unbuttonized-mime-type-p (car handle))
8694 (gnus-insert-mime-security-button handle))
8695 (gnus-mime-display-part (cadr handle))
8698 (unless (gnus-unbuttonized-mime-type-p (car handle))
8699 (let ((gnus-mime-security-button-line-format
8700 gnus-mime-security-button-end-line-format))
8701 (gnus-insert-mime-security-button handle)))
8702 (mm-set-handle-multipart-parameter
8704 (cons (set-marker (make-marker) (point-min))
8705 (set-marker (make-marker) (point-max))))
8706 (goto-char (point-max))))
8708 (defun gnus-mime-security-run-function (function)
8709 "Run FUNCTION with the security part under point."
8710 (gnus-article-check-buffer)
8711 (let ((data (get-text-property (point) 'gnus-data))
8713 (when (and (stringp (car-safe data))
8714 (setq buffer (mm-handle-multipart-original-buffer data))
8715 (setq handle (cadr data)))
8716 (if (bufferp (mm-handle-buffer handle))
8718 (setq handle (cons buffer (copy-sequence (cdr handle))))
8719 (mm-handle-set-undisplayer handle nil))
8720 (setq handle (mm-make-handle
8722 (mm-handle-multipart-ctl-parameter handle 'protocol)
8723 nil nil nil nil nil nil)))
8724 (funcall function handle))))
8726 (defun gnus-mime-security-save-part ()
8727 "Save the security part under point."
8729 (gnus-mime-security-run-function 'mm-save-part))
8731 (defun gnus-mime-security-pipe-part ()
8732 "Pipe the security part under point to a process."
8734 (gnus-mime-security-run-function 'mm-pipe-part))
8740 (run-hooks 'gnus-art-load-hook)
8742 ;;; gnus-art.el ends here