1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
64 (defgroup gnus-article nil
66 :link '(custom-manual "(gnus)The Article Buffer")
69 (defgroup gnus-article-treat nil
70 "Treating article parts."
71 :link '(custom-manual "(gnus)Article Hiding")
74 (defgroup gnus-article-hiding nil
75 "Hiding article parts."
76 :link '(custom-manual "(gnus)Article Hiding")
79 (defgroup gnus-article-highlight nil
80 "Article highlighting."
81 :link '(custom-manual "(gnus)Article Highlighting")
85 (defgroup gnus-article-signature nil
87 :link '(custom-manual "(gnus)Article Signature")
90 (defgroup gnus-article-headers nil
92 :link '(custom-manual "(gnus)Hiding Headers")
95 (defgroup gnus-article-washing nil
96 "Special commands on articles."
97 :link '(custom-manual "(gnus)Article Washing")
100 (defgroup gnus-article-emphasis nil
101 "Fontisizing articles."
102 :link '(custom-manual "(gnus)Article Fontisizing")
103 :group 'gnus-article)
105 (defgroup gnus-article-saving nil
107 :link '(custom-manual "(gnus)Saving Articles")
108 :group 'gnus-article)
110 (defgroup gnus-article-mime nil
111 "Worshiping the MIME wonder."
112 :link '(custom-manual "(gnus)Using MIME")
113 :group 'gnus-article)
115 (defgroup gnus-article-buttons nil
116 "Pushable buttons in the article buffer."
117 :link '(custom-manual "(gnus)Article Buttons")
118 :group 'gnus-article)
120 (defgroup gnus-article-various nil
121 "Other article options."
122 :link '(custom-manual "(gnus)Misc Article")
123 :group 'gnus-article)
125 (defcustom gnus-ignored-headers
128 (concat "^" header ":"))
129 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
130 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
131 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
132 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
133 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
134 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
135 "X-Attribution" "X-Originating-IP" "Delivered-To"
136 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
137 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
138 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
139 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
140 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
141 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
142 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
143 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
144 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
145 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
146 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
147 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
148 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
149 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
150 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
151 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
152 "List-[A-Za-z]+" "X-Listprocessor-Version"
153 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
154 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
155 "X-Received" "Content-length" "X-precedence"
156 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
157 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
158 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
159 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
160 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
161 "X-Content-length" "X-Posting-Agent" "Original-Received"
162 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
163 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
164 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
165 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
166 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
167 "*All headers that start with this regexp will be hidden.
168 This variable can also be a list of regexps of headers to be ignored.
169 If `gnus-visible-headers' is non-nil, this variable will be ignored."
170 :type '(choice :custom-show nil
173 :group 'gnus-article-hiding)
175 (defcustom gnus-visible-headers
176 "^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:"
177 "*All headers that do not match this regexp will be hidden.
178 This variable can also be a list of regexp of headers to remain visible.
179 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
180 :type '(repeat :value-to-internal (lambda (widget value)
181 (custom-split-regexp-maybe value))
182 :match (lambda (widget value)
184 (widget-editable-list-match widget value)))
186 :group 'gnus-article-hiding)
188 (defcustom gnus-sorted-header-list
189 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
190 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
191 "*This variable is a list of regular expressions.
192 If it is non-nil, headers that match the regular expressions will
193 be placed first in the article buffer in the sequence specified by
195 :type '(repeat regexp)
196 :group 'gnus-article-hiding)
198 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
199 "Headers that are only to be displayed if they have interesting data.
200 Possible values in this list are:
202 'empty Headers with no content.
203 'newsgroups Newsgroup identical to Gnus group.
204 'to-address To identical to To-address.
205 'to-list To identical to To-list.
206 'cc-list CC identical to To-list.
207 'followup-to Followup-to identical to Newsgroups.
208 'reply-to Reply-to identical to From.
209 'date Date less than four days old.
210 'long-to To and/or Cc longer than 1024 characters.
211 'many-to Multiple To and/or Cc."
212 :type '(set (const :tag "Headers with no content." empty)
213 (const :tag "Newsgroups identical to Gnus group." newsgroups)
214 (const :tag "To identical to To-address." to-address)
215 (const :tag "To identical to To-list." to-list)
216 (const :tag "CC identical to To-list." cc-list)
217 (const :tag "Followup-to identical to Newsgroups." followup-to)
218 (const :tag "Reply-to identical to From." reply-to)
219 (const :tag "Date less than four days old." date)
220 (const :tag "To and/or Cc longer than 1024 characters." long-to)
221 (const :tag "Multiple To and/or Cc headers." many-to))
222 :group 'gnus-article-hiding)
224 (defcustom gnus-article-skip-boring nil
225 "Skip over text that is not worth reading.
226 By default, if you set this t, then Gnus will display citations and
227 signatures, but will never scroll down to show you a page consisting
228 only of boring text. Boring text is controlled by
229 `gnus-article-boring-faces'."
231 :group 'gnus-article-hiding)
233 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
234 "Regexp matching signature separator.
235 This can also be a list of regexps. In that case, it will be checked
236 from head to tail looking for a separator. Searches will be done from
237 the end of the buffer."
238 :type '(repeat string)
239 :group 'gnus-article-signature)
241 (defcustom gnus-signature-limit nil
242 "Provide a limit to what is considered a signature.
243 If it is a number, no signature may not be longer (in characters) than
244 that number. If it is a floating point number, no signature may be
245 longer (in lines) than that number. If it is a function, the function
246 will be called without any parameters, and if it returns nil, there is
247 no signature in the buffer. If it is a string, it will be used as a
248 regexp. If it matches, the text in question is not a signature."
249 :type '(choice (integer :value 200)
251 (function :value fun)
252 (regexp :value ".*"))
253 :group 'gnus-article-signature)
255 (defcustom gnus-hidden-properties '(invisible t intangible t)
256 "Property list to use for hiding text."
258 :group 'gnus-article-hiding)
260 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
261 ;; frames in a session.
262 (defcustom gnus-article-x-face-command
267 (if (or (gnus-image-type-available-p 'xface)
268 (gnus-image-type-available-p 'pbm))
269 'gnus-display-x-face-in-from
270 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
271 ((and (fboundp 'image-type-available-p)
272 (module-installed-p 'x-face-e21))
273 'x-face-decode-message-header)
274 ((gnus-image-type-available-p 'pbm)
275 'gnus-display-x-face-in-from)
277 (module-installed-p 'x-face-mule))
278 'x-face-mule-gnus-article-display-x-face)
280 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
282 "*String or function to be executed to display an X-Face header.
283 If it is a string, the command will be executed in a sub-shell
284 asynchronously. The compressed face will be piped to this command."
286 ,@(let (x-face-e21 x-face-mule)
287 (if (featurep 'xemacs)
289 (setq x-face-e21 (module-installed-p 'x-face-e21)
290 x-face-mule (module-installed-p 'x-face-mule)))
294 (if (or (gnus-image-type-available-p 'xface)
295 (gnus-image-type-available-p 'pbm))
296 '(function-item gnus-display-x-face-in-from))
298 (fboundp 'image-type-available-p))
300 :tag "x-face-decode-message-header (x-face-e21)"
301 x-face-decode-message-header))
304 x-face-mule-gnus-article-display-x-face))
308 :group 'gnus-article-washing)
310 (defcustom gnus-article-x-face-too-ugly nil
311 "Regexp matching posters whose face shouldn't be shown automatically."
312 :type '(choice regexp (const nil))
313 :group 'gnus-article-washing)
315 (defcustom gnus-article-banner-alist nil
316 "Banner alist for stripping.
318 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
320 :type '(repeat (cons symbol regexp))
321 :group 'gnus-article-washing)
323 (gnus-define-group-parameter
326 "Alist of regexps (to match group names) and banner."
327 :variable-group gnus-article-washing
329 '(choice :tag "Banner"
331 (const :tag "Remove signature" signature)
332 (symbol :tag "Item in `gnus-article-banner-alist'" none)
334 (const :tag "None" nil))
336 "If non-nil, specify how to remove `banners' from articles.
338 Symbol `signature' means to remove signatures delimited by
339 `gnus-signature-separator'. Any other symbol is used to look up a
340 regular expression to match the banner in `gnus-article-banner-alist'.
341 A string is used as a regular expression to match the banner
344 (defcustom gnus-article-address-banner-alist nil
345 "Alist of mail addresses and banners.
346 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
347 to match a mail address in the From: header, BANNER is one of a symbol
348 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
349 If ADDRESS matches author's mail address, it will remove things like
350 advertisements. For example:
352 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
356 (regexp :tag "Address")
357 (choice :tag "Banner" :value nil
358 (const :tag "Remove signature" signature)
359 (symbol :tag "Item in `gnus-article-banner-alist'" none)
361 (const :tag "None" nil))))
362 :group 'gnus-article-washing)
364 (defcustom gnus-emphasis-alist
366 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
371 ("_/" "/_" underline-italic)
372 ("_\\*" "\\*_" underline-bold)
373 ("\\*/" "/\\*" bold-italic)
374 ("_\\*/" "/\\*_" underline-bold-italic))))
378 (format format (car spec) (car (cdr spec)))
379 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
381 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
382 2 3 gnus-emphasis-strikethru)
383 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
384 2 3 gnus-emphasis-underline)))
385 "*Alist that says how to fontify certain phrases.
386 Each item looks like this:
388 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
390 The first element is a regular expression to be matched. The second
391 is a number that says what regular expression grouping used to find
392 the entire emphasized word. The third is a number that says what
393 regexp grouping should be displayed and highlighted. The fourth
394 is the face used for highlighting."
395 :type '(repeat (list :value ("" 0 0 default)
397 (integer :tag "Match group")
398 (integer :tag "Emphasize group")
400 :group 'gnus-article-emphasis)
402 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
403 "A regexp to describe whitespace which should not be emphasized.
404 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
405 The former avoids underlining of leading and trailing whitespace,
406 and the latter avoids underlining any whitespace at all."
408 :group 'gnus-article-emphasis
411 (defface gnus-emphasis-bold '((t (:bold t)))
412 "Face used for displaying strong emphasized text (*word*)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-italic '((t (:italic t)))
416 "Face used for displaying italic emphasized text (/word/)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline '((t (:underline t)))
420 "Face used for displaying underlined emphasized text (_word_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
424 "Face used for displaying underlined bold emphasized text (_*word*_)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
428 "Face used for displaying underlined italic emphasized text (_/word/_)."
429 :group 'gnus-article-emphasis)
431 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
432 "Face used for displaying bold italic emphasized text (/*word*/)."
433 :group 'gnus-article-emphasis)
435 (defface gnus-emphasis-underline-bold-italic
436 '((t (:bold t :italic t :underline t)))
437 "Face used for displaying underlined bold italic emphasized text.
438 Example: (_/*word*/_)."
439 :group 'gnus-article-emphasis)
441 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
442 '((t (:strikethru t)))
443 '((t (:strike-through t))))
444 "Face used for displaying strike-through text (-word-)."
445 :group 'gnus-article-emphasis)
447 (defface gnus-emphasis-highlight-words
448 '((t (:background "black" :foreground "yellow")))
449 "Face used for displaying highlighted words."
450 :group 'gnus-article-emphasis)
452 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
453 "Format for display of Date headers in article bodies.
454 See `format-time-string' for the possible values.
456 The variable can also be function, which should return a complete Date
457 header. The function is called with one argument, the time, which can
458 be fed to `format-time-string'."
459 :type '(choice string symbol)
460 :link '(custom-manual "(gnus)Article Date")
461 :group 'gnus-article-washing)
464 (autoload 'mail-extract-address-components "mail-extr"))
466 (defcustom gnus-save-all-headers t
467 "*If non-nil, don't remove any headers before saving."
468 :group 'gnus-article-saving
471 (defcustom gnus-prompt-before-saving 'always
472 "*This variable says how much prompting is to be done when saving articles.
473 If it is nil, no prompting will be done, and the articles will be
474 saved to the default files. If this variable is `always', each and
475 every article that is saved will be preceded by a prompt, even when
476 saving large batches of articles. If this variable is neither nil not
477 `always', there the user will be prompted once for a file name for
478 each invocation of the saving commands."
479 :group 'gnus-article-saving
480 :type '(choice (item always)
481 (item :tag "never" nil)
482 (sexp :tag "once" :format "%t\n" :value t)))
484 (defcustom gnus-saved-headers gnus-visible-headers
485 "Headers to keep if `gnus-save-all-headers' is nil.
486 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
487 If that variable is nil, however, all headers that match this regexp
488 will be kept while the rest will be deleted before saving."
489 :group 'gnus-article-saving
492 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
493 "A function to save articles in your favourite format.
494 The function must be interactively callable (in other words, it must
495 be an Emacs command).
497 Gnus provides the following functions:
499 * gnus-summary-save-in-rmail (Rmail format)
500 * gnus-summary-save-in-mail (Unix mail format)
501 * gnus-summary-save-in-folder (MH folder)
502 * gnus-summary-save-in-file (article format)
503 * gnus-summary-save-body-in-file (article body)
504 * gnus-summary-save-in-vm (use VM's folder format)
505 * gnus-summary-write-to-file (article format -- overwrite)."
506 :group 'gnus-article-saving
507 :type '(radio (function-item gnus-summary-save-in-rmail)
508 (function-item gnus-summary-save-in-mail)
509 (function-item gnus-summary-save-in-folder)
510 (function-item gnus-summary-save-in-file)
511 (function-item gnus-summary-save-body-in-file)
512 (function-item gnus-summary-save-in-vm)
513 (function-item gnus-summary-write-to-file)))
515 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
516 "A function generating a file name to save articles in Rmail format.
517 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
518 :group 'gnus-article-saving
521 (defcustom gnus-mail-save-name 'gnus-plain-save-name
522 "A function generating a file name to save articles in Unix mail format.
523 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
524 :group 'gnus-article-saving
527 (defcustom gnus-folder-save-name 'gnus-folder-save-name
528 "A function generating a file name to save articles in MH folder.
529 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
530 :group 'gnus-article-saving
533 (defcustom gnus-file-save-name 'gnus-numeric-save-name
534 "A function generating a file name to save articles in article format.
535 The function is called with NEWSGROUP, HEADERS, and optional
537 :group 'gnus-article-saving
540 (defcustom gnus-split-methods
541 '((gnus-article-archive-name)
542 (gnus-article-nndoc-name))
543 "*Variable used to suggest where articles are to be saved.
544 For instance, if you would like to save articles related to Gnus in
545 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
546 you could set this variable to something like:
548 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
549 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
551 This variable is an alist where the where the key is the match and the
552 value is a list of possible files to save in if the match is non-nil.
554 If the match is a string, it is used as a regexp match on the
555 article. If the match is a symbol, that symbol will be funcalled
556 from the buffer of the article to be saved with the newsgroup as the
557 parameter. If it is a list, it will be evaled in the same buffer.
559 If this form or function returns a string, this string will be used as
560 a possible file name; and if it returns a non-nil list, that list will
561 be used as possible file names."
562 :group 'gnus-article-saving
563 :type '(repeat (choice (list :value (fun) function)
564 (cons :value ("" "") regexp (repeat string))
567 (defcustom gnus-article-display-method-for-mime
568 'gnus-article-display-mime-message
569 "Function to display a MIME message.
570 The function is called from the article buffer."
571 :group 'gnus-article-mime
574 (defcustom gnus-article-display-method-for-traditional
575 'gnus-article-display-traditional-message
576 "*Function to display a traditional message.
577 The function is called from the article buffer."
578 :group 'gnus-article-mime
581 (defcustom gnus-page-delimiter "^\^L"
582 "*Regexp describing what to use as article page delimiters.
583 The default value is \"^\^L\", which is a form linefeed at the
584 beginning of a line."
586 :group 'gnus-article-various)
588 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
589 "*The format specification for the article mode line.
590 See `gnus-summary-mode-line-format' for a closer description.
592 The following additional specs are available:
594 %w The article washing status.
595 %m The number of MIME parts in the article."
597 :group 'gnus-article-various)
599 (defcustom gnus-article-mode-hook nil
600 "*A hook for Gnus article mode."
602 :group 'gnus-article-various)
604 (when (featurep 'xemacs)
605 ;; Extracted from gnus-xmas-define in order to preserve user settings
606 (when (fboundp 'turn-off-scroll-in-place)
607 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
608 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
609 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
611 (defcustom gnus-article-menu-hook nil
612 "*Hook run after the creation of the article mode menu."
614 :group 'gnus-article-various)
616 (defcustom gnus-article-prepare-hook nil
617 "*A hook called after an article has been prepared in the article buffer."
619 :group 'gnus-article-various)
621 (make-obsolete-variable 'gnus-article-hide-pgp-hook
622 "This variable is obsolete in Gnus 5.10.")
624 (defcustom gnus-article-button-face 'bold
625 "Face used for highlighting buttons in the article buffer.
627 An article button is a piece of text that you can activate by pressing
628 `RET' or `mouse-2' above it."
630 :group 'gnus-article-buttons)
632 (defcustom gnus-article-mouse-face 'highlight
633 "Face used for mouse highlighting in the article buffer.
635 Article buttons will be displayed in this face when the cursor is
638 :group 'gnus-article-buttons)
640 (defcustom gnus-signature-face 'gnus-signature-face
641 "Face used for highlighting a signature in the article buffer.
642 Obsolete; use the face `gnus-signature-face' for customizations instead."
644 :group 'gnus-article-highlight
645 :group 'gnus-article-signature)
647 (defface gnus-signature-face
650 "Face used for highlighting a signature in the article buffer."
651 :group 'gnus-article-highlight
652 :group 'gnus-article-signature)
654 (defface gnus-header-from-face
657 (:foreground "spring green"))
660 (:foreground "red3"))
663 "Face used for displaying from headers."
664 :group 'gnus-article-headers
665 :group 'gnus-article-highlight)
667 (defface gnus-header-subject-face
670 (:foreground "SeaGreen3"))
673 (:foreground "red4"))
675 (:bold t :italic t)))
676 "Face used for displaying subject headers."
677 :group 'gnus-article-headers
678 :group 'gnus-article-highlight)
680 (defface gnus-header-newsgroups-face
683 (:foreground "yellow" :italic t))
686 (:foreground "MidnightBlue" :italic t))
689 "Face used for displaying newsgroups headers.
690 In the default setup this face is only used for crossposted
692 :group 'gnus-article-headers
693 :group 'gnus-article-highlight)
695 (defface gnus-header-name-face
698 (:foreground "SeaGreen"))
701 (:foreground "maroon"))
704 "Face used for displaying header names."
705 :group 'gnus-article-headers
706 :group 'gnus-article-highlight)
708 (defface gnus-header-content-face
711 (:foreground "forest green" :italic t))
714 (:foreground "indianred4" :italic t))
717 "Face used for displaying header content."
718 :group 'gnus-article-headers
719 :group 'gnus-article-highlight)
721 (defcustom gnus-header-face-alist
722 '(("From" nil gnus-header-from-face)
723 ("Subject" nil gnus-header-subject-face)
724 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
725 ("" gnus-header-name-face gnus-header-content-face))
726 "*Controls highlighting of article headers.
728 An alist of the form (HEADER NAME CONTENT).
730 HEADER is a regular expression which should match the name of a
731 header and NAME and CONTENT are either face names or nil.
733 The name of each header field will be displayed using the face
734 specified by the first element in the list where HEADER matches
735 the header name and NAME is non-nil. Similarly, the content will
736 be displayed by the first non-nil matching CONTENT face."
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight
739 :type '(repeat (list (regexp :tag "Header")
741 (item :tag "skip" nil)
742 (face :value default))
743 (choice :tag "Content"
744 (item :tag "skip" nil)
745 (face :value default)))))
747 (defcustom gnus-article-decode-hook
748 '(article-decode-group-name article-decode-idna-rhs)
749 "*Hook run to decode charsets in articles."
750 :group 'gnus-article-headers
753 (defcustom gnus-display-mime-function 'gnus-display-mime
754 "Function to display MIME articles."
755 :group 'gnus-article-mime
758 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
759 "Function used to decode headers.")
761 (defvar gnus-article-dumbquotes-map
781 "Table for MS-to-Latin1 translation.")
783 (defcustom gnus-ignored-mime-types nil
784 "List of MIME types that should be ignored by Gnus."
786 :group 'gnus-article-mime
787 :type '(repeat regexp))
789 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
790 "List of MIME types that should not be given buttons when rendered inline.
791 See also `gnus-buttonized-mime-types' which may override this variable.
792 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
794 :group 'gnus-article-mime
795 :type '(repeat regexp))
797 (defcustom gnus-buttonized-mime-types nil
798 "List of MIME types that should be given buttons when rendered inline.
799 If set, this variable overrides `gnus-unbuttonized-mime-types'.
800 To see e.g. security buttons you could set this to
801 `(\"multipart/signed\")'.
802 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
804 :group 'gnus-article-mime
805 :type '(repeat regexp))
807 (defcustom gnus-inhibit-mime-unbuttonizing nil
808 "If non-nil, all MIME parts get buttons.
809 When nil (the default value), then some MIME parts do not get buttons,
810 as described by the variables `gnus-buttonized-mime-types' and
811 `gnus-unbuttonized-mime-types'."
815 (defcustom gnus-body-boundary-delimiter "_"
816 "String used to delimit header and body.
817 This variable is used by `gnus-article-treat-body-boundary' which can
818 be controlled by `gnus-treat-body-boundary'."
819 :group 'gnus-article-various
820 :type '(choice (item :tag "None" :value nil)
823 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
824 "Defines the location of the faces database.
825 For information on obtaining this database of pretty pictures, please
826 see http://www.cs.indiana.edu/picons/ftp/index.html"
827 :type '(repeat directory)
828 :link '(url-link :tag "download"
829 "http://www.cs.indiana.edu/picons/ftp/index.html")
830 :link '(custom-manual "(gnus)Picons")
833 (defun gnus-picons-installed-p ()
834 "Say whether picons are installed on your machine."
835 (let ((installed nil))
836 (dolist (database gnus-picon-databases)
837 (when (file-exists-p database)
841 (defcustom gnus-article-mime-part-function nil
842 "Function called with a MIME handle as the argument.
843 This is meant for people who want to do something automatic based
844 on parts -- for instance, adding Vcard info to a database."
845 :group 'gnus-article-mime
848 (defcustom gnus-mime-multipart-functions nil
849 "An alist of MIME types to functions to display them."
851 :group 'gnus-article-mime
854 (defcustom gnus-article-date-lapsed-new-header nil
855 "Whether the X-Sent and Date headers can coexist.
856 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
857 either replace the old \"Date:\" header (if this variable is nil), or
858 be added below it (otherwise)."
860 :group 'gnus-article-headers
863 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
864 "Function called with a MIME handle as the argument.
865 This is meant for people who want to view first matched part.
866 For `undisplayed-alternative' (default), the first undisplayed
867 part or alternative part is used. For `undisplayed', the first
868 undisplayed part is used. For a function, the first part which
869 the function return t is used. For nil, the first part is
872 :group 'gnus-article-mime
874 (item :tag "first" :value nil)
875 (item :tag "undisplayed" :value undisplayed)
876 (item :tag "undisplayed or alternative"
877 :value undisplayed-alternative)
880 (defcustom gnus-mime-action-alist
881 '(("save to file" . gnus-mime-save-part)
882 ("save and strip" . gnus-mime-save-part-and-strip)
883 ("delete part" . gnus-mime-delete-part)
884 ("display as text" . gnus-mime-inline-part)
885 ("view the part" . gnus-mime-view-part)
886 ("pipe to command" . gnus-mime-pipe-part)
887 ("toggle display" . gnus-article-press-button)
888 ("toggle display" . gnus-article-view-part-as-charset)
889 ("view as type" . gnus-mime-view-part-as-type)
890 ("view internally" . gnus-mime-view-part-internally)
891 ("view externally" . gnus-mime-view-part-externally))
892 "An alist of actions that run on the MIME attachment."
893 :group 'gnus-article-mime
894 :type '(repeat (cons (string :tag "name")
898 ;;; The treatment variables
901 (defvar gnus-part-display-hook nil
902 "Hook called on parts that are to receive treatment.")
904 (defvar gnus-article-treat-custom
905 '(choice (const :tag "Off" nil)
907 (const :tag "Header" head)
908 (const :tag "Last" last)
909 (const :tag "Mime" mime)
910 (integer :tag "Less")
911 (repeat :tag "Groups" regexp)
912 (sexp :tag "Predicate")))
914 (defvar gnus-article-treat-head-custom
915 '(choice (const :tag "Off" nil)
916 (const :tag "Header" head)))
918 (defvar gnus-article-treat-types '("text/plain")
921 (defvar gnus-inhibit-treatment nil
922 "Whether to inhibit treatment.")
924 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
925 "Highlight the signature.
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles'."
928 :group 'gnus-article-treat
929 :link '(custom-manual "(gnus)Customizing Articles")
930 :type gnus-article-treat-custom)
931 (put 'gnus-treat-highlight-signature 'highlight t)
933 (defcustom gnus-treat-buttonize 100000
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles'."
937 :group 'gnus-article-treat
938 :link '(custom-manual "(gnus)Customizing Articles")
939 :type gnus-article-treat-custom)
940 (put 'gnus-treat-buttonize 'highlight t)
942 (defcustom gnus-treat-buttonize-head 'head
943 "Add buttons to the head.
944 Valid values are nil, t, `head', `last', an integer or a predicate.
945 See Info node `(gnus)Customizing Articles' for details."
946 :group 'gnus-article-treat
947 :link '(custom-manual "(gnus)Customizing Articles")
948 :type gnus-article-treat-head-custom)
949 (put 'gnus-treat-buttonize-head 'highlight t)
951 (defcustom gnus-treat-emphasize
952 (and (or window-system
954 (>= (string-to-number emacs-version) 21))
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
962 (put 'gnus-treat-emphasize 'highlight t)
964 (defcustom gnus-treat-strip-cr nil
965 "Remove carriage returns.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-unsplit-urls nil
973 "Remove newlines from within URLs.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-leading-whitespace nil
981 "Remove leading whitespace in headers.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (defcustom gnus-treat-hide-headers 'head
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-hide-boring-headers nil
997 "Hide boring headers.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-head-custom)
1004 (defcustom gnus-treat-hide-signature nil
1005 "Hide the signature.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-fill-article nil
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-hide-citation nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-hide-citation-maybe nil
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-strip-list-identifiers 'head
1037 "Strip list identifiers from `gnus-list-identifiers`.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (make-obsolete-variable 'gnus-treat-strip-pgp
1046 "This option is obsolete in Gnus 5.10.")
1048 (defcustom gnus-treat-strip-pem nil
1049 "Strip PEM signatures.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1056 (defcustom gnus-treat-strip-banner t
1057 "Strip banners from articles.
1058 The banner to be stripped is specified in the `banner' group parameter.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-highlight-headers 'head
1066 "Highlight the headers.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1072 (put 'gnus-treat-highlight-headers 'highlight t)
1074 (defcustom gnus-treat-highlight-citation t
1075 "Highlight cited text.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-custom)
1081 (put 'gnus-treat-highlight-citation 'highlight t)
1083 (defcustom gnus-treat-date-ut nil
1084 "Display the Date in UT (GMT).
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-head-custom)
1091 (defcustom gnus-treat-date-local nil
1092 "Display the Date in the local timezone.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-english nil
1100 "Display the Date in a format that can be read aloud in English.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-lapsed nil
1108 "Display the Date header in a way that says how much time has elapsed.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-head-custom)
1115 (defcustom gnus-treat-date-original nil
1116 "Display the date in the original timezone.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-head-custom)
1123 (defcustom gnus-treat-date-iso8601 nil
1124 "Display the date in the ISO8601 format.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-head-custom)
1132 (defcustom gnus-treat-date-user-defined nil
1133 "Display the date in a user-defined format.
1134 The format is defined by the `gnus-article-time-format' variable.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-strip-headers-in-body t
1142 "Strip the X-No-Archive header line from the beginning of the body.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-strip-trailing-blank-lines nil
1151 "Strip trailing blank lines.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-leading-blank-lines nil
1159 "Strip leading blank lines.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-strip-multiple-blank-lines nil
1167 "Strip multiple blank lines.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-unfold-headers 'head
1175 "Unfold folded header lines.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fold-headers nil
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-fold-newsgroups 'head
1191 "Fold the Newsgroups and Followup-To headers.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-overstrike t
1199 "Treat overstrike highlighting.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1205 (put 'gnus-treat-overstrike 'highlight t)
1207 (make-obsolete-variable 'gnus-treat-display-xface
1208 'gnus-treat-display-x-face)
1210 (defcustom gnus-treat-display-x-face
1211 (and (not noninteractive)
1212 (or (memq gnus-article-x-face-command
1213 '(x-face-decode-message-header
1214 x-face-mule-gnus-article-display-x-face))
1215 (and (fboundp 'image-type-available-p)
1216 (image-type-available-p 'xbm)
1217 (string-match "^0x" (shell-command-to-string "uncompface"))
1218 (executable-find "icontopbm"))
1219 (and (featurep 'xemacs)
1222 "Display X-Face headers.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)X-Face' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)X-Face")
1230 :type gnus-article-treat-head-custom
1231 :set (lambda (symbol value)
1234 (cond ((or (boundp symbol) (get symbol 'saved-value))
1236 ((boundp 'gnus-treat-display-xface)
1238 ** gnus-treat-display-xface is an obsolete variable;\
1239 use gnus-treat-display-x-face instead")
1240 (default-value 'gnus-treat-display-xface))
1241 ((get 'gnus-treat-display-xface 'saved-value)
1243 ** gnus-treat-display-xface is an obsolete variable;\
1244 use gnus-treat-display-x-face instead")
1245 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1248 (put 'gnus-treat-display-x-face 'highlight t)
1250 (defcustom gnus-article-should-use-smiley-mule
1251 (not (or (featurep 'xemacs)
1252 (gnus-image-type-available-p 'xpm)
1253 (gnus-image-type-available-p 'pbm)))
1254 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1255 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1256 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1257 even if you are using Emacs 21+. It has no effect on XEmacs."
1258 :group 'gnus-article-various
1260 :get (lambda (symbol)
1261 (and (not noninteractive)
1262 (default-value symbol)
1263 (not (featurep 'xemacs))
1264 (module-installed-p 'smiley-mule)
1266 :set (lambda (symbol value)
1267 (set-default symbol (and (not noninteractive)
1269 (not (featurep 'xemacs))
1270 (module-installed-p 'smiley-mule)
1273 (defvar gnus-article-smiley-mule-loaded-p nil
1274 "Internal variable used to say whether `smiley-mule' is loaded (whether
1275 smiley functions are not overridden by `smiley').")
1277 (defcustom gnus-treat-display-face
1278 (and (not noninteractive)
1279 ;; x-face-e21 handles both X-Face and Face headers.
1280 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1281 (module-installed-p 'x-face-e21)))
1282 (or (and (fboundp 'image-type-available-p)
1283 (image-type-available-p 'png))
1284 (and (featurep 'xemacs)
1287 "Display Face headers.
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' and Info node
1290 `(gnus)X-Face' for details."
1291 :group 'gnus-article-treat
1293 :link '(custom-manual "(gnus)Customizing Articles")
1294 :link '(custom-manual "(gnus)X-Face")
1295 :type gnus-article-treat-head-custom)
1296 (put 'gnus-treat-display-face 'highlight t)
1298 (defcustom gnus-treat-display-smileys
1299 (if (and (not noninteractive)
1300 (or (and (featurep 'xemacs)
1302 (gnus-image-type-available-p 'xpm)
1303 (gnus-image-type-available-p 'pbm)
1304 (and (not (featurep 'xemacs))
1306 (module-installed-p 'smiley-mule))))
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' and Info node
1312 `(gnus)Smileys' for details."
1313 :group 'gnus-article-treat
1315 :link '(custom-manual "(gnus)Customizing Articles")
1316 :link '(custom-manual "(gnus)Smileys")
1317 :type gnus-article-treat-custom)
1318 (put 'gnus-treat-display-smileys 'highlight t)
1320 (defcustom gnus-treat-from-picon
1321 (if (and (gnus-image-type-available-p 'xpm)
1322 (gnus-picons-installed-p))
1324 "Display picons in the From header.
1325 Valid values are nil, t, `head', `last', an integer or a predicate.
1326 See Info node `(gnus)Customizing Articles' and Info node
1327 `(gnus)Picons' for details."
1328 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :link '(custom-manual "(gnus)Picons")
1332 :type gnus-article-treat-head-custom)
1333 (put 'gnus-treat-from-picon 'highlight t)
1335 (defcustom gnus-treat-mail-picon
1336 (if (and (gnus-image-type-available-p 'xpm)
1337 (gnus-picons-installed-p))
1339 "Display picons in To and Cc headers.
1340 Valid values are nil, t, `head', `last', an integer or a predicate.
1341 See Info node `(gnus)Customizing Articles' and Info node
1342 `(gnus)Picons' for details."
1343 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :link '(custom-manual "(gnus)Picons")
1347 :type gnus-article-treat-head-custom)
1348 (put 'gnus-treat-mail-picon 'highlight t)
1350 (defcustom gnus-treat-newsgroups-picon
1351 (if (and (gnus-image-type-available-p 'xpm)
1352 (gnus-picons-installed-p))
1354 "Display picons in the Newsgroups and Followup-To headers.
1355 Valid values are nil, t, `head', `last', an integer or a predicate.
1356 See Info node `(gnus)Customizing Articles' and Info node
1357 `(gnus)Picons' for details."
1358 :group 'gnus-article-treat
1360 :link '(custom-manual "(gnus)Customizing Articles")
1361 :link '(custom-manual "(gnus)Picons")
1362 :type gnus-article-treat-head-custom)
1363 (put 'gnus-treat-newsgroups-picon 'highlight t)
1365 (defcustom gnus-treat-body-boundary
1366 (if (or gnus-treat-newsgroups-picon
1367 gnus-treat-mail-picon
1368 gnus-treat-from-picon)
1370 "Draw a boundary at the end of the headers.
1371 Valid values are nil and `head'.
1372 See Info node `(gnus)Customizing Articles' for details."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-head-custom)
1378 (defcustom gnus-treat-capitalize-sentences nil
1379 "Capitalize sentence-starting words.
1380 Valid values are nil, t, `head', `last', an integer or a predicate.
1381 See Info node `(gnus)Customizing Articles' for details."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-wash-html nil
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1395 (defcustom gnus-treat-fill-long-lines nil
1397 Valid values are nil, t, `head', `last', an integer or a predicate.
1398 See Info node `(gnus)Customizing Articles' for details."
1399 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom)
1403 (defcustom gnus-treat-play-sounds nil
1405 Valid values are nil, t, `head', `last', an integer or a predicate.
1406 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1413 "Decode an article as `default-mime-charset'. For instance, if you want to
1414 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1415 you could set this variable to something like: nil for don't decode, t for
1416 decode the body, '(or header t) for the whole article, etc."
1417 :group 'gnus-article-treat
1418 :type '(radio (const :tag "Off" nil)
1419 (const :tag "Decode body" t)
1420 (const :tag "Decode all" (or head t))))
1422 (defcustom gnus-treat-translate nil
1423 "Translate articles from one language to another.
1424 Valid values are nil, t, `head', `last', an integer or a predicate.
1425 See Info node `(gnus)Customizing Articles' for details."
1427 :group 'gnus-article-treat
1428 :link '(custom-manual "(gnus)Customizing Articles")
1429 :type gnus-article-treat-custom)
1431 (defcustom gnus-treat-x-pgp-sig nil
1433 To automatically treat X-PGP-Sig, set it to head.
1434 Valid values are nil, t, `head', `last', an integer or a predicate.
1435 See Info node `(gnus)Customizing Articles' for details."
1436 :group 'gnus-article-treat
1437 :group 'mime-security
1438 :type gnus-article-treat-custom)
1440 (defcustom gnus-treat-monafy nil
1441 "Display body part with mona font.
1442 Valid values are nil, t, `head', `last', an integer or a predicate.
1443 See Info node `(gnus)Customizing Articles' for details."
1444 :group 'gnus-article-treat
1445 :group 'mime-security
1446 :link '(custom-manual "(gnus)Customizing Articles")
1447 :type gnus-article-treat-custom)
1449 (defvar gnus-article-encrypt-protocol-alist
1450 '(("PGP" . mml2015-self-encrypt)))
1452 ;; Set to nil if more than one protocol added to
1453 ;; gnus-article-encrypt-protocol-alist.
1454 (defcustom gnus-article-encrypt-protocol "PGP"
1455 "The protocol used for encrypt articles.
1456 It is a string, such as \"PGP\". If nil, ask user."
1458 :group 'mime-security)
1460 (defvar gnus-article-wash-function nil
1461 "Function used for converting HTML into text.")
1463 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1464 (mm-coding-system-p 'utf-8)
1465 (executable-find idna-program))
1466 "Whether IDNA decoding of headers is used when viewing messages.
1467 This requires GNU Libidn, and by default only enabled if it is found."
1468 :group 'gnus-article-headers
1471 (defcustom gnus-article-over-scroll nil
1472 "If non-nil, allow scrolling the article buffer even when there no more text."
1473 :group 'gnus-article
1476 ;;; Internal variables
1478 (defvar gnus-english-month-names
1479 '("January" "February" "March" "April" "May" "June" "July" "August"
1480 "September" "October" "November" "December"))
1482 (defvar article-goto-body-goes-to-point-min-p nil)
1483 (defvar gnus-article-wash-types nil)
1484 (defvar gnus-article-emphasis-alist nil)
1485 (defvar gnus-article-image-alist nil)
1487 (defvar gnus-article-mime-handle-alist-1 nil)
1488 (defvar gnus-treatment-function-alist
1489 '((gnus-treat-decode-article-as-default-mime-charset
1490 gnus-article-decode-article-as-default-mime-charset)
1491 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1492 (gnus-treat-monafy gnus-article-monafy)
1493 (gnus-treat-strip-banner gnus-article-strip-banner)
1494 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1495 (gnus-treat-buttonize gnus-article-add-buttons)
1496 (gnus-treat-fill-article gnus-article-fill-cited-article)
1497 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1498 (gnus-treat-strip-cr gnus-article-remove-cr)
1499 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1500 (gnus-treat-date-ut gnus-article-date-ut)
1501 (gnus-treat-date-local gnus-article-date-local)
1502 (gnus-treat-date-english gnus-article-date-english)
1503 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1504 (gnus-treat-date-original gnus-article-date-original)
1505 (gnus-treat-date-user-defined gnus-article-date-user)
1506 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1507 (gnus-treat-display-face gnus-article-display-face)
1508 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1509 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1510 (gnus-treat-hide-signature gnus-article-hide-signature)
1511 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1512 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1513 (gnus-treat-strip-pem gnus-article-hide-pem)
1514 (gnus-treat-from-picon gnus-treat-from-picon)
1515 (gnus-treat-mail-picon gnus-treat-mail-picon)
1516 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1517 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1518 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1519 (gnus-treat-strip-trailing-blank-lines
1520 gnus-article-remove-trailing-blank-lines)
1521 (gnus-treat-strip-leading-blank-lines
1522 gnus-article-strip-leading-blank-lines)
1523 (gnus-treat-strip-multiple-blank-lines
1524 gnus-article-strip-multiple-blank-lines)
1525 (gnus-treat-overstrike gnus-article-treat-overstrike)
1526 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1527 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1528 ;; Displaying X-Face should be done after unfolding headers
1529 ;; to protect bitmap lines.
1530 (gnus-treat-display-x-face gnus-article-display-x-face)
1531 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1532 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1533 (gnus-treat-display-smileys gnus-treat-smiley)
1534 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1535 (gnus-treat-wash-html gnus-article-wash-html)
1536 (gnus-treat-emphasize gnus-article-emphasize)
1537 (gnus-treat-hide-citation gnus-article-hide-citation)
1538 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1539 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1540 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1541 (gnus-treat-play-sounds gnus-earcon-display)))
1543 (defvar gnus-article-mime-handle-alist nil)
1544 (defvar article-lapsed-timer nil)
1545 (defvar gnus-article-current-summary nil)
1547 (defvar gnus-article-mode-syntax-table
1548 (let ((table (copy-syntax-table text-mode-syntax-table)))
1549 ;; This causes the citation match run O(2^n).
1550 ;; (modify-syntax-entry ?- "w" table)
1551 (modify-syntax-entry ?> ")<" table)
1552 (modify-syntax-entry ?< "(>" table)
1553 ;; make M-. in article buffers work for `foo' strings
1554 (modify-syntax-entry ?' " " table)
1555 (modify-syntax-entry ?` " " table)
1557 "Syntax table used in article mode buffers.
1558 Initialized from `text-mode-syntax-table.")
1560 (defvar gnus-save-article-buffer nil)
1562 (defvar gnus-article-mode-line-format-alist
1563 (nconc '((?w (gnus-article-wash-status) ?s)
1564 (?m (gnus-article-mime-part-status) ?s))
1565 gnus-summary-mode-line-format-alist))
1567 (defvar gnus-number-of-articles-to-be-saved nil)
1569 (defvar gnus-inhibit-hiding nil)
1571 ;;; Macros for dealing with the article buffer.
1573 (defmacro gnus-with-article-headers (&rest forms)
1575 (set-buffer gnus-article-buffer)
1577 (let ((buffer-read-only nil)
1578 (inhibit-point-motion-hooks t)
1579 (case-fold-search t))
1580 (article-narrow-to-head)
1583 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1584 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1586 (defmacro gnus-with-article-buffer (&rest forms)
1588 (set-buffer gnus-article-buffer)
1589 (let ((buffer-read-only nil))
1592 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1593 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1595 (defun gnus-article-goto-header (header)
1596 "Go to HEADER, which is a regular expression."
1597 (re-search-forward (concat "^\\(" header "\\):") nil t))
1599 (defsubst gnus-article-hide-text (b e props)
1600 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1601 (gnus-add-text-properties-when 'article-type nil b e props)
1602 (when (memq 'intangible props)
1604 (max (1- b) (point-min))
1605 b 'intangible (cddr (memq 'intangible props)))))
1607 (defsubst gnus-article-unhide-text (b e)
1608 "Remove hidden text properties from region between B and E."
1609 (remove-text-properties b e gnus-hidden-properties)
1610 (when (memq 'intangible gnus-hidden-properties)
1611 (put-text-property (max (1- b) (point-min))
1612 b 'intangible nil)))
1614 (defun gnus-article-hide-text-type (b e type)
1615 "Hide text of TYPE between B and E."
1616 (gnus-add-wash-type type)
1617 (gnus-article-hide-text
1618 b e (cons 'article-type (cons type gnus-hidden-properties))))
1620 (defun gnus-article-unhide-text-type (b e type)
1621 "Unhide text of TYPE between B and E."
1622 (gnus-delete-wash-type type)
1623 (remove-text-properties
1624 b e (cons 'article-type (cons type gnus-hidden-properties)))
1625 (when (memq 'intangible gnus-hidden-properties)
1626 (put-text-property (max (1- b) (point-min))
1627 b 'intangible nil)))
1629 (defun gnus-article-hide-text-of-type (type)
1630 "Hide text of TYPE in the current buffer."
1632 (let ((b (point-min))
1634 (while (setq b (text-property-any b e 'article-type type))
1635 (add-text-properties b (incf b) gnus-hidden-properties)))))
1637 (defun gnus-article-delete-text-of-type (type)
1638 "Delete text of TYPE in the current buffer."
1640 (let ((b (point-min)))
1641 (while (setq b (text-property-any b (point-max) 'article-type type))
1643 b (or (text-property-not-all b (point-max) 'article-type type)
1646 (defun gnus-article-delete-invisible-text ()
1647 "Delete all invisible text in the current buffer."
1649 (let ((b (point-min)))
1650 (while (setq b (text-property-any b (point-max) 'invisible t))
1652 b (or (text-property-not-all b (point-max) 'invisible t)
1655 (defun gnus-article-text-type-exists-p (type)
1656 "Say whether any text of type TYPE exists in the buffer."
1657 (text-property-any (point-min) (point-max) 'article-type type))
1659 (defsubst gnus-article-header-rank ()
1660 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1661 (let ((list gnus-sorted-header-list)
1664 (if (looking-at (car list))
1666 (setq list (cdr list))
1670 (defun article-hide-headers (&optional arg delete)
1671 "Hide unwanted headers and possibly sort them as well."
1672 (interactive (gnus-article-hidden-arg))
1673 ;; Lars said that this function might be inhibited.
1674 (if (gnus-article-check-hidden-text 'headers arg)
1676 ;; Show boring headers as well.
1677 (gnus-article-show-hidden-text 'boring-headers)
1678 (when (eq 1 (point-min))
1679 (set-window-start (get-buffer-window (current-buffer)) 1)))
1680 (unless gnus-inhibit-hiding
1683 (let ((inhibit-read-only t)
1684 (case-fold-search t)
1685 (max (1+ (length gnus-sorted-header-list)))
1686 (ignored (when (not gnus-visible-headers)
1687 (cond ((stringp gnus-ignored-headers)
1688 gnus-ignored-headers)
1689 ((listp gnus-ignored-headers)
1690 (mapconcat 'identity gnus-ignored-headers
1693 (cond ((stringp gnus-visible-headers)
1694 gnus-visible-headers)
1695 ((and gnus-visible-headers
1696 (listp gnus-visible-headers))
1697 (mapconcat 'identity gnus-visible-headers "\\|"))))
1698 (inhibit-point-motion-hooks t)
1700 ;; First we narrow to just the headers.
1701 (article-narrow-to-head)
1702 ;; Hide any "From " lines at the beginning of (mail) articles.
1703 (while (looking-at "From ")
1707 (delete-region (point-min) (point))
1708 (gnus-article-hide-text (point-min) (point)
1709 (nconc (list 'article-type 'headers)
1710 gnus-hidden-properties))))
1711 ;; Then treat the rest of the header lines.
1712 ;; Then we use the two regular expressions
1713 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1714 ;; select which header lines is to remain visible in the
1716 (while (re-search-forward "^[^ \t:]*:" nil t)
1718 ;; Mark the rank of the header.
1720 (point) (1+ (point)) 'message-rank
1721 (if (or (and visible (looking-at visible))
1723 (not (looking-at ignored))))
1724 (gnus-article-header-rank)
1727 (message-sort-headers-1)
1728 (when (setq beg (text-property-any
1729 (point-min) (point-max) 'message-rank (+ 2 max)))
1730 ;; We delete or make invisible the unwanted headers.
1731 (gnus-add-wash-type 'headers)
1734 (add-text-properties
1735 (point-min) (+ 5 (point-min))
1736 '(article-type headers dummy-invisible t))
1737 (delete-region beg (point-max)))
1738 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1740 (defun article-hide-boring-headers (&optional arg)
1741 "Toggle hiding of headers that aren't very interesting.
1742 If given a negative prefix, always show; if given a positive prefix,
1744 (interactive (gnus-article-hidden-arg))
1745 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1746 (not gnus-show-all-headers))
1749 (let ((buffer-read-only nil)
1750 (list gnus-boring-article-headers)
1751 (inhibit-point-motion-hooks t)
1753 (article-narrow-to-head)
1755 (setq elem (pop list))
1756 (goto-char (point-min))
1758 ;; Hide empty headers.
1760 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1762 (gnus-article-hide-text-type
1766 (if (re-search-forward "^[^ \t]" nil t)
1770 ;; Hide boring Newsgroups header.
1771 ((eq elem 'newsgroups)
1772 (when (gnus-string-equal
1773 (gnus-fetch-field "newsgroups")
1774 (gnus-group-real-name
1775 (if (boundp 'gnus-newsgroup-name)
1778 (gnus-article-hide-header "newsgroups")))
1779 ((eq elem 'to-address)
1780 (let ((to (message-fetch-field "to"))
1782 (gnus-parameter-to-address
1783 (if (boundp 'gnus-newsgroup-name)
1784 gnus-newsgroup-name ""))))
1785 (when (and to to-address
1788 ;; only one address in To
1789 (nth 1 (mail-extract-address-components to))
1791 (gnus-article-hide-header "to"))))
1793 (let ((to (message-fetch-field "to"))
1795 (gnus-parameter-to-list
1796 (if (boundp 'gnus-newsgroup-name)
1797 gnus-newsgroup-name ""))))
1798 (when (and to to-list
1801 ;; only one address in To
1802 (nth 1 (mail-extract-address-components to))
1804 (gnus-article-hide-header "to"))))
1806 (let ((cc (message-fetch-field "cc"))
1808 (gnus-parameter-to-list
1809 (if (boundp 'gnus-newsgroup-name)
1810 gnus-newsgroup-name ""))))
1811 (when (and cc to-list
1814 ;; only one address in CC
1815 (nth 1 (mail-extract-address-components cc))
1817 (gnus-article-hide-header "cc"))))
1818 ((eq elem 'followup-to)
1819 (when (gnus-string-equal
1820 (message-fetch-field "followup-to")
1821 (message-fetch-field "newsgroups"))
1822 (gnus-article-hide-header "followup-to")))
1823 ((eq elem 'reply-to)
1824 (if (gnus-group-find-parameter
1825 gnus-newsgroup-name 'broken-reply-to)
1826 (gnus-article-hide-header "reply-to")
1827 (let ((from (message-fetch-field "from"))
1828 (reply-to (message-fetch-field "reply-to")))
1835 (lambda (x) (downcase (cadr x)))
1836 (mail-extract-address-components from t))
1839 (lambda (x) (downcase (cadr x)))
1840 (mail-extract-address-components reply-to t))
1842 (gnus-article-hide-header "reply-to")))))
1844 (let ((date (message-fetch-field "date")))
1846 (< (days-between (current-time-string) date)
1848 (gnus-article-hide-header "date"))))
1850 (let ((to (message-fetch-field "to"))
1851 (cc (message-fetch-field "cc")))
1852 (when (> (length to) 1024)
1853 (gnus-article-hide-header "to"))
1854 (when (> (length cc) 1024)
1855 (gnus-article-hide-header "cc"))))
1859 (goto-char (point-min))
1860 (while (re-search-forward "^to:" nil t)
1861 (setq to-count (1+ to-count)))
1862 (when (> to-count 1)
1863 (while (> to-count 0)
1864 (goto-char (point-min))
1866 (re-search-forward "^to:" nil nil to-count)
1868 (narrow-to-region (point) (point-max))
1869 (gnus-article-hide-header "to"))
1870 (setq to-count (1- to-count))))
1871 (goto-char (point-min))
1872 (while (re-search-forward "^cc:" nil t)
1873 (setq cc-count (1+ cc-count)))
1874 (when (> cc-count 1)
1875 (while (> cc-count 0)
1876 (goto-char (point-min))
1878 (re-search-forward "^cc:" nil nil cc-count)
1880 (narrow-to-region (point) (point-max))
1881 (gnus-article-hide-header "cc"))
1882 (setq cc-count (1- cc-count)))))))))))))
1884 (defun gnus-article-hide-header (header)
1886 (goto-char (point-min))
1887 (when (re-search-forward (concat "^" header ":") nil t)
1888 (gnus-article-hide-text-type
1892 (if (re-search-forward "^[^ \t]" nil t)
1897 (defvar gnus-article-normalized-header-length 40
1898 "Length of normalized headers.")
1900 (defun article-normalize-headers ()
1901 "Make all header lines 40 characters long."
1903 (let ((buffer-read-only nil)
1907 (article-narrow-to-head)
1910 ((< (setq column (- (gnus-point-at-eol) (point)))
1911 gnus-article-normalized-header-length)
1913 (insert (make-string
1914 (- gnus-article-normalized-header-length column)
1916 ((> column gnus-article-normalized-header-length)
1917 (gnus-put-text-property
1919 (forward-char gnus-article-normalized-header-length)
1926 (forward-line 1))))))
1928 (defun article-treat-dumbquotes ()
1929 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1930 Note that this function guesses whether a character is a sm*rtq**t* or
1931 not, so it should only be used interactively.
1933 Sm*rtq**t*s are M****s***'s unilateral extension to the
1934 iso-8859-1 character map in an attempt to provide more quoting
1935 characters. If you see something like \\222 or \\264 where
1936 you're expecting some kind of apostrophe or quotation mark, then
1939 (article-translate-strings gnus-article-dumbquotes-map))
1941 (defun article-translate-characters (from to)
1942 "Translate all characters in the body of the article according to FROM and TO.
1943 FROM is a string of characters to translate from; to is a string of
1944 characters to translate to."
1946 (when (article-goto-body)
1947 (let ((buffer-read-only nil)
1948 (x (make-string 225 ?x))
1950 (while (< (incf i) (length x))
1953 (while (< i (length from))
1954 (aset x (aref from i) (aref to i))
1956 (translate-region (point) (point-max) x)))))
1958 (defun article-translate-strings (map)
1959 "Translate all string in the body of the article according to MAP.
1960 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1962 (when (article-goto-body)
1963 (let ((buffer-read-only nil)
1965 (while (setq elem (pop map))
1967 (while (search-forward (car elem) nil t)
1968 (replace-match (cadr elem)))))))))
1970 (defun article-treat-overstrike ()
1971 "Translate overstrikes into bold text."
1974 (when (article-goto-body)
1975 (let ((buffer-read-only nil))
1976 (while (search-forward "\b" nil t)
1977 (let ((next (char-after))
1981 previous (char-after))
1985 ;; We do the boldification/underlining by hiding the
1986 ;; overstrikes and putting the proper text property
1990 (gnus-article-hide-text-type start (point) 'overstrike)
1991 (put-text-property (point) end 'face 'bold))
1993 (gnus-article-hide-text-type
1994 (1- (point)) (1+ (point)) 'overstrike)
1996 start (1- (point)) 'face 'underline))
1998 (gnus-article-hide-text-type start (point) 'overstrike)
2000 (point) end 'face 'underline)))))))))
2002 (defun gnus-article-treat-unfold-headers ()
2003 "Unfold folded message headers.
2004 Only the headers that fit into the current window width will be
2007 (gnus-with-article-headers
2011 (mail-header-narrow-to-field)
2012 (let ((header (buffer-string)))
2015 (goto-char (point-min))
2016 (while (re-search-forward "\n[\t ]" nil t)
2017 (replace-match " " t t)))
2018 (setq length (- (point-max) (point-min) 1)))
2019 (when (< length (window-width))
2020 (while (re-search-forward "\n[\t ]" nil t)
2021 (replace-match " " t t)))
2022 (goto-char (point-max)))))))
2024 (defun gnus-article-treat-fold-headers ()
2025 "Fold message headers."
2027 (gnus-with-article-headers
2030 (mail-header-narrow-to-field)
2031 (mail-header-fold-field)
2032 (goto-char (point-max))))))
2034 (defun gnus-treat-smiley ()
2035 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2037 (unless (featurep 'xemacs)
2038 (when (and (>= emacs-major-version 21)
2039 (not gnus-article-should-use-smiley-mule)
2040 gnus-article-smiley-mule-loaded-p)
2041 (load "smiley" nil t)
2042 (setq gnus-article-smiley-mule-loaded-p nil))
2043 (when (and gnus-article-should-use-smiley-mule
2044 (not gnus-article-smiley-mule-loaded-p))
2045 (load "smiley-mule" nil t)
2046 (setq gnus-article-smiley-mule-loaded-p t)))
2047 (gnus-with-article-buffer
2048 (if (memq 'smiley gnus-article-wash-types)
2049 (gnus-delete-images 'smiley)
2051 (let ((images (smiley-region (point) (point-max))))
2053 (gnus-add-wash-type 'smiley)
2054 (dolist (image images)
2055 (gnus-add-image 'smiley image)))))))
2057 (defun gnus-article-remove-images ()
2058 "Remove all images from the article buffer."
2060 (gnus-with-article-buffer
2061 (dolist (elem gnus-article-image-alist)
2062 (gnus-delete-images (car elem)))))
2064 (defun gnus-article-treat-fold-newsgroups ()
2065 "Unfold folded message headers.
2066 Only the headers that fit into the current window width will be
2069 (gnus-with-article-headers
2070 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2072 (mail-header-narrow-to-field)
2073 (while (re-search-forward ", *" nil t)
2074 (replace-match ", " t t))
2075 (mail-header-fold-field)
2076 (goto-char (point-max))))))
2078 (defun gnus-article-treat-body-boundary ()
2079 "Place a boundary line at the end of the headers."
2081 (when (and gnus-body-boundary-delimiter
2082 (> (length gnus-body-boundary-delimiter) 0))
2083 (gnus-with-article-headers
2084 (goto-char (point-max))
2085 (let ((start (point)))
2086 (insert "X-Boundary: ")
2087 (gnus-add-text-properties start (point) '(invisible t intangible t))
2089 (while (>= (1- (window-width)) (length str))
2090 (setq str (concat str gnus-body-boundary-delimiter)))
2091 (substring str 0 (1- (window-width))))
2093 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2095 (defun article-fill-long-lines ()
2096 "Fill lines that are wider than the window width."
2099 (let ((buffer-read-only nil)
2100 (width (window-width (get-buffer-window (current-buffer)))))
2103 (let ((adaptive-fill-mode nil)) ;Why? -sm
2106 (when (>= (current-column) (min fill-column width))
2107 (narrow-to-region (min (1+ (point)) (point-max))
2108 (gnus-point-at-bol))
2109 (let ((goback (point-marker)))
2110 (fill-paragraph nil)
2111 (goto-char (marker-position goback)))
2113 (forward-line 1)))))))
2115 (defun article-capitalize-sentences ()
2116 "Capitalize the first word in each sentence."
2119 (let ((buffer-read-only nil)
2120 (paragraph-start "^[\n\^L]"))
2124 (forward-sentence)))))
2126 (defun article-remove-cr ()
2127 "Remove trailing CRs and then translate remaining CRs into LFs."
2130 (let ((buffer-read-only nil))
2131 (goto-char (point-min))
2132 (while (re-search-forward "\r+$" nil t)
2133 (replace-match "" t t))
2134 (goto-char (point-min))
2135 (while (search-forward "\r" nil t)
2136 (replace-match "\n" t t)))))
2138 (defun article-remove-trailing-blank-lines ()
2139 "Remove all trailing blank lines from the article."
2142 (let ((buffer-read-only nil))
2143 (goto-char (point-max))
2147 (while (and (not (bobp))
2148 (looking-at "^[ \t]*$")
2149 (not (gnus-annotation-in-region-p
2150 (point) (gnus-point-at-eol))))
2155 (defun article-display-face ()
2156 "Display any Face headers in the header."
2158 (let ((wash-face-p buffer-read-only))
2159 (gnus-with-article-headers
2160 ;; When displaying parts, this function can be called several times on
2161 ;; the same article, without any intended toggle semantic (as typing `W
2162 ;; D d' would have). So face deletion must occur only when we come from
2163 ;; an interactive command, that is when the *Article* buffer is
2165 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2166 (gnus-delete-images 'face)
2169 (when (and wash-face-p
2171 (goto-char (point-min))
2172 (not (re-search-forward "^Face:[\t ]*" nil t)))
2173 (gnus-buffer-live-p gnus-original-article-buffer))
2174 (set-buffer gnus-original-article-buffer))
2176 (mail-narrow-to-head)
2177 (while (gnus-article-goto-header "Face")
2178 (push (mail-header-field-value) faces))))
2179 (while (setq face (pop faces))
2180 (let ((png (gnus-convert-face-to-png face))
2183 (setq image (gnus-create-image png 'png t))
2184 (gnus-article-goto-header "from")
2186 (insert "From: [no `from' set]\n")
2188 (gnus-add-wash-type 'face)
2189 (gnus-add-image 'face image)
2190 (gnus-put-image image nil 'face))))))
2193 (defun article-display-x-face (&optional force)
2194 "Look for an X-Face header and display it if present."
2195 (interactive (list 'force))
2196 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2197 (gnus-with-article-headers
2198 ;; Delete the old process, if any.
2199 (when (process-status "article-x-face")
2200 (delete-process "article-x-face"))
2201 ;; See the comment in `article-display-face'.
2202 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2203 ;; We have already displayed X-Faces, so we remove them
2205 (gnus-delete-images 'xface)
2207 (let (x-faces from face)
2209 (when (and wash-face-p
2211 (goto-char (point-min))
2212 (not (re-search-forward
2213 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2214 (gnus-buffer-live-p gnus-original-article-buffer))
2215 ;; If type `W f', use gnus-original-article-buffer,
2216 ;; otherwise use the current buffer because displaying
2217 ;; RFC822 parts calls this function too.
2218 (set-buffer gnus-original-article-buffer))
2220 (mail-narrow-to-head)
2221 (while (gnus-article-goto-header "X-Face")
2222 (push (mail-header-field-value) x-faces))
2223 (setq from (message-fetch-field "from"))))
2224 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2225 ;; single external face.
2226 (when (stringp gnus-article-x-face-command)
2227 (setq x-faces (list (car x-faces))))
2228 (while (and (setq face (pop x-faces))
2229 gnus-article-x-face-command
2231 ;; Check whether this face is censored.
2232 (not gnus-article-x-face-too-ugly)
2233 (and gnus-article-x-face-too-ugly from
2234 (not (string-match gnus-article-x-face-too-ugly
2236 ;; We display the face.
2237 (cond ((stringp gnus-article-x-face-command)
2238 ;; The command is a string, so we interpret the command
2239 ;; as a, well, command, and fork it off.
2240 (let ((process-connection-type nil))
2241 (process-kill-without-query
2243 "article-x-face" nil shell-file-name
2244 shell-command-switch gnus-article-x-face-command))
2247 (process-send-region "article-x-face"
2248 (point-min) (point-max)))
2249 (process-send-eof "article-x-face")))
2250 ((functionp gnus-article-x-face-command)
2251 ;; The command is a lisp function, so we call it.
2252 (funcall gnus-article-x-face-command face))
2254 (error "%s is not a function"
2255 gnus-article-x-face-command)))))))))
2257 (defun article-decode-mime-words ()
2258 "Decode all MIME-encoded words in the article."
2261 (set-buffer gnus-article-buffer)
2262 (let ((inhibit-point-motion-hooks t)
2264 (mail-parse-charset gnus-newsgroup-charset)
2265 (mail-parse-ignored-charsets
2266 (save-excursion (set-buffer gnus-summary-buffer)
2267 gnus-newsgroup-ignored-charsets)))
2268 (mail-decode-encoded-word-region (point-min) (point-max)))))
2270 (defun article-decode-charset (&optional prompt)
2271 "Decode charset-encoded text in the article.
2272 If PROMPT (the prefix), prompt for a coding system to use."
2274 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2276 (mail-parse-charset gnus-newsgroup-charset)
2277 (mail-parse-ignored-charsets
2278 (save-excursion (condition-case nil
2279 (set-buffer gnus-summary-buffer)
2281 gnus-newsgroup-ignored-charsets))
2282 ct cte ctl charset format)
2285 (article-narrow-to-head)
2286 (setq ct (message-fetch-field "Content-Type" t)
2287 cte (message-fetch-field "Content-Transfer-Encoding" t)
2288 ctl (and ct (ignore-errors
2289 (mail-header-parse-content-type ct)))
2292 (mm-read-coding-system "Charset to decode: "))
2294 (mail-content-type-get ctl 'charset)))
2295 format (and ctl (mail-content-type-get ctl 'format)))
2297 (setq cte (mail-header-strip cte)))
2298 (if (and ctl (not (string-match "/" (car ctl))))
2300 (goto-char (point-max)))
2303 (narrow-to-region (point) (point-max))
2304 (when (and (eq mail-parse-charset 'gnus-decoded)
2305 (eq (mm-body-7-or-8) '8bit))
2306 ;; The text code could have been decoded.
2307 (setq charset mail-parse-charset))
2308 (when (and (or (not ctl)
2309 (equal (car ctl) "text/plain"))
2310 (not format)) ;; article with format will decode later.
2312 charset (and cte (intern (downcase
2313 (gnus-strip-whitespace cte))))
2316 (defun article-decode-encoded-words ()
2317 "Remove encoded-word encoding from headers."
2318 (let (buffer-read-only)
2319 (let ((charset (save-excursion
2320 (set-buffer gnus-summary-buffer)
2321 default-mime-charset)))
2322 (mime-decode-header-in-buffer charset))))
2324 (defun article-decode-group-name ()
2325 "Decode group names in `Newsgroups:'."
2326 (let ((inhibit-point-motion-hooks t)
2328 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2329 (when (and (or gnus-group-name-charset-method-alist
2330 gnus-group-name-charset-group-alist)
2331 (gnus-buffer-live-p gnus-original-article-buffer))
2333 (article-narrow-to-head)
2334 (with-current-buffer gnus-original-article-buffer
2335 (goto-char (point-min)))
2336 (while (re-search-forward
2337 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2338 (replace-match (save-match-data
2339 (gnus-decode-newsgroups
2340 ;; XXX how to use data in article buffer?
2341 (with-current-buffer gnus-original-article-buffer
2343 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2346 gnus-newsgroup-name method))
2348 (goto-char (point-min))
2349 (with-current-buffer gnus-original-article-buffer
2350 (goto-char (point-min)))
2351 (while (re-search-forward
2352 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2353 (replace-match (save-match-data
2354 (gnus-decode-newsgroups
2355 ;; XXX how to use data in article buffer?
2356 (with-current-buffer gnus-original-article-buffer
2358 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2361 gnus-newsgroup-name method))
2364 (autoload 'idna-to-unicode "idna")
2366 (defun article-decode-idna-rhs ()
2367 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2370 (let ((inhibit-point-motion-hooks t)
2372 (article-narrow-to-head)
2373 (goto-char (point-min))
2374 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2376 (when (save-match-data
2377 (and (setq ace (match-string 1))
2379 (and (re-search-backward "^[^ \t]" nil t)
2380 (looking-at "From\\|To\\|Cc")))
2381 (save-excursion (backward-char)
2382 (message-idna-inside-rhs-p))
2383 (setq unicode (idna-to-unicode ace))))
2384 (unless (string= ace unicode)
2385 (replace-match unicode nil nil nil 1)))))))))
2387 (defun article-de-quoted-unreadable (&optional force read-charset)
2388 "Translate a quoted-printable-encoded article.
2389 If FORCE, decode the article whether it is marked as quoted-printable
2391 If READ-CHARSET, ask for a coding system."
2392 (interactive (list 'force current-prefix-arg))
2394 (let ((buffer-read-only nil) type charset)
2395 (if (gnus-buffer-live-p gnus-original-article-buffer)
2396 (with-current-buffer gnus-original-article-buffer
2398 (gnus-fetch-field "content-transfer-encoding"))
2399 (let* ((ct (gnus-fetch-field "content-type"))
2402 (mail-header-parse-content-type ct)))))
2403 (setq charset (and ctl
2404 (mail-content-type-get ctl 'charset)))
2405 (if (stringp charset)
2406 (setq charset (intern (downcase charset)))))))
2408 (setq charset (mm-read-coding-system "Charset: " charset)))
2410 (setq charset gnus-newsgroup-charset))
2412 (and type (let ((case-fold-search t))
2413 (string-match "quoted-printable" type))))
2415 (quoted-printable-decode-region
2416 (point) (point-max) (mm-charset-to-coding-system charset))))))
2418 (defun article-de-base64-unreadable (&optional force read-charset)
2419 "Translate a base64 article.
2420 If FORCE, decode the article whether it is marked as base64 not.
2421 If READ-CHARSET, ask for a coding system."
2422 (interactive (list 'force current-prefix-arg))
2424 (let ((buffer-read-only nil) type charset)
2425 (if (gnus-buffer-live-p gnus-original-article-buffer)
2426 (with-current-buffer gnus-original-article-buffer
2428 (gnus-fetch-field "content-transfer-encoding"))
2429 (let* ((ct (gnus-fetch-field "content-type"))
2432 (mail-header-parse-content-type ct)))))
2433 (setq charset (and ctl
2434 (mail-content-type-get ctl 'charset)))
2435 (if (stringp charset)
2436 (setq charset (intern (downcase charset)))))))
2438 (setq charset (mm-read-coding-system "Charset: " charset)))
2440 (setq charset gnus-newsgroup-charset))
2442 (and type (let ((case-fold-search t))
2443 (string-match "base64" type))))
2446 (narrow-to-region (point) (point-max))
2447 (base64-decode-region (point-min) (point-max))
2448 (mm-decode-coding-region
2449 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2454 (defun article-decode-HZ ()
2455 "Translate a HZ-encoded article."
2459 (let ((buffer-read-only nil))
2460 (rfc1843-decode-region (point-min) (point-max)))))
2462 (defun article-unsplit-urls ()
2463 "Remove the newlines that some other mailers insert into URLs."
2466 (let ((buffer-read-only nil))
2467 (goto-char (point-min))
2468 (while (re-search-forward
2469 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2470 (replace-match "\\1\\3" t)))
2471 (when (interactive-p)
2472 (gnus-treat-article nil))))
2475 (defun article-wash-html (&optional read-charset)
2476 "Format an HTML article.
2477 If READ-CHARSET, ask for a coding system."
2480 (let ((buffer-read-only nil)
2482 (when (gnus-buffer-live-p gnus-original-article-buffer)
2483 (with-current-buffer gnus-original-article-buffer
2484 (let* ((ct (gnus-fetch-field "content-type"))
2487 (mail-header-parse-content-type ct)))))
2488 (setq charset (and ctl
2489 (mail-content-type-get ctl 'charset)))
2490 (when (stringp charset)
2491 (setq charset (intern (downcase charset)))))))
2493 (setq charset (mm-read-coding-system "Charset: " charset)))
2495 (setq charset gnus-newsgroup-charset))
2497 (save-window-excursion
2499 (narrow-to-region (point) (point-max))
2500 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2501 (entry (assq func mm-text-html-washer-alist)))
2503 (setq func (cdr entry)))
2508 (apply (car func) (cdr func))))))))))
2510 (defun gnus-article-wash-html-with-w3 ()
2511 "Wash the current buffer with w3."
2513 (let ((w3-strict-width (window-width))
2514 (url-standalone-mode t)
2515 (url-gateway-unplugged t)
2516 (w3-honor-stylesheets nil))
2518 (w3-region (point-min) (point-max))
2521 (defun gnus-article-wash-html-with-w3m ()
2522 "Wash the current buffer with emacs-w3m."
2525 (narrow-to-region (point) (point-max))
2526 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2529 w3m-force-redisplay)
2530 (w3m-region (point-min) (point-max)))
2531 (when mm-inline-text-html-with-w3m-keymap
2532 (add-text-properties
2533 (point-min) (point-max)
2534 (nconc (mm-w3m-local-map-property)
2535 '(mm-inline-text-html-with-w3m t))))))
2537 (defun article-hide-list-identifiers ()
2538 "Remove list identifies from the Subject header.
2539 The `gnus-list-identifiers' variable specifies what to do."
2541 (let ((inhibit-point-motion-hooks t)
2542 (regexp (if (consp gnus-list-identifiers)
2543 (mapconcat 'identity gnus-list-identifiers " *\\|")
2544 gnus-list-identifiers))
2549 (article-narrow-to-head)
2550 (goto-char (point-min))
2551 (while (re-search-forward
2552 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2554 (delete-region (match-beginning 2) (match-end 0))
2555 (beginning-of-line))
2556 (when (re-search-forward
2557 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2558 (delete-region (match-beginning 1) (match-end 1))))))))
2560 (defun article-hide-pem (&optional arg)
2561 "Toggle hiding of any PEM headers and signatures in the current article.
2562 If given a negative prefix, always show; if given a positive prefix,
2564 (interactive (gnus-article-hidden-arg))
2565 (unless (gnus-article-check-hidden-text 'pem arg)
2567 (let (buffer-read-only end)
2568 (goto-char (point-min))
2569 ;; Hide the horrendously ugly "header".
2570 (when (and (search-forward
2571 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2573 (setq end (1+ (match-beginning 0))))
2574 (gnus-add-wash-type 'pem)
2575 (gnus-article-hide-text-type
2577 (if (search-forward "\n\n" nil t)
2581 ;; Hide the trailer as well
2582 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2584 (gnus-article-hide-text-type
2585 (match-beginning 0) (match-end 0) 'pem)))))))
2587 (defun article-strip-banner ()
2588 "Strip the banners specified by the `banner' group parameter and by
2589 `gnus-article-address-banner-alist'."
2593 (let ((inhibit-point-motion-hooks t))
2594 (when (gnus-parameter-banner gnus-newsgroup-name)
2595 (article-really-strip-banner
2596 (gnus-parameter-banner gnus-newsgroup-name)))
2597 (when gnus-article-address-banner-alist
2598 (article-really-strip-banner
2599 (let ((from (save-restriction
2601 (article-narrow-to-head)
2602 (mail-fetch-field "from"))))
2605 (caar (mail-header-parse-addresses from))))
2607 (dolist (pair gnus-article-address-banner-alist)
2608 (when (string-match (car pair) from)
2609 (throw 'found (cdr pair)))))))))))))
2611 (defun article-really-strip-banner (banner)
2612 "Strip the banner specified by the argument."
2615 (let ((inhibit-point-motion-hooks t)
2616 (gnus-signature-limit nil)
2620 ((eq banner 'signature)
2621 (when (gnus-article-narrow-to-signature)
2624 (delete-region (point) (point-max))))
2626 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2627 (while (re-search-forward banner nil t)
2628 (delete-region (match-beginning 0) (match-end 0)))))
2630 (while (re-search-forward banner nil t)
2631 (delete-region (match-beginning 0) (match-end 0)))))))))
2633 (defun article-babel ()
2634 "Translate article using an online translation service."
2638 (set-buffer gnus-article-buffer)
2639 (when (article-goto-body)
2640 (let* ((buffer-read-only nil)
2643 (orig (buffer-substring start end))
2644 (trans (babel-as-string orig)))
2646 (narrow-to-region start end)
2647 (delete-region start end)
2650 (defun article-hide-signature (&optional arg)
2651 "Hide the signature in the current article.
2652 If given a negative prefix, always show; if given a positive prefix,
2654 (interactive (gnus-article-hidden-arg))
2660 (article-goto-body))
2661 (goto-char (point-min)))
2662 (unless (gnus-article-check-hidden-text 'signature arg)
2663 (let ((buffer-read-only nil)
2665 (while (setq button (text-property-any button (point-max)
2667 'gnus-signature-toggle))
2668 (setq button (text-property-not-all button (point-max)
2670 'gnus-signature-toggle))
2671 (when (and button (not (eobp)))
2672 (gnus-article-hide-text-type
2674 (next-single-property-change (1+ button) 'mime-view-entity
2677 (gnus-set-mode-line 'article))
2679 (defun article-strip-headers-in-body ()
2680 "Strip offensive headers from bodies."
2684 (let ((case-fold-search t))
2685 (when (looking-at "x-no-archive:")
2686 (gnus-delete-line)))))
2688 (defun article-strip-leading-blank-lines ()
2689 "Remove all blank lines from the beginning of the article."
2692 (let ((inhibit-point-motion-hooks t)
2694 (when (article-goto-body)
2695 (while (and (not (eobp))
2696 (looking-at "[ \t]*$"))
2697 (gnus-delete-line))))))
2699 (defun article-narrow-to-head ()
2700 "Narrow the buffer to the head of the message.
2701 Point is left at the beginning of the narrowed-to region."
2703 (goto-char (point-min))
2704 (if (search-forward "\n\n" nil 1)
2707 (goto-char (point-min)))
2709 (defun article-goto-body ()
2710 "Place point at the start of the body."
2711 (goto-char (point-min))
2713 ;; This variable is only bound when dealing with separate
2715 (article-goto-body-goes-to-point-min-p
2717 ((search-forward "\n\n" nil t)
2720 (goto-char (point-max))
2723 (defun article-strip-multiple-blank-lines ()
2724 "Replace consecutive blank lines with one empty line."
2727 (let ((inhibit-point-motion-hooks t)
2729 ;; First make all blank lines empty.
2731 (while (re-search-forward "^[ \t]+$" nil t)
2732 (unless (gnus-annotation-in-region-p
2733 (match-beginning 0) (match-end 0))
2734 (replace-match "" nil t)))
2735 ;; Then replace multiple empty lines with a single empty line.
2737 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2738 (unless (gnus-annotation-in-region-p
2739 (match-beginning 0) (match-end 0))
2740 (delete-region (match-beginning 1) (match-end 1)))))))
2742 (defun article-strip-leading-space ()
2743 "Remove all white space from the beginning of the lines in the article."
2746 (let ((inhibit-point-motion-hooks t)
2749 (while (re-search-forward "^[ \t]+" nil t)
2750 (replace-match "" t t)))))
2752 (defun article-strip-trailing-space ()
2753 "Remove all white space from the end of the lines in the article."
2756 (let ((inhibit-point-motion-hooks t)
2759 (while (re-search-forward "[ \t]+$" nil t)
2760 (replace-match "" t t)))))
2762 (defun article-strip-blank-lines ()
2763 "Strip leading, trailing and multiple blank lines."
2765 (article-strip-leading-blank-lines)
2766 (article-remove-trailing-blank-lines)
2767 (article-strip-multiple-blank-lines))
2769 (defun article-strip-all-blank-lines ()
2770 "Strip all blank lines."
2773 (let ((inhibit-point-motion-hooks t)
2776 (while (re-search-forward "^[ \t]*\n" nil t)
2777 (replace-match "" t t)))))
2779 (defun gnus-article-narrow-to-signature ()
2780 "Narrow to the signature; return t if a signature is found, else nil."
2781 (let ((inhibit-point-motion-hooks t))
2782 (when (gnus-article-search-signature)
2784 ;; Check whether we have some limits to what we consider
2785 ;; to be a signature.
2786 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2787 (list gnus-signature-limit)))
2789 (while (setq limit (pop limits))
2790 (if (or (and (integerp limit)
2791 (< (- (point-max) (point)) limit))
2793 (< (count-lines (point) (point-max)) limit))
2794 (and (functionp limit)
2796 (and (stringp limit)
2797 (not (re-search-forward limit nil t))))
2798 () ; This limit did not succeed.
2802 (narrow-to-region (point) (point-max))
2805 (defun gnus-article-search-signature ()
2806 "Search the current buffer for the signature separator.
2807 Put point at the beginning of the signature separator."
2808 (let ((cur (point)))
2809 (goto-char (point-max))
2810 (if (if (stringp gnus-signature-separator)
2811 (re-search-backward gnus-signature-separator nil t)
2812 (let ((seps gnus-signature-separator))
2814 (not (re-search-backward (car seps) nil t)))
2821 (defun gnus-article-hidden-arg ()
2822 "Return the current prefix arg as a number, or 0 if no prefix."
2823 (list (if current-prefix-arg
2824 (prefix-numeric-value current-prefix-arg)
2827 (defun gnus-article-check-hidden-text (type arg)
2828 "Return nil if hiding is necessary.
2829 Arg can be nil or a number. nil and positive means hide, negative
2830 means show, 0 means toggle."
2833 (let ((hide (gnus-article-hidden-text-p type)))
2839 (gnus-article-show-hidden-text type)
2842 (if (eq hide 'hidden)
2844 (gnus-article-show-hidden-text type)
2848 (defun gnus-article-hidden-text-p (type)
2849 "Say whether the current buffer contains hidden text of type TYPE."
2850 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2852 (not (get-text-property pos 'invisible))
2853 (not (get-text-property pos 'dummy-invisible)))
2855 (text-property-any (1+ pos) (point-max) 'article-type type)))
2860 (defun gnus-article-show-hidden-text (type &optional dummy)
2861 "Show all hidden text of type TYPE.
2862 Originally it is hide instead of DUMMY."
2863 (let ((buffer-read-only nil)
2864 (inhibit-point-motion-hooks t))
2865 (gnus-remove-text-properties-when
2867 (point-min) (point-max)
2868 (cons 'article-type (cons type
2869 gnus-hidden-properties)))
2870 (gnus-delete-wash-type type)))
2872 (defconst article-time-units
2873 `((year . ,(* 365.25 24 60 60))
2874 (week . ,(* 7 24 60 60))
2875 (day . ,(* 24 60 60))
2879 "Mapping from time units to seconds.")
2881 (defun gnus-article-forward-header ()
2882 "Move point to the start of the next header.
2883 If the current header is a continuation header, this can be several
2888 (if (looking-at "[ \t]+[^ \t]")
2892 (defun article-date-ut (&optional type highlight header)
2893 "Convert DATE date to universal time in the current article.
2894 If TYPE is `local', convert to local time; if it is `lapsed', output
2895 how much time has lapsed since DATE. For `lapsed', the value of
2896 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2897 should replace the \"Date:\" one, or should be added below it."
2898 (interactive (list 'ut t))
2899 (let* ((header (or header
2900 (and (eq 1 (point-min))
2901 (mail-header-date (save-excursion
2902 (set-buffer gnus-summary-buffer)
2903 gnus-current-headers)))
2904 (message-fetch-field "date")
2906 (date (if (vectorp header) (mail-header-date header)
2908 (inhibit-point-motion-hooks t)
2909 bface eface date-pos)
2910 (when (and date (not (string= date "")))
2913 (article-narrow-to-head)
2914 (when (or (and (eq type 'lapsed)
2915 gnus-article-date-lapsed-new-header
2916 ;; Attempt to get the face of X-Sent first.
2917 (re-search-forward "^X-Sent:[ \t]" nil t))
2918 (re-search-forward "^Date:[ \t]" nil t)
2919 ;; If Date is missing, try again for X-Sent.
2920 (re-search-forward "^X-Sent:[ \t]" nil t))
2921 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2922 date (or (get-text-property (gnus-point-at-bol)
2925 eface (get-text-property (1- (gnus-point-at-eol))
2927 (let ((buffer-read-only nil))
2928 ;; Delete any old X-Sent headers.
2929 (when (setq date-pos
2930 (text-property-any (point-min) (point-max)
2931 'article-date-lapsed t))
2932 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2933 (delete-region (match-beginning 0)
2934 (progn (forward-line 1) (point))))
2935 (goto-char (point-min))
2936 ;; Delete any old Date headers.
2937 (while (re-search-forward "^Date:[ \t]" nil t)
2939 (setq date-pos (match-beginning 0)))
2940 (unless (and (eq type 'lapsed)
2941 gnus-article-date-lapsed-new-header)
2942 (delete-region (match-beginning 0)
2943 (progn (message-next-header) (point)))))
2946 (goto-char date-pos)
2948 ;; Possibly, Date has been deleted.
2950 (when (and (eq type 'lapsed)
2951 gnus-article-date-lapsed-new-header
2952 (looking-at "Date:"))
2954 (goto-char (point-min)))
2955 (insert (article-make-date-line date type))
2956 (when (eq type 'lapsed)
2957 (put-text-property (gnus-point-at-bol) (point)
2958 'article-date-lapsed t))
2962 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2963 (put-text-property (match-beginning 1) (1+ (match-end 1))
2964 'original-date date)
2965 (put-text-property (match-beginning 1) (1+ (match-end 1))
2967 (put-text-property (match-beginning 2) (match-end 2)
2970 (defun article-make-date-line (date type)
2971 "Return a DATE line of TYPE."
2972 (unless (memq type '(local ut original user iso8601 lapsed english))
2973 (error "Unknown conversion type: %s" type))
2975 (let ((time (date-to-time date)))
2977 ;; Convert to the local timezone.
2979 (let ((tz (car (current-time-zone time))))
2980 (format "Date: %s %s%02d%02d" (current-time-string time)
2981 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2982 (/ (% (abs tz) 3600) 60))))
2983 ;; Convert to Universal Time.
2986 (current-time-string
2987 (let* ((e (parse-time-string date))
2988 (tm (apply 'encode-time e))
2990 (ls (- (cadr tm) (car (current-time-zone time)))))
2991 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2992 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2995 ;; Get the original date from the article.
2996 ((eq type 'original)
2997 (concat "Date: " (if (string-match "\n+$" date)
2998 (substring date 0 (match-beginning 0))
3000 ;; Let the user define the format.
3002 (let ((format (or (condition-case nil
3003 (with-current-buffer gnus-summary-buffer
3004 gnus-article-time-format)
3006 gnus-article-time-format)))
3007 (if (functionp format)
3008 (funcall format time)
3009 (concat "Date: " (format-time-string format time)))))
3012 (let ((tz (car (current-time-zone time))))
3015 (format-time-string "%Y%m%dT%H%M%S" time)
3016 (format "%s%02d%02d"
3017 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3018 (/ (% (abs tz) 3600) 60)))))
3019 ;; Do an X-Sent lapsed format.
3021 ;; If the date is seriously mangled, the timezone functions are
3022 ;; liable to bug out, so we ignore all errors.
3023 (let* ((now (current-time))
3024 (real-time (subtract-time now time))
3025 (real-sec (and real-time
3026 (+ (* (float (car real-time)) 65536)
3028 (sec (and real-time (abs real-sec)))
3038 ;; This is a bit convoluted, but basically we go
3039 ;; through the time units for years, weeks, etc,
3040 ;; and divide things to see whether that results
3041 ;; in positive answers.
3044 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3045 ;; The (remaining) seconds are too few to
3046 ;; be divided into this time unit.
3048 ;; It's big enough, so we output it.
3049 (setq sec (- sec (* num (cdr unit))))
3051 (concat (if prev ", " "") (int-to-string
3053 " " (symbol-name (car unit))
3054 (if (> num 1) "s" ""))
3056 article-time-units "")
3057 ;; If dates are odd, then it might appear like the
3058 ;; article was sent in the future.
3061 " in the future"))))))
3062 ;; Display the date in proper English
3064 (let ((dtime (decode-time time)))
3067 (number-to-string (nth 3 dtime))
3068 (let ((digit (% (nth 3 dtime) 10)))
3070 ((memq (nth 3 dtime) '(11 12 13)) "th")
3076 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3078 (number-to-string (nth 5 dtime))
3080 (format "%02d" (nth 2 dtime))
3082 (format "%02d" (nth 1 dtime)))))))
3084 (format "Date: %s (from T-gnus)" date))))
3086 (defun article-date-local (&optional highlight)
3087 "Convert the current article date to the local timezone."
3088 (interactive (list t))
3089 (article-date-ut 'local highlight))
3091 (defun article-date-english (&optional highlight)
3092 "Convert the current article date to something that is proper English."
3093 (interactive (list t))
3094 (article-date-ut 'english highlight))
3096 (defun article-date-original (&optional highlight)
3097 "Convert the current article date to what it was originally.
3098 This is only useful if you have used some other date conversion
3099 function and want to see what the date was before converting."
3100 (interactive (list t))
3101 (article-date-ut 'original highlight))
3103 (defun article-date-lapsed (&optional highlight)
3104 "Convert the current article date to time lapsed since it was sent."
3105 (interactive (list t))
3106 (article-date-ut 'lapsed highlight))
3108 (defun article-update-date-lapsed ()
3109 "Function to be run from a timer to update the lapsed time line."
3110 (let (deactivate-mark)
3115 (set-buffer (window-buffer w))
3116 (when (eq major-mode 'gnus-article-mode)
3117 (let ((mark (point-marker)))
3118 (goto-char (point-min))
3119 (when (re-search-forward "^X-Sent:" nil t)
3120 (article-date-lapsed t))
3121 (goto-char (marker-position mark))
3122 (move-marker mark nil))))
3125 (defun gnus-start-date-timer (&optional n)
3126 "Start a timer to update the X-Sent header in the article buffers.
3127 The numerical prefix says how frequently (in seconds) the function
3132 (gnus-stop-date-timer)
3133 (setq article-lapsed-timer
3134 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3136 (defun gnus-stop-date-timer ()
3137 "Stop the X-Sent timer."
3139 (when article-lapsed-timer
3140 (nnheader-cancel-timer article-lapsed-timer)
3141 (setq article-lapsed-timer nil)))
3143 (defun article-date-user (&optional highlight)
3144 "Convert the current article date to the user-defined format.
3145 This format is defined by the `gnus-article-time-format' variable."
3146 (interactive (list t))
3147 (article-date-ut 'user highlight))
3149 (defun article-date-iso8601 (&optional highlight)
3150 "Convert the current article date to ISO8601."
3151 (interactive (list t))
3152 (article-date-ut 'iso8601 highlight))
3154 ;; (defun article-show-all ()
3155 ;; "Show all hidden text in the article buffer."
3159 ;; (let ((buffer-read-only nil))
3160 ;; (gnus-article-unhide-text (point-min) (point-max))
3161 ;; (gnus-remove-text-with-property 'gnus-prev)
3162 ;; (gnus-remove-text-with-property 'gnus-next))))
3164 (defun article-show-all-headers ()
3165 "Show all hidden headers in the article buffer."
3170 (article-narrow-to-head)
3171 (let ((buffer-read-only nil))
3172 (gnus-article-unhide-text (point-min) (point-max))))))
3174 (defun article-remove-leading-whitespace ()
3175 "Remove excessive whitespace from all headers."
3179 (let ((buffer-read-only nil))
3180 (article-narrow-to-head)
3181 (goto-char (point-min))
3182 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3183 (delete-region (match-beginning 1) (match-end 1)))))))
3185 (defun article-emphasize (&optional arg)
3186 "Emphasize text according to `gnus-emphasis-alist'."
3187 (interactive (gnus-article-hidden-arg))
3188 (unless (gnus-article-check-hidden-text 'emphasis arg)
3192 (with-current-buffer gnus-summary-buffer
3193 gnus-article-emphasis-alist)
3195 gnus-emphasis-alist))
3196 (buffer-read-only nil)
3197 (props (append '(article-type emphasis)
3198 gnus-hidden-properties))
3199 regexp elem beg invisible visible face)
3202 (while (setq elem (pop alist))
3204 (setq regexp (car elem)
3205 invisible (nth 1 elem)
3206 visible (nth 2 elem)
3208 (while (re-search-forward regexp nil t)
3209 (when (and (match-beginning visible) (match-beginning invisible))
3210 (gnus-article-hide-text
3211 (match-beginning invisible) (match-end invisible) props)
3212 (gnus-article-unhide-text-type
3213 (match-beginning visible) (match-end visible) 'emphasis)
3214 (gnus-put-overlay-excluding-newlines
3215 (match-beginning visible) (match-end visible) 'face face)
3216 (gnus-add-wash-type 'emphasis)
3217 (goto-char (match-end invisible)))))))))
3219 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3220 "Setup newsgroup emphasis alist."
3221 (unless gnus-article-emphasis-alist
3222 (let ((name (and gnus-newsgroup-name
3223 (gnus-group-real-name gnus-newsgroup-name))))
3224 (make-local-variable 'gnus-article-emphasis-alist)
3225 (setq gnus-article-emphasis-alist
3227 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3228 (while (setq elem (pop alist))
3229 (when (and name (string-match (car elem) name))
3231 highlight (copy-sequence (cdr elem)))))
3233 (copy-sequence highlight-words)
3234 (if gnus-newsgroup-name
3235 (copy-sequence (gnus-group-find-parameter
3236 gnus-newsgroup-name 'highlight-words t)))
3237 gnus-emphasis-alist)))))
3240 (defvar gnus-summary-article-menu)
3241 (defvar gnus-summary-post-menu))
3243 ;;; Saving functions.
3245 (defun gnus-article-save (save-buffer file &optional num)
3246 "Save the currently selected article."
3247 (unless gnus-save-all-headers
3248 ;; Remove headers according to `gnus-saved-headers'.
3249 (let ((gnus-visible-headers
3250 (or gnus-saved-headers gnus-visible-headers))
3251 (gnus-article-buffer save-buffer))
3253 (set-buffer save-buffer)
3254 (article-hide-headers 1 t))))
3255 (save-window-excursion
3256 (if (not gnus-default-article-saver)
3257 (error "No default saver is defined")
3258 ;; !!! Magic! The saving functions all save
3259 ;; `gnus-save-article-buffer' (or so they think), but we
3260 ;; bind that variable to our save-buffer.
3261 (set-buffer gnus-article-buffer)
3262 (let* ((gnus-save-article-buffer save-buffer)
3265 ((not gnus-prompt-before-saving) 'default)
3266 ((eq gnus-prompt-before-saving 'always) nil)
3268 (gnus-number-of-articles-to-be-saved
3269 (when (eq gnus-prompt-before-saving t)
3271 (set-buffer gnus-article-current-summary)
3272 (funcall gnus-default-article-saver filename)))))
3274 (defun gnus-read-save-file-name (prompt &optional filename
3275 function group headers variable)
3277 (funcall function group headers (symbol-value variable)))
3282 ((eq filename 'default)
3288 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3291 (if (and gnus-number-of-articles-to-be-saved
3292 (> gnus-number-of-articles-to-be-saved 1))
3293 (format "these %d articles"
3294 gnus-number-of-articles-to-be-saved)
3297 ;; Let the split methods have their say.
3299 ;; No split name was found.
3302 (concat prompt " (default "
3303 (file-name-nondirectory default-name) ") ")
3304 (file-name-directory default-name)
3306 ;; A single group name is returned.
3307 ((stringp split-name)
3309 (funcall function split-name headers
3310 (symbol-value variable)))
3312 (concat prompt " (default "
3313 (file-name-nondirectory default-name) ") ")
3314 (file-name-directory default-name)
3316 ;; A single split name was found
3317 ((= 1 (length split-name))
3318 (let* ((name (expand-file-name
3320 gnus-article-save-directory))
3321 (dir (cond ((file-directory-p name)
3322 (file-name-as-directory name))
3323 ((file-exists-p name) name)
3324 (t gnus-article-save-directory))))
3326 (concat prompt " (default " name ") ")
3328 ;; A list of splits was found.
3330 (setq split-name (nreverse split-name))
3332 (let ((file-name-history
3333 (nconc split-name file-name-history)))
3337 (concat prompt " (`M-p' for defaults) ")
3338 gnus-article-save-directory
3340 gnus-article-save-directory)))
3341 (car (push result file-name-history)))))))
3342 ;; Create the directory.
3343 (gnus-make-directory (file-name-directory file))
3344 ;; If we have read a directory, we append the default file name.
3345 (when (file-directory-p file)
3346 (setq file (expand-file-name (file-name-nondirectory
3348 (file-name-as-directory file))))
3349 ;; Possibly translate some characters.
3350 (nnheader-translate-file-chars file))))))
3351 (gnus-make-directory (file-name-directory result))
3352 (set variable result)))
3354 (defun gnus-article-archive-name (group)
3355 "Return the first instance of an \"Archive-name\" in the current buffer."
3356 (let ((case-fold-search t))
3357 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3358 (nnheader-concat gnus-article-save-directory
3359 (match-string 1)))))
3361 (defun gnus-article-nndoc-name (group)
3362 "If GROUP is an nndoc group, return the name of the parent group."
3363 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3364 (gnus-group-get-parameter group 'save-article-group)))
3366 (defun gnus-summary-save-in-rmail (&optional filename)
3367 "Append this article to Rmail file.
3368 Optional argument FILENAME specifies file name.
3369 Directory to save to is default to `gnus-article-save-directory'."
3370 (setq filename (gnus-read-save-file-name
3371 "Save %s in rmail file:" filename
3372 gnus-rmail-save-name gnus-newsgroup-name
3373 gnus-current-headers 'gnus-newsgroup-last-rmail))
3374 (gnus-eval-in-buffer-window gnus-save-article-buffer
3378 (gnus-output-to-rmail filename))))
3381 (defun gnus-summary-save-in-mail (&optional filename)
3382 "Append this article to Unix mail file.
3383 Optional argument FILENAME specifies file name.
3384 Directory to save to is default to `gnus-article-save-directory'."
3385 (setq filename (gnus-read-save-file-name
3386 "Save %s in Unix mail file:" filename
3387 gnus-mail-save-name gnus-newsgroup-name
3388 gnus-current-headers 'gnus-newsgroup-last-mail))
3389 (gnus-eval-in-buffer-window gnus-save-article-buffer
3393 (if (and (file-readable-p filename)
3394 (file-regular-p filename)
3395 (mail-file-babyl-p filename))
3396 (rmail-output-to-rmail-file filename t)
3397 (gnus-output-to-mail filename)))))
3400 (defun gnus-summary-save-in-file (&optional filename overwrite)
3401 "Append this article to file.
3402 Optional argument FILENAME specifies file name.
3403 Directory to save to is default to `gnus-article-save-directory'."
3404 (setq filename (gnus-read-save-file-name
3405 "Save %s in file:" filename
3406 gnus-file-save-name gnus-newsgroup-name
3407 gnus-current-headers 'gnus-newsgroup-last-file))
3408 (gnus-eval-in-buffer-window gnus-save-article-buffer
3412 (when (and overwrite
3413 (file-exists-p filename))
3414 (delete-file filename))
3415 (gnus-output-to-file filename))))
3418 (defun gnus-summary-write-to-file (&optional filename)
3419 "Write this article to a file, overwriting it if the file exists.
3420 Optional argument FILENAME specifies file name.
3421 The directory to save in defaults to `gnus-article-save-directory'."
3422 (gnus-summary-save-in-file nil t))
3424 (defun gnus-summary-save-body-in-file (&optional filename)
3425 "Append this article body to a file.
3426 Optional argument FILENAME specifies file name.
3427 The directory to save in defaults to `gnus-article-save-directory'."
3428 (setq filename (gnus-read-save-file-name
3429 "Save %s body in file:" filename
3430 gnus-file-save-name gnus-newsgroup-name
3431 gnus-current-headers 'gnus-newsgroup-last-file))
3432 (gnus-eval-in-buffer-window gnus-save-article-buffer
3436 (when (article-goto-body)
3437 (narrow-to-region (point) (point-max)))
3438 (gnus-output-to-file filename))))
3441 (defun gnus-summary-save-in-pipe (&optional command)
3442 "Pipe this article to subprocess."
3444 (cond ((and (eq command 'default)
3445 gnus-last-shell-command)
3446 gnus-last-shell-command)
3451 "Shell command on %s: "
3452 (if (and gnus-number-of-articles-to-be-saved
3453 (> gnus-number-of-articles-to-be-saved 1))
3454 (format "these %d articles"
3455 gnus-number-of-articles-to-be-saved)
3457 gnus-last-shell-command))))
3458 (when (string-equal command "")
3459 (if gnus-last-shell-command
3460 (setq command gnus-last-shell-command)
3461 (error "A command is required")))
3462 (gnus-eval-in-buffer-window gnus-article-buffer
3465 (shell-command-on-region (point-min) (point-max) command nil)))
3466 (setq gnus-last-shell-command command))
3468 (defmacro gnus-read-string (prompt &optional initial-contents history
3470 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3471 (if (and (featurep 'xemacs)
3472 (< emacs-minor-version 2))
3473 `(read-string ,prompt ,initial-contents ,history)
3474 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3476 (defun gnus-summary-pipe-to-muttprint (&optional command)
3477 "Pipe this article to muttprint."
3478 (setq command (gnus-read-string
3479 "Print using command: " gnus-summary-muttprint-program
3480 nil gnus-summary-muttprint-program))
3481 (gnus-summary-save-in-pipe command))
3483 ;;; Article file names when saving.
3485 (defun gnus-capitalize-newsgroup (newsgroup)
3486 "Capitalize NEWSGROUP name."
3487 (when (not (zerop (length newsgroup)))
3488 (concat (char-to-string (upcase (aref newsgroup 0)))
3489 (substring newsgroup 1))))
3491 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3492 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3493 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3494 Otherwise, it is like ~/News/news/group/num."
3497 (concat (if (gnus-use-long-file-name 'not-save)
3498 (gnus-capitalize-newsgroup newsgroup)
3499 (gnus-newsgroup-directory-form newsgroup))
3500 "/" (int-to-string (mail-header-number headers)))
3501 gnus-article-save-directory)))
3503 (string-equal (file-name-directory default)
3504 (file-name-directory last-file))
3505 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3507 (or last-file default))))
3509 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3510 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3511 If variable `gnus-use-long-file-name' is non-nil, it is
3512 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3515 (concat (if (gnus-use-long-file-name 'not-save)
3517 (gnus-newsgroup-directory-form newsgroup))
3518 "/" (int-to-string (mail-header-number headers)))
3519 gnus-article-save-directory)))
3521 (string-equal (file-name-directory default)
3522 (file-name-directory last-file))
3523 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3525 (or last-file default))))
3527 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3528 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3529 If variable `gnus-use-long-file-name' is non-nil, it is
3530 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3533 (if (gnus-use-long-file-name 'not-save)
3536 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3538 gnus-article-save-directory)))
3540 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3541 "Generate file name from sender."
3542 (let ((from (mail-header-from headers)))
3544 (if (and from (string-match "\\([^ <]+\\)@" from))
3545 (match-string 1 from)
3547 gnus-article-save-directory)))
3549 (defun article-verify-x-pgp-sig ()
3552 (if (gnus-buffer-live-p gnus-original-article-buffer)
3553 (let ((sig (with-current-buffer gnus-original-article-buffer
3554 (gnus-fetch-field "X-PGP-Sig")))
3558 (mml2015-clear-verify-function))
3560 (insert-buffer-substring gnus-original-article-buffer)
3561 (setq items (split-string sig))
3562 (message-narrow-to-head)
3563 (let ((inhibit-point-motion-hooks t)
3564 (case-fold-search t))
3565 ;; Don't verify multiple headers.
3566 (setq headers (mapconcat (lambda (header)
3568 (mail-fetch-field header)
3570 (split-string (nth 1 items) ",") "")))
3571 (delete-region (point-min) (point-max))
3572 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3573 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3578 (if (looking-at "^-")
3581 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3582 (insert "Version: " (car items) "\n\n")
3583 (insert (mapconcat 'identity (cddr items) "\n"))
3584 (insert "\n-----END PGP SIGNATURE-----\n")
3585 (let ((mm-security-handle (list (format "multipart/signed"))))
3586 (mml2015-clean-buffer)
3587 (let ((coding-system-for-write (or gnus-newsgroup-charset
3589 (funcall (mml2015-clear-verify-function)))
3591 (or (mm-handle-multipart-ctl-parameter
3592 mm-security-handle 'gnus-details)
3593 (mm-handle-multipart-ctl-parameter
3594 mm-security-handle 'gnus-info)))))
3596 (let (buffer-read-only bface eface)
3598 (message-narrow-to-head)
3599 (goto-char (point-max))
3601 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3602 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3603 (message-remove-header "X-Gnus-PGP-Verify")
3604 (if (re-search-forward "^X-PGP-Sig:" nil t)
3606 (goto-char (point-max)))
3607 (narrow-to-region (point) (point))
3608 (insert "X-Gnus-PGP-Verify: " info "\n")
3609 (goto-char (point-min))
3612 (if (not (looking-at "^[ \t]"))
3616 (goto-char (point-min))
3617 (when (looking-at "\\([^:]+\\): *")
3618 (put-text-property (match-beginning 1) (1+ (match-end 1))
3620 (put-text-property (match-end 0) (point-max)
3621 'face eface)))))))))
3623 (defun article-verify-cancel-lock ()
3624 "Verify Cancel-Lock header."
3626 (if (gnus-buffer-live-p gnus-original-article-buffer)
3627 (canlock-verify gnus-original-article-buffer)))
3629 (defun article-monafy ()
3630 "Display body part with mona font."
3632 (unless (if (featurep 'xemacs)
3633 (find-face 'gnus-mona-face)
3634 (facep 'gnus-mona-face))
3635 (require 'navi2ch-mona)
3636 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3638 (let ((buffer-read-only nil))
3641 (gnus-make-overlay (point) (point-max))
3642 'face 'gnus-mona-face))))
3649 (setq afunc (car func)
3652 gfunc (intern (format "gnus-%s" func))))
3654 (when (fboundp afunc)
3655 `(lambda (&optional interactive &rest args)
3656 ,(documentation afunc t)
3657 (interactive (list t))
3659 (set-buffer gnus-article-buffer)
3661 (call-interactively ',afunc)
3662 (apply ',afunc args))))))))
3663 '(article-hide-headers
3664 article-verify-x-pgp-sig
3665 article-verify-cancel-lock
3667 article-hide-boring-headers
3668 article-treat-overstrike
3669 article-fill-long-lines
3670 article-capitalize-sentences
3672 article-remove-leading-whitespace
3673 article-display-x-face
3674 article-display-face
3675 article-de-quoted-unreadable
3676 article-de-base64-unreadable
3679 article-unsplit-urls
3680 article-hide-list-identifiers
3681 article-strip-banner
3684 article-hide-signature
3685 article-strip-headers-in-body
3686 article-remove-trailing-blank-lines
3687 article-strip-leading-blank-lines
3688 article-strip-multiple-blank-lines
3689 article-strip-leading-space
3690 article-strip-trailing-space
3691 article-strip-blank-lines
3692 article-strip-all-blank-lines
3694 article-date-english
3695 article-date-iso8601
3696 article-date-original
3698 article-decode-mime-words
3699 article-decode-charset
3700 article-decode-encoded-words
3704 article-treat-dumbquotes
3705 article-normalize-headers
3706 (article-show-all-headers . gnus-article-show-all-headers)
3707 ;; (article-show-all . gnus-article-show-all)
3711 ;;; Gnus article mode
3714 (put 'gnus-article-mode 'mode-class 'special)
3716 (gnus-define-keys gnus-article-mode-map
3717 " " gnus-article-goto-next-page
3718 "\177" gnus-article-goto-prev-page
3719 [delete] gnus-article-goto-prev-page
3720 [backspace] gnus-article-goto-prev-page
3721 "\C-c^" gnus-article-refer-article
3722 "h" gnus-article-show-summary
3723 "s" gnus-article-show-summary
3724 "\C-c\C-m" gnus-article-mail
3725 "?" gnus-article-describe-briefly
3726 "e" gnus-summary-edit-article
3727 "<" beginning-of-buffer
3729 "\C-c\C-i" gnus-info-find-node
3731 "R" gnus-article-reply-with-original
3732 "F" gnus-article-followup-with-original
3733 "\C-hk" gnus-article-describe-key
3734 "\C-hc" gnus-article-describe-key-briefly
3736 "\C-d" gnus-article-read-summary-keys
3737 "\M-*" gnus-article-read-summary-keys
3738 "\M-#" gnus-article-read-summary-keys
3739 "\M-^" gnus-article-read-summary-keys
3740 "\M-g" gnus-article-read-summary-keys)
3742 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3746 (push (char-to-string key) keys)
3748 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3749 (setq key (car elem))
3750 (when (and (> (length key) 0)
3751 (not (eq 'menu-bar (aref key 0)))
3752 (symbolp (lookup-key gnus-summary-mode-map key)))
3755 (unless (lookup-key gnus-article-mode-map key)
3756 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3758 (defun gnus-article-make-menu-bar ()
3759 (unless (boundp 'gnus-article-commands-menu)
3760 (gnus-summary-make-menu-bar))
3761 (gnus-turn-off-edit-menu 'article)
3762 (unless (boundp 'gnus-article-article-menu)
3764 gnus-article-article-menu gnus-article-mode-map ""
3766 ["Scroll forwards" gnus-article-goto-next-page t]
3767 ["Scroll backwards" gnus-article-goto-prev-page t]
3768 ["Show summary" gnus-article-show-summary t]
3769 ["Fetch Message-ID at point" gnus-article-refer-article t]
3770 ["Mail to address at point" gnus-article-mail t]
3771 ["Send a bug report" gnus-bug t]))
3774 gnus-article-treatment-menu gnus-article-mode-map ""
3775 ;; Fixme: this should use :active (and maybe :visible).
3777 ["Hide headers" gnus-article-hide-headers t]
3778 ["Hide signature" gnus-article-hide-signature t]
3779 ["Hide citation" gnus-article-hide-citation t]
3780 ["Treat overstrike" gnus-article-treat-overstrike t]
3781 ["Remove carriage return" gnus-article-remove-cr t]
3782 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3783 ["Treat html" gnus-article-wash-html t]
3784 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3785 ["Decode HZ" gnus-article-decode-HZ t]))
3787 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3789 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3791 (gnus-run-hooks 'gnus-article-menu-hook)))
3793 (defun gnus-article-mode ()
3794 "Major mode for displaying an article.
3796 All normal editing commands are switched off.
3798 The following commands are available in addition to all summary mode
3800 \\<gnus-article-mode-map>
3801 \\[gnus-article-next-page]\t Scroll the article one page forwards
3802 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3803 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3804 \\[gnus-article-show-summary]\t Display the summary buffer
3805 \\[gnus-article-mail]\t Send a reply to the address near point
3806 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3807 \\[gnus-info-find-node]\t Go to the Gnus info node"
3809 (gnus-simplify-mode-line)
3810 (setq mode-name "Article")
3811 (setq major-mode 'gnus-article-mode)
3812 (make-local-variable 'minor-mode-alist)
3813 (unless (assq 'gnus-show-mime minor-mode-alist)
3814 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3815 (use-local-map gnus-article-mode-map)
3816 (when (gnus-visual-p 'article-menu 'menu)
3817 (gnus-article-make-menu-bar)
3818 (when gnus-summary-tool-bar-map
3819 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3820 (gnus-update-format-specifications nil 'article-mode)
3821 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3822 (set (make-local-variable 'gnus-page-broken) nil)
3823 (make-local-variable 'gnus-button-marker-list)
3824 (make-local-variable 'gnus-article-current-summary)
3825 (make-local-variable 'gnus-article-mime-handles)
3826 (make-local-variable 'gnus-article-decoded-p)
3827 (make-local-variable 'gnus-article-mime-handle-alist)
3828 (make-local-variable 'gnus-article-wash-types)
3829 (make-local-variable 'gnus-article-image-alist)
3830 (make-local-variable 'gnus-article-charset)
3831 (make-local-variable 'gnus-article-ignored-charsets)
3832 (gnus-set-default-directory)
3833 (buffer-disable-undo)
3834 (setq buffer-read-only t)
3835 (set-syntax-table gnus-article-mode-syntax-table)
3836 (gnus-run-hooks 'gnus-article-mode-hook))
3838 (defun gnus-article-setup-buffer ()
3839 "Initialize the article buffer."
3840 (let* ((name (if gnus-single-article-buffer "*Article*"
3841 (concat "*Article " gnus-newsgroup-name "*")))
3843 (progn (string-match "\\*Article" name)
3844 (concat " *Original Article"
3845 (substring name (match-end 0))))))
3846 (setq gnus-article-buffer name)
3847 (setq gnus-original-article-buffer original)
3848 (setq gnus-article-mime-handle-alist nil)
3849 ;; This might be a variable local to the summary buffer.
3850 (unless gnus-single-article-buffer
3852 (set-buffer gnus-summary-buffer)
3853 (setq gnus-article-buffer name)
3854 (setq gnus-original-article-buffer original)
3855 (gnus-set-global-variables)))
3856 (gnus-article-setup-highlight-words)
3857 ;; Init original article buffer.
3859 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3860 (set-buffer-multibyte t)
3861 (setq major-mode 'gnus-original-article-mode)
3862 (make-local-variable 'gnus-original-article))
3863 (if (get-buffer name)
3866 (when (and gnus-article-edit-mode
3869 (y-or-n-p "Article mode edit in progress; discard? ")))
3870 (error "Action aborted"))
3871 (set (make-local-variable 'gnus-article-edit-mode) nil)
3872 (buffer-disable-undo)
3873 (setq buffer-read-only t)
3874 ;; This list just keeps growing if we don't reset it.
3875 (setq gnus-button-marker-list nil)
3876 (unless (eq major-mode 'gnus-article-mode)
3877 (gnus-article-mode))
3880 (set-buffer (gnus-get-buffer-create name))
3882 (make-local-variable 'gnus-summary-buffer)
3883 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3884 (current-buffer)))))
3886 ;; Set article window start at LINE, where LINE is the number of lines
3887 ;; from the head of the article.
3888 (defun gnus-article-set-window-start (&optional line)
3890 (gnus-get-buffer-window gnus-article-buffer t)
3892 (set-buffer gnus-article-buffer)
3893 (goto-char (point-min))
3896 (gnus-message 6 "Moved to bookmark")
3897 (search-forward "\n\n" nil t)
3901 ;;; @@ article filters
3904 (defun gnus-article-display-mime-message ()
3905 "Article display method for MIME message."
3906 ;; called from `gnus-original-article-buffer'.
3907 (let (charset all-headers)
3908 (with-current-buffer gnus-summary-buffer
3909 (setq charset default-mime-charset
3910 all-headers gnus-have-all-headers))
3911 (make-local-variable 'default-mime-charset)
3912 (setq default-mime-charset charset)
3913 (with-current-buffer (get-buffer-create gnus-article-buffer)
3914 (make-local-variable 'default-mime-charset)
3915 (setq default-mime-charset charset))
3916 (mime-display-message mime-message-structure
3917 gnus-article-buffer nil gnus-article-mode-map)
3919 (gnus-article-hide-headers nil -1)))
3920 (run-hooks 'gnus-mime-article-prepare-hook))
3922 (defun gnus-article-display-traditional-message ()
3923 "Article display method for traditional message."
3924 (set-buffer gnus-article-buffer)
3925 (let (buffer-read-only)
3927 (insert-buffer-substring gnus-original-article-buffer)))
3929 (defun gnus-article-make-full-mail-header (&optional number charset)
3930 "Create a new mail header structure in a raw article buffer."
3931 (unless (and number charset)
3932 (save-current-buffer
3933 (set-buffer gnus-summary-buffer)
3935 (setq number (or (cdr gnus-article-current) 0)))
3937 (setq charset (or default-mime-charset 'x-ctext)))))
3938 (goto-char (point-min))
3939 (let ((header-end (if (search-forward "\n\n" nil t)
3941 (goto-char (point-max))))
3942 (chars (- (point-max) (point)))
3943 (lines (count-lines (point) (point-max)))
3944 (default-mime-charset charset)
3946 (narrow-to-region (point-min) header-end)
3947 (setq xref (std11-fetch-field "xref"))
3949 (make-full-mail-header
3951 (std11-fetch-field "subject")
3952 (std11-fetch-field "from")
3953 (std11-fetch-field "date")
3954 (std11-fetch-field "message-id")
3955 (std11-fetch-field "references")
3958 (when xref (concat "Xref: " xref)))
3961 (defun gnus-article-prepare (article &optional all-headers header)
3962 "Prepare ARTICLE in article mode buffer.
3963 ARTICLE should either be an article number or a Message-ID.
3964 If ARTICLE is an id, HEADER should be the article headers.
3965 If ALL-HEADERS is non-nil, no headers are hidden."
3967 ;; Make sure we start in a summary buffer.
3968 (unless (eq major-mode 'gnus-summary-mode)
3969 (set-buffer gnus-summary-buffer))
3970 (setq gnus-summary-buffer (current-buffer))
3971 (let* ((gnus-article (if header (mail-header-number header) article))
3972 (summary-buffer (current-buffer))
3973 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3974 (group gnus-newsgroup-name)
3977 (gnus-article-setup-buffer)
3978 (set-buffer gnus-article-buffer)
3979 ;; Deactivate active regions.
3980 (when (and (boundp 'transient-mark-mode)
3981 transient-mark-mode)
3982 (setq mark-active nil))
3983 (if (not (setq result (let ((buffer-read-only nil))
3984 (gnus-request-article-this-buffer
3986 ;; There is no such article.
3988 (when (and (numberp article)
3989 (not (memq article gnus-newsgroup-sparse)))
3990 (setq gnus-article-current
3991 (cons gnus-newsgroup-name article))
3992 (set-buffer gnus-summary-buffer)
3993 (setq gnus-current-article article)
3994 (if (and (memq article gnus-newsgroup-undownloaded)
3995 (not (gnus-online (gnus-find-method-for-group
3996 gnus-newsgroup-name))))
3998 (gnus-summary-set-agent-mark article)
3999 (message "Message marked for downloading"))
4000 (gnus-summary-mark-article article gnus-canceled-mark)
4001 (unless (memq article gnus-newsgroup-sparse)
4002 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4003 (if (or (eq result 'pseudo)
4004 (eq result 'nneething))
4007 (set-buffer summary-buffer)
4008 (push article gnus-newsgroup-history)
4009 (setq gnus-last-article gnus-current-article
4010 gnus-current-article 0
4011 gnus-current-headers nil
4012 gnus-article-current nil)
4013 (if (eq result 'nneething)
4014 (gnus-configure-windows 'summary)
4015 (gnus-configure-windows 'article))
4016 (gnus-set-global-variables))
4017 (let ((gnus-article-mime-handle-alist-1
4018 gnus-article-mime-handle-alist))
4019 (gnus-set-mode-line 'article)))
4020 ;; The result from the `request' was an actual article -
4021 ;; or at least some text that is now displayed in the
4023 (when (and (numberp article)
4024 (not (eq article gnus-current-article)))
4025 ;; Seems like a new article has been selected.
4026 ;; `gnus-current-article' must be an article number.
4028 (set-buffer summary-buffer)
4029 (push article gnus-newsgroup-history)
4030 (setq gnus-last-article gnus-current-article
4031 gnus-current-article article
4032 gnus-current-headers
4033 (gnus-summary-article-header gnus-current-article)
4034 gnus-article-current
4035 (cons gnus-newsgroup-name gnus-current-article))
4036 (unless (vectorp gnus-current-headers)
4037 (setq gnus-current-headers nil))
4038 (gnus-summary-goto-subject gnus-current-article)
4039 (when (gnus-summary-show-thread)
4040 ;; If the summary buffer really was folded, the
4041 ;; previous goto may not actually have gone to
4042 ;; the right article, but the thread root instead.
4044 (gnus-summary-goto-subject gnus-current-article))
4045 (gnus-run-hooks 'gnus-mark-article-hook)
4046 (gnus-set-mode-line 'summary)
4047 (when (gnus-visual-p 'article-highlight 'highlight)
4048 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4049 ;; Set the global newsgroup variables here.
4050 (gnus-set-global-variables)
4051 (setq gnus-have-all-headers
4052 (or all-headers gnus-show-all-headers))))
4054 (gnus-configure-windows 'article))
4055 (when (or (numberp article)
4057 (gnus-article-prepare-display)
4059 (goto-char (point-min))
4060 (when gnus-break-pages
4061 (gnus-narrow-to-page)))
4062 (let ((gnus-article-mime-handle-alist-1
4063 gnus-article-mime-handle-alist))
4064 (gnus-set-mode-line 'article))
4068 (set-window-point (get-buffer-window (current-buffer)) (point))
4069 (gnus-configure-windows 'article)
4072 (defun gnus-article-prepare-mime-display (&optional number)
4073 (goto-char (point-min))
4074 (when (re-search-forward "^[^\t ]+:" nil t)
4075 (goto-char (match-beginning 0)))
4076 (let ((entity (if (eq 1 (point-min))
4077 (get-text-property 1 'mime-view-entity)
4078 (get-text-property (point) 'mime-view-entity)))
4079 last-entity child-entity next type)
4080 (setq child-entity (mime-entity-children entity))
4082 (setq last-entity (nth (1- (length child-entity))
4084 (setq last-entity entity))
4086 (narrow-to-region (point)
4087 (if (search-forward "\n\n" nil t)
4090 (gnus-treat-article 'head)
4091 (put-text-property (point-min) (point-max) 'article-treated-header t)
4092 (goto-char (point-max)))
4093 (while (and (not (eobp)) entity)
4094 (setq next (set-marker
4096 (next-single-property-change (point) 'mime-view-entity
4098 (let ((types (mime-entity-content-type entity)))
4099 (while (eq 'multipart (mime-content-type-primary-type types))
4100 (setq entity (car (mime-entity-children entity))
4101 types (mime-entity-content-type entity)))
4103 (setq type (format "%s/%s"
4104 (mime-content-type-primary-type types)
4105 (mime-content-type-subtype types)))))
4106 (if (string-equal type "message/rfc822")
4109 (let ((children (mime-entity-children entity))
4112 (setq last-children (nth (1- (length children)) children))
4115 (not (eq last-children
4116 (get-text-property next 'mime-view-entity)))
4118 (next-single-property-change next
4120 nil (point-max)))))))
4121 (setq next (next-single-property-change next 'mime-view-entity
4124 (narrow-to-region (point) next)
4125 (gnus-article-prepare-mime-display)
4126 (goto-char (point-max)))
4127 (setq entity (get-text-property (point) 'mime-view-entity)))
4129 (narrow-to-region (point) next)
4130 ;; Kludge. We have to count true number, but for now,
4131 ;; part number is here only to achieve `last'.
4132 (gnus-treat-article nil 1
4133 (if (eq entity last-entity)
4136 (goto-char (point-max)))
4137 (setq entity (get-text-property next 'mime-view-entity))))))
4140 (defun gnus-article-prepare-display ()
4141 "Make the current buffer look like a nice article."
4142 (let ((gnus-article-buffer (current-buffer))
4144 (unless (eq major-mode 'gnus-article-mode)
4145 (gnus-article-mode))
4146 (setq buffer-read-only nil
4147 gnus-button-marker-list nil
4148 gnus-article-wash-types nil
4149 gnus-article-image-alist nil)
4152 (static-if (featurep 'xemacs)
4153 (map-extents (lambda (extent maparg) (delete-extent extent)))
4154 (let ((lists (overlay-lists)))
4155 (dolist (overlay (nconc (car lists) (cdr lists)))
4156 (delete-overlay overlay)))))
4157 (gnus-run-hooks 'gnus-tmp-internal-hook))
4158 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4161 (inhibit-read-only t))
4162 (set-buffer gnus-original-article-buffer)
4164 (setq mime-message-structure gnus-current-headers)
4165 (mime-buffer-entity-set-buffer-internal mime-message-structure
4166 gnus-original-article-buffer)
4167 (mime-entity-set-representation-type-internal mime-message-structure
4168 'mime-buffer-entity)
4169 (luna-send mime-message-structure 'initialize-instance
4170 mime-message-structure)
4172 (let (mime-display-header-hook mime-display-text/plain-hook)
4173 (funcall gnus-article-display-method-for-mime))
4174 (funcall gnus-article-display-method-for-traditional))
4175 ;; Call the treatment functions.
4179 (gnus-article-prepare-mime-display)
4180 (narrow-to-region (goto-char (point-min))
4181 (if (search-forward "\n\n" nil t)
4184 (gnus-treat-article 'head)
4185 (put-text-property (point-min) (point-max) 'article-treated-header t)
4186 (goto-char (point-max))
4188 (narrow-to-region (point) (point-max))
4189 (gnus-treat-article nil))
4190 (put-text-property (point-min) (point-max) 'read-only nil)))
4191 (gnus-run-hooks 'gnus-article-prepare-hook))
4193 (defun gnus-article-decode-article-as-default-mime-charset ()
4194 "Decode an article as `default-mime-charset'. It won't work if the
4195 value of the variable `gnus-show-mime' is non-nil."
4196 (unless (or gnus-show-mime
4197 (member gnus-newsgroup-name '("nndraft:delayed"
4199 (set (make-local-variable 'default-mime-charset)
4200 (with-current-buffer gnus-summary-buffer
4201 default-mime-charset))
4202 (decode-mime-charset-region (point-min) (point-max)
4203 default-mime-charset)))
4206 ;;; Gnus MIME viewing functions
4209 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4210 "Format of the MIME buttons.
4212 Valid specifiers include:
4214 %T MIME type, along with additional info
4215 %n The `name' parameter
4216 %d The description, if any
4217 %l The length of the encoded part
4218 %p The part identifier number
4219 %e Dots if the part isn't displayed
4221 General format specifiers can also be used. See Info node
4222 `(gnus)Formatting Variables'.")
4224 (defvar gnus-mime-button-line-format-alist
4225 '((?t gnus-tmp-type ?s)
4226 (?T gnus-tmp-type-long ?s)
4227 (?n gnus-tmp-name ?s)
4228 (?d gnus-tmp-description ?s)
4230 (?l gnus-tmp-length ?d)
4231 (?e gnus-tmp-dots ?s)))
4233 (defvar gnus-mime-button-commands
4234 '((gnus-article-press-button "\r" "Toggle Display")
4235 (gnus-mime-view-part "v" "View Interactively...")
4236 (gnus-mime-view-part-as-type "t" "View As Type...")
4237 (gnus-mime-view-part-as-charset "C" "View As charset...")
4238 (gnus-mime-save-part "o" "Save...")
4239 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4240 (gnus-mime-delete-part "d" "Delete part")
4241 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4242 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4243 (gnus-mime-view-part-internally "E" "View Internally")
4244 (gnus-mime-view-part-externally "e" "View Externally")
4245 (gnus-mime-print-part "p" "Print")
4246 (gnus-mime-pipe-part "|" "Pipe To Command...")
4247 (gnus-mime-action-on-part "." "Take action on the part...")))
4249 (defun gnus-article-mime-part-status ()
4250 (with-current-buffer gnus-article-buffer
4251 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4254 (setq children (mime-entity-children entity))
4255 (setq children (length children)))
4258 (format " (%d parts)" children))
4261 (defvar gnus-mime-button-map
4262 (let ((map (make-sparse-keymap)))
4263 (unless (>= (string-to-number emacs-version) 21)
4264 ;; XEmacs doesn't care.
4265 (set-keymap-parent map gnus-article-mode-map))
4266 (define-key map gnus-mouse-2 'gnus-article-push-button)
4267 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4268 (dolist (c gnus-mime-button-commands)
4269 (define-key map (cadr c) (car c)))
4273 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4275 ,@(mapcar (lambda (c)
4276 (vector (caddr c) (car c) :enable t))
4277 gnus-mime-button-commands)))
4279 (defun gnus-mime-button-menu (event prefix)
4280 "Construct a context-sensitive menu of MIME commands."
4281 (interactive "e\nP")
4282 (save-window-excursion
4283 (let ((pos (event-start event)))
4284 (select-window (posn-window pos))
4285 (goto-char (posn-point pos))
4286 (gnus-article-check-buffer)
4287 (popup-menu gnus-mime-button-menu nil prefix))))
4289 (defun gnus-mime-view-all-parts (&optional handles)
4290 "View all the MIME parts."
4292 (save-current-buffer
4293 (set-buffer gnus-article-buffer)
4294 (let ((handles (or handles gnus-article-mime-handles))
4295 (mail-parse-charset gnus-newsgroup-charset)
4296 (mail-parse-ignored-charsets
4297 (with-current-buffer gnus-summary-buffer
4298 gnus-newsgroup-ignored-charsets)))
4300 (mm-remove-parts handles)
4301 (goto-char (point-min))
4302 (or (search-forward "\n\n") (goto-char (point-max)))
4303 (let (buffer-read-only)
4304 (delete-region (point) (point-max))
4305 (mm-display-parts handles))))))
4307 (defun gnus-mime-save-part-and-strip ()
4308 "Save the MIME part under point then replace it with an external body."
4310 (gnus-article-check-buffer)
4311 (let* ((data (get-text-property (point) 'gnus-data))
4313 (handles gnus-article-mime-handles))
4314 (if (mm-multiple-handles gnus-article-mime-handles)
4315 (error "This function is not implemented"))
4316 (setq file (and data (mm-save-part data)))
4318 (with-current-buffer (mm-handle-buffer data)
4320 (insert "Content-Type: " (mm-handle-media-type data))
4321 (mml-insert-parameter-string (cdr (mm-handle-type data))
4324 (insert "Content-ID: " (message-make-message-id) "\n")
4325 (insert "Content-Transfer-Encoding: binary\n")
4328 (cdr (mm-make-handle nil
4329 `("message/external-body"
4330 (access-type . "LOCAL-FILE")
4332 (set-buffer gnus-summary-buffer)
4333 (gnus-article-edit-article
4336 (let ((mail-parse-charset (or gnus-article-charset
4337 ',gnus-newsgroup-charset))
4338 (mail-parse-ignored-charsets
4339 (or gnus-article-ignored-charsets
4340 ',gnus-newsgroup-ignored-charsets))
4341 (mbl mml-buffer-list))
4342 (setq mml-buffer-list nil)
4343 (insert-buffer gnus-original-article-buffer)
4344 (mime-to-mml ',handles)
4345 (setq gnus-article-mime-handles nil)
4346 (let ((mbl1 mml-buffer-list))
4347 (setq mml-buffer-list mbl)
4348 (set (make-local-variable 'mml-buffer-list) mbl1))
4349 (gnus-make-local-hook 'kill-buffer-hook)
4350 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4351 `(lambda (no-highlight)
4352 (let ((mail-parse-charset (or gnus-article-charset
4353 ',gnus-newsgroup-charset))
4354 (message-options message-options)
4355 (message-options-set-recipient)
4356 (mail-parse-ignored-charsets
4357 (or gnus-article-ignored-charsets
4358 ',gnus-newsgroup-ignored-charsets)))
4360 (mml-destroy-buffers)
4361 (remove-hook 'kill-buffer-hook
4362 'mml-destroy-buffers t)
4363 (kill-local-variable 'mml-buffer-list))
4364 (gnus-summary-edit-article-done
4365 ,(or (mail-header-references gnus-current-headers) "")
4366 ,(gnus-group-read-only-p)
4367 ,gnus-summary-buffer no-highlight))))))
4369 (defun gnus-mime-delete-part ()
4370 "Delete the MIME part under point.
4371 Replace it with some information about the removed part."
4373 (gnus-article-check-buffer)
4374 (unless (and gnus-novice-user
4375 (not (gnus-yes-or-no-p
4376 "Really delete attachment forever? ")))
4377 (let* ((data (get-text-property (point) 'gnus-data))
4378 (handles gnus-article-mime-handles)
4382 (mail-decode-encoded-word-string (or (mm-handle-description data)
4385 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4387 (type (mm-handle-media-type data)))
4388 (if (mm-multiple-handles gnus-article-mime-handles)
4389 (error "This function is not implemented"))
4390 (with-current-buffer (mm-handle-buffer data)
4391 (let ((bsize (format "%s" (buffer-size))))
4396 "| The following attachment has been deleted:\n"
4398 "| Type: " type "\n"
4399 "| Filename: " filename "\n"
4400 "| Size (encoded): " bsize " Byte\n"
4401 "| Description: " description "\n"
4404 (cdr (mm-make-handle
4405 nil `("text/plain") nil nil
4407 (format "Deleted attachment (%s bytes)" bsize))))))
4408 (set-buffer gnus-summary-buffer)
4409 ;; FIXME: maybe some of the following code (borrowed from
4410 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4411 (gnus-article-edit-article
4414 (let ((mail-parse-charset (or gnus-article-charset
4415 ',gnus-newsgroup-charset))
4416 (mail-parse-ignored-charsets
4417 (or gnus-article-ignored-charsets
4418 ',gnus-newsgroup-ignored-charsets))
4419 (mbl mml-buffer-list))
4420 (setq mml-buffer-list nil)
4421 (insert-buffer gnus-original-article-buffer)
4422 (mime-to-mml ',handles)
4423 (setq gnus-article-mime-handles nil)
4424 (let ((mbl1 mml-buffer-list))
4425 (setq mml-buffer-list mbl)
4426 (set (make-local-variable 'mml-buffer-list) mbl1))
4427 (gnus-make-local-hook 'kill-buffer-hook)
4428 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4429 `(lambda (no-highlight)
4430 (let ((mail-parse-charset (or gnus-article-charset
4431 ',gnus-newsgroup-charset))
4432 (message-options message-options)
4433 (message-options-set-recipient)
4434 (mail-parse-ignored-charsets
4435 (or gnus-article-ignored-charsets
4436 ',gnus-newsgroup-ignored-charsets)))
4438 (mml-destroy-buffers)
4439 (remove-hook 'kill-buffer-hook
4440 'mml-destroy-buffers t)
4441 (kill-local-variable 'mml-buffer-list))
4442 (gnus-summary-edit-article-done
4443 ,(or (mail-header-references gnus-current-headers) "")
4444 ,(gnus-group-read-only-p)
4445 ,gnus-summary-buffer no-highlight)))))
4446 ;; Not in `gnus-mime-save-part-and-strip':
4447 (gnus-article-edit-done)
4448 (gnus-summary-expand-window)
4449 (gnus-summary-show-article))
4451 (defun gnus-mime-save-part ()
4452 "Save the MIME part under point."
4454 (gnus-article-check-buffer)
4455 (let ((data (get-text-property (point) 'gnus-data)))
4457 (mm-save-part data))))
4459 (defun gnus-mime-pipe-part ()
4460 "Pipe the MIME part under point to a process."
4462 (gnus-article-check-buffer)
4463 (let ((data (get-text-property (point) 'gnus-data)))
4465 (mm-pipe-part data))))
4467 (defun gnus-mime-view-part ()
4468 "Interactively choose a viewing method for the MIME part under point."
4470 (gnus-article-check-buffer)
4471 (let ((data (get-text-property (point) 'gnus-data)))
4473 (setq gnus-article-mime-handles
4475 gnus-article-mime-handles (setq data (copy-sequence data))))
4476 (mm-interactively-view-part data))))
4478 (defun gnus-mime-view-part-as-type-internal ()
4479 (gnus-article-check-buffer)
4480 (let* ((name (mail-content-type-get
4481 (mm-handle-type (get-text-property (point) 'gnus-data))
4483 (def-type (and name (mm-default-file-encoding name))))
4484 (and def-type (cons def-type 0))))
4486 (defun gnus-mime-view-part-as-type (&optional mime-type)
4487 "Choose a MIME media type, and view the part as such."
4490 (setq mime-type (completing-read
4491 "View as MIME type: "
4492 (mapcar #'list (mailcap-mime-types))
4494 (gnus-mime-view-part-as-type-internal))))
4495 (gnus-article-check-buffer)
4496 (let ((handle (get-text-property (point) 'gnus-data)))
4499 (mm-make-handle (mm-handle-buffer handle)
4500 (cons mime-type (cdr (mm-handle-type handle)))
4501 (mm-handle-encoding handle)
4502 (mm-handle-undisplayer handle)
4503 (mm-handle-disposition handle)
4504 (mm-handle-description handle)
4506 (mm-handle-id handle)))
4507 (setq gnus-article-mime-handles
4508 (mm-merge-handles gnus-article-mime-handles handle))
4509 (gnus-mm-display-part handle))))
4512 (require 'jka-compr))
4514 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4515 ;; emacs can do that itself.
4517 (defun gnus-mime-jka-compr-maybe-uncompress ()
4518 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4519 The uncompress method used is derived from `buffer-file-name'."
4520 (when (and (fboundp 'jka-compr-installed-p)
4521 (jka-compr-installed-p))
4522 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4524 (let ((basename (file-name-nondirectory buffer-file-name))
4525 (args (jka-compr-info-uncompress-args info))
4526 (prog (jka-compr-info-uncompress-program info))
4527 (message (jka-compr-info-uncompress-message info))
4528 (err-file (jka-compr-make-temp-name)))
4530 (message "%s %s..." message basename))
4532 (unless (memq (apply 'call-process-region
4533 (point-min) (point-max)
4535 t (list t err-file) nil
4537 jka-compr-acceptable-retval-list)
4538 (jka-compr-error prog args basename message err-file))
4539 (jka-compr-delete-temp-file err-file)))))))
4541 (defun gnus-mime-copy-part (&optional handle)
4542 "Put the MIME part under point into a new buffer.
4543 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4546 (gnus-article-check-buffer)
4547 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4548 (contents (and handle (mm-get-part handle)))
4550 (file-name-nondirectory
4552 (mail-content-type-get (mm-handle-type handle) 'name)
4553 (mail-content-type-get (mm-handle-disposition handle)
4556 (buffer (and base (generate-new-buffer base))))
4558 (switch-to-buffer buffer)
4560 ;; We do it this way to make `normal-mode' set the appropriate mode.
4563 (setq buffer-file-name (expand-file-name base))
4564 (gnus-mime-jka-compr-maybe-uncompress)
4566 (setq buffer-file-name nil))
4567 (goto-char (point-min)))))
4569 (defun gnus-mime-print-part (&optional handle filename)
4570 "Print the MIME part under point."
4571 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4572 (gnus-article-check-buffer)
4573 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4574 (contents (and handle (mm-get-part handle)))
4575 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4576 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4581 (mm-save-part-to-file handle file)
4582 (call-process shell-file-name nil
4583 (generate-new-buffer " *mm*")
4585 shell-command-switch
4587 printer file (mm-handle-type handle))))
4591 (gnus-print-buffer))
4592 (ps-despool filename)))))
4594 (defun gnus-mime-inline-part (&optional handle arg)
4595 "Insert the MIME part under point into the current buffer."
4596 (interactive (list nil current-prefix-arg))
4597 (gnus-article-check-buffer)
4598 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4603 (if (and (not arg) (mm-handle-undisplayer handle))
4604 (mm-remove-part handle)
4605 (setq contents (mm-get-part handle))
4608 (setq charset (or (mail-content-type-get
4609 (mm-handle-type handle) 'charset)
4610 gnus-newsgroup-charset)))
4612 (if (mm-handle-undisplayer handle)
4613 (mm-remove-part handle))
4616 gnus-summary-show-article-charset-alist))
4617 (mm-read-coding-system "Charset: ")))))
4619 (mm-insert-inline handle
4621 (setq charset (mm-charset-to-coding-system
4623 (not (eq charset 'ascii)))
4624 (mm-decode-coding-string contents charset)
4628 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4629 "Insert the MIME part under point into the current buffer using the
4631 (interactive (list nil current-prefix-arg))
4632 (gnus-article-check-buffer)
4633 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4638 (if (mm-handle-undisplayer handle)
4639 (mm-remove-part handle))
4640 (let ((gnus-newsgroup-charset
4642 gnus-summary-show-article-charset-alist))
4643 (mm-read-coding-system "Charset: ")))
4644 (gnus-newsgroup-ignored-charsets 'gnus-all))
4645 (gnus-article-press-button)))))
4647 (defun gnus-mime-view-part-externally (&optional handle)
4648 "View the MIME part under point with an external viewer."
4650 (gnus-article-check-buffer)
4651 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4652 (mm-user-display-methods nil)
4653 (mm-inlined-types nil)
4654 (mail-parse-charset gnus-newsgroup-charset)
4655 (mail-parse-ignored-charsets
4656 (save-excursion (set-buffer gnus-summary-buffer)
4657 gnus-newsgroup-ignored-charsets)))
4659 (if (mm-handle-undisplayer handle)
4660 (mm-remove-part handle)
4661 (mm-display-part handle)))))
4663 (defun gnus-mime-view-part-internally (&optional handle)
4664 "View the MIME part under point with an internal viewer.
4665 If no internal viewer is available, use an external viewer."
4667 (gnus-article-check-buffer)
4668 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4669 (mm-inlined-types '(".*"))
4670 (mm-inline-large-images t)
4671 (mail-parse-charset gnus-newsgroup-charset)
4672 (mail-parse-ignored-charsets
4673 (save-excursion (set-buffer gnus-summary-buffer)
4674 gnus-newsgroup-ignored-charsets))
4677 (if (mm-handle-undisplayer handle)
4678 (mm-remove-part handle)
4679 (mm-display-part handle)))))
4681 (defun gnus-mime-action-on-part (&optional action)
4682 "Do something with the MIME attachment at \(point\)."
4684 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4685 (gnus-article-check-buffer)
4686 (let ((action-pair (assoc action gnus-mime-action-alist)))
4688 (funcall (cdr action-pair)))))
4690 (defun gnus-article-part-wrapper (n function)
4691 (save-current-buffer
4692 (set-buffer gnus-article-buffer)
4693 (when (> n (length gnus-article-mime-handle-alist))
4694 (error "No such part"))
4695 (gnus-article-goto-part n)
4696 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4697 (funcall function handle))))
4699 (defun gnus-article-pipe-part (n)
4700 "Pipe MIME part N, which is the numerical prefix."
4702 (gnus-article-part-wrapper n 'mm-pipe-part))
4704 (defun gnus-article-save-part (n)
4705 "Save MIME part N, which is the numerical prefix."
4707 (gnus-article-part-wrapper n 'mm-save-part))
4709 (defun gnus-article-interactively-view-part (n)
4710 "View MIME part N interactively, which is the numerical prefix."
4712 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4714 (defun gnus-article-copy-part (n)
4715 "Copy MIME part N, which is the numerical prefix."
4717 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4719 (defun gnus-article-view-part-as-charset (n)
4720 "View MIME part N using a specified charset.
4721 N is the numerical prefix."
4723 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4725 (defun gnus-article-view-part-externally (n)
4726 "View MIME part N externally, which is the numerical prefix."
4728 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4730 (defun gnus-article-inline-part (n)
4731 "Inline MIME part N, which is the numerical prefix."
4733 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4735 (defun gnus-article-mime-match-handle-first (condition)
4737 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4738 (while (setq ihandle (pop alist))
4740 ((functionp condition)
4741 (funcall condition (cdr ihandle)))
4742 ((eq condition 'undisplayed)
4743 (not (or (mm-handle-undisplayer (cdr ihandle))
4744 (equal (mm-handle-media-type (cdr ihandle))
4745 "multipart/alternative"))))
4746 ((eq condition 'undisplayed-alternative)
4747 (not (mm-handle-undisplayer (cdr ihandle))))
4749 (gnus-article-goto-part (car ihandle))
4750 (or (not n) (< (car ihandle) n)))
4751 (setq n (car ihandle))))
4755 (defun gnus-article-view-part (&optional n)
4756 "View MIME part N, which is the numerical prefix."
4758 (save-current-buffer
4759 (set-buffer gnus-article-buffer)
4760 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4761 gnus-article-mime-match-handle-function)))
4762 (when (> n (length gnus-article-mime-handle-alist))
4763 (error "No such part"))
4764 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4765 (when (gnus-article-goto-part n)
4766 (if (equal (car handle) "multipart/alternative")
4767 (gnus-article-press-button)
4768 (when (eq (gnus-mm-display-part handle) 'internal)
4769 (gnus-set-window-start)))))))
4771 (defsubst gnus-article-mime-total-parts ()
4772 (if (bufferp (car gnus-article-mime-handles))
4774 (1- (length gnus-article-mime-handles))))
4776 (defun gnus-mm-display-part (handle)
4777 "Display HANDLE and fix MIME button."
4778 (let ((id (get-text-property (point) 'gnus-part))
4783 (let ((window (selected-window))
4784 (mail-parse-charset gnus-newsgroup-charset)
4785 (mail-parse-ignored-charsets
4786 (if (gnus-buffer-live-p gnus-summary-buffer)
4788 (set-buffer gnus-summary-buffer)
4789 gnus-newsgroup-ignored-charsets)
4793 (let ((win (gnus-get-buffer-window (current-buffer) t))
4796 (select-window win))
4799 (if (mm-handle-displayed-p handle)
4800 ;; This will remove the part.
4801 (mm-display-part handle)
4803 (narrow-to-region (point)
4804 (if (eobp) (point) (1+ (point))))
4805 (mm-display-part handle)
4806 ;; We narrow to the part itself and
4807 ;; then call the treatment functions.
4808 (goto-char (point-min))
4810 (narrow-to-region (point) (point-max))
4813 (gnus-article-mime-total-parts)
4814 (mm-handle-media-type handle)))))
4815 (if (window-live-p window)
4816 (select-window window)))))
4819 (gnus-insert-mime-button
4820 handle id (list (mm-handle-displayed-p handle)))
4821 (goto-char point))))
4823 (defun gnus-article-goto-part (n)
4824 "Go to MIME part N."
4825 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4827 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4828 (let ((gnus-tmp-name
4829 (or (mail-content-type-get (mm-handle-type handle) 'name)
4830 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4831 (mail-content-type-get (mm-handle-type handle) 'url)
4833 (gnus-tmp-type (mm-handle-media-type handle))
4834 (gnus-tmp-description
4835 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4838 (if (if displayed (car displayed)
4839 (mm-handle-displayed-p handle))
4841 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4843 gnus-tmp-type-long b e)
4844 (when (string-match ".*/" gnus-tmp-name)
4845 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4846 (setq gnus-tmp-type-long (concat gnus-tmp-type
4847 (and (not (equal gnus-tmp-name ""))
4848 (concat "; " gnus-tmp-name))))
4849 (unless (equal gnus-tmp-description "")
4850 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4855 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4856 `(,@(gnus-local-map-property gnus-mime-button-map)
4857 gnus-callback gnus-mm-display-part
4858 gnus-part ,gnus-tmp-id
4859 article-type annotation
4862 ;; Exclude a newline.
4865 (widget-convert-button
4868 :action 'gnus-widget-press-button
4869 :button-keymap gnus-mime-button-map
4871 (lambda (widget/window &optional overlay pos)
4872 ;; Needed to properly clear the message due to a bug in
4873 ;; wid-edit (XEmacs only).
4874 (if (boundp 'help-echo-owns-message)
4875 (setq help-echo-owns-message t))
4877 "%S: %s the MIME part; %S: more options"
4878 (aref gnus-mouse-2 0)
4879 ;; XEmacs will get a single widget arg; Emacs 21 will get
4880 ;; window, overlay, position.
4881 (if (mm-handle-displayed-p
4883 (with-current-buffer (gnus-overlay-buffer overlay)
4884 (widget-get (widget-at (gnus-overlay-start overlay))
4886 (widget-get widget/window :mime-handle)))
4888 (aref gnus-down-mouse-3 0))))))
4890 (defun gnus-widget-press-button (elems el)
4891 (goto-char (widget-get elems :from))
4892 (gnus-article-press-button))
4894 (defvar gnus-displaying-mime nil)
4896 (defun gnus-display-mime (&optional ihandles)
4897 "Display the MIME parts."
4899 (save-selected-window
4900 (let ((window (get-buffer-window gnus-article-buffer))
4903 (select-window window)
4904 ;; We have to do this since selecting the window
4905 ;; may change the point. So we set the window point.
4906 (set-window-point window point)))
4907 (let* ((handles (or ihandles
4908 (mm-dissect-buffer nil gnus-article-loose-mime)
4909 (and gnus-article-emulate-mime
4911 buffer-read-only handle name type b e display)
4912 (when (and (not ihandles)
4913 (not gnus-displaying-mime))
4914 ;; Top-level call; we clean up.
4915 (when gnus-article-mime-handles
4916 (mm-destroy-parts gnus-article-mime-handles)
4917 (setq gnus-article-mime-handle-alist nil));; A trick.
4918 (setq gnus-article-mime-handles handles)
4919 ;; We allow users to glean info from the handles.
4920 (when gnus-article-mime-part-function
4921 (gnus-mime-part-function handles)))
4923 (or (not (stringp (car handles)))
4926 (when (and (not ihandles)
4927 (not gnus-displaying-mime))
4928 ;; Clean up for mime parts.
4930 (delete-region (point) (point-max)))
4931 (let ((gnus-displaying-mime t))
4932 (gnus-mime-display-part handles)))
4935 (narrow-to-region (point) (point-max))
4936 (gnus-treat-article nil 1 1)
4939 ;; Highlight the headers.
4943 (narrow-to-region (point-min) (point))
4944 (gnus-treat-article 'head))))))))
4946 (defcustom gnus-mime-display-multipart-as-mixed nil
4947 "Display \"multipart\" parts as \"multipart/mixed\".
4949 If t, it overrides nil values of
4950 `gnus-mime-display-multipart-alternative-as-mixed' and
4951 `gnus-mime-display-multipart-related-as-mixed'."
4952 :group 'gnus-article-mime
4955 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4956 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4957 :group 'gnus-article-mime
4960 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4961 "Display \"multipart/related\" parts as \"multipart/mixed\".
4963 If displaying \"text/html\" is discouraged \(see
4964 `mm-discouraged-alternatives'\) images or other material inside a
4965 \"multipart/related\" part might be overlooked when this variable is nil."
4966 :group 'gnus-article-mime
4969 (defun gnus-mime-display-part (handle)
4972 ((not (stringp (car handle)))
4973 (gnus-mime-display-single handle))
4974 ;; User-defined multipart
4975 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4976 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4978 ;; multipart/alternative
4979 ((and (equal (car handle) "multipart/alternative")
4980 (not (or gnus-mime-display-multipart-as-mixed
4981 gnus-mime-display-multipart-alternative-as-mixed)))
4982 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4983 (push (cons id handle) gnus-article-mime-handle-alist)
4984 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4985 ;; multipart/related
4986 ((and (equal (car handle) "multipart/related")
4987 (not (or gnus-mime-display-multipart-as-mixed
4988 gnus-mime-display-multipart-related-as-mixed)))
4989 ;;;!!!We should find the start part, but we just default
4990 ;;;!!!to the first part.
4991 ;;(gnus-mime-display-part (cadr handle))
4992 ;;;!!! Most multipart/related is an HTML message plus images.
4993 ;;;!!! Unfortunately we are unable to let W3 display those
4994 ;;;!!! included images, so we just display it as a mixed multipart.
4995 ;;(gnus-mime-display-mixed (cdr handle))
4996 ;;;!!! No, w3 can display everything just fine.
4997 (gnus-mime-display-part (cadr handle)))
4998 ((equal (car handle) "multipart/signed")
4999 (gnus-add-wash-type 'signed)
5000 (gnus-mime-display-security handle))
5001 ((equal (car handle) "multipart/encrypted")
5002 (gnus-add-wash-type 'encrypted)
5003 (gnus-mime-display-security handle))
5004 ;; Other multiparts are handled like multipart/mixed.
5006 (gnus-mime-display-mixed (cdr handle)))))
5008 (defun gnus-mime-part-function (handles)
5009 (if (stringp (car handles))
5010 (mapcar 'gnus-mime-part-function (cdr handles))
5011 (funcall gnus-article-mime-part-function handles)))
5013 (defun gnus-mime-display-mixed (handles)
5014 (mapcar 'gnus-mime-display-part handles))
5016 (defun gnus-mime-display-single (handle)
5017 (let ((type (mm-handle-media-type handle))
5018 (ignored gnus-ignored-mime-types)
5025 (when (string-match (pop ignored) type)
5026 (throw 'ignored nil)))
5027 (if (and (setq not-attachment
5028 (and (not (mm-inline-override-p handle))
5029 (or (not (mm-handle-disposition handle))
5030 (equal (car (mm-handle-disposition handle))
5032 (mm-attachment-override-p handle))))
5033 (mm-automatic-display-p handle)
5035 (mm-inlinable-p handle)
5036 (mm-inlined-p handle))
5037 (mm-automatic-external-display-p type)))
5039 (when (equal (mm-handle-media-supertype handle) "text")
5041 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5043 (push (cons id handle) gnus-article-mime-handle-alist)
5044 (when (or (not display)
5045 (not (gnus-unbuttonized-mime-type-p type)))
5046 ;(gnus-article-insert-newline)
5047 (gnus-insert-mime-button
5048 handle id (list (or display (and not-attachment text))))
5049 (gnus-article-insert-newline)
5050 ;(gnus-article-insert-newline)
5051 ;; Remember modify the number of forward lines.
5059 (let ((mail-parse-charset gnus-newsgroup-charset)
5060 (mail-parse-ignored-charsets
5061 (save-excursion (condition-case ()
5062 (set-buffer gnus-summary-buffer)
5064 gnus-newsgroup-ignored-charsets)))
5065 (mm-display-part handle t))
5066 (goto-char (point-max)))
5067 ((and text not-attachment)
5071 (gnus-article-insert-newline)
5072 (mm-insert-inline handle (mm-get-part handle))
5073 (goto-char (point-max))))
5077 (narrow-to-region beg (point))
5080 (gnus-article-mime-total-parts)
5081 (mm-handle-media-type handle)))))))))
5083 (defun gnus-unbuttonized-mime-type-p (type)
5084 "Say whether TYPE is to be unbuttonized."
5085 (unless gnus-inhibit-mime-unbuttonizing
5087 (let ((types gnus-unbuttonized-mime-types))
5089 (when (string-match (pop types) type)
5090 (throw 'found t)))))
5092 (let ((types gnus-buttonized-mime-types))
5094 (when (string-match (pop types) type)
5095 (throw 'found t)))))))))
5097 (defun gnus-article-insert-newline ()
5098 "Insert a newline, but mark it as undeletable."
5099 (gnus-put-text-property
5100 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5102 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5103 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5106 handle buffer-read-only from props begend not-pref)
5107 (save-window-excursion
5110 (narrow-to-region (car ibegend)
5113 (goto-char (car ibegend))
5116 (delete-region (point-min) (point-max))
5117 (mm-remove-parts handles))
5118 (setq begend (list (point-marker)))
5120 (unless (setq not-pref (cadr (member preferred ihandles)))
5121 (setq not-pref (car ihandles)))
5124 (not (gnus-unbuttonized-mime-type-p
5125 "multipart/alternative")))
5126 (gnus-add-text-properties
5129 (insert (format "%d. " id))
5133 (unless ,(not ibegend)
5134 (setq gnus-article-mime-handle-alist
5135 ',gnus-article-mime-handle-alist))
5136 (gnus-mime-display-alternative
5137 ',ihandles ',not-pref ',begend ,id))
5138 ,@(gnus-local-map-property gnus-mime-button-map)
5139 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5140 face ,gnus-article-button-face
5143 (widget-convert-button 'link from (point)
5144 :action 'gnus-widget-press-button
5145 :button-keymap gnus-widget-button-keymap)
5147 (while (setq handle (pop handles))
5148 (gnus-add-text-properties
5151 (insert (format "(%c) %-18s"
5152 (if (equal handle preferred) ?* ? )
5153 (mm-handle-media-type handle)))
5157 (unless ,(not ibegend)
5158 (setq gnus-article-mime-handle-alist
5159 ',gnus-article-mime-handle-alist))
5160 (gnus-mime-display-alternative
5161 ',ihandles ',handle ',begend ,id))
5162 ,@(gnus-local-map-property gnus-mime-button-map)
5163 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5164 face ,gnus-article-button-face
5167 (widget-convert-button 'link from (point)
5168 :action 'gnus-widget-press-button
5169 :button-keymap gnus-widget-button-keymap)
5173 (if (stringp (car preferred))
5174 (gnus-display-mime preferred)
5175 (let ((mail-parse-charset gnus-newsgroup-charset)
5176 (mail-parse-ignored-charsets
5177 (save-excursion (set-buffer gnus-summary-buffer)
5178 gnus-newsgroup-ignored-charsets)))
5179 (mm-display-part preferred)
5183 (narrow-to-region (car begend) (point-max))
5185 nil (length gnus-article-mime-handle-alist)
5186 (gnus-article-mime-total-parts)
5187 (mm-handle-media-type handle))))))
5188 (goto-char (point-max))
5189 (setcdr begend (point-marker)))))
5191 (goto-char point))))
5193 (defconst gnus-article-wash-status-strings
5194 (let ((alist '((cite "c" "Possible hidden citation text"
5195 " " "All citation text visible")
5196 (headers "h" "Hidden headers"
5197 " " "All headers visible.")
5198 (pgp "p" "Encrypted or signed message status hidden"
5199 " " "No hidden encryption nor digital signature status")
5200 (signature "s" "Signature has been hidden"
5201 " " "Signature is visible")
5202 (overstrike "o" "Overstrike (^H) characters applied"
5203 " " "No overstrike characters applied")
5204 (gnus-show-mime "m" "Mime processing is activated"
5205 " " "Mime processing is not activated")
5206 (emphasis "e" "/*_Emphasis_*/ characters applied"
5207 " " "No /*_emphasis_*/ characters applied")))
5209 (dolist (entry alist result)
5210 (let ((key (nth 0 entry))
5211 (on (copy-sequence (nth 1 entry)))
5212 (on-help (nth 2 entry))
5213 (off (copy-sequence (nth 3 entry)))
5214 (off-help (nth 4 entry)))
5215 (put-text-property 0 1 'help-echo on-help on)
5216 (put-text-property 0 1 'help-echo off-help off)
5217 (push (list key on off) result))))
5218 "Alist of strings describing wash status in the mode line.
5219 Each entry has the form (KEY ON OF), where the KEY is a symbol
5220 representing the particular washing function, ON is the string to use
5221 in the article mode line when the washing function is active, and OFF
5222 is the string to use when it is inactive.")
5224 (defun gnus-article-wash-status-entry (key value)
5225 (let ((entry (assoc key gnus-article-wash-status-strings)))
5226 (if value (nth 1 entry) (nth 2 entry))))
5228 (defun gnus-article-wash-status ()
5229 "Return a string which display status of article washing."
5231 (set-buffer gnus-article-buffer)
5232 (let ((cite (memq 'cite gnus-article-wash-types))
5233 (headers (memq 'headers gnus-article-wash-types))
5234 (boring (memq 'boring-headers gnus-article-wash-types))
5235 (pgp (memq 'pgp gnus-article-wash-types))
5236 (pem (memq 'pem gnus-article-wash-types))
5237 (signed (memq 'signed gnus-article-wash-types))
5238 (encrypted (memq 'encrypted gnus-article-wash-types))
5239 (signature (memq 'signature gnus-article-wash-types))
5240 (overstrike (memq 'overstrike gnus-article-wash-types))
5241 (emphasis (memq 'emphasis gnus-article-wash-types)))
5243 (gnus-article-wash-status-entry 'cite cite)
5244 (gnus-article-wash-status-entry 'headers (or headers boring))
5245 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5246 (gnus-article-wash-status-entry 'signature signature)
5247 (gnus-article-wash-status-entry 'overstrike overstrike)
5248 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5249 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5251 (defun gnus-add-wash-type (type)
5252 "Add a washing of TYPE to the current status."
5253 (add-to-list 'gnus-article-wash-types type))
5255 (defun gnus-delete-wash-type (type)
5256 "Add a washing of TYPE to the current status."
5257 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5259 (defun gnus-add-image (category image)
5260 "Add IMAGE of CATEGORY to the list of displayed images."
5261 (let ((entry (assq category gnus-article-image-alist)))
5263 (setq entry (list category))
5264 (push entry gnus-article-image-alist))
5265 (nconc entry (list image))))
5267 (defun gnus-delete-images (category)
5268 "Delete all images in CATEGORY."
5269 (let ((entry (assq category gnus-article-image-alist)))
5270 (dolist (image (cdr entry))
5271 (gnus-remove-image image category))
5272 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5273 (gnus-delete-wash-type category)))
5275 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5277 (defun gnus-article-maybe-hide-headers ()
5278 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5279 Provided for backwards compatibility."
5280 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5281 (not (save-excursion (set-buffer gnus-summary-buffer)
5282 gnus-have-all-headers)))
5283 (not gnus-inhibit-hiding))
5284 (gnus-article-hide-headers)))
5288 (defun gnus-output-to-file (file-name)
5289 "Append the current article to a file named FILE-NAME."
5290 (let ((artbuf (current-buffer)))
5292 (insert-buffer-substring artbuf)
5293 ;; Append newline at end of the buffer as separator, and then
5295 (goto-char (point-max))
5297 (let ((file-name-coding-system nnmail-pathname-coding-system)
5298 (pathname-coding-system nnmail-pathname-coding-system))
5299 (write-region-as-binary (point-min) (point-max) file-name 'append))
5302 (defun gnus-narrow-to-page (&optional arg)
5303 "Narrow the article buffer to a page.
5304 If given a numerical ARG, move forward ARG pages."
5306 (setq arg (if arg (prefix-numeric-value arg) 0))
5308 (set-buffer gnus-article-buffer)
5309 (goto-char (point-min))
5311 ;; Remove any old next/prev buttons.
5312 (when (gnus-visual-p 'page-marker)
5313 (let ((buffer-read-only nil))
5314 (gnus-remove-text-with-property 'gnus-prev)
5315 (gnus-remove-text-with-property 'gnus-next)))
5318 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5320 (re-search-forward page-delimiter nil 'move arg)))
5321 (goto-char (match-end 0))
5323 (goto-char (point-min))
5324 (setq gnus-page-broken
5325 (and (re-search-forward page-delimiter nil t) t))))
5326 (when gnus-page-broken
5329 (if (re-search-forward page-delimiter nil 'move)
5332 (when (and (gnus-visual-p 'page-marker)
5333 (not (= (point-min) 1)))
5335 (goto-char (point-min))
5336 (gnus-insert-prev-page-button)))
5337 (when (and (gnus-visual-p 'page-marker)
5338 (< (+ (point-max) 2) (buffer-size)))
5340 (goto-char (point-max))
5341 (gnus-insert-next-page-button))))))
5343 ;; Article mode commands
5345 (defun gnus-article-goto-next-page ()
5346 "Show the next page of the article."
5348 (when (gnus-article-next-page)
5349 (goto-char (point-min))
5350 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5353 (defun gnus-article-goto-prev-page ()
5354 "Show the previous page of the article."
5357 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5358 (gnus-article-prev-page nil)))
5360 ;; This is cleaner but currently breaks `gnus-pick-mode':
5362 ;; (defun gnus-article-goto-next-page ()
5363 ;; "Show the next page of the article."
5365 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5366 ;; (gnus-summary-next-page)))
5368 ;; (defun gnus-article-goto-prev-page ()
5369 ;; "Show the next page of the article."
5371 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5372 ;; (gnus-summary-prev-page)))
5374 (defun gnus-article-next-page (&optional lines)
5375 "Show the next page of the current article.
5376 If end of article, return non-nil. Otherwise return nil.
5377 Argument LINES specifies lines to be scrolled up."
5379 (move-to-window-line -1)
5382 (and (pos-visible-in-window-p) ;Not continuation line.
5383 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5384 ;; Nothing in this page.
5385 (if (or (not gnus-page-broken)
5389 (eobp)))) ;Real end-of-buffer?
5391 (when gnus-article-over-scroll
5392 (gnus-article-next-page-1 lines))
5394 (gnus-narrow-to-page 1) ;Go to next page.
5396 ;; More in this page.
5397 (gnus-article-next-page-1 lines)
5400 (defun gnus-article-next-page-1 (lines)
5401 (let ((scroll-in-place nil))
5405 ;; Long lines may cause an end-of-buffer error.
5406 (goto-char (point-max)))))
5407 (move-to-window-line 0))
5409 (defun gnus-article-prev-page (&optional lines)
5410 "Show previous page of current article.
5411 Argument LINES specifies lines to be scrolled down."
5413 (move-to-window-line 0)
5414 (if (and gnus-page-broken
5416 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5418 (gnus-narrow-to-page -1) ;Go to previous page.
5419 (goto-char (point-max))
5421 (let ((scroll-in-place nil))
5425 (beginning-of-buffer
5426 (goto-char (point-min))))
5427 (move-to-window-line 0)))))
5429 (defun gnus-article-only-boring-p ()
5430 "Decide whether there is only boring text remaining in the article.
5431 Something \"interesting\" is a word of at least two letters that does
5432 not have a face in `gnus-article-boring-faces'."
5433 (when (and gnus-article-skip-boring
5434 (boundp 'gnus-article-boring-faces)
5435 (symbol-value 'gnus-article-boring-faces))
5438 (while (re-search-forward "\\b\\w\\w" nil t)
5440 (when (not (gnus-intersection
5441 (gnus-faces-at (point))
5442 (symbol-value 'gnus-article-boring-faces)))
5443 (throw 'only-boring nil)))
5444 (throw 'only-boring t)))))
5446 (defun gnus-article-refer-article ()
5447 "Read article specified by message-id around point."
5450 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5451 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5452 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5453 (let ((msg-id (concat "<" (match-string 0) ">")))
5454 (set-buffer gnus-summary-buffer)
5455 (gnus-summary-refer-article msg-id))
5456 (error "No references around point"))))
5458 (defun gnus-article-show-summary ()
5459 "Reconfigure windows to show summary buffer."
5461 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5462 (error "There is no summary buffer for this article buffer")
5463 (gnus-article-set-globals)
5464 (gnus-configure-windows 'article)
5465 (gnus-summary-goto-subject gnus-current-article)
5466 (gnus-summary-position-point)))
5468 (defun gnus-article-describe-briefly ()
5469 "Describe article mode commands briefly."
5471 (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")))
5473 (defun gnus-article-summary-command ()
5474 "Execute the last keystroke in the summary buffer."
5476 (let ((obuf (current-buffer))
5477 (owin (current-window-configuration))
5479 (switch-to-buffer gnus-article-current-summary 'norecord)
5480 (setq func (lookup-key (current-local-map) (this-command-keys)))
5481 (call-interactively func)
5483 (set-window-configuration owin)
5484 (set-window-point (get-buffer-window (current-buffer)) (point))))
5486 (defun gnus-article-summary-command-nosave ()
5487 "Execute the last keystroke in the summary buffer."
5490 (pop-to-buffer gnus-article-current-summary 'norecord)
5491 (setq func (lookup-key (current-local-map) (this-command-keys)))
5492 (call-interactively func)))
5494 (defun gnus-article-check-buffer ()
5495 "Beep if not in an article buffer."
5496 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5497 (error "Command invoked outside of a Gnus article buffer")))
5499 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5500 "Read a summary buffer key sequence and execute it from the article buffer."
5502 (gnus-article-check-buffer)
5504 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5505 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5506 "=" "^" "\M-^" "|"))
5512 '("n" "Gn" "p" "Gp"))
5515 (set-buffer gnus-article-current-summary)
5516 (let (gnus-pick-mode)
5517 (push (or key last-command-event) unread-command-events)
5518 (setq keys (static-if (featurep 'xemacs)
5519 (events-to-keys (read-key-sequence nil))
5520 (read-key-sequence nil)))))
5523 (if (or (member keys nosaves)
5524 (member keys nosave-but-article)
5525 (member keys nosave-in-article))
5527 (save-window-excursion
5528 (pop-to-buffer gnus-article-current-summary 'norecord)
5529 ;; We disable the pick minor mode commands.
5530 (let (gnus-pick-mode)
5531 (setq func (lookup-key (current-local-map) keys))))
5535 (unless (member keys nosave-in-article)
5536 (set-buffer gnus-article-current-summary))
5537 (call-interactively func)
5538 (setq new-sum-point (point)))
5539 (when (member keys nosave-but-article)
5540 (pop-to-buffer gnus-article-buffer 'norecord)))
5541 ;; These commands should restore window configuration.
5542 (let ((obuf (current-buffer))
5543 (owin (current-window-configuration))
5545 (summary gnus-article-current-summary)
5546 func in-buffer selected)
5547 (if not-restore-window
5548 (pop-to-buffer summary 'norecord)
5549 (switch-to-buffer summary 'norecord))
5550 (setq in-buffer (current-buffer))
5551 ;; We disable the pick minor mode commands.
5552 (if (and (setq func (let (gnus-pick-mode)
5553 (lookup-key (current-local-map) keys)))
5556 (call-interactively func)
5557 (setq new-sum-point (point))
5558 (when (eq in-buffer (current-buffer))
5559 (setq selected (gnus-summary-select-article))
5561 (unless not-restore-window
5562 (set-window-configuration owin))
5563 (when (eq selected 'old)
5565 (set-window-start (get-buffer-window (current-buffer))
5567 (set-window-point (get-buffer-window (current-buffer))
5569 (let ((win (get-buffer-window gnus-article-current-summary)))
5571 (set-window-point win new-sum-point)))) )
5572 (switch-to-buffer gnus-article-buffer)
5575 (defun gnus-article-describe-key (key)
5576 "Display documentation of the function invoked by KEY. KEY is a string."
5577 (interactive "kDescribe key: ")
5578 (gnus-article-check-buffer)
5579 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5581 (set-buffer gnus-article-current-summary)
5582 (let (gnus-pick-mode)
5583 (if (featurep 'xemacs)
5585 (push (elt key 0) unread-command-events)
5586 (setq key (events-to-keys
5587 (read-key-sequence "Describe key: "))))
5588 (setq unread-command-events
5590 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5592 (setq key (read-key-sequence "Describe key: "))))
5594 (describe-key key)))
5596 (defun gnus-article-describe-key-briefly (key &optional insert)
5597 "Display documentation of the function invoked by KEY. KEY is a string."
5598 (interactive "kDescribe key: \nP")
5599 (gnus-article-check-buffer)
5600 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5602 (set-buffer gnus-article-current-summary)
5603 (let (gnus-pick-mode)
5604 (if (featurep 'xemacs)
5606 (push (elt key 0) unread-command-events)
5607 (setq key (events-to-keys
5608 (read-key-sequence "Describe key: "))))
5609 (setq unread-command-events
5611 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5613 (setq key (read-key-sequence "Describe key: "))))
5614 (describe-key-briefly key insert))
5615 (describe-key-briefly key insert)))
5617 (defun gnus-article-reply-with-original (&optional wide)
5618 "Start composing a reply mail to the current message.
5619 The text in the region will be yanked. If the region isn't active,
5620 the entire article will be yanked."
5622 (let ((article (cdr gnus-article-current))
5624 (if (not (gnus-mark-active-p))
5625 (with-current-buffer gnus-summary-buffer
5626 (gnus-summary-reply (list (list article)) wide))
5627 (setq contents (buffer-substring (point) (mark t)))
5628 ;; Deactivate active regions.
5629 (when (and (boundp 'transient-mark-mode)
5630 transient-mark-mode)
5631 (setq mark-active nil))
5632 (with-current-buffer gnus-summary-buffer
5634 (list (list article contents)) wide)))))
5636 (defun gnus-article-followup-with-original ()
5637 "Compose a followup to the current article.
5638 The text in the region will be yanked. If the region isn't active,
5639 the entire article will be yanked."
5641 (let ((article (cdr gnus-article-current))
5643 (if (not (gnus-mark-active-p))
5644 (with-current-buffer gnus-summary-buffer
5645 (gnus-summary-followup (list (list article))))
5646 (setq contents (buffer-substring (point) (mark t)))
5647 ;; Deactivate active regions.
5648 (when (and (boundp 'transient-mark-mode)
5649 transient-mark-mode)
5650 (setq mark-active nil))
5651 (with-current-buffer gnus-summary-buffer
5652 (gnus-summary-followup
5653 (list (list article contents)))))))
5655 (defun gnus-article-hide (&optional arg force)
5656 "Hide all the gruft in the current article.
5657 This means that signatures, cited text and (some) headers will be
5659 If given a prefix, show the hidden text instead."
5660 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5661 (gnus-article-hide-headers arg)
5662 (gnus-article-hide-list-identifiers arg)
5663 (gnus-article-hide-citation-maybe arg force)
5664 (gnus-article-hide-signature arg))
5666 (defun gnus-article-maybe-highlight ()
5667 "Do some article highlighting if article highlighting is requested."
5668 (when (gnus-visual-p 'article-highlight 'highlight)
5669 (gnus-article-highlight-some)))
5671 (defun gnus-check-group-server ()
5672 ;; Make sure the connection to the server is alive.
5673 (unless (gnus-server-opened
5674 (gnus-find-method-for-group gnus-newsgroup-name))
5675 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5676 (gnus-request-group gnus-newsgroup-name t)))
5679 (autoload 'nneething-get-file-name "nneething"))
5681 (defun gnus-request-article-this-buffer (article group)
5682 "Get an article and insert it into this buffer."
5683 (let (do-update-line sparse-header)
5687 (gnus-kill-all-overlays)
5688 (setq group (or group gnus-newsgroup-name))
5690 ;; Using `gnus-request-article' directly will insert the article into
5691 ;; `nntp-server-buffer' - so we'll save some time by not having to
5692 ;; copy it from the server buffer into the article buffer.
5694 ;; We only request an article by message-id when we do not have the
5695 ;; headers for it, so we'll have to get those.
5696 (when (stringp article)
5697 (gnus-read-header article))
5699 ;; If the article number is negative, that means that this article
5700 ;; doesn't belong in this newsgroup (possibly), so we find its
5701 ;; message-id and request it by id instead of number.
5702 (when (and (numberp article)
5704 (get-buffer gnus-summary-buffer)
5705 (gnus-buffer-exists-p gnus-summary-buffer))
5707 (set-buffer gnus-summary-buffer)
5708 (let ((header (gnus-summary-article-header article)))
5711 ((memq article gnus-newsgroup-sparse)
5712 ;; This is a sparse gap article.
5713 (setq do-update-line article)
5714 (setq article (mail-header-id header))
5715 (setq sparse-header (gnus-read-header article))
5716 (setq gnus-newsgroup-sparse
5717 (delq article gnus-newsgroup-sparse)))
5719 ;; It's a real article.
5720 (setq article (mail-header-id header)))
5722 ;; It is an extracted pseudo-article.
5723 (setq article 'pseudo)
5724 (gnus-request-pseudo-article header))))
5726 (let ((method (gnus-find-method-for-group
5727 gnus-newsgroup-name)))
5728 (when (and (eq (car method) 'nneething)
5730 (let ((dir (nneething-get-file-name
5731 (mail-header-id header))))
5732 (when (and (stringp dir)
5733 (file-directory-p dir))
5734 (setq article 'nneething)
5735 (gnus-group-enter-directory dir))))))))
5738 ;; Refuse to select canceled articles.
5739 ((and (numberp article)
5741 (get-buffer gnus-summary-buffer)
5742 (gnus-buffer-exists-p gnus-summary-buffer)
5743 (eq (cdr (save-excursion
5744 (set-buffer gnus-summary-buffer)
5745 (assq article gnus-newsgroup-reads)))
5746 gnus-canceled-mark))
5748 ;; We first check `gnus-original-article-buffer'.
5749 ((and (get-buffer gnus-original-article-buffer)
5752 (set-buffer gnus-original-article-buffer)
5753 (and (equal (car gnus-original-article) group)
5754 (eq (cdr gnus-original-article) article))))
5755 (insert-buffer-substring gnus-original-article-buffer)
5757 ;; Check the backlog.
5758 ((and gnus-keep-backlog
5759 (gnus-backlog-request-article group article (current-buffer)))
5761 ;; Check asynchronous pre-fetch.
5762 ((gnus-async-request-fetched-article group article (current-buffer))
5763 (gnus-async-prefetch-next group article gnus-summary-buffer)
5764 (when (and (numberp article) gnus-keep-backlog)
5765 (gnus-backlog-enter-article group article (current-buffer)))
5768 ((and gnus-use-cache
5770 (gnus-cache-request-article article group))
5772 ;; Check the agent cache.
5773 ((gnus-agent-request-article article group)
5775 ;; Get the article and put into the article buffer.
5776 ((or (stringp article)
5778 (let ((gnus-override-method gnus-override-method)
5779 (methods (and (stringp article)
5780 gnus-refer-article-method))
5781 (backend (car (gnus-find-method-for-group
5782 gnus-newsgroup-name)))
5784 (buffer-read-only nil))
5785 (if (or (not (listp methods))
5786 (and (symbolp (car methods))
5787 (assq (car methods) nnoo-definition-alist)))
5788 (setq methods (list methods)))
5789 (when (and (null gnus-override-method)
5791 (setq gnus-override-method (pop methods)))
5793 (when (eq gnus-override-method 'current)
5794 (setq gnus-override-method
5795 (with-current-buffer gnus-summary-buffer
5796 gnus-current-select-method)))
5798 (gnus-kill-all-overlays)
5799 (let ((gnus-newsgroup-name group))
5800 (gnus-check-group-server))
5802 ((gnus-request-article article group (current-buffer))
5803 (when (numberp article)
5804 (gnus-async-prefetch-next group article
5805 gnus-summary-buffer)
5806 (when gnus-keep-backlog
5807 (gnus-backlog-enter-article
5808 group article (current-buffer))))
5809 (setq result 'article))
5811 (setq gnus-override-method (pop methods)))
5812 ((not (string-match "^400 "
5813 (nnheader-get-report backend)))
5814 ;; If we get 400 server disconnect, reconnect and
5815 ;; retry; otherwise, assume the article has expired.
5816 (setq result 'done))))
5817 (and (eq result 'article) 'article)))
5821 ;; Associate this article with the current summary buffer.
5822 (setq gnus-article-current-summary gnus-summary-buffer)
5824 ;; Take the article from the original article buffer
5825 ;; and place it in the buffer it's supposed to be in.
5826 (when (and (get-buffer gnus-article-buffer)
5827 (equal (buffer-name (current-buffer))
5828 (buffer-name (get-buffer gnus-article-buffer))))
5830 (if (get-buffer gnus-original-article-buffer)
5831 (set-buffer gnus-original-article-buffer)
5832 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5833 (buffer-disable-undo)
5834 (setq major-mode 'gnus-original-article-mode)
5835 (setq buffer-read-only t))
5836 (let (buffer-read-only)
5838 (insert-buffer-substring gnus-article-buffer))
5839 (setq gnus-original-article (cons group article)))
5842 (run-hooks 'gnus-article-decode-hook)
5843 ;; Mark article as decoded or not.
5844 (setq gnus-article-decoded-p gnus-article-decode-hook))
5846 ;; Update sparse articles.
5847 (when (and do-update-line
5848 (or (numberp article)
5850 (let ((buf (current-buffer)))
5851 (set-buffer gnus-summary-buffer)
5852 (gnus-summary-update-article do-update-line sparse-header)
5853 (gnus-summary-goto-subject do-update-line nil t)
5854 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5856 (set-buffer buf))))))
5862 (defcustom gnus-article-edit-mode-hook nil
5863 "Hook run in article edit mode buffers."
5864 :group 'gnus-article-various
5867 (defcustom gnus-article-edit-article-setup-function
5868 'gnus-article-mime-edit-article-setup
5869 "Function called to setup an editing article buffer."
5870 :group 'gnus-article-various
5873 (defvar gnus-article-edit-done-function nil)
5875 (defvar gnus-article-edit-mode-map nil)
5876 (defvar gnus-article-edit-mode nil)
5878 ;; Should we be using derived.el for this?
5879 (unless gnus-article-edit-mode-map
5880 (setq gnus-article-edit-mode-map (make-keymap))
5881 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5883 (gnus-define-keys gnus-article-edit-mode-map
5884 "\C-c?" describe-mode
5885 "\C-c\C-c" gnus-article-edit-done
5886 "\C-c\C-k" gnus-article-edit-exit
5887 "\C-c\C-f\C-t" message-goto-to
5888 "\C-c\C-f\C-o" message-goto-from
5889 "\C-c\C-f\C-b" message-goto-bcc
5890 ;;"\C-c\C-f\C-w" message-goto-fcc
5891 "\C-c\C-f\C-c" message-goto-cc
5892 "\C-c\C-f\C-s" message-goto-subject
5893 "\C-c\C-f\C-r" message-goto-reply-to
5894 "\C-c\C-f\C-n" message-goto-newsgroups
5895 "\C-c\C-f\C-d" message-goto-distribution
5896 "\C-c\C-f\C-f" message-goto-followup-to
5897 "\C-c\C-f\C-m" message-goto-mail-followup-to
5898 "\C-c\C-f\C-k" message-goto-keywords
5899 "\C-c\C-f\C-u" message-goto-summary
5900 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5901 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5902 "\C-c\C-b" message-goto-body
5903 "\C-c\C-i" message-goto-signature
5905 "\C-c\C-t" message-insert-to
5906 "\C-c\C-n" message-insert-newsgroups
5907 "\C-c\C-o" message-sort-headers
5908 "\C-c\C-e" message-elide-region
5909 "\C-c\C-v" message-delete-not-region
5910 "\C-c\C-z" message-kill-to-signature
5911 "\M-\r" message-newline-and-reformat
5912 "\C-c\C-a" mml-attach-file
5913 "\C-a" message-beginning-of-line
5915 "\M-;" comment-region)
5917 (gnus-define-keys (gnus-article-edit-wash-map
5918 "\C-c\C-w" gnus-article-edit-mode-map)
5919 "f" gnus-article-edit-full-stops))
5922 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5924 ["Fetch To" message-insert-to t]
5925 ["Fetch Newsgroups" message-insert-newsgroups t]
5927 ["To" message-goto-to t]
5928 ["From" message-goto-from t]
5929 ["Subject" message-goto-subject t]
5930 ["Cc" message-goto-cc t]
5931 ["Reply-To" message-goto-reply-to t]
5932 ["Summary" message-goto-summary t]
5933 ["Keywords" message-goto-keywords t]
5934 ["Newsgroups" message-goto-newsgroups t]
5935 ["Followup-To" message-goto-followup-to t]
5936 ["Mail-Followup-To" message-goto-mail-followup-to t]
5937 ["Distribution" message-goto-distribution t]
5938 ["Body" message-goto-body t]
5939 ["Signature" message-goto-signature t]))
5941 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5942 "Major mode for editing articles.
5943 This is an extended text-mode.
5945 \\{gnus-article-edit-mode-map}"
5946 (make-local-variable 'gnus-article-edit-done-function)
5947 (make-local-variable 'gnus-prev-winconf)
5948 (set (make-local-variable 'font-lock-defaults)
5949 '(message-font-lock-keywords t))
5950 (set (make-local-variable 'mail-header-separator) "")
5951 (set (make-local-variable 'gnus-article-edit-mode) t)
5952 (easy-menu-add message-mode-field-menu message-mode-map)
5953 (setq buffer-read-only nil)
5954 (buffer-enable-undo)
5957 (defun gnus-article-edit (&optional force)
5958 "Edit the current article.
5959 This will have permanent effect only in mail groups.
5960 If FORCE is non-nil, allow editing of articles even in read-only
5963 (when (and (not force)
5964 (gnus-group-read-only-p))
5965 (error "The current newsgroup does not support article editing"))
5966 (gnus-article-date-original)
5967 (gnus-article-edit-article
5969 `(lambda (no-highlight)
5971 (gnus-summary-edit-article-done
5972 ,(or (mail-header-references gnus-current-headers) "")
5973 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5975 (defun gnus-article-edit-article (start-func exit-func)
5976 "Start editing the contents of the current article buffer."
5977 (let ((winconf (current-window-configuration)))
5978 (set-buffer gnus-article-buffer)
5979 (gnus-article-edit-mode)
5980 (funcall start-func)
5981 (set-buffer-modified-p nil)
5982 (gnus-configure-windows 'edit-article)
5983 (setq gnus-article-edit-done-function exit-func)
5984 (setq gnus-prev-winconf winconf)
5985 (when gnus-article-edit-article-setup-function
5986 (funcall gnus-article-edit-article-setup-function))
5987 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5989 (defun gnus-article-edit-done (&optional arg)
5990 "Update the article edits and exit."
5992 (let ((func gnus-article-edit-done-function)
5993 (buf (current-buffer))
5994 (start (window-start))
5996 (winconf gnus-prev-winconf))
5997 (remove-hook 'gnus-article-mode-hook
5998 'gnus-article-mime-edit-article-unwind)
5999 (widen) ;; Widen it in case that users narrowed the buffer.
6002 ;; The cache and backlog have to be flushed somewhat.
6003 (when gnus-keep-backlog
6004 (gnus-backlog-remove-article
6005 (car gnus-article-current) (cdr gnus-article-current)))
6006 ;; Flush original article as well.
6008 (when (get-buffer gnus-original-article-buffer)
6009 (set-buffer gnus-original-article-buffer)
6010 (setq gnus-original-article nil)))
6011 (when gnus-use-cache
6012 (gnus-cache-update-article
6013 (car gnus-article-current) (cdr gnus-article-current)))
6014 ;; We remove all text props from the article buffer.
6015 (kill-all-local-variables)
6016 (gnus-set-text-properties (point-min) (point-max) nil)
6018 (set-window-configuration winconf)
6020 (set-window-start (get-buffer-window buf) start)
6021 (set-window-point (get-buffer-window buf) (point)))
6022 (gnus-summary-show-article))
6024 (defun gnus-article-edit-exit ()
6025 "Exit the article editing without updating."
6027 (when (or (not (buffer-modified-p))
6028 (yes-or-no-p "Article modified; kill anyway? "))
6029 (let ((curbuf (current-buffer))
6031 (window-start (window-start)))
6033 (if (gnus-buffer-live-p gnus-original-article-buffer)
6034 (insert-buffer-substring gnus-original-article-buffer))
6035 (let ((winconf gnus-prev-winconf))
6036 (kill-all-local-variables)
6038 (set-window-configuration winconf)
6039 ;; Tippy-toe some to make sure that point remains where it was.
6040 (save-current-buffer
6042 (set-window-start (get-buffer-window (current-buffer)) window-start)
6044 (gnus-summary-show-article)))
6046 (defun gnus-article-edit-full-stops ()
6047 "Interactively repair spacing at end of sentences."
6050 (goto-char (point-min))
6051 (search-forward-regexp "^$" nil t)
6052 (let ((case-fold-search nil))
6053 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6056 ;;; Article editing with MIME-Edit
6059 (defcustom gnus-article-mime-edit-article-setup-hook nil
6060 "Hook run after setting up a MIME editing article buffer."
6061 :group 'gnus-article-various
6064 (defun gnus-article-mime-edit-article-unwind ()
6065 "Unwind `gnus-article-buffer' if article editing was given up."
6066 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6067 (when (featurep 'font-lock)
6068 (setq font-lock-defaults nil)
6069 (font-lock-mode -1))
6070 (when mime-edit-mode-flag
6071 (mime-edit-exit 'nomime 'no-error)
6074 (defun gnus-article-mime-edit-article-setup ()
6075 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6076 after replacing with the original article."
6077 (setq gnus-show-mime t)
6078 (setq gnus-article-edit-done-function
6079 `(lambda (&rest args)
6080 (when mime-edit-mode-flag
6081 (let (mime-edit-insert-user-agent-field)
6084 (goto-char (point-min))
6085 (let (case-fold-search)
6086 (when (re-search-forward
6087 (format "^%s$" (regexp-quote mail-header-separator))
6089 (replace-match "")))
6090 (apply ,gnus-article-edit-done-function args)
6093 (buffer-substring-no-properties (point-min) (point-max))
6094 (set-buffer (get-buffer-create gnus-original-article-buffer))
6096 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6097 (set-buffer gnus-article-buffer)
6098 (gnus-article-prepare-display)))
6099 (substitute-key-definition 'gnus-article-edit-done
6100 'gnus-article-mime-edit-done
6101 gnus-article-edit-mode-map)
6102 (substitute-key-definition 'gnus-article-edit-exit
6103 'gnus-article-mime-edit-exit
6104 gnus-article-edit-mode-map)
6106 (insert-buffer-substring gnus-original-article-buffer)
6107 (unless (member (with-current-buffer gnus-summary-buffer
6108 gnus-newsgroup-name)
6109 '("nndraft:delayed" "nndraft:drafts"))
6110 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6111 (fset 'mime-edit-decode-single-part-in-buffer
6112 (lambda (&rest args)
6113 (if (let ((content-type (car args)))
6114 (and (eq 'message (mime-content-type-primary-type
6116 (eq 'rfc822 (mime-content-type-subtype
6118 (setcar (cdr args) 'not-decode-text))
6122 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6123 (when (featurep 'font-lock)
6124 (set (make-local-variable 'font-lock-defaults)
6125 '(message-font-lock-keywords t))
6126 (font-lock-set-defaults)
6127 (turn-on-font-lock))
6128 (set-buffer-modified-p nil)
6129 (delete-other-windows)
6130 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6131 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6133 (defun gnus-article-mime-edit-done (&optional arg)
6134 "Update the article MIME edits and exit."
6136 (when (featurep 'font-lock)
6137 (setq font-lock-defaults nil)
6138 (font-lock-mode -1))
6139 (let ((inhibit-read-only t))
6140 (gnus-article-edit-done arg)))
6142 (defun gnus-article-mime-edit-exit ()
6143 "Exit the article MIME editing without updating."
6145 (when (or (not (buffer-modified-p))
6146 (yes-or-no-p "Article modified; kill anyway? "))
6147 (when (featurep 'font-lock)
6148 (setq font-lock-defaults nil)
6149 (font-lock-mode -1))
6150 (when mime-edit-mode-flag
6151 (let (mime-edit-insert-user-agent-field)
6154 (goto-char (point-min))
6155 (let (case-fold-search)
6156 (when (re-search-forward
6157 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6158 (replace-match "")))
6159 (let ((winconf gnus-prev-winconf))
6161 (buffer-substring-no-properties (point-min) (point-max))
6162 (set-buffer (get-buffer-create gnus-original-article-buffer))
6164 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6165 (set-buffer gnus-article-buffer)
6166 (gnus-article-prepare-display)
6167 (set-window-configuration winconf))))
6170 ;;; Article highlights
6173 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6175 ;;; Internal Variables:
6177 (defcustom gnus-button-url-regexp
6178 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6179 "\\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:]]\\)"
6180 "\\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\\)\\)")
6181 "Regular expression that matches URLs."
6182 :group 'gnus-article-buttons
6185 (defcustom gnus-button-valid-fqdn-regexp
6186 message-valid-fqdn-regexp
6187 "Regular expression that matches a valid FQDN."
6188 :group 'gnus-article-buttons
6191 (defcustom gnus-button-man-handler 'manual-entry
6192 "Function to use for displaying man pages.
6193 The function must take at least one argument with a string naming the
6195 :type '(choice (function-item :tag "Man" manual-entry)
6196 (function-item :tag "Woman" woman)
6197 (function :tag "Other"))
6198 :group 'gnus-article-buttons)
6200 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6201 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6202 If the default site is too slow, try to find a CTAN mirror, see
6203 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6204 the variable `gnus-button-handle-ctan'."
6205 :group 'gnus-article-buttons
6206 :link '(custom-manual "(gnus)Group Parameters")
6207 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6208 (const "http://tug.ctan.org/tex-archive/")
6209 (const "http://www.dante.de/CTAN/")
6210 (string :tag "Other")))
6212 (defcustom gnus-button-ctan-handler 'browse-url
6213 "Function to use for displaying CTAN links.
6214 The function must take one argument, the string naming the URL."
6215 :type '(choice (function-item :tag "Browse Url" browse-url)
6216 (function :tag "Other"))
6217 :group 'gnus-article-buttons)
6219 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6220 "Bogus strings removed from CTAN URLs."
6221 :group 'gnus-article-buttons
6222 :type '(choice (const "^/?tex-archive/\\|/")
6223 (regexp :tag "Other")))
6225 (defcustom gnus-button-ctan-directory-regexp
6227 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6228 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6229 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6230 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6232 "Regular expression for ctan directories.
6233 It should match all directories in the top level of `gnus-ctan-url'."
6234 :group 'gnus-article-buttons
6237 (defcustom gnus-button-mid-or-mail-regexp
6238 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6239 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6240 gnus-button-valid-fqdn-regexp
6242 "Regular expression that matches a message ID or a mail address."
6243 :group 'gnus-article-buttons
6246 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6247 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6248 Strings like this can be either a message ID or a mail address. If it is one
6249 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6250 message ID or a mail address, respectively. If this variable is set to the
6251 symbol `ask', always query the user what do do. If it is a function, this
6252 function will be called with the string as it's only argument. The function
6253 must return `mid', `mail', `invalid' or `ask'."
6254 :group 'gnus-article-buttons
6255 :type '(choice (function-item :tag "Heuristic function"
6256 gnus-button-mid-or-mail-heuristic)
6261 (defcustom gnus-button-mid-or-mail-heuristic-alist
6262 '((-10.0 . ".+\\$.+@")
6265 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6266 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6267 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6268 (-1.0 . "^[^a-z]+@")
6270 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6271 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6272 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6273 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6276 (-1.0 . "^[0-9][0-9]")
6278 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6279 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6280 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6281 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6283 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6284 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6287 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6289 ;; compensation for TDMA dated mail addresses:
6290 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6292 (-20.0 . "\\.fsf@") ;; Gnus
6295 (-20.0 . "_-_") ;; Subject change in thread
6297 (-20.0 . "\\.ln@") ;; leafnode
6298 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6299 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6301 ;; (5.0 . "") ;; $local_part_len <= 7
6302 (10.0 . "^[^0-9]+@")
6303 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6304 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6307 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6309 (0.5 . "^[A-Z][a-z]")
6310 (0.5 . "^[A-Z][a-z][a-z]")
6311 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6312 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6313 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6315 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6316 address. The REGEXP is processed with `case-fold-search' set to nil."
6317 :group 'gnus-article-buttons
6318 :type '(repeat (cons (number :tag "Rate")
6319 (regexp :tag "Regexp"))))
6321 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6322 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6323 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6324 address, `ask' if unsure and `invalid' if the string is invalid."
6325 (let ((case-fold-search nil)
6326 (list gnus-button-mid-or-mail-heuristic-alist)
6327 (result 0) rate regexp lpartlen elem)
6329 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6330 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6331 ;; Certain special cases...
6334 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6335 "^[0-9]+\\.[0-9]+@compuserve\\|"
6336 "@public\\.gmane\\.org")
6338 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6339 (setq result 'mail))
6340 (when (string-match "@.*@\\| " mid-or-mail)
6341 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6342 (setq result 'invalid))
6343 ;; Nothing more to do, if result is not a number here...
6344 (when (numberp result)
6346 (setq elem (car list)
6350 (when (string-match regexp mid-or-mail)
6351 (setq result (+ result rate))
6353 9 "`%s' matched `%s', rate `%s', result `%s'."
6354 mid-or-mail regexp rate result)))
6355 (when (<= lpartlen 7)
6356 (setq result (+ result 5.0))
6357 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6358 mid-or-mail result))
6359 (when (>= lpartlen 12)
6360 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6362 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6363 ;; Long local part should contain realname if e-mail address,
6364 ;; too many digits: message-id.
6365 ;; $score -= 5.0 + 0.1 * $local_part_len;
6366 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6367 (setq result (+ result rate))
6369 9 "Many digits in `%s', rate `%s', result `%s'."
6370 mid-or-mail rate result))
6371 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6373 ;; Too few vowels [^aeiouy]{4,}.*\@
6374 (setq result (+ result -5.0))
6376 9 "Few vowels in `%s', rate `%s', result `%s'."
6377 mid-or-mail -5.0 result))
6379 (setq result (+ result 5.0))
6381 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6382 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6383 ;; Maybe we should make this a customizable alist: (condition . 'result)
6385 ((symbolp result) result)
6386 ;; Now convert number into proper results:
6387 ((< result -10.0) 'mid)
6388 ((> result 10.0) 'mail)
6391 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6392 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6393 (url-mid (concat "news" ":" mid-or-mail))
6394 (url-mailto (concat "mailto" ":" mid-or-mail)))
6395 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6396 (when (fboundp pref)
6398 ;; get rid of surrounding angles...
6400 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6401 (if (or (eq 'mid guessed) (eq 'mail guessed))
6405 (save-window-excursion
6406 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6409 (cond ((eq pref 'mid)
6410 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6411 (gnus-button-handle-news url-mid))
6413 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6414 (gnus-url-mailto url-mailto))
6415 (t (gnus-message 3 "Invalid string.")))))
6417 (defun gnus-button-handle-custom (url)
6418 "Follow a Custom URL."
6419 (customize-apropos (gnus-url-unhex-string url)))
6421 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6423 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6426 (defun gnus-button-handle-describe-function (url)
6427 "Call `describe-function' when pushing the corresponding URL button."
6430 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6432 (defun gnus-button-handle-describe-variable (url)
6433 "Call `describe-variable' when pushing the corresponding URL button."
6436 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6438 (defun gnus-button-handle-symbol (url)
6439 "Display help on variable or function.
6440 Calls `describe-variable' or `describe-function'."
6441 (let ((sym (intern url)))
6443 ((fboundp sym) (describe-function sym))
6444 ((boundp sym) (describe-variable sym))
6445 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6447 (defun gnus-button-handle-describe-key (url)
6448 "Call `describe-key' when pushing the corresponding URL button."
6450 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6451 (keys (ignore-errors (eval `(kbd ,key-string)))))
6454 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6456 (defun gnus-button-handle-apropos (url)
6457 "Call `apropos' when pushing the corresponding URL button."
6458 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6460 (defun gnus-button-handle-apropos-command (url)
6461 "Call `apropos' when pushing the corresponding URL button."
6463 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6465 (defun gnus-button-handle-apropos-variable (url)
6466 "Call `apropos' when pushing the corresponding URL button."
6468 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6469 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6471 (defun gnus-button-handle-apropos-documentation (url)
6472 "Call `apropos' when pushing the corresponding URL button."
6474 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6475 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6477 (defun gnus-button-handle-library (url)
6478 "Call `locate-library' when pushing the corresponding URL button."
6479 (gnus-message 9 "url=`%s'" url)
6480 (let* ((lib (locate-library url))
6481 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6483 (gnus-message 1 "Cannot locale library `%s'." url)
6484 (find-file-read-only file))))
6486 (defun gnus-button-handle-ctan (url)
6487 "Call `browse-url' when pushing a CTAN URL button."
6489 gnus-button-ctan-handler
6492 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6494 (defcustom gnus-button-tex-level 5
6495 "*Integer that says how many TeX-related buttons Gnus will show.
6496 The higher the number, the more buttons will appear and the more false
6497 positives are possible. Note that you can set this variable local to
6498 specific groups. Setting it higher in TeX groups is probably a good idea.
6499 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6500 how to set variables in specific groups."
6501 :group 'gnus-article-buttons
6502 :link '(custom-manual "(gnus)Group Parameters")
6505 (defcustom gnus-button-man-level 5
6506 "*Integer that says how many man-related buttons Gnus will show.
6507 The higher the number, the more buttons will appear and the more false
6508 positives are possible. Note that you can set this variable local to
6509 specific groups. Setting it higher in Unix groups is probably a good idea.
6510 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6511 how to set variables in specific groups."
6512 :group 'gnus-article-buttons
6513 :link '(custom-manual "(gnus)Group Parameters")
6516 (defcustom gnus-button-emacs-level 5
6517 "*Integer that says how many emacs-related buttons Gnus will show.
6518 The higher the number, the more buttons will appear and the more false
6519 positives are possible. Note that you can set this variable local to
6520 specific groups. Setting it higher in Emacs or Gnus related groups is
6521 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6522 `gnus-parameters' on how to set variables in specific groups."
6523 :group 'gnus-article-buttons
6524 :link '(custom-manual "(gnus)Group Parameters")
6527 (defcustom gnus-button-message-level 5
6528 "*Integer that says how many buttons for news or mail messages will appear.
6529 The higher the number, the more buttons will appear and the more false
6530 positives are possible."
6531 ;; mail addresses, MIDs, URLs for news, ...
6532 :group 'gnus-article-buttons
6535 (defcustom gnus-button-browse-level 5
6536 "*Integer that says how many buttons for browsing will appear.
6537 The higher the number, the more buttons will appear and the more false
6538 positives are possible."
6539 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6540 :group 'gnus-article-buttons
6543 (defcustom gnus-button-alist
6544 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6545 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6546 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6547 gnus-button-handle-news 2)
6548 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6549 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6550 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6551 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6552 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6553 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6554 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6555 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6556 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6557 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6558 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6559 ;; RFC 2368 (The mailto URL scheme)
6560 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6561 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6562 ("\\bmailto:\\([^ \n\t]+\\)"
6563 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6565 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6566 gnus-button-ctan-directory-regexp
6567 "[^][>)!;:,'\n\t ]+\\)")
6568 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6569 ((concat "\\btex-archive/\\("
6570 gnus-button-ctan-directory-regexp
6571 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6572 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6575 gnus-button-ctan-directory-regexp
6576 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6577 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6578 ;; This is info (home-grown style) <info://foo/bar+baz>
6579 ("\\binfo://\\([^'\">\n\t ]+\\)"
6580 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6581 ;; Info GNOME style <info:foo#bar_baz>
6582 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6583 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6584 ;; Info KDE style <info:(foo)bar baz>
6585 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6586 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6587 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6588 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6589 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6590 ;; Info links like `C-h i d m CC Mode RET'
6591 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6593 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6594 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6595 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6596 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6597 ;; Emacs help commands
6598 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6599 ;; regexp doesn't match arguments containing ` '.
6600 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6601 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6602 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6603 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6604 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6605 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6606 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6607 ;; The following entries may lead to many false positives so don't enable
6608 ;; them by default (use a high button level):
6609 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6610 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6611 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6612 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6613 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6614 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6615 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6616 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6617 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6618 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6619 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6620 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6621 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6623 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6624 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6625 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6626 ;; Unlike the other regexps we really have to require quoting
6627 ;; here to determine where it ends.
6628 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6629 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6630 ("<URL: *\\([^<>]*\\)>"
6631 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6632 ;; RFC 2396 (2.4.3., delims) ...
6633 ("\"URL: *\\([^\"]*\\)\""
6634 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6635 ;; RFC 2396 (2.4.3., delims) ...
6636 ("\"URL: *\\([^\"]*\\)\""
6637 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6639 (gnus-button-url-regexp
6640 0 (>= gnus-button-browse-level 0) browse-url 0)
6642 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6643 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6644 gnus-button-handle-man 1)
6645 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6646 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6647 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6648 gnus-button-handle-man 1)
6649 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6650 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6651 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6652 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6653 ;; MID or mail: To avoid too many false positives we don't try to catch
6654 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6655 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6656 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6657 ;; so that non-ambiguous entries (see above) match first.
6658 (gnus-button-mid-or-mail-regexp
6659 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6660 "*Alist of regexps matching buttons in article bodies.
6662 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6663 REGEXP: is the string (case insensitive) matching text around the button (can
6664 also be Lisp expression evaluating to a string),
6665 BUTTON: is the number of the regexp grouping actually matching the button,
6666 FORM: is a Lisp expression which must eval to true for the button to
6668 CALLBACK: is the function to call when the user push this button, and each
6669 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6671 CALLBACK can also be a variable, in that case the value of that
6672 variable it the real callback function."
6673 :group 'gnus-article-buttons
6674 :type '(repeat (list (choice regexp variable sexp)
6675 (integer :tag "Button")
6677 (function :tag "Callback")
6680 (integer :tag "Regexp group")))))
6682 (defcustom gnus-header-button-alist
6683 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6684 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6685 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6686 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6687 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6688 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6689 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6690 0 (>= gnus-button-browse-level 0) browse-url 0)
6691 ("^Subject:" gnus-button-url-regexp
6692 0 (>= gnus-button-browse-level 0) browse-url 0)
6693 ("^[^:]+:" gnus-button-url-regexp
6694 0 (>= gnus-button-browse-level 0) browse-url 0)
6695 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6696 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6697 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6698 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6699 "*Alist of headers and regexps to match buttons in article heads.
6701 This alist is very similar to `gnus-button-alist', except that each
6702 alist has an additional HEADER element first in each entry:
6704 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6706 HEADER is a regexp to match a header. For a fuller explanation, see
6707 `gnus-button-alist'."
6708 :group 'gnus-article-buttons
6709 :group 'gnus-article-headers
6710 :type '(repeat (list (regexp :tag "Header")
6711 (choice regexp variable)
6712 (integer :tag "Button")
6714 (function :tag "Callback")
6717 (integer :tag "Regexp group")))))
6719 (defvar gnus-button-regexp nil)
6720 (defvar gnus-button-marker-list nil)
6721 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6723 (defvar gnus-button-last nil)
6724 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6728 (defun gnus-article-push-button (event)
6729 "Check text under the mouse pointer for a callback function.
6730 If the text under the mouse pointer has a `gnus-callback' property,
6731 call it with the value of the `gnus-data' text property."
6733 (set-buffer (window-buffer (posn-window (event-start event))))
6734 (let* ((pos (posn-point (event-start event)))
6735 (data (get-text-property pos 'gnus-data))
6736 (fun (get-text-property pos 'gnus-callback)))
6739 (funcall fun data))))
6741 (defun gnus-article-press-button ()
6742 "Check text at point for a callback function.
6743 If the text at point has a `gnus-callback' property,
6744 call it with the value of the `gnus-data' text property."
6746 (let ((data (get-text-property (point) 'gnus-data))
6747 (fun (get-text-property (point) 'gnus-callback)))
6749 (funcall fun data))))
6751 (defun gnus-article-prev-button (n)
6752 "Move point to N buttons backward.
6753 If N is negative, move forward instead."
6755 (gnus-article-next-button (- n)))
6757 (defun gnus-article-next-button (n)
6758 "Move point to N buttons forward.
6759 If N is negative, move backward instead."
6761 (let ((function (if (< n 0) 'previous-single-property-change
6762 'next-single-property-change))
6763 (inhibit-point-motion-hooks t)
6765 (limit (if (< n 0) (point-min) (point-max))))
6767 (while (and (not (= limit (point)))
6769 ;; Skip past the current button.
6770 (when (get-text-property (point) 'gnus-callback)
6771 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6772 ;; Go to the next (or previous) button.
6773 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6774 ;; Put point at the start of the button.
6775 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6776 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6777 ;; Skip past intangible buttons.
6778 (when (get-text-property (point) 'intangible)
6782 (gnus-message 5 "No more buttons"))
6785 (defun gnus-article-highlight (&optional force)
6786 "Highlight current article.
6787 This function calls `gnus-article-highlight-headers',
6788 `gnus-article-highlight-citation',
6789 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6790 do the highlighting. See the documentation for those functions."
6791 (interactive (list 'force))
6792 (gnus-article-highlight-headers)
6793 (gnus-article-highlight-citation force)
6794 (gnus-article-highlight-signature)
6795 (gnus-article-add-buttons force)
6796 (gnus-article-add-buttons-to-head))
6798 (defun gnus-article-highlight-some (&optional force)
6799 "Highlight current article.
6800 This function calls `gnus-article-highlight-headers',
6801 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6802 do the highlighting. See the documentation for those functions."
6803 (interactive (list 'force))
6804 (gnus-article-highlight-headers)
6805 (gnus-article-highlight-signature)
6806 (gnus-article-add-buttons))
6808 (defun gnus-article-highlight-headers ()
6809 "Highlight article headers as specified by `gnus-header-face-alist'."
6812 (set-buffer gnus-article-buffer)
6814 (let ((alist gnus-header-face-alist)
6815 (buffer-read-only nil)
6816 (case-fold-search t)
6817 (inhibit-point-motion-hooks t)
6818 entry regexp header-face field-face from hpoints fpoints)
6819 (article-narrow-to-head)
6820 (while (setq entry (pop alist))
6821 (goto-char (point-min))
6822 (setq regexp (concat "^\\("
6823 (if (string-equal "" (nth 0 entry))
6827 header-face (nth 1 entry)
6828 field-face (nth 2 entry))
6829 (while (and (re-search-forward regexp nil t)
6833 (unless (search-forward ":" nil t)
6835 (when (and header-face
6836 (not (memq (point) hpoints)))
6837 (push (point) hpoints)
6838 (gnus-put-text-property from (point) 'face header-face))
6839 (when (and field-face
6840 (not (memq (setq from (point)) fpoints)))
6842 (if (re-search-forward "^[^ \t]" nil t)
6844 (goto-char (point-max)))
6845 (gnus-put-text-property from (point) 'face field-face))))))))
6847 (defun gnus-article-highlight-signature ()
6848 "Highlight the signature in an article.
6849 It does this by highlighting everything after
6850 `gnus-signature-separator' using `gnus-signature-face'."
6852 (when gnus-signature-face
6854 (set-buffer gnus-article-buffer)
6855 (let ((buffer-read-only nil)
6856 (inhibit-point-motion-hooks t))
6858 (when (gnus-article-narrow-to-signature)
6859 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6860 'face gnus-signature-face)))))))
6862 (defun gnus-article-buttonize-signature ()
6863 "Add button to the signature."
6866 (set-buffer gnus-article-buffer)
6867 (let ((buffer-read-only nil)
6868 (inhibit-point-motion-hooks t))
6869 (when (gnus-article-search-signature)
6870 (gnus-article-add-button (match-beginning 0) (match-end 0)
6871 'gnus-signature-toggle
6872 (set-marker (make-marker)
6873 (1+ (match-end 0))))))))
6875 (defun gnus-button-in-region-p (b e prop)
6876 "Say whether PROP exists in the region."
6877 (text-property-not-all b e prop nil))
6879 (defun gnus-article-add-buttons (&optional force)
6880 "Find external references in the article and make buttons of them.
6881 \"External references\" are things like Message-IDs and URLs, as
6882 specified by `gnus-button-alist'."
6883 (interactive (list 'force))
6885 (set-buffer gnus-article-buffer)
6886 (let ((buffer-read-only nil)
6887 (inhibit-point-motion-hooks t)
6888 (case-fold-search t)
6889 (alist gnus-button-alist)
6891 ;; Remove all old markers.
6892 (let (marker entry new-list)
6893 (while (setq marker (pop gnus-button-marker-list))
6894 (if (or (< marker (point-min)) (>= marker (point-max)))
6895 (push marker new-list)
6897 (when (setq entry (gnus-button-entry))
6898 (put-text-property (match-beginning (nth 1 entry))
6899 (match-end (nth 1 entry))
6900 'gnus-callback nil))
6901 (set-marker marker nil)))
6902 (setq gnus-button-marker-list new-list))
6903 ;; We skip the headers.
6906 (while (setq entry (pop alist))
6907 (setq regexp (eval (car entry)))
6909 (while (re-search-forward regexp nil t)
6910 (let* ((start (and entry (match-beginning (nth 1 entry))))
6911 (end (and entry (match-end (nth 1 entry))))
6912 (from (match-beginning 0)))
6913 (when (and (or (eq t (nth 2 entry))
6914 (eval (nth 2 entry)))
6915 (not (gnus-button-in-region-p
6916 start end 'gnus-callback)))
6917 ;; That optional form returned non-nil, so we add the
6919 (gnus-article-add-button
6920 start end 'gnus-button-push
6921 (car (push (set-marker (make-marker) from)
6922 gnus-button-marker-list))))))))))
6924 ;; Add buttons to the head of an article.
6925 (defun gnus-article-add-buttons-to-head ()
6926 "Add buttons to the head of the article."
6929 (set-buffer gnus-article-buffer)
6931 (let ((buffer-read-only nil)
6932 (inhibit-point-motion-hooks t)
6933 (case-fold-search t)
6934 (alist gnus-header-button-alist)
6936 (article-narrow-to-head)
6938 ;; Each alist entry.
6939 (setq entry (car alist)
6941 (goto-char (point-min))
6942 (while (re-search-forward (car entry) nil t)
6943 ;; Each header matching the entry.
6944 (setq beg (match-beginning 0))
6945 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6946 (match-beginning 0))
6949 (while (re-search-forward (eval (nth 1 entry)) end t)
6950 ;; Each match within a header.
6951 (let* ((entry (cdr entry))
6952 (start (match-beginning (nth 1 entry)))
6953 (end (match-end (nth 1 entry)))
6954 (form (nth 2 entry)))
6955 (goto-char (match-end 0))
6957 (gnus-article-add-button
6958 start end (nth 3 entry)
6959 (buffer-substring (match-beginning (nth 4 entry))
6960 (match-end (nth 4 entry)))))))
6961 (goto-char end)))))))
6963 ;;; External functions:
6965 (defun gnus-article-add-button (from to fun &optional data)
6966 "Create a button between FROM and TO with callback FUN and data DATA."
6967 (when gnus-article-button-face
6968 (gnus-overlay-put (gnus-make-overlay from to)
6969 'face gnus-article-button-face))
6970 (gnus-add-text-properties
6972 (nconc (and gnus-article-mouse-face
6973 (list gnus-mouse-face-prop gnus-article-mouse-face))
6974 (list 'gnus-callback fun)
6975 (and data (list 'gnus-data data))))
6976 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6977 ;; Quote `:button-keymap' for Mule 2.3
6978 ;; but it won't work.
6979 ':button-keymap gnus-widget-button-keymap))
6981 ;;; Internal functions:
6983 (defun gnus-article-set-globals ()
6985 (set-buffer gnus-summary-buffer)
6986 (gnus-set-global-variables)))
6988 (defun gnus-signature-toggle (end)
6990 (set-buffer gnus-article-buffer)
6991 (let ((buffer-read-only nil)
6992 (inhibit-point-motion-hooks t)
6993 (limit (next-single-property-change end 'mime-view-entity
6995 (if (text-property-any end limit 'article-type 'signature)
6997 (gnus-delete-wash-type 'signature)
6998 (gnus-remove-text-properties-when
6999 'article-type 'signature end limit
7000 (cons 'article-type (cons 'signature
7001 gnus-hidden-properties))))
7002 (gnus-add-wash-type 'signature)
7003 (gnus-add-text-properties-when
7004 'article-type nil end limit
7005 (cons 'article-type (cons 'signature
7006 gnus-hidden-properties)))))
7007 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7008 (gnus-set-mode-line 'article))))
7010 (defun gnus-button-entry ()
7011 ;; Return the first entry in `gnus-button-alist' matching this place.
7012 (let ((alist gnus-button-alist)
7015 (setq entry (pop alist))
7016 (if (looking-at (eval (car entry)))
7021 (defun gnus-button-push (marker)
7022 ;; Push button starting at MARKER.
7025 (let* ((entry (gnus-button-entry))
7026 (inhibit-point-motion-hooks t)
7028 (args (mapcar (lambda (group)
7029 (let ((string (match-string group)))
7030 (gnus-set-text-properties
7031 0 (length string) nil string)
7038 (fboundp (symbol-value fun)))
7039 (apply (symbol-value fun) args))
7041 (gnus-message 1 "You must define `%S' to use this button"
7042 (cons fun args)))))))
7044 (defun gnus-parse-news-url (url)
7045 (let (scheme server group message-id articles)
7048 (goto-char (point-min))
7049 (when (looking-at "\\([A-Za-z]+\\):")
7050 (setq scheme (match-string 1))
7051 (goto-char (match-end 0)))
7052 (when (looking-at "//\\([^/]+\\)/")
7053 (setq server (match-string 1))
7054 (goto-char (match-end 0)))
7057 ((looking-at "\\(.*@.*\\)")
7058 (setq message-id (match-string 1)))
7059 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7060 (setq group (match-string 1)
7061 articles (split-string (match-string 2) "-")))
7062 ((looking-at "\\([^/]+\\)/?")
7063 (setq group (match-string 1)))
7065 (error "Unknown news URL syntax"))))
7066 (list scheme server group message-id articles)))
7068 (defun gnus-button-handle-news (url)
7070 (destructuring-bind (scheme server group message-id articles)
7071 (gnus-parse-news-url url)
7075 (set-buffer gnus-summary-buffer)
7077 (let ((gnus-refer-article-method (list (list 'nntp server))))
7078 (gnus-summary-refer-article message-id))
7079 (gnus-summary-refer-article message-id))))
7081 (gnus-button-fetch-group url)))))
7083 (defun gnus-button-handle-man (url)
7085 (funcall gnus-button-man-handler url))
7087 (defun gnus-button-handle-info-url (url)
7088 "Fetch an info URL."
7089 (setq url (mm-subst-char-in-string ?+ ?\ url))
7091 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7092 (gnus-info-find-node
7093 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7095 ")" (gnus-url-unhex-string (match-string 2 url)))))
7096 ((string-match "([^)\"]+)[^\"]+" url)
7098 (gnus-replace-in-string
7099 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7100 (gnus-info-find-node url))
7101 (t (error "Can't parse %s" url))))
7103 (defun gnus-button-handle-info-url-gnome (url)
7104 "Fetch GNOME style info URL."
7105 (setq url (mm-subst-char-in-string ?_ ?\ url))
7106 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7107 (gnus-info-find-node
7109 (gnus-url-unhex-string
7110 (match-string 1 url))
7112 (or (gnus-url-unhex-string
7113 (match-string 2 url))
7115 (error "Can't parse %s" url)))
7117 (defun gnus-button-handle-info-url-kde (url)
7118 "Fetch KDE style info URL."
7119 (gnus-info-find-node (gnus-url-unhex-string url)))
7121 (defun gnus-button-handle-info-keystrokes (url)
7122 "Call `info' when pushing the corresponding URL button."
7123 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7128 (defun gnus-button-message-id (message-id)
7131 (set-buffer gnus-summary-buffer)
7132 (gnus-summary-refer-article message-id)))
7134 (defun gnus-button-fetch-group (address)
7135 "Fetch GROUP specified by ADDRESS."
7136 (if (not (string-match "[:/]" address))
7137 ;; This is just a simple group url.
7138 (gnus-group-read-ephemeral-group address gnus-select-method)
7141 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7143 (error "Can't parse %s" address)
7144 (gnus-group-read-ephemeral-group
7145 (match-string 4 address)
7146 `(nntp ,(match-string 1 address)
7147 (nntp-address ,(match-string 1 address))
7148 (nntp-port-number ,(if (match-end 3)
7149 (match-string 3 address)
7152 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7154 (defun gnus-url-parse-query-string (query &optional downcase)
7155 (let (retval pairs cur key val)
7156 (setq pairs (split-string query "&"))
7158 (setq cur (car pairs)
7160 (if (not (string-match "=" cur))
7162 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7163 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7165 (setq key (downcase key)))
7166 (setq cur (assoc key retval))
7168 (setcdr cur (cons val (cdr cur)))
7169 (setq retval (cons (list key val) retval)))))
7172 (defun gnus-url-mailto (url)
7173 ;; Send mail to someone
7174 (when (string-match "mailto:/*\\(.*\\)" url)
7175 (setq url (substring url (match-beginning 1) nil)))
7176 (let (to args subject func)
7177 (setq args (gnus-url-parse-query-string
7178 (if (string-match "^\\?" url)
7180 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7181 (concat "to=" (match-string 1 url) "&"
7182 (match-string 2 url))
7183 (concat "to=" url)))
7185 subject (cdr-safe (assoc "subject" args)))
7188 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7191 (message-position-on-field (caar args)))
7192 (insert (gnus-replace-in-string
7193 (mapconcat 'identity (reverse (cdar args)) ", ")
7195 (setq args (cdr args)))
7198 (message-goto-subject))))
7200 (defun gnus-button-embedded-url (address)
7201 "Activate ADDRESS with `browse-url'."
7202 (browse-url (gnus-strip-whitespace address)))
7204 ;;; Next/prev buttons in the article buffer.
7206 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7207 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7209 (defvar gnus-prev-page-map
7210 (let ((map (make-sparse-keymap)))
7211 (unless (>= emacs-major-version 21)
7212 ;; XEmacs doesn't care.
7213 (set-keymap-parent map gnus-article-mode-map))
7214 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7215 (define-key map "\r" 'gnus-button-prev-page)
7218 (defun gnus-insert-prev-page-button ()
7220 (buffer-read-only nil)
7221 (situation (get-text-property (point-min) 'mime-view-situation)))
7223 gnus-prev-page-line-format nil
7224 `(,@(gnus-local-map-property gnus-prev-page-map)
7226 gnus-callback gnus-article-button-prev-page
7227 article-type annotation
7228 mime-view-situation ,situation))
7229 (widget-convert-button
7231 ;; Exclude a newline.
7234 :action 'gnus-button-prev-page
7235 :button-keymap gnus-prev-page-map)))
7237 (defvar gnus-next-page-map
7238 (let ((map (make-sparse-keymap)))
7239 (unless (>= emacs-major-version 21)
7240 ;; XEmacs doesn't care.
7241 (set-keymap-parent map gnus-article-mode-map))
7242 (define-key map gnus-mouse-2 'gnus-button-next-page)
7243 (define-key map "\r" 'gnus-button-next-page)
7246 (defun gnus-button-next-page (&optional args more-args)
7247 "Go to the next page."
7249 (let ((win (selected-window)))
7250 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7251 (gnus-article-next-page)
7252 (select-window win)))
7254 (defun gnus-button-prev-page (&optional args more-args)
7255 "Go to the prev page."
7257 (let ((win (selected-window)))
7258 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7259 (gnus-article-prev-page)
7260 (select-window win)))
7262 (defun gnus-insert-next-page-button ()
7264 (buffer-read-only nil)
7265 (situation (get-text-property (point-min) 'mime-view-situation)))
7266 (gnus-eval-format gnus-next-page-line-format nil
7267 `(,@(gnus-local-map-property gnus-next-page-map)
7269 gnus-callback gnus-article-button-next-page
7270 article-type annotation
7271 mime-view-situation ,situation))
7272 (widget-convert-button
7274 ;; Exclude a newline.
7277 :action 'gnus-button-next-page
7278 :button-keymap gnus-next-page-map)))
7280 (defun gnus-article-button-next-page (arg)
7281 "Go to the next page."
7283 (let ((win (selected-window)))
7284 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7285 (gnus-article-next-page)
7286 (select-window win)))
7288 (defun gnus-article-button-prev-page (arg)
7289 "Go to the prev page."
7291 (let ((win (selected-window)))
7292 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7293 (gnus-article-prev-page)
7294 (select-window win)))
7296 (defvar gnus-decode-header-methods
7297 '(mail-decode-encoded-word-region)
7298 "List of methods used to decode headers.
7300 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7301 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7302 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7303 whose names match REGEXP.
7306 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7307 mail-decode-encoded-word-region
7308 (\"chinese\" . rfc1843-decode-region))
7311 (defvar gnus-decode-header-methods-cache nil)
7313 (defun gnus-multi-decode-header (start end)
7314 "Apply the functions from `gnus-encoded-word-methods' that match."
7315 (unless (and gnus-decode-header-methods-cache
7316 (eq gnus-newsgroup-name
7317 (car gnus-decode-header-methods-cache)))
7318 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7321 (nconc gnus-decode-header-methods-cache (list x))
7322 (if (and gnus-newsgroup-name
7323 (string-match (car x) gnus-newsgroup-name))
7324 (nconc gnus-decode-header-methods-cache
7326 gnus-decode-header-methods))
7327 (let ((xlist gnus-decode-header-methods-cache))
7330 (narrow-to-region start end)
7332 (funcall (pop xlist) (point-min) (point-max))))))
7335 ;;; Treatment top-level handling.
7338 (defun gnus-treat-article (condition &optional part-number total-parts type)
7339 (let ((length (- (point-max) (point-min)))
7340 (alist gnus-treatment-function-alist)
7341 (article-goto-body-goes-to-point-min-p t)
7345 (let ((list gnus-article-treat-types))
7347 (when (string-match (pop list) type)
7348 (throw 'found t)))))))
7349 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7350 (entity (static-unless (featurep 'xemacs)
7351 (when (eq 'head condition)
7352 (get-text-property (point-min) 'mime-view-entity))))
7353 val elem buttonized)
7354 (gnus-run-hooks 'gnus-part-display-hook)
7355 (unless gnus-inhibit-treatment
7356 (dolist (elem alist)
7359 (when (gnus-buffer-live-p gnus-summary-buffer)
7360 (set-buffer gnus-summary-buffer))
7361 (symbol-value (car elem))))
7362 (when (and (or (consp val)
7364 (gnus-treat-predicate val)
7365 (or (not (get (car elem) 'highlight))
7367 (when (and (not buttonized)
7369 '(gnus-treat-hide-signature
7370 gnus-treat-highlight-signature)))
7371 (gnus-article-buttonize-signature)
7372 (setq buttonized t))
7374 (funcall (cadr elem)))))
7375 ;; FSF Emacsen does not inherit the existing text properties
7376 ;; in the new text, so we should do it for `mime-view-entity'.
7377 (static-unless (featurep 'xemacs)
7379 (put-text-property (point-min) (point-max)
7380 'mime-view-entity entity))))))
7382 ;; Dynamic variables.
7384 (defvar part-number)
7385 (defvar total-parts)
7390 (defun gnus-treat-predicate (val)
7395 (stringp (car val)))
7396 (apply 'gnus-or (mapcar `(lambda (s)
7397 (string-match s ,(or gnus-newsgroup-name "")))
7400 (let ((pred (pop val)))
7403 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7405 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7407 (not (gnus-treat-predicate (car val))))
7409 (equal (car val) type))
7411 (error "%S is not a valid predicate" pred)))))
7421 (eq part-number total-parts))
7425 (error "%S is not a valid value" val))))
7427 (defun gnus-article-encrypt-body (protocol &optional n)
7428 "Encrypt the article body."
7431 (or gnus-article-encrypt-protocol
7432 (completing-read "Encrypt protocol: "
7433 gnus-article-encrypt-protocol-alist
7435 current-prefix-arg))
7436 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7438 (error (format "Can't find the encrypt protocol %s" protocol)))
7439 (if (member gnus-newsgroup-name '("nndraft:delayed"
7442 (error "Can't encrypt the article in group %s"
7443 gnus-newsgroup-name))
7444 (gnus-summary-iterate n
7446 (set-buffer gnus-summary-buffer)
7447 (let ((mail-parse-charset gnus-newsgroup-charset)
7448 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7449 (summary-buffer gnus-summary-buffer)
7451 (gnus-set-global-variables)
7452 (when (gnus-group-read-only-p)
7453 (error "The current newsgroup does not support article encrypt"))
7454 (gnus-summary-show-article t)
7456 (or (mail-header-references gnus-current-headers) ""))
7457 (set-buffer gnus-article-buffer)
7458 (let* ((buffer-read-only nil)
7460 (mapcar (lambda (field)
7461 (and (save-restriction
7462 (message-narrow-to-head)
7463 (goto-char (point-min))
7464 (search-forward field nil t))
7466 (message-narrow-to-field)
7468 (delete-region (point-min) (point-max))
7470 '("Content-Type:" "Content-Transfer-Encoding:"
7471 "Content-Disposition:"))))
7472 (message-narrow-to-head)
7473 (message-remove-header "MIME-Version")
7474 (goto-char (point-max))
7475 (setq point (point))
7476 (insert (apply 'concat headers))
7478 (narrow-to-region point (point-max))
7479 (let ((message-options message-options))
7480 (message-options-set 'message-sender user-mail-address)
7481 (message-options-set 'message-recipients user-mail-address)
7482 (message-options-set 'message-sign-encrypt 'not)
7484 (goto-char (point-min))
7485 (insert "MIME-Version: 1.0\n")
7487 (gnus-summary-edit-article-done
7488 references nil summary-buffer t))
7489 (when gnus-keep-backlog
7490 (gnus-backlog-remove-article
7491 (car gnus-article-current) (cdr gnus-article-current)))
7493 (when (get-buffer gnus-original-article-buffer)
7494 (set-buffer gnus-original-article-buffer)
7495 (setq gnus-original-article nil)))
7496 (when gnus-use-cache
7497 (gnus-cache-update-article
7498 (car gnus-article-current) (cdr gnus-article-current))))))))
7500 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7501 "The following specs can be used:
7502 %t The security MIME type
7505 %D Details if button is pressed")
7507 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7508 "The following specs can be used:
7509 %t The security MIME type
7512 %D Details if button is pressed")
7514 (defvar gnus-mime-security-button-line-format-alist
7515 '((?t gnus-tmp-type ?s)
7516 (?i gnus-tmp-info ?s)
7517 (?d gnus-tmp-details ?s)
7518 (?D gnus-tmp-pressed-details ?s)))
7520 (defvar gnus-mime-security-button-map
7521 (let ((map (make-sparse-keymap)))
7522 (unless (>= (string-to-number emacs-version) 21)
7523 (set-keymap-parent map gnus-article-mode-map))
7524 (define-key map gnus-mouse-2 'gnus-article-push-button)
7525 (define-key map "\r" 'gnus-article-press-button)
7528 (defvar gnus-mime-security-details-buffer nil)
7530 (defvar gnus-mime-security-button-pressed nil)
7532 (defvar gnus-mime-security-show-details-inline t
7533 "If non-nil, show details in the article buffer.")
7535 (defun gnus-mime-security-verify-or-decrypt (handle)
7536 (mm-remove-parts (cdr handle))
7537 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7538 point buffer-read-only)
7540 (goto-char (car region)))
7542 (narrow-to-region (point) (point))
7543 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7544 (let* ((mm-verify-option 'known)
7545 (mm-decrypt-option 'known)
7546 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7547 (unless (eq nparts (cdr handle))
7548 (mm-destroy-parts (cdr handle))
7549 (setcdr handle nparts))))
7550 (setq point (point))
7551 (gnus-mime-display-security handle)
7552 (goto-char (point-max)))
7554 (delete-region (point) (cdr region))
7555 (set-marker (car region) nil)
7556 (set-marker (cdr region) nil))
7559 (defun gnus-mime-security-show-details (handle)
7560 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7562 (gnus-message 5 "No details.")
7563 (if gnus-mime-security-show-details-inline
7564 (let ((gnus-mime-security-button-pressed
7565 (not (get-text-property (point) 'gnus-mime-details)))
7566 (gnus-mime-security-button-line-format
7567 (get-text-property (point) 'gnus-line-format))
7570 (while (eq (get-text-property (point) 'gnus-line-format)
7571 gnus-mime-security-button-line-format)
7575 (narrow-to-region (point) (point))
7576 (gnus-insert-mime-security-button handle))
7577 (delete-region (point)
7578 (or (text-property-not-all
7581 gnus-mime-security-button-line-format)
7584 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7585 (with-current-buffer gnus-mime-security-details-buffer
7588 (setq gnus-mime-security-details-buffer
7589 (gnus-get-buffer-create "*MIME Security Details*")))
7590 (with-current-buffer gnus-mime-security-details-buffer
7592 (goto-char (point-min)))
7593 (pop-to-buffer gnus-mime-security-details-buffer)))))
7595 (defun gnus-mime-security-press-button (handle)
7597 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7598 (gnus-mime-security-show-details handle)
7599 (gnus-mime-security-verify-or-decrypt handle))))
7601 (defun gnus-insert-mime-security-button (handle &optional displayed)
7602 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7605 (or (nth 2 (assoc protocol mm-verify-function-alist))
7606 (nth 2 (assoc protocol mm-decrypt-function-alist))
7608 (if (equal (car handle) "multipart/signed")
7609 " Signed" " Encrypted")
7612 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7615 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7616 gnus-tmp-pressed-details
7618 (setq gnus-tmp-details
7619 (if gnus-tmp-details
7620 (concat "\n" gnus-tmp-details)
7622 (setq gnus-tmp-pressed-details
7623 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7628 gnus-mime-security-button-line-format
7629 gnus-mime-security-button-line-format-alist
7630 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7631 gnus-callback gnus-mime-security-press-button
7632 gnus-line-format ,gnus-mime-security-button-line-format
7633 gnus-mime-details ,gnus-mime-security-button-pressed
7634 article-type annotation
7637 ;; Exclude a newline.
7640 (widget-convert-button
7643 :action 'gnus-widget-press-button
7644 :button-keymap gnus-mime-security-button-map
7646 (lambda (widget/window &optional overlay pos)
7647 ;; Needed to properly clear the message due to a bug in
7648 ;; wid-edit (XEmacs only).
7649 (when (boundp 'help-echo-owns-message)
7650 (setq help-echo-owns-message t))
7653 (aref gnus-mouse-2 0))))))
7655 (defun gnus-mime-display-security (handle)
7657 (narrow-to-region (point) (point))
7658 (unless (gnus-unbuttonized-mime-type-p (car handle))
7659 (gnus-insert-mime-security-button handle))
7660 (gnus-mime-display-mixed (cdr handle))
7663 (unless (gnus-unbuttonized-mime-type-p (car handle))
7664 (let ((gnus-mime-security-button-line-format
7665 gnus-mime-security-button-end-line-format))
7666 (gnus-insert-mime-security-button handle)))
7667 (mm-set-handle-multipart-parameter
7669 (cons (set-marker (make-marker) (point-min))
7670 (set-marker (make-marker) (point-max))))))
7676 (defun gnus-article-header-presentation-method (entity situation)
7677 (mime-insert-header entity)
7678 (article-decode-group-name))
7680 (set-alist 'mime-header-presentation-method-alist
7681 'gnus-original-article-mode
7682 #'gnus-article-header-presentation-method)
7684 (defun gnus-mime-preview-quitting-method ()
7685 (mime-preview-kill-buffer)
7686 (delete-other-windows)
7687 (gnus-article-show-summary)
7688 (gnus-summary-select-article gnus-show-all-headers t))
7690 (set-alist 'mime-preview-quitting-method-alist
7691 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7693 (set-alist 'mime-preview-following-method-alist
7694 'gnus-original-article-mode #'gnus-following-method)
7696 (set-alist 'mime-preview-over-to-previous-method-alist
7697 'gnus-original-article-mode
7699 (if (> (point-min) 1)
7700 (gnus-article-prev-page)
7701 (gnus-article-read-summary-keys
7702 nil (gnus-character-to-event ?P)))))
7704 (set-alist 'mime-preview-over-to-next-method-alist
7705 'gnus-original-article-mode'
7707 (if (< (point-max) (buffer-size))
7708 (gnus-article-next-page)
7709 (gnus-article-read-summary-keys
7710 nil (gnus-character-to-event ?N)))))
7720 (run-hooks 'gnus-art-load-hook)
7722 ;;; gnus-art.el ends here