Mercurial > emacs
comparison lisp/gnus/gnus-art.el @ 31716:9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 19 Sep 2000 13:37:09 +0000 |
parents | 925a1c3dd62a |
children | 51cea22fd2aa |
comparison
equal
deleted
inserted
replaced
31715:7c896543d225 | 31716:9968f55ad26e |
---|---|
1 ;;; gnus-art.el --- article mode commands for Gnus | 1 ;;; gnus-art.el --- article mode commands for Gnus |
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc. | 2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. |
3 | 3 |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> | 4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
5 ;; Keywords: news | 5 ;; Keywords: news |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
25 | 25 |
26 ;;; Code: | 26 ;;; Code: |
27 | 27 |
28 (eval-when-compile (require 'cl)) | 28 (eval-when-compile (require 'cl)) |
29 | 29 |
30 (eval-when-compile (require 'cl)) | |
31 | |
32 (require 'custom) | |
33 (require 'gnus) | 30 (require 'gnus) |
34 (require 'gnus-sum) | 31 (require 'gnus-sum) |
35 (require 'gnus-spec) | 32 (require 'gnus-spec) |
36 (require 'gnus-int) | 33 (require 'gnus-int) |
37 (require 'browse-url) | 34 (require 'mm-bodies) |
35 (require 'mail-parse) | |
36 (require 'mm-decode) | |
37 (require 'mm-view) | |
38 (require 'wid-edit) | |
39 (require 'mm-uu) | |
38 | 40 |
39 (defgroup gnus-article nil | 41 (defgroup gnus-article nil |
40 "Article display." | 42 "Article display." |
41 :link '(custom-manual "(gnus)The Article Buffer") | 43 :link '(custom-manual "(gnus)The Article Buffer") |
42 :group 'gnus) | 44 :group 'gnus) |
45 | |
46 (defgroup gnus-article-treat nil | |
47 "Treating article parts." | |
48 :link '(custom-manual "(gnus)Article Hiding") | |
49 :group 'gnus-article) | |
43 | 50 |
44 (defgroup gnus-article-hiding nil | 51 (defgroup gnus-article-hiding nil |
45 "Hiding article parts." | 52 "Hiding article parts." |
46 :link '(custom-manual "(gnus)Article Hiding") | 53 :link '(custom-manual "(gnus)Article Hiding") |
47 :group 'gnus-article) | 54 :group 'gnus-article) |
105 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:" | 112 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:" |
106 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:" | 113 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:" |
107 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:" | 114 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:" |
108 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:" | 115 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:" |
109 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:" | 116 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:" |
110 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:" | 117 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:" |
111 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:" | |
112 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:" | 118 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:" |
113 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:" | 119 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:" |
114 "^Status:") | 120 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:" |
121 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:" | |
122 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:" | |
123 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:" | |
124 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:" | |
125 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:" | |
126 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:" | |
127 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:" | |
128 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:" | |
129 "^X-Received:" "^Content-length:" "X-precedence:") | |
115 "*All headers that start with this regexp will be hidden. | 130 "*All headers that start with this regexp will be hidden. |
116 This variable can also be a list of regexps of headers to be ignored. | 131 This variable can also be a list of regexps of headers to be ignored. |
117 If `gnus-visible-headers' is non-nil, this variable will be ignored." | 132 If `gnus-visible-headers' is non-nil, this variable will be ignored." |
118 :type '(choice :custom-show nil | 133 :type '(choice :custom-show nil |
119 regexp | 134 regexp |
120 (repeat regexp)) | 135 (repeat regexp)) |
121 :group 'gnus-article-hiding) | 136 :group 'gnus-article-hiding) |
122 | 137 |
123 (defcustom gnus-visible-headers | 138 (defcustom gnus-visible-headers |
124 "From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|X-Sent:" | 139 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:" |
125 "*All headers that do not match this regexp will be hidden. | 140 "*All headers that do not match this regexp will be hidden. |
126 This variable can also be a list of regexp of headers to remain visible. | 141 This variable can also be a list of regexp of headers to remain visible. |
127 If this variable is non-nil, `gnus-ignored-headers' will be ignored." | 142 If this variable is non-nil, `gnus-ignored-headers' will be ignored." |
128 :type '(repeat :value-to-internal (lambda (widget value) | 143 :type '(repeat :value-to-internal (lambda (widget value) |
129 (custom-split-regexp-maybe value)) | 144 (custom-split-regexp-maybe value)) |
150 :type '(set (const :tag "Headers with no content." empty) | 165 :type '(set (const :tag "Headers with no content." empty) |
151 (const :tag "Newsgroups with only one group." newsgroups) | 166 (const :tag "Newsgroups with only one group." newsgroups) |
152 (const :tag "Followup-to identical to newsgroups." followup-to) | 167 (const :tag "Followup-to identical to newsgroups." followup-to) |
153 (const :tag "Reply-to identical to from." reply-to) | 168 (const :tag "Reply-to identical to from." reply-to) |
154 (const :tag "Date less than four days old." date) | 169 (const :tag "Date less than four days old." date) |
155 (const :tag "Very long To header." long-to) | 170 (const :tag "Very long To and/or Cc header." long-to) |
156 (const :tag "Multiple To headers." many-to)) | 171 (const :tag "Multiple To and/or Cc headers." many-to)) |
157 :group 'gnus-article-hiding) | 172 :group 'gnus-article-hiding) |
158 | 173 |
159 (defcustom gnus-signature-separator '("^-- $" "^-- *$") | 174 (defcustom gnus-signature-separator '("^-- $" "^-- *$") |
160 "Regexp matching signature separator. | 175 "Regexp matching signature separator. |
161 This can also be a list of regexps. In that case, it will be checked | 176 This can also be a list of regexps. In that case, it will be checked |
163 the end of the buffer." | 178 the end of the buffer." |
164 :type '(repeat string) | 179 :type '(repeat string) |
165 :group 'gnus-article-signature) | 180 :group 'gnus-article-signature) |
166 | 181 |
167 (defcustom gnus-signature-limit nil | 182 (defcustom gnus-signature-limit nil |
168 "Provide a limit to what is considered a signature. | 183 "Provide a limit to what is considered a signature. |
169 If it is a number, no signature may not be longer (in characters) than | 184 If it is a number, no signature may not be longer (in characters) than |
170 that number. If it is a floating point number, no signature may be | 185 that number. If it is a floating point number, no signature may be |
171 longer (in lines) than that number. If it is a function, the function | 186 longer (in lines) than that number. If it is a function, the function |
172 will be called without any parameters, and if it returns nil, there is | 187 will be called without any parameters, and if it returns nil, there is |
173 no signature in the buffer. If it is a string, it will be used as a | 188 no signature in the buffer. If it is a string, it will be used as a |
181 (defcustom gnus-hidden-properties '(invisible t intangible t) | 196 (defcustom gnus-hidden-properties '(invisible t intangible t) |
182 "Property list to use for hiding text." | 197 "Property list to use for hiding text." |
183 :type 'sexp | 198 :type 'sexp |
184 :group 'gnus-article-hiding) | 199 :group 'gnus-article-hiding) |
185 | 200 |
201 ;; Fixme: This isn't the right thing for mixed graphical and and | |
202 ;; non-graphical frames in a session. | |
203 ;; gnus-xmas.el overrides this for XEmacs. | |
186 (defcustom gnus-article-x-face-command | 204 (defcustom gnus-article-x-face-command |
187 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -" | 205 (if (and (fboundp 'image-type-available-p) |
206 (image-type-available-p 'xbm)) | |
207 'gnus-article-display-xface | |
208 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | display -") | |
188 "*String or function to be executed to display an X-Face header. | 209 "*String or function to be executed to display an X-Face header. |
189 If it is a string, the command will be executed in a sub-shell | 210 If it is a string, the command will be executed in a sub-shell |
190 asynchronously. The compressed face will be piped to this command." | 211 asynchronously. The compressed face will be piped to this command." |
191 :type 'string ;Leave function case to Lisp. | 212 :type '(choice string |
213 (function-item gnus-article-display-xface) | |
214 function) | |
192 :group 'gnus-article-washing) | 215 :group 'gnus-article-washing) |
193 | 216 |
194 (defcustom gnus-article-x-face-too-ugly nil | 217 (defcustom gnus-article-x-face-too-ugly nil |
195 "Regexp matching posters whose face shouldn't be shown automatically." | 218 "Regexp matching posters whose face shouldn't be shown automatically." |
196 :type '(choice regexp (const nil)) | 219 :type '(choice regexp (const nil)) |
197 :group 'gnus-article-washing) | 220 :group 'gnus-article-washing) |
198 | 221 |
199 (defcustom gnus-emphasis-alist | 222 (defcustom gnus-emphasis-alist |
200 (let ((format | 223 (let ((format |
201 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)") | 224 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)") |
202 (types | 225 (types |
203 '(("_" "_" underline) | 226 '(("_" "_" underline) |
204 ("/" "/" italic) | 227 ("/" "/" italic) |
205 ("\\*" "\\*" bold) | 228 ("\\*" "\\*" bold) |
206 ("_/" "/_" underline-italic) | 229 ("_/" "/_" underline-italic) |
230 (integer :tag "Match group") | 253 (integer :tag "Match group") |
231 (integer :tag "Emphasize group") | 254 (integer :tag "Emphasize group") |
232 face)) | 255 face)) |
233 :group 'gnus-article-emphasis) | 256 :group 'gnus-article-emphasis) |
234 | 257 |
258 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n" | |
259 "A regexp to describe whitespace which should not be emphasized. | |
260 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\". | |
261 The former avoids underlining of leading and trailing whitespace, | |
262 and the latter avoids underlining any whitespace at all." | |
263 :group 'gnus-article-emphasis | |
264 :type 'regexp) | |
265 | |
235 (defface gnus-emphasis-bold '((t (:bold t))) | 266 (defface gnus-emphasis-bold '((t (:bold t))) |
236 "Face used for displaying strong emphasized text (*word*)." | 267 "Face used for displaying strong emphasized text (*word*)." |
237 :group 'gnus-article-emphasis) | 268 :group 'gnus-article-emphasis) |
238 | 269 |
239 (defface gnus-emphasis-italic '((t (:italic t))) | 270 (defface gnus-emphasis-italic '((t (:italic t))) |
258 | 289 |
259 (defface gnus-emphasis-underline-bold-italic | 290 (defface gnus-emphasis-underline-bold-italic |
260 '((t (:bold t :italic t :underline t))) | 291 '((t (:bold t :italic t :underline t))) |
261 "Face used for displaying underlined bold italic emphasized text. | 292 "Face used for displaying underlined bold italic emphasized text. |
262 Esample: (_/*word*/_)." | 293 Esample: (_/*word*/_)." |
294 :group 'gnus-article-emphasis) | |
295 | |
296 (defface gnus-emphasis-highlight-words | |
297 '((t (:background "black" :foreground "yellow"))) | |
298 "Face used for displaying highlighted words." | |
263 :group 'gnus-article-emphasis) | 299 :group 'gnus-article-emphasis) |
264 | 300 |
265 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z" | 301 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z" |
266 "Format for display of Date headers in article bodies. | 302 "Format for display of Date headers in article bodies. |
267 See `format-time-string' for the possible values. | 303 See `format-time-string' for the possible values. |
272 :type '(choice string symbol) | 308 :type '(choice string symbol) |
273 :link '(custom-manual "(gnus)Article Date") | 309 :link '(custom-manual "(gnus)Article Date") |
274 :group 'gnus-article-washing) | 310 :group 'gnus-article-washing) |
275 | 311 |
276 (eval-and-compile | 312 (eval-and-compile |
277 (autoload 'hexl-hex-string-to-integer "hexl") | |
278 (autoload 'timezone-make-date-arpa-standard "timezone") | |
279 (autoload 'mail-extract-address-components "mail-extr")) | 313 (autoload 'mail-extract-address-components "mail-extr")) |
280 | 314 |
281 (defcustom gnus-save-all-headers t | 315 (defcustom gnus-save-all-headers t |
282 "*If non-nil, don't remove any headers before saving." | 316 "*If non-nil, don't remove any headers before saving." |
283 :group 'gnus-article-saving | 317 :group 'gnus-article-saving |
375 :group 'gnus-article-saving | 409 :group 'gnus-article-saving |
376 :type '(repeat (choice (list :value (fun) function) | 410 :type '(repeat (choice (list :value (fun) function) |
377 (cons :value ("" "") regexp (repeat string)) | 411 (cons :value ("" "") regexp (repeat string)) |
378 (sexp :value nil)))) | 412 (sexp :value nil)))) |
379 | 413 |
380 (defcustom gnus-strict-mime t | |
381 "*If nil, MIME-decode even if there is no Mime-Version header." | |
382 :group 'gnus-article-mime | |
383 :type 'boolean) | |
384 | |
385 (defcustom gnus-show-mime-method 'metamail-buffer | |
386 "Function to process a MIME message. | |
387 The function is called from the article buffer." | |
388 :group 'gnus-article-mime | |
389 :type 'function) | |
390 | |
391 (defcustom gnus-decode-encoded-word-method 'gnus-article-de-quoted-unreadable | |
392 "*Function to decode MIME encoded words. | |
393 The function is called from the article buffer." | |
394 :group 'gnus-article-mime | |
395 :type 'function) | |
396 | |
397 (defcustom gnus-show-traditional-method | |
398 (if (and (featurep 'mule) | |
399 (boundp 'enable-multibyte-characters)) | |
400 (lambda () | |
401 (if enable-multibyte-characters (gnus-mule-decode-article))) | |
402 (lambda ())) | |
403 "Function to decode ``localized RFC 822 messages''. | |
404 The function is called from the article buffer." | |
405 :group 'gnus-article-mime | |
406 :type 'function) | |
407 | |
408 (defcustom gnus-page-delimiter "^\^L" | 414 (defcustom gnus-page-delimiter "^\^L" |
409 "*Regexp describing what to use as article page delimiters. | 415 "*Regexp describing what to use as article page delimiters. |
410 The default value is \"^\^L\", which is a form linefeed at the | 416 The default value is \"^\^L\", which is a form linefeed at the |
411 beginning of a line." | 417 beginning of a line." |
412 :type 'regexp | 418 :type 'regexp |
413 :group 'gnus-article-various) | 419 :group 'gnus-article-various) |
414 | 420 |
415 (defcustom gnus-article-mode-line-format "Gnus: %%b %S" | 421 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m" |
416 "*The format specification for the article mode line. | 422 "*The format specification for the article mode line. |
417 See `gnus-summary-mode-line-format' for a closer description." | 423 See `gnus-summary-mode-line-format' for a closer description. |
424 | |
425 The following additional specs are available: | |
426 | |
427 %w The article washing status. | |
428 %m The number of MIME parts in the article." | |
418 :type 'string | 429 :type 'string |
419 :group 'gnus-article-various) | 430 :group 'gnus-article-various) |
420 | 431 |
421 (defcustom gnus-article-mode-hook nil | 432 (defcustom gnus-article-mode-hook nil |
422 "*A hook for Gnus article mode." | 433 "*A hook for Gnus article mode." |
427 "*Hook run after the creation of the article mode menu." | 438 "*Hook run after the creation of the article mode menu." |
428 :type 'hook | 439 :type 'hook |
429 :group 'gnus-article-various) | 440 :group 'gnus-article-various) |
430 | 441 |
431 (defcustom gnus-article-prepare-hook nil | 442 (defcustom gnus-article-prepare-hook nil |
432 "*A hook called after an article has been prepared in the article buffer. | 443 "*A hook called after an article has been prepared in the article buffer." |
433 If you want to run a special decoding program like nkf, use this hook." | |
434 :type 'hook | 444 :type 'hook |
435 :group 'gnus-article-various) | 445 :group 'gnus-article-various) |
436 | 446 |
437 (defcustom gnus-article-hide-pgp-hook nil | 447 (defcustom gnus-article-hide-pgp-hook nil |
438 "*A hook called after successfully hiding a PGP signature." | 448 "*A hook called after successfully hiding a PGP signature." |
557 (face :value default)) | 567 (face :value default)) |
558 (choice :tag "Content" | 568 (choice :tag "Content" |
559 (item :tag "skip" nil) | 569 (item :tag "skip" nil) |
560 (face :value default))))) | 570 (face :value default))))) |
561 | 571 |
572 (defcustom gnus-article-decode-hook | |
573 '(article-decode-charset article-decode-encoded-words) | |
574 "*Hook run to decode charsets in articles." | |
575 :group 'gnus-article-headers | |
576 :type 'hook) | |
577 | |
578 (defcustom gnus-display-mime-function 'gnus-display-mime | |
579 "Function to display MIME articles." | |
580 :group 'gnus-article-mime | |
581 :type 'function) | |
582 | |
583 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region | |
584 "Function used to decode headers.") | |
585 | |
586 (defvar gnus-article-dumbquotes-map | |
587 '(("\202" ",") | |
588 ("\203" "f") | |
589 ("\204" ",,") | |
590 ("\205" "...") | |
591 ("\213" "<") | |
592 ("\214" "OE") | |
593 ("\221" "`") | |
594 ("\222" "'") | |
595 ("\223" "``") | |
596 ("\224" "\"") | |
597 ("\225" "*") | |
598 ("\226" "---") | |
599 ("\227" "-") | |
600 ("\231" "(TM)") | |
601 ("\233" ">") | |
602 ("\234" "oe") | |
603 ("\264" "'")) | |
604 "Table for MS-to-Latin1 translation.") | |
605 | |
606 (defcustom gnus-ignored-mime-types nil | |
607 "List of MIME types that should be ignored by Gnus." | |
608 :group 'gnus-article-mime | |
609 :type '(repeat regexp)) | |
610 | |
611 (defcustom gnus-unbuttonized-mime-types '(".*/.*") | |
612 "List of MIME types that should not be given buttons when rendered inline." | |
613 :group 'gnus-article-mime | |
614 :type '(repeat regexp)) | |
615 | |
616 (defcustom gnus-article-mime-part-function nil | |
617 "Function called with a MIME handle as the argument. | |
618 This is meant for people who want to do something automatic based | |
619 on parts -- for instance, adding Vcard info to a database." | |
620 :group 'gnus-article-mime | |
621 :type 'function) | |
622 | |
623 (defcustom gnus-mime-multipart-functions nil | |
624 "An alist of MIME types to functions to display them.") | |
625 | |
626 (defcustom gnus-article-date-lapsed-new-header nil | |
627 "Whether the X-Sent and Date headers can coexist. | |
628 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will | |
629 either replace the old \"Date:\" header (if this variable is nil), or | |
630 be added below it (otherwise)." | |
631 :group 'gnus-article-headers | |
632 :type 'boolean) | |
633 | |
634 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative | |
635 "Function called with a MIME handle as the argument. | |
636 This is meant for people who want to view first matched part. | |
637 For `undisplayed-alternative' (default), the first undisplayed | |
638 part or alternative part is used. For `undisplayed', the first | |
639 undisplayed part is used. For a function, the first part which | |
640 the function return `t' is used. For `nil', the first part is | |
641 used." | |
642 :group 'gnus-article-mime | |
643 :type '(choice | |
644 (item :tag "first" :value nil) | |
645 (item :tag "undisplayed" :value undisplayed) | |
646 (item :tag "undisplayed or alternative" | |
647 :value undisplayed-alternative) | |
648 (function))) | |
649 | |
650 ;;; | |
651 ;;; The treatment variables | |
652 ;;; | |
653 | |
654 (defvar gnus-part-display-hook nil | |
655 "Hook called on parts that are to receive treatment.") | |
656 | |
657 (defvar gnus-article-treat-custom | |
658 '(choice (const :tag "Off" nil) | |
659 (const :tag "On" t) | |
660 (const :tag "Header" head) | |
661 (const :tag "Last" last) | |
662 (integer :tag "Less") | |
663 (repeat :tag "Groups" regexp) | |
664 (sexp :tag "Predicate"))) | |
665 | |
666 (defvar gnus-article-treat-head-custom | |
667 '(choice (const :tag "Off" nil) | |
668 (const :tag "Header" head))) | |
669 | |
670 (defvar gnus-article-treat-types '("text/plain") | |
671 "Parts to treat.") | |
672 | |
673 (defvar gnus-inhibit-treatment nil | |
674 "Whether to inhibit treatment.") | |
675 | |
676 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard")) | |
677 "Highlight the signature. | |
678 Valid values are nil, t, `head', `last', an integer or a predicate. | |
679 See the manual for details." | |
680 :group 'gnus-article-treat | |
681 :type gnus-article-treat-custom) | |
682 (put 'gnus-treat-highlight-signature 'highlight t) | |
683 | |
684 (defcustom gnus-treat-buttonize 100000 | |
685 "Add buttons. | |
686 Valid values are nil, t, `head', `last', an integer or a predicate. | |
687 See the manual for details." | |
688 :group 'gnus-article-treat | |
689 :type gnus-article-treat-custom) | |
690 (put 'gnus-treat-buttonize 'highlight t) | |
691 | |
692 (defcustom gnus-treat-buttonize-head 'head | |
693 "Add buttons to the head. | |
694 Valid values are nil, t, `head', `last', an integer or a predicate. | |
695 See the manual for details." | |
696 :group 'gnus-article-treat | |
697 :type gnus-article-treat-head-custom) | |
698 (put 'gnus-treat-buttonize-head 'highlight t) | |
699 | |
700 (defcustom gnus-treat-emphasize 50000 | |
701 "Emphasize text. | |
702 Valid values are nil, t, `head', `last', an integer or a predicate. | |
703 See the manual for details." | |
704 :group 'gnus-article-treat | |
705 :type gnus-article-treat-custom) | |
706 (put 'gnus-treat-emphasize 'highlight t) | |
707 | |
708 (defcustom gnus-treat-strip-cr nil | |
709 "Remove carriage returns. | |
710 Valid values are nil, t, `head', `last', an integer or a predicate. | |
711 See the manual for details." | |
712 :group 'gnus-article-treat | |
713 :type gnus-article-treat-custom) | |
714 | |
715 (defcustom gnus-treat-hide-headers 'head | |
716 "Hide headers. | |
717 Valid values are nil, t, `head', `last', an integer or a predicate. | |
718 See the manual for details." | |
719 :group 'gnus-article-treat | |
720 :type gnus-article-treat-head-custom) | |
721 | |
722 (defcustom gnus-treat-hide-boring-headers nil | |
723 "Hide boring headers. | |
724 Valid values are nil, t, `head', `last', an integer or a predicate. | |
725 See the manual for details." | |
726 :group 'gnus-article-treat | |
727 :type gnus-article-treat-head-custom) | |
728 | |
729 (defcustom gnus-treat-hide-signature nil | |
730 "Hide the signature. | |
731 Valid values are nil, t, `head', `last', an integer or a predicate. | |
732 See the manual for details." | |
733 :group 'gnus-article-treat | |
734 :type gnus-article-treat-custom) | |
735 | |
736 (defcustom gnus-treat-fill-article nil | |
737 "Fill the article. | |
738 Valid values are nil, t, `head', `last', an integer or a predicate. | |
739 See the manual for details." | |
740 :group 'gnus-article-treat | |
741 :type gnus-article-treat-custom) | |
742 | |
743 (defcustom gnus-treat-hide-citation nil | |
744 "Hide cited text. | |
745 Valid values are nil, t, `head', `last', an integer or a predicate. | |
746 See the manual for details." | |
747 :group 'gnus-article-treat | |
748 :type gnus-article-treat-custom) | |
749 | |
750 (defcustom gnus-treat-strip-list-identifiers 'head | |
751 "Strip list identifiers from `gnus-list-identifiers`. | |
752 Valid values are nil, t, `head', `last', an integer or a predicate. | |
753 See the manual for details." | |
754 :group 'gnus-article-treat | |
755 :type gnus-article-treat-custom) | |
756 | |
757 (defcustom gnus-treat-strip-pgp t | |
758 "Strip PGP signatures. | |
759 Valid values are nil, t, `head', `last', an integer or a predicate. | |
760 See the manual for details." | |
761 :group 'gnus-article-treat | |
762 :type gnus-article-treat-custom) | |
763 | |
764 (defcustom gnus-treat-strip-pem nil | |
765 "Strip PEM signatures. | |
766 Valid values are nil, t, `head', `last', an integer or a predicate. | |
767 See the manual for details." | |
768 :group 'gnus-article-treat | |
769 :type gnus-article-treat-custom) | |
770 | |
771 (defcustom gnus-treat-strip-banner t | |
772 "Strip banners from articles. | |
773 The banner to be stripped is specified in the `banner' group parameter. | |
774 Valid values are nil, t, `head', `last', an integer or a predicate. | |
775 See the manual for details." | |
776 :group 'gnus-article-treat | |
777 :type gnus-article-treat-custom) | |
778 | |
779 (defcustom gnus-treat-highlight-headers 'head | |
780 "Highlight the headers. | |
781 Valid values are nil, t, `head', `last', an integer or a predicate. | |
782 See the manual for details." | |
783 :group 'gnus-article-treat | |
784 :type gnus-article-treat-head-custom) | |
785 (put 'gnus-treat-highlight-headers 'highlight t) | |
786 | |
787 (defcustom gnus-treat-highlight-citation t | |
788 "Highlight cited text. | |
789 Valid values are nil, t, `head', `last', an integer or a predicate. | |
790 See the manual for details." | |
791 :group 'gnus-article-treat | |
792 :type gnus-article-treat-custom) | |
793 (put 'gnus-treat-highlight-citation 'highlight t) | |
794 | |
795 (defcustom gnus-treat-date-ut nil | |
796 "Display the Date in UT (GMT). | |
797 Valid values are nil, t, `head', `last', an integer or a predicate. | |
798 See the manual for details." | |
799 :group 'gnus-article-treat | |
800 :type gnus-article-treat-head-custom) | |
801 | |
802 (defcustom gnus-treat-date-local nil | |
803 "Display the Date in the local timezone. | |
804 Valid values are nil, t, `head', `last', an integer or a predicate. | |
805 See the manual for details." | |
806 :group 'gnus-article-treat | |
807 :type gnus-article-treat-head-custom) | |
808 | |
809 (defcustom gnus-treat-date-lapsed nil | |
810 "Display the Date header in a way that says how much time has elapsed. | |
811 Valid values are nil, t, `head', `last', an integer or a predicate. | |
812 See the manual for details." | |
813 :group 'gnus-article-treat | |
814 :type gnus-article-treat-head-custom) | |
815 | |
816 (defcustom gnus-treat-date-original nil | |
817 "Display the date in the original timezone. | |
818 Valid values are nil, t, `head', `last', an integer or a predicate. | |
819 See the manual for details." | |
820 :group 'gnus-article-treat | |
821 :type gnus-article-treat-head-custom) | |
822 | |
823 (defcustom gnus-treat-date-iso8601 nil | |
824 "Display the date in the ISO8601 format. | |
825 Valid values are nil, t, `head', `last', an integer or a predicate. | |
826 See the manual for details." | |
827 :group 'gnus-article-treat | |
828 :type gnus-article-treat-head-custom) | |
829 | |
830 (defcustom gnus-treat-date-user-defined nil | |
831 "Display the date in a user-defined format. | |
832 The format is defined by the `gnus-article-time-format' variable. | |
833 Valid values are nil, t, `head', `last', an integer or a predicate. | |
834 See the manual for details." | |
835 :group 'gnus-article-treat | |
836 :type gnus-article-treat-head-custom) | |
837 | |
838 (defcustom gnus-treat-strip-headers-in-body t | |
839 "Strip the X-No-Archive header line from the beginning of the body. | |
840 Valid values are nil, t, `head', `last', an integer or a predicate. | |
841 See the manual for details." | |
842 :group 'gnus-article-treat | |
843 :type gnus-article-treat-custom) | |
844 | |
845 (defcustom gnus-treat-strip-trailing-blank-lines nil | |
846 "Strip trailing blank lines. | |
847 Valid values are nil, t, `head', `last', an integer or a predicate. | |
848 See the manual for details." | |
849 :group 'gnus-article-treat | |
850 :type gnus-article-treat-custom) | |
851 | |
852 (defcustom gnus-treat-strip-leading-blank-lines nil | |
853 "Strip leading blank lines. | |
854 Valid values are nil, t, `head', `last', an integer or a predicate. | |
855 See the manual for details." | |
856 :group 'gnus-article-treat | |
857 :type gnus-article-treat-custom) | |
858 | |
859 (defcustom gnus-treat-strip-multiple-blank-lines nil | |
860 "Strip multiple blank lines. | |
861 Valid values are nil, t, `head', `last', an integer or a predicate. | |
862 See the manual for details." | |
863 :group 'gnus-article-treat | |
864 :type gnus-article-treat-custom) | |
865 | |
866 (defcustom gnus-treat-overstrike t | |
867 "Treat overstrike highlighting. | |
868 Valid values are nil, t, `head', `last', an integer or a predicate. | |
869 See the manual for details." | |
870 :group 'gnus-article-treat | |
871 :type gnus-article-treat-custom) | |
872 (put 'gnus-treat-overstrike 'highlight t) | |
873 | |
874 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface)) | |
875 'head nil) | |
876 "Display X-Face headers. | |
877 Valid values are nil, t, `head', `last', an integer or a predicate. | |
878 See the manual for details." | |
879 :group 'gnus-article-treat | |
880 :type gnus-article-treat-head-custom) | |
881 (put 'gnus-treat-display-xface 'highlight t) | |
882 | |
883 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs | |
884 (featurep 'xpm)) | |
885 t nil) | |
886 "Display smileys. | |
887 Valid values are nil, t, `head', `last', an integer or a predicate. | |
888 See the manual for details." | |
889 :group 'gnus-article-treat | |
890 :type gnus-article-treat-custom) | |
891 (put 'gnus-treat-display-smileys 'highlight t) | |
892 | |
893 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil) | |
894 "Display picons. | |
895 Valid values are nil, t, `head', `last', an integer or a predicate. | |
896 See the manual for details." | |
897 :group 'gnus-article-treat | |
898 :type gnus-article-treat-head-custom) | |
899 (put 'gnus-treat-display-picons 'highlight t) | |
900 | |
901 (defcustom gnus-treat-capitalize-sentences nil | |
902 "Capitalize sentence-starting words. | |
903 Valid values are nil, t, `head', `last', an integer or a predicate. | |
904 See the manual for details." | |
905 :group 'gnus-article-treat | |
906 :type gnus-article-treat-custom) | |
907 | |
908 (defcustom gnus-treat-fill-long-lines nil | |
909 "Fill long lines. | |
910 Valid values are nil, t, `head', `last', an integer or a predicate. | |
911 See the manual for details." | |
912 :group 'gnus-article-treat | |
913 :type gnus-article-treat-custom) | |
914 | |
915 (defcustom gnus-treat-play-sounds nil | |
916 "Play sounds. | |
917 Valid values are nil, t, `head', `last', an integer or a predicate. | |
918 See the manual for details." | |
919 :group 'gnus-article-treat | |
920 :type gnus-article-treat-custom) | |
921 | |
922 (defcustom gnus-treat-translate nil | |
923 "Translate articles from one language to another. | |
924 Valid values are nil, t, `head', `last', an integer or a predicate. | |
925 See the manual for details." | |
926 :group 'gnus-article-treat | |
927 :type gnus-article-treat-custom) | |
928 | |
562 ;;; Internal variables | 929 ;;; Internal variables |
563 | 930 |
931 (defvar article-goto-body-goes-to-point-min-p nil) | |
932 (defvar gnus-article-wash-types nil) | |
933 (defvar gnus-article-emphasis-alist nil) | |
934 | |
935 (defvar gnus-article-mime-handle-alist-1 nil) | |
936 (defvar gnus-treatment-function-alist | |
937 '((gnus-treat-strip-banner gnus-article-strip-banner) | |
938 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body) | |
939 (gnus-treat-highlight-signature gnus-article-highlight-signature) | |
940 (gnus-treat-buttonize gnus-article-add-buttons) | |
941 (gnus-treat-fill-article gnus-article-fill-cited-article) | |
942 (gnus-treat-fill-long-lines gnus-article-fill-long-lines) | |
943 (gnus-treat-strip-cr gnus-article-remove-cr) | |
944 (gnus-treat-emphasize gnus-article-emphasize) | |
945 (gnus-treat-display-xface gnus-article-display-x-face) | |
946 (gnus-treat-hide-headers gnus-article-maybe-hide-headers) | |
947 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers) | |
948 (gnus-treat-hide-signature gnus-article-hide-signature) | |
949 (gnus-treat-hide-citation gnus-article-hide-citation) | |
950 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers) | |
951 (gnus-treat-strip-pgp gnus-article-hide-pgp) | |
952 (gnus-treat-strip-pem gnus-article-hide-pem) | |
953 (gnus-treat-highlight-headers gnus-article-highlight-headers) | |
954 (gnus-treat-highlight-citation gnus-article-highlight-citation) | |
955 (gnus-treat-highlight-signature gnus-article-highlight-signature) | |
956 (gnus-treat-date-ut gnus-article-date-ut) | |
957 (gnus-treat-date-local gnus-article-date-local) | |
958 (gnus-treat-date-lapsed gnus-article-date-lapsed) | |
959 (gnus-treat-date-original gnus-article-date-original) | |
960 (gnus-treat-date-user-defined gnus-article-date-user) | |
961 (gnus-treat-date-iso8601 gnus-article-date-iso8601) | |
962 (gnus-treat-strip-trailing-blank-lines | |
963 gnus-article-remove-trailing-blank-lines) | |
964 (gnus-treat-strip-leading-blank-lines | |
965 gnus-article-strip-leading-blank-lines) | |
966 (gnus-treat-strip-multiple-blank-lines | |
967 gnus-article-strip-multiple-blank-lines) | |
968 (gnus-treat-overstrike gnus-article-treat-overstrike) | |
969 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head) | |
970 (gnus-treat-display-smileys gnus-smiley-display) | |
971 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences) | |
972 (gnus-treat-display-picons gnus-article-display-picons) | |
973 (gnus-treat-play-sounds gnus-earcon-display))) | |
974 | |
975 (defvar gnus-article-mime-handle-alist nil) | |
564 (defvar article-lapsed-timer nil) | 976 (defvar article-lapsed-timer nil) |
565 (defvar gnus-article-current-summary nil) | 977 (defvar gnus-article-current-summary nil) |
566 | 978 |
567 (defvar gnus-article-mode-syntax-table | 979 (defvar gnus-article-mode-syntax-table |
568 (let ((table (copy-syntax-table text-mode-syntax-table))) | 980 (let ((table (copy-syntax-table text-mode-syntax-table))) |
574 Initialized from `text-mode-syntax-table.") | 986 Initialized from `text-mode-syntax-table.") |
575 | 987 |
576 (defvar gnus-save-article-buffer nil) | 988 (defvar gnus-save-article-buffer nil) |
577 | 989 |
578 (defvar gnus-article-mode-line-format-alist | 990 (defvar gnus-article-mode-line-format-alist |
579 (nconc '((?w (gnus-article-wash-status) ?s)) | 991 (nconc '((?w (gnus-article-wash-status) ?s) |
992 (?m (gnus-article-mime-part-status) ?s)) | |
580 gnus-summary-mode-line-format-alist)) | 993 gnus-summary-mode-line-format-alist)) |
581 | 994 |
582 (defvar gnus-number-of-articles-to-be-saved nil) | 995 (defvar gnus-number-of-articles-to-be-saved nil) |
583 | 996 |
584 (defvar gnus-inhibit-hiding nil) | 997 (defvar gnus-inhibit-hiding nil) |
588 (add-text-properties b e props) | 1001 (add-text-properties b e props) |
589 (when (memq 'intangible props) | 1002 (when (memq 'intangible props) |
590 (put-text-property | 1003 (put-text-property |
591 (max (1- b) (point-min)) | 1004 (max (1- b) (point-min)) |
592 b 'intangible (cddr (memq 'intangible props))))) | 1005 b 'intangible (cddr (memq 'intangible props))))) |
593 | |
594 (defsubst gnus-article-unhide-text (b e) | 1006 (defsubst gnus-article-unhide-text (b e) |
595 "Remove hidden text properties from region between B and E." | 1007 "Remove hidden text properties from region between B and E." |
596 (remove-text-properties b e gnus-hidden-properties) | 1008 (remove-text-properties b e gnus-hidden-properties) |
597 (when (memq 'intangible gnus-hidden-properties) | 1009 (when (memq 'intangible gnus-hidden-properties) |
598 (put-text-property (max (1- b) (point-min)) | 1010 (put-text-property (max (1- b) (point-min)) |
599 b 'intangible nil))) | 1011 b 'intangible nil))) |
600 | 1012 |
601 (defun gnus-article-hide-text-type (b e type) | 1013 (defun gnus-article-hide-text-type (b e type) |
602 "Hide text of TYPE between B and E." | 1014 "Hide text of TYPE between B and E." |
1015 (push type gnus-article-wash-types) | |
603 (gnus-article-hide-text | 1016 (gnus-article-hide-text |
604 b e (cons 'article-type (cons type gnus-hidden-properties)))) | 1017 b e (cons 'article-type (cons type gnus-hidden-properties)))) |
605 | 1018 |
606 (defun gnus-article-unhide-text-type (b e type) | 1019 (defun gnus-article-unhide-text-type (b e type) |
607 "Unhide text of TYPE between B and E." | 1020 "Unhide text of TYPE between B and E." |
1021 (setq gnus-article-wash-types | |
1022 (delq type gnus-article-wash-types)) | |
608 (remove-text-properties | 1023 (remove-text-properties |
609 b e (cons 'article-type (cons type gnus-hidden-properties))) | 1024 b e (cons 'article-type (cons type gnus-hidden-properties))) |
610 (when (memq 'intangible gnus-hidden-properties) | 1025 (when (memq 'intangible gnus-hidden-properties) |
611 (put-text-property (max (1- b) (point-min)) | 1026 (put-text-property (max (1- b) (point-min)) |
612 b 'intangible nil))) | 1027 b 'intangible nil))) |
651 (setq list (cdr list)) | 1066 (setq list (cdr list)) |
652 (incf i)) | 1067 (incf i)) |
653 i)) | 1068 i)) |
654 | 1069 |
655 (defun article-hide-headers (&optional arg delete) | 1070 (defun article-hide-headers (&optional arg delete) |
656 "Toggle whether to hide unwanted headers and possibly sort them as well. | 1071 "Hide unwanted headers and possibly sort them as well." |
657 If given a negative prefix, always show; if given a positive prefix, | 1072 (interactive) |
658 always hide." | 1073 ;; This function might be inhibited. |
659 (interactive (gnus-article-hidden-arg)) | 1074 (unless gnus-inhibit-hiding |
660 (current-buffer) | 1075 (save-excursion |
661 (if (gnus-article-check-hidden-text 'headers arg) | 1076 (save-restriction |
662 ;; Show boring headers as well. | 1077 (let ((buffer-read-only nil) |
663 (gnus-article-show-hidden-text 'boring-headers) | 1078 (case-fold-search t) |
664 ;; This function might be inhibited. | 1079 (max (1+ (length gnus-sorted-header-list))) |
665 (unless gnus-inhibit-hiding | 1080 (ignored (when (not gnus-visible-headers) |
666 (save-excursion | 1081 (cond ((stringp gnus-ignored-headers) |
667 (save-restriction | 1082 gnus-ignored-headers) |
668 (let ((buffer-read-only nil) | 1083 ((listp gnus-ignored-headers) |
669 (case-fold-search t) | 1084 (mapconcat 'identity gnus-ignored-headers |
670 (props (nconc (list 'article-type 'headers) | 1085 "\\|"))))) |
671 gnus-hidden-properties)) | 1086 (visible |
672 (max (1+ (length gnus-sorted-header-list))) | 1087 (cond ((stringp gnus-visible-headers) |
673 (ignored (when (not gnus-visible-headers) | 1088 gnus-visible-headers) |
674 (cond ((stringp gnus-ignored-headers) | 1089 ((and gnus-visible-headers |
675 gnus-ignored-headers) | 1090 (listp gnus-visible-headers)) |
676 ((listp gnus-ignored-headers) | 1091 (mapconcat 'identity gnus-visible-headers "\\|")))) |
677 (mapconcat 'identity gnus-ignored-headers | 1092 (inhibit-point-motion-hooks t) |
678 "\\|"))))) | 1093 beg) |
679 (visible | 1094 ;; First we narrow to just the headers. |
680 (cond ((stringp gnus-visible-headers) | 1095 (article-narrow-to-head) |
681 gnus-visible-headers) | 1096 ;; Hide any "From " lines at the beginning of (mail) articles. |
682 ((and gnus-visible-headers | 1097 (while (looking-at "From ") |
683 (listp gnus-visible-headers)) | 1098 (forward-line 1)) |
684 (mapconcat 'identity gnus-visible-headers "\\|")))) | 1099 (unless (bobp) |
685 (inhibit-point-motion-hooks t) | 1100 (delete-region (point-min) (point))) |
686 beg) | 1101 ;; Then treat the rest of the header lines. |
687 ;; First we narrow to just the headers. | 1102 ;; Then we use the two regular expressions |
688 (widen) | 1103 ;; `gnus-ignored-headers' and `gnus-visible-headers' to |
689 (goto-char (point-min)) | 1104 ;; select which header lines is to remain visible in the |
690 ;; Hide any "From " lines at the beginning of (mail) articles. | 1105 ;; article buffer. |
691 (while (looking-at "From ") | 1106 (while (re-search-forward "^[^ \t]*:" nil t) |
692 (forward-line 1)) | 1107 (beginning-of-line) |
693 (unless (bobp) | 1108 ;; Mark the rank of the header. |
694 (if delete | 1109 (put-text-property |
695 (delete-region (point-min) (point)) | 1110 (point) (1+ (point)) 'message-rank |
696 (gnus-article-hide-text (point-min) (point) props))) | 1111 (if (or (and visible (looking-at visible)) |
697 ;; Then treat the rest of the header lines. | 1112 (and ignored |
698 (narrow-to-region | 1113 (not (looking-at ignored)))) |
699 (point) | 1114 (gnus-article-header-rank) |
700 (if (search-forward "\n\n" nil t) ; if there's a body | 1115 (+ 2 max))) |
701 (progn (forward-line -1) (point)) | 1116 (forward-line 1)) |
702 (point-max))) | 1117 (message-sort-headers-1) |
703 ;; Then we use the two regular expressions | 1118 (when (setq beg (text-property-any |
704 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | 1119 (point-min) (point-max) 'message-rank (+ 2 max))) |
705 ;; select which header lines is to remain visible in the | 1120 ;; We delete the unwanted headers. |
706 ;; article buffer. | 1121 (push 'headers gnus-article-wash-types) |
707 (goto-char (point-min)) | 1122 (add-text-properties (point-min) (+ 5 (point-min)) |
708 (while (re-search-forward "^[^ \t]*:" nil t) | 1123 '(article-type headers dummy-invisible t)) |
709 (beginning-of-line) | 1124 (delete-region beg (point-max)))))))) |
710 ;; Mark the rank of the header. | |
711 (put-text-property | |
712 (point) (1+ (point)) 'message-rank | |
713 (if (or (and visible (looking-at visible)) | |
714 (and ignored | |
715 (not (looking-at ignored)))) | |
716 (gnus-article-header-rank) | |
717 (+ 2 max))) | |
718 (forward-line 1)) | |
719 (message-sort-headers-1) | |
720 (when (setq beg (text-property-any | |
721 (point-min) (point-max) 'message-rank (+ 2 max))) | |
722 ;; We make the unwanted headers invisible. | |
723 (if delete | |
724 (delete-region beg (point-max)) | |
725 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
726 (gnus-article-hide-text-type beg (point-max) 'headers)) | |
727 ;; Work around XEmacs lossage. | |
728 (put-text-property (point-min) beg 'invisible nil)))))))) | |
729 | 1125 |
730 (defun article-hide-boring-headers (&optional arg) | 1126 (defun article-hide-boring-headers (&optional arg) |
731 "Toggle hiding of headers that aren't very interesting. | 1127 "Toggle hiding of headers that aren't very interesting. |
732 If given a negative prefix, always show; if given a positive prefix, | 1128 If given a negative prefix, always show; if given a positive prefix, |
733 always hide." | 1129 always hide." |
738 (save-restriction | 1134 (save-restriction |
739 (let ((buffer-read-only nil) | 1135 (let ((buffer-read-only nil) |
740 (list gnus-boring-article-headers) | 1136 (list gnus-boring-article-headers) |
741 (inhibit-point-motion-hooks t) | 1137 (inhibit-point-motion-hooks t) |
742 elem) | 1138 elem) |
743 (nnheader-narrow-to-headers) | 1139 (article-narrow-to-head) |
744 (while list | 1140 (while list |
745 (setq elem (pop list)) | 1141 (setq elem (pop list)) |
746 (goto-char (point-min)) | 1142 (goto-char (point-min)) |
747 (cond | 1143 (cond |
748 ;; Hide empty headers. | 1144 ;; Hide empty headers. |
749 ((eq elem 'empty) | 1145 ((eq elem 'empty) |
750 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t) | 1146 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t) |
751 (forward-line -1) | 1147 (forward-line -1) |
752 (gnus-article-hide-text-type | 1148 (gnus-article-hide-text-type |
753 (progn (beginning-of-line) (point)) | 1149 (progn (beginning-of-line) (point)) |
754 (progn | 1150 (progn |
755 (end-of-line) | 1151 (end-of-line) |
780 (nth 1 (mail-extract-address-components reply-to))))) | 1176 (nth 1 (mail-extract-address-components reply-to))))) |
781 (gnus-article-hide-header "reply-to")))) | 1177 (gnus-article-hide-header "reply-to")))) |
782 ((eq elem 'date) | 1178 ((eq elem 'date) |
783 (let ((date (message-fetch-field "date"))) | 1179 (let ((date (message-fetch-field "date"))) |
784 (when (and date | 1180 (when (and date |
785 (< (gnus-days-between (current-time-string) date) | 1181 (< (days-between (current-time-string) date) |
786 4)) | 1182 4)) |
787 (gnus-article-hide-header "date")))) | 1183 (gnus-article-hide-header "date")))) |
788 ((eq elem 'long-to) | 1184 ((eq elem 'long-to) |
789 (let ((to (message-fetch-field "to"))) | 1185 (let ((to (message-fetch-field "to")) |
1186 (cc (message-fetch-field "cc"))) | |
790 (when (> (length to) 1024) | 1187 (when (> (length to) 1024) |
791 (gnus-article-hide-header "to")))) | 1188 (gnus-article-hide-header "to")) |
1189 (when (> (length cc) 1024) | |
1190 (gnus-article-hide-header "cc")))) | |
792 ((eq elem 'many-to) | 1191 ((eq elem 'many-to) |
793 (let ((to-count 0)) | 1192 (let ((to-count 0) |
1193 (cc-count 0)) | |
794 (goto-char (point-min)) | 1194 (goto-char (point-min)) |
795 (while (re-search-forward "^to:" nil t) | 1195 (while (re-search-forward "^to:" nil t) |
796 (setq to-count (1+ to-count))) | 1196 (setq to-count (1+ to-count))) |
797 (when (> to-count 1) | 1197 (when (> to-count 1) |
798 (while (> to-count 0) | 1198 (while (> to-count 0) |
800 (save-restriction | 1200 (save-restriction |
801 (re-search-forward "^to:" nil nil to-count) | 1201 (re-search-forward "^to:" nil nil to-count) |
802 (forward-line -1) | 1202 (forward-line -1) |
803 (narrow-to-region (point) (point-max)) | 1203 (narrow-to-region (point) (point-max)) |
804 (gnus-article-hide-header "to")) | 1204 (gnus-article-hide-header "to")) |
805 (setq to-count (1- to-count))))))))))))) | 1205 (setq to-count (1- to-count)))) |
1206 (goto-char (point-min)) | |
1207 (while (re-search-forward "^cc:" nil t) | |
1208 (setq cc-count (1+ cc-count))) | |
1209 (when (> cc-count 1) | |
1210 (while (> cc-count 0) | |
1211 (goto-char (point-min)) | |
1212 (save-restriction | |
1213 (re-search-forward "^cc:" nil nil cc-count) | |
1214 (forward-line -1) | |
1215 (narrow-to-region (point) (point-max)) | |
1216 (gnus-article-hide-header "cc")) | |
1217 (setq cc-count (1- cc-count))))))))))))) | |
806 | 1218 |
807 (defun gnus-article-hide-header (header) | 1219 (defun gnus-article-hide-header (header) |
808 (save-excursion | 1220 (save-excursion |
809 (goto-char (point-min)) | 1221 (goto-char (point-min)) |
810 (when (re-search-forward (concat "^" header ":") nil t) | 1222 (when (re-search-forward (concat "^" header ":") nil t) |
815 (if (re-search-forward "^[^ \t]" nil t) | 1227 (if (re-search-forward "^[^ \t]" nil t) |
816 (match-beginning 0) | 1228 (match-beginning 0) |
817 (point-max))) | 1229 (point-max))) |
818 'boring-headers)))) | 1230 'boring-headers)))) |
819 | 1231 |
1232 (defvar gnus-article-normalized-header-length 40 | |
1233 "Length of normalized headers.") | |
1234 | |
1235 (defun article-normalize-headers () | |
1236 "Make all header lines 40 characters long." | |
1237 (interactive) | |
1238 (let ((buffer-read-only nil) | |
1239 column) | |
1240 (save-excursion | |
1241 (save-restriction | |
1242 (article-narrow-to-head) | |
1243 (while (not (eobp)) | |
1244 (cond | |
1245 ((< (setq column (- (gnus-point-at-eol) (point))) | |
1246 gnus-article-normalized-header-length) | |
1247 (end-of-line) | |
1248 (insert (make-string | |
1249 (- gnus-article-normalized-header-length column) | |
1250 ? ))) | |
1251 ((> column gnus-article-normalized-header-length) | |
1252 (gnus-put-text-property | |
1253 (progn | |
1254 (forward-char gnus-article-normalized-header-length) | |
1255 (point)) | |
1256 (gnus-point-at-eol) | |
1257 'invisible t)) | |
1258 (t | |
1259 ;; Do nothing. | |
1260 )) | |
1261 (forward-line 1)))))) | |
1262 | |
820 (defun article-treat-dumbquotes () | 1263 (defun article-treat-dumbquotes () |
821 "Translate M******** sm*rtq**t*s into proper text." | 1264 "Translate M******** sm*rtq**t*s into proper text. |
822 (interactive) | 1265 Note that this function guesses whether a character is a sm*rtq**t* or |
823 (article-translate-characters "\221\222\223\223" "`'\"\"")) | 1266 not, so it should only be used interactively." |
1267 (interactive) | |
1268 (article-translate-strings gnus-article-dumbquotes-map)) | |
824 | 1269 |
825 (defun article-translate-characters (from to) | 1270 (defun article-translate-characters (from to) |
826 "Translate all characters in the body of the article according to FROM and TO. | 1271 "Translate all characters in the body of the article according to FROM and TO. |
827 FROM is a string of characters to translate from; to is a string of | 1272 FROM is a string of characters to translate from; to is a string of |
828 characters to translate to." | 1273 characters to translate to." |
829 (save-excursion | 1274 (save-excursion |
830 (goto-char (point-min)) | 1275 (when (article-goto-body) |
831 (when (search-forward "\n\n" nil t) | |
832 (let ((buffer-read-only nil) | 1276 (let ((buffer-read-only nil) |
833 (x (make-string 225 ?x)) | 1277 (x (make-string 225 ?x)) |
834 (i -1)) | 1278 (i -1)) |
835 (while (< (incf i) (length x)) | 1279 (while (< (incf i) (length x)) |
836 (aset x i i)) | 1280 (aset x i i)) |
838 (while (< i (length from)) | 1282 (while (< i (length from)) |
839 (aset x (aref from i) (aref to i)) | 1283 (aset x (aref from i) (aref to i)) |
840 (incf i)) | 1284 (incf i)) |
841 (translate-region (point) (point-max) x))))) | 1285 (translate-region (point) (point-max) x))))) |
842 | 1286 |
1287 (defun article-translate-strings (map) | |
1288 "Translate all string in the body of the article according to MAP. | |
1289 MAP is an alist where the elements are on the form (\"from\" \"to\")." | |
1290 (save-excursion | |
1291 (when (article-goto-body) | |
1292 (let ((buffer-read-only nil) | |
1293 elem) | |
1294 (while (setq elem (pop map)) | |
1295 (save-excursion | |
1296 (while (search-forward (car elem) nil t) | |
1297 (replace-match (cadr elem))))))))) | |
1298 | |
843 (defun article-treat-overstrike () | 1299 (defun article-treat-overstrike () |
844 "Translate overstrikes into bold text." | 1300 "Translate overstrikes into bold text." |
845 (interactive) | 1301 (interactive) |
846 (save-excursion | 1302 (save-excursion |
847 (goto-char (point-min)) | 1303 (when (article-goto-body) |
848 (when (search-forward "\n\n" nil t) | |
849 (let ((buffer-read-only nil)) | 1304 (let ((buffer-read-only nil)) |
850 (while (search-forward "\b" nil t) | 1305 (while (search-forward "\b" nil t) |
851 (let ((next (following-char)) | 1306 (let ((next (char-after)) |
852 (previous (char-after (- (point) 2)))) | 1307 (previous (char-after (- (point) 2)))) |
853 ;; We do the boldification/underlining by hiding the | 1308 ;; We do the boldification/underlining by hiding the |
854 ;; overstrikes and putting the proper text property | 1309 ;; overstrikes and putting the proper text property |
855 ;; on the letters. | 1310 ;; on the letters. |
856 (cond | 1311 (cond |
865 ((eq previous ?_) | 1320 ((eq previous ?_) |
866 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | 1321 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) |
867 (put-text-property | 1322 (put-text-property |
868 (point) (1+ (point)) 'face 'underline))))))))) | 1323 (point) (1+ (point)) 'face 'underline))))))))) |
869 | 1324 |
870 (defun article-fill () | 1325 (defun article-fill-long-lines () |
871 "Format too long lines." | 1326 "Fill lines that are wider than the window width." |
872 (interactive) | 1327 (interactive) |
873 (save-excursion | 1328 (save-excursion |
874 (let ((buffer-read-only nil)) | 1329 (let ((buffer-read-only nil) |
875 (widen) | 1330 (width (window-width (get-buffer-window (current-buffer))))) |
876 (goto-char (point-min)) | 1331 (save-restriction |
877 (search-forward "\n\n" nil t) | 1332 (article-goto-body) |
878 (end-of-line 1) | 1333 (let ((adaptive-fill-mode nil)) |
879 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | 1334 (while (not (eobp)) |
880 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | 1335 (end-of-line) |
881 (adaptive-fill-mode t)) | 1336 (when (>= (current-column) (min fill-column width)) |
882 (while (not (eobp)) | 1337 (narrow-to-region (point) (gnus-point-at-bol)) |
883 (and (>= (current-column) (min fill-column (window-width))) | 1338 (fill-paragraph nil) |
884 (/= (preceding-char) ?:) | 1339 (goto-char (point-max)) |
885 (fill-paragraph nil)) | 1340 (widen)) |
886 (end-of-line 2)))))) | 1341 (forward-line 1))))))) |
1342 | |
1343 (defun article-capitalize-sentences () | |
1344 "Capitalize the first word in each sentence." | |
1345 (interactive) | |
1346 (save-excursion | |
1347 (let ((buffer-read-only nil) | |
1348 (paragraph-start "^[\n\^L]")) | |
1349 (article-goto-body) | |
1350 (while (not (eobp)) | |
1351 (capitalize-word 1) | |
1352 (forward-sentence))))) | |
887 | 1353 |
888 (defun article-remove-cr () | 1354 (defun article-remove-cr () |
889 "Remove carriage returns from an article." | 1355 "Remove trailing CRs and then translate remaining CRs into LFs." |
890 (interactive) | 1356 (interactive) |
891 (save-excursion | 1357 (save-excursion |
892 (let ((buffer-read-only nil)) | 1358 (let ((buffer-read-only nil)) |
893 (goto-char (point-min)) | 1359 (goto-char (point-min)) |
1360 (while (re-search-forward "\r+$" nil t) | |
1361 (replace-match "" t t)) | |
1362 (goto-char (point-min)) | |
894 (while (search-forward "\r" nil t) | 1363 (while (search-forward "\r" nil t) |
895 (replace-match "" t t))))) | 1364 (replace-match "\n" t t))))) |
896 | 1365 |
897 (defun article-remove-trailing-blank-lines () | 1366 (defun article-remove-trailing-blank-lines () |
898 "Remove all trailing blank lines from the article." | 1367 "Remove all trailing blank lines from the article." |
899 (interactive) | 1368 (interactive) |
900 (save-excursion | 1369 (save-excursion |
902 (goto-char (point-max)) | 1371 (goto-char (point-max)) |
903 (delete-region | 1372 (delete-region |
904 (point) | 1373 (point) |
905 (progn | 1374 (progn |
906 (while (and (not (bobp)) | 1375 (while (and (not (bobp)) |
907 (looking-at "^[ \t]*$")) | 1376 (looking-at "^[ \t]*$") |
1377 (not (gnus-annotation-in-region-p | |
1378 (point) (gnus-point-at-eol)))) | |
908 (forward-line -1)) | 1379 (forward-line -1)) |
909 (forward-line 1) | 1380 (forward-line 1) |
910 (point)))))) | 1381 (point)))))) |
911 | 1382 |
912 (defun article-display-x-face (&optional force) | 1383 (defun article-display-x-face (&optional force) |
918 (delete-process "article-x-face")) | 1389 (delete-process "article-x-face")) |
919 (let ((inhibit-point-motion-hooks t) | 1390 (let ((inhibit-point-motion-hooks t) |
920 (case-fold-search t) | 1391 (case-fold-search t) |
921 from last) | 1392 from last) |
922 (save-restriction | 1393 (save-restriction |
923 (nnheader-narrow-to-headers) | 1394 (article-narrow-to-head) |
1395 (goto-char (point-min)) | |
924 (setq from (message-fetch-field "from")) | 1396 (setq from (message-fetch-field "from")) |
925 (goto-char (point-min)) | 1397 (goto-char (point-min)) |
926 (while (and gnus-article-x-face-command | 1398 (while (and gnus-article-x-face-command |
927 (not last) | 1399 (not last) |
928 (or force | 1400 (or force |
957 "article-x-face" nil shell-file-name shell-command-switch | 1429 "article-x-face" nil shell-file-name shell-command-switch |
958 gnus-article-x-face-command)) | 1430 gnus-article-x-face-command)) |
959 (process-send-region "article-x-face" beg end) | 1431 (process-send-region "article-x-face" beg end) |
960 (process-send-eof "article-x-face")))))))))) | 1432 (process-send-eof "article-x-face")))))))))) |
961 | 1433 |
962 (defun gnus-hack-decode-rfc1522 () | 1434 (defun article-decode-mime-words () |
963 "Emergency hack function for avoiding problems when decoding." | 1435 "Decode all MIME-encoded words in the article." |
964 (let ((buffer-read-only nil)) | 1436 (interactive) |
965 (goto-char (point-min)) | 1437 (save-excursion |
966 ;; Remove encoded TABs. | 1438 (set-buffer gnus-article-buffer) |
967 (while (search-forward "=09" nil t) | 1439 (let ((inhibit-point-motion-hooks t) |
968 (replace-match " " t t)) | 1440 buffer-read-only |
969 ;; Remove encoded newlines. | 1441 (mail-parse-charset gnus-newsgroup-charset) |
970 (goto-char (point-min)) | 1442 (mail-parse-ignored-charsets |
971 (while (search-forward "=10" nil t) | 1443 (save-excursion (set-buffer gnus-summary-buffer) |
972 (replace-match " " t t)))) | 1444 gnus-newsgroup-ignored-charsets))) |
973 | 1445 (mail-decode-encoded-word-region (point-min) (point-max))))) |
974 (defalias 'gnus-decode-rfc1522 'article-decode-rfc1522) | 1446 |
975 (defalias 'gnus-article-decode-rfc1522 'article-decode-rfc1522) | 1447 (defun article-decode-charset (&optional prompt) |
976 (defun article-decode-rfc1522 () | 1448 "Decode charset-encoded text in the article. |
977 "Hack to remove QP encoding from headers." | 1449 If PROMPT (the prefix), prompt for a coding system to use." |
978 (let ((case-fold-search t) | 1450 (interactive "P") |
979 (inhibit-point-motion-hooks t) | 1451 (let ((inhibit-point-motion-hooks t) (case-fold-search t) |
980 (buffer-read-only nil) | 1452 buffer-read-only |
981 string) | 1453 (mail-parse-charset gnus-newsgroup-charset) |
1454 (mail-parse-ignored-charsets | |
1455 (save-excursion (condition-case nil | |
1456 (set-buffer gnus-summary-buffer) | |
1457 (error)) | |
1458 gnus-newsgroup-ignored-charsets)) | |
1459 ct cte ctl charset format) | |
1460 (save-excursion | |
982 (save-restriction | 1461 (save-restriction |
983 (narrow-to-region | 1462 (article-narrow-to-head) |
984 (goto-char (point-min)) | 1463 (setq ct (message-fetch-field "Content-Type" t) |
985 (or (search-forward "\n\n" nil t) (point-max))) | 1464 cte (message-fetch-field "Content-Transfer-Encoding" t) |
986 (goto-char (point-min)) | 1465 ctl (and ct (ignore-errors |
987 (while (re-search-forward | 1466 (mail-header-parse-content-type ct))) |
988 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t) | 1467 charset (cond |
989 (setq string (match-string 1)) | 1468 (prompt |
990 (save-restriction | 1469 (mm-read-coding-system "Charset to decode: ")) |
991 (narrow-to-region (match-beginning 0) (match-end 0)) | 1470 (ctl |
992 (delete-region (point-min) (point-max)) | 1471 (mail-content-type-get ctl 'charset))) |
993 (insert string) | 1472 format (and ctl (mail-content-type-get ctl 'format))) |
994 (article-mime-decode-quoted-printable | 1473 (when cte |
995 (goto-char (point-min)) (point-max)) | 1474 (setq cte (mail-header-strip cte))) |
996 (subst-char-in-region (point-min) (point-max) ?_ ? ) | 1475 (if (and ctl (not (string-match "/" (car ctl)))) |
997 (goto-char (point-max))) | 1476 (setq ctl nil)) |
998 (goto-char (point-min)))))) | 1477 (goto-char (point-max))) |
1478 (forward-line 1) | |
1479 (save-restriction | |
1480 (narrow-to-region (point) (point-max)) | |
1481 (when (and (eq mail-parse-charset 'gnus-decoded) | |
1482 (eq (mm-body-7-or-8) '8bit)) | |
1483 ;; The text code could have been decoded. | |
1484 (setq charset mail-parse-charset)) | |
1485 (when (and (or (not ctl) | |
1486 (equal (car ctl) "text/plain")) | |
1487 (not format)) ;; article with format will decode later. | |
1488 (mm-decode-body | |
1489 charset (and cte (intern (downcase | |
1490 (gnus-strip-whitespace cte)))) | |
1491 (car ctl))))))) | |
1492 | |
1493 (defun article-decode-encoded-words () | |
1494 "Remove encoded-word encoding from headers." | |
1495 (let ((inhibit-point-motion-hooks t) | |
1496 (mail-parse-charset gnus-newsgroup-charset) | |
1497 (mail-parse-ignored-charsets | |
1498 (save-excursion (condition-case nil | |
1499 (set-buffer gnus-summary-buffer) | |
1500 (error)) | |
1501 gnus-newsgroup-ignored-charsets)) | |
1502 buffer-read-only) | |
1503 (save-restriction | |
1504 (article-narrow-to-head) | |
1505 (funcall gnus-decode-header-function (point-min) (point-max))))) | |
999 | 1506 |
1000 (defun article-de-quoted-unreadable (&optional force) | 1507 (defun article-de-quoted-unreadable (&optional force) |
1001 "Do a naive translation of a quoted-printable-encoded article. | 1508 "Translate a quoted-printable-encoded article. |
1002 This is in no way, shape or form meant as a replacement for real MIME | |
1003 processing, but is simply a stop-gap measure until MIME support is | |
1004 written. | |
1005 If FORCE, decode the article whether it is marked as quoted-printable | 1509 If FORCE, decode the article whether it is marked as quoted-printable |
1006 or not." | 1510 or not." |
1007 (interactive (list 'force)) | 1511 (interactive (list 'force)) |
1008 (save-excursion | 1512 (save-excursion |
1009 (let ((case-fold-search t) | 1513 (let ((buffer-read-only nil) |
1010 (buffer-read-only nil) | 1514 (type (gnus-fetch-field "content-transfer-encoding")) |
1011 (type (gnus-fetch-field "content-transfer-encoding"))) | 1515 (charset gnus-newsgroup-charset)) |
1012 (gnus-article-decode-rfc1522) | |
1013 (when (or force | 1516 (when (or force |
1014 (and type (string-match "quoted-printable" (downcase type)))) | 1517 (and type (string-match "quoted-printable" (downcase type)))) |
1015 (goto-char (point-min)) | 1518 (article-goto-body) |
1016 (search-forward "\n\n" nil 'move) | 1519 (quoted-printable-decode-region (point) (point-max) charset))))) |
1017 (article-mime-decode-quoted-printable (point) (point-max)))))) | 1520 |
1018 | 1521 (defun article-de-base64-unreadable (&optional force) |
1019 (defun article-mime-decode-quoted-printable-buffer () | 1522 "Translate a base64 article. |
1020 "Decode Quoted-Printable in the current buffer." | 1523 If FORCE, decode the article whether it is marked as base64 not." |
1021 (article-mime-decode-quoted-printable (point-min) (point-max))) | 1524 (interactive (list 'force)) |
1022 | 1525 (save-excursion |
1023 (defun article-mime-decode-quoted-printable (from to) | 1526 (let ((buffer-read-only nil) |
1024 "Decode Quoted-Printable in the region between FROM and TO." | 1527 (type (gnus-fetch-field "content-transfer-encoding")) |
1025 (interactive "r") | 1528 (charset gnus-newsgroup-charset)) |
1026 (goto-char from) | 1529 (when (or force |
1027 (while (search-forward "=" to t) | 1530 (and type (string-match "base64" (downcase type)))) |
1028 (cond ((eq (following-char) ?\n) | 1531 (article-goto-body) |
1029 (delete-char -1) | 1532 (save-restriction |
1030 (delete-char 1)) | 1533 (narrow-to-region (point) (point-max)) |
1031 ((looking-at "[0-9A-F][0-9A-F]") | 1534 (base64-decode-region (point-min) (point-max)) |
1032 (subst-char-in-region | 1535 (if (mm-coding-system-p charset) |
1033 (1- (point)) (point) ?= | 1536 (mm-decode-coding-region (point-min) (point-max) charset))))))) |
1034 (hexl-hex-string-to-integer | 1537 |
1035 (buffer-substring (point) (+ 2 (point))))) | 1538 (eval-when-compile |
1036 (delete-char 2)) | 1539 (require 'rfc1843)) |
1037 ((looking-at "=") | 1540 |
1038 (delete-char 1)) | 1541 (defun article-decode-HZ () |
1039 ((gnus-message 3 "Malformed MIME quoted-printable message"))))) | 1542 "Translate a HZ-encoded article." |
1040 | 1543 (interactive) |
1041 (defun article-hide-pgp (&optional arg) | 1544 (require 'rfc1843) |
1042 "Toggle hiding of any PGP headers and signatures in the current article. | 1545 (save-excursion |
1043 If given a negative prefix, always show; if given a positive prefix, | 1546 (let ((buffer-read-only nil)) |
1044 always hide." | 1547 (rfc1843-decode-region (point-min) (point-max))))) |
1045 (interactive (gnus-article-hidden-arg)) | 1548 |
1046 (unless (gnus-article-check-hidden-text 'pgp arg) | 1549 (defun article-wash-html () |
1047 (save-excursion | 1550 "Format an html article." |
1551 (interactive) | |
1552 (save-excursion | |
1553 (let ((buffer-read-only nil) | |
1554 (charset gnus-newsgroup-charset)) | |
1555 (article-goto-body) | |
1556 (save-window-excursion | |
1557 (save-restriction | |
1558 (narrow-to-region (point) (point-max)) | |
1559 (mm-setup-w3) | |
1560 (let ((w3-strict-width (window-width)) | |
1561 (url-standalone-mode t)) | |
1562 (condition-case var | |
1563 (w3-region (point-min) (point-max)) | |
1564 (error)))))))) | |
1565 | |
1566 (defun article-hide-list-identifiers () | |
1567 "Remove list identifies from the Subject header. | |
1568 The `gnus-list-identifiers' variable specifies what to do." | |
1569 (interactive) | |
1570 (save-excursion | |
1571 (save-restriction | |
1572 (let ((inhibit-point-motion-hooks t) | |
1573 buffer-read-only) | |
1574 (article-narrow-to-head) | |
1575 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers | |
1576 (mapconcat 'identity gnus-list-identifiers " *\\|")))) | |
1577 (when regexp | |
1578 (goto-char (point-min)) | |
1579 (when (re-search-forward | |
1580 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp | |
1581 " *\\)\\)+\\(Re: +\\)?\\)") | |
1582 nil t) | |
1583 (let ((s (or (match-string 3) (match-string 5)))) | |
1584 (delete-region (match-beginning 1) (match-end 1)) | |
1585 (when s | |
1586 (goto-char (match-beginning 1)) | |
1587 (insert s)))))))))) | |
1588 | |
1589 (defun article-hide-pgp () | |
1590 "Remove any PGP headers and signatures in the current article." | |
1591 (interactive) | |
1592 (save-excursion | |
1593 (save-restriction | |
1048 (let ((inhibit-point-motion-hooks t) | 1594 (let ((inhibit-point-motion-hooks t) |
1049 buffer-read-only beg end) | 1595 buffer-read-only beg end) |
1050 (widen) | 1596 (article-goto-body) |
1051 (goto-char (point-min)) | |
1052 ;; Hide the "header". | 1597 ;; Hide the "header". |
1053 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) | 1598 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) |
1054 (delete-region (1+ (match-beginning 0)) (match-end 0)) | 1599 (push 'pgp gnus-article-wash-types) |
1600 (delete-region (match-beginning 0) (match-end 0)) | |
1601 ;; Remove armor headers (rfc2440 6.2) | |
1602 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t) | |
1603 (point))) | |
1055 (setq beg (point)) | 1604 (setq beg (point)) |
1056 ;; Hide the actual signature. | 1605 ;; Hide the actual signature. |
1057 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) | 1606 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) |
1058 (setq end (1+ (match-beginning 0))) | 1607 (setq end (1+ (match-beginning 0))) |
1059 (delete-region | 1608 (delete-region |
1079 always hide." | 1628 always hide." |
1080 (interactive (gnus-article-hidden-arg)) | 1629 (interactive (gnus-article-hidden-arg)) |
1081 (unless (gnus-article-check-hidden-text 'pem arg) | 1630 (unless (gnus-article-check-hidden-text 'pem arg) |
1082 (save-excursion | 1631 (save-excursion |
1083 (let (buffer-read-only end) | 1632 (let (buffer-read-only end) |
1084 (widen) | |
1085 (goto-char (point-min)) | 1633 (goto-char (point-min)) |
1086 ;; hide the horrendously ugly "header". | 1634 ;; Hide the horrendously ugly "header". |
1087 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | 1635 (when (and (search-forward |
1088 nil | 1636 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" |
1089 t) | 1637 nil t) |
1090 (setq end (1+ (match-beginning 0))) | 1638 (setq end (1+ (match-beginning 0)))) |
1091 (gnus-article-hide-text-type | 1639 (push 'pem gnus-article-wash-types) |
1092 end | 1640 (gnus-article-hide-text-type |
1093 (if (search-forward "\n\n" nil t) | 1641 end |
1094 (match-end 0) | 1642 (if (search-forward "\n\n" nil t) |
1095 (point-max)) | 1643 (match-end 0) |
1096 'pem)) | 1644 (point-max)) |
1097 ;; hide the trailer as well | 1645 'pem) |
1098 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | 1646 ;; Hide the trailer as well |
1099 nil | 1647 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" |
1100 t) | 1648 nil t) |
1101 (gnus-article-hide-text-type | 1649 (gnus-article-hide-text-type |
1102 (match-beginning 0) (match-end 0) 'pem)))))) | 1650 (match-beginning 0) (match-end 0) 'pem))))))) |
1651 | |
1652 (defun article-strip-banner () | |
1653 "Strip the banner specified by the `banner' group parameter." | |
1654 (interactive) | |
1655 (save-excursion | |
1656 (save-restriction | |
1657 (let ((inhibit-point-motion-hooks t) | |
1658 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner)) | |
1659 (gnus-signature-limit nil) | |
1660 buffer-read-only beg end) | |
1661 (when banner | |
1662 (article-goto-body) | |
1663 (cond | |
1664 ((eq banner 'signature) | |
1665 (when (gnus-article-narrow-to-signature) | |
1666 (widen) | |
1667 (forward-line -1) | |
1668 (delete-region (point) (point-max)))) | |
1669 ((stringp banner) | |
1670 (while (re-search-forward banner nil t) | |
1671 (delete-region (match-beginning 0) (match-end 0)))))))))) | |
1672 | |
1673 (defun article-babel () | |
1674 "Translate article using an online translation service." | |
1675 (interactive) | |
1676 (require 'babel) | |
1677 (save-excursion | |
1678 (set-buffer gnus-article-buffer) | |
1679 (when (article-goto-body) | |
1680 (let* ((buffer-read-only nil) | |
1681 (start (point)) | |
1682 (end (point-max)) | |
1683 (orig (buffer-substring start end)) | |
1684 (trans (babel-as-string orig))) | |
1685 (save-restriction | |
1686 (narrow-to-region start end) | |
1687 (delete-region start end) | |
1688 (insert trans)))))) | |
1103 | 1689 |
1104 (defun article-hide-signature (&optional arg) | 1690 (defun article-hide-signature (&optional arg) |
1105 "Hide the signature in the current article. | 1691 "Hide the signature in the current article. |
1106 If given a negative prefix, always show; if given a positive prefix, | 1692 If given a negative prefix, always show; if given a positive prefix, |
1107 always hide." | 1693 always hide." |
1112 (let ((buffer-read-only nil)) | 1698 (let ((buffer-read-only nil)) |
1113 (when (gnus-article-narrow-to-signature) | 1699 (when (gnus-article-narrow-to-signature) |
1114 (gnus-article-hide-text-type | 1700 (gnus-article-hide-text-type |
1115 (point-min) (point-max) 'signature))))))) | 1701 (point-min) (point-max) 'signature))))))) |
1116 | 1702 |
1703 (defun article-strip-headers-in-body () | |
1704 "Strip offensive headers from bodies." | |
1705 (interactive) | |
1706 (save-excursion | |
1707 (article-goto-body) | |
1708 (let ((case-fold-search t)) | |
1709 (when (looking-at "x-no-archive:") | |
1710 (gnus-delete-line))))) | |
1711 | |
1117 (defun article-strip-leading-blank-lines () | 1712 (defun article-strip-leading-blank-lines () |
1118 "Remove all blank lines from the beginning of the article." | 1713 "Remove all blank lines from the beginning of the article." |
1119 (interactive) | 1714 (interactive) |
1120 (save-excursion | 1715 (save-excursion |
1121 (let ((inhibit-point-motion-hooks t) | 1716 (let ((inhibit-point-motion-hooks t) |
1122 buffer-read-only) | 1717 buffer-read-only) |
1123 (goto-char (point-min)) | 1718 (when (article-goto-body) |
1124 (when (search-forward "\n\n" nil t) | |
1125 (while (and (not (eobp)) | 1719 (while (and (not (eobp)) |
1126 (looking-at "[ \t]*$")) | 1720 (looking-at "[ \t]*$")) |
1127 (gnus-delete-line)))))) | 1721 (gnus-delete-line)))))) |
1722 | |
1723 (defun article-narrow-to-head () | |
1724 "Narrow the buffer to the head of the message. | |
1725 Point is left at the beginning of the narrowed-to region." | |
1726 (narrow-to-region | |
1727 (goto-char (point-min)) | |
1728 (if (search-forward "\n\n" nil 1) | |
1729 (1- (point)) | |
1730 (point-max))) | |
1731 (goto-char (point-min))) | |
1732 | |
1733 (defun article-goto-body () | |
1734 "Place point at the start of the body." | |
1735 (goto-char (point-min)) | |
1736 (cond | |
1737 ;; This variable is only bound when dealing with separate | |
1738 ;; MIME body parts. | |
1739 (article-goto-body-goes-to-point-min-p | |
1740 t) | |
1741 ((search-forward "\n\n" nil t) | |
1742 t) | |
1743 (t | |
1744 (goto-char (point-max)) | |
1745 nil))) | |
1128 | 1746 |
1129 (defun article-strip-multiple-blank-lines () | 1747 (defun article-strip-multiple-blank-lines () |
1130 "Replace consecutive blank lines with one empty line." | 1748 "Replace consecutive blank lines with one empty line." |
1131 (interactive) | 1749 (interactive) |
1132 (save-excursion | 1750 (save-excursion |
1133 (let ((inhibit-point-motion-hooks t) | 1751 (let ((inhibit-point-motion-hooks t) |
1134 buffer-read-only) | 1752 buffer-read-only) |
1135 ;; First make all blank lines empty. | 1753 ;; First make all blank lines empty. |
1136 (goto-char (point-min)) | 1754 (article-goto-body) |
1137 (search-forward "\n\n" nil t) | |
1138 (while (re-search-forward "^[ \t]+$" nil t) | 1755 (while (re-search-forward "^[ \t]+$" nil t) |
1139 (replace-match "" nil t)) | 1756 (unless (gnus-annotation-in-region-p |
1757 (match-beginning 0) (match-end 0)) | |
1758 (replace-match "" nil t))) | |
1140 ;; Then replace multiple empty lines with a single empty line. | 1759 ;; Then replace multiple empty lines with a single empty line. |
1141 (goto-char (point-min)) | 1760 (article-goto-body) |
1142 (search-forward "\n\n" nil t) | |
1143 (while (re-search-forward "\n\n\n+" nil t) | 1761 (while (re-search-forward "\n\n\n+" nil t) |
1144 (replace-match "\n\n" t t))))) | 1762 (unless (gnus-annotation-in-region-p |
1763 (match-beginning 0) (match-end 0)) | |
1764 (replace-match "\n\n" t t)))))) | |
1145 | 1765 |
1146 (defun article-strip-leading-space () | 1766 (defun article-strip-leading-space () |
1147 "Remove all white space from the beginning of the lines in the article." | 1767 "Remove all white space from the beginning of the lines in the article." |
1148 (interactive) | 1768 (interactive) |
1149 (save-excursion | 1769 (save-excursion |
1150 (let ((inhibit-point-motion-hooks t) | 1770 (let ((inhibit-point-motion-hooks t) |
1151 buffer-read-only) | 1771 buffer-read-only) |
1152 (goto-char (point-min)) | 1772 (article-goto-body) |
1153 (search-forward "\n\n" nil t) | |
1154 (while (re-search-forward "^[ \t]+" nil t) | 1773 (while (re-search-forward "^[ \t]+" nil t) |
1774 (replace-match "" t t))))) | |
1775 | |
1776 (defun article-strip-trailing-space () | |
1777 "Remove all white space from the end of the lines in the article." | |
1778 (interactive) | |
1779 (save-excursion | |
1780 (let ((inhibit-point-motion-hooks t) | |
1781 buffer-read-only) | |
1782 (article-goto-body) | |
1783 (while (re-search-forward "[ \t]+$" nil t) | |
1155 (replace-match "" t t))))) | 1784 (replace-match "" t t))))) |
1156 | 1785 |
1157 (defun article-strip-blank-lines () | 1786 (defun article-strip-blank-lines () |
1158 "Strip leading, trailing and multiple blank lines." | 1787 "Strip leading, trailing and multiple blank lines." |
1159 (interactive) | 1788 (interactive) |
1165 "Strip all blank lines." | 1794 "Strip all blank lines." |
1166 (interactive) | 1795 (interactive) |
1167 (save-excursion | 1796 (save-excursion |
1168 (let ((inhibit-point-motion-hooks t) | 1797 (let ((inhibit-point-motion-hooks t) |
1169 buffer-read-only) | 1798 buffer-read-only) |
1170 (goto-char (point-min)) | 1799 (article-goto-body) |
1171 (search-forward "\n\n" nil t) | |
1172 (while (re-search-forward "^[ \t]*\n" nil t) | 1800 (while (re-search-forward "^[ \t]*\n" nil t) |
1173 (replace-match "" t t))))) | 1801 (replace-match "" t t))))) |
1174 | 1802 |
1175 (defvar mime::preview/content-list) | |
1176 (defvar mime::preview-content-info/point-min) | |
1177 (defun gnus-article-narrow-to-signature () | 1803 (defun gnus-article-narrow-to-signature () |
1178 "Narrow to the signature; return t if a signature is found, else nil." | 1804 "Narrow to the signature; return t if a signature is found, else nil." |
1179 (widen) | |
1180 (let ((inhibit-point-motion-hooks t)) | 1805 (let ((inhibit-point-motion-hooks t)) |
1181 (when (and (boundp 'mime::preview/content-list) | |
1182 mime::preview/content-list) | |
1183 ;; We have a MIMEish article, so we use the MIME data to narrow. | |
1184 (let ((pcinfo (car (last mime::preview/content-list)))) | |
1185 (ignore-errors | |
1186 (narrow-to-region | |
1187 (funcall (intern "mime::preview-content-info/point-min") pcinfo) | |
1188 (point-max))))) | |
1189 | |
1190 (when (gnus-article-search-signature) | 1806 (when (gnus-article-search-signature) |
1191 (forward-line 1) | 1807 (forward-line 1) |
1192 ;; Check whether we have some limits to what we consider | 1808 ;; Check whether we have some limits to what we consider |
1193 ;; to be a signature. | 1809 ;; to be a signature. |
1194 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit | 1810 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit |
1224 seps)) | 1840 seps)) |
1225 t | 1841 t |
1226 (goto-char cur) | 1842 (goto-char cur) |
1227 nil))) | 1843 nil))) |
1228 | 1844 |
1229 (eval-and-compile | |
1230 (autoload 'w3-display "w3-parse") | |
1231 (autoload 'w3-do-setup "w3" "" t) | |
1232 (autoload 'w3-region "w3-display" "" t)) | |
1233 | |
1234 (defun gnus-article-treat-html () | |
1235 "Render HTML." | |
1236 (interactive) | |
1237 (let ((cbuf (current-buffer))) | |
1238 (set-buffer gnus-article-buffer) | |
1239 (let (buf buffer-read-only b e) | |
1240 (w3-do-setup) | |
1241 (goto-char (point-min)) | |
1242 (narrow-to-region | |
1243 (if (search-forward "\n\n" nil t) | |
1244 (setq b (point)) | |
1245 (point-max)) | |
1246 (setq e (point-max))) | |
1247 (nnheader-temp-write nil | |
1248 (insert-buffer-substring gnus-article-buffer b e) | |
1249 (require 'url) | |
1250 (save-window-excursion | |
1251 (w3-region (point-min) (point-max)) | |
1252 (setq buf (buffer-substring-no-properties (point-min) (point-max))))) | |
1253 (when buf | |
1254 (delete-region (point-min) (point-max)) | |
1255 (insert buf)) | |
1256 (widen) | |
1257 (goto-char (point-min)) | |
1258 (set-window-start (get-buffer-window (current-buffer)) (point-min)) | |
1259 (set-buffer cbuf)))) | |
1260 | |
1261 (defun gnus-article-hidden-arg () | 1845 (defun gnus-article-hidden-arg () |
1262 "Return the current prefix arg as a number, or 0 if no prefix." | 1846 "Return the current prefix arg as a number, or 0 if no prefix." |
1263 (list (if current-prefix-arg | 1847 (list (if current-prefix-arg |
1264 (prefix-numeric-value current-prefix-arg) | 1848 (prefix-numeric-value current-prefix-arg) |
1265 0))) | 1849 0))) |
1268 "Return nil if hiding is necessary. | 1852 "Return nil if hiding is necessary. |
1269 Arg can be nil or a number. Nil and positive means hide, negative | 1853 Arg can be nil or a number. Nil and positive means hide, negative |
1270 means show, 0 means toggle." | 1854 means show, 0 means toggle." |
1271 (save-excursion | 1855 (save-excursion |
1272 (save-restriction | 1856 (save-restriction |
1273 (widen) | |
1274 (let ((hide (gnus-article-hidden-text-p type))) | 1857 (let ((hide (gnus-article-hidden-text-p type))) |
1275 (cond | 1858 (cond |
1276 ((or (null arg) | 1859 ((or (null arg) |
1277 (> arg 0)) | 1860 (> arg 0)) |
1278 nil) | 1861 nil) |
1285 | 1868 |
1286 (defun gnus-article-hidden-text-p (type) | 1869 (defun gnus-article-hidden-text-p (type) |
1287 "Say whether the current buffer contains hidden text of type TYPE." | 1870 "Say whether the current buffer contains hidden text of type TYPE." |
1288 (let ((pos (text-property-any (point-min) (point-max) 'article-type type))) | 1871 (let ((pos (text-property-any (point-min) (point-max) 'article-type type))) |
1289 (while (and pos | 1872 (while (and pos |
1290 (not (get-text-property pos 'invisible))) | 1873 (not (get-text-property pos 'invisible)) |
1874 (not (get-text-property pos 'dummy-invisible))) | |
1291 (setq pos | 1875 (setq pos |
1292 (text-property-any (1+ pos) (point-max) 'article-type type))) | 1876 (text-property-any (1+ pos) (point-max) 'article-type type))) |
1293 (if pos | 1877 (if pos |
1294 'hidden | 1878 'hidden |
1295 'shown))) | 1879 nil))) |
1296 | 1880 |
1297 (defun gnus-article-show-hidden-text (type &optional hide) | 1881 (defun gnus-article-show-hidden-text (type &optional hide) |
1298 "Show all hidden text of type TYPE. | 1882 "Show all hidden text of type TYPE. |
1299 If HIDE, hide the text instead." | 1883 If HIDE, hide the text instead." |
1300 (save-excursion | 1884 (save-excursion |
1323 "Mapping from time units to seconds.") | 1907 "Mapping from time units to seconds.") |
1324 | 1908 |
1325 (defun article-date-ut (&optional type highlight header) | 1909 (defun article-date-ut (&optional type highlight header) |
1326 "Convert DATE date to universal time in the current article. | 1910 "Convert DATE date to universal time in the current article. |
1327 If TYPE is `local', convert to local time; if it is `lapsed', output | 1911 If TYPE is `local', convert to local time; if it is `lapsed', output |
1328 how much time has lapsed since DATE." | 1912 how much time has lapsed since DATE. For `lapsed', the value of |
1913 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header | |
1914 should replace the \"Date:\" one, or should be added below it." | |
1329 (interactive (list 'ut t)) | 1915 (interactive (list 'ut t)) |
1330 (let* ((header (or header | 1916 (let* ((header (or header |
1331 (mail-header-date gnus-current-headers) | |
1332 (message-fetch-field "date") | 1917 (message-fetch-field "date") |
1333 "")) | 1918 "")) |
1919 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") | |
1920 (date-regexp | |
1921 (cond | |
1922 ((not gnus-article-date-lapsed-new-header) | |
1923 tdate-regexp) | |
1924 ((eq type 'lapsed) | |
1925 "^X-Sent:[ \t]") | |
1926 (t | |
1927 "^Date:[ \t]"))) | |
1334 (date (if (vectorp header) (mail-header-date header) | 1928 (date (if (vectorp header) (mail-header-date header) |
1335 header)) | 1929 header)) |
1336 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") | |
1337 (inhibit-point-motion-hooks t) | 1930 (inhibit-point-motion-hooks t) |
1338 bface eface newline) | 1931 pos |
1339 (when (and date (not (string= date ""))) | 1932 bface eface) |
1340 (save-excursion | 1933 (save-excursion |
1341 (save-restriction | 1934 (save-restriction |
1342 (nnheader-narrow-to-headers) | 1935 (article-narrow-to-head) |
1936 (when (re-search-forward tdate-regexp nil t) | |
1937 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
1938 date (or (get-text-property (gnus-point-at-bol) | |
1939 'original-date) | |
1940 date) | |
1941 eface (get-text-property (1- (gnus-point-at-eol)) 'face)) | |
1942 (forward-line 1)) | |
1943 (when (and date (not (string= date ""))) | |
1944 (goto-char (point-min)) | |
1343 (let ((buffer-read-only nil)) | 1945 (let ((buffer-read-only nil)) |
1344 ;; Delete any old Date headers. | 1946 ;; Delete any old Date headers. |
1345 (if (re-search-forward date-regexp nil t) | 1947 (while (re-search-forward date-regexp nil t) |
1346 (progn | 1948 (if pos |
1347 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
1348 eface (get-text-property (1- (gnus-point-at-eol)) | |
1349 'face)) | |
1350 (delete-region (progn (beginning-of-line) (point)) | 1949 (delete-region (progn (beginning-of-line) (point)) |
1351 (progn (end-of-line) (point))) | 1950 (progn (forward-line 1) (point))) |
1352 (beginning-of-line)) | 1951 (delete-region (progn (beginning-of-line) (point)) |
1353 (goto-char (point-max)) | 1952 (progn (end-of-line) (point))) |
1354 (setq newline t)) | 1953 (setq pos (point)))) |
1355 (insert (article-make-date-line date type)) | 1954 (when (and (not pos) (re-search-forward tdate-regexp nil t)) |
1955 (forward-line 1)) | |
1956 (if pos (goto-char pos)) | |
1957 (insert (article-make-date-line date (or type 'ut))) | |
1958 (when (not pos) | |
1959 (insert "\n") | |
1960 (forward-line -1)) | |
1356 ;; Do highlighting. | 1961 ;; Do highlighting. |
1357 (beginning-of-line) | 1962 (beginning-of-line) |
1358 (when (looking-at "\\([^:]+\\): *\\(.*\\)$") | 1963 (when (looking-at "\\([^:]+\\): *\\(.*\\)$") |
1359 (put-text-property (match-beginning 1) (1+ (match-end 1)) | 1964 (put-text-property (match-beginning 1) (1+ (match-end 1)) |
1965 'original-date date) | |
1966 (put-text-property (match-beginning 1) (1+ (match-end 1)) | |
1360 'face bface) | 1967 'face bface) |
1361 (put-text-property (match-beginning 2) (match-end 2) | 1968 (put-text-property (match-beginning 2) (match-end 2) |
1362 'face eface)) | 1969 'face eface)))))))) |
1363 (when newline | |
1364 (end-of-line) | |
1365 (insert "\n")))))))) | |
1366 | 1970 |
1367 (defun article-make-date-line (date type) | 1971 (defun article-make-date-line (date type) |
1368 "Return a DATE line of TYPE." | 1972 "Return a DATE line of TYPE." |
1369 (cond | 1973 (let ((time (condition-case () |
1370 ;; Convert to the local timezone. We have to slap a | 1974 (date-to-time date) |
1371 ;; `condition-case' round the calls to the timezone | 1975 (error '(0 0))))) |
1372 ;; functions since they aren't particularly resistant to | 1976 (cond |
1373 ;; buggy dates. | 1977 ;; Convert to the local timezone. We have to slap a |
1374 ((eq type 'local) | 1978 ;; `condition-case' round the calls to the timezone |
1375 (concat "Date: " (condition-case () | 1979 ;; functions since they aren't particularly resistant to |
1376 (timezone-make-date-arpa-standard date) | 1980 ;; buggy dates. |
1377 (error date)))) | 1981 ((eq type 'local) |
1378 ;; Convert to Universal Time. | 1982 (let ((tz (car (current-time-zone time)))) |
1379 ((eq type 'ut) | 1983 (format "Date: %s %s%02d%02d" (current-time-string time) |
1380 (concat "Date: " | 1984 (if (> tz 0) "+" "-") (/ (abs tz) 3600) |
1381 (condition-case () | 1985 (/ (% (abs tz) 3600) 60)))) |
1382 (timezone-make-date-arpa-standard date nil "UT") | 1986 ;; Convert to Universal Time. |
1383 (error date)))) | 1987 ((eq type 'ut) |
1384 ;; Get the original date from the article. | 1988 (concat "Date: " |
1385 ((eq type 'original) | 1989 (current-time-string |
1386 (concat "Date: " date)) | 1990 (let* ((e (parse-time-string date)) |
1387 ;; Let the user define the format. | 1991 (tm (apply 'encode-time e)) |
1388 ((eq type 'user) | 1992 (ms (car tm)) |
1389 (if (gnus-functionp gnus-article-time-format) | 1993 (ls (- (cadr tm) (car (current-time-zone time))))) |
1390 (funcall | 1994 (cond ((< ls 0) (list (1- ms) (+ ls 65536))) |
1391 gnus-article-time-format | 1995 ((> ls 65535) (list (1+ ms) (- ls 65536))) |
1392 (ignore-errors | 1996 (t (list ms ls))))) |
1393 (gnus-encode-date | 1997 " UT")) |
1394 (timezone-make-date-arpa-standard | 1998 ;; Get the original date from the article. |
1395 date nil "UT")))) | 1999 ((eq type 'original) |
1396 (concat | 2000 (concat "Date: " (if (string-match "\n+$" date) |
1397 "Date: " | 2001 (substring date 0 (match-beginning 0)) |
1398 (format-time-string gnus-article-time-format | 2002 date))) |
1399 (ignore-errors | 2003 ;; Let the user define the format. |
1400 (gnus-encode-date | 2004 ((eq type 'user) |
1401 (timezone-make-date-arpa-standard | 2005 (if (gnus-functionp gnus-article-time-format) |
1402 date nil "UT"))))))) | 2006 (funcall gnus-article-time-format time) |
1403 ;; ISO 8601. | |
1404 ((eq type 'iso8601) | |
1405 (concat | |
1406 "Date: " | |
1407 (format-time-string "%Y%M%DT%h%m%s" | |
1408 (ignore-errors | |
1409 (gnus-encode-date | |
1410 (timezone-make-date-arpa-standard | |
1411 date nil "UT")))))) | |
1412 ;; Do an X-Sent lapsed format. | |
1413 ((eq type 'lapsed) | |
1414 ;; If the date is seriously mangled, the timezone functions are | |
1415 ;; liable to bug out, so we ignore all errors. | |
1416 (let* ((now (current-time)) | |
1417 (real-time | |
1418 (ignore-errors | |
1419 (gnus-time-minus | |
1420 (gnus-encode-date | |
1421 (timezone-make-date-arpa-standard | |
1422 (current-time-string now) | |
1423 (current-time-zone now) "UT")) | |
1424 (gnus-encode-date | |
1425 (timezone-make-date-arpa-standard | |
1426 date nil "UT"))))) | |
1427 (real-sec (and real-time | |
1428 (+ (* (float (car real-time)) 65536) | |
1429 (cadr real-time)))) | |
1430 (sec (and real-time (abs real-sec))) | |
1431 num prev) | |
1432 (cond | |
1433 ((null real-time) | |
1434 "X-Sent: Unknown") | |
1435 ((zerop sec) | |
1436 "X-Sent: Now") | |
1437 (t | |
1438 (concat | 2007 (concat |
1439 "X-Sent: " | 2008 "Date: " |
1440 ;; This is a bit convoluted, but basically we go | 2009 (format-time-string gnus-article-time-format time)))) |
1441 ;; through the time units for years, weeks, etc, | 2010 ;; ISO 8601. |
1442 ;; and divide things to see whether that results | 2011 ((eq type 'iso8601) |
1443 ;; in positive answers. | 2012 (let ((tz (car (current-time-zone time)))) |
1444 (mapconcat | 2013 (concat |
1445 (lambda (unit) | 2014 "Date: " |
1446 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | 2015 (format-time-string "%Y%m%dT%H%M%S" time) |
1447 ;; The (remaining) seconds are too few to | 2016 (format "%s%02d%02d" |
1448 ;; be divided into this time unit. | 2017 (if (> tz 0) "+" "-") (/ (abs tz) 3600) |
1449 "" | 2018 (/ (% (abs tz) 3600) 60))))) |
1450 ;; It's big enough, so we output it. | 2019 ;; Do an X-Sent lapsed format. |
1451 (setq sec (- sec (* num (cdr unit)))) | 2020 ((eq type 'lapsed) |
1452 (prog1 | 2021 ;; If the date is seriously mangled, the timezone functions are |
1453 (concat (if prev ", " "") (int-to-string | 2022 ;; liable to bug out, so we ignore all errors. |
1454 (floor num)) | 2023 (let* ((now (current-time)) |
1455 " " (symbol-name (car unit)) | 2024 (real-time (subtract-time now time)) |
1456 (if (> num 1) "s" "")) | 2025 (real-sec (and real-time |
1457 (setq prev t)))) | 2026 (+ (* (float (car real-time)) 65536) |
1458 article-time-units "") | 2027 (cadr real-time)))) |
1459 ;; If dates are odd, then it might appear like the | 2028 (sec (and real-time (abs real-sec))) |
1460 ;; article was sent in the future. | 2029 num prev) |
1461 (if (> real-sec 0) | 2030 (cond |
1462 " ago" | 2031 ((null real-time) |
1463 " in the future")))))) | 2032 "X-Sent: Unknown") |
1464 (t | 2033 ((zerop sec) |
1465 (error "Unknown conversion type: %s" type)))) | 2034 "X-Sent: Now") |
2035 (t | |
2036 (concat | |
2037 "X-Sent: " | |
2038 ;; This is a bit convoluted, but basically we go | |
2039 ;; through the time units for years, weeks, etc, | |
2040 ;; and divide things to see whether that results | |
2041 ;; in positive answers. | |
2042 (mapconcat | |
2043 (lambda (unit) | |
2044 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
2045 ;; The (remaining) seconds are too few to | |
2046 ;; be divided into this time unit. | |
2047 "" | |
2048 ;; It's big enough, so we output it. | |
2049 (setq sec (- sec (* num (cdr unit)))) | |
2050 (prog1 | |
2051 (concat (if prev ", " "") (int-to-string | |
2052 (floor num)) | |
2053 " " (symbol-name (car unit)) | |
2054 (if (> num 1) "s" "")) | |
2055 (setq prev t)))) | |
2056 article-time-units "") | |
2057 ;; If dates are odd, then it might appear like the | |
2058 ;; article was sent in the future. | |
2059 (if (> real-sec 0) | |
2060 " ago" | |
2061 " in the future")))))) | |
2062 (t | |
2063 (error "Unknown conversion type: %s" type))))) | |
1466 | 2064 |
1467 (defun article-date-local (&optional highlight) | 2065 (defun article-date-local (&optional highlight) |
1468 "Convert the current article date to the local timezone." | 2066 "Convert the current article date to the local timezone." |
1469 (interactive (list t)) | 2067 (interactive (list t)) |
1470 (article-date-ut 'local highlight)) | 2068 (article-date-ut 'local highlight)) |
1484 (defun article-update-date-lapsed () | 2082 (defun article-update-date-lapsed () |
1485 "Function to be run from a timer to update the lapsed time line." | 2083 "Function to be run from a timer to update the lapsed time line." |
1486 (let (deactivate-mark) | 2084 (let (deactivate-mark) |
1487 (save-excursion | 2085 (save-excursion |
1488 (ignore-errors | 2086 (ignore-errors |
1489 (when (gnus-buffer-live-p gnus-article-buffer) | 2087 (walk-windows |
1490 (set-buffer gnus-article-buffer) | 2088 (lambda (w) |
1491 (goto-char (point-min)) | 2089 (set-buffer (window-buffer w)) |
1492 (when (re-search-forward "^X-Sent:" nil t) | 2090 (when (eq major-mode 'gnus-article-mode) |
1493 (article-date-lapsed t))))))) | 2091 (goto-char (point-min)) |
2092 (when (re-search-forward "^X-Sent:" nil t) | |
2093 (article-date-lapsed t)))) | |
2094 nil 'visible))))) | |
1494 | 2095 |
1495 (defun gnus-start-date-timer (&optional n) | 2096 (defun gnus-start-date-timer (&optional n) |
1496 "Start a timer to update the X-Sent header in the article buffers. | 2097 "Start a timer to update the X-Sent header in the article buffers. |
1497 The numerical prefix says how frequently (in seconds) the function | 2098 The numerical prefix says how frequently (in seconds) the function |
1498 is to run." | 2099 is to run." |
1531 (defun article-emphasize (&optional arg) | 2132 (defun article-emphasize (&optional arg) |
1532 "Emphasize text according to `gnus-emphasis-alist'." | 2133 "Emphasize text according to `gnus-emphasis-alist'." |
1533 (interactive (gnus-article-hidden-arg)) | 2134 (interactive (gnus-article-hidden-arg)) |
1534 (unless (gnus-article-check-hidden-text 'emphasis arg) | 2135 (unless (gnus-article-check-hidden-text 'emphasis arg) |
1535 (save-excursion | 2136 (save-excursion |
1536 (let ((alist gnus-emphasis-alist) | 2137 (let ((alist (or |
2138 (condition-case nil | |
2139 (with-current-buffer gnus-summary-buffer | |
2140 gnus-article-emphasis-alist) | |
2141 (error)) | |
2142 gnus-emphasis-alist)) | |
1537 (buffer-read-only nil) | 2143 (buffer-read-only nil) |
1538 (props (append '(article-type emphasis) | 2144 (props (append '(article-type emphasis) |
1539 gnus-hidden-properties)) | 2145 gnus-hidden-properties)) |
1540 regexp elem beg invisible visible face) | 2146 regexp elem beg invisible visible face) |
1541 (goto-char (point-min)) | 2147 (article-goto-body) |
1542 (search-forward "\n\n" nil t) | |
1543 (setq beg (point)) | 2148 (setq beg (point)) |
1544 (while (setq elem (pop alist)) | 2149 (while (setq elem (pop alist)) |
1545 (goto-char beg) | 2150 (goto-char beg) |
1546 (setq regexp (car elem) | 2151 (setq regexp (car elem) |
1547 invisible (nth 1 elem) | 2152 invisible (nth 1 elem) |
1548 visible (nth 2 elem) | 2153 visible (nth 2 elem) |
1549 face (nth 3 elem)) | 2154 face (nth 3 elem)) |
1550 (while (re-search-forward regexp nil t) | 2155 (while (re-search-forward regexp nil t) |
1551 (when (and (match-beginning visible) (match-beginning invisible)) | 2156 (when (and (match-beginning visible) (match-beginning invisible)) |
2157 (push 'emphasis gnus-article-wash-types) | |
1552 (gnus-article-hide-text | 2158 (gnus-article-hide-text |
1553 (match-beginning invisible) (match-end invisible) props) | 2159 (match-beginning invisible) (match-end invisible) props) |
1554 (gnus-article-unhide-text-type | 2160 (gnus-article-unhide-text-type |
1555 (match-beginning visible) (match-end visible) 'emphasis) | 2161 (match-beginning visible) (match-end visible) 'emphasis) |
1556 (gnus-put-text-property-excluding-newlines | 2162 (gnus-put-text-property-excluding-newlines |
1557 (match-beginning visible) (match-end visible) 'face face) | 2163 (match-beginning visible) (match-end visible) 'face face) |
1558 (goto-char (match-end invisible))))))))) | 2164 (goto-char (match-end invisible))))))))) |
2165 | |
2166 (defun gnus-article-setup-highlight-words (&optional highlight-words) | |
2167 "Setup newsgroup emphasis alist." | |
2168 (unless gnus-article-emphasis-alist | |
2169 (let ((name (and gnus-newsgroup-name | |
2170 (gnus-group-real-name gnus-newsgroup-name)))) | |
2171 (make-local-variable 'gnus-article-emphasis-alist) | |
2172 (setq gnus-article-emphasis-alist | |
2173 (nconc | |
2174 (let ((alist gnus-group-highlight-words-alist) elem highlight) | |
2175 (while (setq elem (pop alist)) | |
2176 (when (and name (string-match (car elem) name)) | |
2177 (setq alist nil | |
2178 highlight (copy-sequence (cdr elem))))) | |
2179 highlight) | |
2180 (copy-sequence highlight-words) | |
2181 (if gnus-newsgroup-name | |
2182 (copy-sequence (gnus-group-find-parameter | |
2183 gnus-newsgroup-name 'highlight-words t))) | |
2184 gnus-emphasis-alist))))) | |
1559 | 2185 |
1560 (defvar gnus-summary-article-menu) | 2186 (defvar gnus-summary-article-menu) |
1561 (defvar gnus-summary-post-menu) | 2187 (defvar gnus-summary-post-menu) |
1562 | 2188 |
1563 ;;; Saving functions. | 2189 ;;; Saving functions. |
1574 (article-hide-headers 1 t)))) | 2200 (article-hide-headers 1 t)))) |
1575 (save-window-excursion | 2201 (save-window-excursion |
1576 (if (not gnus-default-article-saver) | 2202 (if (not gnus-default-article-saver) |
1577 (error "No default saver is defined") | 2203 (error "No default saver is defined") |
1578 ;; !!! Magic! The saving functions all save | 2204 ;; !!! Magic! The saving functions all save |
1579 ;; `gnus-original-article-buffer' (or so they think), but we | 2205 ;; `gnus-save-article-buffer' (or so they think), but we |
1580 ;; bind that variable to our save-buffer. | 2206 ;; bind that variable to our save-buffer. |
1581 (set-buffer gnus-article-buffer) | 2207 (set-buffer gnus-article-buffer) |
1582 (let* ((gnus-save-article-buffer save-buffer) | 2208 (let* ((gnus-save-article-buffer save-buffer) |
1583 (filename | 2209 (filename |
1584 (cond | 2210 (cond |
1660 (car (push result file-name-history))))))) | 2286 (car (push result file-name-history))))))) |
1661 ;; Create the directory. | 2287 ;; Create the directory. |
1662 (gnus-make-directory (file-name-directory file)) | 2288 (gnus-make-directory (file-name-directory file)) |
1663 ;; If we have read a directory, we append the default file name. | 2289 ;; If we have read a directory, we append the default file name. |
1664 (when (file-directory-p file) | 2290 (when (file-directory-p file) |
1665 (setq file (concat (file-name-as-directory file) | 2291 (setq file (expand-file-name (file-name-nondirectory default-name) |
1666 (file-name-nondirectory default-name)))) | 2292 (file-name-as-directory file)))) |
1667 ;; Possibly translate some characters. | 2293 ;; Possibly translate some characters. |
1668 (nnheader-translate-file-chars file))))) | 2294 (nnheader-translate-file-chars file))))) |
1669 (gnus-make-directory (file-name-directory result)) | 2295 (gnus-make-directory (file-name-directory result)) |
1670 (set variable result))) | 2296 (set variable result))) |
1671 | 2297 |
1708 (save-excursion | 2334 (save-excursion |
1709 (save-restriction | 2335 (save-restriction |
1710 (widen) | 2336 (widen) |
1711 (if (and (file-readable-p filename) | 2337 (if (and (file-readable-p filename) |
1712 (mail-file-babyl-p filename)) | 2338 (mail-file-babyl-p filename)) |
1713 (gnus-output-to-rmail filename t) | 2339 (rmail-output-to-rmail-file filename t) |
1714 (gnus-output-to-mail filename))))) | 2340 (gnus-output-to-mail filename))))) |
1715 filename) | 2341 filename) |
1716 | 2342 |
1717 (defun gnus-summary-save-in-file (&optional filename overwrite) | 2343 (defun gnus-summary-save-in-file (&optional filename overwrite) |
1718 "Append this article to file. | 2344 "Append this article to file. |
1748 gnus-current-headers 'gnus-newsgroup-last-file)) | 2374 gnus-current-headers 'gnus-newsgroup-last-file)) |
1749 (gnus-eval-in-buffer-window gnus-save-article-buffer | 2375 (gnus-eval-in-buffer-window gnus-save-article-buffer |
1750 (save-excursion | 2376 (save-excursion |
1751 (save-restriction | 2377 (save-restriction |
1752 (widen) | 2378 (widen) |
1753 (goto-char (point-min)) | 2379 (when (article-goto-body) |
1754 (when (search-forward "\n\n" nil t) | |
1755 (narrow-to-region (point) (point-max))) | 2380 (narrow-to-region (point) (point-max))) |
1756 (gnus-output-to-file filename)))) | 2381 (gnus-output-to-file filename)))) |
1757 filename) | 2382 filename) |
1758 | 2383 |
1759 (defun gnus-summary-save-in-pipe (&optional command) | 2384 (defun gnus-summary-save-in-pipe (&optional command) |
1760 "Pipe this article to subprocess." | 2385 "Pipe this article to subprocess." |
1761 (setq command | 2386 (setq command |
1762 (cond ((eq command 'default) | 2387 (cond ((and (eq command 'default) |
2388 gnus-last-shell-command) | |
1763 gnus-last-shell-command) | 2389 gnus-last-shell-command) |
1764 (command command) | 2390 (command command) |
1765 (t (read-string | 2391 (t (read-string |
1766 (format | 2392 (format |
1767 "Shell command on %s: " | 2393 "Shell command on %s: " |
1821 (file-name-directory last-file)) | 2447 (file-name-directory last-file)) |
1822 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | 2448 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) |
1823 default | 2449 default |
1824 (or last-file default)))) | 2450 (or last-file default)))) |
1825 | 2451 |
1826 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
1827 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1828 If variable `gnus-use-long-file-name' is non-nil, it is | |
1829 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
1830 (or last-file | |
1831 (expand-file-name | |
1832 (if (gnus-use-long-file-name 'not-save) | |
1833 (gnus-capitalize-newsgroup newsgroup) | |
1834 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
1835 gnus-article-save-directory))) | |
1836 | |
1837 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | 2452 (defun gnus-plain-save-name (newsgroup headers &optional last-file) |
1838 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | 2453 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. |
1839 If variable `gnus-use-long-file-name' is non-nil, it is | 2454 If variable `gnus-use-long-file-name' is non-nil, it is |
1840 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | 2455 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." |
1841 (or last-file | 2456 (or last-file |
1842 (expand-file-name | 2457 (expand-file-name |
1843 (if (gnus-use-long-file-name 'not-save) | 2458 (if (gnus-use-long-file-name 'not-save) |
1844 newsgroup | 2459 newsgroup |
1845 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | 2460 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))) |
1846 gnus-article-save-directory))) | 2461 gnus-article-save-directory))) |
1847 | 2462 |
1848 (eval-and-compile | 2463 (eval-and-compile |
1849 (mapcar | 2464 (mapcar |
1850 (lambda (func) | 2465 (lambda (func) |
1852 (if (consp func) | 2467 (if (consp func) |
1853 (setq afunc (car func) | 2468 (setq afunc (car func) |
1854 gfunc (cdr func)) | 2469 gfunc (cdr func)) |
1855 (setq afunc func | 2470 (setq afunc func |
1856 gfunc (intern (format "gnus-%s" func)))) | 2471 gfunc (intern (format "gnus-%s" func)))) |
1857 (fset gfunc | 2472 (defalias gfunc |
1858 (if (not (fboundp afunc)) | 2473 (if (fboundp afunc) |
1859 nil | 2474 `(lambda (&optional interactive &rest args) |
1860 `(lambda (&optional interactive &rest args) | 2475 ,(documentation afunc t) |
1861 ,(documentation afunc t) | 2476 (interactive (list t)) |
1862 (interactive (list t)) | 2477 (save-excursion |
1863 (save-excursion | 2478 (set-buffer gnus-article-buffer) |
1864 (set-buffer gnus-article-buffer) | 2479 (if interactive |
1865 (if interactive | 2480 (call-interactively ',afunc) |
1866 (call-interactively ',afunc) | 2481 (apply ',afunc args)))))))) |
1867 (apply ',afunc args)))))))) | |
1868 '(article-hide-headers | 2482 '(article-hide-headers |
1869 article-hide-boring-headers | 2483 article-hide-boring-headers |
1870 article-treat-overstrike | 2484 article-treat-overstrike |
1871 (article-fill . gnus-article-word-wrap) | 2485 article-fill-long-lines |
2486 article-capitalize-sentences | |
1872 article-remove-cr | 2487 article-remove-cr |
1873 article-display-x-face | 2488 article-display-x-face |
1874 article-de-quoted-unreadable | 2489 article-de-quoted-unreadable |
1875 article-mime-decode-quoted-printable | 2490 article-de-base64-unreadable |
2491 article-decode-HZ | |
2492 article-wash-html | |
2493 article-hide-list-identifiers | |
1876 article-hide-pgp | 2494 article-hide-pgp |
2495 article-strip-banner | |
2496 article-babel | |
1877 article-hide-pem | 2497 article-hide-pem |
1878 article-hide-signature | 2498 article-hide-signature |
2499 article-strip-headers-in-body | |
1879 article-remove-trailing-blank-lines | 2500 article-remove-trailing-blank-lines |
1880 article-strip-leading-blank-lines | 2501 article-strip-leading-blank-lines |
1881 article-strip-multiple-blank-lines | 2502 article-strip-multiple-blank-lines |
1882 article-strip-leading-space | 2503 article-strip-leading-space |
2504 article-strip-trailing-space | |
1883 article-strip-blank-lines | 2505 article-strip-blank-lines |
1884 article-strip-all-blank-lines | 2506 article-strip-all-blank-lines |
1885 article-date-local | 2507 article-date-local |
1886 article-date-iso8601 | 2508 article-date-iso8601 |
1887 article-date-original | 2509 article-date-original |
1888 article-date-ut | 2510 article-date-ut |
2511 article-decode-mime-words | |
2512 article-decode-charset | |
2513 article-decode-encoded-words | |
1889 article-date-user | 2514 article-date-user |
1890 article-date-lapsed | 2515 article-date-lapsed |
1891 article-emphasize | 2516 article-emphasize |
1892 article-treat-dumbquotes | 2517 article-treat-dumbquotes |
2518 article-normalize-headers | |
1893 (article-show-all . gnus-article-show-all-headers)))) | 2519 (article-show-all . gnus-article-show-all-headers)))) |
1894 | 2520 |
1895 ;;; | 2521 ;;; |
1896 ;;; Gnus article mode | 2522 ;;; Gnus article mode |
1897 ;;; | 2523 ;;; |
1898 | 2524 |
1899 (put 'gnus-article-mode 'mode-class 'special) | 2525 (put 'gnus-article-mode 'mode-class 'special) |
1900 | 2526 |
2527 (set-keymap-parent gnus-article-mode-map widget-keymap) | |
2528 | |
1901 (gnus-define-keys gnus-article-mode-map | 2529 (gnus-define-keys gnus-article-mode-map |
1902 " " gnus-article-goto-next-page | 2530 " " gnus-article-goto-next-page |
1903 "\177" gnus-article-goto-prev-page | 2531 "\177" gnus-article-goto-prev-page |
1904 [delete] gnus-article-goto-prev-page | 2532 [delete] gnus-article-goto-prev-page |
2533 [backspace] gnus-article-goto-prev-page | |
1905 "\C-c^" gnus-article-refer-article | 2534 "\C-c^" gnus-article-refer-article |
1906 "h" gnus-article-show-summary | 2535 "h" gnus-article-show-summary |
1907 "s" gnus-article-show-summary | 2536 "s" gnus-article-show-summary |
1908 "\C-c\C-m" gnus-article-mail | 2537 "\C-c\C-m" gnus-article-mail |
1909 "?" gnus-article-describe-briefly | 2538 "?" gnus-article-describe-briefly |
1910 gnus-mouse-2 gnus-article-push-button | 2539 "e" gnus-summary-edit-article |
1911 "\r" gnus-article-press-button | |
1912 "\t" gnus-article-next-button | |
1913 "\M-\t" gnus-article-prev-button | |
1914 "e" gnus-article-edit | |
1915 "<" beginning-of-buffer | 2540 "<" beginning-of-buffer |
1916 ">" end-of-buffer | 2541 ">" end-of-buffer |
1917 "\C-c\C-i" gnus-info-find-node | 2542 "\C-c\C-i" gnus-info-find-node |
1918 "\C-c\C-b" gnus-bug | 2543 "\C-c\C-b" gnus-bug |
1919 | 2544 |
1945 ["Hide headers" gnus-article-hide-headers t] | 2570 ["Hide headers" gnus-article-hide-headers t] |
1946 ["Hide signature" gnus-article-hide-signature t] | 2571 ["Hide signature" gnus-article-hide-signature t] |
1947 ["Hide citation" gnus-article-hide-citation t] | 2572 ["Hide citation" gnus-article-hide-citation t] |
1948 ["Treat overstrike" gnus-article-treat-overstrike t] | 2573 ["Treat overstrike" gnus-article-treat-overstrike t] |
1949 ["Remove carriage return" gnus-article-remove-cr t] | 2574 ["Remove carriage return" gnus-article-remove-cr t] |
1950 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t])) | 2575 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] |
2576 ["Remove base64" gnus-article-de-base64-unreadable t] | |
2577 ["Treat html" gnus-article-wash-html t] | |
2578 ["Decode HZ" gnus-article-decode-HZ t])) | |
1951 | 2579 |
1952 ;; Note "Commands" menu is defined in gnus-sum.el for consistency | 2580 ;; Note "Commands" menu is defined in gnus-sum.el for consistency |
1953 | 2581 |
1954 (when (boundp 'gnus-summary-post-menu) | 2582 (when (boundp 'gnus-summary-post-menu) |
1955 (define-key gnus-article-mode-map [menu-bar post] | 2583 (define-key gnus-article-mode-map [menu-bar post] |
1977 (gnus-article-make-menu-bar)) | 2605 (gnus-article-make-menu-bar)) |
1978 (gnus-simplify-mode-line) | 2606 (gnus-simplify-mode-line) |
1979 (setq mode-name "Article") | 2607 (setq mode-name "Article") |
1980 (setq major-mode 'gnus-article-mode) | 2608 (setq major-mode 'gnus-article-mode) |
1981 (make-local-variable 'minor-mode-alist) | 2609 (make-local-variable 'minor-mode-alist) |
1982 (unless (assq 'gnus-show-mime minor-mode-alist) | |
1983 (push (list 'gnus-show-mime " MIME") minor-mode-alist)) | |
1984 (use-local-map gnus-article-mode-map) | 2610 (use-local-map gnus-article-mode-map) |
1985 (gnus-update-format-specifications nil 'article-mode) | 2611 (gnus-update-format-specifications nil 'article-mode) |
1986 (set (make-local-variable 'page-delimiter) gnus-page-delimiter) | 2612 (set (make-local-variable 'page-delimiter) gnus-page-delimiter) |
1987 (make-local-variable 'gnus-page-broken) | 2613 (make-local-variable 'gnus-page-broken) |
1988 (make-local-variable 'gnus-button-marker-list) | 2614 (make-local-variable 'gnus-button-marker-list) |
1989 (make-local-variable 'gnus-article-current-summary) | 2615 (make-local-variable 'gnus-article-current-summary) |
2616 (make-local-variable 'gnus-article-mime-handles) | |
2617 (make-local-variable 'gnus-article-decoded-p) | |
2618 (make-local-variable 'gnus-article-mime-handle-alist) | |
2619 (make-local-variable 'gnus-article-wash-types) | |
1990 (gnus-set-default-directory) | 2620 (gnus-set-default-directory) |
1991 (buffer-disable-undo (current-buffer)) | 2621 (buffer-disable-undo) |
1992 (setq buffer-read-only t) | 2622 (setq buffer-read-only t) |
1993 (set-syntax-table gnus-article-mode-syntax-table) | 2623 (set-syntax-table gnus-article-mode-syntax-table) |
2624 (mm-enable-multibyte) | |
1994 (gnus-run-hooks 'gnus-article-mode-hook)) | 2625 (gnus-run-hooks 'gnus-article-mode-hook)) |
1995 | 2626 |
1996 (defun gnus-article-setup-buffer () | 2627 (defun gnus-article-setup-buffer () |
1997 "Initialize the article buffer." | 2628 "Initialize the article buffer." |
1998 (let* ((name (if gnus-single-article-buffer "*Article*" | 2629 (let* ((name (if gnus-single-article-buffer "*Article*" |
2001 (progn (string-match "\\*Article" name) | 2632 (progn (string-match "\\*Article" name) |
2002 (concat " *Original Article" | 2633 (concat " *Original Article" |
2003 (substring name (match-end 0)))))) | 2634 (substring name (match-end 0)))))) |
2004 (setq gnus-article-buffer name) | 2635 (setq gnus-article-buffer name) |
2005 (setq gnus-original-article-buffer original) | 2636 (setq gnus-original-article-buffer original) |
2637 (setq gnus-article-mime-handle-alist nil) | |
2006 ;; This might be a variable local to the summary buffer. | 2638 ;; This might be a variable local to the summary buffer. |
2007 (unless gnus-single-article-buffer | 2639 (unless gnus-single-article-buffer |
2008 (save-excursion | 2640 (save-excursion |
2009 (set-buffer gnus-summary-buffer) | 2641 (set-buffer gnus-summary-buffer) |
2010 (setq gnus-article-buffer name) | 2642 (setq gnus-article-buffer name) |
2011 (setq gnus-original-article-buffer original) | 2643 (setq gnus-original-article-buffer original) |
2012 (gnus-set-global-variables))) | 2644 (gnus-set-global-variables))) |
2645 (gnus-article-setup-highlight-words) | |
2013 ;; Init original article buffer. | 2646 ;; Init original article buffer. |
2014 (save-excursion | 2647 (save-excursion |
2015 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) | 2648 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) |
2016 (buffer-disable-undo (current-buffer)) | 2649 (mm-enable-multibyte) |
2017 (setq major-mode 'gnus-original-article-mode) | 2650 (setq major-mode 'gnus-original-article-mode) |
2018 (make-local-variable 'gnus-original-article)) | 2651 (make-local-variable 'gnus-original-article)) |
2019 (if (get-buffer name) | 2652 (if (get-buffer name) |
2020 (save-excursion | 2653 (save-excursion |
2021 (set-buffer name) | 2654 (set-buffer name) |
2022 (buffer-disable-undo (current-buffer)) | 2655 (when gnus-article-mime-handles |
2656 (mm-destroy-parts gnus-article-mime-handles) | |
2657 (setq gnus-article-mime-handles nil)) | |
2658 ;; Set it to nil in article-buffer! | |
2659 (setq gnus-article-mime-handle-alist nil) | |
2660 (buffer-disable-undo) | |
2023 (setq buffer-read-only t) | 2661 (setq buffer-read-only t) |
2024 (unless (eq major-mode 'gnus-article-mode) | 2662 (unless (eq major-mode 'gnus-article-mode) |
2025 (gnus-article-mode)) | 2663 (gnus-article-mode)) |
2026 (current-buffer)) | 2664 (current-buffer)) |
2027 (save-excursion | 2665 (save-excursion |
2028 (set-buffer (gnus-get-buffer-create name)) | 2666 (set-buffer (gnus-get-buffer-create name)) |
2029 (gnus-article-mode) | 2667 (gnus-article-mode) |
2030 (make-local-variable 'gnus-summary-buffer) | 2668 (make-local-variable 'gnus-summary-buffer) |
2669 (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
2031 (current-buffer))))) | 2670 (current-buffer))))) |
2032 | 2671 |
2033 ;; Set article window start at LINE, where LINE is the number of lines | 2672 ;; Set article window start at LINE, where LINE is the number of lines |
2034 ;; from the head of the article. | 2673 ;; from the head of the article. |
2035 (defun gnus-article-set-window-start (&optional line) | 2674 (defun gnus-article-set-window-start (&optional line) |
2082 (progn | 2721 (progn |
2083 (gnus-summary-set-agent-mark article) | 2722 (gnus-summary-set-agent-mark article) |
2084 (message "Message marked for downloading")) | 2723 (message "Message marked for downloading")) |
2085 (gnus-summary-mark-article article gnus-canceled-mark) | 2724 (gnus-summary-mark-article article gnus-canceled-mark) |
2086 (unless (memq article gnus-newsgroup-sparse) | 2725 (unless (memq article gnus-newsgroup-sparse) |
2087 (gnus-error 1 | 2726 (gnus-error 1 "No such article (may have expired or been canceled)"))))) |
2088 "No such article (may have expired or been canceled)"))))) | |
2089 (if (or (eq result 'pseudo) | 2727 (if (or (eq result 'pseudo) |
2090 (eq result 'nneething)) | 2728 (eq result 'nneething)) |
2091 (progn | 2729 (progn |
2092 (save-excursion | 2730 (save-excursion |
2093 (set-buffer summary-buffer) | 2731 (set-buffer summary-buffer) |
2098 gnus-article-current nil) | 2736 gnus-article-current nil) |
2099 (if (eq result 'nneething) | 2737 (if (eq result 'nneething) |
2100 (gnus-configure-windows 'summary) | 2738 (gnus-configure-windows 'summary) |
2101 (gnus-configure-windows 'article)) | 2739 (gnus-configure-windows 'article)) |
2102 (gnus-set-global-variables)) | 2740 (gnus-set-global-variables)) |
2103 (gnus-set-mode-line 'article)) | 2741 (let ((gnus-article-mime-handle-alist-1 |
2742 gnus-article-mime-handle-alist)) | |
2743 (gnus-set-mode-line 'article))) | |
2104 ;; The result from the `request' was an actual article - | 2744 ;; The result from the `request' was an actual article - |
2105 ;; or at least some text that is now displayed in the | 2745 ;; or at least some text that is now displayed in the |
2106 ;; article buffer. | 2746 ;; article buffer. |
2107 (when (and (numberp article) | 2747 (when (and (numberp article) |
2108 (not (eq article gnus-current-article))) | 2748 (not (eq article gnus-current-article))) |
2129 (gnus-run-hooks 'gnus-mark-article-hook) | 2769 (gnus-run-hooks 'gnus-mark-article-hook) |
2130 (gnus-set-mode-line 'summary) | 2770 (gnus-set-mode-line 'summary) |
2131 (when (gnus-visual-p 'article-highlight 'highlight) | 2771 (when (gnus-visual-p 'article-highlight 'highlight) |
2132 (gnus-run-hooks 'gnus-visual-mark-article-hook)) | 2772 (gnus-run-hooks 'gnus-visual-mark-article-hook)) |
2133 ;; Set the global newsgroup variables here. | 2773 ;; Set the global newsgroup variables here. |
2134 ;; Suggested by Jim Sisolak | |
2135 ;; <sisolak@trans4.neep.wisc.edu>. | |
2136 (gnus-set-global-variables) | 2774 (gnus-set-global-variables) |
2137 (setq gnus-have-all-headers | 2775 (setq gnus-have-all-headers |
2138 (or all-headers gnus-show-all-headers)))) | 2776 (or all-headers gnus-show-all-headers)))) |
2139 (when (or (numberp article) | 2777 (when (or (numberp article) |
2140 (stringp article)) | 2778 (stringp article)) |
2141 ;; Hooks for getting information from the article. | 2779 (gnus-article-prepare-display) |
2142 ;; This hook must be called before being narrowed. | |
2143 (let (buffer-read-only) | |
2144 (gnus-run-hooks 'gnus-tmp-internal-hook) | |
2145 (gnus-run-hooks 'gnus-article-prepare-hook) | |
2146 ;; Decode MIME message. | |
2147 (if gnus-show-mime | |
2148 (if (or (not gnus-strict-mime) | |
2149 (gnus-fetch-field "Mime-Version")) | |
2150 (let ((coding-system-for-write 'binary) | |
2151 (coding-system-for-read 'binary)) | |
2152 (funcall gnus-show-mime-method)) | |
2153 (funcall gnus-decode-encoded-word-method)) | |
2154 (funcall gnus-show-traditional-method)) | |
2155 ;; Perform the article display hooks. | |
2156 (gnus-run-hooks 'gnus-article-display-hook)) | |
2157 ;; Do page break. | 2780 ;; Do page break. |
2158 (goto-char (point-min)) | 2781 (goto-char (point-min)) |
2159 (setq gnus-page-broken | 2782 (setq gnus-page-broken |
2160 (when gnus-break-pages | 2783 (when gnus-break-pages |
2161 (gnus-narrow-to-page) | 2784 (gnus-narrow-to-page) |
2162 t))) | 2785 t))) |
2163 (gnus-set-mode-line 'article) | 2786 (let ((gnus-article-mime-handle-alist-1 |
2787 gnus-article-mime-handle-alist)) | |
2788 (gnus-set-mode-line 'article)) | |
2789 (article-goto-body) | |
2790 (set-window-point (get-buffer-window (current-buffer)) (point)) | |
2164 (gnus-configure-windows 'article) | 2791 (gnus-configure-windows 'article) |
2165 (goto-char (point-min)) | |
2166 (search-forward "\n\n" nil t) | |
2167 (set-window-point (get-buffer-window (current-buffer)) (point)) | |
2168 t)))))) | 2792 t)))))) |
2793 | |
2794 ;;;###autoload | |
2795 (defun gnus-article-prepare-display () | |
2796 "Make the current buffer look like a nice article." | |
2797 ;; Hooks for getting information from the article. | |
2798 ;; This hook must be called before being narrowed. | |
2799 (let ((gnus-article-buffer (current-buffer)) | |
2800 buffer-read-only) | |
2801 (unless (eq major-mode 'gnus-article-mode) | |
2802 (gnus-article-mode)) | |
2803 (setq buffer-read-only nil | |
2804 gnus-article-wash-types nil) | |
2805 (gnus-run-hooks 'gnus-tmp-internal-hook) | |
2806 (when gnus-display-mime-function | |
2807 (funcall gnus-display-mime-function)) | |
2808 (gnus-run-hooks 'gnus-article-prepare-hook))) | |
2809 | |
2810 ;;; | |
2811 ;;; Gnus MIME viewing functions | |
2812 ;;; | |
2813 | |
2814 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n" | |
2815 "The following specs can be used: | |
2816 %t The MIME type | |
2817 %T MIME type, along with additional info | |
2818 %n The `name' parameter | |
2819 %d The description, if any | |
2820 %l The length of the encoded part | |
2821 %p The part identifier number | |
2822 %e Dots if the part isn't displayed") | |
2823 | |
2824 (defvar gnus-mime-button-line-format-alist | |
2825 '((?t gnus-tmp-type ?s) | |
2826 (?T gnus-tmp-type-long ?s) | |
2827 (?n gnus-tmp-name ?s) | |
2828 (?d gnus-tmp-description ?s) | |
2829 (?p gnus-tmp-id ?s) | |
2830 (?l gnus-tmp-length ?d) | |
2831 (?e gnus-tmp-dots ?s))) | |
2832 | |
2833 (defvar gnus-mime-button-commands | |
2834 '((gnus-article-press-button "\r" "Toggle Display") | |
2835 (gnus-mime-view-part "v" "View Interactively...") | |
2836 (gnus-mime-view-part-as-type "t" "View As Type...") | |
2837 (gnus-mime-save-part "o" "Save...") | |
2838 (gnus-mime-copy-part "c" "View As Text, In Other Buffer") | |
2839 (gnus-mime-inline-part "i" "View As Text, In This Buffer") | |
2840 (gnus-mime-internalize-part "E" "View Internally") | |
2841 (gnus-mime-externalize-part "e" "View Externally") | |
2842 (gnus-mime-pipe-part "|" "Pipe To Command..."))) | |
2843 | |
2844 (defun gnus-article-mime-part-status () | |
2845 (if gnus-article-mime-handle-alist-1 | |
2846 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)) | |
2847 "")) | |
2848 | |
2849 (defvar gnus-mime-button-map | |
2850 (let ((map (make-sparse-keymap))) | |
2851 (set-keymap-parent map gnus-article-mode-map) | |
2852 (define-key map gnus-mouse-2 'gnus-article-push-button) | |
2853 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu) | |
2854 (dolist (c gnus-mime-button-commands) | |
2855 (define-key map (cadr c) (car c))) | |
2856 map)) | |
2857 | |
2858 (defun gnus-mime-button-menu (event) | |
2859 "Construct a context-sensitive menu of MIME commands." | |
2860 (interactive "e") | |
2861 (save-excursion | |
2862 (let ((pos (event-start event))) | |
2863 (set-buffer (window-buffer (posn-window pos))) | |
2864 (goto-char (posn-point pos)) | |
2865 (gnus-article-check-buffer) | |
2866 (let ((response (x-popup-menu | |
2867 t `("MIME Part" | |
2868 ("" ,@(mapcar (lambda (c) | |
2869 (cons (caddr c) (car c))) | |
2870 gnus-mime-button-commands)))))) | |
2871 (if response | |
2872 (call-interactively response)))))) | |
2873 | |
2874 (defun gnus-mime-view-all-parts (&optional handles) | |
2875 "View all the MIME parts." | |
2876 (interactive) | |
2877 (save-current-buffer | |
2878 (set-buffer gnus-article-buffer) | |
2879 (let ((handles (or handles gnus-article-mime-handles)) | |
2880 (mail-parse-charset gnus-newsgroup-charset) | |
2881 (mail-parse-ignored-charsets | |
2882 (save-excursion (set-buffer gnus-summary-buffer) | |
2883 gnus-newsgroup-ignored-charsets))) | |
2884 (if (stringp (car handles)) | |
2885 (gnus-mime-view-all-parts (cdr handles)) | |
2886 (mapcar 'mm-display-part handles))))) | |
2887 | |
2888 (defun gnus-mime-save-part () | |
2889 "Save the MIME part under point." | |
2890 (interactive) | |
2891 (gnus-article-check-buffer) | |
2892 (let ((data (get-text-property (point) 'gnus-data))) | |
2893 (mm-save-part data))) | |
2894 | |
2895 (defun gnus-mime-pipe-part () | |
2896 "Pipe the MIME part under point to a process." | |
2897 (interactive) | |
2898 (gnus-article-check-buffer) | |
2899 (let ((data (get-text-property (point) 'gnus-data))) | |
2900 (mm-pipe-part data))) | |
2901 | |
2902 (defun gnus-mime-view-part () | |
2903 "Interactively choose a viewing method for the MIME part under point." | |
2904 (interactive) | |
2905 (gnus-article-check-buffer) | |
2906 (let ((data (get-text-property (point) 'gnus-data))) | |
2907 (mm-interactively-view-part data))) | |
2908 | |
2909 (defun gnus-mime-view-part-as-type-internal () | |
2910 (gnus-article-check-buffer) | |
2911 (let* ((name (mail-content-type-get | |
2912 (mm-handle-type (get-text-property (point) 'gnus-data)) | |
2913 'name)) | |
2914 (def-type (and name (mm-default-file-encoding name)))) | |
2915 (and def-type (cons def-type 0)))) | |
2916 | |
2917 (defun gnus-mime-view-part-as-type (mime-type) | |
2918 "Choose a MIME media type, and view the part as such." | |
2919 (interactive | |
2920 (list (completing-read | |
2921 "View as MIME type: " | |
2922 (mapcar #'list (mailcap-mime-types)) | |
2923 nil nil | |
2924 (gnus-mime-view-part-as-type-internal)))) | |
2925 (gnus-article-check-buffer) | |
2926 (let ((handle (get-text-property (point) 'gnus-data))) | |
2927 (gnus-mm-display-part | |
2928 (mm-make-handle (mm-handle-buffer handle) | |
2929 (cons mime-type (cdr (mm-handle-type handle))) | |
2930 (mm-handle-encoding handle) | |
2931 (mm-handle-undisplayer handle) | |
2932 (mm-handle-disposition handle) | |
2933 (mm-handle-description handle) | |
2934 (mm-handle-cache handle) | |
2935 (mm-handle-id handle))))) | |
2936 | |
2937 (defun gnus-mime-copy-part (&optional handle) | |
2938 "Put the the MIME part under point into a new buffer." | |
2939 (interactive) | |
2940 (gnus-article-check-buffer) | |
2941 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
2942 (contents (mm-get-part handle))| | |
2943 (base (file-name-nondirectory | |
2944 (or | |
2945 (mail-content-type-get (mm-handle-type handle) 'name) | |
2946 (mail-content-type-get (mm-handle-type handle) | |
2947 'filename) | |
2948 "*decoded*"))) | |
2949 (buffer (generate-new-buffer base))) | |
2950 (switch-to-buffer buffer) | |
2951 (insert contents) | |
2952 ;; We do it this way to make `normal-mode' set the appropriate mode. | |
2953 (unwind-protect | |
2954 (progn | |
2955 (setq buffer-file-name (expand-file-name base)) | |
2956 (normal-mode)) | |
2957 (setq buffer-file-name nil)) | |
2958 (goto-char (point-min)))) | |
2959 | |
2960 (defun gnus-mime-inline-part (&optional handle) | |
2961 "Insert the MIME part under point into the current buffer." | |
2962 (interactive) | |
2963 (gnus-article-check-buffer) | |
2964 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
2965 contents | |
2966 (b (point)) | |
2967 buffer-read-only) | |
2968 (if (mm-handle-undisplayer handle) | |
2969 (mm-remove-part handle) | |
2970 (setq contents (mm-get-part handle)) | |
2971 (forward-line 2) | |
2972 (mm-insert-inline handle contents) | |
2973 (goto-char b)))) | |
2974 | |
2975 (defun gnus-mime-externalize-part (&optional handle) | |
2976 "View the MIME part under point with an external viewer." | |
2977 (interactive) | |
2978 (gnus-article-check-buffer) | |
2979 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
2980 (mm-user-display-methods nil) | |
2981 (mm-inlined-types nil) | |
2982 (mail-parse-charset gnus-newsgroup-charset) | |
2983 (mail-parse-ignored-charsets | |
2984 (save-excursion (set-buffer gnus-summary-buffer) | |
2985 gnus-newsgroup-ignored-charsets))) | |
2986 (if (mm-handle-undisplayer handle) | |
2987 (mm-remove-part handle) | |
2988 (mm-display-part handle)))) | |
2989 | |
2990 (defun gnus-mime-internalize-part (&optional handle) | |
2991 "View the MIME part under point with an internal viewer. | |
2992 In no internal viewer is available, use an external viewer." | |
2993 (interactive) | |
2994 (gnus-article-check-buffer) | |
2995 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
2996 (mm-inlined-types '(".*")) | |
2997 (mm-inline-large-images t) | |
2998 (mail-parse-charset gnus-newsgroup-charset) | |
2999 (mail-parse-ignored-charsets | |
3000 (save-excursion (set-buffer gnus-summary-buffer) | |
3001 gnus-newsgroup-ignored-charsets))) | |
3002 (if (mm-handle-undisplayer handle) | |
3003 (mm-remove-part handle) | |
3004 (mm-display-part handle)))) | |
3005 | |
3006 (defun gnus-article-part-wrapper (n function) | |
3007 (save-current-buffer | |
3008 (set-buffer gnus-article-buffer) | |
3009 (when (> n (length gnus-article-mime-handle-alist)) | |
3010 (error "No such part")) | |
3011 (gnus-article-goto-part n) | |
3012 (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) | |
3013 (funcall function handle)))) | |
3014 | |
3015 (defun gnus-article-pipe-part (n) | |
3016 "Pipe MIME part N, which is the numerical prefix." | |
3017 (interactive "p") | |
3018 (gnus-article-part-wrapper n 'mm-pipe-part)) | |
3019 | |
3020 (defun gnus-article-save-part (n) | |
3021 "Save MIME part N, which is the numerical prefix." | |
3022 (interactive "p") | |
3023 (gnus-article-part-wrapper n 'mm-save-part)) | |
3024 | |
3025 (defun gnus-article-interactively-view-part (n) | |
3026 "View MIME part N interactively, which is the numerical prefix." | |
3027 (interactive "p") | |
3028 (gnus-article-part-wrapper n 'mm-interactively-view-part)) | |
3029 | |
3030 (defun gnus-article-copy-part (n) | |
3031 "Copy MIME part N, which is the numerical prefix." | |
3032 (interactive "p") | |
3033 (gnus-article-part-wrapper n 'gnus-mime-copy-part)) | |
3034 | |
3035 (defun gnus-article-externalize-part (n) | |
3036 "View MIME part N externally, which is the numerical prefix." | |
3037 (interactive "p") | |
3038 (gnus-article-part-wrapper n 'gnus-mime-externalize-part)) | |
3039 | |
3040 (defun gnus-article-inline-part (n) | |
3041 "Inline MIME part N, which is the numerical prefix." | |
3042 (interactive "p") | |
3043 (gnus-article-part-wrapper n 'gnus-mime-inline-part)) | |
3044 | |
3045 (defun gnus-article-mime-match-handle-first (condition) | |
3046 (if condition | |
3047 (let ((alist gnus-article-mime-handle-alist) ihandle n) | |
3048 (while (setq ihandle (pop alist)) | |
3049 (if (and (cond | |
3050 ((functionp condition) | |
3051 (funcall condition (cdr ihandle))) | |
3052 ((eq condition 'undisplayed) | |
3053 (not (or (mm-handle-undisplayer (cdr ihandle)) | |
3054 (equal (mm-handle-media-type (cdr ihandle)) | |
3055 "multipart/alternative")))) | |
3056 ((eq condition 'undisplayed-alternative) | |
3057 (not (mm-handle-undisplayer (cdr ihandle)))) | |
3058 (t t)) | |
3059 (gnus-article-goto-part (car ihandle)) | |
3060 (or (not n) (< (car ihandle) n))) | |
3061 (setq n (car ihandle)))) | |
3062 (or n 1)) | |
3063 1)) | |
3064 | |
3065 (defun gnus-article-view-part (&optional n) | |
3066 "View MIME part N, which is the numerical prefix." | |
3067 (interactive "P") | |
3068 (save-current-buffer | |
3069 (set-buffer gnus-article-buffer) | |
3070 (or (numberp n) (setq n (gnus-article-mime-match-handle-first | |
3071 gnus-article-mime-match-handle-function))) | |
3072 (when (> n (length gnus-article-mime-handle-alist)) | |
3073 (error "No such part")) | |
3074 (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) | |
3075 (when (gnus-article-goto-part n) | |
3076 (if (equal (car handle) "multipart/alternative") | |
3077 (gnus-article-press-button) | |
3078 (when (eq (gnus-mm-display-part handle) 'internal) | |
3079 (gnus-set-window-start))))))) | |
3080 | |
3081 (defun gnus-mm-display-part (handle) | |
3082 "Display HANDLE and fix MIME button." | |
3083 (let ((id (get-text-property (point) 'gnus-part)) | |
3084 (point (point)) | |
3085 buffer-read-only) | |
3086 (forward-line 1) | |
3087 (prog1 | |
3088 (let ((window (selected-window)) | |
3089 (mail-parse-charset gnus-newsgroup-charset) | |
3090 (mail-parse-ignored-charsets | |
3091 (save-excursion (set-buffer gnus-summary-buffer) | |
3092 gnus-newsgroup-ignored-charsets))) | |
3093 (save-excursion | |
3094 (unwind-protect | |
3095 (let ((win (get-buffer-window (current-buffer) t)) | |
3096 (beg (point))) | |
3097 (when win | |
3098 (select-window win)) | |
3099 (goto-char point) | |
3100 (forward-line) | |
3101 (if (mm-handle-displayed-p handle) | |
3102 ;; This will remove the part. | |
3103 (mm-display-part handle) | |
3104 (save-restriction | |
3105 (narrow-to-region (point) (1+ (point))) | |
3106 (mm-display-part handle) | |
3107 ;; We narrow to the part itself and | |
3108 ;; then call the treatment functions. | |
3109 (goto-char (point-min)) | |
3110 (forward-line 1) | |
3111 (narrow-to-region (point) (point-max)) | |
3112 (gnus-treat-article | |
3113 nil id | |
3114 (1- (length gnus-article-mime-handles)) | |
3115 (mm-handle-media-type handle))))) | |
3116 (select-window window)))) | |
3117 (goto-char point) | |
3118 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point))) | |
3119 (gnus-insert-mime-button | |
3120 handle id (list (mm-handle-displayed-p handle))) | |
3121 (goto-char point)))) | |
3122 | |
3123 (defun gnus-article-goto-part (n) | |
3124 "Go to MIME part N." | |
3125 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n))) | |
3126 (when point | |
3127 (goto-char point)))) | |
3128 | |
3129 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) | |
3130 (let ((gnus-tmp-name | |
3131 (or (mail-content-type-get (mm-handle-type handle) | |
3132 'name) | |
3133 (mail-content-type-get (mm-handle-disposition handle) | |
3134 'filename) | |
3135 "")) | |
3136 (gnus-tmp-type (mm-handle-media-type handle)) | |
3137 (gnus-tmp-description | |
3138 (mail-decode-encoded-word-string (or (mm-handle-description handle) | |
3139 ""))) | |
3140 (gnus-tmp-dots | |
3141 (if (if displayed (car displayed) | |
3142 (mm-handle-displayed-p handle)) | |
3143 "" "...")) | |
3144 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle) | |
3145 (buffer-size))) | |
3146 gnus-tmp-type-long b e) | |
3147 (when (string-match ".*/" gnus-tmp-name) | |
3148 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name))) | |
3149 (setq gnus-tmp-type-long (concat gnus-tmp-type | |
3150 (and (not (equal gnus-tmp-name "")) | |
3151 (concat "; " gnus-tmp-name)))) | |
3152 (or (equal gnus-tmp-description "") | |
3153 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long))) | |
3154 (unless (bolp) | |
3155 (insert "\n")) | |
3156 (setq b (point)) | |
3157 (gnus-eval-format | |
3158 gnus-mime-button-line-format gnus-mime-button-line-format-alist | |
3159 `(local-map ,gnus-mime-button-map | |
3160 keymap ,gnus-mime-button-map | |
3161 gnus-callback gnus-mm-display-part | |
3162 gnus-part ,gnus-tmp-id | |
3163 article-type annotation | |
3164 gnus-data ,handle)) | |
3165 (setq e (point)) | |
3166 (widget-convert-button | |
3167 'link b e | |
3168 :mime-handle handle | |
3169 :action 'gnus-widget-press-button | |
3170 :button-keymap gnus-mime-button-map | |
3171 :help-echo | |
3172 (lambda (widget/window &optional overlay pos) | |
3173 ;; Needed to properly clear the message due to a bug in | |
3174 ;; wid-edit (XEmacs only). | |
3175 (if (boundp 'help-echo-owns-message) | |
3176 (setq help-echo-owns-message t)) | |
3177 (format | |
3178 "%S: %s the MIME part; %S: more options" | |
3179 (aref gnus-mouse-2 0) | |
3180 ;; XEmacs will get a single widget arg; Emacs 21 will get | |
3181 ;; window, overlay, position. | |
3182 (if (mm-handle-displayed-p | |
3183 (if overlay | |
3184 (with-current-buffer (overlay-buffer overlay) | |
3185 (widget-get (widget-at (overlay-start overlay)) | |
3186 :mime-handle)) | |
3187 (widget-get widget/window :mime-handle))) | |
3188 "hide" "show") | |
3189 (aref gnus-down-mouse-3 0)))))) | |
3190 | |
3191 (defun gnus-widget-press-button (elems el) | |
3192 (goto-char (widget-get elems :from)) | |
3193 (gnus-article-press-button)) | |
3194 | |
3195 (defvar gnus-displaying-mime nil) | |
3196 | |
3197 (defun gnus-display-mime (&optional ihandles) | |
3198 "Display the MIME parts." | |
3199 (save-excursion | |
3200 (save-selected-window | |
3201 (let ((window (get-buffer-window gnus-article-buffer)) | |
3202 (point (point))) | |
3203 (when window | |
3204 (select-window window) | |
3205 ;; We have to do this since selecting the window | |
3206 ;; may change the point. So we set the window point. | |
3207 (set-window-point window point))) | |
3208 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect))) | |
3209 buffer-read-only handle name type b e display) | |
3210 (when (and (not ihandles) | |
3211 (not gnus-displaying-mime)) | |
3212 ;; Top-level call; we clean up. | |
3213 (when gnus-article-mime-handles | |
3214 (mm-destroy-parts gnus-article-mime-handles) | |
3215 (setq gnus-article-mime-handle-alist nil));; A trick. | |
3216 (setq gnus-article-mime-handles handles) | |
3217 ;; We allow users to glean info from the handles. | |
3218 (when gnus-article-mime-part-function | |
3219 (gnus-mime-part-function handles))) | |
3220 (if (and handles | |
3221 (or (not (stringp (car handles))) | |
3222 (cdr handles))) | |
3223 (progn | |
3224 (when (and (not ihandles) | |
3225 (not gnus-displaying-mime)) | |
3226 ;; Clean up for mime parts. | |
3227 (article-goto-body) | |
3228 (delete-region (point) (point-max))) | |
3229 (let ((gnus-displaying-mime t)) | |
3230 (gnus-mime-display-part handles))) | |
3231 (save-restriction | |
3232 (article-goto-body) | |
3233 (narrow-to-region (point) (point-max)) | |
3234 (gnus-treat-article nil 1 1) | |
3235 (widen))) | |
3236 (unless ihandles | |
3237 ;; Highlight the headers. | |
3238 (save-excursion | |
3239 (save-restriction | |
3240 (article-goto-body) | |
3241 (narrow-to-region (point-min) (point)) | |
3242 (gnus-treat-article 'head)))))))) | |
3243 | |
3244 (defvar gnus-mime-display-multipart-as-mixed nil) | |
3245 | |
3246 (defun gnus-mime-display-part (handle) | |
3247 (cond | |
3248 ;; Single part. | |
3249 ((not (stringp (car handle))) | |
3250 (gnus-mime-display-single handle)) | |
3251 ;; User-defined multipart | |
3252 ((cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
3253 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
3254 handle)) | |
3255 ;; multipart/alternative | |
3256 ((and (equal (car handle) "multipart/alternative") | |
3257 (not gnus-mime-display-multipart-as-mixed)) | |
3258 (let ((id (1+ (length gnus-article-mime-handle-alist)))) | |
3259 (push (cons id handle) gnus-article-mime-handle-alist) | |
3260 (gnus-mime-display-alternative (cdr handle) nil nil id))) | |
3261 ;; multipart/related | |
3262 ((and (equal (car handle) "multipart/related") | |
3263 (not gnus-mime-display-multipart-as-mixed)) | |
3264 ;;;!!!We should find the start part, but we just default | |
3265 ;;;!!!to the first part. | |
3266 (gnus-mime-display-part (cadr handle))) | |
3267 ;; Other multiparts are handled like multipart/mixed. | |
3268 (t | |
3269 (gnus-mime-display-mixed (cdr handle))))) | |
3270 | |
3271 (defun gnus-mime-part-function (handles) | |
3272 (if (stringp (car handles)) | |
3273 (mapcar 'gnus-mime-part-function (cdr handles)) | |
3274 (funcall gnus-article-mime-part-function handles))) | |
3275 | |
3276 (defun gnus-mime-display-mixed (handles) | |
3277 (mapcar 'gnus-mime-display-part handles)) | |
3278 | |
3279 (defun gnus-mime-display-single (handle) | |
3280 (let ((type (mm-handle-media-type handle)) | |
3281 (ignored gnus-ignored-mime-types) | |
3282 (not-attachment t) | |
3283 (move nil) | |
3284 display text) | |
3285 (catch 'ignored | |
3286 (progn | |
3287 (while ignored | |
3288 (when (string-match (pop ignored) type) | |
3289 (throw 'ignored nil))) | |
3290 (if (and (setq not-attachment | |
3291 (and (not (mm-inline-override-p handle)) | |
3292 (or (not (mm-handle-disposition handle)) | |
3293 (equal (car (mm-handle-disposition handle)) | |
3294 "inline") | |
3295 (mm-attachment-override-p handle)))) | |
3296 (mm-automatic-display-p handle) | |
3297 (or (mm-inlined-p handle) | |
3298 (mm-automatic-external-display-p type))) | |
3299 (setq display t) | |
3300 (when (equal (mm-handle-media-supertype handle) "text") | |
3301 (setq text t))) | |
3302 (let ((id (1+ (length gnus-article-mime-handle-alist)))) | |
3303 (push (cons id handle) gnus-article-mime-handle-alist) | |
3304 (when (or (not display) | |
3305 (not (gnus-unbuttonized-mime-type-p type))) | |
3306 ;(gnus-article-insert-newline) | |
3307 (gnus-insert-mime-button | |
3308 handle id (list (or display (and not-attachment text)))) | |
3309 (gnus-article-insert-newline) | |
3310 ;(gnus-article-insert-newline) | |
3311 (setq move t))) | |
3312 (let ((beg (point))) | |
3313 (cond | |
3314 (display | |
3315 (when move | |
3316 (forward-line -2) | |
3317 (setq beg (point))) | |
3318 (let ((mail-parse-charset gnus-newsgroup-charset) | |
3319 (mail-parse-ignored-charsets | |
3320 (save-excursion (condition-case () | |
3321 (set-buffer gnus-summary-buffer) | |
3322 (error)) | |
3323 gnus-newsgroup-ignored-charsets))) | |
3324 (mm-display-part handle t)) | |
3325 (goto-char (point-max))) | |
3326 ((and text not-attachment) | |
3327 (when move | |
3328 (forward-line -2) | |
3329 (setq beg (point))) | |
3330 (gnus-article-insert-newline) | |
3331 (mm-insert-inline handle (mm-get-part handle)) | |
3332 (goto-char (point-max)))) | |
3333 ;; Do highlighting. | |
3334 (save-excursion | |
3335 (save-restriction | |
3336 (narrow-to-region beg (point)) | |
3337 (gnus-treat-article | |
3338 nil (length gnus-article-mime-handle-alist) | |
3339 (1- (length gnus-article-mime-handles)) | |
3340 (mm-handle-media-type handle))))))))) | |
3341 | |
3342 (defun gnus-unbuttonized-mime-type-p (type) | |
3343 "Say whether TYPE is to be unbuttonized." | |
3344 (unless gnus-inhibit-mime-unbuttonizing | |
3345 (catch 'found | |
3346 (let ((types gnus-unbuttonized-mime-types)) | |
3347 (while types | |
3348 (when (string-match (pop types) type) | |
3349 (throw 'found t))))))) | |
3350 | |
3351 (defun gnus-article-insert-newline () | |
3352 "Insert a newline, but mark it as undeletable." | |
3353 (gnus-put-text-property | |
3354 (point) (progn (insert "\n") (point)) 'gnus-undeletable t)) | |
3355 | |
3356 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id) | |
3357 (let* ((preferred (or preferred (mm-preferred-alternative handles))) | |
3358 (ihandles handles) | |
3359 (point (point)) | |
3360 handle buffer-read-only from props begend not-pref) | |
3361 (save-window-excursion | |
3362 (save-restriction | |
3363 (when ibegend | |
3364 (narrow-to-region (car ibegend) | |
3365 (or (cdr ibegend) | |
3366 (progn | |
3367 (goto-char (car ibegend)) | |
3368 (forward-line 2) | |
3369 (point)))) | |
3370 (delete-region (point-min) (point-max)) | |
3371 (mm-remove-parts handles)) | |
3372 (setq begend (list (point-marker))) | |
3373 ;; Do the toggle. | |
3374 (unless (setq not-pref (cadr (member preferred ihandles))) | |
3375 (setq not-pref (car ihandles))) | |
3376 (when (or ibegend | |
3377 (not (gnus-unbuttonized-mime-type-p | |
3378 "multipart/alternative"))) | |
3379 (gnus-add-text-properties | |
3380 (setq from (point)) | |
3381 (progn | |
3382 (insert (format "%d. " id)) | |
3383 (point)) | |
3384 `(gnus-callback | |
3385 (lambda (handles) | |
3386 (unless ,(not ibegend) | |
3387 (setq gnus-article-mime-handle-alist | |
3388 ',gnus-article-mime-handle-alist)) | |
3389 (gnus-mime-display-alternative | |
3390 ',ihandles ',not-pref ',begend ,id)) | |
3391 local-map ,gnus-mime-button-map | |
3392 ,gnus-mouse-face-prop ,gnus-article-mouse-face | |
3393 face ,gnus-article-button-face | |
3394 keymap ,gnus-mime-button-map | |
3395 gnus-part ,id | |
3396 gnus-data ,handle)) | |
3397 (widget-convert-button 'link from (point) | |
3398 :action 'gnus-widget-press-button | |
3399 :button-keymap gnus-widget-button-keymap) | |
3400 ;; Do the handles | |
3401 (while (setq handle (pop handles)) | |
3402 (gnus-add-text-properties | |
3403 (setq from (point)) | |
3404 (progn | |
3405 (insert (format "(%c) %-18s" | |
3406 (if (equal handle preferred) ?* ? ) | |
3407 (mm-handle-media-type handle))) | |
3408 (point)) | |
3409 `(gnus-callback | |
3410 (lambda (handles) | |
3411 (unless ,(not ibegend) | |
3412 (setq gnus-article-mime-handle-alist | |
3413 ',gnus-article-mime-handle-alist)) | |
3414 (gnus-mime-display-alternative | |
3415 ',ihandles ',handle ',begend ,id)) | |
3416 local-map ,gnus-mime-button-map | |
3417 ,gnus-mouse-face-prop ,gnus-article-mouse-face | |
3418 face ,gnus-article-button-face | |
3419 keymap ,gnus-mime-button-map | |
3420 gnus-part ,id | |
3421 gnus-data ,handle)) | |
3422 (widget-convert-button 'link from (point) | |
3423 :action 'gnus-widget-press-button | |
3424 :button-keymap gnus-widget-button-keymap) | |
3425 (insert " ")) | |
3426 (insert "\n\n")) | |
3427 (when preferred | |
3428 (if (stringp (car preferred)) | |
3429 (gnus-display-mime preferred) | |
3430 (let ((mail-parse-charset gnus-newsgroup-charset) | |
3431 (mail-parse-ignored-charsets | |
3432 (save-excursion (set-buffer gnus-summary-buffer) | |
3433 gnus-newsgroup-ignored-charsets))) | |
3434 (mm-display-part preferred) | |
3435 ;; Do highlighting. | |
3436 (save-excursion | |
3437 (save-restriction | |
3438 (narrow-to-region (car begend) (point-max)) | |
3439 (gnus-treat-article | |
3440 nil (length gnus-article-mime-handle-alist) | |
3441 (1- (length gnus-article-mime-handles)) | |
3442 (mm-handle-media-type handle)))))) | |
3443 (goto-char (point-max)) | |
3444 (setcdr begend (point-marker))))) | |
3445 (when ibegend | |
3446 (goto-char point)))) | |
2169 | 3447 |
2170 (defun gnus-article-wash-status () | 3448 (defun gnus-article-wash-status () |
2171 "Return a string which display status of article washing." | 3449 "Return a string which display status of article washing." |
2172 (save-excursion | 3450 (save-excursion |
2173 (set-buffer gnus-article-buffer) | 3451 (set-buffer gnus-article-buffer) |
2174 (let ((cite (gnus-article-hidden-text-p 'cite)) | 3452 (let ((cite (memq 'cite gnus-article-wash-types)) |
2175 (headers (gnus-article-hidden-text-p 'headers)) | 3453 (headers (memq 'headers gnus-article-wash-types)) |
2176 (boring (gnus-article-hidden-text-p 'boring-headers)) | 3454 (boring (memq 'boring-headers gnus-article-wash-types)) |
2177 (pgp (gnus-article-hidden-text-p 'pgp)) | 3455 (pgp (memq 'pgp gnus-article-wash-types)) |
2178 (pem (gnus-article-hidden-text-p 'pem)) | 3456 (pem (memq 'pem gnus-article-wash-types)) |
2179 (signature (gnus-article-hidden-text-p 'signature)) | 3457 (signature (memq 'signature gnus-article-wash-types)) |
2180 (overstrike (gnus-article-hidden-text-p 'overstrike)) | 3458 (overstrike (memq 'overstrike gnus-article-wash-types)) |
2181 (emphasis (gnus-article-hidden-text-p 'emphasis)) | 3459 (emphasis (memq 'emphasis gnus-article-wash-types))) |
2182 (mime gnus-show-mime)) | 3460 (format "%c%c%c%c%c%c" |
2183 (format "%c%c%c%c%c%c%c" | |
2184 (if cite ?c ? ) | 3461 (if cite ?c ? ) |
2185 (if (or headers boring) ?h ? ) | 3462 (if (or headers boring) ?h ? ) |
2186 (if (or pgp pem) ?p ? ) | 3463 (if (or pgp pem) ?p ? ) |
2187 (if signature ?s ? ) | 3464 (if signature ?s ? ) |
2188 (if overstrike ?o ? ) | 3465 (if overstrike ?o ? ) |
2189 (if mime ?m ? ) | |
2190 (if emphasis ?e ? ))))) | 3466 (if emphasis ?e ? ))))) |
2191 | 3467 |
2192 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers) | 3468 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers) |
2193 | 3469 |
2194 (defun gnus-article-maybe-hide-headers () | 3470 (defun gnus-article-maybe-hide-headers () |
2195 "Hide unwanted headers if `gnus-have-all-headers' is nil. | 3471 "Hide unwanted headers if `gnus-have-all-headers' is nil. |
2196 Provided for backwards compatibility." | 3472 Provided for backwards compatibility." |
2197 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | 3473 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer)) |
2198 gnus-inhibit-hiding | 3474 (not (save-excursion (set-buffer gnus-summary-buffer) |
2199 (gnus-article-hide-headers))) | 3475 gnus-have-all-headers))) |
3476 (not gnus-inhibit-hiding)) | |
3477 (gnus-article-hide-headers))) | |
2200 | 3478 |
2201 ;;; Article savers. | 3479 ;;; Article savers. |
2202 | 3480 |
2203 (defun gnus-output-to-file (file-name) | 3481 (defun gnus-output-to-file (file-name) |
2204 "Append the current article to a file named FILE-NAME." | 3482 "Append the current article to a file named FILE-NAME." |
2205 (let ((artbuf (current-buffer))) | 3483 (let ((artbuf (current-buffer))) |
2206 (nnheader-temp-write nil | 3484 (with-temp-buffer |
2207 (insert-buffer-substring artbuf) | 3485 (insert-buffer-substring artbuf) |
2208 ;; Append newline at end of the buffer as separator, and then | 3486 ;; Append newline at end of the buffer as separator, and then |
2209 ;; save it to file. | 3487 ;; save it to file. |
2210 (goto-char (point-max)) | 3488 (goto-char (point-max)) |
2211 (insert "\n") | 3489 (insert "\n") |
2212 (append-to-file (point-min) (point-max) file-name) | 3490 (mm-append-to-file (point-min) (point-max) file-name) |
2213 t))) | 3491 t))) |
2214 | 3492 |
2215 (defun gnus-narrow-to-page (&optional arg) | 3493 (defun gnus-narrow-to-page (&optional arg) |
2216 "Narrow the article buffer to a page. | 3494 "Narrow the article buffer to a page. |
2217 If given a numerical ARG, move forward ARG pages." | 3495 If given a numerical ARG, move forward ARG pages." |
2335 (gnus-summary-position-point))) | 3613 (gnus-summary-position-point))) |
2336 | 3614 |
2337 (defun gnus-article-describe-briefly () | 3615 (defun gnus-article-describe-briefly () |
2338 "Describe article mode commands briefly." | 3616 "Describe article mode commands briefly." |
2339 (interactive) | 3617 (interactive) |
2340 (gnus-message 6 | 3618 (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"))) |
2341 (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"))) | |
2342 | 3619 |
2343 (defun gnus-article-summary-command () | 3620 (defun gnus-article-summary-command () |
2344 "Execute the last keystroke in the summary buffer." | 3621 "Execute the last keystroke in the summary buffer." |
2345 (interactive) | 3622 (interactive) |
2346 (let ((obuf (current-buffer)) | 3623 (let ((obuf (current-buffer)) |
2359 (let (func) | 3636 (let (func) |
2360 (pop-to-buffer gnus-article-current-summary 'norecord) | 3637 (pop-to-buffer gnus-article-current-summary 'norecord) |
2361 (setq func (lookup-key (current-local-map) (this-command-keys))) | 3638 (setq func (lookup-key (current-local-map) (this-command-keys))) |
2362 (call-interactively func))) | 3639 (call-interactively func))) |
2363 | 3640 |
3641 (defun gnus-article-check-buffer () | |
3642 "Beep if not in an article buffer." | |
3643 (unless (equal major-mode 'gnus-article-mode) | |
3644 (error "Command invoked outside of a Gnus article buffer"))) | |
3645 | |
2364 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) | 3646 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) |
2365 "Read a summary buffer key sequence and execute it from the article buffer." | 3647 "Read a summary buffer key sequence and execute it from the article buffer." |
2366 (interactive "P") | 3648 (interactive "P") |
3649 (gnus-article-check-buffer) | |
2367 (let ((nosaves | 3650 (let ((nosaves |
2368 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | 3651 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" |
2369 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | 3652 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" |
2370 "=" "^" "\M-^" "|")) | 3653 "=" "^" "\M-^" "|")) |
2371 (nosave-but-article | 3654 (nosave-but-article |
2377 keys new-sum-point) | 3660 keys new-sum-point) |
2378 (save-excursion | 3661 (save-excursion |
2379 (set-buffer gnus-article-current-summary) | 3662 (set-buffer gnus-article-current-summary) |
2380 (let (gnus-pick-mode) | 3663 (let (gnus-pick-mode) |
2381 (push (or key last-command-event) unread-command-events) | 3664 (push (or key last-command-event) unread-command-events) |
2382 (setq keys (read-key-sequence nil)))) | 3665 (setq keys (if gnus-xemacs |
3666 (events-to-keys (read-key-sequence nil)) | |
3667 (read-key-sequence nil))))) | |
3668 | |
2383 (message "") | 3669 (message "") |
2384 | 3670 |
2385 (if (or (member keys nosaves) | 3671 (if (or (member keys nosaves) |
2386 (member keys nosave-but-article) | 3672 (member keys nosave-but-article) |
2387 (member keys nosave-in-article)) | 3673 (member keys nosave-in-article)) |
2389 (save-window-excursion | 3675 (save-window-excursion |
2390 (pop-to-buffer gnus-article-current-summary 'norecord) | 3676 (pop-to-buffer gnus-article-current-summary 'norecord) |
2391 ;; We disable the pick minor mode commands. | 3677 ;; We disable the pick minor mode commands. |
2392 (let (gnus-pick-mode) | 3678 (let (gnus-pick-mode) |
2393 (setq func (lookup-key (current-local-map) keys)))) | 3679 (setq func (lookup-key (current-local-map) keys)))) |
2394 (if (not func) | 3680 (if (or (not func) |
3681 (numberp func)) | |
2395 (ding) | 3682 (ding) |
2396 (unless (member keys nosave-in-article) | 3683 (unless (member keys nosave-in-article) |
2397 (set-buffer gnus-article-current-summary)) | 3684 (set-buffer gnus-article-current-summary)) |
2398 (call-interactively func) | 3685 (call-interactively func) |
2399 (setq new-sum-point (point))) | 3686 (setq new-sum-point (point))) |
2419 (when (eq in-buffer (current-buffer)) | 3706 (when (eq in-buffer (current-buffer)) |
2420 (setq selected (gnus-summary-select-article)) | 3707 (setq selected (gnus-summary-select-article)) |
2421 (set-buffer obuf) | 3708 (set-buffer obuf) |
2422 (unless not-restore-window | 3709 (unless not-restore-window |
2423 (set-window-configuration owin)) | 3710 (set-window-configuration owin)) |
2424 (unless (or (not (eq selected 'old)) (member keys up-to-top)) | 3711 (when (eq selected 'old) |
3712 (article-goto-body) | |
3713 (set-window-start (get-buffer-window (current-buffer)) | |
3714 1) | |
2425 (set-window-point (get-buffer-window (current-buffer)) | 3715 (set-window-point (get-buffer-window (current-buffer)) |
2426 opoint)) | 3716 (point))) |
2427 (let ((win (get-buffer-window gnus-article-current-summary))) | 3717 (let ((win (get-buffer-window gnus-article-current-summary))) |
2428 (when win | 3718 (when win |
2429 (set-window-point win new-sum-point)))))))) | 3719 (set-window-point win new-sum-point)))))))) |
2430 | 3720 |
2431 (defun gnus-article-hide (&optional arg force) | 3721 (defun gnus-article-hide (&optional arg force) |
2433 This means that PGP stuff, signatures, cited text and (some) | 3723 This means that PGP stuff, signatures, cited text and (some) |
2434 headers will be hidden. | 3724 headers will be hidden. |
2435 If given a prefix, show the hidden text instead." | 3725 If given a prefix, show the hidden text instead." |
2436 (interactive (append (gnus-article-hidden-arg) (list 'force))) | 3726 (interactive (append (gnus-article-hidden-arg) (list 'force))) |
2437 (gnus-article-hide-headers arg) | 3727 (gnus-article-hide-headers arg) |
3728 (gnus-article-hide-list-identifiers arg) | |
2438 (gnus-article-hide-pgp arg) | 3729 (gnus-article-hide-pgp arg) |
2439 (gnus-article-hide-citation-maybe arg force) | 3730 (gnus-article-hide-citation-maybe arg force) |
2440 (gnus-article-hide-signature arg)) | 3731 (gnus-article-hide-signature arg)) |
2441 | 3732 |
2442 (defun gnus-article-maybe-highlight () | 3733 (defun gnus-article-maybe-highlight () |
2465 ;; copy it from the server buffer into the article buffer. | 3756 ;; copy it from the server buffer into the article buffer. |
2466 | 3757 |
2467 ;; We only request an article by message-id when we do not have the | 3758 ;; We only request an article by message-id when we do not have the |
2468 ;; headers for it, so we'll have to get those. | 3759 ;; headers for it, so we'll have to get those. |
2469 (when (stringp article) | 3760 (when (stringp article) |
2470 (let ((gnus-override-method gnus-refer-article-method)) | 3761 (gnus-read-header article)) |
2471 (gnus-read-header article))) | |
2472 | 3762 |
2473 ;; If the article number is negative, that means that this article | 3763 ;; If the article number is negative, that means that this article |
2474 ;; doesn't belong in this newsgroup (possibly), so we find its | 3764 ;; doesn't belong in this newsgroup (possibly), so we find its |
2475 ;; message-id and request it by id instead of number. | 3765 ;; message-id and request it by id instead of number. |
2476 (when (and (numberp article) | 3766 (when (and (numberp article) |
2484 (cond | 3774 (cond |
2485 ((memq article gnus-newsgroup-sparse) | 3775 ((memq article gnus-newsgroup-sparse) |
2486 ;; This is a sparse gap article. | 3776 ;; This is a sparse gap article. |
2487 (setq do-update-line article) | 3777 (setq do-update-line article) |
2488 (setq article (mail-header-id header)) | 3778 (setq article (mail-header-id header)) |
2489 (let ((gnus-override-method gnus-refer-article-method)) | 3779 (setq sparse-header (gnus-read-header article)) |
2490 (setq sparse-header (gnus-read-header article))) | |
2491 (setq gnus-newsgroup-sparse | 3780 (setq gnus-newsgroup-sparse |
2492 (delq article gnus-newsgroup-sparse))) | 3781 (delq article gnus-newsgroup-sparse))) |
2493 ((vectorp header) | 3782 ((vectorp header) |
2494 ;; It's a real article. | 3783 ;; It's a real article. |
2495 (setq article (mail-header-id header))) | 3784 (setq article (mail-header-id header))) |
2500 | 3789 |
2501 (let ((method (gnus-find-method-for-group | 3790 (let ((method (gnus-find-method-for-group |
2502 gnus-newsgroup-name))) | 3791 gnus-newsgroup-name))) |
2503 (when (and (eq (car method) 'nneething) | 3792 (when (and (eq (car method) 'nneething) |
2504 (vectorp header)) | 3793 (vectorp header)) |
2505 (let ((dir (concat | 3794 (let ((dir (expand-file-name |
3795 (mail-header-subject header) | |
2506 (file-name-as-directory | 3796 (file-name-as-directory |
2507 (or (cadr (assq 'nneething-address method)) | 3797 (or (cadr (assq 'nneething-address method)) |
2508 (nth 1 method))) | 3798 (nth 1 method)))))) |
2509 (mail-header-subject header)))) | |
2510 (when (file-directory-p dir) | 3799 (when (file-directory-p dir) |
2511 (setq article 'nneething) | 3800 (setq article 'nneething) |
2512 (gnus-group-enter-directory dir)))))))) | 3801 (gnus-group-enter-directory dir)))))))) |
2513 | 3802 |
2514 (cond | 3803 (cond |
2545 ((and gnus-use-cache | 3834 ((and gnus-use-cache |
2546 (numberp article) | 3835 (numberp article) |
2547 (gnus-cache-request-article article group)) | 3836 (gnus-cache-request-article article group)) |
2548 'article) | 3837 'article) |
2549 ;; Get the article and put into the article buffer. | 3838 ;; Get the article and put into the article buffer. |
2550 ((or (stringp article) (numberp article)) | 3839 ((or (stringp article) |
2551 (let ((gnus-override-method | 3840 (numberp article)) |
2552 (and (stringp article) gnus-refer-article-method)) | 3841 (let ((gnus-override-method gnus-override-method) |
3842 (methods (and (stringp article) | |
3843 gnus-refer-article-method)) | |
3844 result | |
2553 (buffer-read-only nil)) | 3845 (buffer-read-only nil)) |
2554 (erase-buffer) | 3846 (setq methods |
2555 (gnus-kill-all-overlays) | 3847 (if (listp methods) |
2556 (gnus-check-group-server) | 3848 methods |
2557 (when (gnus-request-article article group (current-buffer)) | 3849 (list methods))) |
2558 (when (numberp article) | 3850 (when (and (null gnus-override-method) |
2559 (gnus-async-prefetch-next group article gnus-summary-buffer) | 3851 methods) |
2560 (when gnus-keep-backlog | 3852 (setq gnus-override-method (pop methods))) |
2561 (gnus-backlog-enter-article | 3853 (while (not result) |
2562 group article (current-buffer)))) | 3854 (when (eq gnus-override-method 'current) |
2563 'article))) | 3855 (setq gnus-override-method gnus-current-select-method)) |
3856 (erase-buffer) | |
3857 (gnus-kill-all-overlays) | |
3858 (let ((gnus-newsgroup-name group)) | |
3859 (gnus-check-group-server)) | |
3860 (when (gnus-request-article article group (current-buffer)) | |
3861 (when (numberp article) | |
3862 (gnus-async-prefetch-next group article | |
3863 gnus-summary-buffer) | |
3864 (when gnus-keep-backlog | |
3865 (gnus-backlog-enter-article | |
3866 group article (current-buffer)))) | |
3867 (setq result 'article)) | |
3868 (if (not result) | |
3869 (if methods | |
3870 (setq gnus-override-method (pop methods)) | |
3871 (setq result 'done)))) | |
3872 (and (eq result 'article) 'article))) | |
2564 ;; It was a pseudo. | 3873 ;; It was a pseudo. |
2565 (t article))) | 3874 (t article))) |
2566 | 3875 |
2567 ;; Associate this article with the current summary buffer. | 3876 ;; Associate this article with the current summary buffer. |
2568 (setq gnus-article-current-summary gnus-summary-buffer) | 3877 (setq gnus-article-current-summary gnus-summary-buffer) |
2574 (buffer-name (get-buffer gnus-article-buffer)))) | 3883 (buffer-name (get-buffer gnus-article-buffer)))) |
2575 (save-excursion | 3884 (save-excursion |
2576 (if (get-buffer gnus-original-article-buffer) | 3885 (if (get-buffer gnus-original-article-buffer) |
2577 (set-buffer gnus-original-article-buffer) | 3886 (set-buffer gnus-original-article-buffer) |
2578 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) | 3887 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) |
2579 (buffer-disable-undo (current-buffer)) | 3888 (buffer-disable-undo) |
2580 (setq major-mode 'gnus-original-article-mode) | 3889 (setq major-mode 'gnus-original-article-mode) |
2581 (setq buffer-read-only t)) | 3890 (setq buffer-read-only t)) |
2582 (let (buffer-read-only) | 3891 (let (buffer-read-only) |
2583 (erase-buffer) | 3892 (erase-buffer) |
2584 (insert-buffer-substring gnus-article-buffer)) | 3893 (insert-buffer-substring gnus-article-buffer)) |
2585 (setq gnus-original-article (cons group article)))) | 3894 (setq gnus-original-article (cons group article))) |
3895 | |
3896 ;; Decode charsets. | |
3897 (run-hooks 'gnus-article-decode-hook) | |
3898 ;; Mark article as decoded or not. | |
3899 (setq gnus-article-decoded-p gnus-article-decode-hook)) | |
2586 | 3900 |
2587 ;; Update sparse articles. | 3901 ;; Update sparse articles. |
2588 (when (and do-update-line | 3902 (when (and do-update-line |
2589 (or (numberp article) | 3903 (or (numberp article) |
2590 (stringp article))) | 3904 (stringp article))) |
2607 | 3921 |
2608 (defvar gnus-article-edit-done-function nil) | 3922 (defvar gnus-article-edit-done-function nil) |
2609 | 3923 |
2610 (defvar gnus-article-edit-mode-map nil) | 3924 (defvar gnus-article-edit-mode-map nil) |
2611 | 3925 |
3926 ;; Should we be using derived.el for this? | |
2612 (unless gnus-article-edit-mode-map | 3927 (unless gnus-article-edit-mode-map |
2613 (setq gnus-article-edit-mode-map (copy-keymap text-mode-map)) | 3928 (setq gnus-article-edit-mode-map (make-sparse-keymap)) |
3929 (set-keymap-parent gnus-article-edit-mode-map text-mode-map) | |
2614 | 3930 |
2615 (gnus-define-keys gnus-article-edit-mode-map | 3931 (gnus-define-keys gnus-article-edit-mode-map |
2616 "\C-c\C-c" gnus-article-edit-done | 3932 "\C-c\C-c" gnus-article-edit-done |
2617 "\C-c\C-k" gnus-article-edit-exit) | 3933 "\C-c\C-k" gnus-article-edit-exit) |
2618 | 3934 |
2645 (when (and (not force) | 3961 (when (and (not force) |
2646 (gnus-group-read-only-p)) | 3962 (gnus-group-read-only-p)) |
2647 (error "The current newsgroup does not support article editing")) | 3963 (error "The current newsgroup does not support article editing")) |
2648 (gnus-article-date-original) | 3964 (gnus-article-date-original) |
2649 (gnus-article-edit-article | 3965 (gnus-article-edit-article |
3966 'ignore | |
2650 `(lambda (no-highlight) | 3967 `(lambda (no-highlight) |
3968 'ignore | |
2651 (gnus-summary-edit-article-done | 3969 (gnus-summary-edit-article-done |
2652 ,(or (mail-header-references gnus-current-headers) "") | 3970 ,(or (mail-header-references gnus-current-headers) "") |
2653 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) | 3971 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) |
2654 | 3972 |
2655 (defun gnus-article-edit-article (exit-func) | 3973 (defun gnus-article-edit-article (start-func exit-func) |
2656 "Start editing the contents of the current article buffer." | 3974 "Start editing the contents of the current article buffer." |
2657 (let ((winconf (current-window-configuration))) | 3975 (let ((winconf (current-window-configuration))) |
2658 (set-buffer gnus-article-buffer) | 3976 (set-buffer gnus-article-buffer) |
2659 (gnus-article-edit-mode) | 3977 (gnus-article-edit-mode) |
2660 (gnus-article-delete-text-of-type 'annotation) | 3978 (funcall start-func) |
2661 (gnus-set-text-properties (point-min) (point-max) nil) | |
2662 (gnus-configure-windows 'edit-article) | 3979 (gnus-configure-windows 'edit-article) |
2663 (setq gnus-article-edit-done-function exit-func) | 3980 (setq gnus-article-edit-done-function exit-func) |
2664 (setq gnus-prev-winconf winconf) | 3981 (setq gnus-prev-winconf winconf) |
2665 (gnus-message 6 "C-c C-c to end edits"))) | 3982 (gnus-message 6 "C-c C-c to end edits"))) |
2666 | 3983 |
2668 "Update the article edits and exit." | 3985 "Update the article edits and exit." |
2669 (interactive "P") | 3986 (interactive "P") |
2670 (save-excursion | 3987 (save-excursion |
2671 (save-restriction | 3988 (save-restriction |
2672 (widen) | 3989 (widen) |
2673 (goto-char (point-min)) | 3990 (when (article-goto-body) |
2674 (when (search-forward "\n\n" nil 1) | |
2675 (let ((lines (count-lines (point) (point-max))) | 3991 (let ((lines (count-lines (point) (point-max))) |
2676 (length (- (point-max) (point))) | 3992 (length (- (point-max) (point))) |
2677 (case-fold-search t) | 3993 (case-fold-search t) |
2678 (body (copy-marker (point)))) | 3994 (body (copy-marker (point)))) |
2679 (goto-char (point-min)) | 3995 (goto-char (point-min)) |
2694 (start (window-start))) | 4010 (start (window-start))) |
2695 (gnus-article-edit-exit) | 4011 (gnus-article-edit-exit) |
2696 (save-excursion | 4012 (save-excursion |
2697 (set-buffer buf) | 4013 (set-buffer buf) |
2698 (let ((buffer-read-only nil)) | 4014 (let ((buffer-read-only nil)) |
2699 (funcall func arg))) | 4015 (funcall func arg)) |
2700 (set-buffer buf) | |
2701 (set-window-start (get-buffer-window buf) start) | |
2702 (set-window-point (get-buffer-window buf) (point)))) | |
2703 | |
2704 (defun gnus-article-edit-exit () | |
2705 "Exit the article editing without updating." | |
2706 (interactive) | |
2707 ;; We remove all text props from the article buffer. | |
2708 (let ((buf (format "%s" (buffer-string))) | |
2709 (curbuf (current-buffer)) | |
2710 (p (point)) | |
2711 (window-start (window-start))) | |
2712 (erase-buffer) | |
2713 (insert buf) | |
2714 (let ((winconf gnus-prev-winconf)) | |
2715 (gnus-article-mode) | |
2716 ;; The cache and backlog have to be flushed somewhat. | 4016 ;; The cache and backlog have to be flushed somewhat. |
2717 (when gnus-use-cache | |
2718 (gnus-cache-update-article | |
2719 (car gnus-article-current) (cdr gnus-article-current))) | |
2720 (when gnus-keep-backlog | 4017 (when gnus-keep-backlog |
2721 (gnus-backlog-remove-article | 4018 (gnus-backlog-remove-article |
2722 (car gnus-article-current) (cdr gnus-article-current))) | 4019 (car gnus-article-current) (cdr gnus-article-current))) |
2723 ;; Flush original article as well. | 4020 ;; Flush original article as well. |
2724 (save-excursion | 4021 (save-excursion |
2725 (when (get-buffer gnus-original-article-buffer) | 4022 (when (get-buffer gnus-original-article-buffer) |
2726 (set-buffer gnus-original-article-buffer) | 4023 (set-buffer gnus-original-article-buffer) |
2727 (setq gnus-original-article nil))) | 4024 (setq gnus-original-article nil))) |
4025 (when gnus-use-cache | |
4026 (gnus-cache-update-article | |
4027 (car gnus-article-current) (cdr gnus-article-current)))) | |
4028 (set-buffer buf) | |
4029 (set-window-start (get-buffer-window buf) start) | |
4030 (set-window-point (get-buffer-window buf) (point)))) | |
4031 | |
4032 (defun gnus-article-edit-exit () | |
4033 "Exit the article editing without updating." | |
4034 (interactive) | |
4035 ;; We remove all text props from the article buffer. | |
4036 (let ((buf (buffer-substring-no-properties (point-min) (point-max))) | |
4037 (curbuf (current-buffer)) | |
4038 (p (point)) | |
4039 (window-start (window-start))) | |
4040 (erase-buffer) | |
4041 (insert buf) | |
4042 (let ((winconf gnus-prev-winconf)) | |
4043 (gnus-article-mode) | |
2728 (set-window-configuration winconf) | 4044 (set-window-configuration winconf) |
2729 ;; Tippy-toe some to make sure that point remains where it was. | 4045 ;; Tippy-toe some to make sure that point remains where it was. |
2730 (let ((buf (current-buffer))) | 4046 (save-current-buffer |
2731 (set-buffer curbuf) | 4047 (set-buffer curbuf) |
2732 (set-window-start (get-buffer-window (current-buffer)) window-start) | 4048 (set-window-start (get-buffer-window (current-buffer)) window-start) |
2733 (goto-char p) | 4049 (goto-char p))))) |
2734 (set-buffer buf))))) | |
2735 | 4050 |
2736 (defun gnus-article-edit-full-stops () | 4051 (defun gnus-article-edit-full-stops () |
2737 "Interactively repair spacing at end of sentences." | 4052 "Interactively repair spacing at end of sentences." |
2738 (interactive) | 4053 (interactive) |
2739 (save-excursion | 4054 (save-excursion |
2748 | 4063 |
2749 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. | 4064 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. |
2750 | 4065 |
2751 ;;; Internal Variables: | 4066 ;;; Internal Variables: |
2752 | 4067 |
2753 (defcustom gnus-button-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)" | 4068 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)" |
2754 "Regular expression that matches URLs." | 4069 "Regular expression that matches URLs." |
2755 :group 'gnus-article-buttons | 4070 :group 'gnus-article-buttons |
2756 :type 'regexp) | 4071 :type 'regexp) |
2757 | 4072 |
2758 (defcustom gnus-button-alist | 4073 (defcustom gnus-button-alist |
2759 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t | 4074 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" |
2760 gnus-button-message-id 2) | 4075 0 t gnus-button-message-id 2) |
2761 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*\\)" 0 t gnus-button-message-id 1) | 4076 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1) |
2762 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)" | 4077 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)" |
2763 1 t | 4078 1 t |
2764 gnus-button-fetch-group 4) | 4079 gnus-button-fetch-group 4) |
2765 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2) | 4080 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2) |
2766 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2 | 4081 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2 |
2767 t gnus-button-message-id 3) | 4082 t gnus-button-message-id 3) |
2768 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2) | 4083 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2) |
2769 ("mailto:\\([a-zA-Z.-@_+0-9%]+\\)" 0 t gnus-url-mailto 1) | 4084 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1) |
2770 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1) | 4085 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1) |
2771 ;; This is how URLs _should_ be embedded in text... | 4086 ;; This is how URLs _should_ be embedded in text... |
2772 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1) | 4087 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1) |
2773 ;; Raw URLs. | 4088 ;; Raw URLs. |
2774 (,gnus-button-url-regexp 0 t gnus-button-url 0)) | 4089 (,gnus-button-url-regexp 0 t browse-url 0)) |
2775 "*Alist of regexps matching buttons in article bodies. | 4090 "*Alist of regexps matching buttons in article bodies. |
2776 | 4091 |
2777 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where | 4092 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where |
2778 REGEXP: is the string matching text around the button, | 4093 REGEXP: is the string matching text around the button, |
2779 BUTTON: is the number of the regexp grouping actually matching the button, | 4094 BUTTON: is the number of the regexp grouping actually matching the button, |
2797 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>" | 4112 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>" |
2798 0 t gnus-button-message-id 0) | 4113 0 t gnus-button-message-id 0) |
2799 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1) | 4114 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1) |
2800 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" | 4115 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" |
2801 0 t gnus-button-mailto 0) | 4116 0 t gnus-button-mailto 0) |
2802 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | 4117 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0) |
2803 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | 4118 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0) |
2804 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | 4119 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0) |
2805 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t | 4120 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t |
2806 gnus-button-message-id 3)) | 4121 gnus-button-message-id 3)) |
2807 "*Alist of headers and regexps to match buttons in article heads. | 4122 "*Alist of headers and regexps to match buttons in article heads. |
2808 | 4123 |
2809 This alist is very similar to `gnus-button-alist', except that each | 4124 This alist is very similar to `gnus-button-alist', except that each |
2854 (let* ((data (get-text-property (point) 'gnus-data)) | 4169 (let* ((data (get-text-property (point) 'gnus-data)) |
2855 (fun (get-text-property (point) 'gnus-callback))) | 4170 (fun (get-text-property (point) 'gnus-callback))) |
2856 (when fun | 4171 (when fun |
2857 (funcall fun data)))) | 4172 (funcall fun data)))) |
2858 | 4173 |
2859 (defun gnus-article-prev-button (n) | |
2860 "Move point to N buttons backward. | |
2861 If N is negative, move forward instead." | |
2862 (interactive "p") | |
2863 (gnus-article-next-button (- n))) | |
2864 | |
2865 (defun gnus-article-next-button (n) | |
2866 "Move point to N buttons forward. | |
2867 If N is negative, move backward instead." | |
2868 (interactive "p") | |
2869 (let ((function (if (< n 0) 'previous-single-property-change | |
2870 'next-single-property-change)) | |
2871 (inhibit-point-motion-hooks t) | |
2872 (backward (< n 0)) | |
2873 (limit (if (< n 0) (point-min) (point-max)))) | |
2874 (setq n (abs n)) | |
2875 (while (and (not (= limit (point))) | |
2876 (> n 0)) | |
2877 ;; Skip past the current button. | |
2878 (when (get-text-property (point) 'gnus-callback) | |
2879 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2880 ;; Go to the next (or previous) button. | |
2881 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit)) | |
2882 ;; Put point at the start of the button. | |
2883 (when (and backward (not (get-text-property (point) 'gnus-callback))) | |
2884 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2885 ;; Skip past intangible buttons. | |
2886 (when (get-text-property (point) 'intangible) | |
2887 (incf n)) | |
2888 (decf n)) | |
2889 (unless (zerop n) | |
2890 (gnus-message 5 "No more buttons")) | |
2891 n)) | |
2892 | |
2893 (defun gnus-article-highlight (&optional force) | 4174 (defun gnus-article-highlight (&optional force) |
2894 "Highlight current article. | 4175 "Highlight current article. |
2895 This function calls `gnus-article-highlight-headers', | 4176 This function calls `gnus-article-highlight-headers', |
2896 `gnus-article-highlight-citation', | 4177 `gnus-article-highlight-citation', |
2897 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | 4178 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to |
2922 (let ((alist gnus-header-face-alist) | 4203 (let ((alist gnus-header-face-alist) |
2923 (buffer-read-only nil) | 4204 (buffer-read-only nil) |
2924 (case-fold-search t) | 4205 (case-fold-search t) |
2925 (inhibit-point-motion-hooks t) | 4206 (inhibit-point-motion-hooks t) |
2926 entry regexp header-face field-face from hpoints fpoints) | 4207 entry regexp header-face field-face from hpoints fpoints) |
2927 (message-narrow-to-head) | 4208 (article-narrow-to-head) |
2928 (while (setq entry (pop alist)) | 4209 (while (setq entry (pop alist)) |
2929 (goto-char (point-min)) | 4210 (goto-char (point-min)) |
2930 (setq regexp (concat "^\\(" | 4211 (setq regexp (concat "^\\(" |
2931 (if (string-equal "" (nth 0 entry)) | 4212 (if (string-equal "" (nth 0 entry)) |
2932 "[^\t ]" | 4213 "[^\t ]" |
2988 (inhibit-point-motion-hooks t) | 4269 (inhibit-point-motion-hooks t) |
2989 (case-fold-search t) | 4270 (case-fold-search t) |
2990 (alist gnus-button-alist) | 4271 (alist gnus-button-alist) |
2991 beg entry regexp) | 4272 beg entry regexp) |
2992 ;; Remove all old markers. | 4273 ;; Remove all old markers. |
2993 (let (marker entry) | 4274 (let (marker entry new-list) |
2994 (while (setq marker (pop gnus-button-marker-list)) | 4275 (while (setq marker (pop gnus-button-marker-list)) |
2995 (goto-char marker) | 4276 (if (or (< marker (point-min)) (>= marker (point-max))) |
2996 (when (setq entry (gnus-button-entry)) | 4277 (push marker new-list) |
2997 (put-text-property (match-beginning (nth 1 entry)) | 4278 (goto-char marker) |
2998 (match-end (nth 1 entry)) | 4279 (when (setq entry (gnus-button-entry)) |
2999 'gnus-callback nil)) | 4280 (put-text-property (match-beginning (nth 1 entry)) |
3000 (set-marker marker nil))) | 4281 (match-end (nth 1 entry)) |
4282 'gnus-callback nil)) | |
4283 (set-marker marker nil))) | |
4284 (setq gnus-button-marker-list new-list)) | |
3001 ;; We skip the headers. | 4285 ;; We skip the headers. |
3002 (goto-char (point-min)) | 4286 (article-goto-body) |
3003 (unless (search-forward "\n\n" nil t) | |
3004 (goto-char (point-max))) | |
3005 (setq beg (point)) | 4287 (setq beg (point)) |
3006 (while (setq entry (pop alist)) | 4288 (while (setq entry (pop alist)) |
3007 (setq regexp (car entry)) | 4289 (setq regexp (car entry)) |
3008 (goto-char beg) | 4290 (goto-char beg) |
3009 (while (re-search-forward regexp nil t) | 4291 (while (re-search-forward regexp nil t) |
3025 (defun gnus-article-add-buttons-to-head () | 4307 (defun gnus-article-add-buttons-to-head () |
3026 "Add buttons to the head of the article." | 4308 "Add buttons to the head of the article." |
3027 (interactive) | 4309 (interactive) |
3028 (save-excursion | 4310 (save-excursion |
3029 (set-buffer gnus-article-buffer) | 4311 (set-buffer gnus-article-buffer) |
3030 (let ((buffer-read-only nil) | 4312 (save-restriction |
3031 (inhibit-point-motion-hooks t) | 4313 (let ((buffer-read-only nil) |
3032 (case-fold-search t) | 4314 (inhibit-point-motion-hooks t) |
3033 (alist gnus-header-button-alist) | 4315 (case-fold-search t) |
3034 entry beg end) | 4316 (alist gnus-header-button-alist) |
3035 (nnheader-narrow-to-headers) | 4317 entry beg end) |
3036 (while alist | 4318 (article-narrow-to-head) |
3037 ;; Each alist entry. | 4319 (while alist |
3038 (setq entry (car alist) | 4320 ;; Each alist entry. |
3039 alist (cdr alist)) | 4321 (setq entry (car alist) |
3040 (goto-char (point-min)) | 4322 alist (cdr alist)) |
3041 (while (re-search-forward (car entry) nil t) | 4323 (goto-char (point-min)) |
3042 ;; Each header matching the entry. | 4324 (while (re-search-forward (car entry) nil t) |
3043 (setq beg (match-beginning 0)) | 4325 ;; Each header matching the entry. |
3044 (setq end (or (and (re-search-forward "^[^ \t]" nil t) | 4326 (setq beg (match-beginning 0)) |
3045 (match-beginning 0)) | 4327 (setq end (or (and (re-search-forward "^[^ \t]" nil t) |
3046 (point-max))) | 4328 (match-beginning 0)) |
3047 (goto-char beg) | 4329 (point-max))) |
3048 (while (re-search-forward (nth 1 entry) end t) | 4330 (goto-char beg) |
3049 ;; Each match within a header. | 4331 (while (re-search-forward (nth 1 entry) end t) |
3050 (let* ((entry (cdr entry)) | 4332 ;; Each match within a header. |
3051 (start (match-beginning (nth 1 entry))) | 4333 (let* ((entry (cdr entry)) |
3052 (end (match-end (nth 1 entry))) | 4334 (start (match-beginning (nth 1 entry))) |
3053 (form (nth 2 entry))) | 4335 (end (match-end (nth 1 entry))) |
3054 (goto-char (match-end 0)) | 4336 (form (nth 2 entry))) |
3055 (when (eval form) | 4337 (goto-char (match-end 0)) |
3056 (gnus-article-add-button | 4338 (when (eval form) |
3057 start end (nth 3 entry) | 4339 (gnus-article-add-button |
3058 (buffer-substring (match-beginning (nth 4 entry)) | 4340 start end (nth 3 entry) |
3059 (match-end (nth 4 entry))))))) | 4341 (buffer-substring (match-beginning (nth 4 entry)) |
3060 (goto-char end)))) | 4342 (match-end (nth 4 entry))))))) |
3061 (widen))) | 4343 (goto-char end))))))) |
3062 | 4344 |
3063 ;;; External functions: | 4345 ;;; External functions: |
3064 | 4346 |
3065 (defun gnus-article-add-button (from to fun &optional data) | 4347 (defun gnus-article-add-button (from to fun &optional data) |
3066 "Create a button between FROM and TO with callback FUN and data DATA." | 4348 "Create a button between FROM and TO with callback FUN and data DATA." |
3070 (gnus-add-text-properties | 4352 (gnus-add-text-properties |
3071 from to | 4353 from to |
3072 (nconc (and gnus-article-mouse-face | 4354 (nconc (and gnus-article-mouse-face |
3073 (list gnus-mouse-face-prop gnus-article-mouse-face)) | 4355 (list gnus-mouse-face-prop gnus-article-mouse-face)) |
3074 (list 'gnus-callback fun) | 4356 (list 'gnus-callback fun) |
3075 (and data (list 'gnus-data data))))) | 4357 (and data (list 'gnus-data data)))) |
4358 (widget-convert-button 'link from to :action 'gnus-widget-press-button | |
4359 :button-keymap gnus-widget-button-keymap)) | |
3076 | 4360 |
3077 ;;; Internal functions: | 4361 ;;; Internal functions: |
3078 | 4362 |
3079 (defun gnus-article-set-globals () | 4363 (defun gnus-article-set-globals () |
3080 (save-excursion | 4364 (save-excursion |
3102 entry)) | 4386 entry)) |
3103 | 4387 |
3104 (defun gnus-button-push (marker) | 4388 (defun gnus-button-push (marker) |
3105 ;; Push button starting at MARKER. | 4389 ;; Push button starting at MARKER. |
3106 (save-excursion | 4390 (save-excursion |
3107 (set-buffer gnus-article-buffer) | |
3108 (goto-char marker) | 4391 (goto-char marker) |
3109 (let* ((entry (gnus-button-entry)) | 4392 (let* ((entry (gnus-button-entry)) |
3110 (inhibit-point-motion-hooks t) | 4393 (inhibit-point-motion-hooks t) |
3111 (fun (nth 3 entry)) | 4394 (fun (nth 3 entry)) |
3112 (args (mapcar (lambda (group) | 4395 (args (mapcar (lambda (group) |
3147 (match-string 3 address) | 4430 (match-string 3 address) |
3148 "nntp"))))))) | 4431 "nntp"))))))) |
3149 | 4432 |
3150 (defun gnus-url-parse-query-string (query &optional downcase) | 4433 (defun gnus-url-parse-query-string (query &optional downcase) |
3151 (let (retval pairs cur key val) | 4434 (let (retval pairs cur key val) |
3152 (setq pairs (gnus-split-string query "&")) | 4435 (setq pairs (split-string query "&")) |
3153 (while pairs | 4436 (while pairs |
3154 (setq cur (car pairs) | 4437 (setq cur (car pairs) |
3155 pairs (cdr pairs)) | 4438 pairs (cdr pairs)) |
3156 (if (not (string-match "=" cur)) | 4439 (if (not (string-match "=" cur)) |
3157 nil ; Grace | 4440 nil ; Grace |
3228 | 4511 |
3229 (defun gnus-button-reply (address) | 4512 (defun gnus-button-reply (address) |
3230 ;; Reply to ADDRESS. | 4513 ;; Reply to ADDRESS. |
3231 (message-reply address)) | 4514 (message-reply address)) |
3232 | 4515 |
3233 (defun gnus-button-url (address) | |
3234 "Browse ADDRESS." | |
3235 (browse-url address)) | |
3236 | |
3237 (defun gnus-button-embedded-url (address) | 4516 (defun gnus-button-embedded-url (address) |
3238 "Browse ADDRESS." | 4517 "Browse ADDRESS." |
3239 ;; In Emacs 20, `browse-url-browser-function' may be an alist. | |
3240 (browse-url (gnus-strip-whitespace address))) | 4518 (browse-url (gnus-strip-whitespace address))) |
3241 | 4519 |
3242 ;;; Next/prev buttons in the article buffer. | 4520 ;;; Next/prev buttons in the article buffer. |
3243 | 4521 |
3244 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") | 4522 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") |
3254 (let ((buffer-read-only nil)) | 4532 (let ((buffer-read-only nil)) |
3255 (gnus-eval-format | 4533 (gnus-eval-format |
3256 gnus-prev-page-line-format nil | 4534 gnus-prev-page-line-format nil |
3257 `(gnus-prev t local-map ,gnus-prev-page-map | 4535 `(gnus-prev t local-map ,gnus-prev-page-map |
3258 gnus-callback gnus-article-button-prev-page | 4536 gnus-callback gnus-article-button-prev-page |
3259 gnus-type annotation)))) | 4537 article-type annotation)))) |
3260 | 4538 |
3261 (defvar gnus-next-page-map nil) | 4539 (defvar gnus-next-page-map nil) |
3262 (unless gnus-next-page-map | 4540 (unless gnus-next-page-map |
3263 (setq gnus-next-page-map (make-keymap)) | 4541 (setq gnus-next-page-map (make-keymap)) |
3264 (suppress-keymap gnus-prev-page-map) | 4542 (suppress-keymap gnus-prev-page-map) |
3285 (let ((buffer-read-only nil)) | 4563 (let ((buffer-read-only nil)) |
3286 (gnus-eval-format gnus-next-page-line-format nil | 4564 (gnus-eval-format gnus-next-page-line-format nil |
3287 `(gnus-next | 4565 `(gnus-next |
3288 t local-map ,gnus-next-page-map | 4566 t local-map ,gnus-next-page-map |
3289 gnus-callback gnus-article-button-next-page | 4567 gnus-callback gnus-article-button-next-page |
3290 gnus-type annotation)))) | 4568 article-type annotation)))) |
3291 | 4569 |
3292 (defun gnus-article-button-next-page (arg) | 4570 (defun gnus-article-button-next-page (arg) |
3293 "Go to the next page." | 4571 "Go to the next page." |
3294 (interactive "P") | 4572 (interactive "P") |
3295 (let ((win (selected-window))) | 4573 (let ((win (selected-window))) |
3303 (let ((win (selected-window))) | 4581 (let ((win (selected-window))) |
3304 (select-window (get-buffer-window gnus-article-buffer t)) | 4582 (select-window (get-buffer-window gnus-article-buffer t)) |
3305 (gnus-article-prev-page) | 4583 (gnus-article-prev-page) |
3306 (select-window win))) | 4584 (select-window win))) |
3307 | 4585 |
4586 (defvar gnus-decode-header-methods | |
4587 '(mail-decode-encoded-word-region) | |
4588 "List of methods used to decode headers. | |
4589 | |
4590 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item | |
4591 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a | |
4592 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups | |
4593 whose names match REGEXP. | |
4594 | |
4595 For example: | |
4596 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess) | |
4597 mail-decode-encoded-word-region | |
4598 (\"chinese\" . rfc1843-decode-region)) | |
4599 ") | |
4600 | |
4601 (defvar gnus-decode-header-methods-cache nil) | |
4602 | |
4603 (defun gnus-multi-decode-header (start end) | |
4604 "Apply the functions from `gnus-encoded-word-methods' that match." | |
4605 (unless (and gnus-decode-header-methods-cache | |
4606 (eq gnus-newsgroup-name | |
4607 (car gnus-decode-header-methods-cache))) | |
4608 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name)) | |
4609 (mapcar (lambda (x) | |
4610 (if (symbolp x) | |
4611 (nconc gnus-decode-header-methods-cache (list x)) | |
4612 (if (and gnus-newsgroup-name | |
4613 (string-match (car x) gnus-newsgroup-name)) | |
4614 (nconc gnus-decode-header-methods-cache | |
4615 (list (cdr x)))))) | |
4616 gnus-decode-header-methods)) | |
4617 (let ((xlist gnus-decode-header-methods-cache)) | |
4618 (pop xlist) | |
4619 (save-restriction | |
4620 (narrow-to-region start end) | |
4621 (while xlist | |
4622 (funcall (pop xlist) (point-min) (point-max)))))) | |
4623 | |
4624 ;;; | |
4625 ;;; Treatment top-level handling. | |
4626 ;;; | |
4627 | |
4628 (defun gnus-treat-article (condition &optional part-number total-parts type) | |
4629 (let ((length (- (point-max) (point-min))) | |
4630 (alist gnus-treatment-function-alist) | |
4631 (article-goto-body-goes-to-point-min-p t) | |
4632 (treated-type | |
4633 (or (not type) | |
4634 (catch 'found | |
4635 (let ((list gnus-article-treat-types)) | |
4636 (while list | |
4637 (when (string-match (pop list) type) | |
4638 (throw 'found t))))))) | |
4639 (highlightp (gnus-visual-p 'article-highlight 'highlight)) | |
4640 val elem) | |
4641 (gnus-run-hooks 'gnus-part-display-hook) | |
4642 (while (setq elem (pop alist)) | |
4643 (setq val | |
4644 (save-excursion | |
4645 (if (gnus-buffer-live-p gnus-summary-buffer) | |
4646 (set-buffer gnus-summary-buffer)) | |
4647 (symbol-value (car elem)))) | |
4648 (when (and (or (consp val) | |
4649 treated-type) | |
4650 (gnus-treat-predicate val) | |
4651 (or (not (get (car elem) 'highlight)) | |
4652 highlightp)) | |
4653 (save-restriction | |
4654 (funcall (cadr elem))))))) | |
4655 | |
4656 ;; Dynamic variables. | |
4657 (defvar part-number) | |
4658 (defvar total-parts) | |
4659 (defvar type) | |
4660 (defvar condition) | |
4661 (defvar length) | |
4662 (defun gnus-treat-predicate (val) | |
4663 (cond | |
4664 ((null val) | |
4665 nil) | |
4666 ((and (listp val) | |
4667 (stringp (car val))) | |
4668 (apply 'gnus-or (mapcar `(lambda (s) | |
4669 (string-match s ,(or gnus-newsgroup-name ""))) | |
4670 val))) | |
4671 ((listp val) | |
4672 (let ((pred (pop val))) | |
4673 (cond | |
4674 ((eq pred 'or) | |
4675 (apply 'gnus-or (mapcar 'gnus-treat-predicate val))) | |
4676 ((eq pred 'and) | |
4677 (apply 'gnus-and (mapcar 'gnus-treat-predicate val))) | |
4678 ((eq pred 'not) | |
4679 (not (gnus-treat-predicate (car val)))) | |
4680 ((eq pred 'typep) | |
4681 (equal (car val) type)) | |
4682 (t | |
4683 (error "%S is not a valid predicate" pred))))) | |
4684 (condition | |
4685 (eq condition val)) | |
4686 ((eq val t) | |
4687 t) | |
4688 ((eq val 'head) | |
4689 nil) | |
4690 ((eq val 'last) | |
4691 (eq part-number total-parts)) | |
4692 ((numberp val) | |
4693 (< length val)) | |
4694 (t | |
4695 (error "%S is not a valid value" val)))) | |
4696 | |
3308 (gnus-ems-redefine) | 4697 (gnus-ems-redefine) |
3309 | 4698 |
3310 (provide 'gnus-art) | 4699 (provide 'gnus-art) |
3311 | 4700 |
3312 (run-hooks 'gnus-art-load-hook) | 4701 (run-hooks 'gnus-art-load-hook) |