comparison lisp/gnus/gnus-art.el @ 85712:a3c27999decb

Update Gnus to No Gnus 0.7 from the Gnus CVS trunk Revision: emacs@sv.gnu.org/emacs--devo--0--patch-911
author Miles Bader <miles@gnu.org>
date Sun, 28 Oct 2007 09:18:39 +0000
parents d7862063d437
children a3af441f6431
comparison
equal deleted inserted replaced
85711:b6f5dc84b2e1 85712:a3c27999decb
31 (require 'cl) 31 (require 'cl)
32 (defvar tool-bar-map) 32 (defvar tool-bar-map)
33 (defvar w3m-minor-mode-map)) 33 (defvar w3m-minor-mode-map))
34 34
35 (require 'gnus) 35 (require 'gnus)
36 (require 'gnus-sum) 36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
37 (eval-and-compile
38 (let ((recursive-load-depth-limit 100))
39 (require 'gnus-sum)))
37 (require 'gnus-spec) 40 (require 'gnus-spec)
38 (require 'gnus-int) 41 (require 'gnus-int)
39 (require 'gnus-win) 42 (require 'gnus-win)
40 (require 'mm-bodies) 43 (require 'mm-bodies)
41 (require 'mail-parse) 44 (require 'mail-parse)
47 50
48 (autoload 'gnus-msg-mail "gnus-msg" nil t) 51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg") 52 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t) 53 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil) 54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (autoload 'mm-url-insert-file-contents-external "mm-url")
52 (autoload 'mm-extern-cache-contents "mm-extern") 57 (autoload 'mm-extern-cache-contents "mm-extern")
53 58
54 (defgroup gnus-article nil 59 (defgroup gnus-article nil
55 "Article display." 60 "Article display."
56 :link '(custom-manual "(gnus)Article Buffer") 61 :link '(custom-manual "(gnus)Article Buffer")
151 "X-Content-length" "X-Posting-Agent" "Original-Received" 156 "X-Content-length" "X-Posting-Agent" "Original-Received"
152 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom" 157 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway" 158 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1" 159 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications" 160 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer")) 161 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
162 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
163 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
164 "Envelope-Sender" "Envelope-Recipients"))
157 "*All headers that start with this regexp will be hidden. 165 "*All headers that start with this regexp will be hidden.
158 This variable can also be a list of regexps of headers to be ignored. 166 This variable can also be a list of regexps of headers to be ignored.
159 If `gnus-visible-headers' is non-nil, this variable will be ignored." 167 If `gnus-visible-headers' is non-nil, this variable will be ignored."
160 :type '(choice :custom-show nil 168 :type '(choice :custom-show nil
161 regexp 169 regexp
236 If it is a number, no signature may not be longer (in characters) than 244 If it is a number, no signature may not be longer (in characters) than
237 that number. If it is a floating point number, no signature may be 245 that number. If it is a floating point number, no signature may be
238 longer (in lines) than that number. If it is a function, the function 246 longer (in lines) than that number. If it is a function, the function
239 will be called without any parameters, and if it returns nil, there is 247 will be called without any parameters, and if it returns nil, there is
240 no signature in the buffer. If it is a string, it will be used as a 248 no signature in the buffer. If it is a string, it will be used as a
241 regexp. If it matches, the text in question is not a signature." 249 regexp. If it matches, the text in question is not a signature.
250
251 This can also be a list of the above values."
242 :type '(choice (const nil) 252 :type '(choice (const nil)
243 (integer :value 200) 253 (integer :value 200)
244 (number :value 4.0) 254 (number :value 4.0)
245 function 255 function
246 (regexp :value ".*")) 256 (regexp :value ".*"))
410 :value 420 :value
411 (gnus-emphasis-custom-value-to-external value)))) 421 (gnus-emphasis-custom-value-to-external value))))
412 (widget-group-value-create widget)) 422 (widget-group-value-create widget))
413 regexp 423 regexp
414 (integer :format "Match group: %v") 424 (integer :format "Match group: %v")
415 (integer :format "Emphasize group: %v") 425 (integer :format "Emphasize group: %v")
416 face) 426 face)
417 (group :tag "Simple" 427 (group :tag "Simple"
418 :value (("_" . "_") nil default) 428 :value (("_" . "_") nil default)
419 (cons :format "%v" 429 (cons :format "%v"
420 (regexp :format "Start regexp: %v") 430 (regexp :format "Start regexp: %v")
478 (defface gnus-emphasis-highlight-words 488 (defface gnus-emphasis-highlight-words
479 '((t (:background "black" :foreground "yellow"))) 489 '((t (:background "black" :foreground "yellow")))
480 "Face used for displaying highlighted words." 490 "Face used for displaying highlighted words."
481 :group 'gnus-article-emphasis) 491 :group 'gnus-article-emphasis)
482 492
483 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z" 493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
484 "Format for display of Date headers in article bodies. 494 "Format for display of Date headers in article bodies.
485 See `format-time-string' for the possible values. 495 See `format-time-string' for the possible values.
486 496
487 The variable can also be function, which should return a complete Date 497 The variable can also be function, which should return a complete Date
488 header. The function is called with one argument, the time, which can 498 header. The function is called with one argument, the time, which can
489 be fed to `format-time-string'." 499 be fed to `format-time-string'."
490 :type '(choice string symbol) 500 :type '(choice string function)
491 :link '(custom-manual "(gnus)Article Date") 501 :link '(custom-manual "(gnus)Article Date")
492 :group 'gnus-article-washing) 502 :group 'gnus-article-washing)
493 503
494 (defcustom gnus-save-all-headers t 504 (defcustom gnus-save-all-headers t
495 "*If non-nil, don't remove any headers before saving. 505 "*If non-nil, don't remove any headers before saving.
643 you could set this variable to something like: 653 you could set this variable to something like:
644 654
645 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") 655 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
646 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) 656 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
647 657
648 This variable is an alist where the where the key is the match and the 658 This variable is an alist where the key is the match and the
649 value is a list of possible files to save in if the match is non-nil. 659 value is a list of possible files to save in if the match is
660 non-nil.
650 661
651 If the match is a string, it is used as a regexp match on the 662 If the match is a string, it is used as a regexp match on the
652 article. If the match is a symbol, that symbol will be funcalled 663 article. If the match is a symbol, that symbol will be funcalled
653 from the buffer of the article to be saved with the newsgroup as the 664 from the buffer of the article to be saved with the newsgroup as the
654 parameter. If it is a list, it will be evalled in the same buffer. 665 parameter. If it is a list, it will be evaled in the same buffer.
655 666
656 If this form or function returns a string, this string will be used as 667 If this form or function returns a string, this string will be used as a
657 a possible file name; and if it returns a non-nil list, that list will 668 possible file name; and if it returns a non-nil list, that list will be
658 be used as possible file names." 669 used as possible file names."
659 :group 'gnus-article-saving 670 :group 'gnus-article-saving
660 :type '(repeat (choice (list :value (fun) function) 671 :type '(repeat (choice (list :value (fun) function)
661 (cons :value ("" "") regexp (repeat string)) 672 (cons :value ("" "") regexp (repeat string))
662 (sexp :value nil)))) 673 (sexp :value nil))))
663 674
699 (defcustom gnus-article-prepare-hook nil 710 (defcustom gnus-article-prepare-hook nil
700 "*A hook called after an article has been prepared in the article buffer." 711 "*A hook called after an article has been prepared in the article buffer."
701 :type 'hook 712 :type 'hook
702 :group 'gnus-article-various) 713 :group 'gnus-article-various)
703 714
715 (defcustom gnus-copy-article-ignored-headers nil
716 "List of headers to be removed when copying an article.
717 Each element is a regular expression."
718 :version "23.0" ;; No Gnus
719 :type '(repeat regexp)
720 :group 'gnus-article-various)
721
704 (make-obsolete-variable 'gnus-article-hide-pgp-hook 722 (make-obsolete-variable 'gnus-article-hide-pgp-hook
705 "This variable is obsolete in Gnus 5.10.") 723 "This variable is obsolete in Gnus 5.10.")
706 724
707 (defcustom gnus-article-button-face 'bold 725 (defface gnus-button
726 '((t (:weight bold)))
727 "Face used for highlighting a button in the article buffer."
728 :group 'gnus-article-buttons)
729
730 (defcustom gnus-article-button-face 'gnus-button
708 "Face used for highlighting buttons in the article buffer. 731 "Face used for highlighting buttons in the article buffer.
709 732
710 An article button is a piece of text that you can activate by pressing 733 An article button is a piece of text that you can activate by pressing
711 `RET' or `mouse-2' above it." 734 `RET' or `mouse-2' above it."
712 :type 'face 735 :type 'face
737 (put 'gnus-signature-face 'face-alias 'gnus-signature) 760 (put 'gnus-signature-face 'face-alias 'gnus-signature)
738 761
739 (defface gnus-header-from 762 (defface gnus-header-from
740 '((((class color) 763 '((((class color)
741 (background dark)) 764 (background dark))
742 (:foreground "spring green")) 765 (:foreground "PaleGreen1"))
743 (((class color) 766 (((class color)
744 (background light)) 767 (background light))
745 (:foreground "red3")) 768 (:foreground "red3"))
746 (t 769 (t
747 (:italic t))) 770 (:italic t)))
752 (put 'gnus-header-from-face 'face-alias 'gnus-header-from) 775 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
753 776
754 (defface gnus-header-subject 777 (defface gnus-header-subject
755 '((((class color) 778 '((((class color)
756 (background dark)) 779 (background dark))
757 (:foreground "SeaGreen3")) 780 (:foreground "SeaGreen1"))
758 (((class color) 781 (((class color)
759 (background light)) 782 (background light))
760 (:foreground "red4")) 783 (:foreground "red4"))
761 (t 784 (t
762 (:bold t :italic t))) 785 (:bold t :italic t)))
784 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups) 807 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
785 808
786 (defface gnus-header-name 809 (defface gnus-header-name
787 '((((class color) 810 '((((class color)
788 (background dark)) 811 (background dark))
789 (:foreground "SeaGreen")) 812 (:foreground "SpringGreen2"))
790 (((class color) 813 (((class color)
791 (background light)) 814 (background light))
792 (:foreground "maroon")) 815 (:foreground "maroon"))
793 (t 816 (t
794 (:bold t))) 817 (:bold t)))
799 (put 'gnus-header-name-face 'face-alias 'gnus-header-name) 822 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
800 823
801 (defface gnus-header-content 824 (defface gnus-header-content
802 '((((class color) 825 '((((class color)
803 (background dark)) 826 (background dark))
804 (:foreground "forest green" :italic t)) 827 (:foreground "SpringGreen1" :italic t))
805 (((class color) 828 (((class color)
806 (background light)) 829 (background light))
807 (:foreground "indianred4" :italic t)) 830 (:foreground "indianred4" :italic t))
808 (t 831 (t
809 (:italic t))) "Face used for displaying header content." 832 (:italic t))) "Face used for displaying header content."
835 (item :tag "skip" nil) 858 (item :tag "skip" nil)
836 (face :value default)) 859 (face :value default))
837 (choice :tag "Content" 860 (choice :tag "Content"
838 (item :tag "skip" nil) 861 (item :tag "skip" nil)
839 (face :value default))))) 862 (face :value default)))))
863
864 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
865 '((xface . (:face gnus-x-face)))
866 '((pbm . (:face gnus-x-face))
867 (png . nil)))
868 "Alist of image types and properties applied to Face and X-Face images.
869 Here are examples:
870
871 ;; Specify the altitude of Face images in the From header.
872 \(setq gnus-face-properties-alist
873 '((pbm . (:face gnus-x-face :ascent 80))
874 (png . (:ascent 80))))
875
876 ;; Show Face images as pressed buttons.
877 \(setq gnus-face-properties-alist
878 '((pbm . (:face gnus-x-face :relief -2))
879 (png . (:relief -2))))
880
881 See the manual for the valid properties for various image types.
882 Currently, `pbm' is used for X-Face images and `png' is used for Face
883 images in Emacs. Only the `:face' property is effective on the `xface'
884 image type in XEmacs if it is built with the libcompface library."
885 :version "23.0" ;; No Gnus
886 :group 'gnus-article-headers
887 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
840 888
841 (defcustom gnus-article-decode-hook 889 (defcustom gnus-article-decode-hook
842 '(article-decode-charset article-decode-encoded-words 890 '(article-decode-charset article-decode-encoded-words
843 article-decode-group-name article-decode-idna-rhs) 891 article-decode-group-name article-decode-idna-rhs)
844 "*Hook run to decode charsets in articles." 892 "*Hook run to decode charsets in articles."
952 1000
953 (defcustom gnus-mime-multipart-functions nil 1001 (defcustom gnus-mime-multipart-functions nil
954 "An alist of MIME types to functions to display them." 1002 "An alist of MIME types to functions to display them."
955 :version "21.1" 1003 :version "21.1"
956 :group 'gnus-article-mime 1004 :group 'gnus-article-mime
957 :type 'alist) 1005 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
958 1006
959 (defcustom gnus-article-date-lapsed-new-header nil 1007 (defcustom gnus-article-date-lapsed-new-header nil
960 "Whether the X-Sent and Date headers can coexist. 1008 "Whether the X-Sent and Date headers can coexist.
961 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will 1009 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
962 either replace the old \"Date:\" header (if this variable is nil), or 1010 either replace the old \"Date:\" header (if this variable is nil), or
983 (function))) 1031 (function)))
984 1032
985 (defcustom gnus-mime-action-alist 1033 (defcustom gnus-mime-action-alist
986 '(("save to file" . gnus-mime-save-part) 1034 '(("save to file" . gnus-mime-save-part)
987 ("save and strip" . gnus-mime-save-part-and-strip) 1035 ("save and strip" . gnus-mime-save-part-and-strip)
1036 ("replace with file" . gnus-mime-replace-part)
988 ("delete part" . gnus-mime-delete-part) 1037 ("delete part" . gnus-mime-delete-part)
989 ("display as text" . gnus-mime-inline-part) 1038 ("display as text" . gnus-mime-inline-part)
990 ("view the part" . gnus-mime-view-part) 1039 ("view the part" . gnus-mime-view-part)
991 ("pipe to command" . gnus-mime-pipe-part) 1040 ("pipe to command" . gnus-mime-pipe-part)
992 ("toggle display" . gnus-article-press-button) 1041 ("toggle display" . gnus-article-press-button)
997 "An alist of actions that run on the MIME attachment." 1046 "An alist of actions that run on the MIME attachment."
998 :group 'gnus-article-mime 1047 :group 'gnus-article-mime
999 :type '(repeat (cons (string :tag "name") 1048 :type '(repeat (cons (string :tag "name")
1000 (function)))) 1049 (function))))
1001 1050
1051 (defcustom gnus-auto-select-part 1
1052 "Advance to next MIME part when deleting or stripping parts.
1053
1054 When 0, point will be placed on the same part as before. When
1055 positive (negative), move point forward (backwards) this many
1056 parts. When nil, redisplay article."
1057 :version "23.0" ;; No Gnus
1058 :group 'gnus-article-mime
1059 :type '(choice (const nil :tag "Redisplay article.")
1060 (const 1 :tag "Next part.")
1061 (const 0 :tag "Current part.")
1062 integer))
1063
1002 ;;; 1064 ;;;
1003 ;;; The treatment variables 1065 ;;; The treatment variables
1004 ;;; 1066 ;;;
1005 1067
1006 (defvar gnus-part-display-hook nil 1068 (defvar gnus-part-display-hook nil
1008 1070
1009 (defvar gnus-article-treat-custom 1071 (defvar gnus-article-treat-custom
1010 '(choice (const :tag "Off" nil) 1072 '(choice (const :tag "Off" nil)
1011 (const :tag "On" t) 1073 (const :tag "On" t)
1012 (const :tag "Header" head) 1074 (const :tag "Header" head)
1075 (const :tag "First" first)
1013 (const :tag "Last" last) 1076 (const :tag "Last" last)
1014 (integer :tag "Less") 1077 (integer :tag "Less")
1015 (repeat :tag "Groups" regexp) 1078 (repeat :tag "Groups" regexp)
1016 (sexp :tag "Predicate"))) 1079 (sexp :tag "Predicate")))
1017 1080
1018 (defvar gnus-article-treat-head-custom 1081 (defvar gnus-article-treat-head-custom
1019 '(choice (const :tag "Off" nil) 1082 '(choice (const :tag "Off" nil)
1020 (const :tag "Header" head))) 1083 (const :tag "Header" head)))
1021 1084
1022 (defvar gnus-article-treat-types '("text/plain") 1085 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1086 "text/x-patch")
1023 "Parts to treat.") 1087 "Parts to treat.")
1024 1088
1025 (defvar gnus-inhibit-treatment nil 1089 (defvar gnus-inhibit-treatment nil
1026 "Whether to inhibit treatment.") 1090 "Whether to inhibit treatment.")
1027 1091
1028 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard")) 1092 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1029 "Highlight the signature. 1093 "Highlight the signature.
1030 Valid values are nil, t, `head', `last', an integer or a predicate. 1094 Valid values are nil, t, `head', `first', `last', an integer or a
1031 See Info node `(gnus)Customizing Articles'." 1095 predicate. See Info node `(gnus)Customizing Articles'."
1032 :group 'gnus-article-treat 1096 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles") 1097 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom) 1098 :type gnus-article-treat-custom)
1035 (put 'gnus-treat-highlight-signature 'highlight t) 1099 (put 'gnus-treat-highlight-signature 'highlight t)
1036 1100
1037 (defcustom gnus-treat-buttonize 100000 1101 (defcustom gnus-treat-buttonize 100000
1038 "Add buttons. 1102 "Add buttons.
1039 Valid values are nil, t, `head', `last', an integer or a predicate. 1103 Valid values are nil, t, `head', `first', `last', an integer or a
1040 See Info node `(gnus)Customizing Articles'." 1104 predicate. See Info node `(gnus)Customizing Articles'."
1041 :group 'gnus-article-treat 1105 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles") 1106 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom) 1107 :type gnus-article-treat-custom)
1044 (put 'gnus-treat-buttonize 'highlight t) 1108 (put 'gnus-treat-buttonize 'highlight t)
1045 1109
1046 (defcustom gnus-treat-buttonize-head 'head 1110 (defcustom gnus-treat-buttonize-head 'head
1047 "Add buttons to the head. 1111 "Add buttons to the head.
1048 Valid values are nil, t, `head', `last', an integer or a predicate. 1112 Valid values are nil, t, `head', `first', `last', an integer or a
1049 See Info node `(gnus)Customizing Articles' for details." 1113 predicate. See Info node `(gnus)Customizing Articles'."
1050 :group 'gnus-article-treat 1114 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles") 1115 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-head-custom) 1116 :type gnus-article-treat-head-custom)
1053 (put 'gnus-treat-buttonize-head 'highlight t) 1117 (put 'gnus-treat-buttonize-head 'highlight t)
1054 1118
1055 (defcustom gnus-treat-emphasize 1119 (defcustom gnus-treat-emphasize
1056 (and (or window-system 1120 (and (or window-system
1057 (featurep 'xemacs) 1121 (featurep 'xemacs))
1058 (>= (string-to-number emacs-version) 21))
1059 50000) 1122 50000)
1060 "Emphasize text. 1123 "Emphasize text.
1061 Valid values are nil, t, `head', `last', an integer or a predicate. 1124 Valid values are nil, t, `head', `first', `last', an integer or a
1062 See Info node `(gnus)Customizing Articles' for details." 1125 predicate. See Info node `(gnus)Customizing Articles'."
1063 :group 'gnus-article-treat 1126 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles") 1127 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom) 1128 :type gnus-article-treat-custom)
1066 (put 'gnus-treat-emphasize 'highlight t) 1129 (put 'gnus-treat-emphasize 'highlight t)
1067 1130
1068 (defcustom gnus-treat-strip-cr nil 1131 (defcustom gnus-treat-strip-cr nil
1069 "Remove carriage returns. 1132 "Remove carriage returns.
1070 Valid values are nil, t, `head', `last', an integer or a predicate. 1133 Valid values are nil, t, `head', `first', `last', an integer or a
1071 See Info node `(gnus)Customizing Articles' for details." 1134 predicate. See Info node `(gnus)Customizing Articles'."
1072 :version "22.1" 1135 :version "22.1"
1073 :group 'gnus-article-treat 1136 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles") 1137 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-custom) 1138 :type gnus-article-treat-custom)
1076 1139
1077 (defcustom gnus-treat-unsplit-urls nil 1140 (defcustom gnus-treat-unsplit-urls nil
1078 "Remove newlines from within URLs. 1141 "Remove newlines from within URLs.
1079 Valid values are nil, t, `head', `last', an integer or a predicate. 1142 Valid values are nil, t, `head', `first', `last', an integer or a
1080 See Info node `(gnus)Customizing Articles' for details." 1143 predicate. See Info node `(gnus)Customizing Articles'."
1081 :version "22.1" 1144 :version "22.1"
1082 :group 'gnus-article-treat 1145 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles") 1146 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom) 1147 :type gnus-article-treat-custom)
1085 1148
1086 (defcustom gnus-treat-leading-whitespace nil 1149 (defcustom gnus-treat-leading-whitespace nil
1087 "Remove leading whitespace in headers. 1150 "Remove leading whitespace in headers.
1088 Valid values are nil, t, `head', `last', an integer or a predicate. 1151 Valid values are nil, t, `head', `first', `last', an integer or a
1089 See Info node `(gnus)Customizing Articles' for details." 1152 predicate. See Info node `(gnus)Customizing Articles'."
1090 :version "22.1" 1153 :version "22.1"
1091 :group 'gnus-article-treat 1154 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles") 1155 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-custom) 1156 :type gnus-article-treat-custom)
1094 1157
1095 (defcustom gnus-treat-hide-headers 'head 1158 (defcustom gnus-treat-hide-headers 'head
1096 "Hide headers. 1159 "Hide headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate. 1160 Valid values are nil, t, `head', `first', `last', an integer or a
1098 See Info node `(gnus)Customizing Articles' for details." 1161 predicate. See Info node `(gnus)Customizing Articles'."
1099 :group 'gnus-article-treat 1162 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles") 1163 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-head-custom) 1164 :type gnus-article-treat-head-custom)
1102 1165
1103 (defcustom gnus-treat-hide-boring-headers nil 1166 (defcustom gnus-treat-hide-boring-headers nil
1104 "Hide boring headers. 1167 "Hide boring headers.
1105 Valid values are nil, t, `head', `last', an integer or a predicate. 1168 Valid values are nil, t, `head', `first', `last', an integer or a
1106 See Info node `(gnus)Customizing Articles' for details." 1169 predicate. See Info node `(gnus)Customizing Articles'."
1107 :group 'gnus-article-treat 1170 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles") 1171 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-head-custom) 1172 :type gnus-article-treat-head-custom)
1110 1173
1111 (defcustom gnus-treat-hide-signature nil 1174 (defcustom gnus-treat-hide-signature nil
1112 "Hide the signature. 1175 "Hide the signature.
1113 Valid values are nil, t, `head', `last', an integer or a predicate. 1176 Valid values are nil, t, `head', `first', `last', an integer or a
1114 See Info node `(gnus)Customizing Articles' for details." 1177 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat 1178 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles") 1179 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom) 1180 :type gnus-article-treat-custom)
1118 1181
1119 (defcustom gnus-treat-fill-article nil 1182 (defcustom gnus-treat-fill-article nil
1120 "Fill the article. 1183 "Fill the article.
1121 Valid values are nil, t, `head', `last', an integer or a predicate. 1184 Valid values are nil, t, `head', `first', `last', an integer or a
1122 See Info node `(gnus)Customizing Articles' for details." 1185 predicate. See Info node `(gnus)Customizing Articles'."
1123 :group 'gnus-article-treat 1186 :group 'gnus-article-treat
1124 :link '(custom-manual "(gnus)Customizing Articles") 1187 :link '(custom-manual "(gnus)Customizing Articles")
1125 :type gnus-article-treat-custom) 1188 :type gnus-article-treat-custom)
1126 1189
1127 (defcustom gnus-treat-hide-citation nil 1190 (defcustom gnus-treat-hide-citation nil
1128 "Hide cited text. 1191 "Hide cited text.
1129 Valid values are nil, t, `head', `last', an integer or a predicate. 1192 Valid values are nil, t, `head', `first', `last', an integer or a
1130 See Info node `(gnus)Customizing Articles' for details." 1193 predicate. See Info node `(gnus)Customizing Articles'."
1131 :group 'gnus-article-treat 1194 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles") 1195 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom) 1196 :type gnus-article-treat-custom)
1134 1197
1135 (defcustom gnus-treat-hide-citation-maybe nil 1198 (defcustom gnus-treat-hide-citation-maybe nil
1136 "Hide cited text. 1199 "Hide cited text.
1137 Valid values are nil, t, `head', `last', an integer or a predicate. 1200 Valid values are nil, t, `head', `first', `last', an integer or a
1138 See Info node `(gnus)Customizing Articles' for details." 1201 predicate. See Info node `(gnus)Customizing Articles'."
1139 :group 'gnus-article-treat 1202 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles") 1203 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-custom) 1204 :type gnus-article-treat-custom)
1142 1205
1143 (defcustom gnus-treat-strip-list-identifiers 'head 1206 (defcustom gnus-treat-strip-list-identifiers 'head
1144 "Strip list identifiers from `gnus-list-identifiers`. 1207 "Strip list identifiers from `gnus-list-identifiers`.
1145 Valid values are nil, t, `head', `last', an integer or a predicate. 1208 Valid values are nil, t, `head', `first', `last', an integer or a
1146 See Info node `(gnus)Customizing Articles' for details." 1209 predicate. See Info node `(gnus)Customizing Articles'."
1147 :version "21.1" 1210 :version "21.1"
1148 :group 'gnus-article-treat 1211 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles") 1212 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom) 1213 :type gnus-article-treat-custom)
1151 1214
1152 (make-obsolete-variable 'gnus-treat-strip-pgp 1215 (make-obsolete-variable 'gnus-treat-strip-pgp
1153 "This option is obsolete in Gnus 5.10.") 1216 "This option is obsolete in Gnus 5.10.")
1154 1217
1155 (defcustom gnus-treat-strip-pem nil 1218 (defcustom gnus-treat-strip-pem nil
1156 "Strip PEM signatures. 1219 "Strip PEM signatures.
1157 Valid values are nil, t, `head', `last', an integer or a predicate. 1220 Valid values are nil, t, `head', `first', `last', an integer or a
1158 See Info node `(gnus)Customizing Articles' for details." 1221 predicate. See Info node `(gnus)Customizing Articles'."
1159 :group 'gnus-article-treat 1222 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles") 1223 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom) 1224 :type gnus-article-treat-custom)
1162 1225
1163 (defcustom gnus-treat-strip-banner t 1226 (defcustom gnus-treat-strip-banner t
1164 "Strip banners from articles. 1227 "Strip banners from articles.
1165 The banner to be stripped is specified in the `banner' group parameter. 1228 The banner to be stripped is specified in the `banner' group parameter.
1166 Valid values are nil, t, `head', `last', an integer or a predicate. 1229 Valid values are nil, t, `head', `first', `last', an integer or a
1167 See Info node `(gnus)Customizing Articles' for details." 1230 predicate. See Info node `(gnus)Customizing Articles'."
1168 :group 'gnus-article-treat 1231 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles") 1232 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom) 1233 :type gnus-article-treat-custom)
1171 1234
1172 (defcustom gnus-treat-highlight-headers 'head 1235 (defcustom gnus-treat-highlight-headers 'head
1173 "Highlight the headers. 1236 "Highlight the headers.
1174 Valid values are nil, t, `head', `last', an integer or a predicate. 1237 Valid values are nil, t, `head', `first', `last', an integer or a
1175 See Info node `(gnus)Customizing Articles' for details." 1238 predicate. See Info node `(gnus)Customizing Articles'."
1176 :group 'gnus-article-treat 1239 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles") 1240 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-head-custom) 1241 :type gnus-article-treat-head-custom)
1179 (put 'gnus-treat-highlight-headers 'highlight t) 1242 (put 'gnus-treat-highlight-headers 'highlight t)
1180 1243
1181 (defcustom gnus-treat-highlight-citation t 1244 (defcustom gnus-treat-highlight-citation t
1182 "Highlight cited text. 1245 "Highlight cited text.
1183 Valid values are nil, t, `head', `last', an integer or a predicate. 1246 Valid values are nil, t, `head', `first', `last', an integer or a
1184 See Info node `(gnus)Customizing Articles' for details." 1247 predicate. See Info node `(gnus)Customizing Articles'."
1185 :group 'gnus-article-treat 1248 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles") 1249 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom) 1250 :type gnus-article-treat-custom)
1188 (put 'gnus-treat-highlight-citation 'highlight t) 1251 (put 'gnus-treat-highlight-citation 'highlight t)
1189 1252
1190 (defcustom gnus-treat-date-ut nil 1253 (defcustom gnus-treat-date-ut nil
1191 "Display the Date in UT (GMT). 1254 "Display the Date in UT (GMT).
1192 Valid values are nil, t, `head', `last', an integer or a predicate. 1255 Valid values are nil, t, `head', `first', `last', an integer or a
1193 See Info node `(gnus)Customizing Articles' for details." 1256 predicate. See Info node `(gnus)Customizing Articles'."
1194 :group 'gnus-article-treat 1257 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles") 1258 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-head-custom) 1259 :type gnus-article-treat-head-custom)
1197 1260
1198 (defcustom gnus-treat-date-local nil 1261 (defcustom gnus-treat-date-local nil
1199 "Display the Date in the local timezone. 1262 "Display the Date in the local timezone.
1200 Valid values are nil, t, `head', `last', an integer or a predicate. 1263 Valid values are nil, t, `head', `first', `last', an integer or a
1201 See Info node `(gnus)Customizing Articles' for details." 1264 predicate. See Info node `(gnus)Customizing Articles'."
1202 :group 'gnus-article-treat 1265 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles") 1266 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-head-custom) 1267 :type gnus-article-treat-head-custom)
1205 1268
1206 (defcustom gnus-treat-date-english nil 1269 (defcustom gnus-treat-date-english nil
1207 "Display the Date in a format that can be read aloud in English. 1270 "Display the Date in a format that can be read aloud in English.
1208 Valid values are nil, t, `head', `last', an integer or a predicate. 1271 Valid values are nil, t, `head', `first', `last', an integer or a
1209 See Info node `(gnus)Customizing Articles' for details." 1272 predicate. See Info node `(gnus)Customizing Articles'."
1210 :version "22.1" 1273 :version "22.1"
1211 :group 'gnus-article-treat 1274 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles") 1275 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-head-custom) 1276 :type gnus-article-treat-head-custom)
1214 1277
1215 (defcustom gnus-treat-date-lapsed nil 1278 (defcustom gnus-treat-date-lapsed nil
1216 "Display the Date header in a way that says how much time has elapsed. 1279 "Display the Date header in a way that says how much time has elapsed.
1217 Valid values are nil, t, `head', `last', an integer or a predicate. 1280 Valid values are nil, t, `head', `first', `last', an integer or a
1218 See Info node `(gnus)Customizing Articles' for details." 1281 predicate. See Info node `(gnus)Customizing Articles'."
1219 :group 'gnus-article-treat 1282 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles") 1283 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-head-custom) 1284 :type gnus-article-treat-head-custom)
1222 1285
1223 (defcustom gnus-treat-date-original nil 1286 (defcustom gnus-treat-date-original nil
1224 "Display the date in the original timezone. 1287 "Display the date in the original timezone.
1225 Valid values are nil, t, `head', `last', an integer or a predicate. 1288 Valid values are nil, t, `head', `first', `last', an integer or a
1226 See Info node `(gnus)Customizing Articles' for details." 1289 predicate. See Info node `(gnus)Customizing Articles'."
1227 :group 'gnus-article-treat 1290 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles") 1291 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-head-custom) 1292 :type gnus-article-treat-head-custom)
1230 1293
1231 (defcustom gnus-treat-date-iso8601 nil 1294 (defcustom gnus-treat-date-iso8601 nil
1232 "Display the date in the ISO8601 format. 1295 "Display the date in the ISO8601 format.
1233 Valid values are nil, t, `head', `last', an integer or a predicate. 1296 Valid values are nil, t, `head', `first', `last', an integer or a
1234 See Info node `(gnus)Customizing Articles' for details." 1297 predicate. See Info node `(gnus)Customizing Articles'."
1235 :version "21.1" 1298 :version "21.1"
1236 :group 'gnus-article-treat 1299 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles") 1300 :link '(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-head-custom) 1301 :type gnus-article-treat-head-custom)
1239 1302
1240 (defcustom gnus-treat-date-user-defined nil 1303 (defcustom gnus-treat-date-user-defined nil
1241 "Display the date in a user-defined format. 1304 "Display the date in a user-defined format.
1242 The format is defined by the `gnus-article-time-format' variable. 1305 The format is defined by the `gnus-article-time-format' variable.
1243 Valid values are nil, t, `head', `last', an integer or a predicate. 1306 Valid values are nil, t, `head', `first', `last', an integer or a
1244 See Info node `(gnus)Customizing Articles' for details." 1307 predicate. See Info node `(gnus)Customizing Articles'."
1245 :group 'gnus-article-treat 1308 :group 'gnus-article-treat
1246 :link '(custom-manual "(gnus)Customizing Articles") 1309 :link '(custom-manual "(gnus)Customizing Articles")
1247 :type gnus-article-treat-head-custom) 1310 :type gnus-article-treat-head-custom)
1248 1311
1249 (defcustom gnus-treat-strip-headers-in-body t 1312 (defcustom gnus-treat-strip-headers-in-body t
1250 "Strip the X-No-Archive header line from the beginning of the body. 1313 "Strip the X-No-Archive header line from the beginning of the body.
1251 Valid values are nil, t, `head', `last', an integer or a predicate. 1314 Valid values are nil, t, `head', `first', `last', an integer or a
1252 See Info node `(gnus)Customizing Articles' for details." 1315 predicate. See Info node `(gnus)Customizing Articles'."
1253 :version "21.1" 1316 :version "21.1"
1254 :group 'gnus-article-treat 1317 :group 'gnus-article-treat
1255 :link '(custom-manual "(gnus)Customizing Articles") 1318 :link '(custom-manual "(gnus)Customizing Articles")
1256 :type gnus-article-treat-custom) 1319 :type gnus-article-treat-custom)
1257 1320
1258 (defcustom gnus-treat-strip-trailing-blank-lines nil 1321 (defcustom gnus-treat-strip-trailing-blank-lines nil
1259 "Strip trailing blank lines. 1322 "Strip trailing blank lines.
1260 Valid values are nil, t, `head', `last', an integer or a predicate. 1323 Valid values are nil, t, `head', `first', `last', an integer or a
1261 See Info node `(gnus)Customizing Articles' for details. 1324 predicate. See Info node `(gnus)Customizing Articles'.
1262 1325
1263 When set to t, it also strips trailing blanks in all MIME parts. 1326 When set to t, it also strips trailing blanks in all MIME parts.
1264 Consider to use `last' instead." 1327 Consider to use `last' instead."
1265 :group 'gnus-article-treat 1328 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles") 1329 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-custom) 1330 :type gnus-article-treat-custom)
1268 1331
1269 (defcustom gnus-treat-strip-leading-blank-lines nil 1332 (defcustom gnus-treat-strip-leading-blank-lines nil
1270 "Strip leading blank lines. 1333 "Strip leading blank lines.
1271 Valid values are nil, t, `head', `last', an integer or a predicate. 1334 Valid values are nil, t, `head', `first', `last', an integer or a
1272 See Info node `(gnus)Customizing Articles' for details. 1335 predicate. See Info node `(gnus)Customizing Articles'.
1273 1336
1274 When set to t, it also strips trailing blanks in all MIME parts." 1337 When set to t, it also strips trailing blanks in all MIME parts."
1275 :group 'gnus-article-treat 1338 :group 'gnus-article-treat
1276 :link '(custom-manual "(gnus)Customizing Articles") 1339 :link '(custom-manual "(gnus)Customizing Articles")
1277 :type gnus-article-treat-custom) 1340 :type gnus-article-treat-custom)
1278 1341
1279 (defcustom gnus-treat-strip-multiple-blank-lines nil 1342 (defcustom gnus-treat-strip-multiple-blank-lines nil
1280 "Strip multiple blank lines. 1343 "Strip multiple blank lines.
1281 Valid values are nil, t, `head', `last', an integer or a predicate. 1344 Valid values are nil, t, `head', `first', `last', an integer or a
1282 See Info node `(gnus)Customizing Articles' for details." 1345 predicate. See Info node `(gnus)Customizing Articles'."
1283 :group 'gnus-article-treat 1346 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles") 1347 :link '(custom-manual "(gnus)Customizing Articles")
1285 :type gnus-article-treat-custom) 1348 :type gnus-article-treat-custom)
1286 1349
1287 (defcustom gnus-treat-unfold-headers 'head 1350 (defcustom gnus-treat-unfold-headers 'head
1288 "Unfold folded header lines. 1351 "Unfold folded header lines.
1289 Valid values are nil, t, `head', `last', an integer or a predicate. 1352 Valid values are nil, t, `head', `first', `last', an integer or a
1290 See Info node `(gnus)Customizing Articles' for details." 1353 predicate. See Info node `(gnus)Customizing Articles'."
1291 :version "22.1" 1354 :version "22.1"
1292 :group 'gnus-article-treat 1355 :group 'gnus-article-treat
1293 :link '(custom-manual "(gnus)Customizing Articles") 1356 :link '(custom-manual "(gnus)Customizing Articles")
1294 :type gnus-article-treat-custom) 1357 :type gnus-article-treat-custom)
1295 1358
1359 (defcustom gnus-article-unfold-long-headers nil
1360 "If non-nil, allow unfolding headers even if the header is long.
1361 If it is a regexp, only long headers matching this regexp are unfolded.
1362 If it is t, all long headers are unfolded.
1363
1364 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1365 :version "23.0" ;; No Gnus
1366 :group 'gnus-article-treat
1367 :type '(choice (const nil)
1368 (const :tag "all" t)
1369 (regexp)))
1370
1296 (defcustom gnus-treat-fold-headers nil 1371 (defcustom gnus-treat-fold-headers nil
1297 "Fold headers. 1372 "Fold headers.
1298 Valid values are nil, t, `head', `last', an integer or a predicate. 1373 Valid values are nil, t, `head', `first', `last', an integer or a
1299 See Info node `(gnus)Customizing Articles' for details." 1374 predicate. See Info node `(gnus)Customizing Articles'."
1300 :version "22.1" 1375 :version "22.1"
1301 :group 'gnus-article-treat 1376 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles") 1377 :link '(custom-manual "(gnus)Customizing Articles")
1303 :type gnus-article-treat-custom) 1378 :type gnus-article-treat-custom)
1304 1379
1305 (defcustom gnus-treat-fold-newsgroups 'head 1380 (defcustom gnus-treat-fold-newsgroups 'head
1306 "Fold the Newsgroups and Followup-To headers. 1381 "Fold the Newsgroups and Followup-To headers.
1307 Valid values are nil, t, `head', `last', an integer or a predicate. 1382 Valid values are nil, t, `head', `first', `last', an integer or a
1308 See Info node `(gnus)Customizing Articles' for details." 1383 predicate. See Info node `(gnus)Customizing Articles'."
1309 :version "22.1" 1384 :version "22.1"
1310 :group 'gnus-article-treat 1385 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles") 1386 :link '(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-custom) 1387 :type gnus-article-treat-custom)
1313 1388
1314 (defcustom gnus-treat-overstrike t 1389 (defcustom gnus-treat-overstrike t
1315 "Treat overstrike highlighting. 1390 "Treat overstrike highlighting.
1316 Valid values are nil, t, `head', `last', an integer or a predicate. 1391 Valid values are nil, t, `head', `first', `last', an integer or a
1317 See Info node `(gnus)Customizing Articles' for details." 1392 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group 'gnus-article-treat 1393 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles") 1394 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom) 1395 :type gnus-article-treat-custom)
1321 (put 'gnus-treat-overstrike 'highlight t) 1396 (put 'gnus-treat-overstrike 'highlight t)
1397
1398 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1399 "Treat ANSI SGR control sequences.
1400 Valid values are nil, t, `head', `first', `last', an integer or a
1401 predicate. See Info node `(gnus)Customizing Articles'."
1402 :group 'gnus-article-treat
1403 :link '(custom-manual "(gnus)Customizing Articles")
1404 :type gnus-article-treat-custom)
1322 1405
1323 (make-obsolete-variable 'gnus-treat-display-xface 1406 (make-obsolete-variable 'gnus-treat-display-xface
1324 'gnus-treat-display-x-face) 1407 'gnus-treat-display-x-face)
1325 1408
1326 (defcustom gnus-treat-display-x-face 1409 (defcustom gnus-treat-display-x-face
1362 (defcustom gnus-treat-display-face 1445 (defcustom gnus-treat-display-face
1363 (and (not noninteractive) 1446 (and (not noninteractive)
1364 (gnus-image-type-available-p 'png) 1447 (gnus-image-type-available-p 'png)
1365 'head) 1448 'head)
1366 "Display Face headers. 1449 "Display Face headers.
1367 Valid values are nil, t, `head', `last', an integer or a predicate. 1450 Valid values are nil, t, `head', `first', `last', an integer or a
1368 See Info node `(gnus)Customizing Articles' and Info node 1451 predicate. See Info node `(gnus)Customizing Articles' and Info
1369 `(gnus)X-Face' for details." 1452 node `(gnus)X-Face' for details."
1370 :group 'gnus-article-treat 1453 :group 'gnus-article-treat
1371 :version "22.1" 1454 :version "22.1"
1372 :link '(custom-manual "(gnus)Customizing Articles") 1455 :link '(custom-manual "(gnus)Customizing Articles")
1373 :link '(custom-manual "(gnus)X-Face") 1456 :link '(custom-manual "(gnus)X-Face")
1374 :type gnus-article-treat-head-custom) 1457 :type gnus-article-treat-head-custom)
1375 (put 'gnus-treat-display-face 'highlight t) 1458 (put 'gnus-treat-display-face 'highlight t)
1376 1459
1377 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm) 1460 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1378 "Display smileys. 1461 "Display smileys.
1379 Valid values are nil, t, `head', `last', an integer or a predicate. 1462 Valid values are nil, t, `head', `first', `last', an integer or a
1380 See Info node `(gnus)Customizing Articles' and Info node 1463 predicate. See Info node `(gnus)Customizing Articles' and Info
1381 `(gnus)Smileys' for details." 1464 node `(gnus)Smileys' for details."
1382 :group 'gnus-article-treat 1465 :group 'gnus-article-treat
1383 :version "21.1" 1466 :version "21.1"
1384 :link '(custom-manual "(gnus)Customizing Articles") 1467 :link '(custom-manual "(gnus)Customizing Articles")
1385 :link '(custom-manual "(gnus)Smileys") 1468 :link '(custom-manual "(gnus)Smileys")
1386 :type gnus-article-treat-custom) 1469 :type gnus-article-treat-custom)
1389 (defcustom gnus-treat-from-picon 1472 (defcustom gnus-treat-from-picon
1390 (if (and (gnus-image-type-available-p 'xpm) 1473 (if (and (gnus-image-type-available-p 'xpm)
1391 (gnus-picons-installed-p)) 1474 (gnus-picons-installed-p))
1392 'head nil) 1475 'head nil)
1393 "Display picons in the From header. 1476 "Display picons in the From header.
1394 Valid values are nil, t, `head', `last', an integer or a predicate. 1477 Valid values are nil, t, `head', `first', `last', an integer or a
1395 See Info node `(gnus)Customizing Articles' and Info node 1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1396 `(gnus)Picons' for details." 1479 node `(gnus)Picons' for details."
1397 :version "22.1" 1480 :version "22.1"
1398 :group 'gnus-article-treat 1481 :group 'gnus-article-treat
1399 :group 'gnus-picon 1482 :group 'gnus-picon
1400 :link '(custom-manual "(gnus)Customizing Articles") 1483 :link '(custom-manual "(gnus)Customizing Articles")
1401 :link '(custom-manual "(gnus)Picons") 1484 :link '(custom-manual "(gnus)Picons")
1405 (defcustom gnus-treat-mail-picon 1488 (defcustom gnus-treat-mail-picon
1406 (if (and (gnus-image-type-available-p 'xpm) 1489 (if (and (gnus-image-type-available-p 'xpm)
1407 (gnus-picons-installed-p)) 1490 (gnus-picons-installed-p))
1408 'head nil) 1491 'head nil)
1409 "Display picons in To and Cc headers. 1492 "Display picons in To and Cc headers.
1410 Valid values are nil, t, `head', `last', an integer or a predicate. 1493 Valid values are nil, t, `head', `first', `last', an integer or a
1411 See Info node `(gnus)Customizing Articles' and Info node 1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1412 `(gnus)Picons' for details." 1495 node `(gnus)Picons' for details."
1413 :version "22.1" 1496 :version "22.1"
1414 :group 'gnus-article-treat 1497 :group 'gnus-article-treat
1415 :group 'gnus-picon 1498 :group 'gnus-picon
1416 :link '(custom-manual "(gnus)Customizing Articles") 1499 :link '(custom-manual "(gnus)Customizing Articles")
1417 :link '(custom-manual "(gnus)Picons") 1500 :link '(custom-manual "(gnus)Picons")
1421 (defcustom gnus-treat-newsgroups-picon 1504 (defcustom gnus-treat-newsgroups-picon
1422 (if (and (gnus-image-type-available-p 'xpm) 1505 (if (and (gnus-image-type-available-p 'xpm)
1423 (gnus-picons-installed-p)) 1506 (gnus-picons-installed-p))
1424 'head nil) 1507 'head nil)
1425 "Display picons in the Newsgroups and Followup-To headers. 1508 "Display picons in the Newsgroups and Followup-To headers.
1426 Valid values are nil, t, `head', `last', an integer or a predicate. 1509 Valid values are nil, t, `head', `first', `last', an integer or a
1427 See Info node `(gnus)Customizing Articles' and Info node 1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1428 `(gnus)Picons' for details." 1511 node `(gnus)Picons' for details."
1429 :version "22.1" 1512 :version "22.1"
1430 :group 'gnus-article-treat 1513 :group 'gnus-article-treat
1431 :group 'gnus-picon 1514 :group 'gnus-picon
1432 :link '(custom-manual "(gnus)Customizing Articles") 1515 :link '(custom-manual "(gnus)Customizing Articles")
1433 :link '(custom-manual "(gnus)Picons") 1516 :link '(custom-manual "(gnus)Picons")
1434 :type gnus-article-treat-head-custom) 1517 :type gnus-article-treat-head-custom)
1435 (put 'gnus-treat-newsgroups-picon 'highlight t) 1518 (put 'gnus-treat-newsgroups-picon 'highlight t)
1436 1519
1437 (defcustom gnus-treat-body-boundary 1520 (defcustom gnus-treat-body-boundary
1438 (if (or gnus-treat-newsgroups-picon 1521 (if (and (eq window-system 'x)
1439 gnus-treat-mail-picon 1522 (or gnus-treat-newsgroups-picon
1440 gnus-treat-from-picon) 1523 gnus-treat-mail-picon
1524 gnus-treat-from-picon))
1441 'head nil) 1525 'head nil)
1442 "Draw a boundary at the end of the headers. 1526 "Draw a boundary at the end of the headers.
1443 Valid values are nil and `head'. 1527 Valid values are nil and `head'.
1444 See Info node `(gnus)Customizing Articles' for details." 1528 See Info node `(gnus)Customizing Articles' for details."
1445 :version "22.1" 1529 :version "22.1"
1447 :link '(custom-manual "(gnus)Customizing Articles") 1531 :link '(custom-manual "(gnus)Customizing Articles")
1448 :type gnus-article-treat-head-custom) 1532 :type gnus-article-treat-head-custom)
1449 1533
1450 (defcustom gnus-treat-capitalize-sentences nil 1534 (defcustom gnus-treat-capitalize-sentences nil
1451 "Capitalize sentence-starting words. 1535 "Capitalize sentence-starting words.
1452 Valid values are nil, t, `head', `last', an integer or a predicate. 1536 Valid values are nil, t, `head', `first', `last', an integer or a
1453 See Info node `(gnus)Customizing Articles' for details." 1537 predicate. See Info node `(gnus)Customizing Articles'."
1454 :version "21.1" 1538 :version "21.1"
1455 :group 'gnus-article-treat 1539 :group 'gnus-article-treat
1456 :link '(custom-manual "(gnus)Customizing Articles") 1540 :link '(custom-manual "(gnus)Customizing Articles")
1457 :type gnus-article-treat-custom) 1541 :type gnus-article-treat-custom)
1458 1542
1459 (defcustom gnus-treat-wash-html nil 1543 (defcustom gnus-treat-wash-html nil
1460 "Format as HTML. 1544 "Format as HTML.
1461 Valid values are nil, t, `head', `last', an integer or a predicate. 1545 Valid values are nil, t, `head', `first', `last', an integer or a
1462 See Info node `(gnus)Customizing Articles' for details." 1546 predicate. See Info node `(gnus)Customizing Articles'."
1463 :version "22.1" 1547 :version "22.1"
1464 :group 'gnus-article-treat 1548 :group 'gnus-article-treat
1465 :link '(custom-manual "(gnus)Customizing Articles") 1549 :link '(custom-manual "(gnus)Customizing Articles")
1466 :type gnus-article-treat-custom) 1550 :type gnus-article-treat-custom)
1467 1551
1468 (defcustom gnus-treat-fill-long-lines nil 1552 (defcustom gnus-treat-fill-long-lines nil
1469 "Fill long lines. 1553 "Fill long lines.
1470 Valid values are nil, t, `head', `last', an integer or a predicate. 1554 Valid values are nil, t, `head', `first', `last', an integer or a
1471 See Info node `(gnus)Customizing Articles' for details." 1555 predicate. See Info node `(gnus)Customizing Articles'."
1472 :group 'gnus-article-treat 1556 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles") 1557 :link '(custom-manual "(gnus)Customizing Articles")
1474 :type gnus-article-treat-custom) 1558 :type gnus-article-treat-custom)
1475 1559
1476 (defcustom gnus-treat-play-sounds nil 1560 (defcustom gnus-treat-play-sounds nil
1477 "Play sounds. 1561 "Play sounds.
1478 Valid values are nil, t, `head', `last', an integer or a predicate. 1562 Valid values are nil, t, `head', `first', `last', an integer or a
1479 See Info node `(gnus)Customizing Articles' for details." 1563 predicate. See Info node `(gnus)Customizing Articles'."
1480 :version "21.1" 1564 :version "21.1"
1481 :group 'gnus-article-treat 1565 :group 'gnus-article-treat
1482 :link '(custom-manual "(gnus)Customizing Articles") 1566 :link '(custom-manual "(gnus)Customizing Articles")
1483 :type gnus-article-treat-custom) 1567 :type gnus-article-treat-custom)
1484 1568
1485 (defcustom gnus-treat-translate nil 1569 (defcustom gnus-treat-translate nil
1486 "Translate articles from one language to another. 1570 "Translate articles from one language to another.
1487 Valid values are nil, t, `head', `last', an integer or a predicate. 1571 Valid values are nil, t, `head', `first', `last', an integer or a
1488 See Info node `(gnus)Customizing Articles' for details." 1572 predicate. See Info node `(gnus)Customizing Articles'."
1489 :version "21.1" 1573 :version "21.1"
1490 :group 'gnus-article-treat 1574 :group 'gnus-article-treat
1491 :link '(custom-manual "(gnus)Customizing Articles") 1575 :link '(custom-manual "(gnus)Customizing Articles")
1492 :type gnus-article-treat-custom) 1576 :type gnus-article-treat-custom)
1493 1577
1494 (defcustom gnus-treat-x-pgp-sig nil 1578 (defcustom gnus-treat-x-pgp-sig nil
1495 "Verify X-PGP-Sig. 1579 "Verify X-PGP-Sig.
1496 To automatically treat X-PGP-Sig, set it to head. 1580 To automatically treat X-PGP-Sig, set it to head.
1497 Valid values are nil, t, `head', `last', an integer or a predicate. 1581 Valid values are nil, t, `head', `first', `last', an integer or a
1498 See Info node `(gnus)Customizing Articles' for details." 1582 predicate. See Info node `(gnus)Customizing Articles'."
1499 :version "22.1" 1583 :version "22.1"
1500 :group 'gnus-article-treat 1584 :group 'gnus-article-treat
1501 :group 'mime-security 1585 :group 'mime-security
1502 :link '(custom-manual "(gnus)Customizing Articles") 1586 :link '(custom-manual "(gnus)Customizing Articles")
1503 :type gnus-article-treat-custom) 1587 :type gnus-article-treat-custom)
1579 (gnus-treat-strip-leading-blank-lines 1663 (gnus-treat-strip-leading-blank-lines
1580 gnus-article-strip-leading-blank-lines) 1664 gnus-article-strip-leading-blank-lines)
1581 (gnus-treat-strip-multiple-blank-lines 1665 (gnus-treat-strip-multiple-blank-lines
1582 gnus-article-strip-multiple-blank-lines) 1666 gnus-article-strip-multiple-blank-lines)
1583 (gnus-treat-overstrike gnus-article-treat-overstrike) 1667 (gnus-treat-overstrike gnus-article-treat-overstrike)
1668 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1584 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers) 1669 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1670 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1585 (gnus-treat-fold-headers gnus-article-treat-fold-headers) 1671 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1586 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1587 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head) 1672 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1588 (gnus-treat-display-smileys gnus-treat-smiley) 1673 (gnus-treat-display-smileys gnus-treat-smiley)
1589 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences) 1674 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1590 (gnus-treat-wash-html gnus-article-wash-html) 1675 (gnus-treat-wash-html gnus-article-wash-html)
1591 (gnus-treat-emphasize gnus-article-emphasize) 1676 (gnus-treat-emphasize gnus-article-emphasize)
1812 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) 1897 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1813 (not gnus-show-all-headers)) 1898 (not gnus-show-all-headers))
1814 (save-excursion 1899 (save-excursion
1815 (save-restriction 1900 (save-restriction
1816 (let ((inhibit-read-only t) 1901 (let ((inhibit-read-only t)
1817 (list gnus-boring-article-headers) 1902 (inhibit-point-motion-hooks t))
1818 (inhibit-point-motion-hooks t)
1819 elem)
1820 (article-narrow-to-head) 1903 (article-narrow-to-head)
1821 (while list 1904 (dolist (elem gnus-boring-article-headers)
1822 (setq elem (pop list))
1823 (goto-char (point-min)) 1905 (goto-char (point-min))
1824 (cond 1906 (cond
1825 ;; Hide empty headers. 1907 ;; Hide empty headers.
1826 ((eq elem 'empty) 1908 ((eq elem 'empty)
1827 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t) 1909 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1828 (forward-line -1) 1910 (forward-line -1)
1829 (gnus-article-hide-text-type 1911 (gnus-article-hide-text-type
1830 (gnus-point-at-bol) 1912 (point-at-bol)
1831 (progn 1913 (progn
1832 (end-of-line) 1914 (end-of-line)
1833 (if (re-search-forward "^[^ \t]" nil t) 1915 (if (re-search-forward "^[^ \t]" nil t)
1834 (match-beginning 0) 1916 (match-beginning 0)
1835 (point-max))) 1917 (point-max)))
1955 (defun gnus-article-hide-header (header) 2037 (defun gnus-article-hide-header (header)
1956 (save-excursion 2038 (save-excursion
1957 (goto-char (point-min)) 2039 (goto-char (point-min))
1958 (when (re-search-forward (concat "^" header ":") nil t) 2040 (when (re-search-forward (concat "^" header ":") nil t)
1959 (gnus-article-hide-text-type 2041 (gnus-article-hide-text-type
1960 (gnus-point-at-bol) 2042 (point-at-bol)
1961 (progn 2043 (progn
1962 (end-of-line) 2044 (end-of-line)
1963 (if (re-search-forward "^[^ \t]" nil t) 2045 (if (re-search-forward "^[^ \t]" nil t)
1964 (match-beginning 0) 2046 (match-beginning 0)
1965 (point-max))) 2047 (point-max)))
1976 (save-excursion 2058 (save-excursion
1977 (save-restriction 2059 (save-restriction
1978 (article-narrow-to-head) 2060 (article-narrow-to-head)
1979 (while (not (eobp)) 2061 (while (not (eobp))
1980 (cond 2062 (cond
1981 ((< (setq column (- (gnus-point-at-eol) (point))) 2063 ((< (setq column (- (point-at-eol) (point)))
1982 gnus-article-normalized-header-length) 2064 gnus-article-normalized-header-length)
1983 (end-of-line) 2065 (end-of-line)
1984 (insert (make-string 2066 (insert (make-string
1985 (- gnus-article-normalized-header-length column) 2067 (- gnus-article-normalized-header-length column)
1986 ? ))) 2068 ? )))
1987 ((> column gnus-article-normalized-header-length) 2069 ((> column gnus-article-normalized-header-length)
1988 (gnus-put-text-property 2070 (gnus-put-text-property
1989 (progn 2071 (progn
1990 (forward-char gnus-article-normalized-header-length) 2072 (forward-char gnus-article-normalized-header-length)
1991 (point)) 2073 (point))
1992 (gnus-point-at-eol) 2074 (point-at-eol)
1993 'invisible t)) 2075 'invisible t))
1994 (t 2076 (t
1995 ;; Do nothing. 2077 ;; Do nothing.
1996 )) 2078 ))
1997 (forward-line 1)))))) 2079 (forward-line 1))))))
2029 (defun article-translate-strings (map) 2111 (defun article-translate-strings (map)
2030 "Translate all string in the body of the article according to MAP. 2112 "Translate all string in the body of the article according to MAP.
2031 MAP is an alist where the elements are on the form (\"from\" \"to\")." 2113 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2032 (save-excursion 2114 (save-excursion
2033 (when (article-goto-body) 2115 (when (article-goto-body)
2034 (let ((inhibit-read-only t) 2116 (let ((inhibit-read-only t))
2035 elem) 2117 (dolist (elem map)
2036 (while (setq elem (pop map))
2037 (save-excursion 2118 (save-excursion
2038 (while (search-forward (car elem) nil t) 2119 (while (search-forward (car elem) nil t)
2039 (replace-match (cadr elem))))))))) 2120 (replace-match (cadr elem)))))))))
2040 2121
2041 (defun article-treat-overstrike () 2122 (defun article-treat-overstrike ()
2062 ((eq previous ?_) 2143 ((eq previous ?_)
2063 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) 2144 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2064 (put-text-property 2145 (put-text-property
2065 (point) (1+ (point)) 'face 'underline))))))))) 2146 (point) (1+ (point)) 'face 'underline)))))))))
2066 2147
2148 (defun article-treat-ansi-sequences ()
2149 "Translate ANSI SGR control sequences into overlays or extents."
2150 (interactive)
2151 (save-excursion
2152 (when (article-goto-body)
2153 (let ((inhibit-read-only t))
2154 (ansi-color-apply-on-region (point) (point-max))))))
2155
2067 (defun gnus-article-treat-unfold-headers () 2156 (defun gnus-article-treat-unfold-headers ()
2068 "Unfold folded message headers. 2157 "Unfold folded message headers.
2069 Only the headers that fit into the current window width will be 2158 Only the headers that fit into the current window width will be
2070 unfolded." 2159 unfolded."
2071 (interactive) 2160 (interactive)
2072 (gnus-with-article-headers 2161 (gnus-with-article-headers
2073 (let (length) 2162 (let (length)
2074 (while (not (eobp)) 2163 (while (not (eobp))
2075 (save-restriction 2164 (save-restriction
2076 (mail-header-narrow-to-field) 2165 (mail-header-narrow-to-field)
2077 (let ((header (buffer-string))) 2166 (let* ((header (buffer-string))
2167 (unfoldable
2168 (or (equal gnus-article-unfold-long-headers t)
2169 (and (stringp gnus-article-unfold-long-headers)
2170 (string-match gnus-article-unfold-long-headers header)))))
2078 (with-temp-buffer 2171 (with-temp-buffer
2079 (insert header) 2172 (insert header)
2080 (goto-char (point-min)) 2173 (goto-char (point-min))
2081 (while (re-search-forward "\n[\t ]" nil t) 2174 (while (re-search-forward "\n[\t ]" nil t)
2082 (replace-match " " t t))) 2175 (replace-match " " t t)))
2083 (setq length (- (point-max) (point-min) 1))) 2176 (setq length (- (point-max) (point-min) 1))
2084 (when (< length (window-width)) 2177 (when (or unfoldable
2085 (while (re-search-forward "\n[\t ]" nil t) 2178 (< length (window-width)))
2086 (replace-match " " t t))) 2179 (while (re-search-forward "\n[\t ]" nil t)
2180 (replace-match " " t t))))
2087 (goto-char (point-max))))))) 2181 (goto-char (point-max)))))))
2088 2182
2089 (defun gnus-article-treat-fold-headers () 2183 (defun gnus-article-treat-fold-headers ()
2090 "Fold message headers." 2184 "Fold message headers."
2091 (interactive) 2185 (interactive)
2127 (mail-header-narrow-to-field) 2221 (mail-header-narrow-to-field)
2128 (while (re-search-forward ", *" nil t) 2222 (while (re-search-forward ", *" nil t)
2129 (replace-match ", " t t)) 2223 (replace-match ", " t t))
2130 (mail-header-fold-field) 2224 (mail-header-fold-field)
2131 (goto-char (point-max)))))) 2225 (goto-char (point-max))))))
2226
2227 (defcustom gnus-article-truncate-lines default-truncate-lines
2228 "Value of `truncate-lines' in Gnus Article buffer.
2229 Valid values are nil, t, `head', `first', `last', an integer or a
2230 predicate. See Info node `(gnus)Customizing Articles'."
2231 :version "23.0" ;; No Gnus
2232 :group 'gnus-article
2233 ;; :link '(custom-manual "(gnus)Customizing Articles")
2234 :type 'boolean)
2235
2236 (defun gnus-article-toggle-truncate-lines (&optional arg)
2237 "Toggle whether to fold or truncate long lines in article the buffer.
2238 If ARG is non-nil and not a number, toggle
2239 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2240 long lines iff arg is positive."
2241 (interactive "P")
2242 (cond
2243 ((and (numberp arg) (> arg 0))
2244 (setq gnus-article-truncate-lines t))
2245 ((numberp arg)
2246 (setq gnus-article-truncate-lines nil))
2247 (arg
2248 (setq gnus-article-truncate-lines
2249 (not gnus-article-truncate-lines))))
2250 (gnus-with-article-buffer
2251 (cond
2252 ((and (numberp arg) (> arg 0))
2253 (setq truncate-lines nil))
2254 ((numberp arg)
2255 (setq truncate-lines t)))
2256 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2257 ;; `toggle-truncate-lines' needs an argument.
2258 (toggle-truncate-lines)))
2132 2259
2133 (defun gnus-article-treat-body-boundary () 2260 (defun gnus-article-treat-body-boundary ()
2134 "Place a boundary line at the end of the headers." 2261 "Place a boundary line at the end of the headers."
2135 (interactive) 2262 (interactive)
2136 (when (and gnus-body-boundary-delimiter 2263 (when (and gnus-body-boundary-delimiter
2158 (let ((adaptive-fill-mode nil)) ;Why? -sm 2285 (let ((adaptive-fill-mode nil)) ;Why? -sm
2159 (while (not (eobp)) 2286 (while (not (eobp))
2160 (end-of-line) 2287 (end-of-line)
2161 (when (>= (current-column) (min fill-column width)) 2288 (when (>= (current-column) (min fill-column width))
2162 (narrow-to-region (min (1+ (point)) (point-max)) 2289 (narrow-to-region (min (1+ (point)) (point-max))
2163 (gnus-point-at-bol)) 2290 (point-at-bol))
2164 (let ((goback (point-marker))) 2291 (let ((goback (point-marker)))
2165 (fill-paragraph nil) 2292 (fill-paragraph nil)
2166 (goto-char (marker-position goback))) 2293 (goto-char (marker-position goback)))
2167 (widen)) 2294 (widen))
2168 (forward-line 1))))))) 2295 (forward-line 1)))))))
2200 (point) 2327 (point)
2201 (progn 2328 (progn
2202 (while (and (not (bobp)) 2329 (while (and (not (bobp))
2203 (looking-at "^[ \t]*$") 2330 (looking-at "^[ \t]*$")
2204 (not (gnus-annotation-in-region-p 2331 (not (gnus-annotation-in-region-p
2205 (point) (gnus-point-at-eol)))) 2332 (point) (point-at-eol))))
2206 (forward-line -1)) 2333 (forward-line -1))
2207 (forward-line 1) 2334 (forward-line 1)
2208 (point)))))) 2335 (point))))))
2336
2337 (eval-when-compile
2338 (defvar gnus-face-properties-alist))
2209 2339
2210 (defun article-display-face () 2340 (defun article-display-face ()
2211 "Display any Face headers in the header." 2341 "Display any Face headers in the header."
2212 (interactive) 2342 (interactive)
2213 (let ((wash-face-p buffer-read-only)) 2343 (let ((wash-face-p buffer-read-only))
2237 (insert "From:") 2367 (insert "From:")
2238 (setq from (point)) 2368 (setq from (point))
2239 (insert "[no `from' set]\n")) 2369 (insert "[no `from' set]\n"))
2240 (while faces 2370 (while faces
2241 (when (setq png (gnus-convert-face-to-png (pop faces))) 2371 (when (setq png (gnus-convert-face-to-png (pop faces)))
2242 (setq image (gnus-create-image png 'png t)) 2372 (setq image
2373 (apply 'gnus-create-image png 'png t
2374 (cdr (assq 'png gnus-face-properties-alist))))
2243 (goto-char from) 2375 (goto-char from)
2244 (gnus-add-wash-type 'face) 2376 (gnus-add-wash-type 'face)
2245 (gnus-add-image 'face image) 2377 (gnus-add-image 'face image)
2246 (gnus-put-image image nil 'face)))))))))) 2378 (gnus-put-image image nil 'face))))))))))
2247 2379
2309 gnus-article-x-face-command)))))))))) 2441 gnus-article-x-face-command))))))))))
2310 2442
2311 (defun article-decode-mime-words () 2443 (defun article-decode-mime-words ()
2312 "Decode all MIME-encoded words in the article." 2444 "Decode all MIME-encoded words in the article."
2313 (interactive) 2445 (interactive)
2314 (save-excursion 2446 (gnus-with-article-buffer
2315 (set-buffer gnus-article-buffer)
2316 (let ((inhibit-point-motion-hooks t) 2447 (let ((inhibit-point-motion-hooks t)
2317 (inhibit-read-only t)
2318 (mail-parse-charset gnus-newsgroup-charset) 2448 (mail-parse-charset gnus-newsgroup-charset)
2319 (mail-parse-ignored-charsets 2449 (mail-parse-ignored-charsets
2320 (save-excursion (set-buffer gnus-summary-buffer) 2450 (with-current-buffer gnus-summary-buffer
2321 gnus-newsgroup-ignored-charsets))) 2451 gnus-newsgroup-ignored-charsets)))
2322 (mail-decode-encoded-word-region (point-min) (point-max))))) 2452 (mail-decode-encoded-word-region (point-min) (point-max)))))
2323 2453
2324 (defun article-decode-charset (&optional prompt) 2454 (defun article-decode-charset (&optional prompt)
2325 "Decode charset-encoded text in the article. 2455 "Decode charset-encoded text in the article.
2326 If PROMPT (the prefix), prompt for a coding system to use." 2456 If PROMPT (the prefix), prompt for a coding system to use."
2393 (funcall gnus-decode-address-function start end) 2523 (funcall gnus-decode-address-function start end)
2394 (funcall gnus-decode-header-function start end)) 2524 (funcall gnus-decode-header-function start end))
2395 (goto-char (setq end start))))) 2525 (goto-char (setq end start)))))
2396 2526
2397 (defun article-decode-group-name () 2527 (defun article-decode-group-name ()
2398 "Decode group names in `Newsgroups:'." 2528 "Decode group names in Newsgroups, Followup-To and Xref headers."
2399 (let ((inhibit-point-motion-hooks t) 2529 (let ((inhibit-point-motion-hooks t)
2400 (inhibit-read-only t) 2530 (inhibit-read-only t)
2401 (method (gnus-find-method-for-group gnus-newsgroup-name))) 2531 (method (gnus-find-method-for-group gnus-newsgroup-name))
2532 regexp)
2402 (when (and (or gnus-group-name-charset-method-alist 2533 (when (and (or gnus-group-name-charset-method-alist
2403 gnus-group-name-charset-group-alist) 2534 gnus-group-name-charset-group-alist)
2404 (gnus-buffer-live-p gnus-original-article-buffer)) 2535 (gnus-buffer-live-p gnus-original-article-buffer))
2405 (save-restriction 2536 (save-restriction
2406 (article-narrow-to-head) 2537 (article-narrow-to-head)
2407 (with-current-buffer gnus-original-article-buffer 2538 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2408 (goto-char (point-min))) 2539 (with-current-buffer gnus-original-article-buffer
2409 (while (re-search-forward 2540 (goto-char (point-min)))
2410 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t) 2541 (setq regexp (concat "^" header
2411 (replace-match (save-match-data 2542 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2412 (gnus-decode-newsgroups 2543 (while (re-search-forward regexp nil t)
2413 ;; XXX how to use data in article buffer? 2544 (replace-match (save-match-data
2414 (with-current-buffer gnus-original-article-buffer 2545 (gnus-decode-newsgroups
2415 (re-search-forward 2546 ;; XXX how to use data in article buffer?
2416 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" 2547 (with-current-buffer gnus-original-article-buffer
2417 nil t) 2548 (re-search-forward regexp nil t)
2418 (match-string 1)) 2549 (match-string 1))
2419 gnus-newsgroup-name method)) 2550 gnus-newsgroup-name method))
2420 t t nil 1)) 2551 t t nil 1))
2421 (goto-char (point-min)) 2552 (goto-char (point-min)))))))
2422 (with-current-buffer gnus-original-article-buffer
2423 (goto-char (point-min)))
2424 (while (re-search-forward
2425 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2426 (replace-match (save-match-data
2427 (gnus-decode-newsgroups
2428 ;; XXX how to use data in article buffer?
2429 (with-current-buffer gnus-original-article-buffer
2430 (re-search-forward
2431 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2432 nil t)
2433 (match-string 1))
2434 gnus-newsgroup-name method))
2435 t t nil 1))))))
2436 2553
2437 (autoload 'idna-to-unicode "idna") 2554 (autoload 'idna-to-unicode "idna")
2438 2555
2439 (defun article-decode-idna-rhs () 2556 (defun article-decode-idna-rhs ()
2440 "Decode IDNA strings in RHS in various headers in current buffer. 2557 "Decode IDNA strings in RHS in various headers in current buffer.
2626 (point-min) (point-max) 2743 (point-min) (point-max)
2627 "w3m" t t nil "-dump" "-T" "text/html" 2744 "w3m" t t nil "-dump" "-T" "text/html"
2628 "-I" (symbol-name charset) "-O" (symbol-name charset)))) 2745 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2629 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html"))) 2746 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2630 2747
2748 (defvar gnus-article-browse-html-temp-list nil
2749 "List of temporary files created by `gnus-article-browse-html-parts'.
2750 Internal variable.")
2751
2752 (defcustom gnus-article-browse-delete-temp 'ask
2753 "What to do with temporary files from `gnus-article-browse-html-parts'.
2754 If nil, don't delete temporary files. If it is t, delete them on
2755 exit from the summary buffer. If it is the symbol `file', query
2756 on each file, if it is `ask' ask once when exiting from the
2757 summary buffer."
2758 :group 'gnus-article
2759 :version "23.0" ;; No Gnus
2760 :type '(choice (const :tag "Don't delete" nil)
2761 (const :tag "Don't ask" t)
2762 (const :tag "Ask" ask)
2763 (const :tag "Ask for each file" file)))
2764
2765 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2766
2767 (defun gnus-article-browse-delete-temp-files (&optional how)
2768 "Delete temp-files created by `gnus-article-browse-html-parts'."
2769 (when (and gnus-article-browse-html-temp-list
2770 (or how
2771 (setq how gnus-article-browse-delete-temp)))
2772 (when (and (eq how 'ask)
2773 (y-or-n-p (format
2774 "Delete all %s temporary HTML file(s)? "
2775 (length gnus-article-browse-html-temp-list)))
2776 (setq how t)))
2777 (dolist (file gnus-article-browse-html-temp-list)
2778 (when (and (file-exists-p file)
2779 (or (eq how t)
2780 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2781 (gnus-y-or-n-p
2782 (format "Delete temporary HTML file `%s'? " file))))
2783 (delete-file file)))
2784 ;; Also remove file from the list when not deleted or if file doesn't
2785 ;; exist anymore.
2786 (setq gnus-article-browse-html-temp-list nil))
2787 gnus-article-browse-html-temp-list)
2788
2789 (defun gnus-article-browse-html-parts (list)
2790 "View all \"text/html\" parts from LIST.
2791 Recurse into multiparts."
2792 ;; Internal function used by `gnus-article-browse-html-article'.
2793 (let ((showed))
2794 ;; Find and show the html-parts.
2795 (dolist (handle list)
2796 ;; If HTML, show it:
2797 (when (listp handle)
2798 (cond ((and (bufferp (car handle))
2799 (string-match "text/html" (car (mm-handle-type handle))))
2800 (let ((tmp-file (mm-make-temp-file
2801 ;; Do we need to care for 8.3 filenames?
2802 "mm-" nil ".html")))
2803 (mm-save-part-to-file handle tmp-file)
2804 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2805 (add-hook 'gnus-summary-prepare-exit-hook
2806 'gnus-article-browse-delete-temp-files)
2807 (add-hook 'gnus-exit-gnus-hook
2808 (lambda ()
2809 (gnus-article-browse-delete-temp-files t)))
2810 ;; FIXME: Warn if there's an <img> tag?
2811 (browse-url-of-file tmp-file)
2812 (setq showed t)))
2813 ;; If multipart, recurse
2814 ((and (stringp (car handle))
2815 (string-match "^multipart/" (car handle))
2816 (setq showed
2817 (or showed
2818 (gnus-article-browse-html-parts handle))))))))
2819 showed))
2820
2821 ;; FIXME: Documentation in texi/gnus.texi missing.
2822 (defun gnus-article-browse-html-article ()
2823 "View \"text/html\" parts of the current article with a WWW browser.
2824
2825 Warning: Spammers use links to images in HTML articles to verify
2826 whether you have read the message. As
2827 `gnus-article-browse-html-article' passes the unmodified HTML
2828 content to the browser without eliminating these \"web bugs\" you
2829 should only use it for mails from trusted senders."
2830 ;; Cf. `mm-w3m-safe-url-regexp'
2831 (interactive)
2832 (save-window-excursion
2833 ;; Open raw article and select the buffer
2834 (gnus-summary-show-article t)
2835 (gnus-summary-select-article-buffer)
2836 (let ((parts (mm-dissect-buffer t t)))
2837 ;; If singlepart, enforce a list.
2838 (when (and (bufferp (car parts))
2839 (stringp (car (mm-handle-type parts))))
2840 (setq parts (list parts)))
2841 ;; Process the list
2842 (unless (gnus-article-browse-html-parts parts)
2843 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2844 (gnus-summary-show-article))))
2845
2631 (defun article-hide-list-identifiers () 2846 (defun article-hide-list-identifiers ()
2632 "Remove list identifies from the Subject header. 2847 "Remove list identifies from the Subject header.
2633 The `gnus-list-identifiers' variable specifies what to do." 2848 The `gnus-list-identifiers' variable specifies what to do."
2634 (interactive) 2849 (interactive)
2635 (let ((inhibit-point-motion-hooks t) 2850 (let ((inhibit-point-motion-hooks t)
2730 2945
2731 (defun article-babel () 2946 (defun article-babel ()
2732 "Translate article using an online translation service." 2947 "Translate article using an online translation service."
2733 (interactive) 2948 (interactive)
2734 (require 'babel) 2949 (require 'babel)
2735 (save-excursion 2950 (gnus-with-article-buffer
2736 (set-buffer gnus-article-buffer)
2737 (when (article-goto-body) 2951 (when (article-goto-body)
2738 (let* ((inhibit-read-only t) 2952 (let* ((start (point))
2739 (start (point))
2740 (end (point-max)) 2953 (end (point-max))
2741 (orig (buffer-substring start end)) 2954 (orig (buffer-substring start end))
2742 (trans (babel-as-string orig))) 2955 (trans (babel-as-string orig)))
2743 (save-restriction 2956 (save-restriction
2744 (narrow-to-region start end) 2957 (narrow-to-region start end)
3005 (narrow-to-region pos (or (text-property-any pos (point-max) 3218 (narrow-to-region pos (or (text-property-any pos (point-max)
3006 'original-date nil) 3219 'original-date nil)
3007 (point-max))) 3220 (point-max)))
3008 (goto-char (point-min)) 3221 (goto-char (point-min))
3009 (when (re-search-forward tdate-regexp nil t) 3222 (when (re-search-forward tdate-regexp nil t)
3010 (setq bface (get-text-property (gnus-point-at-bol) 'face) 3223 (setq bface (get-text-property (point-at-bol) 'face)
3011 eface (get-text-property (1- (gnus-point-at-eol)) 'face))) 3224 eface (get-text-property (1- (point-at-eol)) 'face)))
3012 (goto-char (point-min)) 3225 (goto-char (point-min))
3013 (setq pos nil) 3226 (setq pos nil)
3014 ;; Delete any old Date headers. 3227 ;; Delete any old Date headers.
3015 (while (re-search-forward date-regexp nil t) 3228 (while (re-search-forward date-regexp nil t)
3016 (if pos 3229 (if pos
3017 (delete-region (gnus-point-at-bol) 3230 (delete-region (point-at-bol) (progn
3018 (progn 3231 (gnus-article-forward-header)
3019 (gnus-article-forward-header) 3232 (point)))
3020 (point))) 3233 (delete-region (point-at-bol) (progn
3021 (delete-region (gnus-point-at-bol) 3234 (gnus-article-forward-header)
3022 (progn 3235 (forward-char -1)
3023 (gnus-article-forward-header) 3236 (point)))
3024 (forward-char -1)
3025 (point)))
3026 (setq pos (point)))) 3237 (setq pos (point))))
3027 (when (and (not pos) 3238 (when (and (not pos)
3028 (re-search-forward tdate-regexp nil t)) 3239 (re-search-forward tdate-regexp nil t))
3029 (forward-line 1)) 3240 (forward-line 1))
3030 (gnus-goto-char pos) 3241 (gnus-goto-char pos)
3050 (condition-case () 3261 (condition-case ()
3051 (let ((time (date-to-time date))) 3262 (let ((time (date-to-time date)))
3052 (cond 3263 (cond
3053 ;; Convert to the local timezone. 3264 ;; Convert to the local timezone.
3054 ((eq type 'local) 3265 ((eq type 'local)
3055 (let ((tz (car (current-time-zone time)))) 3266 (concat "Date: " (message-make-date time)))
3056 (format "Date: %s %s%02d%02d" (current-time-string time)
3057 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3058 (/ (% (abs tz) 3600) 60))))
3059 ;; Convert to Universal Time. 3267 ;; Convert to Universal Time.
3060 ((eq type 'ut) 3268 ((eq type 'ut)
3061 (concat "Date: " 3269 (concat "Date: "
3062 (current-time-string 3270 (substring
3063 (let* ((e (parse-time-string date)) 3271 (message-make-date
3064 (tm (apply 'encode-time e)) 3272 (let* ((e (parse-time-string date))
3065 (ms (car tm)) 3273 (tm (apply 'encode-time e))
3066 (ls (- (cadr tm) (car (current-time-zone time))))) 3274 (ms (car tm))
3067 (cond ((< ls 0) (list (1- ms) (+ ls 65536))) 3275 (ls (- (cadr tm) (car (current-time-zone time)))))
3068 ((> ls 65535) (list (1+ ms) (- ls 65536))) 3276 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3069 (t (list ms ls))))) 3277 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3070 " UT")) 3278 (t (list ms ls)))))
3279 0 -5)
3280 "UT"))
3071 ;; Get the original date from the article. 3281 ;; Get the original date from the article.
3072 ((eq type 'original) 3282 ((eq type 'original)
3073 (concat "Date: " (if (string-match "\n+$" date) 3283 (concat "Date: " (if (string-match "\n+$" date)
3074 (substring date 0 (match-beginning 0)) 3284 (substring date 0 (match-beginning 0))
3075 date))) 3285 date)))
3206 (interactive "p") 3416 (interactive "p")
3207 (unless n 3417 (unless n
3208 (setq n 1)) 3418 (setq n 1))
3209 (gnus-stop-date-timer) 3419 (gnus-stop-date-timer)
3210 (setq article-lapsed-timer 3420 (setq article-lapsed-timer
3211 (nnheader-run-at-time 1 n 'article-update-date-lapsed))) 3421 (run-at-time 1 n 'article-update-date-lapsed)))
3212 3422
3213 (defun gnus-stop-date-timer () 3423 (defun gnus-stop-date-timer ()
3214 "Stop the X-Sent timer." 3424 "Stop the X-Sent timer."
3215 (interactive) 3425 (interactive)
3216 (when article-lapsed-timer 3426 (when article-lapsed-timer
3235 (goto-char (point-min)) 3445 (goto-char (point-min))
3236 (when (and (re-search-forward "^date:[\t\n ]+" nil t) 3446 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3237 (not (bolp))) 3447 (not (bolp)))
3238 (match-end 0)))) 3448 (match-end 0))))
3239 (date (when (and start 3449 (date (when (and start
3240 (re-search-forward "[\t ]*\n\\([^\t ]\\|\\'\\)" 3450 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3241 nil t)) 3451 nil t))
3242 (buffer-substring-no-properties start 3452 (buffer-substring-no-properties start
3243 (match-beginning 0))))) 3453 (match-beginning 0)))))
3244 (goto-char (point-max)) 3454 (goto-char (point-max))
3245 (skip-chars-backward "\n") 3455 (skip-chars-backward "\n")
3586 (save-restriction 3796 (save-restriction
3587 (widen) 3797 (widen)
3588 (shell-command-on-region (point-min) (point-max) command nil))) 3798 (shell-command-on-region (point-min) (point-max) command nil)))
3589 (setq gnus-last-shell-command command)) 3799 (setq gnus-last-shell-command command))
3590 3800
3591 (defmacro gnus-read-string (prompt &optional initial-contents history
3592 default-value)
3593 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3594 (if (and (featurep 'xemacs)
3595 (< emacs-minor-version 2))
3596 `(read-string ,prompt ,initial-contents ,history)
3597 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3598
3599 (defun gnus-summary-pipe-to-muttprint (&optional command) 3801 (defun gnus-summary-pipe-to-muttprint (&optional command)
3600 "Pipe this article to muttprint." 3802 "Pipe this article to muttprint."
3601 (setq command (gnus-read-string 3803 (setq command (read-string
3602 "Print using command: " gnus-summary-muttprint-program 3804 "Print using command: " gnus-summary-muttprint-program
3603 nil gnus-summary-muttprint-program)) 3805 nil gnus-summary-muttprint-program))
3604 (gnus-summary-save-in-pipe command)) 3806 (gnus-summary-save-in-pipe command))
3605 3807
3606 ;;; Article file names when saving. 3808 ;;; Article file names when saving.
3719 (let ((inhibit-read-only t) bface eface) 3921 (let ((inhibit-read-only t) bface eface)
3720 (save-restriction 3922 (save-restriction
3721 (message-narrow-to-head) 3923 (message-narrow-to-head)
3722 (goto-char (point-max)) 3924 (goto-char (point-max))
3723 (forward-line -1) 3925 (forward-line -1)
3724 (setq bface (get-text-property (gnus-point-at-bol) 'face) 3926 (setq bface (get-text-property (point-at-bol) 'face)
3725 eface (get-text-property (1- (gnus-point-at-eol)) 'face)) 3927 eface (get-text-property (1- (point-at-eol)) 'face))
3726 (message-remove-header "X-Gnus-PGP-Verify") 3928 (message-remove-header "X-Gnus-PGP-Verify")
3727 (if (re-search-forward "^X-PGP-Sig:" nil t) 3929 (if (re-search-forward "^X-PGP-Sig:" nil t)
3728 (forward-line) 3930 (forward-line)
3729 (goto-char (point-max))) 3931 (goto-char (point-max)))
3730 (narrow-to-region (point) (point)) 3932 (narrow-to-region (point) (point))
3748 (interactive) 3950 (interactive)
3749 (if (gnus-buffer-live-p gnus-original-article-buffer) 3951 (if (gnus-buffer-live-p gnus-original-article-buffer)
3750 (canlock-verify gnus-original-article-buffer))) 3952 (canlock-verify gnus-original-article-buffer)))
3751 3953
3752 (eval-and-compile 3954 (eval-and-compile
3753 (mapcar 3955 (mapc
3754 (lambda (func) 3956 (lambda (func)
3755 (let (afunc gfunc) 3957 (let (afunc gfunc)
3756 (if (consp func) 3958 (if (consp func)
3757 (setq afunc (car func) 3959 (setq afunc (car func)
3758 gfunc (cdr func)) 3960 gfunc (cdr func))
3771 '(article-hide-headers 3973 '(article-hide-headers
3772 article-verify-x-pgp-sig 3974 article-verify-x-pgp-sig
3773 article-verify-cancel-lock 3975 article-verify-cancel-lock
3774 article-hide-boring-headers 3976 article-hide-boring-headers
3775 article-treat-overstrike 3977 article-treat-overstrike
3978 article-treat-ansi-sequences
3776 article-fill-long-lines 3979 article-fill-long-lines
3777 article-capitalize-sentences 3980 article-capitalize-sentences
3778 article-remove-cr 3981 article-remove-cr
3779 article-remove-leading-whitespace 3982 article-remove-leading-whitespace
3780 article-display-x-face 3983 article-display-x-face
3808 article-date-user 4011 article-date-user
3809 article-date-lapsed 4012 article-date-lapsed
3810 article-emphasize 4013 article-emphasize
3811 article-treat-dumbquotes 4014 article-treat-dumbquotes
3812 article-normalize-headers 4015 article-normalize-headers
3813 ;; (article-show-all . gnus-article-show-all-headers) 4016 ;;(article-show-all . gnus-article-show-all-headers)
3814 ))) 4017 )))
3815 4018
3816 ;;; 4019 ;;;
3817 ;;; Gnus article mode 4020 ;;; Gnus article mode
3818 ;;; 4021 ;;;
3871 '("Treatment" 4074 '("Treatment"
3872 ["Hide headers" gnus-article-hide-headers t] 4075 ["Hide headers" gnus-article-hide-headers t]
3873 ["Hide signature" gnus-article-hide-signature t] 4076 ["Hide signature" gnus-article-hide-signature t]
3874 ["Hide citation" gnus-article-hide-citation t] 4077 ["Hide citation" gnus-article-hide-citation t]
3875 ["Treat overstrike" gnus-article-treat-overstrike t] 4078 ["Treat overstrike" gnus-article-treat-overstrike t]
4079 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3876 ["Remove carriage return" gnus-article-remove-cr t] 4080 ["Remove carriage return" gnus-article-remove-cr t]
3877 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t] 4081 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3878 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] 4082 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3879 ["Remove base64" gnus-article-de-base64-unreadable t] 4083 ["Remove base64" gnus-article-de-base64-unreadable t]
3880 ["Treat html" gnus-article-wash-html t] 4084 ["Treat html" gnus-article-wash-html t]
3927 (make-local-variable 'gnus-article-ignored-charsets) 4131 (make-local-variable 'gnus-article-ignored-charsets)
3928 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space' 4132 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
3929 ;; face. 4133 ;; face.
3930 (set (make-local-variable 'nobreak-char-display) nil) 4134 (set (make-local-variable 'nobreak-char-display) nil)
3931 (setq cursor-in-non-selected-windows nil) 4135 (setq cursor-in-non-selected-windows nil)
4136 (setq truncate-lines gnus-article-truncate-lines)
3932 (gnus-set-default-directory) 4137 (gnus-set-default-directory)
3933 (buffer-disable-undo) 4138 (buffer-disable-undo)
3934 (setq buffer-read-only t) 4139 (setq buffer-read-only t
4140 show-trailing-whitespace nil)
3935 (set-syntax-table gnus-article-mode-syntax-table) 4141 (set-syntax-table gnus-article-mode-syntax-table)
3936 (mm-enable-multibyte) 4142 (mm-enable-multibyte)
3937 (gnus-run-mode-hooks 'gnus-article-mode-hook)) 4143 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3938 4144
3939 ;; Internal variables. Are `gnus-button-regexp' and `gnus-button-last' used
3940 ;; at all?
3941 (defvar gnus-button-regexp nil)
3942 (defvar gnus-button-marker-list nil 4145 (defvar gnus-button-marker-list nil
3943 "Regexp matching any of the regexps from `gnus-button-alist'.") 4146 "Regexp matching any of the regexps from `gnus-button-alist'.
3944 (defvar gnus-button-last nil 4147 Internal variable.")
3945 "The value of `gnus-button-alist' when `gnus-button-regexp' was build.")
3946 4148
3947 (defun gnus-article-setup-buffer () 4149 (defun gnus-article-setup-buffer ()
3948 "Initialize the article buffer." 4150 "Initialize the article buffer."
3949 (let* ((name (if gnus-single-article-buffer "*Article*" 4151 (let* ((name (if gnus-single-article-buffer "*Article*"
3950 (concat "*Article " gnus-newsgroup-name "*"))) 4152 (concat "*Article " gnus-newsgroup-name "*")))
3953 (concat " *Original Article" 4155 (concat " *Original Article"
3954 (substring name (match-end 0)))))) 4156 (substring name (match-end 0))))))
3955 (setq gnus-article-buffer name) 4157 (setq gnus-article-buffer name)
3956 (setq gnus-original-article-buffer original) 4158 (setq gnus-original-article-buffer original)
3957 (setq gnus-article-mime-handle-alist nil) 4159 (setq gnus-article-mime-handle-alist nil)
3958 ;; This might be a variable local to the summary buffer. 4160 (with-current-buffer gnus-summary-buffer
3959 (unless gnus-single-article-buffer 4161 ;; This might be a variable local to the summary buffer.
3960 (save-excursion 4162 (unless gnus-single-article-buffer
3961 (set-buffer gnus-summary-buffer)
3962 (setq gnus-article-buffer name) 4163 (setq gnus-article-buffer name)
3963 (setq gnus-original-article-buffer original) 4164 (setq gnus-original-article-buffer original)
3964 (gnus-set-global-variables))) 4165 (gnus-set-global-variables)))
3965 (gnus-article-setup-highlight-words) 4166 (gnus-article-setup-highlight-words)
3966 ;; Init original article buffer. 4167 ;; Init original article buffer.
3997 (current-buffer)) 4198 (current-buffer))
3998 (save-excursion 4199 (save-excursion
3999 (set-buffer (gnus-get-buffer-create name)) 4200 (set-buffer (gnus-get-buffer-create name))
4000 (gnus-article-mode) 4201 (gnus-article-mode)
4001 (make-local-variable 'gnus-summary-buffer) 4202 (make-local-variable 'gnus-summary-buffer)
4203 (setq gnus-summary-buffer
4204 (gnus-summary-buffer-name gnus-newsgroup-name))
4002 (gnus-summary-set-local-parameters gnus-newsgroup-name) 4205 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4003 (current-buffer))))) 4206 (current-buffer)))))
4004 4207
4005 ;; Set article window start at LINE, where LINE is the number of lines 4208 ;; Set article window start at LINE, where LINE is the number of lines
4006 ;; from the head of the article. 4209 ;; from the head of the article.
4007 (defun gnus-article-set-window-start (&optional line) 4210 (defun gnus-article-set-window-start (&optional line)
4008 (set-window-start 4211 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4009 (gnus-get-buffer-window gnus-article-buffer t) 4212 (when article-window
4010 (save-excursion 4213 (set-window-start
4011 (set-buffer gnus-article-buffer) 4214 article-window
4012 (goto-char (point-min)) 4215 (save-excursion
4013 (if (not line) 4216 (set-buffer gnus-article-buffer)
4014 (point-min) 4217 (goto-char (point-min))
4015 (gnus-message 6 "Moved to bookmark") 4218 (if (not line)
4016 (search-forward "\n\n" nil t) 4219 (point-min)
4017 (forward-line line) 4220 (gnus-message 6 "Moved to bookmark")
4018 (point))))) 4221 (search-forward "\n\n" nil t)
4222 (forward-line line)
4223 (point)))))))
4019 4224
4020 (defun gnus-article-prepare (article &optional all-headers header) 4225 (defun gnus-article-prepare (article &optional all-headers header)
4021 "Prepare ARTICLE in article mode buffer. 4226 "Prepare ARTICLE in article mode buffer.
4022 ARTICLE should either be an article number or a Message-ID. 4227 ARTICLE should either be an article number or a Message-ID.
4023 If ARTICLE is an id, HEADER should be the article headers. 4228 If ARTICLE is an id, HEADER should be the article headers.
4145 (when gnus-display-mime-function 4350 (when gnus-display-mime-function
4146 (funcall gnus-display-mime-function)) 4351 (funcall gnus-display-mime-function))
4147 (gnus-run-hooks 'gnus-article-prepare-hook))) 4352 (gnus-run-hooks 'gnus-article-prepare-hook)))
4148 4353
4149 ;;; 4354 ;;;
4355 ;;; Gnus Sticky Article Mode
4356 ;;;
4357
4358 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4359 "Mode for sticky articles."
4360 ;; Release bindings that won't work.
4361 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4362 gnus-sticky-article-mode-map)
4363 (substitute-key-definition 'gnus-article-refer-article 'undefined
4364 gnus-sticky-article-mode-map)
4365 (dolist (k '("e" "h" "s" "F" "R"))
4366 (define-key gnus-sticky-article-mode-map k nil))
4367 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4368 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4369 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4370 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4371
4372 (defun gnus-sticky-article (arg)
4373 "Make the current article sticky.
4374 If a prefix ARG is given, ask for a name for this sticky article buffer."
4375 (interactive "P")
4376 (gnus-summary-show-thread)
4377 (gnus-summary-select-article nil nil 'pseudo)
4378 (let (new-art-buf-name)
4379 (gnus-eval-in-buffer-window gnus-article-buffer
4380 (setq new-art-buf-name
4381 (concat
4382 "*Sticky Article: "
4383 (if arg
4384 (read-from-minibuffer "Sticky article buffer name: ")
4385 (gnus-with-article-headers
4386 (gnus-article-goto-header "subject")
4387 (setq new-art-buf-name
4388 (buffer-substring-no-properties
4389 (line-beginning-position) (line-end-position)))
4390 (goto-char (point-min))
4391 (gnus-article-goto-header "from")
4392 (setq new-art-buf-name
4393 (concat
4394 new-art-buf-name ", "
4395 (buffer-substring-no-properties
4396 (line-beginning-position) (line-end-position))))
4397 (goto-char (point-min))
4398 (gnus-article-goto-header "date")
4399 (setq new-art-buf-name
4400 (concat
4401 new-art-buf-name ", "
4402 (buffer-substring-no-properties
4403 (line-beginning-position) (line-end-position))))))
4404 "*"))
4405 (if (and (gnus-buffer-live-p new-art-buf-name)
4406 (with-current-buffer new-art-buf-name
4407 (eq major-mode 'gnus-sticky-article-mode)))
4408 (switch-to-buffer new-art-buf-name)
4409 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4410 (gnus-sticky-article-mode))
4411 (setq gnus-article-buffer new-art-buf-name))
4412 (gnus-summary-recenter)
4413 (gnus-summary-position-point))
4414
4415 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4416 "Kill the given sticky article BUFFER.
4417 If none is given, assume the current buffer and kill it if it has
4418 `gnus-sticky-article-mode'."
4419 (interactive)
4420 (unless buffer
4421 (setq buffer (current-buffer)))
4422 (with-current-buffer buffer
4423 (when (eq major-mode 'gnus-sticky-article-mode)
4424 (gnus-kill-buffer buffer))))
4425
4426 (defun gnus-kill-sticky-article-buffers (arg)
4427 "Kill all sticky article buffers.
4428 If a prefix ARG is given, ask for confirmation."
4429 (interactive "P")
4430 (dolist (buf (gnus-buffers))
4431 (with-current-buffer buf
4432 (when (eq major-mode 'gnus-sticky-article-mode)
4433 (if (not arg)
4434 (gnus-kill-buffer buf)
4435 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4436 (gnus-kill-buffer buf)))))))
4437
4438 ;;;
4150 ;;; Gnus MIME viewing functions 4439 ;;; Gnus MIME viewing functions
4151 ;;; 4440 ;;;
4152 4441
4153 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n" 4442 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4154 "Format of the MIME buttons. 4443 "Format of the MIME buttons.
4179 (gnus-mime-view-part "v" "View Interactively...") 4468 (gnus-mime-view-part "v" "View Interactively...")
4180 (gnus-mime-view-part-as-type "t" "View As Type...") 4469 (gnus-mime-view-part-as-type "t" "View As Type...")
4181 (gnus-mime-view-part-as-charset "C" "View As charset...") 4470 (gnus-mime-view-part-as-charset "C" "View As charset...")
4182 (gnus-mime-save-part "o" "Save...") 4471 (gnus-mime-save-part "o" "Save...")
4183 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip") 4472 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4473 (gnus-mime-replace-part "r" "Replace part")
4184 (gnus-mime-delete-part "d" "Delete part") 4474 (gnus-mime-delete-part "d" "Delete part")
4185 (gnus-mime-copy-part "c" "View As Text, In Other Buffer") 4475 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4186 (gnus-mime-inline-part "i" "View As Text, In This Buffer") 4476 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4187 (gnus-mime-view-part-internally "E" "View Internally") 4477 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4188 (gnus-mime-view-part-externally "e" "View Externally") 4478 (gnus-mime-view-part-externally "e" "View Externally")
4189 (gnus-mime-print-part "p" "Print") 4479 (gnus-mime-print-part "p" "Print")
4190 (gnus-mime-pipe-part "|" "Pipe To Command...") 4480 (gnus-mime-pipe-part "|" "Pipe To Command...")
4191 (gnus-mime-action-on-part "." "Take action on the part..."))) 4481 (gnus-mime-action-on-part "." "Take action on the part...")))
4192 4482
4197 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))) 4487 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4198 "")) 4488 ""))
4199 4489
4200 (defvar gnus-mime-button-map 4490 (defvar gnus-mime-button-map
4201 (let ((map (make-sparse-keymap))) 4491 (let ((map (make-sparse-keymap)))
4202 (unless (>= (string-to-number emacs-version) 21)
4203 ;; XEmacs doesn't care.
4204 (set-keymap-parent map gnus-article-mode-map))
4205 (define-key map gnus-mouse-2 'gnus-article-push-button) 4492 (define-key map gnus-mouse-2 'gnus-article-push-button)
4206 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu) 4493 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4207 (dolist (c gnus-mime-button-commands) 4494 (dolist (c gnus-mime-button-commands)
4208 (define-key map (cadr c) (car c))) 4495 (define-key map (cadr c) (car c)))
4209 map)) 4496 map))
4210 4497
4211 (easy-menu-define 4498 (easy-menu-define
4212 gnus-mime-button-menu gnus-mime-button-map "MIME button menu." 4499 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4213 `("MIME Part" 4500 `("MIME Part"
4214 ,@(mapcar (lambda (c) 4501 ,@(mapcar (lambda (c)
4215 (vector (caddr c) (car c) :enable t)) 4502 (vector (caddr c) (car c) :active t))
4216 gnus-mime-button-commands))) 4503 gnus-mime-button-commands)))
4217
4218 (eval-when-compile
4219 (define-compiler-macro popup-menu (&whole form
4220 menu &optional position prefix)
4221 (if (and (fboundp 'popup-menu)
4222 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4223 form
4224 ;; Gnus is probably running under Emacs 20.
4225 `(let* ((menu (cdr ,menu))
4226 (response (x-popup-menu
4227 t (list (car menu)
4228 (cons "" (mapcar (lambda (c)
4229 (cons (caddr c) (car c)))
4230 (cdr menu)))))))
4231 (if response
4232 (call-interactively (nth 3 (assq response menu))))))))
4233 4504
4234 (defun gnus-mime-button-menu (event prefix) 4505 (defun gnus-mime-button-menu (event prefix)
4235 "Construct a context-sensitive menu of MIME commands." 4506 "Construct a context-sensitive menu of MIME commands."
4236 (interactive "e\nP") 4507 (interactive "e\nP")
4237 (save-window-excursion 4508 (save-window-excursion
4242 (popup-menu gnus-mime-button-menu nil prefix)))) 4513 (popup-menu gnus-mime-button-menu nil prefix))))
4243 4514
4244 (defun gnus-mime-view-all-parts (&optional handles) 4515 (defun gnus-mime-view-all-parts (&optional handles)
4245 "View all the MIME parts." 4516 "View all the MIME parts."
4246 (interactive) 4517 (interactive)
4247 (save-current-buffer 4518 (with-current-buffer gnus-article-buffer
4248 (set-buffer gnus-article-buffer)
4249 (let ((handles (or handles gnus-article-mime-handles)) 4519 (let ((handles (or handles gnus-article-mime-handles))
4250 (mail-parse-charset gnus-newsgroup-charset) 4520 (mail-parse-charset gnus-newsgroup-charset)
4251 (mail-parse-ignored-charsets 4521 (mail-parse-ignored-charsets
4252 (with-current-buffer gnus-summary-buffer 4522 (with-current-buffer gnus-summary-buffer
4253 gnus-newsgroup-ignored-charsets))) 4523 gnus-newsgroup-ignored-charsets)))
4257 (or (search-forward "\n\n") (goto-char (point-max))) 4527 (or (search-forward "\n\n") (goto-char (point-max)))
4258 (let ((inhibit-read-only t)) 4528 (let ((inhibit-read-only t))
4259 (delete-region (point) (point-max)) 4529 (delete-region (point) (point-max))
4260 (mm-display-parts handles)))))) 4530 (mm-display-parts handles))))))
4261 4531
4262 (defun gnus-mime-save-part-and-strip () 4532 (defun gnus-article-jump-to-part (n)
4263 "Save the MIME part under point then replace it with an external body." 4533 "Jump to MIME part N."
4534 (interactive "P")
4535 (pop-to-buffer gnus-article-buffer)
4536 ;; FIXME: why is it necessary?
4537 (sit-for 0)
4538 (let ((parts (length gnus-article-mime-handle-alist)))
4539 (or n (setq n
4540 (string-to-number
4541 (read-string ;; Emacs 21 doesn't have `read-number'.
4542 (format "Jump to part (2..%s): " parts)))))
4543 (unless (and (integerp n) (<= n parts) (>= n 1))
4544 (setq n
4545 (progn
4546 (gnus-message 7 "Invalid part `%s', using %s instead."
4547 n parts)
4548 parts)))
4549 (gnus-message 9 "Jumping to part %s." n)
4550 (cond ((>= gnus-auto-select-part 1)
4551 (while (and (<= n parts)
4552 (not (gnus-article-goto-part n)))
4553 (setq n (1+ n))))
4554 ((< gnus-auto-select-part 0)
4555 (while (and (>= n 1)
4556 (not (gnus-article-goto-part n)))
4557 (setq n (1- n))))
4558 (t
4559 (gnus-article-goto-part n)))))
4560
4561 (eval-when-compile
4562 (defsubst gnus-article-edit-part (handles &optional current-id)
4563 "Edit an article in order to delete a mime part.
4564 This function is exclusively used by `gnus-mime-save-part-and-strip'
4565 and `gnus-mime-delete-part', and not provided at run-time normally."
4566 (gnus-article-edit-article
4567 `(lambda ()
4568 (buffer-disable-undo)
4569 (erase-buffer)
4570 (let ((mail-parse-charset (or gnus-article-charset
4571 ',gnus-newsgroup-charset))
4572 (mail-parse-ignored-charsets
4573 (or gnus-article-ignored-charsets
4574 ',gnus-newsgroup-ignored-charsets))
4575 (mbl mml-buffer-list))
4576 (setq mml-buffer-list nil)
4577 (insert-buffer-substring gnus-original-article-buffer)
4578 (mime-to-mml ',handles)
4579 (setq gnus-article-mime-handles nil)
4580 (let ((mbl1 mml-buffer-list))
4581 (setq mml-buffer-list mbl)
4582 (set (make-local-variable 'mml-buffer-list) mbl1))
4583 (gnus-make-local-hook 'kill-buffer-hook)
4584 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4585 `(lambda (no-highlight)
4586 (let ((mail-parse-charset (or gnus-article-charset
4587 ',gnus-newsgroup-charset))
4588 (message-options message-options)
4589 (message-options-set-recipient)
4590 (mail-parse-ignored-charsets
4591 (or gnus-article-ignored-charsets
4592 ',gnus-newsgroup-ignored-charsets)))
4593 (mml-to-mime)
4594 (mml-destroy-buffers)
4595 (remove-hook 'kill-buffer-hook
4596 'mml-destroy-buffers t)
4597 (kill-local-variable 'mml-buffer-list))
4598 (gnus-summary-edit-article-done
4599 ,(or (mail-header-references gnus-current-headers) "")
4600 ,(gnus-group-read-only-p)
4601 ,gnus-summary-buffer no-highlight))
4602 t)
4603 (gnus-article-edit-done)
4604 (gnus-summary-expand-window)
4605 (gnus-summary-show-article)
4606 (when (and current-id (integerp gnus-auto-select-part))
4607 (gnus-article-jump-to-part
4608 (if (text-property-any (point-min) (point-max)
4609 'gnus-part (+ current-id gnus-auto-select-part))
4610 (+ current-id gnus-auto-select-part)
4611 (with-current-buffer gnus-article-buffer
4612 (length gnus-article-mime-handle-alist)))))))
4613
4614 (defun gnus-mime-replace-part (file)
4615 "Replace MIME part under point with an external body."
4616 ;; Useful if file has already been saved to disk
4617 (interactive
4618 (list
4619 (mm-with-multibyte
4620 (read-file-name "Replace MIME part with file: "
4621 (or mm-default-directory default-directory)
4622 nil nil))))
4623 (gnus-mime-save-part-and-strip file))
4624
4625 (defun gnus-mime-save-part-and-strip (&optional file)
4626 "Save the MIME part under point then replace it with an external body.
4627 If FILE is given, use it for the external part."
4264 (interactive) 4628 (interactive)
4265 (gnus-article-check-buffer) 4629 (gnus-article-check-buffer)
4266 (when (gnus-group-read-only-p) 4630 (when (gnus-group-read-only-p)
4267 (error "The current group does not support deleting of parts")) 4631 (error "The current group does not support deleting of parts"))
4268 (when (mm-complicated-handles gnus-article-mime-handles) 4632 (when (mm-complicated-handles gnus-article-mime-handles)
4269 (error "\ 4633 (error "\
4270 The current article has a complicated MIME structure, giving up...")) 4634 The current article has a complicated MIME structure, giving up..."))
4271 (when (gnus-yes-or-no-p "\ 4635 (let* ((data (get-text-property (point) 'gnus-data))
4272 Deleting parts may malfunction or destroy the article; continue? ") 4636 (id (get-text-property (point) 'gnus-part))
4273 (let* ((data (get-text-property (point) 'gnus-data)) 4637 param
4274 file param 4638 (handles gnus-article-mime-handles))
4275 (handles gnus-article-mime-handles)) 4639 (unless file
4276 (setq file (and data (mm-save-part data))) 4640 (setq file
4277 (when file 4641 (and data (mm-save-part data "Delete MIME part and save to: "))))
4278 (with-current-buffer (mm-handle-buffer data) 4642 (when file
4279 (erase-buffer) 4643 (with-current-buffer (mm-handle-buffer data)
4280 (insert "Content-Type: " (mm-handle-media-type data)) 4644 (erase-buffer)
4281 (mml-insert-parameter-string (cdr (mm-handle-type data)) 4645 (insert "Content-Type: " (mm-handle-media-type data))
4282 '(charset)) 4646 (mml-insert-parameter-string (cdr (mm-handle-type data))
4283 ;; Add a filename for the sake of saving the part again. 4647 '(charset))
4284 (mml-insert-parameter 4648 ;; Add a filename for the sake of saving the part again.
4285 (mail-header-encode-parameter "name" (file-name-nondirectory file))) 4649 (mml-insert-parameter
4286 (insert "\n") 4650 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4287 (insert "Content-ID: " (message-make-message-id) "\n") 4651 (insert "\n")
4288 (insert "Content-Transfer-Encoding: binary\n") 4652 (insert "Content-ID: " (message-make-message-id) "\n")
4289 (insert "\n")) 4653 (insert "Content-Transfer-Encoding: binary\n")
4290 (setcdr data 4654 (insert "\n"))
4291 (cdr (mm-make-handle nil 4655 (setcdr data
4292 `("message/external-body" 4656 (cdr (mm-make-handle nil
4293 (access-type . "LOCAL-FILE") 4657 `("message/external-body"
4294 (name . ,file))))) 4658 (access-type . "LOCAL-FILE")
4295 (set-buffer gnus-summary-buffer) 4659 (name . ,file)))))
4296 (gnus-article-edit-article 4660 ;; (set-buffer gnus-summary-buffer)
4297 `(lambda () 4661 (gnus-article-edit-part handles id))))
4298 (erase-buffer) 4662
4299 (let ((mail-parse-charset (or gnus-article-charset 4663 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4300 ',gnus-newsgroup-charset)) 4664 ;; parts...>') but with stripping would be nice.
4301 (mail-parse-ignored-charsets
4302 (or gnus-article-ignored-charsets
4303 ',gnus-newsgroup-ignored-charsets))
4304 (mbl mml-buffer-list))
4305 (setq mml-buffer-list nil)
4306 (insert-buffer-substring gnus-original-article-buffer)
4307 (mime-to-mml ',handles)
4308 (setq gnus-article-mime-handles nil)
4309 (let ((mbl1 mml-buffer-list))
4310 (setq mml-buffer-list mbl)
4311 (set (make-local-variable 'mml-buffer-list) mbl1))
4312 (gnus-make-local-hook 'kill-buffer-hook)
4313 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4314 `(lambda (no-highlight)
4315 (let ((mail-parse-charset (or gnus-article-charset
4316 ',gnus-newsgroup-charset))
4317 (message-options message-options)
4318 (message-options-set-recipient)
4319 (mail-parse-ignored-charsets
4320 (or gnus-article-ignored-charsets
4321 ',gnus-newsgroup-ignored-charsets)))
4322 (mml-to-mime)
4323 (mml-destroy-buffers)
4324 (remove-hook 'kill-buffer-hook
4325 'mml-destroy-buffers t)
4326 (kill-local-variable 'mml-buffer-list))
4327 (gnus-summary-edit-article-done
4328 ,(or (mail-header-references gnus-current-headers) "")
4329 ,(gnus-group-read-only-p)
4330 ,gnus-summary-buffer no-highlight)))))))
4331 4665
4332 (defun gnus-mime-delete-part () 4666 (defun gnus-mime-delete-part ()
4333 "Delete the MIME part under point. 4667 "Delete the MIME part under point.
4334 Replace it with some information about the removed part." 4668 Replace it with some information about the removed part."
4335 (interactive) 4669 (interactive)
4337 (when (gnus-group-read-only-p) 4671 (when (gnus-group-read-only-p)
4338 (error "The current group does not support deleting of parts")) 4672 (error "The current group does not support deleting of parts"))
4339 (when (mm-complicated-handles gnus-article-mime-handles) 4673 (when (mm-complicated-handles gnus-article-mime-handles)
4340 (error "\ 4674 (error "\
4341 The current article has a complicated MIME structure, giving up...")) 4675 The current article has a complicated MIME structure, giving up..."))
4342 (when (gnus-yes-or-no-p "\ 4676 (when (or gnus-expert-user
4343 Deleting parts may malfunction or destroy the article; continue? ") 4677 (gnus-yes-or-no-p "\
4678 Deleting parts may malfunction or destroy the article; continue? "))
4344 (let* ((data (get-text-property (point) 'gnus-data)) 4679 (let* ((data (get-text-property (point) 'gnus-data))
4680 (id (get-text-property (point) 'gnus-part))
4345 (handles gnus-article-mime-handles) 4681 (handles gnus-article-mime-handles)
4346 (none "(none)") 4682 (none "(none)")
4347 (description 4683 (description
4348 (mail-decode-encoded-word-string (or (mm-handle-description data) 4684 (mail-decode-encoded-word-string (or (mm-handle-description data)
4349 none))) 4685 none)))
4369 (setcdr data 4705 (setcdr data
4370 (cdr (mm-make-handle 4706 (cdr (mm-make-handle
4371 nil `("text/plain") nil nil 4707 nil `("text/plain") nil nil
4372 (list "attachment") 4708 (list "attachment")
4373 (format "Deleted attachment (%s bytes)" bsize)))))) 4709 (format "Deleted attachment (%s bytes)" bsize))))))
4374 (set-buffer gnus-summary-buffer) 4710 ;; (set-buffer gnus-summary-buffer)
4375 ;; FIXME: maybe some of the following code (borrowed from 4711 (gnus-article-edit-part handles id))))
4376 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4377 (gnus-article-edit-article
4378 `(lambda ()
4379 (erase-buffer)
4380 (let ((mail-parse-charset (or gnus-article-charset
4381 ',gnus-newsgroup-charset))
4382 (mail-parse-ignored-charsets
4383 (or gnus-article-ignored-charsets
4384 ',gnus-newsgroup-ignored-charsets))
4385 (mbl mml-buffer-list))
4386 (setq mml-buffer-list nil)
4387 (insert-buffer-substring gnus-original-article-buffer)
4388 (mime-to-mml ',handles)
4389 (setq gnus-article-mime-handles nil)
4390 (let ((mbl1 mml-buffer-list))
4391 (setq mml-buffer-list mbl)
4392 (set (make-local-variable 'mml-buffer-list) mbl1))
4393 (gnus-make-local-hook 'kill-buffer-hook)
4394 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4395 `(lambda (no-highlight)
4396 (let ((mail-parse-charset (or gnus-article-charset
4397 ',gnus-newsgroup-charset))
4398 (message-options message-options)
4399 (message-options-set-recipient)
4400 (mail-parse-ignored-charsets
4401 (or gnus-article-ignored-charsets
4402 ',gnus-newsgroup-ignored-charsets)))
4403 (mml-to-mime)
4404 (mml-destroy-buffers)
4405 (remove-hook 'kill-buffer-hook
4406 'mml-destroy-buffers t)
4407 (kill-local-variable 'mml-buffer-list))
4408 (gnus-summary-edit-article-done
4409 ,(or (mail-header-references gnus-current-headers) "")
4410 ,(gnus-group-read-only-p)
4411 ,gnus-summary-buffer no-highlight))))
4412 ;; Not in `gnus-mime-save-part-and-strip':
4413 (gnus-article-edit-done)
4414 (gnus-summary-expand-window)
4415 (gnus-summary-show-article)))
4416 4712
4417 (defun gnus-mime-save-part () 4713 (defun gnus-mime-save-part ()
4418 "Save the MIME part under point." 4714 "Save the MIME part under point."
4419 (interactive) 4715 (interactive)
4420 (gnus-article-check-buffer) 4716 (gnus-article-check-buffer)
4448 ;; Content-Type: foo/bar; name=... 4744 ;; Content-Type: foo/bar; name=...
4449 (mail-content-type-get (mm-handle-type handle) 'name) 4745 (mail-content-type-get (mm-handle-type handle) 'name)
4450 ;; Content-Disposition: attachment; filename=... 4746 ;; Content-Disposition: attachment; filename=...
4451 (cdr (assq 'filename (cdr (mm-handle-disposition handle)))))) 4747 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4452 (def-type (and name (mm-default-file-encoding name)))) 4748 (def-type (and name (mm-default-file-encoding name))))
4453 (and def-type (cons def-type 0)))) 4749 (or (and def-type (cons def-type 0))
4750 (and handle
4751 (equal (mm-handle-media-supertype handle) "text")
4752 '("text/plain" . 0))
4753 '("application/octet-stream" . 0))))
4454 4754
4455 (defun gnus-mime-view-part-as-type (&optional mime-type pred) 4755 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4456 "Choose a MIME media type, and view the part as such. 4756 "Choose a MIME media type, and view the part as such.
4457 If non-nil, PRED is a predicate to use during completion to limit the 4757 If non-nil, PRED is a predicate to use during completion to limit the
4458 available media-types." 4758 available media-types."
4482 (mm-handle-description handle) 4782 (mm-handle-description handle)
4483 nil 4783 nil
4484 (mm-handle-id handle))) 4784 (mm-handle-id handle)))
4485 (setq gnus-article-mime-handles 4785 (setq gnus-article-mime-handles
4486 (mm-merge-handles gnus-article-mime-handles handle)) 4786 (mm-merge-handles gnus-article-mime-handles handle))
4787 (when (mm-handle-displayed-p handle)
4788 (mm-remove-part handle))
4487 (gnus-mm-display-part handle)))) 4789 (gnus-mm-display-part handle))))
4488 4790
4489 (eval-when-compile 4791 (defun gnus-mime-copy-part (&optional handle arg)
4490 (require 'jka-compr))
4491
4492 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4493 ;; emacs can do that itself.
4494 ;;
4495 (defun gnus-mime-jka-compr-maybe-uncompress ()
4496 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4497 The uncompress method used is derived from `buffer-file-name'."
4498 (when (and (fboundp 'jka-compr-installed-p)
4499 (jka-compr-installed-p))
4500 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4501 (when info
4502 (let ((basename (file-name-nondirectory buffer-file-name))
4503 (args (jka-compr-info-uncompress-args info))
4504 (prog (jka-compr-info-uncompress-program info))
4505 (message (jka-compr-info-uncompress-message info))
4506 (err-file (jka-compr-make-temp-name)))
4507 (if message
4508 (message "%s %s..." message basename))
4509 (unwind-protect
4510 (unless (memq (apply 'call-process-region
4511 (point-min) (point-max)
4512 prog
4513 t (list t err-file) nil
4514 args)
4515 jka-compr-acceptable-retval-list)
4516 (jka-compr-error prog args basename message err-file))
4517 (jka-compr-delete-temp-file err-file)))))))
4518
4519 (defun gnus-mime-copy-part (&optional handle)
4520 "Put the MIME part under point into a new buffer. 4792 "Put the MIME part under point into a new buffer.
4521 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2 4793 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4522 are decompressed." 4794 are decompressed."
4523 (interactive) 4795 (interactive (list nil current-prefix-arg))
4524 (gnus-article-check-buffer) 4796 (gnus-article-check-buffer)
4525 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) 4797 (unless handle
4526 (contents (and handle (mm-get-part handle))) 4798 (setq handle (get-text-property (point) 'gnus-data)))
4527 (base (and handle 4799 (when handle
4528 (file-name-nondirectory 4800 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4529 (or 4801 'name)
4530 (mail-content-type-get (mm-handle-type handle) 'name) 4802 (mail-content-type-get (mm-handle-disposition handle)
4531 (mail-content-type-get (mm-handle-disposition handle) 4803 'filename)))
4532 'filename) 4804 contents dont-decode charset coding-system)
4533 "*decoded*")))) 4805 (mm-with-unibyte-buffer
4534 (buffer (and base (generate-new-buffer base)))) 4806 (mm-insert-part handle)
4535 (when contents 4807 (setq contents (or (condition-case nil
4536 (switch-to-buffer buffer) 4808 (mm-decompress-buffer filename nil 'sig)
4537 (insert contents) 4809 (error
4810 (setq dont-decode t)
4811 nil))
4812 (buffer-string))))
4813 (setq filename (cond (filename (file-name-nondirectory filename))
4814 (dont-decode "*raw data*")
4815 (t "*decoded*")))
4816 (cond
4817 (dont-decode)
4818 ((not arg)
4819 (unless (setq charset (mail-content-type-get
4820 (mm-handle-type handle) 'charset))
4821 (unless (setq coding-system (mm-with-unibyte-buffer
4822 (insert contents)
4823 (mm-find-buffer-file-coding-system)))
4824 (setq charset gnus-newsgroup-charset))))
4825 ((numberp arg)
4826 (setq charset (or (cdr (assq arg
4827 gnus-summary-show-article-charset-alist))
4828 (mm-read-coding-system "Charset: ")))))
4829 (switch-to-buffer (generate-new-buffer filename))
4830 (if (or coding-system
4831 (and charset
4832 (setq coding-system (mm-charset-to-coding-system charset))
4833 (not (eq charset 'ascii))))
4834 (progn
4835 (mm-enable-multibyte)
4836 (insert (mm-decode-coding-string contents coding-system))
4837 (setq buffer-file-coding-system
4838 (if (boundp 'last-coding-system-used)
4839 (symbol-value 'last-coding-system-used)
4840 coding-system)))
4841 (mm-disable-multibyte)
4842 (insert contents)
4843 (setq buffer-file-coding-system mm-binary-coding-system))
4538 ;; We do it this way to make `normal-mode' set the appropriate mode. 4844 ;; We do it this way to make `normal-mode' set the appropriate mode.
4539 (unwind-protect 4845 (unwind-protect
4540 (progn 4846 (progn
4541 (setq buffer-file-name (expand-file-name base)) 4847 (setq buffer-file-name (expand-file-name filename))
4542 (gnus-mime-jka-compr-maybe-uncompress)
4543 (normal-mode)) 4848 (normal-mode))
4544 (setq buffer-file-name nil)) 4849 (setq buffer-file-name nil))
4545 (goto-char (point-min))))) 4850 (goto-char (point-min)))))
4546 4851
4547 (defun gnus-mime-print-part (&optional handle filename) 4852 (defun gnus-mime-print-part (&optional handle filename)
4568 (insert contents) 4873 (insert contents)
4569 (gnus-print-buffer)) 4874 (gnus-print-buffer))
4570 (ps-despool filename))))) 4875 (ps-despool filename)))))
4571 4876
4572 (defun gnus-mime-inline-part (&optional handle arg) 4877 (defun gnus-mime-inline-part (&optional handle arg)
4573 "Insert the MIME part under point into the current buffer." 4878 "Insert the MIME part under point into the current buffer.
4879 Compressed files like .gz and .bz2 are decompressed."
4574 (interactive (list nil current-prefix-arg)) 4880 (interactive (list nil current-prefix-arg))
4575 (gnus-article-check-buffer) 4881 (gnus-article-check-buffer)
4576 (let* ((handle (or handle (get-text-property (point) 'gnus-data))) 4882 (unless handle
4577 contents charset 4883 (setq handle (get-text-property (point) 'gnus-data)))
4578 (b (point)) 4884 (when handle
4579 (inhibit-read-only t)) 4885 (let ((b (point))
4580 (when handle 4886 (inhibit-read-only t)
4887 contents charset coding-system)
4581 (if (and (not arg) (mm-handle-undisplayer handle)) 4888 (if (and (not arg) (mm-handle-undisplayer handle))
4582 (mm-remove-part handle) 4889 (mm-remove-part handle)
4583 (setq contents (mm-get-part handle)) 4890 (mm-with-unibyte-buffer
4891 (mm-insert-part handle)
4892 (setq contents
4893 (or (mm-decompress-buffer
4894 (or (mail-content-type-get (mm-handle-type handle)
4895 'name)
4896 (mail-content-type-get (mm-handle-disposition handle)
4897 'filename))
4898 nil t)
4899 (buffer-string))))
4584 (cond 4900 (cond
4585 ((not arg) 4901 ((not arg)
4586 (setq charset (or (mail-content-type-get 4902 (unless (setq charset (mail-content-type-get
4587 (mm-handle-type handle) 'charset) 4903 (mm-handle-type handle) 'charset))
4588 gnus-newsgroup-charset))) 4904 (unless (setq coding-system
4905 (mm-with-unibyte-buffer
4906 (insert contents)
4907 (mm-find-buffer-file-coding-system)))
4908 (setq charset gnus-newsgroup-charset))))
4589 ((numberp arg) 4909 ((numberp arg)
4590 (if (mm-handle-undisplayer handle) 4910 (if (mm-handle-undisplayer handle)
4591 (mm-remove-part handle)) 4911 (mm-remove-part handle))
4592 (setq charset 4912 (setq charset
4593 (or (cdr (assq arg 4913 (or (cdr (assq arg
4597 (if (mm-handle-undisplayer handle) 4917 (if (mm-handle-undisplayer handle)
4598 (mm-remove-part handle)))) 4918 (mm-remove-part handle))))
4599 (forward-line 2) 4919 (forward-line 2)
4600 (mm-insert-inline 4920 (mm-insert-inline
4601 handle 4921 handle
4602 (if (and charset 4922 (if (or coding-system
4603 (setq charset (mm-charset-to-coding-system 4923 (and charset
4604 charset)) 4924 (setq coding-system
4605 (not (eq charset 'ascii))) 4925 (mm-charset-to-coding-system charset))
4606 (mm-decode-coding-string contents charset) 4926 (not (eq coding-system 'ascii))))
4927 (mm-decode-coding-string contents coding-system)
4607 (mm-string-to-multibyte contents))) 4928 (mm-string-to-multibyte contents)))
4608 (goto-char b))))) 4929 (goto-char b)))))
4609 4930
4610 (defun gnus-mime-strip-charset-parameters (handle) 4931 (defun gnus-mime-strip-charset-parameters (handle)
4611 "Strip charset parameters from HANDLE." 4932 "Strip charset parameters from HANDLE."
4630 (let ((handle (or handle (get-text-property (point) 'gnus-data))) 4951 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4631 (fun (get-text-property (point) 'gnus-callback)) 4952 (fun (get-text-property (point) 'gnus-callback))
4632 (gnus-newsgroup-ignored-charsets 'gnus-all) 4953 (gnus-newsgroup-ignored-charsets 'gnus-all)
4633 gnus-newsgroup-charset form preferred parts) 4954 gnus-newsgroup-charset form preferred parts)
4634 (when handle 4955 (when handle
4635 (if (mm-handle-undisplayer handle) 4956 (when (prog1
4636 (mm-remove-part handle)) 4957 (and fun
4637 (when fun 4958 (setq gnus-newsgroup-charset
4638 (setq gnus-newsgroup-charset 4959 (or (cdr (assq
4639 (or (cdr (assq arg gnus-summary-show-article-charset-alist)) 4960 arg
4640 (mm-read-coding-system "Charset: "))) 4961 gnus-summary-show-article-charset-alist))
4962 (mm-read-coding-system "Charset: "))))
4963 (if (mm-handle-undisplayer handle)
4964 (mm-remove-part handle)))
4641 (gnus-mime-strip-charset-parameters handle) 4965 (gnus-mime-strip-charset-parameters handle)
4642 (when (and (consp (setq form (cdr-safe fun))) 4966 (when (and (consp (setq form (cdr-safe fun)))
4643 (setq form (ignore-errors 4967 (setq form (ignore-errors
4644 (assq 'gnus-mime-display-alternative form))) 4968 (assq 'gnus-mime-display-alternative form)))
4645 (setq preferred (caddr form)) 4969 (setq preferred (caddr form))
4708 (gnus-article-check-buffer) 5032 (gnus-article-check-buffer)
4709 (let ((action-pair (assoc action gnus-mime-action-alist))) 5033 (let ((action-pair (assoc action gnus-mime-action-alist)))
4710 (if action-pair 5034 (if action-pair
4711 (funcall (cdr action-pair))))) 5035 (funcall (cdr action-pair)))))
4712 5036
4713 (defun gnus-article-part-wrapper (n function) 5037 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4714 (let ((window (get-buffer-window gnus-article-buffer 'visible)) 5038 "Call FUNCTION on MIME part N.
4715 frame) 5039 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4716 (when window 5040 If INTERACTIVE, call FUNCTION interactivly."
4717 ;; It is necessary to select the article window so that 5041 (let (window frame)
4718 ;; `gnus-article-goto-part' may really move the point. 5042 ;; Check whether the article is displayed.
4719 (setq frame (selected-frame)) 5043 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4720 (gnus-select-frame-set-input-focus (window-frame window)) 5044 (setq window (get-buffer-window gnus-article-buffer t))
4721 (unwind-protect 5045 (frame-visible-p (setq frame (window-frame window))))
4722 (save-window-excursion 5046 (error "No article is displayed"))
4723 (select-window window) 5047 (with-current-buffer gnus-article-buffer
4724 (when (> n (length gnus-article-mime-handle-alist)) 5048 ;; Check whether the article displays the right contents.
4725 (error "No such part")) 5049 (unless (with-current-buffer gnus-summary-buffer
4726 (gnus-article-goto-part n) 5050 (eq gnus-current-article (gnus-summary-article-number)))
4727 (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) 5051 (error "You should select the right article first"))
4728 (funcall function handle))) 5052 (if n
4729 (gnus-select-frame-set-input-focus frame))))) 5053 (setq n (prefix-numeric-value n))
5054 (let ((pt (point)))
5055 (setq n (or (get-text-property pt 'gnus-part)
5056 (and (not (bobp))
5057 (get-text-property (1- pt) 'gnus-part))
5058 (get-text-property (prog2
5059 (forward-line 1)
5060 (point)
5061 (goto-char pt))
5062 'gnus-part)
5063 (get-text-property
5064 (or (and (setq pt (previous-single-property-change
5065 pt 'gnus-part))
5066 (1- pt))
5067 (next-single-property-change (point) 'gnus-part)
5068 (point))
5069 'gnus-part)
5070 1))))
5071 ;; Check whether the specified part exists.
5072 (when (> n (length gnus-article-mime-handle-alist))
5073 (error "No such part")))
5074 (unless
5075 (progn
5076 ;; To select the window is needed so that the cursor
5077 ;; might be visible on the MIME button.
5078 (select-window (prog1
5079 window
5080 (setq window (selected-window))
5081 ;; Article may be displayed in the other frame.
5082 (gnus-select-frame-set-input-focus
5083 (prog1
5084 frame
5085 (setq frame (selected-frame))))))
5086 (when (gnus-article-goto-part n)
5087 ;; We point the cursor and the arrow at the MIME button
5088 ;; when the `function' prompt the user for something.
5089 (let ((cursor-in-non-selected-windows t)
5090 (overlay-arrow-string "=>")
5091 (overlay-arrow-position (point-marker)))
5092 (unwind-protect
5093 (cond
5094 ((and no-handle interactive)
5095 (call-interactively function))
5096 (no-handle
5097 (funcall function))
5098 (interactive
5099 (call-interactively
5100 function
5101 (cdr (assq n gnus-article-mime-handle-alist))))
5102 (t
5103 (funcall function
5104 (cdr (assq n gnus-article-mime-handle-alist)))))
5105 (set-marker overlay-arrow-position nil)
5106 (unless gnus-auto-select-part
5107 (gnus-select-frame-set-input-focus frame)
5108 (select-window window))))
5109 t))
5110 (if gnus-inhibit-mime-unbuttonizing
5111 ;; This is the default though the program shouldn't reach here.
5112 (error "No such part")
5113 ;; The part which doesn't have the MIME button is selected.
5114 ;; So, we display all the buttons and redo it.
5115 (let ((gnus-inhibit-mime-unbuttonizing t))
5116 (gnus-summary-show-article)
5117 (gnus-article-part-wrapper n function no-handle))))))
4730 5118
4731 (defun gnus-article-pipe-part (n) 5119 (defun gnus-article-pipe-part (n)
4732 "Pipe MIME part N, which is the numerical prefix." 5120 "Pipe MIME part N, which is the numerical prefix."
4733 (interactive "p") 5121 (interactive "P")
4734 (gnus-article-part-wrapper n 'mm-pipe-part)) 5122 (gnus-article-part-wrapper n 'mm-pipe-part))
4735 5123
4736 (defun gnus-article-save-part (n) 5124 (defun gnus-article-save-part (n)
4737 "Save MIME part N, which is the numerical prefix." 5125 "Save MIME part N, which is the numerical prefix."
4738 (interactive "p") 5126 (interactive "P")
4739 (gnus-article-part-wrapper n 'mm-save-part)) 5127 (gnus-article-part-wrapper n 'mm-save-part))
4740 5128
4741 (defun gnus-article-interactively-view-part (n) 5129 (defun gnus-article-interactively-view-part (n)
4742 "View MIME part N interactively, which is the numerical prefix." 5130 "View MIME part N interactively, which is the numerical prefix."
4743 (interactive "p") 5131 (interactive "P")
4744 (gnus-article-part-wrapper n 'mm-interactively-view-part)) 5132 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4745 5133
4746 (defun gnus-article-copy-part (n) 5134 (defun gnus-article-copy-part (n)
4747 "Copy MIME part N, which is the numerical prefix." 5135 "Copy MIME part N, which is the numerical prefix."
4748 (interactive "p") 5136 (interactive "P")
4749 (gnus-article-part-wrapper n 'gnus-mime-copy-part)) 5137 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4750 5138
4751 (defun gnus-article-view-part-as-charset (n) 5139 (defun gnus-article-view-part-as-charset (n)
4752 "View MIME part N using a specified charset. 5140 "View MIME part N using a specified charset.
4753 N is the numerical prefix." 5141 N is the numerical prefix."
4754 (interactive "p") 5142 (interactive "P")
4755 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset)) 5143 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4756 5144
4757 (defun gnus-article-view-part-externally (n) 5145 (defun gnus-article-view-part-externally (n)
4758 "View MIME part N externally, which is the numerical prefix." 5146 "View MIME part N externally, which is the numerical prefix."
4759 (interactive "p") 5147 (interactive "P")
4760 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally)) 5148 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4761 5149
4762 (defun gnus-article-inline-part (n) 5150 (defun gnus-article-inline-part (n)
4763 "Inline MIME part N, which is the numerical prefix." 5151 "Inline MIME part N, which is the numerical prefix."
4764 (interactive "p") 5152 (interactive "P")
4765 (gnus-article-part-wrapper n 'gnus-mime-inline-part)) 5153 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5154
5155 (defun gnus-article-save-part-and-strip (n)
5156 "Save MIME part N and replace it with an external body.
5157 N is the numerical prefix."
5158 (interactive "P")
5159 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5160
5161 (defun gnus-article-replace-part (n)
5162 "Replace MIME part N with an external body.
5163 N is the numerical prefix."
5164 (interactive "P")
5165 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5166
5167 (defun gnus-article-delete-part (n)
5168 "Delete MIME part N and add some information about the removed part.
5169 N is the numerical prefix."
5170 (interactive "P")
5171 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5172
5173 (defun gnus-article-view-part-as-type (n)
5174 "Choose a MIME media type, and view part N as such.
5175 N is the numerical prefix."
5176 (interactive "P")
5177 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
4766 5178
4767 (defun gnus-article-mime-match-handle-first (condition) 5179 (defun gnus-article-mime-match-handle-first (condition)
4768 (if condition 5180 (if condition
4769 (let ((alist gnus-article-mime-handle-alist) ihandle n) 5181 (let (n)
4770 (while (setq ihandle (pop alist)) 5182 (dolist (ihandle gnus-article-mime-handle-alist)
4771 (if (and (cond 5183 (if (and (cond
4772 ((functionp condition) 5184 ((functionp condition)
4773 (funcall condition (cdr ihandle))) 5185 (funcall condition (cdr ihandle)))
4774 ((eq condition 'undisplayed) 5186 ((eq condition 'undisplayed)
4775 (not (or (mm-handle-undisplayer (cdr ihandle)) 5187 (not (or (mm-handle-undisplayer (cdr ihandle))
4785 1)) 5197 1))
4786 5198
4787 (defun gnus-article-view-part (&optional n) 5199 (defun gnus-article-view-part (&optional n)
4788 "View MIME part N, which is the numerical prefix." 5200 "View MIME part N, which is the numerical prefix."
4789 (interactive "P") 5201 (interactive "P")
4790 (save-current-buffer 5202 (with-current-buffer gnus-article-buffer
4791 (set-buffer gnus-article-buffer)
4792 (or (numberp n) (setq n (gnus-article-mime-match-handle-first 5203 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4793 gnus-article-mime-match-handle-function))) 5204 gnus-article-mime-match-handle-function)))
4794 (when (> n (length gnus-article-mime-handle-alist)) 5205 (when (> n (length gnus-article-mime-handle-alist))
4795 (error "No such part")) 5206 (error "No such part"))
4796 (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) 5207 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4814 (prog1 5225 (prog1
4815 (let ((window (selected-window)) 5226 (let ((window (selected-window))
4816 (mail-parse-charset gnus-newsgroup-charset) 5227 (mail-parse-charset gnus-newsgroup-charset)
4817 (mail-parse-ignored-charsets 5228 (mail-parse-ignored-charsets
4818 (if (gnus-buffer-live-p gnus-summary-buffer) 5229 (if (gnus-buffer-live-p gnus-summary-buffer)
4819 (save-excursion 5230 (with-current-buffer gnus-summary-buffer
4820 (set-buffer gnus-summary-buffer)
4821 gnus-newsgroup-ignored-charsets) 5231 gnus-newsgroup-ignored-charsets)
4822 nil))) 5232 nil)))
4823 (save-excursion 5233 (save-excursion
4824 (unwind-protect 5234 (unwind-protect
4825 (let ((win (gnus-get-buffer-window (current-buffer) t)) 5235 (let ((win (gnus-get-buffer-window (current-buffer) t))
4883 (unless (bolp) 5293 (unless (bolp)
4884 (insert "\n")) 5294 (insert "\n"))
4885 (setq b (point)) 5295 (setq b (point))
4886 (gnus-eval-format 5296 (gnus-eval-format
4887 gnus-mime-button-line-format gnus-mime-button-line-format-alist 5297 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4888 `(,@(gnus-local-map-property gnus-mime-button-map) 5298 `(keymap ,gnus-mime-button-map
4889 gnus-callback gnus-mm-display-part 5299 gnus-callback gnus-mm-display-part
4890 gnus-part ,gnus-tmp-id 5300 gnus-part ,gnus-tmp-id
4891 article-type annotation 5301 article-type annotation
4892 gnus-data ,handle)) 5302 gnus-data ,handle))
4893 (setq e (if (bolp) 5303 (setq e (if (bolp)
4894 ;; Exclude a newline. 5304 ;; Exclude a newline.
4895 (1- (point)) 5305 (1- (point))
4896 (point))) 5306 (point)))
5307 (when gnus-article-button-face
5308 (gnus-overlay-put (gnus-make-overlay b e nil t)
5309 'face gnus-article-button-face))
4897 (widget-convert-button 5310 (widget-convert-button
4898 'link b e 5311 'link b e
4899 :mime-handle handle 5312 :mime-handle handle
4900 :action 'gnus-widget-press-button 5313 :action 'gnus-widget-press-button
4901 :button-keymap gnus-mime-button-map 5314 :button-keymap gnus-mime-button-map
5119 (forward-line -1) 5532 (forward-line -1)
5120 (setq beg (point))) 5533 (setq beg (point)))
5121 (gnus-article-insert-newline) 5534 (gnus-article-insert-newline)
5122 (mm-insert-inline 5535 (mm-insert-inline
5123 handle 5536 handle
5124 (let ((charset (mail-content-type-get (mm-handle-type handle) 5537 (let ((charset (or (mail-content-type-get (mm-handle-type handle)
5125 'charset))) 5538 'charset)
5539 (and (equal type "text/calendar") 'utf-8))))
5126 (cond ((not charset) 5540 (cond ((not charset)
5127 (mm-string-as-multibyte (mm-get-part handle))) 5541 (mm-string-as-multibyte (mm-get-part handle)))
5128 ((eq charset 'gnus-decoded) 5542 ((eq charset 'gnus-decoded)
5129 (with-current-buffer (mm-handle-buffer handle) 5543 (with-current-buffer (mm-handle-buffer handle)
5130 (buffer-string))) 5544 (buffer-string)))
5133 (goto-char (point-max)))) 5547 (goto-char (point-max))))
5134 ;; Do highlighting. 5548 ;; Do highlighting.
5135 (save-excursion 5549 (save-excursion
5136 (save-restriction 5550 (save-restriction
5137 (narrow-to-region beg (point)) 5551 (narrow-to-region beg (point))
5138 (gnus-treat-article 5552 (if (eq handle gnus-article-mime-handles)
5139 nil id 5553 ;; The format=flowed case.
5140 (gnus-article-mime-total-parts) 5554 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5141 (mm-handle-media-type handle))))))))) 5555 ;; Don't count signature parts that are never displayed.
5556 ;; The part number should be re-calculated supposing this
5557 ;; might be a message/rfc822 part.
5558 (let (handles)
5559 (dolist (part gnus-article-mime-handles)
5560 (unless (or (stringp part)
5561 (equal (car (mm-handle-type part))
5562 "application/pgp-signature"))
5563 (push part handles)))
5564 (gnus-treat-article
5565 nil (length (memq handle handles)) (length handles)
5566 (mm-handle-media-type handle)))))))))))
5142 5567
5143 (defun gnus-unbuttonized-mime-type-p (type) 5568 (defun gnus-unbuttonized-mime-type-p (type)
5144 "Say whether TYPE is to be unbuttonized." 5569 "Say whether TYPE is to be unbuttonized."
5145 (unless gnus-inhibit-mime-unbuttonizing 5570 (unless gnus-inhibit-mime-unbuttonizing
5146 (when (catch 'found 5571 (when (catch 'found
5193 (unless ,(not ibegend) 5618 (unless ,(not ibegend)
5194 (setq gnus-article-mime-handle-alist 5619 (setq gnus-article-mime-handle-alist
5195 ',gnus-article-mime-handle-alist)) 5620 ',gnus-article-mime-handle-alist))
5196 (gnus-mime-display-alternative 5621 (gnus-mime-display-alternative
5197 ',ihandles ',not-pref ',begend ,id)) 5622 ',ihandles ',not-pref ',begend ,id))
5198 ,@(gnus-local-map-property gnus-mime-button-map) 5623 keymap ,gnus-mime-button-map
5199 ,gnus-mouse-face-prop ,gnus-article-mouse-face 5624 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5200 face ,gnus-article-button-face 5625 face ,gnus-article-button-face
5201 gnus-part ,id 5626 gnus-part ,id
5202 article-type multipart)) 5627 article-type multipart))
5203 (widget-convert-button 'link from (point) 5628 (widget-convert-button 'link from (point)
5217 (unless ,(not ibegend) 5642 (unless ,(not ibegend)
5218 (setq gnus-article-mime-handle-alist 5643 (setq gnus-article-mime-handle-alist
5219 ',gnus-article-mime-handle-alist)) 5644 ',gnus-article-mime-handle-alist))
5220 (gnus-mime-display-alternative 5645 (gnus-mime-display-alternative
5221 ',ihandles ',handle ',begend ,id)) 5646 ',ihandles ',handle ',begend ,id))
5222 ,@(gnus-local-map-property gnus-mime-button-map) 5647 keymap ,gnus-mime-button-map
5223 ,gnus-mouse-face-prop ,gnus-article-mouse-face 5648 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5224 face ,gnus-article-button-face 5649 face ,gnus-article-button-face
5225 gnus-part ,id 5650 gnus-part ,id
5226 gnus-data ,handle)) 5651 gnus-data ,handle))
5227 (widget-convert-button 'link from (point) 5652 (widget-convert-button 'link from (point)
5232 (when preferred 5657 (when preferred
5233 (if (stringp (car preferred)) 5658 (if (stringp (car preferred))
5234 (gnus-display-mime preferred) 5659 (gnus-display-mime preferred)
5235 (let ((mail-parse-charset gnus-newsgroup-charset) 5660 (let ((mail-parse-charset gnus-newsgroup-charset)
5236 (mail-parse-ignored-charsets 5661 (mail-parse-ignored-charsets
5237 (save-excursion (set-buffer gnus-summary-buffer) 5662 (with-current-buffer gnus-summary-buffer
5238 gnus-newsgroup-ignored-charsets))) 5663 gnus-newsgroup-ignored-charsets)))
5239 (mm-display-part preferred) 5664 (mm-display-part preferred)
5240 ;; Do highlighting. 5665 ;; Do highlighting.
5241 (save-excursion 5666 (save-excursion
5242 (save-restriction 5667 (save-restriction
5243 (narrow-to-region (car begend) (point-max)) 5668 (narrow-to-region (car begend) (point-max))
5283 (let ((entry (assoc key gnus-article-wash-status-strings))) 5708 (let ((entry (assoc key gnus-article-wash-status-strings)))
5284 (if value (nth 1 entry) (nth 2 entry)))) 5709 (if value (nth 1 entry) (nth 2 entry))))
5285 5710
5286 (defun gnus-article-wash-status () 5711 (defun gnus-article-wash-status ()
5287 "Return a string which display status of article washing." 5712 "Return a string which display status of article washing."
5288 (save-excursion 5713 (with-current-buffer gnus-article-buffer
5289 (set-buffer gnus-article-buffer)
5290 (let ((cite (memq 'cite gnus-article-wash-types)) 5714 (let ((cite (memq 'cite gnus-article-wash-types))
5291 (headers (memq 'headers gnus-article-wash-types)) 5715 (headers (memq 'headers gnus-article-wash-types))
5292 (boring (memq 'boring-headers gnus-article-wash-types)) 5716 (boring (memq 'boring-headers gnus-article-wash-types))
5293 (pgp (memq 'pgp gnus-article-wash-types)) 5717 (pgp (memq 'pgp gnus-article-wash-types))
5294 (pem (memq 'pem gnus-article-wash-types)) 5718 (pem (memq 'pem gnus-article-wash-types))
5333 5757
5334 (defun gnus-article-maybe-hide-headers () 5758 (defun gnus-article-maybe-hide-headers ()
5335 "Hide unwanted headers if `gnus-have-all-headers' is nil. 5759 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5336 Provided for backwards compatibility." 5760 Provided for backwards compatibility."
5337 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer)) 5761 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5338 (not (save-excursion (set-buffer gnus-summary-buffer) 5762 (not (with-current-buffer gnus-summary-buffer
5339 gnus-have-all-headers))) 5763 gnus-have-all-headers)))
5340 (not gnus-inhibit-hiding)) 5764 (not gnus-inhibit-hiding))
5341 (gnus-article-hide-headers))) 5765 (gnus-article-hide-headers)))
5342 5766
5343 ;;; Article savers. 5767 ;;; Article savers.
5344 5768
5500 '(move-to-window-line 0) 5924 '(move-to-window-line 0)
5501 '(move-to-window-line 5925 '(move-to-window-line
5502 (min (max 0 scroll-margin) 5926 (min (max 0 scroll-margin)
5503 (max 1 (- (window-height) 5927 (max 1 (- (window-height)
5504 (if mode-line-format 1 0) 5928 (if mode-line-format 1 0)
5505 (if (and (boundp 'header-line-format) 5929 (if header-line-format 1 0)))))))
5506 (symbol-value 'header-line-format))
5507 1 0)))))))
5508 5930
5509 (defun gnus-article-next-page-1 (lines) 5931 (defun gnus-article-next-page-1 (lines)
5510 (when (and (not (featurep 'xemacs)) 5932 (when (and (not (featurep 'xemacs))
5511 (numberp lines) 5933 (numberp lines)
5512 (> lines 0) 5934 (> lines 0)
5565 5987
5566 (defun gnus-article-refer-article () 5988 (defun gnus-article-refer-article ()
5567 "Read article specified by message-id around point." 5989 "Read article specified by message-id around point."
5568 (interactive) 5990 (interactive)
5569 (save-excursion 5991 (save-excursion
5570 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t) 5992 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5571 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t) 5993 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5572 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t) 5994 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5573 (let ((msg-id (concat "<" (match-string 0) ">"))) 5995 (let ((msg-id (concat "<" (match-string 0) ">")))
5574 (set-buffer gnus-summary-buffer) 5996 (set-buffer gnus-summary-buffer)
5575 (gnus-summary-refer-article msg-id)) 5997 (gnus-summary-refer-article msg-id))
5576 (error "No references around point")))) 5998 (error "No references around point"))))
5577 5999
5639 (events-to-keys (read-key-sequence nil)) 6061 (events-to-keys (read-key-sequence nil))
5640 (read-key-sequence nil))))) 6062 (read-key-sequence nil)))))
5641 6063
5642 (message "") 6064 (message "")
5643 6065
5644 (if (or (member keys nosaves) 6066 (cond
5645 (member keys nosave-but-article) 6067 ((eq (aref keys (1- (length keys))) ?\C-h)
5646 (member keys nosave-in-article)) 6068 (with-current-buffer gnus-article-current-summary
5647 (let (func) 6069 (describe-bindings (substring keys 0 -1))))
5648 (save-window-excursion 6070 ((or (member keys nosaves)
5649 (pop-to-buffer gnus-article-current-summary) 6071 (member keys nosave-but-article)
5650 ;; We disable the pick minor mode commands. 6072 (member keys nosave-in-article))
5651 (let (gnus-pick-mode) 6073 (let (func)
5652 (setq func (lookup-key (current-local-map) keys)))) 6074 (save-window-excursion
5653 (if (or (not func) 6075 (pop-to-buffer gnus-article-current-summary)
5654 (numberp func)) 6076 ;; We disable the pick minor mode commands.
5655 (ding) 6077 (let (gnus-pick-mode)
5656 (unless (member keys nosave-in-article) 6078 (setq func (lookup-key (current-local-map) keys))))
5657 (set-buffer gnus-article-current-summary)) 6079 (if (or (not func)
5658 (call-interactively func) 6080 (numberp func))
5659 (setq new-sum-point (point))) 6081 (ding)
5660 (when (member keys nosave-but-article) 6082 (unless (member keys nosave-in-article)
5661 (pop-to-buffer gnus-article-buffer))) 6083 (set-buffer gnus-article-current-summary))
6084 (call-interactively func)
6085 (setq new-sum-point (point)))
6086 (when (member keys nosave-but-article)
6087 (pop-to-buffer gnus-article-buffer))))
6088 (t
5662 ;; These commands should restore window configuration. 6089 ;; These commands should restore window configuration.
5663 (let ((obuf (current-buffer)) 6090 (let ((obuf (current-buffer))
5664 (owin (current-window-configuration)) 6091 (owin (current-window-configuration))
5665 (opoint (point)) 6092 win func in-buffer selected new-sum-start new-sum-hscroll err)
5666 win func in-buffer selected new-sum-start new-sum-hscroll)
5667 (cond (not-restore-window 6093 (cond (not-restore-window
5668 (pop-to-buffer gnus-article-current-summary)) 6094 (pop-to-buffer gnus-article-current-summary)
6095 (setq win (selected-window)))
5669 ((setq win (get-buffer-window gnus-article-current-summary)) 6096 ((setq win (get-buffer-window gnus-article-current-summary))
5670 (select-window win)) 6097 (select-window win))
5671 (t 6098 (t
5672 (switch-to-buffer gnus-article-current-summary 'norecord))) 6099 (let ((summary-buffer gnus-article-current-summary))
6100 (gnus-configure-windows 'article)
6101 (unless (setq win (get-buffer-window summary-buffer 'visible))
6102 (let ((gnus-buffer-configuration
6103 '(article ((vertical 1.0
6104 (summary 0.25 point)
6105 (article 1.0))))))
6106 (gnus-configure-windows 'article))
6107 (setq win (get-buffer-window summary-buffer 'visible)))
6108 (gnus-select-frame-set-input-focus (window-frame win))
6109 (select-window win))))
5673 (setq in-buffer (current-buffer)) 6110 (setq in-buffer (current-buffer))
5674 ;; We disable the pick minor mode commands. 6111 ;; We disable the pick minor mode commands.
5675 (if (and (setq func (let (gnus-pick-mode) 6112 (if (and (setq func (let (gnus-pick-mode)
5676 (lookup-key (current-local-map) keys))) 6113 (lookup-key (current-local-map) keys)))
5677 (functionp func)) 6114 (functionp func)
6115 (condition-case code
6116 (progn
6117 (call-interactively func)
6118 t)
6119 (error
6120 (setq err code)
6121 nil)))
5678 (progn 6122 (progn
5679 (call-interactively func)
5680 (when (eq win (selected-window)) 6123 (when (eq win (selected-window))
5681 (setq new-sum-point (point) 6124 (setq new-sum-point (point)
5682 new-sum-start (window-start win) 6125 new-sum-start (window-start win)
5683 new-sum-hscroll (window-hscroll win))) 6126 new-sum-hscroll (window-hscroll win)))
5684 (when (eq in-buffer (current-buffer)) 6127 (when (or (eq in-buffer (current-buffer))
6128 (when (eq obuf (current-buffer))
6129 (set-buffer in-buffer)
6130 t))
5685 (setq selected (gnus-summary-select-article)) 6131 (setq selected (gnus-summary-select-article))
5686 (set-buffer obuf) 6132 (set-buffer obuf)
5687 (unless not-restore-window 6133 (unless not-restore-window
5688 (set-window-configuration owin)) 6134 (set-window-configuration owin))
5689 (when (eq selected 'old) 6135 (when (and (eq selected 'old)
5690 (article-goto-body) 6136 new-sum-point)
5691 (set-window-start (get-buffer-window (current-buffer)) 6137 (set-window-start (get-buffer-window (current-buffer))
5692 1) 6138 1)
5693 (set-window-point (get-buffer-window (current-buffer)) 6139 (set-window-point (get-buffer-window (current-buffer))
5694 (point))) 6140 (if (article-goto-body)
6141 (1- (point))
6142 (point))))
5695 (when (and (not not-restore-window) 6143 (when (and (not not-restore-window)
5696 new-sum-point) 6144 new-sum-point
6145 (with-current-buffer (window-buffer win)
6146 (eq major-mode 'gnus-summary-mode)))
5697 (set-window-point win new-sum-point) 6147 (set-window-point win new-sum-point)
5698 (set-window-start win new-sum-start) 6148 (set-window-start win new-sum-start)
5699 (set-window-hscroll win new-sum-hscroll)))) 6149 (set-window-hscroll win new-sum-hscroll))))
5700 (set-window-configuration owin) 6150 (set-window-configuration owin)
5701 (ding)))))) 6151 (if err
6152 (signal (car err) (cdr err))
6153 (ding))))))))
5702 6154
5703 (defun gnus-article-describe-key (key) 6155 (defun gnus-article-describe-key (key)
5704 "Display documentation of the function invoked by KEY. KEY is a string." 6156 "Display documentation of the function invoked by KEY. KEY is a string."
5705 (interactive "kDescribe key: ") 6157 (interactive "kDescribe key: ")
5706 (gnus-article-check-buffer) 6158 (gnus-article-check-buffer)
5866 ;; Refuse to select canceled articles. 6318 ;; Refuse to select canceled articles.
5867 ((and (numberp article) 6319 ((and (numberp article)
5868 gnus-summary-buffer 6320 gnus-summary-buffer
5869 (get-buffer gnus-summary-buffer) 6321 (get-buffer gnus-summary-buffer)
5870 (gnus-buffer-exists-p gnus-summary-buffer) 6322 (gnus-buffer-exists-p gnus-summary-buffer)
5871 (eq (cdr (save-excursion 6323 (eq (cdr (with-current-buffer gnus-summary-buffer
5872 (set-buffer gnus-summary-buffer)
5873 (assq article gnus-newsgroup-reads))) 6324 (assq article gnus-newsgroup-reads)))
5874 gnus-canceled-mark)) 6325 gnus-canceled-mark))
5875 nil) 6326 nil)
5876 ;; We first check `gnus-original-article-buffer'. 6327 ;; We first check `gnus-original-article-buffer'.
5877 ((and (get-buffer gnus-original-article-buffer) 6328 ((and (get-buffer gnus-original-article-buffer)
5878 (numberp article) 6329 (numberp article)
5879 (save-excursion 6330 (with-current-buffer gnus-original-article-buffer
5880 (set-buffer gnus-original-article-buffer)
5881 (and (equal (car gnus-original-article) group) 6331 (and (equal (car gnus-original-article) group)
5882 (eq (cdr gnus-original-article) article)))) 6332 (eq (cdr gnus-original-article) article))))
5883 (insert-buffer-substring gnus-original-article-buffer) 6333 (insert-buffer-substring gnus-original-article-buffer)
5884 'article) 6334 'article)
5885 ;; Check the backlog. 6335 ;; Check the backlog.
5993 :type 'hook) 6443 :type 'hook)
5994 6444
5995 (defvar gnus-article-edit-done-function nil) 6445 (defvar gnus-article-edit-done-function nil)
5996 6446
5997 (defvar gnus-article-edit-mode-map nil) 6447 (defvar gnus-article-edit-mode-map nil)
5998 (defvar gnus-article-edit-mode nil)
5999 6448
6000 ;; Should we be using derived.el for this? 6449 ;; Should we be using derived.el for this?
6001 (unless gnus-article-edit-mode-map 6450 (unless gnus-article-edit-mode-map
6002 (setq gnus-article-edit-mode-map (make-keymap)) 6451 (setq gnus-article-edit-mode-map (make-keymap))
6003 (set-keymap-parent gnus-article-edit-mode-map text-mode-map) 6452 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6093 'ignore 6542 'ignore
6094 (gnus-summary-edit-article-done 6543 (gnus-summary-edit-article-done
6095 ,(or (mail-header-references gnus-current-headers) "") 6544 ,(or (mail-header-references gnus-current-headers) "")
6096 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) 6545 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6097 6546
6098 (defun gnus-article-edit-article (start-func exit-func) 6547 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6099 "Start editing the contents of the current article buffer." 6548 "Start editing the contents of the current article buffer."
6100 (let ((winconf (current-window-configuration))) 6549 (let ((winconf (current-window-configuration)))
6101 (set-buffer gnus-article-buffer) 6550 (set-buffer gnus-article-buffer)
6102 (let ((message-auto-save-directory 6551 (let ((message-auto-save-directory
6103 ;; Don't associate the article buffer with a draft file. 6552 ;; Don't associate the article buffer with a draft file.
6106 (funcall start-func) 6555 (funcall start-func)
6107 (set-buffer-modified-p nil) 6556 (set-buffer-modified-p nil)
6108 (gnus-configure-windows 'edit-article) 6557 (gnus-configure-windows 'edit-article)
6109 (setq gnus-article-edit-done-function exit-func) 6558 (setq gnus-article-edit-done-function exit-func)
6110 (setq gnus-prev-winconf winconf) 6559 (setq gnus-prev-winconf winconf)
6111 (gnus-message 6 "C-c C-c to end edits"))) 6560 (unless quiet
6561 (gnus-message 6 "C-c C-c to end edits"))))
6112 6562
6113 (defun gnus-article-edit-done (&optional arg) 6563 (defun gnus-article-edit-done (&optional arg)
6114 "Update the article edits and exit." 6564 "Update the article edits and exit."
6115 (interactive "P") 6565 (interactive "P")
6116 (let ((func gnus-article-edit-done-function) 6566 (let ((func gnus-article-edit-done-function)
6133 (when gnus-use-cache 6583 (when gnus-use-cache
6134 (gnus-cache-update-article 6584 (gnus-cache-update-article
6135 (car gnus-article-current) (cdr gnus-article-current))) 6585 (car gnus-article-current) (cdr gnus-article-current)))
6136 ;; We remove all text props from the article buffer. 6586 ;; We remove all text props from the article buffer.
6137 (kill-all-local-variables) 6587 (kill-all-local-variables)
6138 (gnus-set-text-properties (point-min) (point-max) nil) 6588 (set-text-properties (point-min) (point-max) nil)
6139 (gnus-article-mode) 6589 (gnus-article-mode)
6140 (set-window-configuration winconf) 6590 (set-window-configuration winconf)
6141 (set-buffer buf) 6591 (set-buffer buf)
6142 (set-window-start (get-buffer-window buf) start) 6592 (set-window-start (get-buffer-window buf) start)
6143 (set-window-point (get-buffer-window buf) (point))) 6593 (set-window-point (get-buffer-window buf) (point)))
6181 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. 6631 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6182 6632
6183 ;;; Internal Variables: 6633 ;;; Internal Variables:
6184 6634
6185 (defcustom gnus-button-url-regexp 6635 (defcustom gnus-button-url-regexp
6186 (if (string-match "[[:digit:]]" "1") ;; support POSIX? 6636 (concat
6187 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)" 6637 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
6188 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)") 6638 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
6639 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
6640 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
6641 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
6642 (punct "!?:;.,"))
6643 (concat
6644 "\\(?:"
6645 ;; Match paired parentheses, e.g. in Wikipedia URLs:
6646 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]"
6647 "\\|"
6648 "[" chars punct "]+" "[" chars "]"
6649 "\\)"))
6650 (concat ;; XEmacs 21.4 doesn't support POSIX.
6651 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
6652 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
6653 "\\)")
6189 "Regular expression that matches URLs." 6654 "Regular expression that matches URLs."
6190 :group 'gnus-article-buttons 6655 :group 'gnus-article-buttons
6191 :type 'regexp) 6656 :type 'regexp)
6192 6657
6193 (defcustom gnus-button-valid-fqdn-regexp 6658 (defcustom gnus-button-valid-fqdn-regexp
6435 ((eq pref 'mail) 6900 ((eq pref 'mail)
6436 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto) 6901 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6437 (gnus-url-mailto url-mailto)) 6902 (gnus-url-mailto url-mailto))
6438 (t (gnus-message 3 "Invalid string."))))) 6903 (t (gnus-message 3 "Invalid string.")))))
6439 6904
6440 (defun gnus-button-handle-custom (url) 6905 (defun gnus-button-handle-custom (fun arg)
6441 "Follow a Custom URL." 6906 "Call function FUN on argument ARG.
6442 (customize-apropos (gnus-url-unhex-string url))) 6907 Both FUN and ARG are supposed to be strings. ARG will be passed
6908 as a symbol to FUN."
6909 (funcall (intern fun)
6910 (if (string-match "^customize-apropos" fun)
6911 arg
6912 (intern arg))))
6443 6913
6444 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)") 6914 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6445 6915
6446 ;; FIXME: Maybe we should merge some of the functions that do quite similar 6916 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6447 ;; stuff? 6917 ;; stuff?
6580 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3) 7050 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6581 ;; RFC 2392 (Don't allow `/' in domain part --> CID) 7051 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6582 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)" 7052 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6583 0 (>= gnus-button-message-level 0) gnus-button-message-id 2) 7053 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6584 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 7054 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7055 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7056 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6585 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) 7057 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6586 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 7058 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6587 0 (>= gnus-button-message-level 0) gnus-url-mailto 2) 7059 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6588 ;; RFC 2368 (The mailto URL scheme) 7060 ;; RFC 2368 (The mailto URL scheme)
6589 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" 7061 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6617 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2) 7089 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6618 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" 7090 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6619 ;; Info links like `C-h i d m CC Mode RET' 7091 ;; Info links like `C-h i d m CC Mode RET'
6620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2) 7092 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6621 ;; This is custom 7093 ;; This is custom
6622 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 7094 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6623 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2) 7095 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6624 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6625 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6626 ;; Emacs help commands 7096 ;; Emacs help commands
6627 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" 7097 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6628 ;; regexp doesn't match arguments containing ` '. 7098 ;; regexp doesn't match arguments containing ` '.
6629 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1) 7099 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6630 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" 7100 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6638 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]" 7108 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6639 ;; Exclude [.?] for URLs in gmane.emacs.cvs 7109 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6640 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) 7110 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6641 ("`\\([a-z][-a-z0-9]+\\.el\\)'" 7111 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6642 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) 7112 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6643 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'" 7113 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6644 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1) 7114 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6645 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'" 7115 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6646 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1) 7116 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6647 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)" 7117 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6648 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1) 7118 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6655 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 7125 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6656 ;; Unlike the other regexps we really have to require quoting 7126 ;; Unlike the other regexps we really have to require quoting
6657 ;; here to determine where it ends. 7127 ;; here to determine where it ends.
6658 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3) 7128 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6659 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)... 7129 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6660 ("<URL: *\\([^<>]*\\)>" 7130 ("<URL: *\\([^\n<>]*\\)>"
6661 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) 7131 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6662 ;; RFC 2396 (2.4.3., delims) ... 7132 ;; RFC 2396 (2.4.3., delims) ...
6663 ("\"URL: *\\([^\"]*\\)\"" 7133 ("\"URL: *\\([^\n\"]*\\)\""
6664 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6665 ;; RFC 2396 (2.4.3., delims) ...
6666 ("\"URL: *\\([^\"]*\\)\""
6667 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) 7134 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6668 ;; Raw URLs. 7135 ;; Raw URLs.
6669 (gnus-button-url-regexp 7136 (gnus-button-url-regexp
6670 0 (>= gnus-button-browse-level 0) browse-url 0) 7137 0 (>= gnus-button-browse-level 0) browse-url 0)
6671 ;; man pages 7138 ;; man pages
6678 gnus-button-handle-man 1) 7145 gnus-button-handle-man 1)
6679 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), 7146 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6680 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7) 7147 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6681 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W" 7148 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6682 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1) 7149 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7150 ;; Recognizing patches to .el files. This is somewhat obscure,
7151 ;; but considering the percentage of Gnus users who hack Emacs
7152 ;; Lisp files...
7153 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7154 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7155 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7156 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6683 ;; MID or mail: To avoid too many false positives we don't try to catch 7157 ;; MID or mail: To avoid too many false positives we don't try to catch
6684 ;; all kind of allowed MIDs or mail addresses. Domain part must contain 7158 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6685 ;; at least one dot. TLD must contain two or three chars or be a know TLD 7159 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6686 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist' 7160 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6687 ;; so that non-ambiguous entries (see above) match first. 7161 ;; so that non-ambiguous entries (see above) match first.
6720 0 (>= gnus-button-browse-level 0) browse-url 0) 7194 0 (>= gnus-button-browse-level 0) browse-url 0)
6721 ("^Subject:" gnus-button-url-regexp 7195 ("^Subject:" gnus-button-url-regexp
6722 0 (>= gnus-button-browse-level 0) browse-url 0) 7196 0 (>= gnus-button-browse-level 0) browse-url 0)
6723 ("^[^:]+:" gnus-button-url-regexp 7197 ("^[^:]+:" gnus-button-url-regexp
6724 0 (>= gnus-button-browse-level 0) browse-url 0) 7198 0 (>= gnus-button-browse-level 0) browse-url 0)
7199 ("^OpenPGP:.*url=" gnus-button-url-regexp
7200 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6725 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" 7201 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6726 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) 7202 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6727 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)" 7203 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6728 1 (>= gnus-button-message-level 0) gnus-button-message-id 4)) 7204 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6729 "*Alist of headers and regexps to match buttons in article heads. 7205 "*Alist of headers and regexps to match buttons in article heads.
6795 (gnus-article-add-buttons)) 7271 (gnus-article-add-buttons))
6796 7272
6797 (defun gnus-article-highlight-headers () 7273 (defun gnus-article-highlight-headers ()
6798 "Highlight article headers as specified by `gnus-header-face-alist'." 7274 "Highlight article headers as specified by `gnus-header-face-alist'."
6799 (interactive) 7275 (interactive)
6800 (save-excursion 7276 (gnus-with-article-headers
6801 (set-buffer gnus-article-buffer) 7277 (let (regexp header-face field-face from hpoints fpoints)
6802 (save-restriction 7278 (dolist (entry gnus-header-face-alist)
6803 (let ((alist gnus-header-face-alist) 7279 (goto-char (point-min))
6804 (inhibit-read-only t) 7280 (setq regexp (concat "^\\("
6805 (case-fold-search t) 7281 (if (string-equal "" (nth 0 entry))
6806 (inhibit-point-motion-hooks t) 7282 "[^\t ]"
6807 entry regexp header-face field-face from hpoints fpoints) 7283 (nth 0 entry))
6808 (article-narrow-to-head) 7284 "\\)")
6809 (while (setq entry (pop alist)) 7285 header-face (nth 1 entry)
6810 (goto-char (point-min)) 7286 field-face (nth 2 entry))
6811 (setq regexp (concat "^\\(" 7287 (while (and (re-search-forward regexp nil t)
6812 (if (string-equal "" (nth 0 entry)) 7288 (not (eobp)))
6813 "[^\t ]" 7289 (beginning-of-line)
6814 (nth 0 entry)) 7290 (setq from (point))
6815 "\\)") 7291 (unless (search-forward ":" nil t)
6816 header-face (nth 1 entry) 7292 (forward-char 1))
6817 field-face (nth 2 entry)) 7293 (when (and header-face
6818 (while (and (re-search-forward regexp nil t) 7294 (not (memq (point) hpoints)))
6819 (not (eobp))) 7295 (push (point) hpoints)
6820 (beginning-of-line) 7296 (gnus-put-text-property from (point) 'face header-face))
6821 (setq from (point)) 7297 (when (and field-face
6822 (unless (search-forward ":" nil t) 7298 (not (memq (setq from (point)) fpoints)))
6823 (forward-char 1)) 7299 (push from fpoints)
6824 (when (and header-face 7300 (if (re-search-forward "^[^ \t]" nil t)
6825 (not (memq (point) hpoints))) 7301 (forward-char -2)
6826 (push (point) hpoints) 7302 (goto-char (point-max)))
6827 (gnus-put-text-property from (point) 'face header-face)) 7303 (gnus-put-text-property from (point) 'face field-face)))))))
6828 (when (and field-face
6829 (not (memq (setq from (point)) fpoints)))
6830 (push from fpoints)
6831 (if (re-search-forward "^[^ \t]" nil t)
6832 (forward-char -2)
6833 (goto-char (point-max)))
6834 (gnus-put-text-property from (point) 'face field-face))))))))
6835 7304
6836 (defun gnus-article-highlight-signature () 7305 (defun gnus-article-highlight-signature ()
6837 "Highlight the signature in an article. 7306 "Highlight the signature in an article.
6838 It does this by highlighting everything after 7307 It does this by highlighting everything after
6839 `gnus-signature-separator' using the face `gnus-signature'." 7308 `gnus-signature-separator' using the face `gnus-signature'."
6840 (interactive) 7309 (interactive)
6841 (save-excursion 7310 (gnus-with-article-buffer
6842 (set-buffer gnus-article-buffer) 7311 (let ((inhibit-point-motion-hooks t))
6843 (let ((inhibit-read-only t)
6844 (inhibit-point-motion-hooks t))
6845 (save-restriction 7312 (save-restriction
6846 (when (and gnus-signature-face 7313 (when (and gnus-signature-face
6847 (gnus-article-narrow-to-signature)) 7314 (gnus-article-narrow-to-signature))
6848 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max)) 7315 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t)
6849 'face gnus-signature-face) 7316 'face gnus-signature-face)
6850 (widen) 7317 (widen)
6851 (gnus-article-search-signature) 7318 (gnus-article-search-signature)
6852 (let ((start (match-beginning 0)) 7319 (let ((start (match-beginning 0))
6853 (end (set-marker (make-marker) (1+ (match-end 0))))) 7320 (end (set-marker (make-marker) (1+ (match-end 0)))))
6861 (defun gnus-article-add-buttons (&optional force) 7328 (defun gnus-article-add-buttons (&optional force)
6862 "Find external references in the article and make buttons of them. 7329 "Find external references in the article and make buttons of them.
6863 \"External references\" are things like Message-IDs and URLs, as 7330 \"External references\" are things like Message-IDs and URLs, as
6864 specified by `gnus-button-alist'." 7331 specified by `gnus-button-alist'."
6865 (interactive (list 'force)) 7332 (interactive (list 'force))
6866 (save-excursion 7333 (gnus-with-article-buffer
6867 (set-buffer gnus-article-buffer) 7334 (let ((inhibit-point-motion-hooks t)
6868 (let ((inhibit-read-only t)
6869 (inhibit-point-motion-hooks t)
6870 (case-fold-search t) 7335 (case-fold-search t)
6871 (alist gnus-button-alist) 7336 (alist gnus-button-alist)
6872 beg entry regexp) 7337 beg entry regexp)
6873 ;; Remove all old markers. 7338 ;; Remove all old markers.
6874 (let (marker entry new-list) 7339 (let (marker entry new-list)
6887 (setq beg (point)) 7352 (setq beg (point))
6888 (while (setq entry (pop alist)) 7353 (while (setq entry (pop alist))
6889 (setq regexp (eval (car entry))) 7354 (setq regexp (eval (car entry)))
6890 (goto-char beg) 7355 (goto-char beg)
6891 (while (re-search-forward regexp nil t) 7356 (while (re-search-forward regexp nil t)
6892 (let* ((start (and entry (match-beginning (nth 1 entry)))) 7357 (let ((start (match-beginning (nth 1 entry)))
6893 (end (and entry (match-end (nth 1 entry)))) 7358 (end (match-end (nth 1 entry)))
6894 (from (match-beginning 0))) 7359 (from (match-beginning 0)))
6895 (when (and (or (eq t (nth 2 entry)) 7360 (when (and (or (eq t (nth 2 entry))
6896 (eval (nth 2 entry))) 7361 (eval (nth 2 entry)))
6897 (not (gnus-button-in-region-p 7362 (not (gnus-button-in-region-p
6898 start end 'gnus-callback))) 7363 start end 'gnus-callback)))
6899 ;; That optional form returned non-nil, so we add the 7364 ;; That optional form returned non-nil, so we add the
6900 ;; button. 7365 ;; button.
6901 (gnus-article-add-button 7366 (setq from (set-marker (make-marker) from))
6902 start end 'gnus-button-push 7367 (push from gnus-button-marker-list)
6903 (car (push (set-marker (make-marker) from) 7368 (unless (and (eq (car entry) 'gnus-button-url-regexp)
6904 gnus-button-marker-list)))))))))) 7369 (gnus-article-extend-url-button from start end))
7370 (gnus-article-add-button start end
7371 'gnus-button-push from)))))))))
7372
7373 (defun gnus-article-extend-url-button (beg start end)
7374 "Extend url button if url is folded into two or more lines.
7375 Return non-nil if button is extended. BEG is a marker that points to
7376 the beginning position of a text containing url. START and END are
7377 the endpoints of a url button before it is extended. The concatenated
7378 url is put as the `gnus-button-url' overlay property on the button."
7379 (let ((opoint (point))
7380 (points (list start end))
7381 url delim regexp)
7382 (prog1
7383 (when (and (progn
7384 (goto-char end)
7385 (not (looking-at "[\t ]*[\">]")))
7386 (progn
7387 (goto-char start)
7388 (string-match
7389 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
7390 (buffer-substring (point-at-bol) start)))
7391 (progn
7392 (setq url (list (buffer-substring start end))
7393 delim (if (match-beginning 1) ">" "\""))
7394 (beginning-of-line)
7395 (setq regexp (concat
7396 (when (and (looking-at
7397 message-cite-prefix-regexp)
7398 (< (match-end 0) start))
7399 (regexp-quote (match-string 0)))
7400 "\
7401 \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
7402 delim "\\)"))
7403 (while (progn
7404 (forward-line 1)
7405 (and (looking-at regexp)
7406 (prog1
7407 (match-beginning 1)
7408 (push (or (match-string 2)
7409 (match-string 1))
7410 url)
7411 (push (setq end (or (match-end 2)
7412 (match-end 1)))
7413 points)
7414 (push (or (match-beginning 2)
7415 (match-beginning 1))
7416 points)))))
7417 (match-beginning 2)))
7418 (let (gnus-article-mouse-face widget-mouse-face)
7419 (while points
7420 (gnus-article-add-button (pop points) (pop points)
7421 'gnus-button-push beg)))
7422 (let ((overlay (gnus-make-overlay start end)))
7423 (gnus-overlay-put overlay 'evaporate t)
7424 (gnus-overlay-put overlay 'gnus-button-url
7425 (list (mapconcat 'identity (nreverse url) "")))
7426 (when gnus-article-mouse-face
7427 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))
7428 t)
7429 (goto-char opoint))))
6905 7430
6906 ;; Add buttons to the head of an article. 7431 ;; Add buttons to the head of an article.
6907 (defun gnus-article-add-buttons-to-head () 7432 (defun gnus-article-add-buttons-to-head ()
6908 "Add buttons to the head of the article." 7433 "Add buttons to the head of the article."
6909 (interactive) 7434 (interactive)
6910 (save-excursion 7435 (gnus-with-article-headers
6911 (set-buffer gnus-article-buffer) 7436 (let (beg end)
6912 (save-restriction 7437 (dolist (entry gnus-header-button-alist)
6913 (let ((inhibit-read-only t) 7438 ;; Each alist entry.
6914 (inhibit-point-motion-hooks t) 7439 (goto-char (point-min))
6915 (case-fold-search t) 7440 (while (re-search-forward (car entry) nil t)
6916 (alist gnus-header-button-alist) 7441 ;; Each header matching the entry.
6917 entry beg end) 7442 (setq beg (match-beginning 0))
6918 (article-narrow-to-head) 7443 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6919 (while alist 7444 (match-beginning 0))
6920 ;; Each alist entry. 7445 (point-max)))
6921 (setq entry (car alist) 7446 (goto-char beg)
6922 alist (cdr alist)) 7447 (while (re-search-forward (eval (nth 1 entry)) end t)
6923 (goto-char (point-min)) 7448 ;; Each match within a header.
6924 (while (re-search-forward (car entry) nil t) 7449 (let* ((entry (cdr entry))
6925 ;; Each header matching the entry. 7450 (start (match-beginning (nth 1 entry)))
6926 (setq beg (match-beginning 0)) 7451 (end (match-end (nth 1 entry)))
6927 (setq end (or (and (re-search-forward "^[^ \t]" nil t) 7452 (form (nth 2 entry)))
6928 (match-beginning 0)) 7453 (goto-char (match-end 0))
6929 (point-max))) 7454 (when (eval form)
6930 (goto-char beg) 7455 (gnus-article-add-button
6931 (while (re-search-forward (eval (nth 1 entry)) end t) 7456 start end (nth 3 entry)
6932 ;; Each match within a header. 7457 (buffer-substring (match-beginning (nth 4 entry))
6933 (let* ((entry (cdr entry)) 7458 (match-end (nth 4 entry)))))))
6934 (start (match-beginning (nth 1 entry))) 7459 (goto-char end))))))
6935 (end (match-end (nth 1 entry)))
6936 (form (nth 2 entry)))
6937 (goto-char (match-end 0))
6938 (when (eval form)
6939 (gnus-article-add-button
6940 start end (nth 3 entry)
6941 (buffer-substring (match-beginning (nth 4 entry))
6942 (match-end (nth 4 entry)))))))
6943 (goto-char end)))))))
6944 7460
6945 ;;; External functions: 7461 ;;; External functions:
6946 7462
6947 (defun gnus-article-add-button (from to fun &optional data) 7463 (defun gnus-article-add-button (from to fun &optional data)
6948 "Create a button between FROM and TO with callback FUN and data DATA." 7464 "Create a button between FROM and TO with callback FUN and data DATA."
6949 (when gnus-article-button-face 7465 (when gnus-article-button-face
6950 (gnus-overlay-put (gnus-make-overlay from to) 7466 (gnus-overlay-put (gnus-make-overlay from to nil t)
6951 'face gnus-article-button-face)) 7467 'face gnus-article-button-face))
6952 (gnus-add-text-properties 7468 (gnus-add-text-properties
6953 from to 7469 from to
6954 (nconc (and gnus-article-mouse-face 7470 (nconc (and gnus-article-mouse-face
6955 (list gnus-mouse-face-prop gnus-article-mouse-face)) 7471 (list gnus-mouse-face-prop gnus-article-mouse-face))
6959 :button-keymap gnus-widget-button-keymap)) 7475 :button-keymap gnus-widget-button-keymap))
6960 7476
6961 ;;; Internal functions: 7477 ;;; Internal functions:
6962 7478
6963 (defun gnus-article-set-globals () 7479 (defun gnus-article-set-globals ()
6964 (save-excursion 7480 (with-current-buffer gnus-summary-buffer
6965 (set-buffer gnus-summary-buffer)
6966 (gnus-set-global-variables))) 7481 (gnus-set-global-variables)))
6967 7482
6968 (defun gnus-signature-toggle (end) 7483 (defun gnus-signature-toggle (end)
6969 (save-excursion 7484 (gnus-with-article-buffer
6970 (set-buffer gnus-article-buffer) 7485 (let ((inhibit-point-motion-hooks t))
6971 (let ((inhibit-read-only t)
6972 (inhibit-point-motion-hooks t))
6973 (if (text-property-any end (point-max) 'article-type 'signature) 7486 (if (text-property-any end (point-max) 'article-type 'signature)
6974 (progn 7487 (progn
6975 (gnus-delete-wash-type 'signature) 7488 (gnus-delete-wash-type 'signature)
6976 (gnus-remove-text-properties-when 7489 (gnus-remove-text-properties-when
6977 'article-type 'signature end (point-max) 7490 'article-type 'signature end (point-max)
7001 (save-excursion 7514 (save-excursion
7002 (goto-char marker) 7515 (goto-char marker)
7003 (let* ((entry (gnus-button-entry)) 7516 (let* ((entry (gnus-button-entry))
7004 (inhibit-point-motion-hooks t) 7517 (inhibit-point-motion-hooks t)
7005 (fun (nth 3 entry)) 7518 (fun (nth 3 entry))
7006 (args (mapcar (lambda (group) 7519 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
7007 (let ((string (match-string group))) 7520 (get-char-property marker 'gnus-button-url))
7008 (gnus-set-text-properties 7521 (mapcar (lambda (group)
7009 0 (length string) nil string) 7522 (let ((string (match-string group)))
7010 string)) 7523 (set-text-properties
7011 (nthcdr 4 entry)))) 7524 0 (length string) nil string)
7525 string))
7526 (nthcdr 4 entry)))))
7012 (cond 7527 (cond
7013 ((fboundp fun) 7528 ((fboundp fun)
7014 (apply fun args)) 7529 (apply fun args))
7015 ((and (boundp fun) 7530 ((and (boundp fun)
7016 (fboundp (symbol-value fun))) 7531 (fboundp (symbol-value fun)))
7064 (gnus-summary-refer-article message-id)) 7579 (gnus-summary-refer-article message-id))
7065 (gnus-summary-refer-article message-id)))) 7580 (gnus-summary-refer-article message-id))))
7066 (group 7581 (group
7067 (gnus-button-fetch-group url))))) 7582 (gnus-button-fetch-group url)))))
7068 7583
7584 (defun gnus-button-patch (library line)
7585 "Visit an Emacs Lisp library LIBRARY on line LINE."
7586 (interactive)
7587 (let ((file (locate-library (file-name-nondirectory library))))
7588 (unless file
7589 (error "Couldn't find library %s" library))
7590 (find-file file)
7591 (goto-line (string-to-number line))))
7592
7069 (defun gnus-button-handle-man (url) 7593 (defun gnus-button-handle-man (url)
7070 "Fetch a man page." 7594 "Fetch a man page."
7071 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) 7595 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7072 (when (eq gnus-button-man-handler 'woman) 7596 (when (eq gnus-button-man-handler 'woman)
7073 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" ""))) 7597 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7113 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'. 7637 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7114 (info) 7638 (info)
7115 (Info-directory) 7639 (Info-directory)
7116 (Info-menu url)) 7640 (Info-menu url))
7117 7641
7642 (defun gnus-button-openpgp (url)
7643 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7644 (with-temp-buffer
7645 (mm-url-insert-file-contents-external url)
7646 (pgg-snarf-keys-region (point-min) (point-max))
7647 (pgg-display-output-buffer nil nil nil)))
7648
7118 (defun gnus-button-message-id (message-id) 7649 (defun gnus-button-message-id (message-id)
7119 "Fetch MESSAGE-ID." 7650 "Fetch MESSAGE-ID."
7120 (save-excursion 7651 (with-current-buffer gnus-summary-buffer
7121 (set-buffer gnus-summary-buffer)
7122 (gnus-summary-refer-article message-id))) 7652 (gnus-summary-refer-article message-id)))
7123 7653
7124 (defun gnus-button-fetch-group (address) 7654 (defun gnus-button-fetch-group (address &rest ignore)
7125 "Fetch GROUP specified by ADDRESS." 7655 "Fetch GROUP specified by ADDRESS."
7656 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
7657 address)
7658 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
7659 ;; for nntp:// and news://
7660 (setq address (match-string 3 address)))
7126 (if (not (string-match "[:/]" address)) 7661 (if (not (string-match "[:/]" address))
7127 ;; This is just a simple group url. 7662 ;; This is just a simple group url.
7128 (gnus-group-read-ephemeral-group address gnus-select-method) 7663 (gnus-group-read-ephemeral-group address gnus-select-method)
7129 (if (not 7664 (if (not
7130 (string-match 7665 (string-match
7196 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") 7731 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7197 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") 7732 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7198 7733
7199 (defvar gnus-prev-page-map 7734 (defvar gnus-prev-page-map
7200 (let ((map (make-sparse-keymap))) 7735 (let ((map (make-sparse-keymap)))
7201 (unless (>= emacs-major-version 21)
7202 ;; XEmacs doesn't care.
7203 (set-keymap-parent map gnus-article-mode-map))
7204 (define-key map gnus-mouse-2 'gnus-button-prev-page) 7736 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7205 (define-key map "\r" 'gnus-button-prev-page) 7737 (define-key map "\r" 'gnus-button-prev-page)
7206 map)) 7738 map))
7207 7739
7208 (defvar gnus-next-page-map 7740 (defvar gnus-next-page-map
7213 (define-key map gnus-mouse-2 'gnus-button-next-page) 7745 (define-key map gnus-mouse-2 'gnus-button-next-page)
7214 (define-key map "\r" 'gnus-button-next-page) 7746 (define-key map "\r" 'gnus-button-next-page)
7215 map)) 7747 map))
7216 7748
7217 (defun gnus-insert-prev-page-button () 7749 (defun gnus-insert-prev-page-button ()
7218 (let ((b (point)) 7750 (let ((b (point)) e
7219 (inhibit-read-only t)) 7751 (inhibit-read-only t))
7220 (gnus-eval-format 7752 (gnus-eval-format
7221 gnus-prev-page-line-format nil 7753 gnus-prev-page-line-format nil
7222 `(,@(gnus-local-map-property gnus-prev-page-map) 7754 `(keymap ,gnus-prev-page-map
7223 gnus-prev t 7755 gnus-prev t
7224 gnus-callback gnus-article-button-prev-page 7756 gnus-callback gnus-article-button-prev-page
7225 article-type annotation)) 7757 article-type annotation))
7758 (setq e (if (bolp)
7759 ;; Exclude a newline.
7760 (1- (point))
7761 (point)))
7762 (when gnus-article-button-face
7763 (gnus-overlay-put (gnus-make-overlay b e nil t)
7764 'face gnus-article-button-face))
7226 (widget-convert-button 7765 (widget-convert-button
7227 'link b (if (bolp) 7766 'link b e
7228 ;; Exclude a newline.
7229 (1- (point))
7230 (point))
7231 :action 'gnus-button-prev-page 7767 :action 'gnus-button-prev-page
7232 :button-keymap gnus-prev-page-map))) 7768 :button-keymap gnus-prev-page-map)))
7233 7769
7234 (defun gnus-button-next-page (&optional args more-args) 7770 (defun gnus-button-next-page (&optional args more-args)
7235 "Go to the next page." 7771 "Go to the next page."
7246 (select-window (gnus-get-buffer-window gnus-article-buffer t)) 7782 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7247 (gnus-article-prev-page) 7783 (gnus-article-prev-page)
7248 (select-window win))) 7784 (select-window win)))
7249 7785
7250 (defun gnus-insert-next-page-button () 7786 (defun gnus-insert-next-page-button ()
7251 (let ((b (point)) 7787 (let ((b (point)) e
7252 (inhibit-read-only t)) 7788 (inhibit-read-only t))
7253 (gnus-eval-format gnus-next-page-line-format nil 7789 (gnus-eval-format gnus-next-page-line-format nil
7254 `(,@(gnus-local-map-property gnus-next-page-map) 7790 `(keymap ,gnus-next-page-map
7255 gnus-next t 7791 gnus-next t
7256 gnus-callback gnus-article-button-next-page 7792 gnus-callback gnus-article-button-next-page
7257 article-type annotation)) 7793 article-type annotation))
7794 (setq e (if (bolp)
7795 ;; Exclude a newline.
7796 (1- (point))
7797 (point)))
7798 (when gnus-article-button-face
7799 (gnus-overlay-put (gnus-make-overlay b e nil t)
7800 'face gnus-article-button-face))
7258 (widget-convert-button 7801 (widget-convert-button
7259 'link b (if (bolp) 7802 'link b e
7260 ;; Exclude a newline.
7261 (1- (point))
7262 (point))
7263 :action 'gnus-button-next-page 7803 :action 'gnus-button-next-page
7264 :button-keymap gnus-next-page-map))) 7804 :button-keymap gnus-next-page-map)))
7265 7805
7266 (defun gnus-article-button-next-page (arg) 7806 (defun gnus-article-button-next-page (arg)
7267 "Go to the next page." 7807 "Go to the next page."
7300 "Apply the functions from `gnus-encoded-word-methods' that match." 7840 "Apply the functions from `gnus-encoded-word-methods' that match."
7301 (unless (and gnus-decode-header-methods-cache 7841 (unless (and gnus-decode-header-methods-cache
7302 (eq gnus-newsgroup-name 7842 (eq gnus-newsgroup-name
7303 (car gnus-decode-header-methods-cache))) 7843 (car gnus-decode-header-methods-cache)))
7304 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name)) 7844 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7305 (mapcar (lambda (x) 7845 (dolist (x gnus-decode-header-methods)
7306 (if (symbolp x) 7846 (if (symbolp x)
7307 (nconc gnus-decode-header-methods-cache (list x)) 7847 (nconc gnus-decode-header-methods-cache (list x))
7308 (if (and gnus-newsgroup-name 7848 (if (and gnus-newsgroup-name
7309 (string-match (car x) gnus-newsgroup-name)) 7849 (string-match (car x) gnus-newsgroup-name))
7310 (nconc gnus-decode-header-methods-cache 7850 (nconc gnus-decode-header-methods-cache
7311 (list (cdr x)))))) 7851 (list (cdr x)))))))
7312 gnus-decode-header-methods))
7313 (let ((xlist gnus-decode-header-methods-cache)) 7852 (let ((xlist gnus-decode-header-methods-cache))
7314 (pop xlist) 7853 (pop xlist)
7315 (save-restriction 7854 (save-restriction
7316 (narrow-to-region start end) 7855 (narrow-to-region start end)
7317 (while xlist 7856 (while xlist
7383 (error "%S is not a valid predicate" pred))))) 7922 (error "%S is not a valid predicate" pred)))))
7384 ((eq val t) 7923 ((eq val t)
7385 t) 7924 t)
7386 ((eq val 'head) 7925 ((eq val 'head)
7387 nil) 7926 nil)
7927 ((eq val 'first)
7928 (eq part-number 1))
7388 ((eq val 'last) 7929 ((eq val 'last)
7389 (eq part-number total-parts)) 7930 (eq part-number total-parts))
7390 ((numberp val) 7931 ((numberp val)
7391 (< length val)) 7932 (< length val))
7392 (t 7933 (t
7483 '((?t gnus-tmp-type ?s) 8024 '((?t gnus-tmp-type ?s)
7484 (?i gnus-tmp-info ?s) 8025 (?i gnus-tmp-info ?s)
7485 (?d gnus-tmp-details ?s) 8026 (?d gnus-tmp-details ?s)
7486 (?D gnus-tmp-pressed-details ?s))) 8027 (?D gnus-tmp-pressed-details ?s)))
7487 8028
8029 (defvar gnus-mime-security-button-commands
8030 '((gnus-article-press-button "\r" "Show Detail")
8031 (undefined "v")
8032 (undefined "t")
8033 (undefined "C")
8034 (gnus-mime-security-save-part "o" "Save...")
8035 (undefined "\C-o")
8036 (undefined "r")
8037 (undefined "d")
8038 (undefined "c")
8039 (undefined "i")
8040 (undefined "E")
8041 (undefined "e")
8042 (undefined "p")
8043 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8044 (undefined ".")))
8045
7488 (defvar gnus-mime-security-button-map 8046 (defvar gnus-mime-security-button-map
7489 (let ((map (make-sparse-keymap))) 8047 (let ((map (make-sparse-keymap)))
7490 (unless (>= (string-to-number emacs-version) 21)
7491 (set-keymap-parent map gnus-article-mode-map))
7492 (define-key map gnus-mouse-2 'gnus-article-push-button) 8048 (define-key map gnus-mouse-2 'gnus-article-push-button)
7493 (define-key map "\r" 'gnus-article-press-button) 8049 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8050 (dolist (c gnus-mime-security-button-commands)
8051 (define-key map (cadr c) (car c)))
7494 map)) 8052 map))
8053
8054 (easy-menu-define
8055 gnus-mime-security-button-menu gnus-mime-security-button-map
8056 "Security button menu."
8057 `("Security Part"
8058 ,@(delq nil
8059 (mapcar (lambda (c)
8060 (unless (eq (car c) 'undefined)
8061 (vector (caddr c) (car c) :active t)))
8062 gnus-mime-security-button-commands))))
8063
8064 (defun gnus-mime-security-button-menu (event prefix)
8065 "Construct a context-sensitive menu of security commands."
8066 (interactive "e\nP")
8067 (save-window-excursion
8068 (let ((pos (event-start event)))
8069 (select-window (posn-window pos))
8070 (goto-char (posn-point pos))
8071 (gnus-article-check-buffer)
8072 (popup-menu gnus-mime-security-button-menu nil prefix))))
7495 8073
7496 (defvar gnus-mime-security-details-buffer nil) 8074 (defvar gnus-mime-security-details-buffer nil)
7497 8075
7498 (defvar gnus-mime-security-button-pressed nil) 8076 (defvar gnus-mime-security-button-pressed nil)
7499 8077
7504 (mm-remove-parts (cdr handle)) 8082 (mm-remove-parts (cdr handle))
7505 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region)) 8083 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7506 point (inhibit-read-only t)) 8084 point (inhibit-read-only t))
7507 (if region 8085 (if region
7508 (goto-char (car region))) 8086 (goto-char (car region)))
7509 (save-restriction 8087 (setq point (point))
7510 (narrow-to-region (point) (point)) 8088 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7511 (with-current-buffer (mm-handle-multipart-original-buffer handle) 8089 (let* ((mm-verify-option 'known)
7512 (let* ((mm-verify-option 'known) 8090 (mm-decrypt-option 'known)
7513 (mm-decrypt-option 'known) 8091 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7514 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle))) 8092 (unless (eq nparts (cdr handle))
7515 (unless (eq nparts (cdr handle)) 8093 (mm-destroy-parts (cdr handle))
7516 (mm-destroy-parts (cdr handle)) 8094 (setcdr handle nparts))))
7517 (setcdr handle nparts)))) 8095 (gnus-mime-display-security handle)
7518 (setq point (point))
7519 (gnus-mime-display-security handle)
7520 (goto-char (point-max)))
7521 (when region 8096 (when region
7522 (delete-region (point) (cdr region)) 8097 (delete-region (point) (cdr region))
7523 (set-marker (car region) nil) 8098 (set-marker (car region) nil)
7524 (set-marker (cdr region) nil)) 8099 (set-marker (cdr region) nil))
7525 (goto-char point))) 8100 (goto-char point)))
7593 (insert "\n")) 8168 (insert "\n"))
7594 (setq b (point)) 8169 (setq b (point))
7595 (gnus-eval-format 8170 (gnus-eval-format
7596 gnus-mime-security-button-line-format 8171 gnus-mime-security-button-line-format
7597 gnus-mime-security-button-line-format-alist 8172 gnus-mime-security-button-line-format-alist
7598 `(,@(gnus-local-map-property gnus-mime-security-button-map) 8173 `(keymap ,gnus-mime-security-button-map
7599 gnus-callback gnus-mime-security-press-button 8174 gnus-callback gnus-mime-security-press-button
7600 gnus-line-format ,gnus-mime-security-button-line-format 8175 gnus-line-format ,gnus-mime-security-button-line-format
7601 gnus-mime-details ,gnus-mime-security-button-pressed 8176 gnus-mime-details ,gnus-mime-security-button-pressed
7602 article-type annotation 8177 article-type annotation
7603 gnus-data ,handle)) 8178 gnus-data ,handle))
7604 (setq e (if (bolp) 8179 (setq e (if (bolp)
7605 ;; Exclude a newline. 8180 ;; Exclude a newline.
7606 (1- (point)) 8181 (1- (point))
7607 (point))) 8182 (point)))
8183 (when gnus-article-button-face
8184 (gnus-overlay-put (gnus-make-overlay b e nil t)
8185 'face gnus-article-button-face))
7608 (widget-convert-button 8186 (widget-convert-button
7609 'link b e 8187 'link b e
7610 :mime-handle handle 8188 :mime-handle handle
7611 :action 'gnus-widget-press-button 8189 :action 'gnus-widget-press-button
7612 :button-keymap gnus-mime-security-button-map 8190 :button-keymap gnus-mime-security-button-map
7615 ;; Needed to properly clear the message due to a bug in 8193 ;; Needed to properly clear the message due to a bug in
7616 ;; wid-edit (XEmacs only). 8194 ;; wid-edit (XEmacs only).
7617 (when (boundp 'help-echo-owns-message) 8195 (when (boundp 'help-echo-owns-message)
7618 (setq help-echo-owns-message t)) 8196 (setq help-echo-owns-message t))
7619 (format 8197 (format
7620 "%S: show detail" 8198 "%S: show detail; %S: more options"
7621 (aref gnus-mouse-2 0)))))) 8199 (aref gnus-mouse-2 0)
8200 (aref gnus-down-mouse-3 0))))))
7622 8201
7623 (defun gnus-mime-display-security (handle) 8202 (defun gnus-mime-display-security (handle)
7624 (save-restriction 8203 (save-restriction
7625 (narrow-to-region (point) (point)) 8204 (narrow-to-region (point) (point))
7626 (unless (gnus-unbuttonized-mime-type-p (car handle)) 8205 (unless (gnus-unbuttonized-mime-type-p (car handle))
7627 (gnus-insert-mime-security-button handle)) 8206 (gnus-insert-mime-security-button handle))
7628 (gnus-mime-display-mixed (cdr handle)) 8207 (gnus-mime-display-part (cadr handle))
7629 (unless (bolp) 8208 (unless (bolp)
7630 (insert "\n")) 8209 (insert "\n"))
7631 (unless (gnus-unbuttonized-mime-type-p (car handle)) 8210 (unless (gnus-unbuttonized-mime-type-p (car handle))
7632 (let ((gnus-mime-security-button-line-format 8211 (let ((gnus-mime-security-button-line-format
7633 gnus-mime-security-button-end-line-format)) 8212 gnus-mime-security-button-end-line-format))
7634 (gnus-insert-mime-security-button handle))) 8213 (gnus-insert-mime-security-button handle)))
7635 (mm-set-handle-multipart-parameter 8214 (mm-set-handle-multipart-parameter
7636 handle 'gnus-region 8215 handle 'gnus-region
7637 (cons (set-marker (make-marker) (point-min)) 8216 (cons (set-marker (make-marker) (point-min))
7638 (set-marker (make-marker) (point-max)))))) 8217 (set-marker (make-marker) (point-max))))
8218 (goto-char (point-max))))
8219
8220 (defun gnus-mime-security-run-function (function)
8221 "Run FUNCTION with the security part under point."
8222 (gnus-article-check-buffer)
8223 (let ((data (get-text-property (point) 'gnus-data))
8224 buffer handle)
8225 (when (and (stringp (car-safe data))
8226 (setq buffer (mm-handle-multipart-original-buffer data))
8227 (setq handle (cadr data)))
8228 (if (bufferp (mm-handle-buffer handle))
8229 (progn
8230 (setq handle (cons buffer (copy-sequence (cdr handle))))
8231 (mm-handle-set-undisplayer handle nil))
8232 (setq handle (mm-make-handle
8233 buffer
8234 (mm-handle-multipart-ctl-parameter handle 'protocol)
8235 nil nil nil nil nil nil)))
8236 (funcall function handle))))
8237
8238 (defun gnus-mime-security-save-part ()
8239 "Save the security part under point."
8240 (interactive)
8241 (gnus-mime-security-run-function 'mm-save-part))
8242
8243 (defun gnus-mime-security-pipe-part ()
8244 "Pipe the security part under point to a process."
8245 (interactive)
8246 (gnus-mime-security-run-function 'mm-pipe-part))
7639 8247
7640 (gnus-ems-redefine) 8248 (gnus-ems-redefine)
7641 8249
7642 (provide 'gnus-art) 8250 (provide 'gnus-art)
7643 8251