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 :type '(choice (const :tag "Don't delete" nil)
2622 (const :tag "Don't ask" t)
2623 (const :tag "Ask" ask)
2624 (const :tag "Ask for each file" file)))
2626 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2628 (defun gnus-article-browse-delete-temp-files (&optional how)
2629 "Delete temp-files created by `gnus-article-browse-html-parts'."
2630 (when (and gnus-article-browse-html-temp-list
2632 (setq how gnus-article-browse-delete-temp)))
2633 (when (and (eq how 'ask)
2635 "Delete all %s temporary HTML file(s)? "
2636 (length gnus-article-browse-html-temp-list)))
2638 (dolist (file gnus-article-browse-html-temp-list)
2639 (when (and (file-exists-p file)
2641 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2643 (format "Delete temporary HTML file `%s'? " file))))
2644 (delete-file file)))
2645 ;; Also remove file from the list when not deleted or if file doesn't
2647 (setq gnus-article-browse-html-temp-list nil))
2648 gnus-article-browse-html-temp-list)
2650 (defun gnus-article-browse-html-parts (list)
2651 "View all \"text/html\" parts from LIST.
2652 Recurse into multiparts."
2653 ;; Internal function used by `gnus-article-browse-html-article'.
2655 ;; Find and show the html-parts.
2656 (dolist (handle list)
2657 ;; If HTML, show it:
2658 (when (listp handle)
2659 (cond ((and (bufferp (car handle))
2660 (string-match "text/html" (car (mm-handle-type handle))))
2661 (let ((tmp-file (mm-make-temp-file
2662 ;; Do we need to care for 8.3 filenames?
2663 "mm-" nil ".html")))
2664 (mm-save-part-to-file handle tmp-file)
2665 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2666 (add-hook 'gnus-summary-prepare-exit-hook
2667 'gnus-article-browse-delete-temp-files)
2668 (add-hook 'gnus-exit-gnus-hook
2670 (gnus-article-browse-delete-temp-files t)))
2671 (browse-url tmp-file)
2673 ;; If multipart, recurse
2674 ((and (stringp (car handle))
2675 (string-match "^multipart/" (car handle))
2678 (gnus-article-browse-html-parts handle))))))))
2681 ;; TODO: Key binding
2682 (defun gnus-article-browse-html-article ()
2683 "View \"text/html\" parts of the current article with a WWW browser."
2685 (save-window-excursion
2686 ;; Open raw article and select the buffer
2687 (gnus-summary-show-article t)
2688 (gnus-summary-select-article-buffer)
2689 (let ((parts (mm-dissect-buffer t t)))
2690 ;; If singlepart, enforce a list.
2691 (when (and (bufferp (car parts))
2692 (stringp (car (mm-handle-type parts))))
2693 (setq parts (list parts)))
2695 (unless (gnus-article-browse-html-parts parts)
2696 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2697 (gnus-summary-show-article))))
2699 (defun article-hide-list-identifiers ()
2700 "Remove list identifies from the Subject header.
2701 The `gnus-list-identifiers' variable specifies what to do."
2703 (let ((inhibit-point-motion-hooks t)
2704 (regexp (if (consp gnus-list-identifiers)
2705 (mapconcat 'identity gnus-list-identifiers " *\\|")
2706 gnus-list-identifiers))
2707 (inhibit-read-only t))
2711 (article-narrow-to-head)
2712 (goto-char (point-min))
2713 (while (re-search-forward
2714 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2716 (delete-region (match-beginning 2) (match-end 0))
2717 (beginning-of-line))
2718 (when (re-search-forward
2719 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2720 (delete-region (match-beginning 1) (match-end 1))))))))
2722 (defun article-hide-pem (&optional arg)
2723 "Toggle hiding of any PEM headers and signatures in the current article.
2724 If given a negative prefix, always show; if given a positive prefix,
2726 (interactive (gnus-article-hidden-arg))
2727 (unless (gnus-article-check-hidden-text 'pem arg)
2729 (let ((inhibit-read-only t) end)
2730 (goto-char (point-min))
2731 ;; Hide the horrendously ugly "header".
2732 (when (and (search-forward
2733 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2735 (setq end (1+ (match-beginning 0))))
2736 (gnus-add-wash-type 'pem)
2737 (gnus-article-hide-text-type
2739 (if (search-forward "\n\n" nil t)
2743 ;; Hide the trailer as well
2744 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2746 (gnus-article-hide-text-type
2747 (match-beginning 0) (match-end 0) 'pem)))))))
2749 (defun article-strip-banner ()
2750 "Strip the banners specified by the `banner' group parameter and by
2751 `gnus-article-address-banner-alist'."
2755 (let ((inhibit-point-motion-hooks t))
2756 (when (gnus-parameter-banner gnus-newsgroup-name)
2757 (article-really-strip-banner
2758 (gnus-parameter-banner gnus-newsgroup-name)))
2759 (when gnus-article-address-banner-alist
2760 ;; Note that the From header is decoded here, so it is
2761 ;; required that the *-extract-address-components function
2762 ;; supports non-ASCII text.
2763 (let ((from (save-restriction
2765 (article-narrow-to-head)
2766 (mail-fetch-field "from"))))
2769 (cadr (funcall gnus-extract-address-components
2772 (dolist (pair gnus-article-address-banner-alist)
2773 (when (string-match (car pair) from)
2775 (article-really-strip-banner (cdr pair)))))))))))))
2777 (defun article-really-strip-banner (banner)
2778 "Strip the banner specified by the argument."
2781 (let ((inhibit-point-motion-hooks t)
2782 (gnus-signature-limit nil)
2783 (inhibit-read-only t))
2786 ((eq banner 'signature)
2787 (when (gnus-article-narrow-to-signature)
2790 (delete-region (point) (point-max))))
2792 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2793 (while (re-search-forward banner nil t)
2794 (delete-region (match-beginning 0) (match-end 0)))))
2796 (while (re-search-forward banner nil t)
2797 (delete-region (match-beginning 0) (match-end 0)))))))))
2799 (defun article-babel ()
2800 "Translate article using an online translation service."
2803 (gnus-with-article-buffer
2804 (when (article-goto-body)
2805 (let* ((start (point))
2807 (orig (buffer-substring start end))
2808 (trans (babel-as-string orig)))
2810 (narrow-to-region start end)
2811 (delete-region start end)
2814 (defun article-hide-signature (&optional arg)
2815 "Hide the signature in the current article.
2816 If given a negative prefix, always show; if given a positive prefix,
2818 (interactive (gnus-article-hidden-arg))
2819 (unless (gnus-article-check-hidden-text 'signature arg)
2822 (let ((inhibit-read-only t))
2823 (when (gnus-article-narrow-to-signature)
2824 (gnus-article-hide-text-type
2825 (point-min) (point-max) 'signature))))))
2826 (gnus-set-mode-line 'article))
2828 (defun article-strip-headers-in-body ()
2829 "Strip offensive headers from bodies."
2833 (let ((case-fold-search t))
2834 (when (looking-at "x-no-archive:")
2835 (gnus-delete-line)))))
2837 (defun article-strip-leading-blank-lines ()
2838 "Remove all blank lines from the beginning of the article."
2841 (let ((inhibit-point-motion-hooks t)
2842 (inhibit-read-only t))
2843 (when (article-goto-body)
2844 (while (and (not (eobp))
2845 (looking-at "[ \t]*$"))
2846 (gnus-delete-line))))))
2848 (defun article-narrow-to-head ()
2849 "Narrow the buffer to the head of the message.
2850 Point is left at the beginning of the narrowed-to region."
2852 (goto-char (point-min))
2853 (if (search-forward "\n\n" nil 1)
2856 (goto-char (point-min)))
2858 (defun article-goto-body ()
2859 "Place point at the start of the body."
2860 (goto-char (point-min))
2862 ;; This variable is only bound when dealing with separate
2864 (article-goto-body-goes-to-point-min-p
2866 ((search-forward "\n\n" nil t)
2869 (goto-char (point-max))
2872 (defun article-strip-multiple-blank-lines ()
2873 "Replace consecutive blank lines with one empty line."
2876 (let ((inhibit-point-motion-hooks t)
2877 (inhibit-read-only t))
2878 ;; First make all blank lines empty.
2880 (while (re-search-forward "^[ \t]+$" nil t)
2881 (unless (gnus-annotation-in-region-p
2882 (match-beginning 0) (match-end 0))
2883 (replace-match "" nil t)))
2884 ;; Then replace multiple empty lines with a single empty line.
2886 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2887 (unless (gnus-annotation-in-region-p
2888 (match-beginning 0) (match-end 0))
2889 (delete-region (match-beginning 1) (match-end 1)))))))
2891 (defun article-strip-leading-space ()
2892 "Remove all white space from the beginning of the lines in the article."
2895 (let ((inhibit-point-motion-hooks t)
2896 (inhibit-read-only t))
2898 (while (re-search-forward "^[ \t]+" nil t)
2899 (replace-match "" t t)))))
2901 (defun article-strip-trailing-space ()
2902 "Remove all white space from the end of the lines in the article."
2905 (let ((inhibit-point-motion-hooks t)
2906 (inhibit-read-only t))
2908 (while (re-search-forward "[ \t]+$" nil t)
2909 (replace-match "" t t)))))
2911 (defun article-strip-blank-lines ()
2912 "Strip leading, trailing and multiple blank lines."
2914 (article-strip-leading-blank-lines)
2915 (article-remove-trailing-blank-lines)
2916 (article-strip-multiple-blank-lines))
2918 (defun article-strip-all-blank-lines ()
2919 "Strip all blank lines."
2922 (let ((inhibit-point-motion-hooks t)
2923 (inhibit-read-only t))
2925 (while (re-search-forward "^[ \t]*\n" nil t)
2926 (replace-match "" t t)))))
2928 (defun gnus-article-narrow-to-signature ()
2929 "Narrow to the signature; return t if a signature is found, else nil."
2930 (let ((inhibit-point-motion-hooks t))
2931 (when (gnus-article-search-signature)
2933 ;; Check whether we have some limits to what we consider
2934 ;; to be a signature.
2935 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2936 (list gnus-signature-limit)))
2938 (while (setq limit (pop limits))
2939 (if (or (and (integerp limit)
2940 (< (- (point-max) (point)) limit))
2942 (< (count-lines (point) (point-max)) limit))
2943 (and (functionp limit)
2945 (and (stringp limit)
2946 (not (re-search-forward limit nil t))))
2947 () ; This limit did not succeed.
2951 (narrow-to-region (point) (point-max))
2954 (defun gnus-article-search-signature ()
2955 "Search the current buffer for the signature separator.
2956 Put point at the beginning of the signature separator."
2957 (let ((cur (point)))
2958 (goto-char (point-max))
2959 (if (if (stringp gnus-signature-separator)
2960 (re-search-backward gnus-signature-separator nil t)
2961 (let ((seps gnus-signature-separator))
2963 (not (re-search-backward (car seps) nil t)))
2970 (defun gnus-article-hidden-arg ()
2971 "Return the current prefix arg as a number, or 0 if no prefix."
2972 (list (if current-prefix-arg
2973 (prefix-numeric-value current-prefix-arg)
2976 (defun gnus-article-check-hidden-text (type arg)
2977 "Return nil if hiding is necessary.
2978 Arg can be nil or a number. nil and positive means hide, negative
2979 means show, 0 means toggle."
2982 (let ((hide (gnus-article-hidden-text-p type)))
2988 (gnus-article-show-hidden-text type)
2991 (if (eq hide 'hidden)
2993 (gnus-article-show-hidden-text type)
2997 (defun gnus-article-hidden-text-p (type)
2998 "Say whether the current buffer contains hidden text of type TYPE."
2999 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3001 (not (get-text-property pos 'invisible))
3002 (not (get-text-property pos 'dummy-invisible)))
3004 (text-property-any (1+ pos) (point-max) 'article-type type)))
3009 (defun gnus-article-show-hidden-text (type &optional dummy)
3010 "Show all hidden text of type TYPE.
3011 Originally it is hide instead of DUMMY."
3012 (let ((inhibit-read-only t)
3013 (inhibit-point-motion-hooks t))
3014 (gnus-remove-text-properties-when
3016 (point-min) (point-max)
3017 (cons 'article-type (cons type
3018 gnus-hidden-properties)))
3019 (gnus-delete-wash-type type)))
3021 (defconst article-time-units
3022 `((year . ,(* 365.25 24 60 60))
3023 (week . ,(* 7 24 60 60))
3024 (day . ,(* 24 60 60))
3028 "Mapping from time units to seconds.")
3030 (defun gnus-article-forward-header ()
3031 "Move point to the start of the next header.
3032 If the current header is a continuation header, this can be several
3037 (if (looking-at "[ \t]+[^ \t]")
3041 (defun article-date-ut (&optional type highlight)
3042 "Convert DATE date to universal time in the current article.
3043 If TYPE is `local', convert to local time; if it is `lapsed', output
3044 how much time has lapsed since DATE. For `lapsed', the value of
3045 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3046 should replace the \"Date:\" one, or should be added below it."
3047 (interactive (list 'ut t))
3048 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3049 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3053 (article-lapsed-timer
3057 (case-fold-search t)
3058 (inhibit-read-only t)
3059 (inhibit-point-motion-hooks t)
3060 pos date bface eface)
3064 (goto-char (point-min))
3065 (while (or (setq date (get-text-property (setq pos (point))
3067 (when (setq pos (next-single-property-change
3068 (point) 'original-date))
3069 (setq date (get-text-property pos 'original-date))
3071 (narrow-to-region pos (or (text-property-any pos (point-max)
3074 (goto-char (point-min))
3075 (when (re-search-forward tdate-regexp nil t)
3076 (setq bface (get-text-property (point-at-bol) 'face)
3077 eface (get-text-property (1- (point-at-eol)) 'face)))
3078 (goto-char (point-min))
3080 ;; Delete any old Date headers.
3081 (while (re-search-forward date-regexp nil t)
3083 (delete-region (point-at-bol) (progn
3084 (gnus-article-forward-header)
3086 (delete-region (point-at-bol) (progn
3087 (gnus-article-forward-header)
3090 (setq pos (point))))
3091 (when (and (not pos)
3092 (re-search-forward tdate-regexp nil t))
3094 (gnus-goto-char pos)
3095 (insert (article-make-date-line date (or type 'ut)))
3101 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3102 (put-text-property (match-beginning 1) (1+ (match-end 1))
3104 (put-text-property (match-beginning 2) (match-end 2)
3106 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3107 (goto-char (point-max))
3110 (defun article-make-date-line (date type)
3111 "Return a DATE line of TYPE."
3112 (unless (memq type '(local ut original user iso8601 lapsed english))
3113 (error "Unknown conversion type: %s" type))
3115 (let ((time (date-to-time date)))
3117 ;; Convert to the local timezone.
3119 (concat "Date: " (message-make-date time)))
3120 ;; Convert to Universal Time.
3125 (let* ((e (parse-time-string date))
3126 (tm (apply 'encode-time e))
3128 (ls (- (cadr tm) (car (current-time-zone time)))))
3129 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3130 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3134 ;; Get the original date from the article.
3135 ((eq type 'original)
3136 (concat "Date: " (if (string-match "\n+$" date)
3137 (substring date 0 (match-beginning 0))
3139 ;; Let the user define the format.
3141 (let ((format (or (condition-case nil
3142 (with-current-buffer gnus-summary-buffer
3143 gnus-article-time-format)
3145 gnus-article-time-format)))
3146 (if (functionp format)
3147 (funcall format time)
3148 (concat "Date: " (format-time-string format time)))))
3151 (let ((tz (car (current-time-zone time))))
3154 (format-time-string "%Y%m%dT%H%M%S" time)
3155 (format "%s%02d%02d"
3156 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3157 (/ (% (abs tz) 3600) 60)))))
3158 ;; Do an X-Sent lapsed format.
3160 ;; If the date is seriously mangled, the timezone functions are
3161 ;; liable to bug out, so we ignore all errors.
3162 (let* ((now (current-time))
3163 (real-time (subtract-time now time))
3164 (real-sec (and real-time
3165 (+ (* (float (car real-time)) 65536)
3167 (sec (and real-time (abs real-sec)))
3177 ;; This is a bit convoluted, but basically we go
3178 ;; through the time units for years, weeks, etc,
3179 ;; and divide things to see whether that results
3180 ;; in positive answers.
3183 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3184 ;; The (remaining) seconds are too few to
3185 ;; be divided into this time unit.
3187 ;; It's big enough, so we output it.
3188 (setq sec (- sec (* num (cdr unit))))
3190 (concat (if prev ", " "") (int-to-string
3192 " " (symbol-name (car unit))
3193 (if (> num 1) "s" ""))
3195 article-time-units "")
3196 ;; If dates are odd, then it might appear like the
3197 ;; article was sent in the future.
3200 " in the future"))))))
3201 ;; Display the date in proper English
3203 (let ((dtime (decode-time time)))
3206 (number-to-string (nth 3 dtime))
3207 (let ((digit (% (nth 3 dtime) 10)))
3209 ((memq (nth 3 dtime) '(11 12 13)) "th")
3215 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3217 (number-to-string (nth 5 dtime))
3219 (format "%02d" (nth 2 dtime))
3221 (format "%02d" (nth 1 dtime)))))))
3223 (format "Date: %s (from Gnus)" date))))
3225 (defun article-date-local (&optional highlight)
3226 "Convert the current article date to the local timezone."
3227 (interactive (list t))
3228 (article-date-ut 'local highlight))
3230 (defun article-date-english (&optional highlight)
3231 "Convert the current article date to something that is proper English."
3232 (interactive (list t))
3233 (article-date-ut 'english highlight))
3235 (defun article-date-original (&optional highlight)
3236 "Convert the current article date to what it was originally.
3237 This is only useful if you have used some other date conversion
3238 function and want to see what the date was before converting."
3239 (interactive (list t))
3240 (article-date-ut 'original highlight))
3242 (defun article-date-lapsed (&optional highlight)
3243 "Convert the current article date to time lapsed since it was sent."
3244 (interactive (list t))
3245 (article-date-ut 'lapsed highlight))
3247 (defun article-update-date-lapsed ()
3248 "Function to be run from a timer to update the lapsed time line."
3250 (let (deactivate-mark)
3255 (set-buffer (window-buffer w))
3256 (when (eq major-mode 'gnus-article-mode)
3257 (let ((mark (point-marker)))
3258 (goto-char (point-min))
3259 (when (re-search-forward "^X-Sent:" nil t)
3260 (article-date-lapsed t))
3261 (goto-char (marker-position mark))
3262 (move-marker mark nil))))
3265 (defun gnus-start-date-timer (&optional n)
3266 "Start a timer to update the X-Sent header in the article buffers.
3267 The numerical prefix says how frequently (in seconds) the function
3272 (gnus-stop-date-timer)
3273 (setq article-lapsed-timer
3274 (run-at-time 1 n 'article-update-date-lapsed)))
3276 (defun gnus-stop-date-timer ()
3277 "Stop the X-Sent timer."
3279 (when article-lapsed-timer
3280 (nnheader-cancel-timer article-lapsed-timer)
3281 (setq article-lapsed-timer nil)))
3283 (defun article-date-user (&optional highlight)
3284 "Convert the current article date to the user-defined format.
3285 This format is defined by the `gnus-article-time-format' variable."
3286 (interactive (list t))
3287 (article-date-ut 'user highlight))
3289 (defun article-date-iso8601 (&optional highlight)
3290 "Convert the current article date to ISO8601."
3291 (interactive (list t))
3292 (article-date-ut 'iso8601 highlight))
3294 (defmacro gnus-article-save-original-date (&rest forms)
3295 "Save the original date as a text property and evaluate FORMS."
3296 `(let* ((case-fold-search t)
3298 (goto-char (point-min))
3299 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3302 (date (when (and start
3303 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3305 (buffer-substring-no-properties start
3306 (match-beginning 0)))))
3307 (goto-char (point-max))
3308 (skip-chars-backward "\n")
3309 (put-text-property (point-min) (point) 'original-date date)
3311 (goto-char (point-max))
3312 (skip-chars-backward "\n")
3313 (put-text-property (point-min) (point) 'original-date date)))
3315 ;; (defun article-show-all ()
3316 ;; "Show all hidden text in the article buffer."
3319 ;; (let ((inhibit-read-only t))
3320 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3322 (defun article-remove-leading-whitespace ()
3323 "Remove excessive whitespace from all headers."
3327 (let ((inhibit-read-only t))
3328 (article-narrow-to-head)
3329 (goto-char (point-min))
3330 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3331 (delete-region (match-beginning 1) (match-end 1)))))))
3333 (defun article-emphasize (&optional arg)
3334 "Emphasize text according to `gnus-emphasis-alist'."
3335 (interactive (gnus-article-hidden-arg))
3336 (unless (gnus-article-check-hidden-text 'emphasis arg)
3340 (with-current-buffer gnus-summary-buffer
3341 gnus-article-emphasis-alist)
3343 gnus-emphasis-alist))
3344 (inhibit-read-only t)
3345 (props (append '(article-type emphasis)
3346 gnus-hidden-properties))
3347 regexp elem beg invisible visible face)
3350 (while (setq elem (pop alist))
3352 (setq regexp (car elem)
3353 invisible (nth 1 elem)
3354 visible (nth 2 elem)
3356 (while (re-search-forward regexp nil t)
3357 (when (and (match-beginning visible) (match-beginning invisible))
3358 (gnus-article-hide-text
3359 (match-beginning invisible) (match-end invisible) props)
3360 (gnus-article-unhide-text-type
3361 (match-beginning visible) (match-end visible) 'emphasis)
3362 (gnus-put-overlay-excluding-newlines
3363 (match-beginning visible) (match-end visible) 'face face)
3364 (gnus-add-wash-type 'emphasis)
3365 (goto-char (match-end invisible)))))))))
3367 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3368 "Setup newsgroup emphasis alist."
3369 (unless gnus-article-emphasis-alist
3370 (let ((name (and gnus-newsgroup-name
3371 (gnus-group-real-name gnus-newsgroup-name))))
3372 (make-local-variable 'gnus-article-emphasis-alist)
3373 (setq gnus-article-emphasis-alist
3375 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3376 (while (setq elem (pop alist))
3377 (when (and name (string-match (car elem) name))
3379 highlight (copy-sequence (cdr elem)))))
3381 (copy-sequence highlight-words)
3382 (if gnus-newsgroup-name
3383 (copy-sequence (gnus-group-find-parameter
3384 gnus-newsgroup-name 'highlight-words t)))
3385 gnus-emphasis-alist)))))
3388 (defvar gnus-summary-article-menu)
3389 (defvar gnus-summary-post-menu))
3391 ;;; Saving functions.
3393 (defun gnus-article-save (save-buffer file &optional num)
3394 "Save the currently selected article."
3395 (unless gnus-save-all-headers
3396 ;; Remove headers according to `gnus-saved-headers'.
3397 (let ((gnus-visible-headers
3398 (or gnus-saved-headers gnus-visible-headers))
3399 (gnus-article-buffer save-buffer))
3401 (set-buffer save-buffer)
3402 (article-hide-headers 1 t))))
3403 (save-window-excursion
3404 (if (not gnus-default-article-saver)
3405 (error "No default saver is defined")
3406 ;; !!! Magic! The saving functions all save
3407 ;; `gnus-save-article-buffer' (or so they think), but we
3408 ;; bind that variable to our save-buffer.
3409 (set-buffer gnus-article-buffer)
3410 (let* ((gnus-save-article-buffer save-buffer)
3413 ((not gnus-prompt-before-saving) 'default)
3414 ((eq gnus-prompt-before-saving 'always) nil)
3416 (gnus-number-of-articles-to-be-saved
3417 (when (eq gnus-prompt-before-saving t)
3419 (set-buffer gnus-article-current-summary)
3420 (funcall gnus-default-article-saver filename)))))
3422 (defun gnus-read-save-file-name (prompt &optional filename
3423 function group headers variable)
3425 (funcall function group headers (symbol-value variable)))
3430 ((eq filename 'default)
3436 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3439 (if (and gnus-number-of-articles-to-be-saved
3440 (> gnus-number-of-articles-to-be-saved 1))
3441 (format "these %d articles"
3442 gnus-number-of-articles-to-be-saved)
3445 ;; Let the split methods have their say.
3447 ;; No split name was found.
3450 (concat prompt " (default "
3451 (file-name-nondirectory default-name) "): ")
3452 (file-name-directory default-name)
3454 ;; A single group name is returned.
3455 ((stringp split-name)
3457 (funcall function split-name headers
3458 (symbol-value variable)))
3460 (concat prompt " (default "
3461 (file-name-nondirectory default-name) "): ")
3462 (file-name-directory default-name)
3464 ;; A single split name was found
3465 ((= 1 (length split-name))
3466 (let* ((name (expand-file-name
3468 gnus-article-save-directory))
3469 (dir (cond ((file-directory-p name)
3470 (file-name-as-directory name))
3471 ((file-exists-p name) name)
3472 (t gnus-article-save-directory))))
3474 (concat prompt " (default " name "): ")
3476 ;; A list of splits was found.
3478 (setq split-name (nreverse split-name))
3480 (let ((file-name-history
3481 (nconc split-name file-name-history)))
3485 (concat prompt " (`M-p' for defaults): ")
3486 gnus-article-save-directory
3488 gnus-article-save-directory)))
3489 (car (push result file-name-history)))))))
3490 ;; Create the directory.
3491 (gnus-make-directory (file-name-directory file))
3492 ;; If we have read a directory, we append the default file name.
3493 (when (file-directory-p file)
3494 (setq file (expand-file-name (file-name-nondirectory
3496 (file-name-as-directory file))))
3497 ;; Possibly translate some characters.
3498 (nnheader-translate-file-chars file))))))
3499 (gnus-make-directory (file-name-directory result))
3500 (set variable result)))
3502 (defun gnus-article-archive-name (group)
3503 "Return the first instance of an \"Archive-name\" in the current buffer."
3504 (let ((case-fold-search t))
3505 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3506 (nnheader-concat gnus-article-save-directory
3507 (match-string 1)))))
3509 (defun gnus-article-nndoc-name (group)
3510 "If GROUP is an nndoc group, return the name of the parent group."
3511 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3512 (gnus-group-get-parameter group 'save-article-group)))
3514 (defun gnus-summary-save-in-rmail (&optional filename)
3515 "Append this article to Rmail file.
3516 Optional argument FILENAME specifies file name.
3517 Directory to save to is default to `gnus-article-save-directory'."
3518 (setq filename (gnus-read-save-file-name
3519 "Save %s in rmail file" filename
3520 gnus-rmail-save-name gnus-newsgroup-name
3521 gnus-current-headers 'gnus-newsgroup-last-rmail))
3522 (gnus-eval-in-buffer-window gnus-save-article-buffer
3526 (gnus-output-to-rmail filename))))
3529 (defun gnus-summary-save-in-mail (&optional filename)
3530 "Append this article to Unix mail file.
3531 Optional argument FILENAME specifies file name.
3532 Directory to save to is default to `gnus-article-save-directory'."
3533 (setq filename (gnus-read-save-file-name
3534 "Save %s in Unix mail file" filename
3535 gnus-mail-save-name gnus-newsgroup-name
3536 gnus-current-headers 'gnus-newsgroup-last-mail))
3537 (gnus-eval-in-buffer-window gnus-save-article-buffer
3541 (if (and (file-readable-p filename)
3542 (file-regular-p filename)
3543 (mail-file-babyl-p filename))
3544 (rmail-output-to-rmail-file filename t)
3545 (gnus-output-to-mail filename)))))
3548 (defun gnus-summary-save-in-file (&optional filename overwrite)
3549 "Append this article to file.
3550 Optional argument FILENAME specifies file name.
3551 Directory to save to is default to `gnus-article-save-directory'."
3552 (setq filename (gnus-read-save-file-name
3553 "Save %s in file" filename
3554 gnus-file-save-name gnus-newsgroup-name
3555 gnus-current-headers 'gnus-newsgroup-last-file))
3556 (gnus-eval-in-buffer-window gnus-save-article-buffer
3560 (when (and overwrite
3561 (file-exists-p filename))
3562 (delete-file filename))
3563 (gnus-output-to-file filename))))
3566 (defun gnus-summary-write-to-file (&optional filename)
3567 "Write this article to a file, overwriting it if the file exists.
3568 Optional argument FILENAME specifies file name.
3569 The directory to save in defaults to `gnus-article-save-directory'."
3570 (gnus-summary-save-in-file nil t))
3572 (defun gnus-summary-save-body-in-file (&optional filename)
3573 "Append this article body to a file.
3574 Optional argument FILENAME specifies file name.
3575 The directory to save in defaults to `gnus-article-save-directory'."
3576 (setq filename (gnus-read-save-file-name
3577 "Save %s body in file" filename
3578 gnus-file-save-name gnus-newsgroup-name
3579 gnus-current-headers 'gnus-newsgroup-last-file))
3580 (gnus-eval-in-buffer-window gnus-save-article-buffer
3584 (when (article-goto-body)
3585 (narrow-to-region (point) (point-max)))
3586 (gnus-output-to-file filename))))
3589 (defun gnus-summary-save-in-pipe (&optional command)
3590 "Pipe this article to subprocess."
3592 (cond ((and (eq command 'default)
3593 gnus-last-shell-command)
3594 gnus-last-shell-command)
3599 "Shell command on %s: "
3600 (if (and gnus-number-of-articles-to-be-saved
3601 (> gnus-number-of-articles-to-be-saved 1))
3602 (format "these %d articles"
3603 gnus-number-of-articles-to-be-saved)
3605 gnus-last-shell-command))))
3606 (when (string-equal command "")
3607 (if gnus-last-shell-command
3608 (setq command gnus-last-shell-command)
3609 (error "A command is required")))
3610 (gnus-eval-in-buffer-window gnus-article-buffer
3613 (shell-command-on-region (point-min) (point-max) command nil)))
3614 (setq gnus-last-shell-command command))
3616 (defun gnus-summary-pipe-to-muttprint (&optional command)
3617 "Pipe this article to muttprint."
3618 (setq command (read-string
3619 "Print using command: " gnus-summary-muttprint-program
3620 nil gnus-summary-muttprint-program))
3621 (gnus-summary-save-in-pipe command))
3623 ;;; Article file names when saving.
3625 (defun gnus-capitalize-newsgroup (newsgroup)
3626 "Capitalize NEWSGROUP name."
3627 (when (not (zerop (length newsgroup)))
3628 (concat (char-to-string (upcase (aref newsgroup 0)))
3629 (substring newsgroup 1))))
3631 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3632 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3633 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3634 Otherwise, it is like ~/News/news/group/num."
3637 (concat (if (gnus-use-long-file-name 'not-save)
3638 (gnus-capitalize-newsgroup newsgroup)
3639 (gnus-newsgroup-directory-form newsgroup))
3640 "/" (int-to-string (mail-header-number headers)))
3641 gnus-article-save-directory)))
3643 (string-equal (file-name-directory default)
3644 (file-name-directory last-file))
3645 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3647 (or last-file default))))
3649 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3650 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3651 If variable `gnus-use-long-file-name' is non-nil, it is
3652 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3655 (concat (if (gnus-use-long-file-name 'not-save)
3657 (gnus-newsgroup-directory-form newsgroup))
3658 "/" (int-to-string (mail-header-number headers)))
3659 gnus-article-save-directory)))
3661 (string-equal (file-name-directory default)
3662 (file-name-directory last-file))
3663 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3665 (or last-file default))))
3667 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3668 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3669 If variable `gnus-use-long-file-name' is non-nil, it is
3670 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3673 (if (gnus-use-long-file-name 'not-save)
3676 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3678 gnus-article-save-directory)))
3680 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3681 "Generate file name from sender."
3682 (let ((from (mail-header-from headers)))
3684 (if (and from (string-match "\\([^ <]+\\)@" from))
3685 (match-string 1 from)
3687 gnus-article-save-directory)))
3689 (defun article-verify-x-pgp-sig ()
3692 (if (gnus-buffer-live-p gnus-original-article-buffer)
3693 (let ((sig (with-current-buffer gnus-original-article-buffer
3694 (gnus-fetch-field "X-PGP-Sig")))
3698 (mml2015-clear-verify-function))
3700 (insert-buffer-substring gnus-original-article-buffer)
3701 (setq items (split-string sig))
3702 (message-narrow-to-head)
3703 (let ((inhibit-point-motion-hooks t)
3704 (case-fold-search t))
3705 ;; Don't verify multiple headers.
3706 (setq headers (mapconcat (lambda (header)
3708 (mail-fetch-field header)
3710 (split-string (nth 1 items) ",") "")))
3711 (delete-region (point-min) (point-max))
3712 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3713 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3718 (if (looking-at "^-")
3721 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3722 (insert "Version: " (car items) "\n\n")
3723 (insert (mapconcat 'identity (cddr items) "\n"))
3724 (insert "\n-----END PGP SIGNATURE-----\n")
3725 (let ((mm-security-handle (list (format "multipart/signed"))))
3726 (mml2015-clean-buffer)
3727 (let ((coding-system-for-write (or gnus-newsgroup-charset
3729 (funcall (mml2015-clear-verify-function)))
3731 (or (mm-handle-multipart-ctl-parameter
3732 mm-security-handle 'gnus-details)
3733 (mm-handle-multipart-ctl-parameter
3734 mm-security-handle 'gnus-info)))))
3736 (let ((inhibit-read-only t) bface eface)
3738 (message-narrow-to-head)
3739 (goto-char (point-max))
3741 (setq bface (get-text-property (point-at-bol) 'face)
3742 eface (get-text-property (1- (point-at-eol)) 'face))
3743 (message-remove-header "X-Gnus-PGP-Verify")
3744 (if (re-search-forward "^X-PGP-Sig:" nil t)
3746 (goto-char (point-max)))
3747 (narrow-to-region (point) (point))
3748 (insert "X-Gnus-PGP-Verify: " info "\n")
3749 (goto-char (point-min))
3752 (if (not (looking-at "^[ \t]"))
3756 (goto-char (point-min))
3757 (when (looking-at "\\([^:]+\\): *")
3758 (put-text-property (match-beginning 1) (1+ (match-end 1))
3760 (put-text-property (match-end 0) (point-max)
3761 'face eface)))))))))
3763 (defun article-verify-cancel-lock ()
3764 "Verify Cancel-Lock header."
3766 (if (gnus-buffer-live-p gnus-original-article-buffer)
3767 (canlock-verify gnus-original-article-buffer)))
3774 (setq afunc (car func)
3777 gfunc (intern (format "gnus-%s" func))))
3779 (when (fboundp afunc)
3780 `(lambda (&optional interactive &rest args)
3781 ,(documentation afunc t)
3782 (interactive (list t))
3784 (set-buffer gnus-article-buffer)
3786 (call-interactively ',afunc)
3787 (apply ',afunc args))))))))
3788 '(article-hide-headers
3789 article-verify-x-pgp-sig
3790 article-verify-cancel-lock
3791 article-hide-boring-headers
3792 article-treat-overstrike
3793 article-treat-ansi-sequences
3794 article-fill-long-lines
3795 article-capitalize-sentences
3797 article-remove-leading-whitespace
3798 article-display-x-face
3799 article-display-face
3800 article-de-quoted-unreadable
3801 article-de-base64-unreadable
3804 article-unsplit-urls
3805 article-hide-list-identifiers
3806 article-strip-banner
3809 article-hide-signature
3810 article-strip-headers-in-body
3811 article-remove-trailing-blank-lines
3812 article-strip-leading-blank-lines
3813 article-strip-multiple-blank-lines
3814 article-strip-leading-space
3815 article-strip-trailing-space
3816 article-strip-blank-lines
3817 article-strip-all-blank-lines
3819 article-date-english
3820 article-date-iso8601
3821 article-date-original
3823 article-decode-mime-words
3824 article-decode-charset
3825 article-decode-encoded-words
3829 article-treat-dumbquotes
3830 article-normalize-headers
3831 ;; (article-show-all . gnus-article-show-all-headers)
3835 ;;; Gnus article mode
3838 (put 'gnus-article-mode 'mode-class 'special)
3840 (set-keymap-parent gnus-article-mode-map widget-keymap)
3842 (gnus-define-keys gnus-article-mode-map
3843 " " gnus-article-goto-next-page
3844 "\177" gnus-article-goto-prev-page
3845 [delete] gnus-article-goto-prev-page
3846 [backspace] gnus-article-goto-prev-page
3847 "\C-c^" gnus-article-refer-article
3848 "h" gnus-article-show-summary
3849 "s" gnus-article-show-summary
3850 "\C-c\C-m" gnus-article-mail
3851 "?" gnus-article-describe-briefly
3852 "e" gnus-summary-edit-article
3853 "<" beginning-of-buffer
3855 "\C-c\C-i" gnus-info-find-node
3857 "R" gnus-article-reply-with-original
3858 "F" gnus-article-followup-with-original
3859 "\C-hk" gnus-article-describe-key
3860 "\C-hc" gnus-article-describe-key-briefly
3862 "\C-d" gnus-article-read-summary-keys
3863 "\M-*" gnus-article-read-summary-keys
3864 "\M-#" gnus-article-read-summary-keys
3865 "\M-^" gnus-article-read-summary-keys
3866 "\M-g" gnus-article-read-summary-keys)
3868 (substitute-key-definition
3869 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3871 (defun gnus-article-make-menu-bar ()
3872 (unless (boundp 'gnus-article-commands-menu)
3873 (gnus-summary-make-menu-bar))
3874 (gnus-turn-off-edit-menu 'article)
3875 (unless (boundp 'gnus-article-article-menu)
3877 gnus-article-article-menu gnus-article-mode-map ""
3879 ["Scroll forwards" gnus-article-goto-next-page t]
3880 ["Scroll backwards" gnus-article-goto-prev-page t]
3881 ["Show summary" gnus-article-show-summary t]
3882 ["Fetch Message-ID at point" gnus-article-refer-article t]
3883 ["Mail to address at point" gnus-article-mail t]
3884 ["Send a bug report" gnus-bug t]))
3887 gnus-article-treatment-menu gnus-article-mode-map ""
3888 ;; Fixme: this should use :active (and maybe :visible).
3890 ["Hide headers" gnus-article-hide-headers t]
3891 ["Hide signature" gnus-article-hide-signature t]
3892 ["Hide citation" gnus-article-hide-citation t]
3893 ["Treat overstrike" gnus-article-treat-overstrike t]
3894 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3895 ["Remove carriage return" gnus-article-remove-cr t]
3896 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3897 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3898 ["Remove base64" gnus-article-de-base64-unreadable t]
3899 ["Treat html" gnus-article-wash-html t]
3900 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3901 ["Decode HZ" gnus-article-decode-HZ t]))
3903 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3905 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3907 (gnus-run-hooks 'gnus-article-menu-hook)))
3909 (defun gnus-article-mode ()
3910 "Major mode for displaying an article.
3912 All normal editing commands are switched off.
3914 The following commands are available in addition to all summary mode
3916 \\<gnus-article-mode-map>
3917 \\[gnus-article-next-page]\t Scroll the article one page forwards
3918 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3919 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3920 \\[gnus-article-show-summary]\t Display the summary buffer
3921 \\[gnus-article-mail]\t Send a reply to the address near point
3922 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3923 \\[gnus-info-find-node]\t Go to the Gnus info node"
3925 (kill-all-local-variables)
3926 (gnus-simplify-mode-line)
3927 (setq mode-name "Article")
3928 (setq major-mode 'gnus-article-mode)
3929 (make-local-variable 'minor-mode-alist)
3930 (use-local-map gnus-article-mode-map)
3931 (when (gnus-visual-p 'article-menu 'menu)
3932 (gnus-article-make-menu-bar)
3933 (when gnus-summary-tool-bar-map
3934 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3935 (gnus-update-format-specifications nil 'article-mode)
3936 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3937 (set (make-local-variable 'gnus-page-broken) nil)
3938 (make-local-variable 'gnus-button-marker-list)
3939 (make-local-variable 'gnus-article-current-summary)
3940 (make-local-variable 'gnus-article-mime-handles)
3941 (make-local-variable 'gnus-article-decoded-p)
3942 (make-local-variable 'gnus-article-mime-handle-alist)
3943 (make-local-variable 'gnus-article-wash-types)
3944 (make-local-variable 'gnus-article-image-alist)
3945 (make-local-variable 'gnus-article-charset)
3946 (make-local-variable 'gnus-article-ignored-charsets)
3947 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3948 (set (make-local-variable 'nobreak-char-display) nil)
3949 (gnus-set-default-directory)
3950 (buffer-disable-undo)
3951 (setq buffer-read-only t
3952 show-trailing-whitespace nil)
3953 (set-syntax-table gnus-article-mode-syntax-table)
3954 (mm-enable-multibyte)
3955 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3957 (defun gnus-article-setup-buffer ()
3958 "Initialize the article buffer."
3959 (let* ((name (if gnus-single-article-buffer "*Article*"
3960 (concat "*Article " gnus-newsgroup-name "*")))
3962 (progn (string-match "\\*Article" name)
3963 (concat " *Original Article"
3964 (substring name (match-end 0))))))
3965 (setq gnus-article-buffer name)
3966 (setq gnus-original-article-buffer original)
3967 (setq gnus-article-mime-handle-alist nil)
3968 ;; This might be a variable local to the summary buffer.
3969 (unless gnus-single-article-buffer
3971 (set-buffer gnus-summary-buffer)
3972 (setq gnus-article-buffer name)
3973 (setq gnus-original-article-buffer original)
3974 (gnus-set-global-variables)))
3975 (gnus-article-setup-highlight-words)
3976 ;; Init original article buffer.
3978 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3979 (mm-enable-multibyte)
3980 (setq major-mode 'gnus-original-article-mode)
3981 (make-local-variable 'gnus-original-article))
3982 (if (and (get-buffer name)
3983 (with-current-buffer name
3984 (if gnus-article-edit-mode
3985 (if (y-or-n-p "Article mode edit in progress; discard? ")
3987 (set-buffer-modified-p nil)
3988 (gnus-kill-buffer name)
3991 (error "Action aborted"))
3995 (set (make-local-variable 'gnus-article-edit-mode) nil)
3996 (when gnus-article-mime-handles
3997 (mm-destroy-parts gnus-article-mime-handles)
3998 (setq gnus-article-mime-handles nil))
3999 ;; Set it to nil in article-buffer!
4000 (setq gnus-article-mime-handle-alist nil)
4001 (buffer-disable-undo)
4002 (setq buffer-read-only t)
4003 ;; This list just keeps growing if we don't reset it.
4004 (setq gnus-button-marker-list nil)
4005 (unless (eq major-mode 'gnus-article-mode)
4006 (gnus-article-mode))
4009 (set-buffer (gnus-get-buffer-create name))
4011 (make-local-variable 'gnus-summary-buffer)
4012 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4013 (current-buffer)))))
4015 ;; Set article window start at LINE, where LINE is the number of lines
4016 ;; from the head of the article.
4017 (defun gnus-article-set-window-start (&optional line)
4019 (gnus-get-buffer-window gnus-article-buffer t)
4021 (set-buffer gnus-article-buffer)
4022 (goto-char (point-min))
4025 (gnus-message 6 "Moved to bookmark")
4026 (search-forward "\n\n" nil t)
4030 (defun gnus-article-prepare (article &optional all-headers header)
4031 "Prepare ARTICLE in article mode buffer.
4032 ARTICLE should either be an article number or a Message-ID.
4033 If ARTICLE is an id, HEADER should be the article headers.
4034 If ALL-HEADERS is non-nil, no headers are hidden."
4036 ;; Make sure we start in a summary buffer.
4037 (unless (eq major-mode 'gnus-summary-mode)
4038 (set-buffer gnus-summary-buffer))
4039 (setq gnus-summary-buffer (current-buffer))
4040 (let* ((gnus-article (if header (mail-header-number header) article))
4041 (summary-buffer (current-buffer))
4042 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4043 (group gnus-newsgroup-name)
4046 (gnus-article-setup-buffer)
4047 (set-buffer gnus-article-buffer)
4048 ;; Deactivate active regions.
4049 (when (and (boundp 'transient-mark-mode)
4050 transient-mark-mode)
4051 (setq mark-active nil))
4052 (if (not (setq result (let ((inhibit-read-only t))
4053 (gnus-request-article-this-buffer
4055 ;; There is no such article.
4057 (when (and (numberp article)
4058 (not (memq article gnus-newsgroup-sparse)))
4059 (setq gnus-article-current
4060 (cons gnus-newsgroup-name article))
4061 (set-buffer gnus-summary-buffer)
4062 (setq gnus-current-article article)
4063 (if (and (memq article gnus-newsgroup-undownloaded)
4064 (not (gnus-online (gnus-find-method-for-group
4065 gnus-newsgroup-name))))
4067 (gnus-summary-set-agent-mark article)
4068 (message "Message marked for downloading"))
4069 (gnus-summary-mark-article article gnus-canceled-mark)
4070 (unless (memq article gnus-newsgroup-sparse)
4071 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4072 (if (or (eq result 'pseudo)
4073 (eq result 'nneething))
4076 (set-buffer summary-buffer)
4077 (push article gnus-newsgroup-history)
4078 (setq gnus-last-article gnus-current-article
4079 gnus-current-article 0
4080 gnus-current-headers nil
4081 gnus-article-current nil)
4082 (if (eq result 'nneething)
4083 (gnus-configure-windows 'summary)
4084 (gnus-configure-windows 'article))
4085 (gnus-set-global-variables))
4086 (let ((gnus-article-mime-handle-alist-1
4087 gnus-article-mime-handle-alist))
4088 (gnus-set-mode-line 'article)))
4089 ;; The result from the `request' was an actual article -
4090 ;; or at least some text that is now displayed in the
4092 (when (and (numberp article)
4093 (not (eq article gnus-current-article)))
4094 ;; Seems like a new article has been selected.
4095 ;; `gnus-current-article' must be an article number.
4097 (set-buffer summary-buffer)
4098 (push article gnus-newsgroup-history)
4099 (setq gnus-last-article gnus-current-article
4100 gnus-current-article article
4101 gnus-current-headers
4102 (gnus-summary-article-header gnus-current-article)
4103 gnus-article-current
4104 (cons gnus-newsgroup-name gnus-current-article))
4105 (unless (vectorp gnus-current-headers)
4106 (setq gnus-current-headers nil))
4107 (gnus-summary-goto-subject gnus-current-article)
4108 (when (gnus-summary-show-thread)
4109 ;; If the summary buffer really was folded, the
4110 ;; previous goto may not actually have gone to
4111 ;; the right article, but the thread root instead.
4113 (gnus-summary-goto-subject gnus-current-article))
4114 (gnus-run-hooks 'gnus-mark-article-hook)
4115 (gnus-set-mode-line 'summary)
4116 (when (gnus-visual-p 'article-highlight 'highlight)
4117 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4118 ;; Set the global newsgroup variables here.
4119 (gnus-set-global-variables)
4120 (setq gnus-have-all-headers
4121 (or all-headers gnus-show-all-headers))))
4123 (gnus-configure-windows 'article))
4124 (when (or (numberp article)
4126 (gnus-article-prepare-display)
4128 (goto-char (point-min))
4129 (when gnus-break-pages
4130 (gnus-narrow-to-page)))
4131 (let ((gnus-article-mime-handle-alist-1
4132 gnus-article-mime-handle-alist))
4133 (gnus-set-mode-line 'article))
4137 (set-window-point (get-buffer-window (current-buffer)) (point))
4138 (gnus-configure-windows 'article)
4142 (defun gnus-article-prepare-display ()
4143 "Make the current buffer look like a nice article."
4144 ;; Hooks for getting information from the article.
4145 ;; This hook must be called before being narrowed.
4146 (let ((gnus-article-buffer (current-buffer))
4148 (inhibit-read-only t))
4149 (unless (eq major-mode 'gnus-article-mode)
4150 (gnus-article-mode))
4151 (setq buffer-read-only nil
4152 gnus-article-wash-types nil
4153 gnus-article-image-alist nil)
4154 (gnus-run-hooks 'gnus-tmp-internal-hook)
4155 (when gnus-display-mime-function
4156 (funcall gnus-display-mime-function))
4157 (gnus-run-hooks 'gnus-article-prepare-hook)))
4160 ;;; Gnus MIME viewing functions
4163 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4164 "Format of the MIME buttons.
4166 Valid specifiers include:
4168 %T MIME type, along with additional info
4169 %n The `name' parameter
4170 %d The description, if any
4171 %l The length of the encoded part
4172 %p The part identifier number
4173 %e Dots if the part isn't displayed
4175 General format specifiers can also be used. See Info node
4176 `(gnus)Formatting Variables'.")
4178 (defvar gnus-mime-button-line-format-alist
4179 '((?t gnus-tmp-type ?s)
4180 (?T gnus-tmp-type-long ?s)
4181 (?n gnus-tmp-name ?s)
4182 (?d gnus-tmp-description ?s)
4184 (?l gnus-tmp-length ?d)
4185 (?e gnus-tmp-dots ?s)))
4187 (defvar gnus-mime-button-commands
4188 '((gnus-article-press-button "\r" "Toggle Display")
4189 (gnus-mime-view-part "v" "View Interactively...")
4190 (gnus-mime-view-part-as-type "t" "View As Type...")
4191 (gnus-mime-view-part-as-charset "C" "View As charset...")
4192 (gnus-mime-save-part "o" "Save...")
4193 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4194 (gnus-mime-replace-part "r" "Replace part")
4195 (gnus-mime-delete-part "d" "Delete part")
4196 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4197 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4198 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4199 (gnus-mime-view-part-externally "e" "View Externally")
4200 (gnus-mime-print-part "p" "Print")
4201 (gnus-mime-pipe-part "|" "Pipe To Command...")
4202 (gnus-mime-action-on-part "." "Take action on the part...")))
4204 (defun gnus-article-mime-part-status ()
4205 (if gnus-article-mime-handle-alist-1
4206 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4208 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4211 (defvar gnus-mime-button-map
4212 (let ((map (make-sparse-keymap)))
4213 (define-key map gnus-mouse-2 'gnus-article-push-button)
4214 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4215 (dolist (c gnus-mime-button-commands)
4216 (define-key map (cadr c) (car c)))
4220 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4222 ,@(mapcar (lambda (c)
4223 (vector (caddr c) (car c) :enable t))
4224 gnus-mime-button-commands)))
4226 (defun gnus-mime-button-menu (event prefix)
4227 "Construct a context-sensitive menu of MIME commands."
4228 (interactive "e\nP")
4229 (save-window-excursion
4230 (let ((pos (event-start event)))
4231 (select-window (posn-window pos))
4232 (goto-char (posn-point pos))
4233 (gnus-article-check-buffer)
4234 (popup-menu gnus-mime-button-menu nil prefix))))
4236 (defun gnus-mime-view-all-parts (&optional handles)
4237 "View all the MIME parts."
4239 (with-current-buffer gnus-article-buffer
4240 (let ((handles (or handles gnus-article-mime-handles))
4241 (mail-parse-charset gnus-newsgroup-charset)
4242 (mail-parse-ignored-charsets
4243 (with-current-buffer gnus-summary-buffer
4244 gnus-newsgroup-ignored-charsets)))
4246 (mm-remove-parts handles)
4247 (goto-char (point-min))
4248 (or (search-forward "\n\n") (goto-char (point-max)))
4249 (let ((inhibit-read-only t))
4250 (delete-region (point) (point-max))
4251 (mm-display-parts handles))))))
4253 (defun gnus-article-jump-to-part (n)
4254 "Jump to MIME part N."
4256 (pop-to-buffer gnus-article-buffer)
4257 ;; FIXME: why is it necessary?
4259 (let ((parts (length gnus-article-mime-handle-alist)))
4262 (read-string ;; Emacs 21 doesn't have `read-number'.
4263 (format "Jump to part (2..%s): " parts)))))
4264 (unless (and (integerp n) (<= n parts) (>= n 1))
4267 (gnus-message 7 "Invalid part `%s', using %s instead."
4270 (gnus-message 9 "Jumping to part %s." n)
4271 (cond ((>= gnus-auto-select-part 1)
4272 (while (and (<= n parts)
4273 (not (gnus-article-goto-part n)))
4275 ((< gnus-auto-select-part 0)
4276 (while (and (>= n 1)
4277 (not (gnus-article-goto-part n)))
4280 (gnus-article-goto-part n)))))
4283 (defsubst gnus-article-edit-part (handles &optional current-id)
4284 "Edit an article in order to delete a mime part.
4285 This function is exclusively used by `gnus-mime-save-part-and-strip'
4286 and `gnus-mime-delete-part', and not provided at run-time normally."
4287 (gnus-article-edit-article
4289 (buffer-disable-undo)
4291 (let ((mail-parse-charset (or gnus-article-charset
4292 ',gnus-newsgroup-charset))
4293 (mail-parse-ignored-charsets
4294 (or gnus-article-ignored-charsets
4295 ',gnus-newsgroup-ignored-charsets))
4296 (mbl mml-buffer-list))
4297 (setq mml-buffer-list nil)
4298 (insert-buffer-substring gnus-original-article-buffer)
4299 (mime-to-mml ',handles)
4300 (setq gnus-article-mime-handles nil)
4301 (let ((mbl1 mml-buffer-list))
4302 (setq mml-buffer-list mbl)
4303 (set (make-local-variable 'mml-buffer-list) mbl1))
4304 (gnus-make-local-hook 'kill-buffer-hook)
4305 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4306 `(lambda (no-highlight)
4307 (let ((mail-parse-charset (or gnus-article-charset
4308 ',gnus-newsgroup-charset))
4309 (message-options message-options)
4310 (message-options-set-recipient)
4311 (mail-parse-ignored-charsets
4312 (or gnus-article-ignored-charsets
4313 ',gnus-newsgroup-ignored-charsets)))
4315 (mml-destroy-buffers)
4316 (remove-hook 'kill-buffer-hook
4317 'mml-destroy-buffers t)
4318 (kill-local-variable 'mml-buffer-list))
4319 (gnus-summary-edit-article-done
4320 ,(or (mail-header-references gnus-current-headers) "")
4321 ,(gnus-group-read-only-p)
4322 ,gnus-summary-buffer no-highlight))
4324 (gnus-article-edit-done)
4325 (gnus-summary-expand-window)
4326 (gnus-summary-show-article)
4327 (when (and current-id (integerp gnus-auto-select-part))
4328 (gnus-article-jump-to-part
4329 (+ current-id gnus-auto-select-part)))))
4331 (defun gnus-mime-replace-part (file)
4332 "Replace MIME part under point with an external body."
4333 ;; Useful if file has already been saved to disk
4337 (read-file-name "Replace MIME part with file: "
4338 (or mm-default-directory default-directory)
4340 (gnus-mime-save-part-and-strip file))
4342 (defun gnus-mime-save-part-and-strip (&optional file)
4343 "Save the MIME part under point then replace it with an external body.
4344 If FILE is given, use it for the external part."
4346 (gnus-article-check-buffer)
4347 (when (gnus-group-read-only-p)
4348 (error "The current group does not support deleting of parts"))
4349 (when (mm-complicated-handles gnus-article-mime-handles)
4351 The current article has a complicated MIME structure, giving up..."))
4352 (let* ((data (get-text-property (point) 'gnus-data))
4353 (id (get-text-property (point) 'gnus-part))
4355 (handles gnus-article-mime-handles))
4358 (and data (mm-save-part data "Delete MIME part and save to: "))))
4360 (with-current-buffer (mm-handle-buffer data)
4362 (insert "Content-Type: " (mm-handle-media-type data))
4363 (mml-insert-parameter-string (cdr (mm-handle-type data))
4365 ;; Add a filename for the sake of saving the part again.
4366 (mml-insert-parameter
4367 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4369 (insert "Content-ID: " (message-make-message-id) "\n")
4370 (insert "Content-Transfer-Encoding: binary\n")
4373 (cdr (mm-make-handle nil
4374 `("message/external-body"
4375 (access-type . "LOCAL-FILE")
4377 ;; (set-buffer gnus-summary-buffer)
4378 (gnus-article-edit-part handles id))))
4380 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4381 ;; parts...>') but with stripping would be nice.
4383 (defun gnus-mime-delete-part ()
4384 "Delete the MIME part under point.
4385 Replace it with some information about the removed part."
4387 (gnus-article-check-buffer)
4388 (when (gnus-group-read-only-p)
4389 (error "The current group does not support deleting of parts"))
4390 (when (mm-complicated-handles gnus-article-mime-handles)
4392 The current article has a complicated MIME structure, giving up..."))
4393 (when (or gnus-expert-user
4394 (gnus-yes-or-no-p "\
4395 Deleting parts may malfunction or destroy the article; continue? "))
4396 (let* ((data (get-text-property (point) 'gnus-data))
4397 (id (get-text-property (point) 'gnus-part))
4398 (handles gnus-article-mime-handles)
4402 (mail-decode-encoded-word-string (or (mm-handle-description data)
4405 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4407 (type (mm-handle-media-type data)))
4409 (error "No MIME part under point"))
4410 (with-current-buffer (mm-handle-buffer data)
4411 (let ((bsize (format "%s" (buffer-size))))
4416 "| The following attachment has been deleted:\n"
4418 "| Type: " type "\n"
4419 "| Filename: " filename "\n"
4420 "| Size (encoded): " bsize " Byte\n"
4421 "| Description: " description "\n"
4424 (cdr (mm-make-handle
4425 nil `("text/plain") nil nil
4427 (format "Deleted attachment (%s bytes)" bsize))))))
4428 ;; (set-buffer gnus-summary-buffer)
4429 (gnus-article-edit-part handles id))))
4431 (defun gnus-mime-save-part ()
4432 "Save the MIME part under point."
4434 (gnus-article-check-buffer)
4435 (let ((data (get-text-property (point) 'gnus-data)))
4437 (mm-save-part data))))
4439 (defun gnus-mime-pipe-part ()
4440 "Pipe the MIME part under point to a process."
4442 (gnus-article-check-buffer)
4443 (let ((data (get-text-property (point) 'gnus-data)))
4445 (mm-pipe-part data))))
4447 (defun gnus-mime-view-part ()
4448 "Interactively choose a viewing method for the MIME part under point."
4450 (gnus-article-check-buffer)
4451 (let ((data (get-text-property (point) 'gnus-data)))
4453 (setq gnus-article-mime-handles
4455 gnus-article-mime-handles (setq data (copy-sequence data))))
4456 (mm-interactively-view-part data))))
4458 (defun gnus-mime-view-part-as-type-internal ()
4459 (gnus-article-check-buffer)
4460 (let* ((handle (get-text-property (point) 'gnus-data))
4462 ;; Content-Type: foo/bar; name=...
4463 (mail-content-type-get (mm-handle-type handle) 'name)
4464 ;; Content-Disposition: attachment; filename=...
4465 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4466 (def-type (and name (mm-default-file-encoding name))))
4467 (and def-type (cons def-type 0))))
4469 (defun gnus-mime-view-part-as-type (&optional mime-type)
4470 "Choose a MIME media type, and view the part as such."
4474 (let ((default (gnus-mime-view-part-as-type-internal)))
4476 (format "View as MIME type (default %s): "
4478 (mapcar #'list (mailcap-mime-types))
4481 (gnus-article-check-buffer)
4482 (let ((handle (get-text-property (point) 'gnus-data)))
4484 (when (equal (mm-handle-media-type handle) "message/external-body")
4485 (unless (mm-handle-cache handle)
4486 (mm-extern-cache-contents handle))
4487 (setq handle (mm-handle-cache handle)))
4489 (mm-make-handle (mm-handle-buffer handle)
4490 (cons mime-type (cdr (mm-handle-type handle)))
4491 (mm-handle-encoding handle)
4492 (mm-handle-undisplayer handle)
4493 (mm-handle-disposition handle)
4494 (mm-handle-description handle)
4496 (mm-handle-id handle)))
4497 (setq gnus-article-mime-handles
4498 (mm-merge-handles gnus-article-mime-handles handle))
4499 (gnus-mm-display-part handle))))
4501 (defun gnus-mime-copy-part (&optional handle arg)
4502 "Put the MIME part under point into a new buffer.
4503 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4505 (interactive (list nil current-prefix-arg))
4506 (gnus-article-check-buffer)
4508 (setq handle (get-text-property (point) 'gnus-data)))
4510 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4512 (mail-content-type-get (mm-handle-disposition handle)
4514 contents dont-decode charset coding-system)
4515 (mm-with-unibyte-buffer
4516 (mm-insert-part handle)
4517 (setq contents (or (condition-case nil
4518 (mm-decompress-buffer filename nil 'sig)
4520 (setq dont-decode t)
4523 (setq filename (cond (filename (file-name-nondirectory filename))
4524 (dont-decode "*raw data*")
4529 (unless (setq charset (mail-content-type-get
4530 (mm-handle-type handle) 'charset))
4531 (unless (setq coding-system (mm-with-unibyte-buffer
4533 (mm-find-buffer-file-coding-system)))
4534 (setq charset gnus-newsgroup-charset))))
4536 (setq charset (or (cdr (assq arg
4537 gnus-summary-show-article-charset-alist))
4538 (mm-read-coding-system "Charset: ")))))
4539 (switch-to-buffer (generate-new-buffer filename))
4540 (if (or coding-system
4542 (setq coding-system (mm-charset-to-coding-system charset))
4543 (not (eq charset 'ascii))))
4545 (mm-enable-multibyte)
4546 (insert (mm-decode-coding-string contents coding-system))
4547 (setq buffer-file-coding-system
4548 (if (boundp 'last-coding-system-used)
4549 (symbol-value 'last-coding-system-used)
4551 (mm-disable-multibyte)
4553 (setq buffer-file-coding-system mm-binary-coding-system))
4554 ;; We do it this way to make `normal-mode' set the appropriate mode.
4557 (setq buffer-file-name (expand-file-name filename))
4559 (setq buffer-file-name nil))
4560 (goto-char (point-min)))))
4562 (defun gnus-mime-print-part (&optional handle filename)
4563 "Print the MIME part under point."
4564 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4565 (gnus-article-check-buffer)
4566 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4567 (contents (and handle (mm-get-part handle)))
4568 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4569 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4574 (mm-save-part-to-file handle file)
4575 (call-process shell-file-name nil
4576 (generate-new-buffer " *mm*")
4578 shell-command-switch
4580 printer file (mm-handle-type handle))))
4584 (gnus-print-buffer))
4585 (ps-despool filename)))))
4587 (defun gnus-mime-inline-part (&optional handle arg)
4588 "Insert the MIME part under point into the current buffer.
4589 Compressed files like .gz and .bz2 are decompressed."
4590 (interactive (list nil current-prefix-arg))
4591 (gnus-article-check-buffer)
4593 (setq handle (get-text-property (point) 'gnus-data)))
4596 (inhibit-read-only t)
4597 contents charset coding-system)
4598 (if (and (not arg) (mm-handle-undisplayer handle))
4599 (mm-remove-part handle)
4600 (mm-with-unibyte-buffer
4601 (mm-insert-part handle)
4603 (or (mm-decompress-buffer
4604 (or (mail-content-type-get (mm-handle-disposition handle)
4606 (mail-content-type-get (mm-handle-disposition handle)
4612 (unless (setq charset (mail-content-type-get
4613 (mm-handle-type handle) 'charset))
4614 (unless (setq coding-system
4615 (mm-with-unibyte-buffer
4617 (mm-find-buffer-file-coding-system)))
4618 (setq charset gnus-newsgroup-charset))))
4620 (if (mm-handle-undisplayer handle)
4621 (mm-remove-part handle))
4624 gnus-summary-show-article-charset-alist))
4625 (mm-read-coding-system "Charset: "))))
4627 (if (mm-handle-undisplayer handle)
4628 (mm-remove-part handle))))
4632 (if (or coding-system
4635 (mm-charset-to-coding-system charset))
4636 (not (eq coding-system 'ascii))))
4637 (mm-decode-coding-string contents coding-system)
4638 (mm-string-to-multibyte contents)))
4641 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4642 "Insert the MIME part under point into the current buffer using the
4644 (interactive (list nil current-prefix-arg))
4645 (gnus-article-check-buffer)
4646 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4649 (inhibit-read-only t))
4651 (if (mm-handle-undisplayer handle)
4652 (mm-remove-part handle))
4653 (let ((gnus-newsgroup-charset
4655 gnus-summary-show-article-charset-alist))
4656 (mm-read-coding-system "Charset: ")))
4657 (gnus-newsgroup-ignored-charsets 'gnus-all))
4658 (gnus-article-press-button)))))
4660 (defun gnus-mime-view-part-externally (&optional handle)
4661 "View the MIME part under point with an external viewer."
4663 (gnus-article-check-buffer)
4664 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4665 (mm-user-display-methods nil)
4666 (mm-inlined-types nil)
4667 (mail-parse-charset gnus-newsgroup-charset)
4668 (mail-parse-ignored-charsets
4669 (with-current-buffer gnus-summary-buffer
4670 gnus-newsgroup-ignored-charsets)))
4672 (if (mm-handle-undisplayer handle)
4673 (mm-remove-part handle)
4674 (mm-display-part handle)))))
4676 (defun gnus-mime-view-part-internally (&optional handle)
4677 "View the MIME part under point with an internal viewer.
4678 If no internal viewer is available, use an external viewer."
4680 (gnus-article-check-buffer)
4681 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4682 (mm-inlined-types '(".*"))
4683 (mm-inline-large-images t)
4684 (mail-parse-charset gnus-newsgroup-charset)
4685 (mail-parse-ignored-charsets
4686 (with-current-buffer gnus-summary-buffer
4687 gnus-newsgroup-ignored-charsets))
4688 (inhibit-read-only t))
4690 (if (mm-handle-undisplayer handle)
4691 (mm-remove-part handle)
4692 (mm-display-part handle)))))
4694 (defun gnus-mime-action-on-part (&optional action)
4695 "Do something with the MIME attachment at \(point\)."
4697 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4698 (gnus-article-check-buffer)
4699 (let ((action-pair (assoc action gnus-mime-action-alist)))
4701 (funcall (cdr action-pair)))))
4703 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4704 "Call FUNCTION on MIME part N.
4705 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4706 If INTERACTIVE, call FUNCTION interactivly."
4708 ;; Check whether the article is displayed.
4709 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4710 (setq window (get-buffer-window gnus-article-buffer t))
4711 (frame-visible-p (setq frame (window-frame window))))
4712 (error "No article is displayed"))
4713 (with-current-buffer gnus-article-buffer
4714 ;; Check whether the article displays the right contents.
4715 (unless (with-current-buffer gnus-summary-buffer
4716 (eq gnus-current-article (gnus-summary-article-number)))
4717 (error "You should select the right article first"))
4718 ;; Check whether the specified part exists.
4719 (when (> n (length gnus-article-mime-handle-alist))
4720 (error "No such part")))
4723 ;; To select the window is needed so that the cursor
4724 ;; might be visible on the MIME button.
4725 (select-window (prog1
4727 (setq window (selected-window))
4728 ;; Article may be displayed in the other frame.
4729 (gnus-select-frame-set-input-focus
4732 (setq frame (selected-frame))))))
4733 (when (gnus-article-goto-part n)
4734 ;; We point the cursor and the arrow at the MIME button
4735 ;; when the `function' prompt the user for something.
4736 (let ((cursor-in-non-selected-windows t)
4737 (overlay-arrow-string "=>")
4738 (overlay-arrow-position (point-marker)))
4741 ((and no-handle interactive)
4742 (call-interactively function))
4748 (cdr (assq n gnus-article-mime-handle-alist))))
4751 (cdr (assq n gnus-article-mime-handle-alist)))))
4752 (set-marker overlay-arrow-position nil)
4753 (unless gnus-auto-select-part
4754 (gnus-select-frame-set-input-focus frame)
4755 (select-window window))))
4757 (if gnus-inhibit-mime-unbuttonizing
4758 ;; This is the default though the program shouldn't reach here.
4759 (error "No such part")
4760 ;; The part which doesn't have the MIME button is selected.
4761 ;; So, we display all the buttons and redo it.
4762 (let ((gnus-inhibit-mime-unbuttonizing t))
4763 (gnus-summary-show-article)
4764 (gnus-article-part-wrapper n function no-handle))))))
4766 (defun gnus-article-pipe-part (n)
4767 "Pipe MIME part N, which is the numerical prefix."
4769 (gnus-article-part-wrapper n 'mm-pipe-part))
4771 (defun gnus-article-save-part (n)
4772 "Save MIME part N, which is the numerical prefix."
4774 (gnus-article-part-wrapper n 'mm-save-part))
4776 (defun gnus-article-interactively-view-part (n)
4777 "View MIME part N interactively, which is the numerical prefix."
4779 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4781 (defun gnus-article-copy-part (n)
4782 "Copy MIME part N, which is the numerical prefix."
4784 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4786 (defun gnus-article-view-part-as-charset (n)
4787 "View MIME part N using a specified charset.
4788 N is the numerical prefix."
4790 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4792 (defun gnus-article-view-part-externally (n)
4793 "View MIME part N externally, which is the numerical prefix."
4795 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4797 (defun gnus-article-inline-part (n)
4798 "Inline MIME part N, which is the numerical prefix."
4800 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4802 (defun gnus-article-save-part-and-strip (n)
4803 "Save MIME part N and replace it with an external body.
4804 N is the numerical prefix."
4806 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4808 (defun gnus-article-replace-part (n)
4809 "Replace MIME part N with an external body.
4810 N is the numerical prefix."
4812 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
4814 (defun gnus-article-delete-part (n)
4815 "Delete MIME part N and add some information about the removed part.
4816 N is the numerical prefix."
4818 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4820 (defun gnus-article-mime-match-handle-first (condition)
4823 (dolist (ihandle gnus-article-mime-handle-alist)
4825 ((functionp condition)
4826 (funcall condition (cdr ihandle)))
4827 ((eq condition 'undisplayed)
4828 (not (or (mm-handle-undisplayer (cdr ihandle))
4829 (equal (mm-handle-media-type (cdr ihandle))
4830 "multipart/alternative"))))
4831 ((eq condition 'undisplayed-alternative)
4832 (not (mm-handle-undisplayer (cdr ihandle))))
4834 (gnus-article-goto-part (car ihandle))
4835 (or (not n) (< (car ihandle) n)))
4836 (setq n (car ihandle))))
4840 (defun gnus-article-view-part (&optional n)
4841 "View MIME part N, which is the numerical prefix."
4843 (with-current-buffer gnus-article-buffer
4844 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4845 gnus-article-mime-match-handle-function)))
4846 (when (> n (length gnus-article-mime-handle-alist))
4847 (error "No such part"))
4848 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4849 (when (gnus-article-goto-part n)
4850 (if (equal (car handle) "multipart/alternative")
4851 (gnus-article-press-button)
4852 (when (eq (gnus-mm-display-part handle) 'internal)
4853 (gnus-set-window-start)))))))
4855 (defsubst gnus-article-mime-total-parts ()
4856 (if (bufferp (car gnus-article-mime-handles))
4858 (1- (length gnus-article-mime-handles))))
4860 (defun gnus-mm-display-part (handle)
4861 "Display HANDLE and fix MIME button."
4862 (let ((id (get-text-property (point) 'gnus-part))
4864 (inhibit-read-only t))
4867 (let ((window (selected-window))
4868 (mail-parse-charset gnus-newsgroup-charset)
4869 (mail-parse-ignored-charsets
4870 (if (gnus-buffer-live-p gnus-summary-buffer)
4871 (with-current-buffer gnus-summary-buffer
4872 gnus-newsgroup-ignored-charsets)
4876 (let ((win (gnus-get-buffer-window (current-buffer) t))
4879 (select-window win))
4882 (if (mm-handle-displayed-p handle)
4883 ;; This will remove the part.
4884 (mm-display-part handle)
4886 (narrow-to-region (point)
4887 (if (eobp) (point) (1+ (point))))
4888 (mm-display-part handle)
4889 ;; We narrow to the part itself and
4890 ;; then call the treatment functions.
4891 (goto-char (point-min))
4893 (narrow-to-region (point) (point-max))
4896 (gnus-article-mime-total-parts)
4897 (mm-handle-media-type handle)))))
4898 (if (window-live-p window)
4899 (select-window window)))))
4902 (gnus-insert-mime-button
4903 handle id (list (mm-handle-displayed-p handle)))
4904 (goto-char point))))
4906 (defun gnus-article-goto-part (n)
4907 "Go to MIME part N."
4908 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4910 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4911 (let ((gnus-tmp-name
4912 (or (mail-content-type-get (mm-handle-type handle) 'name)
4913 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4914 (mail-content-type-get (mm-handle-type handle) 'url)
4916 (gnus-tmp-type (mm-handle-media-type handle))
4917 (gnus-tmp-description
4918 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4921 (if (if displayed (car displayed)
4922 (mm-handle-displayed-p handle))
4924 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4926 gnus-tmp-type-long b e)
4927 (when (string-match ".*/" gnus-tmp-name)
4928 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4929 (setq gnus-tmp-type-long (concat gnus-tmp-type
4930 (and (not (equal gnus-tmp-name ""))
4931 (concat "; " gnus-tmp-name))))
4932 (unless (equal gnus-tmp-description "")
4933 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4938 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4939 `(keymap ,gnus-mime-button-map
4940 gnus-callback gnus-mm-display-part
4941 gnus-part ,gnus-tmp-id
4942 article-type annotation
4945 ;; Exclude a newline.
4948 (widget-convert-button
4951 :action 'gnus-widget-press-button
4952 :button-keymap gnus-mime-button-map
4954 (lambda (widget/window &optional overlay pos)
4955 ;; Needed to properly clear the message due to a bug in
4956 ;; wid-edit (XEmacs only).
4957 (if (boundp 'help-echo-owns-message)
4958 (setq help-echo-owns-message t))
4960 "%S: %s the MIME part; %S: more options"
4961 (aref gnus-mouse-2 0)
4962 ;; XEmacs will get a single widget arg; Emacs 21 will get
4963 ;; window, overlay, position.
4964 (if (mm-handle-displayed-p
4966 (with-current-buffer (gnus-overlay-buffer overlay)
4967 (widget-get (widget-at (gnus-overlay-start overlay))
4969 (widget-get widget/window :mime-handle)))
4971 (aref gnus-down-mouse-3 0))))))
4973 (defun gnus-widget-press-button (elems el)
4974 (goto-char (widget-get elems :from))
4975 (gnus-article-press-button))
4977 (defvar gnus-displaying-mime nil)
4979 (defun gnus-display-mime (&optional ihandles)
4980 "Display the MIME parts."
4982 (save-selected-window
4983 (let ((window (get-buffer-window gnus-article-buffer))
4986 (select-window window)
4987 ;; We have to do this since selecting the window
4988 ;; may change the point. So we set the window point.
4989 (set-window-point window point)))
4990 (let ((handles ihandles)
4991 (inhibit-read-only t)
4994 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4995 (when gnus-article-emulate-mime
4996 (mm-uu-dissect-text-parts handles)))
4997 (gnus-article-emulate-mime
4998 (setq handles (mm-uu-dissect))))
4999 (when (and (not ihandles)
5000 (not gnus-displaying-mime))
5001 ;; Top-level call; we clean up.
5002 (when gnus-article-mime-handles
5003 (mm-destroy-parts gnus-article-mime-handles)
5004 (setq gnus-article-mime-handle-alist nil));; A trick.
5005 (setq gnus-article-mime-handles handles)
5006 ;; We allow users to glean info from the handles.
5007 (when gnus-article-mime-part-function
5008 (gnus-mime-part-function handles)))
5010 (or (not (stringp (car handles)))
5013 (when (and (not ihandles)
5014 (not gnus-displaying-mime))
5015 ;; Clean up for mime parts.
5017 (delete-region (point) (point-max)))
5018 (let ((gnus-displaying-mime t))
5019 (gnus-mime-display-part handles)))
5022 (narrow-to-region (point) (point-max))
5023 (gnus-treat-article nil 1 1)
5026 ;; Highlight the headers.
5030 (narrow-to-region (point-min) (point))
5031 (gnus-article-save-original-date
5032 (gnus-treat-article 'head)))))))))
5034 (defcustom gnus-mime-display-multipart-as-mixed nil
5035 "Display \"multipart\" parts as \"multipart/mixed\".
5037 If t, it overrides nil values of
5038 `gnus-mime-display-multipart-alternative-as-mixed' and
5039 `gnus-mime-display-multipart-related-as-mixed'."
5040 :group 'gnus-article-mime
5043 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5044 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5046 :group 'gnus-article-mime
5049 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5050 "Display \"multipart/related\" parts as \"multipart/mixed\".
5052 If displaying \"text/html\" is discouraged \(see
5053 `mm-discouraged-alternatives'\) images or other material inside a
5054 \"multipart/related\" part might be overlooked when this variable is nil."
5056 :group 'gnus-article-mime
5059 (defun gnus-mime-display-part (handle)
5061 ;; Maybe a broken MIME message.
5064 ((not (stringp (car handle)))
5065 (gnus-mime-display-single handle))
5066 ;; User-defined multipart
5067 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5068 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5070 ;; multipart/alternative
5071 ((and (equal (car handle) "multipart/alternative")
5072 (not (or gnus-mime-display-multipart-as-mixed
5073 gnus-mime-display-multipart-alternative-as-mixed)))
5074 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5075 (push (cons id handle) gnus-article-mime-handle-alist)
5076 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5077 ;; multipart/related
5078 ((and (equal (car handle) "multipart/related")
5079 (not (or gnus-mime-display-multipart-as-mixed
5080 gnus-mime-display-multipart-related-as-mixed)))
5081 ;;;!!!We should find the start part, but we just default
5082 ;;;!!!to the first part.
5083 ;;(gnus-mime-display-part (cadr handle))
5084 ;;;!!! Most multipart/related is an HTML message plus images.
5085 ;;;!!! Unfortunately we are unable to let W3 display those
5086 ;;;!!! included images, so we just display it as a mixed multipart.
5087 ;;(gnus-mime-display-mixed (cdr handle))
5088 ;;;!!! No, w3 can display everything just fine.
5089 (gnus-mime-display-part (cadr handle)))
5090 ((equal (car handle) "multipart/signed")
5091 (gnus-add-wash-type 'signed)
5092 (gnus-mime-display-security handle))
5093 ((equal (car handle) "multipart/encrypted")
5094 (gnus-add-wash-type 'encrypted)
5095 (gnus-mime-display-security handle))
5096 ;; Other multiparts are handled like multipart/mixed.
5098 (gnus-mime-display-mixed (cdr handle)))))
5100 (defun gnus-mime-part-function (handles)
5101 (if (stringp (car handles))
5102 (mapcar 'gnus-mime-part-function (cdr handles))
5103 (funcall gnus-article-mime-part-function handles)))
5105 (defun gnus-mime-display-mixed (handles)
5106 (mapcar 'gnus-mime-display-part handles))
5108 (defun gnus-mime-display-single (handle)
5109 (let ((type (mm-handle-media-type handle))
5110 (ignored gnus-ignored-mime-types)
5117 (when (string-match (pop ignored) type)
5118 (throw 'ignored nil)))
5119 (if (and (setq not-attachment
5120 (and (not (mm-inline-override-p handle))
5121 (or (not (mm-handle-disposition handle))
5122 (equal (car (mm-handle-disposition handle))
5124 (mm-attachment-override-p handle))))
5125 (mm-automatic-display-p handle)
5127 (mm-inlinable-p handle)
5128 (mm-inlined-p handle))
5129 (mm-automatic-external-display-p type)))
5131 (when (equal (mm-handle-media-supertype handle) "text")
5133 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5135 (push (cons id handle) gnus-article-mime-handle-alist)
5137 (equal (mm-handle-media-supertype handle) "message"))
5140 (cond ((not (bolp)) 2)
5141 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5143 (when (or (not display)
5144 (not (gnus-unbuttonized-mime-type-p type)))
5145 (gnus-insert-mime-button
5146 handle id (list (or display (and not-attachment text))))
5147 (gnus-article-insert-newline)
5148 ;; Remember modify the number of forward lines.
5156 (let ((mail-parse-charset gnus-newsgroup-charset)
5157 (mail-parse-ignored-charsets
5158 (save-excursion (condition-case ()
5159 (set-buffer gnus-summary-buffer)
5161 gnus-newsgroup-ignored-charsets)))
5162 (mm-display-part handle t))
5163 (goto-char (point-max)))
5164 ((and text not-attachment)
5168 (gnus-article-insert-newline)
5171 (let ((charset (mail-content-type-get (mm-handle-type handle)
5173 (cond ((not charset)
5174 (mm-string-as-multibyte (mm-get-part handle)))
5175 ((eq charset 'gnus-decoded)
5176 (with-current-buffer (mm-handle-buffer handle)
5179 (mm-decode-string (mm-get-part handle) charset)))))
5180 (goto-char (point-max))))
5184 (narrow-to-region beg (point))
5187 (gnus-article-mime-total-parts)
5188 (mm-handle-media-type handle)))))))))
5190 (defun gnus-unbuttonized-mime-type-p (type)
5191 "Say whether TYPE is to be unbuttonized."
5192 (unless gnus-inhibit-mime-unbuttonizing
5194 (let ((types gnus-unbuttonized-mime-types))
5196 (when (string-match (pop types) type)
5197 (throw 'found t)))))
5199 (let ((types gnus-buttonized-mime-types))
5201 (when (string-match (pop types) type)
5202 (throw 'found t)))))))))
5204 (defun gnus-article-insert-newline ()
5205 "Insert a newline, but mark it as undeletable."
5206 (gnus-put-text-property
5207 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5209 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5210 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5213 handle (inhibit-read-only t) from props begend not-pref)
5214 (save-window-excursion
5217 (narrow-to-region (car ibegend)
5220 (goto-char (car ibegend))
5223 (delete-region (point-min) (point-max))
5224 (mm-remove-parts handles))
5225 (setq begend (list (point-marker)))
5227 (unless (setq not-pref (cadr (member preferred ihandles)))
5228 (setq not-pref (car ihandles)))
5231 (not (gnus-unbuttonized-mime-type-p
5232 "multipart/alternative")))
5233 (gnus-add-text-properties
5236 (insert (format "%d. " id))
5240 (unless ,(not ibegend)
5241 (setq gnus-article-mime-handle-alist
5242 ',gnus-article-mime-handle-alist))
5243 (gnus-mime-display-alternative
5244 ',ihandles ',not-pref ',begend ,id))
5245 keymap ,gnus-mime-button-map
5246 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5247 face ,gnus-article-button-face
5249 article-type multipart))
5250 (widget-convert-button 'link from (point)
5251 :action 'gnus-widget-press-button
5252 :button-keymap gnus-widget-button-keymap)
5254 (while (setq handle (pop handles))
5255 (gnus-add-text-properties
5258 (insert (format "(%c) %-18s"
5259 (if (equal handle preferred) ?* ? )
5260 (mm-handle-media-type handle)))
5264 (unless ,(not ibegend)
5265 (setq gnus-article-mime-handle-alist
5266 ',gnus-article-mime-handle-alist))
5267 (gnus-mime-display-alternative
5268 ',ihandles ',handle ',begend ,id))
5269 keymap ,gnus-mime-button-map
5270 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5271 face ,gnus-article-button-face
5274 (widget-convert-button 'link from (point)
5275 :action 'gnus-widget-press-button
5276 :button-keymap gnus-widget-button-keymap)
5280 (if (stringp (car preferred))
5281 (gnus-display-mime preferred)
5282 (let ((mail-parse-charset gnus-newsgroup-charset)
5283 (mail-parse-ignored-charsets
5284 (with-current-buffer gnus-summary-buffer
5285 gnus-newsgroup-ignored-charsets)))
5286 (mm-display-part preferred)
5290 (narrow-to-region (car begend) (point-max))
5292 nil (length gnus-article-mime-handle-alist)
5293 (gnus-article-mime-total-parts)
5294 (mm-handle-media-type handle))))))
5295 (goto-char (point-max))
5296 (setcdr begend (point-marker)))))
5298 (goto-char point))))
5300 (defconst gnus-article-wash-status-strings
5301 (let ((alist '((cite "c" "Possible hidden citation text"
5302 " " "All citation text visible")
5303 (headers "h" "Hidden headers"
5304 " " "All headers visible.")
5305 (pgp "p" "Encrypted or signed message status hidden"
5306 " " "No hidden encryption nor digital signature status")
5307 (signature "s" "Signature has been hidden"
5308 " " "Signature is visible")
5309 (overstrike "o" "Overstrike (^H) characters applied"
5310 " " "No overstrike characters applied")
5311 (emphasis "e" "/*_Emphasis_*/ characters applied"
5312 " " "No /*_emphasis_*/ characters applied")))
5314 (dolist (entry alist result)
5315 (let ((key (nth 0 entry))
5316 (on (copy-sequence (nth 1 entry)))
5317 (on-help (nth 2 entry))
5318 (off (copy-sequence (nth 3 entry)))
5319 (off-help (nth 4 entry)))
5320 (put-text-property 0 1 'help-echo on-help on)
5321 (put-text-property 0 1 'help-echo off-help off)
5322 (push (list key on off) result))))
5323 "Alist of strings describing wash status in the mode line.
5324 Each entry has the form (KEY ON OF), where the KEY is a symbol
5325 representing the particular washing function, ON is the string to use
5326 in the article mode line when the washing function is active, and OFF
5327 is the string to use when it is inactive.")
5329 (defun gnus-article-wash-status-entry (key value)
5330 (let ((entry (assoc key gnus-article-wash-status-strings)))
5331 (if value (nth 1 entry) (nth 2 entry))))
5333 (defun gnus-article-wash-status ()
5334 "Return a string which display status of article washing."
5335 (with-current-buffer gnus-article-buffer
5336 (let ((cite (memq 'cite gnus-article-wash-types))
5337 (headers (memq 'headers gnus-article-wash-types))
5338 (boring (memq 'boring-headers gnus-article-wash-types))
5339 (pgp (memq 'pgp gnus-article-wash-types))
5340 (pem (memq 'pem gnus-article-wash-types))
5341 (signed (memq 'signed gnus-article-wash-types))
5342 (encrypted (memq 'encrypted gnus-article-wash-types))
5343 (signature (memq 'signature gnus-article-wash-types))
5344 (overstrike (memq 'overstrike gnus-article-wash-types))
5345 (emphasis (memq 'emphasis gnus-article-wash-types)))
5347 (gnus-article-wash-status-entry 'cite cite)
5348 (gnus-article-wash-status-entry 'headers (or headers boring))
5349 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5350 (gnus-article-wash-status-entry 'signature signature)
5351 (gnus-article-wash-status-entry 'overstrike overstrike)
5352 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5354 (defun gnus-add-wash-type (type)
5355 "Add a washing of TYPE to the current status."
5356 (add-to-list 'gnus-article-wash-types type))
5358 (defun gnus-delete-wash-type (type)
5359 "Add a washing of TYPE to the current status."
5360 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5362 (defun gnus-add-image (category image)
5363 "Add IMAGE of CATEGORY to the list of displayed images."
5364 (let ((entry (assq category gnus-article-image-alist)))
5366 (setq entry (list category))
5367 (push entry gnus-article-image-alist))
5368 (nconc entry (list image))))
5370 (defun gnus-delete-images (category)
5371 "Delete all images in CATEGORY."
5372 (let ((entry (assq category gnus-article-image-alist)))
5373 (dolist (image (cdr entry))
5374 (gnus-remove-image image category))
5375 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5376 (gnus-delete-wash-type category)))
5378 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5380 (defun gnus-article-maybe-hide-headers ()
5381 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5382 Provided for backwards compatibility."
5383 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5384 (not (with-current-buffer gnus-summary-buffer
5385 gnus-have-all-headers)))
5386 (not gnus-inhibit-hiding))
5387 (gnus-article-hide-headers)))
5391 (defun gnus-output-to-file (file-name)
5392 "Append the current article to a file named FILE-NAME."
5393 (let ((artbuf (current-buffer)))
5395 (insert-buffer-substring artbuf)
5396 ;; Append newline at end of the buffer as separator, and then
5398 (goto-char (point-max))
5400 (let ((file-name-coding-system nnmail-pathname-coding-system))
5401 (mm-append-to-file (point-min) (point-max) file-name))
5404 (defun gnus-narrow-to-page (&optional arg)
5405 "Narrow the article buffer to a page.
5406 If given a numerical ARG, move forward ARG pages."
5408 (setq arg (if arg (prefix-numeric-value arg) 0))
5410 (set-buffer gnus-article-buffer)
5411 (goto-char (point-min))
5413 ;; Remove any old next/prev buttons.
5414 (when (gnus-visual-p 'page-marker)
5415 (let ((inhibit-read-only t))
5416 (gnus-remove-text-with-property 'gnus-prev)
5417 (gnus-remove-text-with-property 'gnus-next)))
5420 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5422 (re-search-forward page-delimiter nil 'move arg)))
5423 (goto-char (match-end 0))
5425 (goto-char (point-min))
5426 (setq gnus-page-broken
5427 (and (re-search-forward page-delimiter nil t) t))))
5428 (when gnus-page-broken
5431 (if (re-search-forward page-delimiter nil 'move)
5434 (when (and (gnus-visual-p 'page-marker)
5435 (> (point-min) (save-restriction (widen) (point-min))))
5437 (goto-char (point-min))
5438 (gnus-insert-prev-page-button)))
5439 (when (and (gnus-visual-p 'page-marker)
5440 (< (point-max) (save-restriction (widen) (point-max))))
5442 (goto-char (point-max))
5443 (gnus-insert-next-page-button))))))
5445 ;; Article mode commands
5447 (defun gnus-article-goto-next-page ()
5448 "Show the next page of the article."
5450 (when (gnus-article-next-page)
5451 (goto-char (point-min))
5452 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5455 (defun gnus-article-goto-prev-page ()
5456 "Show the previous page of the article."
5459 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5460 (gnus-article-prev-page nil)))
5462 ;; This is cleaner but currently breaks `gnus-pick-mode':
5464 ;; (defun gnus-article-goto-next-page ()
5465 ;; "Show the next page of the article."
5467 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5468 ;; (gnus-summary-next-page)))
5470 ;; (defun gnus-article-goto-prev-page ()
5471 ;; "Show the next page of the article."
5473 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5474 ;; (gnus-summary-prev-page)))
5476 (defun gnus-article-next-page (&optional lines)
5477 "Show the next page of the current article.
5478 If end of article, return non-nil. Otherwise return nil.
5479 Argument LINES specifies lines to be scrolled up."
5481 (move-to-window-line -1)
5484 (and (pos-visible-in-window-p) ;Not continuation line.
5485 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5486 ;; Nothing in this page.
5487 (if (or (not gnus-page-broken)
5492 (eobp)))) ;Real end-of-buffer?
5494 (when gnus-article-over-scroll
5495 (gnus-article-next-page-1 lines))
5497 (gnus-narrow-to-page 1) ;Go to next page.
5499 ;; More in this page.
5500 (gnus-article-next-page-1 lines)
5503 (defmacro gnus-article-beginning-of-window ()
5504 "Move point to the beginning of the window.
5505 In Emacs, the point is placed at the line number which `scroll-margin'
5507 (if (featurep 'xemacs)
5508 '(move-to-window-line 0)
5509 '(move-to-window-line
5510 (min (max 0 scroll-margin)
5511 (max 1 (- (window-height)
5512 (if mode-line-format 1 0)
5513 (if header-line-format 1 0)))))))
5515 (defun gnus-article-next-page-1 (lines)
5516 (when (and (not (featurep 'xemacs))
5519 (numberp (symbol-value 'scroll-margin))
5520 (> (symbol-value 'scroll-margin) 0))
5521 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5522 ;; too many number of lines if `scroll-margin' is set as two or greater.
5523 (setq lines (min lines
5524 (max 0 (- (count-lines (window-start) (point-max))
5525 (symbol-value 'scroll-margin))))))
5527 (let ((scroll-in-place nil))
5530 ;; Long lines may cause an end-of-buffer error.
5531 (goto-char (point-max))))
5532 (gnus-article-beginning-of-window))
5534 (defun gnus-article-prev-page (&optional lines)
5535 "Show previous page of current article.
5536 Argument LINES specifies lines to be scrolled down."
5538 (move-to-window-line 0)
5539 (if (and gnus-page-broken
5541 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5543 (gnus-narrow-to-page -1) ;Go to previous page.
5544 (goto-char (point-max))
5548 (let ((scroll-in-place nil))
5549 (scroll-down lines))
5550 (beginning-of-buffer
5551 (goto-char (point-min))))
5552 (gnus-article-beginning-of-window))))
5554 (defun gnus-article-only-boring-p ()
5555 "Decide whether there is only boring text remaining in the article.
5556 Something \"interesting\" is a word of at least two letters that does
5557 not have a face in `gnus-article-boring-faces'."
5558 (when (and gnus-article-skip-boring
5559 (boundp 'gnus-article-boring-faces)
5560 (symbol-value 'gnus-article-boring-faces))
5562 (let ((inhibit-point-motion-hooks t))
5564 (while (re-search-forward "\\b\\w\\w" nil t)
5566 (when (not (gnus-intersection
5567 (gnus-faces-at (point))
5568 (symbol-value 'gnus-article-boring-faces)))
5569 (throw 'only-boring nil)))
5570 (throw 'only-boring t))))))
5572 (defun gnus-article-refer-article ()
5573 "Read article specified by message-id around point."
5576 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5577 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5578 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5579 (let ((msg-id (concat "<" (match-string 0) ">")))
5580 (set-buffer gnus-summary-buffer)
5581 (gnus-summary-refer-article msg-id))
5582 (error "No references around point"))))
5584 (defun gnus-article-show-summary ()
5585 "Reconfigure windows to show summary buffer."
5587 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5588 (error "There is no summary buffer for this article buffer")
5589 (gnus-article-set-globals)
5590 (gnus-configure-windows 'article)
5591 (gnus-summary-goto-subject gnus-current-article)
5592 (gnus-summary-position-point)))
5594 (defun gnus-article-describe-briefly ()
5595 "Describe article mode commands briefly."
5597 (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")))
5599 (defun gnus-article-summary-command ()
5600 "Execute the last keystroke in the summary buffer."
5602 (let ((obuf (current-buffer))
5603 (owin (current-window-configuration))
5605 (switch-to-buffer gnus-article-current-summary 'norecord)
5606 (setq func (lookup-key (current-local-map) (this-command-keys)))
5607 (call-interactively func)
5609 (set-window-configuration owin)
5610 (set-window-point (get-buffer-window (current-buffer)) (point))))
5612 (defun gnus-article-summary-command-nosave ()
5613 "Execute the last keystroke in the summary buffer."
5616 (pop-to-buffer gnus-article-current-summary 'norecord)
5617 (setq func (lookup-key (current-local-map) (this-command-keys)))
5618 (call-interactively func)))
5620 (defun gnus-article-check-buffer ()
5621 "Beep if not in an article buffer."
5622 (unless (equal major-mode 'gnus-article-mode)
5623 (error "Command invoked outside of a Gnus article buffer")))
5625 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5626 "Read a summary buffer key sequence and execute it from the article buffer."
5628 (gnus-article-check-buffer)
5630 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5631 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5632 "=" "^" "\M-^" "|"))
5638 '("n" "Gn" "p" "Gp"))
5641 (set-buffer gnus-article-current-summary)
5642 (let (gnus-pick-mode)
5643 (push (or key last-command-event) unread-command-events)
5644 (setq keys (if (featurep 'xemacs)
5645 (events-to-keys (read-key-sequence nil))
5646 (read-key-sequence nil)))))
5650 (if (or (member keys nosaves)
5651 (member keys nosave-but-article)
5652 (member keys nosave-in-article))
5654 (save-window-excursion
5655 (pop-to-buffer gnus-article-current-summary 'norecord)
5656 ;; We disable the pick minor mode commands.
5657 (let (gnus-pick-mode)
5658 (setq func (lookup-key (current-local-map) keys))))
5662 (unless (member keys nosave-in-article)
5663 (set-buffer gnus-article-current-summary))
5664 (call-interactively func)
5665 (setq new-sum-point (point)))
5666 (when (member keys nosave-but-article)
5667 (pop-to-buffer gnus-article-buffer 'norecord)))
5668 ;; These commands should restore window configuration.
5669 (let ((obuf (current-buffer))
5670 (owin (current-window-configuration))
5672 win func in-buffer selected new-sum-start new-sum-hscroll)
5673 (cond (not-restore-window
5674 (pop-to-buffer gnus-article-current-summary 'norecord))
5675 ((setq win (get-buffer-window gnus-article-current-summary))
5676 (select-window win))
5678 (switch-to-buffer gnus-article-current-summary 'norecord)))
5679 (setq in-buffer (current-buffer))
5680 ;; We disable the pick minor mode commands.
5681 (if (and (setq func (let (gnus-pick-mode)
5682 (lookup-key (current-local-map) keys)))
5685 (call-interactively func)
5686 (when (eq win (selected-window))
5687 (setq new-sum-point (point)
5688 new-sum-start (window-start win)
5689 new-sum-hscroll (window-hscroll win)))
5690 (when (eq in-buffer (current-buffer))
5691 (setq selected (gnus-summary-select-article))
5693 (unless not-restore-window
5694 (set-window-configuration owin))
5695 (when (eq selected 'old)
5697 (set-window-start (get-buffer-window (current-buffer))
5699 (set-window-point (get-buffer-window (current-buffer))
5701 (when (and (not not-restore-window)
5703 (set-window-point win new-sum-point)
5704 (set-window-start win new-sum-start)
5705 (set-window-hscroll win new-sum-hscroll))))
5706 (set-window-configuration owin)
5709 (defun gnus-article-describe-key (key)
5710 "Display documentation of the function invoked by KEY. KEY is a string."
5711 (interactive "kDescribe key: ")
5712 (gnus-article-check-buffer)
5713 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5715 (set-buffer gnus-article-current-summary)
5716 (let (gnus-pick-mode)
5717 (if (featurep 'xemacs)
5719 (push (elt key 0) unread-command-events)
5720 (setq key (events-to-keys
5721 (read-key-sequence "Describe key: "))))
5722 (setq unread-command-events
5724 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5725 (string-to-list key)))
5726 (setq key (read-key-sequence "Describe key: "))))
5728 (describe-key key)))
5730 (defun gnus-article-describe-key-briefly (key &optional insert)
5731 "Display documentation of the function invoked by KEY. KEY is a string."
5732 (interactive "kDescribe key: \nP")
5733 (gnus-article-check-buffer)
5734 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5736 (set-buffer gnus-article-current-summary)
5737 (let (gnus-pick-mode)
5738 (if (featurep 'xemacs)
5740 (push (elt key 0) unread-command-events)
5741 (setq key (events-to-keys
5742 (read-key-sequence "Describe key: "))))
5743 (setq unread-command-events
5745 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5746 (string-to-list key)))
5747 (setq key (read-key-sequence "Describe key: "))))
5748 (describe-key-briefly key insert))
5749 (describe-key-briefly key insert)))
5751 (defun gnus-article-reply-with-original (&optional wide)
5752 "Start composing a reply mail to the current message.
5753 The text in the region will be yanked. If the region isn't active,
5754 the entire article will be yanked."
5756 (let ((article (cdr gnus-article-current))
5758 (if (not (gnus-region-active-p))
5759 (with-current-buffer gnus-summary-buffer
5760 (gnus-summary-reply (list (list article)) wide))
5761 (setq contents (buffer-substring (point) (mark t)))
5762 ;; Deactivate active regions.
5763 (when (and (boundp 'transient-mark-mode)
5764 transient-mark-mode)
5765 (setq mark-active nil))
5766 (with-current-buffer gnus-summary-buffer
5768 (list (list article contents)) wide)))))
5770 (defun gnus-article-followup-with-original ()
5771 "Compose a followup to the current article.
5772 The text in the region will be yanked. If the region isn't active,
5773 the entire article will be yanked."
5775 (let ((article (cdr gnus-article-current))
5777 (if (not (gnus-region-active-p))
5778 (with-current-buffer gnus-summary-buffer
5779 (gnus-summary-followup (list (list article))))
5780 (setq contents (buffer-substring (point) (mark t)))
5781 ;; Deactivate active regions.
5782 (when (and (boundp 'transient-mark-mode)
5783 transient-mark-mode)
5784 (setq mark-active nil))
5785 (with-current-buffer gnus-summary-buffer
5786 (gnus-summary-followup
5787 (list (list article contents)))))))
5789 (defun gnus-article-hide (&optional arg force)
5790 "Hide all the gruft in the current article.
5791 This means that signatures, cited text and (some) headers will be
5793 If given a prefix, show the hidden text instead."
5794 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5795 (gnus-article-hide-headers arg)
5796 (gnus-article-hide-list-identifiers arg)
5797 (gnus-article-hide-citation-maybe arg force)
5798 (gnus-article-hide-signature arg))
5800 (defun gnus-article-maybe-highlight ()
5801 "Do some article highlighting if article highlighting is requested."
5802 (when (gnus-visual-p 'article-highlight 'highlight)
5803 (gnus-article-highlight-some)))
5805 (defun gnus-check-group-server ()
5806 ;; Make sure the connection to the server is alive.
5807 (unless (gnus-server-opened
5808 (gnus-find-method-for-group gnus-newsgroup-name))
5809 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5810 (gnus-request-group gnus-newsgroup-name t)))
5813 (autoload 'nneething-get-file-name "nneething"))
5815 (defun gnus-request-article-this-buffer (article group)
5816 "Get an article and insert it into this buffer."
5817 (let (do-update-line sparse-header)
5821 (gnus-kill-all-overlays)
5822 (setq group (or group gnus-newsgroup-name))
5824 ;; Using `gnus-request-article' directly will insert the article into
5825 ;; `nntp-server-buffer' - so we'll save some time by not having to
5826 ;; copy it from the server buffer into the article buffer.
5828 ;; We only request an article by message-id when we do not have the
5829 ;; headers for it, so we'll have to get those.
5830 (when (stringp article)
5831 (gnus-read-header article))
5833 ;; If the article number is negative, that means that this article
5834 ;; doesn't belong in this newsgroup (possibly), so we find its
5835 ;; message-id and request it by id instead of number.
5836 (when (and (numberp article)
5838 (get-buffer gnus-summary-buffer)
5839 (gnus-buffer-exists-p gnus-summary-buffer))
5841 (set-buffer gnus-summary-buffer)
5842 (let ((header (gnus-summary-article-header article)))
5845 ((memq article gnus-newsgroup-sparse)
5846 ;; This is a sparse gap article.
5847 (setq do-update-line article)
5848 (setq article (mail-header-id header))
5849 (setq sparse-header (gnus-read-header article))
5850 (setq gnus-newsgroup-sparse
5851 (delq article gnus-newsgroup-sparse)))
5853 ;; It's a real article.
5854 (setq article (mail-header-id header)))
5856 ;; It is an extracted pseudo-article.
5857 (setq article 'pseudo)
5858 (gnus-request-pseudo-article header))))
5860 (let ((method (gnus-find-method-for-group
5861 gnus-newsgroup-name)))
5862 (when (and (eq (car method) 'nneething)
5864 (let ((dir (nneething-get-file-name
5865 (mail-header-id header))))
5866 (when (and (stringp dir)
5867 (file-directory-p dir))
5868 (setq article 'nneething)
5869 (gnus-group-enter-directory dir))))))))
5872 ;; Refuse to select canceled articles.
5873 ((and (numberp article)
5875 (get-buffer gnus-summary-buffer)
5876 (gnus-buffer-exists-p gnus-summary-buffer)
5877 (eq (cdr (with-current-buffer gnus-summary-buffer
5878 (assq article gnus-newsgroup-reads)))
5879 gnus-canceled-mark))
5881 ;; We first check `gnus-original-article-buffer'.
5882 ((and (get-buffer gnus-original-article-buffer)
5884 (with-current-buffer gnus-original-article-buffer
5885 (and (equal (car gnus-original-article) group)
5886 (eq (cdr gnus-original-article) article))))
5887 (insert-buffer-substring gnus-original-article-buffer)
5889 ;; Check the backlog.
5890 ((and gnus-keep-backlog
5891 (gnus-backlog-request-article group article (current-buffer)))
5893 ;; Check asynchronous pre-fetch.
5894 ((gnus-async-request-fetched-article group article (current-buffer))
5895 (gnus-async-prefetch-next group article gnus-summary-buffer)
5896 (when (and (numberp article) gnus-keep-backlog)
5897 (gnus-backlog-enter-article group article (current-buffer)))
5900 ((and gnus-use-cache
5902 (gnus-cache-request-article article group))
5904 ;; Check the agent cache.
5905 ((gnus-agent-request-article article group)
5907 ;; Get the article and put into the article buffer.
5908 ((or (stringp article)
5910 (let ((gnus-override-method gnus-override-method)
5911 (methods (and (stringp article)
5912 gnus-refer-article-method))
5913 (backend (car (gnus-find-method-for-group
5914 gnus-newsgroup-name)))
5916 (inhibit-read-only t))
5917 (if (or (not (listp methods))
5918 (and (symbolp (car methods))
5919 (assq (car methods) nnoo-definition-alist)))
5920 (setq methods (list methods)))
5921 (when (and (null gnus-override-method)
5923 (setq gnus-override-method (pop methods)))
5925 (when (eq gnus-override-method 'current)
5926 (setq gnus-override-method
5927 (with-current-buffer gnus-summary-buffer
5928 gnus-current-select-method)))
5930 (gnus-kill-all-overlays)
5931 (let ((gnus-newsgroup-name group))
5932 (gnus-check-group-server))
5934 ((gnus-request-article article group (current-buffer))
5935 (when (numberp article)
5936 (gnus-async-prefetch-next group article
5937 gnus-summary-buffer)
5938 (when gnus-keep-backlog
5939 (gnus-backlog-enter-article
5940 group article (current-buffer))))
5941 (setq result 'article))
5943 (setq gnus-override-method (pop methods)))
5944 ((not (string-match "^400 "
5945 (nnheader-get-report backend)))
5946 ;; If we get 400 server disconnect, reconnect and
5947 ;; retry; otherwise, assume the article has expired.
5948 (setq result 'done))))
5949 (and (eq result 'article) 'article)))
5953 ;; Associate this article with the current summary buffer.
5954 (setq gnus-article-current-summary gnus-summary-buffer)
5956 ;; Take the article from the original article buffer
5957 ;; and place it in the buffer it's supposed to be in.
5958 (when (and (get-buffer gnus-article-buffer)
5959 (equal (buffer-name (current-buffer))
5960 (buffer-name (get-buffer gnus-article-buffer))))
5962 (if (get-buffer gnus-original-article-buffer)
5963 (set-buffer gnus-original-article-buffer)
5964 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5965 (buffer-disable-undo)
5966 (setq major-mode 'gnus-original-article-mode)
5967 (setq buffer-read-only t))
5968 (let ((inhibit-read-only t))
5970 (insert-buffer-substring gnus-article-buffer))
5971 (setq gnus-original-article (cons group article)))
5974 (run-hooks 'gnus-article-decode-hook)
5975 ;; Mark article as decoded or not.
5976 (setq gnus-article-decoded-p gnus-article-decode-hook))
5978 ;; Update sparse articles.
5979 (when (and do-update-line
5980 (or (numberp article)
5982 (let ((buf (current-buffer)))
5983 (set-buffer gnus-summary-buffer)
5984 (gnus-summary-update-article do-update-line sparse-header)
5985 (gnus-summary-goto-subject do-update-line nil t)
5986 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5988 (set-buffer buf))))))
5994 (defcustom gnus-article-edit-mode-hook nil
5995 "Hook run in article edit mode buffers."
5996 :group 'gnus-article-various
5999 (defvar gnus-article-edit-done-function nil)
6001 (defvar gnus-article-edit-mode-map nil)
6003 ;; Should we be using derived.el for this?
6004 (unless gnus-article-edit-mode-map
6005 (setq gnus-article-edit-mode-map (make-keymap))
6006 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6008 (gnus-define-keys gnus-article-edit-mode-map
6009 "\C-c?" describe-mode
6010 "\C-c\C-c" gnus-article-edit-done
6011 "\C-c\C-k" gnus-article-edit-exit
6012 "\C-c\C-f\C-t" message-goto-to
6013 "\C-c\C-f\C-o" message-goto-from
6014 "\C-c\C-f\C-b" message-goto-bcc
6015 ;;"\C-c\C-f\C-w" message-goto-fcc
6016 "\C-c\C-f\C-c" message-goto-cc
6017 "\C-c\C-f\C-s" message-goto-subject
6018 "\C-c\C-f\C-r" message-goto-reply-to
6019 "\C-c\C-f\C-n" message-goto-newsgroups
6020 "\C-c\C-f\C-d" message-goto-distribution
6021 "\C-c\C-f\C-f" message-goto-followup-to
6022 "\C-c\C-f\C-m" message-goto-mail-followup-to
6023 "\C-c\C-f\C-k" message-goto-keywords
6024 "\C-c\C-f\C-u" message-goto-summary
6025 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6026 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6027 "\C-c\C-b" message-goto-body
6028 "\C-c\C-i" message-goto-signature
6030 "\C-c\C-t" message-insert-to
6031 "\C-c\C-n" message-insert-newsgroups
6032 "\C-c\C-o" message-sort-headers
6033 "\C-c\C-e" message-elide-region
6034 "\C-c\C-v" message-delete-not-region
6035 "\C-c\C-z" message-kill-to-signature
6036 "\M-\r" message-newline-and-reformat
6037 "\C-c\C-a" mml-attach-file
6038 "\C-a" message-beginning-of-line
6040 "\M-;" comment-region)
6042 (gnus-define-keys (gnus-article-edit-wash-map
6043 "\C-c\C-w" gnus-article-edit-mode-map)
6044 "f" gnus-article-edit-full-stops))
6047 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6049 ["Fetch To" message-insert-to t]
6050 ["Fetch Newsgroups" message-insert-newsgroups t]
6052 ["To" message-goto-to t]
6053 ["From" message-goto-from t]
6054 ["Subject" message-goto-subject t]
6055 ["Cc" message-goto-cc t]
6056 ["Reply-To" message-goto-reply-to t]
6057 ["Summary" message-goto-summary t]
6058 ["Keywords" message-goto-keywords t]
6059 ["Newsgroups" message-goto-newsgroups t]
6060 ["Followup-To" message-goto-followup-to t]
6061 ["Mail-Followup-To" message-goto-mail-followup-to t]
6062 ["Distribution" message-goto-distribution t]
6063 ["Body" message-goto-body t]
6064 ["Signature" message-goto-signature t]))
6066 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6067 "Major mode for editing articles.
6068 This is an extended text-mode.
6070 \\{gnus-article-edit-mode-map}"
6071 (make-local-variable 'gnus-article-edit-done-function)
6072 (make-local-variable 'gnus-prev-winconf)
6073 (set (make-local-variable 'font-lock-defaults)
6074 '(message-font-lock-keywords t))
6075 (set (make-local-variable 'mail-header-separator) "")
6076 (set (make-local-variable 'gnus-article-edit-mode) t)
6077 (easy-menu-add message-mode-field-menu message-mode-map)
6079 (setq buffer-read-only nil)
6080 (buffer-enable-undo)
6083 (defun gnus-article-edit (&optional force)
6084 "Edit the current article.
6085 This will have permanent effect only in mail groups.
6086 If FORCE is non-nil, allow editing of articles even in read-only
6089 (when (and (not force)
6090 (gnus-group-read-only-p))
6091 (error "The current newsgroup does not support article editing"))
6092 (gnus-article-date-original)
6093 (gnus-article-edit-article
6095 `(lambda (no-highlight)
6097 (gnus-summary-edit-article-done
6098 ,(or (mail-header-references gnus-current-headers) "")
6099 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6101 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6102 "Start editing the contents of the current article buffer."
6103 (let ((winconf (current-window-configuration)))
6104 (set-buffer gnus-article-buffer)
6105 (let ((message-auto-save-directory
6106 ;; Don't associate the article buffer with a draft file.
6108 (gnus-article-edit-mode))
6109 (funcall start-func)
6110 (set-buffer-modified-p nil)
6111 (gnus-configure-windows 'edit-article)
6112 (setq gnus-article-edit-done-function exit-func)
6113 (setq gnus-prev-winconf winconf)
6115 (gnus-message 6 "C-c C-c to end edits"))))
6117 (defun gnus-article-edit-done (&optional arg)
6118 "Update the article edits and exit."
6120 (let ((func gnus-article-edit-done-function)
6121 (buf (current-buffer))
6122 (start (window-start))
6124 (winconf gnus-prev-winconf))
6125 (widen) ;; Widen it in case that users narrowed the buffer.
6128 ;; The cache and backlog have to be flushed somewhat.
6129 (when gnus-keep-backlog
6130 (gnus-backlog-remove-article
6131 (car gnus-article-current) (cdr gnus-article-current)))
6132 ;; Flush original article as well.
6134 (when (get-buffer gnus-original-article-buffer)
6135 (set-buffer gnus-original-article-buffer)
6136 (setq gnus-original-article nil)))
6137 (when gnus-use-cache
6138 (gnus-cache-update-article
6139 (car gnus-article-current) (cdr gnus-article-current)))
6140 ;; We remove all text props from the article buffer.
6141 (kill-all-local-variables)
6142 (set-text-properties (point-min) (point-max) nil)
6144 (set-window-configuration winconf)
6146 (set-window-start (get-buffer-window buf) start)
6147 (set-window-point (get-buffer-window buf) (point)))
6148 (gnus-summary-show-article))
6150 (defun gnus-article-edit-exit ()
6151 "Exit the article editing without updating."
6153 (when (or (not (buffer-modified-p))
6154 (yes-or-no-p "Article modified; kill anyway? "))
6155 (let ((curbuf (current-buffer))
6157 (window-start (window-start)))
6159 (if (gnus-buffer-live-p gnus-original-article-buffer)
6160 (insert-buffer-substring gnus-original-article-buffer))
6161 (let ((winconf gnus-prev-winconf))
6162 (kill-all-local-variables)
6164 (set-window-configuration winconf)
6165 ;; Tippy-toe some to make sure that point remains where it was.
6166 (save-current-buffer
6168 (set-window-start (get-buffer-window (current-buffer)) window-start)
6170 (gnus-summary-show-article)))
6172 (defun gnus-article-edit-full-stops ()
6173 "Interactively repair spacing at end of sentences."
6176 (goto-char (point-min))
6177 (search-forward-regexp "^$" nil t)
6178 (let ((case-fold-search nil))
6179 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6182 ;;; Article highlights
6185 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6187 ;;; Internal Variables:
6189 (defcustom gnus-button-url-regexp
6190 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6191 "\\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:]]\\)"
6192 "\\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\\)\\)")
6193 "Regular expression that matches URLs."
6194 :group 'gnus-article-buttons
6197 (defcustom gnus-button-valid-fqdn-regexp
6198 message-valid-fqdn-regexp
6199 "Regular expression that matches a valid FQDN."
6201 :group 'gnus-article-buttons
6204 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6205 (defcustom gnus-button-valid-localpart-regexp
6206 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6207 "Regular expression that matches a localpart of mail addresses or MIDs."
6209 :group 'gnus-article-buttons
6212 (defcustom gnus-button-man-handler 'manual-entry
6213 "Function to use for displaying man pages.
6214 The function must take at least one argument with a string naming the
6217 :type '(choice (function-item :tag "Man" manual-entry)
6218 (function-item :tag "Woman" woman)
6219 (function :tag "Other"))
6220 :group 'gnus-article-buttons)
6222 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6223 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6224 If the default site is too slow, try to find a CTAN mirror, see
6225 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6226 the variable `gnus-button-handle-ctan'."
6228 :group 'gnus-article-buttons
6229 :link '(custom-manual "(gnus)Group Parameters")
6230 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6231 (const "http://tug.ctan.org/tex-archive/")
6232 (const "http://www.dante.de/CTAN/")
6233 (string :tag "Other")))
6235 (defcustom gnus-button-ctan-handler 'browse-url
6236 "Function to use for displaying CTAN links.
6237 The function must take one argument, the string naming the URL."
6239 :type '(choice (function-item :tag "Browse Url" browse-url)
6240 (function :tag "Other"))
6241 :group 'gnus-article-buttons)
6243 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6244 "Bogus strings removed from CTAN URLs."
6246 :group 'gnus-article-buttons
6247 :type '(choice (const "^/?tex-archive/\\|/")
6248 (regexp :tag "Other")))
6250 (defcustom gnus-button-ctan-directory-regexp
6252 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6253 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6254 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6255 "tds" "tools" "usergrps" "web") t)
6256 "Regular expression for ctan directories.
6257 It should match all directories in the top level of `gnus-ctan-url'."
6259 :group 'gnus-article-buttons
6262 (defcustom gnus-button-mid-or-mail-regexp
6263 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6264 gnus-button-valid-fqdn-regexp
6266 "Regular expression that matches a message ID or a mail address."
6268 :group 'gnus-article-buttons
6271 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6272 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6273 Strings like this can be either a message ID or a mail address. If it is one
6274 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6275 message ID or a mail address, respectively. If this variable is set to the
6276 symbol `ask', always query the user what do do. If it is a function, this
6277 function will be called with the string as it's only argument. The function
6278 must return `mid', `mail', `invalid' or `ask'."
6280 :group 'gnus-article-buttons
6281 :type '(choice (function-item :tag "Heuristic function"
6282 gnus-button-mid-or-mail-heuristic)
6287 (defcustom gnus-button-mid-or-mail-heuristic-alist
6288 '((-10.0 . ".+\\$.+@")
6291 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6292 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6293 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6294 (-1.0 . "^[^a-z]+@")
6296 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6297 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6298 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6299 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6302 (-1.0 . "^[0-9][0-9]")
6304 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6305 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6306 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6307 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6309 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6310 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6313 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6315 ;; compensation for TDMA dated mail addresses:
6316 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6318 (-20.0 . "\\.fsf@") ;; Gnus
6321 (-20.0 . "_-_") ;; Subject change in thread
6323 (-20.0 . "\\.ln@") ;; leafnode
6324 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6325 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6327 ;; (5.0 . "") ;; $local_part_len <= 7
6328 (10.0 . "^[^0-9]+@")
6329 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6330 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6333 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6335 (0.5 . "^[A-Z][a-z]")
6336 (0.5 . "^[A-Z][a-z][a-z]")
6337 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6338 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6339 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6341 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6342 address. The REGEXP is processed with `case-fold-search' set to nil."
6344 :group 'gnus-article-buttons
6345 :type '(repeat (cons (number :tag "Rate")
6346 (regexp :tag "Regexp"))))
6348 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6349 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6350 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6351 address, `ask' if unsure and `invalid' if the string is invalid."
6352 (let ((case-fold-search nil)
6353 (list gnus-button-mid-or-mail-heuristic-alist)
6354 (result 0) rate regexp lpartlen elem)
6356 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6357 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6358 ;; Certain special cases...
6361 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6362 "^[0-9]+\\.[0-9]+@compuserve\\|"
6363 "@public\\.gmane\\.org")
6365 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6366 (setq result 'mail))
6367 (when (string-match "@.*@\\| " mid-or-mail)
6368 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6369 (setq result 'invalid))
6370 ;; Nothing more to do, if result is not a number here...
6371 (when (numberp result)
6373 (setq elem (car list)
6377 (when (string-match regexp mid-or-mail)
6378 (setq result (+ result rate))
6380 9 "`%s' matched `%s', rate `%s', result `%s'."
6381 mid-or-mail regexp rate result)))
6382 (when (<= lpartlen 7)
6383 (setq result (+ result 5.0))
6384 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6385 mid-or-mail result))
6386 (when (>= lpartlen 12)
6387 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6389 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6390 ;; Long local part should contain realname if e-mail address,
6391 ;; too many digits: message-id.
6392 ;; $score -= 5.0 + 0.1 * $local_part_len;
6393 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6394 (setq result (+ result rate))
6396 9 "Many digits in `%s', rate `%s', result `%s'."
6397 mid-or-mail rate result))
6398 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6400 ;; Too few vowels [^aeiouy]{4,}.*\@
6401 (setq result (+ result -5.0))
6403 9 "Few vowels in `%s', rate `%s', result `%s'."
6404 mid-or-mail -5.0 result))
6406 (setq result (+ result 5.0))
6408 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6409 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6410 ;; Maybe we should make this a customizable alist: (condition . 'result)
6412 ((symbolp result) result)
6413 ;; Now convert number into proper results:
6414 ((< result -10.0) 'mid)
6415 ((> result 10.0) 'mail)
6418 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6419 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6420 (url-mid (concat "news" ":" mid-or-mail))
6421 (url-mailto (concat "mailto" ":" mid-or-mail)))
6422 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6423 (when (fboundp pref)
6425 ;; get rid of surrounding angles...
6427 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6428 (if (or (eq 'mid guessed) (eq 'mail guessed))
6432 (save-window-excursion
6433 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6436 (cond ((eq pref 'mid)
6437 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6438 (gnus-button-handle-news url-mid))
6440 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6441 (gnus-url-mailto url-mailto))
6442 (t (gnus-message 3 "Invalid string.")))))
6444 (defun gnus-button-handle-custom (fun arg)
6445 "Call function FUN on argument ARG.
6446 Both FUN and ARG are supposed to be strings. ARG will be passed
6447 as a symbol to FUN."
6448 (funcall (intern fun) (intern arg)))
6450 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6452 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6455 (defun gnus-button-handle-describe-function (url)
6456 "Call `describe-function' when pushing the corresponding URL button."
6459 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6461 (defun gnus-button-handle-describe-variable (url)
6462 "Call `describe-variable' when pushing the corresponding URL button."
6465 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6467 (defun gnus-button-handle-symbol (url)
6468 "Display help on variable or function.
6469 Calls `describe-variable' or `describe-function'."
6470 (let ((sym (intern url)))
6472 ((fboundp sym) (describe-function sym))
6473 ((boundp sym) (describe-variable sym))
6474 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6476 (defun gnus-button-handle-describe-key (url)
6477 "Call `describe-key' when pushing the corresponding URL button."
6479 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6480 (keys (ignore-errors (eval `(kbd ,key-string)))))
6483 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6485 (defun gnus-button-handle-apropos (url)
6486 "Call `apropos' when pushing the corresponding URL button."
6487 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6489 (defun gnus-button-handle-apropos-command (url)
6490 "Call `apropos' when pushing the corresponding URL button."
6492 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6494 (defun gnus-button-handle-apropos-variable (url)
6495 "Call `apropos' when pushing the corresponding URL button."
6497 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6498 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6500 (defun gnus-button-handle-apropos-documentation (url)
6501 "Call `apropos' when pushing the corresponding URL button."
6503 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6504 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6506 (defun gnus-button-handle-library (url)
6507 "Call `locate-library' when pushing the corresponding URL button."
6508 (gnus-message 9 "url=`%s'" url)
6509 (let* ((lib (locate-library url))
6510 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6512 (gnus-message 1 "Cannot locale library `%s'." url)
6513 (find-file-read-only file))))
6515 (defun gnus-button-handle-ctan (url)
6516 "Call `browse-url' when pushing a CTAN URL button."
6518 gnus-button-ctan-handler
6521 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6523 (defcustom gnus-button-tex-level 5
6524 "*Integer that says how many TeX-related buttons Gnus will show.
6525 The higher the number, the more buttons will appear and the more false
6526 positives are possible. Note that you can set this variable local to
6527 specific groups. Setting it higher in TeX groups is probably a good idea.
6528 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6529 how to set variables in specific groups."
6531 :group 'gnus-article-buttons
6532 :link '(custom-manual "(gnus)Group Parameters")
6535 (defcustom gnus-button-man-level 5
6536 "*Integer that says how many man-related buttons Gnus will show.
6537 The higher the number, the more buttons will appear and the more false
6538 positives are possible. Note that you can set this variable local to
6539 specific groups. Setting it higher in Unix groups is probably a good idea.
6540 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6541 how to set variables in specific groups."
6543 :group 'gnus-article-buttons
6544 :link '(custom-manual "(gnus)Group Parameters")
6547 (defcustom gnus-button-emacs-level 5
6548 "*Integer that says how many emacs-related buttons Gnus will show.
6549 The higher the number, the more buttons will appear and the more false
6550 positives are possible. Note that you can set this variable local to
6551 specific groups. Setting it higher in Emacs or Gnus related groups is
6552 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6553 `gnus-parameters' on how to set variables in specific groups."
6555 :group 'gnus-article-buttons
6556 :link '(custom-manual "(gnus)Group Parameters")
6559 (defcustom gnus-button-message-level 5
6560 "*Integer that says how many buttons for news or mail messages will appear.
6561 The higher the number, the more buttons will appear and the more false
6562 positives are possible."
6563 ;; mail addresses, MIDs, URLs for news, ...
6565 :group 'gnus-article-buttons
6568 (defcustom gnus-button-browse-level 5
6569 "*Integer that says how many buttons for browsing will appear.
6570 The higher the number, the more buttons will appear and the more false
6571 positives are possible."
6572 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6574 :group 'gnus-article-buttons
6577 (defcustom gnus-button-alist
6578 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6579 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6580 ((concat "\\b\\(nntp\\|news\\):\\("
6581 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6582 0 t gnus-button-handle-news 2)
6583 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6584 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6585 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6586 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6587 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6588 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6589 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6590 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6591 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6592 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6593 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6594 ;; RFC 2368 (The mailto URL scheme)
6595 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6596 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6597 ("\\bmailto:\\([^ \n\t]+\\)"
6598 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6600 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6601 gnus-button-ctan-directory-regexp
6602 "[^][>)!;:,'\n\t ]+\\)")
6603 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6604 ((concat "\\btex-archive/\\("
6605 gnus-button-ctan-directory-regexp
6606 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6607 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6610 gnus-button-ctan-directory-regexp
6611 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6612 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6613 ;; This is info (home-grown style) <info://foo/bar+baz>
6614 ("\\binfo://\\([^'\">\n\t ]+\\)"
6615 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6616 ;; Info GNOME style <info:foo#bar_baz>
6617 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6618 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6619 ;; Info KDE style <info:(foo)bar baz>
6620 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6621 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6622 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6623 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6624 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6625 ;; Info links like `C-h i d m CC Mode RET'
6626 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6628 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6629 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6630 ;; Emacs help commands
6631 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6632 ;; regexp doesn't match arguments containing ` '.
6633 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6634 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6635 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6636 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6637 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6638 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6639 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6640 ;; The following entries may lead to many false positives so don't enable
6641 ;; them by default (use a high button level).
6642 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6643 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6644 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6645 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6646 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6647 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6648 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6649 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6650 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6651 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6652 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6653 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6654 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6655 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6656 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6657 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6658 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6659 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6660 ;; Unlike the other regexps we really have to require quoting
6661 ;; here to determine where it ends.
6662 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6663 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6664 ("<URL: *\\([^<>]*\\)>"
6665 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6666 ;; RFC 2396 (2.4.3., delims) ...
6667 ("\"URL: *\\([^\"]*\\)\""
6668 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6669 ;; RFC 2396 (2.4.3., delims) ...
6670 ("\"URL: *\\([^\"]*\\)\""
6671 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6673 (gnus-button-url-regexp
6674 0 (>= gnus-button-browse-level 0) browse-url 0)
6676 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6677 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6678 gnus-button-handle-man 1)
6679 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6680 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6681 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6682 gnus-button-handle-man 1)
6683 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6684 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6685 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6686 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6687 ;; MID or mail: To avoid too many false positives we don't try to catch
6688 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6689 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6690 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6691 ;; so that non-ambiguous entries (see above) match first.
6692 (gnus-button-mid-or-mail-regexp
6693 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6694 "*Alist of regexps matching buttons in article bodies.
6696 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6697 REGEXP: is the string (case insensitive) matching text around the button (can
6698 also be Lisp expression evaluating to a string),
6699 BUTTON: is the number of the regexp grouping actually matching the button,
6700 FORM: is a Lisp expression which must eval to true for the button to
6702 CALLBACK: is the function to call when the user push this button, and each
6703 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6705 CALLBACK can also be a variable, in that case the value of that
6706 variable it the real callback function."
6707 :group 'gnus-article-buttons
6708 :type '(repeat (list (choice regexp variable sexp)
6709 (integer :tag "Button")
6711 (function :tag "Callback")
6714 (integer :tag "Regexp group")))))
6716 (defcustom gnus-header-button-alist
6717 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6718 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6719 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6720 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6721 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6722 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6723 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6724 0 (>= gnus-button-browse-level 0) browse-url 0)
6725 ("^Subject:" gnus-button-url-regexp
6726 0 (>= gnus-button-browse-level 0) browse-url 0)
6727 ("^[^:]+:" gnus-button-url-regexp
6728 0 (>= gnus-button-browse-level 0) browse-url 0)
6729 ("^OpenPGP:.*url=" gnus-button-url-regexp
6730 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6731 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6732 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6733 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6734 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6735 "*Alist of headers and regexps to match buttons in article heads.
6737 This alist is very similar to `gnus-button-alist', except that each
6738 alist has an additional HEADER element first in each entry:
6740 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6742 HEADER is a regexp to match a header. For a fuller explanation, see
6743 `gnus-button-alist'."
6744 :group 'gnus-article-buttons
6745 :group 'gnus-article-headers
6746 :type '(repeat (list (regexp :tag "Header")
6747 (choice regexp variable)
6748 (integer :tag "Button")
6750 (function :tag "Callback")
6753 (integer :tag "Regexp group")))))
6757 (defun gnus-article-push-button (event)
6758 "Check text under the mouse pointer for a callback function.
6759 If the text under the mouse pointer has a `gnus-callback' property,
6760 call it with the value of the `gnus-data' text property."
6762 (set-buffer (window-buffer (posn-window (event-start event))))
6763 (let* ((pos (posn-point (event-start event)))
6764 (data (get-text-property pos 'gnus-data))
6765 (fun (get-text-property pos 'gnus-callback)))
6768 (funcall fun data))))
6770 (defun gnus-article-press-button ()
6771 "Check text at point for a callback function.
6772 If the text at point has a `gnus-callback' property,
6773 call it with the value of the `gnus-data' text property."
6775 (let ((data (get-text-property (point) 'gnus-data))
6776 (fun (get-text-property (point) 'gnus-callback)))
6778 (funcall fun data))))
6780 (defun gnus-article-highlight (&optional force)
6781 "Highlight current article.
6782 This function calls `gnus-article-highlight-headers',
6783 `gnus-article-highlight-citation',
6784 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6785 do the highlighting. See the documentation for those functions."
6786 (interactive (list 'force))
6787 (gnus-article-highlight-headers)
6788 (gnus-article-highlight-citation force)
6789 (gnus-article-highlight-signature)
6790 (gnus-article-add-buttons force)
6791 (gnus-article-add-buttons-to-head))
6793 (defun gnus-article-highlight-some (&optional force)
6794 "Highlight current article.
6795 This function calls `gnus-article-highlight-headers',
6796 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6797 do the highlighting. See the documentation for those functions."
6798 (interactive (list 'force))
6799 (gnus-article-highlight-headers)
6800 (gnus-article-highlight-signature)
6801 (gnus-article-add-buttons))
6803 (defun gnus-article-highlight-headers ()
6804 "Highlight article headers as specified by `gnus-header-face-alist'."
6806 (gnus-with-article-headers
6807 (let (regexp header-face field-face from hpoints fpoints)
6808 (dolist (entry gnus-header-face-alist)
6809 (goto-char (point-min))
6810 (setq regexp (concat "^\\("
6811 (if (string-equal "" (nth 0 entry))
6815 header-face (nth 1 entry)
6816 field-face (nth 2 entry))
6817 (while (and (re-search-forward regexp nil t)
6821 (unless (search-forward ":" nil t)
6823 (when (and header-face
6824 (not (memq (point) hpoints)))
6825 (push (point) hpoints)
6826 (gnus-put-text-property from (point) 'face header-face))
6827 (when (and field-face
6828 (not (memq (setq from (point)) fpoints)))
6830 (if (re-search-forward "^[^ \t]" nil t)
6832 (goto-char (point-max)))
6833 (gnus-put-text-property from (point) 'face field-face)))))))
6835 (defun gnus-article-highlight-signature ()
6836 "Highlight the signature in an article.
6837 It does this by highlighting everything after
6838 `gnus-signature-separator' using the face `gnus-signature'."
6840 (gnus-with-article-buffer
6841 (let ((inhibit-point-motion-hooks t))
6843 (when (and gnus-signature-face
6844 (gnus-article-narrow-to-signature))
6845 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6846 'face gnus-signature-face)
6848 (gnus-article-search-signature)
6849 (let ((start (match-beginning 0))
6850 (end (set-marker (make-marker) (1+ (match-end 0)))))
6851 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6854 (defun gnus-button-in-region-p (b e prop)
6855 "Say whether PROP exists in the region."
6856 (text-property-not-all b e prop nil))
6858 (defun gnus-article-add-buttons (&optional force)
6859 "Find external references in the article and make buttons of them.
6860 \"External references\" are things like Message-IDs and URLs, as
6861 specified by `gnus-button-alist'."
6862 (interactive (list 'force))
6863 (gnus-with-article-buffer
6864 (let ((inhibit-point-motion-hooks t)
6865 (case-fold-search t)
6866 (alist gnus-button-alist)
6868 ;; Remove all old markers.
6869 (let (marker entry new-list)
6870 (while (setq marker (pop gnus-button-marker-list))
6871 (if (or (< marker (point-min)) (>= marker (point-max)))
6872 (push marker new-list)
6874 (when (setq entry (gnus-button-entry))
6875 (put-text-property (match-beginning (nth 1 entry))
6876 (match-end (nth 1 entry))
6877 'gnus-callback nil))
6878 (set-marker marker nil)))
6879 (setq gnus-button-marker-list new-list))
6880 ;; We skip the headers.
6883 (while (setq entry (pop alist))
6884 (setq regexp (eval (car entry)))
6886 (while (re-search-forward regexp nil t)
6887 (let* ((start (and entry (match-beginning (nth 1 entry))))
6888 (end (and entry (match-end (nth 1 entry))))
6889 (from (match-beginning 0)))
6890 (when (and (or (eq t (nth 2 entry))
6891 (eval (nth 2 entry)))
6892 (not (gnus-button-in-region-p
6893 start end 'gnus-callback)))
6894 ;; That optional form returned non-nil, so we add the
6896 (gnus-article-add-button
6897 start end 'gnus-button-push
6898 (car (push (set-marker (make-marker) from)
6899 gnus-button-marker-list))))))))))
6901 ;; Add buttons to the head of an article.
6902 (defun gnus-article-add-buttons-to-head ()
6903 "Add buttons to the head of the article."
6905 (gnus-with-article-headers
6907 (dolist (entry gnus-header-button-alist)
6908 ;; Each alist entry.
6909 (goto-char (point-min))
6910 (while (re-search-forward (car entry) nil t)
6911 ;; Each header matching the entry.
6912 (setq beg (match-beginning 0))
6913 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6914 (match-beginning 0))
6917 (while (re-search-forward (eval (nth 1 entry)) end t)
6918 ;; Each match within a header.
6919 (let* ((entry (cdr entry))
6920 (start (match-beginning (nth 1 entry)))
6921 (end (match-end (nth 1 entry)))
6922 (form (nth 2 entry)))
6923 (goto-char (match-end 0))
6925 (gnus-article-add-button
6926 start end (nth 3 entry)
6927 (buffer-substring (match-beginning (nth 4 entry))
6928 (match-end (nth 4 entry)))))))
6929 (goto-char end))))))
6931 ;;; External functions:
6933 (defun gnus-article-add-button (from to fun &optional data)
6934 "Create a button between FROM and TO with callback FUN and data DATA."
6935 (when gnus-article-button-face
6936 (gnus-overlay-put (gnus-make-overlay from to)
6937 'face gnus-article-button-face))
6938 (gnus-add-text-properties
6940 (nconc (and gnus-article-mouse-face
6941 (list gnus-mouse-face-prop gnus-article-mouse-face))
6942 (list 'gnus-callback fun)
6943 (and data (list 'gnus-data data))))
6944 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6945 :button-keymap gnus-widget-button-keymap))
6947 ;;; Internal functions:
6949 (defun gnus-article-set-globals ()
6950 (with-current-buffer gnus-summary-buffer
6951 (gnus-set-global-variables)))
6953 (defun gnus-signature-toggle (end)
6954 (gnus-with-article-buffer
6955 (let ((inhibit-point-motion-hooks t))
6956 (if (text-property-any end (point-max) 'article-type 'signature)
6958 (gnus-delete-wash-type 'signature)
6959 (gnus-remove-text-properties-when
6960 'article-type 'signature end (point-max)
6961 (cons 'article-type (cons 'signature
6962 gnus-hidden-properties))))
6963 (gnus-add-wash-type 'signature)
6964 (gnus-add-text-properties-when
6965 'article-type nil end (point-max)
6966 (cons 'article-type (cons 'signature
6967 gnus-hidden-properties)))))
6968 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6969 (gnus-set-mode-line 'article))))
6971 (defun gnus-button-entry ()
6972 ;; Return the first entry in `gnus-button-alist' matching this place.
6973 (let ((alist gnus-button-alist)
6976 (setq entry (pop alist))
6977 (if (looking-at (eval (car entry)))
6982 (defun gnus-button-push (marker)
6983 ;; Push button starting at MARKER.
6986 (let* ((entry (gnus-button-entry))
6987 (inhibit-point-motion-hooks t)
6989 (args (mapcar (lambda (group)
6990 (let ((string (match-string group)))
6991 (set-text-properties
6992 0 (length string) nil string)
6999 (fboundp (symbol-value fun)))
7000 (apply (symbol-value fun) args))
7002 (gnus-message 1 "You must define `%S' to use this button"
7003 (cons fun args)))))))
7005 (defun gnus-parse-news-url (url)
7006 (let (scheme server port group message-id articles)
7009 (goto-char (point-min))
7010 (when (looking-at "\\([A-Za-z]+\\):")
7011 (setq scheme (match-string 1))
7012 (goto-char (match-end 0)))
7013 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7014 (setq server (match-string 1))
7015 (setq port (if (stringp (match-string 3))
7016 (string-to-number (match-string 3))
7018 (goto-char (match-end 0)))
7021 ((looking-at "\\(.*@.*\\)")
7022 (setq message-id (match-string 1)))
7023 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7024 (setq group (match-string 1)
7025 articles (split-string (match-string 2) "-")))
7026 ((looking-at "\\([^/]+\\)/?")
7027 (setq group (match-string 1)))
7029 (error "Unknown news URL syntax"))))
7030 (list scheme server port group message-id articles)))
7032 (defun gnus-button-handle-news (url)
7034 (destructuring-bind (scheme server port group message-id articles)
7035 (gnus-parse-news-url url)
7039 (set-buffer gnus-summary-buffer)
7041 (let ((gnus-refer-article-method
7042 (nconc (list (list 'nntp server))
7043 gnus-refer-article-method))
7044 (nntp-port-number (or port "nntp")))
7045 (gnus-message 7 "Fetching %s with %s"
7046 message-id gnus-refer-article-method)
7047 (gnus-summary-refer-article message-id))
7048 (gnus-summary-refer-article message-id))))
7050 (gnus-button-fetch-group url)))))
7052 (defun gnus-button-handle-man (url)
7054 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7055 (when (eq gnus-button-man-handler 'woman)
7056 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7057 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7058 (funcall gnus-button-man-handler url))
7060 (defun gnus-button-handle-info-url (url)
7061 "Fetch an info URL."
7062 (setq url (mm-subst-char-in-string ?+ ?\ url))
7064 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7065 (gnus-info-find-node
7066 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7068 ")" (gnus-url-unhex-string (match-string 2 url)))))
7069 ((string-match "([^)\"]+)[^\"]+" url)
7071 (gnus-replace-in-string
7072 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7073 (gnus-info-find-node url))
7074 (t (error "Can't parse %s" url))))
7076 (defun gnus-button-handle-info-url-gnome (url)
7077 "Fetch GNOME style info URL."
7078 (setq url (mm-subst-char-in-string ?_ ?\ url))
7079 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7080 (gnus-info-find-node
7082 (gnus-url-unhex-string
7083 (match-string 1 url))
7085 (or (gnus-url-unhex-string
7086 (match-string 2 url))
7088 (error "Can't parse %s" url)))
7090 (defun gnus-button-handle-info-url-kde (url)
7091 "Fetch KDE style info URL."
7092 (gnus-info-find-node (gnus-url-unhex-string url)))
7094 (defun gnus-button-handle-info-keystrokes (url)
7095 "Call `info' when pushing the corresponding URL button."
7096 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7101 (defun gnus-button-openpgp (url)
7102 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7104 (mm-url-insert-file-contents-external url)
7105 (pgg-snarf-keys-region (point-min) (point-max))
7106 (pgg-display-output-buffer nil nil nil)))
7108 (defun gnus-button-message-id (message-id)
7110 (with-current-buffer gnus-summary-buffer
7111 (gnus-summary-refer-article message-id)))
7113 (defun gnus-button-fetch-group (address)
7114 "Fetch GROUP specified by ADDRESS."
7115 (if (not (string-match "[:/]" address))
7116 ;; This is just a simple group url.
7117 (gnus-group-read-ephemeral-group address gnus-select-method)
7120 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7122 (error "Can't parse %s" address)
7123 (gnus-group-read-ephemeral-group
7124 (match-string 4 address)
7125 `(nntp ,(match-string 1 address)
7126 (nntp-address ,(match-string 1 address))
7127 (nntp-port-number ,(if (match-end 3)
7128 (match-string 3 address)
7131 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7133 (defun gnus-url-parse-query-string (query &optional downcase)
7134 (let (retval pairs cur key val)
7135 (setq pairs (split-string query "&"))
7137 (setq cur (car pairs)
7139 (if (not (string-match "=" cur))
7141 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7142 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7144 (setq key (downcase key)))
7145 (setq cur (assoc key retval))
7147 (setcdr cur (cons val (cdr cur)))
7148 (setq retval (cons (list key val) retval)))))
7151 (defun gnus-url-mailto (url)
7152 ;; Send mail to someone
7153 (when (string-match "mailto:/*\\(.*\\)" url)
7154 (setq url (substring url (match-beginning 1) nil)))
7155 (let (to args subject func)
7156 (setq args (gnus-url-parse-query-string
7157 (if (string-match "^\\?" url)
7159 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7160 (concat "to=" (match-string 1 url) "&"
7161 (match-string 2 url))
7162 (concat "to=" url)))
7164 subject (cdr-safe (assoc "subject" args)))
7167 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7170 (message-position-on-field (caar args)))
7171 (insert (gnus-replace-in-string
7172 (mapconcat 'identity (reverse (cdar args)) ", ")
7174 (setq args (cdr args)))
7177 (message-goto-subject))))
7179 (defun gnus-button-embedded-url (address)
7180 "Activate ADDRESS with `browse-url'."
7181 (browse-url (gnus-strip-whitespace address)))
7183 ;;; Next/prev buttons in the article buffer.
7185 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7186 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7188 (defvar gnus-prev-page-map
7189 (let ((map (make-sparse-keymap)))
7190 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7191 (define-key map "\r" 'gnus-button-prev-page)
7194 (defvar gnus-next-page-map
7195 (let ((map (make-sparse-keymap)))
7196 (unless (>= emacs-major-version 21)
7197 ;; XEmacs doesn't care.
7198 (set-keymap-parent map gnus-article-mode-map))
7199 (define-key map gnus-mouse-2 'gnus-button-next-page)
7200 (define-key map "\r" 'gnus-button-next-page)
7203 (defun gnus-insert-prev-page-button ()
7205 (inhibit-read-only t))
7207 gnus-prev-page-line-format nil
7208 `(keymap ,gnus-prev-page-map
7210 gnus-callback gnus-article-button-prev-page
7211 article-type annotation))
7212 (widget-convert-button
7214 ;; Exclude a newline.
7217 :action 'gnus-button-prev-page
7218 :button-keymap gnus-prev-page-map)))
7220 (defun gnus-button-next-page (&optional args more-args)
7221 "Go to the next page."
7223 (let ((win (selected-window)))
7224 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7225 (gnus-article-next-page)
7226 (select-window win)))
7228 (defun gnus-button-prev-page (&optional args more-args)
7229 "Go to the prev page."
7231 (let ((win (selected-window)))
7232 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7233 (gnus-article-prev-page)
7234 (select-window win)))
7236 (defun gnus-insert-next-page-button ()
7238 (inhibit-read-only t))
7239 (gnus-eval-format gnus-next-page-line-format nil
7240 `(keymap ,gnus-next-page-map
7242 gnus-callback gnus-article-button-next-page
7243 article-type annotation))
7244 (widget-convert-button
7246 ;; Exclude a newline.
7249 :action 'gnus-button-next-page
7250 :button-keymap gnus-next-page-map)))
7252 (defun gnus-article-button-next-page (arg)
7253 "Go to the next page."
7255 (let ((win (selected-window)))
7256 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7257 (gnus-article-next-page)
7258 (select-window win)))
7260 (defun gnus-article-button-prev-page (arg)
7261 "Go to the prev page."
7263 (let ((win (selected-window)))
7264 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7265 (gnus-article-prev-page)
7266 (select-window win)))
7268 (defvar gnus-decode-header-methods
7269 '(mail-decode-encoded-word-region)
7270 "List of methods used to decode headers.
7272 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7273 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7274 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7275 whose names match REGEXP.
7278 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7279 mail-decode-encoded-word-region
7280 (\"chinese\" . rfc1843-decode-region))
7283 (defvar gnus-decode-header-methods-cache nil)
7285 (defun gnus-multi-decode-header (start end)
7286 "Apply the functions from `gnus-encoded-word-methods' that match."
7287 (unless (and gnus-decode-header-methods-cache
7288 (eq gnus-newsgroup-name
7289 (car gnus-decode-header-methods-cache)))
7290 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7293 (nconc gnus-decode-header-methods-cache (list x))
7294 (if (and gnus-newsgroup-name
7295 (string-match (car x) gnus-newsgroup-name))
7296 (nconc gnus-decode-header-methods-cache
7298 gnus-decode-header-methods))
7299 (let ((xlist gnus-decode-header-methods-cache))
7302 (narrow-to-region start end)
7304 (funcall (pop xlist) (point-min) (point-max))))))
7307 ;;; Treatment top-level handling.
7310 (defun gnus-treat-article (condition &optional part-number total-parts type)
7311 (let ((length (- (point-max) (point-min)))
7312 (alist gnus-treatment-function-alist)
7313 (article-goto-body-goes-to-point-min-p t)
7317 (let ((list gnus-article-treat-types))
7319 (when (string-match (pop list) type)
7320 (throw 'found t)))))))
7321 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7323 (gnus-run-hooks 'gnus-part-display-hook)
7324 (dolist (elem alist)
7327 (when (gnus-buffer-live-p gnus-summary-buffer)
7328 (set-buffer gnus-summary-buffer))
7329 (symbol-value (car elem))))
7330 (when (and (or (consp val)
7332 (gnus-treat-predicate val)
7333 (or (not (get (car elem) 'highlight))
7336 (funcall (cadr elem)))))))
7338 ;; Dynamic variables.
7340 (defvar part-number)
7341 (defvar total-parts)
7346 (defun gnus-treat-predicate (val)
7353 (stringp (car val)))
7354 (apply 'gnus-or (mapcar `(lambda (s)
7355 (string-match s ,(or gnus-newsgroup-name "")))
7358 (let ((pred (pop val)))
7361 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7363 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7365 (not (gnus-treat-predicate (car val))))
7367 (equal (car val) type))
7369 (error "%S is not a valid predicate" pred)))))
7377 (eq part-number total-parts))
7381 (error "%S is not a valid value" val))))
7383 (defun gnus-article-encrypt-body (protocol &optional n)
7384 "Encrypt the article body."
7387 (or gnus-article-encrypt-protocol
7388 (completing-read "Encrypt protocol: "
7389 gnus-article-encrypt-protocol-alist
7391 current-prefix-arg))
7392 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7394 (error "Can't find the encrypt protocol %s" protocol))
7395 (if (member gnus-newsgroup-name '("nndraft:delayed"
7398 (error "Can't encrypt the article in group %s"
7399 gnus-newsgroup-name))
7400 (gnus-summary-iterate n
7402 (set-buffer gnus-summary-buffer)
7403 (let ((mail-parse-charset gnus-newsgroup-charset)
7404 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7405 (summary-buffer gnus-summary-buffer)
7407 (gnus-set-global-variables)
7408 (when (gnus-group-read-only-p)
7409 (error "The current newsgroup does not support article encrypt"))
7410 (gnus-summary-show-article t)
7412 (or (mail-header-references gnus-current-headers) ""))
7413 (set-buffer gnus-article-buffer)
7414 (let* ((inhibit-read-only t)
7416 (mapcar (lambda (field)
7417 (and (save-restriction
7418 (message-narrow-to-head)
7419 (goto-char (point-min))
7420 (search-forward field nil t))
7422 (message-narrow-to-field)
7424 (delete-region (point-min) (point-max))
7426 '("Content-Type:" "Content-Transfer-Encoding:"
7427 "Content-Disposition:"))))
7428 (message-narrow-to-head)
7429 (message-remove-header "MIME-Version")
7430 (goto-char (point-max))
7431 (setq point (point))
7432 (insert (apply 'concat headers))
7434 (narrow-to-region point (point-max))
7435 (let ((message-options message-options))
7436 (message-options-set 'message-sender user-mail-address)
7437 (message-options-set 'message-recipients user-mail-address)
7438 (message-options-set 'message-sign-encrypt 'not)
7440 (goto-char (point-min))
7441 (insert "MIME-Version: 1.0\n")
7443 (gnus-summary-edit-article-done
7444 references nil summary-buffer t))
7445 (when gnus-keep-backlog
7446 (gnus-backlog-remove-article
7447 (car gnus-article-current) (cdr gnus-article-current)))
7449 (when (get-buffer gnus-original-article-buffer)
7450 (set-buffer gnus-original-article-buffer)
7451 (setq gnus-original-article nil)))
7452 (when gnus-use-cache
7453 (gnus-cache-update-article
7454 (car gnus-article-current) (cdr gnus-article-current))))))))
7456 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7457 "The following specs can be used:
7458 %t The security MIME type
7461 %D Details if button is pressed")
7463 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7464 "The following specs can be used:
7465 %t The security MIME type
7468 %D Details if button is pressed")
7470 (defvar gnus-mime-security-button-line-format-alist
7471 '((?t gnus-tmp-type ?s)
7472 (?i gnus-tmp-info ?s)
7473 (?d gnus-tmp-details ?s)
7474 (?D gnus-tmp-pressed-details ?s)))
7476 (defvar gnus-mime-security-button-commands
7477 '((gnus-article-press-button "\r" "Show Detail")
7481 (gnus-mime-security-save-part "o" "Save...")
7490 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7493 (defvar gnus-mime-security-button-map
7494 (let ((map (make-sparse-keymap)))
7495 (define-key map gnus-mouse-2 'gnus-article-push-button)
7496 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7497 (dolist (c gnus-mime-security-button-commands)
7498 (define-key map (cadr c) (car c)))
7502 gnus-mime-security-button-menu gnus-mime-security-button-map
7503 "Security button menu."
7507 (unless (eq (car c) 'undefined)
7508 (vector (caddr c) (car c) :enable t)))
7509 gnus-mime-security-button-commands))))
7511 (defun gnus-mime-security-button-menu (event prefix)
7512 "Construct a context-sensitive menu of security commands."
7513 (interactive "e\nP")
7514 (save-window-excursion
7515 (let ((pos (event-start event)))
7516 (select-window (posn-window pos))
7517 (goto-char (posn-point pos))
7518 (gnus-article-check-buffer)
7519 (popup-menu gnus-mime-security-button-menu nil prefix))))
7521 (defvar gnus-mime-security-details-buffer nil)
7523 (defvar gnus-mime-security-button-pressed nil)
7525 (defvar gnus-mime-security-show-details-inline t
7526 "If non-nil, show details in the article buffer.")
7528 (defun gnus-mime-security-verify-or-decrypt (handle)
7529 (mm-remove-parts (cdr handle))
7530 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7531 point (inhibit-read-only t))
7533 (goto-char (car region)))
7535 (narrow-to-region (point) (point))
7536 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7537 (let* ((mm-verify-option 'known)
7538 (mm-decrypt-option 'known)
7539 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7540 (unless (eq nparts (cdr handle))
7541 (mm-destroy-parts (cdr handle))
7542 (setcdr handle nparts))))
7543 (setq point (point))
7544 (gnus-mime-display-security handle)
7545 (goto-char (point-max)))
7547 (delete-region (point) (cdr region))
7548 (set-marker (car region) nil)
7549 (set-marker (cdr region) nil))
7552 (defun gnus-mime-security-show-details (handle)
7553 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7555 (gnus-message 5 "No details.")
7556 (if gnus-mime-security-show-details-inline
7557 (let ((gnus-mime-security-button-pressed
7558 (not (get-text-property (point) 'gnus-mime-details)))
7559 (gnus-mime-security-button-line-format
7560 (get-text-property (point) 'gnus-line-format))
7561 (inhibit-read-only t))
7563 (while (eq (get-text-property (point) 'gnus-line-format)
7564 gnus-mime-security-button-line-format)
7568 (narrow-to-region (point) (point))
7569 (gnus-insert-mime-security-button handle))
7570 (delete-region (point)
7571 (or (text-property-not-all
7574 gnus-mime-security-button-line-format)
7577 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7578 (with-current-buffer gnus-mime-security-details-buffer
7581 (setq gnus-mime-security-details-buffer
7582 (gnus-get-buffer-create "*MIME Security Details*")))
7583 (with-current-buffer gnus-mime-security-details-buffer
7585 (goto-char (point-min)))
7586 (pop-to-buffer gnus-mime-security-details-buffer)))))
7588 (defun gnus-mime-security-press-button (handle)
7590 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7591 (gnus-mime-security-show-details handle)
7592 (gnus-mime-security-verify-or-decrypt handle))))
7594 (defun gnus-insert-mime-security-button (handle &optional displayed)
7595 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7598 (or (nth 2 (assoc protocol mm-verify-function-alist))
7599 (nth 2 (assoc protocol mm-decrypt-function-alist))
7601 (if (equal (car handle) "multipart/signed")
7602 " Signed" " Encrypted")
7605 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7608 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7609 gnus-tmp-pressed-details
7611 (setq gnus-tmp-details
7612 (if gnus-tmp-details
7613 (concat "\n" gnus-tmp-details)
7615 (setq gnus-tmp-pressed-details
7616 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7621 gnus-mime-security-button-line-format
7622 gnus-mime-security-button-line-format-alist
7623 `(keymap ,gnus-mime-security-button-map
7624 gnus-callback gnus-mime-security-press-button
7625 gnus-line-format ,gnus-mime-security-button-line-format
7626 gnus-mime-details ,gnus-mime-security-button-pressed
7627 article-type annotation
7630 ;; Exclude a newline.
7633 (widget-convert-button
7636 :action 'gnus-widget-press-button
7637 :button-keymap gnus-mime-security-button-map
7639 (lambda (widget/window &optional overlay pos)
7640 ;; Needed to properly clear the message due to a bug in
7641 ;; wid-edit (XEmacs only).
7642 (when (boundp 'help-echo-owns-message)
7643 (setq help-echo-owns-message t))
7645 "%S: show detail; %S: more options"
7646 (aref gnus-mouse-2 0)
7647 (aref gnus-down-mouse-3 0))))))
7649 (defun gnus-mime-display-security (handle)
7651 (narrow-to-region (point) (point))
7652 (unless (gnus-unbuttonized-mime-type-p (car handle))
7653 (gnus-insert-mime-security-button handle))
7654 (gnus-mime-display-part (cadr handle))
7657 (unless (gnus-unbuttonized-mime-type-p (car handle))
7658 (let ((gnus-mime-security-button-line-format
7659 gnus-mime-security-button-end-line-format))
7660 (gnus-insert-mime-security-button handle)))
7661 (mm-set-handle-multipart-parameter
7663 (cons (set-marker (make-marker) (point-min))
7664 (set-marker (make-marker) (point-max))))))
7666 (defun gnus-mime-security-run-function (function)
7667 "Run FUNCTION with the security part under point."
7668 (gnus-article-check-buffer)
7669 (let ((data (get-text-property (point) 'gnus-data))
7671 (when (and (stringp (car-safe data))
7672 (setq buffer (mm-handle-multipart-original-buffer data))
7673 (setq handle (cadr data)))
7674 (if (bufferp (mm-handle-buffer handle))
7676 (setq handle (cons buffer (copy-sequence (cdr handle))))
7677 (mm-handle-set-undisplayer handle nil))
7678 (setq handle (mm-make-handle
7680 (mm-handle-multipart-ctl-parameter handle 'protocol)
7681 nil nil nil nil nil nil)))
7682 (funcall function handle))))
7684 (defun gnus-mime-security-save-part ()
7685 "Save the security part under point."
7687 (gnus-mime-security-run-function 'mm-save-part))
7689 (defun gnus-mime-security-pipe-part ()
7690 "Pipe the security part under point to a process."
7692 (gnus-mime-security-run-function 'mm-pipe-part))
7698 (run-hooks 'gnus-art-load-hook)
7700 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7701 ;;; gnus-art.el ends here