1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (autoload 'mm-url-insert-file-contents-external "mm-url")
57 (autoload 'mm-extern-cache-contents "mm-extern")
59 (defgroup gnus-article nil
61 :link '(custom-manual "(gnus)Article Buffer")
64 (defgroup gnus-article-treat nil
65 "Treating article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-hiding nil
70 "Hiding article parts."
71 :link '(custom-manual "(gnus)Article Hiding")
74 (defgroup gnus-article-highlight nil
75 "Article highlighting."
76 :link '(custom-manual "(gnus)Article Highlighting")
80 (defgroup gnus-article-signature nil
82 :link '(custom-manual "(gnus)Article Signature")
85 (defgroup gnus-article-headers nil
87 :link '(custom-manual "(gnus)Hiding Headers")
90 (defgroup gnus-article-washing nil
91 "Special commands on articles."
92 :link '(custom-manual "(gnus)Article Washing")
95 (defgroup gnus-article-emphasis nil
96 "Fontisizing articles."
97 :link '(custom-manual "(gnus)Article Fontisizing")
100 (defgroup gnus-article-saving nil
102 :link '(custom-manual "(gnus)Saving Articles")
103 :group 'gnus-article)
105 (defgroup gnus-article-mime nil
106 "Worshiping the MIME wonder."
107 :link '(custom-manual "(gnus)Using MIME")
108 :group 'gnus-article)
110 (defgroup gnus-article-buttons nil
111 "Pushable buttons in the article buffer."
112 :link '(custom-manual "(gnus)Article Buttons")
113 :group 'gnus-article)
115 (defgroup gnus-article-various nil
116 "Other article options."
117 :link '(custom-manual "(gnus)Misc Article")
118 :group 'gnus-article)
120 (defcustom gnus-ignored-headers
123 (concat "^" header ":"))
124 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
125 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
126 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
127 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
128 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
129 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
130 "X-Attribution" "X-Originating-IP" "Delivered-To"
131 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
132 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
133 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
134 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
135 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
136 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
137 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
138 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
139 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
140 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
141 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
142 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
143 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
144 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
145 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
146 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
147 "List-[A-Za-z]+" "X-Listprocessor-Version"
148 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
149 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
150 "X-Received" "Content-length" "X-precedence"
151 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
152 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
153 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
154 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
155 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
156 "X-Content-length" "X-Posting-Agent" "Original-Received"
157 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
158 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
159 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
160 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
161 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type '(choice :custom-show nil
168 :group 'gnus-article-hiding)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
175 :type '(repeat :value-to-internal (lambda (widget value)
176 (custom-split-regexp-maybe value))
177 :match (lambda (widget value)
179 (widget-editable-list-match widget value)))
181 :group 'gnus-article-hiding)
183 (defcustom gnus-sorted-header-list
184 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
185 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
186 "*This variable is a list of regular expressions.
187 If it is non-nil, headers that match the regular expressions will
188 be placed first in the article buffer in the sequence specified by
190 :type '(repeat regexp)
191 :group 'gnus-article-hiding)
193 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
194 "Headers that are only to be displayed if they have interesting data.
195 Possible values in this list are:
197 'empty Headers with no content.
198 'newsgroups Newsgroup identical to Gnus group.
199 'to-address To identical to To-address.
200 'to-list To identical to To-list.
201 'cc-list CC identical to To-list.
202 'followup-to Followup-to identical to Newsgroups.
203 'reply-to Reply-to identical to From.
204 'date Date less than four days old.
205 'long-to To and/or Cc longer than 1024 characters.
206 'many-to Multiple To and/or Cc."
207 :type '(set (const :tag "Headers with no content." empty)
208 (const :tag "Newsgroups identical to Gnus group." newsgroups)
209 (const :tag "To identical to To-address." to-address)
210 (const :tag "To identical to To-list." to-list)
211 (const :tag "CC identical to To-list." cc-list)
212 (const :tag "Followup-to identical to Newsgroups." followup-to)
213 (const :tag "Reply-to identical to From." reply-to)
214 (const :tag "Date less than four days old." date)
215 (const :tag "To and/or Cc longer than 1024 characters." long-to)
216 (const :tag "Multiple To and/or Cc headers." many-to))
217 :group 'gnus-article-hiding)
219 (defcustom gnus-article-skip-boring nil
220 "Skip over text that is not worth reading.
221 By default, if you set this t, then Gnus will display citations and
222 signatures, but will never scroll down to show you a page consisting
223 only of boring text. Boring text is controlled by
224 `gnus-article-boring-faces'."
227 :group 'gnus-article-hiding)
229 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
230 "Regexp matching signature separator.
231 This can also be a list of regexps. In that case, it will be checked
232 from head to tail looking for a separator. Searches will be done from
233 the end of the buffer."
234 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
236 (repeat :tag "List of regexp" regexp))
237 :group 'gnus-article-signature)
239 (defcustom gnus-signature-limit nil
240 "Provide a limit to what is considered a signature.
241 If it is a number, no signature may not be longer (in characters) than
242 that number. If it is a floating point number, no signature may be
243 longer (in lines) than that number. If it is a function, the function
244 will be called without any parameters, and if it returns nil, there is
245 no signature in the buffer. If it is a string, it will be used as a
246 regexp. If it matches, the text in question is not a signature.
248 This can also be a list of the above values."
249 :type '(choice (const nil)
252 (function :value fun)
253 (regexp :value ".*"))
254 :group 'gnus-article-signature)
256 (defcustom gnus-hidden-properties '(invisible t intangible t)
257 "Property list to use for hiding text."
259 :group 'gnus-article-hiding)
261 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
262 ;; frames in a session.
263 (defcustom gnus-article-x-face-command
264 (if (featurep 'xemacs)
265 (if (or (gnus-image-type-available-p 'xface)
266 (gnus-image-type-available-p 'pbm))
267 'gnus-display-x-face-in-from
268 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
269 (if (gnus-image-type-available-p 'pbm)
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
273 "*String or function to be executed to display an X-Face header.
274 If it is a string, the command will be executed in a sub-shell
275 asynchronously. The compressed face will be piped to this command."
276 :type `(choice string
277 (function-item gnus-display-x-face-in-from)
281 :group 'gnus-article-washing)
283 (defcustom gnus-article-x-face-too-ugly nil
284 "Regexp matching posters whose face shouldn't be shown automatically."
285 :type '(choice regexp (const nil))
286 :group 'gnus-article-washing)
288 (defcustom gnus-article-banner-alist nil
289 "Banner alist for stripping.
291 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
293 :type '(repeat (cons symbol regexp))
294 :group 'gnus-article-washing)
296 (gnus-define-group-parameter
299 "Alist of regexps (to match group names) and banner."
300 :variable-group gnus-article-washing
302 '(choice :tag "Banner"
304 (const :tag "Remove signature" signature)
305 (symbol :tag "Item in `gnus-article-banner-alist'" none)
307 (const :tag "None" nil))
309 "If non-nil, specify how to remove `banners' from articles.
311 Symbol `signature' means to remove signatures delimited by
312 `gnus-signature-separator'. Any other symbol is used to look up a
313 regular expression to match the banner in `gnus-article-banner-alist'.
314 A string is used as a regular expression to match the banner
317 (defcustom gnus-article-address-banner-alist nil
318 "Alist of mail addresses and banners.
319 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
320 to match a mail address in the From: header, BANNER is one of a symbol
321 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
322 If ADDRESS matches author's mail address, it will remove things like
323 advertisements. For example:
325 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
329 (regexp :tag "Address")
330 (choice :tag "Banner" :value nil
331 (const :tag "Remove signature" signature)
332 (symbol :tag "Item in `gnus-article-banner-alist'" none)
334 (const :tag "None" nil))))
336 :group 'gnus-article-washing)
338 (defmacro gnus-emphasis-custom-with-format (&rest body)
340 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
341 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
344 (defun gnus-emphasis-custom-value-to-external (value)
345 (gnus-emphasis-custom-with-format
346 (if (consp (car value))
347 (list (format format (car (car value)) (cdr (car value)))
349 (if (nth 1 value) 2 3)
353 (defun gnus-emphasis-custom-value-to-internal (value)
354 (gnus-emphasis-custom-with-format
355 (let ((regexp (concat "\\`"
356 (format (regexp-quote format)
357 "\\([^()]+\\)" "\\([^()]+\\)")
360 (if (string-match regexp (setq pattern (car value)))
361 (list (cons (match-string 1 pattern) (match-string 2 pattern))
366 (defcustom gnus-emphasis-alist
368 '(("\\*" "\\*" bold nil 2)
371 ("_/" "/_" underline-italic)
372 ("_\\*" "\\*_" underline-bold)
373 ("\\*/" "/\\*" bold-italic)
374 ("_\\*/" "/\\*_" underline-bold-italic))))
376 (gnus-emphasis-custom-with-format
377 (mapcar (lambda (spec)
378 (list (format format (car spec) (cadr spec))
381 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
383 '(;; I've never seen anyone use this strikethru convention whereas I've
384 ;; several times seen it triggered by normal text. --Stef
385 ;; Miles suggests that this form is sometimes used but for italics,
386 ;; so maybe we should map it to `italic'.
387 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
388 ;; 2 3 gnus-emphasis-strikethru)
389 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
390 2 3 gnus-emphasis-underline))))
391 "*Alist that says how to fontify certain phrases.
392 Each item looks like this:
394 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
396 The first element is a regular expression to be matched. The second
397 is a number that says what regular expression grouping used to find
398 the entire emphasized word. The third is a number that says what
399 regexp grouping should be displayed and highlighted. The fourth
400 is the face used for highlighting."
404 :format "%[Customizing Style%]\n%v"
406 (group :tag "Default"
407 :value ("" 0 0 default)
410 (let ((value (widget-get
411 (cadr (widget-get (widget-get widget :parent)
414 (if (not (eq (nth 2 value) 'default))
418 (gnus-emphasis-custom-value-to-external value))))
419 (widget-group-value-create widget))
421 (integer :format "Match group: %v")
422 (integer :format "Emphasize group: %v")
425 :value (("_" . "_") nil default)
427 (regexp :format "Start regexp: %v")
428 (regexp :format "End regexp: %v"))
429 (boolean :format "Show start and end patterns: %[%v%]\n"
430 :on " On " :off " Off ")
432 :get (lambda (symbol)
433 (mapcar 'gnus-emphasis-custom-value-to-internal
434 (default-value symbol)))
435 :set (lambda (symbol value)
436 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
438 :group 'gnus-article-emphasis)
440 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
441 "A regexp to describe whitespace which should not be emphasized.
442 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
443 The former avoids underlining of leading and trailing whitespace,
444 and the latter avoids underlining any whitespace at all."
446 :group 'gnus-article-emphasis
449 (defface gnus-emphasis-bold '((t (:bold t)))
450 "Face used for displaying strong emphasized text (*word*)."
451 :group 'gnus-article-emphasis)
453 (defface gnus-emphasis-italic '((t (:italic t)))
454 "Face used for displaying italic emphasized text (/word/)."
455 :group 'gnus-article-emphasis)
457 (defface gnus-emphasis-underline '((t (:underline t)))
458 "Face used for displaying underlined emphasized text (_word_)."
459 :group 'gnus-article-emphasis)
461 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
462 "Face used for displaying underlined bold emphasized text (_*word*_)."
463 :group 'gnus-article-emphasis)
465 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
466 "Face used for displaying underlined italic emphasized text (_/word/_)."
467 :group 'gnus-article-emphasis)
469 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
470 "Face used for displaying bold italic emphasized text (/*word*/)."
471 :group 'gnus-article-emphasis)
473 (defface gnus-emphasis-underline-bold-italic
474 '((t (:bold t :italic t :underline t)))
475 "Face used for displaying underlined bold italic emphasized text.
476 Example: (_/*word*/_)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
480 '((t (:strikethru t)))
481 '((t (:strike-through t))))
482 "Face used for displaying strike-through text (-word-)."
483 :group 'gnus-article-emphasis)
485 (defface gnus-emphasis-highlight-words
486 '((t (:background "black" :foreground "yellow")))
487 "Face used for displaying highlighted words."
488 :group 'gnus-article-emphasis)
490 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
491 "Format for display of Date headers in article bodies.
492 See `format-time-string' for the possible values.
494 The variable can also be function, which should return a complete Date
495 header. The function is called with one argument, the time, which can
496 be fed to `format-time-string'."
497 :type '(choice string function)
498 :link '(custom-manual "(gnus)Article Date")
499 :group 'gnus-article-washing)
501 (defcustom gnus-save-all-headers t
502 "*If non-nil, don't remove any headers before saving."
503 :group 'gnus-article-saving
506 (defcustom gnus-prompt-before-saving 'always
507 "*This variable says how much prompting is to be done when saving articles.
508 If it is nil, no prompting will be done, and the articles will be
509 saved to the default files. If this variable is `always', each and
510 every article that is saved will be preceded by a prompt, even when
511 saving large batches of articles. If this variable is neither nil not
512 `always', there the user will be prompted once for a file name for
513 each invocation of the saving commands."
514 :group 'gnus-article-saving
515 :type '(choice (item always)
516 (item :tag "never" nil)
517 (sexp :tag "once" :format "%t\n" :value t)))
519 (defcustom gnus-saved-headers gnus-visible-headers
520 "Headers to keep if `gnus-save-all-headers' is nil.
521 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
522 If that variable is nil, however, all headers that match this regexp
523 will be kept while the rest will be deleted before saving."
524 :group 'gnus-article-saving
527 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
528 "A function to save articles in your favourite format.
529 The function must be interactively callable (in other words, it must
530 be an Emacs command).
532 Gnus provides the following functions:
534 * gnus-summary-save-in-rmail (Rmail format)
535 * gnus-summary-save-in-mail (Unix mail format)
536 * gnus-summary-save-in-folder (MH folder)
537 * gnus-summary-save-in-file (article format)
538 * gnus-summary-save-body-in-file (article body)
539 * gnus-summary-save-in-vm (use VM's folder format)
540 * gnus-summary-write-to-file (article format -- overwrite)."
541 :group 'gnus-article-saving
542 :type '(radio (function-item gnus-summary-save-in-rmail)
543 (function-item gnus-summary-save-in-mail)
544 (function-item gnus-summary-save-in-folder)
545 (function-item gnus-summary-save-in-file)
546 (function-item gnus-summary-save-body-in-file)
547 (function-item gnus-summary-save-in-vm)
548 (function-item gnus-summary-write-to-file)
551 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
552 "A function generating a file name to save articles in Rmail format.
553 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
554 :group 'gnus-article-saving
557 (defcustom gnus-mail-save-name 'gnus-plain-save-name
558 "A function generating a file name to save articles in Unix mail format.
559 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
560 :group 'gnus-article-saving
563 (defcustom gnus-folder-save-name 'gnus-folder-save-name
564 "A function generating a file name to save articles in MH folder.
565 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
566 :group 'gnus-article-saving
569 (defcustom gnus-file-save-name 'gnus-numeric-save-name
570 "A function generating a file name to save articles in article format.
571 The function is called with NEWSGROUP, HEADERS, and optional
573 :group 'gnus-article-saving
576 (defcustom gnus-split-methods
577 '((gnus-article-archive-name)
578 (gnus-article-nndoc-name))
579 "*Variable used to suggest where articles are to be saved.
580 For instance, if you would like to save articles related to Gnus in
581 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
582 you could set this variable to something like:
584 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
585 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
587 This variable is an alist where the key is the match and the
588 value is a list of possible files to save in if the match is
591 If the match is a string, it is used as a regexp match on the
592 article. If the match is a symbol, that symbol will be funcalled
593 from the buffer of the article to be saved with the newsgroup as
594 the parameter. If it is a list, it will be evaled in the same
597 If this form or function returns a string, this string will be
598 used as a possible file name; and if it returns a non-nil list,
599 that list will be used as possible file names."
600 :group 'gnus-article-saving
601 :type '(repeat (choice (list :value (fun) function)
602 (cons :value ("" "") regexp (repeat string))
605 (defcustom gnus-page-delimiter "^\^L"
606 "*Regexp describing what to use as article page delimiters.
607 The default value is \"^\^L\", which is a form linefeed at the
608 beginning of a line."
610 :group 'gnus-article-various)
612 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
613 "*The format specification for the article mode line.
614 See `gnus-summary-mode-line-format' for a closer description.
616 The following additional specs are available:
618 %w The article washing status.
619 %m The number of MIME parts in the article."
621 :group 'gnus-article-various)
623 (defcustom gnus-article-mode-hook nil
624 "*A hook for Gnus article mode."
626 :group 'gnus-article-various)
628 (when (featurep 'xemacs)
629 ;; Extracted from gnus-xmas-define in order to preserve user settings
630 (when (fboundp 'turn-off-scroll-in-place)
631 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
632 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
633 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
635 (defcustom gnus-article-menu-hook nil
636 "*Hook run after the creation of the article mode menu."
638 :group 'gnus-article-various)
640 (defcustom gnus-article-prepare-hook nil
641 "*A hook called after an article has been prepared in the article buffer."
643 :group 'gnus-article-various)
645 (defcustom gnus-copy-article-ignored-headers nil
646 "List of headers to be removed when copying an article.
647 Each element is a regular expression."
648 :version "23.0" ;; No Gnus
649 :type '(repeat regexp)
650 :group 'gnus-article-various)
652 (make-obsolete-variable 'gnus-article-hide-pgp-hook
653 "This variable is obsolete in Gnus 5.10.")
656 '((t (:weight bold)))
657 "Face used for highlighting a button in the article buffer."
658 :group 'gnus-article-buttons)
660 (defcustom gnus-article-button-face 'gnus-button
661 "Face used for highlighting buttons in the article buffer.
663 An article button is a piece of text that you can activate by pressing
664 `RET' or `mouse-2' above it."
666 :group 'gnus-article-buttons)
668 (defcustom gnus-article-mouse-face 'highlight
669 "Face used for mouse highlighting in the article buffer.
671 Article buttons will be displayed in this face when the cursor is
674 :group 'gnus-article-buttons)
676 (defcustom gnus-signature-face 'gnus-signature
677 "Face used for highlighting a signature in the article buffer.
678 Obsolete; use the face `gnus-signature' for customizations instead."
680 :group 'gnus-article-highlight
681 :group 'gnus-article-signature)
683 (defface gnus-signature
686 "Face used for highlighting a signature in the article buffer."
687 :group 'gnus-article-highlight
688 :group 'gnus-article-signature)
689 ;; backward-compatibility alias
690 (put 'gnus-signature-face 'face-alias 'gnus-signature)
692 (defface gnus-header-from
695 (:foreground "spring green"))
698 (:foreground "red3"))
701 "Face used for displaying from headers."
702 :group 'gnus-article-headers
703 :group 'gnus-article-highlight)
704 ;; backward-compatibility alias
705 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
707 (defface gnus-header-subject
710 (:foreground "SeaGreen3"))
713 (:foreground "red4"))
715 (:bold t :italic t)))
716 "Face used for displaying subject headers."
717 :group 'gnus-article-headers
718 :group 'gnus-article-highlight)
719 ;; backward-compatibility alias
720 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
722 (defface gnus-header-newsgroups
725 (:foreground "yellow" :italic t))
728 (:foreground "MidnightBlue" :italic t))
731 "Face used for displaying newsgroups headers.
732 In the default setup this face is only used for crossposted
734 :group 'gnus-article-headers
735 :group 'gnus-article-highlight)
736 ;; backward-compatibility alias
737 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
739 (defface gnus-header-name
742 (:foreground "SeaGreen"))
745 (:foreground "maroon"))
748 "Face used for displaying header names."
749 :group 'gnus-article-headers
750 :group 'gnus-article-highlight)
751 ;; backward-compatibility alias
752 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
754 (defface gnus-header-content
757 (:foreground "forest green" :italic t))
760 (:foreground "indianred4" :italic t))
762 (:italic t))) "Face used for displaying header content."
763 :group 'gnus-article-headers
764 :group 'gnus-article-highlight)
765 ;; backward-compatibility alias
766 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
768 (defcustom gnus-header-face-alist
769 '(("From" nil gnus-header-from)
770 ("Subject" nil gnus-header-subject)
771 ("Newsgroups:.*," nil gnus-header-newsgroups)
772 ("" gnus-header-name gnus-header-content))
773 "*Controls highlighting of article headers.
775 An alist of the form (HEADER NAME CONTENT).
777 HEADER is a regular expression which should match the name of a
778 header and NAME and CONTENT are either face names or nil.
780 The name of each header field will be displayed using the face
781 specified by the first element in the list where HEADER matches
782 the header name and NAME is non-nil. Similarly, the content will
783 be displayed by the first non-nil matching CONTENT face."
784 :group 'gnus-article-headers
785 :group 'gnus-article-highlight
786 :type '(repeat (list (regexp :tag "Header")
788 (item :tag "skip" nil)
789 (face :value default))
790 (choice :tag "Content"
791 (item :tag "skip" nil)
792 (face :value default)))))
794 (defcustom gnus-article-decode-hook
795 '(article-decode-charset article-decode-encoded-words
796 article-decode-group-name article-decode-idna-rhs)
797 "*Hook run to decode charsets in articles."
798 :group 'gnus-article-headers
801 (defcustom gnus-display-mime-function 'gnus-display-mime
802 "Function to display MIME articles."
803 :group 'gnus-article-mime
806 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
807 "Function used to decode headers.")
809 (defvar gnus-article-dumbquotes-map
829 "Table for MS-to-Latin1 translation.")
831 (defcustom gnus-ignored-mime-types nil
832 "List of MIME types that should be ignored by Gnus."
834 :group 'gnus-article-mime
835 :type '(repeat regexp))
837 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
838 "List of MIME types that should not be given buttons when rendered inline.
839 See also `gnus-buttonized-mime-types' which may override this variable.
840 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
842 :group 'gnus-article-mime
843 :type '(repeat regexp))
845 (defcustom gnus-buttonized-mime-types nil
846 "List of MIME types that should be given buttons when rendered inline.
847 If set, this variable overrides `gnus-unbuttonized-mime-types'.
848 To see e.g. security buttons you could set this to
849 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
850 this list to display radio buttons that allow you to choose one of two
851 media types those mails include. See also `mm-discouraged-alternatives'.
852 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
854 :group 'gnus-article-mime
855 :type '(repeat regexp))
857 (defcustom gnus-inhibit-mime-unbuttonizing nil
858 "If non-nil, all MIME parts get buttons.
859 When nil (the default value), then some MIME parts do not get buttons,
860 as described by the variables `gnus-buttonized-mime-types' and
861 `gnus-unbuttonized-mime-types'."
863 :group 'gnus-article-mime
866 (defcustom gnus-body-boundary-delimiter "_"
867 "String used to delimit header and body.
868 This variable is used by `gnus-article-treat-body-boundary' which can
869 be controlled by `gnus-treat-body-boundary'."
871 :group 'gnus-article-various
872 :type '(choice (item :tag "None" :value nil)
875 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
877 "Defines the location of the faces database.
878 For information on obtaining this database of pretty pictures, please
879 see http://www.cs.indiana.edu/picons/ftp/index.html"
881 :type '(repeat directory)
882 :link '(url-link :tag "download"
883 "http://www.cs.indiana.edu/picons/ftp/index.html")
884 :link '(custom-manual "(gnus)Picons")
887 (defun gnus-picons-installed-p ()
888 "Say whether picons are installed on your machine."
889 (let ((installed nil))
890 (dolist (database gnus-picon-databases)
891 (when (file-exists-p database)
895 (defcustom gnus-article-mime-part-function nil
896 "Function called with a MIME handle as the argument.
897 This is meant for people who want to do something automatic based
898 on parts -- for instance, adding Vcard info to a database."
899 :group 'gnus-article-mime
900 :type '(choice (const nil)
903 (defcustom gnus-mime-multipart-functions nil
904 "An alist of MIME types to functions to display them."
906 :group 'gnus-article-mime
907 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
909 (defcustom gnus-article-date-lapsed-new-header nil
910 "Whether the X-Sent and Date headers can coexist.
911 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
912 either replace the old \"Date:\" header (if this variable is nil), or
913 be added below it (otherwise)."
915 :group 'gnus-article-headers
918 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
919 "Function called with a MIME handle as the argument.
920 This is meant for people who want to view first matched part.
921 For `undisplayed-alternative' (default), the first undisplayed
922 part or alternative part is used. For `undisplayed', the first
923 undisplayed part is used. For a function, the first part which
924 the function return t is used. For nil, the first part is
927 :group 'gnus-article-mime
929 (item :tag "first" :value nil)
930 (item :tag "undisplayed" :value undisplayed)
931 (item :tag "undisplayed or alternative"
932 :value undisplayed-alternative)
935 (defcustom gnus-mime-action-alist
936 '(("save to file" . gnus-mime-save-part)
937 ("save and strip" . gnus-mime-save-part-and-strip)
938 ("replace with file" . gnus-mime-replace-part)
939 ("delete part" . gnus-mime-delete-part)
940 ("display as text" . gnus-mime-inline-part)
941 ("view the part" . gnus-mime-view-part)
942 ("pipe to command" . gnus-mime-pipe-part)
943 ("toggle display" . gnus-article-press-button)
944 ("toggle display" . gnus-article-view-part-as-charset)
945 ("view as type" . gnus-mime-view-part-as-type)
946 ("view internally" . gnus-mime-view-part-internally)
947 ("view externally" . gnus-mime-view-part-externally))
948 "An alist of actions that run on the MIME attachment."
949 :group 'gnus-article-mime
950 :type '(repeat (cons (string :tag "name")
953 (defcustom gnus-auto-select-part 1
954 "Advance to next MIME part when deleting or stripping parts.
956 When 0, point will be placed on the same part as before. When
957 positive (negative), move point forward (backwards) this many
958 parts. When nil, redisplay article."
959 :version "23.0" ;; No Gnus
960 :group 'gnus-article-mime
961 :type '(choice (const nil :tag "Redisplay article.")
962 (const 1 :tag "Next part.")
963 (const 0 :tag "Current part.")
967 ;;; The treatment variables
970 (defvar gnus-part-display-hook nil
971 "Hook called on parts that are to receive treatment.")
973 (defvar gnus-article-treat-custom
974 '(choice (const :tag "Off" nil)
976 (const :tag "Header" head)
977 (const :tag "First" first)
978 (const :tag "Last" last)
979 (integer :tag "Less")
980 (repeat :tag "Groups" regexp)
981 (sexp :tag "Predicate")))
983 (defvar gnus-article-treat-head-custom
984 '(choice (const :tag "Off" nil)
985 (const :tag "Header" head)))
987 (defvar gnus-article-treat-types '("text/plain")
990 (defvar gnus-inhibit-treatment nil
991 "Whether to inhibit treatment.")
993 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
994 "Highlight the signature.
995 Valid values are nil, t, `head', `first', `last', an integer or a
996 predicate. See Info node `(gnus)Customizing Articles'."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1000 (put 'gnus-treat-highlight-signature 'highlight t)
1002 (defcustom gnus-treat-buttonize 100000
1004 Valid values are nil, t, `head', `first', `last', an integer or a
1005 predicate. See Info node `(gnus)Customizing Articles'."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1009 (put 'gnus-treat-buttonize 'highlight t)
1011 (defcustom gnus-treat-buttonize-head 'head
1012 "Add buttons to the head.
1013 Valid values are nil, t, `head', `first', `last', an integer or a
1014 predicate. See Info node `(gnus)Customizing Articles'."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-head-custom)
1018 (put 'gnus-treat-buttonize-head 'highlight t)
1020 (defcustom gnus-treat-emphasize
1021 (and (or window-system
1025 Valid values are nil, t, `head', `first', `last', an integer or a
1026 predicate. See Info node `(gnus)Customizing Articles'."
1027 :group 'gnus-article-treat
1028 :link '(custom-manual "(gnus)Customizing Articles")
1029 :type gnus-article-treat-custom)
1030 (put 'gnus-treat-emphasize 'highlight t)
1032 (defcustom gnus-treat-strip-cr nil
1033 "Remove carriage returns.
1034 Valid values are nil, t, `head', `first', `last', an integer or a
1035 predicate. See Info node `(gnus)Customizing Articles'."
1037 :group 'gnus-article-treat
1038 :link '(custom-manual "(gnus)Customizing Articles")
1039 :type gnus-article-treat-custom)
1041 (defcustom gnus-treat-unsplit-urls nil
1042 "Remove newlines from within URLs.
1043 Valid values are nil, t, `head', `first', `last', an integer or a
1044 predicate. See Info node `(gnus)Customizing Articles'."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-leading-whitespace nil
1051 "Remove leading whitespace in headers.
1052 Valid values are nil, t, `head', `first', `last', an integer or a
1053 predicate. See Info node `(gnus)Customizing Articles'."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-hide-headers 'head
1061 Valid values are nil, t, `head', `first', `last', an integer or a
1062 predicate. See Info node `(gnus)Customizing Articles'."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1067 (defcustom gnus-treat-hide-boring-headers nil
1068 "Hide boring headers.
1069 Valid values are nil, t, `head', `first', `last', an integer or a
1070 predicate. See Info node `(gnus)Customizing Articles'."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-hide-signature nil
1076 "Hide the signature.
1077 Valid values are nil, t, `head', `first', `last', an integer or a
1078 predicate. See Info node `(gnus)Customizing Articles'."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom)
1083 (defcustom gnus-treat-fill-article nil
1085 Valid values are nil, t, `head', `first', `last', an integer or a
1086 predicate. See Info node `(gnus)Customizing Articles'."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-hide-citation nil
1093 Valid values are nil, t, `head', `first', `last', an integer or a
1094 predicate. See Info node `(gnus)Customizing Articles'."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-hide-citation-maybe nil
1101 Valid values are nil, t, `head', `first', `last', an integer or a
1102 predicate. See Info node `(gnus)Customizing Articles'."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-strip-list-identifiers 'head
1108 "Strip list identifiers from `gnus-list-identifiers`.
1109 Valid values are nil, t, `head', `first', `last', an integer or a
1110 predicate. See Info node `(gnus)Customizing Articles'."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom)
1116 (make-obsolete-variable 'gnus-treat-strip-pgp
1117 "This option is obsolete in Gnus 5.10.")
1119 (defcustom gnus-treat-strip-pem nil
1120 "Strip PEM signatures.
1121 Valid values are nil, t, `head', `first', `last', an integer or a
1122 predicate. See Info node `(gnus)Customizing Articles'."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-strip-banner t
1128 "Strip banners from articles.
1129 The banner to be stripped is specified in the `banner' group parameter.
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1136 (defcustom gnus-treat-highlight-headers 'head
1137 "Highlight the headers.
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-head-custom)
1143 (put 'gnus-treat-highlight-headers 'highlight t)
1145 (defcustom gnus-treat-highlight-citation t
1146 "Highlight cited text.
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-custom)
1152 (put 'gnus-treat-highlight-citation 'highlight t)
1154 (defcustom gnus-treat-date-ut nil
1155 "Display the Date in UT (GMT).
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-head-custom)
1162 (defcustom gnus-treat-date-local nil
1163 "Display the Date in the local timezone.
1164 Valid values are nil, t, `head', `first', `last', an integer or a
1165 predicate. See Info node `(gnus)Customizing Articles'."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-date-english nil
1171 "Display the Date in a format that can be read aloud in English.
1172 Valid values are nil, t, `head', `first', `last', an integer or a
1173 predicate. See Info node `(gnus)Customizing Articles'."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom)
1179 (defcustom gnus-treat-date-lapsed nil
1180 "Display the Date header in a way that says how much time has elapsed.
1181 Valid values are nil, t, `head', `first', `last', an integer or a
1182 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-original nil
1188 "Display the date in the original timezone.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-head-custom)
1195 (defcustom gnus-treat-date-iso8601 nil
1196 "Display the date in the ISO8601 format.
1197 Valid values are nil, t, `head', `first', `last', an integer or a
1198 predicate. See Info node `(gnus)Customizing Articles'."
1200 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-head-custom)
1204 (defcustom gnus-treat-date-user-defined nil
1205 "Display the date in a user-defined format.
1206 The format is defined by the `gnus-article-time-format' variable.
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom)
1213 (defcustom gnus-treat-strip-headers-in-body t
1214 "Strip the X-No-Archive header line from the beginning of the body.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom)
1222 (defcustom gnus-treat-strip-trailing-blank-lines nil
1223 "Strip trailing blank lines.
1224 Valid values are nil, t, `head', `first', `last', an integer or a
1225 predicate. See Info node `(gnus)Customizing Articles'.
1227 When set to t, it also strips trailing blanks in all MIME parts.
1228 Consider to use `last' instead."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-strip-leading-blank-lines nil
1234 "Strip leading blank lines.
1235 Valid values are nil, t, `head', `first', `last', an integer or a
1236 predicate. See Info node `(gnus)Customizing Articles'.
1238 When set to t, it also strips trailing blanks in all MIME parts."
1239 :group 'gnus-article-treat
1240 :link '(custom-manual "(gnus)Customizing Articles")
1241 :type gnus-article-treat-custom)
1243 (defcustom gnus-treat-strip-multiple-blank-lines nil
1244 "Strip multiple blank lines.
1245 Valid values are nil, t, `head', `first', `last', an integer or a
1246 predicate. See Info node `(gnus)Customizing Articles'."
1247 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom)
1251 (defcustom gnus-treat-unfold-headers 'head
1252 "Unfold folded header lines.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1256 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :type gnus-article-treat-custom)
1260 (defcustom gnus-treat-fold-headers nil
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1265 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-custom)
1269 (defcustom gnus-treat-fold-newsgroups 'head
1270 "Fold the Newsgroups and Followup-To headers.
1271 Valid values are nil, t, `head', `first', `last', an integer or a
1272 predicate. See Info node `(gnus)Customizing Articles'."
1274 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :type gnus-article-treat-custom)
1278 (defcustom gnus-treat-overstrike t
1279 "Treat overstrike highlighting.
1280 Valid values are nil, t, `head', `first', `last', an integer or a
1281 predicate. See Info node `(gnus)Customizing Articles'."
1282 :group 'gnus-article-treat
1283 :link '(custom-manual "(gnus)Customizing Articles")
1284 :type gnus-article-treat-custom)
1285 (put 'gnus-treat-overstrike 'highlight t)
1287 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1288 "Treat ANSI SGR control sequences.
1289 Valid values are nil, t, `head', `first', `last', an integer or a
1290 predicate. See Info node `(gnus)Customizing Articles'."
1291 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom)
1295 (make-obsolete-variable 'gnus-treat-display-xface
1296 'gnus-treat-display-x-face)
1298 (defcustom gnus-treat-display-x-face
1299 (and (not noninteractive)
1300 (or (and (fboundp 'image-type-available-p)
1301 (image-type-available-p 'xbm)
1302 (string-match "^0x" (shell-command-to-string "uncompface"))
1303 (executable-find "icontopbm"))
1304 (and (featurep 'xemacs)
1307 "Display X-Face headers.
1308 Valid values are nil, t, `head', `first', `last', an integer or a
1309 predicate. See Info node `(gnus)Customizing Articles' and Info
1310 node `(gnus)X-Face' for details."
1311 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :link '(custom-manual "(gnus)X-Face")
1315 :type gnus-article-treat-head-custom
1316 :set (lambda (symbol value)
1319 (cond ((or (boundp symbol) (get symbol 'saved-value))
1321 ((boundp 'gnus-treat-display-xface)
1323 ** gnus-treat-display-xface is an obsolete variable;\
1324 use gnus-treat-display-x-face instead")
1325 (default-value 'gnus-treat-display-xface))
1326 ((get 'gnus-treat-display-xface 'saved-value)
1328 ** gnus-treat-display-xface is an obsolete variable;\
1329 use gnus-treat-display-x-face instead")
1330 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1333 (put 'gnus-treat-display-x-face 'highlight t)
1335 (defcustom gnus-treat-display-face
1336 (and (not noninteractive)
1337 (or (and (fboundp 'image-type-available-p)
1338 (image-type-available-p 'png))
1339 (and (featurep 'xemacs)
1342 "Display Face headers.
1343 Valid values are nil, t, `head', `first', `last', an integer or a
1344 predicate. See Info node `(gnus)Customizing Articles' and Info
1345 node `(gnus)X-Face' for details."
1346 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :link '(custom-manual "(gnus)X-Face")
1350 :type gnus-article-treat-head-custom)
1351 (put 'gnus-treat-display-face 'highlight t)
1353 (defcustom gnus-treat-display-smileys
1354 (if (or (and (featurep 'xemacs)
1356 (and (fboundp 'image-type-available-p)
1357 (image-type-available-p 'pbm)))
1360 Valid values are nil, t, `head', `first', `last', an integer or a
1361 predicate. See Info node `(gnus)Customizing Articles' and Info
1362 node `(gnus)Smileys' for details."
1363 :group 'gnus-article-treat
1365 :link '(custom-manual "(gnus)Customizing Articles")
1366 :link '(custom-manual "(gnus)Smileys")
1367 :type gnus-article-treat-custom)
1368 (put 'gnus-treat-display-smileys 'highlight t)
1370 (defcustom gnus-treat-from-picon
1371 (if (and (gnus-image-type-available-p 'xpm)
1372 (gnus-picons-installed-p))
1374 "Display picons in the From header.
1375 Valid values are nil, t, `head', `first', `last', an integer or a
1376 predicate. See Info node `(gnus)Customizing Articles' and Info
1377 node `(gnus)Picons' for details."
1379 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :link '(custom-manual "(gnus)Picons")
1383 :type gnus-article-treat-head-custom)
1384 (put 'gnus-treat-from-picon 'highlight t)
1386 (defcustom gnus-treat-mail-picon
1387 (if (and (gnus-image-type-available-p 'xpm)
1388 (gnus-picons-installed-p))
1390 "Display picons in To and Cc headers.
1391 Valid values are nil, t, `head', `first', `last', an integer or a
1392 predicate. See Info node `(gnus)Customizing Articles' and Info
1393 node `(gnus)Picons' for details."
1395 :group 'gnus-article-treat
1397 :link '(custom-manual "(gnus)Customizing Articles")
1398 :link '(custom-manual "(gnus)Picons")
1399 :type gnus-article-treat-head-custom)
1400 (put 'gnus-treat-mail-picon 'highlight t)
1402 (defcustom gnus-treat-newsgroups-picon
1403 (if (and (gnus-image-type-available-p 'xpm)
1404 (gnus-picons-installed-p))
1406 "Display picons in the Newsgroups and Followup-To headers.
1407 Valid values are nil, t, `head', `first', `last', an integer or a
1408 predicate. See Info node `(gnus)Customizing Articles' and Info
1409 node `(gnus)Picons' for details."
1411 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :link '(custom-manual "(gnus)Picons")
1415 :type gnus-article-treat-head-custom)
1416 (put 'gnus-treat-newsgroups-picon 'highlight t)
1418 (defcustom gnus-treat-body-boundary
1419 (if (and (eq window-system 'x)
1420 (or gnus-treat-newsgroups-picon
1421 gnus-treat-mail-picon
1422 gnus-treat-from-picon))
1424 "Draw a boundary at the end of the headers.
1425 Valid values are nil and `head'.
1426 See Info node `(gnus)Customizing Articles' for details."
1428 :group 'gnus-article-treat
1429 :link '(custom-manual "(gnus)Customizing Articles")
1430 :type gnus-article-treat-head-custom)
1432 (defcustom gnus-treat-capitalize-sentences nil
1433 "Capitalize sentence-starting words.
1434 Valid values are nil, t, `head', `first', `last', an integer or a
1435 predicate. See Info node `(gnus)Customizing Articles'."
1437 :group 'gnus-article-treat
1438 :link '(custom-manual "(gnus)Customizing Articles")
1439 :type gnus-article-treat-custom)
1441 (defcustom gnus-treat-wash-html nil
1443 Valid values are nil, t, `head', `first', `last', an integer or a
1444 predicate. See Info node `(gnus)Customizing Articles'."
1446 :group 'gnus-article-treat
1447 :link '(custom-manual "(gnus)Customizing Articles")
1448 :type gnus-article-treat-custom)
1450 (defcustom gnus-treat-fill-long-lines nil
1452 Valid values are nil, t, `head', `first', `last', an integer or a
1453 predicate. See Info node `(gnus)Customizing Articles'."
1454 :group 'gnus-article-treat
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :type gnus-article-treat-custom)
1458 (defcustom gnus-treat-play-sounds nil
1460 Valid values are nil, t, `head', `first', `last', an integer or a
1461 predicate. See Info node `(gnus)Customizing Articles'."
1463 :group 'gnus-article-treat
1464 :link '(custom-manual "(gnus)Customizing Articles")
1465 :type gnus-article-treat-custom)
1467 (defcustom gnus-treat-translate nil
1468 "Translate articles from one language to another.
1469 Valid values are nil, t, `head', `first', `last', an integer or a
1470 predicate. See Info node `(gnus)Customizing Articles'."
1472 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles")
1474 :type gnus-article-treat-custom)
1476 (defcustom gnus-treat-x-pgp-sig nil
1478 To automatically treat X-PGP-Sig, set it to head.
1479 Valid values are nil, t, `head', `first', `last', an integer or a
1480 predicate. See Info node `(gnus)Customizing Articles'."
1482 :group 'gnus-article-treat
1483 :group 'mime-security
1484 :link '(custom-manual "(gnus)Customizing Articles")
1485 :type gnus-article-treat-custom)
1487 (defvar gnus-article-encrypt-protocol-alist
1488 '(("PGP" . mml2015-self-encrypt)))
1490 ;; Set to nil if more than one protocol added to
1491 ;; gnus-article-encrypt-protocol-alist.
1492 (defcustom gnus-article-encrypt-protocol "PGP"
1493 "The protocol used for encrypt articles.
1494 It is a string, such as \"PGP\". If nil, ask user."
1497 :group 'mime-security)
1499 (defvar gnus-article-wash-function nil
1500 "Function used for converting HTML into text.")
1502 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1503 (mm-coding-system-p 'utf-8)
1504 (executable-find idna-program))
1505 "Whether IDNA decoding of headers is used when viewing messages.
1506 This requires GNU Libidn, and by default only enabled if it is found."
1508 :group 'gnus-article-headers
1511 (defcustom gnus-article-over-scroll nil
1512 "If non-nil, allow scrolling the article buffer even when there no more text."
1514 :group 'gnus-article
1517 ;;; Internal variables
1519 (defvar gnus-english-month-names
1520 '("January" "February" "March" "April" "May" "June" "July" "August"
1521 "September" "October" "November" "December"))
1523 (defvar gnus-button-regexp nil)
1524 (defvar gnus-button-marker-list nil)
1525 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1527 (defvar gnus-button-last nil)
1528 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1530 (defvar article-goto-body-goes-to-point-min-p nil)
1531 (defvar gnus-article-wash-types nil)
1532 (defvar gnus-article-emphasis-alist nil)
1533 (defvar gnus-article-image-alist nil)
1535 (defvar gnus-article-mime-handle-alist-1 nil)
1536 (defvar gnus-treatment-function-alist
1537 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1538 (gnus-treat-strip-banner gnus-article-strip-banner)
1539 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1540 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1541 (gnus-treat-buttonize gnus-article-add-buttons)
1542 (gnus-treat-fill-article gnus-article-fill-cited-article)
1543 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1544 (gnus-treat-strip-cr gnus-article-remove-cr)
1545 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1546 (gnus-treat-date-ut gnus-article-date-ut)
1547 (gnus-treat-date-local gnus-article-date-local)
1548 (gnus-treat-date-english gnus-article-date-english)
1549 (gnus-treat-date-original gnus-article-date-original)
1550 (gnus-treat-date-user-defined gnus-article-date-user)
1551 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1552 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1553 (gnus-treat-display-x-face gnus-article-display-x-face)
1554 (gnus-treat-display-face gnus-article-display-face)
1555 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1556 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1557 (gnus-treat-hide-signature gnus-article-hide-signature)
1558 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1559 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1560 (gnus-treat-strip-pem gnus-article-hide-pem)
1561 (gnus-treat-from-picon gnus-treat-from-picon)
1562 (gnus-treat-mail-picon gnus-treat-mail-picon)
1563 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1564 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1565 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1566 (gnus-treat-strip-trailing-blank-lines
1567 gnus-article-remove-trailing-blank-lines)
1568 (gnus-treat-strip-leading-blank-lines
1569 gnus-article-strip-leading-blank-lines)
1570 (gnus-treat-strip-multiple-blank-lines
1571 gnus-article-strip-multiple-blank-lines)
1572 (gnus-treat-overstrike gnus-article-treat-overstrike)
1573 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1574 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1575 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1576 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1577 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1578 (gnus-treat-display-smileys gnus-treat-smiley)
1579 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1580 (gnus-treat-wash-html gnus-article-wash-html)
1581 (gnus-treat-emphasize gnus-article-emphasize)
1582 (gnus-treat-hide-citation gnus-article-hide-citation)
1583 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1584 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1585 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1586 (gnus-treat-play-sounds gnus-earcon-display)))
1588 (defvar gnus-article-mime-handle-alist nil)
1589 (defvar article-lapsed-timer nil)
1590 (defvar gnus-article-current-summary nil)
1592 (defvar gnus-article-mode-syntax-table
1593 (let ((table (copy-syntax-table text-mode-syntax-table)))
1594 ;; This causes the citation match run O(2^n).
1595 ;; (modify-syntax-entry ?- "w" table)
1596 (modify-syntax-entry ?> ")<" table)
1597 (modify-syntax-entry ?< "(>" table)
1598 ;; make M-. in article buffers work for `foo' strings
1599 (modify-syntax-entry ?' " " table)
1600 (modify-syntax-entry ?` " " table)
1602 "Syntax table used in article mode buffers.
1603 Initialized from `text-mode-syntax-table.")
1605 (defvar gnus-save-article-buffer nil)
1607 (defvar gnus-article-mode-line-format-alist
1608 (nconc '((?w (gnus-article-wash-status) ?s)
1609 (?m (gnus-article-mime-part-status) ?s))
1610 gnus-summary-mode-line-format-alist))
1612 (defvar gnus-number-of-articles-to-be-saved nil)
1614 (defvar gnus-inhibit-hiding nil)
1616 (defvar gnus-article-edit-mode nil)
1618 ;;; Macros for dealing with the article buffer.
1620 (defmacro gnus-with-article-headers (&rest forms)
1622 (set-buffer gnus-article-buffer)
1624 (let ((inhibit-read-only t)
1625 (inhibit-point-motion-hooks t)
1626 (case-fold-search t))
1627 (article-narrow-to-head)
1630 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1631 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1633 (defmacro gnus-with-article-buffer (&rest forms)
1635 (set-buffer gnus-article-buffer)
1636 (let ((inhibit-read-only t))
1639 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1640 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1642 (defun gnus-article-goto-header (header)
1643 "Go to HEADER, which is a regular expression."
1644 (re-search-forward (concat "^\\(" header "\\):") nil t))
1646 (defsubst gnus-article-hide-text (b e props)
1647 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1648 (gnus-add-text-properties-when 'article-type nil b e props)
1649 (when (memq 'intangible props)
1651 (max (1- b) (point-min))
1652 b 'intangible (cddr (memq 'intangible props)))))
1654 (defsubst gnus-article-unhide-text (b e)
1655 "Remove hidden text properties from region between B and E."
1656 (remove-text-properties b e gnus-hidden-properties)
1657 (when (memq 'intangible gnus-hidden-properties)
1658 (put-text-property (max (1- b) (point-min))
1659 b 'intangible nil)))
1661 (defun gnus-article-hide-text-type (b e type)
1662 "Hide text of TYPE between B and E."
1663 (gnus-add-wash-type type)
1664 (gnus-article-hide-text
1665 b e (cons 'article-type (cons type gnus-hidden-properties))))
1667 (defun gnus-article-unhide-text-type (b e type)
1668 "Unhide text of TYPE between B and E."
1669 (gnus-delete-wash-type type)
1670 (remove-text-properties
1671 b e (cons 'article-type (cons type gnus-hidden-properties)))
1672 (when (memq 'intangible gnus-hidden-properties)
1673 (put-text-property (max (1- b) (point-min))
1674 b 'intangible nil)))
1676 (defun gnus-article-hide-text-of-type (type)
1677 "Hide text of TYPE in the current buffer."
1679 (let ((b (point-min))
1681 (while (setq b (text-property-any b e 'article-type type))
1682 (add-text-properties b (incf b) gnus-hidden-properties)))))
1684 (defun gnus-article-delete-text-of-type (type)
1685 "Delete text of TYPE in the current buffer."
1687 (let ((b (point-min)))
1688 (if (eq type 'multipart)
1689 ;; Remove MIME buttons associated with multipart/alternative parts.
1692 (while (if (get-text-property (point) 'gnus-part)
1694 (when (setq b (next-single-property-change (point)
1699 (skip-chars-forward "\n")
1700 (when (eq (get-text-property b 'article-type) 'multipart)
1701 (delete-region b (point)))))
1702 (while (setq b (text-property-any b (point-max) 'article-type type))
1704 b (or (text-property-not-all b (point-max) 'article-type type)
1707 (defun gnus-article-delete-invisible-text ()
1708 "Delete all invisible text in the current buffer."
1710 (let ((b (point-min)))
1711 (while (setq b (text-property-any b (point-max) 'invisible t))
1713 b (or (text-property-not-all b (point-max) 'invisible t)
1716 (defun gnus-article-text-type-exists-p (type)
1717 "Say whether any text of type TYPE exists in the buffer."
1718 (text-property-any (point-min) (point-max) 'article-type type))
1720 (defsubst gnus-article-header-rank ()
1721 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1722 (let ((list gnus-sorted-header-list)
1725 (if (looking-at (car list))
1727 (setq list (cdr list))
1731 (defun article-hide-headers (&optional arg delete)
1732 "Hide unwanted headers and possibly sort them as well."
1734 ;; This function might be inhibited.
1735 (unless gnus-inhibit-hiding
1736 (let ((inhibit-read-only nil)
1737 (case-fold-search t)
1738 (max (1+ (length gnus-sorted-header-list)))
1739 (inhibit-point-motion-hooks t)
1740 (cur (current-buffer))
1741 ignored visible beg)
1743 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1744 ;; group parameters, so we should go to the summary buffer.
1747 (progn (set-buffer gnus-summary-buffer) t)
1749 (setq ignored (when (not gnus-visible-headers)
1750 (cond ((stringp gnus-ignored-headers)
1751 gnus-ignored-headers)
1752 ((listp gnus-ignored-headers)
1753 (mapconcat 'identity
1754 gnus-ignored-headers
1756 visible (cond ((stringp gnus-visible-headers)
1757 gnus-visible-headers)
1758 ((and gnus-visible-headers
1759 (listp gnus-visible-headers))
1760 (mapconcat 'identity
1761 gnus-visible-headers
1765 ;; First we narrow to just the headers.
1766 (article-narrow-to-head)
1767 ;; Hide any "From " lines at the beginning of (mail) articles.
1768 (while (looking-at "From ")
1771 (delete-region (point-min) (point)))
1772 ;; Then treat the rest of the header lines.
1773 ;; Then we use the two regular expressions
1774 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1775 ;; select which header lines is to remain visible in the
1777 (while (re-search-forward "^[^ \t:]*:" nil t)
1779 ;; Mark the rank of the header.
1781 (point) (1+ (point)) 'message-rank
1782 (if (or (and visible (looking-at visible))
1784 (not (looking-at ignored))))
1785 (gnus-article-header-rank)
1788 (message-sort-headers-1)
1789 (when (setq beg (text-property-any
1790 (point-min) (point-max) 'message-rank (+ 2 max)))
1791 ;; We delete the unwanted headers.
1792 (gnus-add-wash-type 'headers)
1793 (add-text-properties (point-min) (+ 5 (point-min))
1794 '(article-type headers dummy-invisible t))
1795 (delete-region beg (point-max))))))))
1797 (defun article-hide-boring-headers (&optional arg)
1798 "Toggle hiding of headers that aren't very interesting.
1799 If given a negative prefix, always show; if given a positive prefix,
1801 (interactive (gnus-article-hidden-arg))
1802 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1803 (not gnus-show-all-headers))
1806 (let ((inhibit-read-only t)
1807 (inhibit-point-motion-hooks t))
1808 (article-narrow-to-head)
1809 (dolist (elem gnus-boring-article-headers)
1810 (goto-char (point-min))
1812 ;; Hide empty headers.
1814 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1816 (gnus-article-hide-text-type
1820 (if (re-search-forward "^[^ \t]" nil t)
1824 ;; Hide boring Newsgroups header.
1825 ((eq elem 'newsgroups)
1826 (when (gnus-string-equal
1827 (gnus-fetch-field "newsgroups")
1828 (gnus-group-real-name
1829 (if (boundp 'gnus-newsgroup-name)
1832 (gnus-article-hide-header "newsgroups")))
1833 ((eq elem 'to-address)
1834 (let ((to (message-fetch-field "to"))
1836 (gnus-parameter-to-address
1837 (if (boundp 'gnus-newsgroup-name)
1838 gnus-newsgroup-name ""))))
1839 (when (and to to-address
1842 ;; only one address in To
1843 (nth 1 (mail-extract-address-components to))
1845 (gnus-article-hide-header "to"))))
1847 (let ((to (message-fetch-field "to"))
1849 (gnus-parameter-to-list
1850 (if (boundp 'gnus-newsgroup-name)
1851 gnus-newsgroup-name ""))))
1852 (when (and to to-list
1855 ;; only one address in To
1856 (nth 1 (mail-extract-address-components to))
1858 (gnus-article-hide-header "to"))))
1860 (let ((cc (message-fetch-field "cc"))
1862 (gnus-parameter-to-list
1863 (if (boundp 'gnus-newsgroup-name)
1864 gnus-newsgroup-name ""))))
1865 (when (and cc to-list
1868 ;; only one address in CC
1869 (nth 1 (mail-extract-address-components cc))
1871 (gnus-article-hide-header "cc"))))
1872 ((eq elem 'followup-to)
1873 (when (gnus-string-equal
1874 (message-fetch-field "followup-to")
1875 (message-fetch-field "newsgroups"))
1876 (gnus-article-hide-header "followup-to")))
1877 ((eq elem 'reply-to)
1878 (if (gnus-group-find-parameter
1879 gnus-newsgroup-name 'broken-reply-to)
1880 (gnus-article-hide-header "reply-to")
1881 (let ((from (message-fetch-field "from"))
1882 (reply-to (message-fetch-field "reply-to")))
1889 (lambda (x) (downcase (cadr x)))
1890 (mail-extract-address-components from t))
1893 (lambda (x) (downcase (cadr x)))
1894 (mail-extract-address-components reply-to t))
1896 (gnus-article-hide-header "reply-to")))))
1898 (let ((date (message-fetch-field "date")))
1900 (< (days-between (current-time-string) date)
1902 (gnus-article-hide-header "date"))))
1904 (let ((to (message-fetch-field "to"))
1905 (cc (message-fetch-field "cc")))
1906 (when (> (length to) 1024)
1907 (gnus-article-hide-header "to"))
1908 (when (> (length cc) 1024)
1909 (gnus-article-hide-header "cc"))))
1913 (goto-char (point-min))
1914 (while (re-search-forward "^to:" nil t)
1915 (setq to-count (1+ to-count)))
1916 (when (> to-count 1)
1917 (while (> to-count 0)
1918 (goto-char (point-min))
1920 (re-search-forward "^to:" nil nil to-count)
1922 (narrow-to-region (point) (point-max))
1923 (gnus-article-hide-header "to"))
1924 (setq to-count (1- to-count))))
1925 (goto-char (point-min))
1926 (while (re-search-forward "^cc:" nil t)
1927 (setq cc-count (1+ cc-count)))
1928 (when (> cc-count 1)
1929 (while (> cc-count 0)
1930 (goto-char (point-min))
1932 (re-search-forward "^cc:" nil nil cc-count)
1934 (narrow-to-region (point) (point-max))
1935 (gnus-article-hide-header "cc"))
1936 (setq cc-count (1- cc-count)))))))))))))
1938 (defun gnus-article-hide-header (header)
1940 (goto-char (point-min))
1941 (when (re-search-forward (concat "^" header ":") nil t)
1942 (gnus-article-hide-text-type
1946 (if (re-search-forward "^[^ \t]" nil t)
1951 (defvar gnus-article-normalized-header-length 40
1952 "Length of normalized headers.")
1954 (defun article-normalize-headers ()
1955 "Make all header lines 40 characters long."
1957 (let ((inhibit-read-only t)
1961 (article-narrow-to-head)
1964 ((< (setq column (- (point-at-eol) (point)))
1965 gnus-article-normalized-header-length)
1967 (insert (make-string
1968 (- gnus-article-normalized-header-length column)
1970 ((> column gnus-article-normalized-header-length)
1971 (gnus-put-text-property
1973 (forward-char gnus-article-normalized-header-length)
1980 (forward-line 1))))))
1982 (defun article-treat-dumbquotes ()
1983 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1984 Note that this function guesses whether a character is a sm*rtq**t* or
1985 not, so it should only be used interactively.
1987 Sm*rtq**t*s are M****s***'s unilateral extension to the
1988 iso-8859-1 character map in an attempt to provide more quoting
1989 characters. If you see something like \\222 or \\264 where
1990 you're expecting some kind of apostrophe or quotation mark, then
1993 (article-translate-strings gnus-article-dumbquotes-map))
1995 (defun article-translate-characters (from to)
1996 "Translate all characters in the body of the article according to FROM and TO.
1997 FROM is a string of characters to translate from; to is a string of
1998 characters to translate to."
2000 (when (article-goto-body)
2001 (let ((inhibit-read-only t)
2002 (x (make-string 225 ?x))
2004 (while (< (incf i) (length x))
2007 (while (< i (length from))
2008 (aset x (aref from i) (aref to i))
2010 (translate-region (point) (point-max) x)))))
2012 (defun article-translate-strings (map)
2013 "Translate all string in the body of the article according to MAP.
2014 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2016 (when (article-goto-body)
2017 (let ((inhibit-read-only t))
2020 (while (search-forward (car elem) nil t)
2021 (replace-match (cadr elem)))))))))
2023 (defun article-treat-overstrike ()
2024 "Translate overstrikes into bold text."
2027 (when (article-goto-body)
2028 (let ((inhibit-read-only t))
2029 (while (search-forward "\b" nil t)
2030 (let ((next (char-after))
2031 (previous (char-after (- (point) 2))))
2032 ;; We do the boldification/underlining by hiding the
2033 ;; overstrikes and putting the proper text property
2037 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2038 (put-text-property (point) (1+ (point)) 'face 'bold))
2040 (gnus-article-hide-text-type
2041 (1- (point)) (1+ (point)) 'overstrike)
2043 (- (point) 2) (1- (point)) 'face 'underline))
2045 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2047 (point) (1+ (point)) 'face 'underline)))))))))
2049 (defun article-treat-ansi-sequences ()
2050 "Translate ANSI SGR control sequences into overlays or extents."
2053 (when (article-goto-body)
2054 (let ((inhibit-read-only t))
2055 (ansi-color-apply-on-region (point) (point-max))))))
2057 (defun gnus-article-treat-unfold-headers ()
2058 "Unfold folded message headers.
2059 Only the headers that fit into the current window width will be
2062 (gnus-with-article-headers
2066 (mail-header-narrow-to-field)
2067 (let ((header (buffer-string)))
2070 (goto-char (point-min))
2071 (while (re-search-forward "\n[\t ]" nil t)
2072 (replace-match " " t t)))
2073 (setq length (- (point-max) (point-min) 1)))
2074 (when (< length (window-width))
2075 (while (re-search-forward "\n[\t ]" nil t)
2076 (replace-match " " t t)))
2077 (goto-char (point-max)))))))
2079 (defun gnus-article-treat-fold-headers ()
2080 "Fold message headers."
2082 (gnus-with-article-headers
2085 (mail-header-narrow-to-field)
2086 (mail-header-fold-field)
2087 (goto-char (point-max))))))
2089 (defun gnus-treat-smiley ()
2090 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2092 (gnus-with-article-buffer
2093 (if (memq 'smiley gnus-article-wash-types)
2094 (gnus-delete-images 'smiley)
2096 (let ((images (smiley-region (point) (point-max))))
2098 (gnus-add-wash-type 'smiley)
2099 (dolist (image images)
2100 (gnus-add-image 'smiley image)))))))
2102 (defun gnus-article-remove-images ()
2103 "Remove all images from the article buffer."
2105 (gnus-with-article-buffer
2106 (dolist (elem gnus-article-image-alist)
2107 (gnus-delete-images (car elem)))))
2109 (defun gnus-article-treat-fold-newsgroups ()
2110 "Unfold folded message headers.
2111 Only the headers that fit into the current window width will be
2114 (gnus-with-article-headers
2115 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2117 (mail-header-narrow-to-field)
2118 (while (re-search-forward ", *" nil t)
2119 (replace-match ", " t t))
2120 (mail-header-fold-field)
2121 (goto-char (point-max))))))
2123 (defun gnus-article-treat-body-boundary ()
2124 "Place a boundary line at the end of the headers."
2126 (when (and gnus-body-boundary-delimiter
2127 (> (length gnus-body-boundary-delimiter) 0))
2128 (gnus-with-article-headers
2129 (goto-char (point-max))
2130 (let ((start (point)))
2131 (insert "X-Boundary: ")
2132 (gnus-add-text-properties start (point) '(invisible t intangible t))
2134 (while (>= (1- (window-width)) (length str))
2135 (setq str (concat str gnus-body-boundary-delimiter)))
2136 (substring str 0 (1- (window-width))))
2138 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2140 (defun article-fill-long-lines ()
2141 "Fill lines that are wider than the window width."
2144 (let ((inhibit-read-only t)
2145 (width (window-width (get-buffer-window (current-buffer)))))
2148 (let ((adaptive-fill-mode nil)) ;Why? -sm
2151 (when (>= (current-column) (min fill-column width))
2152 (narrow-to-region (min (1+ (point)) (point-max))
2154 (let ((goback (point-marker)))
2155 (fill-paragraph nil)
2156 (goto-char (marker-position goback)))
2158 (forward-line 1)))))))
2160 (defun article-capitalize-sentences ()
2161 "Capitalize the first word in each sentence."
2164 (let ((inhibit-read-only t)
2165 (paragraph-start "^[\n\^L]"))
2169 (forward-sentence)))))
2171 (defun article-remove-cr ()
2172 "Remove trailing CRs and then translate remaining CRs into LFs."
2175 (let ((inhibit-read-only t))
2176 (goto-char (point-min))
2177 (while (re-search-forward "\r+$" nil t)
2178 (replace-match "" t t))
2179 (goto-char (point-min))
2180 (while (search-forward "\r" nil t)
2181 (replace-match "\n" t t)))))
2183 (defun article-remove-trailing-blank-lines ()
2184 "Remove all trailing blank lines from the article."
2187 (let ((inhibit-read-only t))
2188 (goto-char (point-max))
2192 (while (and (not (bobp))
2193 (looking-at "^[ \t]*$")
2194 (not (gnus-annotation-in-region-p
2195 (point) (point-at-eol))))
2201 (defvar gnus-face-properties-alist))
2203 (defun article-display-face ()
2204 "Display any Face headers in the header."
2206 (let ((wash-face-p buffer-read-only))
2207 (gnus-with-article-headers
2208 ;; When displaying parts, this function can be called several times on
2209 ;; the same article, without any intended toggle semantic (as typing `W
2210 ;; D d' would have). So face deletion must occur only when we come from
2211 ;; an interactive command, that is when the *Article* buffer is
2213 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2214 (gnus-delete-images 'face)
2215 (let (face faces from)
2216 (save-current-buffer
2217 (when (and wash-face-p
2218 (gnus-buffer-live-p gnus-original-article-buffer)
2219 (not (re-search-forward "^Face:[\t ]*" nil t)))
2220 (set-buffer gnus-original-article-buffer))
2222 (mail-narrow-to-head)
2223 (while (gnus-article-goto-header "Face")
2224 (push (mail-header-field-value) faces))))
2226 (goto-char (point-min))
2227 (let ((from (gnus-article-goto-header "from"))
2232 (insert "[no `from' set]\n"))
2234 (when (setq png (gnus-convert-face-to-png (pop faces)))
2236 (apply 'gnus-create-image png 'png t
2237 (cdr (assq 'png gnus-face-properties-alist))))
2239 (gnus-add-wash-type 'face)
2240 (gnus-add-image 'face image)
2241 (gnus-put-image image nil 'face))))))))))
2243 (defun article-display-x-face (&optional force)
2244 "Look for an X-Face header and display it if present."
2245 (interactive (list 'force))
2246 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2247 (gnus-with-article-headers
2248 ;; Delete the old process, if any.
2249 (when (process-status "article-x-face")
2250 (delete-process "article-x-face"))
2251 ;; See the comment in `article-display-face'.
2252 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2253 ;; We have already displayed X-Faces, so we remove them
2255 (gnus-delete-images 'xface)
2257 (let (x-faces from face)
2258 (save-current-buffer
2259 (when (and wash-face-p
2260 (gnus-buffer-live-p gnus-original-article-buffer)
2261 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2262 ;; If type `W f', use gnus-original-article-buffer,
2263 ;; otherwise use the current buffer because displaying
2264 ;; RFC822 parts calls this function too.
2265 (set-buffer gnus-original-article-buffer))
2267 (mail-narrow-to-head)
2268 (while (gnus-article-goto-header "X-Face")
2269 (push (mail-header-field-value) x-faces))
2270 (setq from (message-fetch-field "from"))))
2271 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2272 ;; single external face.
2273 (when (stringp gnus-article-x-face-command)
2274 (setq x-faces (list (car x-faces))))
2276 gnus-article-x-face-command
2278 ;; Check whether this face is censored.
2279 (not gnus-article-x-face-too-ugly)
2281 (not (string-match gnus-article-x-face-too-ugly
2283 (while (setq face (pop x-faces))
2284 ;; We display the face.
2285 (cond ((stringp gnus-article-x-face-command)
2286 ;; The command is a string, so we interpret the command
2287 ;; as a, well, command, and fork it off.
2288 (let ((process-connection-type nil))
2289 (gnus-set-process-query-on-exit-flag
2291 "article-x-face" nil shell-file-name
2292 shell-command-switch gnus-article-x-face-command)
2296 (process-send-region "article-x-face"
2297 (point-min) (point-max)))
2298 (process-send-eof "article-x-face")))
2299 ((functionp gnus-article-x-face-command)
2300 ;; The command is a lisp function, so we call it.
2301 (funcall gnus-article-x-face-command face))
2303 (error "%s is not a function"
2304 gnus-article-x-face-command))))))))))
2306 (defun article-decode-mime-words ()
2307 "Decode all MIME-encoded words in the article."
2309 (gnus-with-article-buffer
2310 (let ((inhibit-point-motion-hooks t)
2311 (mail-parse-charset gnus-newsgroup-charset)
2312 (mail-parse-ignored-charsets
2313 (with-current-buffer gnus-summary-buffer
2314 gnus-newsgroup-ignored-charsets)))
2315 (mail-decode-encoded-word-region (point-min) (point-max)))))
2317 (defun article-decode-charset (&optional prompt)
2318 "Decode charset-encoded text in the article.
2319 If PROMPT (the prefix), prompt for a coding system to use."
2321 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2322 (inhibit-read-only t)
2323 (mail-parse-charset gnus-newsgroup-charset)
2324 (mail-parse-ignored-charsets
2325 (save-excursion (condition-case nil
2326 (set-buffer gnus-summary-buffer)
2328 gnus-newsgroup-ignored-charsets))
2329 ct cte ctl charset format)
2332 (article-narrow-to-head)
2333 (setq ct (message-fetch-field "Content-Type" t)
2334 cte (message-fetch-field "Content-Transfer-Encoding" t)
2335 ctl (and ct (mail-header-parse-content-type ct))
2338 (mm-read-coding-system "Charset to decode: "))
2340 (mail-content-type-get ctl 'charset)))
2341 format (and ctl (mail-content-type-get ctl 'format)))
2343 (setq cte (mail-header-strip cte)))
2344 (if (and ctl (not (string-match "/" (car ctl))))
2346 (goto-char (point-max)))
2349 (narrow-to-region (point) (point-max))
2350 (when (and (eq mail-parse-charset 'gnus-decoded)
2351 (eq (mm-body-7-or-8) '8bit))
2352 ;; The text code could have been decoded.
2353 (setq charset mail-parse-charset))
2354 (when (and (or (not ctl)
2355 (equal (car ctl) "text/plain"))
2356 (not format)) ;; article with format will decode later.
2358 charset (and cte (intern (downcase
2359 (gnus-strip-whitespace cte))))
2362 (defun article-decode-encoded-words ()
2363 "Remove encoded-word encoding from headers."
2364 (let ((inhibit-point-motion-hooks t)
2365 (mail-parse-charset gnus-newsgroup-charset)
2366 (mail-parse-ignored-charsets
2367 (save-excursion (condition-case nil
2368 (set-buffer gnus-summary-buffer)
2370 gnus-newsgroup-ignored-charsets))
2371 (inhibit-read-only t))
2373 (article-narrow-to-head)
2374 (funcall gnus-decode-header-function (point-min) (point-max)))))
2376 (defun article-decode-group-name ()
2377 "Decode group names in `Newsgroups:'."
2378 (let ((inhibit-point-motion-hooks t)
2379 (inhibit-read-only t)
2380 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2381 (when (and (or gnus-group-name-charset-method-alist
2382 gnus-group-name-charset-group-alist)
2383 (gnus-buffer-live-p gnus-original-article-buffer))
2385 (article-narrow-to-head)
2386 (with-current-buffer gnus-original-article-buffer
2387 (goto-char (point-min)))
2388 (while (re-search-forward
2389 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2390 (replace-match (save-match-data
2391 (gnus-decode-newsgroups
2392 ;; XXX how to use data in article buffer?
2393 (with-current-buffer gnus-original-article-buffer
2395 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2398 gnus-newsgroup-name method))
2400 (goto-char (point-min))
2401 (with-current-buffer gnus-original-article-buffer
2402 (goto-char (point-min)))
2403 (while (re-search-forward
2404 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2405 (replace-match (save-match-data
2406 (gnus-decode-newsgroups
2407 ;; XXX how to use data in article buffer?
2408 (with-current-buffer gnus-original-article-buffer
2410 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2413 gnus-newsgroup-name method))
2416 (autoload 'idna-to-unicode "idna")
2418 (defun article-decode-idna-rhs ()
2419 "Decode IDNA strings in RHS in various headers in current buffer.
2420 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2421 Mail-Reply-To: and Mail-Followup-To:."
2424 (let ((inhibit-point-motion-hooks t)
2425 (inhibit-read-only t))
2426 (article-narrow-to-head)
2427 (goto-char (point-min))
2428 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2430 (when (save-match-data
2431 (and (setq ace (match-string 1))
2433 (and (re-search-backward "^[^ \t]" nil t)
2434 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2435 (setq unicode (idna-to-unicode ace))))
2436 (unless (string= ace unicode)
2437 (replace-match unicode nil nil nil 1)))))))))
2439 (defun article-de-quoted-unreadable (&optional force read-charset)
2440 "Translate a quoted-printable-encoded article.
2441 If FORCE, decode the article whether it is marked as quoted-printable
2443 If READ-CHARSET, ask for a coding system."
2444 (interactive (list 'force current-prefix-arg))
2446 (let ((inhibit-read-only t) type charset)
2447 (if (gnus-buffer-live-p gnus-original-article-buffer)
2448 (with-current-buffer gnus-original-article-buffer
2450 (gnus-fetch-field "content-transfer-encoding"))
2451 (let* ((ct (gnus-fetch-field "content-type"))
2452 (ctl (and ct (mail-header-parse-content-type ct))))
2453 (setq charset (and ctl
2454 (mail-content-type-get ctl 'charset)))
2455 (if (stringp charset)
2456 (setq charset (intern (downcase charset)))))))
2458 (setq charset (mm-read-coding-system "Charset: " charset)))
2460 (setq charset gnus-newsgroup-charset))
2462 (and type (let ((case-fold-search t))
2463 (string-match "quoted-printable" type))))
2465 (quoted-printable-decode-region
2466 (point) (point-max) (mm-charset-to-coding-system charset))))))
2468 (defun article-de-base64-unreadable (&optional force read-charset)
2469 "Translate a base64 article.
2470 If FORCE, decode the article whether it is marked as base64 not.
2471 If READ-CHARSET, ask for a coding system."
2472 (interactive (list 'force current-prefix-arg))
2474 (let ((inhibit-read-only t) type charset)
2475 (if (gnus-buffer-live-p gnus-original-article-buffer)
2476 (with-current-buffer gnus-original-article-buffer
2478 (gnus-fetch-field "content-transfer-encoding"))
2479 (let* ((ct (gnus-fetch-field "content-type"))
2480 (ctl (and ct (mail-header-parse-content-type ct))))
2481 (setq charset (and ctl
2482 (mail-content-type-get ctl 'charset)))
2483 (if (stringp charset)
2484 (setq charset (intern (downcase charset)))))))
2486 (setq charset (mm-read-coding-system "Charset: " charset)))
2488 (setq charset gnus-newsgroup-charset))
2490 (and type (let ((case-fold-search t))
2491 (string-match "base64" type))))
2494 (narrow-to-region (point) (point-max))
2495 (base64-decode-region (point-min) (point-max))
2496 (mm-decode-coding-region
2497 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2502 (defun article-decode-HZ ()
2503 "Translate a HZ-encoded article."
2507 (let ((inhibit-read-only t))
2508 (rfc1843-decode-region (point-min) (point-max)))))
2510 (defun article-unsplit-urls ()
2511 "Remove the newlines that some other mailers insert into URLs."
2514 (let ((inhibit-read-only t))
2515 (goto-char (point-min))
2516 (while (re-search-forward
2517 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2518 (replace-match "\\1\\3" t)))
2519 (when (interactive-p)
2520 (gnus-treat-article nil))))
2523 (defun article-wash-html (&optional read-charset)
2524 "Format an HTML article.
2525 If READ-CHARSET, ask for a coding system. If it is a number, the
2526 charset defined in `gnus-summary-show-article-charset-alist' is used."
2529 (let ((inhibit-read-only t)
2532 (if (or (and (numberp read-charset)
2536 gnus-summary-show-article-charset-alist))))
2537 (setq charset (mm-read-coding-system "Charset: ")))
2538 (let ((gnus-summary-show-article-charset-alist
2539 (list (cons 1 charset))))
2540 (with-current-buffer gnus-summary-buffer
2541 (gnus-summary-show-article 1)))
2542 (error "No charset is given"))
2543 (when (gnus-buffer-live-p gnus-original-article-buffer)
2544 (with-current-buffer gnus-original-article-buffer
2545 (let* ((ct (gnus-fetch-field "content-type"))
2546 (ctl (and ct (mail-header-parse-content-type ct))))
2547 (setq charset (and ctl
2548 (mail-content-type-get ctl 'charset)))
2549 (when (stringp charset)
2550 (setq charset (intern (downcase charset)))))))
2552 (setq charset gnus-newsgroup-charset)))
2554 (save-window-excursion
2556 (narrow-to-region (point) (point-max))
2557 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2558 (entry (assq func mm-text-html-washer-alist)))
2560 (setq func (cdr entry)))
2565 (apply (car func) (cdr func))))))))))
2567 (defun gnus-article-wash-html-with-w3 ()
2568 "Wash the current buffer with w3."
2570 (let ((w3-strict-width (window-width))
2571 (url-standalone-mode t)
2572 (url-gateway-unplugged t)
2573 (w3-honor-stylesheets nil))
2575 (w3-region (point-min) (point-max))
2578 (defun gnus-article-wash-html-with-w3m ()
2579 "Wash the current buffer with emacs-w3m."
2581 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2582 w3m-force-redisplay)
2583 (w3m-region (point-min) (point-max)))
2584 (when (and mm-inline-text-html-with-w3m-keymap
2585 (boundp 'w3m-minor-mode-map)
2587 (add-text-properties
2588 (point-min) (point-max)
2589 (list 'keymap w3m-minor-mode-map
2590 ;; Put the mark meaning this part was rendered by emacs-w3m.
2591 'mm-inline-text-html-with-w3m t))))
2593 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2595 (defun gnus-article-wash-html-with-w3m-standalone ()
2596 "Wash the current buffer with w3m."
2597 (if (mm-w3m-standalone-supports-m17n-p)
2599 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2601 (setq charset 'iso-8859-1))
2602 (let ((coding-system-for-write charset)
2603 (coding-system-for-read charset))
2604 (call-process-region
2605 (point-min) (point-max)
2606 "w3m" t t nil "-dump" "-T" "text/html"
2607 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2608 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2610 (defvar gnus-article-browse-html-temp-list nil
2611 "List of temporary files created by `gnus-article-browse-html-parts'.
2612 Internal variable.")
2614 (defcustom gnus-article-browse-delete-temp 'ask
2615 "What to do with temporary files from `gnus-article-browse-html-parts'.
2616 If nil, don't delete temporary files. If it is t, delete them on
2617 exit from the summary buffer. If it is the symbol `file', query
2618 on each file, if it is `ask' ask once when exiting from the
2620 :group 'gnus-article
2621 :version "23.0" ;; No Gnus
2622 :type '(choice (const :tag "Don't delete" nil)
2623 (const :tag "Don't ask" t)
2624 (const :tag "Ask" ask)
2625 (const :tag "Ask for each file" file)))
2627 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2629 (defun gnus-article-browse-delete-temp-files (&optional how)
2630 "Delete temp-files created by `gnus-article-browse-html-parts'."
2631 (when (and gnus-article-browse-html-temp-list
2633 (setq how gnus-article-browse-delete-temp)))
2634 (when (and (eq how 'ask)
2636 "Delete all %s temporary HTML file(s)? "
2637 (length gnus-article-browse-html-temp-list)))
2639 (dolist (file gnus-article-browse-html-temp-list)
2640 (when (and (file-exists-p file)
2642 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2644 (format "Delete temporary HTML file `%s'? " file))))
2645 (delete-file file)))
2646 ;; Also remove file from the list when not deleted or if file doesn't
2648 (setq gnus-article-browse-html-temp-list nil))
2649 gnus-article-browse-html-temp-list)
2651 (defun gnus-article-browse-html-parts (list)
2652 "View all \"text/html\" parts from LIST.
2653 Recurse into multiparts."
2654 ;; Internal function used by `gnus-article-browse-html-article'.
2656 ;; Find and show the html-parts.
2657 (dolist (handle list)
2658 ;; If HTML, show it:
2659 (when (listp handle)
2660 (cond ((and (bufferp (car handle))
2661 (string-match "text/html" (car (mm-handle-type handle))))
2662 (let ((tmp-file (mm-make-temp-file
2663 ;; Do we need to care for 8.3 filenames?
2664 "mm-" nil ".html")))
2665 (mm-save-part-to-file handle tmp-file)
2666 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2667 (add-hook 'gnus-summary-prepare-exit-hook
2668 'gnus-article-browse-delete-temp-files)
2669 (add-hook 'gnus-exit-gnus-hook
2671 (gnus-article-browse-delete-temp-files t)))
2672 (browse-url tmp-file)
2674 ;; If multipart, recurse
2675 ((and (stringp (car handle))
2676 (string-match "^multipart/" (car handle))
2679 (gnus-article-browse-html-parts handle))))))))
2682 ;; TODO: Key binding
2683 (defun gnus-article-browse-html-article ()
2684 "View \"text/html\" parts of the current article with a WWW browser."
2686 (save-window-excursion
2687 ;; Open raw article and select the buffer
2688 (gnus-summary-show-article t)
2689 (gnus-summary-select-article-buffer)
2690 (let ((parts (mm-dissect-buffer t t)))
2691 ;; If singlepart, enforce a list.
2692 (when (and (bufferp (car parts))
2693 (stringp (car (mm-handle-type parts))))
2694 (setq parts (list parts)))
2696 (unless (gnus-article-browse-html-parts parts)
2697 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2698 (gnus-summary-show-article))))
2700 (defun article-hide-list-identifiers ()
2701 "Remove list identifies from the Subject header.
2702 The `gnus-list-identifiers' variable specifies what to do."
2704 (let ((inhibit-point-motion-hooks t)
2705 (regexp (if (consp gnus-list-identifiers)
2706 (mapconcat 'identity gnus-list-identifiers " *\\|")
2707 gnus-list-identifiers))
2708 (inhibit-read-only t))
2712 (article-narrow-to-head)
2713 (goto-char (point-min))
2714 (while (re-search-forward
2715 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2717 (delete-region (match-beginning 2) (match-end 0))
2718 (beginning-of-line))
2719 (when (re-search-forward
2720 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2721 (delete-region (match-beginning 1) (match-end 1))))))))
2723 (defun article-hide-pem (&optional arg)
2724 "Toggle hiding of any PEM headers and signatures in the current article.
2725 If given a negative prefix, always show; if given a positive prefix,
2727 (interactive (gnus-article-hidden-arg))
2728 (unless (gnus-article-check-hidden-text 'pem arg)
2730 (let ((inhibit-read-only t) end)
2731 (goto-char (point-min))
2732 ;; Hide the horrendously ugly "header".
2733 (when (and (search-forward
2734 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2736 (setq end (1+ (match-beginning 0))))
2737 (gnus-add-wash-type 'pem)
2738 (gnus-article-hide-text-type
2740 (if (search-forward "\n\n" nil t)
2744 ;; Hide the trailer as well
2745 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2747 (gnus-article-hide-text-type
2748 (match-beginning 0) (match-end 0) 'pem)))))))
2750 (defun article-strip-banner ()
2751 "Strip the banners specified by the `banner' group parameter and by
2752 `gnus-article-address-banner-alist'."
2756 (let ((inhibit-point-motion-hooks t))
2757 (when (gnus-parameter-banner gnus-newsgroup-name)
2758 (article-really-strip-banner
2759 (gnus-parameter-banner gnus-newsgroup-name)))
2760 (when gnus-article-address-banner-alist
2761 ;; Note that the From header is decoded here, so it is
2762 ;; required that the *-extract-address-components function
2763 ;; supports non-ASCII text.
2764 (let ((from (save-restriction
2766 (article-narrow-to-head)
2767 (mail-fetch-field "from"))))
2770 (cadr (funcall gnus-extract-address-components
2773 (dolist (pair gnus-article-address-banner-alist)
2774 (when (string-match (car pair) from)
2776 (article-really-strip-banner (cdr pair)))))))))))))
2778 (defun article-really-strip-banner (banner)
2779 "Strip the banner specified by the argument."
2782 (let ((inhibit-point-motion-hooks t)
2783 (gnus-signature-limit nil)
2784 (inhibit-read-only t))
2787 ((eq banner 'signature)
2788 (when (gnus-article-narrow-to-signature)
2791 (delete-region (point) (point-max))))
2793 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2794 (while (re-search-forward banner nil t)
2795 (delete-region (match-beginning 0) (match-end 0)))))
2797 (while (re-search-forward banner nil t)
2798 (delete-region (match-beginning 0) (match-end 0)))))))))
2800 (defun article-babel ()
2801 "Translate article using an online translation service."
2804 (gnus-with-article-buffer
2805 (when (article-goto-body)
2806 (let* ((start (point))
2808 (orig (buffer-substring start end))
2809 (trans (babel-as-string orig)))
2811 (narrow-to-region start end)
2812 (delete-region start end)
2815 (defun article-hide-signature (&optional arg)
2816 "Hide the signature in the current article.
2817 If given a negative prefix, always show; if given a positive prefix,
2819 (interactive (gnus-article-hidden-arg))
2820 (unless (gnus-article-check-hidden-text 'signature arg)
2823 (let ((inhibit-read-only t))
2824 (when (gnus-article-narrow-to-signature)
2825 (gnus-article-hide-text-type
2826 (point-min) (point-max) 'signature))))))
2827 (gnus-set-mode-line 'article))
2829 (defun article-strip-headers-in-body ()
2830 "Strip offensive headers from bodies."
2834 (let ((case-fold-search t))
2835 (when (looking-at "x-no-archive:")
2836 (gnus-delete-line)))))
2838 (defun article-strip-leading-blank-lines ()
2839 "Remove all blank lines from the beginning of the article."
2842 (let ((inhibit-point-motion-hooks t)
2843 (inhibit-read-only t))
2844 (when (article-goto-body)
2845 (while (and (not (eobp))
2846 (looking-at "[ \t]*$"))
2847 (gnus-delete-line))))))
2849 (defun article-narrow-to-head ()
2850 "Narrow the buffer to the head of the message.
2851 Point is left at the beginning of the narrowed-to region."
2853 (goto-char (point-min))
2854 (if (search-forward "\n\n" nil 1)
2857 (goto-char (point-min)))
2859 (defun article-goto-body ()
2860 "Place point at the start of the body."
2861 (goto-char (point-min))
2863 ;; This variable is only bound when dealing with separate
2865 (article-goto-body-goes-to-point-min-p
2867 ((search-forward "\n\n" nil t)
2870 (goto-char (point-max))
2873 (defun article-strip-multiple-blank-lines ()
2874 "Replace consecutive blank lines with one empty line."
2877 (let ((inhibit-point-motion-hooks t)
2878 (inhibit-read-only t))
2879 ;; First make all blank lines empty.
2881 (while (re-search-forward "^[ \t]+$" nil t)
2882 (unless (gnus-annotation-in-region-p
2883 (match-beginning 0) (match-end 0))
2884 (replace-match "" nil t)))
2885 ;; Then replace multiple empty lines with a single empty line.
2887 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2888 (unless (gnus-annotation-in-region-p
2889 (match-beginning 0) (match-end 0))
2890 (delete-region (match-beginning 1) (match-end 1)))))))
2892 (defun article-strip-leading-space ()
2893 "Remove all white space from the beginning of the lines in the article."
2896 (let ((inhibit-point-motion-hooks t)
2897 (inhibit-read-only t))
2899 (while (re-search-forward "^[ \t]+" nil t)
2900 (replace-match "" t t)))))
2902 (defun article-strip-trailing-space ()
2903 "Remove all white space from the end of the lines in the article."
2906 (let ((inhibit-point-motion-hooks t)
2907 (inhibit-read-only t))
2909 (while (re-search-forward "[ \t]+$" nil t)
2910 (replace-match "" t t)))))
2912 (defun article-strip-blank-lines ()
2913 "Strip leading, trailing and multiple blank lines."
2915 (article-strip-leading-blank-lines)
2916 (article-remove-trailing-blank-lines)
2917 (article-strip-multiple-blank-lines))
2919 (defun article-strip-all-blank-lines ()
2920 "Strip all blank lines."
2923 (let ((inhibit-point-motion-hooks t)
2924 (inhibit-read-only t))
2926 (while (re-search-forward "^[ \t]*\n" nil t)
2927 (replace-match "" t t)))))
2929 (defun gnus-article-narrow-to-signature ()
2930 "Narrow to the signature; return t if a signature is found, else nil."
2931 (let ((inhibit-point-motion-hooks t))
2932 (when (gnus-article-search-signature)
2934 ;; Check whether we have some limits to what we consider
2935 ;; to be a signature.
2936 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2937 (list gnus-signature-limit)))
2939 (while (setq limit (pop limits))
2940 (if (or (and (integerp limit)
2941 (< (- (point-max) (point)) limit))
2943 (< (count-lines (point) (point-max)) limit))
2944 (and (functionp limit)
2946 (and (stringp limit)
2947 (not (re-search-forward limit nil t))))
2948 () ; This limit did not succeed.
2952 (narrow-to-region (point) (point-max))
2955 (defun gnus-article-search-signature ()
2956 "Search the current buffer for the signature separator.
2957 Put point at the beginning of the signature separator."
2958 (let ((cur (point)))
2959 (goto-char (point-max))
2960 (if (if (stringp gnus-signature-separator)
2961 (re-search-backward gnus-signature-separator nil t)
2962 (let ((seps gnus-signature-separator))
2964 (not (re-search-backward (car seps) nil t)))
2971 (defun gnus-article-hidden-arg ()
2972 "Return the current prefix arg as a number, or 0 if no prefix."
2973 (list (if current-prefix-arg
2974 (prefix-numeric-value current-prefix-arg)
2977 (defun gnus-article-check-hidden-text (type arg)
2978 "Return nil if hiding is necessary.
2979 Arg can be nil or a number. nil and positive means hide, negative
2980 means show, 0 means toggle."
2983 (let ((hide (gnus-article-hidden-text-p type)))
2989 (gnus-article-show-hidden-text type)
2992 (if (eq hide 'hidden)
2994 (gnus-article-show-hidden-text type)
2998 (defun gnus-article-hidden-text-p (type)
2999 "Say whether the current buffer contains hidden text of type TYPE."
3000 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3002 (not (get-text-property pos 'invisible))
3003 (not (get-text-property pos 'dummy-invisible)))
3005 (text-property-any (1+ pos) (point-max) 'article-type type)))
3010 (defun gnus-article-show-hidden-text (type &optional dummy)
3011 "Show all hidden text of type TYPE.
3012 Originally it is hide instead of DUMMY."
3013 (let ((inhibit-read-only t)
3014 (inhibit-point-motion-hooks t))
3015 (gnus-remove-text-properties-when
3017 (point-min) (point-max)
3018 (cons 'article-type (cons type
3019 gnus-hidden-properties)))
3020 (gnus-delete-wash-type type)))
3022 (defconst article-time-units
3023 `((year . ,(* 365.25 24 60 60))
3024 (week . ,(* 7 24 60 60))
3025 (day . ,(* 24 60 60))
3029 "Mapping from time units to seconds.")
3031 (defun gnus-article-forward-header ()
3032 "Move point to the start of the next header.
3033 If the current header is a continuation header, this can be several
3038 (if (looking-at "[ \t]+[^ \t]")
3042 (defun article-date-ut (&optional type highlight)
3043 "Convert DATE date to universal time in the current article.
3044 If TYPE is `local', convert to local time; if it is `lapsed', output
3045 how much time has lapsed since DATE. For `lapsed', the value of
3046 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3047 should replace the \"Date:\" one, or should be added below it."
3048 (interactive (list 'ut t))
3049 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3050 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3054 (article-lapsed-timer
3058 (case-fold-search t)
3059 (inhibit-read-only t)
3060 (inhibit-point-motion-hooks t)
3061 pos date bface eface)
3065 (goto-char (point-min))
3066 (while (or (setq date (get-text-property (setq pos (point))
3068 (when (setq pos (next-single-property-change
3069 (point) 'original-date))
3070 (setq date (get-text-property pos 'original-date))
3072 (narrow-to-region pos (or (text-property-any pos (point-max)
3075 (goto-char (point-min))
3076 (when (re-search-forward tdate-regexp nil t)
3077 (setq bface (get-text-property (point-at-bol) 'face)
3078 eface (get-text-property (1- (point-at-eol)) 'face)))
3079 (goto-char (point-min))
3081 ;; Delete any old Date headers.
3082 (while (re-search-forward date-regexp nil t)
3084 (delete-region (point-at-bol) (progn
3085 (gnus-article-forward-header)
3087 (delete-region (point-at-bol) (progn
3088 (gnus-article-forward-header)
3091 (setq pos (point))))
3092 (when (and (not pos)
3093 (re-search-forward tdate-regexp nil t))
3095 (gnus-goto-char pos)
3096 (insert (article-make-date-line date (or type 'ut)))
3102 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3103 (put-text-property (match-beginning 1) (1+ (match-end 1))
3105 (put-text-property (match-beginning 2) (match-end 2)
3107 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3108 (goto-char (point-max))
3111 (defun article-make-date-line (date type)
3112 "Return a DATE line of TYPE."
3113 (unless (memq type '(local ut original user iso8601 lapsed english))
3114 (error "Unknown conversion type: %s" type))
3116 (let ((time (date-to-time date)))
3118 ;; Convert to the local timezone.
3120 (concat "Date: " (message-make-date time)))
3121 ;; Convert to Universal Time.
3126 (let* ((e (parse-time-string date))
3127 (tm (apply 'encode-time e))
3129 (ls (- (cadr tm) (car (current-time-zone time)))))
3130 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3131 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3135 ;; Get the original date from the article.
3136 ((eq type 'original)
3137 (concat "Date: " (if (string-match "\n+$" date)
3138 (substring date 0 (match-beginning 0))
3140 ;; Let the user define the format.
3142 (let ((format (or (condition-case nil
3143 (with-current-buffer gnus-summary-buffer
3144 gnus-article-time-format)
3146 gnus-article-time-format)))
3147 (if (functionp format)
3148 (funcall format time)
3149 (concat "Date: " (format-time-string format time)))))
3152 (let ((tz (car (current-time-zone time))))
3155 (format-time-string "%Y%m%dT%H%M%S" time)
3156 (format "%s%02d%02d"
3157 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3158 (/ (% (abs tz) 3600) 60)))))
3159 ;; Do an X-Sent lapsed format.
3161 ;; If the date is seriously mangled, the timezone functions are
3162 ;; liable to bug out, so we ignore all errors.
3163 (let* ((now (current-time))
3164 (real-time (subtract-time now time))
3165 (real-sec (and real-time
3166 (+ (* (float (car real-time)) 65536)
3168 (sec (and real-time (abs real-sec)))
3178 ;; This is a bit convoluted, but basically we go
3179 ;; through the time units for years, weeks, etc,
3180 ;; and divide things to see whether that results
3181 ;; in positive answers.
3184 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3185 ;; The (remaining) seconds are too few to
3186 ;; be divided into this time unit.
3188 ;; It's big enough, so we output it.
3189 (setq sec (- sec (* num (cdr unit))))
3191 (concat (if prev ", " "") (int-to-string
3193 " " (symbol-name (car unit))
3194 (if (> num 1) "s" ""))
3196 article-time-units "")
3197 ;; If dates are odd, then it might appear like the
3198 ;; article was sent in the future.
3201 " in the future"))))))
3202 ;; Display the date in proper English
3204 (let ((dtime (decode-time time)))
3207 (number-to-string (nth 3 dtime))
3208 (let ((digit (% (nth 3 dtime) 10)))
3210 ((memq (nth 3 dtime) '(11 12 13)) "th")
3216 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3218 (number-to-string (nth 5 dtime))
3220 (format "%02d" (nth 2 dtime))
3222 (format "%02d" (nth 1 dtime)))))))
3224 (format "Date: %s (from Gnus)" date))))
3226 (defun article-date-local (&optional highlight)
3227 "Convert the current article date to the local timezone."
3228 (interactive (list t))
3229 (article-date-ut 'local highlight))
3231 (defun article-date-english (&optional highlight)
3232 "Convert the current article date to something that is proper English."
3233 (interactive (list t))
3234 (article-date-ut 'english highlight))
3236 (defun article-date-original (&optional highlight)
3237 "Convert the current article date to what it was originally.
3238 This is only useful if you have used some other date conversion
3239 function and want to see what the date was before converting."
3240 (interactive (list t))
3241 (article-date-ut 'original highlight))
3243 (defun article-date-lapsed (&optional highlight)
3244 "Convert the current article date to time lapsed since it was sent."
3245 (interactive (list t))
3246 (article-date-ut 'lapsed highlight))
3248 (defun article-update-date-lapsed ()
3249 "Function to be run from a timer to update the lapsed time line."
3251 (let (deactivate-mark)
3256 (set-buffer (window-buffer w))
3257 (when (eq major-mode 'gnus-article-mode)
3258 (let ((mark (point-marker)))
3259 (goto-char (point-min))
3260 (when (re-search-forward "^X-Sent:" nil t)
3261 (article-date-lapsed t))
3262 (goto-char (marker-position mark))
3263 (move-marker mark nil))))
3266 (defun gnus-start-date-timer (&optional n)
3267 "Start a timer to update the X-Sent header in the article buffers.
3268 The numerical prefix says how frequently (in seconds) the function
3273 (gnus-stop-date-timer)
3274 (setq article-lapsed-timer
3275 (run-at-time 1 n 'article-update-date-lapsed)))
3277 (defun gnus-stop-date-timer ()
3278 "Stop the X-Sent timer."
3280 (when article-lapsed-timer
3281 (nnheader-cancel-timer article-lapsed-timer)
3282 (setq article-lapsed-timer nil)))
3284 (defun article-date-user (&optional highlight)
3285 "Convert the current article date to the user-defined format.
3286 This format is defined by the `gnus-article-time-format' variable."
3287 (interactive (list t))
3288 (article-date-ut 'user highlight))
3290 (defun article-date-iso8601 (&optional highlight)
3291 "Convert the current article date to ISO8601."
3292 (interactive (list t))
3293 (article-date-ut 'iso8601 highlight))
3295 (defmacro gnus-article-save-original-date (&rest forms)
3296 "Save the original date as a text property and evaluate FORMS."
3297 `(let* ((case-fold-search t)
3299 (goto-char (point-min))
3300 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3303 (date (when (and start
3304 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3306 (buffer-substring-no-properties start
3307 (match-beginning 0)))))
3308 (goto-char (point-max))
3309 (skip-chars-backward "\n")
3310 (put-text-property (point-min) (point) 'original-date date)
3312 (goto-char (point-max))
3313 (skip-chars-backward "\n")
3314 (put-text-property (point-min) (point) 'original-date date)))
3316 ;; (defun article-show-all ()
3317 ;; "Show all hidden text in the article buffer."
3320 ;; (let ((inhibit-read-only t))
3321 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3323 (defun article-remove-leading-whitespace ()
3324 "Remove excessive whitespace from all headers."
3328 (let ((inhibit-read-only t))
3329 (article-narrow-to-head)
3330 (goto-char (point-min))
3331 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3332 (delete-region (match-beginning 1) (match-end 1)))))))
3334 (defun article-emphasize (&optional arg)
3335 "Emphasize text according to `gnus-emphasis-alist'."
3336 (interactive (gnus-article-hidden-arg))
3337 (unless (gnus-article-check-hidden-text 'emphasis arg)
3341 (with-current-buffer gnus-summary-buffer
3342 gnus-article-emphasis-alist)
3344 gnus-emphasis-alist))
3345 (inhibit-read-only t)
3346 (props (append '(article-type emphasis)
3347 gnus-hidden-properties))
3348 regexp elem beg invisible visible face)
3351 (while (setq elem (pop alist))
3353 (setq regexp (car elem)
3354 invisible (nth 1 elem)
3355 visible (nth 2 elem)
3357 (while (re-search-forward regexp nil t)
3358 (when (and (match-beginning visible) (match-beginning invisible))
3359 (gnus-article-hide-text
3360 (match-beginning invisible) (match-end invisible) props)
3361 (gnus-article-unhide-text-type
3362 (match-beginning visible) (match-end visible) 'emphasis)
3363 (gnus-put-overlay-excluding-newlines
3364 (match-beginning visible) (match-end visible) 'face face)
3365 (gnus-add-wash-type 'emphasis)
3366 (goto-char (match-end invisible)))))))))
3368 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3369 "Setup newsgroup emphasis alist."
3370 (unless gnus-article-emphasis-alist
3371 (let ((name (and gnus-newsgroup-name
3372 (gnus-group-real-name gnus-newsgroup-name))))
3373 (make-local-variable 'gnus-article-emphasis-alist)
3374 (setq gnus-article-emphasis-alist
3376 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3377 (while (setq elem (pop alist))
3378 (when (and name (string-match (car elem) name))
3380 highlight (copy-sequence (cdr elem)))))
3382 (copy-sequence highlight-words)
3383 (if gnus-newsgroup-name
3384 (copy-sequence (gnus-group-find-parameter
3385 gnus-newsgroup-name 'highlight-words t)))
3386 gnus-emphasis-alist)))))
3389 (defvar gnus-summary-article-menu)
3390 (defvar gnus-summary-post-menu))
3392 ;;; Saving functions.
3394 (defun gnus-article-save (save-buffer file &optional num)
3395 "Save the currently selected article."
3396 (unless gnus-save-all-headers
3397 ;; Remove headers according to `gnus-saved-headers'.
3398 (let ((gnus-visible-headers
3399 (or gnus-saved-headers gnus-visible-headers))
3400 (gnus-article-buffer save-buffer))
3402 (set-buffer save-buffer)
3403 (article-hide-headers 1 t))))
3404 (save-window-excursion
3405 (if (not gnus-default-article-saver)
3406 (error "No default saver is defined")
3407 ;; !!! Magic! The saving functions all save
3408 ;; `gnus-save-article-buffer' (or so they think), but we
3409 ;; bind that variable to our save-buffer.
3410 (set-buffer gnus-article-buffer)
3411 (let* ((gnus-save-article-buffer save-buffer)
3414 ((not gnus-prompt-before-saving) 'default)
3415 ((eq gnus-prompt-before-saving 'always) nil)
3417 (gnus-number-of-articles-to-be-saved
3418 (when (eq gnus-prompt-before-saving t)
3420 (set-buffer gnus-article-current-summary)
3421 (funcall gnus-default-article-saver filename)))))
3423 (defun gnus-read-save-file-name (prompt &optional filename
3424 function group headers variable)
3426 (funcall function group headers (symbol-value variable)))
3431 ((eq filename 'default)
3437 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3440 (if (and gnus-number-of-articles-to-be-saved
3441 (> gnus-number-of-articles-to-be-saved 1))
3442 (format "these %d articles"
3443 gnus-number-of-articles-to-be-saved)
3446 ;; Let the split methods have their say.
3448 ;; No split name was found.
3451 (concat prompt " (default "
3452 (file-name-nondirectory default-name) "): ")
3453 (file-name-directory default-name)
3455 ;; A single group name is returned.
3456 ((stringp split-name)
3458 (funcall function split-name headers
3459 (symbol-value variable)))
3461 (concat prompt " (default "
3462 (file-name-nondirectory default-name) "): ")
3463 (file-name-directory default-name)
3465 ;; A single split name was found
3466 ((= 1 (length split-name))
3467 (let* ((name (expand-file-name
3469 gnus-article-save-directory))
3470 (dir (cond ((file-directory-p name)
3471 (file-name-as-directory name))
3472 ((file-exists-p name) name)
3473 (t gnus-article-save-directory))))
3475 (concat prompt " (default " name "): ")
3477 ;; A list of splits was found.
3479 (setq split-name (nreverse split-name))
3481 (let ((file-name-history
3482 (nconc split-name file-name-history)))
3486 (concat prompt " (`M-p' for defaults): ")
3487 gnus-article-save-directory
3489 gnus-article-save-directory)))
3490 (car (push result file-name-history)))))))
3491 ;; Create the directory.
3492 (gnus-make-directory (file-name-directory file))
3493 ;; If we have read a directory, we append the default file name.
3494 (when (file-directory-p file)
3495 (setq file (expand-file-name (file-name-nondirectory
3497 (file-name-as-directory file))))
3498 ;; Possibly translate some characters.
3499 (nnheader-translate-file-chars file))))))
3500 (gnus-make-directory (file-name-directory result))
3501 (set variable result)))
3503 (defun gnus-article-archive-name (group)
3504 "Return the first instance of an \"Archive-name\" in the current buffer."
3505 (let ((case-fold-search t))
3506 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3507 (nnheader-concat gnus-article-save-directory
3508 (match-string 1)))))
3510 (defun gnus-article-nndoc-name (group)
3511 "If GROUP is an nndoc group, return the name of the parent group."
3512 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3513 (gnus-group-get-parameter group 'save-article-group)))
3515 (defun gnus-summary-save-in-rmail (&optional filename)
3516 "Append this article to Rmail file.
3517 Optional argument FILENAME specifies file name.
3518 Directory to save to is default to `gnus-article-save-directory'."
3519 (setq filename (gnus-read-save-file-name
3520 "Save %s in rmail file" filename
3521 gnus-rmail-save-name gnus-newsgroup-name
3522 gnus-current-headers 'gnus-newsgroup-last-rmail))
3523 (gnus-eval-in-buffer-window gnus-save-article-buffer
3527 (gnus-output-to-rmail filename))))
3530 (defun gnus-summary-save-in-mail (&optional filename)
3531 "Append this article to Unix mail file.
3532 Optional argument FILENAME specifies file name.
3533 Directory to save to is default to `gnus-article-save-directory'."
3534 (setq filename (gnus-read-save-file-name
3535 "Save %s in Unix mail file" filename
3536 gnus-mail-save-name gnus-newsgroup-name
3537 gnus-current-headers 'gnus-newsgroup-last-mail))
3538 (gnus-eval-in-buffer-window gnus-save-article-buffer
3542 (if (and (file-readable-p filename)
3543 (file-regular-p filename)
3544 (mail-file-babyl-p filename))
3545 (rmail-output-to-rmail-file filename t)
3546 (gnus-output-to-mail filename)))))
3549 (defun gnus-summary-save-in-file (&optional filename overwrite)
3550 "Append this article to file.
3551 Optional argument FILENAME specifies file name.
3552 Directory to save to is default to `gnus-article-save-directory'."
3553 (setq filename (gnus-read-save-file-name
3554 "Save %s in file" filename
3555 gnus-file-save-name gnus-newsgroup-name
3556 gnus-current-headers 'gnus-newsgroup-last-file))
3557 (gnus-eval-in-buffer-window gnus-save-article-buffer
3561 (when (and overwrite
3562 (file-exists-p filename))
3563 (delete-file filename))
3564 (gnus-output-to-file filename))))
3567 (defun gnus-summary-write-to-file (&optional filename)
3568 "Write this article to a file, overwriting it if the file exists.
3569 Optional argument FILENAME specifies file name.
3570 The directory to save in defaults to `gnus-article-save-directory'."
3571 (gnus-summary-save-in-file nil t))
3573 (defun gnus-summary-save-body-in-file (&optional filename)
3574 "Append this article body to a file.
3575 Optional argument FILENAME specifies file name.
3576 The directory to save in defaults to `gnus-article-save-directory'."
3577 (setq filename (gnus-read-save-file-name
3578 "Save %s body in file" filename
3579 gnus-file-save-name gnus-newsgroup-name
3580 gnus-current-headers 'gnus-newsgroup-last-file))
3581 (gnus-eval-in-buffer-window gnus-save-article-buffer
3585 (when (article-goto-body)
3586 (narrow-to-region (point) (point-max)))
3587 (gnus-output-to-file filename))))
3590 (defun gnus-summary-save-in-pipe (&optional command)
3591 "Pipe this article to subprocess."
3593 (cond ((and (eq command 'default)
3594 gnus-last-shell-command)
3595 gnus-last-shell-command)
3600 "Shell command on %s: "
3601 (if (and gnus-number-of-articles-to-be-saved
3602 (> gnus-number-of-articles-to-be-saved 1))
3603 (format "these %d articles"
3604 gnus-number-of-articles-to-be-saved)
3606 gnus-last-shell-command))))
3607 (when (string-equal command "")
3608 (if gnus-last-shell-command
3609 (setq command gnus-last-shell-command)
3610 (error "A command is required")))
3611 (gnus-eval-in-buffer-window gnus-article-buffer
3614 (shell-command-on-region (point-min) (point-max) command nil)))
3615 (setq gnus-last-shell-command command))
3617 (defun gnus-summary-pipe-to-muttprint (&optional command)
3618 "Pipe this article to muttprint."
3619 (setq command (read-string
3620 "Print using command: " gnus-summary-muttprint-program
3621 nil gnus-summary-muttprint-program))
3622 (gnus-summary-save-in-pipe command))
3624 ;;; Article file names when saving.
3626 (defun gnus-capitalize-newsgroup (newsgroup)
3627 "Capitalize NEWSGROUP name."
3628 (when (not (zerop (length newsgroup)))
3629 (concat (char-to-string (upcase (aref newsgroup 0)))
3630 (substring newsgroup 1))))
3632 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3633 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3634 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3635 Otherwise, it is like ~/News/news/group/num."
3638 (concat (if (gnus-use-long-file-name 'not-save)
3639 (gnus-capitalize-newsgroup newsgroup)
3640 (gnus-newsgroup-directory-form newsgroup))
3641 "/" (int-to-string (mail-header-number headers)))
3642 gnus-article-save-directory)))
3644 (string-equal (file-name-directory default)
3645 (file-name-directory last-file))
3646 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3648 (or last-file default))))
3650 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3651 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3652 If variable `gnus-use-long-file-name' is non-nil, it is
3653 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3656 (concat (if (gnus-use-long-file-name 'not-save)
3658 (gnus-newsgroup-directory-form newsgroup))
3659 "/" (int-to-string (mail-header-number headers)))
3660 gnus-article-save-directory)))
3662 (string-equal (file-name-directory default)
3663 (file-name-directory last-file))
3664 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3666 (or last-file default))))
3668 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3669 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3670 If variable `gnus-use-long-file-name' is non-nil, it is
3671 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3674 (if (gnus-use-long-file-name 'not-save)
3677 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3679 gnus-article-save-directory)))
3681 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3682 "Generate file name from sender."
3683 (let ((from (mail-header-from headers)))
3685 (if (and from (string-match "\\([^ <]+\\)@" from))
3686 (match-string 1 from)
3688 gnus-article-save-directory)))
3690 (defun article-verify-x-pgp-sig ()
3693 (if (gnus-buffer-live-p gnus-original-article-buffer)
3694 (let ((sig (with-current-buffer gnus-original-article-buffer
3695 (gnus-fetch-field "X-PGP-Sig")))
3699 (mml2015-clear-verify-function))
3701 (insert-buffer-substring gnus-original-article-buffer)
3702 (setq items (split-string sig))
3703 (message-narrow-to-head)
3704 (let ((inhibit-point-motion-hooks t)
3705 (case-fold-search t))
3706 ;; Don't verify multiple headers.
3707 (setq headers (mapconcat (lambda (header)
3709 (mail-fetch-field header)
3711 (split-string (nth 1 items) ",") "")))
3712 (delete-region (point-min) (point-max))
3713 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3714 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3719 (if (looking-at "^-")
3722 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3723 (insert "Version: " (car items) "\n\n")
3724 (insert (mapconcat 'identity (cddr items) "\n"))
3725 (insert "\n-----END PGP SIGNATURE-----\n")
3726 (let ((mm-security-handle (list (format "multipart/signed"))))
3727 (mml2015-clean-buffer)
3728 (let ((coding-system-for-write (or gnus-newsgroup-charset
3730 (funcall (mml2015-clear-verify-function)))
3732 (or (mm-handle-multipart-ctl-parameter
3733 mm-security-handle 'gnus-details)
3734 (mm-handle-multipart-ctl-parameter
3735 mm-security-handle 'gnus-info)))))
3737 (let ((inhibit-read-only t) bface eface)
3739 (message-narrow-to-head)
3740 (goto-char (point-max))
3742 (setq bface (get-text-property (point-at-bol) 'face)
3743 eface (get-text-property (1- (point-at-eol)) 'face))
3744 (message-remove-header "X-Gnus-PGP-Verify")
3745 (if (re-search-forward "^X-PGP-Sig:" nil t)
3747 (goto-char (point-max)))
3748 (narrow-to-region (point) (point))
3749 (insert "X-Gnus-PGP-Verify: " info "\n")
3750 (goto-char (point-min))
3753 (if (not (looking-at "^[ \t]"))
3757 (goto-char (point-min))
3758 (when (looking-at "\\([^:]+\\): *")
3759 (put-text-property (match-beginning 1) (1+ (match-end 1))
3761 (put-text-property (match-end 0) (point-max)
3762 'face eface)))))))))
3764 (defun article-verify-cancel-lock ()
3765 "Verify Cancel-Lock header."
3767 (if (gnus-buffer-live-p gnus-original-article-buffer)
3768 (canlock-verify gnus-original-article-buffer)))
3775 (setq afunc (car func)
3778 gfunc (intern (format "gnus-%s" func))))
3780 (when (fboundp afunc)
3781 `(lambda (&optional interactive &rest args)
3782 ,(documentation afunc t)
3783 (interactive (list t))
3785 (set-buffer gnus-article-buffer)
3787 (call-interactively ',afunc)
3788 (apply ',afunc args))))))))
3789 '(article-hide-headers
3790 article-verify-x-pgp-sig
3791 article-verify-cancel-lock
3792 article-hide-boring-headers
3793 article-treat-overstrike
3794 article-treat-ansi-sequences
3795 article-fill-long-lines
3796 article-capitalize-sentences
3798 article-remove-leading-whitespace
3799 article-display-x-face
3800 article-display-face
3801 article-de-quoted-unreadable
3802 article-de-base64-unreadable
3805 article-unsplit-urls
3806 article-hide-list-identifiers
3807 article-strip-banner
3810 article-hide-signature
3811 article-strip-headers-in-body
3812 article-remove-trailing-blank-lines
3813 article-strip-leading-blank-lines
3814 article-strip-multiple-blank-lines
3815 article-strip-leading-space
3816 article-strip-trailing-space
3817 article-strip-blank-lines
3818 article-strip-all-blank-lines
3820 article-date-english
3821 article-date-iso8601
3822 article-date-original
3824 article-decode-mime-words
3825 article-decode-charset
3826 article-decode-encoded-words
3830 article-treat-dumbquotes
3831 article-normalize-headers
3832 ;; (article-show-all . gnus-article-show-all-headers)
3836 ;;; Gnus article mode
3839 (put 'gnus-article-mode 'mode-class 'special)
3841 (set-keymap-parent gnus-article-mode-map widget-keymap)
3843 (gnus-define-keys gnus-article-mode-map
3844 " " gnus-article-goto-next-page
3845 "\177" gnus-article-goto-prev-page
3846 [delete] gnus-article-goto-prev-page
3847 [backspace] gnus-article-goto-prev-page
3848 "\C-c^" gnus-article-refer-article
3849 "h" gnus-article-show-summary
3850 "s" gnus-article-show-summary
3851 "\C-c\C-m" gnus-article-mail
3852 "?" gnus-article-describe-briefly
3853 "e" gnus-summary-edit-article
3854 "<" beginning-of-buffer
3856 "\C-c\C-i" gnus-info-find-node
3858 "R" gnus-article-reply-with-original
3859 "F" gnus-article-followup-with-original
3860 "\C-hk" gnus-article-describe-key
3861 "\C-hc" gnus-article-describe-key-briefly
3863 "\C-d" gnus-article-read-summary-keys
3864 "\M-*" gnus-article-read-summary-keys
3865 "\M-#" gnus-article-read-summary-keys
3866 "\M-^" gnus-article-read-summary-keys
3867 "\M-g" gnus-article-read-summary-keys)
3869 (substitute-key-definition
3870 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3872 (defun gnus-article-make-menu-bar ()
3873 (unless (boundp 'gnus-article-commands-menu)
3874 (gnus-summary-make-menu-bar))
3875 (gnus-turn-off-edit-menu 'article)
3876 (unless (boundp 'gnus-article-article-menu)
3878 gnus-article-article-menu gnus-article-mode-map ""
3880 ["Scroll forwards" gnus-article-goto-next-page t]
3881 ["Scroll backwards" gnus-article-goto-prev-page t]
3882 ["Show summary" gnus-article-show-summary t]
3883 ["Fetch Message-ID at point" gnus-article-refer-article t]
3884 ["Mail to address at point" gnus-article-mail t]
3885 ["Send a bug report" gnus-bug t]))
3888 gnus-article-treatment-menu gnus-article-mode-map ""
3889 ;; Fixme: this should use :active (and maybe :visible).
3891 ["Hide headers" gnus-article-hide-headers t]
3892 ["Hide signature" gnus-article-hide-signature t]
3893 ["Hide citation" gnus-article-hide-citation t]
3894 ["Treat overstrike" gnus-article-treat-overstrike t]
3895 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3896 ["Remove carriage return" gnus-article-remove-cr t]
3897 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3898 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3899 ["Remove base64" gnus-article-de-base64-unreadable t]
3900 ["Treat html" gnus-article-wash-html t]
3901 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3902 ["Decode HZ" gnus-article-decode-HZ t]))
3904 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3906 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3908 (gnus-run-hooks 'gnus-article-menu-hook)))
3910 (defun gnus-article-mode ()
3911 "Major mode for displaying an article.
3913 All normal editing commands are switched off.
3915 The following commands are available in addition to all summary mode
3917 \\<gnus-article-mode-map>
3918 \\[gnus-article-next-page]\t Scroll the article one page forwards
3919 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3920 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3921 \\[gnus-article-show-summary]\t Display the summary buffer
3922 \\[gnus-article-mail]\t Send a reply to the address near point
3923 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3924 \\[gnus-info-find-node]\t Go to the Gnus info node"
3926 (kill-all-local-variables)
3927 (gnus-simplify-mode-line)
3928 (setq mode-name "Article")
3929 (setq major-mode 'gnus-article-mode)
3930 (make-local-variable 'minor-mode-alist)
3931 (use-local-map gnus-article-mode-map)
3932 (when (gnus-visual-p 'article-menu 'menu)
3933 (gnus-article-make-menu-bar)
3934 (when gnus-summary-tool-bar-map
3935 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3936 (gnus-update-format-specifications nil 'article-mode)
3937 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3938 (set (make-local-variable 'gnus-page-broken) nil)
3939 (make-local-variable 'gnus-button-marker-list)
3940 (make-local-variable 'gnus-article-current-summary)
3941 (make-local-variable 'gnus-article-mime-handles)
3942 (make-local-variable 'gnus-article-decoded-p)
3943 (make-local-variable 'gnus-article-mime-handle-alist)
3944 (make-local-variable 'gnus-article-wash-types)
3945 (make-local-variable 'gnus-article-image-alist)
3946 (make-local-variable 'gnus-article-charset)
3947 (make-local-variable 'gnus-article-ignored-charsets)
3948 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3949 (set (make-local-variable 'nobreak-char-display) nil)
3950 (gnus-set-default-directory)
3951 (buffer-disable-undo)
3952 (setq buffer-read-only t
3953 show-trailing-whitespace nil)
3954 (set-syntax-table gnus-article-mode-syntax-table)
3955 (mm-enable-multibyte)
3956 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3958 (defun gnus-article-setup-buffer ()
3959 "Initialize the article buffer."
3960 (let* ((name (if gnus-single-article-buffer "*Article*"
3961 (concat "*Article " gnus-newsgroup-name "*")))
3963 (progn (string-match "\\*Article" name)
3964 (concat " *Original Article"
3965 (substring name (match-end 0))))))
3966 (setq gnus-article-buffer name)
3967 (setq gnus-original-article-buffer original)
3968 (setq gnus-article-mime-handle-alist nil)
3969 ;; This might be a variable local to the summary buffer.
3970 (unless gnus-single-article-buffer
3972 (set-buffer gnus-summary-buffer)
3973 (setq gnus-article-buffer name)
3974 (setq gnus-original-article-buffer original)
3975 (gnus-set-global-variables)))
3976 (gnus-article-setup-highlight-words)
3977 ;; Init original article buffer.
3979 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3980 (mm-enable-multibyte)
3981 (setq major-mode 'gnus-original-article-mode)
3982 (make-local-variable 'gnus-original-article))
3983 (if (and (get-buffer name)
3984 (with-current-buffer name
3985 (if gnus-article-edit-mode
3986 (if (y-or-n-p "Article mode edit in progress; discard? ")
3988 (set-buffer-modified-p nil)
3989 (gnus-kill-buffer name)
3992 (error "Action aborted"))
3996 (set (make-local-variable 'gnus-article-edit-mode) nil)
3997 (when gnus-article-mime-handles
3998 (mm-destroy-parts gnus-article-mime-handles)
3999 (setq gnus-article-mime-handles nil))
4000 ;; Set it to nil in article-buffer!
4001 (setq gnus-article-mime-handle-alist nil)
4002 (buffer-disable-undo)
4003 (setq buffer-read-only t)
4004 ;; This list just keeps growing if we don't reset it.
4005 (setq gnus-button-marker-list nil)
4006 (unless (eq major-mode 'gnus-article-mode)
4007 (gnus-article-mode))
4010 (set-buffer (gnus-get-buffer-create name))
4012 (make-local-variable 'gnus-summary-buffer)
4013 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4014 (current-buffer)))))
4016 ;; Set article window start at LINE, where LINE is the number of lines
4017 ;; from the head of the article.
4018 (defun gnus-article-set-window-start (&optional line)
4020 (gnus-get-buffer-window gnus-article-buffer t)
4022 (set-buffer gnus-article-buffer)
4023 (goto-char (point-min))
4026 (gnus-message 6 "Moved to bookmark")
4027 (search-forward "\n\n" nil t)
4031 (defun gnus-article-prepare (article &optional all-headers header)
4032 "Prepare ARTICLE in article mode buffer.
4033 ARTICLE should either be an article number or a Message-ID.
4034 If ARTICLE is an id, HEADER should be the article headers.
4035 If ALL-HEADERS is non-nil, no headers are hidden."
4037 ;; Make sure we start in a summary buffer.
4038 (unless (eq major-mode 'gnus-summary-mode)
4039 (set-buffer gnus-summary-buffer))
4040 (setq gnus-summary-buffer (current-buffer))
4041 (let* ((gnus-article (if header (mail-header-number header) article))
4042 (summary-buffer (current-buffer))
4043 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4044 (group gnus-newsgroup-name)
4047 (gnus-article-setup-buffer)
4048 (set-buffer gnus-article-buffer)
4049 ;; Deactivate active regions.
4050 (when (and (boundp 'transient-mark-mode)
4051 transient-mark-mode)
4052 (setq mark-active nil))
4053 (if (not (setq result (let ((inhibit-read-only t))
4054 (gnus-request-article-this-buffer
4056 ;; There is no such article.
4058 (when (and (numberp article)
4059 (not (memq article gnus-newsgroup-sparse)))
4060 (setq gnus-article-current
4061 (cons gnus-newsgroup-name article))
4062 (set-buffer gnus-summary-buffer)
4063 (setq gnus-current-article article)
4064 (if (and (memq article gnus-newsgroup-undownloaded)
4065 (not (gnus-online (gnus-find-method-for-group
4066 gnus-newsgroup-name))))
4068 (gnus-summary-set-agent-mark article)
4069 (message "Message marked for downloading"))
4070 (gnus-summary-mark-article article gnus-canceled-mark)
4071 (unless (memq article gnus-newsgroup-sparse)
4072 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4073 (if (or (eq result 'pseudo)
4074 (eq result 'nneething))
4077 (set-buffer summary-buffer)
4078 (push article gnus-newsgroup-history)
4079 (setq gnus-last-article gnus-current-article
4080 gnus-current-article 0
4081 gnus-current-headers nil
4082 gnus-article-current nil)
4083 (if (eq result 'nneething)
4084 (gnus-configure-windows 'summary)
4085 (gnus-configure-windows 'article))
4086 (gnus-set-global-variables))
4087 (let ((gnus-article-mime-handle-alist-1
4088 gnus-article-mime-handle-alist))
4089 (gnus-set-mode-line 'article)))
4090 ;; The result from the `request' was an actual article -
4091 ;; or at least some text that is now displayed in the
4093 (when (and (numberp article)
4094 (not (eq article gnus-current-article)))
4095 ;; Seems like a new article has been selected.
4096 ;; `gnus-current-article' must be an article number.
4098 (set-buffer summary-buffer)
4099 (push article gnus-newsgroup-history)
4100 (setq gnus-last-article gnus-current-article
4101 gnus-current-article article
4102 gnus-current-headers
4103 (gnus-summary-article-header gnus-current-article)
4104 gnus-article-current
4105 (cons gnus-newsgroup-name gnus-current-article))
4106 (unless (vectorp gnus-current-headers)
4107 (setq gnus-current-headers nil))
4108 (gnus-summary-goto-subject gnus-current-article)
4109 (when (gnus-summary-show-thread)
4110 ;; If the summary buffer really was folded, the
4111 ;; previous goto may not actually have gone to
4112 ;; the right article, but the thread root instead.
4114 (gnus-summary-goto-subject gnus-current-article))
4115 (gnus-run-hooks 'gnus-mark-article-hook)
4116 (gnus-set-mode-line 'summary)
4117 (when (gnus-visual-p 'article-highlight 'highlight)
4118 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4119 ;; Set the global newsgroup variables here.
4120 (gnus-set-global-variables)
4121 (setq gnus-have-all-headers
4122 (or all-headers gnus-show-all-headers))))
4124 (gnus-configure-windows 'article))
4125 (when (or (numberp article)
4127 (gnus-article-prepare-display)
4129 (goto-char (point-min))
4130 (when gnus-break-pages
4131 (gnus-narrow-to-page)))
4132 (let ((gnus-article-mime-handle-alist-1
4133 gnus-article-mime-handle-alist))
4134 (gnus-set-mode-line 'article))
4138 (set-window-point (get-buffer-window (current-buffer)) (point))
4139 (gnus-configure-windows 'article)
4143 (defun gnus-article-prepare-display ()
4144 "Make the current buffer look like a nice article."
4145 ;; Hooks for getting information from the article.
4146 ;; This hook must be called before being narrowed.
4147 (let ((gnus-article-buffer (current-buffer))
4149 (inhibit-read-only t))
4150 (unless (eq major-mode 'gnus-article-mode)
4151 (gnus-article-mode))
4152 (setq buffer-read-only nil
4153 gnus-article-wash-types nil
4154 gnus-article-image-alist nil)
4155 (gnus-run-hooks 'gnus-tmp-internal-hook)
4156 (when gnus-display-mime-function
4157 (funcall gnus-display-mime-function))
4158 (gnus-run-hooks 'gnus-article-prepare-hook)))
4161 ;;; Gnus MIME viewing functions
4164 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4165 "Format of the MIME buttons.
4167 Valid specifiers include:
4169 %T MIME type, along with additional info
4170 %n The `name' parameter
4171 %d The description, if any
4172 %l The length of the encoded part
4173 %p The part identifier number
4174 %e Dots if the part isn't displayed
4176 General format specifiers can also be used. See Info node
4177 `(gnus)Formatting Variables'.")
4179 (defvar gnus-mime-button-line-format-alist
4180 '((?t gnus-tmp-type ?s)
4181 (?T gnus-tmp-type-long ?s)
4182 (?n gnus-tmp-name ?s)
4183 (?d gnus-tmp-description ?s)
4185 (?l gnus-tmp-length ?d)
4186 (?e gnus-tmp-dots ?s)))
4188 (defvar gnus-mime-button-commands
4189 '((gnus-article-press-button "\r" "Toggle Display")
4190 (gnus-mime-view-part "v" "View Interactively...")
4191 (gnus-mime-view-part-as-type "t" "View As Type...")
4192 (gnus-mime-view-part-as-charset "C" "View As charset...")
4193 (gnus-mime-save-part "o" "Save...")
4194 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4195 (gnus-mime-replace-part "r" "Replace part")
4196 (gnus-mime-delete-part "d" "Delete part")
4197 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4198 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4199 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4200 (gnus-mime-view-part-externally "e" "View Externally")
4201 (gnus-mime-print-part "p" "Print")
4202 (gnus-mime-pipe-part "|" "Pipe To Command...")
4203 (gnus-mime-action-on-part "." "Take action on the part...")))
4205 (defun gnus-article-mime-part-status ()
4206 (if gnus-article-mime-handle-alist-1
4207 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4209 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4212 (defvar gnus-mime-button-map
4213 (let ((map (make-sparse-keymap)))
4214 (define-key map gnus-mouse-2 'gnus-article-push-button)
4215 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4216 (dolist (c gnus-mime-button-commands)
4217 (define-key map (cadr c) (car c)))
4221 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4223 ,@(mapcar (lambda (c)
4224 (vector (caddr c) (car c) :enable t))
4225 gnus-mime-button-commands)))
4227 (defun gnus-mime-button-menu (event prefix)
4228 "Construct a context-sensitive menu of MIME commands."
4229 (interactive "e\nP")
4230 (save-window-excursion
4231 (let ((pos (event-start event)))
4232 (select-window (posn-window pos))
4233 (goto-char (posn-point pos))
4234 (gnus-article-check-buffer)
4235 (popup-menu gnus-mime-button-menu nil prefix))))
4237 (defun gnus-mime-view-all-parts (&optional handles)
4238 "View all the MIME parts."
4240 (with-current-buffer gnus-article-buffer
4241 (let ((handles (or handles gnus-article-mime-handles))
4242 (mail-parse-charset gnus-newsgroup-charset)
4243 (mail-parse-ignored-charsets
4244 (with-current-buffer gnus-summary-buffer
4245 gnus-newsgroup-ignored-charsets)))
4247 (mm-remove-parts handles)
4248 (goto-char (point-min))
4249 (or (search-forward "\n\n") (goto-char (point-max)))
4250 (let ((inhibit-read-only t))
4251 (delete-region (point) (point-max))
4252 (mm-display-parts handles))))))
4254 (defun gnus-article-jump-to-part (n)
4255 "Jump to MIME part N."
4257 (pop-to-buffer gnus-article-buffer)
4258 ;; FIXME: why is it necessary?
4260 (let ((parts (length gnus-article-mime-handle-alist)))
4263 (read-string ;; Emacs 21 doesn't have `read-number'.
4264 (format "Jump to part (2..%s): " parts)))))
4265 (unless (and (integerp n) (<= n parts) (>= n 1))
4268 (gnus-message 7 "Invalid part `%s', using %s instead."
4271 (gnus-message 9 "Jumping to part %s." n)
4272 (cond ((>= gnus-auto-select-part 1)
4273 (while (and (<= n parts)
4274 (not (gnus-article-goto-part n)))
4276 ((< gnus-auto-select-part 0)
4277 (while (and (>= n 1)
4278 (not (gnus-article-goto-part n)))
4281 (gnus-article-goto-part n)))))
4284 (defsubst gnus-article-edit-part (handles &optional current-id)
4285 "Edit an article in order to delete a mime part.
4286 This function is exclusively used by `gnus-mime-save-part-and-strip'
4287 and `gnus-mime-delete-part', and not provided at run-time normally."
4288 (gnus-article-edit-article
4290 (buffer-disable-undo)
4292 (let ((mail-parse-charset (or gnus-article-charset
4293 ',gnus-newsgroup-charset))
4294 (mail-parse-ignored-charsets
4295 (or gnus-article-ignored-charsets
4296 ',gnus-newsgroup-ignored-charsets))
4297 (mbl mml-buffer-list))
4298 (setq mml-buffer-list nil)
4299 (insert-buffer-substring gnus-original-article-buffer)
4300 (mime-to-mml ',handles)
4301 (setq gnus-article-mime-handles nil)
4302 (let ((mbl1 mml-buffer-list))
4303 (setq mml-buffer-list mbl)
4304 (set (make-local-variable 'mml-buffer-list) mbl1))
4305 (gnus-make-local-hook 'kill-buffer-hook)
4306 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4307 `(lambda (no-highlight)
4308 (let ((mail-parse-charset (or gnus-article-charset
4309 ',gnus-newsgroup-charset))
4310 (message-options message-options)
4311 (message-options-set-recipient)
4312 (mail-parse-ignored-charsets
4313 (or gnus-article-ignored-charsets
4314 ',gnus-newsgroup-ignored-charsets)))
4316 (mml-destroy-buffers)
4317 (remove-hook 'kill-buffer-hook
4318 'mml-destroy-buffers t)
4319 (kill-local-variable 'mml-buffer-list))
4320 (gnus-summary-edit-article-done
4321 ,(or (mail-header-references gnus-current-headers) "")
4322 ,(gnus-group-read-only-p)
4323 ,gnus-summary-buffer no-highlight))
4325 (gnus-article-edit-done)
4326 (gnus-summary-expand-window)
4327 (gnus-summary-show-article)
4328 (when (and current-id (integerp gnus-auto-select-part))
4329 (gnus-article-jump-to-part
4330 (+ current-id gnus-auto-select-part)))))
4332 (defun gnus-mime-replace-part (file)
4333 "Replace MIME part under point with an external body."
4334 ;; Useful if file has already been saved to disk
4338 (read-file-name "Replace MIME part with file: "
4339 (or mm-default-directory default-directory)
4341 (gnus-mime-save-part-and-strip file))
4343 (defun gnus-mime-save-part-and-strip (&optional file)
4344 "Save the MIME part under point then replace it with an external body.
4345 If FILE is given, use it for the external part."
4347 (gnus-article-check-buffer)
4348 (when (gnus-group-read-only-p)
4349 (error "The current group does not support deleting of parts"))
4350 (when (mm-complicated-handles gnus-article-mime-handles)
4352 The current article has a complicated MIME structure, giving up..."))
4353 (let* ((data (get-text-property (point) 'gnus-data))
4354 (id (get-text-property (point) 'gnus-part))
4356 (handles gnus-article-mime-handles))
4359 (and data (mm-save-part data "Delete MIME part and save to: "))))
4361 (with-current-buffer (mm-handle-buffer data)
4363 (insert "Content-Type: " (mm-handle-media-type data))
4364 (mml-insert-parameter-string (cdr (mm-handle-type data))
4366 ;; Add a filename for the sake of saving the part again.
4367 (mml-insert-parameter
4368 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4370 (insert "Content-ID: " (message-make-message-id) "\n")
4371 (insert "Content-Transfer-Encoding: binary\n")
4374 (cdr (mm-make-handle nil
4375 `("message/external-body"
4376 (access-type . "LOCAL-FILE")
4378 ;; (set-buffer gnus-summary-buffer)
4379 (gnus-article-edit-part handles id))))
4381 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4382 ;; parts...>') but with stripping would be nice.
4384 (defun gnus-mime-delete-part ()
4385 "Delete the MIME part under point.
4386 Replace it with some information about the removed part."
4388 (gnus-article-check-buffer)
4389 (when (gnus-group-read-only-p)
4390 (error "The current group does not support deleting of parts"))
4391 (when (mm-complicated-handles gnus-article-mime-handles)
4393 The current article has a complicated MIME structure, giving up..."))
4394 (when (or gnus-expert-user
4395 (gnus-yes-or-no-p "\
4396 Deleting parts may malfunction or destroy the article; continue? "))
4397 (let* ((data (get-text-property (point) 'gnus-data))
4398 (id (get-text-property (point) 'gnus-part))
4399 (handles gnus-article-mime-handles)
4403 (mail-decode-encoded-word-string (or (mm-handle-description data)
4406 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4408 (type (mm-handle-media-type data)))
4410 (error "No MIME part under point"))
4411 (with-current-buffer (mm-handle-buffer data)
4412 (let ((bsize (format "%s" (buffer-size))))
4417 "| The following attachment has been deleted:\n"
4419 "| Type: " type "\n"
4420 "| Filename: " filename "\n"
4421 "| Size (encoded): " bsize " Byte\n"
4422 "| Description: " description "\n"
4425 (cdr (mm-make-handle
4426 nil `("text/plain") nil nil
4428 (format "Deleted attachment (%s bytes)" bsize))))))
4429 ;; (set-buffer gnus-summary-buffer)
4430 (gnus-article-edit-part handles id))))
4432 (defun gnus-mime-save-part ()
4433 "Save the MIME part under point."
4435 (gnus-article-check-buffer)
4436 (let ((data (get-text-property (point) 'gnus-data)))
4438 (mm-save-part data))))
4440 (defun gnus-mime-pipe-part ()
4441 "Pipe the MIME part under point to a process."
4443 (gnus-article-check-buffer)
4444 (let ((data (get-text-property (point) 'gnus-data)))
4446 (mm-pipe-part data))))
4448 (defun gnus-mime-view-part ()
4449 "Interactively choose a viewing method for the MIME part under point."
4451 (gnus-article-check-buffer)
4452 (let ((data (get-text-property (point) 'gnus-data)))
4454 (setq gnus-article-mime-handles
4456 gnus-article-mime-handles (setq data (copy-sequence data))))
4457 (mm-interactively-view-part data))))
4459 (defun gnus-mime-view-part-as-type-internal ()
4460 (gnus-article-check-buffer)
4461 (let* ((handle (get-text-property (point) 'gnus-data))
4463 ;; Content-Type: foo/bar; name=...
4464 (mail-content-type-get (mm-handle-type handle) 'name)
4465 ;; Content-Disposition: attachment; filename=...
4466 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4467 (def-type (and name (mm-default-file-encoding name))))
4468 (and def-type (cons def-type 0))))
4470 (defun gnus-mime-view-part-as-type (&optional mime-type)
4471 "Choose a MIME media type, and view the part as such."
4475 (let ((default (gnus-mime-view-part-as-type-internal)))
4477 (format "View as MIME type (default %s): "
4479 (mapcar #'list (mailcap-mime-types))
4482 (gnus-article-check-buffer)
4483 (let ((handle (get-text-property (point) 'gnus-data)))
4485 (when (equal (mm-handle-media-type handle) "message/external-body")
4486 (unless (mm-handle-cache handle)
4487 (mm-extern-cache-contents handle))
4488 (setq handle (mm-handle-cache handle)))
4490 (mm-make-handle (mm-handle-buffer handle)
4491 (cons mime-type (cdr (mm-handle-type handle)))
4492 (mm-handle-encoding handle)
4493 (mm-handle-undisplayer handle)
4494 (mm-handle-disposition handle)
4495 (mm-handle-description handle)
4497 (mm-handle-id handle)))
4498 (setq gnus-article-mime-handles
4499 (mm-merge-handles gnus-article-mime-handles handle))
4500 (gnus-mm-display-part handle))))
4502 (defun gnus-mime-copy-part (&optional handle arg)
4503 "Put the MIME part under point into a new buffer.
4504 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4506 (interactive (list nil current-prefix-arg))
4507 (gnus-article-check-buffer)
4509 (setq handle (get-text-property (point) 'gnus-data)))
4511 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4513 (mail-content-type-get (mm-handle-disposition handle)
4515 contents dont-decode charset coding-system)
4516 (mm-with-unibyte-buffer
4517 (mm-insert-part handle)
4518 (setq contents (or (condition-case nil
4519 (mm-decompress-buffer filename nil 'sig)
4521 (setq dont-decode t)
4524 (setq filename (cond (filename (file-name-nondirectory filename))
4525 (dont-decode "*raw data*")
4530 (unless (setq charset (mail-content-type-get
4531 (mm-handle-type handle) 'charset))
4532 (unless (setq coding-system (mm-with-unibyte-buffer
4534 (mm-find-buffer-file-coding-system)))
4535 (setq charset gnus-newsgroup-charset))))
4537 (setq charset (or (cdr (assq arg
4538 gnus-summary-show-article-charset-alist))
4539 (mm-read-coding-system "Charset: ")))))
4540 (switch-to-buffer (generate-new-buffer filename))
4541 (if (or coding-system
4543 (setq coding-system (mm-charset-to-coding-system charset))
4544 (not (eq charset 'ascii))))
4546 (mm-enable-multibyte)
4547 (insert (mm-decode-coding-string contents coding-system))
4548 (setq buffer-file-coding-system
4549 (if (boundp 'last-coding-system-used)
4550 (symbol-value 'last-coding-system-used)
4552 (mm-disable-multibyte)
4554 (setq buffer-file-coding-system mm-binary-coding-system))
4555 ;; We do it this way to make `normal-mode' set the appropriate mode.
4558 (setq buffer-file-name (expand-file-name filename))
4560 (setq buffer-file-name nil))
4561 (goto-char (point-min)))))
4563 (defun gnus-mime-print-part (&optional handle filename)
4564 "Print the MIME part under point."
4565 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4566 (gnus-article-check-buffer)
4567 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4568 (contents (and handle (mm-get-part handle)))
4569 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4570 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4575 (mm-save-part-to-file handle file)
4576 (call-process shell-file-name nil
4577 (generate-new-buffer " *mm*")
4579 shell-command-switch
4581 printer file (mm-handle-type handle))))
4585 (gnus-print-buffer))
4586 (ps-despool filename)))))
4588 (defun gnus-mime-inline-part (&optional handle arg)
4589 "Insert the MIME part under point into the current buffer.
4590 Compressed files like .gz and .bz2 are decompressed."
4591 (interactive (list nil current-prefix-arg))
4592 (gnus-article-check-buffer)
4594 (setq handle (get-text-property (point) 'gnus-data)))
4597 (inhibit-read-only t)
4598 contents charset coding-system)
4599 (if (and (not arg) (mm-handle-undisplayer handle))
4600 (mm-remove-part handle)
4601 (mm-with-unibyte-buffer
4602 (mm-insert-part handle)
4604 (or (mm-decompress-buffer
4605 (or (mail-content-type-get (mm-handle-disposition handle)
4607 (mail-content-type-get (mm-handle-disposition handle)
4613 (unless (setq charset (mail-content-type-get
4614 (mm-handle-type handle) 'charset))
4615 (unless (setq coding-system
4616 (mm-with-unibyte-buffer
4618 (mm-find-buffer-file-coding-system)))
4619 (setq charset gnus-newsgroup-charset))))
4621 (if (mm-handle-undisplayer handle)
4622 (mm-remove-part handle))
4625 gnus-summary-show-article-charset-alist))
4626 (mm-read-coding-system "Charset: "))))
4628 (if (mm-handle-undisplayer handle)
4629 (mm-remove-part handle))))
4633 (if (or coding-system
4636 (mm-charset-to-coding-system charset))
4637 (not (eq coding-system 'ascii))))
4638 (mm-decode-coding-string contents coding-system)
4639 (mm-string-to-multibyte contents)))
4642 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4643 "Insert the MIME part under point into the current buffer using the
4645 (interactive (list nil current-prefix-arg))
4646 (gnus-article-check-buffer)
4647 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4650 (inhibit-read-only t))
4652 (if (mm-handle-undisplayer handle)
4653 (mm-remove-part handle))
4654 (let ((gnus-newsgroup-charset
4656 gnus-summary-show-article-charset-alist))
4657 (mm-read-coding-system "Charset: ")))
4658 (gnus-newsgroup-ignored-charsets 'gnus-all))
4659 (gnus-article-press-button)))))
4661 (defun gnus-mime-view-part-externally (&optional handle)
4662 "View the MIME part under point with an external viewer."
4664 (gnus-article-check-buffer)
4665 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4666 (mm-user-display-methods nil)
4667 (mm-inlined-types nil)
4668 (mail-parse-charset gnus-newsgroup-charset)
4669 (mail-parse-ignored-charsets
4670 (with-current-buffer gnus-summary-buffer
4671 gnus-newsgroup-ignored-charsets)))
4673 (if (mm-handle-undisplayer handle)
4674 (mm-remove-part handle)
4675 (mm-display-part handle)))))
4677 (defun gnus-mime-view-part-internally (&optional handle)
4678 "View the MIME part under point with an internal viewer.
4679 If no internal viewer is available, use an external viewer."
4681 (gnus-article-check-buffer)
4682 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4683 (mm-inlined-types '(".*"))
4684 (mm-inline-large-images t)
4685 (mail-parse-charset gnus-newsgroup-charset)
4686 (mail-parse-ignored-charsets
4687 (with-current-buffer gnus-summary-buffer
4688 gnus-newsgroup-ignored-charsets))
4689 (inhibit-read-only t))
4691 (if (mm-handle-undisplayer handle)
4692 (mm-remove-part handle)
4693 (mm-display-part handle)))))
4695 (defun gnus-mime-action-on-part (&optional action)
4696 "Do something with the MIME attachment at \(point\)."
4698 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4699 (gnus-article-check-buffer)
4700 (let ((action-pair (assoc action gnus-mime-action-alist)))
4702 (funcall (cdr action-pair)))))
4704 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4705 "Call FUNCTION on MIME part N.
4706 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4707 If INTERACTIVE, call FUNCTION interactivly."
4709 ;; Check whether the article is displayed.
4710 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4711 (setq window (get-buffer-window gnus-article-buffer t))
4712 (frame-visible-p (setq frame (window-frame window))))
4713 (error "No article is displayed"))
4714 (with-current-buffer gnus-article-buffer
4715 ;; Check whether the article displays the right contents.
4716 (unless (with-current-buffer gnus-summary-buffer
4717 (eq gnus-current-article (gnus-summary-article-number)))
4718 (error "You should select the right article first"))
4719 ;; Check whether the specified part exists.
4720 (when (> n (length gnus-article-mime-handle-alist))
4721 (error "No such part")))
4724 ;; To select the window is needed so that the cursor
4725 ;; might be visible on the MIME button.
4726 (select-window (prog1
4728 (setq window (selected-window))
4729 ;; Article may be displayed in the other frame.
4730 (gnus-select-frame-set-input-focus
4733 (setq frame (selected-frame))))))
4734 (when (gnus-article-goto-part n)
4735 ;; We point the cursor and the arrow at the MIME button
4736 ;; when the `function' prompt the user for something.
4737 (let ((cursor-in-non-selected-windows t)
4738 (overlay-arrow-string "=>")
4739 (overlay-arrow-position (point-marker)))
4742 ((and no-handle interactive)
4743 (call-interactively function))
4749 (cdr (assq n gnus-article-mime-handle-alist))))
4752 (cdr (assq n gnus-article-mime-handle-alist)))))
4753 (set-marker overlay-arrow-position nil)
4754 (unless gnus-auto-select-part
4755 (gnus-select-frame-set-input-focus frame)
4756 (select-window window))))
4758 (if gnus-inhibit-mime-unbuttonizing
4759 ;; This is the default though the program shouldn't reach here.
4760 (error "No such part")
4761 ;; The part which doesn't have the MIME button is selected.
4762 ;; So, we display all the buttons and redo it.
4763 (let ((gnus-inhibit-mime-unbuttonizing t))
4764 (gnus-summary-show-article)
4765 (gnus-article-part-wrapper n function no-handle))))))
4767 (defun gnus-article-pipe-part (n)
4768 "Pipe MIME part N, which is the numerical prefix."
4770 (gnus-article-part-wrapper n 'mm-pipe-part))
4772 (defun gnus-article-save-part (n)
4773 "Save MIME part N, which is the numerical prefix."
4775 (gnus-article-part-wrapper n 'mm-save-part))
4777 (defun gnus-article-interactively-view-part (n)
4778 "View MIME part N interactively, which is the numerical prefix."
4780 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4782 (defun gnus-article-copy-part (n)
4783 "Copy MIME part N, which is the numerical prefix."
4785 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4787 (defun gnus-article-view-part-as-charset (n)
4788 "View MIME part N using a specified charset.
4789 N is the numerical prefix."
4791 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4793 (defun gnus-article-view-part-externally (n)
4794 "View MIME part N externally, which is the numerical prefix."
4796 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4798 (defun gnus-article-inline-part (n)
4799 "Inline MIME part N, which is the numerical prefix."
4801 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4803 (defun gnus-article-save-part-and-strip (n)
4804 "Save MIME part N and replace it with an external body.
4805 N is the numerical prefix."
4807 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4809 (defun gnus-article-replace-part (n)
4810 "Replace MIME part N with an external body.
4811 N is the numerical prefix."
4813 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
4815 (defun gnus-article-delete-part (n)
4816 "Delete MIME part N and add some information about the removed part.
4817 N is the numerical prefix."
4819 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4821 (defun gnus-article-mime-match-handle-first (condition)
4824 (dolist (ihandle gnus-article-mime-handle-alist)
4826 ((functionp condition)
4827 (funcall condition (cdr ihandle)))
4828 ((eq condition 'undisplayed)
4829 (not (or (mm-handle-undisplayer (cdr ihandle))
4830 (equal (mm-handle-media-type (cdr ihandle))
4831 "multipart/alternative"))))
4832 ((eq condition 'undisplayed-alternative)
4833 (not (mm-handle-undisplayer (cdr ihandle))))
4835 (gnus-article-goto-part (car ihandle))
4836 (or (not n) (< (car ihandle) n)))
4837 (setq n (car ihandle))))
4841 (defun gnus-article-view-part (&optional n)
4842 "View MIME part N, which is the numerical prefix."
4844 (with-current-buffer gnus-article-buffer
4845 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4846 gnus-article-mime-match-handle-function)))
4847 (when (> n (length gnus-article-mime-handle-alist))
4848 (error "No such part"))
4849 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4850 (when (gnus-article-goto-part n)
4851 (if (equal (car handle) "multipart/alternative")
4852 (gnus-article-press-button)
4853 (when (eq (gnus-mm-display-part handle) 'internal)
4854 (gnus-set-window-start)))))))
4856 (defsubst gnus-article-mime-total-parts ()
4857 (if (bufferp (car gnus-article-mime-handles))
4859 (1- (length gnus-article-mime-handles))))
4861 (defun gnus-mm-display-part (handle)
4862 "Display HANDLE and fix MIME button."
4863 (let ((id (get-text-property (point) 'gnus-part))
4865 (inhibit-read-only t))
4868 (let ((window (selected-window))
4869 (mail-parse-charset gnus-newsgroup-charset)
4870 (mail-parse-ignored-charsets
4871 (if (gnus-buffer-live-p gnus-summary-buffer)
4872 (with-current-buffer gnus-summary-buffer
4873 gnus-newsgroup-ignored-charsets)
4877 (let ((win (gnus-get-buffer-window (current-buffer) t))
4880 (select-window win))
4883 (if (mm-handle-displayed-p handle)
4884 ;; This will remove the part.
4885 (mm-display-part handle)
4887 (narrow-to-region (point)
4888 (if (eobp) (point) (1+ (point))))
4889 (mm-display-part handle)
4890 ;; We narrow to the part itself and
4891 ;; then call the treatment functions.
4892 (goto-char (point-min))
4894 (narrow-to-region (point) (point-max))
4897 (gnus-article-mime-total-parts)
4898 (mm-handle-media-type handle)))))
4899 (if (window-live-p window)
4900 (select-window window)))))
4903 (gnus-insert-mime-button
4904 handle id (list (mm-handle-displayed-p handle)))
4905 (goto-char point))))
4907 (defun gnus-article-goto-part (n)
4908 "Go to MIME part N."
4909 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4911 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4912 (let ((gnus-tmp-name
4913 (or (mail-content-type-get (mm-handle-type handle) 'name)
4914 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4915 (mail-content-type-get (mm-handle-type handle) 'url)
4917 (gnus-tmp-type (mm-handle-media-type handle))
4918 (gnus-tmp-description
4919 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4922 (if (if displayed (car displayed)
4923 (mm-handle-displayed-p handle))
4925 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4927 gnus-tmp-type-long b e)
4928 (when (string-match ".*/" gnus-tmp-name)
4929 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4930 (setq gnus-tmp-type-long (concat gnus-tmp-type
4931 (and (not (equal gnus-tmp-name ""))
4932 (concat "; " gnus-tmp-name))))
4933 (unless (equal gnus-tmp-description "")
4934 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4939 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4940 `(keymap ,gnus-mime-button-map
4941 gnus-callback gnus-mm-display-part
4942 gnus-part ,gnus-tmp-id
4943 article-type annotation
4946 ;; Exclude a newline.
4949 (widget-convert-button
4952 :action 'gnus-widget-press-button
4953 :button-keymap gnus-mime-button-map
4955 (lambda (widget/window &optional overlay pos)
4956 ;; Needed to properly clear the message due to a bug in
4957 ;; wid-edit (XEmacs only).
4958 (if (boundp 'help-echo-owns-message)
4959 (setq help-echo-owns-message t))
4961 "%S: %s the MIME part; %S: more options"
4962 (aref gnus-mouse-2 0)
4963 ;; XEmacs will get a single widget arg; Emacs 21 will get
4964 ;; window, overlay, position.
4965 (if (mm-handle-displayed-p
4967 (with-current-buffer (gnus-overlay-buffer overlay)
4968 (widget-get (widget-at (gnus-overlay-start overlay))
4970 (widget-get widget/window :mime-handle)))
4972 (aref gnus-down-mouse-3 0))))))
4974 (defun gnus-widget-press-button (elems el)
4975 (goto-char (widget-get elems :from))
4976 (gnus-article-press-button))
4978 (defvar gnus-displaying-mime nil)
4980 (defun gnus-display-mime (&optional ihandles)
4981 "Display the MIME parts."
4983 (save-selected-window
4984 (let ((window (get-buffer-window gnus-article-buffer))
4987 (select-window window)
4988 ;; We have to do this since selecting the window
4989 ;; may change the point. So we set the window point.
4990 (set-window-point window point)))
4991 (let ((handles ihandles)
4992 (inhibit-read-only t)
4995 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4996 (when gnus-article-emulate-mime
4997 (mm-uu-dissect-text-parts handles)))
4998 (gnus-article-emulate-mime
4999 (setq handles (mm-uu-dissect))))
5000 (when (and (not ihandles)
5001 (not gnus-displaying-mime))
5002 ;; Top-level call; we clean up.
5003 (when gnus-article-mime-handles
5004 (mm-destroy-parts gnus-article-mime-handles)
5005 (setq gnus-article-mime-handle-alist nil));; A trick.
5006 (setq gnus-article-mime-handles handles)
5007 ;; We allow users to glean info from the handles.
5008 (when gnus-article-mime-part-function
5009 (gnus-mime-part-function handles)))
5011 (or (not (stringp (car handles)))
5014 (when (and (not ihandles)
5015 (not gnus-displaying-mime))
5016 ;; Clean up for mime parts.
5018 (delete-region (point) (point-max)))
5019 (let ((gnus-displaying-mime t))
5020 (gnus-mime-display-part handles)))
5023 (narrow-to-region (point) (point-max))
5024 (gnus-treat-article nil 1 1)
5027 ;; Highlight the headers.
5031 (narrow-to-region (point-min) (point))
5032 (gnus-article-save-original-date
5033 (gnus-treat-article 'head)))))))))
5035 (defcustom gnus-mime-display-multipart-as-mixed nil
5036 "Display \"multipart\" parts as \"multipart/mixed\".
5038 If t, it overrides nil values of
5039 `gnus-mime-display-multipart-alternative-as-mixed' and
5040 `gnus-mime-display-multipart-related-as-mixed'."
5041 :group 'gnus-article-mime
5044 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5045 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5047 :group 'gnus-article-mime
5050 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5051 "Display \"multipart/related\" parts as \"multipart/mixed\".
5053 If displaying \"text/html\" is discouraged \(see
5054 `mm-discouraged-alternatives'\) images or other material inside a
5055 \"multipart/related\" part might be overlooked when this variable is nil."
5057 :group 'gnus-article-mime
5060 (defun gnus-mime-display-part (handle)
5062 ;; Maybe a broken MIME message.
5065 ((not (stringp (car handle)))
5066 (gnus-mime-display-single handle))
5067 ;; User-defined multipart
5068 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5069 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5071 ;; multipart/alternative
5072 ((and (equal (car handle) "multipart/alternative")
5073 (not (or gnus-mime-display-multipart-as-mixed
5074 gnus-mime-display-multipart-alternative-as-mixed)))
5075 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5076 (push (cons id handle) gnus-article-mime-handle-alist)
5077 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5078 ;; multipart/related
5079 ((and (equal (car handle) "multipart/related")
5080 (not (or gnus-mime-display-multipart-as-mixed
5081 gnus-mime-display-multipart-related-as-mixed)))
5082 ;;;!!!We should find the start part, but we just default
5083 ;;;!!!to the first part.
5084 ;;(gnus-mime-display-part (cadr handle))
5085 ;;;!!! Most multipart/related is an HTML message plus images.
5086 ;;;!!! Unfortunately we are unable to let W3 display those
5087 ;;;!!! included images, so we just display it as a mixed multipart.
5088 ;;(gnus-mime-display-mixed (cdr handle))
5089 ;;;!!! No, w3 can display everything just fine.
5090 (gnus-mime-display-part (cadr handle)))
5091 ((equal (car handle) "multipart/signed")
5092 (gnus-add-wash-type 'signed)
5093 (gnus-mime-display-security handle))
5094 ((equal (car handle) "multipart/encrypted")
5095 (gnus-add-wash-type 'encrypted)
5096 (gnus-mime-display-security handle))
5097 ;; Other multiparts are handled like multipart/mixed.
5099 (gnus-mime-display-mixed (cdr handle)))))
5101 (defun gnus-mime-part-function (handles)
5102 (if (stringp (car handles))
5103 (mapcar 'gnus-mime-part-function (cdr handles))
5104 (funcall gnus-article-mime-part-function handles)))
5106 (defun gnus-mime-display-mixed (handles)
5107 (mapcar 'gnus-mime-display-part handles))
5109 (defun gnus-mime-display-single (handle)
5110 (let ((type (mm-handle-media-type handle))
5111 (ignored gnus-ignored-mime-types)
5118 (when (string-match (pop ignored) type)
5119 (throw 'ignored nil)))
5120 (if (and (setq not-attachment
5121 (and (not (mm-inline-override-p handle))
5122 (or (not (mm-handle-disposition handle))
5123 (equal (car (mm-handle-disposition handle))
5125 (mm-attachment-override-p handle))))
5126 (mm-automatic-display-p handle)
5128 (mm-inlinable-p handle)
5129 (mm-inlined-p handle))
5130 (mm-automatic-external-display-p type)))
5132 (when (equal (mm-handle-media-supertype handle) "text")
5134 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5136 (push (cons id handle) gnus-article-mime-handle-alist)
5138 (equal (mm-handle-media-supertype handle) "message"))
5141 (cond ((not (bolp)) 2)
5142 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5144 (when (or (not display)
5145 (not (gnus-unbuttonized-mime-type-p type)))
5146 (gnus-insert-mime-button
5147 handle id (list (or display (and not-attachment text))))
5148 (gnus-article-insert-newline)
5149 ;; Remember modify the number of forward lines.
5157 (let ((mail-parse-charset gnus-newsgroup-charset)
5158 (mail-parse-ignored-charsets
5159 (save-excursion (condition-case ()
5160 (set-buffer gnus-summary-buffer)
5162 gnus-newsgroup-ignored-charsets)))
5163 (mm-display-part handle t))
5164 (goto-char (point-max)))
5165 ((and text not-attachment)
5169 (gnus-article-insert-newline)
5172 (let ((charset (mail-content-type-get (mm-handle-type handle)
5174 (cond ((not charset)
5175 (mm-string-as-multibyte (mm-get-part handle)))
5176 ((eq charset 'gnus-decoded)
5177 (with-current-buffer (mm-handle-buffer handle)
5180 (mm-decode-string (mm-get-part handle) charset)))))
5181 (goto-char (point-max))))
5185 (narrow-to-region beg (point))
5188 (gnus-article-mime-total-parts)
5189 (mm-handle-media-type handle)))))))))
5191 (defun gnus-unbuttonized-mime-type-p (type)
5192 "Say whether TYPE is to be unbuttonized."
5193 (unless gnus-inhibit-mime-unbuttonizing
5195 (let ((types gnus-unbuttonized-mime-types))
5197 (when (string-match (pop types) type)
5198 (throw 'found t)))))
5200 (let ((types gnus-buttonized-mime-types))
5202 (when (string-match (pop types) type)
5203 (throw 'found t)))))))))
5205 (defun gnus-article-insert-newline ()
5206 "Insert a newline, but mark it as undeletable."
5207 (gnus-put-text-property
5208 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5210 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5211 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5214 handle (inhibit-read-only t) from props begend not-pref)
5215 (save-window-excursion
5218 (narrow-to-region (car ibegend)
5221 (goto-char (car ibegend))
5224 (delete-region (point-min) (point-max))
5225 (mm-remove-parts handles))
5226 (setq begend (list (point-marker)))
5228 (unless (setq not-pref (cadr (member preferred ihandles)))
5229 (setq not-pref (car ihandles)))
5232 (not (gnus-unbuttonized-mime-type-p
5233 "multipart/alternative")))
5234 (gnus-add-text-properties
5237 (insert (format "%d. " id))
5241 (unless ,(not ibegend)
5242 (setq gnus-article-mime-handle-alist
5243 ',gnus-article-mime-handle-alist))
5244 (gnus-mime-display-alternative
5245 ',ihandles ',not-pref ',begend ,id))
5246 keymap ,gnus-mime-button-map
5247 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5248 face ,gnus-article-button-face
5250 article-type multipart))
5251 (widget-convert-button 'link from (point)
5252 :action 'gnus-widget-press-button
5253 :button-keymap gnus-widget-button-keymap)
5255 (while (setq handle (pop handles))
5256 (gnus-add-text-properties
5259 (insert (format "(%c) %-18s"
5260 (if (equal handle preferred) ?* ? )
5261 (mm-handle-media-type handle)))
5265 (unless ,(not ibegend)
5266 (setq gnus-article-mime-handle-alist
5267 ',gnus-article-mime-handle-alist))
5268 (gnus-mime-display-alternative
5269 ',ihandles ',handle ',begend ,id))
5270 keymap ,gnus-mime-button-map
5271 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5272 face ,gnus-article-button-face
5275 (widget-convert-button 'link from (point)
5276 :action 'gnus-widget-press-button
5277 :button-keymap gnus-widget-button-keymap)
5281 (if (stringp (car preferred))
5282 (gnus-display-mime preferred)
5283 (let ((mail-parse-charset gnus-newsgroup-charset)
5284 (mail-parse-ignored-charsets
5285 (with-current-buffer gnus-summary-buffer
5286 gnus-newsgroup-ignored-charsets)))
5287 (mm-display-part preferred)
5291 (narrow-to-region (car begend) (point-max))
5293 nil (length gnus-article-mime-handle-alist)
5294 (gnus-article-mime-total-parts)
5295 (mm-handle-media-type handle))))))
5296 (goto-char (point-max))
5297 (setcdr begend (point-marker)))))
5299 (goto-char point))))
5301 (defconst gnus-article-wash-status-strings
5302 (let ((alist '((cite "c" "Possible hidden citation text"
5303 " " "All citation text visible")
5304 (headers "h" "Hidden headers"
5305 " " "All headers visible.")
5306 (pgp "p" "Encrypted or signed message status hidden"
5307 " " "No hidden encryption nor digital signature status")
5308 (signature "s" "Signature has been hidden"
5309 " " "Signature is visible")
5310 (overstrike "o" "Overstrike (^H) characters applied"
5311 " " "No overstrike characters applied")
5312 (emphasis "e" "/*_Emphasis_*/ characters applied"
5313 " " "No /*_emphasis_*/ characters applied")))
5315 (dolist (entry alist result)
5316 (let ((key (nth 0 entry))
5317 (on (copy-sequence (nth 1 entry)))
5318 (on-help (nth 2 entry))
5319 (off (copy-sequence (nth 3 entry)))
5320 (off-help (nth 4 entry)))
5321 (put-text-property 0 1 'help-echo on-help on)
5322 (put-text-property 0 1 'help-echo off-help off)
5323 (push (list key on off) result))))
5324 "Alist of strings describing wash status in the mode line.
5325 Each entry has the form (KEY ON OF), where the KEY is a symbol
5326 representing the particular washing function, ON is the string to use
5327 in the article mode line when the washing function is active, and OFF
5328 is the string to use when it is inactive.")
5330 (defun gnus-article-wash-status-entry (key value)
5331 (let ((entry (assoc key gnus-article-wash-status-strings)))
5332 (if value (nth 1 entry) (nth 2 entry))))
5334 (defun gnus-article-wash-status ()
5335 "Return a string which display status of article washing."
5336 (with-current-buffer gnus-article-buffer
5337 (let ((cite (memq 'cite gnus-article-wash-types))
5338 (headers (memq 'headers gnus-article-wash-types))
5339 (boring (memq 'boring-headers gnus-article-wash-types))
5340 (pgp (memq 'pgp gnus-article-wash-types))
5341 (pem (memq 'pem gnus-article-wash-types))
5342 (signed (memq 'signed gnus-article-wash-types))
5343 (encrypted (memq 'encrypted gnus-article-wash-types))
5344 (signature (memq 'signature gnus-article-wash-types))
5345 (overstrike (memq 'overstrike gnus-article-wash-types))
5346 (emphasis (memq 'emphasis gnus-article-wash-types)))
5348 (gnus-article-wash-status-entry 'cite cite)
5349 (gnus-article-wash-status-entry 'headers (or headers boring))
5350 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5351 (gnus-article-wash-status-entry 'signature signature)
5352 (gnus-article-wash-status-entry 'overstrike overstrike)
5353 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5355 (defun gnus-add-wash-type (type)
5356 "Add a washing of TYPE to the current status."
5357 (add-to-list 'gnus-article-wash-types type))
5359 (defun gnus-delete-wash-type (type)
5360 "Add a washing of TYPE to the current status."
5361 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5363 (defun gnus-add-image (category image)
5364 "Add IMAGE of CATEGORY to the list of displayed images."
5365 (let ((entry (assq category gnus-article-image-alist)))
5367 (setq entry (list category))
5368 (push entry gnus-article-image-alist))
5369 (nconc entry (list image))))
5371 (defun gnus-delete-images (category)
5372 "Delete all images in CATEGORY."
5373 (let ((entry (assq category gnus-article-image-alist)))
5374 (dolist (image (cdr entry))
5375 (gnus-remove-image image category))
5376 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5377 (gnus-delete-wash-type category)))
5379 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5381 (defun gnus-article-maybe-hide-headers ()
5382 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5383 Provided for backwards compatibility."
5384 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5385 (not (with-current-buffer gnus-summary-buffer
5386 gnus-have-all-headers)))
5387 (not gnus-inhibit-hiding))
5388 (gnus-article-hide-headers)))
5392 (defun gnus-output-to-file (file-name)
5393 "Append the current article to a file named FILE-NAME."
5394 (let ((artbuf (current-buffer)))
5396 (insert-buffer-substring artbuf)
5397 ;; Append newline at end of the buffer as separator, and then
5399 (goto-char (point-max))
5401 (let ((file-name-coding-system nnmail-pathname-coding-system))
5402 (mm-append-to-file (point-min) (point-max) file-name))
5405 (defun gnus-narrow-to-page (&optional arg)
5406 "Narrow the article buffer to a page.
5407 If given a numerical ARG, move forward ARG pages."
5409 (setq arg (if arg (prefix-numeric-value arg) 0))
5411 (set-buffer gnus-article-buffer)
5412 (goto-char (point-min))
5414 ;; Remove any old next/prev buttons.
5415 (when (gnus-visual-p 'page-marker)
5416 (let ((inhibit-read-only t))
5417 (gnus-remove-text-with-property 'gnus-prev)
5418 (gnus-remove-text-with-property 'gnus-next)))
5421 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5423 (re-search-forward page-delimiter nil 'move arg)))
5424 (goto-char (match-end 0))
5426 (goto-char (point-min))
5427 (setq gnus-page-broken
5428 (and (re-search-forward page-delimiter nil t) t))))
5429 (when gnus-page-broken
5432 (if (re-search-forward page-delimiter nil 'move)
5435 (when (and (gnus-visual-p 'page-marker)
5436 (> (point-min) (save-restriction (widen) (point-min))))
5438 (goto-char (point-min))
5439 (gnus-insert-prev-page-button)))
5440 (when (and (gnus-visual-p 'page-marker)
5441 (< (point-max) (save-restriction (widen) (point-max))))
5443 (goto-char (point-max))
5444 (gnus-insert-next-page-button))))))
5446 ;; Article mode commands
5448 (defun gnus-article-goto-next-page ()
5449 "Show the next page of the article."
5451 (when (gnus-article-next-page)
5452 (goto-char (point-min))
5453 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5456 (defun gnus-article-goto-prev-page ()
5457 "Show the previous page of the article."
5460 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5461 (gnus-article-prev-page nil)))
5463 ;; This is cleaner but currently breaks `gnus-pick-mode':
5465 ;; (defun gnus-article-goto-next-page ()
5466 ;; "Show the next page of the article."
5468 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5469 ;; (gnus-summary-next-page)))
5471 ;; (defun gnus-article-goto-prev-page ()
5472 ;; "Show the next page of the article."
5474 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5475 ;; (gnus-summary-prev-page)))
5477 (defun gnus-article-next-page (&optional lines)
5478 "Show the next page of the current article.
5479 If end of article, return non-nil. Otherwise return nil.
5480 Argument LINES specifies lines to be scrolled up."
5482 (move-to-window-line -1)
5485 (and (pos-visible-in-window-p) ;Not continuation line.
5486 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5487 ;; Nothing in this page.
5488 (if (or (not gnus-page-broken)
5493 (eobp)))) ;Real end-of-buffer?
5495 (when gnus-article-over-scroll
5496 (gnus-article-next-page-1 lines))
5498 (gnus-narrow-to-page 1) ;Go to next page.
5500 ;; More in this page.
5501 (gnus-article-next-page-1 lines)
5504 (defmacro gnus-article-beginning-of-window ()
5505 "Move point to the beginning of the window.
5506 In Emacs, the point is placed at the line number which `scroll-margin'
5508 (if (featurep 'xemacs)
5509 '(move-to-window-line 0)
5510 '(move-to-window-line
5511 (min (max 0 scroll-margin)
5512 (max 1 (- (window-height)
5513 (if mode-line-format 1 0)
5514 (if header-line-format 1 0)))))))
5516 (defun gnus-article-next-page-1 (lines)
5517 (when (and (not (featurep 'xemacs))
5520 (numberp (symbol-value 'scroll-margin))
5521 (> (symbol-value 'scroll-margin) 0))
5522 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5523 ;; too many number of lines if `scroll-margin' is set as two or greater.
5524 (setq lines (min lines
5525 (max 0 (- (count-lines (window-start) (point-max))
5526 (symbol-value 'scroll-margin))))))
5528 (let ((scroll-in-place nil))
5531 ;; Long lines may cause an end-of-buffer error.
5532 (goto-char (point-max))))
5533 (gnus-article-beginning-of-window))
5535 (defun gnus-article-prev-page (&optional lines)
5536 "Show previous page of current article.
5537 Argument LINES specifies lines to be scrolled down."
5539 (move-to-window-line 0)
5540 (if (and gnus-page-broken
5542 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5544 (gnus-narrow-to-page -1) ;Go to previous page.
5545 (goto-char (point-max))
5549 (let ((scroll-in-place nil))
5550 (scroll-down lines))
5551 (beginning-of-buffer
5552 (goto-char (point-min))))
5553 (gnus-article-beginning-of-window))))
5555 (defun gnus-article-only-boring-p ()
5556 "Decide whether there is only boring text remaining in the article.
5557 Something \"interesting\" is a word of at least two letters that does
5558 not have a face in `gnus-article-boring-faces'."
5559 (when (and gnus-article-skip-boring
5560 (boundp 'gnus-article-boring-faces)
5561 (symbol-value 'gnus-article-boring-faces))
5563 (let ((inhibit-point-motion-hooks t))
5565 (while (re-search-forward "\\b\\w\\w" nil t)
5567 (when (not (gnus-intersection
5568 (gnus-faces-at (point))
5569 (symbol-value 'gnus-article-boring-faces)))
5570 (throw 'only-boring nil)))
5571 (throw 'only-boring t))))))
5573 (defun gnus-article-refer-article ()
5574 "Read article specified by message-id around point."
5577 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5578 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5579 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5580 (let ((msg-id (concat "<" (match-string 0) ">")))
5581 (set-buffer gnus-summary-buffer)
5582 (gnus-summary-refer-article msg-id))
5583 (error "No references around point"))))
5585 (defun gnus-article-show-summary ()
5586 "Reconfigure windows to show summary buffer."
5588 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5589 (error "There is no summary buffer for this article buffer")
5590 (gnus-article-set-globals)
5591 (gnus-configure-windows 'article)
5592 (gnus-summary-goto-subject gnus-current-article)
5593 (gnus-summary-position-point)))
5595 (defun gnus-article-describe-briefly ()
5596 "Describe article mode commands briefly."
5598 (gnus-message 6 (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")))
5600 (defun gnus-article-summary-command ()
5601 "Execute the last keystroke in the summary buffer."
5603 (let ((obuf (current-buffer))
5604 (owin (current-window-configuration))
5606 (switch-to-buffer gnus-article-current-summary 'norecord)
5607 (setq func (lookup-key (current-local-map) (this-command-keys)))
5608 (call-interactively func)
5610 (set-window-configuration owin)
5611 (set-window-point (get-buffer-window (current-buffer)) (point))))
5613 (defun gnus-article-summary-command-nosave ()
5614 "Execute the last keystroke in the summary buffer."
5617 (pop-to-buffer gnus-article-current-summary 'norecord)
5618 (setq func (lookup-key (current-local-map) (this-command-keys)))
5619 (call-interactively func)))
5621 (defun gnus-article-check-buffer ()
5622 "Beep if not in an article buffer."
5623 (unless (equal major-mode 'gnus-article-mode)
5624 (error "Command invoked outside of a Gnus article buffer")))
5626 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5627 "Read a summary buffer key sequence and execute it from the article buffer."
5629 (gnus-article-check-buffer)
5631 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5632 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5633 "=" "^" "\M-^" "|"))
5639 '("n" "Gn" "p" "Gp"))
5642 (set-buffer gnus-article-current-summary)
5643 (let (gnus-pick-mode)
5644 (push (or key last-command-event) unread-command-events)
5645 (setq keys (if (featurep 'xemacs)
5646 (events-to-keys (read-key-sequence nil))
5647 (read-key-sequence nil)))))
5651 (if (or (member keys nosaves)
5652 (member keys nosave-but-article)
5653 (member keys nosave-in-article))
5655 (save-window-excursion
5656 (pop-to-buffer gnus-article-current-summary 'norecord)
5657 ;; We disable the pick minor mode commands.
5658 (let (gnus-pick-mode)
5659 (setq func (lookup-key (current-local-map) keys))))
5663 (unless (member keys nosave-in-article)
5664 (set-buffer gnus-article-current-summary))
5665 (call-interactively func)
5666 (setq new-sum-point (point)))
5667 (when (member keys nosave-but-article)
5668 (pop-to-buffer gnus-article-buffer 'norecord)))
5669 ;; These commands should restore window configuration.
5670 (let ((obuf (current-buffer))
5671 (owin (current-window-configuration))
5673 win func in-buffer selected new-sum-start new-sum-hscroll)
5674 (cond (not-restore-window
5675 (pop-to-buffer gnus-article-current-summary 'norecord))
5676 ((setq win (get-buffer-window gnus-article-current-summary))
5677 (select-window win))
5679 (switch-to-buffer gnus-article-current-summary 'norecord)))
5680 (setq in-buffer (current-buffer))
5681 ;; We disable the pick minor mode commands.
5682 (if (and (setq func (let (gnus-pick-mode)
5683 (lookup-key (current-local-map) keys)))
5686 (call-interactively func)
5687 (when (eq win (selected-window))
5688 (setq new-sum-point (point)
5689 new-sum-start (window-start win)
5690 new-sum-hscroll (window-hscroll win)))
5691 (when (eq in-buffer (current-buffer))
5692 (setq selected (gnus-summary-select-article))
5694 (unless not-restore-window
5695 (set-window-configuration owin))
5696 (when (eq selected 'old)
5698 (set-window-start (get-buffer-window (current-buffer))
5700 (set-window-point (get-buffer-window (current-buffer))
5702 (when (and (not not-restore-window)
5704 (set-window-point win new-sum-point)
5705 (set-window-start win new-sum-start)
5706 (set-window-hscroll win new-sum-hscroll))))
5707 (set-window-configuration owin)
5710 (defun gnus-article-describe-key (key)
5711 "Display documentation of the function invoked by KEY. KEY is a string."
5712 (interactive "kDescribe key: ")
5713 (gnus-article-check-buffer)
5714 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5716 (set-buffer gnus-article-current-summary)
5717 (let (gnus-pick-mode)
5718 (if (featurep 'xemacs)
5720 (push (elt key 0) unread-command-events)
5721 (setq key (events-to-keys
5722 (read-key-sequence "Describe key: "))))
5723 (setq unread-command-events
5725 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5726 (string-to-list key)))
5727 (setq key (read-key-sequence "Describe key: "))))
5729 (describe-key key)))
5731 (defun gnus-article-describe-key-briefly (key &optional insert)
5732 "Display documentation of the function invoked by KEY. KEY is a string."
5733 (interactive "kDescribe key: \nP")
5734 (gnus-article-check-buffer)
5735 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5737 (set-buffer gnus-article-current-summary)
5738 (let (gnus-pick-mode)
5739 (if (featurep 'xemacs)
5741 (push (elt key 0) unread-command-events)
5742 (setq key (events-to-keys
5743 (read-key-sequence "Describe key: "))))
5744 (setq unread-command-events
5746 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5747 (string-to-list key)))
5748 (setq key (read-key-sequence "Describe key: "))))
5749 (describe-key-briefly key insert))
5750 (describe-key-briefly key insert)))
5752 (defun gnus-article-reply-with-original (&optional wide)
5753 "Start composing a reply mail to the current message.
5754 The text in the region will be yanked. If the region isn't active,
5755 the entire article will be yanked."
5757 (let ((article (cdr gnus-article-current))
5759 (if (not (gnus-region-active-p))
5760 (with-current-buffer gnus-summary-buffer
5761 (gnus-summary-reply (list (list article)) wide))
5762 (setq contents (buffer-substring (point) (mark t)))
5763 ;; Deactivate active regions.
5764 (when (and (boundp 'transient-mark-mode)
5765 transient-mark-mode)
5766 (setq mark-active nil))
5767 (with-current-buffer gnus-summary-buffer
5769 (list (list article contents)) wide)))))
5771 (defun gnus-article-followup-with-original ()
5772 "Compose a followup to the current article.
5773 The text in the region will be yanked. If the region isn't active,
5774 the entire article will be yanked."
5776 (let ((article (cdr gnus-article-current))
5778 (if (not (gnus-region-active-p))
5779 (with-current-buffer gnus-summary-buffer
5780 (gnus-summary-followup (list (list article))))
5781 (setq contents (buffer-substring (point) (mark t)))
5782 ;; Deactivate active regions.
5783 (when (and (boundp 'transient-mark-mode)
5784 transient-mark-mode)
5785 (setq mark-active nil))
5786 (with-current-buffer gnus-summary-buffer
5787 (gnus-summary-followup
5788 (list (list article contents)))))))
5790 (defun gnus-article-hide (&optional arg force)
5791 "Hide all the gruft in the current article.
5792 This means that signatures, cited text and (some) headers will be
5794 If given a prefix, show the hidden text instead."
5795 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5796 (gnus-article-hide-headers arg)
5797 (gnus-article-hide-list-identifiers arg)
5798 (gnus-article-hide-citation-maybe arg force)
5799 (gnus-article-hide-signature arg))
5801 (defun gnus-article-maybe-highlight ()
5802 "Do some article highlighting if article highlighting is requested."
5803 (when (gnus-visual-p 'article-highlight 'highlight)
5804 (gnus-article-highlight-some)))
5806 (defun gnus-check-group-server ()
5807 ;; Make sure the connection to the server is alive.
5808 (unless (gnus-server-opened
5809 (gnus-find-method-for-group gnus-newsgroup-name))
5810 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5811 (gnus-request-group gnus-newsgroup-name t)))
5814 (autoload 'nneething-get-file-name "nneething"))
5816 (defun gnus-request-article-this-buffer (article group)
5817 "Get an article and insert it into this buffer."
5818 (let (do-update-line sparse-header)
5822 (gnus-kill-all-overlays)
5823 (setq group (or group gnus-newsgroup-name))
5825 ;; Using `gnus-request-article' directly will insert the article into
5826 ;; `nntp-server-buffer' - so we'll save some time by not having to
5827 ;; copy it from the server buffer into the article buffer.
5829 ;; We only request an article by message-id when we do not have the
5830 ;; headers for it, so we'll have to get those.
5831 (when (stringp article)
5832 (gnus-read-header article))
5834 ;; If the article number is negative, that means that this article
5835 ;; doesn't belong in this newsgroup (possibly), so we find its
5836 ;; message-id and request it by id instead of number.
5837 (when (and (numberp article)
5839 (get-buffer gnus-summary-buffer)
5840 (gnus-buffer-exists-p gnus-summary-buffer))
5842 (set-buffer gnus-summary-buffer)
5843 (let ((header (gnus-summary-article-header article)))
5846 ((memq article gnus-newsgroup-sparse)
5847 ;; This is a sparse gap article.
5848 (setq do-update-line article)
5849 (setq article (mail-header-id header))
5850 (setq sparse-header (gnus-read-header article))
5851 (setq gnus-newsgroup-sparse
5852 (delq article gnus-newsgroup-sparse)))
5854 ;; It's a real article.
5855 (setq article (mail-header-id header)))
5857 ;; It is an extracted pseudo-article.
5858 (setq article 'pseudo)
5859 (gnus-request-pseudo-article header))))
5861 (let ((method (gnus-find-method-for-group
5862 gnus-newsgroup-name)))
5863 (when (and (eq (car method) 'nneething)
5865 (let ((dir (nneething-get-file-name
5866 (mail-header-id header))))
5867 (when (and (stringp dir)
5868 (file-directory-p dir))
5869 (setq article 'nneething)
5870 (gnus-group-enter-directory dir))))))))
5873 ;; Refuse to select canceled articles.
5874 ((and (numberp article)
5876 (get-buffer gnus-summary-buffer)
5877 (gnus-buffer-exists-p gnus-summary-buffer)
5878 (eq (cdr (with-current-buffer gnus-summary-buffer
5879 (assq article gnus-newsgroup-reads)))
5880 gnus-canceled-mark))
5882 ;; We first check `gnus-original-article-buffer'.
5883 ((and (get-buffer gnus-original-article-buffer)
5885 (with-current-buffer gnus-original-article-buffer
5886 (and (equal (car gnus-original-article) group)
5887 (eq (cdr gnus-original-article) article))))
5888 (insert-buffer-substring gnus-original-article-buffer)
5890 ;; Check the backlog.
5891 ((and gnus-keep-backlog
5892 (gnus-backlog-request-article group article (current-buffer)))
5894 ;; Check asynchronous pre-fetch.
5895 ((gnus-async-request-fetched-article group article (current-buffer))
5896 (gnus-async-prefetch-next group article gnus-summary-buffer)
5897 (when (and (numberp article) gnus-keep-backlog)
5898 (gnus-backlog-enter-article group article (current-buffer)))
5901 ((and gnus-use-cache
5903 (gnus-cache-request-article article group))
5905 ;; Check the agent cache.
5906 ((gnus-agent-request-article article group)
5908 ;; Get the article and put into the article buffer.
5909 ((or (stringp article)
5911 (let ((gnus-override-method gnus-override-method)
5912 (methods (and (stringp article)
5913 gnus-refer-article-method))
5914 (backend (car (gnus-find-method-for-group
5915 gnus-newsgroup-name)))
5917 (inhibit-read-only t))
5918 (if (or (not (listp methods))
5919 (and (symbolp (car methods))
5920 (assq (car methods) nnoo-definition-alist)))
5921 (setq methods (list methods)))
5922 (when (and (null gnus-override-method)
5924 (setq gnus-override-method (pop methods)))
5926 (when (eq gnus-override-method 'current)
5927 (setq gnus-override-method
5928 (with-current-buffer gnus-summary-buffer
5929 gnus-current-select-method)))
5931 (gnus-kill-all-overlays)
5932 (let ((gnus-newsgroup-name group))
5933 (gnus-check-group-server))
5935 ((gnus-request-article article group (current-buffer))
5936 (when (numberp article)
5937 (gnus-async-prefetch-next group article
5938 gnus-summary-buffer)
5939 (when gnus-keep-backlog
5940 (gnus-backlog-enter-article
5941 group article (current-buffer))))
5942 (setq result 'article))
5944 (setq gnus-override-method (pop methods)))
5945 ((not (string-match "^400 "
5946 (nnheader-get-report backend)))
5947 ;; If we get 400 server disconnect, reconnect and
5948 ;; retry; otherwise, assume the article has expired.
5949 (setq result 'done))))
5950 (and (eq result 'article) 'article)))
5954 ;; Associate this article with the current summary buffer.
5955 (setq gnus-article-current-summary gnus-summary-buffer)
5957 ;; Take the article from the original article buffer
5958 ;; and place it in the buffer it's supposed to be in.
5959 (when (and (get-buffer gnus-article-buffer)
5960 (equal (buffer-name (current-buffer))
5961 (buffer-name (get-buffer gnus-article-buffer))))
5963 (if (get-buffer gnus-original-article-buffer)
5964 (set-buffer gnus-original-article-buffer)
5965 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5966 (buffer-disable-undo)
5967 (setq major-mode 'gnus-original-article-mode)
5968 (setq buffer-read-only t))
5969 (let ((inhibit-read-only t))
5971 (insert-buffer-substring gnus-article-buffer))
5972 (setq gnus-original-article (cons group article)))
5975 (run-hooks 'gnus-article-decode-hook)
5976 ;; Mark article as decoded or not.
5977 (setq gnus-article-decoded-p gnus-article-decode-hook))
5979 ;; Update sparse articles.
5980 (when (and do-update-line
5981 (or (numberp article)
5983 (let ((buf (current-buffer)))
5984 (set-buffer gnus-summary-buffer)
5985 (gnus-summary-update-article do-update-line sparse-header)
5986 (gnus-summary-goto-subject do-update-line nil t)
5987 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5989 (set-buffer buf))))))
5995 (defcustom gnus-article-edit-mode-hook nil
5996 "Hook run in article edit mode buffers."
5997 :group 'gnus-article-various
6000 (defvar gnus-article-edit-done-function nil)
6002 (defvar gnus-article-edit-mode-map nil)
6004 ;; Should we be using derived.el for this?
6005 (unless gnus-article-edit-mode-map
6006 (setq gnus-article-edit-mode-map (make-keymap))
6007 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6009 (gnus-define-keys gnus-article-edit-mode-map
6010 "\C-c?" describe-mode
6011 "\C-c\C-c" gnus-article-edit-done
6012 "\C-c\C-k" gnus-article-edit-exit
6013 "\C-c\C-f\C-t" message-goto-to
6014 "\C-c\C-f\C-o" message-goto-from
6015 "\C-c\C-f\C-b" message-goto-bcc
6016 ;;"\C-c\C-f\C-w" message-goto-fcc
6017 "\C-c\C-f\C-c" message-goto-cc
6018 "\C-c\C-f\C-s" message-goto-subject
6019 "\C-c\C-f\C-r" message-goto-reply-to
6020 "\C-c\C-f\C-n" message-goto-newsgroups
6021 "\C-c\C-f\C-d" message-goto-distribution
6022 "\C-c\C-f\C-f" message-goto-followup-to
6023 "\C-c\C-f\C-m" message-goto-mail-followup-to
6024 "\C-c\C-f\C-k" message-goto-keywords
6025 "\C-c\C-f\C-u" message-goto-summary
6026 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6027 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6028 "\C-c\C-b" message-goto-body
6029 "\C-c\C-i" message-goto-signature
6031 "\C-c\C-t" message-insert-to
6032 "\C-c\C-n" message-insert-newsgroups
6033 "\C-c\C-o" message-sort-headers
6034 "\C-c\C-e" message-elide-region
6035 "\C-c\C-v" message-delete-not-region
6036 "\C-c\C-z" message-kill-to-signature
6037 "\M-\r" message-newline-and-reformat
6038 "\C-c\C-a" mml-attach-file
6039 "\C-a" message-beginning-of-line
6041 "\M-;" comment-region)
6043 (gnus-define-keys (gnus-article-edit-wash-map
6044 "\C-c\C-w" gnus-article-edit-mode-map)
6045 "f" gnus-article-edit-full-stops))
6048 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6050 ["Fetch To" message-insert-to t]
6051 ["Fetch Newsgroups" message-insert-newsgroups t]
6053 ["To" message-goto-to t]
6054 ["From" message-goto-from t]
6055 ["Subject" message-goto-subject t]
6056 ["Cc" message-goto-cc t]
6057 ["Reply-To" message-goto-reply-to t]
6058 ["Summary" message-goto-summary t]
6059 ["Keywords" message-goto-keywords t]
6060 ["Newsgroups" message-goto-newsgroups t]
6061 ["Followup-To" message-goto-followup-to t]
6062 ["Mail-Followup-To" message-goto-mail-followup-to t]
6063 ["Distribution" message-goto-distribution t]
6064 ["Body" message-goto-body t]
6065 ["Signature" message-goto-signature t]))
6067 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6068 "Major mode for editing articles.
6069 This is an extended text-mode.
6071 \\{gnus-article-edit-mode-map}"
6072 (make-local-variable 'gnus-article-edit-done-function)
6073 (make-local-variable 'gnus-prev-winconf)
6074 (set (make-local-variable 'font-lock-defaults)
6075 '(message-font-lock-keywords t))
6076 (set (make-local-variable 'mail-header-separator) "")
6077 (set (make-local-variable 'gnus-article-edit-mode) t)
6078 (easy-menu-add message-mode-field-menu message-mode-map)
6080 (setq buffer-read-only nil)
6081 (buffer-enable-undo)
6084 (defun gnus-article-edit (&optional force)
6085 "Edit the current article.
6086 This will have permanent effect only in mail groups.
6087 If FORCE is non-nil, allow editing of articles even in read-only
6090 (when (and (not force)
6091 (gnus-group-read-only-p))
6092 (error "The current newsgroup does not support article editing"))
6093 (gnus-article-date-original)
6094 (gnus-article-edit-article
6096 `(lambda (no-highlight)
6098 (gnus-summary-edit-article-done
6099 ,(or (mail-header-references gnus-current-headers) "")
6100 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6102 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6103 "Start editing the contents of the current article buffer."
6104 (let ((winconf (current-window-configuration)))
6105 (set-buffer gnus-article-buffer)
6106 (let ((message-auto-save-directory
6107 ;; Don't associate the article buffer with a draft file.
6109 (gnus-article-edit-mode))
6110 (funcall start-func)
6111 (set-buffer-modified-p nil)
6112 (gnus-configure-windows 'edit-article)
6113 (setq gnus-article-edit-done-function exit-func)
6114 (setq gnus-prev-winconf winconf)
6116 (gnus-message 6 "C-c C-c to end edits"))))
6118 (defun gnus-article-edit-done (&optional arg)
6119 "Update the article edits and exit."
6121 (let ((func gnus-article-edit-done-function)
6122 (buf (current-buffer))
6123 (start (window-start))
6125 (winconf gnus-prev-winconf))
6126 (widen) ;; Widen it in case that users narrowed the buffer.
6129 ;; The cache and backlog have to be flushed somewhat.
6130 (when gnus-keep-backlog
6131 (gnus-backlog-remove-article
6132 (car gnus-article-current) (cdr gnus-article-current)))
6133 ;; Flush original article as well.
6135 (when (get-buffer gnus-original-article-buffer)
6136 (set-buffer gnus-original-article-buffer)
6137 (setq gnus-original-article nil)))
6138 (when gnus-use-cache
6139 (gnus-cache-update-article
6140 (car gnus-article-current) (cdr gnus-article-current)))
6141 ;; We remove all text props from the article buffer.
6142 (kill-all-local-variables)
6143 (set-text-properties (point-min) (point-max) nil)
6145 (set-window-configuration winconf)
6147 (set-window-start (get-buffer-window buf) start)
6148 (set-window-point (get-buffer-window buf) (point)))
6149 (gnus-summary-show-article))
6151 (defun gnus-article-edit-exit ()
6152 "Exit the article editing without updating."
6154 (when (or (not (buffer-modified-p))
6155 (yes-or-no-p "Article modified; kill anyway? "))
6156 (let ((curbuf (current-buffer))
6158 (window-start (window-start)))
6160 (if (gnus-buffer-live-p gnus-original-article-buffer)
6161 (insert-buffer-substring gnus-original-article-buffer))
6162 (let ((winconf gnus-prev-winconf))
6163 (kill-all-local-variables)
6165 (set-window-configuration winconf)
6166 ;; Tippy-toe some to make sure that point remains where it was.
6167 (save-current-buffer
6169 (set-window-start (get-buffer-window (current-buffer)) window-start)
6171 (gnus-summary-show-article)))
6173 (defun gnus-article-edit-full-stops ()
6174 "Interactively repair spacing at end of sentences."
6177 (goto-char (point-min))
6178 (search-forward-regexp "^$" nil t)
6179 (let ((case-fold-search nil))
6180 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6183 ;;; Article highlights
6186 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6188 ;;; Internal Variables:
6190 (defcustom gnus-button-url-regexp
6191 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6192 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6193 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6194 "Regular expression that matches URLs."
6195 :group 'gnus-article-buttons
6198 (defcustom gnus-button-valid-fqdn-regexp
6199 message-valid-fqdn-regexp
6200 "Regular expression that matches a valid FQDN."
6202 :group 'gnus-article-buttons
6205 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6206 (defcustom gnus-button-valid-localpart-regexp
6207 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6208 "Regular expression that matches a localpart of mail addresses or MIDs."
6210 :group 'gnus-article-buttons
6213 (defcustom gnus-button-man-handler 'manual-entry
6214 "Function to use for displaying man pages.
6215 The function must take at least one argument with a string naming the
6218 :type '(choice (function-item :tag "Man" manual-entry)
6219 (function-item :tag "Woman" woman)
6220 (function :tag "Other"))
6221 :group 'gnus-article-buttons)
6223 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6224 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6225 If the default site is too slow, try to find a CTAN mirror, see
6226 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6227 the variable `gnus-button-handle-ctan'."
6229 :group 'gnus-article-buttons
6230 :link '(custom-manual "(gnus)Group Parameters")
6231 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6232 (const "http://tug.ctan.org/tex-archive/")
6233 (const "http://www.dante.de/CTAN/")
6234 (string :tag "Other")))
6236 (defcustom gnus-button-ctan-handler 'browse-url
6237 "Function to use for displaying CTAN links.
6238 The function must take one argument, the string naming the URL."
6240 :type '(choice (function-item :tag "Browse Url" browse-url)
6241 (function :tag "Other"))
6242 :group 'gnus-article-buttons)
6244 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6245 "Bogus strings removed from CTAN URLs."
6247 :group 'gnus-article-buttons
6248 :type '(choice (const "^/?tex-archive/\\|/")
6249 (regexp :tag "Other")))
6251 (defcustom gnus-button-ctan-directory-regexp
6253 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6254 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6255 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6256 "tds" "tools" "usergrps" "web") t)
6257 "Regular expression for ctan directories.
6258 It should match all directories in the top level of `gnus-ctan-url'."
6260 :group 'gnus-article-buttons
6263 (defcustom gnus-button-mid-or-mail-regexp
6264 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6265 gnus-button-valid-fqdn-regexp
6267 "Regular expression that matches a message ID or a mail address."
6269 :group 'gnus-article-buttons
6272 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6273 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6274 Strings like this can be either a message ID or a mail address. If it is one
6275 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6276 message ID or a mail address, respectively. If this variable is set to the
6277 symbol `ask', always query the user what do do. If it is a function, this
6278 function will be called with the string as it's only argument. The function
6279 must return `mid', `mail', `invalid' or `ask'."
6281 :group 'gnus-article-buttons
6282 :type '(choice (function-item :tag "Heuristic function"
6283 gnus-button-mid-or-mail-heuristic)
6288 (defcustom gnus-button-mid-or-mail-heuristic-alist
6289 '((-10.0 . ".+\\$.+@")
6292 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6293 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6294 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6295 (-1.0 . "^[^a-z]+@")
6297 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6298 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6299 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6300 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6303 (-1.0 . "^[0-9][0-9]")
6305 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6306 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6307 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6308 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6310 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6311 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6314 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6316 ;; compensation for TDMA dated mail addresses:
6317 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6319 (-20.0 . "\\.fsf@") ;; Gnus
6322 (-20.0 . "_-_") ;; Subject change in thread
6324 (-20.0 . "\\.ln@") ;; leafnode
6325 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6326 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6328 ;; (5.0 . "") ;; $local_part_len <= 7
6329 (10.0 . "^[^0-9]+@")
6330 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6331 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6334 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6336 (0.5 . "^[A-Z][a-z]")
6337 (0.5 . "^[A-Z][a-z][a-z]")
6338 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6339 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6340 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6342 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6343 address. The REGEXP is processed with `case-fold-search' set to nil."
6345 :group 'gnus-article-buttons
6346 :type '(repeat (cons (number :tag "Rate")
6347 (regexp :tag "Regexp"))))
6349 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6350 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6351 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6352 address, `ask' if unsure and `invalid' if the string is invalid."
6353 (let ((case-fold-search nil)
6354 (list gnus-button-mid-or-mail-heuristic-alist)
6355 (result 0) rate regexp lpartlen elem)
6357 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6358 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6359 ;; Certain special cases...
6362 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6363 "^[0-9]+\\.[0-9]+@compuserve\\|"
6364 "@public\\.gmane\\.org")
6366 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6367 (setq result 'mail))
6368 (when (string-match "@.*@\\| " mid-or-mail)
6369 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6370 (setq result 'invalid))
6371 ;; Nothing more to do, if result is not a number here...
6372 (when (numberp result)
6374 (setq elem (car list)
6378 (when (string-match regexp mid-or-mail)
6379 (setq result (+ result rate))
6381 9 "`%s' matched `%s', rate `%s', result `%s'."
6382 mid-or-mail regexp rate result)))
6383 (when (<= lpartlen 7)
6384 (setq result (+ result 5.0))
6385 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6386 mid-or-mail result))
6387 (when (>= lpartlen 12)
6388 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6390 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6391 ;; Long local part should contain realname if e-mail address,
6392 ;; too many digits: message-id.
6393 ;; $score -= 5.0 + 0.1 * $local_part_len;
6394 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6395 (setq result (+ result rate))
6397 9 "Many digits in `%s', rate `%s', result `%s'."
6398 mid-or-mail rate result))
6399 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6401 ;; Too few vowels [^aeiouy]{4,}.*\@
6402 (setq result (+ result -5.0))
6404 9 "Few vowels in `%s', rate `%s', result `%s'."
6405 mid-or-mail -5.0 result))
6407 (setq result (+ result 5.0))
6409 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6410 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6411 ;; Maybe we should make this a customizable alist: (condition . 'result)
6413 ((symbolp result) result)
6414 ;; Now convert number into proper results:
6415 ((< result -10.0) 'mid)
6416 ((> result 10.0) 'mail)
6419 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6420 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6421 (url-mid (concat "news" ":" mid-or-mail))
6422 (url-mailto (concat "mailto" ":" mid-or-mail)))
6423 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6424 (when (fboundp pref)
6426 ;; get rid of surrounding angles...
6428 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6429 (if (or (eq 'mid guessed) (eq 'mail guessed))
6433 (save-window-excursion
6434 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6437 (cond ((eq pref 'mid)
6438 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6439 (gnus-button-handle-news url-mid))
6441 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6442 (gnus-url-mailto url-mailto))
6443 (t (gnus-message 3 "Invalid string.")))))
6445 (defun gnus-button-handle-custom (fun arg)
6446 "Call function FUN on argument ARG.
6447 Both FUN and ARG are supposed to be strings. ARG will be passed
6448 as a symbol to FUN."
6449 (funcall (intern fun) (intern arg)))
6451 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6453 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6456 (defun gnus-button-handle-describe-function (url)
6457 "Call `describe-function' when pushing the corresponding URL button."
6460 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6462 (defun gnus-button-handle-describe-variable (url)
6463 "Call `describe-variable' when pushing the corresponding URL button."
6466 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6468 (defun gnus-button-handle-symbol (url)
6469 "Display help on variable or function.
6470 Calls `describe-variable' or `describe-function'."
6471 (let ((sym (intern url)))
6473 ((fboundp sym) (describe-function sym))
6474 ((boundp sym) (describe-variable sym))
6475 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6477 (defun gnus-button-handle-describe-key (url)
6478 "Call `describe-key' when pushing the corresponding URL button."
6480 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6481 (keys (ignore-errors (eval `(kbd ,key-string)))))
6484 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6486 (defun gnus-button-handle-apropos (url)
6487 "Call `apropos' when pushing the corresponding URL button."
6488 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6490 (defun gnus-button-handle-apropos-command (url)
6491 "Call `apropos' when pushing the corresponding URL button."
6493 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6495 (defun gnus-button-handle-apropos-variable (url)
6496 "Call `apropos' when pushing the corresponding URL button."
6498 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6499 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6501 (defun gnus-button-handle-apropos-documentation (url)
6502 "Call `apropos' when pushing the corresponding URL button."
6504 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6505 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6507 (defun gnus-button-handle-library (url)
6508 "Call `locate-library' when pushing the corresponding URL button."
6509 (gnus-message 9 "url=`%s'" url)
6510 (let* ((lib (locate-library url))
6511 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6513 (gnus-message 1 "Cannot locale library `%s'." url)
6514 (find-file-read-only file))))
6516 (defun gnus-button-handle-ctan (url)
6517 "Call `browse-url' when pushing a CTAN URL button."
6519 gnus-button-ctan-handler
6522 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6524 (defcustom gnus-button-tex-level 5
6525 "*Integer that says how many TeX-related buttons Gnus will show.
6526 The higher the number, the more buttons will appear and the more false
6527 positives are possible. Note that you can set this variable local to
6528 specific groups. Setting it higher in TeX groups is probably a good idea.
6529 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6530 how to set variables in specific groups."
6532 :group 'gnus-article-buttons
6533 :link '(custom-manual "(gnus)Group Parameters")
6536 (defcustom gnus-button-man-level 5
6537 "*Integer that says how many man-related buttons Gnus will show.
6538 The higher the number, the more buttons will appear and the more false
6539 positives are possible. Note that you can set this variable local to
6540 specific groups. Setting it higher in Unix groups is probably a good idea.
6541 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6542 how to set variables in specific groups."
6544 :group 'gnus-article-buttons
6545 :link '(custom-manual "(gnus)Group Parameters")
6548 (defcustom gnus-button-emacs-level 5
6549 "*Integer that says how many emacs-related buttons Gnus will show.
6550 The higher the number, the more buttons will appear and the more false
6551 positives are possible. Note that you can set this variable local to
6552 specific groups. Setting it higher in Emacs or Gnus related groups is
6553 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6554 `gnus-parameters' on how to set variables in specific groups."
6556 :group 'gnus-article-buttons
6557 :link '(custom-manual "(gnus)Group Parameters")
6560 (defcustom gnus-button-message-level 5
6561 "*Integer that says how many buttons for news or mail messages will appear.
6562 The higher the number, the more buttons will appear and the more false
6563 positives are possible."
6564 ;; mail addresses, MIDs, URLs for news, ...
6566 :group 'gnus-article-buttons
6569 (defcustom gnus-button-browse-level 5
6570 "*Integer that says how many buttons for browsing will appear.
6571 The higher the number, the more buttons will appear and the more false
6572 positives are possible."
6573 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6575 :group 'gnus-article-buttons
6578 (defcustom gnus-button-alist
6579 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6580 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6581 ((concat "\\b\\(nntp\\|news\\):\\("
6582 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6583 0 t gnus-button-handle-news 2)
6584 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6585 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6586 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6587 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6588 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6589 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6590 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6591 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6592 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6593 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6594 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6595 ;; RFC 2368 (The mailto URL scheme)
6596 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6597 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6598 ("\\bmailto:\\([^ \n\t]+\\)"
6599 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6601 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6602 gnus-button-ctan-directory-regexp
6603 "[^][>)!;:,'\n\t ]+\\)")
6604 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6605 ((concat "\\btex-archive/\\("
6606 gnus-button-ctan-directory-regexp
6607 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6608 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6611 gnus-button-ctan-directory-regexp
6612 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6613 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6614 ;; This is info (home-grown style) <info://foo/bar+baz>
6615 ("\\binfo://\\([^'\">\n\t ]+\\)"
6616 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6617 ;; Info GNOME style <info:foo#bar_baz>
6618 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6619 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6620 ;; Info KDE style <info:(foo)bar baz>
6621 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6622 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6623 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6624 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6625 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6626 ;; Info links like `C-h i d m CC Mode RET'
6627 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6629 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6630 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6631 ;; Emacs help commands
6632 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6633 ;; regexp doesn't match arguments containing ` '.
6634 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6635 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6636 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6637 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6638 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6639 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6640 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6641 ;; The following entries may lead to many false positives so don't enable
6642 ;; them by default (use a high button level).
6643 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6644 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6645 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6646 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6647 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6648 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6649 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6650 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6651 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6652 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6653 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6654 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6655 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6656 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6657 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6658 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6659 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6660 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6661 ;; Unlike the other regexps we really have to require quoting
6662 ;; here to determine where it ends.
6663 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6664 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6665 ("<URL: *\\([^<>]*\\)>"
6666 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6667 ;; RFC 2396 (2.4.3., delims) ...
6668 ("\"URL: *\\([^\"]*\\)\""
6669 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6670 ;; RFC 2396 (2.4.3., delims) ...
6671 ("\"URL: *\\([^\"]*\\)\""
6672 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6674 (gnus-button-url-regexp
6675 0 (>= gnus-button-browse-level 0) browse-url 0)
6677 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6678 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6679 gnus-button-handle-man 1)
6680 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6681 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6682 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6683 gnus-button-handle-man 1)
6684 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6685 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6686 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6687 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6688 ;; MID or mail: To avoid too many false positives we don't try to catch
6689 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6690 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6691 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6692 ;; so that non-ambiguous entries (see above) match first.
6693 (gnus-button-mid-or-mail-regexp
6694 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6695 "*Alist of regexps matching buttons in article bodies.
6697 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6698 REGEXP: is the string (case insensitive) matching text around the button (can
6699 also be Lisp expression evaluating to a string),
6700 BUTTON: is the number of the regexp grouping actually matching the button,
6701 FORM: is a Lisp expression which must eval to true for the button to
6703 CALLBACK: is the function to call when the user push this button, and each
6704 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6706 CALLBACK can also be a variable, in that case the value of that
6707 variable it the real callback function."
6708 :group 'gnus-article-buttons
6709 :type '(repeat (list (choice regexp variable sexp)
6710 (integer :tag "Button")
6712 (function :tag "Callback")
6715 (integer :tag "Regexp group")))))
6717 (defcustom gnus-header-button-alist
6718 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6719 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6720 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6721 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6722 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6723 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6724 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6725 0 (>= gnus-button-browse-level 0) browse-url 0)
6726 ("^Subject:" gnus-button-url-regexp
6727 0 (>= gnus-button-browse-level 0) browse-url 0)
6728 ("^[^:]+:" gnus-button-url-regexp
6729 0 (>= gnus-button-browse-level 0) browse-url 0)
6730 ("^OpenPGP:.*url=" gnus-button-url-regexp
6731 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6732 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6733 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6734 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6735 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6736 "*Alist of headers and regexps to match buttons in article heads.
6738 This alist is very similar to `gnus-button-alist', except that each
6739 alist has an additional HEADER element first in each entry:
6741 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6743 HEADER is a regexp to match a header. For a fuller explanation, see
6744 `gnus-button-alist'."
6745 :group 'gnus-article-buttons
6746 :group 'gnus-article-headers
6747 :type '(repeat (list (regexp :tag "Header")
6748 (choice regexp variable)
6749 (integer :tag "Button")
6751 (function :tag "Callback")
6754 (integer :tag "Regexp group")))))
6758 (defun gnus-article-push-button (event)
6759 "Check text under the mouse pointer for a callback function.
6760 If the text under the mouse pointer has a `gnus-callback' property,
6761 call it with the value of the `gnus-data' text property."
6763 (set-buffer (window-buffer (posn-window (event-start event))))
6764 (let* ((pos (posn-point (event-start event)))
6765 (data (get-text-property pos 'gnus-data))
6766 (fun (get-text-property pos 'gnus-callback)))
6769 (funcall fun data))))
6771 (defun gnus-article-press-button ()
6772 "Check text at point for a callback function.
6773 If the text at point has a `gnus-callback' property,
6774 call it with the value of the `gnus-data' text property."
6776 (let ((data (get-text-property (point) 'gnus-data))
6777 (fun (get-text-property (point) 'gnus-callback)))
6779 (funcall fun data))))
6781 (defun gnus-article-highlight (&optional force)
6782 "Highlight current article.
6783 This function calls `gnus-article-highlight-headers',
6784 `gnus-article-highlight-citation',
6785 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6786 do the highlighting. See the documentation for those functions."
6787 (interactive (list 'force))
6788 (gnus-article-highlight-headers)
6789 (gnus-article-highlight-citation force)
6790 (gnus-article-highlight-signature)
6791 (gnus-article-add-buttons force)
6792 (gnus-article-add-buttons-to-head))
6794 (defun gnus-article-highlight-some (&optional force)
6795 "Highlight current article.
6796 This function calls `gnus-article-highlight-headers',
6797 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6798 do the highlighting. See the documentation for those functions."
6799 (interactive (list 'force))
6800 (gnus-article-highlight-headers)
6801 (gnus-article-highlight-signature)
6802 (gnus-article-add-buttons))
6804 (defun gnus-article-highlight-headers ()
6805 "Highlight article headers as specified by `gnus-header-face-alist'."
6807 (gnus-with-article-headers
6808 (let (regexp header-face field-face from hpoints fpoints)
6809 (dolist (entry gnus-header-face-alist)
6810 (goto-char (point-min))
6811 (setq regexp (concat "^\\("
6812 (if (string-equal "" (nth 0 entry))
6816 header-face (nth 1 entry)
6817 field-face (nth 2 entry))
6818 (while (and (re-search-forward regexp nil t)
6822 (unless (search-forward ":" nil t)
6824 (when (and header-face
6825 (not (memq (point) hpoints)))
6826 (push (point) hpoints)
6827 (gnus-put-text-property from (point) 'face header-face))
6828 (when (and field-face
6829 (not (memq (setq from (point)) fpoints)))
6831 (if (re-search-forward "^[^ \t]" nil t)
6833 (goto-char (point-max)))
6834 (gnus-put-text-property from (point) 'face field-face)))))))
6836 (defun gnus-article-highlight-signature ()
6837 "Highlight the signature in an article.
6838 It does this by highlighting everything after
6839 `gnus-signature-separator' using the face `gnus-signature'."
6841 (gnus-with-article-buffer
6842 (let ((inhibit-point-motion-hooks t))
6844 (when (and gnus-signature-face
6845 (gnus-article-narrow-to-signature))
6846 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6847 'face gnus-signature-face)
6849 (gnus-article-search-signature)
6850 (let ((start (match-beginning 0))
6851 (end (set-marker (make-marker) (1+ (match-end 0)))))
6852 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6855 (defun gnus-button-in-region-p (b e prop)
6856 "Say whether PROP exists in the region."
6857 (text-property-not-all b e prop nil))
6859 (defun gnus-article-add-buttons (&optional force)
6860 "Find external references in the article and make buttons of them.
6861 \"External references\" are things like Message-IDs and URLs, as
6862 specified by `gnus-button-alist'."
6863 (interactive (list 'force))
6864 (gnus-with-article-buffer
6865 (let ((inhibit-point-motion-hooks t)
6866 (case-fold-search t)
6867 (alist gnus-button-alist)
6869 ;; Remove all old markers.
6870 (let (marker entry new-list)
6871 (while (setq marker (pop gnus-button-marker-list))
6872 (if (or (< marker (point-min)) (>= marker (point-max)))
6873 (push marker new-list)
6875 (when (setq entry (gnus-button-entry))
6876 (put-text-property (match-beginning (nth 1 entry))
6877 (match-end (nth 1 entry))
6878 'gnus-callback nil))
6879 (set-marker marker nil)))
6880 (setq gnus-button-marker-list new-list))
6881 ;; We skip the headers.
6884 (while (setq entry (pop alist))
6885 (setq regexp (eval (car entry)))
6887 (while (re-search-forward regexp nil t)
6888 (let* ((start (and entry (match-beginning (nth 1 entry))))
6889 (end (and entry (match-end (nth 1 entry))))
6890 (from (match-beginning 0)))
6891 (when (and (or (eq t (nth 2 entry))
6892 (eval (nth 2 entry)))
6893 (not (gnus-button-in-region-p
6894 start end 'gnus-callback)))
6895 ;; That optional form returned non-nil, so we add the
6897 (gnus-article-add-button
6898 start end 'gnus-button-push
6899 (car (push (set-marker (make-marker) from)
6900 gnus-button-marker-list))))))))))
6902 ;; Add buttons to the head of an article.
6903 (defun gnus-article-add-buttons-to-head ()
6904 "Add buttons to the head of the article."
6906 (gnus-with-article-headers
6908 (dolist (entry gnus-header-button-alist)
6909 ;; Each alist entry.
6910 (goto-char (point-min))
6911 (while (re-search-forward (car entry) nil t)
6912 ;; Each header matching the entry.
6913 (setq beg (match-beginning 0))
6914 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6915 (match-beginning 0))
6918 (while (re-search-forward (eval (nth 1 entry)) end t)
6919 ;; Each match within a header.
6920 (let* ((entry (cdr entry))
6921 (start (match-beginning (nth 1 entry)))
6922 (end (match-end (nth 1 entry)))
6923 (form (nth 2 entry)))
6924 (goto-char (match-end 0))
6926 (gnus-article-add-button
6927 start end (nth 3 entry)
6928 (buffer-substring (match-beginning (nth 4 entry))
6929 (match-end (nth 4 entry)))))))
6930 (goto-char end))))))
6932 ;;; External functions:
6934 (defun gnus-article-add-button (from to fun &optional data)
6935 "Create a button between FROM and TO with callback FUN and data DATA."
6936 (when gnus-article-button-face
6937 (gnus-overlay-put (gnus-make-overlay from to)
6938 'face gnus-article-button-face))
6939 (gnus-add-text-properties
6941 (nconc (and gnus-article-mouse-face
6942 (list gnus-mouse-face-prop gnus-article-mouse-face))
6943 (list 'gnus-callback fun)
6944 (and data (list 'gnus-data data))))
6945 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6946 :button-keymap gnus-widget-button-keymap))
6948 ;;; Internal functions:
6950 (defun gnus-article-set-globals ()
6951 (with-current-buffer gnus-summary-buffer
6952 (gnus-set-global-variables)))
6954 (defun gnus-signature-toggle (end)
6955 (gnus-with-article-buffer
6956 (let ((inhibit-point-motion-hooks t))
6957 (if (text-property-any end (point-max) 'article-type 'signature)
6959 (gnus-delete-wash-type 'signature)
6960 (gnus-remove-text-properties-when
6961 'article-type 'signature end (point-max)
6962 (cons 'article-type (cons 'signature
6963 gnus-hidden-properties))))
6964 (gnus-add-wash-type 'signature)
6965 (gnus-add-text-properties-when
6966 'article-type nil end (point-max)
6967 (cons 'article-type (cons 'signature
6968 gnus-hidden-properties)))))
6969 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6970 (gnus-set-mode-line 'article))))
6972 (defun gnus-button-entry ()
6973 ;; Return the first entry in `gnus-button-alist' matching this place.
6974 (let ((alist gnus-button-alist)
6977 (setq entry (pop alist))
6978 (if (looking-at (eval (car entry)))
6983 (defun gnus-button-push (marker)
6984 ;; Push button starting at MARKER.
6987 (let* ((entry (gnus-button-entry))
6988 (inhibit-point-motion-hooks t)
6990 (args (mapcar (lambda (group)
6991 (let ((string (match-string group)))
6992 (set-text-properties
6993 0 (length string) nil string)
7000 (fboundp (symbol-value fun)))
7001 (apply (symbol-value fun) args))
7003 (gnus-message 1 "You must define `%S' to use this button"
7004 (cons fun args)))))))
7006 (defun gnus-parse-news-url (url)
7007 (let (scheme server port group message-id articles)
7010 (goto-char (point-min))
7011 (when (looking-at "\\([A-Za-z]+\\):")
7012 (setq scheme (match-string 1))
7013 (goto-char (match-end 0)))
7014 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7015 (setq server (match-string 1))
7016 (setq port (if (stringp (match-string 3))
7017 (string-to-number (match-string 3))
7019 (goto-char (match-end 0)))
7022 ((looking-at "\\(.*@.*\\)")
7023 (setq message-id (match-string 1)))
7024 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7025 (setq group (match-string 1)
7026 articles (split-string (match-string 2) "-")))
7027 ((looking-at "\\([^/]+\\)/?")
7028 (setq group (match-string 1)))
7030 (error "Unknown news URL syntax"))))
7031 (list scheme server port group message-id articles)))
7033 (defun gnus-button-handle-news (url)
7035 (destructuring-bind (scheme server port group message-id articles)
7036 (gnus-parse-news-url url)
7040 (set-buffer gnus-summary-buffer)
7042 (let ((gnus-refer-article-method
7043 (nconc (list (list 'nntp server))
7044 gnus-refer-article-method))
7045 (nntp-port-number (or port "nntp")))
7046 (gnus-message 7 "Fetching %s with %s"
7047 message-id gnus-refer-article-method)
7048 (gnus-summary-refer-article message-id))
7049 (gnus-summary-refer-article message-id))))
7051 (gnus-button-fetch-group url)))))
7053 (defun gnus-button-handle-man (url)
7055 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7056 (when (eq gnus-button-man-handler 'woman)
7057 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7058 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7059 (funcall gnus-button-man-handler url))
7061 (defun gnus-button-handle-info-url (url)
7062 "Fetch an info URL."
7063 (setq url (mm-subst-char-in-string ?+ ?\ url))
7065 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7066 (gnus-info-find-node
7067 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7069 ")" (gnus-url-unhex-string (match-string 2 url)))))
7070 ((string-match "([^)\"]+)[^\"]+" url)
7072 (gnus-replace-in-string
7073 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7074 (gnus-info-find-node url))
7075 (t (error "Can't parse %s" url))))
7077 (defun gnus-button-handle-info-url-gnome (url)
7078 "Fetch GNOME style info URL."
7079 (setq url (mm-subst-char-in-string ?_ ?\ url))
7080 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7081 (gnus-info-find-node
7083 (gnus-url-unhex-string
7084 (match-string 1 url))
7086 (or (gnus-url-unhex-string
7087 (match-string 2 url))
7089 (error "Can't parse %s" url)))
7091 (defun gnus-button-handle-info-url-kde (url)
7092 "Fetch KDE style info URL."
7093 (gnus-info-find-node (gnus-url-unhex-string url)))
7095 (defun gnus-button-handle-info-keystrokes (url)
7096 "Call `info' when pushing the corresponding URL button."
7097 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7102 (defun gnus-button-openpgp (url)
7103 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7105 (mm-url-insert-file-contents-external url)
7106 (pgg-snarf-keys-region (point-min) (point-max))
7107 (pgg-display-output-buffer nil nil nil)))
7109 (defun gnus-button-message-id (message-id)
7111 (with-current-buffer gnus-summary-buffer
7112 (gnus-summary-refer-article message-id)))
7114 (defun gnus-button-fetch-group (address)
7115 "Fetch GROUP specified by ADDRESS."
7116 (if (not (string-match "[:/]" address))
7117 ;; This is just a simple group url.
7118 (gnus-group-read-ephemeral-group address gnus-select-method)
7121 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7123 (error "Can't parse %s" address)
7124 (gnus-group-read-ephemeral-group
7125 (match-string 4 address)
7126 `(nntp ,(match-string 1 address)
7127 (nntp-address ,(match-string 1 address))
7128 (nntp-port-number ,(if (match-end 3)
7129 (match-string 3 address)
7132 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7134 (defun gnus-url-parse-query-string (query &optional downcase)
7135 (let (retval pairs cur key val)
7136 (setq pairs (split-string query "&"))
7138 (setq cur (car pairs)
7140 (if (not (string-match "=" cur))
7142 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7143 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7145 (setq key (downcase key)))
7146 (setq cur (assoc key retval))
7148 (setcdr cur (cons val (cdr cur)))
7149 (setq retval (cons (list key val) retval)))))
7152 (defun gnus-url-mailto (url)
7153 ;; Send mail to someone
7154 (when (string-match "mailto:/*\\(.*\\)" url)
7155 (setq url (substring url (match-beginning 1) nil)))
7156 (let (to args subject func)
7157 (setq args (gnus-url-parse-query-string
7158 (if (string-match "^\\?" url)
7160 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7161 (concat "to=" (match-string 1 url) "&"
7162 (match-string 2 url))
7163 (concat "to=" url)))
7165 subject (cdr-safe (assoc "subject" args)))
7168 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7171 (message-position-on-field (caar args)))
7172 (insert (gnus-replace-in-string
7173 (mapconcat 'identity (reverse (cdar args)) ", ")
7175 (setq args (cdr args)))
7178 (message-goto-subject))))
7180 (defun gnus-button-embedded-url (address)
7181 "Activate ADDRESS with `browse-url'."
7182 (browse-url (gnus-strip-whitespace address)))
7184 ;;; Next/prev buttons in the article buffer.
7186 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7187 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7189 (defvar gnus-prev-page-map
7190 (let ((map (make-sparse-keymap)))
7191 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7192 (define-key map "\r" 'gnus-button-prev-page)
7195 (defvar gnus-next-page-map
7196 (let ((map (make-sparse-keymap)))
7197 (unless (>= emacs-major-version 21)
7198 ;; XEmacs doesn't care.
7199 (set-keymap-parent map gnus-article-mode-map))
7200 (define-key map gnus-mouse-2 'gnus-button-next-page)
7201 (define-key map "\r" 'gnus-button-next-page)
7204 (defun gnus-insert-prev-page-button ()
7206 (inhibit-read-only t))
7208 gnus-prev-page-line-format nil
7209 `(keymap ,gnus-prev-page-map
7211 gnus-callback gnus-article-button-prev-page
7212 article-type annotation))
7213 (widget-convert-button
7215 ;; Exclude a newline.
7218 :action 'gnus-button-prev-page
7219 :button-keymap gnus-prev-page-map)))
7221 (defun gnus-button-next-page (&optional args more-args)
7222 "Go to the next page."
7224 (let ((win (selected-window)))
7225 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7226 (gnus-article-next-page)
7227 (select-window win)))
7229 (defun gnus-button-prev-page (&optional args more-args)
7230 "Go to the prev page."
7232 (let ((win (selected-window)))
7233 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7234 (gnus-article-prev-page)
7235 (select-window win)))
7237 (defun gnus-insert-next-page-button ()
7239 (inhibit-read-only t))
7240 (gnus-eval-format gnus-next-page-line-format nil
7241 `(keymap ,gnus-next-page-map
7243 gnus-callback gnus-article-button-next-page
7244 article-type annotation))
7245 (widget-convert-button
7247 ;; Exclude a newline.
7250 :action 'gnus-button-next-page
7251 :button-keymap gnus-next-page-map)))
7253 (defun gnus-article-button-next-page (arg)
7254 "Go to the next page."
7256 (let ((win (selected-window)))
7257 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7258 (gnus-article-next-page)
7259 (select-window win)))
7261 (defun gnus-article-button-prev-page (arg)
7262 "Go to the prev page."
7264 (let ((win (selected-window)))
7265 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7266 (gnus-article-prev-page)
7267 (select-window win)))
7269 (defvar gnus-decode-header-methods
7270 '(mail-decode-encoded-word-region)
7271 "List of methods used to decode headers.
7273 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7274 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7275 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7276 whose names match REGEXP.
7279 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7280 mail-decode-encoded-word-region
7281 (\"chinese\" . rfc1843-decode-region))
7284 (defvar gnus-decode-header-methods-cache nil)
7286 (defun gnus-multi-decode-header (start end)
7287 "Apply the functions from `gnus-encoded-word-methods' that match."
7288 (unless (and gnus-decode-header-methods-cache
7289 (eq gnus-newsgroup-name
7290 (car gnus-decode-header-methods-cache)))
7291 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7294 (nconc gnus-decode-header-methods-cache (list x))
7295 (if (and gnus-newsgroup-name
7296 (string-match (car x) gnus-newsgroup-name))
7297 (nconc gnus-decode-header-methods-cache
7299 gnus-decode-header-methods))
7300 (let ((xlist gnus-decode-header-methods-cache))
7303 (narrow-to-region start end)
7305 (funcall (pop xlist) (point-min) (point-max))))))
7308 ;;; Treatment top-level handling.
7311 (defun gnus-treat-article (condition &optional part-number total-parts type)
7312 (let ((length (- (point-max) (point-min)))
7313 (alist gnus-treatment-function-alist)
7314 (article-goto-body-goes-to-point-min-p t)
7318 (let ((list gnus-article-treat-types))
7320 (when (string-match (pop list) type)
7321 (throw 'found t)))))))
7322 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7324 (gnus-run-hooks 'gnus-part-display-hook)
7325 (dolist (elem alist)
7328 (when (gnus-buffer-live-p gnus-summary-buffer)
7329 (set-buffer gnus-summary-buffer))
7330 (symbol-value (car elem))))
7331 (when (and (or (consp val)
7333 (gnus-treat-predicate val)
7334 (or (not (get (car elem) 'highlight))
7337 (funcall (cadr elem)))))))
7339 ;; Dynamic variables.
7341 (defvar part-number)
7342 (defvar total-parts)
7347 (defun gnus-treat-predicate (val)
7354 (stringp (car val)))
7355 (apply 'gnus-or (mapcar `(lambda (s)
7356 (string-match s ,(or gnus-newsgroup-name "")))
7359 (let ((pred (pop val)))
7362 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7364 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7366 (not (gnus-treat-predicate (car val))))
7368 (equal (car val) type))
7370 (error "%S is not a valid predicate" pred)))))
7378 (eq part-number total-parts))
7382 (error "%S is not a valid value" val))))
7384 (defun gnus-article-encrypt-body (protocol &optional n)
7385 "Encrypt the article body."
7388 (or gnus-article-encrypt-protocol
7389 (completing-read "Encrypt protocol: "
7390 gnus-article-encrypt-protocol-alist
7392 current-prefix-arg))
7393 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7395 (error "Can't find the encrypt protocol %s" protocol))
7396 (if (member gnus-newsgroup-name '("nndraft:delayed"
7399 (error "Can't encrypt the article in group %s"
7400 gnus-newsgroup-name))
7401 (gnus-summary-iterate n
7403 (set-buffer gnus-summary-buffer)
7404 (let ((mail-parse-charset gnus-newsgroup-charset)
7405 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7406 (summary-buffer gnus-summary-buffer)
7408 (gnus-set-global-variables)
7409 (when (gnus-group-read-only-p)
7410 (error "The current newsgroup does not support article encrypt"))
7411 (gnus-summary-show-article t)
7413 (or (mail-header-references gnus-current-headers) ""))
7414 (set-buffer gnus-article-buffer)
7415 (let* ((inhibit-read-only t)
7417 (mapcar (lambda (field)
7418 (and (save-restriction
7419 (message-narrow-to-head)
7420 (goto-char (point-min))
7421 (search-forward field nil t))
7423 (message-narrow-to-field)
7425 (delete-region (point-min) (point-max))
7427 '("Content-Type:" "Content-Transfer-Encoding:"
7428 "Content-Disposition:"))))
7429 (message-narrow-to-head)
7430 (message-remove-header "MIME-Version")
7431 (goto-char (point-max))
7432 (setq point (point))
7433 (insert (apply 'concat headers))
7435 (narrow-to-region point (point-max))
7436 (let ((message-options message-options))
7437 (message-options-set 'message-sender user-mail-address)
7438 (message-options-set 'message-recipients user-mail-address)
7439 (message-options-set 'message-sign-encrypt 'not)
7441 (goto-char (point-min))
7442 (insert "MIME-Version: 1.0\n")
7444 (gnus-summary-edit-article-done
7445 references nil summary-buffer t))
7446 (when gnus-keep-backlog
7447 (gnus-backlog-remove-article
7448 (car gnus-article-current) (cdr gnus-article-current)))
7450 (when (get-buffer gnus-original-article-buffer)
7451 (set-buffer gnus-original-article-buffer)
7452 (setq gnus-original-article nil)))
7453 (when gnus-use-cache
7454 (gnus-cache-update-article
7455 (car gnus-article-current) (cdr gnus-article-current))))))))
7457 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7458 "The following specs can be used:
7459 %t The security MIME type
7462 %D Details if button is pressed")
7464 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7465 "The following specs can be used:
7466 %t The security MIME type
7469 %D Details if button is pressed")
7471 (defvar gnus-mime-security-button-line-format-alist
7472 '((?t gnus-tmp-type ?s)
7473 (?i gnus-tmp-info ?s)
7474 (?d gnus-tmp-details ?s)
7475 (?D gnus-tmp-pressed-details ?s)))
7477 (defvar gnus-mime-security-button-commands
7478 '((gnus-article-press-button "\r" "Show Detail")
7482 (gnus-mime-security-save-part "o" "Save...")
7491 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7494 (defvar gnus-mime-security-button-map
7495 (let ((map (make-sparse-keymap)))
7496 (define-key map gnus-mouse-2 'gnus-article-push-button)
7497 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7498 (dolist (c gnus-mime-security-button-commands)
7499 (define-key map (cadr c) (car c)))
7503 gnus-mime-security-button-menu gnus-mime-security-button-map
7504 "Security button menu."
7508 (unless (eq (car c) 'undefined)
7509 (vector (caddr c) (car c) :enable t)))
7510 gnus-mime-security-button-commands))))
7512 (defun gnus-mime-security-button-menu (event prefix)
7513 "Construct a context-sensitive menu of security commands."
7514 (interactive "e\nP")
7515 (save-window-excursion
7516 (let ((pos (event-start event)))
7517 (select-window (posn-window pos))
7518 (goto-char (posn-point pos))
7519 (gnus-article-check-buffer)
7520 (popup-menu gnus-mime-security-button-menu nil prefix))))
7522 (defvar gnus-mime-security-details-buffer nil)
7524 (defvar gnus-mime-security-button-pressed nil)
7526 (defvar gnus-mime-security-show-details-inline t
7527 "If non-nil, show details in the article buffer.")
7529 (defun gnus-mime-security-verify-or-decrypt (handle)
7530 (mm-remove-parts (cdr handle))
7531 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7532 point (inhibit-read-only t))
7534 (goto-char (car region)))
7536 (narrow-to-region (point) (point))
7537 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7538 (let* ((mm-verify-option 'known)
7539 (mm-decrypt-option 'known)
7540 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7541 (unless (eq nparts (cdr handle))
7542 (mm-destroy-parts (cdr handle))
7543 (setcdr handle nparts))))
7544 (setq point (point))
7545 (gnus-mime-display-security handle)
7546 (goto-char (point-max)))
7548 (delete-region (point) (cdr region))
7549 (set-marker (car region) nil)
7550 (set-marker (cdr region) nil))
7553 (defun gnus-mime-security-show-details (handle)
7554 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7556 (gnus-message 5 "No details.")
7557 (if gnus-mime-security-show-details-inline
7558 (let ((gnus-mime-security-button-pressed
7559 (not (get-text-property (point) 'gnus-mime-details)))
7560 (gnus-mime-security-button-line-format
7561 (get-text-property (point) 'gnus-line-format))
7562 (inhibit-read-only t))
7564 (while (eq (get-text-property (point) 'gnus-line-format)
7565 gnus-mime-security-button-line-format)
7569 (narrow-to-region (point) (point))
7570 (gnus-insert-mime-security-button handle))
7571 (delete-region (point)
7572 (or (text-property-not-all
7575 gnus-mime-security-button-line-format)
7578 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7579 (with-current-buffer gnus-mime-security-details-buffer
7582 (setq gnus-mime-security-details-buffer
7583 (gnus-get-buffer-create "*MIME Security Details*")))
7584 (with-current-buffer gnus-mime-security-details-buffer
7586 (goto-char (point-min)))
7587 (pop-to-buffer gnus-mime-security-details-buffer)))))
7589 (defun gnus-mime-security-press-button (handle)
7591 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7592 (gnus-mime-security-show-details handle)
7593 (gnus-mime-security-verify-or-decrypt handle))))
7595 (defun gnus-insert-mime-security-button (handle &optional displayed)
7596 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7599 (or (nth 2 (assoc protocol mm-verify-function-alist))
7600 (nth 2 (assoc protocol mm-decrypt-function-alist))
7602 (if (equal (car handle) "multipart/signed")
7603 " Signed" " Encrypted")
7606 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7609 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7610 gnus-tmp-pressed-details
7612 (setq gnus-tmp-details
7613 (if gnus-tmp-details
7614 (concat "\n" gnus-tmp-details)
7616 (setq gnus-tmp-pressed-details
7617 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7622 gnus-mime-security-button-line-format
7623 gnus-mime-security-button-line-format-alist
7624 `(keymap ,gnus-mime-security-button-map
7625 gnus-callback gnus-mime-security-press-button
7626 gnus-line-format ,gnus-mime-security-button-line-format
7627 gnus-mime-details ,gnus-mime-security-button-pressed
7628 article-type annotation
7631 ;; Exclude a newline.
7634 (widget-convert-button
7637 :action 'gnus-widget-press-button
7638 :button-keymap gnus-mime-security-button-map
7640 (lambda (widget/window &optional overlay pos)
7641 ;; Needed to properly clear the message due to a bug in
7642 ;; wid-edit (XEmacs only).
7643 (when (boundp 'help-echo-owns-message)
7644 (setq help-echo-owns-message t))
7646 "%S: show detail; %S: more options"
7647 (aref gnus-mouse-2 0)
7648 (aref gnus-down-mouse-3 0))))))
7650 (defun gnus-mime-display-security (handle)
7652 (narrow-to-region (point) (point))
7653 (unless (gnus-unbuttonized-mime-type-p (car handle))
7654 (gnus-insert-mime-security-button handle))
7655 (gnus-mime-display-part (cadr handle))
7658 (unless (gnus-unbuttonized-mime-type-p (car handle))
7659 (let ((gnus-mime-security-button-line-format
7660 gnus-mime-security-button-end-line-format))
7661 (gnus-insert-mime-security-button handle)))
7662 (mm-set-handle-multipart-parameter
7664 (cons (set-marker (make-marker) (point-min))
7665 (set-marker (make-marker) (point-max))))))
7667 (defun gnus-mime-security-run-function (function)
7668 "Run FUNCTION with the security part under point."
7669 (gnus-article-check-buffer)
7670 (let ((data (get-text-property (point) 'gnus-data))
7672 (when (and (stringp (car-safe data))
7673 (setq buffer (mm-handle-multipart-original-buffer data))
7674 (setq handle (cadr data)))
7675 (if (bufferp (mm-handle-buffer handle))
7677 (setq handle (cons buffer (copy-sequence (cdr handle))))
7678 (mm-handle-set-undisplayer handle nil))
7679 (setq handle (mm-make-handle
7681 (mm-handle-multipart-ctl-parameter handle 'protocol)
7682 nil nil nil nil nil nil)))
7683 (funcall function handle))))
7685 (defun gnus-mime-security-save-part ()
7686 "Save the security part under point."
7688 (gnus-mime-security-run-function 'mm-save-part))
7690 (defun gnus-mime-security-pipe-part ()
7691 "Pipe the security part under point to a process."
7693 (gnus-mime-security-run-function 'mm-pipe-part))
7699 (run-hooks 'gnus-art-load-hook)
7701 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7702 ;;; gnus-art.el ends here