1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:")
145 "*All headers that start with this regexp will be hidden.
146 This variable can also be a list of regexps of headers to be ignored.
147 If `gnus-visible-headers' is non-nil, this variable will be ignored."
148 :type '(choice :custom-show nil
151 :group 'gnus-article-hiding)
153 (defcustom gnus-visible-headers
154 "^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:"
155 "*All headers that do not match this regexp will be hidden.
156 This variable can also be a list of regexp of headers to remain visible.
157 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
158 :type '(repeat :value-to-internal (lambda (widget value)
159 (custom-split-regexp-maybe value))
160 :match (lambda (widget value)
162 (widget-editable-list-match widget value)))
164 :group 'gnus-article-hiding)
166 (defcustom gnus-sorted-header-list
167 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
168 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
169 "*This variable is a list of regular expressions.
170 If it is non-nil, headers that match the regular expressions will
171 be placed first in the article buffer in the sequence specified by
173 :type '(repeat regexp)
174 :group 'gnus-article-hiding)
176 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
177 "Headers that are only to be displayed if they have interesting data.
178 Possible values in this list are:
180 'empty Headers with no content.
181 'newsgroups Newsgroup identical to Gnus group.
182 'to-address To identical to To-address.
183 'followup-to Followup-to identical to Newsgroups.
184 'reply-to Reply-to identical to From.
185 'date Date less than four days old.
186 'long-to To and/or Cc longer than 1024 characters.
187 'many-to Multiple To and/or Cc."
188 :type '(set (const :tag "Headers with no content." empty)
189 (const :tag "Newsgroups identical to Gnus group." newsgroups)
190 (const :tag "To identical to To-address." to-address)
191 (const :tag "Followup-to identical to Newsgroups." followup-to)
192 (const :tag "Reply-to identical to From." reply-to)
193 (const :tag "Date less than four days old." date)
194 (const :tag "To and/or Cc longer than 1024 characters." long-to)
195 (const :tag "Multiple To and/or Cc headers." many-to))
196 :group 'gnus-article-hiding)
198 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
199 "Regexp matching signature separator.
200 This can also be a list of regexps. In that case, it will be checked
201 from head to tail looking for a separator. Searches will be done from
202 the end of the buffer."
203 :type '(repeat string)
204 :group 'gnus-article-signature)
206 (defcustom gnus-signature-limit nil
207 "Provide a limit to what is considered a signature.
208 If it is a number, no signature may not be longer (in characters) than
209 that number. If it is a floating point number, no signature may be
210 longer (in lines) than that number. If it is a function, the function
211 will be called without any parameters, and if it returns nil, there is
212 no signature in the buffer. If it is a string, it will be used as a
213 regexp. If it matches, the text in question is not a signature."
214 :type '(choice (integer :value 200)
216 (function :value fun)
217 (regexp :value ".*"))
218 :group 'gnus-article-signature)
220 (defcustom gnus-hidden-properties '(invisible t intangible t)
221 "Property list to use for hiding text."
223 :group 'gnus-article-hiding)
225 ;; Fixme: This isn't the right thing for mixed graphical and and
226 ;; non-graphical frames in a session.
227 (defcustom gnus-article-x-face-command
228 (if (featurep 'xemacs)
229 (if (or (gnus-image-type-available-p 'xface)
230 (gnus-image-type-available-p 'xpm))
231 'gnus-xmas-article-display-xface
232 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
233 (if (gnus-image-type-available-p 'xbm)
234 'gnus-article-display-xface
235 (if gnus-article-compface-xbm
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
237 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
239 "*String or function to be executed to display an X-Face header.
240 If it is a string, the command will be executed in a sub-shell
241 asynchronously. The compressed face will be piped to this command."
242 :type `(choice string
244 ,(if (featurep 'xemacs)
245 'gnus-xmas-article-display-xface
246 'gnus-article-display-xface))
249 :group 'gnus-article-washing)
251 (defcustom gnus-article-x-face-too-ugly nil
252 "Regexp matching posters whose face shouldn't be shown automatically."
253 :type '(choice regexp (const nil))
254 :group 'gnus-article-washing)
256 (defcustom gnus-article-banner-alist nil
257 "Banner alist for stripping.
259 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
261 :type '(repeat (cons symbol regexp))
262 :group 'gnus-article-washing)
264 (gnus-define-group-parameter
267 "Alist of regexps (to match group names) and banner."
268 :variable-group gnus-article-washing
270 '(choice :tag "Banner"
272 (const :tag "Remove signature" signature)
273 (symbol :tag "Item in `gnus-article-banner-alist'" none)
275 (const :tag "None" nil))
277 "If non-nil, specify how to remove `banners' from articles.
279 Symbol `signature' means to remove signatures delimited by
280 `gnus-signature-separator'. Any other symbol is used to look up a
281 regular expression to match the banner in `gnus-article-banner-alist'.
282 A string is used as a regular expression to match the banner
285 (defcustom gnus-emphasis-alist
287 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
289 '(("_" "_" underline)
292 ("_/" "/_" underline-italic)
293 ("_\\*" "\\*_" underline-bold)
294 ("\\*/" "/\\*" bold-italic)
295 ("_\\*/" "/\\*_" underline-bold-italic))))
296 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
297 2 3 gnus-emphasis-underline)
301 (format format (car spec) (cadr spec))
302 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
304 "*Alist that says how to fontify certain phrases.
305 Each item looks like this:
307 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
309 The first element is a regular expression to be matched. The second
310 is a number that says what regular expression grouping used to find
311 the entire emphasized word. The third is a number that says what
312 regexp grouping should be displayed and highlighted. The fourth
313 is the face used for highlighting."
314 :type '(repeat (list :value ("" 0 0 default)
316 (integer :tag "Match group")
317 (integer :tag "Emphasize group")
319 :group 'gnus-article-emphasis)
321 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
322 "A regexp to describe whitespace which should not be emphasized.
323 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
324 The former avoids underlining of leading and trailing whitespace,
325 and the latter avoids underlining any whitespace at all."
327 :group 'gnus-article-emphasis
330 (defface gnus-emphasis-bold '((t (:bold t)))
331 "Face used for displaying strong emphasized text (*word*)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-italic '((t (:italic t)))
335 "Face used for displaying italic emphasized text (/word/)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline '((t (:underline t)))
339 "Face used for displaying underlined emphasized text (_word_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
343 "Face used for displaying underlined bold emphasized text (_*word*_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
347 "Face used for displaying underlined italic emphasized text (_/word/_)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
351 "Face used for displaying bold italic emphasized text (/*word*/)."
352 :group 'gnus-article-emphasis)
354 (defface gnus-emphasis-underline-bold-italic
355 '((t (:bold t :italic t :underline t)))
356 "Face used for displaying underlined bold italic emphasized text.
357 Esample: (_/*word*/_)."
358 :group 'gnus-article-emphasis)
360 (defface gnus-emphasis-highlight-words
361 '((t (:background "black" :foreground "yellow")))
362 "Face used for displaying highlighted words."
363 :group 'gnus-article-emphasis)
365 (defface gnus-body-boundary-face
368 (:background "white")
369 (:foreground "black"))
372 (:background "black")
373 (:foreground "white"))
376 "Face for the body separator.")
378 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
379 "Format for display of Date headers in article bodies.
380 See `format-time-string' for the possible values.
382 The variable can also be function, which should return a complete Date
383 header. The function is called with one argument, the time, which can
384 be fed to `format-time-string'."
385 :type '(choice string symbol)
386 :link '(custom-manual "(gnus)Article Date")
387 :group 'gnus-article-washing)
390 (autoload 'mail-extract-address-components "mail-extr"))
392 (defcustom gnus-save-all-headers t
393 "*If non-nil, don't remove any headers before saving."
394 :group 'gnus-article-saving
397 (defcustom gnus-prompt-before-saving 'always
398 "*This variable says how much prompting is to be done when saving articles.
399 If it is nil, no prompting will be done, and the articles will be
400 saved to the default files. If this variable is `always', each and
401 every article that is saved will be preceded by a prompt, even when
402 saving large batches of articles. If this variable is neither nil not
403 `always', there the user will be prompted once for a file name for
404 each invocation of the saving commands."
405 :group 'gnus-article-saving
406 :type '(choice (item always)
407 (item :tag "never" nil)
408 (sexp :tag "once" :format "%t\n" :value t)))
410 (defcustom gnus-saved-headers gnus-visible-headers
411 "Headers to keep if `gnus-save-all-headers' is nil.
412 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
413 If that variable is nil, however, all headers that match this regexp
414 will be kept while the rest will be deleted before saving."
415 :group 'gnus-article-saving
418 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
419 "A function to save articles in your favourite format.
420 The function must be interactively callable (in other words, it must
421 be an Emacs command).
423 Gnus provides the following functions:
425 * gnus-summary-save-in-rmail (Rmail format)
426 * gnus-summary-save-in-mail (Unix mail format)
427 * gnus-summary-save-in-folder (MH folder)
428 * gnus-summary-save-in-file (article format)
429 * gnus-summary-save-body-in-file (article body)
430 * gnus-summary-save-in-vm (use VM's folder format)
431 * gnus-summary-write-to-file (article format -- overwrite)."
432 :group 'gnus-article-saving
433 :type '(radio (function-item gnus-summary-save-in-rmail)
434 (function-item gnus-summary-save-in-mail)
435 (function-item gnus-summary-save-in-folder)
436 (function-item gnus-summary-save-in-file)
437 (function-item gnus-summary-save-body-in-file)
438 (function-item gnus-summary-save-in-vm)
439 (function-item gnus-summary-write-to-file)))
441 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
442 "A function generating a file name to save articles in Rmail format.
443 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
444 :group 'gnus-article-saving
447 (defcustom gnus-mail-save-name 'gnus-plain-save-name
448 "A function generating a file name to save articles in Unix mail format.
449 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
450 :group 'gnus-article-saving
453 (defcustom gnus-folder-save-name 'gnus-folder-save-name
454 "A function generating a file name to save articles in MH folder.
455 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
456 :group 'gnus-article-saving
459 (defcustom gnus-file-save-name 'gnus-numeric-save-name
460 "A function generating a file name to save articles in article format.
461 The function is called with NEWSGROUP, HEADERS, and optional
463 :group 'gnus-article-saving
466 (defcustom gnus-split-methods
467 '((gnus-article-archive-name)
468 (gnus-article-nndoc-name))
469 "*Variable used to suggest where articles are to be saved.
470 For instance, if you would like to save articles related to Gnus in
471 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
472 you could set this variable to something like:
474 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
475 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
477 This variable is an alist where the where the key is the match and the
478 value is a list of possible files to save in if the match is non-nil.
480 If the match is a string, it is used as a regexp match on the
481 article. If the match is a symbol, that symbol will be funcalled
482 from the buffer of the article to be saved with the newsgroup as the
483 parameter. If it is a list, it will be evaled in the same buffer.
485 If this form or function returns a string, this string will be used as
486 a possible file name; and if it returns a non-nil list, that list will
487 be used as possible file names."
488 :group 'gnus-article-saving
489 :type '(repeat (choice (list :value (fun) function)
490 (cons :value ("" "") regexp (repeat string))
493 (defcustom gnus-page-delimiter "^\^L"
494 "*Regexp describing what to use as article page delimiters.
495 The default value is \"^\^L\", which is a form linefeed at the
496 beginning of a line."
498 :group 'gnus-article-various)
500 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
501 "*The format specification for the article mode line.
502 See `gnus-summary-mode-line-format' for a closer description.
504 The following additional specs are available:
506 %w The article washing status.
507 %m The number of MIME parts in the article."
509 :group 'gnus-article-various)
511 (defcustom gnus-article-mode-hook nil
512 "*A hook for Gnus article mode."
514 :group 'gnus-article-various)
516 (when (featurep 'xemacs)
517 ;; Extracted from gnus-xmas-define in order to preserve user settings
518 (when (fboundp 'turn-off-scroll-in-place)
519 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
520 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
521 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
523 (defcustom gnus-article-menu-hook nil
524 "*Hook run after the creation of the article mode menu."
526 :group 'gnus-article-various)
528 (defcustom gnus-article-prepare-hook nil
529 "*A hook called after an article has been prepared in the article buffer."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-hide-pgp-hook nil
534 "*A hook called after successfully hiding a PGP signature."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-button-face 'bold
539 "Face used for highlighting buttons in the article buffer.
541 An article button is a piece of text that you can activate by pressing
542 `RET' or `mouse-2' above it."
544 :group 'gnus-article-buttons)
546 (defcustom gnus-article-mouse-face 'highlight
547 "Face used for mouse highlighting in the article buffer.
549 Article buttons will be displayed in this face when the cursor is
552 :group 'gnus-article-buttons)
554 (defcustom gnus-signature-face 'gnus-signature-face
555 "Face used for highlighting a signature in the article buffer.
556 Obsolete; use the face `gnus-signature-face' for customizations instead."
558 :group 'gnus-article-highlight
559 :group 'gnus-article-signature)
561 (defface gnus-signature-face
564 "Face used for highlighting a signature in the article buffer."
565 :group 'gnus-article-highlight
566 :group 'gnus-article-signature)
568 (defface gnus-header-from-face
571 (:foreground "spring green"))
574 (:foreground "red3"))
577 "Face used for displaying from headers."
578 :group 'gnus-article-headers
579 :group 'gnus-article-highlight)
581 (defface gnus-header-subject-face
584 (:foreground "SeaGreen3"))
587 (:foreground "red4"))
589 (:bold t :italic t)))
590 "Face used for displaying subject headers."
591 :group 'gnus-article-headers
592 :group 'gnus-article-highlight)
594 (defface gnus-header-newsgroups-face
597 (:foreground "yellow" :italic t))
600 (:foreground "MidnightBlue" :italic t))
603 "Face used for displaying newsgroups headers."
604 :group 'gnus-article-headers
605 :group 'gnus-article-highlight)
607 (defface gnus-header-name-face
610 (:foreground "SeaGreen"))
613 (:foreground "maroon"))
616 "Face used for displaying header names."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defface gnus-header-content-face
623 (:foreground "forest green" :italic t))
626 (:foreground "indianred4" :italic t))
628 (:italic t))) "Face used for displaying header content."
629 :group 'gnus-article-headers
630 :group 'gnus-article-highlight)
632 (defcustom gnus-header-face-alist
633 '(("From" nil gnus-header-from-face)
634 ("Subject" nil gnus-header-subject-face)
635 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
636 ("" gnus-header-name-face gnus-header-content-face))
637 "*Controls highlighting of article header.
639 An alist of the form (HEADER NAME CONTENT).
641 HEADER is a regular expression which should match the name of an
642 header header and NAME and CONTENT are either face names or nil.
644 The name of each header field will be displayed using the face
645 specified by the first element in the list where HEADER match the
646 header name and NAME is non-nil. Similarly, the content will be
647 displayed by the first non-nil matching CONTENT face."
648 :group 'gnus-article-headers
649 :group 'gnus-article-highlight
650 :type '(repeat (list (regexp :tag "Header")
652 (item :tag "skip" nil)
653 (face :value default))
654 (choice :tag "Content"
655 (item :tag "skip" nil)
656 (face :value default)))))
658 (defcustom gnus-article-decode-hook
659 '(article-decode-charset article-decode-encoded-words
660 article-decode-group-name)
661 "*Hook run to decode charsets in articles."
662 :group 'gnus-article-headers
665 (defcustom gnus-display-mime-function 'gnus-display-mime
666 "Function to display MIME articles."
667 :group 'gnus-article-mime
670 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
671 "Function used to decode headers.")
673 (defvar gnus-article-dumbquotes-map
692 "Table for MS-to-Latin1 translation.")
694 (defcustom gnus-ignored-mime-types nil
695 "List of MIME types that should be ignored by Gnus."
697 :group 'gnus-article-mime
698 :type '(repeat regexp))
700 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
701 "List of MIME types that should not be given buttons when rendered inline.
702 See also `gnus-buttonized-mime-types' which may override this variable."
704 :group 'gnus-article-mime
705 :type '(repeat regexp))
707 (defcustom gnus-buttonized-mime-types nil
708 "List of MIME types that should be given buttons when rendered inline.
709 If set, this variable overrides `gnus-unbuttonized-mime-types'.
710 To see e.g. security buttons you could set this to
711 `(\"multipart/signed\")'."
713 :group 'gnus-article-mime
714 :type '(repeat regexp))
716 (defcustom gnus-article-mime-part-function nil
717 "Function called with a MIME handle as the argument.
718 This is meant for people who want to do something automatic based
719 on parts -- for instance, adding Vcard info to a database."
720 :group 'gnus-article-mime
723 (defcustom gnus-mime-multipart-functions nil
724 "An alist of MIME types to functions to display them."
726 :group 'gnus-article-mime
729 (defcustom gnus-article-date-lapsed-new-header nil
730 "Whether the X-Sent and Date headers can coexist.
731 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
732 either replace the old \"Date:\" header (if this variable is nil), or
733 be added below it (otherwise)."
735 :group 'gnus-article-headers
738 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
739 "Function called with a MIME handle as the argument.
740 This is meant for people who want to view first matched part.
741 For `undisplayed-alternative' (default), the first undisplayed
742 part or alternative part is used. For `undisplayed', the first
743 undisplayed part is used. For a function, the first part which
744 the function return `t' is used. For `nil', the first part is
747 :group 'gnus-article-mime
749 (item :tag "first" :value nil)
750 (item :tag "undisplayed" :value undisplayed)
751 (item :tag "undisplayed or alternative"
752 :value undisplayed-alternative)
755 (defcustom gnus-mime-action-alist
756 '(("save to file" . gnus-mime-save-part)
757 ("save and strip" . gnus-mime-save-part-and-strip)
758 ("display as text" . gnus-mime-inline-part)
759 ("view the part" . gnus-mime-view-part)
760 ("pipe to command" . gnus-mime-pipe-part)
761 ("toggle display" . gnus-article-press-button)
762 ("toggle display" . gnus-article-view-part-as-charset)
763 ("view as type" . gnus-mime-view-part-as-type)
764 ("internalize type" . gnus-mime-internalize-part)
765 ("externalize type" . gnus-mime-externalize-part))
766 "An alist of actions that run on the MIME attachment."
767 :group 'gnus-article-mime
768 :type '(repeat (cons (string :tag "name")
771 (defcustom gnus-mime-action-alist
772 '(("save to file" . gnus-mime-save-part)
773 ("display as text" . gnus-mime-inline-part)
774 ("view the part" . gnus-mime-view-part)
775 ("pipe to command" . gnus-mime-pipe-part)
776 ("toggle display" . gnus-article-press-button)
777 ("view as type" . gnus-mime-view-part-as-type)
778 ("internalize type" . gnus-mime-internalize-part)
779 ("externalize type" . gnus-mime-externalize-part))
780 "An alist of actions that run on the MIME attachment."
782 :group 'gnus-article-mime
783 :type '(repeat (cons (string :tag "name")
787 ;;; The treatment variables
790 (defvar gnus-part-display-hook nil
791 "Hook called on parts that are to receive treatment.")
793 (defvar gnus-article-treat-custom
794 '(choice (const :tag "Off" nil)
796 (const :tag "Header" head)
797 (const :tag "Last" last)
798 (integer :tag "Less")
799 (repeat :tag "Groups" regexp)
800 (sexp :tag "Predicate")))
802 (defvar gnus-article-treat-head-custom
803 '(choice (const :tag "Off" nil)
804 (const :tag "Header" head)))
806 (defvar gnus-article-treat-types '("text/plain")
809 (defvar gnus-inhibit-treatment nil
810 "Whether to inhibit treatment.")
812 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
813 "Highlight the signature.
814 Valid values are nil, t, `head', `last', an integer or a predicate.
815 See Info node `(gnus)Customizing Articles'."
816 :group 'gnus-article-treat
817 :type gnus-article-treat-custom)
818 (put 'gnus-treat-highlight-signature 'highlight t)
820 (defcustom gnus-treat-buttonize 100000
822 Valid values are nil, t, `head', `last', an integer or a predicate.
823 See the manual for details."
824 :group 'gnus-article-treat
825 :type gnus-article-treat-custom)
826 (put 'gnus-treat-buttonize 'highlight t)
828 (defcustom gnus-treat-buttonize-head 'head
829 "Add buttons to the head.
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-head-custom)
834 (put 'gnus-treat-buttonize-head 'highlight t)
836 (defcustom gnus-treat-emphasize
837 (and (or window-system
839 (>= (string-to-number emacs-version) 21))
842 Valid values are nil, t, `head', `last', an integer or a predicate.
843 See the manual for details."
844 :group 'gnus-article-treat
845 :type gnus-article-treat-custom)
846 (put 'gnus-treat-emphasize 'highlight t)
848 (defcustom gnus-treat-strip-cr nil
849 "Remove carriage returns.
850 Valid values are nil, t, `head', `last', an integer or a predicate.
851 See the manual for details."
852 :group 'gnus-article-treat
853 :type gnus-article-treat-custom)
855 (defcustom gnus-treat-leading-whitespace nil
856 "Remove leading whitespace in headers.
857 Valid values are nil, t, `head', `last', an integer or a predicate.
858 See the manual for details."
859 :group 'gnus-article-treat
860 :type gnus-article-treat-custom)
862 (defcustom gnus-treat-hide-headers 'head
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See the manual for details."
866 :group 'gnus-article-treat
867 :type gnus-article-treat-head-custom)
869 (defcustom gnus-treat-hide-boring-headers nil
870 "Hide boring headers.
871 Valid values are nil, t, `head', `last', an integer or a predicate.
872 See the manual for details."
873 :group 'gnus-article-treat
874 :type gnus-article-treat-head-custom)
876 (defcustom gnus-treat-hide-signature nil
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See the manual for details."
880 :group 'gnus-article-treat
881 :type gnus-article-treat-custom)
883 (defcustom gnus-treat-fill-article nil
885 Valid values are nil, t, `head', `last', an integer or a predicate.
886 See the manual for details."
887 :group 'gnus-article-treat
888 :type gnus-article-treat-custom)
890 (defcustom gnus-treat-hide-citation nil
892 Valid values are nil, t, `head', `last', an integer or a predicate.
893 See the manual for details."
894 :group 'gnus-article-treat
895 :type gnus-article-treat-custom)
897 (defcustom gnus-treat-hide-citation-maybe nil
899 Valid values are nil, t, `head', `last', an integer or a predicate.
900 See the manual for details."
901 :group 'gnus-article-treat
902 :type gnus-article-treat-custom)
904 (defcustom gnus-treat-strip-list-identifiers 'head
905 "Strip list identifiers from `gnus-list-identifiers`.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See the manual for details."
909 :group 'gnus-article-treat
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-strip-pgp t
913 "Strip PGP signatures.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See the manual for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-strip-pem nil
920 "Strip PEM signatures.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See the manual for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-custom)
926 (defcustom gnus-treat-strip-banner t
927 "Strip banners from articles.
928 The banner to be stripped is specified in the `banner' group parameter.
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See the manual for details."
931 :group 'gnus-article-treat
932 :type gnus-article-treat-custom)
934 (defcustom gnus-treat-highlight-headers 'head
935 "Highlight the headers.
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See the manual for details."
938 :group 'gnus-article-treat
939 :type gnus-article-treat-head-custom)
940 (put 'gnus-treat-highlight-headers 'highlight t)
942 (defcustom gnus-treat-highlight-citation t
943 "Highlight cited text.
944 Valid values are nil, t, `head', `last', an integer or a predicate.
945 See the manual for details."
946 :group 'gnus-article-treat
947 :type gnus-article-treat-custom)
948 (put 'gnus-treat-highlight-citation 'highlight t)
950 (defcustom gnus-treat-date-ut nil
951 "Display the Date in UT (GMT).
952 Valid values are nil, t, `head', `last', an integer or a predicate.
953 See the manual for details."
954 :group 'gnus-article-treat
955 :type gnus-article-treat-head-custom)
957 (defcustom gnus-treat-date-local nil
958 "Display the Date in the local timezone.
959 Valid values are nil, t, `head', `last', an integer or a predicate.
960 See the manual for details."
961 :group 'gnus-article-treat
962 :type gnus-article-treat-head-custom)
964 (defcustom gnus-treat-date-english nil
965 "Display the Date in a format that can be read aloud in English.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See the manual for details."
968 :group 'gnus-article-treat
969 :type gnus-article-treat-head-custom)
971 (defcustom gnus-treat-date-lapsed nil
972 "Display the Date header in a way that says how much time has elapsed.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See the manual for details."
975 :group 'gnus-article-treat
976 :type gnus-article-treat-head-custom)
978 (defcustom gnus-treat-date-original nil
979 "Display the date in the original timezone.
980 Valid values are nil, t, `head', `last', an integer or a predicate.
981 See the manual for details."
982 :group 'gnus-article-treat
983 :type gnus-article-treat-head-custom)
985 (defcustom gnus-treat-date-iso8601 nil
986 "Display the date in the ISO8601 format.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See the manual for details."
990 :group 'gnus-article-treat
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-date-user-defined nil
994 "Display the date in a user-defined format.
995 The format is defined by the `gnus-article-time-format' variable.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See the manual for details."
998 :group 'gnus-article-treat
999 :type gnus-article-treat-head-custom)
1001 (defcustom gnus-treat-strip-headers-in-body t
1002 "Strip the X-No-Archive header line from the beginning of the body.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See the manual for details."
1006 :group 'gnus-article-treat
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-strip-trailing-blank-lines nil
1010 "Strip trailing blank lines.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See the manual for details."
1013 :group 'gnus-article-treat
1014 :type gnus-article-treat-custom)
1016 (defcustom gnus-treat-strip-leading-blank-lines nil
1017 "Strip leading blank lines.
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See the manual for details."
1020 :group 'gnus-article-treat
1021 :type gnus-article-treat-custom)
1023 (defcustom gnus-treat-strip-multiple-blank-lines nil
1024 "Strip multiple blank lines.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See the manual for details."
1027 :group 'gnus-article-treat
1028 :type gnus-article-treat-custom)
1030 (defcustom gnus-treat-unfold-headers 'head
1031 "Unfold folded header lines.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See the manual for details."
1034 :group 'gnus-article-treat
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-overstrike t
1038 "Treat overstrike highlighting.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See the manual for details."
1041 :group 'gnus-article-treat
1042 :type gnus-article-treat-custom)
1043 (put 'gnus-treat-overstrike 'highlight t)
1045 (defcustom gnus-treat-display-xface
1046 (and (or (and (fboundp 'image-type-available-p)
1047 (image-type-available-p 'xbm)
1048 (string-match "^0x" (shell-command-to-string "uncompface")))
1049 (and (featurep 'xemacs) (featurep 'xface)))
1051 "Display X-Face headers.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See the manual for details."
1054 :group 'gnus-article-treat
1056 :type gnus-article-treat-head-custom)
1057 (put 'gnus-treat-display-xface 'highlight t)
1059 (defcustom gnus-treat-display-smileys
1060 (if (or (and (featurep 'xemacs)
1062 (and (fboundp 'image-type-available-p)
1063 (image-type-available-p 'pbm)))
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See the manual for details."
1068 :group 'gnus-article-treat
1070 :type gnus-article-treat-custom)
1071 (put 'gnus-treat-display-smileys 'highlight t)
1073 (defcustom gnus-treat-from-picon
1074 (if (gnus-image-type-available-p 'xpm)
1076 "Display picons in the From header.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See the manual for details."
1079 :group 'gnus-article-treat
1080 :type gnus-article-treat-head-custom)
1081 (put 'gnus-treat-from-picon 'highlight t)
1083 (defcustom gnus-treat-mail-picon
1084 (if (gnus-image-type-available-p 'xpm)
1086 "Display picons in To and Cc headers.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See the manual for details."
1089 :group 'gnus-article-treat
1090 :type gnus-article-treat-head-custom)
1091 (put 'gnus-treat-mail-picon 'highlight t)
1093 (defcustom gnus-treat-newsgroups-picon
1094 (if (gnus-image-type-available-p 'xpm)
1096 "Display picons in the Newsgroups and Followup-To headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See the manual for details."
1099 :group 'gnus-article-treat
1100 :type gnus-article-treat-head-custom)
1101 (put 'gnus-treat-newsgroups-picon 'highlight t)
1103 (defcustom gnus-treat-body-boundary
1104 (if (or gnus-treat-newsgroups-picon
1105 gnus-treat-mail-picon
1106 gnus-treat-from-picon)
1108 "Draw a boundary at the end of the headers.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See the manual for details."
1112 :group 'gnus-article-treat
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-capitalize-sentences nil
1116 "Capitalize sentence-starting words.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See the manual for details."
1120 :group 'gnus-article-treat
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-fill-long-lines nil
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See the manual for details."
1127 :group 'gnus-article-treat
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-play-sounds nil
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See the manual for details."
1135 :group 'gnus-article-treat
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-translate nil
1139 "Translate articles from one language to another.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See the manual for details."
1143 :group 'gnus-article-treat
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-x-pgp-sig nil
1148 To automatically treat X-PGP-Sig, set it to head.
1149 Valid values are nil, t, `head', `last', an integer or a predicate.
1150 See the manual for details."
1151 :group 'gnus-article-treat
1152 :group 'mime-security
1153 :type gnus-article-treat-custom)
1155 (defvar gnus-article-encrypt-protocol-alist
1156 '(("PGP" . mml2015-self-encrypt)))
1158 ;; Set to nil if more than one protocol added to
1159 ;; gnus-article-encrypt-protocol-alist.
1160 (defcustom gnus-article-encrypt-protocol "PGP"
1161 "The protocol used for encrypt articles.
1162 It is a string, such as \"PGP\". If nil, ask user."
1164 :group 'mime-security)
1166 ;;; Internal variables
1168 (defvar gnus-english-month-names
1169 '("January" "February" "March" "April" "May" "June" "July" "August"
1170 "September" "October" "November" "December"))
1172 (defvar article-goto-body-goes-to-point-min-p nil)
1173 (defvar gnus-article-wash-types nil)
1174 (defvar gnus-article-emphasis-alist nil)
1176 (defvar gnus-article-mime-handle-alist-1 nil)
1177 (defvar gnus-treatment-function-alist
1178 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1179 (gnus-treat-strip-banner gnus-article-strip-banner)
1180 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1181 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1182 (gnus-treat-buttonize gnus-article-add-buttons)
1183 (gnus-treat-fill-article gnus-article-fill-cited-article)
1184 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1185 (gnus-treat-strip-cr gnus-article-remove-cr)
1186 (gnus-treat-display-xface gnus-article-display-x-face)
1187 (gnus-treat-date-ut gnus-article-date-ut)
1188 (gnus-treat-date-local gnus-article-date-local)
1189 (gnus-treat-date-english gnus-article-date-english)
1190 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1191 (gnus-treat-date-original gnus-article-date-original)
1192 (gnus-treat-date-user-defined gnus-article-date-user)
1193 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1194 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1195 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1196 (gnus-treat-hide-signature gnus-article-hide-signature)
1197 (gnus-treat-hide-citation gnus-article-hide-citation)
1198 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1199 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1200 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1201 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1202 (gnus-treat-strip-pem gnus-article-hide-pem)
1203 (gnus-treat-from-picon gnus-treat-from-picon)
1204 (gnus-treat-mail-picon gnus-treat-mail-picon)
1205 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1206 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1207 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1208 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1209 (gnus-treat-strip-trailing-blank-lines
1210 gnus-article-remove-trailing-blank-lines)
1211 (gnus-treat-strip-leading-blank-lines
1212 gnus-article-strip-leading-blank-lines)
1213 (gnus-treat-strip-multiple-blank-lines
1214 gnus-article-strip-multiple-blank-lines)
1215 (gnus-treat-overstrike gnus-article-treat-overstrike)
1216 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1217 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1218 (gnus-treat-display-smileys gnus-smiley-display)
1219 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1220 (gnus-treat-emphasize gnus-article-emphasize)
1221 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1222 (gnus-treat-play-sounds gnus-earcon-display)))
1224 (defvar gnus-article-mime-handle-alist nil)
1225 (defvar article-lapsed-timer nil)
1226 (defvar gnus-article-current-summary nil)
1228 (defvar gnus-article-mode-syntax-table
1229 (let ((table (copy-syntax-table text-mode-syntax-table)))
1230 ;; This causes the citation match run O(2^n).
1231 ;; (modify-syntax-entry ?- "w" table)
1232 (modify-syntax-entry ?> ")" table)
1233 (modify-syntax-entry ?< "(" table)
1235 "Syntax table used in article mode buffers.
1236 Initialized from `text-mode-syntax-table.")
1238 (defvar gnus-save-article-buffer nil)
1240 (defvar gnus-article-mode-line-format-alist
1241 (nconc '((?w (gnus-article-wash-status) ?s)
1242 (?m (gnus-article-mime-part-status) ?s))
1243 gnus-summary-mode-line-format-alist))
1245 (defvar gnus-number-of-articles-to-be-saved nil)
1247 (defvar gnus-inhibit-hiding nil)
1249 ;;; Macros for dealing with the article buffer.
1251 (defmacro gnus-with-article-headers (&rest forms)
1253 (set-buffer gnus-article-buffer)
1255 (let ((buffer-read-only nil)
1256 (inhibit-point-motion-hooks t)
1257 (case-fold-search t))
1258 (article-narrow-to-head)
1261 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1262 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1264 (defsubst gnus-article-hide-text (b e props)
1265 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1266 (gnus-add-text-properties-when 'article-type nil b e props)
1267 (when (memq 'intangible props)
1269 (max (1- b) (point-min))
1270 b 'intangible (cddr (memq 'intangible props)))))
1272 (defsubst gnus-article-unhide-text (b e)
1273 "Remove hidden text properties from region between B and E."
1274 (remove-text-properties b e gnus-hidden-properties)
1275 (when (memq 'intangible gnus-hidden-properties)
1276 (put-text-property (max (1- b) (point-min))
1277 b 'intangible nil)))
1279 (defun gnus-article-hide-text-type (b e type)
1280 "Hide text of TYPE between B and E."
1281 (push type gnus-article-wash-types)
1282 (gnus-article-hide-text
1283 b e (cons 'article-type (cons type gnus-hidden-properties))))
1285 (defun gnus-article-unhide-text-type (b e type)
1286 "Unhide text of TYPE between B and E."
1287 (setq gnus-article-wash-types
1288 (delq type gnus-article-wash-types))
1289 (remove-text-properties
1290 b e (cons 'article-type (cons type gnus-hidden-properties)))
1291 (when (memq 'intangible gnus-hidden-properties)
1292 (put-text-property (max (1- b) (point-min))
1293 b 'intangible nil)))
1295 (defun gnus-article-hide-text-of-type (type)
1296 "Hide text of TYPE in the current buffer."
1298 (let ((b (point-min))
1300 (while (setq b (text-property-any b e 'article-type type))
1301 (add-text-properties b (incf b) gnus-hidden-properties)))))
1303 (defun gnus-article-delete-text-of-type (type)
1304 "Delete text of TYPE in the current buffer."
1306 (let ((b (point-min)))
1307 (while (setq b (text-property-any b (point-max) 'article-type type))
1309 b (or (text-property-not-all b (point-max) 'article-type type)
1312 (defun gnus-article-delete-invisible-text ()
1313 "Delete all invisible text in the current buffer."
1315 (let ((b (point-min)))
1316 (while (setq b (text-property-any b (point-max) 'invisible t))
1318 b (or (text-property-not-all b (point-max) 'invisible t)
1321 (defun gnus-article-text-type-exists-p (type)
1322 "Say whether any text of type TYPE exists in the buffer."
1323 (text-property-any (point-min) (point-max) 'article-type type))
1325 (defsubst gnus-article-header-rank ()
1326 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1327 (let ((list gnus-sorted-header-list)
1330 (when (looking-at (car list))
1332 (setq list (cdr list))
1336 (defun article-hide-headers (&optional arg delete)
1337 "Hide unwanted headers and possibly sort them as well."
1339 ;; This function might be inhibited.
1340 (unless gnus-inhibit-hiding
1343 (let ((buffer-read-only nil)
1344 (case-fold-search t)
1345 (max (1+ (length gnus-sorted-header-list)))
1346 (ignored (when (not gnus-visible-headers)
1347 (cond ((stringp gnus-ignored-headers)
1348 gnus-ignored-headers)
1349 ((listp gnus-ignored-headers)
1350 (mapconcat 'identity gnus-ignored-headers
1353 (cond ((stringp gnus-visible-headers)
1354 gnus-visible-headers)
1355 ((and gnus-visible-headers
1356 (listp gnus-visible-headers))
1357 (mapconcat 'identity gnus-visible-headers "\\|"))))
1358 (inhibit-point-motion-hooks t)
1360 ;; First we narrow to just the headers.
1361 (article-narrow-to-head)
1362 ;; Hide any "From " lines at the beginning of (mail) articles.
1363 (while (looking-at "From ")
1366 (delete-region (point-min) (point)))
1367 ;; Then treat the rest of the header lines.
1368 ;; Then we use the two regular expressions
1369 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1370 ;; select which header lines is to remain visible in the
1372 (while (re-search-forward "^[^ \t:]*:" nil t)
1374 ;; Mark the rank of the header.
1376 (point) (1+ (point)) 'message-rank
1377 (if (or (and visible (looking-at visible))
1379 (not (looking-at ignored))))
1380 (gnus-article-header-rank)
1383 (message-sort-headers-1)
1384 (when (setq beg (text-property-any
1385 (point-min) (point-max) 'message-rank (+ 2 max)))
1386 ;; We delete the unwanted headers.
1387 (push 'headers gnus-article-wash-types)
1388 (add-text-properties (point-min) (+ 5 (point-min))
1389 '(article-type headers dummy-invisible t))
1390 (delete-region beg (point-max))))))))
1392 (defun article-hide-boring-headers (&optional arg)
1393 "Toggle hiding of headers that aren't very interesting.
1394 If given a negative prefix, always show; if given a positive prefix,
1396 (interactive (gnus-article-hidden-arg))
1397 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1398 (not gnus-show-all-headers))
1401 (let ((buffer-read-only nil)
1402 (list gnus-boring-article-headers)
1403 (inhibit-point-motion-hooks t)
1405 (article-narrow-to-head)
1407 (setq elem (pop list))
1408 (goto-char (point-min))
1410 ;; Hide empty headers.
1412 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1414 (gnus-article-hide-text-type
1415 (progn (beginning-of-line) (point))
1418 (if (re-search-forward "^[^ \t]" nil t)
1422 ;; Hide boring Newsgroups header.
1423 ((eq elem 'newsgroups)
1424 (when (gnus-string-equal
1425 (gnus-fetch-field "newsgroups")
1426 (gnus-group-real-name
1427 (if (boundp 'gnus-newsgroup-name)
1430 (gnus-article-hide-header "newsgroups")))
1431 ((eq elem 'to-address)
1432 (let ((to (message-fetch-field "to"))
1434 (gnus-parameter-to-address
1435 (if (boundp 'gnus-newsgroup-name)
1436 gnus-newsgroup-name ""))))
1437 (when (and to to-address
1440 ;; only one address in To
1441 (nth 1 (mail-extract-address-components to))
1443 (gnus-article-hide-header "to"))))
1444 ((eq elem 'followup-to)
1445 (when (gnus-string-equal
1446 (message-fetch-field "followup-to")
1447 (message-fetch-field "newsgroups"))
1448 (gnus-article-hide-header "followup-to")))
1449 ((eq elem 'reply-to)
1450 (let ((from (message-fetch-field "from"))
1451 (reply-to (message-fetch-field "reply-to")))
1456 (nth 1 (mail-extract-address-components from))
1457 (nth 1 (mail-extract-address-components reply-to)))))
1458 (gnus-article-hide-header "reply-to"))))
1460 (let ((date (message-fetch-field "date")))
1462 (< (days-between (current-time-string) date)
1464 (gnus-article-hide-header "date"))))
1466 (let ((to (message-fetch-field "to"))
1467 (cc (message-fetch-field "cc")))
1468 (when (> (length to) 1024)
1469 (gnus-article-hide-header "to"))
1470 (when (> (length cc) 1024)
1471 (gnus-article-hide-header "cc"))))
1475 (goto-char (point-min))
1476 (while (re-search-forward "^to:" nil t)
1477 (setq to-count (1+ to-count)))
1478 (when (> to-count 1)
1479 (while (> to-count 0)
1480 (goto-char (point-min))
1482 (re-search-forward "^to:" nil nil to-count)
1484 (narrow-to-region (point) (point-max))
1485 (gnus-article-hide-header "to"))
1486 (setq to-count (1- to-count))))
1487 (goto-char (point-min))
1488 (while (re-search-forward "^cc:" nil t)
1489 (setq cc-count (1+ cc-count)))
1490 (when (> cc-count 1)
1491 (while (> cc-count 0)
1492 (goto-char (point-min))
1494 (re-search-forward "^cc:" nil nil cc-count)
1496 (narrow-to-region (point) (point-max))
1497 (gnus-article-hide-header "cc"))
1498 (setq cc-count (1- cc-count)))))))))))))
1500 (defun gnus-article-hide-header (header)
1502 (goto-char (point-min))
1503 (when (re-search-forward (concat "^" header ":") nil t)
1504 (gnus-article-hide-text-type
1505 (progn (beginning-of-line) (point))
1508 (if (re-search-forward "^[^ \t]" nil t)
1513 (defvar gnus-article-normalized-header-length 40
1514 "Length of normalized headers.")
1516 (defun article-normalize-headers ()
1517 "Make all header lines 40 characters long."
1519 (let ((buffer-read-only nil)
1523 (article-narrow-to-head)
1526 ((< (setq column (- (gnus-point-at-eol) (point)))
1527 gnus-article-normalized-header-length)
1529 (insert (make-string
1530 (- gnus-article-normalized-header-length column)
1532 ((> column gnus-article-normalized-header-length)
1533 (gnus-put-text-property
1535 (forward-char gnus-article-normalized-header-length)
1542 (forward-line 1))))))
1544 (defun article-treat-dumbquotes ()
1545 "Translate M****s*** sm*rtq**t*s into proper text.
1546 Note that this function guesses whether a character is a sm*rtq**t* or
1547 not, so it should only be used interactively.
1549 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1550 in an attempt to provide more quoting characters. If you see
1551 something like \\222 or \\264 where you're expecting some kind of
1552 apostrophe or quotation mark, then try this wash."
1554 (article-translate-strings gnus-article-dumbquotes-map))
1556 (defun article-translate-characters (from to)
1557 "Translate all characters in the body of the article according to FROM and TO.
1558 FROM is a string of characters to translate from; to is a string of
1559 characters to translate to."
1561 (when (article-goto-body)
1562 (let ((buffer-read-only nil)
1563 (x (make-string 225 ?x))
1565 (while (< (incf i) (length x))
1568 (while (< i (length from))
1569 (aset x (aref from i) (aref to i))
1571 (translate-region (point) (point-max) x)))))
1573 (defun article-translate-strings (map)
1574 "Translate all string in the body of the article according to MAP.
1575 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1577 (when (article-goto-body)
1578 (let ((buffer-read-only nil)
1580 (while (setq elem (pop map))
1582 (while (search-forward (car elem) nil t)
1583 (replace-match (cadr elem)))))))))
1585 (defun article-treat-overstrike ()
1586 "Translate overstrikes into bold text."
1589 (when (article-goto-body)
1590 (let ((buffer-read-only nil))
1591 (while (search-forward "\b" nil t)
1592 (let ((next (char-after))
1593 (previous (char-after (- (point) 2))))
1594 ;; We do the boldification/underlining by hiding the
1595 ;; overstrikes and putting the proper text property
1599 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1600 (put-text-property (point) (1+ (point)) 'face 'bold))
1602 (gnus-article-hide-text-type
1603 (1- (point)) (1+ (point)) 'overstrike)
1605 (- (point) 2) (1- (point)) 'face 'underline))
1607 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1609 (point) (1+ (point)) 'face 'underline)))))))))
1611 (defun gnus-article-treat-unfold-headers ()
1612 "Unfold folded message headers.
1613 Only the headers that fit into the current window width will be
1616 (gnus-with-article-headers
1620 (mail-header-narrow-to-field)
1621 (let ((header (buffer-substring (point-min) (point-max))))
1624 (goto-char (point-min))
1625 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1626 (replace-match " " t t)))
1627 (setq length (- (point-max) (point-min) 1)))
1628 (when (< length (window-width))
1629 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1630 (replace-match " " t t)))
1631 (goto-char (point-max)))))))
1633 (defun gnus-article-treat-body-boundary ()
1634 "Place a boundary line at the end of the headers."
1636 (gnus-with-article-headers
1637 (goto-char (point-max))
1638 (let ((start (point)))
1639 (insert "X-Boundary: ")
1640 (gnus-add-text-properties start (point) '(invisible t intangible t))
1641 (insert (make-string (1- (window-width)) ?-)
1643 ;;(put-text-property (point) (progn (forward-line -1) (point))
1644 ;; 'face 'gnus-body-bondary-face)
1647 (defun article-fill-long-lines ()
1648 "Fill lines that are wider than the window width."
1651 (let ((buffer-read-only nil)
1652 (width (window-width (get-buffer-window (current-buffer)))))
1655 (let ((adaptive-fill-mode nil)) ;Why? -sm
1658 (when (>= (current-column) (min fill-column width))
1659 (narrow-to-region (point) (gnus-point-at-bol))
1660 (fill-paragraph nil)
1661 (goto-char (point-max))
1663 (forward-line 1)))))))
1665 (defun article-capitalize-sentences ()
1666 "Capitalize the first word in each sentence."
1669 (let ((buffer-read-only nil)
1670 (paragraph-start "^[\n\^L]"))
1674 (forward-sentence)))))
1676 (defun article-remove-cr ()
1677 "Remove trailing CRs and then translate remaining CRs into LFs."
1680 (let ((buffer-read-only nil))
1681 (goto-char (point-min))
1682 (while (re-search-forward "\r+$" nil t)
1683 (replace-match "" t t))
1684 (goto-char (point-min))
1685 (while (search-forward "\r" nil t)
1686 (replace-match "\n" t t)))))
1688 (defun article-remove-trailing-blank-lines ()
1689 "Remove all trailing blank lines from the article."
1692 (let ((buffer-read-only nil))
1693 (goto-char (point-max))
1697 (while (and (not (bobp))
1698 (looking-at "^[ \t]*$")
1699 (not (gnus-annotation-in-region-p
1700 (point) (gnus-point-at-eol))))
1705 (defun article-display-x-face (&optional force)
1706 "Look for an X-Face header and display it if present."
1707 (interactive (list 'force))
1709 ;; Delete the old process, if any.
1710 (when (process-status "article-x-face")
1711 (delete-process "article-x-face"))
1712 (let ((inhibit-point-motion-hooks t)
1714 (case-fold-search t)
1717 (article-narrow-to-head)
1718 (when (and buffer-read-only ;; When type `W f'
1720 (goto-char (point-min))
1721 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1722 (gnus-buffer-live-p gnus-original-article-buffer))
1723 (with-current-buffer gnus-original-article-buffer
1725 (article-narrow-to-head)
1726 (while (re-search-forward "^X-Face:" nil t)
1732 (1- (re-search-forward
1733 "^\\($\\|[^ \t]\\)" nil t))))))))
1735 (let (point start bface eface buffer-read-only)
1736 (goto-char (point-max))
1738 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1739 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1740 (goto-char (point-max))
1741 (setq point (point))
1744 (while (looking-at "\\([^:]+\\): *")
1745 (put-text-property (match-beginning 1) (1+ (match-end 1))
1747 (setq start (match-end 0))
1749 (while (looking-at "[\t ]")
1751 (put-text-property start (point)
1753 (goto-char (point-min))
1754 (setq from (message-fetch-field "from"))
1755 (goto-char (point-min))
1756 (while (and gnus-article-x-face-command
1759 ;; Check whether this face is censored.
1760 (not gnus-article-x-face-too-ugly)
1761 (and gnus-article-x-face-too-ugly from
1762 (not (string-match gnus-article-x-face-too-ugly
1764 ;; Has to be present.
1765 (re-search-forward "^X-Face:[\t ]*" nil t))
1766 ;; This used to try to do multiple faces (`while' instead of
1767 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1768 ;; work (b) it can crash some versions of Emacs (c) are
1769 ;; multiple faces really something to encourage?
1770 (when (stringp gnus-article-x-face-command)
1772 ;; We now have the area of the buffer where the X-Face is stored.
1775 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))
1777 ;; We display the face.
1778 (if (symbolp gnus-article-x-face-command)
1779 ;; The command is a lisp function, so we call it.
1780 (if (gnus-functionp gnus-article-x-face-command)
1781 (funcall gnus-article-x-face-command beg end)
1782 (error "%s is not a function" gnus-article-x-face-command))
1783 ;; The command is a string, so we interpret the command
1784 ;; as a, well, command, and fork it off.
1785 (let ((process-connection-type nil))
1786 (process-kill-without-query
1788 "article-x-face" nil shell-file-name shell-command-switch
1789 gnus-article-x-face-command))
1790 (process-send-region "article-x-face" beg end)
1791 (process-send-eof "article-x-face"))))))))))
1793 (defun article-decode-mime-words ()
1794 "Decode all MIME-encoded words in the article."
1797 (set-buffer gnus-article-buffer)
1798 (let ((inhibit-point-motion-hooks t)
1800 (mail-parse-charset gnus-newsgroup-charset)
1801 (mail-parse-ignored-charsets
1802 (save-excursion (set-buffer gnus-summary-buffer)
1803 gnus-newsgroup-ignored-charsets)))
1804 (mail-decode-encoded-word-region (point-min) (point-max)))))
1806 (defun article-decode-charset (&optional prompt)
1807 "Decode charset-encoded text in the article.
1808 If PROMPT (the prefix), prompt for a coding system to use."
1810 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1812 (mail-parse-charset gnus-newsgroup-charset)
1813 (mail-parse-ignored-charsets
1814 (save-excursion (condition-case nil
1815 (set-buffer gnus-summary-buffer)
1817 gnus-newsgroup-ignored-charsets))
1818 ct cte ctl charset format)
1821 (article-narrow-to-head)
1822 (setq ct (message-fetch-field "Content-Type" t)
1823 cte (message-fetch-field "Content-Transfer-Encoding" t)
1824 ctl (and ct (ignore-errors
1825 (mail-header-parse-content-type ct)))
1828 (mm-read-coding-system "Charset to decode: "))
1830 (mail-content-type-get ctl 'charset)))
1831 format (and ctl (mail-content-type-get ctl 'format)))
1833 (setq cte (mail-header-strip cte)))
1834 (if (and ctl (not (string-match "/" (car ctl))))
1836 (goto-char (point-max)))
1839 (narrow-to-region (point) (point-max))
1840 (when (and (eq mail-parse-charset 'gnus-decoded)
1841 (eq (mm-body-7-or-8) '8bit))
1842 ;; The text code could have been decoded.
1843 (setq charset mail-parse-charset))
1844 (when (and (or (not ctl)
1845 (equal (car ctl) "text/plain"))
1846 (not format)) ;; article with format will decode later.
1848 charset (and cte (intern (downcase
1849 (gnus-strip-whitespace cte))))
1852 (defun article-decode-encoded-words ()
1853 "Remove encoded-word encoding from headers."
1854 (let ((inhibit-point-motion-hooks t)
1855 (mail-parse-charset gnus-newsgroup-charset)
1856 (mail-parse-ignored-charsets
1857 (save-excursion (condition-case nil
1858 (set-buffer gnus-summary-buffer)
1860 gnus-newsgroup-ignored-charsets))
1863 (article-narrow-to-head)
1864 (funcall gnus-decode-header-function (point-min) (point-max)))))
1866 (defun article-decode-group-name ()
1867 "Decode group names in `Newsgroups:'."
1868 (let ((inhibit-point-motion-hooks t)
1870 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1871 (when (and (or gnus-group-name-charset-method-alist
1872 gnus-group-name-charset-group-alist)
1873 (gnus-buffer-live-p gnus-original-article-buffer))
1874 (when (nnmail-fetch-field "Newsgroups")
1875 (nnheader-replace-header "Newsgroups"
1876 (gnus-decode-newsgroups
1877 (with-current-buffer
1878 gnus-original-article-buffer
1879 (nnmail-fetch-field "Newsgroups"))
1880 gnus-newsgroup-name method)))
1881 (when (nnmail-fetch-field "Followup-To")
1882 (nnheader-replace-header "Followup-To"
1883 (gnus-decode-newsgroups
1884 (with-current-buffer
1885 gnus-original-article-buffer
1886 (nnmail-fetch-field "Followup-To"))
1887 gnus-newsgroup-name method))))))
1889 (defun article-de-quoted-unreadable (&optional force read-charset)
1890 "Translate a quoted-printable-encoded article.
1891 If FORCE, decode the article whether it is marked as quoted-printable
1893 If READ-CHARSET, ask for a coding system."
1894 (interactive (list 'force current-prefix-arg))
1896 (let ((buffer-read-only nil) type charset)
1897 (if (gnus-buffer-live-p gnus-original-article-buffer)
1898 (with-current-buffer gnus-original-article-buffer
1900 (gnus-fetch-field "content-transfer-encoding"))
1901 (let* ((ct (gnus-fetch-field "content-type"))
1904 (mail-header-parse-content-type ct)))))
1905 (setq charset (and ctl
1906 (mail-content-type-get ctl 'charset)))
1907 (if (stringp charset)
1908 (setq charset (intern (downcase charset)))))))
1910 (setq charset (mm-read-coding-system "Charset: " charset)))
1912 (setq charset gnus-newsgroup-charset))
1914 (and type (let ((case-fold-search t))
1915 (string-match "quoted-printable" type))))
1917 (quoted-printable-decode-region
1918 (point) (point-max) (mm-charset-to-coding-system charset))))))
1920 (defun article-de-base64-unreadable (&optional force read-charset)
1921 "Translate a base64 article.
1922 If FORCE, decode the article whether it is marked as base64 not.
1923 If READ-CHARSET, ask for a coding system."
1924 (interactive (list 'force current-prefix-arg))
1926 (let ((buffer-read-only nil) type charset)
1927 (if (gnus-buffer-live-p gnus-original-article-buffer)
1928 (with-current-buffer gnus-original-article-buffer
1930 (gnus-fetch-field "content-transfer-encoding"))
1931 (let* ((ct (gnus-fetch-field "content-type"))
1934 (mail-header-parse-content-type ct)))))
1935 (setq charset (and ctl
1936 (mail-content-type-get ctl 'charset)))
1937 (if (stringp charset)
1938 (setq charset (intern (downcase charset)))))))
1940 (setq charset (mm-read-coding-system "Charset: " charset)))
1942 (setq charset gnus-newsgroup-charset))
1944 (and type (let ((case-fold-search t))
1945 (string-match "base64" type))))
1948 (narrow-to-region (point) (point-max))
1949 (base64-decode-region (point-min) (point-max))
1950 (mm-decode-coding-region
1951 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1956 (defun article-decode-HZ ()
1957 "Translate a HZ-encoded article."
1961 (let ((buffer-read-only nil))
1962 (rfc1843-decode-region (point-min) (point-max)))))
1964 (defun article-wash-html (&optional read-charset)
1965 "Format an html article.
1966 If READ-CHARSET, ask for a coding system."
1969 (let ((buffer-read-only nil)
1971 (if (gnus-buffer-live-p gnus-original-article-buffer)
1972 (with-current-buffer gnus-original-article-buffer
1973 (let* ((ct (gnus-fetch-field "content-type"))
1976 (mail-header-parse-content-type ct)))))
1977 (setq charset (and ctl
1978 (mail-content-type-get ctl 'charset)))
1979 (if (stringp charset)
1980 (setq charset (intern (downcase charset)))))))
1982 (setq charset (mm-read-coding-system "Charset: " charset)))
1984 (setq charset gnus-newsgroup-charset))
1986 (save-window-excursion
1988 (narrow-to-region (point) (point-max))
1990 (let ((w3-strict-width (window-width))
1991 (url-standalone-mode t)
1992 (w3-honor-stylesheets nil)
1993 (w3-delay-image-loads t))
1995 (w3-region (point-min) (point-max))
1998 (defun article-hide-list-identifiers ()
1999 "Remove list identifies from the Subject header.
2000 The `gnus-list-identifiers' variable specifies what to do."
2002 (let ((inhibit-point-motion-hooks t)
2003 (regexp (if (consp gnus-list-identifiers)
2004 (mapconcat 'identity gnus-list-identifiers " *\\|")
2005 gnus-list-identifiers))
2010 (article-narrow-to-head)
2011 (goto-char (point-min))
2012 (while (re-search-forward
2013 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2015 (delete-region (match-beginning 2) (match-end 0))
2016 (beginning-of-line))
2017 (when (re-search-forward
2018 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2019 (delete-region (match-beginning 1) (match-end 1))))))))
2021 (defun article-hide-pgp ()
2022 "Remove any PGP headers and signatures in the current article."
2026 (let ((inhibit-point-motion-hooks t)
2027 buffer-read-only beg end)
2029 ;; Hide the "header".
2030 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2031 (push 'pgp gnus-article-wash-types)
2032 (delete-region (match-beginning 0) (match-end 0))
2033 ;; Remove armor headers (rfc2440 6.2)
2034 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2037 ;; Hide the actual signature.
2038 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2039 (setq end (1+ (match-beginning 0)))
2042 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2044 ;; Perhaps we shouldn't hide to the end of the buffer
2045 ;; if there is no end to the signature?
2047 ;; Hide "- " PGP quotation markers.
2049 (narrow-to-region beg end)
2050 (goto-char (point-min))
2051 (while (re-search-forward "^- " nil t)
2053 (match-beginning 0) (match-end 0)))
2055 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2057 (defun article-hide-pem (&optional arg)
2058 "Toggle hiding of any PEM headers and signatures in the current article.
2059 If given a negative prefix, always show; if given a positive prefix,
2061 (interactive (gnus-article-hidden-arg))
2062 (unless (gnus-article-check-hidden-text 'pem arg)
2064 (let (buffer-read-only end)
2065 (goto-char (point-min))
2066 ;; Hide the horrendously ugly "header".
2067 (when (and (search-forward
2068 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2070 (setq end (1+ (match-beginning 0))))
2071 (push 'pem gnus-article-wash-types)
2072 (gnus-article-hide-text-type
2074 (if (search-forward "\n\n" nil t)
2078 ;; Hide the trailer as well
2079 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2081 (gnus-article-hide-text-type
2082 (match-beginning 0) (match-end 0) 'pem)))))))
2084 (defun article-strip-banner ()
2085 "Strip the banner specified by the `banner' group parameter."
2089 (let ((inhibit-point-motion-hooks t)
2090 (banner (gnus-parameter-banner gnus-newsgroup-name))
2091 (gnus-signature-limit nil)
2092 buffer-read-only beg end)
2096 ((eq banner 'signature)
2097 (when (gnus-article-narrow-to-signature)
2100 (delete-region (point) (point-max))))
2102 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2103 (while (re-search-forward banner nil t)
2104 (delete-region (match-beginning 0) (match-end 0)))))
2106 (while (re-search-forward banner nil t)
2107 (delete-region (match-beginning 0) (match-end 0))))))))))
2109 (defun article-babel ()
2110 "Translate article using an online translation service."
2114 (set-buffer gnus-article-buffer)
2115 (when (article-goto-body)
2116 (let* ((buffer-read-only nil)
2119 (orig (buffer-substring start end))
2120 (trans (babel-as-string orig)))
2122 (narrow-to-region start end)
2123 (delete-region start end)
2126 (defun article-hide-signature (&optional arg)
2127 "Hide the signature in the current article.
2128 If given a negative prefix, always show; if given a positive prefix,
2130 (interactive (gnus-article-hidden-arg))
2131 (unless (gnus-article-check-hidden-text 'signature arg)
2134 (let ((buffer-read-only nil))
2135 (when (gnus-article-narrow-to-signature)
2136 (gnus-article-hide-text-type
2137 (point-min) (point-max) 'signature))))))
2138 (gnus-set-mode-line 'article))
2140 (defun article-strip-headers-in-body ()
2141 "Strip offensive headers from bodies."
2145 (let ((case-fold-search t))
2146 (when (looking-at "x-no-archive:")
2147 (gnus-delete-line)))))
2149 (defun article-strip-leading-blank-lines ()
2150 "Remove all blank lines from the beginning of the article."
2153 (let ((inhibit-point-motion-hooks t)
2155 (when (article-goto-body)
2156 (while (and (not (eobp))
2157 (looking-at "[ \t]*$"))
2158 (gnus-delete-line))))))
2160 (defun article-narrow-to-head ()
2161 "Narrow the buffer to the head of the message.
2162 Point is left at the beginning of the narrowed-to region."
2164 (goto-char (point-min))
2165 (if (search-forward "\n\n" nil 1)
2168 (goto-char (point-min)))
2170 (defun article-goto-body ()
2171 "Place point at the start of the body."
2172 (goto-char (point-min))
2174 ;; This variable is only bound when dealing with separate
2176 (article-goto-body-goes-to-point-min-p
2178 ((search-forward "\n\n" nil t)
2181 (goto-char (point-max))
2184 (defun article-strip-multiple-blank-lines ()
2185 "Replace consecutive blank lines with one empty line."
2188 (let ((inhibit-point-motion-hooks t)
2190 ;; First make all blank lines empty.
2192 (while (re-search-forward "^[ \t]+$" nil t)
2193 (unless (gnus-annotation-in-region-p
2194 (match-beginning 0) (match-end 0))
2195 (replace-match "" nil t)))
2196 ;; Then replace multiple empty lines with a single empty line.
2198 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2199 (unless (gnus-annotation-in-region-p
2200 (match-beginning 0) (match-end 0))
2201 (delete-region (match-beginning 1) (match-end 1)))))))
2203 (defun article-strip-leading-space ()
2204 "Remove all white space from the beginning of the lines in the article."
2207 (let ((inhibit-point-motion-hooks t)
2210 (while (re-search-forward "^[ \t]+" nil t)
2211 (replace-match "" t t)))))
2213 (defun article-strip-trailing-space ()
2214 "Remove all white space from the end of the lines in the article."
2217 (let ((inhibit-point-motion-hooks t)
2220 (while (re-search-forward "[ \t]+$" nil t)
2221 (replace-match "" t t)))))
2223 (defun article-strip-blank-lines ()
2224 "Strip leading, trailing and multiple blank lines."
2226 (article-strip-leading-blank-lines)
2227 (article-remove-trailing-blank-lines)
2228 (article-strip-multiple-blank-lines))
2230 (defun article-strip-all-blank-lines ()
2231 "Strip all blank lines."
2234 (let ((inhibit-point-motion-hooks t)
2237 (while (re-search-forward "^[ \t]*\n" nil t)
2238 (replace-match "" t t)))))
2240 (defun gnus-article-narrow-to-signature ()
2241 "Narrow to the signature; return t if a signature is found, else nil."
2242 (let ((inhibit-point-motion-hooks t))
2243 (when (gnus-article-search-signature)
2245 ;; Check whether we have some limits to what we consider
2246 ;; to be a signature.
2247 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2248 (list gnus-signature-limit)))
2250 (while (setq limit (pop limits))
2251 (if (or (and (integerp limit)
2252 (< (- (point-max) (point)) limit))
2254 (< (count-lines (point) (point-max)) limit))
2255 (and (gnus-functionp limit)
2257 (and (stringp limit)
2258 (not (re-search-forward limit nil t))))
2259 () ; This limit did not succeed.
2263 (narrow-to-region (point) (point-max))
2266 (defun gnus-article-search-signature ()
2267 "Search the current buffer for the signature separator.
2268 Put point at the beginning of the signature separator."
2269 (let ((cur (point)))
2270 (goto-char (point-max))
2271 (if (if (stringp gnus-signature-separator)
2272 (re-search-backward gnus-signature-separator nil t)
2273 (let ((seps gnus-signature-separator))
2275 (not (re-search-backward (car seps) nil t)))
2282 (defun gnus-article-hidden-arg ()
2283 "Return the current prefix arg as a number, or 0 if no prefix."
2284 (list (if current-prefix-arg
2285 (prefix-numeric-value current-prefix-arg)
2288 (defun gnus-article-check-hidden-text (type arg)
2289 "Return nil if hiding is necessary.
2290 Arg can be nil or a number. nil and positive means hide, negative
2291 means show, 0 means toggle."
2294 (let ((hide (gnus-article-hidden-text-p type)))
2300 (gnus-article-show-hidden-text type)
2303 (if (eq hide 'hidden)
2305 (gnus-article-show-hidden-text type)
2309 (defun gnus-article-hidden-text-p (type)
2310 "Say whether the current buffer contains hidden text of type TYPE."
2311 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2313 (not (get-text-property pos 'invisible))
2314 (not (get-text-property pos 'dummy-invisible)))
2316 (text-property-any (1+ pos) (point-max) 'article-type type)))
2321 (defun gnus-article-show-hidden-text (type &optional dummy)
2322 "Show all hidden text of type TYPE.
2323 Originally it is hide instead of DUMMY."
2324 (let ((buffer-read-only nil)
2325 (inhibit-point-motion-hooks t))
2326 (gnus-remove-text-properties-when
2328 (point-min) (point-max)
2329 (cons 'article-type (cons type
2330 gnus-hidden-properties)))
2331 (setq gnus-article-wash-types (delq type gnus-article-wash-types))))
2333 (defconst article-time-units
2334 `((year . ,(* 365.25 24 60 60))
2335 (week . ,(* 7 24 60 60))
2336 (day . ,(* 24 60 60))
2340 "Mapping from time units to seconds.")
2342 (defun article-date-ut (&optional type highlight header)
2343 "Convert DATE date to universal time in the current article.
2344 If TYPE is `local', convert to local time; if it is `lapsed', output
2345 how much time has lapsed since DATE. For `lapsed', the value of
2346 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2347 should replace the \"Date:\" one, or should be added below it."
2348 (interactive (list 'ut t))
2349 (let* ((header (or header
2350 (message-fetch-field "date")
2352 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2355 ((not gnus-article-date-lapsed-new-header)
2361 (date (if (vectorp header) (mail-header-date header)
2363 (inhibit-point-motion-hooks t)
2368 (article-narrow-to-head)
2369 (when (re-search-forward tdate-regexp nil t)
2370 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2371 date (or (get-text-property (gnus-point-at-bol)
2374 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2376 (when (and date (not (string= date "")))
2377 (goto-char (point-min))
2378 (let ((buffer-read-only nil))
2379 ;; Delete any old Date headers.
2380 (while (re-search-forward date-regexp nil t)
2382 (delete-region (progn (beginning-of-line) (point))
2383 (progn (forward-line 1) (point)))
2384 (delete-region (progn (beginning-of-line) (point))
2385 (progn (end-of-line) (point)))
2386 (setq pos (point))))
2387 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2389 (if pos (goto-char pos))
2390 (insert (article-make-date-line date (or type 'ut)))
2396 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2397 (put-text-property (match-beginning 1) (1+ (match-end 1))
2398 'original-date date)
2399 (put-text-property (match-beginning 1) (1+ (match-end 1))
2401 (put-text-property (match-beginning 2) (match-end 2)
2404 (defun article-make-date-line (date type)
2405 "Return a DATE line of TYPE."
2406 (unless (memq type '(local ut original user iso8601 lapsed english))
2407 (error "Unknown conversion type: %s" type))
2409 (let ((time (date-to-time date)))
2411 ;; Convert to the local timezone.
2413 (let ((tz (car (current-time-zone time))))
2414 (format "Date: %s %s%02d%02d" (current-time-string time)
2415 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2416 (/ (% (abs tz) 3600) 60))))
2417 ;; Convert to Universal Time.
2420 (current-time-string
2421 (let* ((e (parse-time-string date))
2422 (tm (apply 'encode-time e))
2424 (ls (- (cadr tm) (car (current-time-zone time)))))
2425 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2426 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2429 ;; Get the original date from the article.
2430 ((eq type 'original)
2431 (concat "Date: " (if (string-match "\n+$" date)
2432 (substring date 0 (match-beginning 0))
2434 ;; Let the user define the format.
2436 (if (gnus-functionp gnus-article-time-format)
2437 (funcall gnus-article-time-format time)
2440 (format-time-string gnus-article-time-format time))))
2443 (let ((tz (car (current-time-zone time))))
2446 (format-time-string "%Y%m%dT%H%M%S" time)
2447 (format "%s%02d%02d"
2448 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2449 (/ (% (abs tz) 3600) 60)))))
2450 ;; Do an X-Sent lapsed format.
2452 ;; If the date is seriously mangled, the timezone functions are
2453 ;; liable to bug out, so we ignore all errors.
2454 (let* ((now (current-time))
2455 (real-time (subtract-time now time))
2456 (real-sec (and real-time
2457 (+ (* (float (car real-time)) 65536)
2459 (sec (and real-time (abs real-sec)))
2469 ;; This is a bit convoluted, but basically we go
2470 ;; through the time units for years, weeks, etc,
2471 ;; and divide things to see whether that results
2472 ;; in positive answers.
2475 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2476 ;; The (remaining) seconds are too few to
2477 ;; be divided into this time unit.
2479 ;; It's big enough, so we output it.
2480 (setq sec (- sec (* num (cdr unit))))
2482 (concat (if prev ", " "") (int-to-string
2484 " " (symbol-name (car unit))
2485 (if (> num 1) "s" ""))
2487 article-time-units "")
2488 ;; If dates are odd, then it might appear like the
2489 ;; article was sent in the future.
2492 " in the future"))))))
2493 ;; Display the date in proper English
2495 (let ((dtime (decode-time time)))
2498 (number-to-string (nth 3 dtime))
2499 (let ((digit (% (nth 3 dtime) 10)))
2501 ((memq (nth 3 dtime) '(11 12 13)) "th")
2507 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2509 (number-to-string (nth 5 dtime))
2511 (format "%02d" (nth 2 dtime))
2513 (format "%02d" (nth 1 dtime)))))))
2515 (format "Date: %s (from Oort)" date))))
2517 (defun article-date-local (&optional highlight)
2518 "Convert the current article date to the local timezone."
2519 (interactive (list t))
2520 (article-date-ut 'local highlight))
2522 (defun article-date-english (&optional highlight)
2523 "Convert the current article date to something that is proper English."
2524 (interactive (list t))
2525 (article-date-ut 'english highlight))
2527 (defun article-date-original (&optional highlight)
2528 "Convert the current article date to what it was originally.
2529 This is only useful if you have used some other date conversion
2530 function and want to see what the date was before converting."
2531 (interactive (list t))
2532 (article-date-ut 'original highlight))
2534 (defun article-date-lapsed (&optional highlight)
2535 "Convert the current article date to time lapsed since it was sent."
2536 (interactive (list t))
2537 (article-date-ut 'lapsed highlight))
2539 (defun article-update-date-lapsed ()
2540 "Function to be run from a timer to update the lapsed time line."
2541 (let (deactivate-mark)
2546 (set-buffer (window-buffer w))
2547 (when (eq major-mode 'gnus-article-mode)
2548 (goto-char (point-min))
2549 (when (re-search-forward "^X-Sent:" nil t)
2550 (article-date-lapsed t))))
2553 (defun gnus-start-date-timer (&optional n)
2554 "Start a timer to update the X-Sent header in the article buffers.
2555 The numerical prefix says how frequently (in seconds) the function
2560 (gnus-stop-date-timer)
2561 (setq article-lapsed-timer
2562 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2564 (defun gnus-stop-date-timer ()
2565 "Stop the X-Sent timer."
2567 (when article-lapsed-timer
2568 (nnheader-cancel-timer article-lapsed-timer)
2569 (setq article-lapsed-timer nil)))
2571 (defun article-date-user (&optional highlight)
2572 "Convert the current article date to the user-defined format.
2573 This format is defined by the `gnus-article-time-format' variable."
2574 (interactive (list t))
2575 (article-date-ut 'user highlight))
2577 (defun article-date-iso8601 (&optional highlight)
2578 "Convert the current article date to ISO8601."
2579 (interactive (list t))
2580 (article-date-ut 'iso8601 highlight))
2582 (defun article-show-all ()
2583 "Show all hidden text in the article buffer."
2586 (let ((buffer-read-only nil))
2587 (gnus-article-unhide-text (point-min) (point-max)))))
2589 (defun article-remove-leading-whitespace ()
2590 "Remove excessive whitespace from all headers."
2594 (let ((buffer-read-only nil))
2595 (article-narrow-to-head)
2596 (goto-char (point-min))
2597 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2598 (delete-region (match-beginning 1) (match-end 1)))))))
2600 (defun article-emphasize (&optional arg)
2601 "Emphasize text according to `gnus-emphasis-alist'."
2602 (interactive (gnus-article-hidden-arg))
2603 (unless (gnus-article-check-hidden-text 'emphasis arg)
2607 (with-current-buffer gnus-summary-buffer
2608 gnus-article-emphasis-alist)
2610 gnus-emphasis-alist))
2611 (buffer-read-only nil)
2612 (props (append '(article-type emphasis)
2613 gnus-hidden-properties))
2614 regexp elem beg invisible visible face)
2617 (while (setq elem (pop alist))
2619 (setq regexp (car elem)
2620 invisible (nth 1 elem)
2621 visible (nth 2 elem)
2623 (while (re-search-forward regexp nil t)
2624 (when (and (match-beginning visible) (match-beginning invisible))
2625 (gnus-article-hide-text
2626 (match-beginning invisible) (match-end invisible) props)
2627 (gnus-article-unhide-text-type
2628 (match-beginning visible) (match-end visible) 'emphasis)
2629 (gnus-put-overlay-excluding-newlines
2630 (match-beginning visible) (match-end visible) 'face face)
2631 (push 'emphasis gnus-article-wash-types)
2632 (goto-char (match-end invisible)))))))))
2634 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2635 "Setup newsgroup emphasis alist."
2636 (unless gnus-article-emphasis-alist
2637 (let ((name (and gnus-newsgroup-name
2638 (gnus-group-real-name gnus-newsgroup-name))))
2639 (make-local-variable 'gnus-article-emphasis-alist)
2640 (setq gnus-article-emphasis-alist
2642 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2643 (while (setq elem (pop alist))
2644 (when (and name (string-match (car elem) name))
2646 highlight (copy-sequence (cdr elem)))))
2648 (copy-sequence highlight-words)
2649 (if gnus-newsgroup-name
2650 (copy-sequence (gnus-group-find-parameter
2651 gnus-newsgroup-name 'highlight-words t)))
2652 gnus-emphasis-alist)))))
2655 (defvar gnus-summary-article-menu)
2656 (defvar gnus-summary-post-menu))
2658 ;;; Saving functions.
2660 (defun gnus-article-save (save-buffer file &optional num)
2661 "Save the currently selected article."
2662 (unless gnus-save-all-headers
2663 ;; Remove headers according to `gnus-saved-headers'.
2664 (let ((gnus-visible-headers
2665 (or gnus-saved-headers gnus-visible-headers))
2666 (gnus-article-buffer save-buffer))
2668 (set-buffer save-buffer)
2669 (article-hide-headers 1 t))))
2670 (save-window-excursion
2671 (if (not gnus-default-article-saver)
2672 (error "No default saver is defined")
2673 ;; !!! Magic! The saving functions all save
2674 ;; `gnus-save-article-buffer' (or so they think), but we
2675 ;; bind that variable to our save-buffer.
2676 (set-buffer gnus-article-buffer)
2677 (let* ((gnus-save-article-buffer save-buffer)
2680 ((not gnus-prompt-before-saving) 'default)
2681 ((eq gnus-prompt-before-saving 'always) nil)
2683 (gnus-number-of-articles-to-be-saved
2684 (when (eq gnus-prompt-before-saving t)
2686 (set-buffer gnus-article-current-summary)
2687 (funcall gnus-default-article-saver filename)))))
2689 (defun gnus-read-save-file-name (prompt &optional filename
2690 function group headers variable)
2692 (funcall function group headers (symbol-value variable)))
2697 ((eq filename 'default)
2703 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2706 (if (and gnus-number-of-articles-to-be-saved
2707 (> gnus-number-of-articles-to-be-saved 1))
2708 (format "these %d articles"
2709 gnus-number-of-articles-to-be-saved)
2712 ;; Let the split methods have their say.
2714 ;; No split name was found.
2717 (concat prompt " (default "
2718 (file-name-nondirectory default-name) ") ")
2719 (file-name-directory default-name)
2721 ;; A single group name is returned.
2722 ((stringp split-name)
2724 (funcall function split-name headers
2725 (symbol-value variable)))
2727 (concat prompt " (default "
2728 (file-name-nondirectory default-name) ") ")
2729 (file-name-directory default-name)
2731 ;; A single split name was found
2732 ((= 1 (length split-name))
2733 (let* ((name (expand-file-name
2735 gnus-article-save-directory))
2736 (dir (cond ((file-directory-p name)
2737 (file-name-as-directory name))
2738 ((file-exists-p name) name)
2739 (t gnus-article-save-directory))))
2741 (concat prompt " (default " name ") ")
2743 ;; A list of splits was found.
2745 (setq split-name (nreverse split-name))
2747 (let ((file-name-history
2748 (nconc split-name file-name-history)))
2752 (concat prompt " (`M-p' for defaults) ")
2753 gnus-article-save-directory
2755 gnus-article-save-directory)))
2756 (car (push result file-name-history)))))))
2757 ;; Create the directory.
2758 (gnus-make-directory (file-name-directory file))
2759 ;; If we have read a directory, we append the default file name.
2760 (when (file-directory-p file)
2761 (setq file (expand-file-name (file-name-nondirectory
2763 (file-name-as-directory file))))
2764 ;; Possibly translate some characters.
2765 (nnheader-translate-file-chars file))))))
2766 (gnus-make-directory (file-name-directory result))
2767 (set variable result)))
2769 (defun gnus-article-archive-name (group)
2770 "Return the first instance of an \"Archive-name\" in the current buffer."
2771 (let ((case-fold-search t))
2772 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2773 (nnheader-concat gnus-article-save-directory
2774 (match-string 1)))))
2776 (defun gnus-article-nndoc-name (group)
2777 "If GROUP is an nndoc group, return the name of the parent group."
2778 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2779 (gnus-group-get-parameter group 'save-article-group)))
2781 (defun gnus-summary-save-in-rmail (&optional filename)
2782 "Append this article to Rmail file.
2783 Optional argument FILENAME specifies file name.
2784 Directory to save to is default to `gnus-article-save-directory'."
2785 (setq filename (gnus-read-save-file-name
2786 "Save %s in rmail file:" filename
2787 gnus-rmail-save-name gnus-newsgroup-name
2788 gnus-current-headers 'gnus-newsgroup-last-rmail))
2789 (gnus-eval-in-buffer-window gnus-save-article-buffer
2793 (gnus-output-to-rmail filename))))
2796 (defun gnus-summary-save-in-mail (&optional filename)
2797 "Append this article to Unix mail file.
2798 Optional argument FILENAME specifies file name.
2799 Directory to save to is default to `gnus-article-save-directory'."
2800 (setq filename (gnus-read-save-file-name
2801 "Save %s in Unix mail file:" filename
2802 gnus-mail-save-name gnus-newsgroup-name
2803 gnus-current-headers 'gnus-newsgroup-last-mail))
2804 (gnus-eval-in-buffer-window gnus-save-article-buffer
2808 (if (and (file-readable-p filename)
2809 (mail-file-babyl-p filename))
2810 (rmail-output-to-rmail-file filename t)
2811 (gnus-output-to-mail filename)))))
2814 (defun gnus-summary-save-in-file (&optional filename overwrite)
2815 "Append this article to file.
2816 Optional argument FILENAME specifies file name.
2817 Directory to save to is default to `gnus-article-save-directory'."
2818 (setq filename (gnus-read-save-file-name
2819 "Save %s in file:" filename
2820 gnus-file-save-name gnus-newsgroup-name
2821 gnus-current-headers 'gnus-newsgroup-last-file))
2822 (gnus-eval-in-buffer-window gnus-save-article-buffer
2826 (when (and overwrite
2827 (file-exists-p filename))
2828 (delete-file filename))
2829 (gnus-output-to-file filename))))
2832 (defun gnus-summary-write-to-file (&optional filename)
2833 "Write this article to a file, overwriting it if the file exists.
2834 Optional argument FILENAME specifies file name.
2835 The directory to save in defaults to `gnus-article-save-directory'."
2836 (gnus-summary-save-in-file nil t))
2838 (defun gnus-summary-save-body-in-file (&optional filename)
2839 "Append this article body to a file.
2840 Optional argument FILENAME specifies file name.
2841 The directory to save in defaults to `gnus-article-save-directory'."
2842 (setq filename (gnus-read-save-file-name
2843 "Save %s body in file:" filename
2844 gnus-file-save-name gnus-newsgroup-name
2845 gnus-current-headers 'gnus-newsgroup-last-file))
2846 (gnus-eval-in-buffer-window gnus-save-article-buffer
2850 (when (article-goto-body)
2851 (narrow-to-region (point) (point-max)))
2852 (gnus-output-to-file filename))))
2855 (defun gnus-summary-save-in-pipe (&optional command)
2856 "Pipe this article to subprocess."
2858 (cond ((and (eq command 'default)
2859 gnus-last-shell-command)
2860 gnus-last-shell-command)
2865 "Shell command on %s: "
2866 (if (and gnus-number-of-articles-to-be-saved
2867 (> gnus-number-of-articles-to-be-saved 1))
2868 (format "these %d articles"
2869 gnus-number-of-articles-to-be-saved)
2871 gnus-last-shell-command))))
2872 (when (string-equal command "")
2873 (if gnus-last-shell-command
2874 (setq command gnus-last-shell-command)
2875 (error "A command is required")))
2876 (gnus-eval-in-buffer-window gnus-article-buffer
2879 (shell-command-on-region (point-min) (point-max) command nil)))
2880 (setq gnus-last-shell-command command))
2882 (defun gnus-summary-pipe-to-muttprint (&optional command)
2883 "Pipe this article to muttprint."
2884 (setq command (read-string
2885 "Print using command: " gnus-summary-muttprint-program
2886 nil gnus-summary-muttprint-program))
2887 (gnus-summary-save-in-pipe command))
2889 ;;; Article file names when saving.
2891 (defun gnus-capitalize-newsgroup (newsgroup)
2892 "Capitalize NEWSGROUP name."
2893 (when (not (zerop (length newsgroup)))
2894 (concat (char-to-string (upcase (aref newsgroup 0)))
2895 (substring newsgroup 1))))
2897 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2898 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2899 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2900 Otherwise, it is like ~/News/news/group/num."
2903 (concat (if (gnus-use-long-file-name 'not-save)
2904 (gnus-capitalize-newsgroup newsgroup)
2905 (gnus-newsgroup-directory-form newsgroup))
2906 "/" (int-to-string (mail-header-number headers)))
2907 gnus-article-save-directory)))
2909 (string-equal (file-name-directory default)
2910 (file-name-directory last-file))
2911 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2913 (or last-file default))))
2915 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2916 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2917 If variable `gnus-use-long-file-name' is non-nil, it is
2918 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2921 (concat (if (gnus-use-long-file-name 'not-save)
2923 (gnus-newsgroup-directory-form newsgroup))
2924 "/" (int-to-string (mail-header-number headers)))
2925 gnus-article-save-directory)))
2927 (string-equal (file-name-directory default)
2928 (file-name-directory last-file))
2929 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2931 (or last-file default))))
2933 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2934 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2935 If variable `gnus-use-long-file-name' is non-nil, it is
2936 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2939 (if (gnus-use-long-file-name 'not-save)
2942 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2944 gnus-article-save-directory)))
2946 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2947 "Generate file name from sender."
2948 (let ((from (mail-header-from headers)))
2950 (if (and from (string-match "\\([^ <]+\\)@" from))
2951 (match-string 1 from)
2953 gnus-article-save-directory)))
2955 (defun article-verify-x-pgp-sig ()
2958 (if (gnus-buffer-live-p gnus-original-article-buffer)
2959 (let ((sig (with-current-buffer gnus-original-article-buffer
2960 (gnus-fetch-field "X-PGP-Sig")))
2964 (mml2015-clear-verify-function))
2966 (insert-buffer gnus-original-article-buffer)
2967 (setq items (split-string sig))
2968 (message-narrow-to-head)
2969 (let ((inhibit-point-motion-hooks t)
2970 (case-fold-search t))
2971 ;; Don't verify multiple headers.
2972 (setq headers (mapconcat (lambda (header)
2974 (mail-fetch-field header) "\n"))
2975 (split-string (nth 1 items) ",") "")))
2976 (delete-region (point-min) (point-max))
2977 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2978 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2983 (if (looking-at "^-")
2986 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2987 (insert "Version: " (car items) "\n\n")
2988 (insert (mapconcat 'identity (cddr items) "\n"))
2989 (insert "\n-----END PGP SIGNATURE-----\n")
2990 (let ((mm-security-handle (list (format "multipart/signed"))))
2991 (mml2015-clean-buffer)
2992 (let ((coding-system-for-write (or gnus-newsgroup-charset
2994 (funcall (mml2015-clear-verify-function)))
2996 (or (mm-handle-multipart-ctl-parameter
2997 mm-security-handle 'gnus-details)
2998 (mm-handle-multipart-ctl-parameter
2999 mm-security-handle 'gnus-info)))))
3001 (let (buffer-read-only bface eface)
3003 (message-narrow-to-head)
3004 (goto-char (point-max))
3006 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3007 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3008 (message-remove-header "X-Gnus-PGP-Verify")
3009 (if (re-search-forward "^X-PGP-Sig:" nil t)
3011 (goto-char (point-max)))
3012 (narrow-to-region (point) (point))
3013 (insert "X-Gnus-PGP-Verify: " info "\n")
3014 (goto-char (point-min))
3017 (if (not (looking-at "^[ \t]"))
3021 (goto-char (point-min))
3022 (when (looking-at "\\([^:]+\\): *")
3023 (put-text-property (match-beginning 1) (1+ (match-end 1))
3025 (put-text-property (match-end 0) (point-max)
3026 'face eface)))))))))
3028 (defun article-verify-cancel-lock ()
3029 "Verify Cancel-Lock header."
3031 (if (gnus-buffer-live-p gnus-original-article-buffer)
3032 (canlock-verify gnus-original-article-buffer)))
3039 (setq afunc (car func)
3042 gfunc (intern (format "gnus-%s" func))))
3045 `(lambda (&optional interactive &rest args)
3046 ,(documentation afunc t)
3047 (interactive (list t))
3049 (set-buffer gnus-article-buffer)
3051 (call-interactively ',afunc)
3052 (apply ',afunc args))))))))
3053 '(article-hide-headers
3054 article-verify-x-pgp-sig
3055 article-verify-cancel-lock
3056 article-hide-boring-headers
3057 article-treat-overstrike
3058 article-fill-long-lines
3059 article-capitalize-sentences
3061 article-remove-leading-whitespace
3062 article-display-x-face
3063 article-de-quoted-unreadable
3064 article-de-base64-unreadable
3067 article-hide-list-identifiers
3069 article-strip-banner
3072 article-hide-signature
3073 article-strip-headers-in-body
3074 article-remove-trailing-blank-lines
3075 article-strip-leading-blank-lines
3076 article-strip-multiple-blank-lines
3077 article-strip-leading-space
3078 article-strip-trailing-space
3079 article-strip-blank-lines
3080 article-strip-all-blank-lines
3081 article-replace-with-quoted-text
3083 article-date-english
3084 article-date-iso8601
3085 article-date-original
3087 article-decode-mime-words
3088 article-decode-charset
3089 article-decode-encoded-words
3093 article-treat-dumbquotes
3094 article-normalize-headers
3095 (article-show-all . gnus-article-show-all-headers))))
3098 ;;; Gnus article mode
3101 (put 'gnus-article-mode 'mode-class 'special)
3103 (set-keymap-parent gnus-article-mode-map widget-keymap)
3105 (gnus-define-keys gnus-article-mode-map
3106 " " gnus-article-goto-next-page
3107 "\177" gnus-article-goto-prev-page
3108 [delete] gnus-article-goto-prev-page
3109 [backspace] gnus-article-goto-prev-page
3110 "\C-c^" gnus-article-refer-article
3111 "h" gnus-article-show-summary
3112 "s" gnus-article-show-summary
3113 "\C-c\C-m" gnus-article-mail
3114 "?" gnus-article-describe-briefly
3115 "e" gnus-summary-edit-article
3116 "<" beginning-of-buffer
3118 "\C-c\C-i" gnus-info-find-node
3120 "\C-hk" gnus-article-describe-key
3121 "\C-hc" gnus-article-describe-key-briefly
3123 "\C-d" gnus-article-read-summary-keys
3124 "\M-*" gnus-article-read-summary-keys
3125 "\M-#" gnus-article-read-summary-keys
3126 "\M-^" gnus-article-read-summary-keys
3127 "\M-g" gnus-article-read-summary-keys)
3129 (substitute-key-definition
3130 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3132 (defun gnus-article-make-menu-bar ()
3133 (unless (boundp 'gnus-article-commands-menu)
3134 (gnus-summary-make-menu-bar))
3135 (gnus-turn-off-edit-menu 'article)
3136 (unless (boundp 'gnus-article-article-menu)
3138 gnus-article-article-menu gnus-article-mode-map ""
3140 ["Scroll forwards" gnus-article-goto-next-page t]
3141 ["Scroll backwards" gnus-article-goto-prev-page t]
3142 ["Show summary" gnus-article-show-summary t]
3143 ["Fetch Message-ID at point" gnus-article-refer-article t]
3144 ["Mail to address at point" gnus-article-mail t]
3145 ["Send a bug report" gnus-bug t]))
3148 gnus-article-treatment-menu gnus-article-mode-map ""
3149 ;; Fixme: this should use :active (and maybe :visible).
3151 ["Hide headers" gnus-article-hide-headers t]
3152 ["Hide signature" gnus-article-hide-signature t]
3153 ["Hide citation" gnus-article-hide-citation t]
3154 ["Treat overstrike" gnus-article-treat-overstrike t]
3155 ["Remove carriage return" gnus-article-remove-cr t]
3156 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3157 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3158 ["Remove base64" gnus-article-de-base64-unreadable t]
3159 ["Treat html" gnus-article-wash-html t]
3160 ["Decode HZ" gnus-article-decode-HZ t]))
3162 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3164 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3166 (gnus-run-hooks 'gnus-article-menu-hook)))
3168 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3171 (defun gnus-article-mode ()
3172 "Major mode for displaying an article.
3174 All normal editing commands are switched off.
3176 The following commands are available in addition to all summary mode
3178 \\<gnus-article-mode-map>
3179 \\[gnus-article-next-page]\t Scroll the article one page forwards
3180 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3181 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3182 \\[gnus-article-show-summary]\t Display the summary buffer
3183 \\[gnus-article-mail]\t Send a reply to the address near point
3184 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3185 \\[gnus-info-find-node]\t Go to the Gnus info node"
3187 (gnus-simplify-mode-line)
3188 (setq mode-name "Article")
3189 (setq major-mode 'gnus-article-mode)
3190 (make-local-variable 'minor-mode-alist)
3191 (use-local-map gnus-article-mode-map)
3192 (when (gnus-visual-p 'article-menu 'menu)
3193 (gnus-article-make-menu-bar))
3194 (gnus-update-format-specifications nil 'article-mode)
3195 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3196 (make-local-variable 'gnus-page-broken)
3197 (make-local-variable 'gnus-button-marker-list)
3198 (make-local-variable 'gnus-article-current-summary)
3199 (make-local-variable 'gnus-article-mime-handles)
3200 (make-local-variable 'gnus-article-decoded-p)
3201 (make-local-variable 'gnus-article-mime-handle-alist)
3202 (make-local-variable 'gnus-article-wash-types)
3203 (make-local-variable 'gnus-article-charset)
3204 (make-local-variable 'gnus-article-ignored-charsets)
3205 (gnus-set-default-directory)
3206 (buffer-disable-undo)
3207 (setq buffer-read-only t)
3208 (set-syntax-table gnus-article-mode-syntax-table)
3209 (mm-enable-multibyte)
3210 (gnus-run-hooks 'gnus-article-mode-hook))
3212 (defun gnus-article-setup-buffer ()
3213 "Initialize the article buffer."
3214 (let* ((name (if gnus-single-article-buffer "*Article*"
3215 (concat "*Article " gnus-newsgroup-name "*")))
3217 (progn (string-match "\\*Article" name)
3218 (concat " *Original Article"
3219 (substring name (match-end 0))))))
3220 (setq gnus-article-buffer name)
3221 (setq gnus-original-article-buffer original)
3222 (setq gnus-article-mime-handle-alist nil)
3223 ;; This might be a variable local to the summary buffer.
3224 (unless gnus-single-article-buffer
3226 (set-buffer gnus-summary-buffer)
3227 (setq gnus-article-buffer name)
3228 (setq gnus-original-article-buffer original)
3229 (gnus-set-global-variables)))
3230 (gnus-article-setup-highlight-words)
3231 ;; Init original article buffer.
3233 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3234 (mm-enable-multibyte)
3235 (setq major-mode 'gnus-original-article-mode)
3236 (make-local-variable 'gnus-original-article))
3237 (if (get-buffer name)
3240 (when gnus-article-mime-handles
3241 (mm-destroy-parts gnus-article-mime-handles)
3242 (setq gnus-article-mime-handles nil))
3243 ;; Set it to nil in article-buffer!
3244 (setq gnus-article-mime-handle-alist nil)
3245 (buffer-disable-undo)
3246 (setq buffer-read-only t)
3247 (unless (eq major-mode 'gnus-article-mode)
3248 (gnus-article-mode))
3251 (set-buffer (gnus-get-buffer-create name))
3253 (make-local-variable 'gnus-summary-buffer)
3254 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3255 (current-buffer)))))
3257 ;; Set article window start at LINE, where LINE is the number of lines
3258 ;; from the head of the article.
3259 (defun gnus-article-set-window-start (&optional line)
3261 (gnus-get-buffer-window gnus-article-buffer t)
3263 (set-buffer gnus-article-buffer)
3264 (goto-char (point-min))
3267 (gnus-message 6 "Moved to bookmark")
3268 (search-forward "\n\n" nil t)
3272 (defun gnus-article-prepare (article &optional all-headers header)
3273 "Prepare ARTICLE in article mode buffer.
3274 ARTICLE should either be an article number or a Message-ID.
3275 If ARTICLE is an id, HEADER should be the article headers.
3276 If ALL-HEADERS is non-nil, no headers are hidden."
3278 ;; Make sure we start in a summary buffer.
3279 (unless (eq major-mode 'gnus-summary-mode)
3280 (set-buffer gnus-summary-buffer))
3281 (setq gnus-summary-buffer (current-buffer))
3282 (let* ((gnus-article (if header (mail-header-number header) article))
3283 (summary-buffer (current-buffer))
3284 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3285 (group gnus-newsgroup-name)
3288 (gnus-article-setup-buffer)
3289 (set-buffer gnus-article-buffer)
3290 ;; Deactivate active regions.
3291 (when (and (boundp 'transient-mark-mode)
3292 transient-mark-mode)
3293 (setq mark-active nil))
3294 (if (not (setq result (let ((buffer-read-only nil))
3295 (gnus-request-article-this-buffer
3297 ;; There is no such article.
3299 (when (and (numberp article)
3300 (not (memq article gnus-newsgroup-sparse)))
3301 (setq gnus-article-current
3302 (cons gnus-newsgroup-name article))
3303 (set-buffer gnus-summary-buffer)
3304 (setq gnus-current-article article)
3305 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3307 (gnus-summary-set-agent-mark article)
3308 (message "Message marked for downloading"))
3309 (gnus-summary-mark-article article gnus-canceled-mark)
3310 (unless (memq article gnus-newsgroup-sparse)
3311 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3312 (if (or (eq result 'pseudo)
3313 (eq result 'nneething))
3316 (set-buffer summary-buffer)
3317 (push article gnus-newsgroup-history)
3318 (setq gnus-last-article gnus-current-article
3319 gnus-current-article 0
3320 gnus-current-headers nil
3321 gnus-article-current nil)
3322 (if (eq result 'nneething)
3323 (gnus-configure-windows 'summary)
3324 (gnus-configure-windows 'article))
3325 (gnus-set-global-variables))
3326 (let ((gnus-article-mime-handle-alist-1
3327 gnus-article-mime-handle-alist))
3328 (gnus-set-mode-line 'article)))
3329 ;; The result from the `request' was an actual article -
3330 ;; or at least some text that is now displayed in the
3332 (when (and (numberp article)
3333 (not (eq article gnus-current-article)))
3334 ;; Seems like a new article has been selected.
3335 ;; `gnus-current-article' must be an article number.
3337 (set-buffer summary-buffer)
3338 (push article gnus-newsgroup-history)
3339 (setq gnus-last-article gnus-current-article
3340 gnus-current-article article
3341 gnus-current-headers
3342 (gnus-summary-article-header gnus-current-article)
3343 gnus-article-current
3344 (cons gnus-newsgroup-name gnus-current-article))
3345 (unless (vectorp gnus-current-headers)
3346 (setq gnus-current-headers nil))
3347 (gnus-summary-goto-subject gnus-current-article)
3348 (when (gnus-summary-show-thread)
3349 ;; If the summary buffer really was folded, the
3350 ;; previous goto may not actually have gone to
3351 ;; the right article, but the thread root instead.
3353 (gnus-summary-goto-subject gnus-current-article))
3354 (gnus-run-hooks 'gnus-mark-article-hook)
3355 (gnus-set-mode-line 'summary)
3356 (when (gnus-visual-p 'article-highlight 'highlight)
3357 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3358 ;; Set the global newsgroup variables here.
3359 (gnus-set-global-variables)
3360 (setq gnus-have-all-headers
3361 (or all-headers gnus-show-all-headers))))
3363 (gnus-configure-windows 'article))
3364 (when (or (numberp article)
3366 (gnus-article-prepare-display)
3368 (goto-char (point-min))
3369 (setq gnus-page-broken
3370 (when gnus-break-pages
3371 (gnus-narrow-to-page)
3373 (let ((gnus-article-mime-handle-alist-1
3374 gnus-article-mime-handle-alist))
3375 (gnus-set-mode-line 'article))
3377 (set-window-point (get-buffer-window (current-buffer)) (point))
3378 (gnus-configure-windows 'article)
3382 (defun gnus-article-prepare-display ()
3383 "Make the current buffer look like a nice article."
3384 ;; Hooks for getting information from the article.
3385 ;; This hook must be called before being narrowed.
3386 (let ((gnus-article-buffer (current-buffer))
3388 (unless (eq major-mode 'gnus-article-mode)
3389 (gnus-article-mode))
3390 (setq buffer-read-only nil
3391 gnus-article-wash-types nil)
3392 (gnus-run-hooks 'gnus-tmp-internal-hook)
3393 (when gnus-display-mime-function
3394 (funcall gnus-display-mime-function))
3395 (gnus-run-hooks 'gnus-article-prepare-hook)))
3398 ;;; Gnus MIME viewing functions
3401 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3402 "The following specs can be used:
3404 %T MIME type, along with additional info
3405 %n The `name' parameter
3406 %d The description, if any
3407 %l The length of the encoded part
3408 %p The part identifier number
3409 %e Dots if the part isn't displayed")
3411 (defvar gnus-mime-button-line-format-alist
3412 '((?t gnus-tmp-type ?s)
3413 (?T gnus-tmp-type-long ?s)
3414 (?n gnus-tmp-name ?s)
3415 (?d gnus-tmp-description ?s)
3417 (?l gnus-tmp-length ?d)
3418 (?e gnus-tmp-dots ?s)))
3420 (defvar gnus-mime-button-commands
3421 '((gnus-article-press-button "\r" "Toggle Display")
3422 (gnus-mime-view-part "v" "View Interactively...")
3423 (gnus-mime-view-part-as-type "t" "View As Type...")
3424 (gnus-mime-view-part-as-charset "C" "View As charset...")
3425 (gnus-mime-save-part "o" "Save...")
3426 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3427 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3428 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3429 (gnus-mime-internalize-part "E" "View Internally")
3430 (gnus-mime-externalize-part "e" "View Externally")
3431 (gnus-mime-pipe-part "|" "Pipe To Command...")
3432 (gnus-mime-action-on-part "." "Take action on the part")))
3434 (defun gnus-article-mime-part-status ()
3435 (if gnus-article-mime-handle-alist-1
3436 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3438 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3441 (defvar gnus-mime-button-map
3442 (let ((map (make-sparse-keymap)))
3443 (unless (>= (string-to-number emacs-version) 21)
3444 ;; XEmacs doesn't care.
3445 (set-keymap-parent map gnus-article-mode-map))
3446 (define-key map gnus-mouse-2 'gnus-article-push-button)
3447 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3448 (dolist (c gnus-mime-button-commands)
3449 (define-key map (cadr c) (car c)))
3452 (defun gnus-mime-button-menu (event)
3453 "Construct a context-sensitive menu of MIME commands."
3455 (save-window-excursion
3456 (let ((pos (event-start event)))
3457 (select-window (posn-window pos))
3458 (goto-char (posn-point pos))
3459 (gnus-article-check-buffer)
3460 (let ((response (x-popup-menu
3462 ("" ,@(mapcar (lambda (c)
3463 (cons (caddr c) (car c)))
3464 gnus-mime-button-commands))))))
3466 (call-interactively response))))))
3468 (defun gnus-mime-view-all-parts (&optional handles)
3469 "View all the MIME parts."
3471 (save-current-buffer
3472 (set-buffer gnus-article-buffer)
3473 (let ((handles (or handles gnus-article-mime-handles))
3474 (mail-parse-charset gnus-newsgroup-charset)
3475 (mail-parse-ignored-charsets
3476 (with-current-buffer gnus-summary-buffer
3477 gnus-newsgroup-ignored-charsets)))
3479 (mm-remove-parts handles)
3480 (goto-char (point-min))
3481 (or (search-forward "\n\n") (goto-char (point-max)))
3482 (let (buffer-read-only)
3483 (delete-region (point) (point-max))
3484 (mm-display-parts handles))))))
3486 (defun gnus-mime-save-part-and-strip ()
3487 "Save the MIME part under point then replace it with an external body."
3489 (gnus-article-check-buffer)
3490 (let* ((data (get-text-property (point) 'gnus-data))
3492 (handles gnus-article-mime-handles))
3493 (if (mm-multiple-handles gnus-article-mime-handles)
3494 (error "This function is not implemented"))
3495 (setq file (and data (mm-save-part data)))
3497 (with-current-buffer (mm-handle-buffer data)
3499 (insert "Content-Type: " (mm-handle-media-type data))
3500 (mml-insert-parameter-string (cdr (mm-handle-type data))
3503 (insert "Content-ID: " (message-make-message-id) "\n")
3504 (insert "Content-Transfer-Encoding: binary\n")
3507 (cdr (mm-make-handle nil
3508 `("message/external-body"
3509 (access-type . "LOCAL-FILE")
3511 (set-buffer gnus-summary-buffer)
3512 (gnus-article-edit-article
3515 (let ((mail-parse-charset (or gnus-article-charset
3516 ',gnus-newsgroup-charset))
3517 (mail-parse-ignored-charsets
3518 (or gnus-article-ignored-charsets
3519 ',gnus-newsgroup-ignored-charsets))
3520 (mbl mml-buffer-list))
3521 (setq mml-buffer-list nil)
3522 (insert-buffer gnus-original-article-buffer)
3523 (mime-to-mml ',handles)
3524 (setq gnus-article-mime-handles nil)
3525 (let ((mbl1 mml-buffer-list))
3526 (setq mml-buffer-list mbl)
3527 (set (make-local-variable 'mml-buffer-list) mbl1))
3528 ;; LOCAL argument of add-hook differs between GNU Emacs
3529 ;; and XEmacs. make-local-hook makes sure they are local.
3530 (make-local-hook 'kill-buffer-hook)
3531 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3532 `(lambda (no-highlight)
3533 (let ((mail-parse-charset (or gnus-article-charset
3534 ',gnus-newsgroup-charset))
3535 (message-options message-options)
3536 (message-options-set-recipient)
3537 (mail-parse-ignored-charsets
3538 (or gnus-article-ignored-charsets
3539 ',gnus-newsgroup-ignored-charsets)))
3541 (mml-destroy-buffers)
3542 (remove-hook 'kill-buffer-hook
3543 'mml-destroy-buffers t)
3544 (kill-local-variable 'mml-buffer-list))
3545 (gnus-summary-edit-article-done
3546 ,(or (mail-header-references gnus-current-headers) "")
3547 ,(gnus-group-read-only-p)
3548 ,gnus-summary-buffer no-highlight))))))
3550 (defun gnus-mime-save-part ()
3551 "Save the MIME part under point."
3553 (gnus-article-check-buffer)
3554 (let ((data (get-text-property (point) 'gnus-data)))
3556 (mm-save-part data))))
3558 (defun gnus-mime-pipe-part ()
3559 "Pipe the MIME part under point to a process."
3561 (gnus-article-check-buffer)
3562 (let ((data (get-text-property (point) 'gnus-data)))
3564 (mm-pipe-part data))))
3566 (defun gnus-mime-view-part ()
3567 "Interactively choose a viewing method for the MIME part under point."
3569 (gnus-article-check-buffer)
3570 (let ((data (get-text-property (point) 'gnus-data)))
3572 (setq gnus-article-mime-handles
3574 gnus-article-mime-handles (setq data (copy-sequence data))))
3575 (mm-interactively-view-part data))))
3577 (defun gnus-mime-view-part-as-type-internal ()
3578 (gnus-article-check-buffer)
3579 (let* ((name (mail-content-type-get
3580 (mm-handle-type (get-text-property (point) 'gnus-data))
3582 (def-type (and name (mm-default-file-encoding name))))
3583 (and def-type (cons def-type 0))))
3585 (defun gnus-mime-view-part-as-type (&optional mime-type)
3586 "Choose a MIME media type, and view the part as such."
3589 (setq mime-type (completing-read
3590 "View as MIME type: "
3591 (mapcar #'list (mailcap-mime-types))
3593 (gnus-mime-view-part-as-type-internal))))
3594 (gnus-article-check-buffer)
3595 (let ((handle (get-text-property (point) 'gnus-data)))
3598 (mm-make-handle (mm-handle-buffer handle)
3599 (cons mime-type (cdr (mm-handle-type handle)))
3600 (mm-handle-encoding handle)
3601 (mm-handle-undisplayer handle)
3602 (mm-handle-disposition handle)
3603 (mm-handle-description handle)
3605 (mm-handle-id handle)))
3606 (setq gnus-article-mime-handles
3607 (mm-merge-handles gnus-article-mime-handles handle))
3608 (gnus-mm-display-part handle))))
3610 (defun gnus-mime-copy-part (&optional handle)
3611 "Put the the MIME part under point into a new buffer."
3613 (gnus-article-check-buffer)
3614 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3615 (contents (and handle (mm-get-part handle)))
3617 (file-name-nondirectory
3619 (mail-content-type-get (mm-handle-type handle) 'name)
3620 (mail-content-type-get (mm-handle-type handle)
3623 (buffer (and base (generate-new-buffer base))))
3625 (switch-to-buffer buffer)
3627 ;; We do it this way to make `normal-mode' set the appropriate mode.
3630 (setq buffer-file-name (expand-file-name base))
3632 (setq buffer-file-name nil))
3633 (goto-char (point-min)))))
3635 (defun gnus-mime-inline-part (&optional handle arg)
3636 "Insert the MIME part under point into the current buffer."
3637 (interactive (list nil current-prefix-arg))
3638 (gnus-article-check-buffer)
3639 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3644 (if (and (not arg) (mm-handle-undisplayer handle))
3645 (mm-remove-part handle)
3646 (setq contents (mm-get-part handle))
3649 (setq charset (or (mail-content-type-get
3650 (mm-handle-type handle) 'charset)
3651 gnus-newsgroup-charset)))
3653 (if (mm-handle-undisplayer handle)
3654 (mm-remove-part handle))
3657 gnus-summary-show-article-charset-alist))
3658 (mm-read-coding-system "Charset: ")))))
3660 (mm-insert-inline handle
3662 (setq charset (mm-charset-to-coding-system
3664 (not (eq charset 'ascii)))
3665 (mm-decode-coding-string contents charset)
3669 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3670 "Insert the MIME part under point into the current buffer using the
3672 (interactive (list nil current-prefix-arg))
3673 (gnus-article-check-buffer)
3674 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3679 (if (mm-handle-undisplayer handle)
3680 (mm-remove-part handle))
3681 (let ((gnus-newsgroup-charset
3683 gnus-summary-show-article-charset-alist))
3684 (mm-read-coding-system "Charset: ")))
3685 (gnus-newsgroup-ignored-charsets 'gnus-all))
3686 (gnus-article-press-button)))))
3688 (defun gnus-mime-externalize-part (&optional handle)
3689 "View the MIME part under point with an external viewer."
3691 (gnus-article-check-buffer)
3692 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3693 (mm-user-display-methods nil)
3694 (mm-inlined-types nil)
3695 (mail-parse-charset gnus-newsgroup-charset)
3696 (mail-parse-ignored-charsets
3697 (save-excursion (set-buffer gnus-summary-buffer)
3698 gnus-newsgroup-ignored-charsets)))
3700 (if (mm-handle-undisplayer handle)
3701 (mm-remove-part handle)
3702 (mm-display-part handle)))))
3704 (defun gnus-mime-internalize-part (&optional handle)
3705 "View the MIME part under point with an internal viewer.
3706 If no internal viewer is available, use an external viewer."
3708 (gnus-article-check-buffer)
3709 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3710 (mm-inlined-types '(".*"))
3711 (mm-inline-large-images t)
3712 (mail-parse-charset gnus-newsgroup-charset)
3713 (mail-parse-ignored-charsets
3714 (save-excursion (set-buffer gnus-summary-buffer)
3715 gnus-newsgroup-ignored-charsets)))
3717 (if (mm-handle-undisplayer handle)
3718 (mm-remove-part handle)
3719 (mm-display-part handle)))))
3721 (defun gnus-mime-action-on-part (&optional action)
3722 "Do something with the MIME attachment at \(point\)."
3724 (list (completing-read "Action: " gnus-mime-action-alist)))
3725 (gnus-article-check-buffer)
3726 (let ((action-pair (assoc action gnus-mime-action-alist)))
3728 (funcall (cdr action-pair)))))
3730 (defun gnus-article-part-wrapper (n function)
3731 (save-current-buffer
3732 (set-buffer gnus-article-buffer)
3733 (when (> n (length gnus-article-mime-handle-alist))
3734 (error "No such part"))
3735 (gnus-article-goto-part n)
3736 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3737 (funcall function handle))))
3739 (defun gnus-article-pipe-part (n)
3740 "Pipe MIME part N, which is the numerical prefix."
3742 (gnus-article-part-wrapper n 'mm-pipe-part))
3744 (defun gnus-article-save-part (n)
3745 "Save MIME part N, which is the numerical prefix."
3747 (gnus-article-part-wrapper n 'mm-save-part))
3749 (defun gnus-article-interactively-view-part (n)
3750 "View MIME part N interactively, which is the numerical prefix."
3752 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3754 (defun gnus-article-copy-part (n)
3755 "Copy MIME part N, which is the numerical prefix."
3757 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3759 (defun gnus-article-view-part-as-charset (n)
3760 "Copy MIME part N, which is the numerical prefix."
3762 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3764 (defun gnus-article-externalize-part (n)
3765 "View MIME part N externally, which is the numerical prefix."
3767 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3769 (defun gnus-article-inline-part (n)
3770 "Inline MIME part N, which is the numerical prefix."
3772 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3774 (defun gnus-article-mime-match-handle-first (condition)
3776 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3777 (while (setq ihandle (pop alist))
3779 ((functionp condition)
3780 (funcall condition (cdr ihandle)))
3781 ((eq condition 'undisplayed)
3782 (not (or (mm-handle-undisplayer (cdr ihandle))
3783 (equal (mm-handle-media-type (cdr ihandle))
3784 "multipart/alternative"))))
3785 ((eq condition 'undisplayed-alternative)
3786 (not (mm-handle-undisplayer (cdr ihandle))))
3788 (gnus-article-goto-part (car ihandle))
3789 (or (not n) (< (car ihandle) n)))
3790 (setq n (car ihandle))))
3794 (defun gnus-article-view-part (&optional n)
3795 "View MIME part N, which is the numerical prefix."
3797 (save-current-buffer
3798 (set-buffer gnus-article-buffer)
3799 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3800 gnus-article-mime-match-handle-function)))
3801 (when (> n (length gnus-article-mime-handle-alist))
3802 (error "No such part"))
3803 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3804 (when (gnus-article-goto-part n)
3805 (if (equal (car handle) "multipart/alternative")
3806 (gnus-article-press-button)
3807 (when (eq (gnus-mm-display-part handle) 'internal)
3808 (gnus-set-window-start)))))))
3810 (defsubst gnus-article-mime-total-parts ()
3811 (if (bufferp (car gnus-article-mime-handles))
3813 (1- (length gnus-article-mime-handles))))
3815 (defun gnus-mm-display-part (handle)
3816 "Display HANDLE and fix MIME button."
3817 (let ((id (get-text-property (point) 'gnus-part))
3822 (let ((window (selected-window))
3823 (mail-parse-charset gnus-newsgroup-charset)
3824 (mail-parse-ignored-charsets
3825 (save-excursion (set-buffer gnus-summary-buffer)
3826 gnus-newsgroup-ignored-charsets)))
3829 (let ((win (gnus-get-buffer-window (current-buffer) t))
3832 (select-window win))
3835 (if (mm-handle-displayed-p handle)
3836 ;; This will remove the part.
3837 (mm-display-part handle)
3839 (narrow-to-region (point)
3840 (if (eobp) (point) (1+ (point))))
3841 (mm-display-part handle)
3842 ;; We narrow to the part itself and
3843 ;; then call the treatment functions.
3844 (goto-char (point-min))
3846 (narrow-to-region (point) (point-max))
3849 (gnus-article-mime-total-parts)
3850 (mm-handle-media-type handle)))))
3851 (if (window-live-p window)
3852 (select-window window)))))
3854 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3855 (gnus-insert-mime-button
3856 handle id (list (mm-handle-displayed-p handle)))
3857 (goto-char point))))
3859 (defun gnus-article-goto-part (n)
3860 "Go to MIME part N."
3861 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3863 (goto-char point))))
3865 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3866 (let ((gnus-tmp-name
3867 (or (mail-content-type-get (mm-handle-type handle) 'name)
3868 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3869 (mail-content-type-get (mm-handle-type handle) 'url)
3871 (gnus-tmp-type (mm-handle-media-type handle))
3872 (gnus-tmp-description
3873 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3876 (if (if displayed (car displayed)
3877 (mm-handle-displayed-p handle))
3879 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3881 gnus-tmp-type-long b e)
3882 (when (string-match ".*/" gnus-tmp-name)
3883 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3884 (setq gnus-tmp-type-long (concat gnus-tmp-type
3885 (and (not (equal gnus-tmp-name ""))
3886 (concat "; " gnus-tmp-name))))
3887 (unless (equal gnus-tmp-description "")
3888 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3893 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3894 `(keymap ,gnus-mime-button-map
3895 ,@(if (>= (string-to-number emacs-version) 21)
3897 (list 'local-map gnus-mime-button-map))
3898 gnus-callback gnus-mm-display-part
3899 gnus-part ,gnus-tmp-id
3900 article-type annotation
3903 (widget-convert-button
3906 :action 'gnus-widget-press-button
3907 :button-keymap gnus-mime-button-map
3909 (lambda (widget/window &optional overlay pos)
3910 ;; Needed to properly clear the message due to a bug in
3911 ;; wid-edit (XEmacs only).
3912 (if (boundp 'help-echo-owns-message)
3913 (setq help-echo-owns-message t))
3915 "%S: %s the MIME part; %S: more options"
3916 (aref gnus-mouse-2 0)
3917 ;; XEmacs will get a single widget arg; Emacs 21 will get
3918 ;; window, overlay, position.
3919 (if (mm-handle-displayed-p
3921 (with-current-buffer (gnus-overlay-buffer overlay)
3922 (widget-get (widget-at (gnus-overlay-start overlay))
3924 (widget-get widget/window :mime-handle)))
3926 (aref gnus-down-mouse-3 0))))))
3928 (defun gnus-widget-press-button (elems el)
3929 (goto-char (widget-get elems :from))
3930 (gnus-article-press-button))
3932 (defvar gnus-displaying-mime nil)
3934 (defun gnus-display-mime (&optional ihandles)
3935 "Display the MIME parts."
3937 (save-selected-window
3938 (let ((window (get-buffer-window gnus-article-buffer))
3941 (select-window window)
3942 ;; We have to do this since selecting the window
3943 ;; may change the point. So we set the window point.
3944 (set-window-point window point)))
3945 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3946 buffer-read-only handle name type b e display)
3947 (when (and (not ihandles)
3948 (not gnus-displaying-mime))
3949 ;; Top-level call; we clean up.
3950 (when gnus-article-mime-handles
3951 (mm-destroy-parts gnus-article-mime-handles)
3952 (setq gnus-article-mime-handle-alist nil));; A trick.
3953 (setq gnus-article-mime-handles handles)
3954 ;; We allow users to glean info from the handles.
3955 (when gnus-article-mime-part-function
3956 (gnus-mime-part-function handles)))
3958 (or (not (stringp (car handles)))
3961 (when (and (not ihandles)
3962 (not gnus-displaying-mime))
3963 ;; Clean up for mime parts.
3965 (delete-region (point) (point-max)))
3966 (let ((gnus-displaying-mime t))
3967 (gnus-mime-display-part handles)))
3970 (narrow-to-region (point) (point-max))
3971 (gnus-treat-article nil 1 1)
3974 ;; Highlight the headers.
3978 (narrow-to-region (point-min) (point))
3979 (gnus-treat-article 'head))))))))
3981 (defvar gnus-mime-display-multipart-as-mixed nil)
3982 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
3983 (defvar gnus-mime-display-multipart-related-as-mixed nil)
3985 (defun gnus-mime-display-part (handle)
3988 ((not (stringp (car handle)))
3989 (gnus-mime-display-single handle))
3990 ;; User-defined multipart
3991 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3992 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3994 ;; multipart/alternative
3995 ((and (equal (car handle) "multipart/alternative")
3996 (not (or gnus-mime-display-multipart-as-mixed
3997 gnus-mime-display-multipart-alternative-as-mixed)))
3998 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3999 (push (cons id handle) gnus-article-mime-handle-alist)
4000 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4001 ;; multipart/related
4002 ((and (equal (car handle) "multipart/related")
4003 (not (or gnus-mime-display-multipart-as-mixed
4004 gnus-mime-display-multipart-related-as-mixed)))
4005 ;;;!!!We should find the start part, but we just default
4006 ;;;!!!to the first part.
4007 ;;(gnus-mime-display-part (cadr handle))
4008 ;;;!!! Most multipart/related is an HTML message plus images.
4009 ;;;!!! Unfortunately we are unable to let W3 display those
4010 ;;;!!! included images, so we just display it as a mixed multipart.
4011 ;;(gnus-mime-display-mixed (cdr handle))
4012 ;;;!!! No, w3 can display everything just fine.
4013 (gnus-mime-display-part (cadr handle)))
4014 ((equal (car handle) "multipart/signed")
4015 (or (memq 'signed gnus-article-wash-types)
4016 (push 'signed gnus-article-wash-types))
4017 (gnus-mime-display-security handle))
4018 ((equal (car handle) "multipart/encrypted")
4019 (or (memq 'encrypted gnus-article-wash-types)
4020 (push 'encrypted gnus-article-wash-types))
4021 (gnus-mime-display-security handle))
4022 ;; Other multiparts are handled like multipart/mixed.
4024 (gnus-mime-display-mixed (cdr handle)))))
4026 (defun gnus-mime-part-function (handles)
4027 (if (stringp (car handles))
4028 (mapcar 'gnus-mime-part-function (cdr handles))
4029 (funcall gnus-article-mime-part-function handles)))
4031 (defun gnus-mime-display-mixed (handles)
4032 (mapcar 'gnus-mime-display-part handles))
4034 (defun gnus-mime-display-single (handle)
4035 (let ((type (mm-handle-media-type handle))
4036 (ignored gnus-ignored-mime-types)
4043 (when (string-match (pop ignored) type)
4044 (throw 'ignored nil)))
4045 (if (and (setq not-attachment
4046 (and (not (mm-inline-override-p handle))
4047 (or (not (mm-handle-disposition handle))
4048 (equal (car (mm-handle-disposition handle))
4050 (mm-attachment-override-p handle))))
4051 (mm-automatic-display-p handle)
4053 (mm-inlinable-p handle)
4054 (mm-inlined-p handle))
4055 (mm-automatic-external-display-p type)))
4057 (when (equal (mm-handle-media-supertype handle) "text")
4059 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4061 (push (cons id handle) gnus-article-mime-handle-alist)
4062 (when (or (not display)
4063 (not (gnus-unbuttonized-mime-type-p type)))
4064 ;(gnus-article-insert-newline)
4065 (gnus-insert-mime-button
4066 handle id (list (or display (and not-attachment text))))
4067 (gnus-article-insert-newline)
4068 ;(gnus-article-insert-newline)
4069 ;; Remember modify the number of forward lines.
4077 (let ((mail-parse-charset gnus-newsgroup-charset)
4078 (mail-parse-ignored-charsets
4079 (save-excursion (condition-case ()
4080 (set-buffer gnus-summary-buffer)
4082 gnus-newsgroup-ignored-charsets)))
4083 (mm-display-part handle t))
4084 (goto-char (point-max)))
4085 ((and text not-attachment)
4089 (gnus-article-insert-newline)
4090 (mm-insert-inline handle (mm-get-part handle))
4091 (goto-char (point-max))))
4095 (narrow-to-region beg (point))
4098 (gnus-article-mime-total-parts)
4099 (mm-handle-media-type handle)))))))))
4101 (defun gnus-unbuttonized-mime-type-p (type)
4102 "Say whether TYPE is to be unbuttonized."
4103 (unless gnus-inhibit-mime-unbuttonizing
4105 (let ((types gnus-unbuttonized-mime-types))
4107 (when (string-match (pop types) type)
4108 (throw 'found t)))))
4110 (let ((types gnus-buttonized-mime-types))
4112 (when (string-match (pop types) type)
4113 (throw 'found t)))))))))
4115 (defun gnus-article-insert-newline ()
4116 "Insert a newline, but mark it as undeletable."
4117 (gnus-put-text-property
4118 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4120 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4121 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4124 handle buffer-read-only from props begend not-pref)
4125 (save-window-excursion
4128 (narrow-to-region (car ibegend)
4131 (goto-char (car ibegend))
4134 (delete-region (point-min) (point-max))
4135 (mm-remove-parts handles))
4136 (setq begend (list (point-marker)))
4138 (unless (setq not-pref (cadr (member preferred ihandles)))
4139 (setq not-pref (car ihandles)))
4142 (not (gnus-unbuttonized-mime-type-p
4143 "multipart/alternative")))
4144 (gnus-add-text-properties
4147 (insert (format "%d. " id))
4151 (unless ,(not ibegend)
4152 (setq gnus-article-mime-handle-alist
4153 ',gnus-article-mime-handle-alist))
4154 (gnus-mime-display-alternative
4155 ',ihandles ',not-pref ',begend ,id))
4156 ,@(if (>= (string-to-number emacs-version) 21)
4157 nil ;; XEmacs doesn't care
4158 (list 'local-map gnus-mime-button-map))
4159 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4160 face ,gnus-article-button-face
4161 keymap ,gnus-mime-button-map
4164 (widget-convert-button 'link from (point)
4165 :action 'gnus-widget-press-button
4166 :button-keymap gnus-widget-button-keymap)
4168 (while (setq handle (pop handles))
4169 (gnus-add-text-properties
4172 (insert (format "(%c) %-18s"
4173 (if (equal handle preferred) ?* ? )
4174 (mm-handle-media-type handle)))
4178 (unless ,(not ibegend)
4179 (setq gnus-article-mime-handle-alist
4180 ',gnus-article-mime-handle-alist))
4181 (gnus-mime-display-alternative
4182 ',ihandles ',handle ',begend ,id))
4183 ,@(if (>= (string-to-number emacs-version) 21)
4184 nil ;; XEmacs doesn't care
4185 (list 'local-map gnus-mime-button-map))
4186 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4187 face ,gnus-article-button-face
4188 keymap ,gnus-mime-button-map
4191 (widget-convert-button 'link from (point)
4192 :action 'gnus-widget-press-button
4193 :button-keymap gnus-widget-button-keymap)
4197 (if (stringp (car preferred))
4198 (gnus-display-mime preferred)
4199 (let ((mail-parse-charset gnus-newsgroup-charset)
4200 (mail-parse-ignored-charsets
4201 (save-excursion (set-buffer gnus-summary-buffer)
4202 gnus-newsgroup-ignored-charsets)))
4203 (mm-display-part preferred)
4207 (narrow-to-region (car begend) (point-max))
4209 nil (length gnus-article-mime-handle-alist)
4210 (gnus-article-mime-total-parts)
4211 (mm-handle-media-type handle))))))
4212 (goto-char (point-max))
4213 (setcdr begend (point-marker)))))
4215 (goto-char point))))
4217 (defconst gnus-article-wash-status-strings
4218 (let ((alist '((cite "c" "Possible hidden citation text"
4219 " " "All citation text visible")
4220 (headers "h" "Hidden headers"
4221 " " "All headers visible.")
4222 (pgp "p" "Encrypted or signed message status hidden"
4223 " " "No hidden encryption nor digital signature status")
4224 (signature "s" "Signature has been hidden"
4225 " " "Signature is visible")
4226 (overstrike "o" "Overstrike (^H) characters applied"
4227 " " "No overstrike characters applied")
4228 (emphasis "e" "/*_Emphasis_*/ characters applied"
4229 " " "No /*_emphasis_*/ characters applied")))
4231 (dolist (entry alist result)
4232 (let ((key (nth 0 entry))
4233 (on (copy-sequence (nth 1 entry)))
4234 (on-help (nth 2 entry))
4235 (off (copy-sequence (nth 3 entry)))
4236 (off-help (nth 4 entry)))
4237 (put-text-property 0 1 'help-echo on-help on)
4238 (put-text-property 0 1 'help-echo off-help off)
4239 (push (list key on off) result))))
4240 "Alist of strings describing wash status in the mode line.
4241 Each entry has the form (KEY ON OF), where the KEY is a symbol
4242 representing the particular washing function, ON is the string to use
4243 in the article mode line when the washing function is active, and OFF
4244 is the string to use when it is inactive.")
4246 (defun gnus-gnus-article-wash-status-entry (key value)
4247 (let ((entry (assoc key gnus-article-wash-status-strings)))
4248 (if value (nth 1 entry) (nth 2 entry))))
4250 (defun gnus-article-wash-status ()
4251 "Return a string which display status of article washing."
4253 (set-buffer gnus-article-buffer)
4254 (let ((cite (memq 'cite gnus-article-wash-types))
4255 (headers (memq 'headers gnus-article-wash-types))
4256 (boring (memq 'boring-headers gnus-article-wash-types))
4257 (pgp (memq 'pgp gnus-article-wash-types))
4258 (pem (memq 'pem gnus-article-wash-types))
4259 (signed (memq 'signed gnus-article-wash-types))
4260 (encrypted (memq 'encrypted gnus-article-wash-types))
4261 (signature (memq 'signature gnus-article-wash-types))
4262 (overstrike (memq 'overstrike gnus-article-wash-types))
4263 (emphasis (memq 'emphasis gnus-article-wash-types)))
4264 (concat (gnus-gnus-article-wash-status-entry 'cite cite)
4265 (gnus-gnus-article-wash-status-entry 'headers
4266 (or headers boring))
4267 (gnus-gnus-article-wash-status-entry
4268 'pgp (or pgp pem signed encrypted))
4269 (gnus-gnus-article-wash-status-entry 'signature signature)
4270 (gnus-gnus-article-wash-status-entry 'overstrike overstrike)
4271 (gnus-gnus-article-wash-status-entry 'emphasis emphasis)))))
4273 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4275 (defun gnus-article-maybe-hide-headers ()
4276 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4277 Provided for backwards compatibility."
4278 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4279 (not (save-excursion (set-buffer gnus-summary-buffer)
4280 gnus-have-all-headers)))
4281 (not gnus-inhibit-hiding))
4282 (gnus-article-hide-headers)))
4286 (defun gnus-output-to-file (file-name)
4287 "Append the current article to a file named FILE-NAME."
4288 (let ((artbuf (current-buffer)))
4290 (insert-buffer-substring artbuf)
4291 ;; Append newline at end of the buffer as separator, and then
4293 (goto-char (point-max))
4295 (let ((file-name-coding-system nnmail-pathname-coding-system))
4296 (mm-append-to-file (point-min) (point-max) file-name))
4299 (defun gnus-narrow-to-page (&optional arg)
4300 "Narrow the article buffer to a page.
4301 If given a numerical ARG, move forward ARG pages."
4303 (setq arg (if arg (prefix-numeric-value arg) 0))
4305 (set-buffer gnus-article-buffer)
4306 (goto-char (point-min))
4308 ;; Remove any old next/prev buttons.
4309 (when (gnus-visual-p 'page-marker)
4310 (let ((buffer-read-only nil))
4311 (gnus-remove-text-with-property 'gnus-prev)
4312 (gnus-remove-text-with-property 'gnus-next)))
4315 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4317 (re-search-forward page-delimiter nil 'move arg)))
4318 (goto-char (match-end 0)))
4321 (if (re-search-forward page-delimiter nil 'move)
4324 (when (and (gnus-visual-p 'page-marker)
4325 (not (= (point-min) 1)))
4327 (goto-char (point-min))
4328 (gnus-insert-prev-page-button)))
4329 (when (and (gnus-visual-p 'page-marker)
4330 (< (+ (point-max) 2) (buffer-size)))
4332 (goto-char (point-max))
4333 (gnus-insert-next-page-button)))))
4335 ;; Article mode commands
4337 (defun gnus-article-goto-next-page ()
4338 "Show the next page of the article."
4340 (when (gnus-article-next-page)
4341 (goto-char (point-min))
4342 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4344 (defun gnus-article-goto-prev-page ()
4345 "Show the next page of the article."
4347 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4348 (gnus-article-prev-page nil)))
4350 (defun gnus-article-next-page (&optional lines)
4351 "Show the next page of the current article.
4352 If end of article, return non-nil. Otherwise return nil.
4353 Argument LINES specifies lines to be scrolled up."
4355 (move-to-window-line -1)
4358 (and (pos-visible-in-window-p) ;Not continuation line.
4360 ;; Nothing in this page.
4361 (if (or (not gnus-page-broken)
4364 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4366 (gnus-narrow-to-page 1) ;Go to next page.
4368 ;; More in this page.
4369 (let ((scroll-in-place nil))
4373 ;; Long lines may cause an end-of-buffer error.
4374 (goto-char (point-max)))))
4375 (move-to-window-line 0)
4378 (defun gnus-article-prev-page (&optional lines)
4379 "Show previous page of current article.
4380 Argument LINES specifies lines to be scrolled down."
4382 (move-to-window-line 0)
4383 (if (and gnus-page-broken
4385 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4387 (gnus-narrow-to-page -1) ;Go to previous page.
4388 (goto-char (point-max))
4390 (let ((scroll-in-place nil))
4394 (beginning-of-buffer
4395 (goto-char (point-min))))
4396 (move-to-window-line 0)))))
4398 (defun gnus-article-refer-article ()
4399 "Read article specified by message-id around point."
4401 (let ((point (point)))
4402 (search-forward ">" nil t) ;Move point to end of "<....>".
4403 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4404 (let ((message-id (match-string 1)))
4406 (set-buffer gnus-summary-buffer)
4407 (gnus-summary-refer-article message-id))
4409 (error "No references around point"))))
4411 (defun gnus-article-show-summary ()
4412 "Reconfigure windows to show summary buffer."
4414 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4415 (error "There is no summary buffer for this article buffer")
4416 (gnus-article-set-globals)
4417 (gnus-configure-windows 'article)
4418 (gnus-summary-goto-subject gnus-current-article)
4419 (gnus-summary-position-point)))
4421 (defun gnus-article-describe-briefly ()
4422 "Describe article mode commands briefly."
4424 (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")))
4426 (defun gnus-article-summary-command ()
4427 "Execute the last keystroke in the summary buffer."
4429 (let ((obuf (current-buffer))
4430 (owin (current-window-configuration))
4432 (switch-to-buffer gnus-article-current-summary 'norecord)
4433 (setq func (lookup-key (current-local-map) (this-command-keys)))
4434 (call-interactively func)
4436 (set-window-configuration owin)
4437 (set-window-point (get-buffer-window (current-buffer)) (point))))
4439 (defun gnus-article-summary-command-nosave ()
4440 "Execute the last keystroke in the summary buffer."
4443 (pop-to-buffer gnus-article-current-summary 'norecord)
4444 (setq func (lookup-key (current-local-map) (this-command-keys)))
4445 (call-interactively func)))
4447 (defun gnus-article-check-buffer ()
4448 "Beep if not in an article buffer."
4449 (unless (equal major-mode 'gnus-article-mode)
4450 (error "Command invoked outside of a Gnus article buffer")))
4452 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4453 "Read a summary buffer key sequence and execute it from the article buffer."
4455 (gnus-article-check-buffer)
4457 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4458 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4459 "=" "^" "\M-^" "|"))
4465 '("n" "Gn" "p" "Gp"))
4468 (set-buffer gnus-article-current-summary)
4469 (let (gnus-pick-mode)
4470 (push (or key last-command-event) unread-command-events)
4471 (setq keys (if (featurep 'xemacs)
4472 (events-to-keys (read-key-sequence nil))
4473 (read-key-sequence nil)))))
4477 (if (or (member keys nosaves)
4478 (member keys nosave-but-article)
4479 (member keys nosave-in-article))
4481 (save-window-excursion
4482 (pop-to-buffer gnus-article-current-summary 'norecord)
4483 ;; We disable the pick minor mode commands.
4484 (let (gnus-pick-mode)
4485 (setq func (lookup-key (current-local-map) keys))))
4489 (unless (member keys nosave-in-article)
4490 (set-buffer gnus-article-current-summary))
4491 (call-interactively func)
4492 (setq new-sum-point (point)))
4493 (when (member keys nosave-but-article)
4494 (pop-to-buffer gnus-article-buffer 'norecord)))
4495 ;; These commands should restore window configuration.
4496 (let ((obuf (current-buffer))
4497 (owin (current-window-configuration))
4499 (summary gnus-article-current-summary)
4500 func in-buffer selected)
4501 (if not-restore-window
4502 (pop-to-buffer summary 'norecord)
4503 (switch-to-buffer summary 'norecord))
4504 (setq in-buffer (current-buffer))
4505 ;; We disable the pick minor mode commands.
4506 (if (and (setq func (let (gnus-pick-mode)
4507 (lookup-key (current-local-map) keys)))
4510 (call-interactively func)
4511 (setq new-sum-point (point))
4512 (when (eq in-buffer (current-buffer))
4513 (setq selected (gnus-summary-select-article))
4515 (unless not-restore-window
4516 (set-window-configuration owin))
4517 (when (eq selected 'old)
4519 (set-window-start (get-buffer-window (current-buffer))
4521 (set-window-point (get-buffer-window (current-buffer))
4523 (let ((win (get-buffer-window gnus-article-current-summary)))
4525 (set-window-point win new-sum-point)))) )
4526 (switch-to-buffer gnus-article-buffer)
4529 (defun gnus-article-describe-key (key)
4530 "Display documentation of the function invoked by KEY. KEY is a string."
4531 (interactive "kDescribe key: ")
4532 (gnus-article-check-buffer)
4533 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4535 (set-buffer gnus-article-current-summary)
4536 (let (gnus-pick-mode)
4537 (if (featurep 'xemacs)
4539 (push (elt key 0) unread-command-events)
4540 (setq key (events-to-keys
4541 (read-key-sequence "Describe key: "))))
4542 (setq unread-command-events
4544 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4545 (string-to-list key)))
4546 (setq key (read-key-sequence "Describe key: "))))
4548 (describe-key key)))
4550 (defun gnus-article-describe-key-briefly (key &optional insert)
4551 "Display documentation of the function invoked by KEY. KEY is a string."
4552 (interactive "kDescribe key: \nP")
4553 (gnus-article-check-buffer)
4554 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4556 (set-buffer gnus-article-current-summary)
4557 (let (gnus-pick-mode)
4558 (if (featurep 'xemacs)
4560 (push (elt key 0) unread-command-events)
4561 (setq key (events-to-keys
4562 (read-key-sequence "Describe key: "))))
4563 (setq unread-command-events
4565 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4566 (string-to-list key)))
4567 (setq key (read-key-sequence "Describe key: "))))
4568 (describe-key-briefly key insert))
4569 (describe-key-briefly key insert)))
4571 (defun gnus-article-hide (&optional arg force)
4572 "Hide all the gruft in the current article.
4573 This means that PGP stuff, signatures, cited text and (some)
4574 headers will be hidden.
4575 If given a prefix, show the hidden text instead."
4576 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4577 (gnus-article-hide-headers arg)
4578 (gnus-article-hide-list-identifiers arg)
4579 (gnus-article-hide-pgp arg)
4580 (gnus-article-hide-citation-maybe arg force)
4581 (gnus-article-hide-signature arg))
4583 (defun gnus-article-maybe-highlight ()
4584 "Do some article highlighting if article highlighting is requested."
4585 (when (gnus-visual-p 'article-highlight 'highlight)
4586 (gnus-article-highlight-some)))
4588 (defun gnus-check-group-server ()
4589 ;; Make sure the connection to the server is alive.
4590 (unless (gnus-server-opened
4591 (gnus-find-method-for-group gnus-newsgroup-name))
4592 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4593 (gnus-request-group gnus-newsgroup-name t)))
4595 (defun gnus-request-article-this-buffer (article group)
4596 "Get an article and insert it into this buffer."
4597 (let (do-update-line sparse-header)
4601 (gnus-kill-all-overlays)
4602 (setq group (or group gnus-newsgroup-name))
4604 ;; Using `gnus-request-article' directly will insert the article into
4605 ;; `nntp-server-buffer' - so we'll save some time by not having to
4606 ;; copy it from the server buffer into the article buffer.
4608 ;; We only request an article by message-id when we do not have the
4609 ;; headers for it, so we'll have to get those.
4610 (when (stringp article)
4611 (gnus-read-header article))
4613 ;; If the article number is negative, that means that this article
4614 ;; doesn't belong in this newsgroup (possibly), so we find its
4615 ;; message-id and request it by id instead of number.
4616 (when (and (numberp article)
4618 (get-buffer gnus-summary-buffer)
4619 (gnus-buffer-exists-p gnus-summary-buffer))
4621 (set-buffer gnus-summary-buffer)
4622 (let ((header (gnus-summary-article-header article)))
4625 ((memq article gnus-newsgroup-sparse)
4626 ;; This is a sparse gap article.
4627 (setq do-update-line article)
4628 (setq article (mail-header-id header))
4629 (setq sparse-header (gnus-read-header article))
4630 (setq gnus-newsgroup-sparse
4631 (delq article gnus-newsgroup-sparse)))
4633 ;; It's a real article.
4634 (setq article (mail-header-id header)))
4636 ;; It is an extracted pseudo-article.
4637 (setq article 'pseudo)
4638 (gnus-request-pseudo-article header))))
4640 (let ((method (gnus-find-method-for-group
4641 gnus-newsgroup-name)))
4642 (when (and (eq (car method) 'nneething)
4644 (let ((dir (expand-file-name
4645 (mail-header-subject header)
4646 (file-name-as-directory
4647 (or (cadr (assq 'nneething-address method))
4649 (when (file-directory-p dir)
4650 (setq article 'nneething)
4651 (gnus-group-enter-directory dir))))))))
4654 ;; Refuse to select canceled articles.
4655 ((and (numberp article)
4657 (get-buffer gnus-summary-buffer)
4658 (gnus-buffer-exists-p gnus-summary-buffer)
4659 (eq (cdr (save-excursion
4660 (set-buffer gnus-summary-buffer)
4661 (assq article gnus-newsgroup-reads)))
4662 gnus-canceled-mark))
4664 ;; We first check `gnus-original-article-buffer'.
4665 ((and (get-buffer gnus-original-article-buffer)
4668 (set-buffer gnus-original-article-buffer)
4669 (and (equal (car gnus-original-article) group)
4670 (eq (cdr gnus-original-article) article))))
4671 (insert-buffer-substring gnus-original-article-buffer)
4673 ;; Check the backlog.
4674 ((and gnus-keep-backlog
4675 (gnus-backlog-request-article group article (current-buffer)))
4677 ;; Check asynchronous pre-fetch.
4678 ((gnus-async-request-fetched-article group article (current-buffer))
4679 (gnus-async-prefetch-next group article gnus-summary-buffer)
4680 (when (and (numberp article) gnus-keep-backlog)
4681 (gnus-backlog-enter-article group article (current-buffer)))
4684 ((and gnus-use-cache
4686 (gnus-cache-request-article article group))
4688 ;; Get the article and put into the article buffer.
4689 ((or (stringp article)
4691 (let ((gnus-override-method gnus-override-method)
4692 (methods (and (stringp article)
4693 gnus-refer-article-method))
4695 (buffer-read-only nil))
4696 (if (or (not (listp methods))
4697 (and (symbolp (car methods))
4698 (assq (car methods) nnoo-definition-alist)))
4699 (setq methods (list methods)))
4700 (when (and (null gnus-override-method)
4702 (setq gnus-override-method (pop methods)))
4704 (when (eq gnus-override-method 'current)
4705 (setq gnus-override-method
4706 (with-current-buffer gnus-summary-buffer
4707 gnus-current-select-method)))
4709 (gnus-kill-all-overlays)
4710 (let ((gnus-newsgroup-name group))
4711 (gnus-check-group-server))
4712 (when (gnus-request-article article group (current-buffer))
4713 (when (numberp article)
4714 (gnus-async-prefetch-next group article
4715 gnus-summary-buffer)
4716 (when gnus-keep-backlog
4717 (gnus-backlog-enter-article
4718 group article (current-buffer))))
4719 (setq result 'article))
4722 (setq gnus-override-method (pop methods))
4723 (setq result 'done))))
4724 (and (eq result 'article) 'article)))
4728 ;; Associate this article with the current summary buffer.
4729 (setq gnus-article-current-summary gnus-summary-buffer)
4731 ;; Take the article from the original article buffer
4732 ;; and place it in the buffer it's supposed to be in.
4733 (when (and (get-buffer gnus-article-buffer)
4734 (equal (buffer-name (current-buffer))
4735 (buffer-name (get-buffer gnus-article-buffer))))
4737 (if (get-buffer gnus-original-article-buffer)
4738 (set-buffer gnus-original-article-buffer)
4739 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4740 (buffer-disable-undo)
4741 (setq major-mode 'gnus-original-article-mode)
4742 (setq buffer-read-only t))
4743 (let (buffer-read-only)
4745 (insert-buffer-substring gnus-article-buffer))
4746 (setq gnus-original-article (cons group article)))
4749 (run-hooks 'gnus-article-decode-hook)
4750 ;; Mark article as decoded or not.
4751 (setq gnus-article-decoded-p gnus-article-decode-hook))
4753 ;; Update sparse articles.
4754 (when (and do-update-line
4755 (or (numberp article)
4757 (let ((buf (current-buffer)))
4758 (set-buffer gnus-summary-buffer)
4759 (gnus-summary-update-article do-update-line sparse-header)
4760 (gnus-summary-goto-subject do-update-line nil t)
4761 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4763 (set-buffer buf))))))
4769 (defcustom gnus-article-edit-mode-hook nil
4770 "Hook run in article edit mode buffers."
4771 :group 'gnus-article-various
4774 (defvar gnus-article-edit-done-function nil)
4776 (defvar gnus-article-edit-mode-map nil)
4778 ;; Should we be using derived.el for this?
4779 (unless gnus-article-edit-mode-map
4780 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4781 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4783 (gnus-define-keys gnus-article-edit-mode-map
4784 "\C-c\C-c" gnus-article-edit-done
4785 "\C-c\C-k" gnus-article-edit-exit)
4787 (gnus-define-keys (gnus-article-edit-wash-map
4788 "\C-c\C-w" gnus-article-edit-mode-map)
4789 "f" gnus-article-edit-full-stops))
4791 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4792 "Major mode for editing articles.
4793 This is an extended text-mode.
4795 \\{gnus-article-edit-mode-map}"
4796 (make-local-variable 'gnus-article-edit-done-function)
4797 (make-local-variable 'gnus-prev-winconf)
4798 (set (make-local-variable 'font-lock-defaults)
4799 '(message-font-lock-keywords t))
4800 (setq buffer-read-only nil)
4801 (buffer-enable-undo)
4804 (defun gnus-article-edit (&optional force)
4805 "Edit the current article.
4806 This will have permanent effect only in mail groups.
4807 If FORCE is non-nil, allow editing of articles even in read-only
4810 (when (and (not force)
4811 (gnus-group-read-only-p))
4812 (error "The current newsgroup does not support article editing"))
4813 (gnus-article-date-original)
4814 (gnus-article-edit-article
4816 `(lambda (no-highlight)
4818 (gnus-summary-edit-article-done
4819 ,(or (mail-header-references gnus-current-headers) "")
4820 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4822 (defun gnus-article-edit-article (start-func exit-func)
4823 "Start editing the contents of the current article buffer."
4824 (let ((winconf (current-window-configuration)))
4825 (set-buffer gnus-article-buffer)
4826 (gnus-article-edit-mode)
4827 (funcall start-func)
4828 (set-buffer-modified-p nil)
4829 (gnus-configure-windows 'edit-article)
4830 (setq gnus-article-edit-done-function exit-func)
4831 (setq gnus-prev-winconf winconf)
4832 (gnus-message 6 "C-c C-c to end edits")))
4834 (defun gnus-article-edit-done (&optional arg)
4835 "Update the article edits and exit."
4837 (let ((func gnus-article-edit-done-function)
4838 (buf (current-buffer))
4839 (start (window-start)))
4840 ;; We remove all text props from the article buffer.
4842 (buffer-substring-no-properties (point-min) (point-max)))
4846 (let ((winconf gnus-prev-winconf))
4848 (set-window-configuration winconf)
4849 ;; Tippy-toe some to make sure that point remains where it was.
4850 (save-current-buffer
4852 (set-window-start (get-buffer-window (current-buffer)) start)
4856 (let ((buffer-read-only nil))
4858 ;; The cache and backlog have to be flushed somewhat.
4859 (when gnus-keep-backlog
4860 (gnus-backlog-remove-article
4861 (car gnus-article-current) (cdr gnus-article-current)))
4862 ;; Flush original article as well.
4864 (when (get-buffer gnus-original-article-buffer)
4865 (set-buffer gnus-original-article-buffer)
4866 (setq gnus-original-article nil)))
4867 (when gnus-use-cache
4868 (gnus-cache-update-article
4869 (car gnus-article-current) (cdr gnus-article-current))))
4871 (set-window-start (get-buffer-window buf) start)
4872 (set-window-point (get-buffer-window buf) (point))))
4874 (defun gnus-article-edit-exit ()
4875 "Exit the article editing without updating."
4877 (when (or (not (buffer-modified-p))
4878 (yes-or-no-p "Article modified; kill anyway? "))
4879 (let ((curbuf (current-buffer))
4881 (window-start (window-start)))
4883 (if (gnus-buffer-live-p gnus-original-article-buffer)
4884 (insert-buffer gnus-original-article-buffer))
4885 (let ((winconf gnus-prev-winconf))
4887 (set-window-configuration winconf)
4888 ;; Tippy-toe some to make sure that point remains where it was.
4889 (save-current-buffer
4891 (set-window-start (get-buffer-window (current-buffer)) window-start)
4894 (defun gnus-article-edit-full-stops ()
4895 "Interactively repair spacing at end of sentences."
4898 (goto-char (point-min))
4899 (search-forward-regexp "^$" nil t)
4900 (let ((case-fold-search nil))
4901 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4904 ;;; Article highlights
4907 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4909 ;;; Internal Variables:
4911 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4912 "Regular expression that matches URLs."
4913 :group 'gnus-article-buttons
4916 (defcustom gnus-button-alist
4917 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4918 0 t gnus-button-handle-news 3)
4919 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
4920 gnus-button-handle-news 2)
4921 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4923 gnus-button-fetch-group 4)
4924 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4925 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4926 t gnus-button-message-id 3)
4927 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4928 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4929 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4931 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
4932 gnus-button-handle-info 2)
4933 ;; This is how URLs _should_ be embedded in text...
4934 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4936 (,gnus-button-url-regexp 0 t browse-url 0))
4937 "*Alist of regexps matching buttons in article bodies.
4939 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4940 REGEXP: is the string matching text around the button,
4941 BUTTON: is the number of the regexp grouping actually matching the button,
4942 FORM: is a lisp expression which must eval to true for the button to
4944 CALLBACK: is the function to call when the user push this button, and each
4945 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4947 CALLBACK can also be a variable, in that case the value of that
4948 variable it the real callback function."
4949 :group 'gnus-article-buttons
4950 :type '(repeat (list regexp
4951 (integer :tag "Button")
4953 (function :tag "Callback")
4956 (integer :tag "Regexp group")))))
4958 (defcustom gnus-header-button-alist
4959 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
4960 0 t gnus-button-message-id 0)
4961 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4962 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4963 0 t gnus-button-mailto 0)
4964 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4965 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4966 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4967 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4968 gnus-button-message-id 3))
4969 "*Alist of headers and regexps to match buttons in article heads.
4971 This alist is very similar to `gnus-button-alist', except that each
4972 alist has an additional HEADER element first in each entry:
4974 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4976 HEADER is a regexp to match a header. For a fuller explanation, see
4977 `gnus-button-alist'."
4978 :group 'gnus-article-buttons
4979 :group 'gnus-article-headers
4980 :type '(repeat (list (regexp :tag "Header")
4982 (integer :tag "Button")
4984 (function :tag "Callback")
4987 (integer :tag "Regexp group")))))
4989 (defvar gnus-button-regexp nil)
4990 (defvar gnus-button-marker-list nil)
4991 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4993 (defvar gnus-button-last nil)
4994 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4998 (defun gnus-article-push-button (event)
4999 "Check text under the mouse pointer for a callback function.
5000 If the text under the mouse pointer has a `gnus-callback' property,
5001 call it with the value of the `gnus-data' text property."
5003 (set-buffer (window-buffer (posn-window (event-start event))))
5004 (let* ((pos (posn-point (event-start event)))
5005 (data (get-text-property pos 'gnus-data))
5006 (fun (get-text-property pos 'gnus-callback)))
5009 (funcall fun data))))
5011 (defun gnus-article-press-button ()
5012 "Check text at point for a callback function.
5013 If the text at point has a `gnus-callback' property,
5014 call it with the value of the `gnus-data' text property."
5016 (let* ((data (get-text-property (point) 'gnus-data))
5017 (fun (get-text-property (point) 'gnus-callback)))
5019 (funcall fun data))))
5021 (defun gnus-article-highlight (&optional force)
5022 "Highlight current article.
5023 This function calls `gnus-article-highlight-headers',
5024 `gnus-article-highlight-citation',
5025 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5026 do the highlighting. See the documentation for those functions."
5027 (interactive (list 'force))
5028 (gnus-article-highlight-headers)
5029 (gnus-article-highlight-citation force)
5030 (gnus-article-highlight-signature)
5031 (gnus-article-add-buttons force)
5032 (gnus-article-add-buttons-to-head))
5034 (defun gnus-article-highlight-some (&optional force)
5035 "Highlight current article.
5036 This function calls `gnus-article-highlight-headers',
5037 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5038 do the highlighting. See the documentation for those functions."
5039 (interactive (list 'force))
5040 (gnus-article-highlight-headers)
5041 (gnus-article-highlight-signature)
5042 (gnus-article-add-buttons))
5044 (defun gnus-article-highlight-headers ()
5045 "Highlight article headers as specified by `gnus-header-face-alist'."
5048 (set-buffer gnus-article-buffer)
5050 (let ((alist gnus-header-face-alist)
5051 (buffer-read-only nil)
5052 (case-fold-search t)
5053 (inhibit-point-motion-hooks t)
5054 entry regexp header-face field-face from hpoints fpoints)
5055 (article-narrow-to-head)
5056 (while (setq entry (pop alist))
5057 (goto-char (point-min))
5058 (setq regexp (concat "^\\("
5059 (if (string-equal "" (nth 0 entry))
5063 header-face (nth 1 entry)
5064 field-face (nth 2 entry))
5065 (while (and (re-search-forward regexp nil t)
5069 (unless (search-forward ":" nil t)
5071 (when (and header-face
5072 (not (memq (point) hpoints)))
5073 (push (point) hpoints)
5074 (gnus-put-text-property from (point) 'face header-face))
5075 (when (and field-face
5076 (not (memq (setq from (point)) fpoints)))
5078 (if (re-search-forward "^[^ \t]" nil t)
5080 (goto-char (point-max)))
5081 (gnus-put-text-property from (point) 'face field-face))))))))
5083 (defun gnus-article-highlight-signature ()
5084 "Highlight the signature in an article.
5085 It does this by highlighting everything after
5086 `gnus-signature-separator' using `gnus-signature-face'."
5089 (set-buffer gnus-article-buffer)
5090 (let ((buffer-read-only nil)
5091 (inhibit-point-motion-hooks t))
5093 (when (and gnus-signature-face
5094 (gnus-article-narrow-to-signature))
5095 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5096 'face gnus-signature-face)
5098 (gnus-article-search-signature)
5099 (let ((start (match-beginning 0))
5100 (end (set-marker (make-marker) (1+ (match-end 0)))))
5101 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5104 (defun gnus-button-in-region-p (b e prop)
5105 "Say whether PROP exists in the region."
5106 (text-property-not-all b e prop nil))
5108 (defun gnus-article-add-buttons (&optional force)
5109 "Find external references in the article and make buttons of them.
5110 \"External references\" are things like Message-IDs and URLs, as
5111 specified by `gnus-button-alist'."
5112 (interactive (list 'force))
5114 (set-buffer gnus-article-buffer)
5115 (let ((buffer-read-only nil)
5116 (inhibit-point-motion-hooks t)
5117 (case-fold-search t)
5118 (alist gnus-button-alist)
5120 ;; Remove all old markers.
5121 (let (marker entry new-list)
5122 (while (setq marker (pop gnus-button-marker-list))
5123 (if (or (< marker (point-min)) (>= marker (point-max)))
5124 (push marker new-list)
5126 (when (setq entry (gnus-button-entry))
5127 (put-text-property (match-beginning (nth 1 entry))
5128 (match-end (nth 1 entry))
5129 'gnus-callback nil))
5130 (set-marker marker nil)))
5131 (setq gnus-button-marker-list new-list))
5132 ;; We skip the headers.
5135 (while (setq entry (pop alist))
5136 (setq regexp (car entry))
5138 (while (re-search-forward regexp nil t)
5139 (let* ((start (and entry (match-beginning (nth 1 entry))))
5140 (end (and entry (match-end (nth 1 entry))))
5141 (from (match-beginning 0)))
5142 (when (and (or (eq t (nth 2 entry))
5143 (eval (nth 2 entry)))
5144 (not (gnus-button-in-region-p
5145 start end 'gnus-callback)))
5146 ;; That optional form returned non-nil, so we add the
5148 (gnus-article-add-button
5149 start end 'gnus-button-push
5150 (car (push (set-marker (make-marker) from)
5151 gnus-button-marker-list))))))))))
5153 ;; Add buttons to the head of an article.
5154 (defun gnus-article-add-buttons-to-head ()
5155 "Add buttons to the head of the article."
5158 (set-buffer gnus-article-buffer)
5160 (let ((buffer-read-only nil)
5161 (inhibit-point-motion-hooks t)
5162 (case-fold-search t)
5163 (alist gnus-header-button-alist)
5165 (article-narrow-to-head)
5167 ;; Each alist entry.
5168 (setq entry (car alist)
5170 (goto-char (point-min))
5171 (while (re-search-forward (car entry) nil t)
5172 ;; Each header matching the entry.
5173 (setq beg (match-beginning 0))
5174 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5175 (match-beginning 0))
5178 (while (re-search-forward (nth 1 entry) end t)
5179 ;; Each match within a header.
5180 (let* ((entry (cdr entry))
5181 (start (match-beginning (nth 1 entry)))
5182 (end (match-end (nth 1 entry)))
5183 (form (nth 2 entry)))
5184 (goto-char (match-end 0))
5186 (gnus-article-add-button
5187 start end (nth 3 entry)
5188 (buffer-substring (match-beginning (nth 4 entry))
5189 (match-end (nth 4 entry)))))))
5190 (goto-char end)))))))
5192 ;;; External functions:
5194 (defun gnus-article-add-button (from to fun &optional data)
5195 "Create a button between FROM and TO with callback FUN and data DATA."
5196 (when gnus-article-button-face
5197 (gnus-overlay-put (gnus-make-overlay from to)
5198 'face gnus-article-button-face))
5199 (gnus-add-text-properties
5201 (nconc (and gnus-article-mouse-face
5202 (list gnus-mouse-face-prop gnus-article-mouse-face))
5203 (list 'gnus-callback fun)
5204 (and data (list 'gnus-data data))))
5205 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5206 :button-keymap gnus-widget-button-keymap))
5208 ;;; Internal functions:
5210 (defun gnus-article-set-globals ()
5212 (set-buffer gnus-summary-buffer)
5213 (gnus-set-global-variables)))
5215 (defun gnus-signature-toggle (end)
5217 (set-buffer gnus-article-buffer)
5218 (let ((buffer-read-only nil)
5219 (inhibit-point-motion-hooks t))
5220 (if (text-property-any end (point-max) 'article-type 'signature)
5222 (setq gnus-article-wash-types
5223 (delq 'signature gnus-article-wash-types))
5224 (gnus-remove-text-properties-when
5225 'article-type 'signature end (point-max)
5226 (cons 'article-type (cons 'signature
5227 gnus-hidden-properties))))
5228 (or (memq 'signature gnus-article-wash-types)
5229 (push 'signature gnus-article-wash-types))
5230 (gnus-add-text-properties-when
5231 'article-type nil end (point-max)
5232 (cons 'article-type (cons 'signature
5233 gnus-hidden-properties)))))
5234 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5235 (gnus-set-mode-line 'article))))
5237 (defun gnus-button-entry ()
5238 ;; Return the first entry in `gnus-button-alist' matching this place.
5239 (let ((alist gnus-button-alist)
5242 (setq entry (pop alist))
5243 (if (looking-at (car entry))
5248 (defun gnus-button-push (marker)
5249 ;; Push button starting at MARKER.
5252 (let* ((entry (gnus-button-entry))
5253 (inhibit-point-motion-hooks t)
5255 (args (mapcar (lambda (group)
5256 (let ((string (match-string group)))
5257 (gnus-set-text-properties
5258 0 (length string) nil string)
5265 (fboundp (symbol-value fun)))
5266 (apply (symbol-value fun) args))
5268 (gnus-message 1 "You must define `%S' to use this button"
5269 (cons fun args)))))))
5271 (defun gnus-parse-news-url (url)
5272 (let (scheme server group message-id articles)
5275 (goto-char (point-min))
5276 (when (looking-at "\\([A-Za-z]+\\):")
5277 (setq scheme (match-string 1))
5278 (goto-char (match-end 0)))
5279 (when (looking-at "//\\([^/]+\\)/")
5280 (setq server (match-string 1))
5281 (goto-char (match-end 0)))
5284 ((looking-at "\\(.*@.*\\)")
5285 (setq message-id (match-string 1)))
5286 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5287 (setq group (match-string 1)
5288 articles (split-string (match-string 2) "-")))
5289 ((looking-at "\\([^/]+\\)/?")
5290 (setq group (match-string 1)))
5292 (error "Unknown news URL syntax"))))
5293 (list scheme server group message-id articles)))
5295 (defun gnus-button-handle-news (url)
5297 (destructuring-bind (scheme server group message-id articles)
5298 (gnus-parse-news-url url)
5302 (set-buffer gnus-summary-buffer)
5304 (let ((gnus-refer-article-method (list (list 'nntp server))))
5305 (gnus-summary-refer-article message-id))
5306 (gnus-summary-refer-article message-id))))
5308 (gnus-button-fetch-group url)))))
5310 (defun gnus-button-handle-info (url)
5311 "Fetch an info URL."
5313 "^\\([^:/]+\\)?/\\(.*\\)"
5315 (gnus-info-find-node
5316 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5319 (gnus-url-unhex-string (match-string 2 url))))
5320 (error "Can't parse %s" url)))
5322 (defun gnus-button-message-id (message-id)
5325 (set-buffer gnus-summary-buffer)
5326 (gnus-summary-refer-article message-id)))
5328 (defun gnus-button-fetch-group (address)
5329 "Fetch GROUP specified by ADDRESS."
5330 (if (not (string-match "[:/]" address))
5331 ;; This is just a simple group url.
5332 (gnus-group-read-ephemeral-group address gnus-select-method)
5335 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5337 (error "Can't parse %s" address)
5338 (gnus-group-read-ephemeral-group
5339 (match-string 4 address)
5340 `(nntp ,(match-string 1 address)
5341 (nntp-address ,(match-string 1 address))
5342 (nntp-port-number ,(if (match-end 3)
5343 (match-string 3 address)
5346 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5348 (defun gnus-url-parse-query-string (query &optional downcase)
5349 (let (retval pairs cur key val)
5350 (setq pairs (split-string query "&"))
5352 (setq cur (car pairs)
5354 (if (not (string-match "=" cur))
5356 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5357 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5359 (setq key (downcase key)))
5360 (setq cur (assoc key retval))
5362 (setcdr cur (cons val (cdr cur)))
5363 (setq retval (cons (list key val) retval)))))
5366 (defun gnus-url-mailto (url)
5367 ;; Send mail to someone
5368 (when (string-match "mailto:/*\\(.*\\)" url)
5369 (setq url (substring url (match-beginning 1) nil)))
5370 (let (to args subject func)
5371 (if (string-match (regexp-quote "?") url)
5372 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5373 args (gnus-url-parse-query-string
5374 (substring url (match-end 0) nil) t))
5375 (setq to (gnus-url-unhex-string url)))
5376 (setq args (cons (list "to" to) args)
5377 subject (cdr-safe (assoc "subject" args)))
5380 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5383 (message-position-on-field (caar args)))
5384 (insert (mapconcat 'identity (cdar args) ", "))
5385 (setq args (cdr args)))
5388 (message-goto-subject))))
5390 (defun gnus-button-embedded-url (address)
5391 "Activate ADDRESS with `browse-url'."
5392 (browse-url (gnus-strip-whitespace address)))
5394 ;;; Next/prev buttons in the article buffer.
5396 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5397 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5399 (defvar gnus-prev-page-map nil)
5400 (unless gnus-prev-page-map
5401 (setq gnus-prev-page-map (make-sparse-keymap))
5402 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5403 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5405 (defun gnus-insert-prev-page-button ()
5406 (let ((buffer-read-only nil))
5408 gnus-prev-page-line-format nil
5409 `(gnus-prev t local-map ,gnus-prev-page-map
5410 gnus-callback gnus-article-button-prev-page
5411 article-type annotation))))
5413 (defvar gnus-next-page-map nil)
5414 (unless gnus-next-page-map
5415 (setq gnus-next-page-map (make-keymap))
5416 (suppress-keymap gnus-prev-page-map)
5417 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5418 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5420 (defun gnus-button-next-page ()
5421 "Go to the next page."
5423 (let ((win (selected-window)))
5424 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5425 (gnus-article-next-page)
5426 (select-window win)))
5428 (defun gnus-button-prev-page ()
5429 "Go to the prev page."
5431 (let ((win (selected-window)))
5432 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5433 (gnus-article-prev-page)
5434 (select-window win)))
5436 (defun gnus-insert-next-page-button ()
5437 (let ((buffer-read-only nil))
5438 (gnus-eval-format gnus-next-page-line-format nil
5440 t local-map ,gnus-next-page-map
5441 gnus-callback gnus-article-button-next-page
5442 article-type annotation))))
5444 (defun gnus-article-button-next-page (arg)
5445 "Go to the next page."
5447 (let ((win (selected-window)))
5448 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5449 (gnus-article-next-page)
5450 (select-window win)))
5452 (defun gnus-article-button-prev-page (arg)
5453 "Go to the prev page."
5455 (let ((win (selected-window)))
5456 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5457 (gnus-article-prev-page)
5458 (select-window win)))
5460 (defvar gnus-decode-header-methods
5461 '(mail-decode-encoded-word-region)
5462 "List of methods used to decode headers.
5464 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5465 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5466 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5467 whose names match REGEXP.
5470 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5471 mail-decode-encoded-word-region
5472 (\"chinese\" . rfc1843-decode-region))
5475 (defvar gnus-decode-header-methods-cache nil)
5477 (defun gnus-multi-decode-header (start end)
5478 "Apply the functions from `gnus-encoded-word-methods' that match."
5479 (unless (and gnus-decode-header-methods-cache
5480 (eq gnus-newsgroup-name
5481 (car gnus-decode-header-methods-cache)))
5482 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5485 (nconc gnus-decode-header-methods-cache (list x))
5486 (if (and gnus-newsgroup-name
5487 (string-match (car x) gnus-newsgroup-name))
5488 (nconc gnus-decode-header-methods-cache
5490 gnus-decode-header-methods))
5491 (let ((xlist gnus-decode-header-methods-cache))
5494 (narrow-to-region start end)
5496 (funcall (pop xlist) (point-min) (point-max))))))
5499 ;;; Treatment top-level handling.
5502 (defun gnus-treat-article (condition &optional part-number total-parts type)
5503 (let ((length (- (point-max) (point-min)))
5504 (alist gnus-treatment-function-alist)
5505 (article-goto-body-goes-to-point-min-p t)
5509 (let ((list gnus-article-treat-types))
5511 (when (string-match (pop list) type)
5512 (throw 'found t)))))))
5513 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5515 (gnus-run-hooks 'gnus-part-display-hook)
5516 (while (setq elem (pop alist))
5519 (if (gnus-buffer-live-p gnus-summary-buffer)
5520 (set-buffer gnus-summary-buffer))
5521 (symbol-value (car elem))))
5522 (when (and (or (consp val)
5524 (gnus-treat-predicate val)
5525 (or (not (get (car elem) 'highlight))
5528 (funcall (cadr elem)))))))
5530 ;; Dynamic variables.
5532 (defvar part-number)
5533 (defvar total-parts)
5538 (defun gnus-treat-predicate (val)
5543 (stringp (car val)))
5544 (apply 'gnus-or (mapcar `(lambda (s)
5545 (string-match s ,(or gnus-newsgroup-name "")))
5548 (let ((pred (pop val)))
5551 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5553 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5555 (not (gnus-treat-predicate (car val))))
5557 (equal (car val) type))
5559 (error "%S is not a valid predicate" pred)))))
5567 (eq part-number total-parts))
5571 (error "%S is not a valid value" val))))
5573 (defun gnus-article-encrypt-body (protocol &optional n)
5574 "Encrypt the article body."
5577 (or gnus-article-encrypt-protocol
5578 (completing-read "Encrypt protocol: "
5579 gnus-article-encrypt-protocol-alist
5581 current-prefix-arg))
5582 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5584 (error (format "Can't find the encrypt protocol %s" protocol)))
5585 (if (equal gnus-newsgroup-name "nndraft:drafts")
5586 (error "Can't encrypt the article in group nndraft:drafts"))
5587 (if (equal gnus-newsgroup-name "nndraft:queue")
5588 (error "Don't encrypt the article in group nndraft:queue"))
5589 (gnus-summary-iterate n
5591 (set-buffer gnus-summary-buffer)
5592 (let ((mail-parse-charset gnus-newsgroup-charset)
5593 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5594 (summary-buffer gnus-summary-buffer)
5596 (gnus-set-global-variables)
5597 (when (gnus-group-read-only-p)
5598 (error "The current newsgroup does not support article encrypt"))
5599 (gnus-summary-show-article t)
5601 (or (mail-header-references gnus-current-headers) ""))
5602 (set-buffer gnus-article-buffer)
5603 (let* ((buffer-read-only nil)
5605 (mapcar (lambda (field)
5606 (and (save-restriction
5607 (message-narrow-to-head)
5608 (goto-char (point-min))
5609 (search-forward field nil t))
5611 (message-narrow-to-field)
5612 (buffer-substring (point-min) (point-max))
5613 (delete-region (point-min) (point-max))
5615 '("Content-Type:" "Content-Transfer-Encoding:"
5616 "Content-Disposition:"))))
5617 (message-narrow-to-head)
5618 (message-remove-header "MIME-Version")
5619 (goto-char (point-max))
5620 (setq point (point))
5621 (insert (apply 'concat headers))
5623 (narrow-to-region point (point-max))
5624 (let ((message-options message-options))
5625 (message-options-set 'message-sender user-mail-address)
5626 (message-options-set 'message-recipients user-mail-address)
5627 (message-options-set 'message-sign-encrypt 'not)
5629 (goto-char (point-min))
5630 (insert "MIME-Version: 1.0\n")
5632 (gnus-summary-edit-article-done
5633 references nil summary-buffer t))
5634 (when gnus-keep-backlog
5635 (gnus-backlog-remove-article
5636 (car gnus-article-current) (cdr gnus-article-current)))
5638 (when (get-buffer gnus-original-article-buffer)
5639 (set-buffer gnus-original-article-buffer)
5640 (setq gnus-original-article nil)))
5641 (when gnus-use-cache
5642 (gnus-cache-update-article
5643 (car gnus-article-current) (cdr gnus-article-current))))))))
5645 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5646 "The following specs can be used:
5647 %t The security MIME type
5650 %D Details if button is pressed")
5652 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5653 "The following specs can be used:
5654 %t The security MIME type
5657 %D Details if button is pressed")
5659 (defvar gnus-mime-security-button-line-format-alist
5660 '((?t gnus-tmp-type ?s)
5661 (?i gnus-tmp-info ?s)
5662 (?d gnus-tmp-details ?s)
5663 (?D gnus-tmp-pressed-details ?s)))
5665 (defvar gnus-mime-security-button-map
5666 (let ((map (make-sparse-keymap)))
5667 (unless (>= (string-to-number emacs-version) 21)
5668 (set-keymap-parent map gnus-article-mode-map))
5669 (define-key map gnus-mouse-2 'gnus-article-push-button)
5670 (define-key map "\r" 'gnus-article-press-button)
5673 (defvar gnus-mime-security-details-buffer nil)
5675 (defvar gnus-mime-security-button-pressed nil)
5677 (defvar gnus-mime-security-show-details-inline t
5678 "If non-nil, show details in the article buffer.")
5680 (defun gnus-mime-security-verify-or-decrypt (handle)
5681 (mm-remove-parts (cdr handle))
5682 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5683 point buffer-read-only)
5685 (goto-char (car region)))
5687 (narrow-to-region (point) (point))
5688 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5689 (let* ((mm-verify-option 'known)
5690 (mm-decrypt-option 'known)
5691 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5692 (unless (eq nparts (cdr handle))
5693 (mm-destroy-parts (cdr handle))
5694 (setcdr handle nparts))))
5695 (setq point (point))
5696 (gnus-mime-display-security handle)
5697 (goto-char (point-max)))
5699 (delete-region (point) (cdr region))
5700 (set-marker (car region) nil)
5701 (set-marker (cdr region) nil))
5704 (defun gnus-mime-security-show-details (handle)
5705 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5707 (if gnus-mime-security-show-details-inline
5708 (let ((gnus-mime-security-button-pressed t)
5709 (gnus-mime-security-button-line-format
5710 (get-text-property (point) 'gnus-line-format))
5713 (while (eq (get-text-property (point) 'gnus-line-format)
5714 gnus-mime-security-button-line-format)
5718 (narrow-to-region (point) (point))
5719 (gnus-insert-mime-security-button handle))
5720 (delete-region (point)
5721 (or (text-property-not-all
5724 gnus-mime-security-button-line-format)
5726 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5727 (with-current-buffer gnus-mime-security-details-buffer
5730 (setq gnus-mime-security-details-buffer
5731 (gnus-get-buffer-create "*MIME Security Details*")))
5732 (with-current-buffer gnus-mime-security-details-buffer
5734 (goto-char (point-min)))
5735 (pop-to-buffer gnus-mime-security-details-buffer))
5736 (gnus-message 5 "No details."))))
5738 (defun gnus-mime-security-press-button (handle)
5739 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5740 (gnus-mime-security-show-details handle)
5741 (gnus-mime-security-verify-or-decrypt handle)))
5743 (defun gnus-insert-mime-security-button (handle &optional displayed)
5744 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5747 (or (nth 2 (assoc protocol mm-verify-function-alist))
5748 (nth 2 (assoc protocol mm-decrypt-function-alist))
5750 (if (equal (car handle) "multipart/signed")
5751 " Signed" " Encrypted")
5754 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5757 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5758 gnus-tmp-pressed-details
5760 (setq gnus-tmp-details
5761 (if gnus-tmp-details
5762 (concat "\n" gnus-tmp-details) ""))
5763 (setq gnus-tmp-pressed-details
5764 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5769 gnus-mime-security-button-line-format
5770 gnus-mime-security-button-line-format-alist
5771 `(keymap ,gnus-mime-security-button-map
5772 ,@(if (>= (string-to-number emacs-version) 21)
5773 nil ;; XEmacs doesn't care
5774 (list 'local-map gnus-mime-security-button-map))
5775 gnus-callback gnus-mime-security-press-button
5776 gnus-line-format ,gnus-mime-security-button-line-format
5777 article-type annotation
5780 (widget-convert-button
5783 :action 'gnus-widget-press-button
5784 :button-keymap gnus-mime-security-button-map
5786 (lambda (widget/window &optional overlay pos)
5787 ;; Needed to properly clear the message due to a bug in
5788 ;; wid-edit (XEmacs only).
5789 (if (boundp 'help-echo-owns-message)
5790 (setq help-echo-owns-message t))
5793 (aref gnus-mouse-2 0))))))
5795 (defun gnus-mime-display-security (handle)
5797 (narrow-to-region (point) (point))
5798 (unless (gnus-unbuttonized-mime-type-p (car handle))
5799 (gnus-insert-mime-security-button handle))
5800 (gnus-mime-display-mixed (cdr handle))
5803 (unless (gnus-unbuttonized-mime-type-p (car handle))
5804 (let ((gnus-mime-security-button-line-format
5805 gnus-mime-security-button-end-line-format))
5806 (gnus-insert-mime-security-button handle)))
5807 (mm-set-handle-multipart-parameter
5809 (cons (set-marker (make-marker) (point-min))
5810 (set-marker (make-marker) (point-max))))))
5812 (defun gnus-article-goto-header (header)
5813 (re-search-forward (concat "^" header ":") nil t))
5819 (run-hooks 'gnus-art-load-hook)
5821 ;;; gnus-art.el ends here