1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (autoload 'mm-url-insert-file-contents-external "mm-url")
57 (autoload 'mm-extern-cache-contents "mm-extern")
59 (defgroup gnus-article nil
61 :link '(custom-manual "(gnus)Article Buffer")
64 (defgroup gnus-article-treat nil
65 "Treating article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-hiding nil
70 "Hiding article parts."
71 :link '(custom-manual "(gnus)Article Hiding")
74 (defgroup gnus-article-highlight nil
75 "Article highlighting."
76 :link '(custom-manual "(gnus)Article Highlighting")
80 (defgroup gnus-article-signature nil
82 :link '(custom-manual "(gnus)Article Signature")
85 (defgroup gnus-article-headers nil
87 :link '(custom-manual "(gnus)Hiding Headers")
90 (defgroup gnus-article-washing nil
91 "Special commands on articles."
92 :link '(custom-manual "(gnus)Article Washing")
95 (defgroup gnus-article-emphasis nil
96 "Fontisizing articles."
97 :link '(custom-manual "(gnus)Article Fontisizing")
100 (defgroup gnus-article-saving nil
102 :link '(custom-manual "(gnus)Saving Articles")
103 :group 'gnus-article)
105 (defgroup gnus-article-mime nil
106 "Worshiping the MIME wonder."
107 :link '(custom-manual "(gnus)Using MIME")
108 :group 'gnus-article)
110 (defgroup gnus-article-buttons nil
111 "Pushable buttons in the article buffer."
112 :link '(custom-manual "(gnus)Article Buttons")
113 :group 'gnus-article)
115 (defgroup gnus-article-various nil
116 "Other article options."
117 :link '(custom-manual "(gnus)Misc Article")
118 :group 'gnus-article)
120 (defcustom gnus-ignored-headers
123 (concat "^" header ":"))
124 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
125 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
126 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
127 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
128 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
129 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
130 "X-Attribution" "X-Originating-IP" "Delivered-To"
131 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
132 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
133 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
134 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
135 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
136 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
137 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
138 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
139 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
140 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
141 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
142 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
143 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
144 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
145 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
146 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
147 "List-[A-Za-z]+" "X-Listprocessor-Version"
148 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
149 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
150 "X-Received" "Content-length" "X-precedence"
151 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
152 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
153 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
154 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
155 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
156 "X-Content-length" "X-Posting-Agent" "Original-Received"
157 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
158 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
159 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
160 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
161 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
162 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
163 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
164 "Envelope-Sender" "Envelope-Recipients"))
165 "*All headers that start with this regexp will be hidden.
166 This variable can also be a list of regexps of headers to be ignored.
167 If `gnus-visible-headers' is non-nil, this variable will be ignored."
168 :type '(choice :custom-show nil
171 :group 'gnus-article-hiding)
173 (defcustom gnus-visible-headers
174 "^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:"
175 "*All headers that do not match this regexp will be hidden.
176 This variable can also be a list of regexp of headers to remain visible.
177 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
178 :type '(repeat :value-to-internal (lambda (widget value)
179 (custom-split-regexp-maybe value))
180 :match (lambda (widget value)
182 (widget-editable-list-match widget value)))
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
255 (function :value fun)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving."
506 :group 'gnus-article-saving
509 (defcustom gnus-prompt-before-saving 'always
510 "*This variable says how much prompting is to be done when saving articles.
511 If it is nil, no prompting will be done, and the articles will be
512 saved to the default files. If this variable is `always', each and
513 every article that is saved will be preceded by a prompt, even when
514 saving large batches of articles. If this variable is neither nil not
515 `always', there the user will be prompted once for a file name for
516 each invocation of the saving commands."
517 :group 'gnus-article-saving
518 :type '(choice (item always)
519 (item :tag "never" nil)
520 (sexp :tag "once" :format "%t\n" :value t)))
522 (defcustom gnus-saved-headers gnus-visible-headers
523 "Headers to keep if `gnus-save-all-headers' is nil.
524 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
525 If that variable is nil, however, all headers that match this regexp
526 will be kept while the rest will be deleted before saving."
527 :group 'gnus-article-saving
530 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
531 "A function to save articles in your favourite format.
532 The function must be interactively callable (in other words, it must
533 be an Emacs command).
535 Gnus provides the following functions:
537 * gnus-summary-save-in-rmail (Rmail format)
538 * gnus-summary-save-in-mail (Unix mail format)
539 * gnus-summary-save-in-folder (MH folder)
540 * gnus-summary-save-in-file (article format)
541 * gnus-summary-save-body-in-file (article body)
542 * gnus-summary-save-in-vm (use VM's folder format)
543 * gnus-summary-write-to-file (article format -- overwrite)."
544 :group 'gnus-article-saving
545 :type '(radio (function-item gnus-summary-save-in-rmail)
546 (function-item gnus-summary-save-in-mail)
547 (function-item gnus-summary-save-in-folder)
548 (function-item gnus-summary-save-in-file)
549 (function-item gnus-summary-save-body-in-file)
550 (function-item gnus-summary-save-in-vm)
551 (function-item gnus-summary-write-to-file)
554 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
555 "A function generating a file name to save articles in Rmail format.
556 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
557 :group 'gnus-article-saving
560 (defcustom gnus-mail-save-name 'gnus-plain-save-name
561 "A function generating a file name to save articles in Unix mail format.
562 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
563 :group 'gnus-article-saving
566 (defcustom gnus-folder-save-name 'gnus-folder-save-name
567 "A function generating a file name to save articles in MH folder.
568 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
569 :group 'gnus-article-saving
572 (defcustom gnus-file-save-name 'gnus-numeric-save-name
573 "A function generating a file name to save articles in article format.
574 The function is called with NEWSGROUP, HEADERS, and optional
576 :group 'gnus-article-saving
579 (defcustom gnus-split-methods
580 '((gnus-article-archive-name)
581 (gnus-article-nndoc-name))
582 "*Variable used to suggest where articles are to be saved.
583 For instance, if you would like to save articles related to Gnus in
584 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
585 you could set this variable to something like:
587 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
588 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
590 This variable is an alist where the key is the match and the
591 value is a list of possible files to save in if the match is
594 If the match is a string, it is used as a regexp match on the
595 article. If the match is a symbol, that symbol will be funcalled
596 from the buffer of the article to be saved with the newsgroup as
597 the parameter. If it is a list, it will be evaled in the same
600 If this form or function returns a string, this string will be
601 used as a possible file name; and if it returns a non-nil list,
602 that list will be used as possible file names."
603 :group 'gnus-article-saving
604 :type '(repeat (choice (list :value (fun) function)
605 (cons :value ("" "") regexp (repeat string))
608 (defcustom gnus-page-delimiter "^\^L"
609 "*Regexp describing what to use as article page delimiters.
610 The default value is \"^\^L\", which is a form linefeed at the
611 beginning of a line."
613 :group 'gnus-article-various)
615 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
616 "*The format specification for the article mode line.
617 See `gnus-summary-mode-line-format' for a closer description.
619 The following additional specs are available:
621 %w The article washing status.
622 %m The number of MIME parts in the article."
624 :group 'gnus-article-various)
626 (defcustom gnus-article-mode-hook nil
627 "*A hook for Gnus article mode."
629 :group 'gnus-article-various)
631 (when (featurep 'xemacs)
632 ;; Extracted from gnus-xmas-define in order to preserve user settings
633 (when (fboundp 'turn-off-scroll-in-place)
634 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
635 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
636 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
638 (defcustom gnus-article-menu-hook nil
639 "*Hook run after the creation of the article mode menu."
641 :group 'gnus-article-various)
643 (defcustom gnus-article-prepare-hook nil
644 "*A hook called after an article has been prepared in the article buffer."
646 :group 'gnus-article-various)
648 (defcustom gnus-copy-article-ignored-headers nil
649 "List of headers to be removed when copying an article.
650 Each element is a regular expression."
651 :version "23.0" ;; No Gnus
652 :type '(repeat regexp)
653 :group 'gnus-article-various)
655 (make-obsolete-variable 'gnus-article-hide-pgp-hook
656 "This variable is obsolete in Gnus 5.10.")
659 '((t (:weight bold)))
660 "Face used for highlighting a button in the article buffer."
661 :group 'gnus-article-buttons)
663 (defcustom gnus-article-button-face 'gnus-button
664 "Face used for highlighting buttons in the article buffer.
666 An article button is a piece of text that you can activate by pressing
667 `RET' or `mouse-2' above it."
669 :group 'gnus-article-buttons)
671 (defcustom gnus-article-mouse-face 'highlight
672 "Face used for mouse highlighting in the article buffer.
674 Article buttons will be displayed in this face when the cursor is
677 :group 'gnus-article-buttons)
679 (defcustom gnus-signature-face 'gnus-signature
680 "Face used for highlighting a signature in the article buffer.
681 Obsolete; use the face `gnus-signature' for customizations instead."
683 :group 'gnus-article-highlight
684 :group 'gnus-article-signature)
686 (defface gnus-signature
689 "Face used for highlighting a signature in the article buffer."
690 :group 'gnus-article-highlight
691 :group 'gnus-article-signature)
692 ;; backward-compatibility alias
693 (put 'gnus-signature-face 'face-alias 'gnus-signature)
695 (defface gnus-header-from
698 (:foreground "spring green"))
701 (:foreground "red3"))
704 "Face used for displaying from headers."
705 :group 'gnus-article-headers
706 :group 'gnus-article-highlight)
707 ;; backward-compatibility alias
708 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
710 (defface gnus-header-subject
713 (:foreground "SeaGreen3"))
716 (:foreground "red4"))
718 (:bold t :italic t)))
719 "Face used for displaying subject headers."
720 :group 'gnus-article-headers
721 :group 'gnus-article-highlight)
722 ;; backward-compatibility alias
723 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
725 (defface gnus-header-newsgroups
728 (:foreground "yellow" :italic t))
731 (:foreground "MidnightBlue" :italic t))
734 "Face used for displaying newsgroups headers.
735 In the default setup this face is only used for crossposted
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight)
739 ;; backward-compatibility alias
740 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
742 (defface gnus-header-name
745 (:foreground "SeaGreen"))
748 (:foreground "maroon"))
751 "Face used for displaying header names."
752 :group 'gnus-article-headers
753 :group 'gnus-article-highlight)
754 ;; backward-compatibility alias
755 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
757 (defface gnus-header-content
760 (:foreground "forest green" :italic t))
763 (:foreground "indianred4" :italic t))
765 (:italic t))) "Face used for displaying header content."
766 :group 'gnus-article-headers
767 :group 'gnus-article-highlight)
768 ;; backward-compatibility alias
769 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
771 (defcustom gnus-header-face-alist
772 '(("From" nil gnus-header-from)
773 ("Subject" nil gnus-header-subject)
774 ("Newsgroups:.*," nil gnus-header-newsgroups)
775 ("" gnus-header-name gnus-header-content))
776 "*Controls highlighting of article headers.
778 An alist of the form (HEADER NAME CONTENT).
780 HEADER is a regular expression which should match the name of a
781 header and NAME and CONTENT are either face names or nil.
783 The name of each header field will be displayed using the face
784 specified by the first element in the list where HEADER matches
785 the header name and NAME is non-nil. Similarly, the content will
786 be displayed by the first non-nil matching CONTENT face."
787 :group 'gnus-article-headers
788 :group 'gnus-article-highlight
789 :type '(repeat (list (regexp :tag "Header")
791 (item :tag "skip" nil)
792 (face :value default))
793 (choice :tag "Content"
794 (item :tag "skip" nil)
795 (face :value default)))))
797 (defcustom gnus-article-decode-hook
798 '(article-decode-charset article-decode-encoded-words
799 article-decode-group-name article-decode-idna-rhs)
800 "*Hook run to decode charsets in articles."
801 :group 'gnus-article-headers
804 (defcustom gnus-display-mime-function 'gnus-display-mime
805 "Function to display MIME articles."
806 :group 'gnus-article-mime
809 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
810 "Function used to decode headers.")
812 (defvar gnus-article-dumbquotes-map
832 "Table for MS-to-Latin1 translation.")
834 (defcustom gnus-ignored-mime-types nil
835 "List of MIME types that should be ignored by Gnus."
837 :group 'gnus-article-mime
838 :type '(repeat regexp))
840 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
841 "List of MIME types that should not be given buttons when rendered inline.
842 See also `gnus-buttonized-mime-types' which may override this variable.
843 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
845 :group 'gnus-article-mime
846 :type '(repeat regexp))
848 (defcustom gnus-buttonized-mime-types nil
849 "List of MIME types that should be given buttons when rendered inline.
850 If set, this variable overrides `gnus-unbuttonized-mime-types'.
851 To see e.g. security buttons you could set this to
852 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
853 this list to display radio buttons that allow you to choose one of two
854 media types those mails include. See also `mm-discouraged-alternatives'.
855 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
857 :group 'gnus-article-mime
858 :type '(repeat regexp))
860 (defcustom gnus-inhibit-mime-unbuttonizing nil
861 "If non-nil, all MIME parts get buttons.
862 When nil (the default value), then some MIME parts do not get buttons,
863 as described by the variables `gnus-buttonized-mime-types' and
864 `gnus-unbuttonized-mime-types'."
866 :group 'gnus-article-mime
869 (defcustom gnus-body-boundary-delimiter "_"
870 "String used to delimit header and body.
871 This variable is used by `gnus-article-treat-body-boundary' which can
872 be controlled by `gnus-treat-body-boundary'."
874 :group 'gnus-article-various
875 :type '(choice (item :tag "None" :value nil)
878 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
880 "Defines the location of the faces database.
881 For information on obtaining this database of pretty pictures, please
882 see http://www.cs.indiana.edu/picons/ftp/index.html"
884 :type '(repeat directory)
885 :link '(url-link :tag "download"
886 "http://www.cs.indiana.edu/picons/ftp/index.html")
887 :link '(custom-manual "(gnus)Picons")
890 (defun gnus-picons-installed-p ()
891 "Say whether picons are installed on your machine."
892 (let ((installed nil))
893 (dolist (database gnus-picon-databases)
894 (when (file-exists-p database)
898 (defcustom gnus-article-mime-part-function nil
899 "Function called with a MIME handle as the argument.
900 This is meant for people who want to do something automatic based
901 on parts -- for instance, adding Vcard info to a database."
902 :group 'gnus-article-mime
903 :type '(choice (const nil)
906 (defcustom gnus-mime-multipart-functions nil
907 "An alist of MIME types to functions to display them."
909 :group 'gnus-article-mime
910 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
912 (defcustom gnus-article-date-lapsed-new-header nil
913 "Whether the X-Sent and Date headers can coexist.
914 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
915 either replace the old \"Date:\" header (if this variable is nil), or
916 be added below it (otherwise)."
918 :group 'gnus-article-headers
921 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
922 "Function called with a MIME handle as the argument.
923 This is meant for people who want to view first matched part.
924 For `undisplayed-alternative' (default), the first undisplayed
925 part or alternative part is used. For `undisplayed', the first
926 undisplayed part is used. For a function, the first part which
927 the function return t is used. For nil, the first part is
930 :group 'gnus-article-mime
932 (item :tag "first" :value nil)
933 (item :tag "undisplayed" :value undisplayed)
934 (item :tag "undisplayed or alternative"
935 :value undisplayed-alternative)
938 (defcustom gnus-mime-action-alist
939 '(("save to file" . gnus-mime-save-part)
940 ("save and strip" . gnus-mime-save-part-and-strip)
941 ("replace with file" . gnus-mime-replace-part)
942 ("delete part" . gnus-mime-delete-part)
943 ("display as text" . gnus-mime-inline-part)
944 ("view the part" . gnus-mime-view-part)
945 ("pipe to command" . gnus-mime-pipe-part)
946 ("toggle display" . gnus-article-press-button)
947 ("toggle display" . gnus-article-view-part-as-charset)
948 ("view as type" . gnus-mime-view-part-as-type)
949 ("view internally" . gnus-mime-view-part-internally)
950 ("view externally" . gnus-mime-view-part-externally))
951 "An alist of actions that run on the MIME attachment."
952 :group 'gnus-article-mime
953 :type '(repeat (cons (string :tag "name")
956 (defcustom gnus-auto-select-part 1
957 "Advance to next MIME part when deleting or stripping parts.
959 When 0, point will be placed on the same part as before. When
960 positive (negative), move point forward (backwards) this many
961 parts. When nil, redisplay article."
962 :version "23.0" ;; No Gnus
963 :group 'gnus-article-mime
964 :type '(choice (const nil :tag "Redisplay article.")
965 (const 1 :tag "Next part.")
966 (const 0 :tag "Current part.")
970 ;;; The treatment variables
973 (defvar gnus-part-display-hook nil
974 "Hook called on parts that are to receive treatment.")
976 (defvar gnus-article-treat-custom
977 '(choice (const :tag "Off" nil)
979 (const :tag "Header" head)
980 (const :tag "First" first)
981 (const :tag "Last" last)
982 (integer :tag "Less")
983 (repeat :tag "Groups" regexp)
984 (sexp :tag "Predicate")))
986 (defvar gnus-article-treat-head-custom
987 '(choice (const :tag "Off" nil)
988 (const :tag "Header" head)))
990 (defvar gnus-article-treat-types '("text/plain")
993 (defvar gnus-inhibit-treatment nil
994 "Whether to inhibit treatment.")
996 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
997 "Highlight the signature.
998 Valid values are nil, t, `head', `first', `last', an integer or a
999 predicate. See Info node `(gnus)Customizing Articles'."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1003 (put 'gnus-treat-highlight-signature 'highlight t)
1005 (defcustom gnus-treat-buttonize 100000
1007 Valid values are nil, t, `head', `first', `last', an integer or a
1008 predicate. See Info node `(gnus)Customizing Articles'."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom)
1012 (put 'gnus-treat-buttonize 'highlight t)
1014 (defcustom gnus-treat-buttonize-head 'head
1015 "Add buttons to the head.
1016 Valid values are nil, t, `head', `first', `last', an integer or a
1017 predicate. See Info node `(gnus)Customizing Articles'."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-head-custom)
1021 (put 'gnus-treat-buttonize-head 'highlight t)
1023 (defcustom gnus-treat-emphasize
1024 (and (or window-system
1028 Valid values are nil, t, `head', `first', `last', an integer or a
1029 predicate. See Info node `(gnus)Customizing Articles'."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-custom)
1033 (put 'gnus-treat-emphasize 'highlight t)
1035 (defcustom gnus-treat-strip-cr nil
1036 "Remove carriage returns.
1037 Valid values are nil, t, `head', `first', `last', an integer or a
1038 predicate. See Info node `(gnus)Customizing Articles'."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-custom)
1044 (defcustom gnus-treat-unsplit-urls nil
1045 "Remove newlines from within URLs.
1046 Valid values are nil, t, `head', `first', `last', an integer or a
1047 predicate. See Info node `(gnus)Customizing Articles'."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-leading-whitespace nil
1054 "Remove leading whitespace in headers.
1055 Valid values are nil, t, `head', `first', `last', an integer or a
1056 predicate. See Info node `(gnus)Customizing Articles'."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-custom)
1062 (defcustom gnus-treat-hide-headers 'head
1064 Valid values are nil, t, `head', `first', `last', an integer or a
1065 predicate. See Info node `(gnus)Customizing Articles'."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-head-custom)
1070 (defcustom gnus-treat-hide-boring-headers nil
1071 "Hide boring headers.
1072 Valid values are nil, t, `head', `first', `last', an integer or a
1073 predicate. See Info node `(gnus)Customizing Articles'."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-head-custom)
1078 (defcustom gnus-treat-hide-signature nil
1079 "Hide the signature.
1080 Valid values are nil, t, `head', `first', `last', an integer or a
1081 predicate. See Info node `(gnus)Customizing Articles'."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-fill-article nil
1088 Valid values are nil, t, `head', `first', `last', an integer or a
1089 predicate. See Info node `(gnus)Customizing Articles'."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-hide-citation nil
1096 Valid values are nil, t, `head', `first', `last', an integer or a
1097 predicate. See Info node `(gnus)Customizing Articles'."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1102 (defcustom gnus-treat-hide-citation-maybe nil
1104 Valid values are nil, t, `head', `first', `last', an integer or a
1105 predicate. See Info node `(gnus)Customizing Articles'."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1110 (defcustom gnus-treat-strip-list-identifiers 'head
1111 "Strip list identifiers from `gnus-list-identifiers`.
1112 Valid values are nil, t, `head', `first', `last', an integer or a
1113 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (make-obsolete-variable 'gnus-treat-strip-pgp
1120 "This option is obsolete in Gnus 5.10.")
1122 (defcustom gnus-treat-strip-pem nil
1123 "Strip PEM signatures.
1124 Valid values are nil, t, `head', `first', `last', an integer or a
1125 predicate. See Info node `(gnus)Customizing Articles'."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-strip-banner t
1131 "Strip banners from articles.
1132 The banner to be stripped is specified in the `banner' group parameter.
1133 Valid values are nil, t, `head', `first', `last', an integer or a
1134 predicate. See Info node `(gnus)Customizing Articles'."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-highlight-headers 'head
1140 "Highlight the headers.
1141 Valid values are nil, t, `head', `first', `last', an integer or a
1142 predicate. See Info node `(gnus)Customizing Articles'."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-head-custom)
1146 (put 'gnus-treat-highlight-headers 'highlight t)
1148 (defcustom gnus-treat-highlight-citation t
1149 "Highlight cited text.
1150 Valid values are nil, t, `head', `first', `last', an integer or a
1151 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1155 (put 'gnus-treat-highlight-citation 'highlight t)
1157 (defcustom gnus-treat-date-ut nil
1158 "Display the Date in UT (GMT).
1159 Valid values are nil, t, `head', `first', `last', an integer or a
1160 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-head-custom)
1165 (defcustom gnus-treat-date-local nil
1166 "Display the Date in the local timezone.
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-head-custom)
1173 (defcustom gnus-treat-date-english nil
1174 "Display the Date in a format that can be read aloud in English.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom)
1182 (defcustom gnus-treat-date-lapsed nil
1183 "Display the Date header in a way that says how much time has elapsed.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-head-custom)
1190 (defcustom gnus-treat-date-original nil
1191 "Display the date in the original timezone.
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-head-custom)
1198 (defcustom gnus-treat-date-iso8601 nil
1199 "Display the date in the ISO8601 format.
1200 Valid values are nil, t, `head', `first', `last', an integer or a
1201 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-head-custom)
1207 (defcustom gnus-treat-date-user-defined nil
1208 "Display the date in a user-defined format.
1209 The format is defined by the `gnus-article-time-format' variable.
1210 Valid values are nil, t, `head', `first', `last', an integer or a
1211 predicate. See Info node `(gnus)Customizing Articles'."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-head-custom)
1216 (defcustom gnus-treat-strip-headers-in-body t
1217 "Strip the X-No-Archive header line from the beginning of the body.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1221 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :type gnus-article-treat-custom)
1225 (defcustom gnus-treat-strip-trailing-blank-lines nil
1226 "Strip trailing blank lines.
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'.
1230 When set to t, it also strips trailing blanks in all MIME parts.
1231 Consider to use `last' instead."
1232 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :type gnus-article-treat-custom)
1236 (defcustom gnus-treat-strip-leading-blank-lines nil
1237 "Strip leading blank lines.
1238 Valid values are nil, t, `head', `first', `last', an integer or a
1239 predicate. See Info node `(gnus)Customizing Articles'.
1241 When set to t, it also strips trailing blanks in all MIME parts."
1242 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom)
1246 (defcustom gnus-treat-strip-multiple-blank-lines nil
1247 "Strip multiple blank lines.
1248 Valid values are nil, t, `head', `first', `last', an integer or a
1249 predicate. See Info node `(gnus)Customizing Articles'."
1250 :group 'gnus-article-treat
1251 :link '(custom-manual "(gnus)Customizing Articles")
1252 :type gnus-article-treat-custom)
1254 (defcustom gnus-treat-unfold-headers 'head
1255 "Unfold folded header lines.
1256 Valid values are nil, t, `head', `first', `last', an integer or a
1257 predicate. See Info node `(gnus)Customizing Articles'."
1259 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :type gnus-article-treat-custom)
1263 (defcustom gnus-treat-fold-headers nil
1265 Valid values are nil, t, `head', `first', `last', an integer or a
1266 predicate. See Info node `(gnus)Customizing Articles'."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-fold-newsgroups 'head
1273 "Fold the Newsgroups and Followup-To headers.
1274 Valid values are nil, t, `head', `first', `last', an integer or a
1275 predicate. See Info node `(gnus)Customizing Articles'."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-overstrike t
1282 "Treat overstrike highlighting.
1283 Valid values are nil, t, `head', `first', `last', an integer or a
1284 predicate. See Info node `(gnus)Customizing Articles'."
1285 :group 'gnus-article-treat
1286 :link '(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-custom)
1288 (put 'gnus-treat-overstrike 'highlight t)
1290 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1291 "Treat ANSI SGR control sequences.
1292 Valid values are nil, t, `head', `first', `last', an integer or a
1293 predicate. See Info node `(gnus)Customizing Articles'."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (make-obsolete-variable 'gnus-treat-display-xface
1299 'gnus-treat-display-x-face)
1301 (defcustom gnus-treat-display-x-face
1302 (and (not noninteractive)
1303 (or (and (fboundp 'image-type-available-p)
1304 (image-type-available-p 'xbm)
1305 (string-match "^0x" (shell-command-to-string "uncompface"))
1306 (executable-find "icontopbm"))
1307 (and (featurep 'xemacs)
1310 "Display X-Face headers.
1311 Valid values are nil, t, `head', `first', `last', an integer or a
1312 predicate. See Info node `(gnus)Customizing Articles' and Info
1313 node `(gnus)X-Face' for details."
1314 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :link '(custom-manual "(gnus)X-Face")
1318 :type gnus-article-treat-head-custom
1319 :set (lambda (symbol value)
1322 (cond ((or (boundp symbol) (get symbol 'saved-value))
1324 ((boundp 'gnus-treat-display-xface)
1326 ** gnus-treat-display-xface is an obsolete variable;\
1327 use gnus-treat-display-x-face instead")
1328 (default-value 'gnus-treat-display-xface))
1329 ((get 'gnus-treat-display-xface 'saved-value)
1331 ** gnus-treat-display-xface is an obsolete variable;\
1332 use gnus-treat-display-x-face instead")
1333 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1336 (put 'gnus-treat-display-x-face 'highlight t)
1338 (defcustom gnus-treat-display-face
1339 (and (not noninteractive)
1340 (or (and (fboundp 'image-type-available-p)
1341 (image-type-available-p 'png))
1342 (and (featurep 'xemacs)
1345 "Display Face headers.
1346 Valid values are nil, t, `head', `first', `last', an integer or a
1347 predicate. See Info node `(gnus)Customizing Articles' and Info
1348 node `(gnus)X-Face' for details."
1349 :group 'gnus-article-treat
1351 :link '(custom-manual "(gnus)Customizing Articles")
1352 :link '(custom-manual "(gnus)X-Face")
1353 :type gnus-article-treat-head-custom)
1354 (put 'gnus-treat-display-face 'highlight t)
1356 (defcustom gnus-treat-display-smileys
1357 (if (or (and (featurep 'xemacs)
1359 (and (fboundp 'image-type-available-p)
1360 (image-type-available-p 'pbm)))
1363 Valid values are nil, t, `head', `first', `last', an integer or a
1364 predicate. See Info node `(gnus)Customizing Articles' and Info
1365 node `(gnus)Smileys' for details."
1366 :group 'gnus-article-treat
1368 :link '(custom-manual "(gnus)Customizing Articles")
1369 :link '(custom-manual "(gnus)Smileys")
1370 :type gnus-article-treat-custom)
1371 (put 'gnus-treat-display-smileys 'highlight t)
1373 (defcustom gnus-treat-from-picon
1374 (if (and (gnus-image-type-available-p 'xpm)
1375 (gnus-picons-installed-p))
1377 "Display picons in the From header.
1378 Valid values are nil, t, `head', `first', `last', an integer or a
1379 predicate. See Info node `(gnus)Customizing Articles' and Info
1380 node `(gnus)Picons' for details."
1382 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :link '(custom-manual "(gnus)Picons")
1386 :type gnus-article-treat-head-custom)
1387 (put 'gnus-treat-from-picon 'highlight t)
1389 (defcustom gnus-treat-mail-picon
1390 (if (and (gnus-image-type-available-p 'xpm)
1391 (gnus-picons-installed-p))
1393 "Display picons in To and Cc headers.
1394 Valid values are nil, t, `head', `first', `last', an integer or a
1395 predicate. See Info node `(gnus)Customizing Articles' and Info
1396 node `(gnus)Picons' for details."
1398 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :link '(custom-manual "(gnus)Picons")
1402 :type gnus-article-treat-head-custom)
1403 (put 'gnus-treat-mail-picon 'highlight t)
1405 (defcustom gnus-treat-newsgroups-picon
1406 (if (and (gnus-image-type-available-p 'xpm)
1407 (gnus-picons-installed-p))
1409 "Display picons in the Newsgroups and Followup-To headers.
1410 Valid values are nil, t, `head', `first', `last', an integer or a
1411 predicate. See Info node `(gnus)Customizing Articles' and Info
1412 node `(gnus)Picons' for details."
1414 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :link '(custom-manual "(gnus)Picons")
1418 :type gnus-article-treat-head-custom)
1419 (put 'gnus-treat-newsgroups-picon 'highlight t)
1421 (defcustom gnus-treat-body-boundary
1422 (if (and (eq window-system 'x)
1423 (or gnus-treat-newsgroups-picon
1424 gnus-treat-mail-picon
1425 gnus-treat-from-picon))
1427 "Draw a boundary at the end of the headers.
1428 Valid values are nil and `head'.
1429 See Info node `(gnus)Customizing Articles' for details."
1431 :group 'gnus-article-treat
1432 :link '(custom-manual "(gnus)Customizing Articles")
1433 :type gnus-article-treat-head-custom)
1435 (defcustom gnus-treat-capitalize-sentences nil
1436 "Capitalize sentence-starting words.
1437 Valid values are nil, t, `head', `first', `last', an integer or a
1438 predicate. See Info node `(gnus)Customizing Articles'."
1440 :group 'gnus-article-treat
1441 :link '(custom-manual "(gnus)Customizing Articles")
1442 :type gnus-article-treat-custom)
1444 (defcustom gnus-treat-wash-html nil
1446 Valid values are nil, t, `head', `first', `last', an integer or a
1447 predicate. See Info node `(gnus)Customizing Articles'."
1449 :group 'gnus-article-treat
1450 :link '(custom-manual "(gnus)Customizing Articles")
1451 :type gnus-article-treat-custom)
1453 (defcustom gnus-treat-fill-long-lines nil
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles'."
1457 :group 'gnus-article-treat
1458 :link '(custom-manual "(gnus)Customizing Articles")
1459 :type gnus-article-treat-custom)
1461 (defcustom gnus-treat-play-sounds nil
1463 Valid values are nil, t, `head', `first', `last', an integer or a
1464 predicate. See Info node `(gnus)Customizing Articles'."
1466 :group 'gnus-article-treat
1467 :link '(custom-manual "(gnus)Customizing Articles")
1468 :type gnus-article-treat-custom)
1470 (defcustom gnus-treat-translate nil
1471 "Translate articles from one language to another.
1472 Valid values are nil, t, `head', `first', `last', an integer or a
1473 predicate. See Info node `(gnus)Customizing Articles'."
1475 :group 'gnus-article-treat
1476 :link '(custom-manual "(gnus)Customizing Articles")
1477 :type gnus-article-treat-custom)
1479 (defcustom gnus-treat-x-pgp-sig nil
1481 To automatically treat X-PGP-Sig, set it to head.
1482 Valid values are nil, t, `head', `first', `last', an integer or a
1483 predicate. See Info node `(gnus)Customizing Articles'."
1485 :group 'gnus-article-treat
1486 :group 'mime-security
1487 :link '(custom-manual "(gnus)Customizing Articles")
1488 :type gnus-article-treat-custom)
1490 (defvar gnus-article-encrypt-protocol-alist
1491 '(("PGP" . mml2015-self-encrypt)))
1493 ;; Set to nil if more than one protocol added to
1494 ;; gnus-article-encrypt-protocol-alist.
1495 (defcustom gnus-article-encrypt-protocol "PGP"
1496 "The protocol used for encrypt articles.
1497 It is a string, such as \"PGP\". If nil, ask user."
1500 :group 'mime-security)
1502 (defvar gnus-article-wash-function nil
1503 "Function used for converting HTML into text.")
1505 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1506 (mm-coding-system-p 'utf-8)
1507 (executable-find idna-program))
1508 "Whether IDNA decoding of headers is used when viewing messages.
1509 This requires GNU Libidn, and by default only enabled if it is found."
1511 :group 'gnus-article-headers
1514 (defcustom gnus-article-over-scroll nil
1515 "If non-nil, allow scrolling the article buffer even when there no more text."
1517 :group 'gnus-article
1520 ;;; Internal variables
1522 (defvar gnus-english-month-names
1523 '("January" "February" "March" "April" "May" "June" "July" "August"
1524 "September" "October" "November" "December"))
1526 (defvar gnus-button-regexp nil)
1527 (defvar gnus-button-marker-list nil)
1528 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1530 (defvar gnus-button-last nil)
1531 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1533 (defvar article-goto-body-goes-to-point-min-p nil)
1534 (defvar gnus-article-wash-types nil)
1535 (defvar gnus-article-emphasis-alist nil)
1536 (defvar gnus-article-image-alist nil)
1538 (defvar gnus-article-mime-handle-alist-1 nil)
1539 (defvar gnus-treatment-function-alist
1540 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1541 (gnus-treat-strip-banner gnus-article-strip-banner)
1542 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1543 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1544 (gnus-treat-buttonize gnus-article-add-buttons)
1545 (gnus-treat-fill-article gnus-article-fill-cited-article)
1546 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1547 (gnus-treat-strip-cr gnus-article-remove-cr)
1548 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1549 (gnus-treat-date-ut gnus-article-date-ut)
1550 (gnus-treat-date-local gnus-article-date-local)
1551 (gnus-treat-date-english gnus-article-date-english)
1552 (gnus-treat-date-original gnus-article-date-original)
1553 (gnus-treat-date-user-defined gnus-article-date-user)
1554 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1555 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1556 (gnus-treat-display-x-face gnus-article-display-x-face)
1557 (gnus-treat-display-face gnus-article-display-face)
1558 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1559 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1560 (gnus-treat-hide-signature gnus-article-hide-signature)
1561 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1562 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1563 (gnus-treat-strip-pem gnus-article-hide-pem)
1564 (gnus-treat-from-picon gnus-treat-from-picon)
1565 (gnus-treat-mail-picon gnus-treat-mail-picon)
1566 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1567 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1568 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1569 (gnus-treat-strip-trailing-blank-lines
1570 gnus-article-remove-trailing-blank-lines)
1571 (gnus-treat-strip-leading-blank-lines
1572 gnus-article-strip-leading-blank-lines)
1573 (gnus-treat-strip-multiple-blank-lines
1574 gnus-article-strip-multiple-blank-lines)
1575 (gnus-treat-overstrike gnus-article-treat-overstrike)
1576 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1577 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1578 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1579 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1580 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1581 (gnus-treat-display-smileys gnus-treat-smiley)
1582 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1583 (gnus-treat-wash-html gnus-article-wash-html)
1584 (gnus-treat-emphasize gnus-article-emphasize)
1585 (gnus-treat-hide-citation gnus-article-hide-citation)
1586 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1587 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1588 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1589 (gnus-treat-play-sounds gnus-earcon-display)))
1591 (defvar gnus-article-mime-handle-alist nil)
1592 (defvar article-lapsed-timer nil)
1593 (defvar gnus-article-current-summary nil)
1595 (defvar gnus-article-mode-syntax-table
1596 (let ((table (copy-syntax-table text-mode-syntax-table)))
1597 ;; This causes the citation match run O(2^n).
1598 ;; (modify-syntax-entry ?- "w" table)
1599 (modify-syntax-entry ?> ")<" table)
1600 (modify-syntax-entry ?< "(>" table)
1601 ;; make M-. in article buffers work for `foo' strings
1602 (modify-syntax-entry ?' " " table)
1603 (modify-syntax-entry ?` " " table)
1605 "Syntax table used in article mode buffers.
1606 Initialized from `text-mode-syntax-table.")
1608 (defvar gnus-save-article-buffer nil)
1610 (defvar gnus-article-mode-line-format-alist
1611 (nconc '((?w (gnus-article-wash-status) ?s)
1612 (?m (gnus-article-mime-part-status) ?s))
1613 gnus-summary-mode-line-format-alist))
1615 (defvar gnus-number-of-articles-to-be-saved nil)
1617 (defvar gnus-inhibit-hiding nil)
1619 (defvar gnus-article-edit-mode nil)
1621 ;;; Macros for dealing with the article buffer.
1623 (defmacro gnus-with-article-headers (&rest forms)
1625 (set-buffer gnus-article-buffer)
1627 (let ((inhibit-read-only t)
1628 (inhibit-point-motion-hooks t)
1629 (case-fold-search t))
1630 (article-narrow-to-head)
1633 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1634 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1636 (defmacro gnus-with-article-buffer (&rest forms)
1638 (set-buffer gnus-article-buffer)
1639 (let ((inhibit-read-only t))
1642 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1643 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1645 (defun gnus-article-goto-header (header)
1646 "Go to HEADER, which is a regular expression."
1647 (re-search-forward (concat "^\\(" header "\\):") nil t))
1649 (defsubst gnus-article-hide-text (b e props)
1650 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1651 (gnus-add-text-properties-when 'article-type nil b e props)
1652 (when (memq 'intangible props)
1654 (max (1- b) (point-min))
1655 b 'intangible (cddr (memq 'intangible props)))))
1657 (defsubst gnus-article-unhide-text (b e)
1658 "Remove hidden text properties from region between B and E."
1659 (remove-text-properties b e gnus-hidden-properties)
1660 (when (memq 'intangible gnus-hidden-properties)
1661 (put-text-property (max (1- b) (point-min))
1662 b 'intangible nil)))
1664 (defun gnus-article-hide-text-type (b e type)
1665 "Hide text of TYPE between B and E."
1666 (gnus-add-wash-type type)
1667 (gnus-article-hide-text
1668 b e (cons 'article-type (cons type gnus-hidden-properties))))
1670 (defun gnus-article-unhide-text-type (b e type)
1671 "Unhide text of TYPE between B and E."
1672 (gnus-delete-wash-type type)
1673 (remove-text-properties
1674 b e (cons 'article-type (cons type gnus-hidden-properties)))
1675 (when (memq 'intangible gnus-hidden-properties)
1676 (put-text-property (max (1- b) (point-min))
1677 b 'intangible nil)))
1679 (defun gnus-article-hide-text-of-type (type)
1680 "Hide text of TYPE in the current buffer."
1682 (let ((b (point-min))
1684 (while (setq b (text-property-any b e 'article-type type))
1685 (add-text-properties b (incf b) gnus-hidden-properties)))))
1687 (defun gnus-article-delete-text-of-type (type)
1688 "Delete text of TYPE in the current buffer."
1690 (let ((b (point-min)))
1691 (if (eq type 'multipart)
1692 ;; Remove MIME buttons associated with multipart/alternative parts.
1695 (while (if (get-text-property (point) 'gnus-part)
1697 (when (setq b (next-single-property-change (point)
1702 (skip-chars-forward "\n")
1703 (when (eq (get-text-property b 'article-type) 'multipart)
1704 (delete-region b (point)))))
1705 (while (setq b (text-property-any b (point-max) 'article-type type))
1707 b (or (text-property-not-all b (point-max) 'article-type type)
1710 (defun gnus-article-delete-invisible-text ()
1711 "Delete all invisible text in the current buffer."
1713 (let ((b (point-min)))
1714 (while (setq b (text-property-any b (point-max) 'invisible t))
1716 b (or (text-property-not-all b (point-max) 'invisible t)
1719 (defun gnus-article-text-type-exists-p (type)
1720 "Say whether any text of type TYPE exists in the buffer."
1721 (text-property-any (point-min) (point-max) 'article-type type))
1723 (defsubst gnus-article-header-rank ()
1724 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1725 (let ((list gnus-sorted-header-list)
1728 (if (looking-at (car list))
1730 (setq list (cdr list))
1734 (defun article-hide-headers (&optional arg delete)
1735 "Hide unwanted headers and possibly sort them as well."
1737 ;; This function might be inhibited.
1738 (unless gnus-inhibit-hiding
1739 (let ((inhibit-read-only nil)
1740 (case-fold-search t)
1741 (max (1+ (length gnus-sorted-header-list)))
1742 (inhibit-point-motion-hooks t)
1743 (cur (current-buffer))
1744 ignored visible beg)
1746 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1747 ;; group parameters, so we should go to the summary buffer.
1750 (progn (set-buffer gnus-summary-buffer) t)
1752 (setq ignored (when (not gnus-visible-headers)
1753 (cond ((stringp gnus-ignored-headers)
1754 gnus-ignored-headers)
1755 ((listp gnus-ignored-headers)
1756 (mapconcat 'identity
1757 gnus-ignored-headers
1759 visible (cond ((stringp gnus-visible-headers)
1760 gnus-visible-headers)
1761 ((and gnus-visible-headers
1762 (listp gnus-visible-headers))
1763 (mapconcat 'identity
1764 gnus-visible-headers
1768 ;; First we narrow to just the headers.
1769 (article-narrow-to-head)
1770 ;; Hide any "From " lines at the beginning of (mail) articles.
1771 (while (looking-at "From ")
1774 (delete-region (point-min) (point)))
1775 ;; Then treat the rest of the header lines.
1776 ;; Then we use the two regular expressions
1777 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1778 ;; select which header lines is to remain visible in the
1780 (while (re-search-forward "^[^ \t:]*:" nil t)
1782 ;; Mark the rank of the header.
1784 (point) (1+ (point)) 'message-rank
1785 (if (or (and visible (looking-at visible))
1787 (not (looking-at ignored))))
1788 (gnus-article-header-rank)
1791 (message-sort-headers-1)
1792 (when (setq beg (text-property-any
1793 (point-min) (point-max) 'message-rank (+ 2 max)))
1794 ;; We delete the unwanted headers.
1795 (gnus-add-wash-type 'headers)
1796 (add-text-properties (point-min) (+ 5 (point-min))
1797 '(article-type headers dummy-invisible t))
1798 (delete-region beg (point-max))))))))
1800 (defun article-hide-boring-headers (&optional arg)
1801 "Toggle hiding of headers that aren't very interesting.
1802 If given a negative prefix, always show; if given a positive prefix,
1804 (interactive (gnus-article-hidden-arg))
1805 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1806 (not gnus-show-all-headers))
1809 (let ((inhibit-read-only t)
1810 (inhibit-point-motion-hooks t))
1811 (article-narrow-to-head)
1812 (dolist (elem gnus-boring-article-headers)
1813 (goto-char (point-min))
1815 ;; Hide empty headers.
1817 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1819 (gnus-article-hide-text-type
1823 (if (re-search-forward "^[^ \t]" nil t)
1827 ;; Hide boring Newsgroups header.
1828 ((eq elem 'newsgroups)
1829 (when (gnus-string-equal
1830 (gnus-fetch-field "newsgroups")
1831 (gnus-group-real-name
1832 (if (boundp 'gnus-newsgroup-name)
1835 (gnus-article-hide-header "newsgroups")))
1836 ((eq elem 'to-address)
1837 (let ((to (message-fetch-field "to"))
1839 (gnus-parameter-to-address
1840 (if (boundp 'gnus-newsgroup-name)
1841 gnus-newsgroup-name ""))))
1842 (when (and to to-address
1845 ;; only one address in To
1846 (nth 1 (mail-extract-address-components to))
1848 (gnus-article-hide-header "to"))))
1850 (let ((to (message-fetch-field "to"))
1852 (gnus-parameter-to-list
1853 (if (boundp 'gnus-newsgroup-name)
1854 gnus-newsgroup-name ""))))
1855 (when (and to to-list
1858 ;; only one address in To
1859 (nth 1 (mail-extract-address-components to))
1861 (gnus-article-hide-header "to"))))
1863 (let ((cc (message-fetch-field "cc"))
1865 (gnus-parameter-to-list
1866 (if (boundp 'gnus-newsgroup-name)
1867 gnus-newsgroup-name ""))))
1868 (when (and cc to-list
1871 ;; only one address in CC
1872 (nth 1 (mail-extract-address-components cc))
1874 (gnus-article-hide-header "cc"))))
1875 ((eq elem 'followup-to)
1876 (when (gnus-string-equal
1877 (message-fetch-field "followup-to")
1878 (message-fetch-field "newsgroups"))
1879 (gnus-article-hide-header "followup-to")))
1880 ((eq elem 'reply-to)
1881 (if (gnus-group-find-parameter
1882 gnus-newsgroup-name 'broken-reply-to)
1883 (gnus-article-hide-header "reply-to")
1884 (let ((from (message-fetch-field "from"))
1885 (reply-to (message-fetch-field "reply-to")))
1892 (lambda (x) (downcase (cadr x)))
1893 (mail-extract-address-components from t))
1896 (lambda (x) (downcase (cadr x)))
1897 (mail-extract-address-components reply-to t))
1899 (gnus-article-hide-header "reply-to")))))
1901 (let ((date (message-fetch-field "date")))
1903 (< (days-between (current-time-string) date)
1905 (gnus-article-hide-header "date"))))
1907 (let ((to (message-fetch-field "to"))
1908 (cc (message-fetch-field "cc")))
1909 (when (> (length to) 1024)
1910 (gnus-article-hide-header "to"))
1911 (when (> (length cc) 1024)
1912 (gnus-article-hide-header "cc"))))
1916 (goto-char (point-min))
1917 (while (re-search-forward "^to:" nil t)
1918 (setq to-count (1+ to-count)))
1919 (when (> to-count 1)
1920 (while (> to-count 0)
1921 (goto-char (point-min))
1923 (re-search-forward "^to:" nil nil to-count)
1925 (narrow-to-region (point) (point-max))
1926 (gnus-article-hide-header "to"))
1927 (setq to-count (1- to-count))))
1928 (goto-char (point-min))
1929 (while (re-search-forward "^cc:" nil t)
1930 (setq cc-count (1+ cc-count)))
1931 (when (> cc-count 1)
1932 (while (> cc-count 0)
1933 (goto-char (point-min))
1935 (re-search-forward "^cc:" nil nil cc-count)
1937 (narrow-to-region (point) (point-max))
1938 (gnus-article-hide-header "cc"))
1939 (setq cc-count (1- cc-count)))))))))))))
1941 (defun gnus-article-hide-header (header)
1943 (goto-char (point-min))
1944 (when (re-search-forward (concat "^" header ":") nil t)
1945 (gnus-article-hide-text-type
1949 (if (re-search-forward "^[^ \t]" nil t)
1954 (defvar gnus-article-normalized-header-length 40
1955 "Length of normalized headers.")
1957 (defun article-normalize-headers ()
1958 "Make all header lines 40 characters long."
1960 (let ((inhibit-read-only t)
1964 (article-narrow-to-head)
1967 ((< (setq column (- (point-at-eol) (point)))
1968 gnus-article-normalized-header-length)
1970 (insert (make-string
1971 (- gnus-article-normalized-header-length column)
1973 ((> column gnus-article-normalized-header-length)
1974 (gnus-put-text-property
1976 (forward-char gnus-article-normalized-header-length)
1983 (forward-line 1))))))
1985 (defun article-treat-dumbquotes ()
1986 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1987 Note that this function guesses whether a character is a sm*rtq**t* or
1988 not, so it should only be used interactively.
1990 Sm*rtq**t*s are M****s***'s unilateral extension to the
1991 iso-8859-1 character map in an attempt to provide more quoting
1992 characters. If you see something like \\222 or \\264 where
1993 you're expecting some kind of apostrophe or quotation mark, then
1996 (article-translate-strings gnus-article-dumbquotes-map))
1998 (defun article-translate-characters (from to)
1999 "Translate all characters in the body of the article according to FROM and TO.
2000 FROM is a string of characters to translate from; to is a string of
2001 characters to translate to."
2003 (when (article-goto-body)
2004 (let ((inhibit-read-only t)
2005 (x (make-string 225 ?x))
2007 (while (< (incf i) (length x))
2010 (while (< i (length from))
2011 (aset x (aref from i) (aref to i))
2013 (translate-region (point) (point-max) x)))))
2015 (defun article-translate-strings (map)
2016 "Translate all string in the body of the article according to MAP.
2017 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2019 (when (article-goto-body)
2020 (let ((inhibit-read-only t))
2023 (while (search-forward (car elem) nil t)
2024 (replace-match (cadr elem)))))))))
2026 (defun article-treat-overstrike ()
2027 "Translate overstrikes into bold text."
2030 (when (article-goto-body)
2031 (let ((inhibit-read-only t))
2032 (while (search-forward "\b" nil t)
2033 (let ((next (char-after))
2034 (previous (char-after (- (point) 2))))
2035 ;; We do the boldification/underlining by hiding the
2036 ;; overstrikes and putting the proper text property
2040 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2041 (put-text-property (point) (1+ (point)) 'face 'bold))
2043 (gnus-article-hide-text-type
2044 (1- (point)) (1+ (point)) 'overstrike)
2046 (- (point) 2) (1- (point)) 'face 'underline))
2048 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2050 (point) (1+ (point)) 'face 'underline)))))))))
2052 (defun article-treat-ansi-sequences ()
2053 "Translate ANSI SGR control sequences into overlays or extents."
2056 (when (article-goto-body)
2057 (let ((inhibit-read-only t))
2058 (ansi-color-apply-on-region (point) (point-max))))))
2060 (defun gnus-article-treat-unfold-headers ()
2061 "Unfold folded message headers.
2062 Only the headers that fit into the current window width will be
2065 (gnus-with-article-headers
2069 (mail-header-narrow-to-field)
2070 (let ((header (buffer-string)))
2073 (goto-char (point-min))
2074 (while (re-search-forward "\n[\t ]" nil t)
2075 (replace-match " " t t)))
2076 (setq length (- (point-max) (point-min) 1)))
2077 (when (< length (window-width))
2078 (while (re-search-forward "\n[\t ]" nil t)
2079 (replace-match " " t t)))
2080 (goto-char (point-max)))))))
2082 (defun gnus-article-treat-fold-headers ()
2083 "Fold message headers."
2085 (gnus-with-article-headers
2088 (mail-header-narrow-to-field)
2089 (mail-header-fold-field)
2090 (goto-char (point-max))))))
2092 (defun gnus-treat-smiley ()
2093 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2095 (gnus-with-article-buffer
2096 (if (memq 'smiley gnus-article-wash-types)
2097 (gnus-delete-images 'smiley)
2099 (let ((images (smiley-region (point) (point-max))))
2101 (gnus-add-wash-type 'smiley)
2102 (dolist (image images)
2103 (gnus-add-image 'smiley image)))))))
2105 (defun gnus-article-remove-images ()
2106 "Remove all images from the article buffer."
2108 (gnus-with-article-buffer
2109 (dolist (elem gnus-article-image-alist)
2110 (gnus-delete-images (car elem)))))
2112 (defun gnus-article-treat-fold-newsgroups ()
2113 "Unfold folded message headers.
2114 Only the headers that fit into the current window width will be
2117 (gnus-with-article-headers
2118 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2120 (mail-header-narrow-to-field)
2121 (while (re-search-forward ", *" nil t)
2122 (replace-match ", " t t))
2123 (mail-header-fold-field)
2124 (goto-char (point-max))))))
2126 (defun gnus-article-treat-body-boundary ()
2127 "Place a boundary line at the end of the headers."
2129 (when (and gnus-body-boundary-delimiter
2130 (> (length gnus-body-boundary-delimiter) 0))
2131 (gnus-with-article-headers
2132 (goto-char (point-max))
2133 (let ((start (point)))
2134 (insert "X-Boundary: ")
2135 (gnus-add-text-properties start (point) '(invisible t intangible t))
2137 (while (>= (1- (window-width)) (length str))
2138 (setq str (concat str gnus-body-boundary-delimiter)))
2139 (substring str 0 (1- (window-width))))
2141 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2143 (defun article-fill-long-lines ()
2144 "Fill lines that are wider than the window width."
2147 (let ((inhibit-read-only t)
2148 (width (window-width (get-buffer-window (current-buffer)))))
2151 (let ((adaptive-fill-mode nil)) ;Why? -sm
2154 (when (>= (current-column) (min fill-column width))
2155 (narrow-to-region (min (1+ (point)) (point-max))
2157 (let ((goback (point-marker)))
2158 (fill-paragraph nil)
2159 (goto-char (marker-position goback)))
2161 (forward-line 1)))))))
2163 (defun article-capitalize-sentences ()
2164 "Capitalize the first word in each sentence."
2167 (let ((inhibit-read-only t)
2168 (paragraph-start "^[\n\^L]"))
2172 (forward-sentence)))))
2174 (defun article-remove-cr ()
2175 "Remove trailing CRs and then translate remaining CRs into LFs."
2178 (let ((inhibit-read-only t))
2179 (goto-char (point-min))
2180 (while (re-search-forward "\r+$" nil t)
2181 (replace-match "" t t))
2182 (goto-char (point-min))
2183 (while (search-forward "\r" nil t)
2184 (replace-match "\n" t t)))))
2186 (defun article-remove-trailing-blank-lines ()
2187 "Remove all trailing blank lines from the article."
2190 (let ((inhibit-read-only t))
2191 (goto-char (point-max))
2195 (while (and (not (bobp))
2196 (looking-at "^[ \t]*$")
2197 (not (gnus-annotation-in-region-p
2198 (point) (point-at-eol))))
2204 (defvar gnus-face-properties-alist))
2206 (defun article-display-face ()
2207 "Display any Face headers in the header."
2209 (let ((wash-face-p buffer-read-only))
2210 (gnus-with-article-headers
2211 ;; When displaying parts, this function can be called several times on
2212 ;; the same article, without any intended toggle semantic (as typing `W
2213 ;; D d' would have). So face deletion must occur only when we come from
2214 ;; an interactive command, that is when the *Article* buffer is
2216 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2217 (gnus-delete-images 'face)
2218 (let (face faces from)
2219 (save-current-buffer
2220 (when (and wash-face-p
2221 (gnus-buffer-live-p gnus-original-article-buffer)
2222 (not (re-search-forward "^Face:[\t ]*" nil t)))
2223 (set-buffer gnus-original-article-buffer))
2225 (mail-narrow-to-head)
2226 (while (gnus-article-goto-header "Face")
2227 (push (mail-header-field-value) faces))))
2229 (goto-char (point-min))
2230 (let ((from (gnus-article-goto-header "from"))
2235 (insert "[no `from' set]\n"))
2237 (when (setq png (gnus-convert-face-to-png (pop faces)))
2239 (apply 'gnus-create-image png 'png t
2240 (cdr (assq 'png gnus-face-properties-alist))))
2242 (gnus-add-wash-type 'face)
2243 (gnus-add-image 'face image)
2244 (gnus-put-image image nil 'face))))))))))
2246 (defun article-display-x-face (&optional force)
2247 "Look for an X-Face header and display it if present."
2248 (interactive (list 'force))
2249 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2250 (gnus-with-article-headers
2251 ;; Delete the old process, if any.
2252 (when (process-status "article-x-face")
2253 (delete-process "article-x-face"))
2254 ;; See the comment in `article-display-face'.
2255 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2256 ;; We have already displayed X-Faces, so we remove them
2258 (gnus-delete-images 'xface)
2260 (let (x-faces from face)
2261 (save-current-buffer
2262 (when (and wash-face-p
2263 (gnus-buffer-live-p gnus-original-article-buffer)
2264 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2265 ;; If type `W f', use gnus-original-article-buffer,
2266 ;; otherwise use the current buffer because displaying
2267 ;; RFC822 parts calls this function too.
2268 (set-buffer gnus-original-article-buffer))
2270 (mail-narrow-to-head)
2271 (while (gnus-article-goto-header "X-Face")
2272 (push (mail-header-field-value) x-faces))
2273 (setq from (message-fetch-field "from"))))
2274 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2275 ;; single external face.
2276 (when (stringp gnus-article-x-face-command)
2277 (setq x-faces (list (car x-faces))))
2279 gnus-article-x-face-command
2281 ;; Check whether this face is censored.
2282 (not gnus-article-x-face-too-ugly)
2284 (not (string-match gnus-article-x-face-too-ugly
2286 (while (setq face (pop x-faces))
2287 ;; We display the face.
2288 (cond ((stringp gnus-article-x-face-command)
2289 ;; The command is a string, so we interpret the command
2290 ;; as a, well, command, and fork it off.
2291 (let ((process-connection-type nil))
2292 (gnus-set-process-query-on-exit-flag
2294 "article-x-face" nil shell-file-name
2295 shell-command-switch gnus-article-x-face-command)
2299 (process-send-region "article-x-face"
2300 (point-min) (point-max)))
2301 (process-send-eof "article-x-face")))
2302 ((functionp gnus-article-x-face-command)
2303 ;; The command is a lisp function, so we call it.
2304 (funcall gnus-article-x-face-command face))
2306 (error "%s is not a function"
2307 gnus-article-x-face-command))))))))))
2309 (defun article-decode-mime-words ()
2310 "Decode all MIME-encoded words in the article."
2312 (gnus-with-article-buffer
2313 (let ((inhibit-point-motion-hooks t)
2314 (mail-parse-charset gnus-newsgroup-charset)
2315 (mail-parse-ignored-charsets
2316 (with-current-buffer gnus-summary-buffer
2317 gnus-newsgroup-ignored-charsets)))
2318 (mail-decode-encoded-word-region (point-min) (point-max)))))
2320 (defun article-decode-charset (&optional prompt)
2321 "Decode charset-encoded text in the article.
2322 If PROMPT (the prefix), prompt for a coding system to use."
2324 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2325 (inhibit-read-only t)
2326 (mail-parse-charset gnus-newsgroup-charset)
2327 (mail-parse-ignored-charsets
2328 (save-excursion (condition-case nil
2329 (set-buffer gnus-summary-buffer)
2331 gnus-newsgroup-ignored-charsets))
2332 ct cte ctl charset format)
2335 (article-narrow-to-head)
2336 (setq ct (message-fetch-field "Content-Type" t)
2337 cte (message-fetch-field "Content-Transfer-Encoding" t)
2338 ctl (and ct (mail-header-parse-content-type ct))
2341 (mm-read-coding-system "Charset to decode: "))
2343 (mail-content-type-get ctl 'charset)))
2344 format (and ctl (mail-content-type-get ctl 'format)))
2346 (setq cte (mail-header-strip cte)))
2347 (if (and ctl (not (string-match "/" (car ctl))))
2349 (goto-char (point-max)))
2352 (narrow-to-region (point) (point-max))
2353 (when (and (eq mail-parse-charset 'gnus-decoded)
2354 (eq (mm-body-7-or-8) '8bit))
2355 ;; The text code could have been decoded.
2356 (setq charset mail-parse-charset))
2357 (when (and (or (not ctl)
2358 (equal (car ctl) "text/plain"))
2359 (not format)) ;; article with format will decode later.
2361 charset (and cte (intern (downcase
2362 (gnus-strip-whitespace cte))))
2365 (defun article-decode-encoded-words ()
2366 "Remove encoded-word encoding from headers."
2367 (let ((inhibit-point-motion-hooks t)
2368 (mail-parse-charset gnus-newsgroup-charset)
2369 (mail-parse-ignored-charsets
2370 (save-excursion (condition-case nil
2371 (set-buffer gnus-summary-buffer)
2373 gnus-newsgroup-ignored-charsets))
2374 (inhibit-read-only t))
2376 (article-narrow-to-head)
2377 (funcall gnus-decode-header-function (point-min) (point-max)))))
2379 (defun article-decode-group-name ()
2380 "Decode group names in `Newsgroups:'."
2381 (let ((inhibit-point-motion-hooks t)
2382 (inhibit-read-only t)
2383 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2384 (when (and (or gnus-group-name-charset-method-alist
2385 gnus-group-name-charset-group-alist)
2386 (gnus-buffer-live-p gnus-original-article-buffer))
2388 (article-narrow-to-head)
2389 (with-current-buffer gnus-original-article-buffer
2390 (goto-char (point-min)))
2391 (while (re-search-forward
2392 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2393 (replace-match (save-match-data
2394 (gnus-decode-newsgroups
2395 ;; XXX how to use data in article buffer?
2396 (with-current-buffer gnus-original-article-buffer
2398 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2401 gnus-newsgroup-name method))
2403 (goto-char (point-min))
2404 (with-current-buffer gnus-original-article-buffer
2405 (goto-char (point-min)))
2406 (while (re-search-forward
2407 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2408 (replace-match (save-match-data
2409 (gnus-decode-newsgroups
2410 ;; XXX how to use data in article buffer?
2411 (with-current-buffer gnus-original-article-buffer
2413 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2416 gnus-newsgroup-name method))
2419 (autoload 'idna-to-unicode "idna")
2421 (defun article-decode-idna-rhs ()
2422 "Decode IDNA strings in RHS in various headers in current buffer.
2423 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2424 Mail-Reply-To: and Mail-Followup-To:."
2427 (let ((inhibit-point-motion-hooks t)
2428 (inhibit-read-only t))
2429 (article-narrow-to-head)
2430 (goto-char (point-min))
2431 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2433 (when (save-match-data
2434 (and (setq ace (match-string 1))
2436 (and (re-search-backward "^[^ \t]" nil t)
2437 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2438 (setq unicode (idna-to-unicode ace))))
2439 (unless (string= ace unicode)
2440 (replace-match unicode nil nil nil 1)))))))))
2442 (defun article-de-quoted-unreadable (&optional force read-charset)
2443 "Translate a quoted-printable-encoded article.
2444 If FORCE, decode the article whether it is marked as quoted-printable
2446 If READ-CHARSET, ask for a coding system."
2447 (interactive (list 'force current-prefix-arg))
2449 (let ((inhibit-read-only t) type charset)
2450 (if (gnus-buffer-live-p gnus-original-article-buffer)
2451 (with-current-buffer gnus-original-article-buffer
2453 (gnus-fetch-field "content-transfer-encoding"))
2454 (let* ((ct (gnus-fetch-field "content-type"))
2455 (ctl (and ct (mail-header-parse-content-type ct))))
2456 (setq charset (and ctl
2457 (mail-content-type-get ctl 'charset)))
2458 (if (stringp charset)
2459 (setq charset (intern (downcase charset)))))))
2461 (setq charset (mm-read-coding-system "Charset: " charset)))
2463 (setq charset gnus-newsgroup-charset))
2465 (and type (let ((case-fold-search t))
2466 (string-match "quoted-printable" type))))
2468 (quoted-printable-decode-region
2469 (point) (point-max) (mm-charset-to-coding-system charset))))))
2471 (defun article-de-base64-unreadable (&optional force read-charset)
2472 "Translate a base64 article.
2473 If FORCE, decode the article whether it is marked as base64 not.
2474 If READ-CHARSET, ask for a coding system."
2475 (interactive (list 'force current-prefix-arg))
2477 (let ((inhibit-read-only t) type charset)
2478 (if (gnus-buffer-live-p gnus-original-article-buffer)
2479 (with-current-buffer gnus-original-article-buffer
2481 (gnus-fetch-field "content-transfer-encoding"))
2482 (let* ((ct (gnus-fetch-field "content-type"))
2483 (ctl (and ct (mail-header-parse-content-type ct))))
2484 (setq charset (and ctl
2485 (mail-content-type-get ctl 'charset)))
2486 (if (stringp charset)
2487 (setq charset (intern (downcase charset)))))))
2489 (setq charset (mm-read-coding-system "Charset: " charset)))
2491 (setq charset gnus-newsgroup-charset))
2493 (and type (let ((case-fold-search t))
2494 (string-match "base64" type))))
2497 (narrow-to-region (point) (point-max))
2498 (base64-decode-region (point-min) (point-max))
2499 (mm-decode-coding-region
2500 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2505 (defun article-decode-HZ ()
2506 "Translate a HZ-encoded article."
2510 (let ((inhibit-read-only t))
2511 (rfc1843-decode-region (point-min) (point-max)))))
2513 (defun article-unsplit-urls ()
2514 "Remove the newlines that some other mailers insert into URLs."
2517 (let ((inhibit-read-only t))
2518 (goto-char (point-min))
2519 (while (re-search-forward
2520 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2521 (replace-match "\\1\\3" t)))
2522 (when (interactive-p)
2523 (gnus-treat-article nil))))
2526 (defun article-wash-html (&optional read-charset)
2527 "Format an HTML article.
2528 If READ-CHARSET, ask for a coding system. If it is a number, the
2529 charset defined in `gnus-summary-show-article-charset-alist' is used."
2532 (let ((inhibit-read-only t)
2535 (if (or (and (numberp read-charset)
2539 gnus-summary-show-article-charset-alist))))
2540 (setq charset (mm-read-coding-system "Charset: ")))
2541 (let ((gnus-summary-show-article-charset-alist
2542 (list (cons 1 charset))))
2543 (with-current-buffer gnus-summary-buffer
2544 (gnus-summary-show-article 1)))
2545 (error "No charset is given"))
2546 (when (gnus-buffer-live-p gnus-original-article-buffer)
2547 (with-current-buffer gnus-original-article-buffer
2548 (let* ((ct (gnus-fetch-field "content-type"))
2549 (ctl (and ct (mail-header-parse-content-type ct))))
2550 (setq charset (and ctl
2551 (mail-content-type-get ctl 'charset)))
2552 (when (stringp charset)
2553 (setq charset (intern (downcase charset)))))))
2555 (setq charset gnus-newsgroup-charset)))
2557 (save-window-excursion
2559 (narrow-to-region (point) (point-max))
2560 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2561 (entry (assq func mm-text-html-washer-alist)))
2563 (setq func (cdr entry)))
2568 (apply (car func) (cdr func))))))))))
2570 (defun gnus-article-wash-html-with-w3 ()
2571 "Wash the current buffer with w3."
2573 (let ((w3-strict-width (window-width))
2574 (url-standalone-mode t)
2575 (url-gateway-unplugged t)
2576 (w3-honor-stylesheets nil))
2578 (w3-region (point-min) (point-max))
2581 (defun gnus-article-wash-html-with-w3m ()
2582 "Wash the current buffer with emacs-w3m."
2584 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2585 w3m-force-redisplay)
2586 (w3m-region (point-min) (point-max)))
2587 (when (and mm-inline-text-html-with-w3m-keymap
2588 (boundp 'w3m-minor-mode-map)
2590 (add-text-properties
2591 (point-min) (point-max)
2592 (list 'keymap w3m-minor-mode-map
2593 ;; Put the mark meaning this part was rendered by emacs-w3m.
2594 'mm-inline-text-html-with-w3m t))))
2596 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2598 (defun gnus-article-wash-html-with-w3m-standalone ()
2599 "Wash the current buffer with w3m."
2600 (if (mm-w3m-standalone-supports-m17n-p)
2602 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2604 (setq charset 'iso-8859-1))
2605 (let ((coding-system-for-write charset)
2606 (coding-system-for-read charset))
2607 (call-process-region
2608 (point-min) (point-max)
2609 "w3m" t t nil "-dump" "-T" "text/html"
2610 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2611 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2613 (defvar gnus-article-browse-html-temp-list nil
2614 "List of temporary files created by `gnus-article-browse-html-parts'.
2615 Internal variable.")
2617 (defcustom gnus-article-browse-delete-temp 'ask
2618 "What to do with temporary files from `gnus-article-browse-html-parts'.
2619 If nil, don't delete temporary files. If it is t, delete them on
2620 exit from the summary buffer. If it is the symbol `file', query
2621 on each file, if it is `ask' ask once when exiting from the
2623 :group 'gnus-article
2624 :version "23.0" ;; No Gnus
2625 :type '(choice (const :tag "Don't delete" nil)
2626 (const :tag "Don't ask" t)
2627 (const :tag "Ask" ask)
2628 (const :tag "Ask for each file" file)))
2630 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2632 (defun gnus-article-browse-delete-temp-files (&optional how)
2633 "Delete temp-files created by `gnus-article-browse-html-parts'."
2634 (when (and gnus-article-browse-html-temp-list
2636 (setq how gnus-article-browse-delete-temp)))
2637 (when (and (eq how 'ask)
2639 "Delete all %s temporary HTML file(s)? "
2640 (length gnus-article-browse-html-temp-list)))
2642 (dolist (file gnus-article-browse-html-temp-list)
2643 (when (and (file-exists-p file)
2645 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2647 (format "Delete temporary HTML file `%s'? " file))))
2648 (delete-file file)))
2649 ;; Also remove file from the list when not deleted or if file doesn't
2651 (setq gnus-article-browse-html-temp-list nil))
2652 gnus-article-browse-html-temp-list)
2654 (defun gnus-article-browse-html-parts (list)
2655 "View all \"text/html\" parts from LIST.
2656 Recurse into multiparts."
2657 ;; Internal function used by `gnus-article-browse-html-article'.
2659 ;; Find and show the html-parts.
2660 (dolist (handle list)
2661 ;; If HTML, show it:
2662 (when (listp handle)
2663 (cond ((and (bufferp (car handle))
2664 (string-match "text/html" (car (mm-handle-type handle))))
2665 (let ((tmp-file (mm-make-temp-file
2666 ;; Do we need to care for 8.3 filenames?
2667 "mm-" nil ".html")))
2668 (mm-save-part-to-file handle tmp-file)
2669 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2670 (add-hook 'gnus-summary-prepare-exit-hook
2671 'gnus-article-browse-delete-temp-files)
2672 (add-hook 'gnus-exit-gnus-hook
2674 (gnus-article-browse-delete-temp-files t)))
2675 (browse-url tmp-file)
2677 ;; If multipart, recurse
2678 ((and (stringp (car handle))
2679 (string-match "^multipart/" (car handle))
2682 (gnus-article-browse-html-parts handle))))))))
2685 ;; TODO: Key binding
2686 (defun gnus-article-browse-html-article ()
2687 "View \"text/html\" parts of the current article with a WWW browser."
2689 (save-window-excursion
2690 ;; Open raw article and select the buffer
2691 (gnus-summary-show-article t)
2692 (gnus-summary-select-article-buffer)
2693 (let ((parts (mm-dissect-buffer t t)))
2694 ;; If singlepart, enforce a list.
2695 (when (and (bufferp (car parts))
2696 (stringp (car (mm-handle-type parts))))
2697 (setq parts (list parts)))
2699 (unless (gnus-article-browse-html-parts parts)
2700 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2701 (gnus-summary-show-article))))
2703 (defun article-hide-list-identifiers ()
2704 "Remove list identifies from the Subject header.
2705 The `gnus-list-identifiers' variable specifies what to do."
2707 (let ((inhibit-point-motion-hooks t)
2708 (regexp (if (consp gnus-list-identifiers)
2709 (mapconcat 'identity gnus-list-identifiers " *\\|")
2710 gnus-list-identifiers))
2711 (inhibit-read-only t))
2715 (article-narrow-to-head)
2716 (goto-char (point-min))
2717 (while (re-search-forward
2718 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2720 (delete-region (match-beginning 2) (match-end 0))
2721 (beginning-of-line))
2722 (when (re-search-forward
2723 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2724 (delete-region (match-beginning 1) (match-end 1))))))))
2726 (defun article-hide-pem (&optional arg)
2727 "Toggle hiding of any PEM headers and signatures in the current article.
2728 If given a negative prefix, always show; if given a positive prefix,
2730 (interactive (gnus-article-hidden-arg))
2731 (unless (gnus-article-check-hidden-text 'pem arg)
2733 (let ((inhibit-read-only t) end)
2734 (goto-char (point-min))
2735 ;; Hide the horrendously ugly "header".
2736 (when (and (search-forward
2737 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2739 (setq end (1+ (match-beginning 0))))
2740 (gnus-add-wash-type 'pem)
2741 (gnus-article-hide-text-type
2743 (if (search-forward "\n\n" nil t)
2747 ;; Hide the trailer as well
2748 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2750 (gnus-article-hide-text-type
2751 (match-beginning 0) (match-end 0) 'pem)))))))
2753 (defun article-strip-banner ()
2754 "Strip the banners specified by the `banner' group parameter and by
2755 `gnus-article-address-banner-alist'."
2759 (let ((inhibit-point-motion-hooks t))
2760 (when (gnus-parameter-banner gnus-newsgroup-name)
2761 (article-really-strip-banner
2762 (gnus-parameter-banner gnus-newsgroup-name)))
2763 (when gnus-article-address-banner-alist
2764 ;; Note that the From header is decoded here, so it is
2765 ;; required that the *-extract-address-components function
2766 ;; supports non-ASCII text.
2767 (let ((from (save-restriction
2769 (article-narrow-to-head)
2770 (mail-fetch-field "from"))))
2773 (cadr (funcall gnus-extract-address-components
2776 (dolist (pair gnus-article-address-banner-alist)
2777 (when (string-match (car pair) from)
2779 (article-really-strip-banner (cdr pair)))))))))))))
2781 (defun article-really-strip-banner (banner)
2782 "Strip the banner specified by the argument."
2785 (let ((inhibit-point-motion-hooks t)
2786 (gnus-signature-limit nil)
2787 (inhibit-read-only t))
2790 ((eq banner 'signature)
2791 (when (gnus-article-narrow-to-signature)
2794 (delete-region (point) (point-max))))
2796 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2797 (while (re-search-forward banner nil t)
2798 (delete-region (match-beginning 0) (match-end 0)))))
2800 (while (re-search-forward banner nil t)
2801 (delete-region (match-beginning 0) (match-end 0)))))))))
2803 (defun article-babel ()
2804 "Translate article using an online translation service."
2807 (gnus-with-article-buffer
2808 (when (article-goto-body)
2809 (let* ((start (point))
2811 (orig (buffer-substring start end))
2812 (trans (babel-as-string orig)))
2814 (narrow-to-region start end)
2815 (delete-region start end)
2818 (defun article-hide-signature (&optional arg)
2819 "Hide the signature in the current article.
2820 If given a negative prefix, always show; if given a positive prefix,
2822 (interactive (gnus-article-hidden-arg))
2823 (unless (gnus-article-check-hidden-text 'signature arg)
2826 (let ((inhibit-read-only t))
2827 (when (gnus-article-narrow-to-signature)
2828 (gnus-article-hide-text-type
2829 (point-min) (point-max) 'signature))))))
2830 (gnus-set-mode-line 'article))
2832 (defun article-strip-headers-in-body ()
2833 "Strip offensive headers from bodies."
2837 (let ((case-fold-search t))
2838 (when (looking-at "x-no-archive:")
2839 (gnus-delete-line)))))
2841 (defun article-strip-leading-blank-lines ()
2842 "Remove all blank lines from the beginning of the article."
2845 (let ((inhibit-point-motion-hooks t)
2846 (inhibit-read-only t))
2847 (when (article-goto-body)
2848 (while (and (not (eobp))
2849 (looking-at "[ \t]*$"))
2850 (gnus-delete-line))))))
2852 (defun article-narrow-to-head ()
2853 "Narrow the buffer to the head of the message.
2854 Point is left at the beginning of the narrowed-to region."
2856 (goto-char (point-min))
2857 (if (search-forward "\n\n" nil 1)
2860 (goto-char (point-min)))
2862 (defun article-goto-body ()
2863 "Place point at the start of the body."
2864 (goto-char (point-min))
2866 ;; This variable is only bound when dealing with separate
2868 (article-goto-body-goes-to-point-min-p
2870 ((search-forward "\n\n" nil t)
2873 (goto-char (point-max))
2876 (defun article-strip-multiple-blank-lines ()
2877 "Replace consecutive blank lines with one empty line."
2880 (let ((inhibit-point-motion-hooks t)
2881 (inhibit-read-only t))
2882 ;; First make all blank lines empty.
2884 (while (re-search-forward "^[ \t]+$" nil t)
2885 (unless (gnus-annotation-in-region-p
2886 (match-beginning 0) (match-end 0))
2887 (replace-match "" nil t)))
2888 ;; Then replace multiple empty lines with a single empty line.
2890 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2891 (unless (gnus-annotation-in-region-p
2892 (match-beginning 0) (match-end 0))
2893 (delete-region (match-beginning 1) (match-end 1)))))))
2895 (defun article-strip-leading-space ()
2896 "Remove all white space from the beginning of the lines in the article."
2899 (let ((inhibit-point-motion-hooks t)
2900 (inhibit-read-only t))
2902 (while (re-search-forward "^[ \t]+" nil t)
2903 (replace-match "" t t)))))
2905 (defun article-strip-trailing-space ()
2906 "Remove all white space from the end of the lines in the article."
2909 (let ((inhibit-point-motion-hooks t)
2910 (inhibit-read-only t))
2912 (while (re-search-forward "[ \t]+$" nil t)
2913 (replace-match "" t t)))))
2915 (defun article-strip-blank-lines ()
2916 "Strip leading, trailing and multiple blank lines."
2918 (article-strip-leading-blank-lines)
2919 (article-remove-trailing-blank-lines)
2920 (article-strip-multiple-blank-lines))
2922 (defun article-strip-all-blank-lines ()
2923 "Strip all blank lines."
2926 (let ((inhibit-point-motion-hooks t)
2927 (inhibit-read-only t))
2929 (while (re-search-forward "^[ \t]*\n" nil t)
2930 (replace-match "" t t)))))
2932 (defun gnus-article-narrow-to-signature ()
2933 "Narrow to the signature; return t if a signature is found, else nil."
2934 (let ((inhibit-point-motion-hooks t))
2935 (when (gnus-article-search-signature)
2937 ;; Check whether we have some limits to what we consider
2938 ;; to be a signature.
2939 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2940 (list gnus-signature-limit)))
2942 (while (setq limit (pop limits))
2943 (if (or (and (integerp limit)
2944 (< (- (point-max) (point)) limit))
2946 (< (count-lines (point) (point-max)) limit))
2947 (and (functionp limit)
2949 (and (stringp limit)
2950 (not (re-search-forward limit nil t))))
2951 () ; This limit did not succeed.
2955 (narrow-to-region (point) (point-max))
2958 (defun gnus-article-search-signature ()
2959 "Search the current buffer for the signature separator.
2960 Put point at the beginning of the signature separator."
2961 (let ((cur (point)))
2962 (goto-char (point-max))
2963 (if (if (stringp gnus-signature-separator)
2964 (re-search-backward gnus-signature-separator nil t)
2965 (let ((seps gnus-signature-separator))
2967 (not (re-search-backward (car seps) nil t)))
2974 (defun gnus-article-hidden-arg ()
2975 "Return the current prefix arg as a number, or 0 if no prefix."
2976 (list (if current-prefix-arg
2977 (prefix-numeric-value current-prefix-arg)
2980 (defun gnus-article-check-hidden-text (type arg)
2981 "Return nil if hiding is necessary.
2982 Arg can be nil or a number. nil and positive means hide, negative
2983 means show, 0 means toggle."
2986 (let ((hide (gnus-article-hidden-text-p type)))
2992 (gnus-article-show-hidden-text type)
2995 (if (eq hide 'hidden)
2997 (gnus-article-show-hidden-text type)
3001 (defun gnus-article-hidden-text-p (type)
3002 "Say whether the current buffer contains hidden text of type TYPE."
3003 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3005 (not (get-text-property pos 'invisible))
3006 (not (get-text-property pos 'dummy-invisible)))
3008 (text-property-any (1+ pos) (point-max) 'article-type type)))
3013 (defun gnus-article-show-hidden-text (type &optional dummy)
3014 "Show all hidden text of type TYPE.
3015 Originally it is hide instead of DUMMY."
3016 (let ((inhibit-read-only t)
3017 (inhibit-point-motion-hooks t))
3018 (gnus-remove-text-properties-when
3020 (point-min) (point-max)
3021 (cons 'article-type (cons type
3022 gnus-hidden-properties)))
3023 (gnus-delete-wash-type type)))
3025 (defconst article-time-units
3026 `((year . ,(* 365.25 24 60 60))
3027 (week . ,(* 7 24 60 60))
3028 (day . ,(* 24 60 60))
3032 "Mapping from time units to seconds.")
3034 (defun gnus-article-forward-header ()
3035 "Move point to the start of the next header.
3036 If the current header is a continuation header, this can be several
3041 (if (looking-at "[ \t]+[^ \t]")
3045 (defun article-date-ut (&optional type highlight)
3046 "Convert DATE date to universal time in the current article.
3047 If TYPE is `local', convert to local time; if it is `lapsed', output
3048 how much time has lapsed since DATE. For `lapsed', the value of
3049 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3050 should replace the \"Date:\" one, or should be added below it."
3051 (interactive (list 'ut t))
3052 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3053 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3057 (article-lapsed-timer
3061 (case-fold-search t)
3062 (inhibit-read-only t)
3063 (inhibit-point-motion-hooks t)
3064 pos date bface eface)
3068 (goto-char (point-min))
3069 (while (or (setq date (get-text-property (setq pos (point))
3071 (when (setq pos (next-single-property-change
3072 (point) 'original-date))
3073 (setq date (get-text-property pos 'original-date))
3075 (narrow-to-region pos (or (text-property-any pos (point-max)
3078 (goto-char (point-min))
3079 (when (re-search-forward tdate-regexp nil t)
3080 (setq bface (get-text-property (point-at-bol) 'face)
3081 eface (get-text-property (1- (point-at-eol)) 'face)))
3082 (goto-char (point-min))
3084 ;; Delete any old Date headers.
3085 (while (re-search-forward date-regexp nil t)
3087 (delete-region (point-at-bol) (progn
3088 (gnus-article-forward-header)
3090 (delete-region (point-at-bol) (progn
3091 (gnus-article-forward-header)
3094 (setq pos (point))))
3095 (when (and (not pos)
3096 (re-search-forward tdate-regexp nil t))
3098 (gnus-goto-char pos)
3099 (insert (article-make-date-line date (or type 'ut)))
3105 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3106 (put-text-property (match-beginning 1) (1+ (match-end 1))
3108 (put-text-property (match-beginning 2) (match-end 2)
3110 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3111 (goto-char (point-max))
3114 (defun article-make-date-line (date type)
3115 "Return a DATE line of TYPE."
3116 (unless (memq type '(local ut original user iso8601 lapsed english))
3117 (error "Unknown conversion type: %s" type))
3119 (let ((time (date-to-time date)))
3121 ;; Convert to the local timezone.
3123 (concat "Date: " (message-make-date time)))
3124 ;; Convert to Universal Time.
3129 (let* ((e (parse-time-string date))
3130 (tm (apply 'encode-time e))
3132 (ls (- (cadr tm) (car (current-time-zone time)))))
3133 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3134 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3138 ;; Get the original date from the article.
3139 ((eq type 'original)
3140 (concat "Date: " (if (string-match "\n+$" date)
3141 (substring date 0 (match-beginning 0))
3143 ;; Let the user define the format.
3145 (let ((format (or (condition-case nil
3146 (with-current-buffer gnus-summary-buffer
3147 gnus-article-time-format)
3149 gnus-article-time-format)))
3150 (if (functionp format)
3151 (funcall format time)
3152 (concat "Date: " (format-time-string format time)))))
3155 (let ((tz (car (current-time-zone time))))
3158 (format-time-string "%Y%m%dT%H%M%S" time)
3159 (format "%s%02d%02d"
3160 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3161 (/ (% (abs tz) 3600) 60)))))
3162 ;; Do an X-Sent lapsed format.
3164 ;; If the date is seriously mangled, the timezone functions are
3165 ;; liable to bug out, so we ignore all errors.
3166 (let* ((now (current-time))
3167 (real-time (subtract-time now time))
3168 (real-sec (and real-time
3169 (+ (* (float (car real-time)) 65536)
3171 (sec (and real-time (abs real-sec)))
3181 ;; This is a bit convoluted, but basically we go
3182 ;; through the time units for years, weeks, etc,
3183 ;; and divide things to see whether that results
3184 ;; in positive answers.
3187 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3188 ;; The (remaining) seconds are too few to
3189 ;; be divided into this time unit.
3191 ;; It's big enough, so we output it.
3192 (setq sec (- sec (* num (cdr unit))))
3194 (concat (if prev ", " "") (int-to-string
3196 " " (symbol-name (car unit))
3197 (if (> num 1) "s" ""))
3199 article-time-units "")
3200 ;; If dates are odd, then it might appear like the
3201 ;; article was sent in the future.
3204 " in the future"))))))
3205 ;; Display the date in proper English
3207 (let ((dtime (decode-time time)))
3210 (number-to-string (nth 3 dtime))
3211 (let ((digit (% (nth 3 dtime) 10)))
3213 ((memq (nth 3 dtime) '(11 12 13)) "th")
3219 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3221 (number-to-string (nth 5 dtime))
3223 (format "%02d" (nth 2 dtime))
3225 (format "%02d" (nth 1 dtime)))))))
3227 (format "Date: %s (from Gnus)" date))))
3229 (defun article-date-local (&optional highlight)
3230 "Convert the current article date to the local timezone."
3231 (interactive (list t))
3232 (article-date-ut 'local highlight))
3234 (defun article-date-english (&optional highlight)
3235 "Convert the current article date to something that is proper English."
3236 (interactive (list t))
3237 (article-date-ut 'english highlight))
3239 (defun article-date-original (&optional highlight)
3240 "Convert the current article date to what it was originally.
3241 This is only useful if you have used some other date conversion
3242 function and want to see what the date was before converting."
3243 (interactive (list t))
3244 (article-date-ut 'original highlight))
3246 (defun article-date-lapsed (&optional highlight)
3247 "Convert the current article date to time lapsed since it was sent."
3248 (interactive (list t))
3249 (article-date-ut 'lapsed highlight))
3251 (defun article-update-date-lapsed ()
3252 "Function to be run from a timer to update the lapsed time line."
3254 (let (deactivate-mark)
3259 (set-buffer (window-buffer w))
3260 (when (eq major-mode 'gnus-article-mode)
3261 (let ((mark (point-marker)))
3262 (goto-char (point-min))
3263 (when (re-search-forward "^X-Sent:" nil t)
3264 (article-date-lapsed t))
3265 (goto-char (marker-position mark))
3266 (move-marker mark nil))))
3269 (defun gnus-start-date-timer (&optional n)
3270 "Start a timer to update the X-Sent header in the article buffers.
3271 The numerical prefix says how frequently (in seconds) the function
3276 (gnus-stop-date-timer)
3277 (setq article-lapsed-timer
3278 (run-at-time 1 n 'article-update-date-lapsed)))
3280 (defun gnus-stop-date-timer ()
3281 "Stop the X-Sent timer."
3283 (when article-lapsed-timer
3284 (nnheader-cancel-timer article-lapsed-timer)
3285 (setq article-lapsed-timer nil)))
3287 (defun article-date-user (&optional highlight)
3288 "Convert the current article date to the user-defined format.
3289 This format is defined by the `gnus-article-time-format' variable."
3290 (interactive (list t))
3291 (article-date-ut 'user highlight))
3293 (defun article-date-iso8601 (&optional highlight)
3294 "Convert the current article date to ISO8601."
3295 (interactive (list t))
3296 (article-date-ut 'iso8601 highlight))
3298 (defmacro gnus-article-save-original-date (&rest forms)
3299 "Save the original date as a text property and evaluate FORMS."
3300 `(let* ((case-fold-search t)
3302 (goto-char (point-min))
3303 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3306 (date (when (and start
3307 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3309 (buffer-substring-no-properties start
3310 (match-beginning 0)))))
3311 (goto-char (point-max))
3312 (skip-chars-backward "\n")
3313 (put-text-property (point-min) (point) 'original-date date)
3315 (goto-char (point-max))
3316 (skip-chars-backward "\n")
3317 (put-text-property (point-min) (point) 'original-date date)))
3319 ;; (defun article-show-all ()
3320 ;; "Show all hidden text in the article buffer."
3323 ;; (let ((inhibit-read-only t))
3324 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3326 (defun article-remove-leading-whitespace ()
3327 "Remove excessive whitespace from all headers."
3331 (let ((inhibit-read-only t))
3332 (article-narrow-to-head)
3333 (goto-char (point-min))
3334 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3335 (delete-region (match-beginning 1) (match-end 1)))))))
3337 (defun article-emphasize (&optional arg)
3338 "Emphasize text according to `gnus-emphasis-alist'."
3339 (interactive (gnus-article-hidden-arg))
3340 (unless (gnus-article-check-hidden-text 'emphasis arg)
3344 (with-current-buffer gnus-summary-buffer
3345 gnus-article-emphasis-alist)
3347 gnus-emphasis-alist))
3348 (inhibit-read-only t)
3349 (props (append '(article-type emphasis)
3350 gnus-hidden-properties))
3351 regexp elem beg invisible visible face)
3354 (while (setq elem (pop alist))
3356 (setq regexp (car elem)
3357 invisible (nth 1 elem)
3358 visible (nth 2 elem)
3360 (while (re-search-forward regexp nil t)
3361 (when (and (match-beginning visible) (match-beginning invisible))
3362 (gnus-article-hide-text
3363 (match-beginning invisible) (match-end invisible) props)
3364 (gnus-article-unhide-text-type
3365 (match-beginning visible) (match-end visible) 'emphasis)
3366 (gnus-put-overlay-excluding-newlines
3367 (match-beginning visible) (match-end visible) 'face face)
3368 (gnus-add-wash-type 'emphasis)
3369 (goto-char (match-end invisible)))))))))
3371 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3372 "Setup newsgroup emphasis alist."
3373 (unless gnus-article-emphasis-alist
3374 (let ((name (and gnus-newsgroup-name
3375 (gnus-group-real-name gnus-newsgroup-name))))
3376 (make-local-variable 'gnus-article-emphasis-alist)
3377 (setq gnus-article-emphasis-alist
3379 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3380 (while (setq elem (pop alist))
3381 (when (and name (string-match (car elem) name))
3383 highlight (copy-sequence (cdr elem)))))
3385 (copy-sequence highlight-words)
3386 (if gnus-newsgroup-name
3387 (copy-sequence (gnus-group-find-parameter
3388 gnus-newsgroup-name 'highlight-words t)))
3389 gnus-emphasis-alist)))))
3392 (defvar gnus-summary-article-menu)
3393 (defvar gnus-summary-post-menu))
3395 ;;; Saving functions.
3397 (defun gnus-article-save (save-buffer file &optional num)
3398 "Save the currently selected article."
3399 (unless gnus-save-all-headers
3400 ;; Remove headers according to `gnus-saved-headers'.
3401 (let ((gnus-visible-headers
3402 (or gnus-saved-headers gnus-visible-headers))
3403 (gnus-article-buffer save-buffer))
3405 (set-buffer save-buffer)
3406 (article-hide-headers 1 t))))
3407 (save-window-excursion
3408 (if (not gnus-default-article-saver)
3409 (error "No default saver is defined")
3410 ;; !!! Magic! The saving functions all save
3411 ;; `gnus-save-article-buffer' (or so they think), but we
3412 ;; bind that variable to our save-buffer.
3413 (set-buffer gnus-article-buffer)
3414 (let* ((gnus-save-article-buffer save-buffer)
3417 ((not gnus-prompt-before-saving) 'default)
3418 ((eq gnus-prompt-before-saving 'always) nil)
3420 (gnus-number-of-articles-to-be-saved
3421 (when (eq gnus-prompt-before-saving t)
3423 (set-buffer gnus-article-current-summary)
3424 (funcall gnus-default-article-saver filename)))))
3426 (defun gnus-read-save-file-name (prompt &optional filename
3427 function group headers variable)
3429 (funcall function group headers (symbol-value variable)))
3434 ((eq filename 'default)
3440 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3443 (if (and gnus-number-of-articles-to-be-saved
3444 (> gnus-number-of-articles-to-be-saved 1))
3445 (format "these %d articles"
3446 gnus-number-of-articles-to-be-saved)
3449 ;; Let the split methods have their say.
3451 ;; No split name was found.
3454 (concat prompt " (default "
3455 (file-name-nondirectory default-name) "): ")
3456 (file-name-directory default-name)
3458 ;; A single group name is returned.
3459 ((stringp split-name)
3461 (funcall function split-name headers
3462 (symbol-value variable)))
3464 (concat prompt " (default "
3465 (file-name-nondirectory default-name) "): ")
3466 (file-name-directory default-name)
3468 ;; A single split name was found
3469 ((= 1 (length split-name))
3470 (let* ((name (expand-file-name
3472 gnus-article-save-directory))
3473 (dir (cond ((file-directory-p name)
3474 (file-name-as-directory name))
3475 ((file-exists-p name) name)
3476 (t gnus-article-save-directory))))
3478 (concat prompt " (default " name "): ")
3480 ;; A list of splits was found.
3482 (setq split-name (nreverse split-name))
3484 (let ((file-name-history
3485 (nconc split-name file-name-history)))
3489 (concat prompt " (`M-p' for defaults): ")
3490 gnus-article-save-directory
3492 gnus-article-save-directory)))
3493 (car (push result file-name-history)))))))
3494 ;; Create the directory.
3495 (gnus-make-directory (file-name-directory file))
3496 ;; If we have read a directory, we append the default file name.
3497 (when (file-directory-p file)
3498 (setq file (expand-file-name (file-name-nondirectory
3500 (file-name-as-directory file))))
3501 ;; Possibly translate some characters.
3502 (nnheader-translate-file-chars file))))))
3503 (gnus-make-directory (file-name-directory result))
3504 (set variable result)))
3506 (defun gnus-article-archive-name (group)
3507 "Return the first instance of an \"Archive-name\" in the current buffer."
3508 (let ((case-fold-search t))
3509 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3510 (nnheader-concat gnus-article-save-directory
3511 (match-string 1)))))
3513 (defun gnus-article-nndoc-name (group)
3514 "If GROUP is an nndoc group, return the name of the parent group."
3515 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3516 (gnus-group-get-parameter group 'save-article-group)))
3518 (defun gnus-summary-save-in-rmail (&optional filename)
3519 "Append this article to Rmail file.
3520 Optional argument FILENAME specifies file name.
3521 Directory to save to is default to `gnus-article-save-directory'."
3522 (setq filename (gnus-read-save-file-name
3523 "Save %s in rmail file" filename
3524 gnus-rmail-save-name gnus-newsgroup-name
3525 gnus-current-headers 'gnus-newsgroup-last-rmail))
3526 (gnus-eval-in-buffer-window gnus-save-article-buffer
3530 (gnus-output-to-rmail filename))))
3533 (defun gnus-summary-save-in-mail (&optional filename)
3534 "Append this article to Unix mail file.
3535 Optional argument FILENAME specifies file name.
3536 Directory to save to is default to `gnus-article-save-directory'."
3537 (setq filename (gnus-read-save-file-name
3538 "Save %s in Unix mail file" filename
3539 gnus-mail-save-name gnus-newsgroup-name
3540 gnus-current-headers 'gnus-newsgroup-last-mail))
3541 (gnus-eval-in-buffer-window gnus-save-article-buffer
3545 (if (and (file-readable-p filename)
3546 (file-regular-p filename)
3547 (mail-file-babyl-p filename))
3548 (rmail-output-to-rmail-file filename t)
3549 (gnus-output-to-mail filename)))))
3552 (defun gnus-summary-save-in-file (&optional filename overwrite)
3553 "Append this article to file.
3554 Optional argument FILENAME specifies file name.
3555 Directory to save to is default to `gnus-article-save-directory'."
3556 (setq filename (gnus-read-save-file-name
3557 "Save %s in file" filename
3558 gnus-file-save-name gnus-newsgroup-name
3559 gnus-current-headers 'gnus-newsgroup-last-file))
3560 (gnus-eval-in-buffer-window gnus-save-article-buffer
3564 (when (and overwrite
3565 (file-exists-p filename))
3566 (delete-file filename))
3567 (gnus-output-to-file filename))))
3570 (defun gnus-summary-write-to-file (&optional filename)
3571 "Write this article to a file, overwriting it if the file exists.
3572 Optional argument FILENAME specifies file name.
3573 The directory to save in defaults to `gnus-article-save-directory'."
3574 (gnus-summary-save-in-file nil t))
3576 (defun gnus-summary-save-body-in-file (&optional filename)
3577 "Append this article body to a file.
3578 Optional argument FILENAME specifies file name.
3579 The directory to save in defaults to `gnus-article-save-directory'."
3580 (setq filename (gnus-read-save-file-name
3581 "Save %s body in file" filename
3582 gnus-file-save-name gnus-newsgroup-name
3583 gnus-current-headers 'gnus-newsgroup-last-file))
3584 (gnus-eval-in-buffer-window gnus-save-article-buffer
3588 (when (article-goto-body)
3589 (narrow-to-region (point) (point-max)))
3590 (gnus-output-to-file filename))))
3593 (defun gnus-summary-save-in-pipe (&optional command)
3594 "Pipe this article to subprocess."
3596 (cond ((and (eq command 'default)
3597 gnus-last-shell-command)
3598 gnus-last-shell-command)
3603 "Shell command on %s: "
3604 (if (and gnus-number-of-articles-to-be-saved
3605 (> gnus-number-of-articles-to-be-saved 1))
3606 (format "these %d articles"
3607 gnus-number-of-articles-to-be-saved)
3609 gnus-last-shell-command))))
3610 (when (string-equal command "")
3611 (if gnus-last-shell-command
3612 (setq command gnus-last-shell-command)
3613 (error "A command is required")))
3614 (gnus-eval-in-buffer-window gnus-article-buffer
3617 (shell-command-on-region (point-min) (point-max) command nil)))
3618 (setq gnus-last-shell-command command))
3620 (defun gnus-summary-pipe-to-muttprint (&optional command)
3621 "Pipe this article to muttprint."
3622 (setq command (read-string
3623 "Print using command: " gnus-summary-muttprint-program
3624 nil gnus-summary-muttprint-program))
3625 (gnus-summary-save-in-pipe command))
3627 ;;; Article file names when saving.
3629 (defun gnus-capitalize-newsgroup (newsgroup)
3630 "Capitalize NEWSGROUP name."
3631 (when (not (zerop (length newsgroup)))
3632 (concat (char-to-string (upcase (aref newsgroup 0)))
3633 (substring newsgroup 1))))
3635 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3636 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3637 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3638 Otherwise, it is like ~/News/news/group/num."
3641 (concat (if (gnus-use-long-file-name 'not-save)
3642 (gnus-capitalize-newsgroup newsgroup)
3643 (gnus-newsgroup-directory-form newsgroup))
3644 "/" (int-to-string (mail-header-number headers)))
3645 gnus-article-save-directory)))
3647 (string-equal (file-name-directory default)
3648 (file-name-directory last-file))
3649 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3651 (or last-file default))))
3653 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3654 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3655 If variable `gnus-use-long-file-name' is non-nil, it is
3656 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3659 (concat (if (gnus-use-long-file-name 'not-save)
3661 (gnus-newsgroup-directory-form newsgroup))
3662 "/" (int-to-string (mail-header-number headers)))
3663 gnus-article-save-directory)))
3665 (string-equal (file-name-directory default)
3666 (file-name-directory last-file))
3667 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3669 (or last-file default))))
3671 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3672 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3673 If variable `gnus-use-long-file-name' is non-nil, it is
3674 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3677 (if (gnus-use-long-file-name 'not-save)
3680 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3682 gnus-article-save-directory)))
3684 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3685 "Generate file name from sender."
3686 (let ((from (mail-header-from headers)))
3688 (if (and from (string-match "\\([^ <]+\\)@" from))
3689 (match-string 1 from)
3691 gnus-article-save-directory)))
3693 (defun article-verify-x-pgp-sig ()
3696 (if (gnus-buffer-live-p gnus-original-article-buffer)
3697 (let ((sig (with-current-buffer gnus-original-article-buffer
3698 (gnus-fetch-field "X-PGP-Sig")))
3702 (mml2015-clear-verify-function))
3704 (insert-buffer-substring gnus-original-article-buffer)
3705 (setq items (split-string sig))
3706 (message-narrow-to-head)
3707 (let ((inhibit-point-motion-hooks t)
3708 (case-fold-search t))
3709 ;; Don't verify multiple headers.
3710 (setq headers (mapconcat (lambda (header)
3712 (mail-fetch-field header)
3714 (split-string (nth 1 items) ",") "")))
3715 (delete-region (point-min) (point-max))
3716 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3717 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3722 (if (looking-at "^-")
3725 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3726 (insert "Version: " (car items) "\n\n")
3727 (insert (mapconcat 'identity (cddr items) "\n"))
3728 (insert "\n-----END PGP SIGNATURE-----\n")
3729 (let ((mm-security-handle (list (format "multipart/signed"))))
3730 (mml2015-clean-buffer)
3731 (let ((coding-system-for-write (or gnus-newsgroup-charset
3733 (funcall (mml2015-clear-verify-function)))
3735 (or (mm-handle-multipart-ctl-parameter
3736 mm-security-handle 'gnus-details)
3737 (mm-handle-multipart-ctl-parameter
3738 mm-security-handle 'gnus-info)))))
3740 (let ((inhibit-read-only t) bface eface)
3742 (message-narrow-to-head)
3743 (goto-char (point-max))
3745 (setq bface (get-text-property (point-at-bol) 'face)
3746 eface (get-text-property (1- (point-at-eol)) 'face))
3747 (message-remove-header "X-Gnus-PGP-Verify")
3748 (if (re-search-forward "^X-PGP-Sig:" nil t)
3750 (goto-char (point-max)))
3751 (narrow-to-region (point) (point))
3752 (insert "X-Gnus-PGP-Verify: " info "\n")
3753 (goto-char (point-min))
3756 (if (not (looking-at "^[ \t]"))
3760 (goto-char (point-min))
3761 (when (looking-at "\\([^:]+\\): *")
3762 (put-text-property (match-beginning 1) (1+ (match-end 1))
3764 (put-text-property (match-end 0) (point-max)
3765 'face eface)))))))))
3767 (defun article-verify-cancel-lock ()
3768 "Verify Cancel-Lock header."
3770 (if (gnus-buffer-live-p gnus-original-article-buffer)
3771 (canlock-verify gnus-original-article-buffer)))
3778 (setq afunc (car func)
3781 gfunc (intern (format "gnus-%s" func))))
3783 (when (fboundp afunc)
3784 `(lambda (&optional interactive &rest args)
3785 ,(documentation afunc t)
3786 (interactive (list t))
3788 (set-buffer gnus-article-buffer)
3790 (call-interactively ',afunc)
3791 (apply ',afunc args))))))))
3792 '(article-hide-headers
3793 article-verify-x-pgp-sig
3794 article-verify-cancel-lock
3795 article-hide-boring-headers
3796 article-treat-overstrike
3797 article-treat-ansi-sequences
3798 article-fill-long-lines
3799 article-capitalize-sentences
3801 article-remove-leading-whitespace
3802 article-display-x-face
3803 article-display-face
3804 article-de-quoted-unreadable
3805 article-de-base64-unreadable
3808 article-unsplit-urls
3809 article-hide-list-identifiers
3810 article-strip-banner
3813 article-hide-signature
3814 article-strip-headers-in-body
3815 article-remove-trailing-blank-lines
3816 article-strip-leading-blank-lines
3817 article-strip-multiple-blank-lines
3818 article-strip-leading-space
3819 article-strip-trailing-space
3820 article-strip-blank-lines
3821 article-strip-all-blank-lines
3823 article-date-english
3824 article-date-iso8601
3825 article-date-original
3827 article-decode-mime-words
3828 article-decode-charset
3829 article-decode-encoded-words
3833 article-treat-dumbquotes
3834 article-normalize-headers
3835 ;; (article-show-all . gnus-article-show-all-headers)
3839 ;;; Gnus article mode
3842 (put 'gnus-article-mode 'mode-class 'special)
3844 (set-keymap-parent gnus-article-mode-map widget-keymap)
3846 (gnus-define-keys gnus-article-mode-map
3847 " " gnus-article-goto-next-page
3848 "\177" gnus-article-goto-prev-page
3849 [delete] gnus-article-goto-prev-page
3850 [backspace] gnus-article-goto-prev-page
3851 "\C-c^" gnus-article-refer-article
3852 "h" gnus-article-show-summary
3853 "s" gnus-article-show-summary
3854 "\C-c\C-m" gnus-article-mail
3855 "?" gnus-article-describe-briefly
3856 "e" gnus-summary-edit-article
3857 "<" beginning-of-buffer
3859 "\C-c\C-i" gnus-info-find-node
3861 "R" gnus-article-reply-with-original
3862 "F" gnus-article-followup-with-original
3863 "\C-hk" gnus-article-describe-key
3864 "\C-hc" gnus-article-describe-key-briefly
3866 "\C-d" gnus-article-read-summary-keys
3867 "\M-*" gnus-article-read-summary-keys
3868 "\M-#" gnus-article-read-summary-keys
3869 "\M-^" gnus-article-read-summary-keys
3870 "\M-g" gnus-article-read-summary-keys)
3872 (substitute-key-definition
3873 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3875 (defun gnus-article-make-menu-bar ()
3876 (unless (boundp 'gnus-article-commands-menu)
3877 (gnus-summary-make-menu-bar))
3878 (gnus-turn-off-edit-menu 'article)
3879 (unless (boundp 'gnus-article-article-menu)
3881 gnus-article-article-menu gnus-article-mode-map ""
3883 ["Scroll forwards" gnus-article-goto-next-page t]
3884 ["Scroll backwards" gnus-article-goto-prev-page t]
3885 ["Show summary" gnus-article-show-summary t]
3886 ["Fetch Message-ID at point" gnus-article-refer-article t]
3887 ["Mail to address at point" gnus-article-mail t]
3888 ["Send a bug report" gnus-bug t]))
3891 gnus-article-treatment-menu gnus-article-mode-map ""
3892 ;; Fixme: this should use :active (and maybe :visible).
3894 ["Hide headers" gnus-article-hide-headers t]
3895 ["Hide signature" gnus-article-hide-signature t]
3896 ["Hide citation" gnus-article-hide-citation t]
3897 ["Treat overstrike" gnus-article-treat-overstrike t]
3898 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3899 ["Remove carriage return" gnus-article-remove-cr t]
3900 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3901 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3902 ["Remove base64" gnus-article-de-base64-unreadable t]
3903 ["Treat html" gnus-article-wash-html t]
3904 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3905 ["Decode HZ" gnus-article-decode-HZ t]))
3907 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3909 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3911 (gnus-run-hooks 'gnus-article-menu-hook)))
3913 (defun gnus-article-mode ()
3914 "Major mode for displaying an article.
3916 All normal editing commands are switched off.
3918 The following commands are available in addition to all summary mode
3920 \\<gnus-article-mode-map>
3921 \\[gnus-article-next-page]\t Scroll the article one page forwards
3922 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3923 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3924 \\[gnus-article-show-summary]\t Display the summary buffer
3925 \\[gnus-article-mail]\t Send a reply to the address near point
3926 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3927 \\[gnus-info-find-node]\t Go to the Gnus info node"
3929 (kill-all-local-variables)
3930 (gnus-simplify-mode-line)
3931 (setq mode-name "Article")
3932 (setq major-mode 'gnus-article-mode)
3933 (make-local-variable 'minor-mode-alist)
3934 (use-local-map gnus-article-mode-map)
3935 (when (gnus-visual-p 'article-menu 'menu)
3936 (gnus-article-make-menu-bar)
3937 (when gnus-summary-tool-bar-map
3938 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3939 (gnus-update-format-specifications nil 'article-mode)
3940 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3941 (set (make-local-variable 'gnus-page-broken) nil)
3942 (make-local-variable 'gnus-button-marker-list)
3943 (make-local-variable 'gnus-article-current-summary)
3944 (make-local-variable 'gnus-article-mime-handles)
3945 (make-local-variable 'gnus-article-decoded-p)
3946 (make-local-variable 'gnus-article-mime-handle-alist)
3947 (make-local-variable 'gnus-article-wash-types)
3948 (make-local-variable 'gnus-article-image-alist)
3949 (make-local-variable 'gnus-article-charset)
3950 (make-local-variable 'gnus-article-ignored-charsets)
3951 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3952 (set (make-local-variable 'nobreak-char-display) nil)
3953 (gnus-set-default-directory)
3954 (buffer-disable-undo)
3955 (setq buffer-read-only t
3956 show-trailing-whitespace nil)
3957 (set-syntax-table gnus-article-mode-syntax-table)
3958 (mm-enable-multibyte)
3959 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3961 (defun gnus-article-setup-buffer ()
3962 "Initialize the article buffer."
3963 (let* ((name (if gnus-single-article-buffer "*Article*"
3964 (concat "*Article " gnus-newsgroup-name "*")))
3966 (progn (string-match "\\*Article" name)
3967 (concat " *Original Article"
3968 (substring name (match-end 0))))))
3969 (setq gnus-article-buffer name)
3970 (setq gnus-original-article-buffer original)
3971 (setq gnus-article-mime-handle-alist nil)
3972 ;; This might be a variable local to the summary buffer.
3973 (unless gnus-single-article-buffer
3975 (set-buffer gnus-summary-buffer)
3976 (setq gnus-article-buffer name)
3977 (setq gnus-original-article-buffer original)
3978 (gnus-set-global-variables)))
3979 (gnus-article-setup-highlight-words)
3980 ;; Init original article buffer.
3982 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3983 (mm-enable-multibyte)
3984 (setq major-mode 'gnus-original-article-mode)
3985 (make-local-variable 'gnus-original-article))
3986 (if (and (get-buffer name)
3987 (with-current-buffer name
3988 (if gnus-article-edit-mode
3989 (if (y-or-n-p "Article mode edit in progress; discard? ")
3991 (set-buffer-modified-p nil)
3992 (gnus-kill-buffer name)
3995 (error "Action aborted"))
3999 (set (make-local-variable 'gnus-article-edit-mode) nil)
4000 (when gnus-article-mime-handles
4001 (mm-destroy-parts gnus-article-mime-handles)
4002 (setq gnus-article-mime-handles nil))
4003 ;; Set it to nil in article-buffer!
4004 (setq gnus-article-mime-handle-alist nil)
4005 (buffer-disable-undo)
4006 (setq buffer-read-only t)
4007 ;; This list just keeps growing if we don't reset it.
4008 (setq gnus-button-marker-list nil)
4009 (unless (eq major-mode 'gnus-article-mode)
4010 (gnus-article-mode))
4013 (set-buffer (gnus-get-buffer-create name))
4015 (make-local-variable 'gnus-summary-buffer)
4016 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4017 (current-buffer)))))
4019 ;; Set article window start at LINE, where LINE is the number of lines
4020 ;; from the head of the article.
4021 (defun gnus-article-set-window-start (&optional line)
4023 (gnus-get-buffer-window gnus-article-buffer t)
4025 (set-buffer gnus-article-buffer)
4026 (goto-char (point-min))
4029 (gnus-message 6 "Moved to bookmark")
4030 (search-forward "\n\n" nil t)
4034 (defun gnus-article-prepare (article &optional all-headers header)
4035 "Prepare ARTICLE in article mode buffer.
4036 ARTICLE should either be an article number or a Message-ID.
4037 If ARTICLE is an id, HEADER should be the article headers.
4038 If ALL-HEADERS is non-nil, no headers are hidden."
4040 ;; Make sure we start in a summary buffer.
4041 (unless (eq major-mode 'gnus-summary-mode)
4042 (set-buffer gnus-summary-buffer))
4043 (setq gnus-summary-buffer (current-buffer))
4044 (let* ((gnus-article (if header (mail-header-number header) article))
4045 (summary-buffer (current-buffer))
4046 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4047 (group gnus-newsgroup-name)
4050 (gnus-article-setup-buffer)
4051 (set-buffer gnus-article-buffer)
4052 ;; Deactivate active regions.
4053 (when (and (boundp 'transient-mark-mode)
4054 transient-mark-mode)
4055 (setq mark-active nil))
4056 (if (not (setq result (let ((inhibit-read-only t))
4057 (gnus-request-article-this-buffer
4059 ;; There is no such article.
4061 (when (and (numberp article)
4062 (not (memq article gnus-newsgroup-sparse)))
4063 (setq gnus-article-current
4064 (cons gnus-newsgroup-name article))
4065 (set-buffer gnus-summary-buffer)
4066 (setq gnus-current-article article)
4067 (if (and (memq article gnus-newsgroup-undownloaded)
4068 (not (gnus-online (gnus-find-method-for-group
4069 gnus-newsgroup-name))))
4071 (gnus-summary-set-agent-mark article)
4072 (message "Message marked for downloading"))
4073 (gnus-summary-mark-article article gnus-canceled-mark)
4074 (unless (memq article gnus-newsgroup-sparse)
4075 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4076 (if (or (eq result 'pseudo)
4077 (eq result 'nneething))
4080 (set-buffer summary-buffer)
4081 (push article gnus-newsgroup-history)
4082 (setq gnus-last-article gnus-current-article
4083 gnus-current-article 0
4084 gnus-current-headers nil
4085 gnus-article-current nil)
4086 (if (eq result 'nneething)
4087 (gnus-configure-windows 'summary)
4088 (gnus-configure-windows 'article))
4089 (gnus-set-global-variables))
4090 (let ((gnus-article-mime-handle-alist-1
4091 gnus-article-mime-handle-alist))
4092 (gnus-set-mode-line 'article)))
4093 ;; The result from the `request' was an actual article -
4094 ;; or at least some text that is now displayed in the
4096 (when (and (numberp article)
4097 (not (eq article gnus-current-article)))
4098 ;; Seems like a new article has been selected.
4099 ;; `gnus-current-article' must be an article number.
4101 (set-buffer summary-buffer)
4102 (push article gnus-newsgroup-history)
4103 (setq gnus-last-article gnus-current-article
4104 gnus-current-article article
4105 gnus-current-headers
4106 (gnus-summary-article-header gnus-current-article)
4107 gnus-article-current
4108 (cons gnus-newsgroup-name gnus-current-article))
4109 (unless (vectorp gnus-current-headers)
4110 (setq gnus-current-headers nil))
4111 (gnus-summary-goto-subject gnus-current-article)
4112 (when (gnus-summary-show-thread)
4113 ;; If the summary buffer really was folded, the
4114 ;; previous goto may not actually have gone to
4115 ;; the right article, but the thread root instead.
4117 (gnus-summary-goto-subject gnus-current-article))
4118 (gnus-run-hooks 'gnus-mark-article-hook)
4119 (gnus-set-mode-line 'summary)
4120 (when (gnus-visual-p 'article-highlight 'highlight)
4121 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4122 ;; Set the global newsgroup variables here.
4123 (gnus-set-global-variables)
4124 (setq gnus-have-all-headers
4125 (or all-headers gnus-show-all-headers))))
4127 (gnus-configure-windows 'article))
4128 (when (or (numberp article)
4130 (gnus-article-prepare-display)
4132 (goto-char (point-min))
4133 (when gnus-break-pages
4134 (gnus-narrow-to-page)))
4135 (let ((gnus-article-mime-handle-alist-1
4136 gnus-article-mime-handle-alist))
4137 (gnus-set-mode-line 'article))
4141 (set-window-point (get-buffer-window (current-buffer)) (point))
4142 (gnus-configure-windows 'article)
4146 (defun gnus-article-prepare-display ()
4147 "Make the current buffer look like a nice article."
4148 ;; Hooks for getting information from the article.
4149 ;; This hook must be called before being narrowed.
4150 (let ((gnus-article-buffer (current-buffer))
4152 (inhibit-read-only t))
4153 (unless (eq major-mode 'gnus-article-mode)
4154 (gnus-article-mode))
4155 (setq buffer-read-only nil
4156 gnus-article-wash-types nil
4157 gnus-article-image-alist nil)
4158 (gnus-run-hooks 'gnus-tmp-internal-hook)
4159 (when gnus-display-mime-function
4160 (funcall gnus-display-mime-function))
4161 (gnus-run-hooks 'gnus-article-prepare-hook)))
4164 ;;; Gnus MIME viewing functions
4167 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4168 "Format of the MIME buttons.
4170 Valid specifiers include:
4172 %T MIME type, along with additional info
4173 %n The `name' parameter
4174 %d The description, if any
4175 %l The length of the encoded part
4176 %p The part identifier number
4177 %e Dots if the part isn't displayed
4179 General format specifiers can also be used. See Info node
4180 `(gnus)Formatting Variables'.")
4182 (defvar gnus-mime-button-line-format-alist
4183 '((?t gnus-tmp-type ?s)
4184 (?T gnus-tmp-type-long ?s)
4185 (?n gnus-tmp-name ?s)
4186 (?d gnus-tmp-description ?s)
4188 (?l gnus-tmp-length ?d)
4189 (?e gnus-tmp-dots ?s)))
4191 (defvar gnus-mime-button-commands
4192 '((gnus-article-press-button "\r" "Toggle Display")
4193 (gnus-mime-view-part "v" "View Interactively...")
4194 (gnus-mime-view-part-as-type "t" "View As Type...")
4195 (gnus-mime-view-part-as-charset "C" "View As charset...")
4196 (gnus-mime-save-part "o" "Save...")
4197 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4198 (gnus-mime-replace-part "r" "Replace part")
4199 (gnus-mime-delete-part "d" "Delete part")
4200 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4201 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4202 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4203 (gnus-mime-view-part-externally "e" "View Externally")
4204 (gnus-mime-print-part "p" "Print")
4205 (gnus-mime-pipe-part "|" "Pipe To Command...")
4206 (gnus-mime-action-on-part "." "Take action on the part...")))
4208 (defun gnus-article-mime-part-status ()
4209 (if gnus-article-mime-handle-alist-1
4210 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4212 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4215 (defvar gnus-mime-button-map
4216 (let ((map (make-sparse-keymap)))
4217 (define-key map gnus-mouse-2 'gnus-article-push-button)
4218 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4219 (dolist (c gnus-mime-button-commands)
4220 (define-key map (cadr c) (car c)))
4224 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4226 ,@(mapcar (lambda (c)
4227 (vector (caddr c) (car c) :enable t))
4228 gnus-mime-button-commands)))
4230 (defun gnus-mime-button-menu (event prefix)
4231 "Construct a context-sensitive menu of MIME commands."
4232 (interactive "e\nP")
4233 (save-window-excursion
4234 (let ((pos (event-start event)))
4235 (select-window (posn-window pos))
4236 (goto-char (posn-point pos))
4237 (gnus-article-check-buffer)
4238 (popup-menu gnus-mime-button-menu nil prefix))))
4240 (defun gnus-mime-view-all-parts (&optional handles)
4241 "View all the MIME parts."
4243 (with-current-buffer gnus-article-buffer
4244 (let ((handles (or handles gnus-article-mime-handles))
4245 (mail-parse-charset gnus-newsgroup-charset)
4246 (mail-parse-ignored-charsets
4247 (with-current-buffer gnus-summary-buffer
4248 gnus-newsgroup-ignored-charsets)))
4250 (mm-remove-parts handles)
4251 (goto-char (point-min))
4252 (or (search-forward "\n\n") (goto-char (point-max)))
4253 (let ((inhibit-read-only t))
4254 (delete-region (point) (point-max))
4255 (mm-display-parts handles))))))
4257 (defun gnus-article-jump-to-part (n)
4258 "Jump to MIME part N."
4260 (pop-to-buffer gnus-article-buffer)
4261 ;; FIXME: why is it necessary?
4263 (let ((parts (length gnus-article-mime-handle-alist)))
4266 (read-string ;; Emacs 21 doesn't have `read-number'.
4267 (format "Jump to part (2..%s): " parts)))))
4268 (unless (and (integerp n) (<= n parts) (>= n 1))
4271 (gnus-message 7 "Invalid part `%s', using %s instead."
4274 (gnus-message 9 "Jumping to part %s." n)
4275 (cond ((>= gnus-auto-select-part 1)
4276 (while (and (<= n parts)
4277 (not (gnus-article-goto-part n)))
4279 ((< gnus-auto-select-part 0)
4280 (while (and (>= n 1)
4281 (not (gnus-article-goto-part n)))
4284 (gnus-article-goto-part n)))))
4287 (defsubst gnus-article-edit-part (handles &optional current-id)
4288 "Edit an article in order to delete a mime part.
4289 This function is exclusively used by `gnus-mime-save-part-and-strip'
4290 and `gnus-mime-delete-part', and not provided at run-time normally."
4291 (gnus-article-edit-article
4293 (buffer-disable-undo)
4295 (let ((mail-parse-charset (or gnus-article-charset
4296 ',gnus-newsgroup-charset))
4297 (mail-parse-ignored-charsets
4298 (or gnus-article-ignored-charsets
4299 ',gnus-newsgroup-ignored-charsets))
4300 (mbl mml-buffer-list))
4301 (setq mml-buffer-list nil)
4302 (insert-buffer-substring gnus-original-article-buffer)
4303 (mime-to-mml ',handles)
4304 (setq gnus-article-mime-handles nil)
4305 (let ((mbl1 mml-buffer-list))
4306 (setq mml-buffer-list mbl)
4307 (set (make-local-variable 'mml-buffer-list) mbl1))
4308 (gnus-make-local-hook 'kill-buffer-hook)
4309 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4310 `(lambda (no-highlight)
4311 (let ((mail-parse-charset (or gnus-article-charset
4312 ',gnus-newsgroup-charset))
4313 (message-options message-options)
4314 (message-options-set-recipient)
4315 (mail-parse-ignored-charsets
4316 (or gnus-article-ignored-charsets
4317 ',gnus-newsgroup-ignored-charsets)))
4319 (mml-destroy-buffers)
4320 (remove-hook 'kill-buffer-hook
4321 'mml-destroy-buffers t)
4322 (kill-local-variable 'mml-buffer-list))
4323 (gnus-summary-edit-article-done
4324 ,(or (mail-header-references gnus-current-headers) "")
4325 ,(gnus-group-read-only-p)
4326 ,gnus-summary-buffer no-highlight))
4328 (gnus-article-edit-done)
4329 (gnus-summary-expand-window)
4330 (gnus-summary-show-article)
4331 (when (and current-id (integerp gnus-auto-select-part))
4332 (gnus-article-jump-to-part
4333 (+ current-id gnus-auto-select-part)))))
4335 (defun gnus-mime-replace-part (file)
4336 "Replace MIME part under point with an external body."
4337 ;; Useful if file has already been saved to disk
4341 (read-file-name "Replace MIME part with file: "
4342 (or mm-default-directory default-directory)
4344 (gnus-mime-save-part-and-strip file))
4346 (defun gnus-mime-save-part-and-strip (&optional file)
4347 "Save the MIME part under point then replace it with an external body.
4348 If FILE is given, use it for the external part."
4350 (gnus-article-check-buffer)
4351 (when (gnus-group-read-only-p)
4352 (error "The current group does not support deleting of parts"))
4353 (when (mm-complicated-handles gnus-article-mime-handles)
4355 The current article has a complicated MIME structure, giving up..."))
4356 (let* ((data (get-text-property (point) 'gnus-data))
4357 (id (get-text-property (point) 'gnus-part))
4359 (handles gnus-article-mime-handles))
4362 (and data (mm-save-part data "Delete MIME part and save to: "))))
4364 (with-current-buffer (mm-handle-buffer data)
4366 (insert "Content-Type: " (mm-handle-media-type data))
4367 (mml-insert-parameter-string (cdr (mm-handle-type data))
4369 ;; Add a filename for the sake of saving the part again.
4370 (mml-insert-parameter
4371 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4373 (insert "Content-ID: " (message-make-message-id) "\n")
4374 (insert "Content-Transfer-Encoding: binary\n")
4377 (cdr (mm-make-handle nil
4378 `("message/external-body"
4379 (access-type . "LOCAL-FILE")
4381 ;; (set-buffer gnus-summary-buffer)
4382 (gnus-article-edit-part handles id))))
4384 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4385 ;; parts...>') but with stripping would be nice.
4387 (defun gnus-mime-delete-part ()
4388 "Delete the MIME part under point.
4389 Replace it with some information about the removed part."
4391 (gnus-article-check-buffer)
4392 (when (gnus-group-read-only-p)
4393 (error "The current group does not support deleting of parts"))
4394 (when (mm-complicated-handles gnus-article-mime-handles)
4396 The current article has a complicated MIME structure, giving up..."))
4397 (when (or gnus-expert-user
4398 (gnus-yes-or-no-p "\
4399 Deleting parts may malfunction or destroy the article; continue? "))
4400 (let* ((data (get-text-property (point) 'gnus-data))
4401 (id (get-text-property (point) 'gnus-part))
4402 (handles gnus-article-mime-handles)
4406 (mail-decode-encoded-word-string (or (mm-handle-description data)
4409 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4411 (type (mm-handle-media-type data)))
4413 (error "No MIME part under point"))
4414 (with-current-buffer (mm-handle-buffer data)
4415 (let ((bsize (format "%s" (buffer-size))))
4420 "| The following attachment has been deleted:\n"
4422 "| Type: " type "\n"
4423 "| Filename: " filename "\n"
4424 "| Size (encoded): " bsize " Byte\n"
4425 "| Description: " description "\n"
4428 (cdr (mm-make-handle
4429 nil `("text/plain") nil nil
4431 (format "Deleted attachment (%s bytes)" bsize))))))
4432 ;; (set-buffer gnus-summary-buffer)
4433 (gnus-article-edit-part handles id))))
4435 (defun gnus-mime-save-part ()
4436 "Save the MIME part under point."
4438 (gnus-article-check-buffer)
4439 (let ((data (get-text-property (point) 'gnus-data)))
4441 (mm-save-part data))))
4443 (defun gnus-mime-pipe-part ()
4444 "Pipe the MIME part under point to a process."
4446 (gnus-article-check-buffer)
4447 (let ((data (get-text-property (point) 'gnus-data)))
4449 (mm-pipe-part data))))
4451 (defun gnus-mime-view-part ()
4452 "Interactively choose a viewing method for the MIME part under point."
4454 (gnus-article-check-buffer)
4455 (let ((data (get-text-property (point) 'gnus-data)))
4457 (setq gnus-article-mime-handles
4459 gnus-article-mime-handles (setq data (copy-sequence data))))
4460 (mm-interactively-view-part data))))
4462 (defun gnus-mime-view-part-as-type-internal ()
4463 (gnus-article-check-buffer)
4464 (let* ((handle (get-text-property (point) 'gnus-data))
4466 ;; Content-Type: foo/bar; name=...
4467 (mail-content-type-get (mm-handle-type handle) 'name)
4468 ;; Content-Disposition: attachment; filename=...
4469 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4470 (def-type (and name (mm-default-file-encoding name))))
4471 (and def-type (cons def-type 0))))
4473 (defun gnus-mime-view-part-as-type (&optional mime-type)
4474 "Choose a MIME media type, and view the part as such."
4478 (let ((default (gnus-mime-view-part-as-type-internal)))
4480 (format "View as MIME type (default %s): "
4482 (mapcar #'list (mailcap-mime-types))
4485 (gnus-article-check-buffer)
4486 (let ((handle (get-text-property (point) 'gnus-data)))
4488 (when (equal (mm-handle-media-type handle) "message/external-body")
4489 (unless (mm-handle-cache handle)
4490 (mm-extern-cache-contents handle))
4491 (setq handle (mm-handle-cache handle)))
4493 (mm-make-handle (mm-handle-buffer handle)
4494 (cons mime-type (cdr (mm-handle-type handle)))
4495 (mm-handle-encoding handle)
4496 (mm-handle-undisplayer handle)
4497 (mm-handle-disposition handle)
4498 (mm-handle-description handle)
4500 (mm-handle-id handle)))
4501 (setq gnus-article-mime-handles
4502 (mm-merge-handles gnus-article-mime-handles handle))
4503 (gnus-mm-display-part handle))))
4505 (defun gnus-mime-copy-part (&optional handle arg)
4506 "Put the MIME part under point into a new buffer.
4507 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4509 (interactive (list nil current-prefix-arg))
4510 (gnus-article-check-buffer)
4512 (setq handle (get-text-property (point) 'gnus-data)))
4514 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4516 (mail-content-type-get (mm-handle-disposition handle)
4518 contents dont-decode charset coding-system)
4519 (mm-with-unibyte-buffer
4520 (mm-insert-part handle)
4521 (setq contents (or (condition-case nil
4522 (mm-decompress-buffer filename nil 'sig)
4524 (setq dont-decode t)
4527 (setq filename (cond (filename (file-name-nondirectory filename))
4528 (dont-decode "*raw data*")
4533 (unless (setq charset (mail-content-type-get
4534 (mm-handle-type handle) 'charset))
4535 (unless (setq coding-system (mm-with-unibyte-buffer
4537 (mm-find-buffer-file-coding-system)))
4538 (setq charset gnus-newsgroup-charset))))
4540 (setq charset (or (cdr (assq arg
4541 gnus-summary-show-article-charset-alist))
4542 (mm-read-coding-system "Charset: ")))))
4543 (switch-to-buffer (generate-new-buffer filename))
4544 (if (or coding-system
4546 (setq coding-system (mm-charset-to-coding-system charset))
4547 (not (eq charset 'ascii))))
4549 (mm-enable-multibyte)
4550 (insert (mm-decode-coding-string contents coding-system))
4551 (setq buffer-file-coding-system
4552 (if (boundp 'last-coding-system-used)
4553 (symbol-value 'last-coding-system-used)
4555 (mm-disable-multibyte)
4557 (setq buffer-file-coding-system mm-binary-coding-system))
4558 ;; We do it this way to make `normal-mode' set the appropriate mode.
4561 (setq buffer-file-name (expand-file-name filename))
4563 (setq buffer-file-name nil))
4564 (goto-char (point-min)))))
4566 (defun gnus-mime-print-part (&optional handle filename)
4567 "Print the MIME part under point."
4568 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4569 (gnus-article-check-buffer)
4570 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4571 (contents (and handle (mm-get-part handle)))
4572 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4573 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4578 (mm-save-part-to-file handle file)
4579 (call-process shell-file-name nil
4580 (generate-new-buffer " *mm*")
4582 shell-command-switch
4584 printer file (mm-handle-type handle))))
4588 (gnus-print-buffer))
4589 (ps-despool filename)))))
4591 (defun gnus-mime-inline-part (&optional handle arg)
4592 "Insert the MIME part under point into the current buffer.
4593 Compressed files like .gz and .bz2 are decompressed."
4594 (interactive (list nil current-prefix-arg))
4595 (gnus-article-check-buffer)
4597 (setq handle (get-text-property (point) 'gnus-data)))
4600 (inhibit-read-only t)
4601 contents charset coding-system)
4602 (if (and (not arg) (mm-handle-undisplayer handle))
4603 (mm-remove-part handle)
4604 (mm-with-unibyte-buffer
4605 (mm-insert-part handle)
4607 (or (mm-decompress-buffer
4608 (or (mail-content-type-get (mm-handle-type handle)
4610 (mail-content-type-get (mm-handle-disposition handle)
4616 (unless (setq charset (mail-content-type-get
4617 (mm-handle-type handle) 'charset))
4618 (unless (setq coding-system
4619 (mm-with-unibyte-buffer
4621 (mm-find-buffer-file-coding-system)))
4622 (setq charset gnus-newsgroup-charset))))
4624 (if (mm-handle-undisplayer handle)
4625 (mm-remove-part handle))
4628 gnus-summary-show-article-charset-alist))
4629 (mm-read-coding-system "Charset: "))))
4631 (if (mm-handle-undisplayer handle)
4632 (mm-remove-part handle))))
4636 (if (or coding-system
4639 (mm-charset-to-coding-system charset))
4640 (not (eq coding-system 'ascii))))
4641 (mm-decode-coding-string contents coding-system)
4642 (mm-string-to-multibyte contents)))
4645 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4646 "Insert the MIME part under point into the current buffer using the
4648 (interactive (list nil current-prefix-arg))
4649 (gnus-article-check-buffer)
4650 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4651 (fun (get-text-property (point) 'gnus-callback))
4652 (gnus-newsgroup-ignored-charsets 'gnus-all)
4653 gnus-newsgroup-charset type charset)
4655 (if (mm-handle-undisplayer handle)
4656 (mm-remove-part handle))
4658 (setq gnus-newsgroup-charset
4659 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4660 (mm-read-coding-system "Charset: ")))
4661 ;; Strip the charset parameter from `handle'.
4662 (setq type (mm-handle-type
4663 (if (equal (mm-handle-media-type handle)
4664 "message/external-body")
4666 (unless (mm-handle-cache handle)
4667 (mm-extern-cache-contents handle))
4668 (mm-handle-cache handle))
4670 charset (assq 'charset (cdr type)))
4672 (funcall fun handle)))))
4674 (defun gnus-mime-view-part-externally (&optional handle)
4675 "View the MIME part under point with an external viewer."
4677 (gnus-article-check-buffer)
4678 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4679 (mm-user-display-methods nil)
4680 (mm-inlined-types nil)
4681 (mail-parse-charset gnus-newsgroup-charset)
4682 (mail-parse-ignored-charsets
4683 (with-current-buffer gnus-summary-buffer
4684 gnus-newsgroup-ignored-charsets)))
4686 (if (mm-handle-undisplayer handle)
4687 (mm-remove-part handle)
4688 (mm-display-part handle)))))
4690 (defun gnus-mime-view-part-internally (&optional handle)
4691 "View the MIME part under point with an internal viewer.
4692 If no internal viewer is available, use an external viewer."
4694 (gnus-article-check-buffer)
4695 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4696 (mm-inlined-types '(".*"))
4697 (mm-inline-large-images t)
4698 (mail-parse-charset gnus-newsgroup-charset)
4699 (mail-parse-ignored-charsets
4700 (with-current-buffer gnus-summary-buffer
4701 gnus-newsgroup-ignored-charsets))
4702 (inhibit-read-only t))
4704 (if (mm-handle-undisplayer handle)
4705 (mm-remove-part handle)
4706 (mm-display-part handle)))))
4708 (defun gnus-mime-action-on-part (&optional action)
4709 "Do something with the MIME attachment at \(point\)."
4711 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4712 (gnus-article-check-buffer)
4713 (let ((action-pair (assoc action gnus-mime-action-alist)))
4715 (funcall (cdr action-pair)))))
4717 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4718 "Call FUNCTION on MIME part N.
4719 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4720 If INTERACTIVE, call FUNCTION interactivly."
4722 ;; Check whether the article is displayed.
4723 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4724 (setq window (get-buffer-window gnus-article-buffer t))
4725 (frame-visible-p (setq frame (window-frame window))))
4726 (error "No article is displayed"))
4727 (with-current-buffer gnus-article-buffer
4728 ;; Check whether the article displays the right contents.
4729 (unless (with-current-buffer gnus-summary-buffer
4730 (eq gnus-current-article (gnus-summary-article-number)))
4731 (error "You should select the right article first"))
4732 ;; Check whether the specified part exists.
4733 (when (> n (length gnus-article-mime-handle-alist))
4734 (error "No such part")))
4737 ;; To select the window is needed so that the cursor
4738 ;; might be visible on the MIME button.
4739 (select-window (prog1
4741 (setq window (selected-window))
4742 ;; Article may be displayed in the other frame.
4743 (gnus-select-frame-set-input-focus
4746 (setq frame (selected-frame))))))
4747 (when (gnus-article-goto-part n)
4748 ;; We point the cursor and the arrow at the MIME button
4749 ;; when the `function' prompt the user for something.
4750 (let ((cursor-in-non-selected-windows t)
4751 (overlay-arrow-string "=>")
4752 (overlay-arrow-position (point-marker)))
4755 ((and no-handle interactive)
4756 (call-interactively function))
4762 (cdr (assq n gnus-article-mime-handle-alist))))
4765 (cdr (assq n gnus-article-mime-handle-alist)))))
4766 (set-marker overlay-arrow-position nil)
4767 (unless gnus-auto-select-part
4768 (gnus-select-frame-set-input-focus frame)
4769 (select-window window))))
4771 (if gnus-inhibit-mime-unbuttonizing
4772 ;; This is the default though the program shouldn't reach here.
4773 (error "No such part")
4774 ;; The part which doesn't have the MIME button is selected.
4775 ;; So, we display all the buttons and redo it.
4776 (let ((gnus-inhibit-mime-unbuttonizing t))
4777 (gnus-summary-show-article)
4778 (gnus-article-part-wrapper n function no-handle))))))
4780 (defun gnus-article-pipe-part (n)
4781 "Pipe MIME part N, which is the numerical prefix."
4783 (gnus-article-part-wrapper n 'mm-pipe-part))
4785 (defun gnus-article-save-part (n)
4786 "Save MIME part N, which is the numerical prefix."
4788 (gnus-article-part-wrapper n 'mm-save-part))
4790 (defun gnus-article-interactively-view-part (n)
4791 "View MIME part N interactively, which is the numerical prefix."
4793 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4795 (defun gnus-article-copy-part (n)
4796 "Copy MIME part N, which is the numerical prefix."
4798 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4800 (defun gnus-article-view-part-as-charset (n)
4801 "View MIME part N using a specified charset.
4802 N is the numerical prefix."
4804 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4806 (defun gnus-article-view-part-externally (n)
4807 "View MIME part N externally, which is the numerical prefix."
4809 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4811 (defun gnus-article-inline-part (n)
4812 "Inline MIME part N, which is the numerical prefix."
4814 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4816 (defun gnus-article-save-part-and-strip (n)
4817 "Save MIME part N and replace it with an external body.
4818 N is the numerical prefix."
4820 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4822 (defun gnus-article-replace-part (n)
4823 "Replace MIME part N with an external body.
4824 N is the numerical prefix."
4826 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
4828 (defun gnus-article-delete-part (n)
4829 "Delete MIME part N and add some information about the removed part.
4830 N is the numerical prefix."
4832 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4834 (defun gnus-article-mime-match-handle-first (condition)
4837 (dolist (ihandle gnus-article-mime-handle-alist)
4839 ((functionp condition)
4840 (funcall condition (cdr ihandle)))
4841 ((eq condition 'undisplayed)
4842 (not (or (mm-handle-undisplayer (cdr ihandle))
4843 (equal (mm-handle-media-type (cdr ihandle))
4844 "multipart/alternative"))))
4845 ((eq condition 'undisplayed-alternative)
4846 (not (mm-handle-undisplayer (cdr ihandle))))
4848 (gnus-article-goto-part (car ihandle))
4849 (or (not n) (< (car ihandle) n)))
4850 (setq n (car ihandle))))
4854 (defun gnus-article-view-part (&optional n)
4855 "View MIME part N, which is the numerical prefix."
4857 (with-current-buffer gnus-article-buffer
4858 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4859 gnus-article-mime-match-handle-function)))
4860 (when (> n (length gnus-article-mime-handle-alist))
4861 (error "No such part"))
4862 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4863 (when (gnus-article-goto-part n)
4864 (if (equal (car handle) "multipart/alternative")
4865 (gnus-article-press-button)
4866 (when (eq (gnus-mm-display-part handle) 'internal)
4867 (gnus-set-window-start)))))))
4869 (defsubst gnus-article-mime-total-parts ()
4870 (if (bufferp (car gnus-article-mime-handles))
4872 (1- (length gnus-article-mime-handles))))
4874 (defun gnus-mm-display-part (handle)
4875 "Display HANDLE and fix MIME button."
4876 (let ((id (get-text-property (point) 'gnus-part))
4878 (inhibit-read-only t))
4881 (let ((window (selected-window))
4882 (mail-parse-charset gnus-newsgroup-charset)
4883 (mail-parse-ignored-charsets
4884 (if (gnus-buffer-live-p gnus-summary-buffer)
4885 (with-current-buffer gnus-summary-buffer
4886 gnus-newsgroup-ignored-charsets)
4890 (let ((win (gnus-get-buffer-window (current-buffer) t))
4893 (select-window win))
4896 (if (mm-handle-displayed-p handle)
4897 ;; This will remove the part.
4898 (mm-display-part handle)
4900 (narrow-to-region (point)
4901 (if (eobp) (point) (1+ (point))))
4902 (mm-display-part handle)
4903 ;; We narrow to the part itself and
4904 ;; then call the treatment functions.
4905 (goto-char (point-min))
4907 (narrow-to-region (point) (point-max))
4910 (gnus-article-mime-total-parts)
4911 (mm-handle-media-type handle)))))
4912 (if (window-live-p window)
4913 (select-window window)))))
4916 (gnus-insert-mime-button
4917 handle id (list (mm-handle-displayed-p handle)))
4918 (goto-char point))))
4920 (defun gnus-article-goto-part (n)
4921 "Go to MIME part N."
4922 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4924 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4925 (let ((gnus-tmp-name
4926 (or (mail-content-type-get (mm-handle-type handle) 'name)
4927 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4928 (mail-content-type-get (mm-handle-type handle) 'url)
4930 (gnus-tmp-type (mm-handle-media-type handle))
4931 (gnus-tmp-description
4932 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4935 (if (if displayed (car displayed)
4936 (mm-handle-displayed-p handle))
4938 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4940 gnus-tmp-type-long b e)
4941 (when (string-match ".*/" gnus-tmp-name)
4942 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4943 (setq gnus-tmp-type-long (concat gnus-tmp-type
4944 (and (not (equal gnus-tmp-name ""))
4945 (concat "; " gnus-tmp-name))))
4946 (unless (equal gnus-tmp-description "")
4947 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4952 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4953 `(keymap ,gnus-mime-button-map
4954 gnus-callback gnus-mm-display-part
4955 gnus-part ,gnus-tmp-id
4956 article-type annotation
4959 ;; Exclude a newline.
4962 (widget-convert-button
4965 :action 'gnus-widget-press-button
4966 :button-keymap gnus-mime-button-map
4968 (lambda (widget/window &optional overlay pos)
4969 ;; Needed to properly clear the message due to a bug in
4970 ;; wid-edit (XEmacs only).
4971 (if (boundp 'help-echo-owns-message)
4972 (setq help-echo-owns-message t))
4974 "%S: %s the MIME part; %S: more options"
4975 (aref gnus-mouse-2 0)
4976 ;; XEmacs will get a single widget arg; Emacs 21 will get
4977 ;; window, overlay, position.
4978 (if (mm-handle-displayed-p
4980 (with-current-buffer (gnus-overlay-buffer overlay)
4981 (widget-get (widget-at (gnus-overlay-start overlay))
4983 (widget-get widget/window :mime-handle)))
4985 (aref gnus-down-mouse-3 0))))))
4987 (defun gnus-widget-press-button (elems el)
4988 (goto-char (widget-get elems :from))
4989 (gnus-article-press-button))
4991 (defvar gnus-displaying-mime nil)
4993 (defun gnus-display-mime (&optional ihandles)
4994 "Display the MIME parts."
4996 (save-selected-window
4997 (let ((window (get-buffer-window gnus-article-buffer))
5000 (select-window window)
5001 ;; We have to do this since selecting the window
5002 ;; may change the point. So we set the window point.
5003 (set-window-point window point)))
5004 (let ((handles ihandles)
5005 (inhibit-read-only t)
5008 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5009 (when gnus-article-emulate-mime
5010 (mm-uu-dissect-text-parts handles)))
5011 (gnus-article-emulate-mime
5012 (setq handles (mm-uu-dissect))))
5013 (when (and (not ihandles)
5014 (not gnus-displaying-mime))
5015 ;; Top-level call; we clean up.
5016 (when gnus-article-mime-handles
5017 (mm-destroy-parts gnus-article-mime-handles)
5018 (setq gnus-article-mime-handle-alist nil));; A trick.
5019 (setq gnus-article-mime-handles handles)
5020 ;; We allow users to glean info from the handles.
5021 (when gnus-article-mime-part-function
5022 (gnus-mime-part-function handles)))
5024 (or (not (stringp (car handles)))
5027 (when (and (not ihandles)
5028 (not gnus-displaying-mime))
5029 ;; Clean up for mime parts.
5031 (delete-region (point) (point-max)))
5032 (let ((gnus-displaying-mime t))
5033 (gnus-mime-display-part handles)))
5036 (narrow-to-region (point) (point-max))
5037 (gnus-treat-article nil 1 1)
5040 ;; Highlight the headers.
5044 (narrow-to-region (point-min) (point))
5045 (gnus-article-save-original-date
5046 (gnus-treat-article 'head)))))))))
5048 (defcustom gnus-mime-display-multipart-as-mixed nil
5049 "Display \"multipart\" parts as \"multipart/mixed\".
5051 If t, it overrides nil values of
5052 `gnus-mime-display-multipart-alternative-as-mixed' and
5053 `gnus-mime-display-multipart-related-as-mixed'."
5054 :group 'gnus-article-mime
5057 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5058 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5060 :group 'gnus-article-mime
5063 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5064 "Display \"multipart/related\" parts as \"multipart/mixed\".
5066 If displaying \"text/html\" is discouraged \(see
5067 `mm-discouraged-alternatives'\) images or other material inside a
5068 \"multipart/related\" part might be overlooked when this variable is nil."
5070 :group 'gnus-article-mime
5073 (defun gnus-mime-display-part (handle)
5075 ;; Maybe a broken MIME message.
5078 ((not (stringp (car handle)))
5079 (gnus-mime-display-single handle))
5080 ;; User-defined multipart
5081 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5082 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5084 ;; multipart/alternative
5085 ((and (equal (car handle) "multipart/alternative")
5086 (not (or gnus-mime-display-multipart-as-mixed
5087 gnus-mime-display-multipart-alternative-as-mixed)))
5088 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5089 (push (cons id handle) gnus-article-mime-handle-alist)
5090 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5091 ;; multipart/related
5092 ((and (equal (car handle) "multipart/related")
5093 (not (or gnus-mime-display-multipart-as-mixed
5094 gnus-mime-display-multipart-related-as-mixed)))
5095 ;;;!!!We should find the start part, but we just default
5096 ;;;!!!to the first part.
5097 ;;(gnus-mime-display-part (cadr handle))
5098 ;;;!!! Most multipart/related is an HTML message plus images.
5099 ;;;!!! Unfortunately we are unable to let W3 display those
5100 ;;;!!! included images, so we just display it as a mixed multipart.
5101 ;;(gnus-mime-display-mixed (cdr handle))
5102 ;;;!!! No, w3 can display everything just fine.
5103 (gnus-mime-display-part (cadr handle)))
5104 ((equal (car handle) "multipart/signed")
5105 (gnus-add-wash-type 'signed)
5106 (gnus-mime-display-security handle))
5107 ((equal (car handle) "multipart/encrypted")
5108 (gnus-add-wash-type 'encrypted)
5109 (gnus-mime-display-security handle))
5110 ;; Other multiparts are handled like multipart/mixed.
5112 (gnus-mime-display-mixed (cdr handle)))))
5114 (defun gnus-mime-part-function (handles)
5115 (if (stringp (car handles))
5116 (mapcar 'gnus-mime-part-function (cdr handles))
5117 (funcall gnus-article-mime-part-function handles)))
5119 (defun gnus-mime-display-mixed (handles)
5120 (mapcar 'gnus-mime-display-part handles))
5122 (defun gnus-mime-display-single (handle)
5123 (let ((type (mm-handle-media-type handle))
5124 (ignored gnus-ignored-mime-types)
5131 (when (string-match (pop ignored) type)
5132 (throw 'ignored nil)))
5133 (if (and (setq not-attachment
5134 (and (not (mm-inline-override-p handle))
5135 (or (not (mm-handle-disposition handle))
5136 (equal (car (mm-handle-disposition handle))
5138 (mm-attachment-override-p handle))))
5139 (mm-automatic-display-p handle)
5141 (mm-inlinable-p handle)
5142 (mm-inlined-p handle))
5143 (mm-automatic-external-display-p type)))
5145 (when (equal (mm-handle-media-supertype handle) "text")
5147 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5149 (push (cons id handle) gnus-article-mime-handle-alist)
5151 (equal (mm-handle-media-supertype handle) "message"))
5154 (cond ((not (bolp)) 2)
5155 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5157 (when (or (not display)
5158 (not (gnus-unbuttonized-mime-type-p type)))
5159 (gnus-insert-mime-button
5160 handle id (list (or display (and not-attachment text))))
5161 (gnus-article-insert-newline)
5162 ;; Remember modify the number of forward lines.
5170 (let ((mail-parse-charset gnus-newsgroup-charset)
5171 (mail-parse-ignored-charsets
5172 (save-excursion (condition-case ()
5173 (set-buffer gnus-summary-buffer)
5175 gnus-newsgroup-ignored-charsets)))
5176 (mm-display-part handle t))
5177 (goto-char (point-max)))
5178 ((and text not-attachment)
5182 (gnus-article-insert-newline)
5185 (let ((charset (mail-content-type-get (mm-handle-type handle)
5187 (cond ((not charset)
5188 (mm-string-as-multibyte (mm-get-part handle)))
5189 ((eq charset 'gnus-decoded)
5190 (with-current-buffer (mm-handle-buffer handle)
5193 (mm-decode-string (mm-get-part handle) charset)))))
5194 (goto-char (point-max))))
5198 (narrow-to-region beg (point))
5201 (gnus-article-mime-total-parts)
5202 (mm-handle-media-type handle)))))))))
5204 (defun gnus-unbuttonized-mime-type-p (type)
5205 "Say whether TYPE is to be unbuttonized."
5206 (unless gnus-inhibit-mime-unbuttonizing
5208 (let ((types gnus-unbuttonized-mime-types))
5210 (when (string-match (pop types) type)
5211 (throw 'found t)))))
5213 (let ((types gnus-buttonized-mime-types))
5215 (when (string-match (pop types) type)
5216 (throw 'found t)))))))))
5218 (defun gnus-article-insert-newline ()
5219 "Insert a newline, but mark it as undeletable."
5220 (gnus-put-text-property
5221 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5223 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5224 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5227 handle (inhibit-read-only t) from props begend not-pref)
5228 (save-window-excursion
5231 (narrow-to-region (car ibegend)
5234 (goto-char (car ibegend))
5237 (delete-region (point-min) (point-max))
5238 (mm-remove-parts handles))
5239 (setq begend (list (point-marker)))
5241 (unless (setq not-pref (cadr (member preferred ihandles)))
5242 (setq not-pref (car ihandles)))
5245 (not (gnus-unbuttonized-mime-type-p
5246 "multipart/alternative")))
5247 (gnus-add-text-properties
5250 (insert (format "%d. " id))
5254 (unless ,(not ibegend)
5255 (setq gnus-article-mime-handle-alist
5256 ',gnus-article-mime-handle-alist))
5257 (gnus-mime-display-alternative
5258 ',ihandles ',not-pref ',begend ,id))
5259 keymap ,gnus-mime-button-map
5260 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5261 face ,gnus-article-button-face
5263 article-type multipart))
5264 (widget-convert-button 'link from (point)
5265 :action 'gnus-widget-press-button
5266 :button-keymap gnus-widget-button-keymap)
5268 (while (setq handle (pop handles))
5269 (gnus-add-text-properties
5272 (insert (format "(%c) %-18s"
5273 (if (equal handle preferred) ?* ? )
5274 (mm-handle-media-type handle)))
5278 (unless ,(not ibegend)
5279 (setq gnus-article-mime-handle-alist
5280 ',gnus-article-mime-handle-alist))
5281 (gnus-mime-display-alternative
5282 ',ihandles ',handle ',begend ,id))
5283 keymap ,gnus-mime-button-map
5284 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5285 face ,gnus-article-button-face
5288 (widget-convert-button 'link from (point)
5289 :action 'gnus-widget-press-button
5290 :button-keymap gnus-widget-button-keymap)
5294 (if (stringp (car preferred))
5295 (gnus-display-mime preferred)
5296 (let ((mail-parse-charset gnus-newsgroup-charset)
5297 (mail-parse-ignored-charsets
5298 (with-current-buffer gnus-summary-buffer
5299 gnus-newsgroup-ignored-charsets)))
5300 (mm-display-part preferred)
5304 (narrow-to-region (car begend) (point-max))
5306 nil (length gnus-article-mime-handle-alist)
5307 (gnus-article-mime-total-parts)
5308 (mm-handle-media-type handle))))))
5309 (goto-char (point-max))
5310 (setcdr begend (point-marker)))))
5312 (goto-char point))))
5314 (defconst gnus-article-wash-status-strings
5315 (let ((alist '((cite "c" "Possible hidden citation text"
5316 " " "All citation text visible")
5317 (headers "h" "Hidden headers"
5318 " " "All headers visible.")
5319 (pgp "p" "Encrypted or signed message status hidden"
5320 " " "No hidden encryption nor digital signature status")
5321 (signature "s" "Signature has been hidden"
5322 " " "Signature is visible")
5323 (overstrike "o" "Overstrike (^H) characters applied"
5324 " " "No overstrike characters applied")
5325 (emphasis "e" "/*_Emphasis_*/ characters applied"
5326 " " "No /*_emphasis_*/ characters applied")))
5328 (dolist (entry alist result)
5329 (let ((key (nth 0 entry))
5330 (on (copy-sequence (nth 1 entry)))
5331 (on-help (nth 2 entry))
5332 (off (copy-sequence (nth 3 entry)))
5333 (off-help (nth 4 entry)))
5334 (put-text-property 0 1 'help-echo on-help on)
5335 (put-text-property 0 1 'help-echo off-help off)
5336 (push (list key on off) result))))
5337 "Alist of strings describing wash status in the mode line.
5338 Each entry has the form (KEY ON OF), where the KEY is a symbol
5339 representing the particular washing function, ON is the string to use
5340 in the article mode line when the washing function is active, and OFF
5341 is the string to use when it is inactive.")
5343 (defun gnus-article-wash-status-entry (key value)
5344 (let ((entry (assoc key gnus-article-wash-status-strings)))
5345 (if value (nth 1 entry) (nth 2 entry))))
5347 (defun gnus-article-wash-status ()
5348 "Return a string which display status of article washing."
5349 (with-current-buffer gnus-article-buffer
5350 (let ((cite (memq 'cite gnus-article-wash-types))
5351 (headers (memq 'headers gnus-article-wash-types))
5352 (boring (memq 'boring-headers gnus-article-wash-types))
5353 (pgp (memq 'pgp gnus-article-wash-types))
5354 (pem (memq 'pem gnus-article-wash-types))
5355 (signed (memq 'signed gnus-article-wash-types))
5356 (encrypted (memq 'encrypted gnus-article-wash-types))
5357 (signature (memq 'signature gnus-article-wash-types))
5358 (overstrike (memq 'overstrike gnus-article-wash-types))
5359 (emphasis (memq 'emphasis gnus-article-wash-types)))
5361 (gnus-article-wash-status-entry 'cite cite)
5362 (gnus-article-wash-status-entry 'headers (or headers boring))
5363 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5364 (gnus-article-wash-status-entry 'signature signature)
5365 (gnus-article-wash-status-entry 'overstrike overstrike)
5366 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5368 (defun gnus-add-wash-type (type)
5369 "Add a washing of TYPE to the current status."
5370 (add-to-list 'gnus-article-wash-types type))
5372 (defun gnus-delete-wash-type (type)
5373 "Add a washing of TYPE to the current status."
5374 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5376 (defun gnus-add-image (category image)
5377 "Add IMAGE of CATEGORY to the list of displayed images."
5378 (let ((entry (assq category gnus-article-image-alist)))
5380 (setq entry (list category))
5381 (push entry gnus-article-image-alist))
5382 (nconc entry (list image))))
5384 (defun gnus-delete-images (category)
5385 "Delete all images in CATEGORY."
5386 (let ((entry (assq category gnus-article-image-alist)))
5387 (dolist (image (cdr entry))
5388 (gnus-remove-image image category))
5389 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5390 (gnus-delete-wash-type category)))
5392 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5394 (defun gnus-article-maybe-hide-headers ()
5395 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5396 Provided for backwards compatibility."
5397 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5398 (not (with-current-buffer gnus-summary-buffer
5399 gnus-have-all-headers)))
5400 (not gnus-inhibit-hiding))
5401 (gnus-article-hide-headers)))
5405 (defun gnus-output-to-file (file-name)
5406 "Append the current article to a file named FILE-NAME."
5407 (let ((artbuf (current-buffer)))
5409 (insert-buffer-substring artbuf)
5410 ;; Append newline at end of the buffer as separator, and then
5412 (goto-char (point-max))
5414 (let ((file-name-coding-system nnmail-pathname-coding-system))
5415 (mm-append-to-file (point-min) (point-max) file-name))
5418 (defun gnus-narrow-to-page (&optional arg)
5419 "Narrow the article buffer to a page.
5420 If given a numerical ARG, move forward ARG pages."
5422 (setq arg (if arg (prefix-numeric-value arg) 0))
5424 (set-buffer gnus-article-buffer)
5425 (goto-char (point-min))
5427 ;; Remove any old next/prev buttons.
5428 (when (gnus-visual-p 'page-marker)
5429 (let ((inhibit-read-only t))
5430 (gnus-remove-text-with-property 'gnus-prev)
5431 (gnus-remove-text-with-property 'gnus-next)))
5434 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5436 (re-search-forward page-delimiter nil 'move arg)))
5437 (goto-char (match-end 0))
5439 (goto-char (point-min))
5440 (setq gnus-page-broken
5441 (and (re-search-forward page-delimiter nil t) t))))
5442 (when gnus-page-broken
5445 (if (re-search-forward page-delimiter nil 'move)
5448 (when (and (gnus-visual-p 'page-marker)
5449 (> (point-min) (save-restriction (widen) (point-min))))
5451 (goto-char (point-min))
5452 (gnus-insert-prev-page-button)))
5453 (when (and (gnus-visual-p 'page-marker)
5454 (< (point-max) (save-restriction (widen) (point-max))))
5456 (goto-char (point-max))
5457 (gnus-insert-next-page-button))))))
5459 ;; Article mode commands
5461 (defun gnus-article-goto-next-page ()
5462 "Show the next page of the article."
5464 (when (gnus-article-next-page)
5465 (goto-char (point-min))
5466 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5469 (defun gnus-article-goto-prev-page ()
5470 "Show the previous page of the article."
5473 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5474 (gnus-article-prev-page nil)))
5476 ;; This is cleaner but currently breaks `gnus-pick-mode':
5478 ;; (defun gnus-article-goto-next-page ()
5479 ;; "Show the next page of the article."
5481 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5482 ;; (gnus-summary-next-page)))
5484 ;; (defun gnus-article-goto-prev-page ()
5485 ;; "Show the next page of the article."
5487 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5488 ;; (gnus-summary-prev-page)))
5490 (defun gnus-article-next-page (&optional lines)
5491 "Show the next page of the current article.
5492 If end of article, return non-nil. Otherwise return nil.
5493 Argument LINES specifies lines to be scrolled up."
5495 (move-to-window-line -1)
5498 (and (pos-visible-in-window-p) ;Not continuation line.
5499 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5500 ;; Nothing in this page.
5501 (if (or (not gnus-page-broken)
5506 (eobp)))) ;Real end-of-buffer?
5508 (when gnus-article-over-scroll
5509 (gnus-article-next-page-1 lines))
5511 (gnus-narrow-to-page 1) ;Go to next page.
5513 ;; More in this page.
5514 (gnus-article-next-page-1 lines)
5517 (defmacro gnus-article-beginning-of-window ()
5518 "Move point to the beginning of the window.
5519 In Emacs, the point is placed at the line number which `scroll-margin'
5521 (if (featurep 'xemacs)
5522 '(move-to-window-line 0)
5523 '(move-to-window-line
5524 (min (max 0 scroll-margin)
5525 (max 1 (- (window-height)
5526 (if mode-line-format 1 0)
5527 (if header-line-format 1 0)))))))
5529 (defun gnus-article-next-page-1 (lines)
5530 (when (and (not (featurep 'xemacs))
5533 (numberp (symbol-value 'scroll-margin))
5534 (> (symbol-value 'scroll-margin) 0))
5535 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5536 ;; too many number of lines if `scroll-margin' is set as two or greater.
5537 (setq lines (min lines
5538 (max 0 (- (count-lines (window-start) (point-max))
5539 (symbol-value 'scroll-margin))))))
5541 (let ((scroll-in-place nil))
5544 ;; Long lines may cause an end-of-buffer error.
5545 (goto-char (point-max))))
5546 (gnus-article-beginning-of-window))
5548 (defun gnus-article-prev-page (&optional lines)
5549 "Show previous page of current article.
5550 Argument LINES specifies lines to be scrolled down."
5552 (move-to-window-line 0)
5553 (if (and gnus-page-broken
5555 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5557 (gnus-narrow-to-page -1) ;Go to previous page.
5558 (goto-char (point-max))
5562 (let ((scroll-in-place nil))
5563 (scroll-down lines))
5564 (beginning-of-buffer
5565 (goto-char (point-min))))
5566 (gnus-article-beginning-of-window))))
5568 (defun gnus-article-only-boring-p ()
5569 "Decide whether there is only boring text remaining in the article.
5570 Something \"interesting\" is a word of at least two letters that does
5571 not have a face in `gnus-article-boring-faces'."
5572 (when (and gnus-article-skip-boring
5573 (boundp 'gnus-article-boring-faces)
5574 (symbol-value 'gnus-article-boring-faces))
5576 (let ((inhibit-point-motion-hooks t))
5578 (while (re-search-forward "\\b\\w\\w" nil t)
5580 (when (not (gnus-intersection
5581 (gnus-faces-at (point))
5582 (symbol-value 'gnus-article-boring-faces)))
5583 (throw 'only-boring nil)))
5584 (throw 'only-boring t))))))
5586 (defun gnus-article-refer-article ()
5587 "Read article specified by message-id around point."
5590 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5591 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5592 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5593 (let ((msg-id (concat "<" (match-string 0) ">")))
5594 (set-buffer gnus-summary-buffer)
5595 (gnus-summary-refer-article msg-id))
5596 (error "No references around point"))))
5598 (defun gnus-article-show-summary ()
5599 "Reconfigure windows to show summary buffer."
5601 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5602 (error "There is no summary buffer for this article buffer")
5603 (gnus-article-set-globals)
5604 (gnus-configure-windows 'article)
5605 (gnus-summary-goto-subject gnus-current-article)
5606 (gnus-summary-position-point)))
5608 (defun gnus-article-describe-briefly ()
5609 "Describe article mode commands briefly."
5611 (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")))
5613 (defun gnus-article-summary-command ()
5614 "Execute the last keystroke in the summary buffer."
5616 (let ((obuf (current-buffer))
5617 (owin (current-window-configuration))
5619 (switch-to-buffer gnus-article-current-summary 'norecord)
5620 (setq func (lookup-key (current-local-map) (this-command-keys)))
5621 (call-interactively func)
5623 (set-window-configuration owin)
5624 (set-window-point (get-buffer-window (current-buffer)) (point))))
5626 (defun gnus-article-summary-command-nosave ()
5627 "Execute the last keystroke in the summary buffer."
5630 (pop-to-buffer gnus-article-current-summary 'norecord)
5631 (setq func (lookup-key (current-local-map) (this-command-keys)))
5632 (call-interactively func)))
5634 (defun gnus-article-check-buffer ()
5635 "Beep if not in an article buffer."
5636 (unless (equal major-mode 'gnus-article-mode)
5637 (error "Command invoked outside of a Gnus article buffer")))
5639 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5640 "Read a summary buffer key sequence and execute it from the article buffer."
5642 (gnus-article-check-buffer)
5644 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5645 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5646 "=" "^" "\M-^" "|"))
5652 '("n" "Gn" "p" "Gp"))
5655 (set-buffer gnus-article-current-summary)
5656 (let (gnus-pick-mode)
5657 (push (or key last-command-event) unread-command-events)
5658 (setq keys (if (featurep 'xemacs)
5659 (events-to-keys (read-key-sequence nil))
5660 (read-key-sequence nil)))))
5664 (if (or (member keys nosaves)
5665 (member keys nosave-but-article)
5666 (member keys nosave-in-article))
5668 (save-window-excursion
5669 (pop-to-buffer gnus-article-current-summary 'norecord)
5670 ;; We disable the pick minor mode commands.
5671 (let (gnus-pick-mode)
5672 (setq func (lookup-key (current-local-map) keys))))
5676 (unless (member keys nosave-in-article)
5677 (set-buffer gnus-article-current-summary))
5678 (call-interactively func)
5679 (setq new-sum-point (point)))
5680 (when (member keys nosave-but-article)
5681 (pop-to-buffer gnus-article-buffer 'norecord)))
5682 ;; These commands should restore window configuration.
5683 (let ((obuf (current-buffer))
5684 (owin (current-window-configuration))
5686 win func in-buffer selected new-sum-start new-sum-hscroll)
5687 (cond (not-restore-window
5688 (pop-to-buffer gnus-article-current-summary 'norecord))
5689 ((setq win (get-buffer-window gnus-article-current-summary))
5690 (select-window win))
5692 (switch-to-buffer gnus-article-current-summary 'norecord)))
5693 (setq in-buffer (current-buffer))
5694 ;; We disable the pick minor mode commands.
5695 (if (and (setq func (let (gnus-pick-mode)
5696 (lookup-key (current-local-map) keys)))
5699 (call-interactively func)
5700 (when (eq win (selected-window))
5701 (setq new-sum-point (point)
5702 new-sum-start (window-start win)
5703 new-sum-hscroll (window-hscroll win)))
5704 (when (eq in-buffer (current-buffer))
5705 (setq selected (gnus-summary-select-article))
5707 (unless not-restore-window
5708 (set-window-configuration owin))
5709 (when (eq selected 'old)
5711 (set-window-start (get-buffer-window (current-buffer))
5713 (set-window-point (get-buffer-window (current-buffer))
5715 (when (and (not not-restore-window)
5717 (set-window-point win new-sum-point)
5718 (set-window-start win new-sum-start)
5719 (set-window-hscroll win new-sum-hscroll))))
5720 (set-window-configuration owin)
5723 (defun gnus-article-describe-key (key)
5724 "Display documentation of the function invoked by KEY. KEY is a string."
5725 (interactive "kDescribe key: ")
5726 (gnus-article-check-buffer)
5727 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5729 (set-buffer gnus-article-current-summary)
5730 (let (gnus-pick-mode)
5731 (if (featurep 'xemacs)
5733 (push (elt key 0) unread-command-events)
5734 (setq key (events-to-keys
5735 (read-key-sequence "Describe key: "))))
5736 (setq unread-command-events
5738 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5739 (string-to-list key)))
5740 (setq key (read-key-sequence "Describe key: "))))
5742 (describe-key key)))
5744 (defun gnus-article-describe-key-briefly (key &optional insert)
5745 "Display documentation of the function invoked by KEY. KEY is a string."
5746 (interactive "kDescribe key: \nP")
5747 (gnus-article-check-buffer)
5748 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5750 (set-buffer gnus-article-current-summary)
5751 (let (gnus-pick-mode)
5752 (if (featurep 'xemacs)
5754 (push (elt key 0) unread-command-events)
5755 (setq key (events-to-keys
5756 (read-key-sequence "Describe key: "))))
5757 (setq unread-command-events
5759 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5760 (string-to-list key)))
5761 (setq key (read-key-sequence "Describe key: "))))
5762 (describe-key-briefly key insert))
5763 (describe-key-briefly key insert)))
5765 (defun gnus-article-reply-with-original (&optional wide)
5766 "Start composing a reply mail to the current message.
5767 The text in the region will be yanked. If the region isn't active,
5768 the entire article will be yanked."
5770 (let ((article (cdr gnus-article-current))
5772 (if (not (gnus-region-active-p))
5773 (with-current-buffer gnus-summary-buffer
5774 (gnus-summary-reply (list (list article)) wide))
5775 (setq contents (buffer-substring (point) (mark t)))
5776 ;; Deactivate active regions.
5777 (when (and (boundp 'transient-mark-mode)
5778 transient-mark-mode)
5779 (setq mark-active nil))
5780 (with-current-buffer gnus-summary-buffer
5782 (list (list article contents)) wide)))))
5784 (defun gnus-article-followup-with-original ()
5785 "Compose a followup to the current article.
5786 The text in the region will be yanked. If the region isn't active,
5787 the entire article will be yanked."
5789 (let ((article (cdr gnus-article-current))
5791 (if (not (gnus-region-active-p))
5792 (with-current-buffer gnus-summary-buffer
5793 (gnus-summary-followup (list (list article))))
5794 (setq contents (buffer-substring (point) (mark t)))
5795 ;; Deactivate active regions.
5796 (when (and (boundp 'transient-mark-mode)
5797 transient-mark-mode)
5798 (setq mark-active nil))
5799 (with-current-buffer gnus-summary-buffer
5800 (gnus-summary-followup
5801 (list (list article contents)))))))
5803 (defun gnus-article-hide (&optional arg force)
5804 "Hide all the gruft in the current article.
5805 This means that signatures, cited text and (some) headers will be
5807 If given a prefix, show the hidden text instead."
5808 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5809 (gnus-article-hide-headers arg)
5810 (gnus-article-hide-list-identifiers arg)
5811 (gnus-article-hide-citation-maybe arg force)
5812 (gnus-article-hide-signature arg))
5814 (defun gnus-article-maybe-highlight ()
5815 "Do some article highlighting if article highlighting is requested."
5816 (when (gnus-visual-p 'article-highlight 'highlight)
5817 (gnus-article-highlight-some)))
5819 (defun gnus-check-group-server ()
5820 ;; Make sure the connection to the server is alive.
5821 (unless (gnus-server-opened
5822 (gnus-find-method-for-group gnus-newsgroup-name))
5823 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5824 (gnus-request-group gnus-newsgroup-name t)))
5827 (autoload 'nneething-get-file-name "nneething"))
5829 (defun gnus-request-article-this-buffer (article group)
5830 "Get an article and insert it into this buffer."
5831 (let (do-update-line sparse-header)
5835 (gnus-kill-all-overlays)
5836 (setq group (or group gnus-newsgroup-name))
5838 ;; Using `gnus-request-article' directly will insert the article into
5839 ;; `nntp-server-buffer' - so we'll save some time by not having to
5840 ;; copy it from the server buffer into the article buffer.
5842 ;; We only request an article by message-id when we do not have the
5843 ;; headers for it, so we'll have to get those.
5844 (when (stringp article)
5845 (gnus-read-header article))
5847 ;; If the article number is negative, that means that this article
5848 ;; doesn't belong in this newsgroup (possibly), so we find its
5849 ;; message-id and request it by id instead of number.
5850 (when (and (numberp article)
5852 (get-buffer gnus-summary-buffer)
5853 (gnus-buffer-exists-p gnus-summary-buffer))
5855 (set-buffer gnus-summary-buffer)
5856 (let ((header (gnus-summary-article-header article)))
5859 ((memq article gnus-newsgroup-sparse)
5860 ;; This is a sparse gap article.
5861 (setq do-update-line article)
5862 (setq article (mail-header-id header))
5863 (setq sparse-header (gnus-read-header article))
5864 (setq gnus-newsgroup-sparse
5865 (delq article gnus-newsgroup-sparse)))
5867 ;; It's a real article.
5868 (setq article (mail-header-id header)))
5870 ;; It is an extracted pseudo-article.
5871 (setq article 'pseudo)
5872 (gnus-request-pseudo-article header))))
5874 (let ((method (gnus-find-method-for-group
5875 gnus-newsgroup-name)))
5876 (when (and (eq (car method) 'nneething)
5878 (let ((dir (nneething-get-file-name
5879 (mail-header-id header))))
5880 (when (and (stringp dir)
5881 (file-directory-p dir))
5882 (setq article 'nneething)
5883 (gnus-group-enter-directory dir))))))))
5886 ;; Refuse to select canceled articles.
5887 ((and (numberp article)
5889 (get-buffer gnus-summary-buffer)
5890 (gnus-buffer-exists-p gnus-summary-buffer)
5891 (eq (cdr (with-current-buffer gnus-summary-buffer
5892 (assq article gnus-newsgroup-reads)))
5893 gnus-canceled-mark))
5895 ;; We first check `gnus-original-article-buffer'.
5896 ((and (get-buffer gnus-original-article-buffer)
5898 (with-current-buffer gnus-original-article-buffer
5899 (and (equal (car gnus-original-article) group)
5900 (eq (cdr gnus-original-article) article))))
5901 (insert-buffer-substring gnus-original-article-buffer)
5903 ;; Check the backlog.
5904 ((and gnus-keep-backlog
5905 (gnus-backlog-request-article group article (current-buffer)))
5907 ;; Check asynchronous pre-fetch.
5908 ((gnus-async-request-fetched-article group article (current-buffer))
5909 (gnus-async-prefetch-next group article gnus-summary-buffer)
5910 (when (and (numberp article) gnus-keep-backlog)
5911 (gnus-backlog-enter-article group article (current-buffer)))
5914 ((and gnus-use-cache
5916 (gnus-cache-request-article article group))
5918 ;; Check the agent cache.
5919 ((gnus-agent-request-article article group)
5921 ;; Get the article and put into the article buffer.
5922 ((or (stringp article)
5924 (let ((gnus-override-method gnus-override-method)
5925 (methods (and (stringp article)
5926 gnus-refer-article-method))
5927 (backend (car (gnus-find-method-for-group
5928 gnus-newsgroup-name)))
5930 (inhibit-read-only t))
5931 (if (or (not (listp methods))
5932 (and (symbolp (car methods))
5933 (assq (car methods) nnoo-definition-alist)))
5934 (setq methods (list methods)))
5935 (when (and (null gnus-override-method)
5937 (setq gnus-override-method (pop methods)))
5939 (when (eq gnus-override-method 'current)
5940 (setq gnus-override-method
5941 (with-current-buffer gnus-summary-buffer
5942 gnus-current-select-method)))
5944 (gnus-kill-all-overlays)
5945 (let ((gnus-newsgroup-name group))
5946 (gnus-check-group-server))
5948 ((gnus-request-article article group (current-buffer))
5949 (when (numberp article)
5950 (gnus-async-prefetch-next group article
5951 gnus-summary-buffer)
5952 (when gnus-keep-backlog
5953 (gnus-backlog-enter-article
5954 group article (current-buffer))))
5955 (setq result 'article))
5957 (setq gnus-override-method (pop methods)))
5958 ((not (string-match "^400 "
5959 (nnheader-get-report backend)))
5960 ;; If we get 400 server disconnect, reconnect and
5961 ;; retry; otherwise, assume the article has expired.
5962 (setq result 'done))))
5963 (and (eq result 'article) 'article)))
5967 ;; Associate this article with the current summary buffer.
5968 (setq gnus-article-current-summary gnus-summary-buffer)
5970 ;; Take the article from the original article buffer
5971 ;; and place it in the buffer it's supposed to be in.
5972 (when (and (get-buffer gnus-article-buffer)
5973 (equal (buffer-name (current-buffer))
5974 (buffer-name (get-buffer gnus-article-buffer))))
5976 (if (get-buffer gnus-original-article-buffer)
5977 (set-buffer gnus-original-article-buffer)
5978 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5979 (buffer-disable-undo)
5980 (setq major-mode 'gnus-original-article-mode)
5981 (setq buffer-read-only t))
5982 (let ((inhibit-read-only t))
5984 (insert-buffer-substring gnus-article-buffer))
5985 (setq gnus-original-article (cons group article)))
5988 (run-hooks 'gnus-article-decode-hook)
5989 ;; Mark article as decoded or not.
5990 (setq gnus-article-decoded-p gnus-article-decode-hook))
5992 ;; Update sparse articles.
5993 (when (and do-update-line
5994 (or (numberp article)
5996 (let ((buf (current-buffer)))
5997 (set-buffer gnus-summary-buffer)
5998 (gnus-summary-update-article do-update-line sparse-header)
5999 (gnus-summary-goto-subject do-update-line nil t)
6000 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6002 (set-buffer buf))))))
6008 (defcustom gnus-article-edit-mode-hook nil
6009 "Hook run in article edit mode buffers."
6010 :group 'gnus-article-various
6013 (defvar gnus-article-edit-done-function nil)
6015 (defvar gnus-article-edit-mode-map nil)
6017 ;; Should we be using derived.el for this?
6018 (unless gnus-article-edit-mode-map
6019 (setq gnus-article-edit-mode-map (make-keymap))
6020 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6022 (gnus-define-keys gnus-article-edit-mode-map
6023 "\C-c?" describe-mode
6024 "\C-c\C-c" gnus-article-edit-done
6025 "\C-c\C-k" gnus-article-edit-exit
6026 "\C-c\C-f\C-t" message-goto-to
6027 "\C-c\C-f\C-o" message-goto-from
6028 "\C-c\C-f\C-b" message-goto-bcc
6029 ;;"\C-c\C-f\C-w" message-goto-fcc
6030 "\C-c\C-f\C-c" message-goto-cc
6031 "\C-c\C-f\C-s" message-goto-subject
6032 "\C-c\C-f\C-r" message-goto-reply-to
6033 "\C-c\C-f\C-n" message-goto-newsgroups
6034 "\C-c\C-f\C-d" message-goto-distribution
6035 "\C-c\C-f\C-f" message-goto-followup-to
6036 "\C-c\C-f\C-m" message-goto-mail-followup-to
6037 "\C-c\C-f\C-k" message-goto-keywords
6038 "\C-c\C-f\C-u" message-goto-summary
6039 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6040 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6041 "\C-c\C-b" message-goto-body
6042 "\C-c\C-i" message-goto-signature
6044 "\C-c\C-t" message-insert-to
6045 "\C-c\C-n" message-insert-newsgroups
6046 "\C-c\C-o" message-sort-headers
6047 "\C-c\C-e" message-elide-region
6048 "\C-c\C-v" message-delete-not-region
6049 "\C-c\C-z" message-kill-to-signature
6050 "\M-\r" message-newline-and-reformat
6051 "\C-c\C-a" mml-attach-file
6052 "\C-a" message-beginning-of-line
6054 "\M-;" comment-region)
6056 (gnus-define-keys (gnus-article-edit-wash-map
6057 "\C-c\C-w" gnus-article-edit-mode-map)
6058 "f" gnus-article-edit-full-stops))
6061 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6063 ["Fetch To" message-insert-to t]
6064 ["Fetch Newsgroups" message-insert-newsgroups t]
6066 ["To" message-goto-to t]
6067 ["From" message-goto-from t]
6068 ["Subject" message-goto-subject t]
6069 ["Cc" message-goto-cc t]
6070 ["Reply-To" message-goto-reply-to t]
6071 ["Summary" message-goto-summary t]
6072 ["Keywords" message-goto-keywords t]
6073 ["Newsgroups" message-goto-newsgroups t]
6074 ["Followup-To" message-goto-followup-to t]
6075 ["Mail-Followup-To" message-goto-mail-followup-to t]
6076 ["Distribution" message-goto-distribution t]
6077 ["Body" message-goto-body t]
6078 ["Signature" message-goto-signature t]))
6080 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6081 "Major mode for editing articles.
6082 This is an extended text-mode.
6084 \\{gnus-article-edit-mode-map}"
6085 (make-local-variable 'gnus-article-edit-done-function)
6086 (make-local-variable 'gnus-prev-winconf)
6087 (set (make-local-variable 'font-lock-defaults)
6088 '(message-font-lock-keywords t))
6089 (set (make-local-variable 'mail-header-separator) "")
6090 (set (make-local-variable 'gnus-article-edit-mode) t)
6091 (easy-menu-add message-mode-field-menu message-mode-map)
6093 (setq buffer-read-only nil)
6094 (buffer-enable-undo)
6097 (defun gnus-article-edit (&optional force)
6098 "Edit the current article.
6099 This will have permanent effect only in mail groups.
6100 If FORCE is non-nil, allow editing of articles even in read-only
6103 (when (and (not force)
6104 (gnus-group-read-only-p))
6105 (error "The current newsgroup does not support article editing"))
6106 (gnus-article-date-original)
6107 (gnus-article-edit-article
6109 `(lambda (no-highlight)
6111 (gnus-summary-edit-article-done
6112 ,(or (mail-header-references gnus-current-headers) "")
6113 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6115 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6116 "Start editing the contents of the current article buffer."
6117 (let ((winconf (current-window-configuration)))
6118 (set-buffer gnus-article-buffer)
6119 (let ((message-auto-save-directory
6120 ;; Don't associate the article buffer with a draft file.
6122 (gnus-article-edit-mode))
6123 (funcall start-func)
6124 (set-buffer-modified-p nil)
6125 (gnus-configure-windows 'edit-article)
6126 (setq gnus-article-edit-done-function exit-func)
6127 (setq gnus-prev-winconf winconf)
6129 (gnus-message 6 "C-c C-c to end edits"))))
6131 (defun gnus-article-edit-done (&optional arg)
6132 "Update the article edits and exit."
6134 (let ((func gnus-article-edit-done-function)
6135 (buf (current-buffer))
6136 (start (window-start))
6138 (winconf gnus-prev-winconf))
6139 (widen) ;; Widen it in case that users narrowed the buffer.
6142 ;; The cache and backlog have to be flushed somewhat.
6143 (when gnus-keep-backlog
6144 (gnus-backlog-remove-article
6145 (car gnus-article-current) (cdr gnus-article-current)))
6146 ;; Flush original article as well.
6148 (when (get-buffer gnus-original-article-buffer)
6149 (set-buffer gnus-original-article-buffer)
6150 (setq gnus-original-article nil)))
6151 (when gnus-use-cache
6152 (gnus-cache-update-article
6153 (car gnus-article-current) (cdr gnus-article-current)))
6154 ;; We remove all text props from the article buffer.
6155 (kill-all-local-variables)
6156 (set-text-properties (point-min) (point-max) nil)
6158 (set-window-configuration winconf)
6160 (set-window-start (get-buffer-window buf) start)
6161 (set-window-point (get-buffer-window buf) (point)))
6162 (gnus-summary-show-article))
6164 (defun gnus-article-edit-exit ()
6165 "Exit the article editing without updating."
6167 (when (or (not (buffer-modified-p))
6168 (yes-or-no-p "Article modified; kill anyway? "))
6169 (let ((curbuf (current-buffer))
6171 (window-start (window-start)))
6173 (if (gnus-buffer-live-p gnus-original-article-buffer)
6174 (insert-buffer-substring gnus-original-article-buffer))
6175 (let ((winconf gnus-prev-winconf))
6176 (kill-all-local-variables)
6178 (set-window-configuration winconf)
6179 ;; Tippy-toe some to make sure that point remains where it was.
6180 (save-current-buffer
6182 (set-window-start (get-buffer-window (current-buffer)) window-start)
6184 (gnus-summary-show-article)))
6186 (defun gnus-article-edit-full-stops ()
6187 "Interactively repair spacing at end of sentences."
6190 (goto-char (point-min))
6191 (search-forward-regexp "^$" nil t)
6192 (let ((case-fold-search nil))
6193 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6196 ;;; Article highlights
6199 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6201 ;;; Internal Variables:
6203 (defcustom gnus-button-url-regexp
6204 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6205 "\\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:]]\\)"
6206 "\\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\\)\\)")
6207 "Regular expression that matches URLs."
6208 :group 'gnus-article-buttons
6211 (defcustom gnus-button-valid-fqdn-regexp
6212 message-valid-fqdn-regexp
6213 "Regular expression that matches a valid FQDN."
6215 :group 'gnus-article-buttons
6218 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6219 (defcustom gnus-button-valid-localpart-regexp
6220 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6221 "Regular expression that matches a localpart of mail addresses or MIDs."
6223 :group 'gnus-article-buttons
6226 (defcustom gnus-button-man-handler 'manual-entry
6227 "Function to use for displaying man pages.
6228 The function must take at least one argument with a string naming the
6231 :type '(choice (function-item :tag "Man" manual-entry)
6232 (function-item :tag "Woman" woman)
6233 (function :tag "Other"))
6234 :group 'gnus-article-buttons)
6236 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6237 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6238 If the default site is too slow, try to find a CTAN mirror, see
6239 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6240 the variable `gnus-button-handle-ctan'."
6242 :group 'gnus-article-buttons
6243 :link '(custom-manual "(gnus)Group Parameters")
6244 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6245 (const "http://tug.ctan.org/tex-archive/")
6246 (const "http://www.dante.de/CTAN/")
6247 (string :tag "Other")))
6249 (defcustom gnus-button-ctan-handler 'browse-url
6250 "Function to use for displaying CTAN links.
6251 The function must take one argument, the string naming the URL."
6253 :type '(choice (function-item :tag "Browse Url" browse-url)
6254 (function :tag "Other"))
6255 :group 'gnus-article-buttons)
6257 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6258 "Bogus strings removed from CTAN URLs."
6260 :group 'gnus-article-buttons
6261 :type '(choice (const "^/?tex-archive/\\|/")
6262 (regexp :tag "Other")))
6264 (defcustom gnus-button-ctan-directory-regexp
6266 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6267 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6268 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6269 "tds" "tools" "usergrps" "web") t)
6270 "Regular expression for ctan directories.
6271 It should match all directories in the top level of `gnus-ctan-url'."
6273 :group 'gnus-article-buttons
6276 (defcustom gnus-button-mid-or-mail-regexp
6277 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6278 gnus-button-valid-fqdn-regexp
6280 "Regular expression that matches a message ID or a mail address."
6282 :group 'gnus-article-buttons
6285 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6286 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6287 Strings like this can be either a message ID or a mail address. If it is one
6288 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6289 message ID or a mail address, respectively. If this variable is set to the
6290 symbol `ask', always query the user what do do. If it is a function, this
6291 function will be called with the string as it's only argument. The function
6292 must return `mid', `mail', `invalid' or `ask'."
6294 :group 'gnus-article-buttons
6295 :type '(choice (function-item :tag "Heuristic function"
6296 gnus-button-mid-or-mail-heuristic)
6301 (defcustom gnus-button-mid-or-mail-heuristic-alist
6302 '((-10.0 . ".+\\$.+@")
6305 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6306 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6307 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6308 (-1.0 . "^[^a-z]+@")
6310 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6311 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6312 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6313 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6316 (-1.0 . "^[0-9][0-9]")
6318 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6319 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6320 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6321 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6323 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6324 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6327 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6329 ;; compensation for TDMA dated mail addresses:
6330 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6332 (-20.0 . "\\.fsf@") ;; Gnus
6335 (-20.0 . "_-_") ;; Subject change in thread
6337 (-20.0 . "\\.ln@") ;; leafnode
6338 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6339 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6341 ;; (5.0 . "") ;; $local_part_len <= 7
6342 (10.0 . "^[^0-9]+@")
6343 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6344 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6347 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6349 (0.5 . "^[A-Z][a-z]")
6350 (0.5 . "^[A-Z][a-z][a-z]")
6351 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6352 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6353 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6355 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6356 address. The REGEXP is processed with `case-fold-search' set to nil."
6358 :group 'gnus-article-buttons
6359 :type '(repeat (cons (number :tag "Rate")
6360 (regexp :tag "Regexp"))))
6362 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6363 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6364 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6365 address, `ask' if unsure and `invalid' if the string is invalid."
6366 (let ((case-fold-search nil)
6367 (list gnus-button-mid-or-mail-heuristic-alist)
6368 (result 0) rate regexp lpartlen elem)
6370 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6371 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6372 ;; Certain special cases...
6375 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6376 "^[0-9]+\\.[0-9]+@compuserve\\|"
6377 "@public\\.gmane\\.org")
6379 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6380 (setq result 'mail))
6381 (when (string-match "@.*@\\| " mid-or-mail)
6382 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6383 (setq result 'invalid))
6384 ;; Nothing more to do, if result is not a number here...
6385 (when (numberp result)
6387 (setq elem (car list)
6391 (when (string-match regexp mid-or-mail)
6392 (setq result (+ result rate))
6394 9 "`%s' matched `%s', rate `%s', result `%s'."
6395 mid-or-mail regexp rate result)))
6396 (when (<= lpartlen 7)
6397 (setq result (+ result 5.0))
6398 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6399 mid-or-mail result))
6400 (when (>= lpartlen 12)
6401 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6403 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6404 ;; Long local part should contain realname if e-mail address,
6405 ;; too many digits: message-id.
6406 ;; $score -= 5.0 + 0.1 * $local_part_len;
6407 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6408 (setq result (+ result rate))
6410 9 "Many digits in `%s', rate `%s', result `%s'."
6411 mid-or-mail rate result))
6412 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6414 ;; Too few vowels [^aeiouy]{4,}.*\@
6415 (setq result (+ result -5.0))
6417 9 "Few vowels in `%s', rate `%s', result `%s'."
6418 mid-or-mail -5.0 result))
6420 (setq result (+ result 5.0))
6422 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6423 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6424 ;; Maybe we should make this a customizable alist: (condition . 'result)
6426 ((symbolp result) result)
6427 ;; Now convert number into proper results:
6428 ((< result -10.0) 'mid)
6429 ((> result 10.0) 'mail)
6432 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6433 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6434 (url-mid (concat "news" ":" mid-or-mail))
6435 (url-mailto (concat "mailto" ":" mid-or-mail)))
6436 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6437 (when (fboundp pref)
6439 ;; get rid of surrounding angles...
6441 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6442 (if (or (eq 'mid guessed) (eq 'mail guessed))
6446 (save-window-excursion
6447 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6450 (cond ((eq pref 'mid)
6451 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6452 (gnus-button-handle-news url-mid))
6454 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6455 (gnus-url-mailto url-mailto))
6456 (t (gnus-message 3 "Invalid string.")))))
6458 (defun gnus-button-handle-custom (fun arg)
6459 "Call function FUN on argument ARG.
6460 Both FUN and ARG are supposed to be strings. ARG will be passed
6461 as a symbol to FUN."
6462 (funcall (intern fun) (intern arg)))
6464 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6466 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6469 (defun gnus-button-handle-describe-function (url)
6470 "Call `describe-function' when pushing the corresponding URL button."
6473 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6475 (defun gnus-button-handle-describe-variable (url)
6476 "Call `describe-variable' when pushing the corresponding URL button."
6479 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6481 (defun gnus-button-handle-symbol (url)
6482 "Display help on variable or function.
6483 Calls `describe-variable' or `describe-function'."
6484 (let ((sym (intern url)))
6486 ((fboundp sym) (describe-function sym))
6487 ((boundp sym) (describe-variable sym))
6488 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6490 (defun gnus-button-handle-describe-key (url)
6491 "Call `describe-key' when pushing the corresponding URL button."
6493 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6494 (keys (ignore-errors (eval `(kbd ,key-string)))))
6497 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6499 (defun gnus-button-handle-apropos (url)
6500 "Call `apropos' when pushing the corresponding URL button."
6501 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6503 (defun gnus-button-handle-apropos-command (url)
6504 "Call `apropos' when pushing the corresponding URL button."
6506 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6508 (defun gnus-button-handle-apropos-variable (url)
6509 "Call `apropos' when pushing the corresponding URL button."
6511 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6512 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6514 (defun gnus-button-handle-apropos-documentation (url)
6515 "Call `apropos' when pushing the corresponding URL button."
6517 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6518 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6520 (defun gnus-button-handle-library (url)
6521 "Call `locate-library' when pushing the corresponding URL button."
6522 (gnus-message 9 "url=`%s'" url)
6523 (let* ((lib (locate-library url))
6524 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6526 (gnus-message 1 "Cannot locale library `%s'." url)
6527 (find-file-read-only file))))
6529 (defun gnus-button-handle-ctan (url)
6530 "Call `browse-url' when pushing a CTAN URL button."
6532 gnus-button-ctan-handler
6535 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6537 (defcustom gnus-button-tex-level 5
6538 "*Integer that says how many TeX-related buttons Gnus will show.
6539 The higher the number, the more buttons will appear and the more false
6540 positives are possible. Note that you can set this variable local to
6541 specific groups. Setting it higher in TeX groups is probably a good idea.
6542 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6543 how to set variables in specific groups."
6545 :group 'gnus-article-buttons
6546 :link '(custom-manual "(gnus)Group Parameters")
6549 (defcustom gnus-button-man-level 5
6550 "*Integer that says how many man-related buttons Gnus will show.
6551 The higher the number, the more buttons will appear and the more false
6552 positives are possible. Note that you can set this variable local to
6553 specific groups. Setting it higher in Unix groups is probably a good idea.
6554 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6555 how to set variables in specific groups."
6557 :group 'gnus-article-buttons
6558 :link '(custom-manual "(gnus)Group Parameters")
6561 (defcustom gnus-button-emacs-level 5
6562 "*Integer that says how many emacs-related buttons Gnus will show.
6563 The higher the number, the more buttons will appear and the more false
6564 positives are possible. Note that you can set this variable local to
6565 specific groups. Setting it higher in Emacs or Gnus related groups is
6566 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6567 `gnus-parameters' on how to set variables in specific groups."
6569 :group 'gnus-article-buttons
6570 :link '(custom-manual "(gnus)Group Parameters")
6573 (defcustom gnus-button-message-level 5
6574 "*Integer that says how many buttons for news or mail messages will appear.
6575 The higher the number, the more buttons will appear and the more false
6576 positives are possible."
6577 ;; mail addresses, MIDs, URLs for news, ...
6579 :group 'gnus-article-buttons
6582 (defcustom gnus-button-browse-level 5
6583 "*Integer that says how many buttons for browsing will appear.
6584 The higher the number, the more buttons will appear and the more false
6585 positives are possible."
6586 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6588 :group 'gnus-article-buttons
6591 (defcustom gnus-button-alist
6592 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6593 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6594 ((concat "\\b\\(nntp\\|news\\):\\("
6595 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6596 0 t gnus-button-handle-news 2)
6597 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6598 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6599 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6600 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6601 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6602 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6603 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6604 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6605 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6606 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6607 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6608 ;; RFC 2368 (The mailto URL scheme)
6609 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6610 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6611 ("\\bmailto:\\([^ \n\t]+\\)"
6612 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6614 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6615 gnus-button-ctan-directory-regexp
6616 "[^][>)!;:,'\n\t ]+\\)")
6617 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6618 ((concat "\\btex-archive/\\("
6619 gnus-button-ctan-directory-regexp
6620 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6621 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6624 gnus-button-ctan-directory-regexp
6625 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6626 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6627 ;; This is info (home-grown style) <info://foo/bar+baz>
6628 ("\\binfo://\\([^'\">\n\t ]+\\)"
6629 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6630 ;; Info GNOME style <info:foo#bar_baz>
6631 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6632 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6633 ;; Info KDE style <info:(foo)bar baz>
6634 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6635 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6636 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6637 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6638 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6639 ;; Info links like `C-h i d m CC Mode RET'
6640 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6642 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6643 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6644 ;; Emacs help commands
6645 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6646 ;; regexp doesn't match arguments containing ` '.
6647 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6648 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6649 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6650 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6651 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6652 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6653 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6654 ;; The following entries may lead to many false positives so don't enable
6655 ;; them by default (use a high button level).
6656 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6657 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6658 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6659 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6660 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6661 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6662 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6663 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6664 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6665 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6666 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6667 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6668 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6669 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6670 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6671 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6672 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6673 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6674 ;; Unlike the other regexps we really have to require quoting
6675 ;; here to determine where it ends.
6676 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6677 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6678 ("<URL: *\\([^<>]*\\)>"
6679 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6680 ;; RFC 2396 (2.4.3., delims) ...
6681 ("\"URL: *\\([^\"]*\\)\""
6682 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6683 ;; RFC 2396 (2.4.3., delims) ...
6684 ("\"URL: *\\([^\"]*\\)\""
6685 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6687 (gnus-button-url-regexp
6688 0 (>= gnus-button-browse-level 0) browse-url 0)
6690 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6691 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6692 gnus-button-handle-man 1)
6693 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6694 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6695 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6696 gnus-button-handle-man 1)
6697 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6698 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6699 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6700 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6701 ;; MID or mail: To avoid too many false positives we don't try to catch
6702 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6703 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6704 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6705 ;; so that non-ambiguous entries (see above) match first.
6706 (gnus-button-mid-or-mail-regexp
6707 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6708 "*Alist of regexps matching buttons in article bodies.
6710 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6711 REGEXP: is the string (case insensitive) matching text around the button (can
6712 also be Lisp expression evaluating to a string),
6713 BUTTON: is the number of the regexp grouping actually matching the button,
6714 FORM: is a Lisp expression which must eval to true for the button to
6716 CALLBACK: is the function to call when the user push this button, and each
6717 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6719 CALLBACK can also be a variable, in that case the value of that
6720 variable it the real callback function."
6721 :group 'gnus-article-buttons
6722 :type '(repeat (list (choice regexp variable sexp)
6723 (integer :tag "Button")
6725 (function :tag "Callback")
6728 (integer :tag "Regexp group")))))
6730 (defcustom gnus-header-button-alist
6731 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6732 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6733 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6734 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6735 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6736 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6737 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6738 0 (>= gnus-button-browse-level 0) browse-url 0)
6739 ("^Subject:" gnus-button-url-regexp
6740 0 (>= gnus-button-browse-level 0) browse-url 0)
6741 ("^[^:]+:" gnus-button-url-regexp
6742 0 (>= gnus-button-browse-level 0) browse-url 0)
6743 ("^OpenPGP:.*url=" gnus-button-url-regexp
6744 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6745 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6746 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6747 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6748 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6749 "*Alist of headers and regexps to match buttons in article heads.
6751 This alist is very similar to `gnus-button-alist', except that each
6752 alist has an additional HEADER element first in each entry:
6754 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6756 HEADER is a regexp to match a header. For a fuller explanation, see
6757 `gnus-button-alist'."
6758 :group 'gnus-article-buttons
6759 :group 'gnus-article-headers
6760 :type '(repeat (list (regexp :tag "Header")
6761 (choice regexp variable)
6762 (integer :tag "Button")
6764 (function :tag "Callback")
6767 (integer :tag "Regexp group")))))
6771 (defun gnus-article-push-button (event)
6772 "Check text under the mouse pointer for a callback function.
6773 If the text under the mouse pointer has a `gnus-callback' property,
6774 call it with the value of the `gnus-data' text property."
6776 (set-buffer (window-buffer (posn-window (event-start event))))
6777 (let* ((pos (posn-point (event-start event)))
6778 (data (get-text-property pos 'gnus-data))
6779 (fun (get-text-property pos 'gnus-callback)))
6782 (funcall fun data))))
6784 (defun gnus-article-press-button ()
6785 "Check text at point for a callback function.
6786 If the text at point has a `gnus-callback' property,
6787 call it with the value of the `gnus-data' text property."
6789 (let ((data (get-text-property (point) 'gnus-data))
6790 (fun (get-text-property (point) 'gnus-callback)))
6792 (funcall fun data))))
6794 (defun gnus-article-highlight (&optional force)
6795 "Highlight current article.
6796 This function calls `gnus-article-highlight-headers',
6797 `gnus-article-highlight-citation',
6798 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6799 do the highlighting. See the documentation for those functions."
6800 (interactive (list 'force))
6801 (gnus-article-highlight-headers)
6802 (gnus-article-highlight-citation force)
6803 (gnus-article-highlight-signature)
6804 (gnus-article-add-buttons force)
6805 (gnus-article-add-buttons-to-head))
6807 (defun gnus-article-highlight-some (&optional force)
6808 "Highlight current article.
6809 This function calls `gnus-article-highlight-headers',
6810 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6811 do the highlighting. See the documentation for those functions."
6812 (interactive (list 'force))
6813 (gnus-article-highlight-headers)
6814 (gnus-article-highlight-signature)
6815 (gnus-article-add-buttons))
6817 (defun gnus-article-highlight-headers ()
6818 "Highlight article headers as specified by `gnus-header-face-alist'."
6820 (gnus-with-article-headers
6821 (let (regexp header-face field-face from hpoints fpoints)
6822 (dolist (entry gnus-header-face-alist)
6823 (goto-char (point-min))
6824 (setq regexp (concat "^\\("
6825 (if (string-equal "" (nth 0 entry))
6829 header-face (nth 1 entry)
6830 field-face (nth 2 entry))
6831 (while (and (re-search-forward regexp nil t)
6835 (unless (search-forward ":" nil t)
6837 (when (and header-face
6838 (not (memq (point) hpoints)))
6839 (push (point) hpoints)
6840 (gnus-put-text-property from (point) 'face header-face))
6841 (when (and field-face
6842 (not (memq (setq from (point)) fpoints)))
6844 (if (re-search-forward "^[^ \t]" nil t)
6846 (goto-char (point-max)))
6847 (gnus-put-text-property from (point) 'face field-face)))))))
6849 (defun gnus-article-highlight-signature ()
6850 "Highlight the signature in an article.
6851 It does this by highlighting everything after
6852 `gnus-signature-separator' using the face `gnus-signature'."
6854 (gnus-with-article-buffer
6855 (let ((inhibit-point-motion-hooks t))
6857 (when (and gnus-signature-face
6858 (gnus-article-narrow-to-signature))
6859 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6860 'face gnus-signature-face)
6862 (gnus-article-search-signature)
6863 (let ((start (match-beginning 0))
6864 (end (set-marker (make-marker) (1+ (match-end 0)))))
6865 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6868 (defun gnus-button-in-region-p (b e prop)
6869 "Say whether PROP exists in the region."
6870 (text-property-not-all b e prop nil))
6872 (defun gnus-article-add-buttons (&optional force)
6873 "Find external references in the article and make buttons of them.
6874 \"External references\" are things like Message-IDs and URLs, as
6875 specified by `gnus-button-alist'."
6876 (interactive (list 'force))
6877 (gnus-with-article-buffer
6878 (let ((inhibit-point-motion-hooks t)
6879 (case-fold-search t)
6880 (alist gnus-button-alist)
6882 ;; Remove all old markers.
6883 (let (marker entry new-list)
6884 (while (setq marker (pop gnus-button-marker-list))
6885 (if (or (< marker (point-min)) (>= marker (point-max)))
6886 (push marker new-list)
6888 (when (setq entry (gnus-button-entry))
6889 (put-text-property (match-beginning (nth 1 entry))
6890 (match-end (nth 1 entry))
6891 'gnus-callback nil))
6892 (set-marker marker nil)))
6893 (setq gnus-button-marker-list new-list))
6894 ;; We skip the headers.
6897 (while (setq entry (pop alist))
6898 (setq regexp (eval (car entry)))
6900 (while (re-search-forward regexp nil t)
6901 (let* ((start (and entry (match-beginning (nth 1 entry))))
6902 (end (and entry (match-end (nth 1 entry))))
6903 (from (match-beginning 0)))
6904 (when (and (or (eq t (nth 2 entry))
6905 (eval (nth 2 entry)))
6906 (not (gnus-button-in-region-p
6907 start end 'gnus-callback)))
6908 ;; That optional form returned non-nil, so we add the
6910 (gnus-article-add-button
6911 start end 'gnus-button-push
6912 (car (push (set-marker (make-marker) from)
6913 gnus-button-marker-list))))))))))
6915 ;; Add buttons to the head of an article.
6916 (defun gnus-article-add-buttons-to-head ()
6917 "Add buttons to the head of the article."
6919 (gnus-with-article-headers
6921 (dolist (entry gnus-header-button-alist)
6922 ;; Each alist entry.
6923 (goto-char (point-min))
6924 (while (re-search-forward (car entry) nil t)
6925 ;; Each header matching the entry.
6926 (setq beg (match-beginning 0))
6927 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6928 (match-beginning 0))
6931 (while (re-search-forward (eval (nth 1 entry)) end t)
6932 ;; Each match within a header.
6933 (let* ((entry (cdr entry))
6934 (start (match-beginning (nth 1 entry)))
6935 (end (match-end (nth 1 entry)))
6936 (form (nth 2 entry)))
6937 (goto-char (match-end 0))
6939 (gnus-article-add-button
6940 start end (nth 3 entry)
6941 (buffer-substring (match-beginning (nth 4 entry))
6942 (match-end (nth 4 entry)))))))
6943 (goto-char end))))))
6945 ;;; External functions:
6947 (defun gnus-article-add-button (from to fun &optional data)
6948 "Create a button between FROM and TO with callback FUN and data DATA."
6949 (when gnus-article-button-face
6950 (gnus-overlay-put (gnus-make-overlay from to)
6951 'face gnus-article-button-face))
6952 (gnus-add-text-properties
6954 (nconc (and gnus-article-mouse-face
6955 (list gnus-mouse-face-prop gnus-article-mouse-face))
6956 (list 'gnus-callback fun)
6957 (and data (list 'gnus-data data))))
6958 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6959 :button-keymap gnus-widget-button-keymap))
6961 ;;; Internal functions:
6963 (defun gnus-article-set-globals ()
6964 (with-current-buffer gnus-summary-buffer
6965 (gnus-set-global-variables)))
6967 (defun gnus-signature-toggle (end)
6968 (gnus-with-article-buffer
6969 (let ((inhibit-point-motion-hooks t))
6970 (if (text-property-any end (point-max) 'article-type 'signature)
6972 (gnus-delete-wash-type 'signature)
6973 (gnus-remove-text-properties-when
6974 'article-type 'signature end (point-max)
6975 (cons 'article-type (cons 'signature
6976 gnus-hidden-properties))))
6977 (gnus-add-wash-type 'signature)
6978 (gnus-add-text-properties-when
6979 'article-type nil end (point-max)
6980 (cons 'article-type (cons 'signature
6981 gnus-hidden-properties)))))
6982 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6983 (gnus-set-mode-line 'article))))
6985 (defun gnus-button-entry ()
6986 ;; Return the first entry in `gnus-button-alist' matching this place.
6987 (let ((alist gnus-button-alist)
6990 (setq entry (pop alist))
6991 (if (looking-at (eval (car entry)))
6996 (defun gnus-button-push (marker)
6997 ;; Push button starting at MARKER.
7000 (let* ((entry (gnus-button-entry))
7001 (inhibit-point-motion-hooks t)
7003 (args (mapcar (lambda (group)
7004 (let ((string (match-string group)))
7005 (set-text-properties
7006 0 (length string) nil string)
7013 (fboundp (symbol-value fun)))
7014 (apply (symbol-value fun) args))
7016 (gnus-message 1 "You must define `%S' to use this button"
7017 (cons fun args)))))))
7019 (defun gnus-parse-news-url (url)
7020 (let (scheme server port group message-id articles)
7023 (goto-char (point-min))
7024 (when (looking-at "\\([A-Za-z]+\\):")
7025 (setq scheme (match-string 1))
7026 (goto-char (match-end 0)))
7027 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7028 (setq server (match-string 1))
7029 (setq port (if (stringp (match-string 3))
7030 (string-to-number (match-string 3))
7032 (goto-char (match-end 0)))
7035 ((looking-at "\\(.*@.*\\)")
7036 (setq message-id (match-string 1)))
7037 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7038 (setq group (match-string 1)
7039 articles (split-string (match-string 2) "-")))
7040 ((looking-at "\\([^/]+\\)/?")
7041 (setq group (match-string 1)))
7043 (error "Unknown news URL syntax"))))
7044 (list scheme server port group message-id articles)))
7046 (defun gnus-button-handle-news (url)
7048 (destructuring-bind (scheme server port group message-id articles)
7049 (gnus-parse-news-url url)
7053 (set-buffer gnus-summary-buffer)
7055 (let ((gnus-refer-article-method
7056 (nconc (list (list 'nntp server))
7057 gnus-refer-article-method))
7058 (nntp-port-number (or port "nntp")))
7059 (gnus-message 7 "Fetching %s with %s"
7060 message-id gnus-refer-article-method)
7061 (gnus-summary-refer-article message-id))
7062 (gnus-summary-refer-article message-id))))
7064 (gnus-button-fetch-group url)))))
7066 (defun gnus-button-handle-man (url)
7068 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7069 (when (eq gnus-button-man-handler 'woman)
7070 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7071 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7072 (funcall gnus-button-man-handler url))
7074 (defun gnus-button-handle-info-url (url)
7075 "Fetch an info URL."
7076 (setq url (mm-subst-char-in-string ?+ ?\ url))
7078 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7079 (gnus-info-find-node
7080 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7082 ")" (gnus-url-unhex-string (match-string 2 url)))))
7083 ((string-match "([^)\"]+)[^\"]+" url)
7085 (gnus-replace-in-string
7086 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7087 (gnus-info-find-node url))
7088 (t (error "Can't parse %s" url))))
7090 (defun gnus-button-handle-info-url-gnome (url)
7091 "Fetch GNOME style info URL."
7092 (setq url (mm-subst-char-in-string ?_ ?\ url))
7093 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7094 (gnus-info-find-node
7096 (gnus-url-unhex-string
7097 (match-string 1 url))
7099 (or (gnus-url-unhex-string
7100 (match-string 2 url))
7102 (error "Can't parse %s" url)))
7104 (defun gnus-button-handle-info-url-kde (url)
7105 "Fetch KDE style info URL."
7106 (gnus-info-find-node (gnus-url-unhex-string url)))
7108 (defun gnus-button-handle-info-keystrokes (url)
7109 "Call `info' when pushing the corresponding URL button."
7110 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7115 (defun gnus-button-openpgp (url)
7116 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7118 (mm-url-insert-file-contents-external url)
7119 (pgg-snarf-keys-region (point-min) (point-max))
7120 (pgg-display-output-buffer nil nil nil)))
7122 (defun gnus-button-message-id (message-id)
7124 (with-current-buffer gnus-summary-buffer
7125 (gnus-summary-refer-article message-id)))
7127 (defun gnus-button-fetch-group (address)
7128 "Fetch GROUP specified by ADDRESS."
7129 (if (not (string-match "[:/]" address))
7130 ;; This is just a simple group url.
7131 (gnus-group-read-ephemeral-group address gnus-select-method)
7134 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7136 (error "Can't parse %s" address)
7137 (gnus-group-read-ephemeral-group
7138 (match-string 4 address)
7139 `(nntp ,(match-string 1 address)
7140 (nntp-address ,(match-string 1 address))
7141 (nntp-port-number ,(if (match-end 3)
7142 (match-string 3 address)
7145 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7147 (defun gnus-url-parse-query-string (query &optional downcase)
7148 (let (retval pairs cur key val)
7149 (setq pairs (split-string query "&"))
7151 (setq cur (car pairs)
7153 (if (not (string-match "=" cur))
7155 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7156 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7158 (setq key (downcase key)))
7159 (setq cur (assoc key retval))
7161 (setcdr cur (cons val (cdr cur)))
7162 (setq retval (cons (list key val) retval)))))
7165 (defun gnus-url-mailto (url)
7166 ;; Send mail to someone
7167 (when (string-match "mailto:/*\\(.*\\)" url)
7168 (setq url (substring url (match-beginning 1) nil)))
7169 (let (to args subject func)
7170 (setq args (gnus-url-parse-query-string
7171 (if (string-match "^\\?" url)
7173 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7174 (concat "to=" (match-string 1 url) "&"
7175 (match-string 2 url))
7176 (concat "to=" url)))
7178 subject (cdr-safe (assoc "subject" args)))
7181 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7184 (message-position-on-field (caar args)))
7185 (insert (gnus-replace-in-string
7186 (mapconcat 'identity (reverse (cdar args)) ", ")
7188 (setq args (cdr args)))
7191 (message-goto-subject))))
7193 (defun gnus-button-embedded-url (address)
7194 "Activate ADDRESS with `browse-url'."
7195 (browse-url (gnus-strip-whitespace address)))
7197 ;;; Next/prev buttons in the article buffer.
7199 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7200 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7202 (defvar gnus-prev-page-map
7203 (let ((map (make-sparse-keymap)))
7204 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7205 (define-key map "\r" 'gnus-button-prev-page)
7208 (defvar gnus-next-page-map
7209 (let ((map (make-sparse-keymap)))
7210 (unless (>= emacs-major-version 21)
7211 ;; XEmacs doesn't care.
7212 (set-keymap-parent map gnus-article-mode-map))
7213 (define-key map gnus-mouse-2 'gnus-button-next-page)
7214 (define-key map "\r" 'gnus-button-next-page)
7217 (defun gnus-insert-prev-page-button ()
7219 (inhibit-read-only t))
7221 gnus-prev-page-line-format nil
7222 `(keymap ,gnus-prev-page-map
7224 gnus-callback gnus-article-button-prev-page
7225 article-type annotation))
7226 (widget-convert-button
7228 ;; Exclude a newline.
7231 :action 'gnus-button-prev-page
7232 :button-keymap gnus-prev-page-map)))
7234 (defun gnus-button-next-page (&optional args more-args)
7235 "Go to the next page."
7237 (let ((win (selected-window)))
7238 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7239 (gnus-article-next-page)
7240 (select-window win)))
7242 (defun gnus-button-prev-page (&optional args more-args)
7243 "Go to the prev page."
7245 (let ((win (selected-window)))
7246 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7247 (gnus-article-prev-page)
7248 (select-window win)))
7250 (defun gnus-insert-next-page-button ()
7252 (inhibit-read-only t))
7253 (gnus-eval-format gnus-next-page-line-format nil
7254 `(keymap ,gnus-next-page-map
7256 gnus-callback gnus-article-button-next-page
7257 article-type annotation))
7258 (widget-convert-button
7260 ;; Exclude a newline.
7263 :action 'gnus-button-next-page
7264 :button-keymap gnus-next-page-map)))
7266 (defun gnus-article-button-next-page (arg)
7267 "Go to the next page."
7269 (let ((win (selected-window)))
7270 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7271 (gnus-article-next-page)
7272 (select-window win)))
7274 (defun gnus-article-button-prev-page (arg)
7275 "Go to the prev page."
7277 (let ((win (selected-window)))
7278 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7279 (gnus-article-prev-page)
7280 (select-window win)))
7282 (defvar gnus-decode-header-methods
7283 '(mail-decode-encoded-word-region)
7284 "List of methods used to decode headers.
7286 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7287 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7288 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7289 whose names match REGEXP.
7292 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7293 mail-decode-encoded-word-region
7294 (\"chinese\" . rfc1843-decode-region))
7297 (defvar gnus-decode-header-methods-cache nil)
7299 (defun gnus-multi-decode-header (start end)
7300 "Apply the functions from `gnus-encoded-word-methods' that match."
7301 (unless (and gnus-decode-header-methods-cache
7302 (eq gnus-newsgroup-name
7303 (car gnus-decode-header-methods-cache)))
7304 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7307 (nconc gnus-decode-header-methods-cache (list x))
7308 (if (and gnus-newsgroup-name
7309 (string-match (car x) gnus-newsgroup-name))
7310 (nconc gnus-decode-header-methods-cache
7312 gnus-decode-header-methods))
7313 (let ((xlist gnus-decode-header-methods-cache))
7316 (narrow-to-region start end)
7318 (funcall (pop xlist) (point-min) (point-max))))))
7321 ;;; Treatment top-level handling.
7324 (defun gnus-treat-article (condition &optional part-number total-parts type)
7325 (let ((length (- (point-max) (point-min)))
7326 (alist gnus-treatment-function-alist)
7327 (article-goto-body-goes-to-point-min-p t)
7331 (let ((list gnus-article-treat-types))
7333 (when (string-match (pop list) type)
7334 (throw 'found t)))))))
7335 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7337 (gnus-run-hooks 'gnus-part-display-hook)
7338 (dolist (elem alist)
7341 (when (gnus-buffer-live-p gnus-summary-buffer)
7342 (set-buffer gnus-summary-buffer))
7343 (symbol-value (car elem))))
7344 (when (and (or (consp val)
7346 (gnus-treat-predicate val)
7347 (or (not (get (car elem) 'highlight))
7350 (funcall (cadr elem)))))))
7352 ;; Dynamic variables.
7354 (defvar part-number)
7355 (defvar total-parts)
7360 (defun gnus-treat-predicate (val)
7367 (stringp (car val)))
7368 (apply 'gnus-or (mapcar `(lambda (s)
7369 (string-match s ,(or gnus-newsgroup-name "")))
7372 (let ((pred (pop val)))
7375 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7377 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7379 (not (gnus-treat-predicate (car val))))
7381 (equal (car val) type))
7383 (error "%S is not a valid predicate" pred)))))
7391 (eq part-number total-parts))
7395 (error "%S is not a valid value" val))))
7397 (defun gnus-article-encrypt-body (protocol &optional n)
7398 "Encrypt the article body."
7401 (or gnus-article-encrypt-protocol
7402 (completing-read "Encrypt protocol: "
7403 gnus-article-encrypt-protocol-alist
7405 current-prefix-arg))
7406 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7408 (error "Can't find the encrypt protocol %s" protocol))
7409 (if (member gnus-newsgroup-name '("nndraft:delayed"
7412 (error "Can't encrypt the article in group %s"
7413 gnus-newsgroup-name))
7414 (gnus-summary-iterate n
7416 (set-buffer gnus-summary-buffer)
7417 (let ((mail-parse-charset gnus-newsgroup-charset)
7418 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7419 (summary-buffer gnus-summary-buffer)
7421 (gnus-set-global-variables)
7422 (when (gnus-group-read-only-p)
7423 (error "The current newsgroup does not support article encrypt"))
7424 (gnus-summary-show-article t)
7426 (or (mail-header-references gnus-current-headers) ""))
7427 (set-buffer gnus-article-buffer)
7428 (let* ((inhibit-read-only t)
7430 (mapcar (lambda (field)
7431 (and (save-restriction
7432 (message-narrow-to-head)
7433 (goto-char (point-min))
7434 (search-forward field nil t))
7436 (message-narrow-to-field)
7438 (delete-region (point-min) (point-max))
7440 '("Content-Type:" "Content-Transfer-Encoding:"
7441 "Content-Disposition:"))))
7442 (message-narrow-to-head)
7443 (message-remove-header "MIME-Version")
7444 (goto-char (point-max))
7445 (setq point (point))
7446 (insert (apply 'concat headers))
7448 (narrow-to-region point (point-max))
7449 (let ((message-options message-options))
7450 (message-options-set 'message-sender user-mail-address)
7451 (message-options-set 'message-recipients user-mail-address)
7452 (message-options-set 'message-sign-encrypt 'not)
7454 (goto-char (point-min))
7455 (insert "MIME-Version: 1.0\n")
7457 (gnus-summary-edit-article-done
7458 references nil summary-buffer t))
7459 (when gnus-keep-backlog
7460 (gnus-backlog-remove-article
7461 (car gnus-article-current) (cdr gnus-article-current)))
7463 (when (get-buffer gnus-original-article-buffer)
7464 (set-buffer gnus-original-article-buffer)
7465 (setq gnus-original-article nil)))
7466 (when gnus-use-cache
7467 (gnus-cache-update-article
7468 (car gnus-article-current) (cdr gnus-article-current))))))))
7470 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7471 "The following specs can be used:
7472 %t The security MIME type
7475 %D Details if button is pressed")
7477 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7478 "The following specs can be used:
7479 %t The security MIME type
7482 %D Details if button is pressed")
7484 (defvar gnus-mime-security-button-line-format-alist
7485 '((?t gnus-tmp-type ?s)
7486 (?i gnus-tmp-info ?s)
7487 (?d gnus-tmp-details ?s)
7488 (?D gnus-tmp-pressed-details ?s)))
7490 (defvar gnus-mime-security-button-commands
7491 '((gnus-article-press-button "\r" "Show Detail")
7495 (gnus-mime-security-save-part "o" "Save...")
7504 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7507 (defvar gnus-mime-security-button-map
7508 (let ((map (make-sparse-keymap)))
7509 (define-key map gnus-mouse-2 'gnus-article-push-button)
7510 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7511 (dolist (c gnus-mime-security-button-commands)
7512 (define-key map (cadr c) (car c)))
7516 gnus-mime-security-button-menu gnus-mime-security-button-map
7517 "Security button menu."
7521 (unless (eq (car c) 'undefined)
7522 (vector (caddr c) (car c) :enable t)))
7523 gnus-mime-security-button-commands))))
7525 (defun gnus-mime-security-button-menu (event prefix)
7526 "Construct a context-sensitive menu of security commands."
7527 (interactive "e\nP")
7528 (save-window-excursion
7529 (let ((pos (event-start event)))
7530 (select-window (posn-window pos))
7531 (goto-char (posn-point pos))
7532 (gnus-article-check-buffer)
7533 (popup-menu gnus-mime-security-button-menu nil prefix))))
7535 (defvar gnus-mime-security-details-buffer nil)
7537 (defvar gnus-mime-security-button-pressed nil)
7539 (defvar gnus-mime-security-show-details-inline t
7540 "If non-nil, show details in the article buffer.")
7542 (defun gnus-mime-security-verify-or-decrypt (handle)
7543 (mm-remove-parts (cdr handle))
7544 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7545 point (inhibit-read-only t))
7547 (goto-char (car region)))
7549 (narrow-to-region (point) (point))
7550 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7551 (let* ((mm-verify-option 'known)
7552 (mm-decrypt-option 'known)
7553 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7554 (unless (eq nparts (cdr handle))
7555 (mm-destroy-parts (cdr handle))
7556 (setcdr handle nparts))))
7557 (setq point (point))
7558 (gnus-mime-display-security handle)
7559 (goto-char (point-max)))
7561 (delete-region (point) (cdr region))
7562 (set-marker (car region) nil)
7563 (set-marker (cdr region) nil))
7566 (defun gnus-mime-security-show-details (handle)
7567 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7569 (gnus-message 5 "No details.")
7570 (if gnus-mime-security-show-details-inline
7571 (let ((gnus-mime-security-button-pressed
7572 (not (get-text-property (point) 'gnus-mime-details)))
7573 (gnus-mime-security-button-line-format
7574 (get-text-property (point) 'gnus-line-format))
7575 (inhibit-read-only t))
7577 (while (eq (get-text-property (point) 'gnus-line-format)
7578 gnus-mime-security-button-line-format)
7582 (narrow-to-region (point) (point))
7583 (gnus-insert-mime-security-button handle))
7584 (delete-region (point)
7585 (or (text-property-not-all
7588 gnus-mime-security-button-line-format)
7591 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7592 (with-current-buffer gnus-mime-security-details-buffer
7595 (setq gnus-mime-security-details-buffer
7596 (gnus-get-buffer-create "*MIME Security Details*")))
7597 (with-current-buffer gnus-mime-security-details-buffer
7599 (goto-char (point-min)))
7600 (pop-to-buffer gnus-mime-security-details-buffer)))))
7602 (defun gnus-mime-security-press-button (handle)
7604 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7605 (gnus-mime-security-show-details handle)
7606 (gnus-mime-security-verify-or-decrypt handle))))
7608 (defun gnus-insert-mime-security-button (handle &optional displayed)
7609 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7612 (or (nth 2 (assoc protocol mm-verify-function-alist))
7613 (nth 2 (assoc protocol mm-decrypt-function-alist))
7615 (if (equal (car handle) "multipart/signed")
7616 " Signed" " Encrypted")
7619 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7622 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7623 gnus-tmp-pressed-details
7625 (setq gnus-tmp-details
7626 (if gnus-tmp-details
7627 (concat "\n" gnus-tmp-details)
7629 (setq gnus-tmp-pressed-details
7630 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7635 gnus-mime-security-button-line-format
7636 gnus-mime-security-button-line-format-alist
7637 `(keymap ,gnus-mime-security-button-map
7638 gnus-callback gnus-mime-security-press-button
7639 gnus-line-format ,gnus-mime-security-button-line-format
7640 gnus-mime-details ,gnus-mime-security-button-pressed
7641 article-type annotation
7644 ;; Exclude a newline.
7647 (widget-convert-button
7650 :action 'gnus-widget-press-button
7651 :button-keymap gnus-mime-security-button-map
7653 (lambda (widget/window &optional overlay pos)
7654 ;; Needed to properly clear the message due to a bug in
7655 ;; wid-edit (XEmacs only).
7656 (when (boundp 'help-echo-owns-message)
7657 (setq help-echo-owns-message t))
7659 "%S: show detail; %S: more options"
7660 (aref gnus-mouse-2 0)
7661 (aref gnus-down-mouse-3 0))))))
7663 (defun gnus-mime-display-security (handle)
7665 (narrow-to-region (point) (point))
7666 (unless (gnus-unbuttonized-mime-type-p (car handle))
7667 (gnus-insert-mime-security-button handle))
7668 (gnus-mime-display-part (cadr handle))
7671 (unless (gnus-unbuttonized-mime-type-p (car handle))
7672 (let ((gnus-mime-security-button-line-format
7673 gnus-mime-security-button-end-line-format))
7674 (gnus-insert-mime-security-button handle)))
7675 (mm-set-handle-multipart-parameter
7677 (cons (set-marker (make-marker) (point-min))
7678 (set-marker (make-marker) (point-max))))))
7680 (defun gnus-mime-security-run-function (function)
7681 "Run FUNCTION with the security part under point."
7682 (gnus-article-check-buffer)
7683 (let ((data (get-text-property (point) 'gnus-data))
7685 (when (and (stringp (car-safe data))
7686 (setq buffer (mm-handle-multipart-original-buffer data))
7687 (setq handle (cadr data)))
7688 (if (bufferp (mm-handle-buffer handle))
7690 (setq handle (cons buffer (copy-sequence (cdr handle))))
7691 (mm-handle-set-undisplayer handle nil))
7692 (setq handle (mm-make-handle
7694 (mm-handle-multipart-ctl-parameter handle 'protocol)
7695 nil nil nil nil nil nil)))
7696 (funcall function handle))))
7698 (defun gnus-mime-security-save-part ()
7699 "Save the security part under point."
7701 (gnus-mime-security-run-function 'mm-save-part))
7703 (defun gnus-mime-security-pipe-part ()
7704 "Pipe the security part under point to a process."
7706 (gnus-mime-security-run-function 'mm-pipe-part))
7712 (run-hooks 'gnus-art-load-hook)
7714 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7715 ;;; gnus-art.el ends here