1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 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 3, 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))
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
52 (autoload 'mm-extern-cache-contents "mm-extern")
54 (defgroup gnus-article nil
56 :link '(custom-manual "(gnus)Article Buffer")
59 (defgroup gnus-article-treat nil
60 "Treating article parts."
61 :link '(custom-manual "(gnus)Article Hiding")
64 (defgroup gnus-article-hiding nil
65 "Hiding article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-highlight nil
70 "Article highlighting."
71 :link '(custom-manual "(gnus)Article Highlighting")
75 (defgroup gnus-article-signature nil
77 :link '(custom-manual "(gnus)Article Signature")
80 (defgroup gnus-article-headers nil
82 :link '(custom-manual "(gnus)Hiding Headers")
85 (defgroup gnus-article-washing nil
86 "Special commands on articles."
87 :link '(custom-manual "(gnus)Article Washing")
90 (defgroup gnus-article-emphasis nil
91 "Fontisizing articles."
92 :link '(custom-manual "(gnus)Article Fontisizing")
95 (defgroup gnus-article-saving nil
97 :link '(custom-manual "(gnus)Saving Articles")
100 (defgroup gnus-article-mime nil
101 "Worshiping the MIME wonder."
102 :link '(custom-manual "(gnus)Using MIME")
103 :group 'gnus-article)
105 (defgroup gnus-article-buttons nil
106 "Pushable buttons in the article buffer."
107 :link '(custom-manual "(gnus)Article Buttons")
108 :group 'gnus-article)
110 (defgroup gnus-article-various nil
111 "Other article options."
112 :link '(custom-manual "(gnus)Misc Article")
113 :group 'gnus-article)
115 (defcustom gnus-ignored-headers
118 (concat "^" header ":"))
119 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
120 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
121 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
122 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
123 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
124 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
125 "X-Attribution" "X-Originating-IP" "Delivered-To"
126 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
127 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
128 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
129 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
130 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
131 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
132 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
133 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
134 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
135 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
136 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
137 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
138 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
139 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
140 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
141 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
142 "List-[A-Za-z]+" "X-Listprocessor-Version"
143 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
144 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
145 "X-Received" "Content-length" "X-precedence"
146 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
147 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
148 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
149 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
150 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
151 "X-Content-length" "X-Posting-Agent" "Original-Received"
152 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
157 "*All headers that start with this regexp will be hidden.
158 This variable can also be a list of regexps of headers to be ignored.
159 If `gnus-visible-headers' is non-nil, this variable will be ignored."
160 :type '(choice :custom-show nil
163 :group 'gnus-article-hiding)
165 (defcustom gnus-visible-headers
166 "^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:"
167 "*All headers that do not match this regexp will be hidden.
168 This variable can also be a list of regexp of headers to remain visible.
169 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
170 :type '(repeat :value-to-internal (lambda (widget value)
171 (custom-split-regexp-maybe value))
172 :match (lambda (widget value)
174 (widget-editable-list-match widget value)))
176 :group 'gnus-article-hiding)
178 (defcustom gnus-sorted-header-list
179 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
180 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
181 "*This variable is a list of regular expressions.
182 If it is non-nil, headers that match the regular expressions will
183 be placed first in the article buffer in the sequence specified by
185 :type '(repeat regexp)
186 :group 'gnus-article-hiding)
188 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
189 "Headers that are only to be displayed if they have interesting data.
190 Possible values in this list are:
192 'empty Headers with no content.
193 'newsgroups Newsgroup identical to Gnus group.
194 'to-address To identical to To-address.
195 'to-list To identical to To-list.
196 'cc-list CC identical to To-list.
197 'followup-to Followup-to identical to Newsgroups.
198 'reply-to Reply-to identical to From.
199 'date Date less than four days old.
200 'long-to To and/or Cc longer than 1024 characters.
201 'many-to Multiple To and/or Cc."
202 :type '(set (const :tag "Headers with no content." empty)
203 (const :tag "Newsgroups identical to Gnus group." newsgroups)
204 (const :tag "To identical to To-address." to-address)
205 (const :tag "To identical to To-list." to-list)
206 (const :tag "CC identical to To-list." cc-list)
207 (const :tag "Followup-to identical to Newsgroups." followup-to)
208 (const :tag "Reply-to identical to From." reply-to)
209 (const :tag "Date less than four days old." date)
210 (const :tag "To and/or Cc longer than 1024 characters." long-to)
211 (const :tag "Multiple To and/or Cc headers." many-to))
212 :group 'gnus-article-hiding)
214 (defcustom gnus-article-skip-boring nil
215 "Skip over text that is not worth reading.
216 By default, if you set this t, then Gnus will display citations and
217 signatures, but will never scroll down to show you a page consisting
218 only of boring text. Boring text is controlled by
219 `gnus-article-boring-faces'."
222 :group 'gnus-article-hiding)
224 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
225 "Regexp matching signature separator.
226 This can also be a list of regexps. In that case, it will be checked
227 from head to tail looking for a separator. Searches will be done from
228 the end of the buffer."
229 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
231 (repeat :tag "List of regexp" regexp))
232 :group 'gnus-article-signature)
234 (defcustom gnus-signature-limit nil
235 "Provide a limit to what is considered a signature.
236 If it is a number, no signature may not be longer (in characters) than
237 that number. If it is a floating point number, no signature may be
238 longer (in lines) than that number. If it is a function, the function
239 will be called without any parameters, and if it returns nil, there is
240 no signature in the buffer. If it is a string, it will be used as a
241 regexp. If it matches, the text in question is not a signature."
242 :type '(choice (const nil)
246 (regexp :value ".*"))
247 :group 'gnus-article-signature)
249 (defcustom gnus-hidden-properties '(invisible t intangible t)
250 "Property list to use for hiding text."
252 :group 'gnus-article-hiding)
254 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
255 ;; frames in a session.
256 (defcustom gnus-article-x-face-command
257 (if (featurep 'xemacs)
258 (if (or (gnus-image-type-available-p 'xface)
259 (gnus-image-type-available-p 'pbm))
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
262 (if (gnus-image-type-available-p 'pbm)
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
266 "*String or function to be executed to display an X-Face header.
267 If it is a string, the command will be executed in a sub-shell
268 asynchronously. The compressed face will be piped to this command."
269 :type `(choice string
270 (function-item gnus-display-x-face-in-from)
274 :group 'gnus-article-washing)
276 (defcustom gnus-article-x-face-too-ugly nil
277 "Regexp matching posters whose face shouldn't be shown automatically."
278 :type '(choice regexp (const nil))
279 :group 'gnus-article-washing)
281 (defcustom gnus-article-banner-alist nil
282 "Banner alist for stripping.
284 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
286 :type '(repeat (cons symbol regexp))
287 :group 'gnus-article-washing)
289 (gnus-define-group-parameter
292 "Alist of regexps (to match group names) and banner."
293 :variable-group gnus-article-washing
295 '(choice :tag "Banner"
297 (const :tag "Remove signature" signature)
298 (symbol :tag "Item in `gnus-article-banner-alist'" none)
300 (const :tag "None" nil))
302 "If non-nil, specify how to remove `banners' from articles.
304 Symbol `signature' means to remove signatures delimited by
305 `gnus-signature-separator'. Any other symbol is used to look up a
306 regular expression to match the banner in `gnus-article-banner-alist'.
307 A string is used as a regular expression to match the banner
310 (defcustom gnus-article-address-banner-alist nil
311 "Alist of mail addresses and banners.
312 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
313 to match a mail address in the From: header, BANNER is one of a symbol
314 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
315 If ADDRESS matches author's mail address, it will remove things like
316 advertisements. For example:
318 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
322 (regexp :tag "Address")
323 (choice :tag "Banner" :value nil
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))))
329 :group 'gnus-article-washing)
331 (defmacro gnus-emphasis-custom-with-format (&rest body)
333 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
334 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
337 (defun gnus-emphasis-custom-value-to-external (value)
338 (gnus-emphasis-custom-with-format
339 (if (consp (car value))
340 (list (format format (car (car value)) (cdr (car value)))
342 (if (nth 1 value) 2 3)
346 (defun gnus-emphasis-custom-value-to-internal (value)
347 (gnus-emphasis-custom-with-format
348 (let ((regexp (concat "\\`"
349 (format (regexp-quote format)
350 "\\([^()]+\\)" "\\([^()]+\\)")
353 (if (string-match regexp (setq pattern (car value)))
354 (list (cons (match-string 1 pattern) (match-string 2 pattern))
359 (defcustom gnus-emphasis-alist
361 '(("\\*" "\\*" bold nil 2)
364 ("_/" "/_" underline-italic)
365 ("_\\*" "\\*_" underline-bold)
366 ("\\*/" "/\\*" bold-italic)
367 ("_\\*/" "/\\*_" underline-bold-italic))))
369 (gnus-emphasis-custom-with-format
370 (mapcar (lambda (spec)
371 (list (format format (car spec) (cadr spec))
374 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
376 '(;; I've never seen anyone use this strikethru convention whereas I've
377 ;; several times seen it triggered by normal text. --Stef
378 ;; Miles suggests that this form is sometimes used but for italics,
379 ;; so maybe we should map it to `italic'.
380 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
381 ;; 2 3 gnus-emphasis-strikethru)
382 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-underline))))
384 "*Alist that says how to fontify certain phrases.
385 Each item looks like this:
387 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
389 The first element is a regular expression to be matched. The second
390 is a number that says what regular expression grouping used to find
391 the entire emphasized word. The third is a number that says what
392 regexp grouping should be displayed and highlighted. The fourth
393 is the face used for highlighting."
397 :format "%[Customizing Style%]\n%v"
399 (group :tag "Default"
400 :value ("" 0 0 default)
403 (let ((value (widget-get
404 (cadr (widget-get (widget-get widget :parent)
407 (if (not (eq (nth 2 value) 'default))
411 (gnus-emphasis-custom-value-to-external value))))
412 (widget-group-value-create widget))
414 (integer :format "Match group: %v")
415 (integer :format "Emphasize group: %v")
418 :value (("_" . "_") nil default)
420 (regexp :format "Start regexp: %v")
421 (regexp :format "End regexp: %v"))
422 (boolean :format "Show start and end patterns: %[%v%]\n"
423 :on " On " :off " Off ")
425 :get (lambda (symbol)
426 (mapcar 'gnus-emphasis-custom-value-to-internal
427 (default-value symbol)))
428 :set (lambda (symbol value)
429 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
431 :group 'gnus-article-emphasis)
433 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
434 "A regexp to describe whitespace which should not be emphasized.
435 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
436 The former avoids underlining of leading and trailing whitespace,
437 and the latter avoids underlining any whitespace at all."
439 :group 'gnus-article-emphasis
442 (defface gnus-emphasis-bold '((t (:bold t)))
443 "Face used for displaying strong emphasized text (*word*)."
444 :group 'gnus-article-emphasis)
446 (defface gnus-emphasis-italic '((t (:italic t)))
447 "Face used for displaying italic emphasized text (/word/)."
448 :group 'gnus-article-emphasis)
450 (defface gnus-emphasis-underline '((t (:underline t)))
451 "Face used for displaying underlined emphasized text (_word_)."
452 :group 'gnus-article-emphasis)
454 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
455 "Face used for displaying underlined bold emphasized text (_*word*_)."
456 :group 'gnus-article-emphasis)
458 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
459 "Face used for displaying underlined italic emphasized text (_/word/_)."
460 :group 'gnus-article-emphasis)
462 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
463 "Face used for displaying bold italic emphasized text (/*word*/)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-underline-bold-italic
467 '((t (:bold t :italic t :underline t)))
468 "Face used for displaying underlined bold italic emphasized text.
469 Example: (_/*word*/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
473 '((t (:strikethru t)))
474 '((t (:strike-through t))))
475 "Face used for displaying strike-through text (-word-)."
476 :group 'gnus-article-emphasis)
478 (defface gnus-emphasis-highlight-words
479 '((t (:background "black" :foreground "yellow")))
480 "Face used for displaying highlighted words."
481 :group 'gnus-article-emphasis)
483 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
484 "Format for display of Date headers in article bodies.
485 See `format-time-string' for the possible values.
487 The variable can also be function, which should return a complete Date
488 header. The function is called with one argument, the time, which can
489 be fed to `format-time-string'."
490 :type '(choice string symbol)
491 :link '(custom-manual "(gnus)Article Date")
492 :group 'gnus-article-washing)
494 (defcustom gnus-save-all-headers t
495 "*If non-nil, don't remove any headers before saving.
496 This will be overridden by the `:headers' property that the symbol of
497 the saver function, which is specified by `gnus-default-article-saver',
499 :group 'gnus-article-saving
502 (defcustom gnus-prompt-before-saving 'always
503 "*This variable says how much prompting is to be done when saving articles.
504 If it is nil, no prompting will be done, and the articles will be
505 saved to the default files. If this variable is `always', each and
506 every article that is saved will be preceded by a prompt, even when
507 saving large batches of articles. If this variable is neither nil not
508 `always', there the user will be prompted once for a file name for
509 each invocation of the saving commands."
510 :group 'gnus-article-saving
511 :type '(choice (item always)
512 (item :tag "never" nil)
513 (sexp :tag "once" :format "%t\n" :value t)))
515 (defcustom gnus-saved-headers gnus-visible-headers
516 "Headers to keep if `gnus-save-all-headers' is nil.
517 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
518 If that variable is nil, however, all headers that match this regexp
519 will be kept while the rest will be deleted before saving. This and
520 `gnus-save-all-headers' will be overridden by the `:headers' property
521 that the symbol of the saver function, which is specified by
522 `gnus-default-article-saver', might have."
523 :group 'gnus-article-saving
526 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
527 "A function to save articles in your favourite format.
528 The function will be called by way of the `gnus-summary-save-article'
529 command, and friends such as `gnus-summary-save-article-rmail'.
531 Gnus provides the following functions:
533 * gnus-summary-save-in-rmail (Rmail format)
534 * gnus-summary-save-in-mail (Unix mail format)
535 * gnus-summary-save-in-folder (MH folder)
536 * gnus-summary-save-in-file (article format)
537 * gnus-summary-save-body-in-file (article body)
538 * gnus-summary-save-in-vm (use VM's folder format)
539 * gnus-summary-write-to-file (article format -- overwrite)
540 * gnus-summary-write-body-to-file (article body -- overwrite)
542 The symbol of each function may have the following properties:
545 The value non-nil means save decoded articles. This is meaningful
546 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
547 `gnus-summary-write-to-file', and `gnus-summary-write-body-to-file'.
550 The value specifies an alternative function which appends, not
551 overwrites, articles to a file. This implies that when saving many
552 articles at a time, `gnus-prompt-before-saving' is bound to t and all
553 articles are saved in a single file. This is meaningful only with
554 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
557 The value specifies the symbol of a variable of which the value
558 specifies headers to be saved. If it is omitted,
559 `gnus-save-all-headers' and `gnus-saved-headers' control what
560 headers should be saved."
561 :group 'gnus-article-saving
562 :type '(radio (function-item gnus-summary-save-in-rmail)
563 (function-item gnus-summary-save-in-mail)
564 (function-item gnus-summary-save-in-folder)
565 (function-item gnus-summary-save-in-file)
566 (function-item gnus-summary-save-body-in-file)
567 (function-item gnus-summary-save-in-vm)
568 (function-item gnus-summary-write-to-file)
569 (function-item gnus-summary-write-body-to-file)
572 (defcustom gnus-article-save-coding-system
573 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
574 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
575 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
576 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
577 "Coding system used to save decoded articles to a file.
579 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
580 which can safely encode any characters in text. This is used by the
583 * gnus-summary-save-article-file
584 * gnus-summary-save-article-body-file
585 * gnus-summary-write-article-file
586 * gnus-summary-write-article-body-file
588 and the functions to which you may set `gnus-default-article-saver':
590 * gnus-summary-save-in-file
591 * gnus-summary-save-body-in-file
592 * gnus-summary-write-to-file
593 * gnus-summary-write-body-to-file
595 Those commands and functions save just text displayed in the article
596 buffer to a file if the value of this variable is non-nil. Note that
597 buttonized MIME parts will be lost in a saved file in that case.
598 Otherwise, raw articles will be saved."
599 :group 'gnus-article-saving
601 :format "%{%t%}:\n %[Value Menu%] %v"
602 (const :tag "Save raw articles" nil)
605 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
606 '((const :tag "UTF-8" utf-8)
607 (const :tag "iso-2022-7bit" iso-2022-7bit)
608 (const :tag "Emacs internal" emacs-mule)
609 (const :tag "escape-quoted" escape-quoted))))
610 (symbol :tag "Coding system")))
612 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
613 "A function generating a file name to save articles in Rmail format.
614 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
615 :group 'gnus-article-saving
618 (defcustom gnus-mail-save-name 'gnus-plain-save-name
619 "A function generating a file name to save articles in Unix mail format.
620 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
621 :group 'gnus-article-saving
624 (defcustom gnus-folder-save-name 'gnus-folder-save-name
625 "A function generating a file name to save articles in MH folder.
626 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
627 :group 'gnus-article-saving
630 (defcustom gnus-file-save-name 'gnus-numeric-save-name
631 "A function generating a file name to save articles in article format.
632 The function is called with NEWSGROUP, HEADERS, and optional
634 :group 'gnus-article-saving
637 (defcustom gnus-split-methods
638 '((gnus-article-archive-name)
639 (gnus-article-nndoc-name))
640 "*Variable used to suggest where articles are to be saved.
641 For instance, if you would like to save articles related to Gnus in
642 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
643 you could set this variable to something like:
645 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
646 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
648 This variable is an alist where the where the key is the match and the
649 value is a list of possible files to save in if the match is non-nil.
651 If the match is a string, it is used as a regexp match on the
652 article. If the match is a symbol, that symbol will be funcalled
653 from the buffer of the article to be saved with the newsgroup as the
654 parameter. If it is a list, it will be evalled in the same buffer.
656 If this form or function returns a string, this string will be used as
657 a possible file name; and if it returns a non-nil list, that list will
658 be used as possible file names."
659 :group 'gnus-article-saving
660 :type '(repeat (choice (list :value (fun) function)
661 (cons :value ("" "") regexp (repeat string))
664 (defcustom gnus-page-delimiter "^\^L"
665 "*Regexp describing what to use as article page delimiters.
666 The default value is \"^\^L\", which is a form linefeed at the
667 beginning of a line."
669 :group 'gnus-article-various)
671 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
672 "*The format specification for the article mode line.
673 See `gnus-summary-mode-line-format' for a closer description.
675 The following additional specs are available:
677 %w The article washing status.
678 %m The number of MIME parts in the article."
680 :group 'gnus-article-various)
682 (defcustom gnus-article-mode-hook nil
683 "*A hook for Gnus article mode."
685 :group 'gnus-article-various)
687 (when (featurep 'xemacs)
688 ;; Extracted from gnus-xmas-define in order to preserve user settings
689 (when (fboundp 'turn-off-scroll-in-place)
690 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
691 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
692 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
694 (defcustom gnus-article-menu-hook nil
695 "*Hook run after the creation of the article mode menu."
697 :group 'gnus-article-various)
699 (defcustom gnus-article-prepare-hook nil
700 "*A hook called after an article has been prepared in the article buffer."
702 :group 'gnus-article-various)
704 (make-obsolete-variable 'gnus-article-hide-pgp-hook
705 "This variable is obsolete in Gnus 5.10.")
707 (defcustom gnus-article-button-face 'bold
708 "Face used for highlighting buttons in the article buffer.
710 An article button is a piece of text that you can activate by pressing
711 `RET' or `mouse-2' above it."
713 :group 'gnus-article-buttons)
715 (defcustom gnus-article-mouse-face 'highlight
716 "Face used for mouse highlighting in the article buffer.
718 Article buttons will be displayed in this face when the cursor is
721 :group 'gnus-article-buttons)
723 (defcustom gnus-signature-face 'gnus-signature
724 "Face used for highlighting a signature in the article buffer.
725 Obsolete; use the face `gnus-signature' for customizations instead."
727 :group 'gnus-article-highlight
728 :group 'gnus-article-signature)
730 (defface gnus-signature
733 "Face used for highlighting a signature in the article buffer."
734 :group 'gnus-article-highlight
735 :group 'gnus-article-signature)
736 ;; backward-compatibility alias
737 (put 'gnus-signature-face 'face-alias 'gnus-signature)
739 (defface gnus-header-from
742 (:foreground "spring green"))
745 (:foreground "red3"))
748 "Face used for displaying from headers."
749 :group 'gnus-article-headers
750 :group 'gnus-article-highlight)
751 ;; backward-compatibility alias
752 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
754 (defface gnus-header-subject
757 (:foreground "SeaGreen3"))
760 (:foreground "red4"))
762 (:bold t :italic t)))
763 "Face used for displaying subject headers."
764 :group 'gnus-article-headers
765 :group 'gnus-article-highlight)
766 ;; backward-compatibility alias
767 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
769 (defface gnus-header-newsgroups
772 (:foreground "yellow" :italic t))
775 (:foreground "MidnightBlue" :italic t))
778 "Face used for displaying newsgroups headers.
779 In the default setup this face is only used for crossposted
781 :group 'gnus-article-headers
782 :group 'gnus-article-highlight)
783 ;; backward-compatibility alias
784 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
786 (defface gnus-header-name
789 (:foreground "SeaGreen"))
792 (:foreground "maroon"))
795 "Face used for displaying header names."
796 :group 'gnus-article-headers
797 :group 'gnus-article-highlight)
798 ;; backward-compatibility alias
799 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
801 (defface gnus-header-content
804 (:foreground "forest green" :italic t))
807 (:foreground "indianred4" :italic t))
809 (:italic t))) "Face used for displaying header content."
810 :group 'gnus-article-headers
811 :group 'gnus-article-highlight)
812 ;; backward-compatibility alias
813 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
815 (defcustom gnus-header-face-alist
816 '(("From" nil gnus-header-from)
817 ("Subject" nil gnus-header-subject)
818 ("Newsgroups:.*," nil gnus-header-newsgroups)
819 ("" gnus-header-name gnus-header-content))
820 "*Controls highlighting of article headers.
822 An alist of the form (HEADER NAME CONTENT).
824 HEADER is a regular expression which should match the name of a
825 header and NAME and CONTENT are either face names or nil.
827 The name of each header field will be displayed using the face
828 specified by the first element in the list where HEADER matches
829 the header name and NAME is non-nil. Similarly, the content will
830 be displayed by the first non-nil matching CONTENT face."
831 :group 'gnus-article-headers
832 :group 'gnus-article-highlight
833 :type '(repeat (list (regexp :tag "Header")
835 (item :tag "skip" nil)
836 (face :value default))
837 (choice :tag "Content"
838 (item :tag "skip" nil)
839 (face :value default)))))
841 (defcustom gnus-article-decode-hook
842 '(article-decode-charset article-decode-encoded-words
843 article-decode-group-name article-decode-idna-rhs)
844 "*Hook run to decode charsets in articles."
845 :group 'gnus-article-headers
848 (defcustom gnus-display-mime-function 'gnus-display-mime
849 "Function to display MIME articles."
850 :group 'gnus-article-mime
853 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
854 "Function used to decode headers.")
856 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
857 "Function used to decode addresses.")
859 (defvar gnus-article-dumbquotes-map
879 "Table for MS-to-Latin1 translation.")
881 (defcustom gnus-ignored-mime-types nil
882 "List of MIME types that should be ignored by Gnus."
884 :group 'gnus-article-mime
885 :type '(repeat regexp))
887 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
888 "List of MIME types that should not be given buttons when rendered inline.
889 See also `gnus-buttonized-mime-types' which may override this variable.
890 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
892 :group 'gnus-article-mime
893 :type '(repeat regexp))
895 (defcustom gnus-buttonized-mime-types nil
896 "List of MIME types that should be given buttons when rendered inline.
897 If set, this variable overrides `gnus-unbuttonized-mime-types'.
898 To see e.g. security buttons you could set this to
899 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
900 this list to display radio buttons that allow you to choose one of two
901 media types those mails include. See also `mm-discouraged-alternatives'.
902 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
904 :group 'gnus-article-mime
905 :type '(repeat regexp))
907 (defcustom gnus-inhibit-mime-unbuttonizing nil
908 "If non-nil, all MIME parts get buttons.
909 When nil (the default value), then some MIME parts do not get buttons,
910 as described by the variables `gnus-buttonized-mime-types' and
911 `gnus-unbuttonized-mime-types'."
913 :group 'gnus-article-mime
916 (defcustom gnus-body-boundary-delimiter "_"
917 "String used to delimit header and body.
918 This variable is used by `gnus-article-treat-body-boundary' which can
919 be controlled by `gnus-treat-body-boundary'."
921 :group 'gnus-article-various
922 :type '(choice (item :tag "None" :value nil)
925 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
927 "Defines the location of the faces database.
928 For information on obtaining this database of pretty pictures, please
929 see http://www.cs.indiana.edu/picons/ftp/index.html"
931 :type '(repeat directory)
932 :link '(url-link :tag "download"
933 "http://www.cs.indiana.edu/picons/ftp/index.html")
934 :link '(custom-manual "(gnus)Picons")
937 (defun gnus-picons-installed-p ()
938 "Say whether picons are installed on your machine."
939 (let ((installed nil))
940 (dolist (database gnus-picon-databases)
941 (when (file-exists-p database)
945 (defcustom gnus-article-mime-part-function nil
946 "Function called with a MIME handle as the argument.
947 This is meant for people who want to do something automatic based
948 on parts -- for instance, adding Vcard info to a database."
949 :group 'gnus-article-mime
950 :type '(choice (const nil)
953 (defcustom gnus-mime-multipart-functions nil
954 "An alist of MIME types to functions to display them."
956 :group 'gnus-article-mime
959 (defcustom gnus-article-date-lapsed-new-header nil
960 "Whether the X-Sent and Date headers can coexist.
961 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
962 either replace the old \"Date:\" header (if this variable is nil), or
963 be added below it (otherwise)."
965 :group 'gnus-article-headers
968 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
969 "Function called with a MIME handle as the argument.
970 This is meant for people who want to view first matched part.
971 For `undisplayed-alternative' (default), the first undisplayed
972 part or alternative part is used. For `undisplayed', the first
973 undisplayed part is used. For a function, the first part which
974 the function return t is used. For nil, the first part is
977 :group 'gnus-article-mime
979 (item :tag "first" :value nil)
980 (item :tag "undisplayed" :value undisplayed)
981 (item :tag "undisplayed or alternative"
982 :value undisplayed-alternative)
985 (defcustom gnus-mime-action-alist
986 '(("save to file" . gnus-mime-save-part)
987 ("save and strip" . gnus-mime-save-part-and-strip)
988 ("delete part" . gnus-mime-delete-part)
989 ("display as text" . gnus-mime-inline-part)
990 ("view the part" . gnus-mime-view-part)
991 ("pipe to command" . gnus-mime-pipe-part)
992 ("toggle display" . gnus-article-press-button)
993 ("toggle display" . gnus-article-view-part-as-charset)
994 ("view as type" . gnus-mime-view-part-as-type)
995 ("view internally" . gnus-mime-view-part-internally)
996 ("view externally" . gnus-mime-view-part-externally))
997 "An alist of actions that run on the MIME attachment."
998 :group 'gnus-article-mime
999 :type '(repeat (cons (string :tag "name")
1003 ;;; The treatment variables
1006 (defvar gnus-part-display-hook nil
1007 "Hook called on parts that are to receive treatment.")
1009 (defvar gnus-article-treat-custom
1010 '(choice (const :tag "Off" nil)
1012 (const :tag "Header" head)
1013 (const :tag "Last" last)
1014 (integer :tag "Less")
1015 (repeat :tag "Groups" regexp)
1016 (sexp :tag "Predicate")))
1018 (defvar gnus-article-treat-head-custom
1019 '(choice (const :tag "Off" nil)
1020 (const :tag "Header" head)))
1022 (defvar gnus-article-treat-types '("text/plain")
1025 (defvar gnus-inhibit-treatment nil
1026 "Whether to inhibit treatment.")
1028 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1029 "Highlight the signature.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles'."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1035 (put 'gnus-treat-highlight-signature 'highlight t)
1037 (defcustom gnus-treat-buttonize 100000
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles'."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1044 (put 'gnus-treat-buttonize 'highlight t)
1046 (defcustom gnus-treat-buttonize-head 'head
1047 "Add buttons to the head.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-head-custom)
1053 (put 'gnus-treat-buttonize-head 'highlight t)
1055 (defcustom gnus-treat-emphasize
1056 (and (or window-system
1058 (>= (string-to-number emacs-version) 21))
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1066 (put 'gnus-treat-emphasize 'highlight t)
1068 (defcustom gnus-treat-strip-cr nil
1069 "Remove carriage returns.
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-custom)
1077 (defcustom gnus-treat-unsplit-urls nil
1078 "Remove newlines from within URLs.
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-leading-whitespace nil
1087 "Remove leading whitespace in headers.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-custom)
1095 (defcustom gnus-treat-hide-headers 'head
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-head-custom)
1103 (defcustom gnus-treat-hide-boring-headers nil
1104 "Hide boring headers.
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-head-custom)
1111 (defcustom gnus-treat-hide-signature nil
1112 "Hide the signature.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1119 (defcustom gnus-treat-fill-article nil
1121 Valid values are nil, t, `head', `last', an integer or a predicate.
1122 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-hide-citation nil
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom)
1135 (defcustom gnus-treat-hide-citation-maybe nil
1137 Valid values are nil, t, `head', `last', an integer or a predicate.
1138 See Info node `(gnus)Customizing Articles' for details."
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-custom)
1143 (defcustom gnus-treat-strip-list-identifiers 'head
1144 "Strip list identifiers from `gnus-list-identifiers`.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (make-obsolete-variable 'gnus-treat-strip-pgp
1153 "This option is obsolete in Gnus 5.10.")
1155 (defcustom gnus-treat-strip-pem nil
1156 "Strip PEM signatures.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom)
1163 (defcustom gnus-treat-strip-banner t
1164 "Strip banners from articles.
1165 The banner to be stripped is specified in the `banner' group parameter.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom)
1172 (defcustom gnus-treat-highlight-headers 'head
1173 "Highlight the headers.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' for details."
1176 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-head-custom)
1179 (put 'gnus-treat-highlight-headers 'highlight t)
1181 (defcustom gnus-treat-highlight-citation t
1182 "Highlight cited text.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1188 (put 'gnus-treat-highlight-citation 'highlight t)
1190 (defcustom gnus-treat-date-ut nil
1191 "Display the Date in UT (GMT).
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-head-custom)
1198 (defcustom gnus-treat-date-local nil
1199 "Display the Date in the local timezone.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-head-custom)
1206 (defcustom gnus-treat-date-english nil
1207 "Display the Date in a format that can be read aloud in English.
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-head-custom)
1215 (defcustom gnus-treat-date-lapsed nil
1216 "Display the Date header in a way that says how much time has elapsed.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' for details."
1219 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-head-custom)
1223 (defcustom gnus-treat-date-original nil
1224 "Display the date in the original timezone.
1225 Valid values are nil, t, `head', `last', an integer or a predicate.
1226 See Info node `(gnus)Customizing Articles' for details."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-head-custom)
1231 (defcustom gnus-treat-date-iso8601 nil
1232 "Display the date in the ISO8601 format.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' for details."
1236 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-head-custom)
1240 (defcustom gnus-treat-date-user-defined nil
1241 "Display the date in a user-defined format.
1242 The format is defined by the `gnus-article-time-format' variable.
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' for details."
1245 :group 'gnus-article-treat
1246 :link '(custom-manual "(gnus)Customizing Articles")
1247 :type gnus-article-treat-head-custom)
1249 (defcustom gnus-treat-strip-headers-in-body t
1250 "Strip the X-No-Archive header line from the beginning of the body.
1251 Valid values are nil, t, `head', `last', an integer or a predicate.
1252 See Info node `(gnus)Customizing Articles' for details."
1254 :group 'gnus-article-treat
1255 :link '(custom-manual "(gnus)Customizing Articles")
1256 :type gnus-article-treat-custom)
1258 (defcustom gnus-treat-strip-trailing-blank-lines nil
1259 "Strip trailing blank lines.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' for details.
1263 When set to t, it also strips trailing blanks in all MIME parts.
1264 Consider to use `last' instead."
1265 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-custom)
1269 (defcustom gnus-treat-strip-leading-blank-lines nil
1270 "Strip leading blank lines.
1271 Valid values are nil, t, `head', `last', an integer or a predicate.
1272 See Info node `(gnus)Customizing Articles' for details.
1274 When set to t, it also strips trailing blanks in all MIME parts."
1275 :group 'gnus-article-treat
1276 :link '(custom-manual "(gnus)Customizing Articles")
1277 :type gnus-article-treat-custom)
1279 (defcustom gnus-treat-strip-multiple-blank-lines nil
1280 "Strip multiple blank lines.
1281 Valid values are nil, t, `head', `last', an integer or a predicate.
1282 See Info node `(gnus)Customizing Articles' for details."
1283 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :type gnus-article-treat-custom)
1287 (defcustom gnus-treat-unfold-headers 'head
1288 "Unfold folded header lines.
1289 Valid values are nil, t, `head', `last', an integer or a predicate.
1290 See Info node `(gnus)Customizing Articles' for details."
1292 :group 'gnus-article-treat
1293 :link '(custom-manual "(gnus)Customizing Articles")
1294 :type gnus-article-treat-custom)
1296 (defcustom gnus-treat-fold-headers nil
1298 Valid values are nil, t, `head', `last', an integer or a predicate.
1299 See Info node `(gnus)Customizing Articles' for details."
1301 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles")
1303 :type gnus-article-treat-custom)
1305 (defcustom gnus-treat-fold-newsgroups 'head
1306 "Fold the Newsgroups and Followup-To headers.
1307 Valid values are nil, t, `head', `last', an integer or a predicate.
1308 See Info node `(gnus)Customizing Articles' for details."
1310 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-custom)
1314 (defcustom gnus-treat-overstrike t
1315 "Treat overstrike highlighting.
1316 Valid values are nil, t, `head', `last', an integer or a predicate.
1317 See Info node `(gnus)Customizing Articles' for details."
1318 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom)
1321 (put 'gnus-treat-overstrike 'highlight t)
1323 (make-obsolete-variable 'gnus-treat-display-xface
1324 'gnus-treat-display-x-face)
1326 (defcustom gnus-treat-display-x-face
1327 (and (not noninteractive)
1328 (gnus-image-type-available-p 'xbm)
1329 (if (featurep 'xemacs)
1331 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1332 (executable-find "icontopbm")))
1334 "Display X-Face headers.
1335 Valid values are nil and `head'.
1336 See Info node `(gnus)Customizing Articles' and Info node
1337 `(gnus)X-Face' for details."
1338 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :link '(custom-manual "(gnus)X-Face")
1342 :type gnus-article-treat-head-custom
1343 :set (lambda (symbol value)
1346 (cond ((or (boundp symbol) (get symbol 'saved-value))
1348 ((boundp 'gnus-treat-display-xface)
1350 ** gnus-treat-display-xface is an obsolete variable;\
1351 use gnus-treat-display-x-face instead")
1352 (default-value 'gnus-treat-display-xface))
1353 ((get 'gnus-treat-display-xface 'saved-value)
1355 ** gnus-treat-display-xface is an obsolete variable;\
1356 use gnus-treat-display-x-face instead")
1357 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1360 (put 'gnus-treat-display-x-face 'highlight t)
1362 (defcustom gnus-treat-display-face
1363 (and (not noninteractive)
1364 (gnus-image-type-available-p 'png)
1366 "Display Face headers.
1367 Valid values are nil, t, `head', `last', an integer or a predicate.
1368 See Info node `(gnus)Customizing Articles' and Info node
1369 `(gnus)X-Face' for details."
1370 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :link '(custom-manual "(gnus)X-Face")
1374 :type gnus-article-treat-head-custom)
1375 (put 'gnus-treat-display-face 'highlight t)
1377 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1379 Valid values are nil, t, `head', `last', an integer or a predicate.
1380 See Info node `(gnus)Customizing Articles' and Info node
1381 `(gnus)Smileys' for details."
1382 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :link '(custom-manual "(gnus)Smileys")
1386 :type gnus-article-treat-custom)
1387 (put 'gnus-treat-display-smileys 'highlight t)
1389 (defcustom gnus-treat-from-picon
1390 (if (and (gnus-image-type-available-p 'xpm)
1391 (gnus-picons-installed-p))
1393 "Display picons in the From header.
1394 Valid values are nil, t, `head', `last', an integer or a predicate.
1395 See Info node `(gnus)Customizing Articles' and Info node
1396 `(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-from-picon 'highlight t)
1405 (defcustom gnus-treat-mail-picon
1406 (if (and (gnus-image-type-available-p 'xpm)
1407 (gnus-picons-installed-p))
1409 "Display picons in To and Cc headers.
1410 Valid values are nil, t, `head', `last', an integer or a predicate.
1411 See Info node `(gnus)Customizing Articles' and Info node
1412 `(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-mail-picon 'highlight t)
1421 (defcustom gnus-treat-newsgroups-picon
1422 (if (and (gnus-image-type-available-p 'xpm)
1423 (gnus-picons-installed-p))
1425 "Display picons in the Newsgroups and Followup-To headers.
1426 Valid values are nil, t, `head', `last', an integer or a predicate.
1427 See Info node `(gnus)Customizing Articles' and Info node
1428 `(gnus)Picons' for details."
1430 :group 'gnus-article-treat
1432 :link '(custom-manual "(gnus)Customizing Articles")
1433 :link '(custom-manual "(gnus)Picons")
1434 :type gnus-article-treat-head-custom)
1435 (put 'gnus-treat-newsgroups-picon 'highlight t)
1437 (defcustom gnus-treat-body-boundary
1438 (if (or gnus-treat-newsgroups-picon
1439 gnus-treat-mail-picon
1440 gnus-treat-from-picon)
1442 "Draw a boundary at the end of the headers.
1443 Valid values are nil and `head'.
1444 See Info node `(gnus)Customizing Articles' for details."
1446 :group 'gnus-article-treat
1447 :link '(custom-manual "(gnus)Customizing Articles")
1448 :type gnus-article-treat-head-custom)
1450 (defcustom gnus-treat-capitalize-sentences nil
1451 "Capitalize sentence-starting words.
1452 Valid values are nil, t, `head', `last', an integer or a predicate.
1453 See Info node `(gnus)Customizing Articles' for details."
1455 :group 'gnus-article-treat
1456 :link '(custom-manual "(gnus)Customizing Articles")
1457 :type gnus-article-treat-custom)
1459 (defcustom gnus-treat-wash-html nil
1461 Valid values are nil, t, `head', `last', an integer or a predicate.
1462 See Info node `(gnus)Customizing Articles' for details."
1464 :group 'gnus-article-treat
1465 :link '(custom-manual "(gnus)Customizing Articles")
1466 :type gnus-article-treat-custom)
1468 (defcustom gnus-treat-fill-long-lines nil
1470 Valid values are nil, t, `head', `last', an integer or a predicate.
1471 See Info node `(gnus)Customizing Articles' for details."
1472 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles")
1474 :type gnus-article-treat-custom)
1476 (defcustom gnus-treat-play-sounds nil
1478 Valid values are nil, t, `head', `last', an integer or a predicate.
1479 See Info node `(gnus)Customizing Articles' for details."
1481 :group 'gnus-article-treat
1482 :link '(custom-manual "(gnus)Customizing Articles")
1483 :type gnus-article-treat-custom)
1485 (defcustom gnus-treat-translate nil
1486 "Translate articles from one language to another.
1487 Valid values are nil, t, `head', `last', an integer or a predicate.
1488 See Info node `(gnus)Customizing Articles' for details."
1490 :group 'gnus-article-treat
1491 :link '(custom-manual "(gnus)Customizing Articles")
1492 :type gnus-article-treat-custom)
1494 (defcustom gnus-treat-x-pgp-sig nil
1496 To automatically treat X-PGP-Sig, set it to head.
1497 Valid values are nil, t, `head', `last', an integer or a predicate.
1498 See Info node `(gnus)Customizing Articles' for details."
1500 :group 'gnus-article-treat
1501 :group 'mime-security
1502 :link '(custom-manual "(gnus)Customizing Articles")
1503 :type gnus-article-treat-custom)
1505 (defvar gnus-article-encrypt-protocol-alist
1506 '(("PGP" . mml2015-self-encrypt)))
1508 ;; Set to nil if more than one protocol added to
1509 ;; gnus-article-encrypt-protocol-alist.
1510 (defcustom gnus-article-encrypt-protocol "PGP"
1511 "The protocol used for encrypt articles.
1512 It is a string, such as \"PGP\". If nil, ask user."
1515 :group 'mime-security)
1517 (defvar gnus-article-wash-function nil
1518 "Function used for converting HTML into text.")
1520 ;; XEmacs change: Don't calculate a default value
1521 (defcustom gnus-use-idna nil
1522 "Whether IDNA decoding of headers is used when viewing messages.
1523 This requires GNU Libidn, and by default only enabled if it is found."
1525 :group 'gnus-article-headers
1528 (defcustom gnus-article-over-scroll nil
1529 "If non-nil, allow scrolling the article buffer even when there no more text."
1531 :group 'gnus-article
1534 ;;; Internal variables
1536 (defvar gnus-english-month-names
1537 '("January" "February" "March" "April" "May" "June" "July" "August"
1538 "September" "October" "November" "December"))
1540 (defvar article-goto-body-goes-to-point-min-p nil)
1541 (defvar gnus-article-wash-types nil)
1542 (defvar gnus-article-emphasis-alist nil)
1543 (defvar gnus-article-image-alist nil)
1545 (defvar gnus-article-mime-handle-alist-1 nil)
1546 (defvar gnus-treatment-function-alist
1547 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1548 (gnus-treat-strip-banner gnus-article-strip-banner)
1549 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1550 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1551 (gnus-treat-buttonize gnus-article-add-buttons)
1552 (gnus-treat-fill-article gnus-article-fill-cited-article)
1553 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1554 (gnus-treat-strip-cr gnus-article-remove-cr)
1555 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1556 (gnus-treat-date-ut gnus-article-date-ut)
1557 (gnus-treat-date-local gnus-article-date-local)
1558 (gnus-treat-date-english gnus-article-date-english)
1559 (gnus-treat-date-original gnus-article-date-original)
1560 (gnus-treat-date-user-defined gnus-article-date-user)
1561 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1562 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1563 (gnus-treat-display-x-face gnus-article-display-x-face)
1564 (gnus-treat-display-face gnus-article-display-face)
1565 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1566 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1567 (gnus-treat-hide-signature gnus-article-hide-signature)
1568 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1569 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1570 (gnus-treat-strip-pem gnus-article-hide-pem)
1571 (gnus-treat-from-picon gnus-treat-from-picon)
1572 (gnus-treat-mail-picon gnus-treat-mail-picon)
1573 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1574 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1575 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1576 (gnus-treat-strip-trailing-blank-lines
1577 gnus-article-remove-trailing-blank-lines)
1578 (gnus-treat-strip-leading-blank-lines
1579 gnus-article-strip-leading-blank-lines)
1580 (gnus-treat-strip-multiple-blank-lines
1581 gnus-article-strip-multiple-blank-lines)
1582 (gnus-treat-overstrike gnus-article-treat-overstrike)
1583 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1584 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1585 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1586 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1587 (gnus-treat-display-smileys gnus-treat-smiley)
1588 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1589 (gnus-treat-wash-html gnus-article-wash-html)
1590 (gnus-treat-emphasize gnus-article-emphasize)
1591 (gnus-treat-hide-citation gnus-article-hide-citation)
1592 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1593 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1594 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1595 (gnus-treat-play-sounds gnus-earcon-display)))
1597 (defvar gnus-article-mime-handle-alist nil)
1598 (defvar article-lapsed-timer nil)
1599 (defvar gnus-article-current-summary nil)
1601 (defvar gnus-article-mode-syntax-table
1602 (let ((table (copy-syntax-table text-mode-syntax-table)))
1603 ;; This causes the citation match run O(2^n).
1604 ;; (modify-syntax-entry ?- "w" table)
1605 (modify-syntax-entry ?> ")<" table)
1606 (modify-syntax-entry ?< "(>" table)
1607 ;; make M-. in article buffers work for `foo' strings
1608 (modify-syntax-entry ?' " " table)
1609 (modify-syntax-entry ?` " " table)
1611 "Syntax table used in article mode buffers.
1612 Initialized from `text-mode-syntax-table.")
1614 (defvar gnus-save-article-buffer nil)
1616 (defvar gnus-article-mode-line-format-alist
1617 (nconc '((?w (gnus-article-wash-status) ?s)
1618 (?m (gnus-article-mime-part-status) ?s))
1619 gnus-summary-mode-line-format-alist))
1621 (defvar gnus-number-of-articles-to-be-saved nil)
1623 (defvar gnus-inhibit-hiding nil)
1625 (defvar gnus-article-edit-mode nil)
1627 ;;; Macros for dealing with the article buffer.
1629 (defmacro gnus-with-article-headers (&rest forms)
1631 (set-buffer gnus-article-buffer)
1633 (let ((inhibit-read-only t)
1634 (inhibit-point-motion-hooks t)
1635 (case-fold-search t))
1636 (article-narrow-to-head)
1639 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1640 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1642 (defmacro gnus-with-article-buffer (&rest forms)
1644 (set-buffer gnus-article-buffer)
1645 (let ((inhibit-read-only t))
1648 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1649 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1651 (defun gnus-article-goto-header (header)
1652 "Go to HEADER, which is a regular expression."
1653 (re-search-forward (concat "^\\(" header "\\):") nil t))
1655 (defsubst gnus-article-hide-text (b e props)
1656 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1657 (gnus-add-text-properties-when 'article-type nil b e props)
1658 (when (memq 'intangible props)
1660 (max (1- b) (point-min))
1661 b 'intangible (cddr (memq 'intangible props)))))
1663 (defsubst gnus-article-unhide-text (b e)
1664 "Remove hidden text properties from region between B and E."
1665 (remove-text-properties b e gnus-hidden-properties)
1666 (when (memq 'intangible gnus-hidden-properties)
1667 (put-text-property (max (1- b) (point-min))
1668 b 'intangible nil)))
1670 (defun gnus-article-hide-text-type (b e type)
1671 "Hide text of TYPE between B and E."
1672 (gnus-add-wash-type type)
1673 (gnus-article-hide-text
1674 b e (cons 'article-type (cons type gnus-hidden-properties))))
1676 (defun gnus-article-unhide-text-type (b e type)
1677 "Unhide text of TYPE between B and E."
1678 (gnus-delete-wash-type type)
1679 (remove-text-properties
1680 b e (cons 'article-type (cons type gnus-hidden-properties)))
1681 (when (memq 'intangible gnus-hidden-properties)
1682 (put-text-property (max (1- b) (point-min))
1683 b 'intangible nil)))
1685 (defun gnus-article-hide-text-of-type (type)
1686 "Hide text of TYPE in the current buffer."
1688 (let ((b (point-min))
1690 (while (setq b (text-property-any b e 'article-type type))
1691 (add-text-properties b (incf b) gnus-hidden-properties)))))
1693 (defun gnus-article-delete-text-of-type (type)
1694 "Delete text of TYPE in the current buffer."
1696 (let ((b (point-min)))
1697 (if (eq type 'multipart)
1698 ;; Remove MIME buttons associated with multipart/alternative parts.
1701 (while (if (get-text-property (point) 'gnus-part)
1703 (when (setq b (next-single-property-change (point)
1708 (skip-chars-forward "\n")
1709 (when (eq (get-text-property b 'article-type) 'multipart)
1710 (delete-region b (point)))))
1711 (while (setq b (text-property-any b (point-max) 'article-type type))
1713 b (or (text-property-not-all b (point-max) 'article-type type)
1716 (defun gnus-article-delete-invisible-text ()
1717 "Delete all invisible text in the current buffer."
1719 (let ((b (point-min)))
1720 (while (setq b (text-property-any b (point-max) 'invisible t))
1722 b (or (text-property-not-all b (point-max) 'invisible t)
1725 (defun gnus-article-text-type-exists-p (type)
1726 "Say whether any text of type TYPE exists in the buffer."
1727 (text-property-any (point-min) (point-max) 'article-type type))
1729 (defsubst gnus-article-header-rank ()
1730 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1731 (let ((list gnus-sorted-header-list)
1734 (if (looking-at (car list))
1736 (setq list (cdr list))
1740 (defun article-hide-headers (&optional arg delete)
1741 "Hide unwanted headers and possibly sort them as well."
1743 ;; This function might be inhibited.
1744 (unless gnus-inhibit-hiding
1745 (let ((inhibit-read-only t)
1746 (case-fold-search t)
1747 (max (1+ (length gnus-sorted-header-list)))
1748 (inhibit-point-motion-hooks t)
1749 (cur (current-buffer))
1750 ignored visible beg)
1752 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1753 ;; group parameters, so we should go to the summary buffer.
1756 (progn (set-buffer gnus-summary-buffer) t)
1758 (setq ignored (when (not gnus-visible-headers)
1759 (cond ((stringp gnus-ignored-headers)
1760 gnus-ignored-headers)
1761 ((listp gnus-ignored-headers)
1762 (mapconcat 'identity
1763 gnus-ignored-headers
1765 visible (cond ((stringp gnus-visible-headers)
1766 gnus-visible-headers)
1767 ((and gnus-visible-headers
1768 (listp gnus-visible-headers))
1769 (mapconcat 'identity
1770 gnus-visible-headers
1774 ;; First we narrow to just the headers.
1775 (article-narrow-to-head)
1776 ;; Hide any "From " lines at the beginning of (mail) articles.
1777 (while (looking-at "From ")
1780 (delete-region (point-min) (point)))
1781 ;; Then treat the rest of the header lines.
1782 ;; Then we use the two regular expressions
1783 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1784 ;; select which header lines is to remain visible in the
1786 (while (re-search-forward "^[^ \t:]*:" nil t)
1788 ;; Mark the rank of the header.
1790 (point) (1+ (point)) 'message-rank
1791 (if (or (and visible (looking-at visible))
1793 (not (looking-at ignored))))
1794 (gnus-article-header-rank)
1797 (message-sort-headers-1)
1798 (when (setq beg (text-property-any
1799 (point-min) (point-max) 'message-rank (+ 2 max)))
1800 ;; We delete the unwanted headers.
1801 (gnus-add-wash-type 'headers)
1802 (add-text-properties (point-min) (+ 5 (point-min))
1803 '(article-type headers dummy-invisible t))
1804 (delete-region beg (point-max))))))))
1806 (defun article-hide-boring-headers (&optional arg)
1807 "Toggle hiding of headers that aren't very interesting.
1808 If given a negative prefix, always show; if given a positive prefix,
1810 (interactive (gnus-article-hidden-arg))
1811 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1812 (not gnus-show-all-headers))
1815 (let ((inhibit-read-only t)
1816 (list gnus-boring-article-headers)
1817 (inhibit-point-motion-hooks t)
1819 (article-narrow-to-head)
1821 (setq elem (pop list))
1822 (goto-char (point-min))
1824 ;; Hide empty headers.
1826 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1828 (gnus-article-hide-text-type
1832 (if (re-search-forward "^[^ \t]" nil t)
1836 ;; Hide boring Newsgroups header.
1837 ((eq elem 'newsgroups)
1838 (when (gnus-string-equal
1839 (gnus-fetch-field "newsgroups")
1840 (gnus-group-real-name
1841 (if (boundp 'gnus-newsgroup-name)
1844 (gnus-article-hide-header "newsgroups")))
1845 ((eq elem 'to-address)
1846 (let ((to (message-fetch-field "to"))
1848 (gnus-parameter-to-address
1849 (if (boundp 'gnus-newsgroup-name)
1850 gnus-newsgroup-name ""))))
1851 (when (and to to-address
1854 ;; only one address in To
1855 (nth 1 (mail-extract-address-components to))
1857 (gnus-article-hide-header "to"))))
1859 (let ((to (message-fetch-field "to"))
1861 (gnus-parameter-to-list
1862 (if (boundp 'gnus-newsgroup-name)
1863 gnus-newsgroup-name ""))))
1864 (when (and to to-list
1867 ;; only one address in To
1868 (nth 1 (mail-extract-address-components to))
1870 (gnus-article-hide-header "to"))))
1872 (let ((cc (message-fetch-field "cc"))
1874 (gnus-parameter-to-list
1875 (if (boundp 'gnus-newsgroup-name)
1876 gnus-newsgroup-name ""))))
1877 (when (and cc to-list
1880 ;; only one address in CC
1881 (nth 1 (mail-extract-address-components cc))
1883 (gnus-article-hide-header "cc"))))
1884 ((eq elem 'followup-to)
1885 (when (gnus-string-equal
1886 (message-fetch-field "followup-to")
1887 (message-fetch-field "newsgroups"))
1888 (gnus-article-hide-header "followup-to")))
1889 ((eq elem 'reply-to)
1890 (if (gnus-group-find-parameter
1891 gnus-newsgroup-name 'broken-reply-to)
1892 (gnus-article-hide-header "reply-to")
1893 (let ((from (message-fetch-field "from"))
1894 (reply-to (message-fetch-field "reply-to")))
1901 (lambda (x) (downcase (cadr x)))
1902 (mail-extract-address-components from t))
1905 (lambda (x) (downcase (cadr x)))
1906 (mail-extract-address-components reply-to t))
1908 (gnus-article-hide-header "reply-to")))))
1910 (let ((date (with-current-buffer gnus-original-article-buffer
1911 ;; If date in `gnus-article-buffer' is localized
1912 ;; (`gnus-treat-date-user-defined'),
1913 ;; `days-between' might fail.
1914 (message-fetch-field "date"))))
1916 (< (days-between (current-time-string) date)
1918 (gnus-article-hide-header "date"))))
1920 (let ((to (message-fetch-field "to"))
1921 (cc (message-fetch-field "cc")))
1922 (when (> (length to) 1024)
1923 (gnus-article-hide-header "to"))
1924 (when (> (length cc) 1024)
1925 (gnus-article-hide-header "cc"))))
1929 (goto-char (point-min))
1930 (while (re-search-forward "^to:" nil t)
1931 (setq to-count (1+ to-count)))
1932 (when (> to-count 1)
1933 (while (> to-count 0)
1934 (goto-char (point-min))
1936 (re-search-forward "^to:" nil nil to-count)
1938 (narrow-to-region (point) (point-max))
1939 (gnus-article-hide-header "to"))
1940 (setq to-count (1- to-count))))
1941 (goto-char (point-min))
1942 (while (re-search-forward "^cc:" nil t)
1943 (setq cc-count (1+ cc-count)))
1944 (when (> cc-count 1)
1945 (while (> cc-count 0)
1946 (goto-char (point-min))
1948 (re-search-forward "^cc:" nil nil cc-count)
1950 (narrow-to-region (point) (point-max))
1951 (gnus-article-hide-header "cc"))
1952 (setq cc-count (1- cc-count)))))))))))))
1954 (defun gnus-article-hide-header (header)
1956 (goto-char (point-min))
1957 (when (re-search-forward (concat "^" header ":") nil t)
1958 (gnus-article-hide-text-type
1962 (if (re-search-forward "^[^ \t]" nil t)
1967 (defvar gnus-article-normalized-header-length 40
1968 "Length of normalized headers.")
1970 (defun article-normalize-headers ()
1971 "Make all header lines 40 characters long."
1973 (let ((inhibit-read-only t)
1977 (article-narrow-to-head)
1980 ((< (setq column (- (gnus-point-at-eol) (point)))
1981 gnus-article-normalized-header-length)
1983 (insert (make-string
1984 (- gnus-article-normalized-header-length column)
1986 ((> column gnus-article-normalized-header-length)
1987 (gnus-put-text-property
1989 (forward-char gnus-article-normalized-header-length)
1996 (forward-line 1))))))
1998 (defun article-treat-dumbquotes ()
1999 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2000 Note that this function guesses whether a character is a sm*rtq**t* or
2001 not, so it should only be used interactively.
2003 Sm*rtq**t*s are M****s***'s unilateral extension to the
2004 iso-8859-1 character map in an attempt to provide more quoting
2005 characters. If you see something like \\222 or \\264 where
2006 you're expecting some kind of apostrophe or quotation mark, then
2009 (article-translate-strings gnus-article-dumbquotes-map))
2011 (defun article-translate-characters (from to)
2012 "Translate all characters in the body of the article according to FROM and TO.
2013 FROM is a string of characters to translate from; to is a string of
2014 characters to translate to."
2016 (when (article-goto-body)
2017 (let ((inhibit-read-only t)
2018 (x (make-string 225 ?x))
2020 (while (< (incf i) (length x))
2023 (while (< i (length from))
2024 (aset x (aref from i) (aref to i))
2026 (translate-region (point) (point-max) x)))))
2028 (defun article-translate-strings (map)
2029 "Translate all string in the body of the article according to MAP.
2030 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2032 (when (article-goto-body)
2033 (let ((inhibit-read-only t)
2035 (while (setq elem (pop map))
2037 (while (search-forward (car elem) nil t)
2038 (replace-match (cadr elem)))))))))
2040 (defun article-treat-overstrike ()
2041 "Translate overstrikes into bold text."
2044 (when (article-goto-body)
2045 (let ((inhibit-read-only t))
2046 (while (search-forward "\b" nil t)
2047 (let ((next (char-after))
2048 (previous (char-after (- (point) 2))))
2049 ;; We do the boldification/underlining by hiding the
2050 ;; overstrikes and putting the proper text property
2054 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2055 (put-text-property (point) (1+ (point)) 'face 'bold))
2057 (gnus-article-hide-text-type
2058 (1- (point)) (1+ (point)) 'overstrike)
2060 (- (point) 2) (1- (point)) 'face 'underline))
2062 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2064 (point) (1+ (point)) 'face 'underline)))))))))
2066 (defun gnus-article-treat-unfold-headers ()
2067 "Unfold folded message headers.
2068 Only the headers that fit into the current window width will be
2071 (gnus-with-article-headers
2075 (mail-header-narrow-to-field)
2076 (let ((header (buffer-string)))
2079 (goto-char (point-min))
2080 (while (re-search-forward "\n[\t ]" nil t)
2081 (replace-match " " t t)))
2082 (setq length (- (point-max) (point-min) 1)))
2083 (when (< length (window-width))
2084 (while (re-search-forward "\n[\t ]" nil t)
2085 (replace-match " " t t)))
2086 (goto-char (point-max)))))))
2088 (defun gnus-article-treat-fold-headers ()
2089 "Fold message headers."
2091 (gnus-with-article-headers
2094 (mail-header-narrow-to-field)
2095 (mail-header-fold-field)
2096 (goto-char (point-max))))))
2098 (defun gnus-treat-smiley ()
2099 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2101 (gnus-with-article-buffer
2102 (if (memq 'smiley gnus-article-wash-types)
2103 (gnus-delete-images 'smiley)
2105 (let ((images (smiley-region (point) (point-max))))
2107 (gnus-add-wash-type 'smiley)
2108 (dolist (image images)
2109 (gnus-add-image 'smiley image)))))))
2111 (defun gnus-article-remove-images ()
2112 "Remove all images from the article buffer."
2114 (gnus-with-article-buffer
2115 (dolist (elem gnus-article-image-alist)
2116 (gnus-delete-images (car elem)))))
2118 (defun gnus-article-treat-fold-newsgroups ()
2119 "Unfold folded message headers.
2120 Only the headers that fit into the current window width will be
2123 (gnus-with-article-headers
2124 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2126 (mail-header-narrow-to-field)
2127 (while (re-search-forward ", *" nil t)
2128 (replace-match ", " t t))
2129 (mail-header-fold-field)
2130 (goto-char (point-max))))))
2132 (defun gnus-article-treat-body-boundary ()
2133 "Place a boundary line at the end of the headers."
2135 (when (and gnus-body-boundary-delimiter
2136 (> (length gnus-body-boundary-delimiter) 0))
2137 (gnus-with-article-headers
2138 (goto-char (point-max))
2139 (let ((start (point)))
2140 (insert "X-Boundary: ")
2141 (gnus-add-text-properties start (point) '(invisible t intangible t))
2143 (while (>= (1- (window-width)) (length str))
2144 (setq str (concat str gnus-body-boundary-delimiter)))
2145 (substring str 0 (1- (window-width))))
2147 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2149 (defun article-fill-long-lines ()
2150 "Fill lines that are wider than the window width."
2153 (let ((inhibit-read-only t)
2154 (width (window-width (get-buffer-window (current-buffer)))))
2157 (let ((adaptive-fill-mode nil)) ;Why? -sm
2160 (when (>= (current-column) (min fill-column width))
2161 (narrow-to-region (min (1+ (point)) (point-max))
2162 (gnus-point-at-bol))
2163 (let ((goback (point-marker)))
2164 (fill-paragraph nil)
2165 (goto-char (marker-position goback)))
2167 (forward-line 1)))))))
2169 (defun article-capitalize-sentences ()
2170 "Capitalize the first word in each sentence."
2173 (let ((inhibit-read-only t)
2174 (paragraph-start "^[\n\^L]"))
2178 (forward-sentence)))))
2180 (defun article-remove-cr ()
2181 "Remove trailing CRs and then translate remaining CRs into LFs."
2184 (let ((inhibit-read-only t))
2185 (goto-char (point-min))
2186 (while (re-search-forward "\r+$" nil t)
2187 (replace-match "" t t))
2188 (goto-char (point-min))
2189 (while (search-forward "\r" nil t)
2190 (replace-match "\n" t t)))))
2192 (defun article-remove-trailing-blank-lines ()
2193 "Remove all trailing blank lines from the article."
2196 (let ((inhibit-read-only t))
2197 (goto-char (point-max))
2201 (while (and (not (bobp))
2202 (looking-at "^[ \t]*$")
2203 (not (gnus-annotation-in-region-p
2204 (point) (gnus-point-at-eol))))
2209 (defun article-display-face ()
2210 "Display any Face headers in the header."
2212 (let ((wash-face-p buffer-read-only))
2213 (gnus-with-article-headers
2214 ;; When displaying parts, this function can be called several times on
2215 ;; the same article, without any intended toggle semantic (as typing `W
2216 ;; D d' would have). So face deletion must occur only when we come from
2217 ;; an interactive command, that is when the *Article* buffer is
2219 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2220 (gnus-delete-images 'face)
2221 (let (face faces from)
2222 (save-current-buffer
2223 (when (and wash-face-p
2224 (gnus-buffer-live-p gnus-original-article-buffer)
2225 (not (re-search-forward "^Face:[\t ]*" nil t)))
2226 (set-buffer gnus-original-article-buffer))
2228 (mail-narrow-to-head)
2229 (while (gnus-article-goto-header "Face")
2230 (push (mail-header-field-value) faces))))
2232 (goto-char (point-min))
2233 (let ((from (gnus-article-goto-header "from"))
2238 (insert "[no `from' set]\n"))
2240 (when (setq png (gnus-convert-face-to-png (pop faces)))
2241 (setq image (gnus-create-image png 'png t))
2243 (gnus-add-wash-type 'face)
2244 (gnus-add-image 'face image)
2245 (gnus-put-image image nil 'face))))))))))
2247 (defun article-display-x-face (&optional force)
2248 "Look for an X-Face header and display it if present."
2249 (interactive (list 'force))
2250 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2251 (gnus-with-article-headers
2252 ;; Delete the old process, if any.
2253 (when (process-status "article-x-face")
2254 (delete-process "article-x-face"))
2255 ;; See the comment in `article-display-face'.
2256 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2257 ;; We have already displayed X-Faces, so we remove them
2259 (gnus-delete-images 'xface)
2261 (let (x-faces from face)
2262 (save-current-buffer
2263 (when (and wash-face-p
2264 (gnus-buffer-live-p gnus-original-article-buffer)
2265 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2266 ;; If type `W f', use gnus-original-article-buffer,
2267 ;; otherwise use the current buffer because displaying
2268 ;; RFC822 parts calls this function too.
2269 (set-buffer gnus-original-article-buffer))
2271 (mail-narrow-to-head)
2272 (while (gnus-article-goto-header "X-Face")
2273 (push (mail-header-field-value) x-faces))
2274 (setq from (message-fetch-field "from"))))
2275 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2276 ;; single external face.
2277 (when (stringp gnus-article-x-face-command)
2278 (setq x-faces (list (car x-faces))))
2280 gnus-article-x-face-command
2282 ;; Check whether this face is censored.
2283 (not gnus-article-x-face-too-ugly)
2285 (not (string-match gnus-article-x-face-too-ugly
2287 (while (setq face (pop x-faces))
2288 ;; We display the face.
2289 (cond ((stringp gnus-article-x-face-command)
2290 ;; The command is a string, so we interpret the command
2291 ;; as a, well, command, and fork it off.
2292 (let ((process-connection-type nil))
2293 (gnus-set-process-query-on-exit-flag
2295 "article-x-face" nil shell-file-name
2296 shell-command-switch gnus-article-x-face-command)
2300 (process-send-region "article-x-face"
2301 (point-min) (point-max)))
2302 (process-send-eof "article-x-face")))
2303 ((functionp gnus-article-x-face-command)
2304 ;; The command is a lisp function, so we call it.
2305 (funcall gnus-article-x-face-command face))
2307 (error "%s is not a function"
2308 gnus-article-x-face-command))))))))))
2310 (defun article-decode-mime-words ()
2311 "Decode all MIME-encoded words in the article."
2314 (set-buffer gnus-article-buffer)
2315 (let ((inhibit-point-motion-hooks t)
2316 (inhibit-read-only t)
2317 (mail-parse-charset gnus-newsgroup-charset)
2318 (mail-parse-ignored-charsets
2319 (save-excursion (set-buffer gnus-summary-buffer)
2320 gnus-newsgroup-ignored-charsets)))
2321 (mail-decode-encoded-word-region (point-min) (point-max)))))
2323 (defun article-decode-charset (&optional prompt)
2324 "Decode charset-encoded text in the article.
2325 If PROMPT (the prefix), prompt for a coding system to use."
2327 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2328 (inhibit-read-only t)
2329 (mail-parse-charset gnus-newsgroup-charset)
2330 (mail-parse-ignored-charsets
2331 (save-excursion (condition-case nil
2332 (set-buffer gnus-summary-buffer)
2334 gnus-newsgroup-ignored-charsets))
2335 ct cte ctl charset format)
2338 (article-narrow-to-head)
2339 (setq ct (message-fetch-field "Content-Type" t)
2340 cte (message-fetch-field "Content-Transfer-Encoding" t)
2341 ctl (and ct (mail-header-parse-content-type ct))
2344 (mm-read-coding-system "Charset to decode: "))
2346 (mail-content-type-get ctl 'charset)))
2347 format (and ctl (mail-content-type-get ctl 'format)))
2349 (setq cte (mail-header-strip cte)))
2350 (if (and ctl (not (string-match "/" (car ctl))))
2352 (goto-char (point-max)))
2355 (narrow-to-region (point) (point-max))
2356 (when (and (eq mail-parse-charset 'gnus-decoded)
2357 (eq (mm-body-7-or-8) '8bit))
2358 ;; The text code could have been decoded.
2359 (setq charset mail-parse-charset))
2360 (when (and (or (not ctl)
2361 (equal (car ctl) "text/plain"))
2362 (not format)) ;; article with format will decode later.
2364 charset (and cte (intern (downcase
2365 (gnus-strip-whitespace cte))))
2368 (defun article-decode-encoded-words ()
2369 "Remove encoded-word encoding from headers."
2370 (let ((inhibit-point-motion-hooks t)
2371 (mail-parse-charset gnus-newsgroup-charset)
2372 (mail-parse-ignored-charsets
2373 (save-excursion (condition-case nil
2374 (set-buffer gnus-summary-buffer)
2376 gnus-newsgroup-ignored-charsets))
2377 (inhibit-read-only t)
2379 (goto-char (point-min))
2380 (when (search-forward "\n\n" nil 'move)
2387 (memq (char-after) '(?\t ? )))))
2388 (setq start (point))
2390 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2391 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2392 (funcall gnus-decode-address-function start end)
2393 (funcall gnus-decode-header-function start end))
2394 (goto-char (setq end start)))))
2396 (defun article-decode-group-name ()
2397 "Decode group names in `Newsgroups:'."
2398 (let ((inhibit-point-motion-hooks t)
2399 (inhibit-read-only t)
2400 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2401 (when (and (or gnus-group-name-charset-method-alist
2402 gnus-group-name-charset-group-alist)
2403 (gnus-buffer-live-p gnus-original-article-buffer))
2405 (article-narrow-to-head)
2406 (with-current-buffer gnus-original-article-buffer
2407 (goto-char (point-min)))
2408 (while (re-search-forward
2409 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2410 (replace-match (save-match-data
2411 (gnus-decode-newsgroups
2412 ;; XXX how to use data in article buffer?
2413 (with-current-buffer gnus-original-article-buffer
2415 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2418 gnus-newsgroup-name method))
2420 (goto-char (point-min))
2421 (with-current-buffer gnus-original-article-buffer
2422 (goto-char (point-min)))
2423 (while (re-search-forward
2424 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2425 (replace-match (save-match-data
2426 (gnus-decode-newsgroups
2427 ;; XXX how to use data in article buffer?
2428 (with-current-buffer gnus-original-article-buffer
2430 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2433 gnus-newsgroup-name method))
2436 (autoload 'idna-to-unicode "idna")
2438 (defun article-decode-idna-rhs ()
2439 "Decode IDNA strings in RHS in various headers in current buffer.
2440 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2441 Mail-Reply-To: and Mail-Followup-To:."
2444 (let ((inhibit-point-motion-hooks t)
2445 (inhibit-read-only t))
2446 (article-narrow-to-head)
2447 (goto-char (point-min))
2448 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2450 (when (save-match-data
2451 (and (setq ace (match-string 1))
2453 (and (re-search-backward "^[^ \t]" nil t)
2454 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2455 (setq unicode (idna-to-unicode ace))))
2456 (unless (string= ace unicode)
2457 (replace-match unicode nil nil nil 1)))))))))
2459 (defun article-de-quoted-unreadable (&optional force read-charset)
2460 "Translate a quoted-printable-encoded article.
2461 If FORCE, decode the article whether it is marked as quoted-printable
2463 If READ-CHARSET, ask for a coding system."
2464 (interactive (list 'force current-prefix-arg))
2466 (let ((inhibit-read-only t) type charset)
2467 (if (gnus-buffer-live-p gnus-original-article-buffer)
2468 (with-current-buffer gnus-original-article-buffer
2470 (gnus-fetch-field "content-transfer-encoding"))
2471 (let* ((ct (gnus-fetch-field "content-type"))
2472 (ctl (and ct (mail-header-parse-content-type ct))))
2473 (setq charset (and ctl
2474 (mail-content-type-get ctl 'charset)))
2475 (if (stringp charset)
2476 (setq charset (intern (downcase charset)))))))
2478 (setq charset (mm-read-coding-system "Charset: " charset)))
2480 (setq charset gnus-newsgroup-charset))
2482 (and type (let ((case-fold-search t))
2483 (string-match "quoted-printable" type))))
2485 (quoted-printable-decode-region
2486 (point) (point-max) (mm-charset-to-coding-system charset))))))
2488 (defun article-de-base64-unreadable (&optional force read-charset)
2489 "Translate a base64 article.
2490 If FORCE, decode the article whether it is marked as base64 not.
2491 If READ-CHARSET, ask for a coding system."
2492 (interactive (list 'force current-prefix-arg))
2494 (let ((inhibit-read-only t) type charset)
2495 (if (gnus-buffer-live-p gnus-original-article-buffer)
2496 (with-current-buffer gnus-original-article-buffer
2498 (gnus-fetch-field "content-transfer-encoding"))
2499 (let* ((ct (gnus-fetch-field "content-type"))
2500 (ctl (and ct (mail-header-parse-content-type ct))))
2501 (setq charset (and ctl
2502 (mail-content-type-get ctl 'charset)))
2503 (if (stringp charset)
2504 (setq charset (intern (downcase charset)))))))
2506 (setq charset (mm-read-coding-system "Charset: " charset)))
2508 (setq charset gnus-newsgroup-charset))
2510 (and type (let ((case-fold-search t))
2511 (string-match "base64" type))))
2514 (narrow-to-region (point) (point-max))
2515 (base64-decode-region (point-min) (point-max))
2516 (mm-decode-coding-region
2517 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2522 (defun article-decode-HZ ()
2523 "Translate a HZ-encoded article."
2527 (let ((inhibit-read-only t))
2528 (rfc1843-decode-region (point-min) (point-max)))))
2530 (defun article-unsplit-urls ()
2531 "Remove the newlines that some other mailers insert into URLs."
2534 (let ((inhibit-read-only t))
2535 (goto-char (point-min))
2536 (while (re-search-forward
2537 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2538 (replace-match "\\1\\3" t)))
2539 (when (interactive-p)
2540 (gnus-treat-article nil))))
2543 (defun article-wash-html (&optional read-charset)
2544 "Format an HTML article.
2545 If READ-CHARSET, ask for a coding system. If it is a number, the
2546 charset defined in `gnus-summary-show-article-charset-alist' is used."
2549 (let ((inhibit-read-only t)
2552 (if (or (and (numberp read-charset)
2556 gnus-summary-show-article-charset-alist))))
2557 (setq charset (mm-read-coding-system "Charset: ")))
2558 (let ((gnus-summary-show-article-charset-alist
2559 (list (cons 1 charset))))
2560 (with-current-buffer gnus-summary-buffer
2561 (gnus-summary-show-article 1)))
2562 (error "No charset is given"))
2563 (when (gnus-buffer-live-p gnus-original-article-buffer)
2564 (with-current-buffer gnus-original-article-buffer
2565 (let* ((ct (gnus-fetch-field "content-type"))
2566 (ctl (and ct (mail-header-parse-content-type ct))))
2567 (setq charset (and ctl
2568 (mail-content-type-get ctl 'charset)))
2569 (when (stringp charset)
2570 (setq charset (intern (downcase charset)))))))
2572 (setq charset gnus-newsgroup-charset)))
2574 (save-window-excursion
2576 (narrow-to-region (point) (point-max))
2577 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2578 (entry (assq func mm-text-html-washer-alist)))
2580 (setq func (cdr entry)))
2585 (apply (car func) (cdr func))))))))))
2587 (defun gnus-article-wash-html-with-w3 ()
2588 "Wash the current buffer with w3."
2590 (let ((w3-strict-width (window-width))
2591 (url-standalone-mode t)
2592 (url-gateway-unplugged t)
2593 (w3-honor-stylesheets nil))
2595 (w3-region (point-min) (point-max))
2598 (defun gnus-article-wash-html-with-w3m ()
2599 "Wash the current buffer with emacs-w3m."
2601 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2602 w3m-force-redisplay)
2603 (w3m-region (point-min) (point-max)))
2604 (when (and mm-inline-text-html-with-w3m-keymap
2605 (boundp 'w3m-minor-mode-map)
2607 (add-text-properties
2608 (point-min) (point-max)
2609 (list 'keymap w3m-minor-mode-map
2610 ;; Put the mark meaning this part was rendered by emacs-w3m.
2611 'mm-inline-text-html-with-w3m t))))
2613 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2615 (defun gnus-article-wash-html-with-w3m-standalone ()
2616 "Wash the current buffer with w3m."
2617 (if (mm-w3m-standalone-supports-m17n-p)
2619 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2621 (setq charset 'iso-8859-1))
2622 (let ((coding-system-for-write charset)
2623 (coding-system-for-read charset))
2624 (call-process-region
2625 (point-min) (point-max)
2626 "w3m" t t nil "-dump" "-T" "text/html"
2627 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2628 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2630 (defun article-hide-list-identifiers ()
2631 "Remove list identifies from the Subject header.
2632 The `gnus-list-identifiers' variable specifies what to do."
2634 (let ((inhibit-point-motion-hooks t)
2635 (regexp (if (consp gnus-list-identifiers)
2636 (mapconcat 'identity gnus-list-identifiers " *\\|")
2637 gnus-list-identifiers))
2638 (inhibit-read-only t))
2642 (article-narrow-to-head)
2643 (goto-char (point-min))
2644 (while (re-search-forward
2645 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2647 (delete-region (match-beginning 2) (match-end 0))
2648 (beginning-of-line))
2649 (when (re-search-forward
2650 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2651 (delete-region (match-beginning 1) (match-end 1))))))))
2653 (defun article-hide-pem (&optional arg)
2654 "Toggle hiding of any PEM headers and signatures in the current article.
2655 If given a negative prefix, always show; if given a positive prefix,
2657 (interactive (gnus-article-hidden-arg))
2658 (unless (gnus-article-check-hidden-text 'pem arg)
2660 (let ((inhibit-read-only t) end)
2661 (goto-char (point-min))
2662 ;; Hide the horrendously ugly "header".
2663 (when (and (search-forward
2664 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2666 (setq end (1+ (match-beginning 0))))
2667 (gnus-add-wash-type 'pem)
2668 (gnus-article-hide-text-type
2670 (if (search-forward "\n\n" nil t)
2674 ;; Hide the trailer as well
2675 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2677 (gnus-article-hide-text-type
2678 (match-beginning 0) (match-end 0) 'pem)))))))
2680 (defun article-strip-banner ()
2681 "Strip the banners specified by the `banner' group parameter and by
2682 `gnus-article-address-banner-alist'."
2686 (let ((inhibit-point-motion-hooks t))
2687 (when (gnus-parameter-banner gnus-newsgroup-name)
2688 (article-really-strip-banner
2689 (gnus-parameter-banner gnus-newsgroup-name)))
2690 (when gnus-article-address-banner-alist
2691 ;; Note that the From header is decoded here, so it is
2692 ;; required that the *-extract-address-components function
2693 ;; supports non-ASCII text.
2694 (let ((from (save-restriction
2696 (article-narrow-to-head)
2697 (mail-fetch-field "from"))))
2700 (cadr (funcall gnus-extract-address-components
2703 (dolist (pair gnus-article-address-banner-alist)
2704 (when (string-match (car pair) from)
2706 (article-really-strip-banner (cdr pair)))))))))))))
2708 (defun article-really-strip-banner (banner)
2709 "Strip the banner specified by the argument."
2712 (let ((inhibit-point-motion-hooks t)
2713 (gnus-signature-limit nil)
2714 (inhibit-read-only t))
2717 ((eq banner 'signature)
2718 (when (gnus-article-narrow-to-signature)
2721 (delete-region (point) (point-max))))
2723 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2724 (while (re-search-forward banner nil t)
2725 (delete-region (match-beginning 0) (match-end 0)))))
2727 (while (re-search-forward banner nil t)
2728 (delete-region (match-beginning 0) (match-end 0)))))))))
2730 (defun article-babel ()
2731 "Translate article using an online translation service."
2735 (set-buffer gnus-article-buffer)
2736 (when (article-goto-body)
2737 (let* ((inhibit-read-only t)
2740 (orig (buffer-substring start end))
2741 (trans (babel-as-string orig)))
2743 (narrow-to-region start end)
2744 (delete-region start end)
2747 (defun article-hide-signature (&optional arg)
2748 "Hide the signature in the current article.
2749 If given a negative prefix, always show; if given a positive prefix,
2751 (interactive (gnus-article-hidden-arg))
2752 (unless (gnus-article-check-hidden-text 'signature arg)
2755 (let ((inhibit-read-only t))
2756 (when (gnus-article-narrow-to-signature)
2757 (gnus-article-hide-text-type
2758 (point-min) (point-max) 'signature))))))
2759 (gnus-set-mode-line 'article))
2761 (defun article-strip-headers-in-body ()
2762 "Strip offensive headers from bodies."
2766 (let ((case-fold-search t))
2767 (when (looking-at "x-no-archive:")
2768 (gnus-delete-line)))))
2770 (defun article-strip-leading-blank-lines ()
2771 "Remove all blank lines from the beginning of the article."
2774 (let ((inhibit-point-motion-hooks t)
2775 (inhibit-read-only t))
2776 (when (article-goto-body)
2777 (while (and (not (eobp))
2778 (looking-at "[ \t]*$"))
2779 (gnus-delete-line))))))
2781 (defun article-narrow-to-head ()
2782 "Narrow the buffer to the head of the message.
2783 Point is left at the beginning of the narrowed-to region."
2785 (goto-char (point-min))
2786 (if (search-forward "\n\n" nil 1)
2789 (goto-char (point-min)))
2791 (defun article-goto-body ()
2792 "Place point at the start of the body."
2793 (goto-char (point-min))
2795 ;; This variable is only bound when dealing with separate
2797 (article-goto-body-goes-to-point-min-p
2799 ((search-forward "\n\n" nil t)
2802 (goto-char (point-max))
2805 (defun article-strip-multiple-blank-lines ()
2806 "Replace consecutive blank lines with one empty line."
2809 (let ((inhibit-point-motion-hooks t)
2810 (inhibit-read-only t))
2811 ;; First make all blank lines empty.
2813 (while (re-search-forward "^[ \t]+$" nil t)
2814 (unless (gnus-annotation-in-region-p
2815 (match-beginning 0) (match-end 0))
2816 (replace-match "" nil t)))
2817 ;; Then replace multiple empty lines with a single empty line.
2819 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2820 (unless (gnus-annotation-in-region-p
2821 (match-beginning 0) (match-end 0))
2822 (delete-region (match-beginning 1) (match-end 1)))))))
2824 (defun article-strip-leading-space ()
2825 "Remove all white space from the beginning of the lines in the article."
2828 (let ((inhibit-point-motion-hooks t)
2829 (inhibit-read-only t))
2831 (while (re-search-forward "^[ \t]+" nil t)
2832 (replace-match "" t t)))))
2834 (defun article-strip-trailing-space ()
2835 "Remove all white space from the end of the lines in the article."
2838 (let ((inhibit-point-motion-hooks t)
2839 (inhibit-read-only t))
2841 (while (re-search-forward "[ \t]+$" nil t)
2842 (replace-match "" t t)))))
2844 (defun article-strip-blank-lines ()
2845 "Strip leading, trailing and multiple blank lines."
2847 (article-strip-leading-blank-lines)
2848 (article-remove-trailing-blank-lines)
2849 (article-strip-multiple-blank-lines))
2851 (defun article-strip-all-blank-lines ()
2852 "Strip all blank lines."
2855 (let ((inhibit-point-motion-hooks t)
2856 (inhibit-read-only t))
2858 (while (re-search-forward "^[ \t]*\n" nil t)
2859 (replace-match "" t t)))))
2861 (defun gnus-article-narrow-to-signature ()
2862 "Narrow to the signature; return t if a signature is found, else nil."
2863 (let ((inhibit-point-motion-hooks t))
2864 (when (gnus-article-search-signature)
2866 ;; Check whether we have some limits to what we consider
2867 ;; to be a signature.
2868 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2869 (list gnus-signature-limit)))
2871 (while (setq limit (pop limits))
2872 (if (or (and (integerp limit)
2873 (< (- (point-max) (point)) limit))
2875 (< (count-lines (point) (point-max)) limit))
2876 (and (functionp limit)
2878 (and (stringp limit)
2879 (not (re-search-forward limit nil t))))
2880 () ; This limit did not succeed.
2884 (narrow-to-region (point) (point-max))
2887 (defun gnus-article-search-signature ()
2888 "Search the current buffer for the signature separator.
2889 Put point at the beginning of the signature separator."
2890 (let ((cur (point)))
2891 (goto-char (point-max))
2892 (if (if (stringp gnus-signature-separator)
2893 (re-search-backward gnus-signature-separator nil t)
2894 (let ((seps gnus-signature-separator))
2896 (not (re-search-backward (car seps) nil t)))
2903 (defun gnus-article-hidden-arg ()
2904 "Return the current prefix arg as a number, or 0 if no prefix."
2905 (list (if current-prefix-arg
2906 (prefix-numeric-value current-prefix-arg)
2909 (defun gnus-article-check-hidden-text (type arg)
2910 "Return nil if hiding is necessary.
2911 Arg can be nil or a number. nil and positive means hide, negative
2912 means show, 0 means toggle."
2915 (let ((hide (gnus-article-hidden-text-p type)))
2921 (gnus-article-show-hidden-text type)
2924 (if (eq hide 'hidden)
2926 (gnus-article-show-hidden-text type)
2930 (defun gnus-article-hidden-text-p (type)
2931 "Say whether the current buffer contains hidden text of type TYPE."
2932 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2934 (not (get-text-property pos 'invisible))
2935 (not (get-text-property pos 'dummy-invisible)))
2937 (text-property-any (1+ pos) (point-max) 'article-type type)))
2942 (defun gnus-article-show-hidden-text (type &optional dummy)
2943 "Show all hidden text of type TYPE.
2944 Originally it is hide instead of DUMMY."
2945 (let ((inhibit-read-only t)
2946 (inhibit-point-motion-hooks t))
2947 (gnus-remove-text-properties-when
2949 (point-min) (point-max)
2950 (cons 'article-type (cons type
2951 gnus-hidden-properties)))
2952 (gnus-delete-wash-type type)))
2954 (defconst article-time-units
2955 `((year . ,(* 365.25 24 60 60))
2956 (week . ,(* 7 24 60 60))
2957 (day . ,(* 24 60 60))
2961 "Mapping from time units to seconds.")
2963 (defun gnus-article-forward-header ()
2964 "Move point to the start of the next header.
2965 If the current header is a continuation header, this can be several
2970 (if (looking-at "[ \t]+[^ \t]")
2974 (defun article-date-ut (&optional type highlight)
2975 "Convert DATE date to universal time in the current article.
2976 If TYPE is `local', convert to local time; if it is `lapsed', output
2977 how much time has lapsed since DATE. For `lapsed', the value of
2978 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2979 should replace the \"Date:\" one, or should be added below it."
2980 (interactive (list 'ut t))
2981 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2982 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2986 (article-lapsed-timer
2990 (case-fold-search t)
2991 (inhibit-read-only t)
2992 (inhibit-point-motion-hooks t)
2993 pos date bface eface)
2997 (goto-char (point-min))
2998 (while (or (setq date (get-text-property (setq pos (point))
3000 (when (setq pos (next-single-property-change
3001 (point) 'original-date))
3002 (setq date (get-text-property pos 'original-date))
3004 (narrow-to-region pos (or (text-property-any pos (point-max)
3007 (goto-char (point-min))
3008 (when (re-search-forward tdate-regexp nil t)
3009 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3010 eface (get-text-property (1- (gnus-point-at-eol)) 'face)))
3011 (goto-char (point-min))
3013 ;; Delete any old Date headers.
3014 (while (re-search-forward date-regexp nil t)
3016 (delete-region (gnus-point-at-bol)
3018 (gnus-article-forward-header)
3020 (delete-region (gnus-point-at-bol)
3022 (gnus-article-forward-header)
3025 (setq pos (point))))
3026 (when (and (not pos)
3027 (re-search-forward tdate-regexp nil t))
3029 (gnus-goto-char pos)
3030 (insert (article-make-date-line date (or type 'ut)))
3036 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3037 (put-text-property (match-beginning 1) (1+ (match-end 1))
3039 (put-text-property (match-beginning 2) (match-end 2)
3041 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3042 (goto-char (point-max))
3045 (defun article-make-date-line (date type)
3046 "Return a DATE line of TYPE."
3047 (unless (memq type '(local ut original user iso8601 lapsed english))
3048 (error "Unknown conversion type: %s" type))
3050 (let ((time (date-to-time date)))
3052 ;; Convert to the local timezone.
3054 (let ((tz (car (current-time-zone time))))
3055 (format "Date: %s %s%02d%02d" (current-time-string time)
3056 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3057 (/ (% (abs tz) 3600) 60))))
3058 ;; Convert to Universal Time.
3061 (current-time-string
3062 (let* ((e (parse-time-string date))
3063 (tm (apply 'encode-time e))
3065 (ls (- (cadr tm) (car (current-time-zone time)))))
3066 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3067 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3070 ;; Get the original date from the article.
3071 ((eq type 'original)
3072 (concat "Date: " (if (string-match "\n+$" date)
3073 (substring date 0 (match-beginning 0))
3075 ;; Let the user define the format.
3077 (let ((format (or (condition-case nil
3078 (with-current-buffer gnus-summary-buffer
3079 gnus-article-time-format)
3081 gnus-article-time-format)))
3082 (if (functionp format)
3083 (funcall format time)
3084 (concat "Date: " (format-time-string format time)))))
3087 (let ((tz (car (current-time-zone time))))
3090 (format-time-string "%Y%m%dT%H%M%S" time)
3091 (format "%s%02d%02d"
3092 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3093 (/ (% (abs tz) 3600) 60)))))
3094 ;; Do an X-Sent lapsed format.
3096 ;; If the date is seriously mangled, the timezone functions are
3097 ;; liable to bug out, so we ignore all errors.
3098 (let* ((now (current-time))
3099 (real-time (subtract-time now time))
3100 (real-sec (and real-time
3101 (+ (* (float (car real-time)) 65536)
3103 (sec (and real-time (abs real-sec)))
3113 ;; This is a bit convoluted, but basically we go
3114 ;; through the time units for years, weeks, etc,
3115 ;; and divide things to see whether that results
3116 ;; in positive answers.
3119 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3120 ;; The (remaining) seconds are too few to
3121 ;; be divided into this time unit.
3123 ;; It's big enough, so we output it.
3124 (setq sec (- sec (* num (cdr unit))))
3126 (concat (if prev ", " "") (int-to-string
3128 " " (symbol-name (car unit))
3129 (if (> num 1) "s" ""))
3131 article-time-units "")
3132 ;; If dates are odd, then it might appear like the
3133 ;; article was sent in the future.
3136 " in the future"))))))
3137 ;; Display the date in proper English
3139 (let ((dtime (decode-time time)))
3142 (number-to-string (nth 3 dtime))
3143 (let ((digit (% (nth 3 dtime) 10)))
3145 ((memq (nth 3 dtime) '(11 12 13)) "th")
3151 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3153 (number-to-string (nth 5 dtime))
3155 (format "%02d" (nth 2 dtime))
3157 (format "%02d" (nth 1 dtime)))))))
3159 (format "Date: %s (from Gnus)" date))))
3161 (defun article-date-local (&optional highlight)
3162 "Convert the current article date to the local timezone."
3163 (interactive (list t))
3164 (article-date-ut 'local highlight))
3166 (defun article-date-english (&optional highlight)
3167 "Convert the current article date to something that is proper English."
3168 (interactive (list t))
3169 (article-date-ut 'english highlight))
3171 (defun article-date-original (&optional highlight)
3172 "Convert the current article date to what it was originally.
3173 This is only useful if you have used some other date conversion
3174 function and want to see what the date was before converting."
3175 (interactive (list t))
3176 (article-date-ut 'original highlight))
3178 (defun article-date-lapsed (&optional highlight)
3179 "Convert the current article date to time lapsed since it was sent."
3180 (interactive (list t))
3181 (article-date-ut 'lapsed highlight))
3183 (defun article-update-date-lapsed ()
3184 "Function to be run from a timer to update the lapsed time line."
3186 (let (deactivate-mark)
3191 (set-buffer (window-buffer w))
3192 (when (eq major-mode 'gnus-article-mode)
3193 (let ((mark (point-marker)))
3194 (goto-char (point-min))
3195 (when (re-search-forward "^X-Sent:" nil t)
3196 (article-date-lapsed t))
3197 (goto-char (marker-position mark))
3198 (move-marker mark nil))))
3201 (defun gnus-start-date-timer (&optional n)
3202 "Start a timer to update the X-Sent header in the article buffers.
3203 The numerical prefix says how frequently (in seconds) the function
3208 (gnus-stop-date-timer)
3209 (setq article-lapsed-timer
3210 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3212 (defun gnus-stop-date-timer ()
3213 "Stop the X-Sent timer."
3215 (when article-lapsed-timer
3216 (nnheader-cancel-timer article-lapsed-timer)
3217 (setq article-lapsed-timer nil)))
3219 (defun article-date-user (&optional highlight)
3220 "Convert the current article date to the user-defined format.
3221 This format is defined by the `gnus-article-time-format' variable."
3222 (interactive (list t))
3223 (article-date-ut 'user highlight))
3225 (defun article-date-iso8601 (&optional highlight)
3226 "Convert the current article date to ISO8601."
3227 (interactive (list t))
3228 (article-date-ut 'iso8601 highlight))
3230 (defmacro gnus-article-save-original-date (&rest forms)
3231 "Save the original date as a text property and evaluate FORMS."
3232 `(let* ((case-fold-search t)
3234 (goto-char (point-min))
3235 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3238 (date (when (and start
3239 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)"
3241 (buffer-substring-no-properties start
3242 (match-beginning 0)))))
3243 (goto-char (point-max))
3244 (skip-chars-backward "\n")
3245 (put-text-property (point-min) (point) 'original-date date)
3247 (goto-char (point-max))
3248 (skip-chars-backward "\n")
3249 (put-text-property (point-min) (point) 'original-date date)))
3251 ;; (defun article-show-all ()
3252 ;; "Show all hidden text in the article buffer."
3255 ;; (let ((inhibit-read-only t))
3256 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3258 (defun article-remove-leading-whitespace ()
3259 "Remove excessive whitespace from all headers."
3263 (let ((inhibit-read-only t))
3264 (article-narrow-to-head)
3265 (goto-char (point-min))
3266 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3267 (delete-region (match-beginning 1) (match-end 1)))))))
3269 (defun article-emphasize (&optional arg)
3270 "Emphasize text according to `gnus-emphasis-alist'."
3271 (interactive (gnus-article-hidden-arg))
3272 (unless (gnus-article-check-hidden-text 'emphasis arg)
3276 (with-current-buffer gnus-summary-buffer
3277 gnus-article-emphasis-alist)
3279 gnus-emphasis-alist))
3280 (inhibit-read-only t)
3281 (props (append '(article-type emphasis)
3282 gnus-hidden-properties))
3283 regexp elem beg invisible visible face)
3286 (while (setq elem (pop alist))
3288 (setq regexp (car elem)
3289 invisible (nth 1 elem)
3290 visible (nth 2 elem)
3292 (while (re-search-forward regexp nil t)
3293 (when (and (match-beginning visible) (match-beginning invisible))
3294 (gnus-article-hide-text
3295 (match-beginning invisible) (match-end invisible) props)
3296 (gnus-article-unhide-text-type
3297 (match-beginning visible) (match-end visible) 'emphasis)
3298 (gnus-put-overlay-excluding-newlines
3299 (match-beginning visible) (match-end visible) 'face face)
3300 (gnus-add-wash-type 'emphasis)
3301 (goto-char (match-end invisible)))))))))
3303 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3304 "Setup newsgroup emphasis alist."
3305 (unless gnus-article-emphasis-alist
3306 (let ((name (and gnus-newsgroup-name
3307 (gnus-group-real-name gnus-newsgroup-name))))
3308 (make-local-variable 'gnus-article-emphasis-alist)
3309 (setq gnus-article-emphasis-alist
3311 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3312 (while (setq elem (pop alist))
3313 (when (and name (string-match (car elem) name))
3315 highlight (copy-sequence (cdr elem)))))
3317 (copy-sequence highlight-words)
3318 (if gnus-newsgroup-name
3319 (copy-sequence (gnus-group-find-parameter
3320 gnus-newsgroup-name 'highlight-words t)))
3321 gnus-emphasis-alist)))))
3324 (defvar gnus-summary-article-menu)
3325 (defvar gnus-summary-post-menu))
3327 ;;; Saving functions.
3329 (defun gnus-article-save (save-buffer file &optional num)
3330 "Save the currently selected article."
3331 (when (or (get gnus-default-article-saver :headers)
3332 (not gnus-save-all-headers))
3333 ;; Remove headers according to `gnus-saved-headers' or the value
3334 ;; of the `:headers' property that the saver function might have.
3335 (let ((gnus-visible-headers
3336 (or (symbol-value (get gnus-default-article-saver :headers))
3337 gnus-saved-headers gnus-visible-headers))
3338 (gnus-article-buffer save-buffer))
3340 (set-buffer save-buffer)
3341 (article-hide-headers 1 t))))
3342 (save-window-excursion
3343 (if (not gnus-default-article-saver)
3344 (error "No default saver is defined")
3345 ;; !!! Magic! The saving functions all save
3346 ;; `gnus-save-article-buffer' (or so they think), but we
3347 ;; bind that variable to our save-buffer.
3348 (set-buffer gnus-article-buffer)
3349 (let* ((gnus-save-article-buffer save-buffer)
3352 ((not gnus-prompt-before-saving) 'default)
3353 ((eq gnus-prompt-before-saving 'always) nil)
3355 (gnus-number-of-articles-to-be-saved
3356 (when (eq gnus-prompt-before-saving t)
3358 (set-buffer gnus-article-current-summary)
3359 (funcall gnus-default-article-saver filename)))))
3361 (defun gnus-read-save-file-name (prompt &optional filename
3362 function group headers variable
3365 (funcall function group headers (symbol-value variable)))
3370 ((eq filename 'default)
3376 (when (symbol-value dir-var)
3377 (setq default-name (expand-file-name
3378 (file-name-nondirectory default-name)
3379 (symbol-value dir-var))))
3380 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3383 (if (and gnus-number-of-articles-to-be-saved
3384 (> gnus-number-of-articles-to-be-saved 1))
3385 (format "these %d articles"
3386 gnus-number-of-articles-to-be-saved)
3389 ;; Let the split methods have their say.
3391 ;; No split name was found.
3394 (concat prompt " (default "
3395 (file-name-nondirectory default-name) "): ")
3396 (file-name-directory default-name)
3398 ;; A single group name is returned.
3399 ((stringp split-name)
3401 (funcall function split-name headers
3402 (symbol-value variable)))
3404 (concat prompt " (default "
3405 (file-name-nondirectory default-name) "): ")
3406 (file-name-directory default-name)
3408 ;; A single split name was found
3409 ((= 1 (length split-name))
3410 (let* ((name (expand-file-name
3412 gnus-article-save-directory))
3413 (dir (cond ((file-directory-p name)
3414 (file-name-as-directory name))
3415 ((file-exists-p name) name)
3416 (t gnus-article-save-directory))))
3418 (concat prompt " (default " name "): ")
3420 ;; A list of splits was found.
3422 (setq split-name (nreverse split-name))
3424 (let ((file-name-history
3425 (nconc split-name file-name-history)))
3429 (concat prompt " (`M-p' for defaults): ")
3430 gnus-article-save-directory
3432 gnus-article-save-directory)))
3433 (car (push result file-name-history)))))))
3434 ;; Create the directory.
3435 (gnus-make-directory (file-name-directory file))
3436 ;; If we have read a directory, we append the default file name.
3437 (when (file-directory-p file)
3438 (setq file (expand-file-name (file-name-nondirectory
3440 (file-name-as-directory file))))
3441 ;; Possibly translate some characters.
3442 (nnheader-translate-file-chars file))))))
3443 (gnus-make-directory (file-name-directory result))
3445 (set variable result))
3447 (set dir-var (file-name-directory result)))
3450 (defun gnus-article-archive-name (group)
3451 "Return the first instance of an \"Archive-name\" in the current buffer."
3452 (let ((case-fold-search t))
3453 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3454 (nnheader-concat gnus-article-save-directory
3455 (match-string 1)))))
3457 (defun gnus-article-nndoc-name (group)
3458 "If GROUP is an nndoc group, return the name of the parent group."
3459 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3460 (gnus-group-get-parameter group 'save-article-group)))
3462 (defun gnus-summary-save-in-rmail (&optional filename)
3463 "Append this article to Rmail file.
3464 Optional argument FILENAME specifies file name.
3465 Directory to save to is default to `gnus-article-save-directory'."
3466 (setq filename (gnus-read-save-file-name
3467 "Save %s in rmail file" filename
3468 gnus-rmail-save-name gnus-newsgroup-name
3469 gnus-current-headers 'gnus-newsgroup-last-rmail))
3470 (gnus-eval-in-buffer-window gnus-save-article-buffer
3474 (gnus-output-to-rmail filename))))
3477 (defun gnus-summary-save-in-mail (&optional filename)
3478 "Append this article to Unix mail file.
3479 Optional argument FILENAME specifies file name.
3480 Directory to save to is default to `gnus-article-save-directory'."
3481 (setq filename (gnus-read-save-file-name
3482 "Save %s in Unix mail file" filename
3483 gnus-mail-save-name gnus-newsgroup-name
3484 gnus-current-headers 'gnus-newsgroup-last-mail))
3485 (gnus-eval-in-buffer-window gnus-save-article-buffer
3489 (if (and (file-readable-p filename)
3490 (file-regular-p filename)
3491 (mail-file-babyl-p filename))
3492 (rmail-output-to-rmail-file filename t)
3493 (gnus-output-to-mail filename)))))
3496 (put 'gnus-summary-save-in-file :decode t)
3497 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3498 (defun gnus-summary-save-in-file (&optional filename overwrite)
3499 "Append this article to file.
3500 Optional argument FILENAME specifies file name.
3501 Directory to save to is default to `gnus-article-save-directory'."
3502 (setq filename (gnus-read-save-file-name
3503 "Save %s in file" filename
3504 gnus-file-save-name gnus-newsgroup-name
3505 gnus-current-headers 'gnus-newsgroup-last-file))
3506 (gnus-eval-in-buffer-window gnus-save-article-buffer
3510 (when (and overwrite
3511 (file-exists-p filename))
3512 (delete-file filename))
3513 (gnus-output-to-file filename))))
3516 (put 'gnus-summary-write-to-file :decode t)
3517 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3518 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3519 (defun gnus-summary-write-to-file (&optional filename)
3520 "Write this article to a file, overwriting it if the file exists.
3521 Optional argument FILENAME specifies file name.
3522 The directory to save in defaults to `gnus-article-save-directory'."
3523 (setq filename (gnus-read-save-file-name
3524 "Save %s in file" filename
3525 gnus-file-save-name gnus-newsgroup-name
3526 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3527 (gnus-summary-save-in-file filename t))
3529 (put 'gnus-summary-save-body-in-file :decode t)
3530 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3531 "Append this article body to a file.
3532 Optional argument FILENAME specifies file name.
3533 The directory to save in defaults to `gnus-article-save-directory'."
3534 (setq filename (gnus-read-save-file-name
3535 "Save %s body in file" filename
3536 gnus-file-save-name gnus-newsgroup-name
3537 gnus-current-headers 'gnus-newsgroup-last-file))
3538 (gnus-eval-in-buffer-window gnus-save-article-buffer
3542 (when (article-goto-body)
3543 (narrow-to-region (point) (point-max)))
3544 (when (and overwrite
3545 (file-exists-p filename))
3546 (delete-file filename))
3547 (gnus-output-to-file filename))))
3550 (put 'gnus-summary-write-body-to-file :decode t)
3551 (put 'gnus-summary-write-body-to-file
3552 :function 'gnus-summary-save-body-in-file)
3553 (defun gnus-summary-write-body-to-file (&optional filename)
3554 "Write this article body to a file, overwriting it if the file exists.
3555 Optional argument FILENAME specifies file name.
3556 The directory to save in defaults to `gnus-article-save-directory'."
3557 (setq filename (gnus-read-save-file-name
3558 "Save %s body in file" filename
3559 gnus-file-save-name gnus-newsgroup-name
3560 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3561 (gnus-summary-save-body-in-file filename t))
3563 (defun gnus-summary-save-in-pipe (&optional command)
3564 "Pipe this article to subprocess."
3566 (cond ((and (eq command 'default)
3567 gnus-last-shell-command)
3568 gnus-last-shell-command)
3573 "Shell command on %s: "
3574 (if (and gnus-number-of-articles-to-be-saved
3575 (> gnus-number-of-articles-to-be-saved 1))
3576 (format "these %d articles"
3577 gnus-number-of-articles-to-be-saved)
3579 gnus-last-shell-command))))
3580 (when (string-equal command "")
3581 (if gnus-last-shell-command
3582 (setq command gnus-last-shell-command)
3583 (error "A command is required")))
3584 (gnus-eval-in-buffer-window gnus-article-buffer
3587 (shell-command-on-region (point-min) (point-max) command nil)))
3588 (setq gnus-last-shell-command command))
3590 (defmacro gnus-read-string (prompt &optional initial-contents history
3592 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3593 (if (and (featurep 'xemacs)
3594 (< emacs-minor-version 2))
3595 `(read-string ,prompt ,initial-contents ,history)
3596 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3598 (defun gnus-summary-pipe-to-muttprint (&optional command)
3599 "Pipe this article to muttprint."
3600 (setq command (gnus-read-string
3601 "Print using command: " gnus-summary-muttprint-program
3602 nil gnus-summary-muttprint-program))
3603 (gnus-summary-save-in-pipe command))
3605 ;;; Article file names when saving.
3607 (defun gnus-capitalize-newsgroup (newsgroup)
3608 "Capitalize NEWSGROUP name."
3609 (when (not (zerop (length newsgroup)))
3610 (concat (char-to-string (upcase (aref newsgroup 0)))
3611 (substring newsgroup 1))))
3613 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3614 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3615 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3616 Otherwise, it is like ~/News/news/group/num."
3619 (concat (if (gnus-use-long-file-name 'not-save)
3620 (gnus-capitalize-newsgroup newsgroup)
3621 (gnus-newsgroup-directory-form newsgroup))
3622 "/" (int-to-string (mail-header-number headers)))
3623 gnus-article-save-directory)))
3625 (string-equal (file-name-directory default)
3626 (file-name-directory last-file))
3627 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3629 (or last-file default))))
3631 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3632 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3633 If variable `gnus-use-long-file-name' is non-nil, it is
3634 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3637 (concat (if (gnus-use-long-file-name 'not-save)
3639 (gnus-newsgroup-directory-form newsgroup))
3640 "/" (int-to-string (mail-header-number headers)))
3641 gnus-article-save-directory)))
3643 (string-equal (file-name-directory default)
3644 (file-name-directory last-file))
3645 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3647 (or last-file default))))
3649 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3650 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3651 If variable `gnus-use-long-file-name' is non-nil, it is
3652 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3655 (if (gnus-use-long-file-name 'not-save)
3658 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3660 gnus-article-save-directory)))
3662 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3663 "Generate file name from sender."
3664 (let ((from (mail-header-from headers)))
3666 (if (and from (string-match "\\([^ <]+\\)@" from))
3667 (match-string 1 from)
3669 gnus-article-save-directory)))
3671 (defun article-verify-x-pgp-sig ()
3674 (if (gnus-buffer-live-p gnus-original-article-buffer)
3675 (let ((sig (with-current-buffer gnus-original-article-buffer
3676 (gnus-fetch-field "X-PGP-Sig")))
3680 (mml2015-clear-verify-function))
3682 (insert-buffer-substring gnus-original-article-buffer)
3683 (setq items (split-string sig))
3684 (message-narrow-to-head)
3685 (let ((inhibit-point-motion-hooks t)
3686 (case-fold-search t))
3687 ;; Don't verify multiple headers.
3688 (setq headers (mapconcat (lambda (header)
3690 (mail-fetch-field header)
3692 (split-string (nth 1 items) ",") "")))
3693 (delete-region (point-min) (point-max))
3694 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3695 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3700 (if (looking-at "^-")
3703 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3704 (insert "Version: " (car items) "\n\n")
3705 (insert (mapconcat 'identity (cddr items) "\n"))
3706 (insert "\n-----END PGP SIGNATURE-----\n")
3707 (let ((mm-security-handle (list (format "multipart/signed"))))
3708 (mml2015-clean-buffer)
3709 (let ((coding-system-for-write (or gnus-newsgroup-charset
3711 (funcall (mml2015-clear-verify-function)))
3713 (or (mm-handle-multipart-ctl-parameter
3714 mm-security-handle 'gnus-details)
3715 (mm-handle-multipart-ctl-parameter
3716 mm-security-handle 'gnus-info)))))
3718 (let ((inhibit-read-only t) bface eface)
3720 (message-narrow-to-head)
3721 (goto-char (point-max))
3723 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3724 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3725 (message-remove-header "X-Gnus-PGP-Verify")
3726 (if (re-search-forward "^X-PGP-Sig:" nil t)
3728 (goto-char (point-max)))
3729 (narrow-to-region (point) (point))
3730 (insert "X-Gnus-PGP-Verify: " info "\n")
3731 (goto-char (point-min))
3734 (if (not (looking-at "^[ \t]"))
3738 (goto-char (point-min))
3739 (when (looking-at "\\([^:]+\\): *")
3740 (put-text-property (match-beginning 1) (1+ (match-end 1))
3742 (put-text-property (match-end 0) (point-max)
3743 'face eface)))))))))
3745 (defun article-verify-cancel-lock ()
3746 "Verify Cancel-Lock header."
3748 (if (gnus-buffer-live-p gnus-original-article-buffer)
3749 (canlock-verify gnus-original-article-buffer)))
3756 (setq afunc (car func)
3759 gfunc (intern (format "gnus-%s" func))))
3761 (when (fboundp afunc)
3762 `(lambda (&optional interactive &rest args)
3763 ,(documentation afunc t)
3764 (interactive (list t))
3766 (set-buffer gnus-article-buffer)
3768 (call-interactively ',afunc)
3769 (apply ',afunc args))))))))
3770 '(article-hide-headers
3771 article-verify-x-pgp-sig
3772 article-verify-cancel-lock
3773 article-hide-boring-headers
3774 article-treat-overstrike
3775 article-fill-long-lines
3776 article-capitalize-sentences
3778 article-remove-leading-whitespace
3779 article-display-x-face
3780 article-display-face
3781 article-de-quoted-unreadable
3782 article-de-base64-unreadable
3785 article-unsplit-urls
3786 article-hide-list-identifiers
3787 article-strip-banner
3790 article-hide-signature
3791 article-strip-headers-in-body
3792 article-remove-trailing-blank-lines
3793 article-strip-leading-blank-lines
3794 article-strip-multiple-blank-lines
3795 article-strip-leading-space
3796 article-strip-trailing-space
3797 article-strip-blank-lines
3798 article-strip-all-blank-lines
3800 article-date-english
3801 article-date-iso8601
3802 article-date-original
3804 article-decode-mime-words
3805 article-decode-charset
3806 article-decode-encoded-words
3810 article-treat-dumbquotes
3811 article-normalize-headers
3812 ;; (article-show-all . gnus-article-show-all-headers)
3816 ;;; Gnus article mode
3819 (put 'gnus-article-mode 'mode-class 'special)
3821 (set-keymap-parent gnus-article-mode-map widget-keymap)
3823 (gnus-define-keys gnus-article-mode-map
3824 " " gnus-article-goto-next-page
3825 "\177" gnus-article-goto-prev-page
3826 [delete] gnus-article-goto-prev-page
3827 [backspace] gnus-article-goto-prev-page
3828 "\C-c^" gnus-article-refer-article
3829 "h" gnus-article-show-summary
3830 "s" gnus-article-show-summary
3831 "\C-c\C-m" gnus-article-mail
3832 "?" gnus-article-describe-briefly
3833 "e" gnus-summary-edit-article
3834 "<" beginning-of-buffer
3836 "\C-c\C-i" gnus-info-find-node
3838 "R" gnus-article-reply-with-original
3839 "F" gnus-article-followup-with-original
3840 "\C-hk" gnus-article-describe-key
3841 "\C-hc" gnus-article-describe-key-briefly
3843 "\C-d" gnus-article-read-summary-keys
3844 "\M-*" gnus-article-read-summary-keys
3845 "\M-#" gnus-article-read-summary-keys
3846 "\M-^" gnus-article-read-summary-keys
3847 "\M-g" gnus-article-read-summary-keys)
3849 (substitute-key-definition
3850 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3852 (defun gnus-article-make-menu-bar ()
3853 (unless (boundp 'gnus-article-commands-menu)
3854 (gnus-summary-make-menu-bar))
3855 (gnus-turn-off-edit-menu 'article)
3856 (unless (boundp 'gnus-article-article-menu)
3858 gnus-article-article-menu gnus-article-mode-map ""
3860 ["Scroll forwards" gnus-article-goto-next-page t]
3861 ["Scroll backwards" gnus-article-goto-prev-page t]
3862 ["Show summary" gnus-article-show-summary t]
3863 ["Fetch Message-ID at point" gnus-article-refer-article t]
3864 ["Mail to address at point" gnus-article-mail t]
3865 ["Send a bug report" gnus-bug t]))
3868 gnus-article-treatment-menu gnus-article-mode-map ""
3869 ;; Fixme: this should use :active (and maybe :visible).
3871 ["Hide headers" gnus-article-hide-headers t]
3872 ["Hide signature" gnus-article-hide-signature t]
3873 ["Hide citation" gnus-article-hide-citation t]
3874 ["Treat overstrike" gnus-article-treat-overstrike t]
3875 ["Remove carriage return" gnus-article-remove-cr t]
3876 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3877 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3878 ["Remove base64" gnus-article-de-base64-unreadable t]
3879 ["Treat html" gnus-article-wash-html t]
3880 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3881 ["Decode HZ" gnus-article-decode-HZ t]))
3883 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3885 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3887 (gnus-run-hooks 'gnus-article-menu-hook)))
3889 (defun gnus-article-mode ()
3890 "Major mode for displaying an article.
3892 All normal editing commands are switched off.
3894 The following commands are available in addition to all summary mode
3896 \\<gnus-article-mode-map>
3897 \\[gnus-article-next-page]\t Scroll the article one page forwards
3898 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3899 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3900 \\[gnus-article-show-summary]\t Display the summary buffer
3901 \\[gnus-article-mail]\t Send a reply to the address near point
3902 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3903 \\[gnus-info-find-node]\t Go to the Gnus info node"
3905 (kill-all-local-variables)
3906 (gnus-simplify-mode-line)
3907 (setq mode-name "Article")
3908 (setq major-mode 'gnus-article-mode)
3909 (make-local-variable 'minor-mode-alist)
3910 (use-local-map gnus-article-mode-map)
3911 (when (gnus-visual-p 'article-menu 'menu)
3912 (gnus-article-make-menu-bar)
3913 (when gnus-summary-tool-bar-map
3914 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3915 (gnus-update-format-specifications nil 'article-mode)
3916 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3917 (set (make-local-variable 'gnus-page-broken) nil)
3918 (make-local-variable 'gnus-button-marker-list)
3919 (make-local-variable 'gnus-article-current-summary)
3920 (make-local-variable 'gnus-article-mime-handles)
3921 (make-local-variable 'gnus-article-decoded-p)
3922 (make-local-variable 'gnus-article-mime-handle-alist)
3923 (make-local-variable 'gnus-article-wash-types)
3924 (make-local-variable 'gnus-article-image-alist)
3925 (make-local-variable 'gnus-article-charset)
3926 (make-local-variable 'gnus-article-ignored-charsets)
3927 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
3929 (set (make-local-variable 'nobreak-char-display) nil)
3930 (setq cursor-in-non-selected-windows nil)
3931 (gnus-set-default-directory)
3932 (buffer-disable-undo)
3933 (setq buffer-read-only t)
3934 (set-syntax-table gnus-article-mode-syntax-table)
3935 (mm-enable-multibyte)
3936 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3938 ;; Internal variables. Are `gnus-button-regexp' and `gnus-button-last' used
3940 (defvar gnus-button-regexp nil)
3941 (defvar gnus-button-marker-list nil
3942 "Regexp matching any of the regexps from `gnus-button-alist'.")
3943 (defvar gnus-button-last nil
3944 "The value of `gnus-button-alist' when `gnus-button-regexp' was build.")
3946 (defun gnus-article-setup-buffer ()
3947 "Initialize the article buffer."
3948 (let* ((name (if gnus-single-article-buffer "*Article*"
3949 (concat "*Article " gnus-newsgroup-name "*")))
3951 (progn (string-match "\\*Article" name)
3952 (concat " *Original Article"
3953 (substring name (match-end 0))))))
3954 (setq gnus-article-buffer name)
3955 (setq gnus-original-article-buffer original)
3956 (setq gnus-article-mime-handle-alist nil)
3957 ;; This might be a variable local to the summary buffer.
3958 (unless gnus-single-article-buffer
3960 (set-buffer gnus-summary-buffer)
3961 (setq gnus-article-buffer name)
3962 (setq gnus-original-article-buffer original)
3963 (gnus-set-global-variables)))
3964 (gnus-article-setup-highlight-words)
3965 ;; Init original article buffer.
3967 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3968 (mm-enable-multibyte)
3969 (setq major-mode 'gnus-original-article-mode)
3970 (make-local-variable 'gnus-original-article))
3971 (if (and (get-buffer name)
3972 (with-current-buffer name
3973 (if gnus-article-edit-mode
3974 (if (y-or-n-p "Article mode edit in progress; discard? ")
3976 (set-buffer-modified-p nil)
3977 (gnus-kill-buffer name)
3980 (error "Action aborted"))
3984 (set (make-local-variable 'gnus-article-edit-mode) nil)
3985 (when gnus-article-mime-handles
3986 (mm-destroy-parts gnus-article-mime-handles)
3987 (setq gnus-article-mime-handles nil))
3988 ;; Set it to nil in article-buffer!
3989 (setq gnus-article-mime-handle-alist nil)
3990 (buffer-disable-undo)
3991 (setq buffer-read-only t)
3992 ;; This list just keeps growing if we don't reset it.
3993 (setq gnus-button-marker-list nil)
3994 (unless (eq major-mode 'gnus-article-mode)
3995 (gnus-article-mode))
3998 (set-buffer (gnus-get-buffer-create name))
4000 (make-local-variable 'gnus-summary-buffer)
4001 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4002 (current-buffer)))))
4004 ;; Set article window start at LINE, where LINE is the number of lines
4005 ;; from the head of the article.
4006 (defun gnus-article-set-window-start (&optional line)
4008 (gnus-get-buffer-window gnus-article-buffer t)
4010 (set-buffer gnus-article-buffer)
4011 (goto-char (point-min))
4014 (gnus-message 6 "Moved to bookmark")
4015 (search-forward "\n\n" nil t)
4019 (defun gnus-article-prepare (article &optional all-headers header)
4020 "Prepare ARTICLE in article mode buffer.
4021 ARTICLE should either be an article number or a Message-ID.
4022 If ARTICLE is an id, HEADER should be the article headers.
4023 If ALL-HEADERS is non-nil, no headers are hidden."
4025 ;; Make sure we start in a summary buffer.
4026 (unless (eq major-mode 'gnus-summary-mode)
4027 (set-buffer gnus-summary-buffer))
4028 (setq gnus-summary-buffer (current-buffer))
4029 (let* ((gnus-article (if header (mail-header-number header) article))
4030 (summary-buffer (current-buffer))
4031 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4032 (group gnus-newsgroup-name)
4035 (gnus-article-setup-buffer)
4036 (set-buffer gnus-article-buffer)
4037 ;; Deactivate active regions.
4038 (when (and (boundp 'transient-mark-mode)
4039 transient-mark-mode)
4040 (setq mark-active nil))
4041 (if (not (setq result (let ((inhibit-read-only t))
4042 (gnus-request-article-this-buffer
4044 ;; There is no such article.
4046 (when (and (numberp article)
4047 (not (memq article gnus-newsgroup-sparse)))
4048 (setq gnus-article-current
4049 (cons gnus-newsgroup-name article))
4050 (set-buffer gnus-summary-buffer)
4051 (setq gnus-current-article article)
4052 (if (and (memq article gnus-newsgroup-undownloaded)
4053 (not (gnus-online (gnus-find-method-for-group
4054 gnus-newsgroup-name))))
4056 (gnus-summary-set-agent-mark article)
4057 (message "Message marked for downloading"))
4058 (gnus-summary-mark-article article gnus-canceled-mark)
4059 (unless (memq article gnus-newsgroup-sparse)
4060 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4061 (if (or (eq result 'pseudo)
4062 (eq result 'nneething))
4065 (set-buffer summary-buffer)
4066 (push article gnus-newsgroup-history)
4067 (setq gnus-last-article gnus-current-article
4068 gnus-current-article 0
4069 gnus-current-headers nil
4070 gnus-article-current nil)
4071 (if (eq result 'nneething)
4072 (gnus-configure-windows 'summary)
4073 (gnus-configure-windows 'article))
4074 (gnus-set-global-variables))
4075 (let ((gnus-article-mime-handle-alist-1
4076 gnus-article-mime-handle-alist))
4077 (gnus-set-mode-line 'article)))
4078 ;; The result from the `request' was an actual article -
4079 ;; or at least some text that is now displayed in the
4081 (when (and (numberp article)
4082 (not (eq article gnus-current-article)))
4083 ;; Seems like a new article has been selected.
4084 ;; `gnus-current-article' must be an article number.
4086 (set-buffer summary-buffer)
4087 (push article gnus-newsgroup-history)
4088 (setq gnus-last-article gnus-current-article
4089 gnus-current-article article
4090 gnus-current-headers
4091 (gnus-summary-article-header gnus-current-article)
4092 gnus-article-current
4093 (cons gnus-newsgroup-name gnus-current-article))
4094 (unless (vectorp gnus-current-headers)
4095 (setq gnus-current-headers nil))
4096 (gnus-summary-goto-subject gnus-current-article)
4097 (when (gnus-summary-show-thread)
4098 ;; If the summary buffer really was folded, the
4099 ;; previous goto may not actually have gone to
4100 ;; the right article, but the thread root instead.
4102 (gnus-summary-goto-subject gnus-current-article))
4103 (gnus-run-hooks 'gnus-mark-article-hook)
4104 (gnus-set-mode-line 'summary)
4105 (when (gnus-visual-p 'article-highlight 'highlight)
4106 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4107 ;; Set the global newsgroup variables here.
4108 (gnus-set-global-variables)
4109 (setq gnus-have-all-headers
4110 (or all-headers gnus-show-all-headers))))
4112 (gnus-configure-windows 'article))
4113 (when (or (numberp article)
4115 (gnus-article-prepare-display)
4117 (goto-char (point-min))
4118 (when gnus-break-pages
4119 (gnus-narrow-to-page)))
4120 (let ((gnus-article-mime-handle-alist-1
4121 gnus-article-mime-handle-alist))
4122 (gnus-set-mode-line 'article))
4126 (set-window-point (get-buffer-window (current-buffer)) (point))
4127 (gnus-configure-windows 'article)
4131 (defun gnus-article-prepare-display ()
4132 "Make the current buffer look like a nice article."
4133 ;; Hooks for getting information from the article.
4134 ;; This hook must be called before being narrowed.
4135 (let ((gnus-article-buffer (current-buffer))
4137 (inhibit-read-only t))
4138 (unless (eq major-mode 'gnus-article-mode)
4139 (gnus-article-mode))
4140 (setq buffer-read-only nil
4141 gnus-article-wash-types nil
4142 gnus-article-image-alist nil)
4143 (gnus-run-hooks 'gnus-tmp-internal-hook)
4144 (when gnus-display-mime-function
4145 (funcall gnus-display-mime-function))
4146 (gnus-run-hooks 'gnus-article-prepare-hook)))
4149 ;;; Gnus MIME viewing functions
4152 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4153 "Format of the MIME buttons.
4155 Valid specifiers include:
4157 %T MIME type, along with additional info
4158 %n The `name' parameter
4159 %d The description, if any
4160 %l The length of the encoded part
4161 %p The part identifier number
4162 %e Dots if the part isn't displayed
4164 General format specifiers can also be used. See Info node
4165 `(gnus)Formatting Variables'.")
4167 (defvar gnus-mime-button-line-format-alist
4168 '((?t gnus-tmp-type ?s)
4169 (?T gnus-tmp-type-long ?s)
4170 (?n gnus-tmp-name ?s)
4171 (?d gnus-tmp-description ?s)
4173 (?l gnus-tmp-length ?d)
4174 (?e gnus-tmp-dots ?s)))
4176 (defvar gnus-mime-button-commands
4177 '((gnus-article-press-button "\r" "Toggle Display")
4178 (gnus-mime-view-part "v" "View Interactively...")
4179 (gnus-mime-view-part-as-type "t" "View As Type...")
4180 (gnus-mime-view-part-as-charset "C" "View As charset...")
4181 (gnus-mime-save-part "o" "Save...")
4182 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4183 (gnus-mime-delete-part "d" "Delete part")
4184 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4185 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4186 (gnus-mime-view-part-internally "E" "View Internally")
4187 (gnus-mime-view-part-externally "e" "View Externally")
4188 (gnus-mime-print-part "p" "Print")
4189 (gnus-mime-pipe-part "|" "Pipe To Command...")
4190 (gnus-mime-action-on-part "." "Take action on the part...")))
4192 (defun gnus-article-mime-part-status ()
4193 (if gnus-article-mime-handle-alist-1
4194 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4196 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4199 (defvar gnus-mime-button-map
4200 (let ((map (make-sparse-keymap)))
4201 (unless (>= (string-to-number emacs-version) 21)
4202 ;; XEmacs doesn't care.
4203 (set-keymap-parent map gnus-article-mode-map))
4204 (define-key map gnus-mouse-2 'gnus-article-push-button)
4205 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4206 (dolist (c gnus-mime-button-commands)
4207 (define-key map (cadr c) (car c)))
4211 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4213 ,@(mapcar (lambda (c)
4214 (vector (caddr c) (car c) :enable t))
4215 gnus-mime-button-commands)))
4218 (define-compiler-macro popup-menu (&whole form
4219 menu &optional position prefix)
4220 (if (and (fboundp 'popup-menu)
4221 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4223 ;; Gnus is probably running under Emacs 20.
4224 `(let* ((menu (cdr ,menu))
4225 (response (x-popup-menu
4227 (cons "" (mapcar (lambda (c)
4228 (cons (caddr c) (car c)))
4231 (call-interactively (nth 3 (assq response menu))))))))
4233 (defun gnus-mime-button-menu (event prefix)
4234 "Construct a context-sensitive menu of MIME commands."
4235 (interactive "e\nP")
4236 (save-window-excursion
4237 (let ((pos (event-start event)))
4238 (select-window (posn-window pos))
4239 (goto-char (posn-point pos))
4240 (gnus-article-check-buffer)
4241 (popup-menu gnus-mime-button-menu nil prefix))))
4243 (defun gnus-mime-view-all-parts (&optional handles)
4244 "View all the MIME parts."
4246 (save-current-buffer
4247 (set-buffer gnus-article-buffer)
4248 (let ((handles (or handles gnus-article-mime-handles))
4249 (mail-parse-charset gnus-newsgroup-charset)
4250 (mail-parse-ignored-charsets
4251 (with-current-buffer gnus-summary-buffer
4252 gnus-newsgroup-ignored-charsets)))
4254 (mm-remove-parts handles)
4255 (goto-char (point-min))
4256 (or (search-forward "\n\n") (goto-char (point-max)))
4257 (let ((inhibit-read-only t))
4258 (delete-region (point) (point-max))
4259 (mm-display-parts handles))))))
4261 (defun gnus-mime-save-part-and-strip ()
4262 "Save the MIME part under point then replace it with an external body."
4264 (gnus-article-check-buffer)
4265 (when (gnus-group-read-only-p)
4266 (error "The current group does not support deleting of parts"))
4267 (when (mm-complicated-handles gnus-article-mime-handles)
4269 The current article has a complicated MIME structure, giving up..."))
4270 (when (gnus-yes-or-no-p "\
4271 Deleting parts may malfunction or destroy the article; continue? ")
4272 (let* ((data (get-text-property (point) 'gnus-data))
4274 (handles gnus-article-mime-handles))
4275 (setq file (and data (mm-save-part data)))
4277 (with-current-buffer (mm-handle-buffer data)
4279 (insert "Content-Type: " (mm-handle-media-type data))
4280 (mml-insert-parameter-string (cdr (mm-handle-type data))
4282 ;; Add a filename for the sake of saving the part again.
4283 (mml-insert-parameter
4284 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4286 (insert "Content-ID: " (message-make-message-id) "\n")
4287 (insert "Content-Transfer-Encoding: binary\n")
4290 (cdr (mm-make-handle nil
4291 `("message/external-body"
4292 (access-type . "LOCAL-FILE")
4294 (set-buffer gnus-summary-buffer)
4295 (gnus-article-edit-article
4298 (let ((mail-parse-charset (or gnus-article-charset
4299 ',gnus-newsgroup-charset))
4300 (mail-parse-ignored-charsets
4301 (or gnus-article-ignored-charsets
4302 ',gnus-newsgroup-ignored-charsets))
4303 (mbl mml-buffer-list))
4304 (setq mml-buffer-list nil)
4305 (insert-buffer-substring gnus-original-article-buffer)
4306 (mime-to-mml ',handles)
4307 (setq gnus-article-mime-handles nil)
4308 (let ((mbl1 mml-buffer-list))
4309 (setq mml-buffer-list mbl)
4310 (set (make-local-variable 'mml-buffer-list) mbl1))
4311 (gnus-make-local-hook 'kill-buffer-hook)
4312 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4313 `(lambda (no-highlight)
4314 (let ((mail-parse-charset (or gnus-article-charset
4315 ',gnus-newsgroup-charset))
4316 (message-options message-options)
4317 (message-options-set-recipient)
4318 (mail-parse-ignored-charsets
4319 (or gnus-article-ignored-charsets
4320 ',gnus-newsgroup-ignored-charsets)))
4322 (mml-destroy-buffers)
4323 (remove-hook 'kill-buffer-hook
4324 'mml-destroy-buffers t)
4325 (kill-local-variable 'mml-buffer-list))
4326 (gnus-summary-edit-article-done
4327 ,(or (mail-header-references gnus-current-headers) "")
4328 ,(gnus-group-read-only-p)
4329 ,gnus-summary-buffer no-highlight)))))))
4331 (defun gnus-mime-delete-part ()
4332 "Delete the MIME part under point.
4333 Replace it with some information about the removed part."
4335 (gnus-article-check-buffer)
4336 (when (gnus-group-read-only-p)
4337 (error "The current group does not support deleting of parts"))
4338 (when (mm-complicated-handles gnus-article-mime-handles)
4340 The current article has a complicated MIME structure, giving up..."))
4341 (when (gnus-yes-or-no-p "\
4342 Deleting parts may malfunction or destroy the article; continue? ")
4343 (let* ((data (get-text-property (point) 'gnus-data))
4344 (handles gnus-article-mime-handles)
4347 (mail-decode-encoded-word-string (or (mm-handle-description data)
4350 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4352 (type (mm-handle-media-type data)))
4354 (error "No MIME part under point"))
4355 (with-current-buffer (mm-handle-buffer data)
4356 (let ((bsize (format "%s" (buffer-size))))
4361 "| The following attachment has been deleted:\n"
4363 "| Type: " type "\n"
4364 "| Filename: " filename "\n"
4365 "| Size (encoded): " bsize " Byte\n"
4366 "| Description: " description "\n"
4369 (cdr (mm-make-handle
4370 nil `("text/plain") nil nil
4372 (format "Deleted attachment (%s bytes)" bsize))))))
4373 (set-buffer gnus-summary-buffer)
4374 ;; FIXME: maybe some of the following code (borrowed from
4375 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4376 (gnus-article-edit-article
4379 (let ((mail-parse-charset (or gnus-article-charset
4380 ',gnus-newsgroup-charset))
4381 (mail-parse-ignored-charsets
4382 (or gnus-article-ignored-charsets
4383 ',gnus-newsgroup-ignored-charsets))
4384 (mbl mml-buffer-list))
4385 (setq mml-buffer-list nil)
4386 (insert-buffer-substring gnus-original-article-buffer)
4387 (mime-to-mml ',handles)
4388 (setq gnus-article-mime-handles nil)
4389 (let ((mbl1 mml-buffer-list))
4390 (setq mml-buffer-list mbl)
4391 (set (make-local-variable 'mml-buffer-list) mbl1))
4392 (gnus-make-local-hook 'kill-buffer-hook)
4393 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4394 `(lambda (no-highlight)
4395 (let ((mail-parse-charset (or gnus-article-charset
4396 ',gnus-newsgroup-charset))
4397 (message-options message-options)
4398 (message-options-set-recipient)
4399 (mail-parse-ignored-charsets
4400 (or gnus-article-ignored-charsets
4401 ',gnus-newsgroup-ignored-charsets)))
4403 (mml-destroy-buffers)
4404 (remove-hook 'kill-buffer-hook
4405 'mml-destroy-buffers t)
4406 (kill-local-variable 'mml-buffer-list))
4407 (gnus-summary-edit-article-done
4408 ,(or (mail-header-references gnus-current-headers) "")
4409 ,(gnus-group-read-only-p)
4410 ,gnus-summary-buffer no-highlight))))
4411 ;; Not in `gnus-mime-save-part-and-strip':
4412 (gnus-article-edit-done)
4413 (gnus-summary-expand-window)
4414 (gnus-summary-show-article)))
4416 (defun gnus-mime-save-part ()
4417 "Save the MIME part under point."
4419 (gnus-article-check-buffer)
4420 (let ((data (get-text-property (point) 'gnus-data)))
4422 (mm-save-part data))))
4424 (defun gnus-mime-pipe-part ()
4425 "Pipe the MIME part under point to a process."
4427 (gnus-article-check-buffer)
4428 (let ((data (get-text-property (point) 'gnus-data)))
4430 (mm-pipe-part data))))
4432 (defun gnus-mime-view-part ()
4433 "Interactively choose a viewing method for the MIME part under point."
4435 (gnus-article-check-buffer)
4436 (let ((data (get-text-property (point) 'gnus-data)))
4438 (setq gnus-article-mime-handles
4440 gnus-article-mime-handles (setq data (copy-sequence data))))
4441 (mm-interactively-view-part data))))
4443 (defun gnus-mime-view-part-as-type-internal ()
4444 (gnus-article-check-buffer)
4445 (let* ((handle (get-text-property (point) 'gnus-data))
4447 ;; Content-Type: foo/bar; name=...
4448 (mail-content-type-get (mm-handle-type handle) 'name)
4449 ;; Content-Disposition: attachment; filename=...
4450 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4451 (def-type (and name (mm-default-file-encoding name))))
4452 (and def-type (cons def-type 0))))
4454 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4455 "Choose a MIME media type, and view the part as such.
4456 If non-nil, PRED is a predicate to use during completion to limit the
4457 available media-types."
4461 (let ((default (gnus-mime-view-part-as-type-internal)))
4463 (format "View as MIME type (default %s): "
4465 (mapcar #'list (mailcap-mime-types))
4468 (gnus-article-check-buffer)
4469 (let ((handle (get-text-property (point) 'gnus-data)))
4471 (when (equal (mm-handle-media-type handle) "message/external-body")
4472 (unless (mm-handle-cache handle)
4473 (mm-extern-cache-contents handle))
4474 (setq handle (mm-handle-cache handle)))
4476 (mm-make-handle (mm-handle-buffer handle)
4477 (cons mime-type (cdr (mm-handle-type handle)))
4478 (mm-handle-encoding handle)
4479 (mm-handle-undisplayer handle)
4480 (mm-handle-disposition handle)
4481 (mm-handle-description handle)
4483 (mm-handle-id handle)))
4484 (setq gnus-article-mime-handles
4485 (mm-merge-handles gnus-article-mime-handles handle))
4486 (gnus-mm-display-part handle))))
4489 (require 'jka-compr))
4491 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4492 ;; emacs can do that itself.
4494 (defun gnus-mime-jka-compr-maybe-uncompress ()
4495 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4496 The uncompress method used is derived from `buffer-file-name'."
4497 (when (and (fboundp 'jka-compr-installed-p)
4498 (jka-compr-installed-p))
4499 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4501 (let ((basename (file-name-nondirectory buffer-file-name))
4502 (args (jka-compr-info-uncompress-args info))
4503 (prog (jka-compr-info-uncompress-program info))
4504 (message (jka-compr-info-uncompress-message info))
4505 (err-file (jka-compr-make-temp-name)))
4507 (message "%s %s..." message basename))
4509 (unless (memq (apply 'call-process-region
4510 (point-min) (point-max)
4512 t (list t err-file) nil
4514 jka-compr-acceptable-retval-list)
4515 (jka-compr-error prog args basename message err-file))
4516 (jka-compr-delete-temp-file err-file)))))))
4518 (defun gnus-mime-copy-part (&optional handle)
4519 "Put the MIME part under point into a new buffer.
4520 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4523 (gnus-article-check-buffer)
4524 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4525 (contents (and handle (mm-get-part handle)))
4527 (file-name-nondirectory
4529 (mail-content-type-get (mm-handle-type handle) 'name)
4530 (mail-content-type-get (mm-handle-disposition handle)
4533 (buffer (and base (generate-new-buffer base))))
4535 (switch-to-buffer buffer)
4537 ;; We do it this way to make `normal-mode' set the appropriate mode.
4540 (setq buffer-file-name (expand-file-name base))
4541 (gnus-mime-jka-compr-maybe-uncompress)
4543 (setq buffer-file-name nil))
4544 (goto-char (point-min)))))
4546 (defun gnus-mime-print-part (&optional handle filename)
4547 "Print the MIME part under point."
4548 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4549 (gnus-article-check-buffer)
4550 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4551 (contents (and handle (mm-get-part handle)))
4552 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4553 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4558 (mm-save-part-to-file handle file)
4559 (call-process shell-file-name nil
4560 (generate-new-buffer " *mm*")
4562 shell-command-switch
4564 printer file (mm-handle-type handle))))
4568 (gnus-print-buffer))
4569 (ps-despool filename)))))
4571 (defun gnus-mime-inline-part (&optional handle arg)
4572 "Insert the MIME part under point into the current buffer."
4573 (interactive (list nil current-prefix-arg))
4574 (gnus-article-check-buffer)
4575 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4578 (inhibit-read-only t))
4580 (if (and (not arg) (mm-handle-undisplayer handle))
4581 (mm-remove-part handle)
4582 (setq contents (mm-get-part handle))
4585 (setq charset (or (mail-content-type-get
4586 (mm-handle-type handle) 'charset)
4587 gnus-newsgroup-charset)))
4589 (if (mm-handle-undisplayer handle)
4590 (mm-remove-part handle))
4593 gnus-summary-show-article-charset-alist))
4594 (mm-read-coding-system "Charset: "))))
4596 (if (mm-handle-undisplayer handle)
4597 (mm-remove-part handle))))
4602 (setq charset (mm-charset-to-coding-system
4604 (not (eq charset 'ascii)))
4605 (mm-decode-coding-string contents charset)
4606 (mm-string-to-multibyte contents)))
4609 (defun gnus-mime-strip-charset-parameters (handle)
4610 "Strip charset parameters from HANDLE."
4611 (if (stringp (car handle))
4612 (mapc #'gnus-mime-strip-charset-parameters (cdr handle))
4613 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
4614 "message/external-body")
4616 (unless (mm-handle-cache handle)
4617 (mm-extern-cache-contents handle))
4618 (mm-handle-cache handle))
4620 (charset (assq 'charset (cdr type))))
4622 (delq charset type)))))
4624 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4625 "Insert the MIME part under point into the current buffer using the
4627 (interactive (list nil current-prefix-arg))
4628 (gnus-article-check-buffer)
4629 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4630 (fun (get-text-property (point) 'gnus-callback))
4631 (gnus-newsgroup-ignored-charsets 'gnus-all)
4632 gnus-newsgroup-charset form preferred parts)
4634 (if (mm-handle-undisplayer handle)
4635 (mm-remove-part handle))
4637 (setq gnus-newsgroup-charset
4638 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4639 (mm-read-coding-system "Charset: ")))
4640 (gnus-mime-strip-charset-parameters handle)
4641 (when (and (consp (setq form (cdr-safe fun)))
4642 (setq form (ignore-errors
4643 (assq 'gnus-mime-display-alternative form)))
4644 (setq preferred (caddr form))
4646 (when (eq (car preferred) 'quote)
4647 (setq preferred (cadr preferred)))
4648 (not (equal preferred
4649 (get-text-property (point) 'gnus-data))))
4650 (setq parts (get-text-property (point) 'gnus-part))
4651 (setq parts (cdr (assq parts
4652 gnus-article-mime-handle-alist)))
4653 (equal (mm-handle-media-type parts) "multipart/alternative")
4654 (setq parts (reverse (cdr parts))))
4656 (list 'quote (or (cadr (member preferred parts))
4658 (funcall fun handle)))))
4660 (defun gnus-mime-view-part-externally (&optional handle)
4661 "View the MIME part under point with an external viewer."
4663 (gnus-article-check-buffer)
4664 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4665 (mm-user-display-methods nil)
4666 (mm-inlined-types nil)
4667 (mail-parse-charset gnus-newsgroup-charset)
4668 (mail-parse-ignored-charsets
4669 (with-current-buffer gnus-summary-buffer
4670 gnus-newsgroup-ignored-charsets))
4671 (type (mm-handle-media-type handle))
4672 (method (mailcap-mime-info type))
4673 (mm-enable-external t))
4674 (if (not (stringp method))
4675 (gnus-mime-view-part-as-type
4676 nil (lambda (types) (stringp (mailcap-mime-info (car types)))))
4678 (if (mm-handle-undisplayer handle)
4679 (mm-remove-part handle)
4680 (mm-display-part handle))))))
4682 (defun gnus-mime-view-part-internally (&optional handle)
4683 "View the MIME part under point with an internal viewer.
4684 If no internal viewer is available, use an external viewer."
4686 (gnus-article-check-buffer)
4687 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4688 (mm-inlined-types '(".*"))
4689 (mm-inline-large-images t)
4690 (mail-parse-charset gnus-newsgroup-charset)
4691 (mail-parse-ignored-charsets
4692 (with-current-buffer gnus-summary-buffer
4693 gnus-newsgroup-ignored-charsets))
4694 (inhibit-read-only t))
4695 (if (not (mm-inlinable-p handle))
4696 (gnus-mime-view-part-as-type
4697 nil (lambda (types) (mm-inlinable-p handle (car types))))
4699 (if (mm-handle-undisplayer handle)
4700 (mm-remove-part handle)
4701 (mm-display-part handle))))))
4703 (defun gnus-mime-action-on-part (&optional action)
4704 "Do something with the MIME attachment at \(point\)."
4706 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4707 (gnus-article-check-buffer)
4708 (let ((action-pair (assoc action gnus-mime-action-alist)))
4710 (funcall (cdr action-pair)))))
4712 (defun gnus-article-part-wrapper (n function)
4713 (let ((window (get-buffer-window gnus-article-buffer 'visible))
4716 ;; It is necessary to select the article window so that
4717 ;; `gnus-article-goto-part' may really move the point.
4718 (setq frame (selected-frame))
4719 (gnus-select-frame-set-input-focus (window-frame window))
4721 (save-window-excursion
4722 (select-window window)
4723 (when (> n (length gnus-article-mime-handle-alist))
4724 (error "No such part"))
4725 (gnus-article-goto-part n)
4726 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4727 (funcall function handle)))
4728 (gnus-select-frame-set-input-focus frame)))))
4730 (defun gnus-article-pipe-part (n)
4731 "Pipe MIME part N, which is the numerical prefix."
4733 (gnus-article-part-wrapper n 'mm-pipe-part))
4735 (defun gnus-article-save-part (n)
4736 "Save MIME part N, which is the numerical prefix."
4738 (gnus-article-part-wrapper n 'mm-save-part))
4740 (defun gnus-article-interactively-view-part (n)
4741 "View MIME part N interactively, which is the numerical prefix."
4743 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4745 (defun gnus-article-copy-part (n)
4746 "Copy MIME part N, which is the numerical prefix."
4748 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4750 (defun gnus-article-view-part-as-charset (n)
4751 "View MIME part N using a specified charset.
4752 N is the numerical prefix."
4754 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4756 (defun gnus-article-view-part-externally (n)
4757 "View MIME part N externally, which is the numerical prefix."
4759 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4761 (defun gnus-article-inline-part (n)
4762 "Inline MIME part N, which is the numerical prefix."
4764 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4766 (defun gnus-article-mime-match-handle-first (condition)
4768 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4769 (while (setq ihandle (pop alist))
4771 ((functionp condition)
4772 (funcall condition (cdr ihandle)))
4773 ((eq condition 'undisplayed)
4774 (not (or (mm-handle-undisplayer (cdr ihandle))
4775 (equal (mm-handle-media-type (cdr ihandle))
4776 "multipart/alternative"))))
4777 ((eq condition 'undisplayed-alternative)
4778 (not (mm-handle-undisplayer (cdr ihandle))))
4780 (gnus-article-goto-part (car ihandle))
4781 (or (not n) (< (car ihandle) n)))
4782 (setq n (car ihandle))))
4786 (defun gnus-article-view-part (&optional n)
4787 "View MIME part N, which is the numerical prefix."
4789 (save-current-buffer
4790 (set-buffer gnus-article-buffer)
4791 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4792 gnus-article-mime-match-handle-function)))
4793 (when (> n (length gnus-article-mime-handle-alist))
4794 (error "No such part"))
4795 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4796 (when (gnus-article-goto-part n)
4797 (if (equal (car handle) "multipart/alternative")
4798 (gnus-article-press-button)
4799 (when (eq (gnus-mm-display-part handle) 'internal)
4800 (gnus-set-window-start)))))))
4802 (defsubst gnus-article-mime-total-parts ()
4803 (if (bufferp (car gnus-article-mime-handles))
4805 (1- (length gnus-article-mime-handles))))
4807 (defun gnus-mm-display-part (handle)
4808 "Display HANDLE and fix MIME button."
4809 (let ((id (get-text-property (point) 'gnus-part))
4811 (inhibit-read-only t))
4814 (let ((window (selected-window))
4815 (mail-parse-charset gnus-newsgroup-charset)
4816 (mail-parse-ignored-charsets
4817 (if (gnus-buffer-live-p gnus-summary-buffer)
4819 (set-buffer gnus-summary-buffer)
4820 gnus-newsgroup-ignored-charsets)
4824 (let ((win (gnus-get-buffer-window (current-buffer) t))
4827 (select-window win))
4830 (if (mm-handle-displayed-p handle)
4831 ;; This will remove the part.
4832 (mm-display-part handle)
4834 (narrow-to-region (point)
4835 (if (eobp) (point) (1+ (point))))
4836 (mm-display-part handle)
4837 ;; We narrow to the part itself and
4838 ;; then call the treatment functions.
4839 (goto-char (point-min))
4841 (narrow-to-region (point) (point-max))
4844 (gnus-article-mime-total-parts)
4845 (mm-handle-media-type handle)))))
4846 (if (window-live-p window)
4847 (select-window window)))))
4850 (gnus-insert-mime-button
4851 handle id (list (mm-handle-displayed-p handle)))
4852 (goto-char point))))
4854 (defun gnus-article-goto-part (n)
4855 "Go to MIME part N."
4856 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4858 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4859 (let ((gnus-tmp-name
4860 (or (mail-content-type-get (mm-handle-type handle) 'name)
4861 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4862 (mail-content-type-get (mm-handle-type handle) 'url)
4864 (gnus-tmp-type (mm-handle-media-type handle))
4865 (gnus-tmp-description
4866 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4869 (if (if displayed (car displayed)
4870 (mm-handle-displayed-p handle))
4872 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4874 gnus-tmp-type-long b e)
4875 (when (string-match ".*/" gnus-tmp-name)
4876 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4877 (setq gnus-tmp-type-long (concat gnus-tmp-type
4878 (and (not (equal gnus-tmp-name ""))
4879 (concat "; " gnus-tmp-name))))
4880 (unless (equal gnus-tmp-description "")
4881 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4886 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4887 `(,@(gnus-local-map-property gnus-mime-button-map)
4888 gnus-callback gnus-mm-display-part
4889 gnus-part ,gnus-tmp-id
4890 article-type annotation
4893 ;; Exclude a newline.
4896 (widget-convert-button
4899 :action 'gnus-widget-press-button
4900 :button-keymap gnus-mime-button-map
4902 (lambda (widget/window &optional overlay pos)
4903 ;; Needed to properly clear the message due to a bug in
4904 ;; wid-edit (XEmacs only).
4905 (if (boundp 'help-echo-owns-message)
4906 (setq help-echo-owns-message t))
4908 "%S: %s the MIME part; %S: more options"
4909 (aref gnus-mouse-2 0)
4910 ;; XEmacs will get a single widget arg; Emacs 21 will get
4911 ;; window, overlay, position.
4912 (if (mm-handle-displayed-p
4914 (with-current-buffer (gnus-overlay-buffer overlay)
4915 (widget-get (widget-at (gnus-overlay-start overlay))
4917 (widget-get widget/window :mime-handle)))
4919 (aref gnus-down-mouse-3 0))))))
4921 (defun gnus-widget-press-button (elems el)
4922 (goto-char (widget-get elems :from))
4923 (gnus-article-press-button))
4925 (defvar gnus-displaying-mime nil)
4927 (defun gnus-display-mime (&optional ihandles)
4928 "Display the MIME parts."
4930 (save-selected-window
4931 (let ((window (get-buffer-window gnus-article-buffer))
4934 (select-window window)
4935 ;; We have to do this since selecting the window
4936 ;; may change the point. So we set the window point.
4937 (set-window-point window point)))
4938 (let ((handles ihandles)
4939 (inhibit-read-only t)
4942 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4943 (when gnus-article-emulate-mime
4944 (mm-uu-dissect-text-parts handles)))
4945 (gnus-article-emulate-mime
4946 (setq handles (mm-uu-dissect))))
4947 (when (and (not ihandles)
4948 (not gnus-displaying-mime))
4949 ;; Top-level call; we clean up.
4950 (when gnus-article-mime-handles
4951 (mm-destroy-parts gnus-article-mime-handles)
4952 (setq gnus-article-mime-handle-alist nil));; A trick.
4953 (setq gnus-article-mime-handles handles)
4954 ;; We allow users to glean info from the handles.
4955 (when gnus-article-mime-part-function
4956 (gnus-mime-part-function handles)))
4958 (or (not (stringp (car handles)))
4961 (when (and (not ihandles)
4962 (not gnus-displaying-mime))
4963 ;; Clean up for mime parts.
4965 (delete-region (point) (point-max)))
4966 (let ((gnus-displaying-mime t))
4967 (gnus-mime-display-part handles)))
4970 (narrow-to-region (point) (point-max))
4971 (gnus-treat-article nil 1 1)
4974 ;; Highlight the headers.
4978 (narrow-to-region (point-min) (point))
4979 (gnus-article-save-original-date
4980 (gnus-treat-article 'head)))))))
4981 ;; Cope with broken MIME messages.
4982 (goto-char (point-max))
4986 (defcustom gnus-mime-display-multipart-as-mixed nil
4987 "Display \"multipart\" parts as \"multipart/mixed\".
4989 If t, it overrides nil values of
4990 `gnus-mime-display-multipart-alternative-as-mixed' and
4991 `gnus-mime-display-multipart-related-as-mixed'."
4992 :group 'gnus-article-mime
4995 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4996 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4998 :group 'gnus-article-mime
5001 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5002 "Display \"multipart/related\" parts as \"multipart/mixed\".
5004 If displaying \"text/html\" is discouraged \(see
5005 `mm-discouraged-alternatives'\) images or other material inside a
5006 \"multipart/related\" part might be overlooked when this variable is nil."
5008 :group 'gnus-article-mime
5011 (defun gnus-mime-display-part (handle)
5013 ;; Maybe a broken MIME message.
5016 ((not (stringp (car handle)))
5017 (gnus-mime-display-single handle))
5018 ;; User-defined multipart
5019 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5020 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5022 ;; multipart/alternative
5023 ((and (equal (car handle) "multipart/alternative")
5024 (not (or gnus-mime-display-multipart-as-mixed
5025 gnus-mime-display-multipart-alternative-as-mixed)))
5026 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5027 (push (cons id handle) gnus-article-mime-handle-alist)
5028 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5029 ;; multipart/related
5030 ((and (equal (car handle) "multipart/related")
5031 (not (or gnus-mime-display-multipart-as-mixed
5032 gnus-mime-display-multipart-related-as-mixed)))
5033 ;;;!!!We should find the start part, but we just default
5034 ;;;!!!to the first part.
5035 ;;(gnus-mime-display-part (cadr handle))
5036 ;;;!!! Most multipart/related is an HTML message plus images.
5037 ;;;!!! Unfortunately we are unable to let W3 display those
5038 ;;;!!! included images, so we just display it as a mixed multipart.
5039 ;;(gnus-mime-display-mixed (cdr handle))
5040 ;;;!!! No, w3 can display everything just fine.
5041 (gnus-mime-display-part (cadr handle)))
5042 ((equal (car handle) "multipart/signed")
5043 (gnus-add-wash-type 'signed)
5044 (gnus-mime-display-security handle))
5045 ((equal (car handle) "multipart/encrypted")
5046 (gnus-add-wash-type 'encrypted)
5047 (gnus-mime-display-security handle))
5048 ;; Other multiparts are handled like multipart/mixed.
5050 (gnus-mime-display-mixed (cdr handle)))))
5052 (defun gnus-mime-part-function (handles)
5053 (if (stringp (car handles))
5054 (mapcar 'gnus-mime-part-function (cdr handles))
5055 (funcall gnus-article-mime-part-function handles)))
5057 (defun gnus-mime-display-mixed (handles)
5058 (mapcar 'gnus-mime-display-part handles))
5060 (defun gnus-mime-display-single (handle)
5061 (let ((type (mm-handle-media-type handle))
5062 (ignored gnus-ignored-mime-types)
5069 (when (string-match (pop ignored) type)
5070 (throw 'ignored nil)))
5071 (if (and (setq not-attachment
5072 (and (not (mm-inline-override-p handle))
5073 (or (not (mm-handle-disposition handle))
5074 (equal (car (mm-handle-disposition handle))
5076 (mm-attachment-override-p handle))))
5077 (mm-automatic-display-p handle)
5079 (mm-inlinable-p handle)
5080 (mm-inlined-p handle))
5081 (mm-automatic-external-display-p type)))
5083 (when (equal (mm-handle-media-supertype handle) "text")
5085 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5087 (push (cons id handle) gnus-article-mime-handle-alist)
5089 (equal (mm-handle-media-supertype handle) "message"))
5092 (cond ((not (bolp)) 2)
5093 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5095 (when (or (not display)
5096 (not (gnus-unbuttonized-mime-type-p type)))
5097 (gnus-insert-mime-button
5098 handle id (list (or display (and not-attachment text))))
5099 (gnus-article-insert-newline)
5100 ;; Remember modify the number of forward lines.
5108 (let ((mail-parse-charset gnus-newsgroup-charset)
5109 (mail-parse-ignored-charsets
5110 (save-excursion (condition-case ()
5111 (set-buffer gnus-summary-buffer)
5113 gnus-newsgroup-ignored-charsets)))
5114 (mm-display-part handle t))
5115 (goto-char (point-max)))
5116 ((and text not-attachment)
5120 (gnus-article-insert-newline)
5123 (let ((charset (mail-content-type-get (mm-handle-type handle)
5125 (cond ((not charset)
5126 (mm-string-as-multibyte (mm-get-part handle)))
5127 ((eq charset 'gnus-decoded)
5128 (with-current-buffer (mm-handle-buffer handle)
5131 (mm-decode-string (mm-get-part handle) charset)))))
5132 (goto-char (point-max))))
5136 (narrow-to-region beg (point))
5139 (gnus-article-mime-total-parts)
5140 (mm-handle-media-type handle)))))))))
5142 (defun gnus-unbuttonized-mime-type-p (type)
5143 "Say whether TYPE is to be unbuttonized."
5144 (unless gnus-inhibit-mime-unbuttonizing
5146 (let ((types gnus-unbuttonized-mime-types))
5148 (when (string-match (pop types) type)
5149 (throw 'found t)))))
5151 (let ((types gnus-buttonized-mime-types))
5153 (when (string-match (pop types) type)
5154 (throw 'found t)))))))))
5156 (defun gnus-article-insert-newline ()
5157 "Insert a newline, but mark it as undeletable."
5158 (gnus-put-text-property
5159 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5161 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5162 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5165 handle (inhibit-read-only t) from props begend not-pref)
5166 (save-window-excursion
5169 (narrow-to-region (car ibegend)
5172 (goto-char (car ibegend))
5175 (delete-region (point-min) (point-max))
5176 (mm-remove-parts handles))
5177 (setq begend (list (point-marker)))
5179 (unless (setq not-pref (cadr (member preferred ihandles)))
5180 (setq not-pref (car ihandles)))
5183 (not (gnus-unbuttonized-mime-type-p
5184 "multipart/alternative")))
5185 (gnus-add-text-properties
5188 (insert (format "%d. " id))
5192 (unless ,(not ibegend)
5193 (setq gnus-article-mime-handle-alist
5194 ',gnus-article-mime-handle-alist))
5195 (gnus-mime-display-alternative
5196 ',ihandles ',not-pref ',begend ,id))
5197 ,@(gnus-local-map-property gnus-mime-button-map)
5198 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5199 face ,gnus-article-button-face
5201 article-type multipart))
5202 (widget-convert-button 'link from (point)
5203 :action 'gnus-widget-press-button
5204 :button-keymap gnus-widget-button-keymap)
5206 (while (setq handle (pop handles))
5207 (gnus-add-text-properties
5210 (insert (format "(%c) %-18s"
5211 (if (equal handle preferred) ?* ? )
5212 (mm-handle-media-type handle)))
5216 (unless ,(not ibegend)
5217 (setq gnus-article-mime-handle-alist
5218 ',gnus-article-mime-handle-alist))
5219 (gnus-mime-display-alternative
5220 ',ihandles ',handle ',begend ,id))
5221 ,@(gnus-local-map-property gnus-mime-button-map)
5222 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5223 face ,gnus-article-button-face
5226 (widget-convert-button 'link from (point)
5227 :action 'gnus-widget-press-button
5228 :button-keymap gnus-widget-button-keymap)
5232 (if (stringp (car preferred))
5233 (gnus-display-mime preferred)
5234 (let ((mail-parse-charset gnus-newsgroup-charset)
5235 (mail-parse-ignored-charsets
5236 (save-excursion (set-buffer gnus-summary-buffer)
5237 gnus-newsgroup-ignored-charsets)))
5238 (mm-display-part preferred)
5242 (narrow-to-region (car begend) (point-max))
5244 nil (length gnus-article-mime-handle-alist)
5245 (gnus-article-mime-total-parts)
5246 (mm-handle-media-type handle))))))
5247 (goto-char (point-max))
5248 (setcdr begend (point-marker)))))
5250 (goto-char point))))
5252 (defconst gnus-article-wash-status-strings
5253 (let ((alist '((cite "c" "Possible hidden citation text"
5254 " " "All citation text visible")
5255 (headers "h" "Hidden headers"
5256 " " "All headers visible.")
5257 (pgp "p" "Encrypted or signed message status hidden"
5258 " " "No hidden encryption nor digital signature status")
5259 (signature "s" "Signature has been hidden"
5260 " " "Signature is visible")
5261 (overstrike "o" "Overstrike (^H) characters applied"
5262 " " "No overstrike characters applied")
5263 (emphasis "e" "/*_Emphasis_*/ characters applied"
5264 " " "No /*_emphasis_*/ characters applied")))
5266 (dolist (entry alist result)
5267 (let ((key (nth 0 entry))
5268 (on (copy-sequence (nth 1 entry)))
5269 (on-help (nth 2 entry))
5270 (off (copy-sequence (nth 3 entry)))
5271 (off-help (nth 4 entry)))
5272 (put-text-property 0 1 'help-echo on-help on)
5273 (put-text-property 0 1 'help-echo off-help off)
5274 (push (list key on off) result))))
5275 "Alist of strings describing wash status in the mode line.
5276 Each entry has the form (KEY ON OF), where the KEY is a symbol
5277 representing the particular washing function, ON is the string to use
5278 in the article mode line when the washing function is active, and OFF
5279 is the string to use when it is inactive.")
5281 (defun gnus-article-wash-status-entry (key value)
5282 (let ((entry (assoc key gnus-article-wash-status-strings)))
5283 (if value (nth 1 entry) (nth 2 entry))))
5285 (defun gnus-article-wash-status ()
5286 "Return a string which display status of article washing."
5288 (set-buffer gnus-article-buffer)
5289 (let ((cite (memq 'cite gnus-article-wash-types))
5290 (headers (memq 'headers gnus-article-wash-types))
5291 (boring (memq 'boring-headers gnus-article-wash-types))
5292 (pgp (memq 'pgp gnus-article-wash-types))
5293 (pem (memq 'pem gnus-article-wash-types))
5294 (signed (memq 'signed gnus-article-wash-types))
5295 (encrypted (memq 'encrypted gnus-article-wash-types))
5296 (signature (memq 'signature gnus-article-wash-types))
5297 (overstrike (memq 'overstrike gnus-article-wash-types))
5298 (emphasis (memq 'emphasis gnus-article-wash-types)))
5300 (gnus-article-wash-status-entry 'cite cite)
5301 (gnus-article-wash-status-entry 'headers (or headers boring))
5302 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5303 (gnus-article-wash-status-entry 'signature signature)
5304 (gnus-article-wash-status-entry 'overstrike overstrike)
5305 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5307 (defun gnus-add-wash-type (type)
5308 "Add a washing of TYPE to the current status."
5309 (add-to-list 'gnus-article-wash-types type))
5311 (defun gnus-delete-wash-type (type)
5312 "Add a washing of TYPE to the current status."
5313 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5315 (defun gnus-add-image (category image)
5316 "Add IMAGE of CATEGORY to the list of displayed images."
5317 (let ((entry (assq category gnus-article-image-alist)))
5319 (setq entry (list category))
5320 (push entry gnus-article-image-alist))
5321 (nconc entry (list image))))
5323 (defun gnus-delete-images (category)
5324 "Delete all images in CATEGORY."
5325 (let ((entry (assq category gnus-article-image-alist)))
5326 (dolist (image (cdr entry))
5327 (gnus-remove-image image category))
5328 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5329 (gnus-delete-wash-type category)))
5331 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5333 (defun gnus-article-maybe-hide-headers ()
5334 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5335 Provided for backwards compatibility."
5336 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5337 (not (save-excursion (set-buffer gnus-summary-buffer)
5338 gnus-have-all-headers)))
5339 (not gnus-inhibit-hiding))
5340 (gnus-article-hide-headers)))
5344 (defun gnus-output-to-file (file-name)
5345 "Append the current article to a file named FILE-NAME.
5346 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5347 text and used as the value of the coding cookie which is added to the
5348 top of a file. Otherwise, this function saves a raw article without
5350 (let* ((artbuf (current-buffer))
5351 (file-name-coding-system nnmail-pathname-coding-system)
5352 (coding gnus-article-save-coding-system)
5353 (coding-system-for-read (if coding
5354 nil ;; Rely on the coding cookie.
5355 mm-text-coding-system))
5356 (coding-system-for-write (or coding
5357 mm-text-coding-system-for-write
5358 mm-text-coding-system))
5359 (exists (file-exists-p file-name)))
5362 (insert-file-contents file-name)
5363 (goto-char (point-min))
5364 ;; Remove the existing coding cookie.
5365 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5366 (delete-region (match-beginning 0) (match-end 0))))
5367 (goto-char (point-max))
5368 (insert-buffer-substring artbuf)
5369 ;; Append newline at end of the buffer as separator, and then
5371 (goto-char (point-max))
5374 ;; If the coding system is not suitable to encode the text,
5375 ;; ask a user for a proper one.
5376 (when (fboundp 'select-safe-coding-system)
5377 (setq coding (coding-system-base
5378 (save-window-excursion
5379 (select-safe-coding-system (point-min) (point-max)
5381 (setq coding-system-for-write
5382 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5384 (goto-char (point-min))
5385 ;; Add the coding cookie.
5386 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5387 coding-system-for-write)))
5390 (write-region (point-min) (point-max) file-name nil 'no-message)
5391 (message "Appended to %s" file-name))
5392 (write-region (point-min) (point-max) file-name))))
5395 (defun gnus-narrow-to-page (&optional arg)
5396 "Narrow the article buffer to a page.
5397 If given a numerical ARG, move forward ARG pages."
5399 (setq arg (if arg (prefix-numeric-value arg) 0))
5400 (with-current-buffer gnus-article-buffer
5402 ;; Remove any old next/prev buttons.
5403 (when (gnus-visual-p 'page-marker)
5404 (let ((inhibit-read-only t))
5405 (gnus-remove-text-with-property 'gnus-prev)
5406 (gnus-remove-text-with-property 'gnus-next)))
5408 (when (save-excursion
5410 (if (re-search-backward page-delimiter nil 'move (abs arg))
5412 (setq nd (match-beginning 0)
5414 (when (re-search-backward page-delimiter nil t)
5415 (setq st (match-end 0))))
5416 (when (re-search-forward page-delimiter nil t)
5417 (setq nd (match-beginning 0)
5420 (if (re-search-forward page-delimiter nil 'move arg)
5422 (setq st (match-end 0)
5424 (when (re-search-forward page-delimiter nil t)
5425 (setq nd (match-beginning 0))))
5426 (when (re-search-backward page-delimiter nil t)
5427 (setq st (match-end 0)
5430 (when (re-search-backward page-delimiter nil t)
5431 (goto-char (setq st (match-end 0))))
5432 (when (re-search-forward page-delimiter nil t)
5433 (setq nd (match-beginning 0)))
5435 (setq gnus-page-broken t)
5436 (when pt (goto-char pt))
5437 (narrow-to-region (or st (point-min)) (or nd (point-max)))
5438 (when (gnus-visual-p 'page-marker)
5442 (gnus-insert-next-page-button))
5445 (gnus-insert-prev-page-button))))))))
5447 ;; Article mode commands
5449 (defun gnus-article-goto-next-page ()
5450 "Show the next page of the article."
5452 (when (gnus-article-next-page)
5453 (goto-char (point-min))
5454 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5457 (defun gnus-article-goto-prev-page ()
5458 "Show the previous page of the article."
5460 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
5461 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5462 (gnus-article-prev-page nil)))
5464 ;; This is cleaner but currently breaks `gnus-pick-mode':
5466 ;; (defun gnus-article-goto-next-page ()
5467 ;; "Show the next page of the article."
5469 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5470 ;; (gnus-summary-next-page)))
5472 ;; (defun gnus-article-goto-prev-page ()
5473 ;; "Show the next page of the article."
5475 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5476 ;; (gnus-summary-prev-page)))
5478 (defun gnus-article-next-page (&optional lines)
5479 "Show the next page of the current article.
5480 If end of article, return non-nil. Otherwise return nil.
5481 Argument LINES specifies lines to be scrolled up."
5483 (move-to-window-line -1)
5486 (and (pos-visible-in-window-p) ;Not continuation line.
5487 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5488 ;; Nothing in this page.
5489 (if (or (not gnus-page-broken)
5494 (eobp)))) ;Real end-of-buffer?
5496 (when gnus-article-over-scroll
5497 (gnus-article-next-page-1 lines))
5499 (gnus-narrow-to-page 1) ;Go to next page.
5501 ;; More in this page.
5502 (gnus-article-next-page-1 lines)
5505 (defmacro gnus-article-beginning-of-window ()
5506 "Move point to the beginning of the window.
5507 In Emacs, the point is placed at the line number which `scroll-margin'
5509 (if (featurep 'xemacs)
5510 '(move-to-window-line 0)
5511 '(move-to-window-line
5512 (min (max 0 scroll-margin)
5513 (max 1 (- (window-height)
5514 (if mode-line-format 1 0)
5515 (if (and (boundp 'header-line-format)
5516 (symbol-value 'header-line-format))
5519 (defun gnus-article-next-page-1 (lines)
5520 (when (and (not (featurep 'xemacs))
5523 (numberp (symbol-value 'scroll-margin))
5524 (> (symbol-value 'scroll-margin) 0))
5525 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5526 ;; too many number of lines if `scroll-margin' is set as two or greater.
5527 (setq lines (min lines
5528 (max 0 (- (count-lines (window-start) (point-max))
5529 (symbol-value 'scroll-margin))))))
5531 (let ((scroll-in-place nil))
5534 ;; Long lines may cause an end-of-buffer error.
5535 (goto-char (point-max))))
5536 (gnus-article-beginning-of-window))
5538 (defun gnus-article-prev-page (&optional lines)
5539 "Show previous page of current article.
5540 Argument LINES specifies lines to be scrolled down."
5542 (move-to-window-line 0)
5543 (if (and gnus-page-broken
5545 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5547 (gnus-narrow-to-page -1) ;Go to previous page.
5548 (goto-char (point-max))
5552 (let ((scroll-in-place nil))
5553 (scroll-down lines))
5554 (beginning-of-buffer
5555 (goto-char (point-min))))
5556 (gnus-article-beginning-of-window))))
5558 (defun gnus-article-only-boring-p ()
5559 "Decide whether there is only boring text remaining in the article.
5560 Something \"interesting\" is a word of at least two letters that does
5561 not have a face in `gnus-article-boring-faces'."
5562 (when (and gnus-article-skip-boring
5563 (boundp 'gnus-article-boring-faces)
5564 (symbol-value 'gnus-article-boring-faces))
5566 (let ((inhibit-point-motion-hooks t))
5568 (while (re-search-forward "\\b\\w\\w" nil t)
5570 (when (not (gnus-intersection
5571 (gnus-faces-at (point))
5572 (symbol-value 'gnus-article-boring-faces)))
5573 (throw 'only-boring nil)))
5574 (throw 'only-boring t))))))
5576 (defun gnus-article-refer-article ()
5577 "Read article specified by message-id around point."
5580 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5581 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5582 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5583 (let ((msg-id (concat "<" (match-string 0) ">")))
5584 (set-buffer gnus-summary-buffer)
5585 (gnus-summary-refer-article msg-id))
5586 (error "No references around point"))))
5588 (defun gnus-article-show-summary ()
5589 "Reconfigure windows to show summary buffer."
5591 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5592 (error "There is no summary buffer for this article buffer")
5593 (gnus-article-set-globals)
5594 (gnus-configure-windows 'article)
5595 (gnus-summary-goto-subject gnus-current-article)
5596 (gnus-summary-position-point)))
5598 (defun gnus-article-describe-briefly ()
5599 "Describe article mode commands briefly."
5601 (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")))
5603 (defun gnus-article-summary-command ()
5604 "Execute the last keystroke in the summary buffer."
5606 (let ((obuf (current-buffer))
5607 (owin (current-window-configuration))
5609 (switch-to-buffer gnus-article-current-summary 'norecord)
5610 (setq func (lookup-key (current-local-map) (this-command-keys)))
5611 (call-interactively func)
5613 (set-window-configuration owin)
5614 (set-window-point (get-buffer-window (current-buffer)) (point))))
5616 (defun gnus-article-summary-command-nosave ()
5617 "Execute the last keystroke in the summary buffer."
5620 (pop-to-buffer gnus-article-current-summary)
5621 (setq func (lookup-key (current-local-map) (this-command-keys)))
5622 (call-interactively func)))
5624 (defun gnus-article-check-buffer ()
5625 "Beep if not in an article buffer."
5626 (unless (equal major-mode 'gnus-article-mode)
5627 (error "Command invoked outside of a Gnus article buffer")))
5629 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5630 "Read a summary buffer key sequence and execute it from the article buffer."
5632 (gnus-article-check-buffer)
5634 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5635 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5636 "=" "^" "\M-^" "|"))
5642 '("n" "Gn" "p" "Gp"))
5645 (set-buffer gnus-article-current-summary)
5646 (let (gnus-pick-mode)
5647 (push (or key last-command-event) unread-command-events)
5648 (setq keys (if (featurep 'xemacs)
5649 (events-to-keys (read-key-sequence nil))
5650 (read-key-sequence nil)))))
5654 (if (or (member keys nosaves)
5655 (member keys nosave-but-article)
5656 (member keys nosave-in-article))
5658 (save-window-excursion
5659 (pop-to-buffer gnus-article-current-summary)
5660 ;; We disable the pick minor mode commands.
5661 (let (gnus-pick-mode)
5662 (setq func (lookup-key (current-local-map) keys))))
5666 (unless (member keys nosave-in-article)
5667 (set-buffer gnus-article-current-summary))
5668 (call-interactively func)
5669 (setq new-sum-point (point)))
5670 (when (member keys nosave-but-article)
5671 (pop-to-buffer gnus-article-buffer)))
5672 ;; These commands should restore window configuration.
5673 (let ((obuf (current-buffer))
5674 (owin (current-window-configuration))
5676 win func in-buffer selected new-sum-start new-sum-hscroll)
5677 (cond (not-restore-window
5678 (pop-to-buffer gnus-article-current-summary))
5679 ((setq win (get-buffer-window gnus-article-current-summary))
5680 (select-window win))
5682 (switch-to-buffer gnus-article-current-summary 'norecord)))
5683 (setq in-buffer (current-buffer))
5684 ;; We disable the pick minor mode commands.
5685 (if (and (setq func (let (gnus-pick-mode)
5686 (lookup-key (current-local-map) keys)))
5689 (call-interactively func)
5690 (when (eq win (selected-window))
5691 (setq new-sum-point (point)
5692 new-sum-start (window-start win)
5693 new-sum-hscroll (window-hscroll win)))
5694 (when (eq in-buffer (current-buffer))
5695 (setq selected (gnus-summary-select-article))
5697 (unless not-restore-window
5698 (set-window-configuration owin))
5699 (when (eq selected 'old)
5701 (set-window-start (get-buffer-window (current-buffer))
5703 (set-window-point (get-buffer-window (current-buffer))
5705 (when (and (not not-restore-window)
5707 (set-window-point win new-sum-point)
5708 (set-window-start win new-sum-start)
5709 (set-window-hscroll win new-sum-hscroll))))
5710 (set-window-configuration owin)
5713 (defun gnus-article-describe-key (key)
5714 "Display documentation of the function invoked by KEY. KEY is a string."
5715 (interactive "kDescribe key: ")
5716 (gnus-article-check-buffer)
5717 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5719 (set-buffer gnus-article-current-summary)
5720 (let (gnus-pick-mode)
5721 (if (featurep 'xemacs)
5723 (push (elt key 0) unread-command-events)
5724 (setq key (events-to-keys
5725 (read-key-sequence "Describe key: "))))
5726 (setq unread-command-events
5728 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5729 (string-to-list key)))
5730 (setq key (read-key-sequence "Describe key: "))))
5732 (describe-key key)))
5734 (defun gnus-article-describe-key-briefly (key &optional insert)
5735 "Display documentation of the function invoked by KEY. KEY is a string."
5736 (interactive "kDescribe key: \nP")
5737 (gnus-article-check-buffer)
5738 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5740 (set-buffer gnus-article-current-summary)
5741 (let (gnus-pick-mode)
5742 (if (featurep 'xemacs)
5744 (push (elt key 0) unread-command-events)
5745 (setq key (events-to-keys
5746 (read-key-sequence "Describe key: "))))
5747 (setq unread-command-events
5749 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5750 (string-to-list key)))
5751 (setq key (read-key-sequence "Describe key: "))))
5752 (describe-key-briefly key insert))
5753 (describe-key-briefly key insert)))
5755 (defun gnus-article-reply-with-original (&optional wide)
5756 "Start composing a reply mail to the current message.
5757 The text in the region will be yanked. If the region isn't active,
5758 the entire article will be yanked."
5760 (let ((article (cdr gnus-article-current))
5762 (if (not (gnus-mark-active-p))
5763 (with-current-buffer gnus-summary-buffer
5764 (gnus-summary-reply (list (list article)) wide))
5765 (setq contents (buffer-substring (point) (mark t)))
5766 ;; Deactivate active regions.
5767 (when (and (boundp 'transient-mark-mode)
5768 transient-mark-mode)
5769 (setq mark-active nil))
5770 (with-current-buffer gnus-summary-buffer
5772 (list (list article contents)) wide)))))
5774 (defun gnus-article-followup-with-original ()
5775 "Compose a followup to the current article.
5776 The text in the region will be yanked. If the region isn't active,
5777 the entire article will be yanked."
5779 (let ((article (cdr gnus-article-current))
5781 (if (not (gnus-mark-active-p))
5782 (with-current-buffer gnus-summary-buffer
5783 (gnus-summary-followup (list (list article))))
5784 (setq contents (buffer-substring (point) (mark t)))
5785 ;; Deactivate active regions.
5786 (when (and (boundp 'transient-mark-mode)
5787 transient-mark-mode)
5788 (setq mark-active nil))
5789 (with-current-buffer gnus-summary-buffer
5790 (gnus-summary-followup
5791 (list (list article contents)))))))
5793 (defun gnus-article-hide (&optional arg force)
5794 "Hide all the gruft in the current article.
5795 This means that signatures, cited text and (some) headers will be
5797 If given a prefix, show the hidden text instead."
5798 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5799 (gnus-article-hide-headers arg)
5800 (gnus-article-hide-list-identifiers arg)
5801 (gnus-article-hide-citation-maybe arg force)
5802 (gnus-article-hide-signature arg))
5804 (defun gnus-article-maybe-highlight ()
5805 "Do some article highlighting if article highlighting is requested."
5806 (when (gnus-visual-p 'article-highlight 'highlight)
5807 (gnus-article-highlight-some)))
5809 (defun gnus-check-group-server ()
5810 ;; Make sure the connection to the server is alive.
5811 (unless (gnus-server-opened
5812 (gnus-find-method-for-group gnus-newsgroup-name))
5813 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5814 (gnus-request-group gnus-newsgroup-name t)))
5817 (autoload 'nneething-get-file-name "nneething"))
5819 (defun gnus-request-article-this-buffer (article group)
5820 "Get an article and insert it into this buffer."
5821 (let (do-update-line sparse-header)
5825 (gnus-kill-all-overlays)
5826 (setq group (or group gnus-newsgroup-name))
5828 ;; Using `gnus-request-article' directly will insert the article into
5829 ;; `nntp-server-buffer' - so we'll save some time by not having to
5830 ;; copy it from the server buffer into the article buffer.
5832 ;; We only request an article by message-id when we do not have the
5833 ;; headers for it, so we'll have to get those.
5834 (when (stringp article)
5835 (gnus-read-header article))
5837 ;; If the article number is negative, that means that this article
5838 ;; doesn't belong in this newsgroup (possibly), so we find its
5839 ;; message-id and request it by id instead of number.
5840 (when (and (numberp article)
5842 (get-buffer gnus-summary-buffer)
5843 (gnus-buffer-exists-p gnus-summary-buffer))
5845 (set-buffer gnus-summary-buffer)
5846 (let ((header (gnus-summary-article-header article)))
5849 ((memq article gnus-newsgroup-sparse)
5850 ;; This is a sparse gap article.
5851 (setq do-update-line article)
5852 (setq article (mail-header-id header))
5853 (setq sparse-header (gnus-read-header article))
5854 (setq gnus-newsgroup-sparse
5855 (delq article gnus-newsgroup-sparse)))
5857 ;; It's a real article.
5858 (setq article (mail-header-id header)))
5860 ;; It is an extracted pseudo-article.
5861 (setq article 'pseudo)
5862 (gnus-request-pseudo-article header))))
5864 (let ((method (gnus-find-method-for-group
5865 gnus-newsgroup-name)))
5866 (when (and (eq (car method) 'nneething)
5868 (let ((dir (nneething-get-file-name
5869 (mail-header-id header))))
5870 (when (and (stringp dir)
5871 (file-directory-p dir))
5872 (setq article 'nneething)
5873 (gnus-group-enter-directory dir))))))))
5876 ;; Refuse to select canceled articles.
5877 ((and (numberp article)
5879 (get-buffer gnus-summary-buffer)
5880 (gnus-buffer-exists-p gnus-summary-buffer)
5881 (eq (cdr (save-excursion
5882 (set-buffer gnus-summary-buffer)
5883 (assq article gnus-newsgroup-reads)))
5884 gnus-canceled-mark))
5886 ;; We first check `gnus-original-article-buffer'.
5887 ((and (get-buffer gnus-original-article-buffer)
5890 (set-buffer gnus-original-article-buffer)
5891 (and (equal (car gnus-original-article) group)
5892 (eq (cdr gnus-original-article) article))))
5893 (insert-buffer-substring gnus-original-article-buffer)
5895 ;; Check the backlog.
5896 ((and gnus-keep-backlog
5897 (gnus-backlog-request-article group article (current-buffer)))
5899 ;; Check asynchronous pre-fetch.
5900 ((gnus-async-request-fetched-article group article (current-buffer))
5901 (gnus-async-prefetch-next group article gnus-summary-buffer)
5902 (when (and (numberp article) gnus-keep-backlog)
5903 (gnus-backlog-enter-article group article (current-buffer)))
5906 ((and gnus-use-cache
5908 (gnus-cache-request-article article group))
5910 ;; Check the agent cache.
5911 ((gnus-agent-request-article article group)
5913 ;; Get the article and put into the article buffer.
5914 ((or (stringp article)
5916 (let ((gnus-override-method gnus-override-method)
5917 (methods (and (stringp article)
5918 gnus-refer-article-method))
5919 (backend (car (gnus-find-method-for-group
5920 gnus-newsgroup-name)))
5922 (inhibit-read-only t))
5923 (if (or (not (listp methods))
5924 (and (symbolp (car methods))
5925 (assq (car methods) nnoo-definition-alist)))
5926 (setq methods (list methods)))
5927 (when (and (null gnus-override-method)
5929 (setq gnus-override-method (pop methods)))
5931 (when (eq gnus-override-method 'current)
5932 (setq gnus-override-method
5933 (with-current-buffer gnus-summary-buffer
5934 gnus-current-select-method)))
5936 (gnus-kill-all-overlays)
5937 (let ((gnus-newsgroup-name group))
5938 (gnus-check-group-server))
5940 ((gnus-request-article article group (current-buffer))
5941 (when (numberp article)
5942 (gnus-async-prefetch-next group article
5943 gnus-summary-buffer)
5944 (when gnus-keep-backlog
5945 (gnus-backlog-enter-article
5946 group article (current-buffer))))
5947 (setq result 'article))
5949 (setq gnus-override-method (pop methods)))
5950 ((not (string-match "^400 "
5951 (nnheader-get-report backend)))
5952 ;; If we get 400 server disconnect, reconnect and
5953 ;; retry; otherwise, assume the article has expired.
5954 (setq result 'done))))
5955 (and (eq result 'article) 'article)))
5959 ;; Associate this article with the current summary buffer.
5960 (setq gnus-article-current-summary gnus-summary-buffer)
5962 ;; Take the article from the original article buffer
5963 ;; and place it in the buffer it's supposed to be in.
5964 (when (and (get-buffer gnus-article-buffer)
5965 (equal (buffer-name (current-buffer))
5966 (buffer-name (get-buffer gnus-article-buffer))))
5968 (if (get-buffer gnus-original-article-buffer)
5969 (set-buffer gnus-original-article-buffer)
5970 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5971 (buffer-disable-undo)
5972 (setq major-mode 'gnus-original-article-mode)
5973 (setq buffer-read-only t))
5974 (let ((inhibit-read-only t))
5976 (insert-buffer-substring gnus-article-buffer))
5977 (setq gnus-original-article (cons group article)))
5980 (run-hooks 'gnus-article-decode-hook)
5981 ;; Mark article as decoded or not.
5982 (setq gnus-article-decoded-p gnus-article-decode-hook))
5984 ;; Update sparse articles.
5985 (when (and do-update-line
5986 (or (numberp article)
5988 (let ((buf (current-buffer)))
5989 (set-buffer gnus-summary-buffer)
5990 (gnus-summary-update-article do-update-line sparse-header)
5991 (gnus-summary-goto-subject do-update-line nil t)
5992 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5994 (set-buffer buf))))))
6000 (defcustom gnus-article-edit-mode-hook nil
6001 "Hook run in article edit mode buffers."
6002 :group 'gnus-article-various
6005 (defvar gnus-article-edit-done-function nil)
6007 (defvar gnus-article-edit-mode-map nil)
6008 (defvar gnus-article-edit-mode nil)
6010 ;; Should we be using derived.el for this?
6011 (unless gnus-article-edit-mode-map
6012 (setq gnus-article-edit-mode-map (make-keymap))
6013 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6015 (gnus-define-keys gnus-article-edit-mode-map
6016 "\C-c?" describe-mode
6017 "\C-c\C-c" gnus-article-edit-done
6018 "\C-c\C-k" gnus-article-edit-exit
6019 "\C-c\C-f\C-t" message-goto-to
6020 "\C-c\C-f\C-o" message-goto-from
6021 "\C-c\C-f\C-b" message-goto-bcc
6022 ;;"\C-c\C-f\C-w" message-goto-fcc
6023 "\C-c\C-f\C-c" message-goto-cc
6024 "\C-c\C-f\C-s" message-goto-subject
6025 "\C-c\C-f\C-r" message-goto-reply-to
6026 "\C-c\C-f\C-n" message-goto-newsgroups
6027 "\C-c\C-f\C-d" message-goto-distribution
6028 "\C-c\C-f\C-f" message-goto-followup-to
6029 "\C-c\C-f\C-m" message-goto-mail-followup-to
6030 "\C-c\C-f\C-k" message-goto-keywords
6031 "\C-c\C-f\C-u" message-goto-summary
6032 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6033 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6034 "\C-c\C-b" message-goto-body
6035 "\C-c\C-i" message-goto-signature
6037 "\C-c\C-t" message-insert-to
6038 "\C-c\C-n" message-insert-newsgroups
6039 "\C-c\C-o" message-sort-headers
6040 "\C-c\C-e" message-elide-region
6041 "\C-c\C-v" message-delete-not-region
6042 "\C-c\C-z" message-kill-to-signature
6043 "\M-\r" message-newline-and-reformat
6044 "\C-c\C-a" mml-attach-file
6045 "\C-a" message-beginning-of-line
6047 "\M-;" comment-region)
6049 (gnus-define-keys (gnus-article-edit-wash-map
6050 "\C-c\C-w" gnus-article-edit-mode-map)
6051 "f" gnus-article-edit-full-stops))
6054 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6056 ["Fetch To" message-insert-to t]
6057 ["Fetch Newsgroups" message-insert-newsgroups t]
6059 ["To" message-goto-to t]
6060 ["From" message-goto-from t]
6061 ["Subject" message-goto-subject t]
6062 ["Cc" message-goto-cc t]
6063 ["Reply-To" message-goto-reply-to t]
6064 ["Summary" message-goto-summary t]
6065 ["Keywords" message-goto-keywords t]
6066 ["Newsgroups" message-goto-newsgroups t]
6067 ["Followup-To" message-goto-followup-to t]
6068 ["Mail-Followup-To" message-goto-mail-followup-to t]
6069 ["Distribution" message-goto-distribution t]
6070 ["Body" message-goto-body t]
6071 ["Signature" message-goto-signature t]))
6073 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6074 "Major mode for editing articles.
6075 This is an extended text-mode.
6077 \\{gnus-article-edit-mode-map}"
6078 (make-local-variable 'gnus-article-edit-done-function)
6079 (make-local-variable 'gnus-prev-winconf)
6080 (set (make-local-variable 'font-lock-defaults)
6081 '(message-font-lock-keywords t))
6082 (set (make-local-variable 'mail-header-separator) "")
6083 (set (make-local-variable 'gnus-article-edit-mode) t)
6084 (easy-menu-add message-mode-field-menu message-mode-map)
6086 (setq buffer-read-only nil)
6087 (buffer-enable-undo)
6090 (defun gnus-article-edit (&optional force)
6091 "Edit the current article.
6092 This will have permanent effect only in mail groups.
6093 If FORCE is non-nil, allow editing of articles even in read-only
6096 (when (and (not force)
6097 (gnus-group-read-only-p))
6098 (error "The current newsgroup does not support article editing"))
6099 (gnus-article-date-original)
6100 (gnus-article-edit-article
6102 `(lambda (no-highlight)
6104 (gnus-summary-edit-article-done
6105 ,(or (mail-header-references gnus-current-headers) "")
6106 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6108 (defun gnus-article-edit-article (start-func exit-func)
6109 "Start editing the contents of the current article buffer."
6110 (let ((winconf (current-window-configuration)))
6111 (set-buffer gnus-article-buffer)
6112 (let ((message-auto-save-directory
6113 ;; Don't associate the article buffer with a draft file.
6115 (gnus-article-edit-mode))
6116 (funcall start-func)
6117 (set-buffer-modified-p nil)
6118 (gnus-configure-windows 'edit-article)
6119 (setq gnus-article-edit-done-function exit-func)
6120 (setq gnus-prev-winconf winconf)
6121 (gnus-message 6 "C-c C-c to end edits")))
6123 (defun gnus-article-edit-done (&optional arg)
6124 "Update the article edits and exit."
6126 (let ((func gnus-article-edit-done-function)
6127 (buf (current-buffer))
6128 (start (window-start))
6130 (winconf gnus-prev-winconf))
6131 (widen) ;; Widen it in case that users narrowed the buffer.
6134 ;; The cache and backlog have to be flushed somewhat.
6135 (when gnus-keep-backlog
6136 (gnus-backlog-remove-article
6137 (car gnus-article-current) (cdr gnus-article-current)))
6138 ;; Flush original article as well.
6140 (when (get-buffer gnus-original-article-buffer)
6141 (set-buffer gnus-original-article-buffer)
6142 (setq gnus-original-article nil)))
6143 (when gnus-use-cache
6144 (gnus-cache-update-article
6145 (car gnus-article-current) (cdr gnus-article-current)))
6146 ;; We remove all text props from the article buffer.
6147 (kill-all-local-variables)
6148 (gnus-set-text-properties (point-min) (point-max) nil)
6150 (set-window-configuration winconf)
6152 (set-window-start (get-buffer-window buf) start)
6153 (set-window-point (get-buffer-window buf) (point)))
6154 (gnus-summary-show-article))
6156 (defun gnus-article-edit-exit ()
6157 "Exit the article editing without updating."
6159 (when (or (not (buffer-modified-p))
6160 (yes-or-no-p "Article modified; kill anyway? "))
6161 (let ((curbuf (current-buffer))
6163 (window-start (window-start)))
6165 (if (gnus-buffer-live-p gnus-original-article-buffer)
6166 (insert-buffer-substring gnus-original-article-buffer))
6167 (let ((winconf gnus-prev-winconf))
6168 (kill-all-local-variables)
6170 (set-window-configuration winconf)
6171 ;; Tippy-toe some to make sure that point remains where it was.
6172 (save-current-buffer
6174 (set-window-start (get-buffer-window (current-buffer)) window-start)
6176 (gnus-summary-show-article)))
6178 (defun gnus-article-edit-full-stops ()
6179 "Interactively repair spacing at end of sentences."
6182 (goto-char (point-min))
6183 (search-forward-regexp "^$" nil t)
6184 (let ((case-fold-search nil))
6185 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6188 ;;; Article highlights
6191 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6193 ;;; Internal Variables:
6195 (defcustom gnus-button-url-regexp
6196 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6197 "\\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:]]\\)"
6198 "\\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\\)\\)")
6199 "Regular expression that matches URLs."
6200 :group 'gnus-article-buttons
6203 (defcustom gnus-button-valid-fqdn-regexp
6204 message-valid-fqdn-regexp
6205 "Regular expression that matches a valid FQDN."
6207 :group 'gnus-article-buttons
6210 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6211 (defcustom gnus-button-valid-localpart-regexp
6212 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6213 "Regular expression that matches a localpart of mail addresses or MIDs."
6215 :group 'gnus-article-buttons
6218 (defcustom gnus-button-man-handler 'manual-entry
6219 "Function to use for displaying man pages.
6220 The function must take at least one argument with a string naming the
6223 :type '(choice (function-item :tag "Man" manual-entry)
6224 (function-item :tag "Woman" woman)
6225 (function :tag "Other"))
6226 :group 'gnus-article-buttons)
6228 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6229 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6230 If the default site is too slow, try to find a CTAN mirror, see
6231 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6232 the variable `gnus-button-handle-ctan'."
6234 :group 'gnus-article-buttons
6235 :link '(custom-manual "(gnus)Group Parameters")
6236 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6237 (const "http://tug.ctan.org/tex-archive/")
6238 (const "http://www.dante.de/CTAN/")
6239 (string :tag "Other")))
6241 (defcustom gnus-button-ctan-handler 'browse-url
6242 "Function to use for displaying CTAN links.
6243 The function must take one argument, the string naming the URL."
6245 :type '(choice (function-item :tag "Browse Url" browse-url)
6246 (function :tag "Other"))
6247 :group 'gnus-article-buttons)
6249 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6250 "Bogus strings removed from CTAN URLs."
6252 :group 'gnus-article-buttons
6253 :type '(choice (const "^/?tex-archive/\\|/")
6254 (regexp :tag "Other")))
6256 (defcustom gnus-button-ctan-directory-regexp
6258 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6259 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6260 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6261 "tds" "tools" "usergrps" "web") t)
6262 "Regular expression for ctan directories.
6263 It should match all directories in the top level of `gnus-ctan-url'."
6265 :group 'gnus-article-buttons
6268 (defcustom gnus-button-mid-or-mail-regexp
6269 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6270 gnus-button-valid-fqdn-regexp
6272 "Regular expression that matches a message ID or a mail address."
6274 :group 'gnus-article-buttons
6277 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6278 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6279 Strings like this can be either a message ID or a mail address. If it is one
6280 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6281 message ID or a mail address, respectively. If this variable is set to the
6282 symbol `ask', always query the user what do do. If it is a function, this
6283 function will be called with the string as its only argument. The function
6284 must return `mid', `mail', `invalid' or `ask'."
6286 :group 'gnus-article-buttons
6287 :type '(choice (function-item :tag "Heuristic function"
6288 gnus-button-mid-or-mail-heuristic)
6293 (defcustom gnus-button-mid-or-mail-heuristic-alist
6294 '((-10.0 . ".+\\$.+@")
6297 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6298 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6299 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6300 (-1.0 . "^[^a-z]+@")
6302 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6303 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6304 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6305 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6308 (-1.0 . "^[0-9][0-9]")
6310 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6311 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6312 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6313 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6315 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6316 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6319 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6321 ;; compensation for TDMA dated mail addresses:
6322 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6324 (-20.0 . "\\.fsf@") ;; Gnus
6327 (-20.0 . "_-_") ;; Subject change in thread
6329 (-20.0 . "\\.ln@") ;; leafnode
6330 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6331 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6333 ;; (5.0 . "") ;; $local_part_len <= 7
6334 (10.0 . "^[^0-9]+@")
6335 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6336 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6339 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6341 (0.5 . "^[A-Z][a-z]")
6342 (0.5 . "^[A-Z][a-z][a-z]")
6343 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6344 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6345 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6347 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6348 address. The REGEXP is processed with `case-fold-search' set to nil."
6350 :group 'gnus-article-buttons
6351 :type '(repeat (cons (number :tag "Rate")
6352 (regexp :tag "Regexp"))))
6354 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6355 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6356 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6357 address, `ask' if unsure and `invalid' if the string is invalid."
6358 (let ((case-fold-search nil)
6359 (list gnus-button-mid-or-mail-heuristic-alist)
6360 (result 0) rate regexp lpartlen elem)
6362 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6363 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6364 ;; Certain special cases...
6367 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6368 "^[0-9]+\\.[0-9]+@compuserve\\|"
6369 "@public\\.gmane\\.org")
6371 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6372 (setq result 'mail))
6373 (when (string-match "@.*@\\| " mid-or-mail)
6374 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6375 (setq result 'invalid))
6376 ;; Nothing more to do, if result is not a number here...
6377 (when (numberp result)
6379 (setq elem (car list)
6383 (when (string-match regexp mid-or-mail)
6384 (setq result (+ result rate))
6386 9 "`%s' matched `%s', rate `%s', result `%s'."
6387 mid-or-mail regexp rate result)))
6388 (when (<= lpartlen 7)
6389 (setq result (+ result 5.0))
6390 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6391 mid-or-mail result))
6392 (when (>= lpartlen 12)
6393 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6395 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6396 ;; Long local part should contain realname if e-mail address,
6397 ;; too many digits: message-id.
6398 ;; $score -= 5.0 + 0.1 * $local_part_len;
6399 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6400 (setq result (+ result rate))
6402 9 "Many digits in `%s', rate `%s', result `%s'."
6403 mid-or-mail rate result))
6404 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6406 ;; Too few vowels [^aeiouy]{4,}.*\@
6407 (setq result (+ result -5.0))
6409 9 "Few vowels in `%s', rate `%s', result `%s'."
6410 mid-or-mail -5.0 result))
6412 (setq result (+ result 5.0))
6414 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6415 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6416 ;; Maybe we should make this a customizable alist: (condition . 'result)
6418 ((symbolp result) result)
6419 ;; Now convert number into proper results:
6420 ((< result -10.0) 'mid)
6421 ((> result 10.0) 'mail)
6424 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6425 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6426 (url-mid (concat "news" ":" mid-or-mail))
6427 (url-mailto (concat "mailto" ":" mid-or-mail)))
6428 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6429 (when (fboundp pref)
6431 ;; get rid of surrounding angles...
6433 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6434 (if (or (eq 'mid guessed) (eq 'mail guessed))
6438 (save-window-excursion
6439 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6442 (cond ((eq pref 'mid)
6443 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6444 (gnus-button-handle-news url-mid))
6446 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6447 (gnus-url-mailto url-mailto))
6448 (t (gnus-message 3 "Invalid string.")))))
6450 (defun gnus-button-handle-custom (url)
6451 "Follow a Custom URL."
6452 (customize-apropos (gnus-url-unhex-string url)))
6454 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6456 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6459 (defun gnus-button-handle-describe-function (url)
6460 "Call `describe-function' when pushing the corresponding URL button."
6463 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6465 (defun gnus-button-handle-describe-variable (url)
6466 "Call `describe-variable' when pushing the corresponding URL button."
6469 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6471 (defun gnus-button-handle-symbol (url)
6472 "Display help on variable or function.
6473 Calls `describe-variable' or `describe-function'."
6474 (let ((sym (intern url)))
6476 ((fboundp sym) (describe-function sym))
6477 ((boundp sym) (describe-variable sym))
6478 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6480 (defun gnus-button-handle-describe-key (url)
6481 "Call `describe-key' when pushing the corresponding URL button."
6483 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6484 (keys (ignore-errors (eval `(kbd ,key-string)))))
6487 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6489 (defun gnus-button-handle-apropos (url)
6490 "Call `apropos' when pushing the corresponding URL button."
6491 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6493 (defun gnus-button-handle-apropos-command (url)
6494 "Call `apropos' when pushing the corresponding URL button."
6496 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6498 (defun gnus-button-handle-apropos-variable (url)
6499 "Call `apropos' when pushing the corresponding URL button."
6501 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6502 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6504 (defun gnus-button-handle-apropos-documentation (url)
6505 "Call `apropos' when pushing the corresponding URL button."
6507 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6508 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6510 (defun gnus-button-handle-library (url)
6511 "Call `locate-library' when pushing the corresponding URL button."
6512 (gnus-message 9 "url=`%s'" url)
6513 (let* ((lib (locate-library url))
6514 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6516 (gnus-message 1 "Cannot locale library `%s'." url)
6517 (find-file-read-only file))))
6519 (defun gnus-button-handle-ctan (url)
6520 "Call `browse-url' when pushing a CTAN URL button."
6522 gnus-button-ctan-handler
6525 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6527 (defcustom gnus-button-tex-level 5
6528 "*Integer that says how many TeX-related buttons Gnus will show.
6529 The higher the number, the more buttons will appear and the more false
6530 positives are possible. Note that you can set this variable local to
6531 specific groups. Setting it higher in TeX groups is probably a good idea.
6532 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6533 how to set variables in specific groups."
6535 :group 'gnus-article-buttons
6536 :link '(custom-manual "(gnus)Group Parameters")
6539 (defcustom gnus-button-man-level 5
6540 "*Integer that says how many man-related buttons Gnus will show.
6541 The higher the number, the more buttons will appear and the more false
6542 positives are possible. Note that you can set this variable local to
6543 specific groups. Setting it higher in Unix groups is probably a good idea.
6544 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6545 how to set variables in specific groups."
6547 :group 'gnus-article-buttons
6548 :link '(custom-manual "(gnus)Group Parameters")
6551 (defcustom gnus-button-emacs-level 5
6552 "*Integer that says how many emacs-related buttons Gnus will show.
6553 The higher the number, the more buttons will appear and the more false
6554 positives are possible. Note that you can set this variable local to
6555 specific groups. Setting it higher in Emacs or Gnus related groups is
6556 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6557 `gnus-parameters' on how to set variables in specific groups."
6559 :group 'gnus-article-buttons
6560 :link '(custom-manual "(gnus)Group Parameters")
6563 (defcustom gnus-button-message-level 5
6564 "*Integer that says how many buttons for news or mail messages will appear.
6565 The higher the number, the more buttons will appear and the more false
6566 positives are possible."
6567 ;; mail addresses, MIDs, URLs for news, ...
6569 :group 'gnus-article-buttons
6572 (defcustom gnus-button-browse-level 5
6573 "*Integer that says how many buttons for browsing will appear.
6574 The higher the number, the more buttons will appear and the more false
6575 positives are possible."
6576 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6578 :group 'gnus-article-buttons
6581 (defcustom gnus-button-alist
6582 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6583 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6584 ((concat "\\b\\(nntp\\|news\\):\\("
6585 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6586 0 t gnus-button-handle-news 2)
6587 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6588 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6589 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6590 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6591 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6592 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6593 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6594 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6595 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6596 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6597 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6598 ;; RFC 2368 (The mailto URL scheme)
6599 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6600 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6601 ("\\bmailto:\\([^ \n\t]+\\)"
6602 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6604 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6605 gnus-button-ctan-directory-regexp
6606 "[^][>)!;:,'\n\t ]+\\)")
6607 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6608 ((concat "\\btex-archive/\\("
6609 gnus-button-ctan-directory-regexp
6610 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6611 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6614 gnus-button-ctan-directory-regexp
6615 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6616 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6617 ;; This is info (home-grown style) <info://foo/bar+baz>
6618 ("\\binfo://\\([^'\">\n\t ]+\\)"
6619 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6620 ;; Info GNOME style <info:foo#bar_baz>
6621 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6623 ;; Info KDE style <info:(foo)bar baz>
6624 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6625 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6626 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6627 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6628 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6629 ;; Info links like `C-h i d m CC Mode RET'
6630 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6632 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6633 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6634 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6635 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6636 ;; Emacs help commands
6637 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6638 ;; regexp doesn't match arguments containing ` '.
6639 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6640 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6641 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6642 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6643 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6644 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6645 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6646 ;; The following entries may lead to many false positives so don't enable
6647 ;; them by default (use a high button level).
6648 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6649 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6650 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6651 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6652 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6653 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6654 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6655 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6656 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6657 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6658 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6659 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6660 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6661 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6662 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6663 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6664 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6665 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6666 ;; Unlike the other regexps we really have to require quoting
6667 ;; here to determine where it ends.
6668 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6669 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6670 ("<URL: *\\([^<>]*\\)>"
6671 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6672 ;; RFC 2396 (2.4.3., delims) ...
6673 ("\"URL: *\\([^\"]*\\)\""
6674 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6675 ;; RFC 2396 (2.4.3., delims) ...
6676 ("\"URL: *\\([^\"]*\\)\""
6677 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6679 (gnus-button-url-regexp
6680 0 (>= gnus-button-browse-level 0) browse-url 0)
6682 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6683 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6684 gnus-button-handle-man 1)
6685 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6686 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6687 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6688 gnus-button-handle-man 1)
6689 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6690 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6691 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6692 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6693 ;; MID or mail: To avoid too many false positives we don't try to catch
6694 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6695 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6696 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6697 ;; so that non-ambiguous entries (see above) match first.
6698 (gnus-button-mid-or-mail-regexp
6699 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6700 "*Alist of regexps matching buttons in article bodies.
6702 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6703 REGEXP: is the string (case insensitive) matching text around the button (can
6704 also be Lisp expression evaluating to a string),
6705 BUTTON: is the number of the regexp grouping actually matching the button,
6706 FORM: is a Lisp expression which must eval to true for the button to
6708 CALLBACK: is the function to call when the user push this button, and each
6709 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6711 CALLBACK can also be a variable, in that case the value of that
6712 variable it the real callback function."
6713 :group 'gnus-article-buttons
6714 :type '(repeat (list (choice regexp variable sexp)
6715 (integer :tag "Button")
6717 (function :tag "Callback")
6720 (integer :tag "Regexp group")))))
6721 (put 'gnus-button-alist 'risky-local-variable t)
6723 (defcustom gnus-header-button-alist
6724 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6725 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6726 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6727 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6728 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6729 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6730 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6731 0 (>= gnus-button-browse-level 0) browse-url 0)
6732 ("^Subject:" gnus-button-url-regexp
6733 0 (>= gnus-button-browse-level 0) browse-url 0)
6734 ("^[^:]+:" gnus-button-url-regexp
6735 0 (>= gnus-button-browse-level 0) browse-url 0)
6736 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6737 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6738 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6739 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6740 "*Alist of headers and regexps to match buttons in article heads.
6742 This alist is very similar to `gnus-button-alist', except that each
6743 alist has an additional HEADER element first in each entry:
6745 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6747 HEADER is a regexp to match a header. For a fuller explanation, see
6748 `gnus-button-alist'."
6749 :group 'gnus-article-buttons
6750 :group 'gnus-article-headers
6751 :type '(repeat (list (regexp :tag "Header")
6752 (choice regexp variable)
6753 (integer :tag "Button")
6755 (function :tag "Callback")
6758 (integer :tag "Regexp group")))))
6759 (put 'gnus-header-button-alist 'risky-local-variable t)
6763 (defun gnus-article-push-button (event)
6764 "Check text under the mouse pointer for a callback function.
6765 If the text under the mouse pointer has a `gnus-callback' property,
6766 call it with the value of the `gnus-data' text property."
6768 (set-buffer (window-buffer (posn-window (event-start event))))
6769 (let* ((pos (posn-point (event-start event)))
6770 (data (get-text-property pos 'gnus-data))
6771 (fun (get-text-property pos 'gnus-callback)))
6774 (funcall fun data))))
6776 (defun gnus-article-press-button ()
6777 "Check text at point for a callback function.
6778 If the text at point has a `gnus-callback' property,
6779 call it with the value of the `gnus-data' text property."
6781 (let ((data (get-text-property (point) 'gnus-data))
6782 (fun (get-text-property (point) 'gnus-callback)))
6784 (funcall fun data))))
6786 (defun gnus-article-highlight (&optional force)
6787 "Highlight current article.
6788 This function calls `gnus-article-highlight-headers',
6789 `gnus-article-highlight-citation',
6790 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6791 do the highlighting. See the documentation for those functions."
6792 (interactive (list 'force))
6793 (gnus-article-highlight-headers)
6794 (gnus-article-highlight-citation force)
6795 (gnus-article-highlight-signature)
6796 (gnus-article-add-buttons force)
6797 (gnus-article-add-buttons-to-head))
6799 (defun gnus-article-highlight-some (&optional force)
6800 "Highlight current article.
6801 This function calls `gnus-article-highlight-headers',
6802 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6803 do the highlighting. See the documentation for those functions."
6804 (interactive (list 'force))
6805 (gnus-article-highlight-headers)
6806 (gnus-article-highlight-signature)
6807 (gnus-article-add-buttons))
6809 (defun gnus-article-highlight-headers ()
6810 "Highlight article headers as specified by `gnus-header-face-alist'."
6813 (set-buffer gnus-article-buffer)
6815 (let ((alist gnus-header-face-alist)
6816 (inhibit-read-only t)
6817 (case-fold-search t)
6818 (inhibit-point-motion-hooks t)
6819 entry regexp header-face field-face from hpoints fpoints)
6820 (article-narrow-to-head)
6821 (while (setq entry (pop alist))
6822 (goto-char (point-min))
6823 (setq regexp (concat "^\\("
6824 (if (string-equal "" (nth 0 entry))
6828 header-face (nth 1 entry)
6829 field-face (nth 2 entry))
6830 (while (and (re-search-forward regexp nil t)
6834 (unless (search-forward ":" nil t)
6836 (when (and header-face
6837 (not (memq (point) hpoints)))
6838 (push (point) hpoints)
6839 (gnus-put-text-property from (point) 'face header-face))
6840 (when (and field-face
6841 (not (memq (setq from (point)) fpoints)))
6843 (if (re-search-forward "^[^ \t]" nil t)
6845 (goto-char (point-max)))
6846 (gnus-put-text-property from (point) 'face field-face))))))))
6848 (defun gnus-article-highlight-signature ()
6849 "Highlight the signature in an article.
6850 It does this by highlighting everything after
6851 `gnus-signature-separator' using the face `gnus-signature'."
6854 (set-buffer gnus-article-buffer)
6855 (let ((inhibit-read-only t)
6856 (inhibit-point-motion-hooks t))
6858 (when (and gnus-signature-face
6859 (gnus-article-narrow-to-signature))
6860 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6861 'face gnus-signature-face)
6863 (gnus-article-search-signature)
6864 (let ((start (match-beginning 0))
6865 (end (set-marker (make-marker) (1+ (match-end 0)))))
6866 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6869 (defun gnus-button-in-region-p (b e prop)
6870 "Say whether PROP exists in the region."
6871 (text-property-not-all b e prop nil))
6873 (defun gnus-article-add-buttons (&optional force)
6874 "Find external references in the article and make buttons of them.
6875 \"External references\" are things like Message-IDs and URLs, as
6876 specified by `gnus-button-alist'."
6877 (interactive (list 'force))
6879 (set-buffer gnus-article-buffer)
6880 (let ((inhibit-read-only t)
6881 (inhibit-point-motion-hooks t)
6882 (case-fold-search t)
6883 (alist gnus-button-alist)
6885 ;; Remove all old markers.
6886 (let (marker entry new-list)
6887 (while (setq marker (pop gnus-button-marker-list))
6888 (if (or (< marker (point-min)) (>= marker (point-max)))
6889 (push marker new-list)
6891 (when (setq entry (gnus-button-entry))
6892 (put-text-property (match-beginning (nth 1 entry))
6893 (match-end (nth 1 entry))
6894 'gnus-callback nil))
6895 (set-marker marker nil)))
6896 (setq gnus-button-marker-list new-list))
6897 ;; We skip the headers.
6900 (while (setq entry (pop alist))
6901 (setq regexp (eval (car entry)))
6903 (while (re-search-forward regexp nil t)
6904 (let* ((start (and entry (match-beginning (nth 1 entry))))
6905 (end (and entry (match-end (nth 1 entry))))
6906 (from (match-beginning 0)))
6907 (when (and (or (eq t (nth 2 entry))
6908 (eval (nth 2 entry)))
6909 (not (gnus-button-in-region-p
6910 start end 'gnus-callback)))
6911 ;; That optional form returned non-nil, so we add the
6913 (gnus-article-add-button
6914 start end 'gnus-button-push
6915 (car (push (set-marker (make-marker) from)
6916 gnus-button-marker-list))))))))))
6918 ;; Add buttons to the head of an article.
6919 (defun gnus-article-add-buttons-to-head ()
6920 "Add buttons to the head of the article."
6923 (set-buffer gnus-article-buffer)
6925 (let ((inhibit-read-only t)
6926 (inhibit-point-motion-hooks t)
6927 (case-fold-search t)
6928 (alist gnus-header-button-alist)
6930 (article-narrow-to-head)
6932 ;; Each alist entry.
6933 (setq entry (car alist)
6935 (goto-char (point-min))
6936 (while (re-search-forward (car entry) nil t)
6937 ;; Each header matching the entry.
6938 (setq beg (match-beginning 0))
6939 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6940 (match-beginning 0))
6943 (while (re-search-forward (eval (nth 1 entry)) end t)
6944 ;; Each match within a header.
6945 (let* ((entry (cdr entry))
6946 (start (match-beginning (nth 1 entry)))
6947 (end (match-end (nth 1 entry)))
6948 (form (nth 2 entry)))
6949 (goto-char (match-end 0))
6951 (gnus-article-add-button
6952 start end (nth 3 entry)
6953 (buffer-substring (match-beginning (nth 4 entry))
6954 (match-end (nth 4 entry)))))))
6955 (goto-char end)))))))
6957 ;;; External functions:
6959 (defun gnus-article-add-button (from to fun &optional data)
6960 "Create a button between FROM and TO with callback FUN and data DATA."
6961 (when gnus-article-button-face
6962 (gnus-overlay-put (gnus-make-overlay from to)
6963 'face gnus-article-button-face))
6964 (gnus-add-text-properties
6966 (nconc (and gnus-article-mouse-face
6967 (list gnus-mouse-face-prop gnus-article-mouse-face))
6968 (list 'gnus-callback fun)
6969 (and data (list 'gnus-data data))))
6970 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6971 :button-keymap gnus-widget-button-keymap))
6973 ;;; Internal functions:
6975 (defun gnus-article-set-globals ()
6977 (set-buffer gnus-summary-buffer)
6978 (gnus-set-global-variables)))
6980 (defun gnus-signature-toggle (end)
6982 (set-buffer gnus-article-buffer)
6983 (let ((inhibit-read-only t)
6984 (inhibit-point-motion-hooks t))
6985 (if (text-property-any end (point-max) 'article-type 'signature)
6987 (gnus-delete-wash-type 'signature)
6988 (gnus-remove-text-properties-when
6989 'article-type 'signature end (point-max)
6990 (cons 'article-type (cons 'signature
6991 gnus-hidden-properties))))
6992 (gnus-add-wash-type 'signature)
6993 (gnus-add-text-properties-when
6994 'article-type nil end (point-max)
6995 (cons 'article-type (cons 'signature
6996 gnus-hidden-properties)))))
6997 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6998 (gnus-set-mode-line 'article))))
7000 (defun gnus-button-entry ()
7001 ;; Return the first entry in `gnus-button-alist' matching this place.
7002 (let ((alist gnus-button-alist)
7005 (setq entry (pop alist))
7006 (if (looking-at (eval (car entry)))
7011 (defun gnus-button-push (marker)
7012 ;; Push button starting at MARKER.
7015 (let* ((entry (gnus-button-entry))
7016 (inhibit-point-motion-hooks t)
7018 (args (mapcar (lambda (group)
7019 (let ((string (match-string group)))
7020 (gnus-set-text-properties
7021 0 (length string) nil string)
7028 (fboundp (symbol-value fun)))
7029 (apply (symbol-value fun) args))
7031 (gnus-message 1 "You must define `%S' to use this button"
7032 (cons fun args)))))))
7034 (defun gnus-parse-news-url (url)
7035 (let (scheme server port group message-id articles)
7038 (goto-char (point-min))
7039 (when (looking-at "\\([A-Za-z]+\\):")
7040 (setq scheme (match-string 1))
7041 (goto-char (match-end 0)))
7042 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7043 (setq server (match-string 1))
7044 (setq port (if (stringp (match-string 3))
7045 (string-to-number (match-string 3))
7047 (goto-char (match-end 0)))
7050 ((looking-at "\\(.*@.*\\)")
7051 (setq message-id (match-string 1)))
7052 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7053 (setq group (match-string 1)
7054 articles (split-string (match-string 2) "-")))
7055 ((looking-at "\\([^/]+\\)/?")
7056 (setq group (match-string 1)))
7058 (error "Unknown news URL syntax"))))
7059 (list scheme server port group message-id articles)))
7061 (defun gnus-button-handle-news (url)
7063 (destructuring-bind (scheme server port group message-id articles)
7064 (gnus-parse-news-url url)
7068 (set-buffer gnus-summary-buffer)
7070 (let ((gnus-refer-article-method
7071 (nconc (list (list 'nntp server))
7072 gnus-refer-article-method))
7073 (nntp-port-number (or port "nntp")))
7074 (gnus-message 7 "Fetching %s with %s"
7075 message-id gnus-refer-article-method)
7076 (gnus-summary-refer-article message-id))
7077 (gnus-summary-refer-article message-id))))
7079 (gnus-button-fetch-group url)))))
7081 (defun gnus-button-handle-man (url)
7083 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7084 (when (eq gnus-button-man-handler 'woman)
7085 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7086 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7087 (funcall gnus-button-man-handler url))
7089 (defun gnus-button-handle-info-url (url)
7090 "Fetch an info URL."
7091 (setq url (mm-subst-char-in-string ?+ ?\ url))
7093 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7094 (gnus-info-find-node
7095 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7097 ")" (gnus-url-unhex-string (match-string 2 url)))))
7098 ((string-match "([^)\"]+)[^\"]+" url)
7100 (gnus-replace-in-string
7101 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7102 (gnus-info-find-node url))
7103 (t (error "Can't parse %s" url))))
7105 (defun gnus-button-handle-info-url-gnome (url)
7106 "Fetch GNOME style info URL."
7107 (setq url (mm-subst-char-in-string ?_ ?\ url))
7108 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7109 (gnus-info-find-node
7111 (gnus-url-unhex-string
7112 (match-string 1 url))
7114 (or (gnus-url-unhex-string
7115 (match-string 2 url))
7117 (error "Can't parse %s" url)))
7119 (defun gnus-button-handle-info-url-kde (url)
7120 "Fetch KDE style info URL."
7121 (gnus-info-find-node (gnus-url-unhex-string url)))
7123 (defun gnus-button-handle-info-keystrokes (url)
7124 "Call `info' when pushing the corresponding URL button."
7125 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7130 (defun gnus-button-message-id (message-id)
7133 (set-buffer gnus-summary-buffer)
7134 (gnus-summary-refer-article message-id)))
7136 (defun gnus-button-fetch-group (address)
7137 "Fetch GROUP specified by ADDRESS."
7138 (if (not (string-match "[:/]" address))
7139 ;; This is just a simple group url.
7140 (gnus-group-read-ephemeral-group address gnus-select-method)
7143 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7145 (error "Can't parse %s" address)
7146 (gnus-group-read-ephemeral-group
7147 (match-string 4 address)
7148 `(nntp ,(match-string 1 address)
7149 (nntp-address ,(match-string 1 address))
7150 (nntp-port-number ,(if (match-end 3)
7151 (match-string 3 address)
7154 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7156 (defun gnus-url-parse-query-string (query &optional downcase)
7157 (let (retval pairs cur key val)
7158 (setq pairs (split-string query "&"))
7160 (setq cur (car pairs)
7162 (if (not (string-match "=" cur))
7164 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7165 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7167 (setq key (downcase key)))
7168 (setq cur (assoc key retval))
7170 (setcdr cur (cons val (cdr cur)))
7171 (setq retval (cons (list key val) retval)))))
7174 (defun gnus-url-mailto (url)
7175 ;; Send mail to someone
7176 (when (string-match "mailto:/*\\(.*\\)" url)
7177 (setq url (substring url (match-beginning 1) nil)))
7178 (let (to args subject func)
7179 (setq args (gnus-url-parse-query-string
7180 (if (string-match "^\\?" url)
7182 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7183 (concat "to=" (match-string 1 url) "&"
7184 (match-string 2 url))
7185 (concat "to=" url)))
7187 subject (cdr-safe (assoc "subject" args)))
7190 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7193 (message-position-on-field (caar args)))
7194 (insert (gnus-replace-in-string
7195 (mapconcat 'identity (reverse (cdar args)) ", ")
7197 (setq args (cdr args)))
7200 (message-goto-subject))))
7202 (defun gnus-button-embedded-url (address)
7203 "Activate ADDRESS with `browse-url'."
7204 (browse-url (gnus-strip-whitespace address)))
7206 ;;; Next/prev buttons in the article buffer.
7208 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7209 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7211 (defvar gnus-prev-page-map
7212 (let ((map (make-sparse-keymap)))
7213 (unless (>= emacs-major-version 21)
7214 ;; XEmacs doesn't care.
7215 (set-keymap-parent map gnus-article-mode-map))
7216 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7217 (define-key map "\r" 'gnus-button-prev-page)
7220 (defvar gnus-next-page-map
7221 (let ((map (make-sparse-keymap)))
7222 (unless (>= emacs-major-version 21)
7223 ;; XEmacs doesn't care.
7224 (set-keymap-parent map gnus-article-mode-map))
7225 (define-key map gnus-mouse-2 'gnus-button-next-page)
7226 (define-key map "\r" 'gnus-button-next-page)
7229 (defun gnus-insert-prev-page-button ()
7231 (inhibit-read-only t))
7233 gnus-prev-page-line-format nil
7234 `(,@(gnus-local-map-property gnus-prev-page-map)
7236 gnus-callback gnus-article-button-prev-page
7237 article-type annotation))
7238 (widget-convert-button
7240 ;; Exclude a newline.
7243 :action 'gnus-button-prev-page
7244 :button-keymap gnus-prev-page-map)))
7246 (defun gnus-button-next-page (&optional args more-args)
7247 "Go to the next page."
7249 (let ((win (selected-window)))
7250 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7251 (gnus-article-next-page)
7252 (select-window win)))
7254 (defun gnus-button-prev-page (&optional args more-args)
7255 "Go to the prev page."
7257 (let ((win (selected-window)))
7258 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7259 (gnus-article-prev-page)
7260 (select-window win)))
7262 (defun gnus-insert-next-page-button ()
7264 (inhibit-read-only t))
7265 (gnus-eval-format gnus-next-page-line-format nil
7266 `(,@(gnus-local-map-property gnus-next-page-map)
7268 gnus-callback gnus-article-button-next-page
7269 article-type annotation))
7270 (widget-convert-button
7272 ;; Exclude a newline.
7275 :action 'gnus-button-next-page
7276 :button-keymap gnus-next-page-map)))
7278 (defun gnus-article-button-next-page (arg)
7279 "Go to the next page."
7281 (let ((win (selected-window)))
7282 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7283 (gnus-article-next-page)
7284 (select-window win)))
7286 (defun gnus-article-button-prev-page (arg)
7287 "Go to the prev page."
7289 (let ((win (selected-window)))
7290 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7291 (gnus-article-prev-page)
7292 (select-window win)))
7294 (defvar gnus-decode-header-methods
7295 '(mail-decode-encoded-word-region)
7296 "List of methods used to decode headers.
7298 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7299 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7300 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7301 whose names match REGEXP.
7304 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7305 mail-decode-encoded-word-region
7306 (\"chinese\" . rfc1843-decode-region))
7309 (defvar gnus-decode-header-methods-cache nil)
7311 (defun gnus-multi-decode-header (start end)
7312 "Apply the functions from `gnus-encoded-word-methods' that match."
7313 (unless (and gnus-decode-header-methods-cache
7314 (eq gnus-newsgroup-name
7315 (car gnus-decode-header-methods-cache)))
7316 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7319 (nconc gnus-decode-header-methods-cache (list x))
7320 (if (and gnus-newsgroup-name
7321 (string-match (car x) gnus-newsgroup-name))
7322 (nconc gnus-decode-header-methods-cache
7324 gnus-decode-header-methods))
7325 (let ((xlist gnus-decode-header-methods-cache))
7328 (narrow-to-region start end)
7330 (funcall (pop xlist) (point-min) (point-max))))))
7333 ;;; Treatment top-level handling.
7336 (defun gnus-treat-article (condition &optional part-number total-parts type)
7337 (let ((length (- (point-max) (point-min)))
7338 (alist gnus-treatment-function-alist)
7339 (article-goto-body-goes-to-point-min-p t)
7343 (let ((list gnus-article-treat-types))
7345 (when (string-match (pop list) type)
7346 (throw 'found t)))))))
7347 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7349 (gnus-run-hooks 'gnus-part-display-hook)
7350 (dolist (elem alist)
7353 (when (gnus-buffer-live-p gnus-summary-buffer)
7354 (set-buffer gnus-summary-buffer))
7355 (symbol-value (car elem))))
7356 (when (and (or (consp val)
7358 (gnus-treat-predicate val)
7359 (or (not (get (car elem) 'highlight))
7362 (funcall (cadr elem)))))))
7364 ;; Dynamic variables.
7366 (defvar part-number)
7367 (defvar total-parts)
7372 (defun gnus-treat-predicate (val)
7379 (stringp (car val)))
7380 (apply 'gnus-or (mapcar `(lambda (s)
7381 (string-match s ,(or gnus-newsgroup-name "")))
7384 (let ((pred (pop val)))
7387 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7389 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7391 (not (gnus-treat-predicate (car val))))
7393 (equal (car val) type))
7395 (error "%S is not a valid predicate" pred)))))
7401 (eq part-number total-parts))
7405 (error "%S is not a valid value" val))))
7407 (defun gnus-article-encrypt-body (protocol &optional n)
7408 "Encrypt the article body."
7411 (or gnus-article-encrypt-protocol
7412 (completing-read "Encrypt protocol: "
7413 gnus-article-encrypt-protocol-alist
7415 current-prefix-arg))
7416 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7418 (error "Can't find the encrypt protocol %s" protocol))
7419 (if (member gnus-newsgroup-name '("nndraft:delayed"
7422 (error "Can't encrypt the article in group %s"
7423 gnus-newsgroup-name))
7424 (gnus-summary-iterate n
7426 (set-buffer gnus-summary-buffer)
7427 (let ((mail-parse-charset gnus-newsgroup-charset)
7428 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7429 (summary-buffer gnus-summary-buffer)
7431 (gnus-set-global-variables)
7432 (when (gnus-group-read-only-p)
7433 (error "The current newsgroup does not support article encrypt"))
7434 (gnus-summary-show-article t)
7436 (or (mail-header-references gnus-current-headers) ""))
7437 (set-buffer gnus-article-buffer)
7438 (let* ((inhibit-read-only t)
7440 (mapcar (lambda (field)
7441 (and (save-restriction
7442 (message-narrow-to-head)
7443 (goto-char (point-min))
7444 (search-forward field nil t))
7446 (message-narrow-to-field)
7448 (delete-region (point-min) (point-max))
7450 '("Content-Type:" "Content-Transfer-Encoding:"
7451 "Content-Disposition:"))))
7452 (message-narrow-to-head)
7453 (message-remove-header "MIME-Version")
7454 (goto-char (point-max))
7455 (setq point (point))
7456 (insert (apply 'concat headers))
7458 (narrow-to-region point (point-max))
7459 (let ((message-options message-options))
7460 (message-options-set 'message-sender user-mail-address)
7461 (message-options-set 'message-recipients user-mail-address)
7462 (message-options-set 'message-sign-encrypt 'not)
7464 (goto-char (point-min))
7465 (insert "MIME-Version: 1.0\n")
7467 (gnus-summary-edit-article-done
7468 references nil summary-buffer t))
7469 (when gnus-keep-backlog
7470 (gnus-backlog-remove-article
7471 (car gnus-article-current) (cdr gnus-article-current)))
7473 (when (get-buffer gnus-original-article-buffer)
7474 (set-buffer gnus-original-article-buffer)
7475 (setq gnus-original-article nil)))
7476 (when gnus-use-cache
7477 (gnus-cache-update-article
7478 (car gnus-article-current) (cdr gnus-article-current))))))))
7480 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7481 "The following specs can be used:
7482 %t The security MIME type
7485 %D Details if button is pressed")
7487 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7488 "The following specs can be used:
7489 %t The security MIME type
7492 %D Details if button is pressed")
7494 (defvar gnus-mime-security-button-line-format-alist
7495 '((?t gnus-tmp-type ?s)
7496 (?i gnus-tmp-info ?s)
7497 (?d gnus-tmp-details ?s)
7498 (?D gnus-tmp-pressed-details ?s)))
7500 (defvar gnus-mime-security-button-map
7501 (let ((map (make-sparse-keymap)))
7502 (unless (>= (string-to-number emacs-version) 21)
7503 (set-keymap-parent map gnus-article-mode-map))
7504 (define-key map gnus-mouse-2 'gnus-article-push-button)
7505 (define-key map "\r" 'gnus-article-press-button)
7508 (defvar gnus-mime-security-details-buffer nil)
7510 (defvar gnus-mime-security-button-pressed nil)
7512 (defvar gnus-mime-security-show-details-inline t
7513 "If non-nil, show details in the article buffer.")
7515 (defun gnus-mime-security-verify-or-decrypt (handle)
7516 (mm-remove-parts (cdr handle))
7517 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7518 point (inhibit-read-only t))
7520 (goto-char (car region)))
7522 (narrow-to-region (point) (point))
7523 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7524 (let* ((mm-verify-option 'known)
7525 (mm-decrypt-option 'known)
7526 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7527 (unless (eq nparts (cdr handle))
7528 (mm-destroy-parts (cdr handle))
7529 (setcdr handle nparts))))
7530 (setq point (point))
7531 (gnus-mime-display-security handle)
7532 (goto-char (point-max)))
7534 (delete-region (point) (cdr region))
7535 (set-marker (car region) nil)
7536 (set-marker (cdr region) nil))
7539 (defun gnus-mime-security-show-details (handle)
7540 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7542 (gnus-message 5 "No details.")
7543 (if gnus-mime-security-show-details-inline
7544 (let ((gnus-mime-security-button-pressed
7545 (not (get-text-property (point) 'gnus-mime-details)))
7546 (gnus-mime-security-button-line-format
7547 (get-text-property (point) 'gnus-line-format))
7548 (inhibit-read-only t))
7550 (while (eq (get-text-property (point) 'gnus-line-format)
7551 gnus-mime-security-button-line-format)
7555 (narrow-to-region (point) (point))
7556 (gnus-insert-mime-security-button handle))
7557 (delete-region (point)
7558 (or (text-property-not-all
7561 gnus-mime-security-button-line-format)
7564 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7565 (with-current-buffer gnus-mime-security-details-buffer
7568 (setq gnus-mime-security-details-buffer
7569 (gnus-get-buffer-create "*MIME Security Details*")))
7570 (with-current-buffer gnus-mime-security-details-buffer
7572 (goto-char (point-min)))
7573 (pop-to-buffer gnus-mime-security-details-buffer)))))
7575 (defun gnus-mime-security-press-button (handle)
7577 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7578 (gnus-mime-security-show-details handle)
7579 (gnus-mime-security-verify-or-decrypt handle))))
7581 (defun gnus-insert-mime-security-button (handle &optional displayed)
7582 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7585 (or (nth 2 (assoc protocol mm-verify-function-alist))
7586 (nth 2 (assoc protocol mm-decrypt-function-alist))
7588 (if (equal (car handle) "multipart/signed")
7589 " Signed" " Encrypted")
7592 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7595 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7596 gnus-tmp-pressed-details
7598 (setq gnus-tmp-details
7599 (if gnus-tmp-details
7600 (concat "\n" gnus-tmp-details)
7602 (setq gnus-tmp-pressed-details
7603 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7608 gnus-mime-security-button-line-format
7609 gnus-mime-security-button-line-format-alist
7610 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7611 gnus-callback gnus-mime-security-press-button
7612 gnus-line-format ,gnus-mime-security-button-line-format
7613 gnus-mime-details ,gnus-mime-security-button-pressed
7614 article-type annotation
7617 ;; Exclude a newline.
7620 (widget-convert-button
7623 :action 'gnus-widget-press-button
7624 :button-keymap gnus-mime-security-button-map
7626 (lambda (widget/window &optional overlay pos)
7627 ;; Needed to properly clear the message due to a bug in
7628 ;; wid-edit (XEmacs only).
7629 (when (boundp 'help-echo-owns-message)
7630 (setq help-echo-owns-message t))
7633 (aref gnus-mouse-2 0))))))
7635 (defun gnus-mime-display-security (handle)
7637 (narrow-to-region (point) (point))
7638 (unless (gnus-unbuttonized-mime-type-p (car handle))
7639 (gnus-insert-mime-security-button handle))
7640 (gnus-mime-display-mixed (cdr handle))
7643 (unless (gnus-unbuttonized-mime-type-p (car handle))
7644 (let ((gnus-mime-security-button-line-format
7645 gnus-mime-security-button-end-line-format))
7646 (gnus-insert-mime-security-button handle)))
7647 (mm-set-handle-multipart-parameter
7649 (cons (set-marker (make-marker) (point-min))
7650 (set-marker (make-marker) (point-max))))))
7656 (run-hooks 'gnus-art-load-hook)
7658 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7659 ;;; gnus-art.el ends here