Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-art.el --- article mode commands for Gnus |
e84b4b86 | 2 | |
ba318903 | 3 | ;; Copyright (C) 1996-2014 Free Software Foundation, Inc. |
eec82323 | 4 | |
6748645f | 5 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
6 | ;; Keywords: news |
7 | ||
8 | ;; This file is part of GNU Emacs. | |
9 | ||
5e809f55 | 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
eec82323 | 11 | ;; it under the terms of the GNU General Public License as published by |
5e809f55 GM |
12 | ;; the Free Software Foundation, either version 3 of the License, or |
13 | ;; (at your option) any later version. | |
eec82323 LMI |
14 | |
15 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
2ff9f5b4 | 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
eec82323 LMI |
18 | ;; GNU General Public License for more details. |
19 | ||
20 | ;; You should have received a copy of the GNU General Public License | |
5e809f55 | 21 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
eec82323 LMI |
22 | |
23 | ;;; Commentary: | |
24 | ||
25 | ;;; Code: | |
26 | ||
23f87bed | 27 | (eval-when-compile |
9efa445f DN |
28 | (require 'cl)) |
29 | (defvar tool-bar-map) | |
30 | (defvar w3m-minor-mode-map) | |
5ab7173c | 31 | |
eec82323 | 32 | (require 'gnus) |
5843126b | 33 | (require 'gnus-sum) |
eec82323 LMI |
34 | (require 'gnus-spec) |
35 | (require 'gnus-int) | |
23f87bed | 36 | (require 'gnus-win) |
16409b0b GM |
37 | (require 'mm-bodies) |
38 | (require 'mail-parse) | |
39 | (require 'mm-decode) | |
40 | (require 'mm-view) | |
41 | (require 'wid-edit) | |
42 | (require 'mm-uu) | |
23f87bed | 43 | (require 'message) |
1518e4f0 | 44 | (require 'mouse) |
23f87bed MB |
45 | |
46 | (autoload 'gnus-msg-mail "gnus-msg" nil t) | |
47 | (autoload 'gnus-button-mailto "gnus-msg") | |
48 | (autoload 'gnus-button-reply "gnus-msg" nil t) | |
498063ec | 49 | (autoload 'parse-time-string "parse-time" nil nil) |
01c52d31 MB |
50 | (autoload 'ansi-color-apply-on-region "ansi-color") |
51 | (autoload 'mm-url-insert-file-contents-external "mm-url") | |
531bedc3 | 52 | (autoload 'mm-extern-cache-contents "mm-extern") |
eec82323 LMI |
53 | |
54 | (defgroup gnus-article nil | |
55 | "Article display." | |
23f87bed | 56 | :link '(custom-manual "(gnus)Article Buffer") |
eec82323 LMI |
57 | :group 'gnus) |
58 | ||
16409b0b GM |
59 | (defgroup gnus-article-treat nil |
60 | "Treating article parts." | |
61 | :link '(custom-manual "(gnus)Article Hiding") | |
62 | :group 'gnus-article) | |
63 | ||
eec82323 LMI |
64 | (defgroup gnus-article-hiding nil |
65 | "Hiding article parts." | |
66 | :link '(custom-manual "(gnus)Article Hiding") | |
67 | :group 'gnus-article) | |
68 | ||
69 | (defgroup gnus-article-highlight nil | |
70 | "Article highlighting." | |
71 | :link '(custom-manual "(gnus)Article Highlighting") | |
72 | :group 'gnus-article | |
73 | :group 'gnus-visual) | |
74 | ||
75 | (defgroup gnus-article-signature nil | |
76 | "Article signatures." | |
77 | :link '(custom-manual "(gnus)Article Signature") | |
78 | :group 'gnus-article) | |
79 | ||
80 | (defgroup gnus-article-headers nil | |
81 | "Article headers." | |
82 | :link '(custom-manual "(gnus)Hiding Headers") | |
83 | :group 'gnus-article) | |
84 | ||
85 | (defgroup gnus-article-washing nil | |
86 | "Special commands on articles." | |
87 | :link '(custom-manual "(gnus)Article Washing") | |
88 | :group 'gnus-article) | |
89 | ||
90 | (defgroup gnus-article-emphasis nil | |
91 | "Fontisizing articles." | |
92 | :link '(custom-manual "(gnus)Article Fontisizing") | |
93 | :group 'gnus-article) | |
94 | ||
95 | (defgroup gnus-article-saving nil | |
96 | "Saving articles." | |
97 | :link '(custom-manual "(gnus)Saving Articles") | |
98 | :group 'gnus-article) | |
99 | ||
100 | (defgroup gnus-article-mime nil | |
101 | "Worshiping the MIME wonder." | |
102 | :link '(custom-manual "(gnus)Using MIME") | |
103 | :group 'gnus-article) | |
104 | ||
105 | (defgroup gnus-article-buttons nil | |
106 | "Pushable buttons in the article buffer." | |
107 | :link '(custom-manual "(gnus)Article Buttons") | |
108 | :group 'gnus-article) | |
109 | ||
110 | (defgroup gnus-article-various nil | |
111 | "Other article options." | |
112 | :link '(custom-manual "(gnus)Misc Article") | |
113 | :group 'gnus-article) | |
114 | ||
115 | (defcustom gnus-ignored-headers | |
23f87bed MB |
116 | (mapcar |
117 | (lambda (header) | |
118 | (concat "^" header ":")) | |
119 | '("Path" "Expires" "Date-Received" "References" "Xref" "Lines" | |
120 | "Relay-Version" "Message-ID" "Approved" "Sender" "Received" | |
121 | "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To" | |
122 | "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature" | |
123 | "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop" | |
124 | "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face" | |
125 | "X-Attribution" "X-Originating-IP" "Delivered-To" | |
126 | "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace" | |
127 | "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*" | |
128 | "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date" | |
129 | "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache" | |
130 | "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time" | |
131 | "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List" | |
132 | "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt" | |
133 | "Old-Received" "X-Pgp" "X-Auth" "X-From-Line" | |
134 | "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender" | |
135 | "MBOX-Line" "Priority" "X400-[-A-Za-z]+" | |
136 | "Status" "X-Gnus-Mail-Source" "Cancel-Lock" | |
137 | "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance" | |
138 | "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3" | |
139 | "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT" | |
140 | "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin" | |
141 | "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender" | |
142 | "List-[A-Za-z]+" "X-Listprocessor-Version" | |
143 | "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks" | |
144 | "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway" | |
145 | "X-Received" "Content-length" "X-precedence" | |
146 | "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info" | |
147 | "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup" | |
148 | "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To" | |
149 | "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post" | |
150 | "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive" | |
151 | "X-Content-length" "X-Posting-Agent" "Original-Received" | |
152 | "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom" | |
153 | "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway" | |
154 | "X-Local-Origin" "X-Local-Destination" "X-UserInfo1" | |
155 | "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications" | |
01c52d31 MB |
156 | "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer" |
157 | "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane" | |
158 | "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At" | |
159 | "Envelope-Sender" "Envelope-Recipients")) | |
6748645f | 160 | "*All headers that start with this regexp will be hidden. |
eec82323 LMI |
161 | This variable can also be a list of regexps of headers to be ignored. |
162 | If `gnus-visible-headers' is non-nil, this variable will be ignored." | |
72aba33f | 163 | :type '(choice regexp |
eec82323 LMI |
164 | (repeat regexp)) |
165 | :group 'gnus-article-hiding) | |
166 | ||
167 | (defcustom gnus-visible-headers | |
12e3ca0a | 168 | "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:" |
6748645f | 169 | "*All headers that do not match this regexp will be hidden. |
eec82323 LMI |
170 | This variable can also be a list of regexp of headers to remain visible. |
171 | If this variable is non-nil, `gnus-ignored-headers' will be ignored." | |
9b3ebcb6 MB |
172 | :type '(choice |
173 | (repeat :value-to-internal (lambda (widget value) | |
174 | (custom-split-regexp-maybe value)) | |
175 | :match (lambda (widget value) | |
176 | (or (stringp value) | |
177 | (widget-editable-list-match widget value))) | |
178 | regexp) | |
179 | (const :tag "Use gnus-ignored-headers" nil) | |
180 | regexp) | |
eec82323 LMI |
181 | :group 'gnus-article-hiding) |
182 | ||
183 | (defcustom gnus-sorted-header-list | |
184 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" | |
185 | "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:") | |
6748645f | 186 | "*This variable is a list of regular expressions. |
eec82323 LMI |
187 | If it is non-nil, headers that match the regular expressions will |
188 | be placed first in the article buffer in the sequence specified by | |
189 | this list." | |
190 | :type '(repeat regexp) | |
191 | :group 'gnus-article-hiding) | |
192 | ||
193 | (defcustom gnus-boring-article-headers '(empty followup-to reply-to) | |
194 | "Headers that are only to be displayed if they have interesting data. | |
23f87bed MB |
195 | Possible values in this list are: |
196 | ||
197 | 'empty Headers with no content. | |
198 | 'newsgroups Newsgroup identical to Gnus group. | |
199 | 'to-address To identical to To-address. | |
200 | 'to-list To identical to To-list. | |
201 | 'cc-list CC identical to To-list. | |
202 | 'followup-to Followup-to identical to Newsgroups. | |
203 | 'reply-to Reply-to identical to From. | |
204 | 'date Date less than four days old. | |
205 | 'long-to To and/or Cc longer than 1024 characters. | |
206 | 'many-to Multiple To and/or Cc." | |
eec82323 | 207 | :type '(set (const :tag "Headers with no content." empty) |
23f87bed MB |
208 | (const :tag "Newsgroups identical to Gnus group." newsgroups) |
209 | (const :tag "To identical to To-address." to-address) | |
210 | (const :tag "To identical to To-list." to-list) | |
211 | (const :tag "CC identical to To-list." cc-list) | |
212 | (const :tag "Followup-to identical to Newsgroups." followup-to) | |
213 | (const :tag "Reply-to identical to From." reply-to) | |
6748645f | 214 | (const :tag "Date less than four days old." date) |
23f87bed | 215 | (const :tag "To and/or Cc longer than 1024 characters." long-to) |
16409b0b | 216 | (const :tag "Multiple To and/or Cc headers." many-to)) |
eec82323 LMI |
217 | :group 'gnus-article-hiding) |
218 | ||
23f87bed MB |
219 | (defcustom gnus-article-skip-boring nil |
220 | "Skip over text that is not worth reading. | |
221 | By default, if you set this t, then Gnus will display citations and | |
222 | signatures, but will never scroll down to show you a page consisting | |
223 | only of boring text. Boring text is controlled by | |
224 | `gnus-article-boring-faces'." | |
bf247b6e | 225 | :version "22.1" |
23f87bed MB |
226 | :type 'boolean |
227 | :group 'gnus-article-hiding) | |
228 | ||
eec82323 LMI |
229 | (defcustom gnus-signature-separator '("^-- $" "^-- *$") |
230 | "Regexp matching signature separator. | |
231 | This can also be a list of regexps. In that case, it will be checked | |
232 | from head to tail looking for a separator. Searches will be done from | |
233 | the end of the buffer." | |
3031d8b0 MB |
234 | :type '(choice :format "%{%t%}: %[Value Menu%]\n%v" |
235 | (regexp) | |
236 | (repeat :tag "List of regexp" regexp)) | |
eec82323 LMI |
237 | :group 'gnus-article-signature) |
238 | ||
239 | (defcustom gnus-signature-limit nil | |
16409b0b | 240 | "Provide a limit to what is considered a signature. |
eec82323 LMI |
241 | If it is a number, no signature may not be longer (in characters) than |
242 | that number. If it is a floating point number, no signature may be | |
243 | longer (in lines) than that number. If it is a function, the function | |
244 | will be called without any parameters, and if it returns nil, there is | |
245 | no signature in the buffer. If it is a string, it will be used as a | |
01c52d31 MB |
246 | regexp. If it matches, the text in question is not a signature. |
247 | ||
248 | This can also be a list of the above values." | |
4a2358e9 MB |
249 | :type '(choice (const nil) |
250 | (integer :value 200) | |
6748645f | 251 | (number :value 4.0) |
b28080e3 | 252 | function |
6748645f | 253 | (regexp :value ".*")) |
eec82323 LMI |
254 | :group 'gnus-article-signature) |
255 | ||
256 | (defcustom gnus-hidden-properties '(invisible t intangible t) | |
257 | "Property list to use for hiding text." | |
258 | :type 'sexp | |
259 | :group 'gnus-article-hiding) | |
260 | ||
23f87bed MB |
261 | ;; Fixme: This isn't the right thing for mixed graphical and non-graphical |
262 | ;; frames in a session. | |
eec82323 | 263 | (defcustom gnus-article-x-face-command |
23f87bed MB |
264 | (if (featurep 'xemacs) |
265 | (if (or (gnus-image-type-available-p 'xface) | |
266 | (gnus-image-type-available-p 'pbm)) | |
267 | 'gnus-display-x-face-in-from | |
71c90957 KY |
268 | "{ echo \ |
269 | '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\ | |
270 | ; uncompface; } | icontopbm | ee -") | |
23f87bed MB |
271 | (if (gnus-image-type-available-p 'pbm) |
272 | 'gnus-display-x-face-in-from | |
71c90957 KY |
273 | "{ echo \ |
274 | '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\ | |
275 | ; uncompface; } | icontopbm | display -")) | |
6748645f | 276 | "*String or function to be executed to display an X-Face header. |
eec82323 | 277 | If it is a string, the command will be executed in a sub-shell |
2ff9f5b4 | 278 | asynchronously. The compressed face will be piped to this command." |
23f87bed MB |
279 | :type `(choice string |
280 | (function-item gnus-display-x-face-in-from) | |
16409b0b | 281 | function) |
b5a206e7 | 282 | :version "21.1" |
23f87bed | 283 | :group 'gnus-picon |
eec82323 LMI |
284 | :group 'gnus-article-washing) |
285 | ||
286 | (defcustom gnus-article-x-face-too-ugly nil | |
287 | "Regexp matching posters whose face shouldn't be shown automatically." | |
4bb6a3a6 | 288 | :type '(choice regexp (const nil)) |
eec82323 LMI |
289 | :group 'gnus-article-washing) |
290 | ||
e0bad764 DL |
291 | (defcustom gnus-article-banner-alist nil |
292 | "Banner alist for stripping. | |
a1506d29 | 293 | For example, |
23f87bed | 294 | ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))" |
fc2c2db8 | 295 | :version "21.1" |
e0bad764 DL |
296 | :type '(repeat (cons symbol regexp)) |
297 | :group 'gnus-article-washing) | |
298 | ||
23f87bed MB |
299 | (gnus-define-group-parameter |
300 | banner | |
301 | :variable-document | |
302 | "Alist of regexps (to match group names) and banner." | |
303 | :variable-group gnus-article-washing | |
304 | :parameter-type | |
305 | '(choice :tag "Banner" | |
306 | :value nil | |
307 | (const :tag "Remove signature" signature) | |
308 | (symbol :tag "Item in `gnus-article-banner-alist'" none) | |
309 | regexp | |
310 | (const :tag "None" nil)) | |
311 | :parameter-document | |
312 | "If non-nil, specify how to remove `banners' from articles. | |
313 | ||
314 | Symbol `signature' means to remove signatures delimited by | |
315 | `gnus-signature-separator'. Any other symbol is used to look up a | |
316 | regular expression to match the banner in `gnus-article-banner-alist'. | |
317 | A string is used as a regular expression to match the banner | |
318 | directly.") | |
319 | ||
320 | (defcustom gnus-article-address-banner-alist nil | |
321 | "Alist of mail addresses and banners. | |
322 | Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp | |
323 | to match a mail address in the From: header, BANNER is one of a symbol | |
324 | `signature', an item in `gnus-article-banner-alist', a regexp and nil. | |
325 | If ADDRESS matches author's mail address, it will remove things like | |
326 | advertisements. For example: | |
327 | ||
328 | \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\")) | |
329 | " | |
330 | :type '(repeat | |
331 | (cons | |
332 | (regexp :tag "Address") | |
333 | (choice :tag "Banner" :value nil | |
334 | (const :tag "Remove signature" signature) | |
335 | (symbol :tag "Item in `gnus-article-banner-alist'" none) | |
336 | regexp | |
337 | (const :tag "None" nil)))) | |
bf247b6e | 338 | :version "22.1" |
23f87bed MB |
339 | :group 'gnus-article-washing) |
340 | ||
ae465fa7 MB |
341 | (defmacro gnus-emphasis-custom-with-format (&rest body) |
342 | `(let ((format "\ | |
343 | \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\ | |
344 | \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")) | |
345 | ,@body)) | |
346 | ||
347 | (defun gnus-emphasis-custom-value-to-external (value) | |
348 | (gnus-emphasis-custom-with-format | |
349 | (if (consp (car value)) | |
350 | (list (format format (car (car value)) (cdr (car value))) | |
351 | 2 | |
352 | (if (nth 1 value) 2 3) | |
353 | (nth 2 value)) | |
354 | value))) | |
355 | ||
356 | (defun gnus-emphasis-custom-value-to-internal (value) | |
357 | (gnus-emphasis-custom-with-format | |
358 | (let ((regexp (concat "\\`" | |
359 | (format (regexp-quote format) | |
360 | "\\([^()]+\\)" "\\([^()]+\\)") | |
361 | "\\'")) | |
362 | pattern) | |
363 | (if (string-match regexp (setq pattern (car value))) | |
364 | (list (cons (match-string 1 pattern) (match-string 2 pattern)) | |
365 | (= (nth 2 value) 2) | |
366 | (nth 3 value)) | |
367 | value)))) | |
368 | ||
eec82323 | 369 | (defcustom gnus-emphasis-alist |
ae465fa7 MB |
370 | (let ((types |
371 | '(("\\*" "\\*" bold nil 2) | |
23f87bed | 372 | ("_" "_" underline) |
eec82323 | 373 | ("/" "/" italic) |
eec82323 LMI |
374 | ("_/" "/_" underline-italic) |
375 | ("_\\*" "\\*_" underline-bold) | |
376 | ("\\*/" "/\\*" bold-italic) | |
377 | ("_\\*/" "/\\*_" underline-bold-italic)))) | |
ae465fa7 MB |
378 | (nconc |
379 | (gnus-emphasis-custom-with-format | |
380 | (mapcar (lambda (spec) | |
381 | (list (format format (car spec) (cadr spec)) | |
382 | (or (nth 3 spec) 2) | |
383 | (or (nth 4 spec) 3) | |
384 | (intern (format "gnus-emphasis-%s" (nth 2 spec))))) | |
385 | types)) | |
95f75c75 SM |
386 | '(;; I've never seen anyone use this strikethru convention whereas I've |
387 | ;; several times seen it triggered by normal text. --Stef | |
388 | ;; Miles suggests that this form is sometimes used but for italics, | |
389 | ;; so maybe we should map it to `italic'. | |
390 | ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)" | |
391 | ;; 2 3 gnus-emphasis-strikethru) | |
ae465fa7 MB |
392 | ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)" |
393 | 2 3 gnus-emphasis-underline)))) | |
6748645f | 394 | "*Alist that says how to fontify certain phrases. |
eec82323 LMI |
395 | Each item looks like this: |
396 | ||
397 | (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline) | |
398 | ||
399 | The first element is a regular expression to be matched. The second | |
400 | is a number that says what regular expression grouping used to find | |
401 | the entire emphasized word. The third is a number that says what | |
402 | regexp grouping should be displayed and highlighted. The fourth | |
403 | is the face used for highlighting." | |
ae465fa7 MB |
404 | :type |
405 | '(repeat | |
406 | (menu-choice | |
407 | :format "%[Customizing Style%]\n%v" | |
408 | :indent 2 | |
409 | (group :tag "Default" | |
410 | :value ("" 0 0 default) | |
411 | :value-create | |
412 | (lambda (widget) | |
413 | (let ((value (widget-get | |
414 | (cadr (widget-get (widget-get widget :parent) | |
415 | :args)) | |
416 | :value))) | |
417 | (if (not (eq (nth 2 value) 'default)) | |
418 | (widget-put | |
419 | widget | |
420 | :value | |
421 | (gnus-emphasis-custom-value-to-external value)))) | |
422 | (widget-group-value-create widget)) | |
ad136a7c MB |
423 | regexp |
424 | (integer :format "Match group: %v") | |
01c52d31 | 425 | (integer :format "Emphasize group: %v") |
ae465fa7 MB |
426 | face) |
427 | (group :tag "Simple" | |
428 | :value (("_" . "_") nil default) | |
429 | (cons :format "%v" | |
ad136a7c MB |
430 | (regexp :format "Start regexp: %v") |
431 | (regexp :format "End regexp: %v")) | |
ae465fa7 MB |
432 | (boolean :format "Show start and end patterns: %[%v%]\n" |
433 | :on " On " :off " Off ") | |
434 | face))) | |
435 | :get (lambda (symbol) | |
436 | (mapcar 'gnus-emphasis-custom-value-to-internal | |
437 | (default-value symbol))) | |
438 | :set (lambda (symbol value) | |
439 | (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external | |
440 | value))) | |
eec82323 LMI |
441 | :group 'gnus-article-emphasis) |
442 | ||
16409b0b GM |
443 | (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n" |
444 | "A regexp to describe whitespace which should not be emphasized. | |
445 | Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\". | |
446 | The former avoids underlining of leading and trailing whitespace, | |
447 | and the latter avoids underlining any whitespace at all." | |
fc2c2db8 | 448 | :version "21.1" |
16409b0b GM |
449 | :group 'gnus-article-emphasis |
450 | :type 'regexp) | |
451 | ||
23f87bed | 452 | (defface gnus-emphasis-bold '((t (:bold t))) |
eec82323 LMI |
453 | "Face used for displaying strong emphasized text (*word*)." |
454 | :group 'gnus-article-emphasis) | |
455 | ||
23f87bed | 456 | (defface gnus-emphasis-italic '((t (:italic t))) |
eec82323 LMI |
457 | "Face used for displaying italic emphasized text (/word/)." |
458 | :group 'gnus-article-emphasis) | |
459 | ||
460 | (defface gnus-emphasis-underline '((t (:underline t))) | |
461 | "Face used for displaying underlined emphasized text (_word_)." | |
462 | :group 'gnus-article-emphasis) | |
463 | ||
23f87bed | 464 | (defface gnus-emphasis-underline-bold '((t (:bold t :underline t))) |
eec82323 LMI |
465 | "Face used for displaying underlined bold emphasized text (_*word*_)." |
466 | :group 'gnus-article-emphasis) | |
467 | ||
23f87bed | 468 | (defface gnus-emphasis-underline-italic '((t (:italic t :underline t))) |
8de38c21 | 469 | "Face used for displaying underlined italic emphasized text (_/word/_)." |
eec82323 LMI |
470 | :group 'gnus-article-emphasis) |
471 | ||
23f87bed | 472 | (defface gnus-emphasis-bold-italic '((t (:bold t :italic t))) |
eec82323 LMI |
473 | "Face used for displaying bold italic emphasized text (/*word*/)." |
474 | :group 'gnus-article-emphasis) | |
475 | ||
476 | (defface gnus-emphasis-underline-bold-italic | |
23f87bed | 477 | '((t (:bold t :italic t :underline t))) |
eec82323 | 478 | "Face used for displaying underlined bold italic emphasized text. |
8f688cb0 | 479 | Example: (_/*word*/_)." |
eec82323 LMI |
480 | :group 'gnus-article-emphasis) |
481 | ||
23f87bed MB |
482 | (defface gnus-emphasis-strikethru (if (featurep 'xemacs) |
483 | '((t (:strikethru t))) | |
484 | '((t (:strike-through t)))) | |
485 | "Face used for displaying strike-through text (-word-)." | |
486 | :group 'gnus-article-emphasis) | |
487 | ||
16409b0b GM |
488 | (defface gnus-emphasis-highlight-words |
489 | '((t (:background "black" :foreground "yellow"))) | |
490 | "Face used for displaying highlighted words." | |
491 | :group 'gnus-article-emphasis) | |
492 | ||
01c52d31 | 493 | (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z" |
eec82323 | 494 | "Format for display of Date headers in article bodies. |
6748645f LMI |
495 | See `format-time-string' for the possible values. |
496 | ||
497 | The variable can also be function, which should return a complete Date | |
498 | header. The function is called with one argument, the time, which can | |
499 | be fed to `format-time-string'." | |
01c52d31 | 500 | :type '(choice string function) |
eec82323 LMI |
501 | :link '(custom-manual "(gnus)Article Date") |
502 | :group 'gnus-article-washing) | |
503 | ||
eec82323 | 504 | (defcustom gnus-save-all-headers t |
26c9afc3 MB |
505 | "*If non-nil, don't remove any headers before saving. |
506 | This will be overridden by the `:headers' property that the symbol of | |
507 | the saver function, which is specified by `gnus-default-article-saver', | |
508 | might have." | |
eec82323 LMI |
509 | :group 'gnus-article-saving |
510 | :type 'boolean) | |
511 | ||
512 | (defcustom gnus-prompt-before-saving 'always | |
513 | "*This variable says how much prompting is to be done when saving articles. | |
514 | If it is nil, no prompting will be done, and the articles will be | |
515 | saved to the default files. If this variable is `always', each and | |
516 | every article that is saved will be preceded by a prompt, even when | |
517 | saving large batches of articles. If this variable is neither nil not | |
518 | `always', there the user will be prompted once for a file name for | |
519 | each invocation of the saving commands." | |
520 | :group 'gnus-article-saving | |
521 | :type '(choice (item always) | |
522 | (item :tag "never" nil) | |
6748645f | 523 | (sexp :tag "once" :format "%t\n" :value t))) |
eec82323 LMI |
524 | |
525 | (defcustom gnus-saved-headers gnus-visible-headers | |
526 | "Headers to keep if `gnus-save-all-headers' is nil. | |
527 | If `gnus-save-all-headers' is non-nil, this variable will be ignored. | |
528 | If that variable is nil, however, all headers that match this regexp | |
26c9afc3 MB |
529 | will be kept while the rest will be deleted before saving. This and |
530 | `gnus-save-all-headers' will be overridden by the `:headers' property | |
531 | that the symbol of the saver function, which is specified by | |
532 | `gnus-default-article-saver', might have." | |
eec82323 | 533 | :group 'gnus-article-saving |
4bb6a3a6 | 534 | :type 'regexp) |
eec82323 | 535 | |
fef8d38e | 536 | ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before. |
eec82323 | 537 | (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail |
c5e87d10 | 538 | "A function to save articles in your favorite format. |
26c9afc3 MB |
539 | The function will be called by way of the `gnus-summary-save-article' |
540 | command, and friends such as `gnus-summary-save-article-rmail'. | |
eec82323 LMI |
541 | |
542 | Gnus provides the following functions: | |
543 | ||
544 | * gnus-summary-save-in-rmail (Rmail format) | |
545 | * gnus-summary-save-in-mail (Unix mail format) | |
546 | * gnus-summary-save-in-folder (MH folder) | |
547 | * gnus-summary-save-in-file (article format) | |
23f87bed | 548 | * gnus-summary-save-body-in-file (article body) |
eec82323 | 549 | * gnus-summary-save-in-vm (use VM's folder format) |
26c9afc3 MB |
550 | * gnus-summary-write-to-file (article format -- overwrite) |
551 | * gnus-summary-write-body-to-file (article body -- overwrite) | |
89167438 | 552 | * gnus-summary-save-in-pipe (article format) |
26c9afc3 MB |
553 | |
554 | The symbol of each function may have the following properties: | |
555 | ||
556 | * :decode | |
557 | The value non-nil means save decoded articles. This is meaningful | |
558 | only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file', | |
89167438 MB |
559 | `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and |
560 | `gnus-summary-save-in-pipe'. | |
26c9afc3 MB |
561 | |
562 | * :function | |
563 | The value specifies an alternative function which appends, not | |
564 | overwrites, articles to a file. This implies that when saving many | |
565 | articles at a time, `gnus-prompt-before-saving' is bound to t and all | |
566 | articles are saved in a single file. This is meaningful only with | |
567 | `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'. | |
568 | ||
569 | * :headers | |
570 | The value specifies the symbol of a variable of which the value | |
571 | specifies headers to be saved. If it is omitted, | |
572 | `gnus-save-all-headers' and `gnus-saved-headers' control what | |
573 | headers should be saved." | |
eec82323 LMI |
574 | :group 'gnus-article-saving |
575 | :type '(radio (function-item gnus-summary-save-in-rmail) | |
576 | (function-item gnus-summary-save-in-mail) | |
577 | (function-item gnus-summary-save-in-folder) | |
578 | (function-item gnus-summary-save-in-file) | |
23f87bed | 579 | (function-item gnus-summary-save-body-in-file) |
eec82323 | 580 | (function-item gnus-summary-save-in-vm) |
58090a8d | 581 | (function-item gnus-summary-write-to-file) |
26c9afc3 | 582 | (function-item gnus-summary-write-body-to-file) |
89167438 | 583 | (function-item gnus-summary-save-in-pipe) |
58090a8d | 584 | (function))) |
eec82323 | 585 | |
26c9afc3 MB |
586 | (defcustom gnus-article-save-coding-system |
587 | (or (and (mm-coding-system-p 'utf-8) 'utf-8) | |
588 | (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit) | |
589 | (and (mm-coding-system-p 'emacs-mule) 'emacs-mule) | |
590 | (and (mm-coding-system-p 'escape-quoted) 'escape-quoted)) | |
591 | "Coding system used to save decoded articles to a file. | |
592 | ||
593 | The recommended coding systems are `utf-8', `iso-2022-7bit' and so on, | |
594 | which can safely encode any characters in text. This is used by the | |
595 | commands including: | |
596 | ||
597 | * gnus-summary-save-article-file | |
598 | * gnus-summary-save-article-body-file | |
599 | * gnus-summary-write-article-file | |
600 | * gnus-summary-write-article-body-file | |
601 | ||
602 | and the functions to which you may set `gnus-default-article-saver': | |
603 | ||
604 | * gnus-summary-save-in-file | |
605 | * gnus-summary-save-body-in-file | |
606 | * gnus-summary-write-to-file | |
607 | * gnus-summary-write-body-to-file | |
608 | ||
609 | Those commands and functions save just text displayed in the article | |
610 | buffer to a file if the value of this variable is non-nil. Note that | |
611 | buttonized MIME parts will be lost in a saved file in that case. | |
612 | Otherwise, raw articles will be saved." | |
613 | :group 'gnus-article-saving | |
614 | :type `(choice | |
615 | :format "%{%t%}:\n %[Value Menu%] %v" | |
616 | (const :tag "Save raw articles" nil) | |
617 | ,@(delq nil | |
618 | (mapcar | |
619 | (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg)) | |
620 | '((const :tag "UTF-8" utf-8) | |
621 | (const :tag "iso-2022-7bit" iso-2022-7bit) | |
622 | (const :tag "Emacs internal" emacs-mule) | |
623 | (const :tag "escape-quoted" escape-quoted)))) | |
624 | (symbol :tag "Coding system"))) | |
625 | ||
eec82323 LMI |
626 | (defcustom gnus-rmail-save-name 'gnus-plain-save-name |
627 | "A function generating a file name to save articles in Rmail format. | |
628 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
629 | :group 'gnus-article-saving | |
630 | :type 'function) | |
631 | ||
632 | (defcustom gnus-mail-save-name 'gnus-plain-save-name | |
633 | "A function generating a file name to save articles in Unix mail format. | |
634 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
635 | :group 'gnus-article-saving | |
636 | :type 'function) | |
637 | ||
638 | (defcustom gnus-folder-save-name 'gnus-folder-save-name | |
639 | "A function generating a file name to save articles in MH folder. | |
640 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER." | |
641 | :group 'gnus-article-saving | |
642 | :type 'function) | |
643 | ||
644 | (defcustom gnus-file-save-name 'gnus-numeric-save-name | |
645 | "A function generating a file name to save articles in article format. | |
646 | The function is called with NEWSGROUP, HEADERS, and optional | |
647 | LAST-FILE." | |
648 | :group 'gnus-article-saving | |
649 | :type 'function) | |
650 | ||
651 | (defcustom gnus-split-methods | |
652 | '((gnus-article-archive-name) | |
653 | (gnus-article-nndoc-name)) | |
6748645f | 654 | "*Variable used to suggest where articles are to be saved. |
eec82323 LMI |
655 | For instance, if you would like to save articles related to Gnus in |
656 | the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
657 | you could set this variable to something like: | |
658 | ||
659 | '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
660 | (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
661 | ||
01c52d31 MB |
662 | This variable is an alist where the key is the match and the |
663 | value is a list of possible files to save in if the match is | |
664 | non-nil. | |
eec82323 LMI |
665 | |
666 | If the match is a string, it is used as a regexp match on the | |
667 | article. If the match is a symbol, that symbol will be funcalled | |
668 | from the buffer of the article to be saved with the newsgroup as the | |
99d99081 | 669 | parameter. If it is a list, it will be evalled in the same buffer. |
eec82323 | 670 | |
01c52d31 MB |
671 | If this form or function returns a string, this string will be used as a |
672 | possible file name; and if it returns a non-nil list, that list will be | |
673 | used as possible file names." | |
eec82323 | 674 | :group 'gnus-article-saving |
6748645f LMI |
675 | :type '(repeat (choice (list :value (fun) function) |
676 | (cons :value ("" "") regexp (repeat string)) | |
677 | (sexp :value nil)))) | |
eec82323 | 678 | |
eec82323 LMI |
679 | (defcustom gnus-page-delimiter "^\^L" |
680 | "*Regexp describing what to use as article page delimiters. | |
681 | The default value is \"^\^L\", which is a form linefeed at the | |
682 | beginning of a line." | |
683 | :type 'regexp | |
684 | :group 'gnus-article-various) | |
685 | ||
12295c5d | 686 | (defcustom gnus-article-mode-line-format "Gnus: %g %S%m" |
eec82323 | 687 | "*The format specification for the article mode line. |
16409b0b GM |
688 | See `gnus-summary-mode-line-format' for a closer description. |
689 | ||
690 | The following additional specs are available: | |
691 | ||
692 | %w The article washing status. | |
693 | %m The number of MIME parts in the article." | |
12295c5d | 694 | :version "24.1" |
eec82323 LMI |
695 | :type 'string |
696 | :group 'gnus-article-various) | |
697 | ||
698 | (defcustom gnus-article-mode-hook nil | |
699 | "*A hook for Gnus article mode." | |
700 | :type 'hook | |
701 | :group 'gnus-article-various) | |
702 | ||
23f87bed MB |
703 | (when (featurep 'xemacs) |
704 | ;; Extracted from gnus-xmas-define in order to preserve user settings | |
705 | (when (fboundp 'turn-off-scroll-in-place) | |
706 | (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place)) | |
707 | ;; Extracted from gnus-xmas-redefine in order to preserve user settings | |
708 | (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)) | |
709 | ||
eec82323 LMI |
710 | (defcustom gnus-article-menu-hook nil |
711 | "*Hook run after the creation of the article mode menu." | |
712 | :type 'hook | |
713 | :group 'gnus-article-various) | |
714 | ||
715 | (defcustom gnus-article-prepare-hook nil | |
16409b0b | 716 | "*A hook called after an article has been prepared in the article buffer." |
eec82323 LMI |
717 | :type 'hook |
718 | :group 'gnus-article-various) | |
719 | ||
01c52d31 MB |
720 | (defcustom gnus-copy-article-ignored-headers nil |
721 | "List of headers to be removed when copying an article. | |
722 | Each element is a regular expression." | |
330f707b | 723 | :version "23.1" ;; No Gnus |
01c52d31 MB |
724 | :type '(repeat regexp) |
725 | :group 'gnus-article-various) | |
726 | ||
265ac10b | 727 | (make-obsolete-variable 'gnus-article-hide-pgp-hook nil |
6b958814 | 728 | "Gnus 5.10 (Emacs 22.1)") |
a8151ef7 | 729 | |
01c52d31 MB |
730 | (defface gnus-button |
731 | '((t (:weight bold))) | |
732 | "Face used for highlighting a button in the article buffer." | |
733 | :group 'gnus-article-buttons) | |
734 | ||
735 | (defcustom gnus-article-button-face 'gnus-button | |
eec82323 LMI |
736 | "Face used for highlighting buttons in the article buffer. |
737 | ||
738 | An article button is a piece of text that you can activate by pressing | |
739 | `RET' or `mouse-2' above it." | |
740 | :type 'face | |
741 | :group 'gnus-article-buttons) | |
742 | ||
743 | (defcustom gnus-article-mouse-face 'highlight | |
744 | "Face used for mouse highlighting in the article buffer. | |
745 | ||
746 | Article buttons will be displayed in this face when the cursor is | |
747 | above them." | |
748 | :type 'face | |
749 | :group 'gnus-article-buttons) | |
750 | ||
0f49874b | 751 | (defcustom gnus-signature-face 'gnus-signature |
a8151ef7 | 752 | "Face used for highlighting a signature in the article buffer. |
0f49874b | 753 | Obsolete; use the face `gnus-signature' for customizations instead." |
eec82323 LMI |
754 | :type 'face |
755 | :group 'gnus-article-highlight | |
756 | :group 'gnus-article-signature) | |
757 | ||
0f49874b | 758 | (defface gnus-signature |
f59a3415 | 759 | '((t |
23f87bed | 760 | (:italic t))) |
a8151ef7 LMI |
761 | "Face used for highlighting a signature in the article buffer." |
762 | :group 'gnus-article-highlight | |
763 | :group 'gnus-article-signature) | |
0f49874b MB |
764 | ;; backward-compatibility alias |
765 | (put 'gnus-signature-face 'face-alias 'gnus-signature) | |
3d493bef | 766 | (put 'gnus-signature-face 'obsolete-face "22.1") |
a8151ef7 | 767 | |
0f49874b | 768 | (defface gnus-header-from |
eec82323 LMI |
769 | '((((class color) |
770 | (background dark)) | |
01c52d31 | 771 | (:foreground "PaleGreen1")) |
eec82323 LMI |
772 | (((class color) |
773 | (background light)) | |
6748645f | 774 | (:foreground "red3")) |
eec82323 | 775 | (t |
23f87bed | 776 | (:italic t))) |
eec82323 LMI |
777 | "Face used for displaying from headers." |
778 | :group 'gnus-article-headers | |
779 | :group 'gnus-article-highlight) | |
0f49874b MB |
780 | ;; backward-compatibility alias |
781 | (put 'gnus-header-from-face 'face-alias 'gnus-header-from) | |
3d493bef | 782 | (put 'gnus-header-from-face 'obsolete-face "22.1") |
eec82323 | 783 | |
0f49874b | 784 | (defface gnus-header-subject |
eec82323 LMI |
785 | '((((class color) |
786 | (background dark)) | |
01c52d31 | 787 | (:foreground "SeaGreen1")) |
eec82323 LMI |
788 | (((class color) |
789 | (background light)) | |
6748645f | 790 | (:foreground "red4")) |
eec82323 | 791 | (t |
23f87bed | 792 | (:bold t :italic t))) |
eec82323 LMI |
793 | "Face used for displaying subject headers." |
794 | :group 'gnus-article-headers | |
795 | :group 'gnus-article-highlight) | |
0f49874b MB |
796 | ;; backward-compatibility alias |
797 | (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject) | |
3d493bef | 798 | (put 'gnus-header-subject-face 'obsolete-face "22.1") |
eec82323 | 799 | |
0f49874b | 800 | (defface gnus-header-newsgroups |
eec82323 LMI |
801 | '((((class color) |
802 | (background dark)) | |
23f87bed | 803 | (:foreground "yellow" :italic t)) |
eec82323 LMI |
804 | (((class color) |
805 | (background light)) | |
23f87bed | 806 | (:foreground "MidnightBlue" :italic t)) |
eec82323 | 807 | (t |
23f87bed MB |
808 | (:italic t))) |
809 | "Face used for displaying newsgroups headers. | |
810 | In the default setup this face is only used for crossposted | |
811 | articles." | |
eec82323 LMI |
812 | :group 'gnus-article-headers |
813 | :group 'gnus-article-highlight) | |
0f49874b MB |
814 | ;; backward-compatibility alias |
815 | (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups) | |
3d493bef | 816 | (put 'gnus-header-newsgroups-face 'obsolete-face "22.1") |
eec82323 | 817 | |
0f49874b | 818 | (defface gnus-header-name |
eec82323 LMI |
819 | '((((class color) |
820 | (background dark)) | |
01c52d31 | 821 | (:foreground "SpringGreen2")) |
eec82323 LMI |
822 | (((class color) |
823 | (background light)) | |
824 | (:foreground "maroon")) | |
825 | (t | |
23f87bed | 826 | (:bold t))) |
eec82323 LMI |
827 | "Face used for displaying header names." |
828 | :group 'gnus-article-headers | |
829 | :group 'gnus-article-highlight) | |
0f49874b MB |
830 | ;; backward-compatibility alias |
831 | (put 'gnus-header-name-face 'face-alias 'gnus-header-name) | |
3d493bef | 832 | (put 'gnus-header-name-face 'obsolete-face "22.1") |
eec82323 | 833 | |
0f49874b | 834 | (defface gnus-header-content |
eec82323 LMI |
835 | '((((class color) |
836 | (background dark)) | |
01c52d31 | 837 | (:foreground "SpringGreen1" :italic t)) |
eec82323 LMI |
838 | (((class color) |
839 | (background light)) | |
23f87bed | 840 | (:foreground "indianred4" :italic t)) |
eec82323 | 841 | (t |
23f87bed | 842 | (:italic t))) "Face used for displaying header content." |
eec82323 LMI |
843 | :group 'gnus-article-headers |
844 | :group 'gnus-article-highlight) | |
0f49874b MB |
845 | ;; backward-compatibility alias |
846 | (put 'gnus-header-content-face 'face-alias 'gnus-header-content) | |
3d493bef | 847 | (put 'gnus-header-content-face 'obsolete-face "22.1") |
eec82323 LMI |
848 | |
849 | (defcustom gnus-header-face-alist | |
0f49874b MB |
850 | '(("From" nil gnus-header-from) |
851 | ("Subject" nil gnus-header-subject) | |
852 | ("Newsgroups:.*," nil gnus-header-newsgroups) | |
853 | ("" gnus-header-name gnus-header-content)) | |
23f87bed | 854 | "*Controls highlighting of article headers. |
eec82323 LMI |
855 | |
856 | An alist of the form (HEADER NAME CONTENT). | |
857 | ||
23f87bed MB |
858 | HEADER is a regular expression which should match the name of a |
859 | header and NAME and CONTENT are either face names or nil. | |
eec82323 LMI |
860 | |
861 | The name of each header field will be displayed using the face | |
23f87bed MB |
862 | specified by the first element in the list where HEADER matches |
863 | the header name and NAME is non-nil. Similarly, the content will | |
864 | be displayed by the first non-nil matching CONTENT face." | |
eec82323 LMI |
865 | :group 'gnus-article-headers |
866 | :group 'gnus-article-highlight | |
867 | :type '(repeat (list (regexp :tag "Header") | |
868 | (choice :tag "Name" | |
869 | (item :tag "skip" nil) | |
870 | (face :value default)) | |
871 | (choice :tag "Content" | |
872 | (item :tag "skip" nil) | |
873 | (face :value default))))) | |
874 | ||
01c52d31 MB |
875 | (defcustom gnus-face-properties-alist (if (featurep 'xemacs) |
876 | '((xface . (:face gnus-x-face))) | |
877 | '((pbm . (:face gnus-x-face)) | |
878 | (png . nil))) | |
879 | "Alist of image types and properties applied to Face and X-Face images. | |
880 | Here are examples: | |
881 | ||
882 | ;; Specify the altitude of Face images in the From header. | |
883 | \(setq gnus-face-properties-alist | |
884 | '((pbm . (:face gnus-x-face :ascent 80)) | |
885 | (png . (:ascent 80)))) | |
886 | ||
887 | ;; Show Face images as pressed buttons. | |
888 | \(setq gnus-face-properties-alist | |
889 | '((pbm . (:face gnus-x-face :relief -2)) | |
890 | (png . (:relief -2)))) | |
891 | ||
892 | See the manual for the valid properties for various image types. | |
893 | Currently, `pbm' is used for X-Face images and `png' is used for Face | |
894 | images in Emacs. Only the `:face' property is effective on the `xface' | |
895 | image type in XEmacs if it is built with the libcompface library." | |
330f707b | 896 | :version "23.1" ;; No Gnus |
01c52d31 MB |
897 | :group 'gnus-article-headers |
898 | :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist))) | |
899 | ||
16409b0b | 900 | (defcustom gnus-article-decode-hook |
23f87bed MB |
901 | '(article-decode-charset article-decode-encoded-words |
902 | article-decode-group-name article-decode-idna-rhs) | |
16409b0b GM |
903 | "*Hook run to decode charsets in articles." |
904 | :group 'gnus-article-headers | |
905 | :type 'hook) | |
906 | ||
907 | (defcustom gnus-display-mime-function 'gnus-display-mime | |
908 | "Function to display MIME articles." | |
909 | :group 'gnus-article-mime | |
910 | :type 'function) | |
911 | ||
912 | (defvar gnus-decode-header-function 'mail-decode-encoded-word-region | |
913 | "Function used to decode headers.") | |
914 | ||
343d6628 MB |
915 | (defvar gnus-decode-address-function 'mail-decode-encoded-address-region |
916 | "Function used to decode addresses.") | |
917 | ||
16409b0b | 918 | (defvar gnus-article-dumbquotes-map |
7cad71ad G |
919 | '((?\200 "EUR") |
920 | (?\202 ",") | |
921 | (?\203 "f") | |
922 | (?\204 ",,") | |
923 | (?\205 "...") | |
924 | (?\213 "<") | |
925 | (?\214 "OE") | |
926 | (?\221 "`") | |
927 | (?\222 "'") | |
928 | (?\223 "``") | |
929 | (?\224 "\"") | |
930 | (?\225 "*") | |
931 | (?\226 "-") | |
932 | (?\227 "--") | |
933 | (?\230 "~") | |
934 | (?\231 "(TM)") | |
935 | (?\233 ">") | |
936 | (?\234 "oe") | |
937 | (?\264 "'")) | |
16409b0b GM |
938 | "Table for MS-to-Latin1 translation.") |
939 | ||
940 | (defcustom gnus-ignored-mime-types nil | |
941 | "List of MIME types that should be ignored by Gnus." | |
fc2c2db8 | 942 | :version "21.1" |
16409b0b GM |
943 | :group 'gnus-article-mime |
944 | :type '(repeat regexp)) | |
945 | ||
946 | (defcustom gnus-unbuttonized-mime-types '(".*/.*") | |
23f87bed MB |
947 | "List of MIME types that should not be given buttons when rendered inline. |
948 | See also `gnus-buttonized-mime-types' which may override this variable. | |
949 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." | |
950 | :version "21.1" | |
951 | :group 'gnus-article-mime | |
952 | :type '(repeat regexp)) | |
953 | ||
954 | (defcustom gnus-buttonized-mime-types nil | |
955 | "List of MIME types that should be given buttons when rendered inline. | |
956 | If set, this variable overrides `gnus-unbuttonized-mime-types'. | |
957 | To see e.g. security buttons you could set this to | |
3031d8b0 MB |
958 | `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to |
959 | this list to display radio buttons that allow you to choose one of two | |
960 | media types those mails include. See also `mm-discouraged-alternatives'. | |
23f87bed | 961 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." |
bf247b6e | 962 | :version "22.1" |
16409b0b GM |
963 | :group 'gnus-article-mime |
964 | :type '(repeat regexp)) | |
965 | ||
23f87bed MB |
966 | (defcustom gnus-inhibit-mime-unbuttonizing nil |
967 | "If non-nil, all MIME parts get buttons. | |
968 | When nil (the default value), then some MIME parts do not get buttons, | |
969 | as described by the variables `gnus-buttonized-mime-types' and | |
970 | `gnus-unbuttonized-mime-types'." | |
bf247b6e | 971 | :version "22.1" |
d0859c9a | 972 | :group 'gnus-article-mime |
23f87bed MB |
973 | :type 'boolean) |
974 | ||
975 | (defcustom gnus-body-boundary-delimiter "_" | |
976 | "String used to delimit header and body. | |
977 | This variable is used by `gnus-article-treat-body-boundary' which can | |
978 | be controlled by `gnus-treat-body-boundary'." | |
bf247b6e | 979 | :version "22.1" |
23f87bed MB |
980 | :group 'gnus-article-various |
981 | :type '(choice (item :tag "None" :value nil) | |
982 | string)) | |
983 | ||
97f78c9b MB |
984 | (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces" |
985 | "/usr/share/picons") | |
23f87bed MB |
986 | "Defines the location of the faces database. |
987 | For information on obtaining this database of pretty pictures, please | |
988 | see http://www.cs.indiana.edu/picons/ftp/index.html" | |
bf247b6e | 989 | :version "22.1" |
23f87bed MB |
990 | :type '(repeat directory) |
991 | :link '(url-link :tag "download" | |
992 | "http://www.cs.indiana.edu/picons/ftp/index.html") | |
993 | :link '(custom-manual "(gnus)Picons") | |
994 | :group 'gnus-picon) | |
995 | ||
996 | (defun gnus-picons-installed-p () | |
997 | "Say whether picons are installed on your machine." | |
998 | (let ((installed nil)) | |
999 | (dolist (database gnus-picon-databases) | |
1000 | (when (file-exists-p database) | |
1001 | (setq installed t))) | |
1002 | installed)) | |
1003 | ||
16409b0b GM |
1004 | (defcustom gnus-article-mime-part-function nil |
1005 | "Function called with a MIME handle as the argument. | |
1006 | This is meant for people who want to do something automatic based | |
1007 | on parts -- for instance, adding Vcard info to a database." | |
1008 | :group 'gnus-article-mime | |
4a2358e9 MB |
1009 | :type '(choice (const nil) |
1010 | function)) | |
16409b0b GM |
1011 | |
1012 | (defcustom gnus-mime-multipart-functions nil | |
fc2c2db8 DL |
1013 | "An alist of MIME types to functions to display them." |
1014 | :version "21.1" | |
1015 | :group 'gnus-article-mime | |
01c52d31 | 1016 | :type '(repeat (cons :format "%v" (string :tag "MIME type") function))) |
16409b0b | 1017 | |
c61a8b44 | 1018 | (defcustom gnus-article-date-headers '(combined-lapsed) |
12e3ca0a LI |
1019 | "A list of Date header formats to display. |
1020 | Valid formats are `ut' (universal time), `local' (local time | |
1021 | zone), `english' (readable English), `lapsed' (elapsed time), | |
1022 | `combined-lapsed' (both the original date and the elapsed time), | |
1023 | `original' (the original date header), `iso8601' (ISO8601 | |
1024 | format), and `user-defined' (a user-defined format defined by the | |
1025 | `gnus-article-time-format' variable). | |
1026 | ||
1027 | You have as many date headers as you want in the article buffer. | |
1028 | Some of these headers are updated automatically. See | |
1029 | `gnus-article-update-date-headers' for details." | |
1030 | :version "24.1" | |
16409b0b | 1031 | :group 'gnus-article-headers |
a931698a GM |
1032 | :type '(set |
1033 | (const :tag "Universal time (UT)" ut) | |
1034 | (const :tag "Local time zone" local) | |
1035 | (const :tag "Readable English" english) | |
1036 | (const :tag "Elapsed time" lapsed) | |
1037 | (const :tag "Original and elapsed time" combined-lapsed) | |
1038 | (const :tag "Original date header" original) | |
1039 | (const :tag "ISO8601 format" iso8601) | |
1040 | (const :tag "User-defined" user-defined))) | |
12e3ca0a | 1041 | |
138c0212 | 1042 | (defcustom gnus-article-update-date-headers nil |
8e22bee0 | 1043 | "A number that says how often to update the date header (in seconds). |
647559c2 LI |
1044 | If nil, don't update it at all." |
1045 | :version "24.1" | |
1046 | :group 'gnus-article-headers | |
1047 | :type '(choice | |
1048 | (item :tag "Don't update" :value nil) | |
1049 | integer)) | |
1050 | ||
16409b0b GM |
1051 | (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative |
1052 | "Function called with a MIME handle as the argument. | |
1053 | This is meant for people who want to view first matched part. | |
a1506d29 JB |
1054 | For `undisplayed-alternative' (default), the first undisplayed |
1055 | part or alternative part is used. For `undisplayed', the first | |
1056 | undisplayed part is used. For a function, the first part which | |
f20b2f5c | 1057 | the function return t is used. For nil, the first part is |
16409b0b | 1058 | used." |
fc2c2db8 | 1059 | :version "21.1" |
16409b0b | 1060 | :group 'gnus-article-mime |
a1506d29 | 1061 | :type '(choice |
16409b0b GM |
1062 | (item :tag "first" :value nil) |
1063 | (item :tag "undisplayed" :value undisplayed) | |
a1506d29 | 1064 | (item :tag "undisplayed or alternative" |
16409b0b GM |
1065 | :value undisplayed-alternative) |
1066 | (function))) | |
1067 | ||
e0bad764 DL |
1068 | (defcustom gnus-mime-action-alist |
1069 | '(("save to file" . gnus-mime-save-part) | |
23f87bed | 1070 | ("save and strip" . gnus-mime-save-part-and-strip) |
01c52d31 | 1071 | ("replace with file" . gnus-mime-replace-part) |
23f87bed | 1072 | ("delete part" . gnus-mime-delete-part) |
e0bad764 DL |
1073 | ("display as text" . gnus-mime-inline-part) |
1074 | ("view the part" . gnus-mime-view-part) | |
1075 | ("pipe to command" . gnus-mime-pipe-part) | |
1076 | ("toggle display" . gnus-article-press-button) | |
23f87bed | 1077 | ("toggle display" . gnus-article-view-part-as-charset) |
e0bad764 | 1078 | ("view as type" . gnus-mime-view-part-as-type) |
23f87bed MB |
1079 | ("view internally" . gnus-mime-view-part-internally) |
1080 | ("view externally" . gnus-mime-view-part-externally)) | |
e0bad764 DL |
1081 | "An alist of actions that run on the MIME attachment." |
1082 | :group 'gnus-article-mime | |
1083 | :type '(repeat (cons (string :tag "name") | |
1084 | (function)))) | |
1085 | ||
01c52d31 MB |
1086 | (defcustom gnus-auto-select-part 1 |
1087 | "Advance to next MIME part when deleting or stripping parts. | |
1088 | ||
1089 | When 0, point will be placed on the same part as before. When | |
1090 | positive (negative), move point forward (backwards) this many | |
1091 | parts. When nil, redisplay article." | |
330f707b | 1092 | :version "23.1" ;; No Gnus |
01c52d31 MB |
1093 | :group 'gnus-article-mime |
1094 | :type '(choice (const nil :tag "Redisplay article.") | |
1095 | (const 1 :tag "Next part.") | |
1096 | (const 0 :tag "Current part.") | |
1097 | integer)) | |
1098 | ||
16409b0b GM |
1099 | ;;; |
1100 | ;;; The treatment variables | |
1101 | ;;; | |
1102 | ||
1103 | (defvar gnus-part-display-hook nil | |
1104 | "Hook called on parts that are to receive treatment.") | |
1105 | ||
1106 | (defvar gnus-article-treat-custom | |
1107 | '(choice (const :tag "Off" nil) | |
1108 | (const :tag "On" t) | |
1109 | (const :tag "Header" head) | |
01c52d31 | 1110 | (const :tag "First" first) |
16409b0b GM |
1111 | (const :tag "Last" last) |
1112 | (integer :tag "Less") | |
1113 | (repeat :tag "Groups" regexp) | |
1114 | (sexp :tag "Predicate"))) | |
1115 | ||
1116 | (defvar gnus-article-treat-head-custom | |
1117 | '(choice (const :tag "Off" nil) | |
1118 | (const :tag "Header" head))) | |
1119 | ||
01c52d31 | 1120 | (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim" |
da42d41a G |
1121 | "text/x-patch" "text/html") |
1122 | "Part types eligible for treatment.") | |
16409b0b GM |
1123 | |
1124 | (defvar gnus-inhibit-treatment nil | |
1125 | "Whether to inhibit treatment.") | |
1126 | ||
23f87bed | 1127 | (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard")) |
16409b0b | 1128 | "Highlight the signature. |
01c52d31 MB |
1129 | Valid values are nil, t, `head', `first', `last', an integer or a |
1130 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1131 | :group 'gnus-article-treat |
23f87bed | 1132 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1133 | :type gnus-article-treat-custom) |
1134 | (put 'gnus-treat-highlight-signature 'highlight t) | |
1135 | ||
1136 | (defcustom gnus-treat-buttonize 100000 | |
1137 | "Add buttons. | |
01c52d31 MB |
1138 | Valid values are nil, t, `head', `first', `last', an integer or a |
1139 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1140 | :group 'gnus-article-treat |
23f87bed | 1141 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1142 | :type gnus-article-treat-custom) |
1143 | (put 'gnus-treat-buttonize 'highlight t) | |
1144 | ||
1145 | (defcustom gnus-treat-buttonize-head 'head | |
1146 | "Add buttons to the head. | |
01c52d31 MB |
1147 | Valid values are nil, t, `head', `first', `last', an integer or a |
1148 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1149 | :group 'gnus-article-treat |
23f87bed | 1150 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1151 | :type gnus-article-treat-head-custom) |
1152 | (put 'gnus-treat-buttonize-head 'highlight t) | |
1153 | ||
12e3ca0a LI |
1154 | (defcustom gnus-treat-date 'head |
1155 | "Display dates according to the `gnus-article-date-headers' variable. | |
1156 | Valid values are nil, t, `head', `first', `last', an integer or a | |
1157 | predicate. See Info node `(gnus)Customizing Articles'." | |
1158 | :version "24.1" | |
1159 | :group 'gnus-article-treat | |
1160 | :link '(custom-manual "(gnus)Customizing Articles") | |
1161 | :type gnus-article-treat-head-custom) | |
1162 | ||
437ce4be | 1163 | (defcustom gnus-treat-emphasize 50000 |
16409b0b | 1164 | "Emphasize text. |
01c52d31 MB |
1165 | Valid values are nil, t, `head', `first', `last', an integer or a |
1166 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1167 | :group 'gnus-article-treat |
23f87bed | 1168 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1169 | :type gnus-article-treat-custom) |
1170 | (put 'gnus-treat-emphasize 'highlight t) | |
1171 | ||
1172 | (defcustom gnus-treat-strip-cr nil | |
1173 | "Remove carriage returns. | |
01c52d31 MB |
1174 | Valid values are nil, t, `head', `first', `last', an integer or a |
1175 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1176 | :version "22.1" |
16409b0b | 1177 | :group 'gnus-article-treat |
23f87bed MB |
1178 | :link '(custom-manual "(gnus)Customizing Articles") |
1179 | :type gnus-article-treat-custom) | |
1180 | ||
1181 | (defcustom gnus-treat-unsplit-urls nil | |
1182 | "Remove newlines from within URLs. | |
01c52d31 MB |
1183 | Valid values are nil, t, `head', `first', `last', an integer or a |
1184 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1185 | :version "22.1" |
23f87bed MB |
1186 | :group 'gnus-article-treat |
1187 | :link '(custom-manual "(gnus)Customizing Articles") | |
1188 | :type gnus-article-treat-custom) | |
1189 | ||
1190 | (defcustom gnus-treat-leading-whitespace nil | |
1191 | "Remove leading whitespace in headers. | |
01c52d31 MB |
1192 | Valid values are nil, t, `head', `first', `last', an integer or a |
1193 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1194 | :version "22.1" |
23f87bed MB |
1195 | :group 'gnus-article-treat |
1196 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1197 | :type gnus-article-treat-custom) |
1198 | ||
1199 | (defcustom gnus-treat-hide-headers 'head | |
1200 | "Hide headers. | |
01c52d31 MB |
1201 | Valid values are nil, t, `head', `first', `last', an integer or a |
1202 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1203 | :group 'gnus-article-treat |
23f87bed | 1204 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1205 | :type gnus-article-treat-head-custom) |
1206 | ||
1207 | (defcustom gnus-treat-hide-boring-headers nil | |
1208 | "Hide boring headers. | |
01c52d31 MB |
1209 | Valid values are nil, t, `head', `first', `last', an integer or a |
1210 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1211 | :group 'gnus-article-treat |
23f87bed | 1212 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1213 | :type gnus-article-treat-head-custom) |
1214 | ||
1215 | (defcustom gnus-treat-hide-signature nil | |
1216 | "Hide the signature. | |
01c52d31 MB |
1217 | Valid values are nil, t, `head', `first', `last', an integer or a |
1218 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1219 | :group 'gnus-article-treat |
23f87bed | 1220 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1221 | :type gnus-article-treat-custom) |
1222 | ||
1223 | (defcustom gnus-treat-fill-article nil | |
1224 | "Fill the article. | |
01c52d31 MB |
1225 | Valid values are nil, t, `head', `first', `last', an integer or a |
1226 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1227 | :group 'gnus-article-treat |
23f87bed | 1228 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1229 | :type gnus-article-treat-custom) |
1230 | ||
1231 | (defcustom gnus-treat-hide-citation nil | |
1232 | "Hide cited text. | |
01c52d31 | 1233 | Valid values are nil, t, `head', `first', `last', an integer or a |
a5166359 LMI |
1234 | predicate. See Info node `(gnus)Customizing Articles'. |
1235 | ||
1236 | See `gnus-article-highlight-citation' for variables used to | |
1237 | control what it hides." | |
16409b0b | 1238 | :group 'gnus-article-treat |
23f87bed | 1239 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1240 | :type gnus-article-treat-custom) |
1241 | ||
e0bad764 | 1242 | (defcustom gnus-treat-hide-citation-maybe nil |
e21bac42 | 1243 | "Hide cited text according to certain conditions. |
01c52d31 | 1244 | Valid values are nil, t, `head', `first', `last', an integer or a |
e21bac42 G |
1245 | predicate. See Info node `(gnus)Customizing Articles'. |
1246 | ||
1247 | See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for | |
1248 | how to control what it hides." | |
e0bad764 | 1249 | :group 'gnus-article-treat |
23f87bed | 1250 | :link '(custom-manual "(gnus)Customizing Articles") |
e0bad764 DL |
1251 | :type gnus-article-treat-custom) |
1252 | ||
16409b0b GM |
1253 | (defcustom gnus-treat-strip-list-identifiers 'head |
1254 | "Strip list identifiers from `gnus-list-identifiers`. | |
01c52d31 MB |
1255 | Valid values are nil, t, `head', `first', `last', an integer or a |
1256 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1257 | :version "21.1" |
16409b0b | 1258 | :group 'gnus-article-treat |
23f87bed | 1259 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1260 | :type gnus-article-treat-custom) |
1261 | ||
fb9b91be JD |
1262 | (gnus-define-group-parameter |
1263 | list-identifier | |
1264 | :variable-document | |
1265 | "Alist of regexps and correspondent identifiers." | |
1266 | :variable-group gnus-article-washing | |
1267 | :parameter-type | |
1268 | '(choice :tag "Identifier" | |
1269 | :value nil | |
1270 | (symbol :tag "Item in `gnus-list-identifiers'" none) | |
1271 | regexp | |
1272 | (const :tag "None" nil)) | |
1273 | :parameter-document | |
1274 | "If non-nil, specify how to remove `identifiers' from articles' subject. | |
1275 | ||
1276 | Any symbol is used to look up a regular expression to match the | |
1277 | banner in `gnus-list-identifiers'. A string is used as a regular | |
1278 | expression to match the identifier directly.") | |
1279 | ||
265ac10b SM |
1280 | (make-obsolete-variable 'gnus-treat-strip-pgp nil |
1281 | "Gnus 5.10 (Emacs 22.1)") | |
16409b0b GM |
1282 | |
1283 | (defcustom gnus-treat-strip-pem nil | |
1284 | "Strip PEM signatures. | |
01c52d31 MB |
1285 | Valid values are nil, t, `head', `first', `last', an integer or a |
1286 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1287 | :group 'gnus-article-treat |
23f87bed | 1288 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1289 | :type gnus-article-treat-custom) |
1290 | ||
1291 | (defcustom gnus-treat-strip-banner t | |
1292 | "Strip banners from articles. | |
1293 | The banner to be stripped is specified in the `banner' group parameter. | |
01c52d31 MB |
1294 | Valid values are nil, t, `head', `first', `last', an integer or a |
1295 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1296 | :group 'gnus-article-treat |
23f87bed | 1297 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1298 | :type gnus-article-treat-custom) |
1299 | ||
1300 | (defcustom gnus-treat-highlight-headers 'head | |
1301 | "Highlight the headers. | |
01c52d31 MB |
1302 | Valid values are nil, t, `head', `first', `last', an integer or a |
1303 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1304 | :group 'gnus-article-treat |
23f87bed | 1305 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1306 | :type gnus-article-treat-head-custom) |
1307 | (put 'gnus-treat-highlight-headers 'highlight t) | |
1308 | ||
1309 | (defcustom gnus-treat-highlight-citation t | |
1310 | "Highlight cited text. | |
01c52d31 MB |
1311 | Valid values are nil, t, `head', `first', `last', an integer or a |
1312 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1313 | :group 'gnus-article-treat |
23f87bed | 1314 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1315 | :type gnus-article-treat-custom) |
1316 | (put 'gnus-treat-highlight-citation 'highlight t) | |
1317 | ||
16409b0b GM |
1318 | (defcustom gnus-treat-strip-headers-in-body t |
1319 | "Strip the X-No-Archive header line from the beginning of the body. | |
01c52d31 MB |
1320 | Valid values are nil, t, `head', `first', `last', an integer or a |
1321 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1322 | :version "21.1" |
16409b0b | 1323 | :group 'gnus-article-treat |
23f87bed | 1324 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1325 | :type gnus-article-treat-custom) |
1326 | ||
1327 | (defcustom gnus-treat-strip-trailing-blank-lines nil | |
1328 | "Strip trailing blank lines. | |
01c52d31 MB |
1329 | Valid values are nil, t, `head', `first', `last', an integer or a |
1330 | predicate. See Info node `(gnus)Customizing Articles'. | |
292f71fe MB |
1331 | |
1332 | When set to t, it also strips trailing blanks in all MIME parts. | |
1333 | Consider to use `last' instead." | |
16409b0b | 1334 | :group 'gnus-article-treat |
23f87bed | 1335 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1336 | :type gnus-article-treat-custom) |
1337 | ||
1338 | (defcustom gnus-treat-strip-leading-blank-lines nil | |
1339 | "Strip leading blank lines. | |
01c52d31 MB |
1340 | Valid values are nil, t, `head', `first', `last', an integer or a |
1341 | predicate. See Info node `(gnus)Customizing Articles'. | |
292f71fe MB |
1342 | |
1343 | When set to t, it also strips trailing blanks in all MIME parts." | |
16409b0b | 1344 | :group 'gnus-article-treat |
23f87bed | 1345 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1346 | :type gnus-article-treat-custom) |
1347 | ||
1348 | (defcustom gnus-treat-strip-multiple-blank-lines nil | |
1349 | "Strip multiple blank lines. | |
01c52d31 MB |
1350 | Valid values are nil, t, `head', `first', `last', an integer or a |
1351 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1352 | :group 'gnus-article-treat |
23f87bed MB |
1353 | :link '(custom-manual "(gnus)Customizing Articles") |
1354 | :type gnus-article-treat-custom) | |
1355 | ||
1356 | (defcustom gnus-treat-unfold-headers 'head | |
1357 | "Unfold folded header lines. | |
01c52d31 MB |
1358 | Valid values are nil, t, `head', `first', `last', an integer or a |
1359 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1360 | :version "22.1" |
23f87bed MB |
1361 | :group 'gnus-article-treat |
1362 | :link '(custom-manual "(gnus)Customizing Articles") | |
1363 | :type gnus-article-treat-custom) | |
1364 | ||
01c52d31 MB |
1365 | (defcustom gnus-article-unfold-long-headers nil |
1366 | "If non-nil, allow unfolding headers even if the header is long. | |
1367 | If it is a regexp, only long headers matching this regexp are unfolded. | |
1368 | If it is t, all long headers are unfolded. | |
1369 | ||
1370 | This variable has no effect if `gnus-treat-unfold-headers' is nil." | |
330f707b | 1371 | :version "23.1" ;; No Gnus |
01c52d31 MB |
1372 | :group 'gnus-article-treat |
1373 | :type '(choice (const nil) | |
1374 | (const :tag "all" t) | |
1375 | (regexp))) | |
1376 | ||
23f87bed MB |
1377 | (defcustom gnus-treat-fold-headers nil |
1378 | "Fold headers. | |
01c52d31 MB |
1379 | Valid values are nil, t, `head', `first', `last', an integer or a |
1380 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1381 | :version "22.1" |
23f87bed MB |
1382 | :group 'gnus-article-treat |
1383 | :link '(custom-manual "(gnus)Customizing Articles") | |
1384 | :type gnus-article-treat-custom) | |
1385 | ||
1386 | (defcustom gnus-treat-fold-newsgroups 'head | |
1387 | "Fold the Newsgroups and Followup-To headers. | |
01c52d31 MB |
1388 | Valid values are nil, t, `head', `first', `last', an integer or a |
1389 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1390 | :version "22.1" |
23f87bed MB |
1391 | :group 'gnus-article-treat |
1392 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1393 | :type gnus-article-treat-custom) |
1394 | ||
1395 | (defcustom gnus-treat-overstrike t | |
1396 | "Treat overstrike highlighting. | |
01c52d31 MB |
1397 | Valid values are nil, t, `head', `first', `last', an integer or a |
1398 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1399 | :group 'gnus-article-treat |
23f87bed | 1400 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1401 | :type gnus-article-treat-custom) |
1402 | (put 'gnus-treat-overstrike 'highlight t) | |
1403 | ||
01c52d31 MB |
1404 | (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t) |
1405 | "Treat ANSI SGR control sequences. | |
1406 | Valid values are nil, t, `head', `first', `last', an integer or a | |
1407 | predicate. See Info node `(gnus)Customizing Articles'." | |
1408 | :group 'gnus-article-treat | |
1409 | :link '(custom-manual "(gnus)Customizing Articles") | |
1410 | :type gnus-article-treat-custom) | |
1411 | ||
23f87bed | 1412 | (make-obsolete-variable 'gnus-treat-display-xface |
6b958814 | 1413 | 'gnus-treat-display-x-face "Emacs 22.1") |
23f87bed MB |
1414 | |
1415 | (defcustom gnus-treat-display-x-face | |
1416 | (and (not noninteractive) | |
11e95b02 MB |
1417 | (gnus-image-type-available-p 'xbm) |
1418 | (if (featurep 'xemacs) | |
1419 | (featurep 'xface) | |
86f5c034 SM |
1420 | (condition-case nil |
1421 | (and (string-match "^0x" (shell-command-to-string "uncompface")) | |
1422 | (executable-find "icontopbm")) | |
1423 | ;; shell-command-to-string may signal an error, e.g. if | |
1424 | ;; shell-file-name is not found. | |
1425 | (error nil))) | |
8b93df01 | 1426 | 'head) |
16409b0b | 1427 | "Display X-Face headers. |
87ba2830 | 1428 | Valid values are nil and `head'. |
23f87bed MB |
1429 | See Info node `(gnus)Customizing Articles' and Info node |
1430 | `(gnus)X-Face' for details." | |
1431 | :group 'gnus-article-treat | |
1432 | :version "21.1" | |
1433 | :link '(custom-manual "(gnus)Customizing Articles") | |
1434 | :link '(custom-manual "(gnus)X-Face") | |
1435 | :type gnus-article-treat-head-custom | |
1436 | :set (lambda (symbol value) | |
1437 | (set-default | |
1438 | symbol | |
1439 | (cond ((or (boundp symbol) (get symbol 'saved-value)) | |
1440 | value) | |
1441 | ((boundp 'gnus-treat-display-xface) | |
1442 | (message "\ | |
1443 | ** gnus-treat-display-xface is an obsolete variable;\ | |
1444 | use gnus-treat-display-x-face instead") | |
1445 | (default-value 'gnus-treat-display-xface)) | |
1446 | ((get 'gnus-treat-display-xface 'saved-value) | |
1447 | (message "\ | |
1448 | ** gnus-treat-display-xface is an obsolete variable;\ | |
1449 | use gnus-treat-display-x-face instead") | |
1450 | (eval (car (get 'gnus-treat-display-xface 'saved-value)))) | |
1451 | (t | |
1452 | value))))) | |
1453 | (put 'gnus-treat-display-x-face 'highlight t) | |
1454 | ||
1455 | (defcustom gnus-treat-display-face | |
1456 | (and (not noninteractive) | |
11e95b02 | 1457 | (gnus-image-type-available-p 'png) |
23f87bed MB |
1458 | 'head) |
1459 | "Display Face headers. | |
01c52d31 MB |
1460 | Valid values are nil, t, `head', `first', `last', an integer or a |
1461 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
41ec3f54 | 1462 | node `(gnus)Face' for details." |
16409b0b | 1463 | :group 'gnus-article-treat |
bf247b6e | 1464 | :version "22.1" |
23f87bed MB |
1465 | :link '(custom-manual "(gnus)Customizing Articles") |
1466 | :link '(custom-manual "(gnus)X-Face") | |
16409b0b | 1467 | :type gnus-article-treat-head-custom) |
23f87bed | 1468 | (put 'gnus-treat-display-face 'highlight t) |
16409b0b | 1469 | |
11e95b02 | 1470 | (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm) |
16409b0b | 1471 | "Display smileys. |
01c52d31 MB |
1472 | Valid values are nil, t, `head', `first', `last', an integer or a |
1473 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1474 | node `(gnus)Smileys' for details." | |
16409b0b | 1475 | :group 'gnus-article-treat |
b5a206e7 | 1476 | :version "21.1" |
23f87bed MB |
1477 | :link '(custom-manual "(gnus)Customizing Articles") |
1478 | :link '(custom-manual "(gnus)Smileys") | |
16409b0b GM |
1479 | :type gnus-article-treat-custom) |
1480 | (put 'gnus-treat-display-smileys 'highlight t) | |
1481 | ||
23f87bed MB |
1482 | (defcustom gnus-treat-from-picon |
1483 | (if (and (gnus-image-type-available-p 'xpm) | |
1484 | (gnus-picons-installed-p)) | |
1485 | 'head nil) | |
1486 | "Display picons in the From header. | |
01c52d31 MB |
1487 | Valid values are nil, t, `head', `first', `last', an integer or a |
1488 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1489 | node `(gnus)Picons' for details." | |
bf247b6e | 1490 | :version "22.1" |
16409b0b | 1491 | :group 'gnus-article-treat |
23f87bed MB |
1492 | :group 'gnus-picon |
1493 | :link '(custom-manual "(gnus)Customizing Articles") | |
1494 | :link '(custom-manual "(gnus)Picons") | |
1495 | :type gnus-article-treat-head-custom) | |
1496 | (put 'gnus-treat-from-picon 'highlight t) | |
1497 | ||
1498 | (defcustom gnus-treat-mail-picon | |
1499 | (if (and (gnus-image-type-available-p 'xpm) | |
1500 | (gnus-picons-installed-p)) | |
1501 | 'head nil) | |
1502 | "Display picons in To and Cc headers. | |
01c52d31 MB |
1503 | Valid values are nil, t, `head', `first', `last', an integer or a |
1504 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1505 | node `(gnus)Picons' for details." | |
bf247b6e | 1506 | :version "22.1" |
23f87bed MB |
1507 | :group 'gnus-article-treat |
1508 | :group 'gnus-picon | |
1509 | :link '(custom-manual "(gnus)Customizing Articles") | |
1510 | :link '(custom-manual "(gnus)Picons") | |
1511 | :type gnus-article-treat-head-custom) | |
1512 | (put 'gnus-treat-mail-picon 'highlight t) | |
1513 | ||
1514 | (defcustom gnus-treat-newsgroups-picon | |
1515 | (if (and (gnus-image-type-available-p 'xpm) | |
1516 | (gnus-picons-installed-p)) | |
1517 | 'head nil) | |
1518 | "Display picons in the Newsgroups and Followup-To headers. | |
01c52d31 MB |
1519 | Valid values are nil, t, `head', `first', `last', an integer or a |
1520 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1521 | node `(gnus)Picons' for details." | |
bf247b6e | 1522 | :version "22.1" |
23f87bed MB |
1523 | :group 'gnus-article-treat |
1524 | :group 'gnus-picon | |
1525 | :link '(custom-manual "(gnus)Customizing Articles") | |
1526 | :link '(custom-manual "(gnus)Picons") | |
1527 | :type gnus-article-treat-head-custom) | |
1528 | (put 'gnus-treat-newsgroups-picon 'highlight t) | |
1529 | ||
6688abe0 | 1530 | (defcustom gnus-treat-from-gravatar nil |
61b1af82 G |
1531 | "Display gravatars in the From header. |
1532 | Valid values are nil, t, `head', `first', `last', an integer or a | |
1533 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1534 | node `(gnus)Gravatars' for details." | |
1535 | :version "24.1" | |
1536 | :group 'gnus-article-treat | |
1537 | :group 'gnus-gravatar | |
1538 | :link '(custom-manual "(gnus)Customizing Articles") | |
1539 | :link '(custom-manual "(gnus)Gravatars") | |
1540 | :type gnus-article-treat-head-custom) | |
1541 | (put 'gnus-treat-from-gravatar 'highlight t) | |
1542 | ||
6688abe0 | 1543 | (defcustom gnus-treat-mail-gravatar nil |
61b1af82 G |
1544 | "Display gravatars in To and Cc headers. |
1545 | Valid values are nil, t, `head', `first', `last', an integer or a | |
1546 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1547 | node `(gnus)Gravatars' for details." | |
1548 | :version "24.1" | |
1549 | :group 'gnus-article-treat | |
1550 | :group 'gnus-gravatar | |
1551 | :link '(custom-manual "(gnus)Customizing Articles") | |
1552 | :link '(custom-manual "(gnus)Gravatars") | |
1553 | :type gnus-article-treat-head-custom) | |
1554 | (put 'gnus-treat-mail-gravatar 'highlight t) | |
1555 | ||
23f87bed | 1556 | (defcustom gnus-treat-body-boundary |
437ce4be MB |
1557 | (if (or gnus-treat-newsgroups-picon |
1558 | gnus-treat-mail-picon | |
61b1af82 G |
1559 | gnus-treat-from-picon |
1560 | gnus-treat-from-gravatar | |
1561 | gnus-treat-mail-gravatar) | |
91af3942 | 1562 | ;; If there's much decoration, the user might prefer a boundary. |
437ce4be MB |
1563 | 'head |
1564 | nil) | |
23f87bed MB |
1565 | "Draw a boundary at the end of the headers. |
1566 | Valid values are nil and `head'. | |
1567 | See Info node `(gnus)Customizing Articles' for details." | |
bf247b6e | 1568 | :version "22.1" |
23f87bed MB |
1569 | :group 'gnus-article-treat |
1570 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b | 1571 | :type gnus-article-treat-head-custom) |
16409b0b GM |
1572 | |
1573 | (defcustom gnus-treat-capitalize-sentences nil | |
1574 | "Capitalize sentence-starting words. | |
01c52d31 MB |
1575 | Valid values are nil, t, `head', `first', `last', an integer or a |
1576 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1577 | :version "21.1" |
16409b0b | 1578 | :group 'gnus-article-treat |
23f87bed MB |
1579 | :link '(custom-manual "(gnus)Customizing Articles") |
1580 | :type gnus-article-treat-custom) | |
1581 | ||
1582 | (defcustom gnus-treat-wash-html nil | |
1583 | "Format as HTML. | |
01c52d31 MB |
1584 | Valid values are nil, t, `head', `first', `last', an integer or a |
1585 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1586 | :version "22.1" |
23f87bed MB |
1587 | :group 'gnus-article-treat |
1588 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1589 | :type gnus-article-treat-custom) |
1590 | ||
389b76fa | 1591 | (defcustom gnus-treat-fill-long-lines '(typep "text/plain") |
16409b0b | 1592 | "Fill long lines. |
01c52d31 MB |
1593 | Valid values are nil, t, `head', `first', `last', an integer or a |
1594 | predicate. See Info node `(gnus)Customizing Articles'." | |
37657cbd | 1595 | :version "24.1" |
16409b0b | 1596 | :group 'gnus-article-treat |
23f87bed | 1597 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1598 | :type gnus-article-treat-custom) |
1599 | ||
23f87bed MB |
1600 | (defcustom gnus-treat-x-pgp-sig nil |
1601 | "Verify X-PGP-Sig. | |
1602 | To automatically treat X-PGP-Sig, set it to head. | |
01c52d31 MB |
1603 | Valid values are nil, t, `head', `first', `last', an integer or a |
1604 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1605 | :version "22.1" |
23f87bed MB |
1606 | :group 'gnus-article-treat |
1607 | :group 'mime-security | |
1608 | :link '(custom-manual "(gnus)Customizing Articles") | |
1609 | :type gnus-article-treat-custom) | |
1610 | ||
1611 | (defvar gnus-article-encrypt-protocol-alist | |
1612 | '(("PGP" . mml2015-self-encrypt))) | |
1613 | ||
1614 | ;; Set to nil if more than one protocol added to | |
1615 | ;; gnus-article-encrypt-protocol-alist. | |
1616 | (defcustom gnus-article-encrypt-protocol "PGP" | |
1617 | "The protocol used for encrypt articles. | |
1618 | It is a string, such as \"PGP\". If nil, ask user." | |
bf247b6e | 1619 | :version "22.1" |
23f87bed MB |
1620 | :type 'string |
1621 | :group 'mime-security) | |
1622 | ||
23f87bed MB |
1623 | (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error)) |
1624 | (mm-coding-system-p 'utf-8) | |
1625 | (executable-find idna-program)) | |
1626 | "Whether IDNA decoding of headers is used when viewing messages. | |
1627 | This requires GNU Libidn, and by default only enabled if it is found." | |
bf247b6e | 1628 | :version "22.1" |
23f87bed MB |
1629 | :group 'gnus-article-headers |
1630 | :type 'boolean) | |
1631 | ||
1632 | (defcustom gnus-article-over-scroll nil | |
1633 | "If non-nil, allow scrolling the article buffer even when there no more text." | |
bf247b6e | 1634 | :version "22.1" |
23f87bed MB |
1635 | :group 'gnus-article |
1636 | :type 'boolean) | |
1637 | ||
40de2c6d KY |
1638 | (defcustom gnus-inhibit-images nil |
1639 | "Non-nil means inhibit displaying of images inline in the article body." | |
1640 | :version "24.1" | |
1641 | :group 'gnus-article | |
1642 | :type 'boolean) | |
1643 | ||
2526f423 G |
1644 | (defcustom gnus-blocked-images 'gnus-block-private-groups |
1645 | "Images that have URLs matching this regexp will be blocked. | |
1646 | This can also be a function to be evaluated. If so, it will be | |
1647 | called with the group name as the parameter, and should return a | |
1648 | regexp." | |
130e977f LMI |
1649 | :version "24.1" |
1650 | :group 'gnus-art | |
a931698a | 1651 | :type '(choice regexp function)) |
130e977f | 1652 | |
eec82323 LMI |
1653 | ;;; Internal variables |
1654 | ||
23f87bed MB |
1655 | (defvar gnus-english-month-names |
1656 | '("January" "February" "March" "April" "May" "June" "July" "August" | |
1657 | "September" "October" "November" "December")) | |
1658 | ||
16409b0b GM |
1659 | (defvar article-goto-body-goes-to-point-min-p nil) |
1660 | (defvar gnus-article-wash-types nil) | |
1661 | (defvar gnus-article-emphasis-alist nil) | |
23f87bed | 1662 | (defvar gnus-article-image-alist nil) |
16409b0b GM |
1663 | |
1664 | (defvar gnus-article-mime-handle-alist-1 nil) | |
1665 | (defvar gnus-treatment-function-alist | |
052bd38a LMI |
1666 | '((gnus-treat-strip-cr gnus-article-remove-cr) |
1667 | (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig) | |
23f87bed | 1668 | (gnus-treat-strip-banner gnus-article-strip-banner) |
16409b0b GM |
1669 | (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body) |
1670 | (gnus-treat-highlight-signature gnus-article-highlight-signature) | |
1671 | (gnus-treat-buttonize gnus-article-add-buttons) | |
1672 | (gnus-treat-fill-article gnus-article-fill-cited-article) | |
389b76fa | 1673 | (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines) |
23f87bed | 1674 | (gnus-treat-unsplit-urls gnus-article-unsplit-urls) |
23f87bed MB |
1675 | (gnus-treat-display-x-face gnus-article-display-x-face) |
1676 | (gnus-treat-display-face gnus-article-display-face) | |
16409b0b GM |
1677 | (gnus-treat-hide-headers gnus-article-maybe-hide-headers) |
1678 | (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers) | |
1679 | (gnus-treat-hide-signature gnus-article-hide-signature) | |
16409b0b | 1680 | (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers) |
23f87bed | 1681 | (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace) |
2696d88f G |
1682 | (gnus-treat-from-picon gnus-treat-from-picon) |
1683 | (gnus-treat-mail-picon gnus-treat-mail-picon) | |
1684 | (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon) | |
16409b0b | 1685 | (gnus-treat-strip-pem gnus-article-hide-pem) |
12e3ca0a | 1686 | (gnus-treat-date gnus-article-treat-date) |
61b1af82 G |
1687 | (gnus-treat-from-gravatar gnus-treat-from-gravatar) |
1688 | (gnus-treat-mail-gravatar gnus-treat-mail-gravatar) | |
16409b0b | 1689 | (gnus-treat-highlight-headers gnus-article-highlight-headers) |
16409b0b | 1690 | (gnus-treat-highlight-signature gnus-article-highlight-signature) |
16409b0b GM |
1691 | (gnus-treat-strip-trailing-blank-lines |
1692 | gnus-article-remove-trailing-blank-lines) | |
1693 | (gnus-treat-strip-leading-blank-lines | |
1694 | gnus-article-strip-leading-blank-lines) | |
1695 | (gnus-treat-strip-multiple-blank-lines | |
1696 | gnus-article-strip-multiple-blank-lines) | |
1697 | (gnus-treat-overstrike gnus-article-treat-overstrike) | |
01c52d31 | 1698 | (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences) |
23f87bed | 1699 | (gnus-treat-unfold-headers gnus-article-treat-unfold-headers) |
23f87bed | 1700 | (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups) |
01c52d31 | 1701 | (gnus-treat-fold-headers gnus-article-treat-fold-headers) |
16409b0b | 1702 | (gnus-treat-buttonize-head gnus-article-add-buttons-to-head) |
23f87bed | 1703 | (gnus-treat-display-smileys gnus-treat-smiley) |
16409b0b | 1704 | (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences) |
23f87bed MB |
1705 | (gnus-treat-wash-html gnus-article-wash-html) |
1706 | (gnus-treat-emphasize gnus-article-emphasize) | |
1707 | (gnus-treat-hide-citation gnus-article-hide-citation) | |
1708 | (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe) | |
1709 | (gnus-treat-highlight-citation gnus-article-highlight-citation) | |
8ccbef23 | 1710 | (gnus-treat-body-boundary gnus-article-treat-body-boundary))) |
16409b0b GM |
1711 | |
1712 | (defvar gnus-article-mime-handle-alist nil) | |
6748645f LMI |
1713 | (defvar article-lapsed-timer nil) |
1714 | (defvar gnus-article-current-summary nil) | |
1715 | ||
eec82323 LMI |
1716 | (defvar gnus-article-mode-syntax-table |
1717 | (let ((table (copy-syntax-table text-mode-syntax-table))) | |
23f87bed MB |
1718 | ;; This causes the citation match run O(2^n). |
1719 | ;; (modify-syntax-entry ?- "w" table) | |
1720 | (modify-syntax-entry ?> ")<" table) | |
1721 | (modify-syntax-entry ?< "(>" table) | |
1722 | ;; make M-. in article buffers work for `foo' strings | |
1723 | (modify-syntax-entry ?' " " table) | |
1724 | (modify-syntax-entry ?` " " table) | |
eec82323 LMI |
1725 | table) |
1726 | "Syntax table used in article mode buffers. | |
1727 | Initialized from `text-mode-syntax-table.") | |
1728 | ||
1729 | (defvar gnus-save-article-buffer nil) | |
1730 | ||
eec82323 LMI |
1731 | (defvar gnus-number-of-articles-to-be-saved nil) |
1732 | ||
1733 | (defvar gnus-inhibit-hiding nil) | |
1734 | ||
c1d7d285 MB |
1735 | (defvar gnus-article-edit-mode nil) |
1736 | ||
23f87bed MB |
1737 | ;;; Macros for dealing with the article buffer. |
1738 | ||
1739 | (defmacro gnus-with-article-headers (&rest forms) | |
80de1778 | 1740 | `(with-current-buffer gnus-article-buffer |
23f87bed MB |
1741 | (save-restriction |
1742 | (let ((inhibit-read-only t) | |
1743 | (inhibit-point-motion-hooks t) | |
1744 | (case-fold-search t)) | |
1745 | (article-narrow-to-head) | |
1746 | ,@forms)))) | |
1747 | ||
1748 | (put 'gnus-with-article-headers 'lisp-indent-function 0) | |
1749 | (put 'gnus-with-article-headers 'edebug-form-spec '(body)) | |
1750 | ||
1751 | (defmacro gnus-with-article-buffer (&rest forms) | |
e1a135a9 | 1752 | `(when (buffer-live-p (get-buffer gnus-article-buffer)) |
3b0468c4 JD |
1753 | (with-current-buffer gnus-article-buffer |
1754 | (let ((inhibit-read-only t)) | |
1755 | ,@forms)))) | |
23f87bed MB |
1756 | |
1757 | (put 'gnus-with-article-buffer 'lisp-indent-function 0) | |
1758 | (put 'gnus-with-article-buffer 'edebug-form-spec '(body)) | |
1759 | ||
1760 | (defun gnus-article-goto-header (header) | |
1761 | "Go to HEADER, which is a regular expression." | |
1762 | (re-search-forward (concat "^\\(" header "\\):") nil t)) | |
1763 | ||
eec82323 LMI |
1764 | (defsubst gnus-article-hide-text (b e props) |
1765 | "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
520aa572 | 1766 | (gnus-add-text-properties-when 'article-type nil b e props) |
eec82323 LMI |
1767 | (when (memq 'intangible props) |
1768 | (put-text-property | |
1769 | (max (1- b) (point-min)) | |
1770 | b 'intangible (cddr (memq 'intangible props))))) | |
520aa572 | 1771 | |
eec82323 LMI |
1772 | (defsubst gnus-article-unhide-text (b e) |
1773 | "Remove hidden text properties from region between B and E." | |
1774 | (remove-text-properties b e gnus-hidden-properties) | |
1775 | (when (memq 'intangible gnus-hidden-properties) | |
1776 | (put-text-property (max (1- b) (point-min)) | |
1777 | b 'intangible nil))) | |
1778 | ||
1779 | (defun gnus-article-hide-text-type (b e type) | |
1780 | "Hide text of TYPE between B and E." | |
23f87bed | 1781 | (gnus-add-wash-type type) |
eec82323 LMI |
1782 | (gnus-article-hide-text |
1783 | b e (cons 'article-type (cons type gnus-hidden-properties)))) | |
1784 | ||
1785 | (defun gnus-article-unhide-text-type (b e type) | |
6748645f | 1786 | "Unhide text of TYPE between B and E." |
23f87bed | 1787 | (gnus-delete-wash-type type) |
eec82323 LMI |
1788 | (remove-text-properties |
1789 | b e (cons 'article-type (cons type gnus-hidden-properties))) | |
1790 | (when (memq 'intangible gnus-hidden-properties) | |
1791 | (put-text-property (max (1- b) (point-min)) | |
1792 | b 'intangible nil))) | |
1793 | ||
eec82323 LMI |
1794 | (defun gnus-article-delete-text-of-type (type) |
1795 | "Delete text of TYPE in the current buffer." | |
1796 | (save-excursion | |
a8151ef7 | 1797 | (let ((b (point-min))) |
7dafe00b MB |
1798 | (if (eq type 'multipart) |
1799 | ;; Remove MIME buttons associated with multipart/alternative parts. | |
1800 | (progn | |
1801 | (goto-char b) | |
1802 | (while (if (get-text-property (point) 'gnus-part) | |
1803 | (setq b (point)) | |
1804 | (when (setq b (next-single-property-change (point) | |
1805 | 'gnus-part)) | |
1806 | (goto-char b) | |
1807 | t)) | |
1808 | (end-of-line) | |
1809 | (skip-chars-forward "\n") | |
1810 | (when (eq (get-text-property b 'article-type) 'multipart) | |
1811 | (delete-region b (point))))) | |
1812 | (while (setq b (text-property-any b (point-max) 'article-type type)) | |
1813 | (delete-region | |
1814 | b (or (text-property-not-all b (point-max) 'article-type type) | |
1815 | (point-max)))))))) | |
eec82323 LMI |
1816 | |
1817 | (defun gnus-article-delete-invisible-text () | |
1818 | "Delete all invisible text in the current buffer." | |
1819 | (save-excursion | |
a8151ef7 LMI |
1820 | (let ((b (point-min))) |
1821 | (while (setq b (text-property-any b (point-max) 'invisible t)) | |
1822 | (delete-region | |
1823 | b (or (text-property-not-all b (point-max) 'invisible t) | |
1824 | (point-max))))))) | |
eec82323 | 1825 | |
eec82323 LMI |
1826 | (defsubst gnus-article-header-rank () |
1827 | "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
1828 | (let ((list gnus-sorted-header-list) | |
23f87bed | 1829 | (i 1)) |
eec82323 | 1830 | (while list |
23f87bed MB |
1831 | (if (looking-at (car list)) |
1832 | (setq list nil) | |
1833 | (setq list (cdr list)) | |
1834 | (incf i))) | |
1835 | i)) | |
eec82323 LMI |
1836 | |
1837 | (defun article-hide-headers (&optional arg delete) | |
16409b0b GM |
1838 | "Hide unwanted headers and possibly sort them as well." |
1839 | (interactive) | |
1840 | ;; This function might be inhibited. | |
1841 | (unless gnus-inhibit-hiding | |
37cc095b | 1842 | (let ((inhibit-read-only t) |
23f87bed MB |
1843 | (case-fold-search t) |
1844 | (max (1+ (length gnus-sorted-header-list))) | |
1845 | (inhibit-point-motion-hooks t) | |
1846 | (cur (current-buffer)) | |
1847 | ignored visible beg) | |
1848 | (save-excursion | |
1849 | ;; `gnus-ignored-headers' and `gnus-visible-headers' may be | |
1850 | ;; group parameters, so we should go to the summary buffer. | |
1851 | (when (prog1 | |
1852 | (condition-case nil | |
1853 | (progn (set-buffer gnus-summary-buffer) t) | |
1854 | (error nil)) | |
1855 | (setq ignored (when (not gnus-visible-headers) | |
1856 | (cond ((stringp gnus-ignored-headers) | |
1857 | gnus-ignored-headers) | |
1858 | ((listp gnus-ignored-headers) | |
1859 | (mapconcat 'identity | |
1860 | gnus-ignored-headers | |
1861 | "\\|")))) | |
1862 | visible (cond ((stringp gnus-visible-headers) | |
1863 | gnus-visible-headers) | |
1864 | ((and gnus-visible-headers | |
1865 | (listp gnus-visible-headers)) | |
1866 | (mapconcat 'identity | |
1867 | gnus-visible-headers | |
1868 | "\\|"))))) | |
1869 | (set-buffer cur)) | |
1870 | (save-restriction | |
16409b0b GM |
1871 | ;; First we narrow to just the headers. |
1872 | (article-narrow-to-head) | |
1873 | ;; Hide any "From " lines at the beginning of (mail) articles. | |
1874 | (while (looking-at "From ") | |
1875 | (forward-line 1)) | |
1876 | (unless (bobp) | |
1877 | (delete-region (point-min) (point))) | |
1878 | ;; Then treat the rest of the header lines. | |
1879 | ;; Then we use the two regular expressions | |
1880 | ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
1881 | ;; select which header lines is to remain visible in the | |
1882 | ;; article buffer. | |
23f87bed | 1883 | (while (re-search-forward "^[^ \t:]*:" nil t) |
16409b0b GM |
1884 | (beginning-of-line) |
1885 | ;; Mark the rank of the header. | |
1886 | (put-text-property | |
1887 | (point) (1+ (point)) 'message-rank | |
1888 | (if (or (and visible (looking-at visible)) | |
1889 | (and ignored | |
1890 | (not (looking-at ignored)))) | |
1891 | (gnus-article-header-rank) | |
1892 | (+ 2 max))) | |
1893 | (forward-line 1)) | |
1894 | (message-sort-headers-1) | |
1895 | (when (setq beg (text-property-any | |
1896 | (point-min) (point-max) 'message-rank (+ 2 max))) | |
1897 | ;; We delete the unwanted headers. | |
23f87bed | 1898 | (gnus-add-wash-type 'headers) |
16409b0b GM |
1899 | (add-text-properties (point-min) (+ 5 (point-min)) |
1900 | '(article-type headers dummy-invisible t)) | |
1901 | (delete-region beg (point-max)))))))) | |
eec82323 LMI |
1902 | |
1903 | (defun article-hide-boring-headers (&optional arg) | |
1904 | "Toggle hiding of headers that aren't very interesting. | |
1905 | If given a negative prefix, always show; if given a positive prefix, | |
1906 | always hide." | |
1907 | (interactive (gnus-article-hidden-arg)) | |
1908 | (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) | |
1909 | (not gnus-show-all-headers)) | |
1910 | (save-excursion | |
1911 | (save-restriction | |
4e7d0221 | 1912 | (let ((inhibit-read-only t) |
01c52d31 | 1913 | (inhibit-point-motion-hooks t)) |
16409b0b | 1914 | (article-narrow-to-head) |
01c52d31 | 1915 | (dolist (elem gnus-boring-article-headers) |
eec82323 LMI |
1916 | (goto-char (point-min)) |
1917 | (cond | |
1918 | ;; Hide empty headers. | |
1919 | ((eq elem 'empty) | |
16409b0b | 1920 | (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t) |
eec82323 LMI |
1921 | (forward-line -1) |
1922 | (gnus-article-hide-text-type | |
01c52d31 | 1923 | (point-at-bol) |
eec82323 LMI |
1924 | (progn |
1925 | (end-of-line) | |
1926 | (if (re-search-forward "^[^ \t]" nil t) | |
1927 | (match-beginning 0) | |
1928 | (point-max))) | |
1929 | 'boring-headers))) | |
1930 | ;; Hide boring Newsgroups header. | |
1931 | ((eq elem 'newsgroups) | |
23f87bed MB |
1932 | (when (gnus-string-equal |
1933 | (gnus-fetch-field "newsgroups") | |
1934 | (gnus-group-real-name | |
1935 | (if (boundp 'gnus-newsgroup-name) | |
1936 | gnus-newsgroup-name | |
1937 | ""))) | |
eec82323 | 1938 | (gnus-article-hide-header "newsgroups"))) |
23f87bed MB |
1939 | ((eq elem 'to-address) |
1940 | (let ((to (message-fetch-field "to")) | |
1941 | (to-address | |
1942 | (gnus-parameter-to-address | |
1943 | (if (boundp 'gnus-newsgroup-name) | |
1944 | gnus-newsgroup-name "")))) | |
1945 | (when (and to to-address | |
1946 | (ignore-errors | |
1947 | (gnus-string-equal | |
1948 | ;; only one address in To | |
1949 | (nth 1 (mail-extract-address-components to)) | |
1950 | to-address))) | |
1951 | (gnus-article-hide-header "to")))) | |
1952 | ((eq elem 'to-list) | |
1953 | (let ((to (message-fetch-field "to")) | |
1954 | (to-list | |
1955 | (gnus-parameter-to-list | |
1956 | (if (boundp 'gnus-newsgroup-name) | |
1957 | gnus-newsgroup-name "")))) | |
1958 | (when (and to to-list | |
1959 | (ignore-errors | |
1960 | (gnus-string-equal | |
1961 | ;; only one address in To | |
1962 | (nth 1 (mail-extract-address-components to)) | |
1963 | to-list))) | |
1964 | (gnus-article-hide-header "to")))) | |
1965 | ((eq elem 'cc-list) | |
1966 | (let ((cc (message-fetch-field "cc")) | |
1967 | (to-list | |
1968 | (gnus-parameter-to-list | |
1969 | (if (boundp 'gnus-newsgroup-name) | |
1970 | gnus-newsgroup-name "")))) | |
1971 | (when (and cc to-list | |
1972 | (ignore-errors | |
1973 | (gnus-string-equal | |
1974 | ;; only one address in CC | |
1975 | (nth 1 (mail-extract-address-components cc)) | |
1976 | to-list))) | |
1977 | (gnus-article-hide-header "cc")))) | |
eec82323 | 1978 | ((eq elem 'followup-to) |
23f87bed MB |
1979 | (when (gnus-string-equal |
1980 | (message-fetch-field "followup-to") | |
1981 | (message-fetch-field "newsgroups")) | |
eec82323 LMI |
1982 | (gnus-article-hide-header "followup-to"))) |
1983 | ((eq elem 'reply-to) | |
23f87bed MB |
1984 | (if (gnus-group-find-parameter |
1985 | gnus-newsgroup-name 'broken-reply-to) | |
1986 | (gnus-article-hide-header "reply-to") | |
1987 | (let ((from (message-fetch-field "from")) | |
1988 | (reply-to (message-fetch-field "reply-to"))) | |
1989 | (when | |
1990 | (and | |
eec82323 LMI |
1991 | from reply-to |
1992 | (ignore-errors | |
1993 | (equal | |
23f87bed MB |
1994 | (sort (mapcar |
1995 | (lambda (x) (downcase (cadr x))) | |
1996 | (mail-extract-address-components from t)) | |
1997 | 'string<) | |
1998 | (sort (mapcar | |
1999 | (lambda (x) (downcase (cadr x))) | |
2000 | (mail-extract-address-components reply-to t)) | |
2001 | 'string<)))) | |
2002 | (gnus-article-hide-header "reply-to"))))) | |
eec82323 | 2003 | ((eq elem 'date) |
b193caa3 MB |
2004 | (let ((date (with-current-buffer gnus-original-article-buffer |
2005 | ;; If date in `gnus-article-buffer' is localized | |
2006 | ;; (`gnus-treat-date-user-defined'), | |
2007 | ;; `days-between' might fail. | |
2008 | (message-fetch-field "date")))) | |
eec82323 | 2009 | (when (and date |
16409b0b | 2010 | (< (days-between (current-time-string) date) |
eec82323 | 2011 | 4)) |
6748645f LMI |
2012 | (gnus-article-hide-header "date")))) |
2013 | ((eq elem 'long-to) | |
16409b0b GM |
2014 | (let ((to (message-fetch-field "to")) |
2015 | (cc (message-fetch-field "cc"))) | |
6748645f | 2016 | (when (> (length to) 1024) |
16409b0b GM |
2017 | (gnus-article-hide-header "to")) |
2018 | (when (> (length cc) 1024) | |
2019 | (gnus-article-hide-header "cc")))) | |
6748645f | 2020 | ((eq elem 'many-to) |
16409b0b GM |
2021 | (let ((to-count 0) |
2022 | (cc-count 0)) | |
6748645f LMI |
2023 | (goto-char (point-min)) |
2024 | (while (re-search-forward "^to:" nil t) | |
2025 | (setq to-count (1+ to-count))) | |
2026 | (when (> to-count 1) | |
2027 | (while (> to-count 0) | |
2028 | (goto-char (point-min)) | |
2029 | (save-restriction | |
2030 | (re-search-forward "^to:" nil nil to-count) | |
2031 | (forward-line -1) | |
2032 | (narrow-to-region (point) (point-max)) | |
2033 | (gnus-article-hide-header "to")) | |
16409b0b GM |
2034 | (setq to-count (1- to-count)))) |
2035 | (goto-char (point-min)) | |
2036 | (while (re-search-forward "^cc:" nil t) | |
2037 | (setq cc-count (1+ cc-count))) | |
2038 | (when (> cc-count 1) | |
2039 | (while (> cc-count 0) | |
2040 | (goto-char (point-min)) | |
2041 | (save-restriction | |
2042 | (re-search-forward "^cc:" nil nil cc-count) | |
2043 | (forward-line -1) | |
2044 | (narrow-to-region (point) (point-max)) | |
2045 | (gnus-article-hide-header "cc")) | |
2046 | (setq cc-count (1- cc-count))))))))))))) | |
eec82323 LMI |
2047 | |
2048 | (defun gnus-article-hide-header (header) | |
2049 | (save-excursion | |
2050 | (goto-char (point-min)) | |
2051 | (when (re-search-forward (concat "^" header ":") nil t) | |
2052 | (gnus-article-hide-text-type | |
01c52d31 | 2053 | (point-at-bol) |
eec82323 LMI |
2054 | (progn |
2055 | (end-of-line) | |
2056 | (if (re-search-forward "^[^ \t]" nil t) | |
2057 | (match-beginning 0) | |
2058 | (point-max))) | |
2059 | 'boring-headers)))) | |
2060 | ||
16409b0b GM |
2061 | (defvar gnus-article-normalized-header-length 40 |
2062 | "Length of normalized headers.") | |
2063 | ||
2064 | (defun article-normalize-headers () | |
2065 | "Make all header lines 40 characters long." | |
2066 | (interactive) | |
4e7d0221 | 2067 | (let ((inhibit-read-only t) |
16409b0b GM |
2068 | column) |
2069 | (save-excursion | |
2070 | (save-restriction | |
2071 | (article-narrow-to-head) | |
2072 | (while (not (eobp)) | |
2073 | (cond | |
01c52d31 | 2074 | ((< (setq column (- (point-at-eol) (point))) |
16409b0b GM |
2075 | gnus-article-normalized-header-length) |
2076 | (end-of-line) | |
2077 | (insert (make-string | |
2078 | (- gnus-article-normalized-header-length column) | |
2079 | ? ))) | |
2080 | ((> column gnus-article-normalized-header-length) | |
2081 | (gnus-put-text-property | |
2082 | (progn | |
2083 | (forward-char gnus-article-normalized-header-length) | |
2084 | (point)) | |
01c52d31 | 2085 | (point-at-eol) |
16409b0b GM |
2086 | 'invisible t)) |
2087 | (t | |
2088 | ;; Do nothing. | |
2089 | )) | |
2090 | (forward-line 1)))))) | |
2091 | ||
6748645f | 2092 | (defun article-treat-dumbquotes () |
23f87bed | 2093 | "Translate M****s*** sm*rtq**t*s and other symbols into proper text. |
16409b0b | 2094 | Note that this function guesses whether a character is a sm*rtq**t* or |
74dd1b0d SZ |
2095 | not, so it should only be used interactively. |
2096 | ||
23f87bed MB |
2097 | Sm*rtq**t*s are M****s***'s unilateral extension to the |
2098 | iso-8859-1 character map in an attempt to provide more quoting | |
2099 | characters. If you see something like \\222 or \\264 where | |
2100 | you're expecting some kind of apostrophe or quotation mark, then | |
2101 | try this wash." | |
6748645f | 2102 | (interactive) |
16409b0b | 2103 | (article-translate-strings gnus-article-dumbquotes-map)) |
6748645f | 2104 | |
16c1b3bc KY |
2105 | (defvar org-entities) |
2106 | ||
be3c11b3 LMI |
2107 | (defun article-treat-non-ascii () |
2108 | "Translate many Unicode characters into their ASCII equivalents." | |
2109 | (interactive) | |
2110 | (require 'org-entities) | |
9c1d3f98 | 2111 | (let ((table (make-char-table (if (featurep 'xemacs) 'generic)))) |
be3c11b3 LMI |
2112 | (dolist (elem org-entities) |
2113 | (when (and (listp elem) | |
2114 | (= (length (nth 6 elem)) 1)) | |
fdf14191 KY |
2115 | (if (featurep 'xemacs) |
2116 | (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table) | |
2117 | (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem))))) | |
be3c11b3 LMI |
2118 | (save-excursion |
2119 | (when (article-goto-body) | |
2120 | (let ((inhibit-read-only t) | |
2f0e0dc8 | 2121 | replace props) |
be3c11b3 | 2122 | (while (not (eobp)) |
9c1d3f98 KY |
2123 | (if (not (setq replace (if (featurep 'xemacs) |
2124 | (get-char-table (following-char) table) | |
2125 | (aref table (following-char))))) | |
be3c11b3 | 2126 | (forward-char 1) |
2f0e0dc8 KY |
2127 | (if (prog1 |
2128 | (setq props (text-properties-at (point))) | |
2129 | (delete-char 1)) | |
2130 | (add-text-properties (point) (progn (insert replace) (point)) | |
2131 | props) | |
2132 | (insert replace))))))))) | |
be3c11b3 | 2133 | |
16409b0b GM |
2134 | (defun article-translate-strings (map) |
2135 | "Translate all string in the body of the article according to MAP. | |
2136 | MAP is an alist where the elements are on the form (\"from\" \"to\")." | |
2137 | (save-excursion | |
2138 | (when (article-goto-body) | |
01c52d31 MB |
2139 | (let ((inhibit-read-only t)) |
2140 | (dolist (elem map) | |
7cad71ad G |
2141 | (let ((from (car elem)) |
2142 | (to (cadr elem))) | |
2143 | (save-excursion | |
2144 | (if (stringp from) | |
2145 | (while (search-forward from nil t) | |
2146 | (replace-match to)) | |
2147 | (while (not (eobp)) | |
2148 | (if (eq (following-char) from) | |
2149 | (progn | |
2150 | (delete-char 1) | |
2151 | (insert to)) | |
2152 | (forward-char 1))))))))))) | |
16409b0b | 2153 | |
eec82323 LMI |
2154 | (defun article-treat-overstrike () |
2155 | "Translate overstrikes into bold text." | |
2156 | (interactive) | |
2157 | (save-excursion | |
16409b0b | 2158 | (when (article-goto-body) |
4e7d0221 | 2159 | (let ((inhibit-read-only t)) |
eec82323 | 2160 | (while (search-forward "\b" nil t) |
16409b0b | 2161 | (let ((next (char-after)) |
eec82323 LMI |
2162 | (previous (char-after (- (point) 2)))) |
2163 | ;; We do the boldification/underlining by hiding the | |
2164 | ;; overstrikes and putting the proper text property | |
2165 | ;; on the letters. | |
2166 | (cond | |
2167 | ((eq next previous) | |
2168 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
2169 | (put-text-property (point) (1+ (point)) 'face 'bold)) | |
2170 | ((eq next ?_) | |
2171 | (gnus-article-hide-text-type | |
2172 | (1- (point)) (1+ (point)) 'overstrike) | |
2173 | (put-text-property | |
2174 | (- (point) 2) (1- (point)) 'face 'underline)) | |
2175 | ((eq previous ?_) | |
2176 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
2177 | (put-text-property | |
2178 | (point) (1+ (point)) 'face 'underline))))))))) | |
2179 | ||
01c52d31 MB |
2180 | (defun article-treat-ansi-sequences () |
2181 | "Translate ANSI SGR control sequences into overlays or extents." | |
2182 | (interactive) | |
2183 | (save-excursion | |
2184 | (when (article-goto-body) | |
2185 | (let ((inhibit-read-only t)) | |
2186 | (ansi-color-apply-on-region (point) (point-max)))))) | |
2187 | ||
23f87bed MB |
2188 | (defun gnus-article-treat-unfold-headers () |
2189 | "Unfold folded message headers. | |
2190 | Only the headers that fit into the current window width will be | |
2191 | unfolded." | |
2192 | (interactive) | |
2193 | (gnus-with-article-headers | |
2194 | (let (length) | |
2195 | (while (not (eobp)) | |
2196 | (save-restriction | |
2197 | (mail-header-narrow-to-field) | |
01c52d31 MB |
2198 | (let* ((header (buffer-string)) |
2199 | (unfoldable | |
2200 | (or (equal gnus-article-unfold-long-headers t) | |
2201 | (and (stringp gnus-article-unfold-long-headers) | |
89b163db G |
2202 | (string-match gnus-article-unfold-long-headers |
2203 | header))))) | |
23f87bed MB |
2204 | (with-temp-buffer |
2205 | (insert header) | |
2206 | (goto-char (point-min)) | |
2207 | (while (re-search-forward "\n[\t ]" nil t) | |
2208 | (replace-match " " t t))) | |
01c52d31 MB |
2209 | (setq length (- (point-max) (point-min) 1)) |
2210 | (when (or unfoldable | |
2211 | (< length (window-width))) | |
2212 | (while (re-search-forward "\n[\t ]" nil t) | |
2213 | (replace-match " " t t)))) | |
23f87bed MB |
2214 | (goto-char (point-max))))))) |
2215 | ||
2216 | (defun gnus-article-treat-fold-headers () | |
2217 | "Fold message headers." | |
2218 | (interactive) | |
2219 | (gnus-with-article-headers | |
2220 | (while (not (eobp)) | |
2221 | (save-restriction | |
2222 | (mail-header-narrow-to-field) | |
2223 | (mail-header-fold-field) | |
2224 | (goto-char (point-max)))))) | |
2225 | ||
2226 | (defun gnus-treat-smiley () | |
2227 | "Toggle display of textual emoticons (\"smileys\") as small graphical icons." | |
2228 | (interactive) | |
2229 | (gnus-with-article-buffer | |
2230 | (if (memq 'smiley gnus-article-wash-types) | |
2231 | (gnus-delete-images 'smiley) | |
2232 | (article-goto-body) | |
2233 | (let ((images (smiley-region (point) (point-max)))) | |
2234 | (when images | |
2235 | (gnus-add-wash-type 'smiley) | |
2236 | (dolist (image images) | |
2237 | (gnus-add-image 'smiley image))))))) | |
2238 | ||
2239 | (defun gnus-article-remove-images () | |
2240 | "Remove all images from the article buffer." | |
2241 | (interactive) | |
2242 | (gnus-with-article-buffer | |
9695908d KY |
2243 | (save-restriction |
2244 | (widen) | |
2245 | (dolist (elem gnus-article-image-alist) | |
2246 | (gnus-delete-images (car elem)))))) | |
23f87bed | 2247 | |
ae97e645 G |
2248 | (autoload 'w3m-toggle-inline-images "w3m") |
2249 | ||
8b6f6573 LMI |
2250 | (defun gnus-article-show-images () |
2251 | "Show any images that are in the HTML-rendered article buffer. | |
2252 | This only works if the article in question is HTML." | |
2253 | (interactive) | |
2254 | (gnus-with-article-buffer | |
9695908d KY |
2255 | (save-restriction |
2256 | (widen) | |
ae97e645 G |
2257 | (if (eq mm-text-html-renderer 'w3m) |
2258 | (let ((mm-inline-text-html-with-images nil)) | |
2259 | (w3m-toggle-inline-images)) | |
2260 | (dolist (region (gnus-find-text-property-region (point-min) (point-max) | |
2261 | 'image-displayer)) | |
2262 | (destructuring-bind (start end function) region | |
2263 | (funcall function (get-text-property start 'image-url) | |
2264 | start end))))))) | |
8b6f6573 | 2265 | |
23f87bed MB |
2266 | (defun gnus-article-treat-fold-newsgroups () |
2267 | "Unfold folded message headers. | |
2268 | Only the headers that fit into the current window width will be | |
2269 | unfolded." | |
2270 | (interactive) | |
2271 | (gnus-with-article-headers | |
2272 | (while (gnus-article-goto-header "newsgroups\\|followup-to") | |
2273 | (save-restriction | |
2274 | (mail-header-narrow-to-field) | |
2275 | (while (re-search-forward ", *" nil t) | |
2276 | (replace-match ", " t t)) | |
2277 | (mail-header-fold-field) | |
2278 | (goto-char (point-max)))))) | |
2279 | ||
b7b80032 | 2280 | (defcustom gnus-article-truncate-lines (default-value 'truncate-lines) |
01c52d31 MB |
2281 | "Value of `truncate-lines' in Gnus Article buffer. |
2282 | Valid values are nil, t, `head', `first', `last', an integer or a | |
2283 | predicate. See Info node `(gnus)Customizing Articles'." | |
330f707b | 2284 | :version "23.1" ;; No Gnus |
01c52d31 MB |
2285 | :group 'gnus-article |
2286 | ;; :link '(custom-manual "(gnus)Customizing Articles") | |
2287 | :type 'boolean) | |
2288 | ||
2289 | (defun gnus-article-toggle-truncate-lines (&optional arg) | |
2290 | "Toggle whether to fold or truncate long lines in article the buffer. | |
2291 | If ARG is non-nil and not a number, toggle | |
2292 | `gnus-article-truncate-lines' too. If ARG is a number, truncate | |
5229211e | 2293 | long lines if and only if arg is positive." |
01c52d31 MB |
2294 | (interactive "P") |
2295 | (cond | |
2296 | ((and (numberp arg) (> arg 0)) | |
2297 | (setq gnus-article-truncate-lines t)) | |
2298 | ((numberp arg) | |
2299 | (setq gnus-article-truncate-lines nil)) | |
2300 | (arg | |
2301 | (setq gnus-article-truncate-lines | |
2302 | (not gnus-article-truncate-lines)))) | |
2303 | (gnus-with-article-buffer | |
2304 | (cond | |
2305 | ((and (numberp arg) (> arg 0)) | |
2306 | (setq truncate-lines nil)) | |
2307 | ((numberp arg) | |
2308 | (setq truncate-lines t))) | |
2309 | ;; In versions of Emacs 22 (CVS) before 2006-05-26, | |
2310 | ;; `toggle-truncate-lines' needs an argument. | |
2311 | (toggle-truncate-lines))) | |
2312 | ||
23f87bed MB |
2313 | (defun gnus-article-treat-body-boundary () |
2314 | "Place a boundary line at the end of the headers." | |
2315 | (interactive) | |
2316 | (when (and gnus-body-boundary-delimiter | |
2317 | (> (length gnus-body-boundary-delimiter) 0)) | |
2318 | (gnus-with-article-headers | |
2319 | (goto-char (point-max)) | |
2320 | (let ((start (point))) | |
2321 | (insert "X-Boundary: ") | |
2322 | (gnus-add-text-properties start (point) '(invisible t intangible t)) | |
a123622d G |
2323 | (insert (let (str (max (window-width))) |
2324 | (if (featurep 'xemacs) | |
2325 | (setq max (1- max))) | |
2326 | (while (>= max (length str)) | |
23f87bed | 2327 | (setq str (concat str gnus-body-boundary-delimiter))) |
a123622d | 2328 | (substring str 0 max)) |
23f87bed MB |
2329 | "\n") |
2330 | (gnus-put-text-property start (point) 'gnus-decoration 'header))))) | |
2331 | ||
16409b0b GM |
2332 | (defun article-fill-long-lines () |
2333 | "Fill lines that are wider than the window width." | |
eec82323 LMI |
2334 | (interactive) |
2335 | (save-excursion | |
4e7d0221 | 2336 | (let ((inhibit-read-only t) |
16409b0b GM |
2337 | (width (window-width (get-buffer-window (current-buffer))))) |
2338 | (save-restriction | |
2339 | (article-goto-body) | |
80b47379 | 2340 | (let ((adaptive-fill-mode nil)) ;Why? -sm |
16409b0b GM |
2341 | (while (not (eobp)) |
2342 | (end-of-line) | |
2343 | (when (>= (current-column) (min fill-column width)) | |
23f87bed | 2344 | (narrow-to-region (min (1+ (point)) (point-max)) |
01c52d31 | 2345 | (point-at-bol)) |
23f87bed MB |
2346 | (let ((goback (point-marker))) |
2347 | (fill-paragraph nil) | |
2348 | (goto-char (marker-position goback))) | |
16409b0b GM |
2349 | (widen)) |
2350 | (forward-line 1))))))) | |
2351 | ||
2352 | (defun article-capitalize-sentences () | |
2353 | "Capitalize the first word in each sentence." | |
2354 | (interactive) | |
2355 | (save-excursion | |
4e7d0221 | 2356 | (let ((inhibit-read-only t) |
16409b0b GM |
2357 | (paragraph-start "^[\n\^L]")) |
2358 | (article-goto-body) | |
2359 | (while (not (eobp)) | |
2360 | (capitalize-word 1) | |
2361 | (forward-sentence))))) | |
eec82323 LMI |
2362 | |
2363 | (defun article-remove-cr () | |
16409b0b | 2364 | "Remove trailing CRs and then translate remaining CRs into LFs." |
eec82323 LMI |
2365 | (interactive) |
2366 | (save-excursion | |
4e7d0221 | 2367 | (let ((inhibit-read-only t)) |
eec82323 | 2368 | (goto-char (point-min)) |
16409b0b GM |
2369 | (while (re-search-forward "\r+$" nil t) |
2370 | (replace-match "" t t)) | |
2371 | (goto-char (point-min)) | |
eec82323 | 2372 | (while (search-forward "\r" nil t) |
16409b0b | 2373 | (replace-match "\n" t t))))) |
eec82323 LMI |
2374 | |
2375 | (defun article-remove-trailing-blank-lines () | |
2376 | "Remove all trailing blank lines from the article." | |
2377 | (interactive) | |
2378 | (save-excursion | |
4e7d0221 | 2379 | (let ((inhibit-read-only t)) |
eec82323 LMI |
2380 | (goto-char (point-max)) |
2381 | (delete-region | |
2382 | (point) | |
2383 | (progn | |
2384 | (while (and (not (bobp)) | |
16409b0b GM |
2385 | (looking-at "^[ \t]*$") |
2386 | (not (gnus-annotation-in-region-p | |
01c52d31 | 2387 | (point) (point-at-eol)))) |
eec82323 LMI |
2388 | (forward-line -1)) |
2389 | (forward-line 1) | |
2390 | (point)))))) | |
2391 | ||
9efa445f | 2392 | (defvar gnus-face-properties-alist) |
01c52d31 | 2393 | |
b890d447 | 2394 | (defun article-display-face (&optional force) |
23f87bed | 2395 | "Display any Face headers in the header." |
b890d447 | 2396 | (interactive (list 'force)) |
23f87bed MB |
2397 | (let ((wash-face-p buffer-read-only)) |
2398 | (gnus-with-article-headers | |
2399 | ;; When displaying parts, this function can be called several times on | |
2400 | ;; the same article, without any intended toggle semantic (as typing `W | |
2401 | ;; D d' would have). So face deletion must occur only when we come from | |
2402 | ;; an interactive command, that is when the *Article* buffer is | |
2403 | ;; read-only. | |
2404 | (if (and wash-face-p (memq 'face gnus-article-wash-types)) | |
2405 | (gnus-delete-images 'face) | |
b890d447 MB |
2406 | (let ((from (message-fetch-field "from")) |
2407 | face faces) | |
7d0c69be | 2408 | (save-current-buffer |
23f87bed | 2409 | (when (and wash-face-p |
7d0c69be MB |
2410 | (gnus-buffer-live-p gnus-original-article-buffer) |
2411 | (not (re-search-forward "^Face:[\t ]*" nil t))) | |
23f87bed MB |
2412 | (set-buffer gnus-original-article-buffer)) |
2413 | (save-restriction | |
2414 | (mail-narrow-to-head) | |
b890d447 MB |
2415 | (when (or force |
2416 | ;; Check whether this face is censored. | |
2417 | (not (and gnus-article-x-face-too-ugly | |
2418 | (or from | |
2419 | (setq from (message-fetch-field "from"))) | |
2420 | (string-match gnus-article-x-face-too-ugly | |
2421 | from)))) | |
2422 | (while (gnus-article-goto-header "Face") | |
2423 | (push (mail-header-field-value) faces))))) | |
d6697c02 | 2424 | (when faces |
7d0c69be | 2425 | (goto-char (point-min)) |
b890d447 MB |
2426 | (let (png image) |
2427 | (unless (setq from (gnus-article-goto-header "from")) | |
7d0c69be MB |
2428 | (insert "From:") |
2429 | (setq from (point)) | |
b890d447 | 2430 | (insert " [no `from' set]\n")) |
7d0c69be MB |
2431 | (while faces |
2432 | (when (setq png (gnus-convert-face-to-png (pop faces))) | |
01c52d31 MB |
2433 | (setq image |
2434 | (apply 'gnus-create-image png 'png t | |
2435 | (cdr (assq 'png gnus-face-properties-alist)))) | |
d6697c02 | 2436 | (goto-char from) |
b4599732 CY |
2437 | (when image |
2438 | (gnus-add-wash-type 'face) | |
2439 | (gnus-add-image 'face image) | |
2440 | (gnus-put-image image nil 'face))))))))))) | |
23f87bed | 2441 | |
eec82323 LMI |
2442 | (defun article-display-x-face (&optional force) |
2443 | "Look for an X-Face header and display it if present." | |
2444 | (interactive (list 'force)) | |
23f87bed MB |
2445 | (let ((wash-face-p buffer-read-only)) ;; When type `W f' |
2446 | (gnus-with-article-headers | |
2447 | ;; Delete the old process, if any. | |
2448 | (when (process-status "article-x-face") | |
2449 | (delete-process "article-x-face")) | |
2450 | ;; See the comment in `article-display-face'. | |
2451 | (if (and wash-face-p (memq 'xface gnus-article-wash-types)) | |
2452 | ;; We have already displayed X-Faces, so we remove them | |
2453 | ;; instead. | |
2454 | (gnus-delete-images 'xface) | |
2455 | ;; Display X-Faces. | |
b890d447 MB |
2456 | (let ((from (message-fetch-field "from")) |
2457 | x-faces face) | |
7d0c69be | 2458 | (save-current-buffer |
23f87bed | 2459 | (when (and wash-face-p |
7d0c69be MB |
2460 | (gnus-buffer-live-p gnus-original-article-buffer) |
2461 | (not (re-search-forward "^X-Face:[\t ]*" nil t))) | |
23f87bed MB |
2462 | ;; If type `W f', use gnus-original-article-buffer, |
2463 | ;; otherwise use the current buffer because displaying | |
2464 | ;; RFC822 parts calls this function too. | |
2465 | (set-buffer gnus-original-article-buffer)) | |
2466 | (save-restriction | |
2467 | (mail-narrow-to-head) | |
b890d447 MB |
2468 | (and gnus-article-x-face-command |
2469 | (or force | |
2470 | ;; Check whether this face is censored. | |
2471 | (not (and gnus-article-x-face-too-ugly | |
2472 | (or from | |
2473 | (setq from (message-fetch-field "from"))) | |
2474 | (string-match gnus-article-x-face-too-ugly | |
2475 | from)))) | |
2476 | (while (gnus-article-goto-header "X-Face") | |
2477 | (push (mail-header-field-value) x-faces))))) | |
2478 | (when x-faces | |
2479 | ;; We display the face. | |
2480 | (cond ((functionp gnus-article-x-face-command) | |
2481 | ;; The command is a lisp function, so we call it. | |
2482 | (mapc gnus-article-x-face-command x-faces)) | |
2483 | ((stringp gnus-article-x-face-command) | |
2484 | ;; The command is a string, so we interpret the command | |
2485 | ;; as a, well, command, and fork it off. | |
2486 | (let ((process-connection-type nil)) | |
2487 | (gnus-set-process-query-on-exit-flag | |
2488 | (start-process | |
2489 | "article-x-face" nil shell-file-name | |
2490 | shell-command-switch gnus-article-x-face-command) | |
2491 | nil) | |
2492 | ;; Sending multiple EOFs to xv doesn't work, | |
2493 | ;; so we only do a single external face. | |
2494 | (with-temp-buffer | |
2495 | (insert (car x-faces)) | |
2496 | (process-send-region "article-x-face" | |
2497 | (point-min) (point-max))) | |
2498 | (process-send-eof "article-x-face"))) | |
2499 | (t | |
2500 | (error "`%s' set to `%s' is not a function" | |
2501 | gnus-article-x-face-command | |
2502 | 'gnus-article-x-face-command))))))))) | |
a8151ef7 | 2503 | |
16409b0b GM |
2504 | (defun article-decode-mime-words () |
2505 | "Decode all MIME-encoded words in the article." | |
2506 | (interactive) | |
01c52d31 | 2507 | (gnus-with-article-buffer |
16409b0b | 2508 | (let ((inhibit-point-motion-hooks t) |
16409b0b | 2509 | (mail-parse-charset gnus-newsgroup-charset) |
a1506d29 | 2510 | (mail-parse-ignored-charsets |
01c52d31 MB |
2511 | (with-current-buffer gnus-summary-buffer |
2512 | gnus-newsgroup-ignored-charsets))) | |
16409b0b GM |
2513 | (mail-decode-encoded-word-region (point-min) (point-max))))) |
2514 | ||
2515 | (defun article-decode-charset (&optional prompt) | |
2516 | "Decode charset-encoded text in the article. | |
2517 | If PROMPT (the prefix), prompt for a coding system to use." | |
2518 | (interactive "P") | |
2519 | (let ((inhibit-point-motion-hooks t) (case-fold-search t) | |
23f87bed | 2520 | (inhibit-read-only t) |
16409b0b | 2521 | (mail-parse-charset gnus-newsgroup-charset) |
a1506d29 | 2522 | (mail-parse-ignored-charsets |
16409b0b GM |
2523 | (save-excursion (condition-case nil |
2524 | (set-buffer gnus-summary-buffer) | |
2525 | (error)) | |
2526 | gnus-newsgroup-ignored-charsets)) | |
2527 | ct cte ctl charset format) | |
c96ec15a MB |
2528 | (save-excursion |
2529 | (save-restriction | |
2530 | (article-narrow-to-head) | |
2531 | (setq ct (message-fetch-field "Content-Type" t) | |
2532 | cte (message-fetch-field "Content-Transfer-Encoding" t) | |
2533 | ctl (and ct (mail-header-parse-content-type ct)) | |
2534 | charset (cond | |
2535 | (prompt | |
2536 | (mm-read-coding-system "Charset to decode: ")) | |
2537 | (ctl | |
2538 | (mail-content-type-get ctl 'charset))) | |
2539 | format (and ctl (mail-content-type-get ctl 'format))) | |
2540 | (when cte | |
2541 | (setq cte (mail-header-strip cte))) | |
2542 | (if (and ctl (not (string-match "/" (car ctl)))) | |
2543 | (setq ctl nil)) | |
2544 | (goto-char (point-max))) | |
2545 | (forward-line 1) | |
2546 | (save-restriction | |
2547 | (narrow-to-region (point) (point-max)) | |
2548 | (when (and (eq mail-parse-charset 'gnus-decoded) | |
2549 | (eq (mm-body-7-or-8) '8bit)) | |
2550 | ;; The text code could have been decoded. | |
2551 | (setq charset mail-parse-charset)) | |
2552 | (when (and (or (not ctl) | |
2553 | (equal (car ctl) "text/plain")) | |
2554 | (not format)) ;; article with format will decode later. | |
2555 | (mm-decode-body | |
2556 | charset (and cte (intern (downcase | |
2557 | (gnus-strip-whitespace cte)))) | |
2558 | (car ctl))))))) | |
16409b0b GM |
2559 | |
2560 | (defun article-decode-encoded-words () | |
2561 | "Remove encoded-word encoding from headers." | |
2562 | (let ((inhibit-point-motion-hooks t) | |
2563 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 2564 | (mail-parse-ignored-charsets |
16409b0b GM |
2565 | (save-excursion (condition-case nil |
2566 | (set-buffer gnus-summary-buffer) | |
2567 | (error)) | |
2568 | gnus-newsgroup-ignored-charsets)) | |
343d6628 | 2569 | (inhibit-read-only t) |
8fbdffe5 MB |
2570 | end start) |
2571 | (goto-char (point-min)) | |
2572 | (when (search-forward "\n\n" nil 'move) | |
2573 | (forward-line -1)) | |
2574 | (setq end (point)) | |
2575 | (while (not (bobp)) | |
2576 | (while (progn | |
2577 | (forward-line -1) | |
2578 | (and (not (bobp)) | |
2579 | (memq (char-after) '(?\t ? ))))) | |
2580 | (setq start (point)) | |
2581 | (if (looking-at "\ | |
343d6628 MB |
2582 | \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\ |
2583 | \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):") | |
8fbdffe5 MB |
2584 | (funcall gnus-decode-address-function start end) |
2585 | (funcall gnus-decode-header-function start end)) | |
2586 | (goto-char (setq end start))))) | |
eec82323 | 2587 | |
23f87bed | 2588 | (defun article-decode-group-name () |
01c52d31 | 2589 | "Decode group names in Newsgroups, Followup-To and Xref headers." |
23f87bed MB |
2590 | (let ((inhibit-point-motion-hooks t) |
2591 | (inhibit-read-only t) | |
01c52d31 MB |
2592 | (method (gnus-find-method-for-group gnus-newsgroup-name)) |
2593 | regexp) | |
23f87bed MB |
2594 | (when (and (or gnus-group-name-charset-method-alist |
2595 | gnus-group-name-charset-group-alist) | |
2596 | (gnus-buffer-live-p gnus-original-article-buffer)) | |
2597 | (save-restriction | |
2598 | (article-narrow-to-head) | |
01c52d31 MB |
2599 | (dolist (header '("Newsgroups" "Followup-To" "Xref")) |
2600 | (with-current-buffer gnus-original-article-buffer | |
2601 | (goto-char (point-min))) | |
2602 | (setq regexp (concat "^" header | |
2603 | ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n")) | |
2604 | (while (re-search-forward regexp nil t) | |
2605 | (replace-match (save-match-data | |
2606 | (gnus-decode-newsgroups | |
2607 | ;; XXX how to use data in article buffer? | |
2608 | (with-current-buffer gnus-original-article-buffer | |
2609 | (re-search-forward regexp nil t) | |
2610 | (match-string 1)) | |
2611 | gnus-newsgroup-name method)) | |
2612 | t t nil 1)) | |
2613 | (goto-char (point-min))))))) | |
23f87bed MB |
2614 | |
2615 | (autoload 'idna-to-unicode "idna") | |
2616 | ||
2617 | (defun article-decode-idna-rhs () | |
53cfefc8 MB |
2618 | "Decode IDNA strings in RHS in various headers in current buffer. |
2619 | The following headers are decoded: From:, To:, Cc:, Reply-To:, | |
2620 | Mail-Reply-To: and Mail-Followup-To:." | |
23f87bed MB |
2621 | (when gnus-use-idna |
2622 | (save-restriction | |
2623 | (let ((inhibit-point-motion-hooks t) | |
2624 | (inhibit-read-only t)) | |
2625 | (article-narrow-to-head) | |
2626 | (goto-char (point-min)) | |
53cfefc8 | 2627 | (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t) |
23f87bed MB |
2628 | (let (ace unicode) |
2629 | (when (save-match-data | |
2630 | (and (setq ace (match-string 1)) | |
2631 | (save-excursion | |
2632 | (and (re-search-backward "^[^ \t]" nil t) | |
53cfefc8 | 2633 | (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To"))) |
23f87bed MB |
2634 | (setq unicode (idna-to-unicode ace)))) |
2635 | (unless (string= ace unicode) | |
2636 | (replace-match unicode nil nil nil 1))))))))) | |
2637 | ||
2638 | (defun article-de-quoted-unreadable (&optional force read-charset) | |
16409b0b | 2639 | "Translate a quoted-printable-encoded article. |
eec82323 | 2640 | If FORCE, decode the article whether it is marked as quoted-printable |
23f87bed MB |
2641 | or not. |
2642 | If READ-CHARSET, ask for a coding system." | |
2643 | (interactive (list 'force current-prefix-arg)) | |
eec82323 | 2644 | (save-excursion |
4e7d0221 | 2645 | (let ((inhibit-read-only t) type charset) |
8b93df01 DL |
2646 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
2647 | (with-current-buffer gnus-original-article-buffer | |
2648 | (setq type | |
2649 | (gnus-fetch-field "content-transfer-encoding")) | |
2650 | (let* ((ct (gnus-fetch-field "content-type")) | |
c96ec15a | 2651 | (ctl (and ct (mail-header-parse-content-type ct)))) |
8b93df01 DL |
2652 | (setq charset (and ctl |
2653 | (mail-content-type-get ctl 'charset))) | |
2654 | (if (stringp charset) | |
2655 | (setq charset (intern (downcase charset))))))) | |
23f87bed MB |
2656 | (if read-charset |
2657 | (setq charset (mm-read-coding-system "Charset: " charset))) | |
a1506d29 | 2658 | (unless charset |
8b93df01 | 2659 | (setq charset gnus-newsgroup-charset)) |
eec82323 | 2660 | (when (or force |
eb806ef3 DL |
2661 | (and type (let ((case-fold-search t)) |
2662 | (string-match "quoted-printable" type)))) | |
16409b0b | 2663 | (article-goto-body) |
eb806ef3 | 2664 | (quoted-printable-decode-region |
07178229 | 2665 | (point) (point-max) (mm-charset-to-coding-system charset nil t)))))) |
16409b0b | 2666 | |
23f87bed | 2667 | (defun article-de-base64-unreadable (&optional force read-charset) |
16409b0b | 2668 | "Translate a base64 article. |
23f87bed MB |
2669 | If FORCE, decode the article whether it is marked as base64 not. |
2670 | If READ-CHARSET, ask for a coding system." | |
2671 | (interactive (list 'force current-prefix-arg)) | |
16409b0b | 2672 | (save-excursion |
4e7d0221 | 2673 | (let ((inhibit-read-only t) type charset) |
8b93df01 DL |
2674 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
2675 | (with-current-buffer gnus-original-article-buffer | |
2676 | (setq type | |
2677 | (gnus-fetch-field "content-transfer-encoding")) | |
2678 | (let* ((ct (gnus-fetch-field "content-type")) | |
c96ec15a | 2679 | (ctl (and ct (mail-header-parse-content-type ct)))) |
8b93df01 DL |
2680 | (setq charset (and ctl |
2681 | (mail-content-type-get ctl 'charset))) | |
2682 | (if (stringp charset) | |
2683 | (setq charset (intern (downcase charset))))))) | |
23f87bed MB |
2684 | (if read-charset |
2685 | (setq charset (mm-read-coding-system "Charset: " charset))) | |
a1506d29 | 2686 | (unless charset |
8b93df01 | 2687 | (setq charset gnus-newsgroup-charset)) |
16409b0b | 2688 | (when (or force |
eb806ef3 DL |
2689 | (and type (let ((case-fold-search t)) |
2690 | (string-match "base64" type)))) | |
16409b0b GM |
2691 | (article-goto-body) |
2692 | (save-restriction | |
2693 | (narrow-to-region (point) (point-max)) | |
2694 | (base64-decode-region (point-min) (point-max)) | |
eb806ef3 | 2695 | (mm-decode-coding-region |
07178229 KY |
2696 | (point-min) (point-max) |
2697 | (mm-charset-to-coding-system charset nil t))))))) | |
16409b0b GM |
2698 | |
2699 | (eval-when-compile | |
2700 | (require 'rfc1843)) | |
2701 | ||
2702 | (defun article-decode-HZ () | |
2703 | "Translate a HZ-encoded article." | |
2704 | (interactive) | |
2705 | (require 'rfc1843) | |
2706 | (save-excursion | |
4e7d0221 | 2707 | (let ((inhibit-read-only t)) |
16409b0b GM |
2708 | (rfc1843-decode-region (point-min) (point-max))))) |
2709 | ||
23f87bed MB |
2710 | (defun article-unsplit-urls () |
2711 | "Remove the newlines that some other mailers insert into URLs." | |
16409b0b | 2712 | (interactive) |
23f87bed MB |
2713 | (save-excursion |
2714 | (let ((inhibit-read-only t)) | |
2715 | (goto-char (point-min)) | |
2716 | (while (re-search-forward | |
97f78c9b | 2717 | "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t) |
23f87bed | 2718 | (replace-match "\\1\\3" t))) |
da946239 | 2719 | (when (gmm-called-interactively-p 'any) |
23f87bed MB |
2720 | (gnus-treat-article nil)))) |
2721 | ||
2526f423 G |
2722 | (defun article-wash-html () |
2723 | "Format an HTML article." | |
2724 | (interactive) | |
2725 | (let ((handles nil) | |
2726 | (buffer-read-only nil)) | |
2727 | (when (gnus-buffer-live-p gnus-original-article-buffer) | |
dc2ab667 LMI |
2728 | (with-current-buffer gnus-original-article-buffer |
2729 | (setq handles (mm-dissect-buffer t t)))) | |
2526f423 G |
2730 | (article-goto-body) |
2731 | (delete-region (point) (point-max)) | |
dc2ab667 | 2732 | (mm-enable-multibyte) |
2526f423 | 2733 | (mm-inline-text-html handles))) |
73043f7d | 2734 | |
01c52d31 MB |
2735 | (defvar gnus-article-browse-html-temp-list nil |
2736 | "List of temporary files created by `gnus-article-browse-html-parts'. | |
2737 | Internal variable.") | |
2738 | ||
2739 | (defcustom gnus-article-browse-delete-temp 'ask | |
2740 | "What to do with temporary files from `gnus-article-browse-html-parts'. | |
2741 | If nil, don't delete temporary files. If it is t, delete them on | |
2742 | exit from the summary buffer. If it is the symbol `file', query | |
2743 | on each file, if it is `ask' ask once when exiting from the | |
2744 | summary buffer." | |
2745 | :group 'gnus-article | |
330f707b | 2746 | :version "23.1" ;; No Gnus |
01c52d31 MB |
2747 | :type '(choice (const :tag "Don't delete" nil) |
2748 | (const :tag "Don't ask" t) | |
2749 | (const :tag "Ask" ask) | |
2750 | (const :tag "Ask for each file" file))) | |
2751 | ||
2752 | ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list. | |
2753 | ||
2754 | (defun gnus-article-browse-delete-temp-files (&optional how) | |
2755 | "Delete temp-files created by `gnus-article-browse-html-parts'." | |
2756 | (when (and gnus-article-browse-html-temp-list | |
3aeb9402 KY |
2757 | (progn |
2758 | (or how (setq how gnus-article-browse-delete-temp)) | |
2759 | (if (eq how 'ask) | |
5c11868c KY |
2760 | (let ((files (length gnus-article-browse-html-temp-list))) |
2761 | (or (gnus-y-or-n-p | |
2762 | (if (= files 1) | |
2763 | "Delete the temporary HTML file? " | |
2764 | (format "Delete all %s temporary HTML files? " | |
2765 | files))) | |
2eff54ba | 2766 | (setq gnus-article-browse-html-temp-list nil))) |
3aeb9402 | 2767 | how))) |
01c52d31 | 2768 | (dolist (file gnus-article-browse-html-temp-list) |
3aeb9402 KY |
2769 | (cond ((file-directory-p file) |
2770 | (when (or (not (eq how 'file)) | |
2771 | (gnus-y-or-n-p | |
2772 | (format | |
2773 | "Delete temporary HTML file(s) in directory `%s'? " | |
2774 | (file-name-as-directory file)))) | |
2775 | (gnus-delete-directory file))) | |
2776 | ((file-exists-p file) | |
2777 | (when (or (not (eq how 'file)) | |
2778 | (gnus-y-or-n-p | |
2779 | (format "Delete temporary HTML file `%s'? " file))) | |
2780 | (delete-file file))))) | |
01c52d31 MB |
2781 | ;; Also remove file from the list when not deleted or if file doesn't |
2782 | ;; exist anymore. | |
2783 | (setq gnus-article-browse-html-temp-list nil)) | |
2784 | gnus-article-browse-html-temp-list) | |
2785 | ||
d40d713a KY |
2786 | (defun gnus-article-browse-html-save-cid-content (cid handles directory) |
2787 | "Find CID content in HANDLES and save it in a file in DIRECTORY. | |
2788 | Return file name." | |
20c0b2ce | 2789 | (save-match-data |
d40d713a KY |
2790 | (let (file type) |
2791 | (catch 'found | |
2792 | (dolist (handle handles) | |
2793 | (cond | |
2794 | ((not (listp handle))) | |
0b575a33 KY |
2795 | ;; Exclude broken handles that `gnus-summary-enter-digest-group' |
2796 | ;; may create. | |
2797 | ((not (or (bufferp (car handle)) (stringp (car handle))))) | |
d40d713a KY |
2798 | ((equal (mm-handle-media-supertype handle) "multipart") |
2799 | (when (setq file (gnus-article-browse-html-save-cid-content | |
2800 | cid handle directory)) | |
2801 | (throw 'found file))) | |
2802 | ((equal (concat "<" cid ">") (mm-handle-id handle)) | |
2803 | (setq file | |
2804 | (expand-file-name | |
0b575a33 KY |
2805 | (or (mm-handle-filename handle) |
2806 | (concat | |
2807 | (make-temp-name "cid") | |
2808 | (car (rassoc (car (mm-handle-type handle)) | |
2809 | mailcap-mime-extensions)))) | |
2810 | directory)) | |
d40d713a KY |
2811 | (mm-save-part-to-file handle file) |
2812 | (throw 'found file)))))))) | |
20c0b2ce | 2813 | |
87035689 | 2814 | (defun gnus-article-browse-html-parts (list &optional header) |
01c52d31 | 2815 | "View all \"text/html\" parts from LIST. |
87035689 MB |
2816 | Recurse into multiparts. The optional HEADER that should be a decoded |
2817 | message header will be added to the bodies of the \"text/html\" parts." | |
01c52d31 | 2818 | ;; Internal function used by `gnus-article-browse-html-article'. |
d40d713a | 2819 | (let (type file charset content cid-dir tmp-file showed) |
01c52d31 MB |
2820 | ;; Find and show the html-parts. |
2821 | (dolist (handle list) | |
2822 | ;; If HTML, show it: | |
bbbe940b MB |
2823 | (cond ((not (listp handle))) |
2824 | ((or (equal (car (setq type (mm-handle-type handle))) "text/html") | |
2825 | (and (equal (car type) "message/external-body") | |
87035689 | 2826 | (or header |
247c22e1 | 2827 | (setq file (mm-handle-filename handle))) |
bbbe940b MB |
2828 | (or (mm-handle-cache handle) |
2829 | (condition-case code | |
2830 | (progn (mm-extern-cache-contents handle) t) | |
2831 | (error | |
2832 | (gnus-message 3 "%s" (error-message-string code)) | |
2833 | (when (>= gnus-verbose 3) (sit-for 2)) | |
2834 | nil))) | |
2835 | (progn | |
2836 | (setq handle (mm-handle-cache handle) | |
2837 | type (mm-handle-type handle)) | |
2838 | (equal (car type) "text/html")))) | |
d40d713a KY |
2839 | (setq charset (mail-content-type-get type 'charset) |
2840 | content (mm-get-part handle)) | |
2841 | (with-temp-buffer | |
2842 | (if (eq charset 'gnus-decoded) | |
2843 | (mm-enable-multibyte) | |
2844 | (mm-disable-multibyte)) | |
2845 | (insert content) | |
2846 | ;; resolve cid contents | |
2847 | (let ((case-fold-search t) | |
2848 | cid-file) | |
2849 | (goto-char (point-min)) | |
2850 | (while (re-search-forward "\ | |
2851 | <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\"" | |
2852 | nil t) | |
2853 | (unless cid-dir | |
765d4319 | 2854 | (setq cid-dir (mm-make-temp-file "cid" t)) |
d40d713a KY |
2855 | (add-to-list 'gnus-article-browse-html-temp-list cid-dir)) |
2856 | (setq file nil | |
2857 | content nil) | |
2858 | (when (setq cid-file | |
2859 | (gnus-article-browse-html-save-cid-content | |
2860 | (match-string 2) | |
2861 | (with-current-buffer gnus-article-buffer | |
2862 | gnus-article-mime-handles) | |
2863 | cid-dir)) | |
df103ffb | 2864 | (when (eq system-type 'cygwin) |
dfdbf7af KY |
2865 | (setq cid-file |
2866 | (concat "/" (substring | |
2867 | (with-output-to-string | |
2868 | (call-process "cygpath" nil | |
2869 | standard-output | |
2870 | nil "-m" cid-file)) | |
2871 | 0 -1)))) | |
d40d713a KY |
2872 | (replace-match (concat "file://" cid-file) |
2873 | nil nil nil 1)))) | |
2874 | (unless content (setq content (buffer-string)))) | |
2875 | (when (or charset header (not file)) | |
bbbe940b MB |
2876 | (setq tmp-file (mm-make-temp-file |
2877 | ;; Do we need to care for 8.3 filenames? | |
2878 | "mm-" nil ".html"))) | |
87035689 MB |
2879 | ;; Add a meta html tag to specify charset and a header. |
2880 | (cond | |
2881 | (header | |
c01f0213 | 2882 | (let (title eheader body hcharset coding) |
87035689 MB |
2883 | (with-temp-buffer |
2884 | (mm-enable-multibyte) | |
2885 | (setq case-fold-search t) | |
2886 | (insert header "\n") | |
2887 | (setq title (message-fetch-field "subject")) | |
2888 | (goto-char (point-min)) | |
5ea1a8d1 KY |
2889 | (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n" |
2890 | nil t) | |
87035689 MB |
2891 | (replace-match (cond ((match-beginning 1) "<") |
2892 | ((match-beginning 2) ">") | |
5ea1a8d1 KY |
2893 | ((match-beginning 3) "&") |
2894 | (t "<br>\n")))) | |
87035689 | 2895 | (goto-char (point-min)) |
4cbac8e9 KY |
2896 | (while (re-search-forward "^[\t ]+" nil t) |
2897 | (dotimes (i (prog1 | |
2898 | (current-column) | |
2899 | (delete-region (match-beginning 0) | |
2900 | (match-end 0)))) | |
2901 | (insert " "))) | |
2902 | (goto-char (point-min)) | |
5ea1a8d1 | 2903 | (insert "<div align=\"left\">\n") |
87035689 | 2904 | (goto-char (point-max)) |
5ea1a8d1 | 2905 | (insert "</div>\n<hr>\n") |
87035689 MB |
2906 | ;; We have to examine charset one by one since |
2907 | ;; charset specified in parts might be different. | |
2908 | (if (eq charset 'gnus-decoded) | |
2909 | (setq charset 'utf-8 | |
2910 | eheader (mm-encode-coding-string (buffer-string) | |
2911 | charset) | |
2912 | title (when title | |
2913 | (mm-encode-coding-string title charset)) | |
c01f0213 | 2914 | body (mm-encode-coding-string content charset)) |
87035689 MB |
2915 | (setq hcharset (mm-find-mime-charset-region (point-min) |
2916 | (point-max))) | |
2917 | (cond ((= (length hcharset) 1) | |
2918 | (setq hcharset (car hcharset) | |
2919 | coding (mm-charset-to-coding-system | |
0b575a33 | 2920 | hcharset nil t))) |
87035689 MB |
2921 | ((> (length hcharset) 1) |
2922 | (setq hcharset 'utf-8 | |
2923 | coding hcharset))) | |
2924 | (if coding | |
2925 | (if charset | |
2926 | (progn | |
2927 | (setq body | |
0b575a33 KY |
2928 | (mm-charset-to-coding-system charset |
2929 | nil t)) | |
87035689 MB |
2930 | (if (eq coding body) |
2931 | (setq eheader (mm-encode-coding-string | |
2932 | (buffer-string) coding) | |
2933 | title (when title | |
2934 | (mm-encode-coding-string | |
2935 | title coding)) | |
d40d713a | 2936 | body content) |
87035689 MB |
2937 | (setq charset 'utf-8 |
2938 | eheader (mm-encode-coding-string | |
2939 | (buffer-string) charset) | |
2940 | title (when title | |
2941 | (mm-encode-coding-string | |
2942 | title charset)) | |
2943 | body (mm-encode-coding-string | |
2944 | (mm-decode-coding-string | |
d40d713a | 2945 | content body) |
c01f0213 | 2946 | charset)))) |
87035689 MB |
2947 | (setq charset hcharset |
2948 | eheader (mm-encode-coding-string | |
2949 | (buffer-string) coding) | |
2950 | title (when title | |
2951 | (mm-encode-coding-string | |
2952 | title coding)) | |
d40d713a | 2953 | body content)) |
87035689 | 2954 | (setq eheader (mm-string-as-unibyte (buffer-string)) |
d40d713a | 2955 | body content))) |
87035689 MB |
2956 | (erase-buffer) |
2957 | (mm-disable-multibyte) | |
2958 | (insert body) | |
2959 | (when charset | |
c01f0213 | 2960 | (mm-add-meta-html-tag handle charset t)) |
87035689 MB |
2961 | (when title |
2962 | (goto-char (point-min)) | |
2963 | (unless (search-forward "<title>" nil t) | |
2964 | (re-search-forward "<head>\\s-*" nil t) | |
2965 | (insert "<title>" title "</title>\n"))) | |
2966 | (goto-char (point-min)) | |
2967 | (or (re-search-forward | |
2968 | "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t) | |
2969 | (re-search-forward | |
2970 | "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)) | |
2971 | (insert eheader) | |
2972 | (mm-write-region (point-min) (point-max) | |
2973 | tmp-file nil nil nil 'binary t)))) | |
2974 | (charset | |
2975 | (mm-with-unibyte-buffer | |
2976 | (insert (if (eq charset 'gnus-decoded) | |
d40d713a KY |
2977 | (mm-encode-coding-string content |
2978 | (setq charset 'utf-8)) | |
2979 | content)) | |
87035689 MB |
2980 | (if (or (mm-add-meta-html-tag handle charset) |
2981 | (not file)) | |
2982 | (mm-write-region (point-min) (point-max) | |
2983 | tmp-file nil nil nil 'binary t) | |
2984 | (setq tmp-file nil)))) | |
2985 | (tmp-file | |
2986 | (mm-save-part-to-file handle tmp-file))) | |
bbbe940b MB |
2987 | (when tmp-file |
2988 | (add-to-list 'gnus-article-browse-html-temp-list tmp-file)) | |
2989 | (add-hook 'gnus-summary-prepare-exit-hook | |
2990 | 'gnus-article-browse-delete-temp-files) | |
2991 | (add-hook 'gnus-exit-gnus-hook | |
2992 | (lambda () | |
2993 | (gnus-article-browse-delete-temp-files t))) | |
2994 | ;; FIXME: Warn if there's an <img> tag? | |
2995 | (browse-url-of-file (or tmp-file (expand-file-name file))) | |
2996 | (setq showed t)) | |
2997 | ;; If multipart, recurse | |
87035689 MB |
2998 | ((equal (mm-handle-media-supertype handle) "multipart") |
2999 | (when (gnus-article-browse-html-parts handle header) | |
3000 | (setq showed t))) | |
3001 | ((equal (mm-handle-media-type handle) "message/rfc822") | |
3002 | (mm-with-multibyte-buffer | |
3003 | (mm-insert-part handle) | |
3004 | (setq handle (mm-dissect-buffer t t)) | |
3005 | (when (and (bufferp (car handle)) | |
3006 | (stringp (car (mm-handle-type handle)))) | |
3007 | (setq handle (list handle))) | |
3008 | (when header | |
3009 | (article-decode-encoded-words) | |
3010 | (let ((gnus-visible-headers | |
3011 | (or (get 'gnus-visible-headers 'standard-value) | |
3012 | gnus-visible-headers))) | |
3013 | (article-hide-headers)) | |
3014 | (goto-char (point-min)) | |
3015 | (search-forward "\n\n" nil 'move) | |
3016 | (skip-chars-backward "\t\n ") | |
3017 | (setq header (buffer-substring (point-min) (point))))) | |
3018 | (when (prog1 | |
3019 | (gnus-article-browse-html-parts handle header) | |
3020 | (mm-destroy-parts handle)) | |
3021 | (setq showed t))))) | |
01c52d31 MB |
3022 | showed)) |
3023 | ||
87035689 | 3024 | (defun gnus-article-browse-html-article (&optional arg) |
01c52d31 | 3025 | "View \"text/html\" parts of the current article with a WWW browser. |
d40d713a KY |
3026 | Inline images embedded in a message using the cid scheme, as they are |
3027 | generally considered to be safe, will be processed properly. | |
87035689 MB |
3028 | The message header is added to the beginning of every html part unless |
3029 | the prefix argument ARG is given. | |
01c52d31 | 3030 | |
d40d713a KY |
3031 | Warning: Spammers use links to images (using the http scheme) in HTML |
3032 | articles to verify whether you have read the message. As | |
9b3ebcb6 MB |
3033 | `gnus-article-browse-html-article' passes the HTML content to the |
3034 | browser without eliminating these \"web bugs\" you should only | |
3035 | use it for mails from trusted senders. | |
b890d447 | 3036 | |
9b3ebcb6 | 3037 | If you always want to display HTML parts in the browser, set |
d40d713a KY |
3038 | `mm-text-html-renderer' to nil. |
3039 | ||
3040 | This command creates temporary files to pass HTML contents including | |
3041 | images if any to the browser, and deletes them when exiting the group | |
3042 | \(if you want)." | |
01c52d31 | 3043 | ;; Cf. `mm-w3m-safe-url-regexp' |
87035689 MB |
3044 | (interactive "P") |
3045 | (if arg | |
3046 | (gnus-summary-show-article) | |
3047 | (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value) | |
9b3ebcb6 MB |
3048 | gnus-visible-headers)) |
3049 | ;; As we insert a <hr>, there's no need for the body boundary. | |
3050 | (gnus-treat-body-boundary nil)) | |
87035689 MB |
3051 | (gnus-summary-show-article))) |
3052 | (with-current-buffer gnus-article-buffer | |
3053 | (let ((header (unless arg | |
3054 | (save-restriction | |
3055 | (widen) | |
3056 | (buffer-substring-no-properties | |
3057 | (goto-char (point-min)) | |
3058 | (if (search-forward "\n\n" nil t) | |
3059 | (match-beginning 0) | |
3060 | (goto-char (point-max)) | |
3061 | (skip-chars-backward "\t\n ") | |
3062 | (point)))))) | |
3063 | parts) | |
3064 | (set-buffer gnus-original-article-buffer) | |
3065 | (setq parts (mm-dissect-buffer t t)) | |
01c52d31 MB |
3066 | ;; If singlepart, enforce a list. |
3067 | (when (and (bufferp (car parts)) | |
3068 | (stringp (car (mm-handle-type parts)))) | |
3069 | (setq parts (list parts))) | |
3070 | ;; Process the list | |
87035689 | 3071 | (unless (gnus-article-browse-html-parts parts header) |
01c52d31 | 3072 | (gnus-error 3 "Mail doesn't contain a \"text/html\" part!")) |
87035689 MB |
3073 | (mm-destroy-parts parts) |
3074 | (unless arg | |
3075 | (gnus-summary-show-article))))) | |
01c52d31 | 3076 | |
16409b0b GM |
3077 | (defun article-hide-list-identifiers () |
3078 | "Remove list identifies from the Subject header. | |
3079 | The `gnus-list-identifiers' variable specifies what to do." | |
3080 | (interactive) | |
23f87bed | 3081 | (let ((inhibit-point-motion-hooks t) |
d6cd56f1 | 3082 | (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name)) |
fb9b91be | 3083 | (inhibit-read-only t)) |
23f87bed MB |
3084 | (when regexp |
3085 | (save-excursion | |
3086 | (save-restriction | |
3087 | (article-narrow-to-head) | |
3088 | (goto-char (point-min)) | |
3089 | (while (re-search-forward | |
3090 | (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)") | |
3091 | nil t) | |
3092 | (delete-region (match-beginning 2) (match-end 0)) | |
3093 | (beginning-of-line)) | |
3094 | (when (re-search-forward | |
3095 | "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t) | |
3096 | (delete-region (match-beginning 1) (match-end 1)))))))) | |
eec82323 LMI |
3097 | |
3098 | (defun article-hide-pem (&optional arg) | |
3099 | "Toggle hiding of any PEM headers and signatures in the current article. | |
3100 | If given a negative prefix, always show; if given a positive prefix, | |
3101 | always hide." | |
3102 | (interactive (gnus-article-hidden-arg)) | |
3103 | (unless (gnus-article-check-hidden-text 'pem arg) | |
3104 | (save-excursion | |
23f87bed | 3105 | (let ((inhibit-read-only t) end) |
eec82323 | 3106 | (goto-char (point-min)) |
16409b0b GM |
3107 | ;; Hide the horrendously ugly "header". |
3108 | (when (and (search-forward | |
3109 | "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | |
3110 | nil t) | |
3111 | (setq end (1+ (match-beginning 0)))) | |
23f87bed | 3112 | (gnus-add-wash-type 'pem) |
16409b0b GM |
3113 | (gnus-article-hide-text-type |
3114 | end | |
3115 | (if (search-forward "\n\n" nil t) | |
3116 | (match-end 0) | |
3117 | (point-max)) | |
3118 | 'pem) | |
3119 | ;; Hide the trailer as well | |
3120 | (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | |
3121 | nil t) | |
3122 | (gnus-article-hide-text-type | |
3123 | (match-beginning 0) (match-end 0) 'pem))))))) | |
3124 | ||
3125 | (defun article-strip-banner () | |
23f87bed MB |
3126 | "Strip the banners specified by the `banner' group parameter and by |
3127 | `gnus-article-address-banner-alist'." | |
16409b0b | 3128 | (interactive) |
23f87bed MB |
3129 | (save-excursion |
3130 | (save-restriction | |
3131 | (let ((inhibit-point-motion-hooks t)) | |
3132 | (when (gnus-parameter-banner gnus-newsgroup-name) | |
3133 | (article-really-strip-banner | |
3134 | (gnus-parameter-banner gnus-newsgroup-name))) | |
3135 | (when gnus-article-address-banner-alist | |
cf5a5c38 MB |
3136 | ;; Note that the From header is decoded here, so it is |
3137 | ;; required that the *-extract-address-components function | |
3138 | ;; supports non-ASCII text. | |
d71c0855 MB |
3139 | (let ((from (save-restriction |
3140 | (widen) | |
3141 | (article-narrow-to-head) | |
3142 | (mail-fetch-field "from")))) | |
3143 | (when (and from | |
3144 | (setq from | |
3145 | (cadr (funcall gnus-extract-address-components | |
3146 | from)))) | |
3147 | (catch 'found | |
3148 | (dolist (pair gnus-article-address-banner-alist) | |
3149 | (when (string-match (car pair) from) | |
3150 | (throw 'found | |
3151 | (article-really-strip-banner (cdr pair))))))))))))) | |
23f87bed MB |
3152 | |
3153 | (defun article-really-strip-banner (banner) | |
3154 | "Strip the banner specified by the argument." | |
16409b0b GM |
3155 | (save-excursion |
3156 | (save-restriction | |
3157 | (let ((inhibit-point-motion-hooks t) | |
16409b0b | 3158 | (gnus-signature-limit nil) |
23f87bed MB |
3159 | (inhibit-read-only t)) |
3160 | (article-goto-body) | |
3161 | (cond | |
3162 | ((eq banner 'signature) | |
3163 | (when (gnus-article-narrow-to-signature) | |
3164 | (widen) | |
3165 | (forward-line -1) | |
3166 | (delete-region (point) (point-max)))) | |
3167 | ((symbolp banner) | |
3168 | (if (setq banner (cdr (assq banner gnus-article-banner-alist))) | |
3169 | (while (re-search-forward banner nil t) | |
3170 | (delete-region (match-beginning 0) (match-end 0))))) | |
3171 | ((stringp banner) | |
3172 | (while (re-search-forward banner nil t) | |
3173 | (delete-region (match-beginning 0) (match-end 0))))))))) | |
16409b0b GM |
3174 | |
3175 | (defun article-babel () | |
3176 | "Translate article using an online translation service." | |
3177 | (interactive) | |
3178 | (require 'babel) | |
01c52d31 | 3179 | (gnus-with-article-buffer |
16409b0b | 3180 | (when (article-goto-body) |
01c52d31 | 3181 | (let* ((start (point)) |
16409b0b GM |
3182 | (end (point-max)) |
3183 | (orig (buffer-substring start end)) | |
23f87bed | 3184 | (trans (babel-as-string orig))) |
16409b0b GM |
3185 | (save-restriction |
3186 | (narrow-to-region start end) | |
3187 | (delete-region start end) | |
23f87bed | 3188 | (insert trans)))))) |
eec82323 LMI |
3189 | |
3190 | (defun article-hide-signature (&optional arg) | |
3191 | "Hide the signature in the current article. | |
3192 | If given a negative prefix, always show; if given a positive prefix, | |
3193 | always hide." | |
3194 | (interactive (gnus-article-hidden-arg)) | |
3195 | (unless (gnus-article-check-hidden-text 'signature arg) | |
3196 | (save-excursion | |
3197 | (save-restriction | |
4e7d0221 | 3198 | (let ((inhibit-read-only t)) |
eec82323 LMI |
3199 | (when (gnus-article-narrow-to-signature) |
3200 | (gnus-article-hide-text-type | |
23f87bed MB |
3201 | (point-min) (point-max) 'signature)))))) |
3202 | (gnus-set-mode-line 'article)) | |
eec82323 | 3203 | |
16409b0b GM |
3204 | (defun article-strip-headers-in-body () |
3205 | "Strip offensive headers from bodies." | |
3206 | (interactive) | |
3207 | (save-excursion | |
3208 | (article-goto-body) | |
3209 | (let ((case-fold-search t)) | |
3210 | (when (looking-at "x-no-archive:") | |
3211 | (gnus-delete-line))))) | |
3212 | ||
eec82323 LMI |
3213 | (defun article-strip-leading-blank-lines () |
3214 | "Remove all blank lines from the beginning of the article." | |
3215 | (interactive) | |
3216 | (save-excursion | |
3217 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3218 | (inhibit-read-only t)) |
16409b0b | 3219 | (when (article-goto-body) |
eec82323 LMI |
3220 | (while (and (not (eobp)) |
3221 | (looking-at "[ \t]*$")) | |
3222 | (gnus-delete-line)))))) | |
3223 | ||
16409b0b GM |
3224 | (defun article-narrow-to-head () |
3225 | "Narrow the buffer to the head of the message. | |
3226 | Point is left at the beginning of the narrowed-to region." | |
3227 | (narrow-to-region | |
3228 | (goto-char (point-min)) | |
e7719ea1 G |
3229 | (cond |
3230 | ;; Absolutely no headers displayed. | |
3231 | ((looking-at "\n") | |
3232 | (point)) | |
3233 | ;; Normal headers. | |
3234 | ((search-forward "\n\n" nil 1) | |
3235 | (1- (point))) | |
3236 | ;; Nothing but headers. | |
3237 | (t | |
3238 | (point-max)))) | |
16409b0b GM |
3239 | (goto-char (point-min))) |
3240 | ||
3241 | (defun article-goto-body () | |
3242 | "Place point at the start of the body." | |
3243 | (goto-char (point-min)) | |
3244 | (cond | |
3245 | ;; This variable is only bound when dealing with separate | |
3246 | ;; MIME body parts. | |
3247 | (article-goto-body-goes-to-point-min-p | |
3248 | t) | |
3249 | ((search-forward "\n\n" nil t) | |
3250 | t) | |
3251 | (t | |
3252 | (goto-char (point-max)) | |
3253 | nil))) | |
3254 | ||
eec82323 LMI |
3255 | (defun article-strip-multiple-blank-lines () |
3256 | "Replace consecutive blank lines with one empty line." | |
3257 | (interactive) | |
3258 | (save-excursion | |
3259 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3260 | (inhibit-read-only t)) |
eec82323 | 3261 | ;; First make all blank lines empty. |
16409b0b | 3262 | (article-goto-body) |
eec82323 | 3263 | (while (re-search-forward "^[ \t]+$" nil t) |
16409b0b GM |
3264 | (unless (gnus-annotation-in-region-p |
3265 | (match-beginning 0) (match-end 0)) | |
3266 | (replace-match "" nil t))) | |
eec82323 | 3267 | ;; Then replace multiple empty lines with a single empty line. |
16409b0b | 3268 | (article-goto-body) |
23f87bed | 3269 | (while (re-search-forward "\n\n\\(\n+\\)" nil t) |
16409b0b GM |
3270 | (unless (gnus-annotation-in-region-p |
3271 | (match-beginning 0) (match-end 0)) | |
23f87bed | 3272 | (delete-region (match-beginning 1) (match-end 1))))))) |
eec82323 LMI |
3273 | |
3274 | (defun article-strip-leading-space () | |
3275 | "Remove all white space from the beginning of the lines in the article." | |
3276 | (interactive) | |
3277 | (save-excursion | |
3278 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3279 | (inhibit-read-only t)) |
16409b0b | 3280 | (article-goto-body) |
eec82323 LMI |
3281 | (while (re-search-forward "^[ \t]+" nil t) |
3282 | (replace-match "" t t))))) | |
3283 | ||
16409b0b GM |
3284 | (defun article-strip-trailing-space () |
3285 | "Remove all white space from the end of the lines in the article." | |
3286 | (interactive) | |
3287 | (save-excursion | |
3288 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3289 | (inhibit-read-only t)) |
16409b0b GM |
3290 | (article-goto-body) |
3291 | (while (re-search-forward "[ \t]+$" nil t) | |
3292 | (replace-match "" t t))))) | |
3293 | ||
eec82323 LMI |
3294 | (defun article-strip-blank-lines () |
3295 | "Strip leading, trailing and multiple blank lines." | |
3296 | (interactive) | |
3297 | (article-strip-leading-blank-lines) | |
3298 | (article-remove-trailing-blank-lines) | |
3299 | (article-strip-multiple-blank-lines)) | |
3300 | ||
6748645f LMI |
3301 | (defun article-strip-all-blank-lines () |
3302 | "Strip all blank lines." | |
3303 | (interactive) | |
3304 | (save-excursion | |
3305 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3306 | (inhibit-read-only t)) |
16409b0b | 3307 | (article-goto-body) |
6748645f LMI |
3308 | (while (re-search-forward "^[ \t]*\n" nil t) |
3309 | (replace-match "" t t))))) | |
3310 | ||
eec82323 LMI |
3311 | (defun gnus-article-narrow-to-signature () |
3312 | "Narrow to the signature; return t if a signature is found, else nil." | |
6748645f | 3313 | (let ((inhibit-point-motion-hooks t)) |
6748645f LMI |
3314 | (when (gnus-article-search-signature) |
3315 | (forward-line 1) | |
3316 | ;; Check whether we have some limits to what we consider | |
3317 | ;; to be a signature. | |
3318 | (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit | |
3319 | (list gnus-signature-limit))) | |
3320 | limit limited) | |
3321 | (while (setq limit (pop limits)) | |
3322 | (if (or (and (integerp limit) | |
3323 | (< (- (point-max) (point)) limit)) | |
3324 | (and (floatp limit) | |
3325 | (< (count-lines (point) (point-max)) limit)) | |
23f87bed | 3326 | (and (functionp limit) |
6748645f LMI |
3327 | (funcall limit)) |
3328 | (and (stringp limit) | |
3329 | (not (re-search-forward limit nil t)))) | |
3330 | () ; This limit did not succeed. | |
3331 | (setq limited t | |
3332 | limits nil))) | |
3333 | (unless limited | |
3334 | (narrow-to-region (point) (point-max)) | |
3335 | t))))) | |
eec82323 LMI |
3336 | |
3337 | (defun gnus-article-search-signature () | |
3338 | "Search the current buffer for the signature separator. | |
3339 | Put point at the beginning of the signature separator." | |
3340 | (let ((cur (point))) | |
3341 | (goto-char (point-max)) | |
3342 | (if (if (stringp gnus-signature-separator) | |
3343 | (re-search-backward gnus-signature-separator nil t) | |
3344 | (let ((seps gnus-signature-separator)) | |
3345 | (while (and seps | |
3346 | (not (re-search-backward (car seps) nil t))) | |
3347 | (pop seps)) | |
3348 | seps)) | |
3349 | t | |
3350 | (goto-char cur) | |
3351 | nil))) | |
3352 | ||
eec82323 LMI |
3353 | (defun gnus-article-hidden-arg () |
3354 | "Return the current prefix arg as a number, or 0 if no prefix." | |
3355 | (list (if current-prefix-arg | |
3356 | (prefix-numeric-value current-prefix-arg) | |
3357 | 0))) | |
3358 | ||
3359 | (defun gnus-article-check-hidden-text (type arg) | |
3360 | "Return nil if hiding is necessary. | |
f0529b5b | 3361 | Arg can be nil or a number. nil and positive means hide, negative |
eec82323 LMI |
3362 | means show, 0 means toggle." |
3363 | (save-excursion | |
3364 | (save-restriction | |
eec82323 LMI |
3365 | (let ((hide (gnus-article-hidden-text-p type))) |
3366 | (cond | |
3367 | ((or (null arg) | |
3368 | (> arg 0)) | |
3369 | nil) | |
3370 | ((< arg 0) | |
4481aa98 SZ |
3371 | (gnus-article-show-hidden-text type) |
3372 | t) | |
eec82323 LMI |
3373 | (t |
3374 | (if (eq hide 'hidden) | |
4481aa98 SZ |
3375 | (progn |
3376 | (gnus-article-show-hidden-text type) | |
3377 | t) | |
eec82323 LMI |
3378 | nil))))))) |
3379 | ||
3380 | (defun gnus-article-hidden-text-p (type) | |
3381 | "Say whether the current buffer contains hidden text of type TYPE." | |
6748645f | 3382 | (let ((pos (text-property-any (point-min) (point-max) 'article-type type))) |
eec82323 | 3383 | (while (and pos |
16409b0b GM |
3384 | (not (get-text-property pos 'invisible)) |
3385 | (not (get-text-property pos 'dummy-invisible))) | |
eec82323 LMI |
3386 | (setq pos |
3387 | (text-property-any (1+ pos) (point-max) 'article-type type))) | |
3388 | (if pos | |
3389 | 'hidden | |
16409b0b | 3390 | nil))) |
eec82323 | 3391 | |
520aa572 | 3392 | (defun gnus-article-show-hidden-text (type &optional dummy) |
eec82323 | 3393 | "Show all hidden text of type TYPE. |
520aa572 | 3394 | Originally it is hide instead of DUMMY." |
4e7d0221 | 3395 | (let ((inhibit-read-only t) |
520aa572 | 3396 | (inhibit-point-motion-hooks t)) |
a1506d29 | 3397 | (gnus-remove-text-properties-when |
520aa572 | 3398 | 'article-type type |
a1506d29 | 3399 | (point-min) (point-max) |
520aa572 | 3400 | (cons 'article-type (cons type |
23f87bed MB |
3401 | gnus-hidden-properties))) |
3402 | (gnus-delete-wash-type type))) | |
eec82323 LMI |
3403 | |
3404 | (defconst article-time-units | |
3405 | `((year . ,(* 365.25 24 60 60)) | |
3406 | (week . ,(* 7 24 60 60)) | |
3407 | (day . ,(* 24 60 60)) | |
3408 | (hour . ,(* 60 60)) | |
3409 | (minute . 60) | |
3410 | (second . 1)) | |
3411 | "Mapping from time units to seconds.") | |
3412 | ||
23f87bed MB |
3413 | (defun gnus-article-forward-header () |
3414 | "Move point to the start of the next header. | |
3415 | If the current header is a continuation header, this can be several | |
3416 | lines forward." | |
3417 | (let ((ended nil)) | |
3418 | (while (not ended) | |
3419 | (forward-line 1) | |
3420 | (if (looking-at "[ \t]+[^ \t]") | |
3421 | (forward-line 1) | |
3422 | (setq ended t))))) | |
3423 | ||
12e3ca0a | 3424 | (defun article-treat-date () |
f8342cf5 KY |
3425 | (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer) |
3426 | (with-current-buffer gnus-summary-buffer | |
3427 | gnus-article-date-headers) | |
3428 | gnus-article-date-headers) | |
3429 | t)) | |
12e3ca0a LI |
3430 | |
3431 | (defun article-date-ut (&optional type highlight date-position) | |
3432 | "Convert DATE date to TYPE in the current article. | |
3433 | The default type is `ut'. See `gnus-article-date-headers' for | |
3434 | possible values." | |
eec82323 | 3435 | (interactive (list 'ut t)) |
12e3ca0a | 3436 | (let* ((case-fold-search t) |
31640842 | 3437 | (inhibit-read-only t) |
eec82323 | 3438 | (inhibit-point-motion-hooks t) |
12e3ca0a | 3439 | (first t) |
d5e9a4e9 | 3440 | (visible-date (mail-fetch-field "Date")) |
31640842 | 3441 | pos date bface eface) |
16409b0b | 3442 | (save-excursion |
0861eb2e KY |
3443 | (if date-position |
3444 | (progn | |
3445 | (goto-char date-position) | |
3446 | (setq date (get-text-property (point) 'original-date)) | |
923c1bfc KY |
3447 | (when (looking-at "[^:]+:[\t ]*") |
3448 | (setq bface (get-text-property (match-beginning 0) 'face) | |
3449 | eface (get-text-property (match-end 0) 'face))) | |
0861eb2e KY |
3450 | (delete-region (point) |
3451 | (progn | |
3452 | (gnus-article-forward-header) | |
3453 | (point))) | |
3454 | (article-transform-date date type bface eface)) | |
3455 | (save-restriction | |
3456 | (widen) | |
3457 | (goto-char (point-min)) | |
3458 | (while (or (get-text-property (setq pos (point)) 'original-date) | |
3459 | (and (setq pos (next-single-property-change | |
3460 | (point) 'original-date)) | |
3461 | (goto-char pos))) | |
3462 | (narrow-to-region pos (if (search-forward "\n\n" nil t) | |
3463 | (1+ (match-beginning 0)) | |
3464 | (point-max))) | |
923c1bfc KY |
3465 | (while (setq pos (text-property-not-all pos (point-max) |
3466 | 'gnus-date-type nil)) | |
3467 | (setq date (get-text-property pos 'original-date)) | |
3468 | (goto-char pos) | |
3469 | (when (looking-at "[^:]+:[\t ]*") | |
3470 | (setq bface (get-text-property (match-beginning 0) 'face) | |
3471 | eface (get-text-property (match-end 0) 'face))) | |
3472 | (delete-region pos (or (text-property-any pos (point-max) | |
3473 | 'gnus-date-type nil) | |
3474 | (point-max)))) | |
3475 | (unless date ;; the 1st time | |
3476 | (goto-char (point-min)) | |
3477 | (while (re-search-forward "^Date:[\t ]*" nil t) | |
3478 | (setq date (get-text-property (match-beginning 0) | |
3479 | 'original-date) | |
3480 | bface (get-text-property (match-beginning 0) 'face) | |
3481 | eface (get-text-property (match-end 0) 'face)) | |
3482 | (delete-region (point-at-bol) (progn | |
3483 | (gnus-article-forward-header) | |
3484 | (point))))) | |
0861eb2e KY |
3485 | (when (and (not date) |
3486 | visible-date) | |
3487 | (setq date visible-date)) | |
3488 | (when date | |
32a400d4 | 3489 | (article-transform-date date type bface eface)) |
0861eb2e KY |
3490 | (goto-char (point-max)) |
3491 | (widen))))))) | |
32a400d4 LI |
3492 | |
3493 | (defun article-transform-date (date type bface eface) | |
3494 | (dolist (this-type (cond | |
3495 | ((null type) | |
3496 | (list 'ut)) | |
3497 | ((atom type) | |
3498 | (list type)) | |
3499 | (t | |
3500 | type))) | |
923c1bfc KY |
3501 | (goto-char |
3502 | (prog1 | |
3503 | (point) | |
3504 | (add-text-properties | |
3505 | (point) | |
3506 | (progn | |
3507 | (insert (article-make-date-line date (or this-type 'ut)) "\n") | |
3508 | (point)) | |
3509 | (list 'original-date date 'gnus-date-type this-type)))) | |
32a400d4 | 3510 | ;; Do highlighting. |
923c1bfc KY |
3511 | (when (looking-at |
3512 | "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?") | |
3513 | (put-text-property (match-beginning 1) (match-end 1) 'face bface) | |
3514 | (when (match-beginning 2) | |
3515 | (put-text-property (match-beginning 2) (match-end 2) 'face eface)) | |
3516 | (while (and (zerop (forward-line 1)) | |
3517 | (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")) | |
3518 | (when (match-beginning 1) | |
3519 | (put-text-property (match-beginning 1) (match-end 1) 'face eface)))))) | |
eec82323 LMI |
3520 | |
3521 | (defun article-make-date-line (date type) | |
3522 | "Return a DATE line of TYPE." | |
5fe18311 KY |
3523 | (unless (memq type '(local ut original user-defined iso8601 lapsed english |
3524 | combined-lapsed)) | |
23f87bed MB |
3525 | (error "Unknown conversion type: %s" type)) |
3526 | (condition-case () | |
fa41748c | 3527 | (let ((time (ignore-errors (date-to-time date)))) |
16409b0b | 3528 | (cond |
23f87bed MB |
3529 | ;; Convert to the local timezone. |
3530 | ((eq type 'local) | |
01c52d31 | 3531 | (concat "Date: " (message-make-date time))) |
23f87bed MB |
3532 | ;; Convert to Universal Time. |
3533 | ((eq type 'ut) | |
3534 | (concat "Date: " | |
01c52d31 MB |
3535 | (substring |
3536 | (message-make-date | |
3537 | (let* ((e (parse-time-string date)) | |
3538 | (tm (apply 'encode-time e)) | |
3539 | (ms (car tm)) | |
3540 | (ls (- (cadr tm) (car (current-time-zone time))))) | |
3541 | (cond ((< ls 0) (list (1- ms) (+ ls 65536))) | |
3542 | ((> ls 65535) (list (1+ ms) (- ls 65536))) | |
3543 | (t (list ms ls))))) | |
3544 | 0 -5) | |
3545 | "UT")) | |
23f87bed MB |
3546 | ;; Get the original date from the article. |
3547 | ((eq type 'original) | |
3548 | (concat "Date: " (if (string-match "\n+$" date) | |
3549 | (substring date 0 (match-beginning 0)) | |
3550 | date))) | |
3551 | ;; Let the user define the format. | |
c4753373 | 3552 | ((eq type 'user-defined) |
23f87bed MB |
3553 | (let ((format (or (condition-case nil |
3554 | (with-current-buffer gnus-summary-buffer | |
3555 | gnus-article-time-format) | |
3556 | (error nil)) | |
3557 | gnus-article-time-format))) | |
3558 | (if (functionp format) | |
3559 | (funcall format time) | |
3560 | (concat "Date: " (format-time-string format time))))) | |
3561 | ;; ISO 8601. | |
3562 | ((eq type 'iso8601) | |
3563 | (let ((tz (car (current-time-zone time)))) | |
3564 | (concat | |
3565 | "Date: " | |
3566 | (format-time-string "%Y%m%dT%H%M%S" time) | |
3567 | (format "%s%02d%02d" | |
3568 | (if (> tz 0) "+" "-") (/ (abs tz) 3600) | |
3569 | (/ (% (abs tz) 3600) 60))))) | |
12e3ca0a | 3570 | ;; Do a lapsed format. |
23f87bed | 3571 | ((eq type 'lapsed) |
12e3ca0a | 3572 | (concat "Date: " (article-lapsed-string time))) |
647559c2 LI |
3573 | ;; A combined date/lapsed format. |
3574 | ((eq type 'combined-lapsed) | |
19cc6697 G |
3575 | (let ((date-string (article-make-date-line date 'original)) |
3576 | (segments 3) | |
3577 | lapsed-string) | |
3578 | (while (and | |
fa41748c | 3579 | time |
19cc6697 G |
3580 | (setq lapsed-string |
3581 | (concat " (" (article-lapsed-string time segments) ")")) | |
3582 | (> (+ (length date-string) | |
3583 | (length lapsed-string)) | |
d6f13ac8 | 3584 | (+ fill-column 6)) |
19cc6697 G |
3585 | (> segments 0)) |
3586 | (setq segments (1- segments))) | |
3587 | (if (> segments 0) | |
3588 | (concat date-string lapsed-string) | |
3589 | date-string))) | |
23f87bed MB |
3590 | ;; Display the date in proper English |
3591 | ((eq type 'english) | |
3592 | (let ((dtime (decode-time time))) | |
3593 | (concat | |
3594 | "Date: the " | |
3595 | (number-to-string (nth 3 dtime)) | |
3596 | (let ((digit (% (nth 3 dtime) 10))) | |
3597 | (cond | |
3598 | ((memq (nth 3 dtime) '(11 12 13)) "th") | |
3599 | ((= digit 1) "st") | |
3600 | ((= digit 2) "nd") | |
3601 | ((= digit 3) "rd") | |
3602 | (t "th"))) | |
3603 | " of " | |
3604 | (nth (1- (nth 4 dtime)) gnus-english-month-names) | |
3605 | " " | |
3606 | (number-to-string (nth 5 dtime)) | |
3607 | " at " | |
3608 | (format "%02d" (nth 2 dtime)) | |
3609 | ":" | |
3610 | (format "%02d" (nth 1 dtime))))))) | |
647559c2 | 3611 | (foo |
a601fb74 | 3612 | (format "Date: %s (from Gnus)" date)))) |
eec82323 | 3613 | |
647559c2 LI |
3614 | (defun article-lapsed-string (time &optional max-segments) |
3615 | ;; If the date is seriously mangled, the timezone functions are | |
3616 | ;; liable to bug out, so we ignore all errors. | |
3617 | (let* ((now (current-time)) | |
3618 | (real-time (subtract-time now time)) | |
3619 | (real-sec (and real-time | |
3620 | (+ (* (float (car real-time)) 65536) | |
3621 | (cadr real-time)))) | |
3622 | (sec (and real-time (abs real-sec))) | |
3623 | (segments 0) | |
3624 | num prev) | |
3625 | (unless max-segments | |
3626 | (setq max-segments (length article-time-units))) | |
3627 | (cond | |
3628 | ((null real-time) | |
3629 | "Unknown") | |
3630 | ((zerop sec) | |
3631 | "Now") | |
3632 | (t | |
3633 | (concat | |
3634 | ;; This is a bit convoluted, but basically we go | |
3635 | ;; through the time units for years, weeks, etc, | |
3636 | ;; and divide things to see whether that results | |
3637 | ;; in positive answers. | |
3638 | (mapconcat | |
3639 | (lambda (unit) | |
3640 | (if (or (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
3641 | (>= segments max-segments)) | |
3642 | ;; The (remaining) seconds are too few to | |
3643 | ;; be divided into this time unit. | |
3644 | "" | |
3645 | ;; It's big enough, so we output it. | |
3646 | (setq sec (- sec (* num (cdr unit)))) | |
3647 | (prog1 | |
3648 | (concat (if prev ", " "") (int-to-string | |
3649 | (floor num)) | |
3650 | " " (symbol-name (car unit)) | |
3651 | (if (> num 1) "s" "")) | |
3652 | (setq prev t | |
3653 | segments (1+ segments))))) | |
3654 | article-time-units "") | |
3655 | ;; If dates are odd, then it might appear like the | |
3656 | ;; article was sent in the future. | |
3657 | (if (> real-sec 0) | |
3658 | " ago" | |
3659 | " in the future")))))) | |
3660 | ||
eec82323 LMI |
3661 | (defun article-date-local (&optional highlight) |
3662 | "Convert the current article date to the local timezone." | |
3663 | (interactive (list t)) | |
3664 | (article-date-ut 'local highlight)) | |
3665 | ||
23f87bed MB |
3666 | (defun article-date-english (&optional highlight) |
3667 | "Convert the current article date to something that is proper English." | |
3668 | (interactive (list t)) | |
3669 | (article-date-ut 'english highlight)) | |
3670 | ||
eec82323 LMI |
3671 | (defun article-date-original (&optional highlight) |
3672 | "Convert the current article date to what it was originally. | |
3673 | This is only useful if you have used some other date conversion | |
3674 | function and want to see what the date was before converting." | |
3675 | (interactive (list t)) | |
3676 | (article-date-ut 'original highlight)) | |
3677 | ||
3678 | (defun article-date-lapsed (&optional highlight) | |
3679 | "Convert the current article date to time lapsed since it was sent." | |
3680 | (interactive (list t)) | |
3681 | (article-date-ut 'lapsed highlight)) | |
3682 | ||
647559c2 LI |
3683 | (defun article-date-combined-lapsed (&optional highlight) |
3684 | "Convert the current article date to time lapsed since it was sent." | |
3685 | (interactive (list t)) | |
3686 | (article-date-ut 'combined-lapsed highlight)) | |
3687 | ||
6748645f LMI |
3688 | (defun article-update-date-lapsed () |
3689 | "Function to be run from a timer to update the lapsed time line." | |
e0a8aa09 | 3690 | (save-match-data |
0832490d LI |
3691 | (let ((buffer (current-buffer))) |
3692 | (ignore-errors | |
3693 | (walk-windows | |
3694 | (lambda (w) | |
3695 | (set-buffer (window-buffer w)) | |
1b3b87df | 3696 | (when (derived-mode-p 'gnus-article-mode) |
0832490d | 3697 | (let ((old-line (count-lines (point-min) (point))) |
c61a8b44 | 3698 | (old-column (- (point) (line-beginning-position))) |
923c1bfc KY |
3699 | (window-start (window-start w)) |
3700 | (pos (point-min)) | |
3701 | type next end) | |
3702 | (while (setq pos (text-property-not-all pos (point-max) | |
3703 | 'gnus-date-type nil)) | |
3704 | (setq next (or (next-single-property-change pos | |
3705 | 'gnus-date-type) | |
3706 | (point-max))) | |
3707 | (setq type (get-text-property pos 'gnus-date-type)) | |
3708 | (when (memq type '(lapsed combined-lapsed user-defined)) | |
3709 | (article-date-ut type t pos) | |
3710 | (setq end (or (next-single-property-change pos | |
3711 | 'gnus-date-type) | |
3712 | (point-max))) | |
3713 | (when window-start | |
3714 | (if (/= window-start next) | |
3715 | (setq window-start nil) | |
3716 | (set-window-start w end))) | |
3717 | (setq next end)) | |
3718 | (setq pos next)) | |
0832490d LI |
3719 | (goto-char (point-min)) |
3720 | (when (> old-column 0) | |
3721 | (setq old-line (1- old-line))) | |
3722 | (forward-line old-line) | |
3723 | (end-of-line) | |
3724 | (when (> (current-column) old-column) | |
3725 | (beginning-of-line) | |
3726 | (forward-char old-column))))) | |
3727 | nil 'visible)) | |
3728 | (set-buffer buffer)))) | |
6748645f LMI |
3729 | |
3730 | (defun gnus-start-date-timer (&optional n) | |
12e3ca0a | 3731 | "Start a timer to update the Date headers in the article buffers. |
6748645f LMI |
3732 | The numerical prefix says how frequently (in seconds) the function |
3733 | is to run." | |
3734 | (interactive "p") | |
3735 | (unless n | |
3736 | (setq n 1)) | |
3737 | (gnus-stop-date-timer) | |
3738 | (setq article-lapsed-timer | |
01c52d31 | 3739 | (run-at-time 1 n 'article-update-date-lapsed))) |
6748645f LMI |
3740 | |
3741 | (defun gnus-stop-date-timer () | |
12e3ca0a | 3742 | "Stop the Date timer." |
6748645f LMI |
3743 | (interactive) |
3744 | (when article-lapsed-timer | |
3745 | (nnheader-cancel-timer article-lapsed-timer) | |
3746 | (setq article-lapsed-timer nil))) | |
3747 | ||
eec82323 LMI |
3748 | (defun article-date-user (&optional highlight) |
3749 | "Convert the current article date to the user-defined format. | |
3750 | This format is defined by the `gnus-article-time-format' variable." | |
3751 | (interactive (list t)) | |
3752 | (article-date-ut 'user highlight)) | |
3753 | ||
6748645f LMI |
3754 | (defun article-date-iso8601 (&optional highlight) |
3755 | "Convert the current article date to ISO8601." | |
3756 | (interactive (list t)) | |
3757 | (article-date-ut 'iso8601 highlight)) | |
3758 | ||
31640842 MB |
3759 | (defmacro gnus-article-save-original-date (&rest forms) |
3760 | "Save the original date as a text property and evaluate FORMS." | |
3761 | `(let* ((case-fold-search t) | |
3762 | (start (progn | |
3763 | (goto-char (point-min)) | |
3764 | (when (and (re-search-forward "^date:[\t\n ]+" nil t) | |
3765 | (not (bolp))) | |
3766 | (match-end 0)))) | |
3767 | (date (when (and start | |
01c52d31 | 3768 | (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)" |
31640842 MB |
3769 | nil t)) |
3770 | (buffer-substring-no-properties start | |
3771 | (match-beginning 0))))) | |
3772 | (goto-char (point-max)) | |
3773 | (skip-chars-backward "\n") | |
3774 | (put-text-property (point-min) (point) 'original-date date) | |
3775 | ,@forms | |
3776 | (goto-char (point-max)) | |
3777 | (skip-chars-backward "\n") | |
3778 | (put-text-property (point-min) (point) 'original-date date))) | |
3779 | ||
23f87bed MB |
3780 | ;; (defun article-show-all () |
3781 | ;; "Show all hidden text in the article buffer." | |
3782 | ;; (interactive) | |
3783 | ;; (save-excursion | |
3784 | ;; (let ((inhibit-read-only t)) | |
3785 | ;; (gnus-article-unhide-text (point-min) (point-max))))) | |
3786 | ||
3787 | (defun article-remove-leading-whitespace () | |
3788 | "Remove excessive whitespace from all headers." | |
eec82323 LMI |
3789 | (interactive) |
3790 | (save-excursion | |
23f87bed MB |
3791 | (save-restriction |
3792 | (let ((inhibit-read-only t)) | |
3793 | (article-narrow-to-head) | |
3794 | (goto-char (point-min)) | |
3795 | (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t) | |
3796 | (delete-region (match-beginning 1) (match-end 1))))))) | |
eec82323 LMI |
3797 | |
3798 | (defun article-emphasize (&optional arg) | |
3799 | "Emphasize text according to `gnus-emphasis-alist'." | |
3800 | (interactive (gnus-article-hidden-arg)) | |
3801 | (unless (gnus-article-check-hidden-text 'emphasis arg) | |
3802 | (save-excursion | |
a1506d29 | 3803 | (let ((alist (or |
16409b0b | 3804 | (condition-case nil |
a1506d29 JB |
3805 | (with-current-buffer gnus-summary-buffer |
3806 | gnus-article-emphasis-alist) | |
16409b0b GM |
3807 | (error)) |
3808 | gnus-emphasis-alist)) | |
4e7d0221 | 3809 | (inhibit-read-only t) |
eec82323 LMI |
3810 | (props (append '(article-type emphasis) |
3811 | gnus-hidden-properties)) | |
3812 | regexp elem beg invisible visible face) | |
16409b0b | 3813 | (article-goto-body) |
eec82323 LMI |
3814 | (setq beg (point)) |
3815 | (while (setq elem (pop alist)) | |
3816 | (goto-char beg) | |
3817 | (setq regexp (car elem) | |
3818 | invisible (nth 1 elem) | |
3819 | visible (nth 2 elem) | |
3820 | face (nth 3 elem)) | |
3821 | (while (re-search-forward regexp nil t) | |
23f87bed MB |
3822 | (when (and (match-beginning visible) (match-beginning invisible)) |
3823 | (gnus-article-hide-text | |
3824 | (match-beginning invisible) (match-end invisible) props) | |
3825 | (gnus-article-unhide-text-type | |
3826 | (match-beginning visible) (match-end visible) 'emphasis) | |
3827 | (gnus-put-overlay-excluding-newlines | |
3828 | (match-beginning visible) (match-end visible) 'face face) | |
3829 | (gnus-add-wash-type 'emphasis) | |
3830 | (goto-char (match-end invisible))))))))) | |
eec82323 | 3831 | |
16409b0b GM |
3832 | (defun gnus-article-setup-highlight-words (&optional highlight-words) |
3833 | "Setup newsgroup emphasis alist." | |
3834 | (unless gnus-article-emphasis-alist | |
3835 | (let ((name (and gnus-newsgroup-name | |
3836 | (gnus-group-real-name gnus-newsgroup-name)))) | |
3837 | (make-local-variable 'gnus-article-emphasis-alist) | |
a1506d29 JB |
3838 | (setq gnus-article-emphasis-alist |
3839 | (nconc | |
16409b0b GM |
3840 | (let ((alist gnus-group-highlight-words-alist) elem highlight) |
3841 | (while (setq elem (pop alist)) | |
3842 | (when (and name (string-match (car elem) name)) | |
3843 | (setq alist nil | |
3844 | highlight (copy-sequence (cdr elem))))) | |
3845 | highlight) | |
3846 | (copy-sequence highlight-words) | |
3847 | (if gnus-newsgroup-name | |
a1506d29 | 3848 | (copy-sequence (gnus-group-find-parameter |
16409b0b GM |
3849 | gnus-newsgroup-name 'highlight-words t))) |
3850 | gnus-emphasis-alist))))) | |
3851 | ||
9efa445f DN |
3852 | (defvar gnus-summary-article-menu) |
3853 | (defvar gnus-summary-post-menu) | |
eec82323 LMI |
3854 | |
3855 | ;;; Saving functions. | |
3856 | ||
3857 | (defun gnus-article-save (save-buffer file &optional num) | |
3858 | "Save the currently selected article." | |
26c9afc3 MB |
3859 | (when (or (get gnus-default-article-saver :headers) |
3860 | (not gnus-save-all-headers)) | |
3861 | ;; Remove headers according to `gnus-saved-headers' or the value | |
3862 | ;; of the `:headers' property that the saver function might have. | |
eec82323 | 3863 | (let ((gnus-visible-headers |
26c9afc3 MB |
3864 | (or (symbol-value (get gnus-default-article-saver :headers)) |
3865 | gnus-saved-headers gnus-visible-headers)) | |
16c85f26 MB |
3866 | ;; Ignore group parameter. See `article-hide-headers'. |
3867 | (gnus-summary-buffer nil)) | |
80de1778 | 3868 | (with-current-buffer save-buffer |
6748645f | 3869 | (article-hide-headers 1 t)))) |
eec82323 LMI |
3870 | (save-window-excursion |
3871 | (if (not gnus-default-article-saver) | |
a8151ef7 | 3872 | (error "No default saver is defined") |
eec82323 | 3873 | ;; !!! Magic! The saving functions all save |
16409b0b | 3874 | ;; `gnus-save-article-buffer' (or so they think), but we |
eec82323 LMI |
3875 | ;; bind that variable to our save-buffer. |
3876 | (set-buffer gnus-article-buffer) | |
3877 | (let* ((gnus-save-article-buffer save-buffer) | |
3878 | (filename | |
3879 | (cond | |
3880 | ((not gnus-prompt-before-saving) 'default) | |
3881 | ((eq gnus-prompt-before-saving 'always) nil) | |
3882 | (t file))) | |
3883 | (gnus-number-of-articles-to-be-saved | |
3884 | (when (eq gnus-prompt-before-saving t) | |
3885 | num))) ; Magic | |
6748645f | 3886 | (set-buffer gnus-article-current-summary) |
eec82323 LMI |
3887 | (funcall gnus-default-article-saver filename))))) |
3888 | ||
3889 | (defun gnus-read-save-file-name (prompt &optional filename | |
26c9afc3 MB |
3890 | function group headers variable |
3891 | dir-var) | |
eec82323 LMI |
3892 | (let ((default-name |
3893 | (funcall function group headers (symbol-value variable))) | |
3894 | result) | |
4325195c | 3895 | (setq result |
a1506d29 | 3896 | (expand-file-name |
4325195c DL |
3897 | (cond |
3898 | ((eq filename 'default) | |
3899 | default-name) | |
3900 | ((eq filename t) | |
3901 | default-name) | |
3902 | (filename filename) | |
3903 | (t | |
26c9afc3 MB |
3904 | (when (symbol-value dir-var) |
3905 | (setq default-name (expand-file-name | |
3906 | (file-name-nondirectory default-name) | |
3907 | (symbol-value dir-var)))) | |
4325195c DL |
3908 | (let* ((split-name (gnus-get-split-value gnus-split-methods)) |
3909 | (prompt | |
3910 | (format prompt | |
3911 | (if (and gnus-number-of-articles-to-be-saved | |
3912 | (> gnus-number-of-articles-to-be-saved 1)) | |
3913 | (format "these %d articles" | |
3914 | gnus-number-of-articles-to-be-saved) | |
3915 | "this article"))) | |
3916 | (file | |
3917 | ;; Let the split methods have their say. | |
3918 | (cond | |
3919 | ;; No split name was found. | |
3920 | ((null split-name) | |
3921 | (read-file-name | |
3922 | (concat prompt " (default " | |
81df110a | 3923 | (file-name-nondirectory default-name) "): ") |
4325195c DL |
3924 | (file-name-directory default-name) |
3925 | default-name)) | |
3926 | ;; A single group name is returned. | |
3927 | ((stringp split-name) | |
3928 | (setq default-name | |
3929 | (funcall function split-name headers | |
3930 | (symbol-value variable))) | |
3931 | (read-file-name | |
3932 | (concat prompt " (default " | |
81df110a | 3933 | (file-name-nondirectory default-name) "): ") |
4325195c DL |
3934 | (file-name-directory default-name) |
3935 | default-name)) | |
3936 | ;; A single split name was found | |
3937 | ((= 1 (length split-name)) | |
3938 | (let* ((name (expand-file-name | |
23f87bed MB |
3939 | (car split-name) |
3940 | gnus-article-save-directory)) | |
4325195c DL |
3941 | (dir (cond ((file-directory-p name) |
3942 | (file-name-as-directory name)) | |
3943 | ((file-exists-p name) name) | |
3944 | (t gnus-article-save-directory)))) | |
3945 | (read-file-name | |
81df110a | 3946 | (concat prompt " (default " name "): ") |
4325195c DL |
3947 | dir name))) |
3948 | ;; A list of splits was found. | |
3949 | (t | |
3950 | (setq split-name (nreverse split-name)) | |
3951 | (let (result) | |
3952 | (let ((file-name-history | |
3953 | (nconc split-name file-name-history))) | |
3954 | (setq result | |
3955 | (expand-file-name | |
3956 | (read-file-name | |
81df110a | 3957 | (concat prompt " (`M-p' for defaults): ") |
4325195c DL |
3958 | gnus-article-save-directory |
3959 | (car split-name)) | |
3960 | gnus-article-save-directory))) | |
3961 | (car (push result file-name-history))))))) | |
3962 | ;; Create the directory. | |
3963 | (gnus-make-directory (file-name-directory file)) | |
23f87bed | 3964 | ;; If we have read a directory, we append the default file name. |
4325195c | 3965 | (when (file-directory-p file) |
23f87bed MB |
3966 | (setq file (expand-file-name (file-name-nondirectory |
3967 | default-name) | |
4325195c DL |
3968 | (file-name-as-directory file)))) |
3969 | ;; Possibly translate some characters. | |
3970 | (nnheader-translate-file-chars file)))))) | |
eec82323 | 3971 | (gnus-make-directory (file-name-directory result)) |
26c9afc3 MB |
3972 | (when variable |
3973 | (set variable result)) | |
3974 | (when dir-var | |
3975 | (set dir-var (file-name-directory result))) | |
3976 | result)) | |
eec82323 LMI |
3977 | |
3978 | (defun gnus-article-archive-name (group) | |
3979 | "Return the first instance of an \"Archive-name\" in the current buffer." | |
3980 | (let ((case-fold-search t)) | |
3981 | (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
3982 | (nnheader-concat gnus-article-save-directory | |
3983 | (match-string 1))))) | |
3984 | ||
3985 | (defun gnus-article-nndoc-name (group) | |
3986 | "If GROUP is an nndoc group, return the name of the parent group." | |
3987 | (when (eq (car (gnus-find-method-for-group group)) 'nndoc) | |
3988 | (gnus-group-get-parameter group 'save-article-group))) | |
3989 | ||
3990 | (defun gnus-summary-save-in-rmail (&optional filename) | |
3991 | "Append this article to Rmail file. | |
3992 | Optional argument FILENAME specifies file name. | |
3993 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 3994 | (setq filename (gnus-read-save-file-name |
81df110a | 3995 | "Save %s in rmail file" filename |
eec82323 LMI |
3996 | gnus-rmail-save-name gnus-newsgroup-name |
3997 | gnus-current-headers 'gnus-newsgroup-last-rmail)) | |
a3f57c41 | 3998 | (with-current-buffer gnus-save-article-buffer |
eec82323 LMI |
3999 | (save-excursion |
4000 | (save-restriction | |
4001 | (widen) | |
fef8d38e GM |
4002 | ;; Note that unlike gnus-summary-save-in-mail, there is no |
4003 | ;; check to see if filename is Babyl. Rmail in Emacs 23 does | |
4004 | ;; not use Babyl. | |
6748645f LMI |
4005 | (gnus-output-to-rmail filename)))) |
4006 | filename) | |
eec82323 LMI |
4007 | |
4008 | (defun gnus-summary-save-in-mail (&optional filename) | |
4009 | "Append this article to Unix mail file. | |
4010 | Optional argument FILENAME specifies file name. | |
4011 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 4012 | (setq filename (gnus-read-save-file-name |
81df110a | 4013 | "Save %s in Unix mail file" filename |
eec82323 LMI |
4014 | gnus-mail-save-name gnus-newsgroup-name |
4015 | gnus-current-headers 'gnus-newsgroup-last-mail)) | |
a3f57c41 | 4016 | (with-current-buffer gnus-save-article-buffer |
eec82323 LMI |
4017 | (save-excursion |
4018 | (save-restriction | |
4019 | (widen) | |
4020 | (if (and (file-readable-p filename) | |
23f87bed | 4021 | (file-regular-p filename) |
eec82323 | 4022 | (mail-file-babyl-p filename)) |
fef8d38e | 4023 | (gnus-output-to-rmail filename) |
6748645f LMI |
4024 | (gnus-output-to-mail filename))))) |
4025 | filename) | |
eec82323 | 4026 | |
26c9afc3 MB |
4027 | (put 'gnus-summary-save-in-file :decode t) |
4028 | (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers) | |
eec82323 LMI |
4029 | (defun gnus-summary-save-in-file (&optional filename overwrite) |
4030 | "Append this article to file. | |
4031 | Optional argument FILENAME specifies file name. | |
4032 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 4033 | (setq filename (gnus-read-save-file-name |
81df110a | 4034 | "Save %s in file" filename |
eec82323 LMI |
4035 | gnus-file-save-name gnus-newsgroup-name |
4036 | gnus-current-headers 'gnus-newsgroup-last-file)) | |
a3f57c41 | 4037 | (with-current-buffer gnus-save-article-buffer |
eec82323 LMI |
4038 | (save-excursion |
4039 | (save-restriction | |
4040 | (widen) | |
4041 | (when (and overwrite | |
4042 | (file-exists-p filename)) | |
4043 | (delete-file filename)) | |
6748645f LMI |
4044 | (gnus-output-to-file filename)))) |
4045 | filename) | |
eec82323 | 4046 | |
26c9afc3 MB |
4047 | (put 'gnus-summary-write-to-file :decode t) |
4048 | (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file) | |
4049 | (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers) | |
eec82323 | 4050 | (defun gnus-summary-write-to-file (&optional filename) |
23f87bed | 4051 | "Write this article to a file, overwriting it if the file exists. |
eec82323 LMI |
4052 | Optional argument FILENAME specifies file name. |
4053 | The directory to save in defaults to `gnus-article-save-directory'." | |
26c9afc3 MB |
4054 | (setq filename (gnus-read-save-file-name |
4055 | "Save %s in file" filename | |
4056 | gnus-file-save-name gnus-newsgroup-name | |
4057 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) | |
4058 | (gnus-summary-save-in-file filename t)) | |
eec82323 | 4059 | |
26c9afc3 MB |
4060 | (put 'gnus-summary-save-body-in-file :decode t) |
4061 | (defun gnus-summary-save-body-in-file (&optional filename overwrite) | |
eec82323 LMI |
4062 | "Append this article body to a file. |
4063 | Optional argument FILENAME specifies file name. | |
4064 | The directory to save in defaults to `gnus-article-save-directory'." | |
eec82323 | 4065 | (setq filename (gnus-read-save-file-name |
81df110a | 4066 | "Save %s body in file" filename |
eec82323 LMI |
4067 | gnus-file-save-name gnus-newsgroup-name |
4068 | gnus-current-headers 'gnus-newsgroup-last-file)) | |
a3f57c41 | 4069 | (with-current-buffer gnus-save-article-buffer |
eec82323 LMI |
4070 | (save-excursion |
4071 | (save-restriction | |
4072 | (widen) | |
16409b0b | 4073 | (when (article-goto-body) |
eec82323 | 4074 | (narrow-to-region (point) (point-max))) |
26c9afc3 MB |
4075 | (when (and overwrite |
4076 | (file-exists-p filename)) | |
4077 | (delete-file filename)) | |
6748645f LMI |
4078 | (gnus-output-to-file filename)))) |
4079 | filename) | |
eec82323 | 4080 | |
26c9afc3 MB |
4081 | (put 'gnus-summary-write-body-to-file :decode t) |
4082 | (put 'gnus-summary-write-body-to-file | |
4083 | :function 'gnus-summary-save-body-in-file) | |
4084 | (defun gnus-summary-write-body-to-file (&optional filename) | |
4085 | "Write this article body to a file, overwriting it if the file exists. | |
4086 | Optional argument FILENAME specifies file name. | |
4087 | The directory to save in defaults to `gnus-article-save-directory'." | |
4088 | (setq filename (gnus-read-save-file-name | |
4089 | "Save %s body in file" filename | |
4090 | gnus-file-save-name gnus-newsgroup-name | |
4091 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) | |
4092 | (gnus-summary-save-body-in-file filename t)) | |
4093 | ||
89167438 MB |
4094 | (put 'gnus-summary-save-in-pipe :decode t) |
4095 | (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers) | |
d62672f3 MB |
4096 | (defun gnus-summary-save-in-pipe (&optional command raw) |
4097 | "Pipe this article to subprocess COMMAND. | |
4098 | Valid values for COMMAND include: | |
4099 | a string | |
4100 | The executable command name and possibly arguments. | |
4101 | nil | |
4102 | You will be prompted for the command in the minibuffer. | |
4103 | the symbol `default' | |
4104 | It will be replaced with the command which the variable | |
4105 | `gnus-summary-pipe-output-default-command' holds or the command | |
4106 | last used for saving. | |
4107 | Non-nil value for RAW overrides `:decode' and `:headers' properties | |
4108 | and the raw article including all headers will be piped." | |
6ecfe5c2 MB |
4109 | (let ((article (gnus-summary-article-number)) |
4110 | (decode (unless raw | |
4111 | (get 'gnus-summary-save-in-pipe :decode))) | |
4112 | save-buffer default) | |
4113 | (if article | |
4114 | (if (vectorp (gnus-summary-article-header article)) | |
4115 | (save-current-buffer | |
4116 | (gnus-summary-select-article decode decode nil article) | |
4117 | (insert-buffer-substring | |
4118 | (prog1 | |
4119 | (if decode | |
4120 | gnus-article-buffer | |
4121 | gnus-original-article-buffer) | |
4122 | (setq save-buffer | |
4123 | (nnheader-set-temp-buffer " *Gnus Save*")))) | |
4124 | ;; Remove unwanted headers. | |
4125 | (when (and (not raw) | |
4126 | (or (get 'gnus-summary-save-in-pipe :headers) | |
4127 | (not gnus-save-all-headers))) | |
4128 | (let ((gnus-visible-headers | |
4129 | (or (symbol-value (get 'gnus-summary-save-in-pipe | |
4130 | :headers)) | |
4131 | gnus-saved-headers gnus-visible-headers)) | |
4132 | (gnus-summary-buffer nil)) | |
4133 | (article-hide-headers 1 t)))) | |
4134 | (error "%d is not a real article" article)) | |
4135 | (error "No article to pipe")) | |
4136 | (setq default (or gnus-summary-pipe-output-default-command | |
4137 | gnus-last-shell-command)) | |
89167438 MB |
4138 | (unless (stringp command) |
4139 | (setq command | |
4140 | (if (and (eq command 'default) default) | |
4141 | default | |
6ecfe5c2 MB |
4142 | (gnus-read-shell-command "Shell command on this article: " |
4143 | default)))) | |
89167438 MB |
4144 | (when (string-equal command "") |
4145 | (if default | |
4146 | (setq command default) | |
16c85f26 | 4147 | (error "A command is required"))) |
a3f57c41 | 4148 | (with-current-buffer save-buffer |
16c85f26 MB |
4149 | (save-restriction |
4150 | (widen) | |
4151 | (shell-command-on-region (point-min) (point-max) command nil))) | |
4152 | (gnus-kill-buffer save-buffer)) | |
89167438 | 4153 | (setq gnus-summary-pipe-output-default-command command)) |
eec82323 | 4154 | |
23f87bed MB |
4155 | (defun gnus-summary-pipe-to-muttprint (&optional command) |
4156 | "Pipe this article to muttprint." | |
16c85f26 MB |
4157 | (unless (stringp command) |
4158 | (setq command (read-string | |
4159 | "Print using command: " gnus-summary-muttprint-program | |
4160 | nil gnus-summary-muttprint-program))) | |
4161 | (let ((gnus-summary-pipe-output-default-command | |
4162 | gnus-summary-pipe-output-default-command)) | |
4163 | (gnus-summary-save-in-pipe command)) | |
4164 | (setq gnus-summary-muttprint-program command)) | |
23f87bed | 4165 | |
eec82323 LMI |
4166 | ;;; Article file names when saving. |
4167 | ||
4168 | (defun gnus-capitalize-newsgroup (newsgroup) | |
4169 | "Capitalize NEWSGROUP name." | |
4170 | (when (not (zerop (length newsgroup))) | |
4171 | (concat (char-to-string (upcase (aref newsgroup 0))) | |
4172 | (substring newsgroup 1)))) | |
4173 | ||
4174 | (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
4175 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4176 | If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num. | |
4177 | Otherwise, it is like ~/News/news/group/num." | |
4178 | (let ((default | |
4179 | (expand-file-name | |
4180 | (concat (if (gnus-use-long-file-name 'not-save) | |
4181 | (gnus-capitalize-newsgroup newsgroup) | |
4182 | (gnus-newsgroup-directory-form newsgroup)) | |
4183 | "/" (int-to-string (mail-header-number headers))) | |
4184 | gnus-article-save-directory))) | |
4185 | (if (and last-file | |
4186 | (string-equal (file-name-directory default) | |
4187 | (file-name-directory last-file)) | |
4188 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4189 | default | |
4190 | (or last-file default)))) | |
4191 | ||
4192 | (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
4193 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4194 | If variable `gnus-use-long-file-name' is non-nil, it is | |
2ff9f5b4 | 4195 | ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." |
eec82323 LMI |
4196 | (let ((default |
4197 | (expand-file-name | |
4198 | (concat (if (gnus-use-long-file-name 'not-save) | |
4199 | newsgroup | |
4200 | (gnus-newsgroup-directory-form newsgroup)) | |
4201 | "/" (int-to-string (mail-header-number headers))) | |
4202 | gnus-article-save-directory))) | |
4203 | (if (and last-file | |
4204 | (string-equal (file-name-directory default) | |
4205 | (file-name-directory last-file)) | |
4206 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4207 | default | |
4208 | (or last-file default)))) | |
4209 | ||
eec82323 LMI |
4210 | (defun gnus-plain-save-name (newsgroup headers &optional last-file) |
4211 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4212 | If variable `gnus-use-long-file-name' is non-nil, it is | |
4213 | ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
4214 | (or last-file | |
4215 | (expand-file-name | |
4216 | (if (gnus-use-long-file-name 'not-save) | |
4217 | newsgroup | |
23f87bed MB |
4218 | (file-relative-name |
4219 | (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)) | |
4220 | default-directory)) | |
eec82323 LMI |
4221 | gnus-article-save-directory))) |
4222 | ||
23f87bed MB |
4223 | (defun gnus-sender-save-name (newsgroup headers &optional last-file) |
4224 | "Generate file name from sender." | |
4225 | (let ((from (mail-header-from headers))) | |
4226 | (expand-file-name | |
4227 | (if (and from (string-match "\\([^ <]+\\)@" from)) | |
4228 | (match-string 1 from) | |
4229 | "nobody") | |
4230 | gnus-article-save-directory))) | |
4231 | ||
4232 | (defun article-verify-x-pgp-sig () | |
4233 | "Verify X-PGP-Sig." | |
bbbe940b | 4234 | ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT> |
23f87bed MB |
4235 | (interactive) |
4236 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
4237 | (let ((sig (with-current-buffer gnus-original-article-buffer | |
4238 | (gnus-fetch-field "X-PGP-Sig"))) | |
4239 | items info headers) | |
4240 | (when (and sig | |
4241 | mml2015-use | |
4242 | (mml2015-clear-verify-function)) | |
4243 | (with-temp-buffer | |
4244 | (insert-buffer-substring gnus-original-article-buffer) | |
4245 | (setq items (split-string sig)) | |
4246 | (message-narrow-to-head) | |
4247 | (let ((inhibit-point-motion-hooks t) | |
4248 | (case-fold-search t)) | |
4249 | ;; Don't verify multiple headers. | |
4250 | (setq headers (mapconcat (lambda (header) | |
4251 | (concat header ": " | |
4252 | (mail-fetch-field header) | |
4253 | "\n")) | |
4254 | (split-string (nth 1 items) ",") ""))) | |
4255 | (delete-region (point-min) (point-max)) | |
4256 | (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n") | |
4257 | (insert "X-Signed-Headers: " (nth 1 items) "\n") | |
4258 | (insert headers) | |
4259 | (widen) | |
4260 | (forward-line) | |
4261 | (while (not (eobp)) | |
4262 | (if (looking-at "^-") | |
4263 | (insert "- ")) | |
4264 | (forward-line)) | |
4265 | (insert "\n-----BEGIN PGP SIGNATURE-----\n") | |
4266 | (insert "Version: " (car items) "\n\n") | |
4267 | (insert (mapconcat 'identity (cddr items) "\n")) | |
4268 | (insert "\n-----END PGP SIGNATURE-----\n") | |
4269 | (let ((mm-security-handle (list (format "multipart/signed")))) | |
4270 | (mml2015-clean-buffer) | |
4271 | (let ((coding-system-for-write (or gnus-newsgroup-charset | |
4272 | 'iso-8859-1))) | |
4273 | (funcall (mml2015-clear-verify-function))) | |
4274 | (setq info | |
4275 | (or (mm-handle-multipart-ctl-parameter | |
4276 | mm-security-handle 'gnus-details) | |
4277 | (mm-handle-multipart-ctl-parameter | |
4278 | mm-security-handle 'gnus-info))))) | |
4279 | (when info | |
4280 | (let ((inhibit-read-only t) bface eface) | |
4281 | (save-restriction | |
4282 | (message-narrow-to-head) | |
4283 | (goto-char (point-max)) | |
4284 | (forward-line -1) | |
01c52d31 MB |
4285 | (setq bface (get-text-property (point-at-bol) 'face) |
4286 | eface (get-text-property (1- (point-at-eol)) 'face)) | |
23f87bed MB |
4287 | (message-remove-header "X-Gnus-PGP-Verify") |
4288 | (if (re-search-forward "^X-PGP-Sig:" nil t) | |
4289 | (forward-line) | |
4290 | (goto-char (point-max))) | |
4291 | (narrow-to-region (point) (point)) | |
4292 | (insert "X-Gnus-PGP-Verify: " info "\n") | |
4293 | (goto-char (point-min)) | |
4294 | (forward-line) | |
4295 | (while (not (eobp)) | |
4296 | (if (not (looking-at "^[ \t]")) | |
4297 | (insert " ")) | |
4298 | (forward-line)) | |
4299 | ;; Do highlighting. | |
4300 | (goto-char (point-min)) | |
4301 | (when (looking-at "\\([^:]+\\): *") | |
4302 | (put-text-property (match-beginning 1) (1+ (match-end 1)) | |
4303 | 'face bface) | |
4304 | (put-text-property (match-end 0) (point-max) | |
4305 | 'face eface))))))))) | |
4306 | ||
5843126b | 4307 | (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs. |
ec7995fa | 4308 | |
23f87bed MB |
4309 | (defun article-verify-cancel-lock () |
4310 | "Verify Cancel-Lock header." | |
4311 | (interactive) | |
4312 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
4313 | (canlock-verify gnus-original-article-buffer))) | |
4314 | ||
eec82323 | 4315 | (eval-and-compile |
01c52d31 | 4316 | (mapc |
eec82323 LMI |
4317 | (lambda (func) |
4318 | (let (afunc gfunc) | |
4319 | (if (consp func) | |
4320 | (setq afunc (car func) | |
4321 | gfunc (cdr func)) | |
4322 | (setq afunc func | |
4323 | gfunc (intern (format "gnus-%s" func)))) | |
16409b0b | 4324 | (defalias gfunc |
23f87bed | 4325 | (when (fboundp afunc) |
16409b0b GM |
4326 | `(lambda (&optional interactive &rest args) |
4327 | ,(documentation afunc t) | |
4328 | (interactive (list t)) | |
80de1778 | 4329 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
4330 | (if interactive |
4331 | (call-interactively ',afunc) | |
4332 | (apply ',afunc args)))))))) | |
eec82323 | 4333 | '(article-hide-headers |
23f87bed MB |
4334 | article-verify-x-pgp-sig |
4335 | article-verify-cancel-lock | |
eec82323 LMI |
4336 | article-hide-boring-headers |
4337 | article-treat-overstrike | |
01c52d31 | 4338 | article-treat-ansi-sequences |
16409b0b GM |
4339 | article-fill-long-lines |
4340 | article-capitalize-sentences | |
eec82323 | 4341 | article-remove-cr |
23f87bed | 4342 | article-remove-leading-whitespace |
eec82323 | 4343 | article-display-x-face |
23f87bed | 4344 | article-display-face |
eec82323 | 4345 | article-de-quoted-unreadable |
16409b0b GM |
4346 | article-de-base64-unreadable |
4347 | article-decode-HZ | |
4348 | article-wash-html | |
23f87bed | 4349 | article-unsplit-urls |
16409b0b | 4350 | article-hide-list-identifiers |
16409b0b GM |
4351 | article-strip-banner |
4352 | article-babel | |
eec82323 LMI |
4353 | article-hide-pem |
4354 | article-hide-signature | |
16409b0b | 4355 | article-strip-headers-in-body |
eec82323 LMI |
4356 | article-remove-trailing-blank-lines |
4357 | article-strip-leading-blank-lines | |
4358 | article-strip-multiple-blank-lines | |
4359 | article-strip-leading-space | |
16409b0b | 4360 | article-strip-trailing-space |
eec82323 | 4361 | article-strip-blank-lines |
6748645f | 4362 | article-strip-all-blank-lines |
eec82323 | 4363 | article-date-local |
23f87bed | 4364 | article-date-english |
6748645f | 4365 | article-date-iso8601 |
eec82323 | 4366 | article-date-original |
12e3ca0a | 4367 | article-treat-date |
eec82323 | 4368 | article-date-ut |
16409b0b GM |
4369 | article-decode-mime-words |
4370 | article-decode-charset | |
4371 | article-decode-encoded-words | |
eec82323 LMI |
4372 | article-date-user |
4373 | article-date-lapsed | |
647559c2 | 4374 | article-date-combined-lapsed |
eec82323 | 4375 | article-emphasize |
6748645f | 4376 | article-treat-dumbquotes |
be3c11b3 | 4377 | article-treat-non-ascii |
16409b0b | 4378 | article-normalize-headers |
01c52d31 | 4379 | ;;(article-show-all . gnus-article-show-all-headers) |
23f87bed | 4380 | ))) |
eec82323 LMI |
4381 | \f |
4382 | ;;; | |
4383 | ;;; Gnus article mode | |
4384 | ;;; | |
4385 | ||
4386 | (put 'gnus-article-mode 'mode-class 'special) | |
4387 | ||
16409b0b GM |
4388 | (set-keymap-parent gnus-article-mode-map widget-keymap) |
4389 | ||
a8151ef7 LMI |
4390 | (gnus-define-keys gnus-article-mode-map |
4391 | " " gnus-article-goto-next-page | |
9cec74cf | 4392 | [?\S-\ ] gnus-article-goto-prev-page |
a8151ef7 LMI |
4393 | "\177" gnus-article-goto-prev-page |
4394 | [delete] gnus-article-goto-prev-page | |
4395 | "\C-c^" gnus-article-refer-article | |
4396 | "h" gnus-article-show-summary | |
4397 | "s" gnus-article-show-summary | |
4398 | "\C-c\C-m" gnus-article-mail | |
4399 | "?" gnus-article-describe-briefly | |
a8151ef7 LMI |
4400 | "<" beginning-of-buffer |
4401 | ">" end-of-buffer | |
4402 | "\C-c\C-i" gnus-info-find-node | |
4403 | "\C-c\C-b" gnus-bug | |
23f87bed MB |
4404 | "R" gnus-article-reply-with-original |
4405 | "F" gnus-article-followup-with-original | |
520aa572 SZ |
4406 | "\C-hk" gnus-article-describe-key |
4407 | "\C-hc" gnus-article-describe-key-briefly | |
0b6799c3 | 4408 | "\C-hb" gnus-article-describe-bindings |
a8151ef7 | 4409 | |
6ab2c7a8 | 4410 | "e" gnus-article-read-summary-keys |
a8151ef7 LMI |
4411 | "\C-d" gnus-article-read-summary-keys |
4412 | "\M-*" gnus-article-read-summary-keys | |
4413 | "\M-#" gnus-article-read-summary-keys | |
4414 | "\M-^" gnus-article-read-summary-keys | |
4415 | "\M-g" gnus-article-read-summary-keys) | |
4416 | ||
4417 | (substitute-key-definition | |
4418 | 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map) | |
eec82323 | 4419 | |
95838435 MB |
4420 | (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map) |
4421 | "W" gnus-article-wide-reply-with-original) | |
4422 | (if (featurep 'xemacs) | |
4423 | (set-keymap-default-binding gnus-article-send-map | |
4424 | 'gnus-article-read-summary-send-keys) | |
4425 | (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys)) | |
4426 | ||
eec82323 | 4427 | (defun gnus-article-make-menu-bar () |
23f87bed MB |
4428 | (unless (boundp 'gnus-article-commands-menu) |
4429 | (gnus-summary-make-menu-bar)) | |
eec82323 LMI |
4430 | (unless (boundp 'gnus-article-article-menu) |
4431 | (easy-menu-define | |
4432 | gnus-article-article-menu gnus-article-mode-map "" | |
4433 | '("Article" | |
4434 | ["Scroll forwards" gnus-article-goto-next-page t] | |
4435 | ["Scroll backwards" gnus-article-goto-prev-page t] | |
4436 | ["Show summary" gnus-article-show-summary t] | |
4437 | ["Fetch Message-ID at point" gnus-article-refer-article t] | |
6748645f LMI |
4438 | ["Mail to address at point" gnus-article-mail t] |
4439 | ["Send a bug report" gnus-bug t])) | |
eec82323 LMI |
4440 | |
4441 | (easy-menu-define | |
4442 | gnus-article-treatment-menu gnus-article-mode-map "" | |
bb367cba | 4443 | ;; Fixme: this should use :active (and maybe :visible). |
eec82323 LMI |
4444 | '("Treatment" |
4445 | ["Hide headers" gnus-article-hide-headers t] | |
4446 | ["Hide signature" gnus-article-hide-signature t] | |
4447 | ["Hide citation" gnus-article-hide-citation t] | |
4448 | ["Treat overstrike" gnus-article-treat-overstrike t] | |
01c52d31 | 4449 | ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t] |
eec82323 | 4450 | ["Remove carriage return" gnus-article-remove-cr t] |
23f87bed | 4451 | ["Remove leading whitespace" gnus-article-remove-leading-whitespace t] |
16409b0b GM |
4452 | ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] |
4453 | ["Remove base64" gnus-article-de-base64-unreadable t] | |
4454 | ["Treat html" gnus-article-wash-html t] | |
23f87bed | 4455 | ["Remove newlines from within URLs" gnus-article-unsplit-urls t] |
16409b0b | 4456 | ["Decode HZ" gnus-article-decode-HZ t])) |
eec82323 | 4457 | |
6748645f | 4458 | ;; Note "Commands" menu is defined in gnus-sum.el for consistency |
eec82323 | 4459 | |
23f87bed | 4460 | ;; Note "Post" menu is defined in gnus-sum.el for consistency |
eec82323 | 4461 | |
6748645f | 4462 | (gnus-run-hooks 'gnus-article-menu-hook))) |
eec82323 | 4463 | |
8e7d4ca1 | 4464 | (defvar bookmark-make-record-function) |
ffb54e99 | 4465 | (defvar shr-put-image-function) |
8e7d4ca1 | 4466 | |
1b3b87df | 4467 | (define-derived-mode gnus-article-mode fundamental-mode "Article" |
eec82323 LMI |
4468 | "Major mode for displaying an article. |
4469 | ||
4470 | All normal editing commands are switched off. | |
4471 | ||
4472 | The following commands are available in addition to all summary mode | |
4473 | commands: | |
4474 | \\<gnus-article-mode-map> | |
4475 | \\[gnus-article-next-page]\t Scroll the article one page forwards | |
4476 | \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
4477 | \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
4478 | \\[gnus-article-show-summary]\t Display the summary buffer | |
4479 | \\[gnus-article-mail]\t Send a reply to the address near point | |
4480 | \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
4481 | \\[gnus-info-find-node]\t Go to the Gnus info node" | |
eec82323 | 4482 | (gnus-simplify-mode-line) |
eec82323 | 4483 | (make-local-variable 'minor-mode-alist) |
1653df0f | 4484 | (when (gnus-visual-p 'article-menu 'menu) |
23f87bed MB |
4485 | (gnus-article-make-menu-bar) |
4486 | (when gnus-summary-tool-bar-map | |
4487 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))) | |
eec82323 LMI |
4488 | (gnus-update-format-specifications nil 'article-mode) |
4489 | (set (make-local-variable 'page-delimiter) gnus-page-delimiter) | |
23f87bed | 4490 | (set (make-local-variable 'gnus-page-broken) nil) |
6748645f | 4491 | (make-local-variable 'gnus-article-current-summary) |
16409b0b GM |
4492 | (make-local-variable 'gnus-article-mime-handles) |
4493 | (make-local-variable 'gnus-article-decoded-p) | |
4494 | (make-local-variable 'gnus-article-mime-handle-alist) | |
4495 | (make-local-variable 'gnus-article-wash-types) | |
23f87bed MB |
4496 | (make-local-variable 'gnus-article-image-alist) |
4497 | (make-local-variable 'gnus-article-charset) | |
4498 | (make-local-variable 'gnus-article-ignored-charsets) | |
33b48483 KF |
4499 | (set (make-local-variable 'bookmark-make-record-function) |
4500 | 'gnus-summary-bookmark-make-record) | |
524705ae MB |
4501 | ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space' |
4502 | ;; face. | |
fc1c32c1 | 4503 | (set (make-local-variable 'nobreak-char-display) nil) |
ffb54e99 KY |
4504 | ;; Enable `gnus-article-remove-images' to delete images shr.el renders. |
4505 | (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image) | |
e4a89ccf | 4506 | (setq cursor-in-non-selected-windows nil) |
eec82323 | 4507 | (gnus-set-default-directory) |
16409b0b | 4508 | (buffer-disable-undo) |
01c52d31 MB |
4509 | (setq buffer-read-only t |
4510 | show-trailing-whitespace nil) | |
1b3b87df | 4511 | (mm-enable-multibyte)) |
eec82323 LMI |
4512 | |
4513 | (defun gnus-article-setup-buffer () | |
4514 | "Initialize the article buffer." | |
4515 | (let* ((name (if gnus-single-article-buffer "*Article*" | |
a3e0ee5a KY |
4516 | (concat "*Article " |
4517 | (gnus-group-decoded-name gnus-newsgroup-name) | |
4518 | "*"))) | |
eec82323 LMI |
4519 | (original |
4520 | (progn (string-match "\\*Article" name) | |
4521 | (concat " *Original Article" | |
4522 | (substring name (match-end 0)))))) | |
4523 | (setq gnus-article-buffer name) | |
4524 | (setq gnus-original-article-buffer original) | |
16409b0b | 4525 | (setq gnus-article-mime-handle-alist nil) |
01c52d31 MB |
4526 | (with-current-buffer gnus-summary-buffer |
4527 | ;; This might be a variable local to the summary buffer. | |
4528 | (unless gnus-single-article-buffer | |
eec82323 LMI |
4529 | (setq gnus-article-buffer name) |
4530 | (setq gnus-original-article-buffer original) | |
4531 | (gnus-set-global-variables))) | |
16409b0b | 4532 | (gnus-article-setup-highlight-words) |
eec82323 | 4533 | ;; Init original article buffer. |
80de1778 | 4534 | (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer) |
16409b0b | 4535 | (mm-enable-multibyte) |
eec82323 | 4536 | (setq major-mode 'gnus-original-article-mode) |
eec82323 | 4537 | (make-local-variable 'gnus-original-article)) |
aba1948a MB |
4538 | (if (and (get-buffer name) |
4539 | (with-current-buffer name | |
4540 | (if gnus-article-edit-mode | |
4541 | (if (y-or-n-p "Article mode edit in progress; discard? ") | |
4542 | (progn | |
4543 | (set-buffer-modified-p nil) | |
4544 | (gnus-kill-buffer name) | |
4545 | (message "") | |
4546 | nil) | |
4547 | (error "Action aborted")) | |
4548 | t))) | |
4e2b87d8 G |
4549 | (let ((summary gnus-summary-buffer)) |
4550 | (with-current-buffer name | |
4551 | (set (make-local-variable 'gnus-article-edit-mode) nil) | |
4552 | (gnus-article-stop-animations) | |
4553 | (when gnus-article-mime-handles | |
4554 | (mm-destroy-parts gnus-article-mime-handles) | |
4555 | (setq gnus-article-mime-handles nil)) | |
4556 | ;; Set it to nil in article-buffer! | |
4557 | (setq gnus-article-mime-handle-alist nil) | |
4558 | (buffer-disable-undo) | |
4559 | (setq buffer-read-only t) | |
4560 | (unless (derived-mode-p 'gnus-article-mode) | |
4561 | (gnus-article-mode)) | |
4562 | (set (make-local-variable 'gnus-summary-buffer) summary) | |
4563 | (setq truncate-lines gnus-article-truncate-lines) | |
4564 | (current-buffer))) | |
cc21c235 G |
4565 | (let ((summary gnus-summary-buffer)) |
4566 | (with-current-buffer (gnus-get-buffer-create name) | |
4567 | (gnus-article-mode) | |
4568 | (setq truncate-lines gnus-article-truncate-lines) | |
4569 | (set (make-local-variable 'gnus-summary-buffer) summary) | |
4570 | (gnus-summary-set-local-parameters gnus-newsgroup-name) | |
4571 | (when article-lapsed-timer | |
4572 | (gnus-stop-date-timer)) | |
4573 | (when gnus-article-update-date-headers | |
4574 | (gnus-start-date-timer gnus-article-update-date-headers)) | |
4575 | (current-buffer)))))) | |
eec82323 | 4576 | |
c146ad85 LMI |
4577 | (defun gnus-article-stop-animations () |
4578 | (dolist (timer (and (boundp 'timer-list) | |
4579 | timer-list)) | |
5e2b4ce1 | 4580 | (when (eq (gnus-timer--function timer) 'image-animate-timeout) |
c146ad85 LMI |
4581 | (cancel-timer timer)))) |
4582 | ||
4eff9c1a LI |
4583 | (defun gnus-stop-downloads () |
4584 | (when (boundp 'url-queue) | |
4585 | (set (intern "url-queue" obarray) nil))) | |
4586 | ||
eec82323 LMI |
4587 | ;; Set article window start at LINE, where LINE is the number of lines |
4588 | ;; from the head of the article. | |
4589 | (defun gnus-article-set-window-start (&optional line) | |
01c52d31 MB |
4590 | (let ((article-window (gnus-get-buffer-window gnus-article-buffer t))) |
4591 | (when article-window | |
4592 | (set-window-start | |
4593 | article-window | |
80de1778 | 4594 | (with-current-buffer gnus-article-buffer |
01c52d31 MB |
4595 | (goto-char (point-min)) |
4596 | (if (not line) | |
4597 | (point-min) | |
4598 | (gnus-message 6 "Moved to bookmark") | |
4599 | (search-forward "\n\n" nil t) | |
4600 | (forward-line line) | |
4601 | (point))))))) | |
eec82323 LMI |
4602 | |
4603 | (defun gnus-article-prepare (article &optional all-headers header) | |
4604 | "Prepare ARTICLE in article mode buffer. | |
4605 | ARTICLE should either be an article number or a Message-ID. | |
4606 | If ARTICLE is an id, HEADER should be the article headers. | |
4607 | If ALL-HEADERS is non-nil, no headers are hidden." | |
4608 | (save-excursion | |
4609 | ;; Make sure we start in a summary buffer. | |
1b3b87df | 4610 | (unless (derived-mode-p 'gnus-summary-mode) |
eec82323 LMI |
4611 | (set-buffer gnus-summary-buffer)) |
4612 | (setq gnus-summary-buffer (current-buffer)) | |
eec82323 LMI |
4613 | (let* ((gnus-article (if header (mail-header-number header) article)) |
4614 | (summary-buffer (current-buffer)) | |
6748645f | 4615 | (gnus-tmp-internal-hook gnus-article-internal-prepare-hook) |
eec82323 LMI |
4616 | (group gnus-newsgroup-name) |
4617 | result) | |
4618 | (save-excursion | |
4619 | (gnus-article-setup-buffer) | |
4620 | (set-buffer gnus-article-buffer) | |
4621 | ;; Deactivate active regions. | |
4622 | (when (and (boundp 'transient-mark-mode) | |
4623 | transient-mark-mode) | |
4624 | (setq mark-active nil)) | |
4e7d0221 | 4625 | (if (not (setq result (let ((inhibit-read-only t)) |
eec82323 LMI |
4626 | (gnus-request-article-this-buffer |
4627 | article group)))) | |
4628 | ;; There is no such article. | |
4629 | (save-excursion | |
4630 | (when (and (numberp article) | |
4631 | (not (memq article gnus-newsgroup-sparse))) | |
4632 | (setq gnus-article-current | |
4633 | (cons gnus-newsgroup-name article)) | |
4634 | (set-buffer gnus-summary-buffer) | |
4635 | (setq gnus-current-article article) | |
23f87bed MB |
4636 | (if (and (memq article gnus-newsgroup-undownloaded) |
4637 | (not (gnus-online (gnus-find-method-for-group | |
4638 | gnus-newsgroup-name)))) | |
6748645f LMI |
4639 | (progn |
4640 | (gnus-summary-set-agent-mark article) | |
4641 | (message "Message marked for downloading")) | |
4642 | (gnus-summary-mark-article article gnus-canceled-mark) | |
4643 | (unless (memq article gnus-newsgroup-sparse) | |
16409b0b | 4644 | (gnus-error 1 "No such article (may have expired or been canceled)"))))) |
6748645f LMI |
4645 | (if (or (eq result 'pseudo) |
4646 | (eq result 'nneething)) | |
eec82323 | 4647 | (progn |
80de1778 | 4648 | (with-current-buffer summary-buffer |
6748645f | 4649 | (push article gnus-newsgroup-history) |
eec82323 | 4650 | (setq gnus-last-article gnus-current-article |
eec82323 LMI |
4651 | gnus-current-article 0 |
4652 | gnus-current-headers nil | |
4653 | gnus-article-current nil) | |
4654 | (if (eq result 'nneething) | |
4655 | (gnus-configure-windows 'summary) | |
4656 | (gnus-configure-windows 'article)) | |
4657 | (gnus-set-global-variables)) | |
16409b0b GM |
4658 | (let ((gnus-article-mime-handle-alist-1 |
4659 | gnus-article-mime-handle-alist)) | |
4660 | (gnus-set-mode-line 'article))) | |
eec82323 LMI |
4661 | ;; The result from the `request' was an actual article - |
4662 | ;; or at least some text that is now displayed in the | |
4663 | ;; article buffer. | |
4664 | (when (and (numberp article) | |
4665 | (not (eq article gnus-current-article))) | |
4666 | ;; Seems like a new article has been selected. | |
4667 | ;; `gnus-current-article' must be an article number. | |
80de1778 | 4668 | (with-current-buffer summary-buffer |
6748645f | 4669 | (push article gnus-newsgroup-history) |
eec82323 | 4670 | (setq gnus-last-article gnus-current-article |
eec82323 LMI |
4671 | gnus-current-article article |
4672 | gnus-current-headers | |
4673 | (gnus-summary-article-header gnus-current-article) | |
4674 | gnus-article-current | |
4675 | (cons gnus-newsgroup-name gnus-current-article)) | |
4676 | (unless (vectorp gnus-current-headers) | |
4677 | (setq gnus-current-headers nil)) | |
6748645f LMI |
4678 | (gnus-summary-goto-subject gnus-current-article) |
4679 | (when (gnus-summary-show-thread) | |
4680 | ;; If the summary buffer really was folded, the | |
4681 | ;; previous goto may not actually have gone to | |
4682 | ;; the right article, but the thread root instead. | |
4683 | ;; So we go again. | |
4684 | (gnus-summary-goto-subject gnus-current-article)) | |
4685 | (gnus-run-hooks 'gnus-mark-article-hook) | |
eec82323 LMI |
4686 | (gnus-set-mode-line 'summary) |
4687 | (when (gnus-visual-p 'article-highlight 'highlight) | |
6748645f | 4688 | (gnus-run-hooks 'gnus-visual-mark-article-hook)) |
eec82323 | 4689 | ;; Set the global newsgroup variables here. |
eec82323 LMI |
4690 | (gnus-set-global-variables) |
4691 | (setq gnus-have-all-headers | |
6748645f | 4692 | (or all-headers gnus-show-all-headers)))) |
e0bad764 DL |
4693 | (save-excursion |
4694 | (gnus-configure-windows 'article)) | |
eec82323 LMI |
4695 | (when (or (numberp article) |
4696 | (stringp article)) | |
16409b0b | 4697 | (gnus-article-prepare-display) |
eec82323 LMI |
4698 | ;; Do page break. |
4699 | (goto-char (point-min)) | |
23f87bed MB |
4700 | (when gnus-break-pages |
4701 | (gnus-narrow-to-page))) | |
16409b0b GM |
4702 | (let ((gnus-article-mime-handle-alist-1 |
4703 | gnus-article-mime-handle-alist)) | |
4704 | (gnus-set-mode-line 'article)) | |
4705 | (article-goto-body) | |
23f87bed MB |
4706 | (unless (bobp) |
4707 | (forward-line -1)) | |
6748645f | 4708 | (set-window-point (get-buffer-window (current-buffer)) (point)) |
16409b0b | 4709 | (gnus-configure-windows 'article) |
56e96bed | 4710 | (gnus-run-hooks 'gnus-article-prepare-hook) |
eec82323 LMI |
4711 | t)))))) |
4712 | ||
16409b0b GM |
4713 | ;;;###autoload |
4714 | (defun gnus-article-prepare-display () | |
4715 | "Make the current buffer look like a nice article." | |
4716 | ;; Hooks for getting information from the article. | |
4717 | ;; This hook must be called before being narrowed. | |
4718 | (let ((gnus-article-buffer (current-buffer)) | |
23f87bed MB |
4719 | buffer-read-only |
4720 | (inhibit-read-only t)) | |
1b3b87df | 4721 | (unless (derived-mode-p 'gnus-article-mode) |
16409b0b GM |
4722 | (gnus-article-mode)) |
4723 | (setq buffer-read-only nil | |
23f87bed MB |
4724 | gnus-article-wash-types nil |
4725 | gnus-article-image-alist nil) | |
16409b0b GM |
4726 | (gnus-run-hooks 'gnus-tmp-internal-hook) |
4727 | (when gnus-display-mime-function | |
4d2226bf G |
4728 | (funcall gnus-display-mime-function)) |
4729 | ;; Add attachment buttons to the header. | |
4730 | (when gnus-mime-display-attachment-buttons-in-header | |
4731 | (gnus-mime-buttonize-attachments-in-header)))) | |
16409b0b | 4732 | |
01c52d31 MB |
4733 | ;;; |
4734 | ;;; Gnus Sticky Article Mode | |
4735 | ;;; | |
4736 | ||
4737 | (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle" | |
4738 | "Mode for sticky articles." | |
4739 | ;; Release bindings that won't work. | |
4740 | (substitute-key-definition 'gnus-article-read-summary-keys 'undefined | |
4741 | gnus-sticky-article-mode-map) | |
4742 | (substitute-key-definition 'gnus-article-refer-article 'undefined | |
4743 | gnus-sticky-article-mode-map) | |
4744 | (dolist (k '("e" "h" "s" "F" "R")) | |
4745 | (define-key gnus-sticky-article-mode-map k nil)) | |
4746 | (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer) | |
4747 | (define-key gnus-sticky-article-mode-map "q" 'bury-buffer) | |
4748 | (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly) | |
4749 | (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key)) | |
4750 | ||
4751 | (defun gnus-sticky-article (arg) | |
4752 | "Make the current article sticky. | |
4753 | If a prefix ARG is given, ask for a name for this sticky article buffer." | |
4754 | (interactive "P") | |
4755 | (gnus-summary-show-thread) | |
4756 | (gnus-summary-select-article nil nil 'pseudo) | |
4757 | (let (new-art-buf-name) | |
4758 | (gnus-eval-in-buffer-window gnus-article-buffer | |
4759 | (setq new-art-buf-name | |
4760 | (concat | |
4761 | "*Sticky Article: " | |
4762 | (if arg | |
4763 | (read-from-minibuffer "Sticky article buffer name: ") | |
4764 | (gnus-with-article-headers | |
4765 | (gnus-article-goto-header "subject") | |
4766 | (setq new-art-buf-name | |
4767 | (buffer-substring-no-properties | |
4768 | (line-beginning-position) (line-end-position))) | |
4769 | (goto-char (point-min)) | |
4770 | (gnus-article-goto-header "from") | |
4771 | (setq new-art-buf-name | |
4772 | (concat | |
4773 | new-art-buf-name ", " | |
4774 | (buffer-substring-no-properties | |
4775 | (line-beginning-position) (line-end-position)))) | |
4776 | (goto-char (point-min)) | |
4777 | (gnus-article-goto-header "date") | |
4778 | (setq new-art-buf-name | |
4779 | (concat | |
4780 | new-art-buf-name ", " | |
4781 | (buffer-substring-no-properties | |
4782 | (line-beginning-position) (line-end-position)))))) | |
4783 | "*")) | |
4784 | (if (and (gnus-buffer-live-p new-art-buf-name) | |
4785 | (with-current-buffer new-art-buf-name | |
1b3b87df | 4786 | (derived-mode-p 'gnus-sticky-article-mode))) |
01c52d31 MB |
4787 | (switch-to-buffer new-art-buf-name) |
4788 | (setq new-art-buf-name (rename-buffer new-art-buf-name t))) | |
4789 | (gnus-sticky-article-mode)) | |
4790 | (setq gnus-article-buffer new-art-buf-name)) | |
4791 | (gnus-summary-recenter) | |
4792 | (gnus-summary-position-point)) | |
4793 | ||
4794 | (defun gnus-kill-sticky-article-buffer (&optional buffer) | |
4795 | "Kill the given sticky article BUFFER. | |
4796 | If none is given, assume the current buffer and kill it if it has | |
4797 | `gnus-sticky-article-mode'." | |
4798 | (interactive) | |
4799 | (unless buffer | |
4800 | (setq buffer (current-buffer))) | |
4801 | (with-current-buffer buffer | |
1b3b87df | 4802 | (when (derived-mode-p 'gnus-sticky-article-mode) |
01c52d31 MB |
4803 | (gnus-kill-buffer buffer)))) |
4804 | ||
71f32295 JD |
4805 | (defun gnus-kill-sticky-article-buffers (arg) |
4806 | "Kill all sticky article buffers. | |
4807 | If a prefix ARG is given, ask for confirmation." | |
4808 | (interactive "P") | |
4809 | (dolist (buf (gnus-buffers)) | |
4810 | (with-current-buffer buf | |
1b3b87df SM |
4811 | (when (derived-mode-p 'gnus-sticky-article-mode) |
4812 | (if (not arg) | |
4813 | (gnus-kill-buffer buf) | |
4814 | (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? ")) | |
4815 | (gnus-kill-buffer buf))))))) | |
71f32295 | 4816 | |
16409b0b GM |
4817 | ;;; |
4818 | ;;; Gnus MIME viewing functions | |
4819 | ;;; | |
4820 | ||
4821 | (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n" | |
23f87bed MB |
4822 | "Format of the MIME buttons. |
4823 | ||
4824 | Valid specifiers include: | |
16409b0b GM |
4825 | %t The MIME type |
4826 | %T MIME type, along with additional info | |
4827 | %n The `name' parameter | |
4828 | %d The description, if any | |
4829 | %l The length of the encoded part | |
4830 | %p The part identifier number | |
23f87bed MB |
4831 | %e Dots if the part isn't displayed |
4832 | ||
4833 | General format specifiers can also be used. See Info node | |
4834 | `(gnus)Formatting Variables'.") | |
16409b0b GM |
4835 | |
4836 | (defvar gnus-mime-button-line-format-alist | |
4837 | '((?t gnus-tmp-type ?s) | |
4838 | (?T gnus-tmp-type-long ?s) | |
4839 | (?n gnus-tmp-name ?s) | |
4840 | (?d gnus-tmp-description ?s) | |
4841 | (?p gnus-tmp-id ?s) | |
4842 | (?l gnus-tmp-length ?d) | |
4843 | (?e gnus-tmp-dots ?s))) | |
4844 | ||
4845 | (defvar gnus-mime-button-commands | |
4846 | '((gnus-article-press-button "\r" "Toggle Display") | |
4847 | (gnus-mime-view-part "v" "View Interactively...") | |
4848 | (gnus-mime-view-part-as-type "t" "View As Type...") | |
23f87bed | 4849 | (gnus-mime-view-part-as-charset "C" "View As charset...") |
16409b0b | 4850 | (gnus-mime-save-part "o" "Save...") |
23f87bed | 4851 | (gnus-mime-save-part-and-strip "\C-o" "Save and Strip") |
01c52d31 | 4852 | (gnus-mime-replace-part "r" "Replace part") |
23f87bed | 4853 | (gnus-mime-delete-part "d" "Delete part") |
16409b0b GM |
4854 | (gnus-mime-copy-part "c" "View As Text, In Other Buffer") |
4855 | (gnus-mime-inline-part "i" "View As Text, In This Buffer") | |
01c52d31 | 4856 | (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'? |
23f87bed MB |
4857 | (gnus-mime-view-part-externally "e" "View Externally") |
4858 | (gnus-mime-print-part "p" "Print") | |
e0bad764 | 4859 | (gnus-mime-pipe-part "|" "Pipe To Command...") |
23f87bed | 4860 | (gnus-mime-action-on-part "." "Take action on the part..."))) |
16409b0b GM |
4861 | |
4862 | (defun gnus-article-mime-part-status () | |
4863 | (if gnus-article-mime-handle-alist-1 | |
23f87bed MB |
4864 | (if (eq 1 (length gnus-article-mime-handle-alist-1)) |
4865 | " (1 part)" | |
4866 | (format " (%d parts)" (length gnus-article-mime-handle-alist-1))) | |
16409b0b GM |
4867 | "")) |
4868 | ||
4869 | (defvar gnus-mime-button-map | |
4870 | (let ((map (make-sparse-keymap))) | |
16409b0b GM |
4871 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
4872 | (define-key map gnus-down-mouse-3 'gnus-mime-button-menu) | |
4873 | (dolist (c gnus-mime-button-commands) | |
4874 | (define-key map (cadr c) (car c))) | |
4875 | map)) | |
4876 | ||
23f87bed MB |
4877 | (easy-menu-define |
4878 | gnus-mime-button-menu gnus-mime-button-map "MIME button menu." | |
4879 | `("MIME Part" | |
4880 | ,@(mapcar (lambda (c) | |
01c52d31 | 4881 | (vector (caddr c) (car c) :active t)) |
23f87bed MB |
4882 | gnus-mime-button-commands))) |
4883 | ||
7426b4f7 LMI |
4884 | (defvar gnus-url-button-commands |
4885 | '((gnus-article-copy-string "u" "Copy URL to kill ring"))) | |
4886 | ||
4887 | (defvar gnus-url-button-map | |
4888 | (let ((map (make-sparse-keymap))) | |
4889 | (dolist (c gnus-url-button-commands) | |
4890 | (define-key map (cadr c) (car c))) | |
4891 | map)) | |
4892 | ||
4893 | (easy-menu-define | |
4894 | gnus-url-button-menu gnus-url-button-map "URL button menu." | |
4895 | `("Url Button" | |
4896 | ,@(mapcar (lambda (c) | |
4897 | (vector (caddr c) (car c) :active t)) | |
4898 | gnus-url-button-commands))) | |
4899 | ||
b0b63450 MB |
4900 | (defmacro gnus-bind-safe-url-regexp (&rest body) |
4901 | "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'." | |
4902 | `(let ((mm-w3m-safe-url-regexp | |
1b3b87df | 4903 | (let ((group (if (and (derived-mode-p 'gnus-article-mode) |
b0b63450 MB |
4904 | (gnus-buffer-live-p |
4905 | gnus-article-current-summary)) | |
4906 | (with-current-buffer gnus-article-current-summary | |
4907 | gnus-newsgroup-name) | |
4908 | gnus-newsgroup-name))) | |
7cab80f9 KY |
4909 | (if (cond ((not group) |
4910 | ;; Maybe we're in a mml-preview buffer | |
4911 | ;; and no group is selected. | |
4912 | t) | |
4913 | ((stringp gnus-safe-html-newsgroups) | |
b0b63450 MB |
4914 | (string-match gnus-safe-html-newsgroups group)) |
4915 | ((consp gnus-safe-html-newsgroups) | |
4916 | (member group gnus-safe-html-newsgroups))) | |
4917 | nil | |
4918 | mm-w3m-safe-url-regexp)))) | |
4919 | ,@body)) | |
4920 | ||
23f87bed MB |
4921 | (defun gnus-mime-button-menu (event prefix) |
4922 | "Construct a context-sensitive menu of MIME commands." | |
4923 | (interactive "e\nP") | |
4924 | (save-window-excursion | |
4925 | (let ((pos (event-start event))) | |
4926 | (select-window (posn-window pos)) | |
4927 | (goto-char (posn-point pos)) | |
4928 | (gnus-article-check-buffer) | |
4929 | (popup-menu gnus-mime-button-menu nil prefix)))) | |
16409b0b GM |
4930 | |
4931 | (defun gnus-mime-view-all-parts (&optional handles) | |
4932 | "View all the MIME parts." | |
4933 | (interactive) | |
01c52d31 | 4934 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
4935 | (let ((handles (or handles gnus-article-mime-handles)) |
4936 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 4937 | (mail-parse-ignored-charsets |
23f87bed MB |
4938 | (with-current-buffer gnus-summary-buffer |
4939 | gnus-newsgroup-ignored-charsets))) | |
4940 | (when handles | |
4941 | (mm-remove-parts handles) | |
4942 | (goto-char (point-min)) | |
4943 | (or (search-forward "\n\n") (goto-char (point-max))) | |
4944 | (let ((inhibit-read-only t)) | |
4945 | (delete-region (point) (point-max)) | |
b0b63450 | 4946 | (gnus-bind-safe-url-regexp (mm-display-parts handles))))))) |
23f87bed | 4947 | |
01c52d31 MB |
4948 | (defun gnus-article-jump-to-part (n) |
4949 | "Jump to MIME part N." | |
4950 | (interactive "P") | |
a87ee50b KY |
4951 | (let ((parts (with-current-buffer gnus-article-buffer |
4952 | (length gnus-article-mime-handle-alist)))) | |
4953 | (when (zerop parts) | |
4954 | (error "No such part")) | |
4955 | (pop-to-buffer gnus-article-buffer) | |
a87ee50b KY |
4956 | (or n |
4957 | (setq n (if (= parts 1) | |
4958 | 1 | |
4959 | (read-number (format "Jump to part (1..%s): " parts))))) | |
01c52d31 MB |
4960 | (unless (and (integerp n) (<= n parts) (>= n 1)) |
4961 | (setq n | |
4962 | (progn | |
4963 | (gnus-message 7 "Invalid part `%s', using %s instead." | |
4964 | n parts) | |
4965 | parts))) | |
4966 | (gnus-message 9 "Jumping to part %s." n) | |
4967 | (cond ((>= gnus-auto-select-part 1) | |
4968 | (while (and (<= n parts) | |
4969 | (not (gnus-article-goto-part n))) | |
4970 | (setq n (1+ n)))) | |
4971 | ((< gnus-auto-select-part 0) | |
4972 | (while (and (>= n 1) | |
4973 | (not (gnus-article-goto-part n))) | |
4974 | (setq n (1- n)))) | |
4975 | (t | |
4976 | (gnus-article-goto-part n))))) | |
4977 | ||
3e3ab3ab KY |
4978 | (defvar gnus-mime-buttonized-part-id nil |
4979 | "ID of a mime part that should be buttonized. | |
4980 | `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.") | |
4981 | ||
01c52d31 MB |
4982 | (eval-when-compile |
4983 | (defsubst gnus-article-edit-part (handles &optional current-id) | |
4984 | "Edit an article in order to delete a mime part. | |
4985 | This function is exclusively used by `gnus-mime-save-part-and-strip' | |
4986 | and `gnus-mime-delete-part', and not provided at run-time normally." | |
4987 | (gnus-article-edit-article | |
4988 | `(lambda () | |
4989 | (buffer-disable-undo) | |
4990 | (erase-buffer) | |
4991 | (let ((mail-parse-charset (or gnus-article-charset | |
4992 | ',gnus-newsgroup-charset)) | |
4993 | (mail-parse-ignored-charsets | |
4994 | (or gnus-article-ignored-charsets | |
4995 | ',gnus-newsgroup-ignored-charsets)) | |
4996 | (mbl mml-buffer-list)) | |
4997 | (setq mml-buffer-list nil) | |
4998 | (insert-buffer-substring gnus-original-article-buffer) | |
4999 | (mime-to-mml ',handles) | |
5000 | (setq gnus-article-mime-handles nil) | |
5001 | (let ((mbl1 mml-buffer-list)) | |
5002 | (setq mml-buffer-list mbl) | |
5003 | (set (make-local-variable 'mml-buffer-list) mbl1)) | |
5004 | (gnus-make-local-hook 'kill-buffer-hook) | |
5005 | (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))) | |
5006 | `(lambda (no-highlight) | |
5007 | (let ((mail-parse-charset (or gnus-article-charset | |
5008 | ',gnus-newsgroup-charset)) | |
5009 | (message-options message-options) | |
5010 | (message-options-set-recipient) | |
5011 | (mail-parse-ignored-charsets | |
5012 | (or gnus-article-ignored-charsets | |
5013 | ',gnus-newsgroup-ignored-charsets))) | |
5014 | (mml-to-mime) | |
5015 | (mml-destroy-buffers) | |
5016 | (remove-hook 'kill-buffer-hook | |
5017 | 'mml-destroy-buffers t) | |
5018 | (kill-local-variable 'mml-buffer-list)) | |
5019 | (gnus-summary-edit-article-done | |
5020 | ,(or (mail-header-references gnus-current-headers) "") | |
5021 | ,(gnus-group-read-only-p) | |
5022 | ,gnus-summary-buffer no-highlight)) | |
5023 | t) | |
3e3ab3ab KY |
5024 | ;; Force buttonizing this part. |
5025 | (let ((gnus-mime-buttonized-part-id current-id)) | |
5026 | (gnus-article-edit-done)) | |
54c72c31 | 5027 | (gnus-configure-windows 'article) |
01c52d31 | 5028 | (when (and current-id (integerp gnus-auto-select-part)) |
3e3ab3ab KY |
5029 | (gnus-article-jump-to-part |
5030 | (min (max (+ current-id gnus-auto-select-part) 1) | |
5031 | (with-current-buffer gnus-article-buffer | |
5032 | (length gnus-article-mime-handle-alist))))))) | |
01c52d31 MB |
5033 | |
5034 | (defun gnus-mime-replace-part (file) | |
5035 | "Replace MIME part under point with an external body." | |
5036 | ;; Useful if file has already been saved to disk | |
5037 | (interactive | |
5038 | (list | |
75eda25b SM |
5039 | (read-file-name "Replace MIME part with file: " |
5040 | (or mm-default-directory default-directory) | |
5041 | nil nil))) | |
01c52d31 MB |
5042 | (gnus-mime-save-part-and-strip file)) |
5043 | ||
5044 | (defun gnus-mime-save-part-and-strip (&optional file) | |
5045 | "Save the MIME part under point then replace it with an external body. | |
5046 | If FILE is given, use it for the external part." | |
23f87bed MB |
5047 | (interactive) |
5048 | (gnus-article-check-buffer) | |
5049 | (when (gnus-group-read-only-p) | |
5050 | (error "The current group does not support deleting of parts")) | |
5051 | (when (mm-complicated-handles gnus-article-mime-handles) | |
5052 | (error "\ | |
5053 | The current article has a complicated MIME structure, giving up...")) | |
01c52d31 MB |
5054 | (let* ((data (get-text-property (point) 'gnus-data)) |
5055 | (id (get-text-property (point) 'gnus-part)) | |
5056 | param | |
5057 | (handles gnus-article-mime-handles)) | |
5058 | (unless file | |
5059 | (setq file | |
5060 | (and data (mm-save-part data "Delete MIME part and save to: ")))) | |
5061 | (when file | |
5062 | (with-current-buffer (mm-handle-buffer data) | |
5063 | (erase-buffer) | |
5064 | (insert "Content-Type: " (mm-handle-media-type data)) | |
5065 | (mml-insert-parameter-string (cdr (mm-handle-type data)) | |
5066 | '(charset)) | |
5067 | ;; Add a filename for the sake of saving the part again. | |
5068 | (mml-insert-parameter | |
5069 | (mail-header-encode-parameter "name" (file-name-nondirectory file))) | |
5070 | (insert "\n") | |
5071 | (insert "Content-ID: " (message-make-message-id) "\n") | |
5072 | (insert "Content-Transfer-Encoding: binary\n") | |
5073 | (insert "\n")) | |
5074 | (setcdr data | |
5075 | (cdr (mm-make-handle nil | |
5076 | `("message/external-body" | |
5077 | (access-type . "LOCAL-FILE") | |
5078 | (name . ,file))))) | |
5079 | ;; (set-buffer gnus-summary-buffer) | |
5080 | (gnus-article-edit-part handles id)))) | |
5081 | ||
5082 | ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all | |
5083 | ;; parts...>') but with stripping would be nice. | |
23f87bed MB |
5084 | |
5085 | (defun gnus-mime-delete-part () | |
5086 | "Delete the MIME part under point. | |
5087 | Replace it with some information about the removed part." | |
5088 | (interactive) | |
5089 | (gnus-article-check-buffer) | |
5090 | (when (gnus-group-read-only-p) | |
5091 | (error "The current group does not support deleting of parts")) | |
5092 | (when (mm-complicated-handles gnus-article-mime-handles) | |
5093 | (error "\ | |
5094 | The current article has a complicated MIME structure, giving up...")) | |
01c52d31 MB |
5095 | (when (or gnus-expert-user |
5096 | (gnus-yes-or-no-p "\ | |
5097 | Deleting parts may malfunction or destroy the article; continue? ")) | |
23f87bed | 5098 | (let* ((data (get-text-property (point) 'gnus-data)) |
01c52d31 | 5099 | (id (get-text-property (point) 'gnus-part)) |
23f87bed | 5100 | (handles gnus-article-mime-handles) |
23f87bed | 5101 | (description |
bbbe940b MB |
5102 | (let ((desc (mm-handle-description data))) |
5103 | (when desc | |
5104 | (mail-decode-encoded-word-string desc)))) | |
88a7a941 | 5105 | (filename (or (mm-handle-filename data) "(none)")) |
23f87bed MB |
5106 | (type (mm-handle-media-type data))) |
5107 | (unless data | |
5108 | (error "No MIME part under point")) | |
5109 | (with-current-buffer (mm-handle-buffer data) | |
e5fa3899 | 5110 | (let ((bsize (buffer-size))) |
23f87bed MB |
5111 | (erase-buffer) |
5112 | (insert | |
5113 | (concat | |
5114 | ",----\n" | |
5115 | "| The following attachment has been deleted:\n" | |
5116 | "|\n" | |
5117 | "| Type: " type "\n" | |
5118 | "| Filename: " filename "\n" | |
e5fa3899 KY |
5119 | "| Size (encoded): " (format "%s byte%s\n" |
5120 | bsize (if (= bsize 1) | |
8ccbef23 G |
5121 | "" |
5122 | "s")) | |
bbbe940b MB |
5123 | (when description |
5124 | (concat "| Description: " description "\n")) | |
23f87bed MB |
5125 | "`----\n")) |
5126 | (setcdr data | |
5127 | (cdr (mm-make-handle | |
0cf681b6 | 5128 | nil `("text/plain" (charset . gnus-decoded)) nil nil |
23f87bed MB |
5129 | (list "attachment") |
5130 | (format "Deleted attachment (%s bytes)" bsize)))))) | |
01c52d31 MB |
5131 | ;; (set-buffer gnus-summary-buffer) |
5132 | (gnus-article-edit-part handles id)))) | |
16409b0b GM |
5133 | |
5134 | (defun gnus-mime-save-part () | |
5135 | "Save the MIME part under point." | |
5136 | (interactive) | |
5137 | (gnus-article-check-buffer) | |
5138 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed MB |
5139 | (when data |
5140 | (mm-save-part data)))) | |
16409b0b | 5141 | |
9581ba4d KY |
5142 | (defun gnus-mime-pipe-part (&optional cmd) |
5143 | "Pipe the MIME part under point to a process. | |
5144 | Use CMD as the process." | |
16409b0b GM |
5145 | (interactive) |
5146 | (gnus-article-check-buffer) | |
5147 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed | 5148 | (when data |
9581ba4d | 5149 | (mm-pipe-part data cmd)))) |
16409b0b GM |
5150 | |
5151 | (defun gnus-mime-view-part () | |
5152 | "Interactively choose a viewing method for the MIME part under point." | |
5153 | (interactive) | |
5154 | (gnus-article-check-buffer) | |
5155 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed MB |
5156 | (when data |
5157 | (setq gnus-article-mime-handles | |
5158 | (mm-merge-handles | |
5159 | gnus-article-mime-handles (setq data (copy-sequence data)))) | |
5160 | (mm-interactively-view-part data)))) | |
16409b0b GM |
5161 | |
5162 | (defun gnus-mime-view-part-as-type-internal () | |
5163 | (gnus-article-check-buffer) | |
54e573e6 MB |
5164 | (let* ((handle (get-text-property (point) 'gnus-data)) |
5165 | (name (or | |
5166 | ;; Content-Type: foo/bar; name=... | |
5167 | (mail-content-type-get (mm-handle-type handle) 'name) | |
5168 | ;; Content-Disposition: attachment; filename=... | |
5169 | (cdr (assq 'filename (cdr (mm-handle-disposition handle)))))) | |
16409b0b | 5170 | (def-type (and name (mm-default-file-encoding name)))) |
01c52d31 MB |
5171 | (or (and def-type (cons def-type 0)) |
5172 | (and handle | |
5173 | (equal (mm-handle-media-supertype handle) "text") | |
5174 | '("text/plain" . 0)) | |
5175 | '("application/octet-stream" . 0)))) | |
16409b0b | 5176 | |
54e573e6 MB |
5177 | (defun gnus-mime-view-part-as-type (&optional mime-type pred) |
5178 | "Choose a MIME media type, and view the part as such. | |
5179 | If non-nil, PRED is a predicate to use during completion to limit the | |
5180 | available media-types." | |
23f87bed MB |
5181 | (interactive) |
5182 | (unless mime-type | |
54e573e6 MB |
5183 | (setq mime-type |
5184 | (let ((default (gnus-mime-view-part-as-type-internal))) | |
229b59da G |
5185 | (gnus-completing-read |
5186 | "View as MIME type" | |
568f71a8 KY |
5187 | (if pred |
5188 | (gnus-remove-if-not pred (mailcap-mime-types)) | |
5189 | (mailcap-mime-types)) | |
229b59da | 5190 | nil nil nil |
54e573e6 | 5191 | (car default))))) |
16409b0b GM |
5192 | (gnus-article-check-buffer) |
5193 | (let ((handle (get-text-property (point) 'gnus-data))) | |
23f87bed | 5194 | (when handle |
531bedc3 MB |
5195 | (when (equal (mm-handle-media-type handle) "message/external-body") |
5196 | (unless (mm-handle-cache handle) | |
5197 | (mm-extern-cache-contents handle)) | |
5198 | (setq handle (mm-handle-cache handle))) | |
23f87bed MB |
5199 | (setq handle |
5200 | (mm-make-handle (mm-handle-buffer handle) | |
5201 | (cons mime-type (cdr (mm-handle-type handle))) | |
5202 | (mm-handle-encoding handle) | |
5203 | (mm-handle-undisplayer handle) | |
5204 | (mm-handle-disposition handle) | |
5205 | (mm-handle-description handle) | |
5206 | nil | |
5207 | (mm-handle-id handle))) | |
5208 | (setq gnus-article-mime-handles | |
5209 | (mm-merge-handles gnus-article-mime-handles handle)) | |
01c52d31 MB |
5210 | (when (mm-handle-displayed-p handle) |
5211 | (mm-remove-part handle)) | |
23f87bed MB |
5212 | (gnus-mm-display-part handle)))) |
5213 | ||
01c52d31 | 5214 | (defun gnus-mime-copy-part (&optional handle arg) |
23f87bed MB |
5215 | "Put the MIME part under point into a new buffer. |
5216 | If `auto-compression-mode' is enabled, compressed files like .gz and .bz2 | |
5217 | are decompressed." | |
01c52d31 | 5218 | (interactive (list nil current-prefix-arg)) |
16409b0b | 5219 | (gnus-article-check-buffer) |
01c52d31 MB |
5220 | (unless handle |
5221 | (setq handle (get-text-property (point) 'gnus-data))) | |
5222 | (when handle | |
247c22e1 | 5223 | (let ((filename (mm-handle-filename handle)) |
01c52d31 MB |
5224 | contents dont-decode charset coding-system) |
5225 | (mm-with-unibyte-buffer | |
5226 | (mm-insert-part handle) | |
5227 | (setq contents (or (condition-case nil | |
5228 | (mm-decompress-buffer filename nil 'sig) | |
5229 | (error | |
5230 | (setq dont-decode t) | |
5231 | nil)) | |
5232 | (buffer-string)))) | |
5233 | (setq filename (cond (filename (file-name-nondirectory filename)) | |
5234 | (dont-decode "*raw data*") | |
5235 | (t "*decoded*"))) | |
5236 | (cond | |
5237 | (dont-decode) | |
5238 | ((not arg) | |
5239 | (unless (setq charset (mail-content-type-get | |
5240 | (mm-handle-type handle) 'charset)) | |
5241 | (unless (setq coding-system (mm-with-unibyte-buffer | |
5242 | (insert contents) | |
5243 | (mm-find-buffer-file-coding-system))) | |
5244 | (setq charset gnus-newsgroup-charset)))) | |
5245 | ((numberp arg) | |
5246 | (setq charset (or (cdr (assq arg | |
5247 | gnus-summary-show-article-charset-alist)) | |
5248 | (mm-read-coding-system "Charset: "))))) | |
5249 | (switch-to-buffer (generate-new-buffer filename)) | |
5250 | (if (or coding-system | |
5251 | (and charset | |
07178229 KY |
5252 | (setq coding-system (mm-charset-to-coding-system |
5253 | charset nil t)) | |
a87ee50b | 5254 | (not (eq coding-system 'ascii)))) |
01c52d31 MB |
5255 | (progn |
5256 | (mm-enable-multibyte) | |
5257 | (insert (mm-decode-coding-string contents coding-system)) | |
5258 | (setq buffer-file-coding-system | |
5259 | (if (boundp 'last-coding-system-used) | |
5260 | (symbol-value 'last-coding-system-used) | |
5261 | coding-system))) | |
5262 | (mm-disable-multibyte) | |
5263 | (insert contents) | |
5264 | (setq buffer-file-coding-system mm-binary-coding-system)) | |
23f87bed MB |
5265 | ;; We do it this way to make `normal-mode' set the appropriate mode. |
5266 | (unwind-protect | |
5267 | (progn | |
01c52d31 | 5268 | (setq buffer-file-name (expand-file-name filename)) |
23f87bed MB |
5269 | (normal-mode)) |
5270 | (setq buffer-file-name nil)) | |
5271 | (goto-char (point-min))))) | |
5272 | ||
5273 | (defun gnus-mime-print-part (&optional handle filename) | |
5274 | "Print the MIME part under point." | |
5275 | (interactive (list nil (ps-print-preprint current-prefix-arg))) | |
5276 | (gnus-article-check-buffer) | |
5277 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5278 | (contents (and handle (mm-get-part handle))) | |
5279 | (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory))) | |
5280 | (printer (mailcap-mime-info (mm-handle-media-type handle) "print"))) | |
5281 | (when contents | |
5282 | (if printer | |
5283 | (unwind-protect | |
5284 | (progn | |
5285 | (mm-save-part-to-file handle file) | |
5286 | (call-process shell-file-name nil | |
5287 | (generate-new-buffer " *mm*") | |
5288 | nil | |
5289 | shell-command-switch | |
5290 | (mm-mailcap-command | |
5291 | printer file (mm-handle-type handle)))) | |
5292 | (delete-file file)) | |
5293 | (with-temp-buffer | |
5294 | (insert contents) | |
5295 | (gnus-print-buffer)) | |
5296 | (ps-despool filename))))) | |
16409b0b | 5297 | |
e0bad764 | 5298 | (defun gnus-mime-inline-part (&optional handle arg) |
01c52d31 MB |
5299 | "Insert the MIME part under point into the current buffer. |
5300 | Compressed files like .gz and .bz2 are decompressed." | |
e0bad764 | 5301 | (interactive (list nil current-prefix-arg)) |
16409b0b | 5302 | (gnus-article-check-buffer) |
01c52d31 MB |
5303 | (unless handle |
5304 | (setq handle (get-text-property (point) 'gnus-data))) | |
5305 | (when handle | |
5306 | (let ((b (point)) | |
5307 | (inhibit-read-only t) | |
5308 | contents charset coding-system) | |
23f87bed MB |
5309 | (if (and (not arg) (mm-handle-undisplayer handle)) |
5310 | (mm-remove-part handle) | |
01c52d31 MB |
5311 | (mm-with-unibyte-buffer |
5312 | (mm-insert-part handle) | |
5313 | (setq contents | |
247c22e1 | 5314 | (or (mm-decompress-buffer (mm-handle-filename handle) nil t) |
01c52d31 | 5315 | (buffer-string)))) |
23f87bed MB |
5316 | (cond |
5317 | ((not arg) | |
01c52d31 MB |
5318 | (unless (setq charset (mail-content-type-get |
5319 | (mm-handle-type handle) 'charset)) | |
5320 | (unless (setq coding-system | |
5321 | (mm-with-unibyte-buffer | |
5322 | (insert contents) | |
5323 | (mm-find-buffer-file-coding-system))) | |
5324 | (setq charset gnus-newsgroup-charset)))) | |
23f87bed MB |
5325 | ((numberp arg) |
5326 | (if (mm-handle-undisplayer handle) | |
5327 | (mm-remove-part handle)) | |
5328 | (setq charset | |
5329 | (or (cdr (assq arg | |
5330 | gnus-summary-show-article-charset-alist)) | |
56c30d72 | 5331 | (mm-read-coding-system "Charset: ")))) |
89b163db G |
5332 | ((mm-handle-undisplayer handle) |
5333 | (mm-remove-part handle))) | |
4d2226bf | 5334 | (forward-line 1) |
6e3165fb | 5335 | (mm-display-inline handle) |
23f87bed MB |
5336 | (goto-char b))))) |
5337 | ||
c0ccb0d6 KY |
5338 | (defun gnus-mime-set-charset-parameters (handle charset) |
5339 | "Set CHARSET to parameters in HANDLE. | |
5340 | CHARSET may either be a string or a symbol." | |
5341 | (unless (stringp charset) | |
5342 | (setq charset (symbol-name charset))) | |
6b554e88 | 5343 | (if (stringp (car handle)) |
c0ccb0d6 KY |
5344 | (dolist (h (cdr handle)) |
5345 | (gnus-mime-set-charset-parameters h charset)) | |
6b554e88 MB |
5346 | (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle) |
5347 | "message/external-body") | |
5348 | (progn | |
5349 | (unless (mm-handle-cache handle) | |
5350 | (mm-extern-cache-contents handle)) | |
5351 | (mm-handle-cache handle)) | |
5352 | handle))) | |
c0ccb0d6 KY |
5353 | (param (assq 'charset (cdr type)))) |
5354 | (if param | |
5355 | (setcdr param charset) | |
5356 | (setcdr type (cons (cons 'charset charset) (cdr type))))))) | |
6b554e88 | 5357 | |
23f87bed MB |
5358 | (defun gnus-mime-view-part-as-charset (&optional handle arg) |
5359 | "Insert the MIME part under point into the current buffer using the | |
5360 | specified charset." | |
5361 | (interactive (list nil current-prefix-arg)) | |
5362 | (gnus-article-check-buffer) | |
163cb72d MB |
5363 | (let ((handle (or handle (get-text-property (point) 'gnus-data))) |
5364 | (fun (get-text-property (point) 'gnus-callback)) | |
5365 | (gnus-newsgroup-ignored-charsets 'gnus-all) | |
c0ccb0d6 | 5366 | charset form preferred parts) |
23f87bed | 5367 | (when handle |
01c52d31 MB |
5368 | (when (prog1 |
5369 | (and fun | |
c0ccb0d6 | 5370 | (setq charset |
01c52d31 MB |
5371 | (or (cdr (assq |
5372 | arg | |
5373 | gnus-summary-show-article-charset-alist)) | |
5374 | (mm-read-coding-system "Charset: ")))) | |
5375 | (if (mm-handle-undisplayer handle) | |
5376 | (mm-remove-part handle))) | |
c0ccb0d6 | 5377 | (gnus-mime-set-charset-parameters handle charset) |
6b554e88 MB |
5378 | (when (and (consp (setq form (cdr-safe fun))) |
5379 | (setq form (ignore-errors | |
5380 | (assq 'gnus-mime-display-alternative form))) | |
5381 | (setq preferred (caddr form)) | |
5382 | (progn | |
5383 | (when (eq (car preferred) 'quote) | |
5384 | (setq preferred (cadr preferred))) | |
5385 | (not (equal preferred | |
5386 | (get-text-property (point) 'gnus-data)))) | |
5387 | (setq parts (get-text-property (point) 'gnus-part)) | |
5388 | (setq parts (cdr (assq parts | |
5389 | gnus-article-mime-handle-alist))) | |
5390 | (equal (mm-handle-media-type parts) "multipart/alternative") | |
5391 | (setq parts (reverse (cdr parts)))) | |
5392 | (setcar (cddr form) | |
5393 | (list 'quote (or (cadr (member preferred parts)) | |
5394 | (car parts))))) | |
163cb72d | 5395 | (funcall fun handle))))) |
23f87bed MB |
5396 | |
5397 | (defun gnus-mime-view-part-externally (&optional handle) | |
16409b0b GM |
5398 | "View the MIME part under point with an external viewer." |
5399 | (interactive) | |
5400 | (gnus-article-check-buffer) | |
5401 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5402 | (mm-user-display-methods nil) | |
5403 | (mm-inlined-types nil) | |
5404 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5405 | (mail-parse-ignored-charsets |
54e573e6 MB |
5406 | (with-current-buffer gnus-summary-buffer |
5407 | gnus-newsgroup-ignored-charsets)) | |
5408 | (type (mm-handle-media-type handle)) | |
5409 | (method (mailcap-mime-info type)) | |
5410 | (mm-enable-external t)) | |
5411 | (if (not (stringp method)) | |
5412 | (gnus-mime-view-part-as-type | |
f7aa0b8f | 5413 | nil (lambda (type) (stringp (mailcap-mime-info type)))) |
54e573e6 | 5414 | (when handle |
a87ee50b | 5415 | (mm-display-part handle nil t))))) |
16409b0b | 5416 | |
23f87bed | 5417 | (defun gnus-mime-view-part-internally (&optional handle) |
16409b0b | 5418 | "View the MIME part under point with an internal viewer. |
23f87bed | 5419 | If no internal viewer is available, use an external viewer." |
16409b0b GM |
5420 | (interactive) |
5421 | (gnus-article-check-buffer) | |
5422 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5423 | (mm-inlined-types '(".*")) | |
5424 | (mm-inline-large-images t) | |
5425 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5426 | (mail-parse-ignored-charsets |
54e573e6 MB |
5427 | (with-current-buffer gnus-summary-buffer |
5428 | gnus-newsgroup-ignored-charsets)) | |
23f87bed | 5429 | (inhibit-read-only t)) |
54e573e6 MB |
5430 | (if (not (mm-inlinable-p handle)) |
5431 | (gnus-mime-view-part-as-type | |
f7aa0b8f | 5432 | nil (lambda (type) (mm-inlinable-p handle type))) |
54e573e6 | 5433 | (when handle |
a87ee50b | 5434 | (gnus-bind-safe-url-regexp (mm-display-part handle)))))) |
16409b0b | 5435 | |
e0bad764 DL |
5436 | (defun gnus-mime-action-on-part (&optional action) |
5437 | "Do something with the MIME attachment at \(point\)." | |
5438 | (interactive | |
229b59da | 5439 | (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t))) |
e0bad764 DL |
5440 | (gnus-article-check-buffer) |
5441 | (let ((action-pair (assoc action gnus-mime-action-alist))) | |
5442 | (if action-pair | |
5443 | (funcall (cdr action-pair))))) | |
5444 | ||
01c52d31 MB |
5445 | (defun gnus-article-part-wrapper (n function &optional no-handle interactive) |
5446 | "Call FUNCTION on MIME part N. | |
c7015153 JB |
5447 | Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument. |
5448 | If INTERACTIVE, call FUNCTION interactively." | |
01c52d31 MB |
5449 | (let (window frame) |
5450 | ;; Check whether the article is displayed. | |
5451 | (unless (and (gnus-buffer-live-p gnus-article-buffer) | |
5452 | (setq window (get-buffer-window gnus-article-buffer t)) | |
5453 | (frame-visible-p (setq frame (window-frame window)))) | |
5454 | (error "No article is displayed")) | |
5455 | (with-current-buffer gnus-article-buffer | |
5456 | ;; Check whether the article displays the right contents. | |
5457 | (unless (with-current-buffer gnus-summary-buffer | |
5458 | (eq gnus-current-article (gnus-summary-article-number))) | |
5459 | (error "You should select the right article first")) | |
5460 | (if n | |
5461 | (setq n (prefix-numeric-value n)) | |
5462 | (let ((pt (point))) | |
5463 | (setq n (or (get-text-property pt 'gnus-part) | |
5464 | (and (not (bobp)) | |
5465 | (get-text-property (1- pt) 'gnus-part)) | |
5466 | (get-text-property (prog2 | |
5467 | (forward-line 1) | |
5468 | (point) | |
5469 | (goto-char pt)) | |
5470 | 'gnus-part) | |
5471 | (get-text-property | |
5472 | (or (and (setq pt (previous-single-property-change | |
5473 | pt 'gnus-part)) | |
5474 | (1- pt)) | |
5475 | (next-single-property-change (point) 'gnus-part) | |
5476 | (point)) | |
5477 | 'gnus-part) | |
5478 | 1)))) | |
5479 | ;; Check whether the specified part exists. | |
5480 | (when (> n (length gnus-article-mime-handle-alist)) | |
5481 | (error "No such part"))) | |
5482 | (unless | |
5483 | (progn | |
5484 | ;; To select the window is needed so that the cursor | |
5485 | ;; might be visible on the MIME button. | |
5486 | (select-window (prog1 | |
5487 | window | |
5488 | (setq window (selected-window)) | |
5489 | ;; Article may be displayed in the other frame. | |
5490 | (gnus-select-frame-set-input-focus | |
5491 | (prog1 | |
5492 | frame | |
5493 | (setq frame (selected-frame)))))) | |
5494 | (when (gnus-article-goto-part n) | |
5495 | ;; We point the cursor and the arrow at the MIME button | |
5496 | ;; when the `function' prompt the user for something. | |
a87ee50b KY |
5497 | (unless (and (pos-visible-in-window-p) |
5498 | (> (count-lines (point) (window-end)) | |
5499 | (/ (1- (window-height)) 3))) | |
5500 | (recenter (/ (1- (window-height)) 3))) | |
01c52d31 MB |
5501 | (let ((cursor-in-non-selected-windows t) |
5502 | (overlay-arrow-string "=>") | |
5503 | (overlay-arrow-position (point-marker))) | |
5504 | (unwind-protect | |
5505 | (cond | |
5506 | ((and no-handle interactive) | |
5507 | (call-interactively function)) | |
5508 | (no-handle | |
5509 | (funcall function)) | |
5510 | (interactive | |
5511 | (call-interactively | |
a87ee50b | 5512 | function (get-text-property (point) 'gnus-data))) |
01c52d31 MB |
5513 | (t |
5514 | (funcall function | |
a87ee50b | 5515 | (get-text-property (point) 'gnus-data)))) |
01c52d31 MB |
5516 | (set-marker overlay-arrow-position nil) |
5517 | (unless gnus-auto-select-part | |
5518 | (gnus-select-frame-set-input-focus frame) | |
5519 | (select-window window)))) | |
5520 | t)) | |
5521 | (if gnus-inhibit-mime-unbuttonizing | |
5522 | ;; This is the default though the program shouldn't reach here. | |
5523 | (error "No such part") | |
5524 | ;; The part which doesn't have the MIME button is selected. | |
5525 | ;; So, we display all the buttons and redo it. | |
5526 | (let ((gnus-inhibit-mime-unbuttonizing t)) | |
5527 | (gnus-summary-show-article) | |
5528 | (gnus-article-part-wrapper n function no-handle)))))) | |
16409b0b GM |
5529 | |
5530 | (defun gnus-article-pipe-part (n) | |
5531 | "Pipe MIME part N, which is the numerical prefix." | |
01c52d31 | 5532 | (interactive "P") |
16409b0b GM |
5533 | (gnus-article-part-wrapper n 'mm-pipe-part)) |
5534 | ||
5535 | (defun gnus-article-save-part (n) | |
5536 | "Save MIME part N, which is the numerical prefix." | |
01c52d31 | 5537 | (interactive "P") |
16409b0b GM |
5538 | (gnus-article-part-wrapper n 'mm-save-part)) |
5539 | ||
5540 | (defun gnus-article-interactively-view-part (n) | |
5541 | "View MIME part N interactively, which is the numerical prefix." | |
01c52d31 | 5542 | (interactive "P") |
16409b0b GM |
5543 | (gnus-article-part-wrapper n 'mm-interactively-view-part)) |
5544 | ||
5545 | (defun gnus-article-copy-part (n) | |
5546 | "Copy MIME part N, which is the numerical prefix." | |
01c52d31 | 5547 | (interactive "P") |
16409b0b GM |
5548 | (gnus-article-part-wrapper n 'gnus-mime-copy-part)) |
5549 | ||
23f87bed MB |
5550 | (defun gnus-article-view-part-as-charset (n) |
5551 | "View MIME part N using a specified charset. | |
5552 | N is the numerical prefix." | |
01c52d31 | 5553 | (interactive "P") |
23f87bed MB |
5554 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset)) |
5555 | ||
5556 | (defun gnus-article-view-part-externally (n) | |
16409b0b | 5557 | "View MIME part N externally, which is the numerical prefix." |
01c52d31 | 5558 | (interactive "P") |
23f87bed | 5559 | (gnus-article-part-wrapper n 'gnus-mime-view-part-externally)) |
16409b0b GM |
5560 | |
5561 | (defun gnus-article-inline-part (n) | |
5562 | "Inline MIME part N, which is the numerical prefix." | |
01c52d31 | 5563 | (interactive "P") |
16409b0b GM |
5564 | (gnus-article-part-wrapper n 'gnus-mime-inline-part)) |
5565 | ||
01c52d31 MB |
5566 | (defun gnus-article-save-part-and-strip (n) |
5567 | "Save MIME part N and replace it with an external body. | |
5568 | N is the numerical prefix." | |
5569 | (interactive "P") | |
5570 | (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t)) | |
5571 | ||
5572 | (defun gnus-article-replace-part (n) | |
5573 | "Replace MIME part N with an external body. | |
5574 | N is the numerical prefix." | |
5575 | (interactive "P") | |
5576 | (gnus-article-part-wrapper n 'gnus-mime-replace-part t t)) | |
5577 | ||
5578 | (defun gnus-article-delete-part (n) | |
5579 | "Delete MIME part N and add some information about the removed part. | |
5580 | N is the numerical prefix." | |
5581 | (interactive "P") | |
5582 | (gnus-article-part-wrapper n 'gnus-mime-delete-part t)) | |
5583 | ||
5584 | (defun gnus-article-view-part-as-type (n) | |
5585 | "Choose a MIME media type, and view part N as such. | |
5586 | N is the numerical prefix." | |
5587 | (interactive "P") | |
5588 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t)) | |
5589 | ||
16409b0b GM |
5590 | (defun gnus-article-mime-match-handle-first (condition) |
5591 | (if condition | |
01c52d31 MB |
5592 | (let (n) |
5593 | (dolist (ihandle gnus-article-mime-handle-alist) | |
a1506d29 | 5594 | (if (and (cond |
16409b0b GM |
5595 | ((functionp condition) |
5596 | (funcall condition (cdr ihandle))) | |
a1506d29 | 5597 | ((eq condition 'undisplayed) |
16409b0b GM |
5598 | (not (or (mm-handle-undisplayer (cdr ihandle)) |
5599 | (equal (mm-handle-media-type (cdr ihandle)) | |
5600 | "multipart/alternative")))) | |
5601 | ((eq condition 'undisplayed-alternative) | |
5602 | (not (mm-handle-undisplayer (cdr ihandle)))) | |
5603 | (t t)) | |
5604 | (gnus-article-goto-part (car ihandle)) | |
5605 | (or (not n) (< (car ihandle) n))) | |
5606 | (setq n (car ihandle)))) | |
5607 | (or n 1)) | |
5608 | 1)) | |
5609 | ||
5610 | (defun gnus-article-view-part (&optional n) | |
47fe149b KY |
5611 | "View MIME part N, which is the numerical prefix. |
5612 | If the part is already shown, hide the part. If N is nil, view | |
5613 | all parts." | |
16409b0b | 5614 | (interactive "P") |
01c52d31 | 5615 | (with-current-buffer gnus-article-buffer |
a1506d29 | 5616 | (or (numberp n) (setq n (gnus-article-mime-match-handle-first |
16409b0b GM |
5617 | gnus-article-mime-match-handle-function))) |
5618 | (when (> n (length gnus-article-mime-handle-alist)) | |
5619 | (error "No such part")) | |
5620 | (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) | |
5621 | (when (gnus-article-goto-part n) | |
5622 | (if (equal (car handle) "multipart/alternative") | |
71f56da2 KY |
5623 | (progn |
5624 | (beginning-of-line) ;; Make it toggle subparts | |
5625 | (gnus-article-press-button)) | |
16409b0b GM |
5626 | (when (eq (gnus-mm-display-part handle) 'internal) |
5627 | (gnus-set-window-start))))))) | |
5628 | ||
e0bad764 DL |
5629 | (defsubst gnus-article-mime-total-parts () |
5630 | (if (bufferp (car gnus-article-mime-handles)) | |
5631 | 1 ;; single part | |
5632 | (1- (length gnus-article-mime-handles)))) | |
5633 | ||
16409b0b GM |
5634 | (defun gnus-mm-display-part (handle) |
5635 | "Display HANDLE and fix MIME button." | |
5636 | (let ((id (get-text-property (point) 'gnus-part)) | |
5637 | (point (point)) | |
23f87bed | 5638 | (inhibit-read-only t)) |
16409b0b GM |
5639 | (forward-line 1) |
5640 | (prog1 | |
5641 | (let ((window (selected-window)) | |
5642 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5643 | (mail-parse-ignored-charsets |
23f87bed | 5644 | (if (gnus-buffer-live-p gnus-summary-buffer) |
01c52d31 | 5645 | (with-current-buffer gnus-summary-buffer |
23f87bed MB |
5646 | gnus-newsgroup-ignored-charsets) |
5647 | nil))) | |
16409b0b GM |
5648 | (save-excursion |
5649 | (unwind-protect | |
23f87bed | 5650 | (let ((win (gnus-get-buffer-window (current-buffer) t)) |
16409b0b GM |
5651 | (beg (point))) |
5652 | (when win | |
5653 | (select-window win)) | |
5654 | (goto-char point) | |
5655 | (forward-line) | |
5656 | (if (mm-handle-displayed-p handle) | |
5657 | ;; This will remove the part. | |
5658 | (mm-display-part handle) | |
4d2226bf G |
5659 | (save-window-excursion |
5660 | (save-restriction | |
5661 | (narrow-to-region (point) | |
5662 | (if (eobp) (point) (1+ (point)))) | |
5663 | (gnus-bind-safe-url-regexp (mm-display-part handle)) | |
5664 | ;; We narrow to the part itself and | |
5665 | ;; then call the treatment functions. | |
5666 | (goto-char (point-min)) | |
5667 | (forward-line 1) | |
5668 | (narrow-to-region (point) (point-max)) | |
5669 | (gnus-treat-article | |
5670 | nil id | |
5671 | (gnus-article-mime-total-parts) | |
5672 | (mm-handle-media-type handle)))))) | |
23f87bed | 5673 | (if (window-live-p window) |
4d2226bf | 5674 | (select-window window)))))))) |
16409b0b GM |
5675 | |
5676 | (defun gnus-article-goto-part (n) | |
5677 | "Go to MIME part N." | |
9efcd224 KY |
5678 | (when gnus-break-pages |
5679 | (widen)) | |
4d2226bf | 5680 | (article-goto-body) |
95de0327 | 5681 | (prog1 |
4d2226bf G |
5682 | (let ((start (or (text-property-any (point) (point-max) 'gnus-part n) |
5683 | ;; There may be header buttons. | |
5684 | (text-property-any (point-min) (point) 'gnus-part n))) | |
95de0327 KY |
5685 | part handle end next handles) |
5686 | (when start | |
5687 | (goto-char start) | |
5688 | (if (setq handle (get-text-property start 'gnus-data)) | |
5689 | start | |
5690 | ;; Go to the displayed subpart, assuming this is | |
5691 | ;; multipart/alternative. | |
5692 | (setq part start | |
5693 | end (point-at-eol)) | |
5694 | (while (and (not handle) | |
5695 | part | |
5696 | (< part end) | |
5697 | (setq next (text-property-not-all part end | |
5698 | 'gnus-data nil))) | |
5699 | (setq part next | |
5700 | handle (get-text-property part 'gnus-data)) | |
5701 | (push (cons handle part) handles) | |
5702 | (unless (mm-handle-displayed-p handle) | |
5703 | (setq handle nil | |
5704 | part (text-property-any part end 'gnus-data nil)))) | |
5705 | (unless handle | |
5706 | ;; No subpart is displayed, so we find preferred one. | |
5707 | (setq part | |
5708 | (cdr (assq (mm-preferred-alternative | |
5709 | (nreverse (mapcar 'car handles))) | |
5710 | handles)))) | |
5711 | (if part | |
5712 | (goto-char (1+ part)) | |
5713 | start)))) | |
5714 | (when gnus-break-pages | |
5715 | (gnus-narrow-to-page)))) | |
16409b0b GM |
5716 | |
5717 | (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) | |
5718 | (let ((gnus-tmp-name | |
247c22e1 | 5719 | (or (mm-handle-filename handle) |
23f87bed | 5720 | (mail-content-type-get (mm-handle-type handle) 'url) |
16409b0b GM |
5721 | "")) |
5722 | (gnus-tmp-type (mm-handle-media-type handle)) | |
4599d0ec | 5723 | (gnus-tmp-description (or (mm-handle-description handle) "")) |
16409b0b GM |
5724 | (gnus-tmp-dots |
5725 | (if (if displayed (car displayed) | |
5726 | (mm-handle-displayed-p handle)) | |
5727 | "" "...")) | |
5728 | (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle) | |
5729 | (buffer-size))) | |
5730 | gnus-tmp-type-long b e) | |
5731 | (when (string-match ".*/" gnus-tmp-name) | |
5732 | (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name))) | |
5733 | (setq gnus-tmp-type-long (concat gnus-tmp-type | |
5734 | (and (not (equal gnus-tmp-name "")) | |
5735 | (concat "; " gnus-tmp-name)))) | |
23f87bed MB |
5736 | (unless (equal gnus-tmp-description "") |
5737 | (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long))) | |
16409b0b GM |
5738 | (setq b (point)) |
5739 | (gnus-eval-format | |
5740 | gnus-mime-button-line-format gnus-mime-button-line-format-alist | |
01c52d31 MB |
5741 | `(keymap ,gnus-mime-button-map |
5742 | gnus-callback gnus-mm-display-part | |
5743 | gnus-part ,gnus-tmp-id | |
5744 | article-type annotation | |
f0867027 KY |
5745 | gnus-data ,handle |
5746 | rear-nonsticky t)) | |
23f87bed MB |
5747 | (setq e (if (bolp) |
5748 | ;; Exclude a newline. | |
5749 | (1- (point)) | |
5750 | (point))) | |
01c52d31 MB |
5751 | (when gnus-article-button-face |
5752 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
5753 | 'face gnus-article-button-face)) | |
16409b0b GM |
5754 | (widget-convert-button |
5755 | 'link b e | |
5756 | :mime-handle handle | |
5757 | :action 'gnus-widget-press-button | |
5758 | :button-keymap gnus-mime-button-map | |
5759 | :help-echo | |
5843126b | 5760 | (lambda (widget) |
16409b0b GM |
5761 | ;; Needed to properly clear the message due to a bug in |
5762 | ;; wid-edit (XEmacs only). | |
5763 | (if (boundp 'help-echo-owns-message) | |
5764 | (setq help-echo-owns-message t)) | |
5765 | (format | |
5766 | "%S: %s the MIME part; %S: more options" | |
5767 | (aref gnus-mouse-2 0) | |
5843126b | 5768 | (if (mm-handle-displayed-p (widget-get widget :mime-handle)) |
16409b0b GM |
5769 | "hide" "show") |
5770 | (aref gnus-down-mouse-3 0)))))) | |
5771 | ||
5772 | (defun gnus-widget-press-button (elems el) | |
5773 | (goto-char (widget-get elems :from)) | |
5774 | (gnus-article-press-button)) | |
5775 | ||
5776 | (defvar gnus-displaying-mime nil) | |
5777 | ||
5778 | (defun gnus-display-mime (&optional ihandles) | |
5779 | "Display the MIME parts." | |
5780 | (save-excursion | |
5781 | (save-selected-window | |
5782 | (let ((window (get-buffer-window gnus-article-buffer)) | |
5783 | (point (point))) | |
5784 | (when window | |
5785 | (select-window window) | |
5786 | ;; We have to do this since selecting the window | |
5787 | ;; may change the point. So we set the window point. | |
5788 | (set-window-point window point))) | |
73043f7d MB |
5789 | (let ((handles ihandles) |
5790 | (inhibit-read-only t) | |
5791 | handle) | |
5792 | (cond (handles) | |
5793 | ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime)) | |
5794 | (when gnus-article-emulate-mime | |
5795 | (mm-uu-dissect-text-parts handles))) | |
5796 | (gnus-article-emulate-mime | |
5797 | (setq handles (mm-uu-dissect)))) | |
16409b0b GM |
5798 | (when (and (not ihandles) |
5799 | (not gnus-displaying-mime)) | |
5800 | ;; Top-level call; we clean up. | |
5801 | (when gnus-article-mime-handles | |
5802 | (mm-destroy-parts gnus-article-mime-handles) | |
5803 | (setq gnus-article-mime-handle-alist nil));; A trick. | |
5804 | (setq gnus-article-mime-handles handles) | |
5805 | ;; We allow users to glean info from the handles. | |
5806 | (when gnus-article-mime-part-function | |
5807 | (gnus-mime-part-function handles))) | |
5808 | (if (and handles | |
5809 | (or (not (stringp (car handles))) | |
5810 | (cdr handles))) | |
5811 | (progn | |
5812 | (when (and (not ihandles) | |
5813 | (not gnus-displaying-mime)) | |
5814 | ;; Clean up for mime parts. | |
5815 | (article-goto-body) | |
5816 | (delete-region (point) (point-max))) | |
5817 | (let ((gnus-displaying-mime t)) | |
5818 | (gnus-mime-display-part handles))) | |
5819 | (save-restriction | |
5820 | (article-goto-body) | |
5821 | (narrow-to-region (point) (point-max)) | |
389b76fa | 5822 | (gnus-treat-article nil 1 1 "text/plain") |
16409b0b GM |
5823 | (widen))) |
5824 | (unless ihandles | |
5825 | ;; Highlight the headers. | |
5826 | (save-excursion | |
5827 | (save-restriction | |
5828 | (article-goto-body) | |
5829 | (narrow-to-region (point-min) (point)) | |
31640842 | 5830 | (gnus-article-save-original-date |
f362b760 MB |
5831 | (gnus-treat-article 'head))))))) |
5832 | ;; Cope with broken MIME messages. | |
5833 | (goto-char (point-max)) | |
5834 | (unless (bolp) | |
5835 | (insert "\n")))) | |
16409b0b | 5836 | |
23f87bed MB |
5837 | (defcustom gnus-mime-display-multipart-as-mixed nil |
5838 | "Display \"multipart\" parts as \"multipart/mixed\". | |
5839 | ||
5840 | If t, it overrides nil values of | |
5841 | `gnus-mime-display-multipart-alternative-as-mixed' and | |
5842 | `gnus-mime-display-multipart-related-as-mixed'." | |
5843 | :group 'gnus-article-mime | |
5844 | :type 'boolean) | |
5845 | ||
5846 | (defcustom gnus-mime-display-multipart-alternative-as-mixed nil | |
5847 | "Display \"multipart/alternative\" parts as \"multipart/mixed\"." | |
bf247b6e | 5848 | :version "22.1" |
23f87bed MB |
5849 | :group 'gnus-article-mime |
5850 | :type 'boolean) | |
5851 | ||
5852 | (defcustom gnus-mime-display-multipart-related-as-mixed nil | |
5853 | "Display \"multipart/related\" parts as \"multipart/mixed\". | |
5854 | ||
5855 | If displaying \"text/html\" is discouraged \(see | |
5856 | `mm-discouraged-alternatives'\) images or other material inside a | |
5857 | \"multipart/related\" part might be overlooked when this variable is nil." | |
bf247b6e | 5858 | :version "22.1" |
23f87bed MB |
5859 | :group 'gnus-article-mime |
5860 | :type 'boolean) | |
16409b0b | 5861 | |
4d2226bf G |
5862 | (defcustom gnus-mime-display-attachment-buttons-in-header t |
5863 | "Add attachment buttons in the end of the header of an article. | |
5864 | Since MIME attachments tend to be put at the end of an article, we may | |
5865 | overlook them if there is a huge body. This option offers you a copy | |
5866 | of all non-inlinable MIME parts as buttons shown in front of an article. | |
5867 | If nil, don't show those extra buttons." | |
5868 | :version "24.5" | |
5869 | :group 'gnus-article | |
5870 | :type 'boolean) | |
5871 | ||
16409b0b GM |
5872 | (defun gnus-mime-display-part (handle) |
5873 | (cond | |
430d3ed7 MB |
5874 | ;; Maybe a broken MIME message. |
5875 | ((null handle)) | |
16409b0b GM |
5876 | ;; Single part. |
5877 | ((not (stringp (car handle))) | |
5878 | (gnus-mime-display-single handle)) | |
5879 | ;; User-defined multipart | |
5880 | ((cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
5881 | (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
5882 | handle)) | |
5883 | ;; multipart/alternative | |
5884 | ((and (equal (car handle) "multipart/alternative") | |
23f87bed MB |
5885 | (not (or gnus-mime-display-multipart-as-mixed |
5886 | gnus-mime-display-multipart-alternative-as-mixed))) | |
16409b0b GM |
5887 | (let ((id (1+ (length gnus-article-mime-handle-alist)))) |
5888 | (push (cons id handle) gnus-article-mime-handle-alist) | |
5889 | (gnus-mime-display-alternative (cdr handle) nil nil id))) | |
5890 | ;; multipart/related | |
5891 | ((and (equal (car handle) "multipart/related") | |
23f87bed MB |
5892 | (not (or gnus-mime-display-multipart-as-mixed |
5893 | gnus-mime-display-multipart-related-as-mixed))) | |
16409b0b | 5894 | (gnus-mime-display-part (cadr handle))) |
23f87bed MB |
5895 | ((equal (car handle) "multipart/signed") |
5896 | (gnus-add-wash-type 'signed) | |
5897 | (gnus-mime-display-security handle)) | |
5898 | ((equal (car handle) "multipart/encrypted") | |
5899 | (gnus-add-wash-type 'encrypted) | |
5900 | (gnus-mime-display-security handle)) | |
16409b0b GM |
5901 | ;; Other multiparts are handled like multipart/mixed. |
5902 | (t | |
5903 | (gnus-mime-display-mixed (cdr handle))))) | |
5904 | ||
5905 | (defun gnus-mime-part-function (handles) | |
5906 | (if (stringp (car handles)) | |
5907 | (mapcar 'gnus-mime-part-function (cdr handles)) | |
5908 | (funcall gnus-article-mime-part-function handles))) | |
5909 | ||
5910 | (defun gnus-mime-display-mixed (handles) | |
5911 | (mapcar 'gnus-mime-display-part handles)) | |
5912 | ||
5913 | (defun gnus-mime-display-single (handle) | |
5914 | (let ((type (mm-handle-media-type handle)) | |
5915 | (ignored gnus-ignored-mime-types) | |
5916 | (not-attachment t) | |
5917 | (move nil) | |
5918 | display text) | |
5919 | (catch 'ignored | |
5920 | (progn | |
5921 | (while ignored | |
5922 | (when (string-match (pop ignored) type) | |
5923 | (throw 'ignored nil))) | |
b59a9eef KY |
5924 | (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer) |
5925 | (with-current-buffer gnus-summary-buffer | |
5926 | gnus-inhibit-images) | |
5927 | gnus-inhibit-images) | |
40de2c6d KY |
5928 | (string-match "\\`image/" type))) |
5929 | (setq not-attachment | |
16409b0b GM |
5930 | (and (not (mm-inline-override-p handle)) |
5931 | (or (not (mm-handle-disposition handle)) | |
5932 | (equal (car (mm-handle-disposition handle)) | |
5933 | "inline") | |
5934 | (mm-attachment-override-p handle)))) | |
5935 | (mm-automatic-display-p handle) | |
23f87bed MB |
5936 | (or (and |
5937 | (mm-inlinable-p handle) | |
5938 | (mm-inlined-p handle)) | |
16409b0b GM |
5939 | (mm-automatic-external-display-p type))) |
5940 | (setq display t) | |
5941 | (when (equal (mm-handle-media-supertype handle) "text") | |
5942 | (setq text t))) | |
e0bad764 DL |
5943 | (let ((id (1+ (length gnus-article-mime-handle-alist))) |
5944 | beg) | |
16409b0b | 5945 | (push (cons id handle) gnus-article-mime-handle-alist) |
531bedc3 MB |
5946 | (when (and display |
5947 | (equal (mm-handle-media-supertype handle) "message")) | |
5948 | (insert-char | |
5949 | ?\n | |
5950 | (cond ((not (bolp)) 2) | |
5951 | ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0) | |
5952 | (t 1)))) | |
16409b0b | 5953 | (when (or (not display) |
3e3ab3ab KY |
5954 | (not (gnus-unbuttonized-mime-type-p type)) |
5955 | (eq id gnus-mime-buttonized-part-id)) | |
16409b0b GM |
5956 | (gnus-insert-mime-button |
5957 | handle id (list (or display (and not-attachment text)))) | |
5958 | (gnus-article-insert-newline) | |
23f87bed | 5959 | ;; Remember modify the number of forward lines. |
e0bad764 DL |
5960 | (setq move t)) |
5961 | (setq beg (point)) | |
16409b0b GM |
5962 | (cond |
5963 | (display | |
5964 | (when move | |
23f87bed | 5965 | (forward-line -1) |
16409b0b GM |
5966 | (setq beg (point))) |
5967 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5968 | (mail-parse-ignored-charsets |
16409b0b GM |
5969 | (save-excursion (condition-case () |
5970 | (set-buffer gnus-summary-buffer) | |
5971 | (error)) | |
5972 | gnus-newsgroup-ignored-charsets))) | |
b0b63450 | 5973 | (gnus-bind-safe-url-regexp (mm-display-part handle t))) |
16409b0b GM |
5974 | (goto-char (point-max))) |
5975 | ((and text not-attachment) | |
5976 | (when move | |
23f87bed | 5977 | (forward-line -1) |
16409b0b GM |
5978 | (setq beg (point))) |
5979 | (gnus-article-insert-newline) | |
f205c6e7 | 5980 | (mm-display-inline handle) |
16409b0b GM |
5981 | (goto-char (point-max)))) |
5982 | ;; Do highlighting. | |
5983 | (save-excursion | |
5984 | (save-restriction | |
5985 | (narrow-to-region beg (point)) | |
01c52d31 MB |
5986 | (if (eq handle gnus-article-mime-handles) |
5987 | ;; The format=flowed case. | |
5988 | (gnus-treat-article nil 1 1 (mm-handle-media-type handle)) | |
5989 | ;; Don't count signature parts that are never displayed. | |
5990 | ;; The part number should be re-calculated supposing this | |
5991 | ;; might be a message/rfc822 part. | |
5992 | (let (handles) | |
5993 | (dolist (part gnus-article-mime-handles) | |
5994 | (unless (or (stringp part) | |
5995 | (equal (car (mm-handle-type part)) | |
5996 | "application/pgp-signature")) | |
5997 | (push part handles))) | |
5998 | (gnus-treat-article | |
5999 | nil (length (memq handle handles)) (length handles) | |
6000 | (mm-handle-media-type handle))))))))))) | |
16409b0b GM |
6001 | |
6002 | (defun gnus-unbuttonized-mime-type-p (type) | |
6003 | "Say whether TYPE is to be unbuttonized." | |
6004 | (unless gnus-inhibit-mime-unbuttonizing | |
23f87bed MB |
6005 | (when (catch 'found |
6006 | (let ((types gnus-unbuttonized-mime-types)) | |
6007 | (while types | |
6008 | (when (string-match (pop types) type) | |
6009 | (throw 'found t))))) | |
6010 | (not (catch 'found | |
6011 | (let ((types gnus-buttonized-mime-types)) | |
6012 | (while types | |
6013 | (when (string-match (pop types) type) | |
6014 | (throw 'found t))))))))) | |
16409b0b GM |
6015 | |
6016 | (defun gnus-article-insert-newline () | |
6017 | "Insert a newline, but mark it as undeletable." | |
6018 | (gnus-put-text-property | |
6019 | (point) (progn (insert "\n") (point)) 'gnus-undeletable t)) | |
6020 | ||
6021 | (defun gnus-mime-display-alternative (handles &optional preferred ibegend id) | |
6022 | (let* ((preferred (or preferred (mm-preferred-alternative handles))) | |
6023 | (ihandles handles) | |
6024 | (point (point)) | |
23f87bed | 6025 | handle (inhibit-read-only t) from props begend not-pref) |
16409b0b GM |
6026 | (save-window-excursion |
6027 | (save-restriction | |
6028 | (when ibegend | |
6029 | (narrow-to-region (car ibegend) | |
6030 | (or (cdr ibegend) | |
6031 | (progn | |
6032 | (goto-char (car ibegend)) | |
6033 | (forward-line 2) | |
6034 | (point)))) | |
6035 | (delete-region (point-min) (point-max)) | |
6036 | (mm-remove-parts handles)) | |
6037 | (setq begend (list (point-marker))) | |
6038 | ;; Do the toggle. | |
6039 | (unless (setq not-pref (cadr (member preferred ihandles))) | |
6040 | (setq not-pref (car ihandles))) | |
6041 | (when (or ibegend | |
23f87bed | 6042 | (not preferred) |
16409b0b GM |
6043 | (not (gnus-unbuttonized-mime-type-p |
6044 | "multipart/alternative"))) | |
6045 | (gnus-add-text-properties | |
6046 | (setq from (point)) | |
6047 | (progn | |
6048 | (insert (format "%d. " id)) | |
6049 | (point)) | |
6050 | `(gnus-callback | |
6051 | (lambda (handles) | |
6052 | (unless ,(not ibegend) | |
6053 | (setq gnus-article-mime-handle-alist | |
6054 | ',gnus-article-mime-handle-alist)) | |
6055 | (gnus-mime-display-alternative | |
6056 | ',ihandles ',not-pref ',begend ,id)) | |
01c52d31 | 6057 | keymap ,gnus-mime-button-map |
16409b0b GM |
6058 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
6059 | face ,gnus-article-button-face | |
16409b0b | 6060 | gnus-part ,id |
f0867027 KY |
6061 | article-type multipart |
6062 | rear-nonsticky t)) | |
16409b0b GM |
6063 | (widget-convert-button 'link from (point) |
6064 | :action 'gnus-widget-press-button | |
6065 | :button-keymap gnus-widget-button-keymap) | |
6066 | ;; Do the handles | |
6067 | (while (setq handle (pop handles)) | |
6068 | (gnus-add-text-properties | |
6069 | (setq from (point)) | |
6070 | (progn | |
6071 | (insert (format "(%c) %-18s" | |
6072 | (if (equal handle preferred) ?* ? ) | |
6073 | (mm-handle-media-type handle))) | |
6074 | (point)) | |
6075 | `(gnus-callback | |
6076 | (lambda (handles) | |
6077 | (unless ,(not ibegend) | |
6078 | (setq gnus-article-mime-handle-alist | |
6079 | ',gnus-article-mime-handle-alist)) | |
6080 | (gnus-mime-display-alternative | |
6081 | ',ihandles ',handle ',begend ,id)) | |
01c52d31 | 6082 | keymap ,gnus-mime-button-map |
16409b0b GM |
6083 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
6084 | face ,gnus-article-button-face | |
16409b0b | 6085 | gnus-part ,id |
f0867027 KY |
6086 | gnus-data ,handle |
6087 | rear-nonsticky t)) | |
16409b0b GM |
6088 | (widget-convert-button 'link from (point) |
6089 | :action 'gnus-widget-press-button | |
6090 | :button-keymap gnus-widget-button-keymap) | |
6091 | (insert " ")) | |
6092 | (insert "\n\n")) | |
6093 | (when preferred | |
6094 | (if (stringp (car preferred)) | |
6095 | (gnus-display-mime preferred) | |
6096 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 6097 | (mail-parse-ignored-charsets |
01c52d31 MB |
6098 | (with-current-buffer gnus-summary-buffer |
6099 | gnus-newsgroup-ignored-charsets))) | |
b0b63450 | 6100 | (gnus-bind-safe-url-regexp (mm-display-part preferred)) |
16409b0b GM |
6101 | ;; Do highlighting. |
6102 | (save-excursion | |
6103 | (save-restriction | |
6104 | (narrow-to-region (car begend) (point-max)) | |
6105 | (gnus-treat-article | |
6106 | nil (length gnus-article-mime-handle-alist) | |
e0bad764 | 6107 | (gnus-article-mime-total-parts) |
389b76fa | 6108 | (mm-handle-media-type preferred)))))) |
16409b0b GM |
6109 | (goto-char (point-max)) |
6110 | (setcdr begend (point-marker))))) | |
6111 | (when ibegend | |
4d2226bf G |
6112 | (goto-char point))) |
6113 | ;; Redraw attachment buttons in the header. | |
6114 | (when gnus-mime-display-attachment-buttons-in-header | |
6115 | (gnus-mime-buttonize-attachments-in-header))) | |
16409b0b | 6116 | |
23f87bed MB |
6117 | (defconst gnus-article-wash-status-strings |
6118 | (let ((alist '((cite "c" "Possible hidden citation text" | |
6119 | " " "All citation text visible") | |
6120 | (headers "h" "Hidden headers" | |
6121 | " " "All headers visible.") | |
6122 | (pgp "p" "Encrypted or signed message status hidden" | |
6123 | " " "No hidden encryption nor digital signature status") | |
6124 | (signature "s" "Signature has been hidden" | |
6125 | " " "Signature is visible") | |
6126 | (overstrike "o" "Overstrike (^H) characters applied" | |
6127 | " " "No overstrike characters applied") | |
6128 | (emphasis "e" "/*_Emphasis_*/ characters applied" | |
6129 | " " "No /*_emphasis_*/ characters applied"))) | |
6130 | result) | |
6131 | (dolist (entry alist result) | |
6132 | (let ((key (nth 0 entry)) | |
6133 | (on (copy-sequence (nth 1 entry))) | |
6134 | (on-help (nth 2 entry)) | |
6135 | (off (copy-sequence (nth 3 entry))) | |
6136 | (off-help (nth 4 entry))) | |
6137 | (put-text-property 0 1 'help-echo on-help on) | |
6138 | (put-text-property 0 1 'help-echo off-help off) | |
6139 | (push (list key on off) result)))) | |
6140 | "Alist of strings describing wash status in the mode line. | |
6141 | Each entry has the form (KEY ON OF), where the KEY is a symbol | |
6142 | representing the particular washing function, ON is the string to use | |
6143 | in the article mode line when the washing function is active, and OFF | |
6144 | is the string to use when it is inactive.") | |
6145 | ||
6146 | (defun gnus-article-wash-status-entry (key value) | |
6147 | (let ((entry (assoc key gnus-article-wash-status-strings))) | |
6148 | (if value (nth 1 entry) (nth 2 entry)))) | |
6149 | ||
eec82323 LMI |
6150 | (defun gnus-article-wash-status () |
6151 | "Return a string which display status of article washing." | |
01c52d31 | 6152 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
6153 | (let ((cite (memq 'cite gnus-article-wash-types)) |
6154 | (headers (memq 'headers gnus-article-wash-types)) | |
6155 | (boring (memq 'boring-headers gnus-article-wash-types)) | |
6156 | (pgp (memq 'pgp gnus-article-wash-types)) | |
6157 | (pem (memq 'pem gnus-article-wash-types)) | |
23f87bed MB |
6158 | (signed (memq 'signed gnus-article-wash-types)) |
6159 | (encrypted (memq 'encrypted gnus-article-wash-types)) | |
16409b0b GM |
6160 | (signature (memq 'signature gnus-article-wash-types)) |
6161 | (overstrike (memq 'overstrike gnus-article-wash-types)) | |
6162 | (emphasis (memq 'emphasis gnus-article-wash-types))) | |
23f87bed MB |
6163 | (concat |
6164 | (gnus-article-wash-status-entry 'cite cite) | |
6165 | (gnus-article-wash-status-entry 'headers (or headers boring)) | |
6166 | (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted)) | |
6167 | (gnus-article-wash-status-entry 'signature signature) | |
6168 | (gnus-article-wash-status-entry 'overstrike overstrike) | |
6169 | (gnus-article-wash-status-entry 'emphasis emphasis))))) | |
6170 | ||
6171 | (defun gnus-add-wash-type (type) | |
6172 | "Add a washing of TYPE to the current status." | |
6173 | (add-to-list 'gnus-article-wash-types type)) | |
6174 | ||
6175 | (defun gnus-delete-wash-type (type) | |
6176 | "Add a washing of TYPE to the current status." | |
6177 | (setq gnus-article-wash-types (delq type gnus-article-wash-types))) | |
6178 | ||
6179 | (defun gnus-add-image (category image) | |
6180 | "Add IMAGE of CATEGORY to the list of displayed images." | |
6181 | (let ((entry (assq category gnus-article-image-alist))) | |
6182 | (unless entry | |
6183 | (setq entry (list category)) | |
6184 | (push entry gnus-article-image-alist)) | |
6185 | (nconc entry (list image)))) | |
6186 | ||
6187 | (defun gnus-delete-images (category) | |
6188 | "Delete all images in CATEGORY." | |
6189 | (let ((entry (assq category gnus-article-image-alist))) | |
6190 | (dolist (image (cdr entry)) | |
6191 | (gnus-remove-image image category)) | |
6192 | (setq gnus-article-image-alist (delq entry gnus-article-image-alist)) | |
6193 | (gnus-delete-wash-type category))) | |
eec82323 | 6194 | |
16409b0b | 6195 | (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers) |
6748645f LMI |
6196 | |
6197 | (defun gnus-article-maybe-hide-headers () | |
eec82323 LMI |
6198 | "Hide unwanted headers if `gnus-have-all-headers' is nil. |
6199 | Provided for backwards compatibility." | |
16409b0b | 6200 | (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer)) |
01c52d31 MB |
6201 | (not (with-current-buffer gnus-summary-buffer |
6202 | gnus-have-all-headers))) | |
16409b0b GM |
6203 | (not gnus-inhibit-hiding)) |
6204 | (gnus-article-hide-headers))) | |
eec82323 | 6205 | |
89b163db | 6206 | (declare-function shr-put-image "shr" (data alt &optional flags)) |
b9bdaf74 | 6207 | |
89b163db | 6208 | (defun gnus-shr-put-image (data alt &optional flags) |
b9bdaf74 | 6209 | "Put image DATA with a string ALT. Enable image to be deleted." |
abd2f2a4 KY |
6210 | (let ((image (if flags |
6211 | (shr-put-image data (propertize (or alt "*") | |
6212 | 'gnus-image-category 'shr) | |
6213 | flags) | |
6214 | ;; Old `shr-put-image' doesn't take the optional `flags' | |
6215 | ;; argument. | |
6216 | (shr-put-image data (propertize (or alt "*") | |
6217 | 'gnus-image-category 'shr))))) | |
b9bdaf74 KY |
6218 | (when image |
6219 | (gnus-add-image 'shr image)))) | |
6220 | ||
4d2226bf G |
6221 | (defun gnus-mime-buttonize-attachments-in-header (&optional interactive) |
6222 | "Show attachments as buttons in the end of the header of an article. | |
6223 | This function toggles the display when called interactively. Note that | |
6224 | buttons to be added to the header are only the ones that aren't inlined | |
6225 | in the body. Use `gnus-header-face-alist' to highlight buttons." | |
6226 | (interactive (list t)) | |
6227 | (gnus-with-article-buffer | |
6228 | (gmm-labels | |
6229 | ;; Function that returns a flattened version of | |
6230 | ;; `gnus-article-mime-handle-alist'. | |
6231 | ((flattened-alist | |
6232 | (&optional alist id all) | |
6233 | (if alist | |
6234 | (let ((i 1) newid flat) | |
6235 | (dolist (handle alist flat) | |
6236 | (setq newid (append id (list i)) | |
6237 | i (1+ i)) | |
6238 | (if (stringp (car handle)) | |
6239 | (setq flat (nconc flat (flattened-alist (cdr handle) | |
6240 | newid all))) | |
6241 | (delq (rassq handle all) all) | |
6242 | (setq flat (nconc flat (list (cons newid handle))))))) | |
6243 | (let ((flat (list nil))) | |
6244 | ;; Assume that elements of `gnus-article-mime-handle-alist' | |
6245 | ;; are in the decreasing order, but unnumbered subsidiaries | |
6246 | ;; in each element are in the increasing order. | |
6247 | (dolist (handle (reverse gnus-article-mime-handle-alist)) | |
6248 | (if (stringp (cadr handle)) | |
6249 | (setq flat (nconc flat (flattened-alist (cddr handle) | |
6250 | (list (car handle)) | |
6251 | flat))) | |
6252 | (delq (rassq (cdr handle) flat) flat) | |
6253 | (setq flat (nconc flat (list (cons (list (car handle)) | |
6254 | (cdr handle))))))) | |
6255 | (setq flat (cdr flat)) | |
6256 | (mapc (lambda (handle) | |
6257 | (if (cdar handle) | |
6258 | ;; This is a hidden (i.e. unnumbered) handle. | |
6259 | (progn | |
6260 | (setcar handle | |
6261 | (1+ (caar gnus-article-mime-handle-alist))) | |
6262 | (push handle gnus-article-mime-handle-alist)) | |
6263 | (setcar handle (caar handle)))) | |
6264 | flat) | |
6265 | flat)))) | |
6266 | (let ((case-fold-search t) buttons st) | |
6267 | (save-excursion | |
6268 | (save-restriction | |
6269 | (widen) | |
6270 | (article-narrow-to-head) | |
6271 | ;; Header buttons exist? | |
6272 | (while (and (not buttons) | |
6273 | (re-search-forward "^attachments?:[\n ]+" nil t)) | |
6274 | (when (get-char-property (match-end 0) | |
6275 | 'gnus-button-attachment-extra) | |
6276 | (setq buttons (match-beginning 0)))) | |
6277 | (widen) | |
6278 | (when buttons | |
6279 | ;; Delete header buttons. | |
6280 | (delete-region buttons (if (re-search-forward "^[^ ]" nil t) | |
6281 | (match-beginning 0) | |
6282 | (point-max)))) | |
6283 | (unless (and interactive buttons) | |
6284 | ;; Find buttons. | |
6285 | (setq buttons nil) | |
6286 | (dolist (handle (flattened-alist)) | |
6287 | (when (and (not (stringp (cadr handle))) | |
6288 | (or (equal (car (mm-handle-disposition | |
6289 | (cdr handle))) | |
6290 | "attachment") | |
6291 | (not (and (mm-inlinable-p (cdr handle)) | |
6292 | (mm-inlined-p (cdr handle)))))) | |
6293 | (push handle buttons))) | |
6294 | (when buttons | |
6295 | ;; Add header buttons. | |
6296 | (article-goto-body) | |
6297 | (forward-line -1) | |
6298 | (narrow-to-region (point) (point)) | |
6299 | (insert "Attachment" (if (cdr buttons) "s" "") ":") | |
6300 | (dolist (button (nreverse buttons)) | |
6301 | (setq st (point)) | |
6302 | (insert " ") | |
6303 | (gnus-insert-mime-button (cdr button) (car button)) | |
6304 | (skip-chars-backward "\t\n ") | |
6305 | (delete-region (point) (point-max)) | |
6306 | (when (> (current-column) (window-width)) | |
6307 | (goto-char st) | |
6308 | (insert "\n") | |
6309 | (end-of-line))) | |
6310 | (insert "\n") | |
6311 | (dolist (ovl (gnus-overlays-in (point-min) (point))) | |
6312 | (gnus-overlay-put ovl 'gnus-button-attachment-extra t) | |
6313 | (gnus-overlay-put ovl 'face nil)) | |
6314 | (let ((gnus-treatment-function-alist | |
6315 | '((gnus-treat-highlight-headers | |
6316 | gnus-article-highlight-headers)))) | |
6317 | (gnus-treat-article 'head)))))))))) | |
6318 | ||
eec82323 LMI |
6319 | ;;; Article savers. |
6320 | ||
6321 | (defun gnus-output-to-file (file-name) | |
26c9afc3 MB |
6322 | "Append the current article to a file named FILE-NAME. |
6323 | If `gnus-article-save-coding-system' is non-nil, it is used to encode | |
6324 | text and used as the value of the coding cookie which is added to the | |
6325 | top of a file. Otherwise, this function saves a raw article without | |
6326 | the coding cookie." | |
6327 | (let* ((artbuf (current-buffer)) | |
6328 | (file-name-coding-system nnmail-pathname-coding-system) | |
6329 | (coding gnus-article-save-coding-system) | |
6330 | (coding-system-for-read (if coding | |
6331 | nil ;; Rely on the coding cookie. | |
6332 | mm-text-coding-system)) | |
6333 | (coding-system-for-write (or coding | |
6334 | mm-text-coding-system-for-write | |
6335 | mm-text-coding-system)) | |
6336 | (exists (file-exists-p file-name))) | |
16409b0b | 6337 | (with-temp-buffer |
26c9afc3 MB |
6338 | (when exists |
6339 | (insert-file-contents file-name) | |
6340 | (goto-char (point-min)) | |
6341 | ;; Remove the existing coding cookie. | |
6342 | (when (looking-at "X-Gnus-Coding-System: .+\n\n") | |
6343 | (delete-region (match-beginning 0) (match-end 0)))) | |
6344 | (goto-char (point-max)) | |
eec82323 LMI |
6345 | (insert-buffer-substring artbuf) |
6346 | ;; Append newline at end of the buffer as separator, and then | |
6347 | ;; save it to file. | |
6348 | (goto-char (point-max)) | |
6349 | (insert "\n") | |
26c9afc3 MB |
6350 | (when coding |
6351 | ;; If the coding system is not suitable to encode the text, | |
6352 | ;; ask a user for a proper one. | |
6353 | (when (fboundp 'select-safe-coding-system) | |
6354 | (setq coding (coding-system-base | |
6355 | (save-window-excursion | |
6356 | (select-safe-coding-system (point-min) (point-max) | |
6357 | coding)))) | |
6358 | (setq coding-system-for-write | |
6359 | (or (cdr (assq coding '((mule-utf-8 . utf-8)))) | |
6360 | coding))) | |
6361 | (goto-char (point-min)) | |
6362 | ;; Add the coding cookie. | |
6363 | (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n" | |
6364 | coding-system-for-write))) | |
6365 | (if exists | |
6366 | (progn | |
6367 | (write-region (point-min) (point-max) file-name nil 'no-message) | |
6368 | (message "Appended to %s" file-name)) | |
6369 | (write-region (point-min) (point-max) file-name)))) | |
6370 | t) | |
eec82323 LMI |
6371 | |
6372 | (defun gnus-narrow-to-page (&optional arg) | |
6373 | "Narrow the article buffer to a page. | |
6374 | If given a numerical ARG, move forward ARG pages." | |
6375 | (interactive "P") | |
6376 | (setq arg (if arg (prefix-numeric-value arg) 0)) | |
80de1778 | 6377 | (with-current-buffer gnus-article-buffer |
eec82323 LMI |
6378 | (widen) |
6379 | ;; Remove any old next/prev buttons. | |
6380 | (when (gnus-visual-p 'page-marker) | |
4e7d0221 | 6381 | (let ((inhibit-read-only t)) |
eec82323 LMI |
6382 | (gnus-remove-text-with-property 'gnus-prev) |
6383 | (gnus-remove-text-with-property 'gnus-next))) | |
8f7abae3 MB |
6384 | (let (st nd pt) |
6385 | (when (save-excursion | |
6386 | (cond ((< arg 0) | |
6387 | (if (re-search-backward page-delimiter nil 'move (abs arg)) | |
6388 | (prog1 | |
6389 | (setq nd (match-beginning 0) | |
6390 | pt nd) | |
6391 | (when (re-search-backward page-delimiter nil t) | |
6392 | (setq st (match-end 0)))) | |
6393 | (when (re-search-forward page-delimiter nil t) | |
6394 | (setq nd (match-beginning 0) | |
6395 | pt (point-min))))) | |
6396 | ((> arg 0) | |
6397 | (if (re-search-forward page-delimiter nil 'move arg) | |
6398 | (prog1 | |
6399 | (setq st (match-end 0) | |
6400 | pt st) | |
6401 | (when (re-search-forward page-delimiter nil t) | |
6402 | (setq nd (match-beginning 0)))) | |
6403 | (when (re-search-backward page-delimiter nil t) | |
6404 | (setq st (match-end 0) | |
6405 | pt (point-max))))) | |
6406 | (t | |
6407 | (when (re-search-backward page-delimiter nil t) | |
6408 | (goto-char (setq st (match-end 0)))) | |
6409 | (when (re-search-forward page-delimiter nil t) | |
6410 | (setq nd (match-beginning 0))) | |
6411 | (or st nd)))) | |
6412 | (setq gnus-page-broken t) | |
6413 | (when pt (goto-char pt)) | |
6414 | (narrow-to-region (or st (point-min)) (or nd (point-max))) | |
6415 | (when (gnus-visual-p 'page-marker) | |
6416 | (save-excursion | |
6417 | (when nd | |
6418 | (goto-char nd) | |
6419 | (gnus-insert-next-page-button)) | |
6420 | (when st | |
6421 | (goto-char st) | |
6422 | (gnus-insert-prev-page-button)))))))) | |
eec82323 LMI |
6423 | |
6424 | ;; Article mode commands | |
6425 | ||
6426 | (defun gnus-article-goto-next-page () | |
6427 | "Show the next page of the article." | |
6428 | (interactive) | |
6429 | (when (gnus-article-next-page) | |
6430 | (goto-char (point-min)) | |
6431 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
6432 | ||
23f87bed | 6433 | |
eec82323 | 6434 | (defun gnus-article-goto-prev-page () |
23f87bed | 6435 | "Show the previous page of the article." |
eec82323 | 6436 | (interactive) |
8f7abae3 | 6437 | (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer? |
23f87bed | 6438 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?p)) |
eec82323 LMI |
6439 | (gnus-article-prev-page nil))) |
6440 | ||
23f87bed MB |
6441 | ;; This is cleaner but currently breaks `gnus-pick-mode': |
6442 | ;; | |
6443 | ;; (defun gnus-article-goto-next-page () | |
6444 | ;; "Show the next page of the article." | |
6445 | ;; (interactive) | |
6446 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer | |
6447 | ;; (gnus-summary-next-page))) | |
6448 | ;; | |
6449 | ;; (defun gnus-article-goto-prev-page () | |
6450 | ;; "Show the next page of the article." | |
6451 | ;; (interactive) | |
6452 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer | |
6453 | ;; (gnus-summary-prev-page))) | |
6454 | ||
eec82323 LMI |
6455 | (defun gnus-article-next-page (&optional lines) |
6456 | "Show the next page of the current article. | |
6457 | If end of article, return non-nil. Otherwise return nil. | |
6458 | Argument LINES specifies lines to be scrolled up." | |
6459 | (interactive "p") | |
9153f10d | 6460 | (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin))) |
60ece9b0 MB |
6461 | (if (and (not (and gnus-article-over-scroll |
6462 | (> (count-lines (window-start) (point-max)) | |
9153f10d MB |
6463 | (if (featurep 'xemacs) |
6464 | (or lines (1- (window-height))) | |
6465 | (+ (or lines (1- (window-height))) scroll-margin))))) | |
60ece9b0 MB |
6466 | (save-excursion |
6467 | (end-of-line) | |
6468 | (and (pos-visible-in-window-p) ;Not continuation line. | |
647559c2 | 6469 | (>= (point) (point-max))))) |
eec82323 LMI |
6470 | ;; Nothing in this page. |
6471 | (if (or (not gnus-page-broken) | |
6472 | (save-excursion | |
6473 | (save-restriction | |
23f87bed MB |
6474 | (widen) |
6475 | (forward-line) | |
6476 | (eobp)))) ;Real end-of-buffer? | |
6477 | (progn | |
6478 | (when gnus-article-over-scroll | |
6479 | (gnus-article-next-page-1 lines)) | |
6480 | t) ;Nothing more. | |
eec82323 LMI |
6481 | (gnus-narrow-to-page 1) ;Go to next page. |
6482 | nil) | |
6483 | ;; More in this page. | |
23f87bed | 6484 | (gnus-article-next-page-1 lines) |
eec82323 LMI |
6485 | nil)) |
6486 | ||
b1992461 | 6487 | (defun gnus-article-beginning-of-window () |
d8a88581 MB |
6488 | "Move point to the beginning of the window. |
6489 | In Emacs, the point is placed at the line number which `scroll-margin' | |
6490 | specifies." | |
6491 | (if (featurep 'xemacs) | |
b1992461 KY |
6492 | (move-to-window-line 0) |
6493 | ;; There is an obscure bug in Emacs that makes it impossible to | |
6494 | ;; scroll past big pictures in the article buffer. Try to fix | |
6495 | ;; this by adding a sanity check by counting the lines visible. | |
6496 | (when (> (count-lines (window-start) (window-end)) 30) | |
6497 | (move-to-window-line | |
6498 | (min (max 0 scroll-margin) | |
6499 | (max 1 (- (window-height) | |
6500 | (if mode-line-format 1 0) | |
6501 | (if header-line-format 1 0) | |
6502 | 2))))))) | |
d8a88581 | 6503 | |
23f87bed | 6504 | (defun gnus-article-next-page-1 (lines) |
4b91459a | 6505 | (condition-case () |
01baa1e6 G |
6506 | (let ((scroll-in-place nil) |
6507 | (auto-window-vscroll nil)) | |
4b91459a MB |
6508 | (scroll-up lines)) |
6509 | (end-of-buffer | |
6510 | ;; Long lines may cause an end-of-buffer error. | |
6511 | (goto-char (point-max)))) | |
6512 | (gnus-article-beginning-of-window)) | |
23f87bed | 6513 | |
eec82323 LMI |
6514 | (defun gnus-article-prev-page (&optional lines) |
6515 | "Show previous page of current article. | |
6516 | Argument LINES specifies lines to be scrolled down." | |
6517 | (interactive "p") | |
d8a88581 | 6518 | (move-to-window-line 0) |
eec82323 LMI |
6519 | (if (and gnus-page-broken |
6520 | (bobp) | |
6521 | (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
6522 | (progn | |
6523 | (gnus-narrow-to-page -1) ;Go to previous page. | |
6524 | (goto-char (point-max)) | |
60ece9b0 MB |
6525 | (recenter (if gnus-article-over-scroll |
6526 | (if lines | |
9153f10d MB |
6527 | (max (if (featurep 'xemacs) |
6528 | lines | |
6529 | (+ lines scroll-margin)) | |
60ece9b0 MB |
6530 | 3) |
6531 | (- (window-height) 2)) | |
6532 | -1))) | |
c03ac728 MB |
6533 | (prog1 |
6534 | (condition-case () | |
6535 | (let ((scroll-in-place nil)) | |
6536 | (scroll-down lines)) | |
6537 | (beginning-of-buffer | |
6538 | (goto-char (point-min)))) | |
6539 | (gnus-article-beginning-of-window)))) | |
eec82323 | 6540 | |
23f87bed MB |
6541 | (defun gnus-article-only-boring-p () |
6542 | "Decide whether there is only boring text remaining in the article. | |
6543 | Something \"interesting\" is a word of at least two letters that does | |
6544 | not have a face in `gnus-article-boring-faces'." | |
6545 | (when (and gnus-article-skip-boring | |
6546 | (boundp 'gnus-article-boring-faces) | |
6547 | (symbol-value 'gnus-article-boring-faces)) | |
6548 | (save-excursion | |
531bedc3 MB |
6549 | (let ((inhibit-point-motion-hooks t)) |
6550 | (catch 'only-boring | |
6551 | (while (re-search-forward "\\b\\w\\w" nil t) | |
6552 | (forward-char -1) | |
6553 | (when (not (gnus-intersection | |
6554 | (gnus-faces-at (point)) | |
6555 | (symbol-value 'gnus-article-boring-faces))) | |
6556 | (throw 'only-boring nil))) | |
6557 | (throw 'only-boring t)))))) | |
23f87bed | 6558 | |
eec82323 LMI |
6559 | (defun gnus-article-refer-article () |
6560 | "Read article specified by message-id around point." | |
6561 | (interactive) | |
23f87bed | 6562 | (save-excursion |
01c52d31 MB |
6563 | (re-search-backward "[ \t]\\|^" (point-at-bol) t) |
6564 | (re-search-forward "<?news:<?\\|<" (point-at-eol) t) | |
6565 | (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t) | |
23f87bed | 6566 | (let ((msg-id (concat "<" (match-string 0) ">"))) |
eec82323 | 6567 | (set-buffer gnus-summary-buffer) |
23f87bed | 6568 | (gnus-summary-refer-article msg-id)) |
eec82323 LMI |
6569 | (error "No references around point")))) |
6570 | ||
6571 | (defun gnus-article-show-summary () | |
6572 | "Reconfigure windows to show summary buffer." | |
6573 | (interactive) | |
6574 | (if (not (gnus-buffer-live-p gnus-summary-buffer)) | |
6575 | (error "There is no summary buffer for this article buffer") | |
a8151ef7 | 6576 | (gnus-article-set-globals) |
eec82323 | 6577 | (gnus-configure-windows 'article) |
6748645f LMI |
6578 | (gnus-summary-goto-subject gnus-current-article) |
6579 | (gnus-summary-position-point))) | |
eec82323 LMI |
6580 | |
6581 | (defun gnus-article-describe-briefly () | |
6582 | "Describe article mode commands briefly." | |
6583 | (interactive) | |
bdaa75c7 | 6584 | (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help"))) |
eec82323 | 6585 | |
16409b0b GM |
6586 | (defun gnus-article-check-buffer () |
6587 | "Beep if not in an article buffer." | |
1b3b87df | 6588 | (unless (derived-mode-p 'gnus-article-mode) |
16409b0b GM |
6589 | (error "Command invoked outside of a Gnus article buffer"))) |
6590 | ||
eec82323 LMI |
6591 | (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) |
6592 | "Read a summary buffer key sequence and execute it from the article buffer." | |
6593 | (interactive "P") | |
16409b0b | 6594 | (gnus-article-check-buffer) |
eec82323 | 6595 | (let ((nosaves |
23f87bed MB |
6596 | '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f" |
6597 | "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
6598 | "=" "^" "\M-^" "|")) | |
6599 | (nosave-but-article | |
0b6799c3 MB |
6600 | '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae" |
6601 | "An" "Ap" [?A (meta return)] [?A delete])) | |
23f87bed | 6602 | (nosave-in-article |
0b6799c3 | 6603 | '("AS" "\C-d")) |
23f87bed MB |
6604 | (up-to-top |
6605 | '("n" "Gn" "p" "Gp")) | |
6606 | keys new-sum-point) | |
80de1778 | 6607 | (with-current-buffer gnus-article-current-summary |
eec82323 | 6608 | (let (gnus-pick-mode) |
95838435 MB |
6609 | (setq unread-command-events (nconc unread-command-events |
6610 | (list (or key last-command-event))) | |
6611 | keys (if (featurep 'xemacs) | |
6612 | (events-to-keys (read-key-sequence nil t)) | |
6613 | (read-key-sequence nil t))))) | |
a1506d29 | 6614 | |
eec82323 LMI |
6615 | (message "") |
6616 | ||
01c52d31 MB |
6617 | (cond |
6618 | ((eq (aref keys (1- (length keys))) ?\C-h) | |
0b6799c3 | 6619 | (gnus-article-describe-bindings (substring keys 0 -1))) |
01c52d31 MB |
6620 | ((or (member keys nosaves) |
6621 | (member keys nosave-but-article) | |
6622 | (member keys nosave-in-article)) | |
6623 | (let (func) | |
6624 | (save-window-excursion | |
6625 | (pop-to-buffer gnus-article-current-summary) | |
6626 | ;; We disable the pick minor mode commands. | |
6627 | (let (gnus-pick-mode) | |
6ab2c7a8 | 6628 | (setq func (key-binding keys t)))) |
01c52d31 MB |
6629 | (if (or (not func) |
6630 | (numberp func)) | |
6631 | (ding) | |
6632 | (unless (member keys nosave-in-article) | |
6633 | (set-buffer gnus-article-current-summary)) | |
89b163db G |
6634 | (when (and (symbolp func) |
6635 | (get func 'disabled)) | |
cb51ba08 | 6636 | (error "Function %s disabled" func)) |
01c52d31 MB |
6637 | (call-interactively func) |
6638 | (setq new-sum-point (point))) | |
6639 | (when (member keys nosave-but-article) | |
6640 | (pop-to-buffer gnus-article-buffer)))) | |
6641 | (t | |
eec82323 LMI |
6642 | ;; These commands should restore window configuration. |
6643 | (let ((obuf (current-buffer)) | |
23f87bed | 6644 | (owin (current-window-configuration)) |
01c52d31 | 6645 | win func in-buffer selected new-sum-start new-sum-hscroll err) |
23f87bed | 6646 | (cond (not-restore-window |
01c52d31 MB |
6647 | (pop-to-buffer gnus-article-current-summary) |
6648 | (setq win (selected-window))) | |
23f87bed MB |
6649 | ((setq win (get-buffer-window gnus-article-current-summary)) |
6650 | (select-window win)) | |
6651 | (t | |
01c52d31 MB |
6652 | (let ((summary-buffer gnus-article-current-summary)) |
6653 | (gnus-configure-windows 'article) | |
6654 | (unless (setq win (get-buffer-window summary-buffer 'visible)) | |
6655 | (let ((gnus-buffer-configuration | |
de0bdfe7 KY |
6656 | '((article ((vertical 1.0 |
6657 | (summary 0.25 point) | |
6658 | (article 1.0))))))) | |
01c52d31 MB |
6659 | (gnus-configure-windows 'article)) |
6660 | (setq win (get-buffer-window summary-buffer 'visible))) | |
6661 | (gnus-select-frame-set-input-focus (window-frame win)) | |
6662 | (select-window win)))) | |
23f87bed MB |
6663 | (setq in-buffer (current-buffer)) |
6664 | ;; We disable the pick minor mode commands. | |
cb51ba08 LI |
6665 | (setq func (let (gnus-pick-mode) |
6666 | (key-binding keys t))) | |
6667 | (when (get func 'disabled) | |
6668 | (error "Function %s disabled" func)) | |
6669 | (if (and func | |
01c52d31 MB |
6670 | (functionp func) |
6671 | (condition-case code | |
6672 | (progn | |
6673 | (call-interactively func) | |
6674 | t) | |
6675 | (error | |
6676 | (setq err code) | |
6677 | nil))) | |
23f87bed | 6678 | (progn |
23f87bed MB |
6679 | (when (eq win (selected-window)) |
6680 | (setq new-sum-point (point) | |
6681 | new-sum-start (window-start win) | |
9a89f5b0 | 6682 | new-sum-hscroll (window-hscroll win))) |
01c52d31 MB |
6683 | (when (or (eq in-buffer (current-buffer)) |
6684 | (when (eq obuf (current-buffer)) | |
6685 | (set-buffer in-buffer) | |
6686 | t)) | |
520aa572 SZ |
6687 | (setq selected (gnus-summary-select-article)) |
6688 | (set-buffer obuf) | |
6689 | (unless not-restore-window | |
6690 | (set-window-configuration owin)) | |
01c52d31 MB |
6691 | (when (and (eq selected 'old) |
6692 | new-sum-point) | |
520aa572 SZ |
6693 | (set-window-start (get-buffer-window (current-buffer)) |
6694 | 1) | |
6695 | (set-window-point (get-buffer-window (current-buffer)) | |
01c52d31 MB |
6696 | (if (article-goto-body) |
6697 | (1- (point)) | |
6698 | (point)))) | |
23f87bed | 6699 | (when (and (not not-restore-window) |
01c52d31 | 6700 | new-sum-point |
4520e527 | 6701 | (window-live-p win) |
01c52d31 | 6702 | (with-current-buffer (window-buffer win) |
1b3b87df | 6703 | (derived-mode-p 'gnus-summary-mode))) |
23f87bed MB |
6704 | (set-window-point win new-sum-point) |
6705 | (set-window-start win new-sum-start) | |
9a89f5b0 | 6706 | (set-window-hscroll win new-sum-hscroll)))) |
23f87bed | 6707 | (set-window-configuration owin) |
01c52d31 MB |
6708 | (if err |
6709 | (signal (car err) (cdr err)) | |
6710 | (ding)))))))) | |
520aa572 | 6711 | |
95838435 MB |
6712 | (defun gnus-article-read-summary-send-keys () |
6713 | (interactive) | |
0b6799c3 | 6714 | (let ((unread-command-events (list (gnus-character-to-event ?S)))) |
95838435 MB |
6715 | (gnus-article-read-summary-keys))) |
6716 | ||
520aa572 | 6717 | (defun gnus-article-describe-key (key) |
95838435 MB |
6718 | "Display documentation of the function invoked by KEY. |
6719 | KEY is a string or a vector." | |
6720 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. | |
6721 | (read-key-sequence "Describe key: ")))) | |
520aa572 | 6722 | (gnus-article-check-buffer) |
95838435 MB |
6723 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
6724 | gnus-article-read-summary-send-keys)) | |
80de1778 | 6725 | (with-current-buffer gnus-article-current-summary |
95838435 MB |
6726 | (setq unread-command-events |
6727 | (if (featurep 'xemacs) | |
6728 | (append key nil) | |
6729 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) | |
6730 | (list 'meta (- x 128)) | |
6731 | x)) | |
6732 | key))) | |
6733 | (let ((cursor-in-echo-area t) | |
6734 | gnus-pick-mode) | |
6735 | (describe-key (read-key-sequence nil t)))) | |
520aa572 SZ |
6736 | (describe-key key))) |
6737 | ||
6738 | (defun gnus-article-describe-key-briefly (key &optional insert) | |
95838435 MB |
6739 | "Display documentation of the function invoked by KEY. |
6740 | KEY is a string or a vector." | |
6741 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. | |
6742 | (read-key-sequence "Describe key: ")) | |
6743 | current-prefix-arg)) | |
520aa572 | 6744 | (gnus-article-check-buffer) |
95838435 MB |
6745 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
6746 | gnus-article-read-summary-send-keys)) | |
80de1778 | 6747 | (with-current-buffer gnus-article-current-summary |
95838435 MB |
6748 | (setq unread-command-events |
6749 | (if (featurep 'xemacs) | |
6750 | (append key nil) | |
6751 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) | |
6752 | (list 'meta (- x 128)) | |
6753 | x)) | |
6754 | key))) | |
6755 | (let ((cursor-in-echo-area t) | |
6756 | gnus-pick-mode) | |
6757 | (describe-key-briefly (read-key-sequence nil t) insert))) | |
520aa572 | 6758 | (describe-key-briefly key insert))) |
eec82323 | 6759 | |
0b6799c3 MB |
6760 | ;;`gnus-agent-mode' in gnus-agent.el will define it. |
6761 | (defvar gnus-agent-summary-mode) | |
e9198520 | 6762 | (defvar gnus-draft-mode) |
12ea3d65 | 6763 | (defvar help-xref-stack-item) |
0b6799c3 MB |
6764 | |
6765 | (defun gnus-article-describe-bindings (&optional prefix) | |
6766 | "Show a list of all defined keys, and their definitions. | |
6767 | The optional argument PREFIX, if non-nil, should be a key sequence; | |
6768 | then we display only bindings that start with that prefix." | |
6769 | (interactive) | |
6770 | (gnus-article-check-buffer) | |
6771 | (let ((keymap (copy-keymap gnus-article-mode-map)) | |
6772 | (map (copy-keymap gnus-article-send-map)) | |
6773 | (sumkeys (where-is-internal 'gnus-article-read-summary-keys)) | |
8a908224 | 6774 | parent agent draft) |
0b6799c3 MB |
6775 | (define-key keymap "S" map) |
6776 | (define-key map [t] nil) | |
6777 | (with-current-buffer gnus-article-current-summary | |
8a908224 KY |
6778 | (set-keymap-parent |
6779 | keymap | |
6780 | (if (setq parent (keymap-parent gnus-article-mode-map)) | |
6781 | (prog1 | |
6782 | (setq parent (copy-keymap parent)) | |
6783 | (set-keymap-parent parent (current-local-map))) | |
6784 | (current-local-map))) | |
0b6799c3 | 6785 | (set-keymap-parent map (key-binding "S")) |
8f7abae3 MB |
6786 | (let (key def gnus-pick-mode) |
6787 | (while sumkeys | |
6788 | (setq key (pop sumkeys)) | |
6789 | (cond ((and (vectorp key) (= (length key) 1) | |
6790 | (consp (setq def (aref key 0))) | |
6791 | (numberp (car def)) (numberp (cdr def))) | |
6792 | (when (< (max (car def) (cdr def)) 128) | |
6793 | (setq sumkeys | |
6794 | (append (mapcar | |
6795 | #'vector | |
6796 | (nreverse (gnus-uncompress-range def))) | |
6797 | sumkeys)))) | |
6798 | ((setq def (key-binding key)) | |
6799 | (unless (eq def 'undefined) | |
6800 | (define-key keymap key def)))))) | |
0b6799c3 | 6801 | (when (boundp 'gnus-agent-summary-mode) |
e9198520 MB |
6802 | (setq agent gnus-agent-summary-mode)) |
6803 | (when (boundp 'gnus-draft-mode) | |
6804 | (setq draft gnus-draft-mode))) | |
0b6799c3 MB |
6805 | (with-temp-buffer |
6806 | (use-local-map keymap) | |
6807 | (set (make-local-variable 'gnus-agent-summary-mode) agent) | |
e9198520 | 6808 | (set (make-local-variable 'gnus-draft-mode) draft) |
0b6799c3 MB |
6809 | (describe-bindings prefix)) |
6810 | (let ((item `((lambda (prefix) | |
80de1778 | 6811 | (with-current-buffer ,(current-buffer) |
0b6799c3 MB |
6812 | (gnus-article-describe-bindings prefix))) |
6813 | ,prefix))) | |
269db053 KY |
6814 | ;; Loading `help-mode' here is necessary if `describe-bindings' |
6815 | ;; is replaced with something, e.g. `helm-descbinds'. | |
af69a478 | 6816 | (require 'help-mode) |
5843126b | 6817 | (with-current-buffer (let (help-xref-following) (help-buffer)) |
0b6799c3 MB |
6818 | (setq help-xref-stack-item item))))) |
6819 | ||
23f87bed MB |
6820 | (defun gnus-article-reply-with-original (&optional wide) |
6821 | "Start composing a reply mail to the current message. | |
6822 | The text in the region will be yanked. If the region isn't active, | |
6823 | the entire article will be yanked." | |
95838435 | 6824 | (interactive) |
23f87bed MB |
6825 | (let ((article (cdr gnus-article-current)) |
6826 | contents) | |
1d0df8af | 6827 | (if (not (gnus-region-active-p)) |
23f87bed MB |
6828 | (with-current-buffer gnus-summary-buffer |
6829 | (gnus-summary-reply (list (list article)) wide)) | |
6830 | (setq contents (buffer-substring (point) (mark t))) | |
6831 | ;; Deactivate active regions. | |
6832 | (when (and (boundp 'transient-mark-mode) | |
6833 | transient-mark-mode) | |
6834 | (setq mark-active nil)) | |
6835 | (with-current-buffer gnus-summary-buffer | |
6836 | (gnus-summary-reply | |
6837 | (list (list article contents)) wide))))) | |
6838 | ||
95838435 MB |
6839 | (defun gnus-article-wide-reply-with-original () |
6840 | "Start composing a wide reply mail to the current message. | |
6841 | The text in the region will be yanked. If the region isn't active, | |
6842 | the entire article will be yanked." | |
6843 | (interactive) | |
6844 | (gnus-article-reply-with-original t)) | |
6845 | ||
23f87bed MB |
6846 | (defun gnus-article-followup-with-original () |
6847 | "Compose a followup to the current article. | |
6848 | The text in the region will be yanked. If the region isn't active, | |
6849 | the entire article will be yanked." | |
6850 | (interactive) | |
6851 | (let ((article (cdr gnus-article-current)) | |
6852 | contents) | |
1d0df8af | 6853 | (if (not (gnus-region-active-p)) |
23f87bed MB |
6854 | (with-current-buffer gnus-summary-buffer |
6855 | (gnus-summary-followup (list (list article)))) | |
6856 | (setq contents (buffer-substring (point) (mark t))) | |
6857 | ;; Deactivate active regions. | |
6858 | (when (and (boundp 'transient-mark-mode) | |
6859 | transient-mark-mode) | |
6860 | (setq mark-active nil)) | |
6861 | (with-current-buffer gnus-summary-buffer | |
6862 | (gnus-summary-followup | |
6863 | (list (list article contents))))))) | |
6864 | ||
eec82323 LMI |
6865 | (defun gnus-article-hide (&optional arg force) |
6866 | "Hide all the gruft in the current article. | |
23f87bed MB |
6867 | This means that signatures, cited text and (some) headers will be |
6868 | hidden. | |
eec82323 | 6869 | If given a prefix, show the hidden text instead." |
6748645f | 6870 | (interactive (append (gnus-article-hidden-arg) (list 'force))) |
eec82323 | 6871 | (gnus-article-hide-headers arg) |
16409b0b | 6872 | (gnus-article-hide-list-identifiers arg) |
eec82323 LMI |
6873 | (gnus-article-hide-citation-maybe arg force) |
6874 | (gnus-article-hide-signature arg)) | |
6875 | ||
6748645f LMI |
6876 | (defun gnus-check-group-server () |
6877 | ;; Make sure the connection to the server is alive. | |
6878 | (unless (gnus-server-opened | |
6879 | (gnus-find-method-for-group gnus-newsgroup-name)) | |
6880 | (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
6881 | (gnus-request-group gnus-newsgroup-name t))) | |
6882 | ||
23f87bed MB |
6883 | (eval-when-compile |
6884 | (autoload 'nneething-get-file-name "nneething")) | |
6885 | ||
eec82323 LMI |
6886 | (defun gnus-request-article-this-buffer (article group) |
6887 | "Get an article and insert it into this buffer." | |
6748645f | 6888 | (let (do-update-line sparse-header) |
eec82323 LMI |
6889 | (prog1 |
6890 | (save-excursion | |
6891 | (erase-buffer) | |
6892 | (gnus-kill-all-overlays) | |
6893 | (setq group (or group gnus-newsgroup-name)) | |
6894 | ||
eec82323 LMI |
6895 | ;; Using `gnus-request-article' directly will insert the article into |
6896 | ;; `nntp-server-buffer' - so we'll save some time by not having to | |
6897 | ;; copy it from the server buffer into the article buffer. | |
6898 | ||
6899 | ;; We only request an article by message-id when we do not have the | |
6900 | ;; headers for it, so we'll have to get those. | |
6901 | (when (stringp article) | |
16409b0b | 6902 | (gnus-read-header article)) |
eec82323 LMI |
6903 | |
6904 | ;; If the article number is negative, that means that this article | |
6905 | ;; doesn't belong in this newsgroup (possibly), so we find its | |
6906 | ;; message-id and request it by id instead of number. | |
6907 | (when (and (numberp article) | |
6908 | gnus-summary-buffer | |
6909 | (get-buffer gnus-summary-buffer) | |
6748645f | 6910 | (gnus-buffer-exists-p gnus-summary-buffer)) |
80de1778 | 6911 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
6912 | (let ((header (gnus-summary-article-header article))) |
6913 | (when (< article 0) | |
6914 | (cond | |
6915 | ((memq article gnus-newsgroup-sparse) | |
6916 | ;; This is a sparse gap article. | |
6917 | (setq do-update-line article) | |
6918 | (setq article (mail-header-id header)) | |
16409b0b | 6919 | (setq sparse-header (gnus-read-header article)) |
eec82323 LMI |
6920 | (setq gnus-newsgroup-sparse |
6921 | (delq article gnus-newsgroup-sparse))) | |
6922 | ((vectorp header) | |
6923 | ;; It's a real article. | |
6924 | (setq article (mail-header-id header))) | |
6925 | (t | |
6926 | ;; It is an extracted pseudo-article. | |
6927 | (setq article 'pseudo) | |
6928 | (gnus-request-pseudo-article header)))) | |
6929 | ||
6930 | (let ((method (gnus-find-method-for-group | |
6931 | gnus-newsgroup-name))) | |
6748645f LMI |
6932 | (when (and (eq (car method) 'nneething) |
6933 | (vectorp header)) | |
23f87bed MB |
6934 | (let ((dir (nneething-get-file-name |
6935 | (mail-header-id header)))) | |
6936 | (when (and (stringp dir) | |
6937 | (file-directory-p dir)) | |
eec82323 LMI |
6938 | (setq article 'nneething) |
6939 | (gnus-group-enter-directory dir)))))))) | |
6940 | ||
6941 | (cond | |
6942 | ;; Refuse to select canceled articles. | |
6943 | ((and (numberp article) | |
6944 | gnus-summary-buffer | |
6945 | (get-buffer gnus-summary-buffer) | |
6748645f | 6946 | (gnus-buffer-exists-p gnus-summary-buffer) |
01c52d31 | 6947 | (eq (cdr (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
6948 | (assq article gnus-newsgroup-reads))) |
6949 | gnus-canceled-mark)) | |
6950 | nil) | |
6951 | ;; We first check `gnus-original-article-buffer'. | |
6952 | ((and (get-buffer gnus-original-article-buffer) | |
6953 | (numberp article) | |
01c52d31 | 6954 | (with-current-buffer gnus-original-article-buffer |
eec82323 LMI |
6955 | (and (equal (car gnus-original-article) group) |
6956 | (eq (cdr gnus-original-article) article)))) | |
75eda25b SM |
6957 | ;; `insert-buffer-substring' would incorrectly use the |
6958 | ;; equivalent of string-make-multibyte which amount to decoding | |
6959 | ;; with locale-coding-system, causing failure of | |
6960 | ;; subsequent decoding. | |
6961 | (insert (mm-string-to-multibyte | |
6962 | (with-current-buffer gnus-original-article-buffer | |
6963 | (buffer-substring (point-min) (point-max))))) | |
eec82323 LMI |
6964 | 'article) |
6965 | ;; Check the backlog. | |
6966 | ((and gnus-keep-backlog | |
6967 | (gnus-backlog-request-article group article (current-buffer))) | |
6968 | 'article) | |
6969 | ;; Check asynchronous pre-fetch. | |
6970 | ((gnus-async-request-fetched-article group article (current-buffer)) | |
6971 | (gnus-async-prefetch-next group article gnus-summary-buffer) | |
6748645f LMI |
6972 | (when (and (numberp article) gnus-keep-backlog) |
6973 | (gnus-backlog-enter-article group article (current-buffer))) | |
eec82323 LMI |
6974 | 'article) |
6975 | ;; Check the cache. | |
6976 | ((and gnus-use-cache | |
6977 | (numberp article) | |
6978 | (gnus-cache-request-article article group)) | |
6979 | 'article) | |
23f87bed MB |
6980 | ;; Check the agent cache. |
6981 | ((gnus-agent-request-article article group) | |
6982 | 'article) | |
eec82323 | 6983 | ;; Get the article and put into the article buffer. |
16409b0b GM |
6984 | ((or (stringp article) |
6985 | (numberp article)) | |
6986 | (let ((gnus-override-method gnus-override-method) | |
a1506d29 | 6987 | (methods (and (stringp article) |
936d08bb G |
6988 | (with-current-buffer gnus-summary-buffer |
6989 | (gnus-refer-article-methods)))) | |
23f87bed MB |
6990 | (backend (car (gnus-find-method-for-group |
6991 | gnus-newsgroup-name))) | |
16409b0b | 6992 | result |
4e7d0221 | 6993 | (inhibit-read-only t)) |
16409b0b GM |
6994 | (when (and (null gnus-override-method) |
6995 | methods) | |
6996 | (setq gnus-override-method (pop methods))) | |
6997 | (while (not result) | |
16409b0b GM |
6998 | (erase-buffer) |
6999 | (gnus-kill-all-overlays) | |
7000 | (let ((gnus-newsgroup-name group)) | |
7001 | (gnus-check-group-server)) | |
23f87bed MB |
7002 | (cond |
7003 | ((gnus-request-article article group (current-buffer)) | |
16409b0b | 7004 | (when (numberp article) |
a1506d29 | 7005 | (gnus-async-prefetch-next group article |
16409b0b GM |
7006 | gnus-summary-buffer) |
7007 | (when gnus-keep-backlog | |
7008 | (gnus-backlog-enter-article | |
f3b146e9 LMI |
7009 | group article (current-buffer))) |
7010 | (when (and gnus-agent | |
7011 | (gnus-agent-group-covered-p group)) | |
7012 | (gnus-agent-store-article article group))) | |
16409b0b | 7013 | (setq result 'article)) |
23f87bed MB |
7014 | (methods |
7015 | (setq gnus-override-method (pop methods))) | |
7016 | ((not (string-match "^400 " | |
7017 | (nnheader-get-report backend))) | |
7018 | ;; If we get 400 server disconnect, reconnect and | |
7019 | ;; retry; otherwise, assume the article has expired. | |
7020 | (setq result 'done)))) | |
16409b0b | 7021 | (and (eq result 'article) 'article))) |
eec82323 LMI |
7022 | ;; It was a pseudo. |
7023 | (t article))) | |
7024 | ||
6748645f LMI |
7025 | ;; Associate this article with the current summary buffer. |
7026 | (setq gnus-article-current-summary gnus-summary-buffer) | |
7027 | ||
eec82323 LMI |
7028 | ;; Take the article from the original article buffer |
7029 | ;; and place it in the buffer it's supposed to be in. | |
7030 | (when (and (get-buffer gnus-article-buffer) | |
eec82323 LMI |
7031 | (equal (buffer-name (current-buffer)) |
7032 | (buffer-name (get-buffer gnus-article-buffer)))) | |
7033 | (save-excursion | |
7034 | (if (get-buffer gnus-original-article-buffer) | |
6748645f LMI |
7035 | (set-buffer gnus-original-article-buffer) |
7036 | (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) | |
16409b0b | 7037 | (buffer-disable-undo) |
eec82323 | 7038 | (setq major-mode 'gnus-original-article-mode) |
6748645f | 7039 | (setq buffer-read-only t)) |
23f87bed | 7040 | (let ((inhibit-read-only t)) |
eec82323 LMI |
7041 | (erase-buffer) |
7042 | (insert-buffer-substring gnus-article-buffer)) | |
16409b0b GM |
7043 | (setq gnus-original-article (cons group article))) |
7044 | ||
7045 | ;; Decode charsets. | |
7046 | (run-hooks 'gnus-article-decode-hook) | |
7047 | ;; Mark article as decoded or not. | |
7048 | (setq gnus-article-decoded-p gnus-article-decode-hook)) | |
eec82323 LMI |
7049 | |
7050 | ;; Update sparse articles. | |
7051 | (when (and do-update-line | |
7052 | (or (numberp article) | |
7053 | (stringp article))) | |
7054 | (let ((buf (current-buffer))) | |
7055 | (set-buffer gnus-summary-buffer) | |
6748645f | 7056 | (gnus-summary-update-article do-update-line sparse-header) |
eec82323 | 7057 | (gnus-summary-goto-subject do-update-line nil t) |
23f87bed | 7058 | (set-window-point (gnus-get-buffer-window (current-buffer) t) |
eec82323 LMI |
7059 | (point)) |
7060 | (set-buffer buf)))))) | |
7061 | ||
2526f423 | 7062 | (defun gnus-block-private-groups (group) |
6ed7a66a G |
7063 | (if (or (gnus-news-group-p group) |
7064 | (gnus-member-of-valid 'global group)) | |
2526f423 G |
7065 | ;; Block nothing in news groups. |
7066 | nil | |
7067 | ;; Block everything anywhere else. | |
7068 | ".")) | |
7069 | ||
7070 | (defun gnus-blocked-images () | |
7071 | (if (functionp gnus-blocked-images) | |
7072 | (funcall gnus-blocked-images gnus-newsgroup-name) | |
7073 | gnus-blocked-images)) | |
7074 | ||
eec82323 LMI |
7075 | ;;; |
7076 | ;;; Article editing | |
7077 | ;;; | |
7078 | ||
7079 | (defcustom gnus-article-edit-mode-hook nil | |
7080 | "Hook run in article edit mode buffers." | |
7081 | :group 'gnus-article-various | |
7082 | :type 'hook) | |
7083 | ||
7084 | (defvar gnus-article-edit-done-function nil) | |
7085 | ||
7086 | (defvar gnus-article-edit-mode-map nil) | |
7087 | ||
16409b0b | 7088 | ;; Should we be using derived.el for this? |
eec82323 | 7089 | (unless gnus-article-edit-mode-map |
23f87bed | 7090 | (setq gnus-article-edit-mode-map (make-keymap)) |
16409b0b | 7091 | (set-keymap-parent gnus-article-edit-mode-map text-mode-map) |
eec82323 LMI |
7092 | |
7093 | (gnus-define-keys gnus-article-edit-mode-map | |
23f87bed | 7094 | "\C-c?" describe-mode |
eec82323 | 7095 | "\C-c\C-c" gnus-article-edit-done |
23f87bed MB |
7096 | "\C-c\C-k" gnus-article-edit-exit |
7097 | "\C-c\C-f\C-t" message-goto-to | |
7098 | "\C-c\C-f\C-o" message-goto-from | |
7099 | "\C-c\C-f\C-b" message-goto-bcc | |
7100 | ;;"\C-c\C-f\C-w" message-goto-fcc | |
7101 | "\C-c\C-f\C-c" message-goto-cc | |
7102 | "\C-c\C-f\C-s" message-goto-subject | |
7103 | "\C-c\C-f\C-r" message-goto-reply-to | |
7104 | "\C-c\C-f\C-n" message-goto-newsgroups | |
7105 | "\C-c\C-f\C-d" message-goto-distribution | |
7106 | "\C-c\C-f\C-f" message-goto-followup-to | |
7107 | "\C-c\C-f\C-m" message-goto-mail-followup-to | |
7108 | "\C-c\C-f\C-k" message-goto-keywords | |
7109 | "\C-c\C-f\C-u" message-goto-summary | |
7110 | "\C-c\C-f\C-i" message-insert-or-toggle-importance | |
7111 | "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to | |
7112 | "\C-c\C-b" message-goto-body | |
7113 | "\C-c\C-i" message-goto-signature | |
7114 | ||
7115 | "\C-c\C-t" message-insert-to | |
7116 | "\C-c\C-n" message-insert-newsgroups | |
7117 | "\C-c\C-o" message-sort-headers | |
7118 | "\C-c\C-e" message-elide-region | |
7119 | "\C-c\C-v" message-delete-not-region | |
7120 | "\C-c\C-z" message-kill-to-signature | |
7121 | "\M-\r" message-newline-and-reformat | |
7122 | "\C-c\C-a" mml-attach-file | |
7123 | "\C-a" message-beginning-of-line | |
7124 | "\t" message-tab | |
7125 | "\M-;" comment-region) | |
eec82323 LMI |
7126 | |
7127 | (gnus-define-keys (gnus-article-edit-wash-map | |
7128 | "\C-c\C-w" gnus-article-edit-mode-map) | |
7129 | "f" gnus-article-edit-full-stops)) | |
7130 | ||
23f87bed MB |
7131 | (easy-menu-define |
7132 | gnus-article-edit-mode-field-menu gnus-article-edit-mode-map "" | |
7133 | '("Field" | |
7134 | ["Fetch To" message-insert-to t] | |
7135 | ["Fetch Newsgroups" message-insert-newsgroups t] | |
7136 | "----" | |
7137 | ["To" message-goto-to t] | |
7138 | ["From" message-goto-from t] | |
7139 | ["Subject" message-goto-subject t] | |
7140 | ["Cc" message-goto-cc t] | |
7141 | ["Reply-To" message-goto-reply-to t] | |
7142 | ["Summary" message-goto-summary t] | |
7143 | ["Keywords" message-goto-keywords t] | |
7144 | ["Newsgroups" message-goto-newsgroups t] | |
7145 | ["Followup-To" message-goto-followup-to t] | |
7146 | ["Mail-Followup-To" message-goto-mail-followup-to t] | |
7147 | ["Distribution" message-goto-distribution t] | |
7148 | ["Body" message-goto-body t] | |
7149 | ["Signature" message-goto-signature t])) | |
7150 | ||
4e7d0221 | 7151 | (define-derived-mode gnus-article-edit-mode message-mode "Article Edit" |
eec82323 LMI |
7152 | "Major mode for editing articles. |
7153 | This is an extended text-mode. | |
7154 | ||
7155 | \\{gnus-article-edit-mode-map}" | |
eec82323 LMI |
7156 | (make-local-variable 'gnus-article-edit-done-function) |
7157 | (make-local-variable 'gnus-prev-winconf) | |
80b47379 SZ |
7158 | (set (make-local-variable 'font-lock-defaults) |
7159 | '(message-font-lock-keywords t)) | |
23f87bed MB |
7160 | (set (make-local-variable 'mail-header-separator) "") |
7161 | (set (make-local-variable 'gnus-article-edit-mode) t) | |
7162 | (easy-menu-add message-mode-field-menu message-mode-map) | |
7163 | (mml-mode) | |
eec82323 LMI |
7164 | (setq buffer-read-only nil) |
7165 | (buffer-enable-undo) | |
80b47379 | 7166 | (widen)) |
eec82323 LMI |
7167 | |
7168 | (defun gnus-article-edit (&optional force) | |
7169 | "Edit the current article. | |
7170 | This will have permanent effect only in mail groups. | |
7171 | If FORCE is non-nil, allow editing of articles even in read-only | |
7172 | groups." | |
7173 | (interactive "P") | |
7174 | (when (and (not force) | |
7175 | (gnus-group-read-only-p)) | |
a8151ef7 | 7176 | (error "The current newsgroup does not support article editing")) |
6748645f | 7177 | (gnus-article-date-original) |
eec82323 | 7178 | (gnus-article-edit-article |
16409b0b | 7179 | 'ignore |
6748645f | 7180 | `(lambda (no-highlight) |
16409b0b | 7181 | 'ignore |
eec82323 LMI |
7182 | (gnus-summary-edit-article-done |
7183 | ,(or (mail-header-references gnus-current-headers) "") | |
6748645f | 7184 | ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) |
eec82323 | 7185 | |
01c52d31 | 7186 | (defun gnus-article-edit-article (start-func exit-func &optional quiet) |
eec82323 LMI |
7187 | "Start editing the contents of the current article buffer." |
7188 | (let ((winconf (current-window-configuration))) | |
7189 | (set-buffer gnus-article-buffer) | |
0683d241 MB |
7190 | (let ((message-auto-save-directory |
7191 | ;; Don't associate the article buffer with a draft file. | |
7192 | nil)) | |
7193 | (gnus-article-edit-mode)) | |
16409b0b | 7194 | (funcall start-func) |
23f87bed | 7195 | (set-buffer-modified-p nil) |
eec82323 LMI |
7196 | (gnus-configure-windows 'edit-article) |
7197 | (setq gnus-article-edit-done-function exit-func) | |
7198 | (setq gnus-prev-winconf winconf) | |
01c52d31 MB |
7199 | (unless quiet |
7200 | (gnus-message 6 "C-c C-c to end edits")))) | |
eec82323 | 7201 | |
6748645f | 7202 | (defun gnus-article-edit-done (&optional arg) |
eec82323 | 7203 | "Update the article edits and exit." |
6748645f | 7204 | (interactive "P") |
eec82323 LMI |
7205 | (let ((func gnus-article-edit-done-function) |
7206 | (buf (current-buffer)) | |
23f87bed MB |
7207 | (start (window-start)) |
7208 | (p (point)) | |
7209 | (winconf gnus-prev-winconf)) | |
7210 | (widen) ;; Widen it in case that users narrowed the buffer. | |
7211 | (funcall func arg) | |
7212 | (set-buffer buf) | |
7213 | ;; The cache and backlog have to be flushed somewhat. | |
7214 | (when gnus-keep-backlog | |
7215 | (gnus-backlog-remove-article | |
7216 | (car gnus-article-current) (cdr gnus-article-current))) | |
7217 | ;; Flush original article as well. | |
8ccbef23 | 7218 | (gnus-flush-original-article-buffer) |
23f87bed MB |
7219 | (when gnus-use-cache |
7220 | (gnus-cache-update-article | |
7221 | (car gnus-article-current) (cdr gnus-article-current))) | |
7222 | ;; We remove all text props from the article buffer. | |
7223 | (kill-all-local-variables) | |
01c52d31 | 7224 | (set-text-properties (point-min) (point-max) nil) |
23f87bed MB |
7225 | (gnus-article-mode) |
7226 | (set-window-configuration winconf) | |
eec82323 LMI |
7227 | (set-buffer buf) |
7228 | (set-window-start (get-buffer-window buf) start) | |
23f87bed MB |
7229 | (set-window-point (get-buffer-window buf) (point))) |
7230 | (gnus-summary-show-article)) | |
eec82323 | 7231 | |
8ccbef23 G |
7232 | (defun gnus-flush-original-article-buffer () |
7233 | (when (get-buffer gnus-original-article-buffer) | |
7234 | (with-current-buffer gnus-original-article-buffer | |
7235 | (setq gnus-original-article nil)))) | |
7236 | ||
eec82323 LMI |
7237 | (defun gnus-article-edit-exit () |
7238 | "Exit the article editing without updating." | |
7239 | (interactive) | |
23f87bed MB |
7240 | (when (or (not (buffer-modified-p)) |
7241 | (yes-or-no-p "Article modified; kill anyway? ")) | |
7242 | (let ((curbuf (current-buffer)) | |
7243 | (p (point)) | |
7244 | (window-start (window-start))) | |
7245 | (erase-buffer) | |
7246 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
d8a88581 | 7247 | (insert-buffer-substring gnus-original-article-buffer)) |
23f87bed MB |
7248 | (let ((winconf gnus-prev-winconf)) |
7249 | (kill-all-local-variables) | |
7250 | (gnus-article-mode) | |
7251 | (set-window-configuration winconf) | |
7252 | ;; Tippy-toe some to make sure that point remains where it was. | |
7253 | (save-current-buffer | |
7254 | (set-buffer curbuf) | |
7255 | (set-window-start (get-buffer-window (current-buffer)) window-start) | |
7256 | (goto-char p)))) | |
7257 | (gnus-summary-show-article))) | |
eec82323 LMI |
7258 | |
7259 | (defun gnus-article-edit-full-stops () | |
7260 | "Interactively repair spacing at end of sentences." | |
7261 | (interactive) | |
7262 | (save-excursion | |
7263 | (goto-char (point-min)) | |
7264 | (search-forward-regexp "^$" nil t) | |
7265 | (let ((case-fold-search nil)) | |
7266 | (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2")))) | |
7267 | ||
7268 | ;;; | |
7269 | ;;; Article highlights | |
7270 | ;;; | |
7271 | ||
7272 | ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. | |
7273 | ||
7274 | ;;; Internal Variables: | |
7275 | ||
a1506d29 | 7276 | (defcustom gnus-button-url-regexp |
01c52d31 MB |
7277 | (concat |
7278 | "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|" | |
7279 | "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)" | |
7280 | "\\(//[-a-z0-9_.]+:[0-9]*\\)?" | |
7281 | (if (string-match "[[:digit:]]" "1") ;; Support POSIX? | |
7282 | (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]") | |
7283 | (punct "!?:;.,")) | |
7284 | (concat | |
7285 | "\\(?:" | |
7286 | ;; Match paired parentheses, e.g. in Wikipedia URLs: | |
9b3ebcb6 | 7287 | ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com |
02e2beb9 AS |
7288 | "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" |
7289 | "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?" | |
01c52d31 | 7290 | "\\|" |
02e2beb9 | 7291 | "[" chars punct "]+" "[" chars "]" |
01c52d31 MB |
7292 | "\\)")) |
7293 | (concat ;; XEmacs 21.4 doesn't support POSIX. | |
7294 | "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+" | |
7295 | "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)")) | |
7296 | "\\)") | |
eec82323 | 7297 | "Regular expression that matches URLs." |
02e2beb9 | 7298 | :version "24.4" |
eec82323 LMI |
7299 | :group 'gnus-article-buttons |
7300 | :type 'regexp) | |
7301 | ||
23f87bed MB |
7302 | (defcustom gnus-button-valid-fqdn-regexp |
7303 | message-valid-fqdn-regexp | |
7304 | "Regular expression that matches a valid FQDN." | |
bf247b6e | 7305 | :version "22.1" |
23f87bed MB |
7306 | :group 'gnus-article-buttons |
7307 | :type 'regexp) | |
7308 | ||
97f78c9b MB |
7309 | ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de> |
7310 | (defcustom gnus-button-valid-localpart-regexp | |
14e6dc54 | 7311 | "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*" |
97f78c9b MB |
7312 | "Regular expression that matches a localpart of mail addresses or MIDs." |
7313 | :version "22.1" | |
7314 | :group 'gnus-article-buttons | |
7315 | :type 'regexp) | |
7316 | ||
23f87bed MB |
7317 | (defcustom gnus-button-man-handler 'manual-entry |
7318 | "Function to use for displaying man pages. | |
7319 | The function must take at least one argument with a string naming the | |
7320 | man page." | |
bf247b6e | 7321 | :version "22.1" |
23f87bed MB |
7322 | :type '(choice (function-item :tag "Man" manual-entry) |
7323 | (function-item :tag "Woman" woman) | |
7324 | (function :tag "Other")) | |
7325 | :group 'gnus-article-buttons) | |
7326 | ||
23f87bed | 7327 | (defcustom gnus-button-mid-or-mail-regexp |
97f78c9b | 7328 | (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@" |
23f87bed MB |
7329 | gnus-button-valid-fqdn-regexp |
7330 | ">?\\)\\b") | |
7331 | "Regular expression that matches a message ID or a mail address." | |
bf247b6e | 7332 | :version "22.1" |
23f87bed MB |
7333 | :group 'gnus-article-buttons |
7334 | :type 'regexp) | |
7335 | ||
7336 | (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic | |
7337 | "What to do when the button on a string as \"foo123@bar.invalid\" is pushed. | |
7338 | Strings like this can be either a message ID or a mail address. If it is one | |
7339 | of the symbols `mid' or `mail', Gnus will always assume that the string is a | |
7340 | message ID or a mail address, respectively. If this variable is set to the | |
7341 | symbol `ask', always query the user what do do. If it is a function, this | |
aa819354 | 7342 | function will be called with the string as its only argument. The function |
23f87bed | 7343 | must return `mid', `mail', `invalid' or `ask'." |
bf247b6e | 7344 | :version "22.1" |
23f87bed MB |
7345 | :group 'gnus-article-buttons |
7346 | :type '(choice (function-item :tag "Heuristic function" | |
7347 | gnus-button-mid-or-mail-heuristic) | |
7348 | (const ask) | |
7349 | (const mid) | |
7350 | (const mail))) | |
7351 | ||
7352 | (defcustom gnus-button-mid-or-mail-heuristic-alist | |
7353 | '((-10.0 . ".+\\$.+@") | |
7354 | (-10.0 . "#") | |
7355 | (-10.0 . "\\*") | |
7356 | (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs | |
7357 | (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i | |
7358 | (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i; | |
7359 | (-1.0 . "^[^a-z]+@") | |
7360 | ;; | |
7361 | (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@" | |
7362 | (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@" | |
7363 | (-3.0 . "[A-Z][A-Z][a-z][a-z].*@") | |
7364 | (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@") | |
7365 | ;; | |
7366 | (-2.0 . "^[0-9]") | |
7367 | (-1.0 . "^[0-9][0-9]") | |
7368 | ;; | |
7369 | ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/; | |
7370 | (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") | |
7371 | ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/; | |
7372 | (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") | |
7373 | ;; | |
7374 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@" | |
7375 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@") | |
7376 | ;; "[0-9]{8,}.*\@" | |
7377 | (-3.0 | |
7378 | . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@") | |
7379 | ;; "[0-9]{12,}.*\@" | |
7380 | ;; compensation for TDMA dated mail addresses: | |
7381 | (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@") | |
7382 | ;; | |
7383 | (-20.0 . "\\.fsf@") ;; Gnus | |
7384 | (-20.0 . "^slrn") | |
7385 | (-20.0 . "^Pine") | |
437ce4be | 7386 | (-20.0 . "^alpine\\.") |
23f87bed MB |
7387 | (-20.0 . "_-_") ;; Subject change in thread |
7388 | ;; | |
7389 | (-20.0 . "\\.ln@") ;; leafnode | |
7390 | (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de") | |
7391 | (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent | |
7392 | ;; | |
7393 | ;; (5.0 . "") ;; $local_part_len <= 7 | |
7394 | (10.0 . "^[^0-9]+@") | |
7395 | (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@") | |
7396 | ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part | |
7397 | (3.0 . "\@stud") | |
7398 | ;; | |
7399 | (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@") | |
7400 | ;; | |
7401 | (0.5 . "^[A-Z][a-z]") | |
7402 | (0.5 . "^[A-Z][a-z][a-z]") | |
7403 | (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3} | |
7404 | (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4} | |
7405 | "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'. | |
7406 | ||
7407 | A negative RATE indicates a message IDs, whereas a positive indicates a mail | |
7408 | address. The REGEXP is processed with `case-fold-search' set to nil." | |
bf247b6e | 7409 | :version "22.1" |
23f87bed MB |
7410 | :group 'gnus-article-buttons |
7411 | :type '(repeat (cons (number :tag "Rate") | |
7412 | (regexp :tag "Regexp")))) | |
7413 | ||
7414 | (defun gnus-button-mid-or-mail-heuristic (mid-or-mail) | |
7415 | "Guess whether MID-OR-MAIL is a message ID or a mail address. | |
7416 | Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail | |
7417 | address, `ask' if unsure and `invalid' if the string is invalid." | |
7418 | (let ((case-fold-search nil) | |
7419 | (list gnus-button-mid-or-mail-heuristic-alist) | |
7420 | (result 0) rate regexp lpartlen elem) | |
7421 | (setq lpartlen | |
7422 | (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1"))) | |
7423 | (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen) | |
7424 | ;; Certain special cases... | |
7425 | (when (string-match | |
7426 | (concat | |
7427 | "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|" | |
7428 | "^[0-9]+\\.[0-9]+@compuserve\\|" | |
7429 | "@public\\.gmane\\.org") | |
7430 | mid-or-mail) | |
7431 | (gnus-message 8 "`%s' is a known mail address." mid-or-mail) | |
7432 | (setq result 'mail)) | |
7433 | (when (string-match "@.*@\\| " mid-or-mail) | |
7434 | (gnus-message 8 "`%s' is invalid." mid-or-mail) | |
7435 | (setq result 'invalid)) | |
7436 | ;; Nothing more to do, if result is not a number here... | |
7437 | (when (numberp result) | |
7438 | (while list | |
7439 | (setq elem (car list) | |
7440 | rate (car elem) | |
7441 | regexp (cdr elem) | |
7442 | list (cdr list)) | |
7443 | (when (string-match regexp mid-or-mail) | |
7444 | (setq result (+ result rate)) | |
7445 | (gnus-message | |
7446 | 9 "`%s' matched `%s', rate `%s', result `%s'." | |
7447 | mid-or-mail regexp rate result))) | |
7448 | (when (<= lpartlen 7) | |
7449 | (setq result (+ result 5.0)) | |
7450 | (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'." | |
7451 | mid-or-mail result)) | |
7452 | (when (>= lpartlen 12) | |
7453 | (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail) | |
7454 | (cond | |
7455 | ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail) | |
7456 | ;; Long local part should contain realname if e-mail address, | |
7457 | ;; too many digits: message-id. | |
7458 | ;; $score -= 5.0 + 0.1 * $local_part_len; | |
7459 | (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen)))) | |
7460 | (setq result (+ result rate)) | |
7461 | (gnus-message | |
7462 | 9 "Many digits in `%s', rate `%s', result `%s'." | |
7463 | mid-or-mail rate result)) | |
7464 | ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@" | |
7465 | mid-or-mail) | |
7466 | ;; Too few vowels [^aeiouy]{4,}.*\@ | |
7467 | (setq result (+ result -5.0)) | |
7468 | (gnus-message | |
7469 | 9 "Few vowels in `%s', rate `%s', result `%s'." | |
7470 | mid-or-mail -5.0 result)) | |
7471 | (t | |
7472 | (setq result (+ result 5.0)) | |
7473 | (gnus-message | |
7474 | 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result))))) | |
7475 | (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result) | |
7476 | ;; Maybe we should make this a customizable alist: (condition . 'result) | |
7477 | (cond | |
7478 | ((symbolp result) result) | |
7479 | ;; Now convert number into proper results: | |
7480 | ((< result -10.0) 'mid) | |
7481 | ((> result 10.0) 'mail) | |
7482 | (t 'ask)))) | |
7483 | ||
7484 | (defun gnus-button-handle-mid-or-mail (mid-or-mail) | |
7485 | (let* ((pref gnus-button-prefer-mid-or-mail) guessed | |
7486 | (url-mid (concat "news" ":" mid-or-mail)) | |
7487 | (url-mailto (concat "mailto" ":" mid-or-mail))) | |
7488 | (gnus-message 9 "mid-or-mail=%s" mid-or-mail) | |
7489 | (when (fboundp pref) | |
7490 | (setq guessed | |
7491 | ;; get rid of surrounding angles... | |
7492 | (funcall pref | |
7493 | (gnus-replace-in-string mid-or-mail "^<\\|>$" ""))) | |
7494 | (if (or (eq 'mid guessed) (eq 'mail guessed)) | |
7495 | (setq pref guessed) | |
7496 | (setq pref 'ask))) | |
7497 | (if (eq pref 'ask) | |
7498 | (save-window-excursion | |
7499 | (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? ")) | |
7500 | (setq pref 'mail) | |
7501 | (setq pref 'mid)))) | |
7502 | (cond ((eq pref 'mid) | |
7503 | (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid) | |
7504 | (gnus-button-handle-news url-mid)) | |
7505 | ((eq pref 'mail) | |
7506 | (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto) | |
7507 | (gnus-url-mailto url-mailto)) | |
7508 | (t (gnus-message 3 "Invalid string."))))) | |
7509 | ||
01c52d31 MB |
7510 | (defun gnus-button-handle-custom (fun arg) |
7511 | "Call function FUN on argument ARG. | |
7512 | Both FUN and ARG are supposed to be strings. ARG will be passed | |
7513 | as a symbol to FUN." | |
7514 | (funcall (intern fun) | |
7515 | (if (string-match "^customize-apropos" fun) | |
7516 | arg | |
7517 | (intern arg)))) | |
23f87bed MB |
7518 | |
7519 | (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)") | |
7520 | ||
23f87bed MB |
7521 | (defun gnus-button-handle-describe-function (url) |
7522 | "Call `describe-function' when pushing the corresponding URL button." | |
7523 | (describe-function | |
7524 | (intern | |
7525 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) | |
7526 | ||
7527 | (defun gnus-button-handle-describe-variable (url) | |
7528 | "Call `describe-variable' when pushing the corresponding URL button." | |
7529 | (describe-variable | |
7530 | (intern | |
7531 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) | |
7532 | ||
7533 | (defun gnus-button-handle-symbol (url) | |
7534 | "Display help on variable or function. | |
7535 | Calls `describe-variable' or `describe-function'." | |
7536 | (let ((sym (intern url))) | |
7537 | (cond | |
7538 | ((fboundp sym) (describe-function sym)) | |
7539 | ((boundp sym) (describe-variable sym)) | |
7540 | (t (gnus-message 3 "`%s' is not a known function of variable." url))))) | |
7541 | ||
7542 | (defun gnus-button-handle-describe-key (url) | |
7543 | "Call `describe-key' when pushing the corresponding URL button." | |
7544 | (let* ((key-string | |
7545 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")) | |
7546 | (keys (ignore-errors (eval `(kbd ,key-string))))) | |
7547 | (if keys | |
7548 | (describe-key keys) | |
7549 | (gnus-message 3 "Invalid key sequence in button: %s" key-string)))) | |
7550 | ||
7551 | (defun gnus-button-handle-apropos (url) | |
7552 | "Call `apropos' when pushing the corresponding URL button." | |
7553 | (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7554 | ||
7555 | (defun gnus-button-handle-apropos-command (url) | |
7556 | "Call `apropos' when pushing the corresponding URL button." | |
7557 | (apropos-command | |
7558 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7559 | ||
7560 | (defun gnus-button-handle-apropos-variable (url) | |
7561 | "Call `apropos' when pushing the corresponding URL button." | |
7562 | (funcall | |
7563 | (if (fboundp 'apropos-variable) 'apropos-variable 'apropos) | |
7564 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7565 | ||
7566 | (defun gnus-button-handle-apropos-documentation (url) | |
7567 | "Call `apropos' when pushing the corresponding URL button." | |
7568 | (funcall | |
7569 | (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos) | |
7570 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7571 | ||
7572 | (defun gnus-button-handle-library (url) | |
7573 | "Call `locate-library' when pushing the corresponding URL button." | |
7574 | (gnus-message 9 "url=`%s'" url) | |
7575 | (let* ((lib (locate-library url)) | |
7576 | (file (gnus-replace-in-string (or lib "") "\.elc" ".el"))) | |
7577 | (if (not lib) | |
7578 | (gnus-message 1 "Cannot locale library `%s'." url) | |
7579 | (find-file-read-only file)))) | |
7580 | ||
23f87bed MB |
7581 | (defcustom gnus-button-man-level 5 |
7582 | "*Integer that says how many man-related buttons Gnus will show. | |
7583 | The higher the number, the more buttons will appear and the more false | |
7584 | positives are possible. Note that you can set this variable local to | |
7585 | specific groups. Setting it higher in Unix groups is probably a good idea. | |
7586 | See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on | |
7587 | how to set variables in specific groups." | |
bf247b6e | 7588 | :version "22.1" |
23f87bed MB |
7589 | :group 'gnus-article-buttons |
7590 | :link '(custom-manual "(gnus)Group Parameters") | |
7591 | :type 'integer) | |
7592 | ||
7593 | (defcustom gnus-button-emacs-level 5 | |
7594 | "*Integer that says how many emacs-related buttons Gnus will show. | |
7595 | The higher the number, the more buttons will appear and the more false | |
7596 | positives are possible. Note that you can set this variable local to | |
7597 | specific groups. Setting it higher in Emacs or Gnus related groups is | |
7598 | probably a good idea. See Info node `(gnus)Group Parameters' and the variable | |
7599 | `gnus-parameters' on how to set variables in specific groups." | |
bf247b6e | 7600 | :version "22.1" |
23f87bed MB |
7601 | :group 'gnus-article-buttons |
7602 | :link '(custom-manual "(gnus)Group Parameters") | |
7603 | :type 'integer) | |
7604 | ||
7605 | (defcustom gnus-button-message-level 5 | |
7606 | "*Integer that says how many buttons for news or mail messages will appear. | |
7607 | The higher the number, the more buttons will appear and the more false | |
7608 | positives are possible." | |
7609 | ;; mail addresses, MIDs, URLs for news, ... | |
bf247b6e | 7610 | :version "22.1" |
23f87bed MB |
7611 | :group 'gnus-article-buttons |
7612 | :type 'integer) | |
7613 | ||
7614 | (defcustom gnus-button-browse-level 5 | |
7615 | "*Integer that says how many buttons for browsing will appear. | |
7616 | The higher the number, the more buttons will appear and the more false | |
7617 | positives are possible." | |
7618 | ;; stuff handled by `browse-url' or `gnus-button-embedded-url' | |
bf247b6e | 7619 | :version "22.1" |
23f87bed MB |
7620 | :group 'gnus-article-buttons |
7621 | :type 'integer) | |
7622 | ||
eec82323 | 7623 | (defcustom gnus-button-alist |
23f87bed MB |
7624 | '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" |
7625 | 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3) | |
97f78c9b MB |
7626 | ((concat "\\b\\(nntp\\|news\\):\\(" |
7627 | gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)") | |
7628 | 0 t gnus-button-handle-news 2) | |
23f87bed MB |
7629 | ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)" |
7630 | 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5) | |
7631 | ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)" | |
7632 | 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3) | |
7633 | ;; RFC 2392 (Don't allow `/' in domain part --> CID) | |
7634 | ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)" | |
7635 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 2) | |
7636 | ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" | |
7637 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) | |
01c52d31 MB |
7638 | ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" |
7639 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) | |
23f87bed MB |
7640 | ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" |
7641 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 2) | |
7642 | ;; RFC 2368 (The mailto URL scheme) | |
531e5812 | 7643 | ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
23f87bed MB |
7644 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
7645 | ("\\bmailto:\\([^ \n\t]+\\)" | |
7646 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) | |
9eb59592 MB |
7647 | ;; Info Konqueror style <info:/foo/bar baz>. |
7648 | ;; Must come before " Gnus home-grown style". | |
7649 | ("\\binfo://?\\([^'\">\n\t]+\\)" | |
7650 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) | |
7651 | ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz> | |
23f87bed MB |
7652 | ("\\binfo://\\([^'\">\n\t ]+\\)" |
7653 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) | |
7654 | ;; Info GNOME style <info:foo#bar_baz> | |
7655 | ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)" | |
7656 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1) | |
7657 | ;; Info KDE style <info:(foo)bar baz> | |
7658 | ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>" | |
7659 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2) | |
7660 | ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0 | |
7661 | (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2) | |
9b3ebcb6 MB |
7662 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n,]*\\)\\)?" |
7663 | ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET' | |
7664 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0) | |
23f87bed | 7665 | ;; This is custom |
e425f18b | 7666 | ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0 |
01c52d31 | 7667 | (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2) |
23f87bed | 7668 | ;; Emacs help commands |
e425f18b | 7669 | ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed MB |
7670 | ;; regexp doesn't match arguments containing ` '. |
7671 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1) | |
e425f18b | 7672 | ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed | 7673 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1) |
e425f18b | 7674 | ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed | 7675 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1) |
e425f18b | 7676 | ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed MB |
7677 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1) |
7678 | ;; The following entries may lead to many false positives so don't enable | |
531e5812 MB |
7679 | ;; them by default (use a high button level). |
7680 | ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]" | |
7681 | ;; Exclude [.?] for URLs in gmane.emacs.cvs | |
23f87bed MB |
7682 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) |
7683 | ("`\\([a-z][-a-z0-9]+\\.el\\)'" | |
7684 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) | |
01c52d31 | 7685 | ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'" |
23f87bed MB |
7686 | 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1) |
7687 | ("`\\([a-z][a-z0-9]+-[a-z]+\\)'" | |
7688 | 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1) | |
7689 | ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)" | |
7690 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1) | |
e425f18b | 7691 | ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed | 7692 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1) |
e425f18b | 7693 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed | 7694 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2) |
e425f18b | 7695 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>" |
23f87bed | 7696 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2) |
87ba2830 | 7697 | ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" |
23f87bed MB |
7698 | ;; Unlike the other regexps we really have to require quoting |
7699 | ;; here to determine where it ends. | |
7700 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3) | |
7701 | ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)... | |
01c52d31 | 7702 | ("<URL: *\\([^\n<>]*\\)>" |
23f87bed MB |
7703 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
7704 | ;; RFC 2396 (2.4.3., delims) ... | |
01c52d31 | 7705 | ("\"URL: *\\([^\n\"]*\\)\"" |
23f87bed | 7706 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
eec82323 | 7707 | ;; Raw URLs. |
23f87bed MB |
7708 | (gnus-button-url-regexp |
7709 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7710 | ;; man pages | |
531e5812 | 7711 | ("\\b\\([a-z][a-z]+([1-9])\\)\\W" |
23f87bed MB |
7712 | 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3)) |
7713 | gnus-button-handle-man 1) | |
7714 | ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x) | |
531e5812 | 7715 | ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W" |
23f87bed MB |
7716 | 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5)) |
7717 | gnus-button-handle-man 1) | |
7718 | ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), | |
7719 | ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7) | |
531e5812 | 7720 | ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W" |
23f87bed | 7721 | 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1) |
01c52d31 MB |
7722 | ;; Recognizing patches to .el files. This is somewhat obscure, |
7723 | ;; but considering the percentage of Gnus users who hack Emacs | |
7724 | ;; Lisp files... | |
7725 | ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1 | |
7726 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) | |
7727 | ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1 | |
7728 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) | |
23f87bed MB |
7729 | ;; MID or mail: To avoid too many false positives we don't try to catch |
7730 | ;; all kind of allowed MIDs or mail addresses. Domain part must contain | |
7731 | ;; at least one dot. TLD must contain two or three chars or be a know TLD | |
7732 | ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist' | |
7733 | ;; so that non-ambiguous entries (see above) match first. | |
7734 | (gnus-button-mid-or-mail-regexp | |
7735 | 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1)) | |
6748645f | 7736 | "*Alist of regexps matching buttons in article bodies. |
eec82323 LMI |
7737 | |
7738 | Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where | |
23f87bed MB |
7739 | REGEXP: is the string (case insensitive) matching text around the button (can |
7740 | also be Lisp expression evaluating to a string), | |
eec82323 | 7741 | BUTTON: is the number of the regexp grouping actually matching the button, |
4e7d0221 | 7742 | FORM: is a Lisp expression which must eval to true for the button to |
eec82323 LMI |
7743 | be added, |
7744 | CALLBACK: is the function to call when the user push this button, and each | |
7745 | PAR: is a number of a regexp grouping whose text will be passed to CALLBACK. | |
7746 | ||
7747 | CALLBACK can also be a variable, in that case the value of that | |
7748 | variable it the real callback function." | |
7749 | :group 'gnus-article-buttons | |
23f87bed | 7750 | :type '(repeat (list (choice regexp variable sexp) |
eec82323 LMI |
7751 | (integer :tag "Button") |
7752 | (sexp :tag "Form") | |
7753 | (function :tag "Callback") | |
7754 | (repeat :tag "Par" | |
7755 | :inline t | |
7756 | (integer :tag "Regexp group"))))) | |
60ece9b0 | 7757 | (put 'gnus-button-alist 'risky-local-variable t) |
eec82323 LMI |
7758 | |
7759 | (defcustom gnus-header-button-alist | |
23f87bed MB |
7760 | '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>" |
7761 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 0) | |
7762 | ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" | |
7763 | 1 (>= gnus-button-message-level 0) gnus-button-reply 1) | |
eec82323 | 7764 | ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" |
fa9a04e1 | 7765 | 0 (>= gnus-button-message-level 0) gnus-msg-mail 0) |
23f87bed MB |
7766 | ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp |
7767 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7768 | ("^Subject:" gnus-button-url-regexp | |
7769 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7770 | ("^[^:]+:" gnus-button-url-regexp | |
7771 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
01c52d31 MB |
7772 | ("^OpenPGP:.*url=" gnus-button-url-regexp |
7773 | 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0) | |
531e5812 | 7774 | ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
23f87bed MB |
7775 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
7776 | ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)" | |
7777 | 1 (>= gnus-button-message-level 0) gnus-button-message-id 4)) | |
6748645f | 7778 | "*Alist of headers and regexps to match buttons in article heads. |
eec82323 LMI |
7779 | |
7780 | This alist is very similar to `gnus-button-alist', except that each | |
7781 | alist has an additional HEADER element first in each entry: | |
7782 | ||
7783 | \(HEADER REGEXP BUTTON FORM CALLBACK PAR) | |
7784 | ||
7785 | HEADER is a regexp to match a header. For a fuller explanation, see | |
7786 | `gnus-button-alist'." | |
7787 | :group 'gnus-article-buttons | |
7788 | :group 'gnus-article-headers | |
7789 | :type '(repeat (list (regexp :tag "Header") | |
23f87bed | 7790 | (choice regexp variable) |
eec82323 LMI |
7791 | (integer :tag "Button") |
7792 | (sexp :tag "Form") | |
7793 | (function :tag "Callback") | |
7794 | (repeat :tag "Par" | |
7795 | :inline t | |
7796 | (integer :tag "Regexp group"))))) | |
60ece9b0 | 7797 | (put 'gnus-header-button-alist 'risky-local-variable t) |
eec82323 | 7798 | |
eec82323 LMI |
7799 | ;;; Commands: |
7800 | ||
7801 | (defun gnus-article-push-button (event) | |
7802 | "Check text under the mouse pointer for a callback function. | |
7803 | If the text under the mouse pointer has a `gnus-callback' property, | |
7804 | call it with the value of the `gnus-data' text property." | |
7805 | (interactive "e") | |
7806 | (set-buffer (window-buffer (posn-window (event-start event)))) | |
7807 | (let* ((pos (posn-point (event-start event))) | |
23f87bed | 7808 | (data (get-text-property pos 'gnus-data)) |
eec82323 | 7809 | (fun (get-text-property pos 'gnus-callback))) |
6748645f | 7810 | (goto-char pos) |
eec82323 LMI |
7811 | (when fun |
7812 | (funcall fun data)))) | |
7813 | ||
7814 | (defun gnus-article-press-button () | |
7815 | "Check text at point for a callback function. | |
7816 | If the text at point has a `gnus-callback' property, | |
7817 | call it with the value of the `gnus-data' text property." | |
7818 | (interactive) | |
23f87bed MB |
7819 | (let ((data (get-text-property (point) 'gnus-data)) |
7820 | (fun (get-text-property (point) 'gnus-callback))) | |
eec82323 LMI |
7821 | (when fun |
7822 | (funcall fun data)))) | |
7823 | ||
eec82323 LMI |
7824 | (defun gnus-article-highlight (&optional force) |
7825 | "Highlight current article. | |
7826 | This function calls `gnus-article-highlight-headers', | |
7827 | `gnus-article-highlight-citation', | |
7828 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
7829 | do the highlighting. See the documentation for those functions." | |
7830 | (interactive (list 'force)) | |
7831 | (gnus-article-highlight-headers) | |
7832 | (gnus-article-highlight-citation force) | |
7833 | (gnus-article-highlight-signature) | |
a2e3ac99 | 7834 | (gnus-article-add-buttons) |
eec82323 LMI |
7835 | (gnus-article-add-buttons-to-head)) |
7836 | ||
7837 | (defun gnus-article-highlight-some (&optional force) | |
7838 | "Highlight current article. | |
7839 | This function calls `gnus-article-highlight-headers', | |
7840 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
7841 | do the highlighting. See the documentation for those functions." | |
7842 | (interactive (list 'force)) | |
7843 | (gnus-article-highlight-headers) | |
7844 | (gnus-article-highlight-signature) | |
7845 | (gnus-article-add-buttons)) | |
7846 | ||
7847 | (defun gnus-article-highlight-headers () | |
7848 | "Highlight article headers as specified by `gnus-header-face-alist'." | |
7849 | (interactive) | |
01c52d31 MB |
7850 | (gnus-with-article-headers |
7851 | (let (regexp header-face field-face from hpoints fpoints) | |
7852 | (dolist (entry gnus-header-face-alist) | |
7853 | (goto-char (point-min)) | |
7854 | (setq regexp (concat "^\\(" | |
7855 | (if (string-equal "" (nth 0 entry)) | |
7856 | "[^\t ]" | |
7857 | (nth 0 entry)) | |
7858 | "\\)") | |
7859 | header-face (nth 1 entry) | |
7860 | field-face (nth 2 entry)) | |
7861 | (while (and (re-search-forward regexp nil t) | |
7862 | (not (eobp))) | |
7863 | (beginning-of-line) | |
7864 | (setq from (point)) | |
7865 | (unless (search-forward ":" nil t) | |
7866 | (forward-char 1)) | |
7867 | (when (and header-face | |
7868 | (not (memq (point) hpoints))) | |
7869 | (push (point) hpoints) | |
7870 | (gnus-put-text-property from (point) 'face header-face)) | |
7871 | (when (and field-face | |
7872 | (not (memq (setq from (point)) fpoints))) | |
7873 | (push from fpoints) | |
7874 | (if (re-search-forward "^[^ \t]" nil t) | |
7875 | (forward-char -2) | |
7876 | (goto-char (point-max))) | |
7877 | (gnus-put-text-property from (point) 'face field-face))))))) | |
eec82323 LMI |
7878 | |
7879 | (defun gnus-article-highlight-signature () | |
7880 | "Highlight the signature in an article. | |
7881 | It does this by highlighting everything after | |
0f49874b | 7882 | `gnus-signature-separator' using the face `gnus-signature'." |
eec82323 | 7883 | (interactive) |
01c52d31 MB |
7884 | (gnus-with-article-buffer |
7885 | (let ((inhibit-point-motion-hooks t)) | |
eec82323 LMI |
7886 | (save-restriction |
7887 | (when (and gnus-signature-face | |
7888 | (gnus-article-narrow-to-signature)) | |
01c52d31 | 7889 | (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t) |
eec82323 LMI |
7890 | 'face gnus-signature-face) |
7891 | (widen) | |
7892 | (gnus-article-search-signature) | |
7893 | (let ((start (match-beginning 0)) | |
7894 | (end (set-marker (make-marker) (1+ (match-end 0))))) | |
7895 | (gnus-article-add-button start (1- end) 'gnus-signature-toggle | |
7896 | end))))))) | |
7897 | ||
7898 | (defun gnus-button-in-region-p (b e prop) | |
7899 | "Say whether PROP exists in the region." | |
7900 | (text-property-not-all b e prop nil)) | |
7901 | ||
672022e7 | 7902 | (defun gnus-article-add-buttons () |
eec82323 LMI |
7903 | "Find external references in the article and make buttons of them. |
7904 | \"External references\" are things like Message-IDs and URLs, as | |
7905 | specified by `gnus-button-alist'." | |
672022e7 | 7906 | (interactive) |
01c52d31 MB |
7907 | (gnus-with-article-buffer |
7908 | (let ((inhibit-point-motion-hooks t) | |
eec82323 LMI |
7909 | (case-fold-search t) |
7910 | (alist gnus-button-alist) | |
7911 | beg entry regexp) | |
eec82323 | 7912 | ;; We skip the headers. |
16409b0b | 7913 | (article-goto-body) |
eec82323 LMI |
7914 | (setq beg (point)) |
7915 | (while (setq entry (pop alist)) | |
23f87bed | 7916 | (setq regexp (eval (car entry))) |
eec82323 LMI |
7917 | (goto-char beg) |
7918 | (while (re-search-forward regexp nil t) | |
01c52d31 MB |
7919 | (let ((start (match-beginning (nth 1 entry))) |
7920 | (end (match-end (nth 1 entry))) | |
7921 | (from (match-beginning 0))) | |
672022e7 | 7922 | (when (and (eval (nth 2 entry)) |
eec82323 LMI |
7923 | (not (gnus-button-in-region-p |
7924 | start end 'gnus-callback))) | |
7925 | ;; That optional form returned non-nil, so we add the | |
7926 | ;; button. | |
01c52d31 | 7927 | (setq from (set-marker (make-marker) from)) |
01c52d31 MB |
7928 | (unless (and (eq (car entry) 'gnus-button-url-regexp) |
7929 | (gnus-article-extend-url-button from start end)) | |
7930 | (gnus-article-add-button start end | |
672022e7 | 7931 | 'gnus-button-push (list from entry)) |
7426b4f7 LMI |
7932 | (gnus-put-text-property |
7933 | start end | |
10e91ca9 LMI |
7934 | 'gnus-string (buffer-substring-no-properties |
7935 | start end)))))))))) | |
01c52d31 MB |
7936 | |
7937 | (defun gnus-article-extend-url-button (beg start end) | |
7938 | "Extend url button if url is folded into two or more lines. | |
7939 | Return non-nil if button is extended. BEG is a marker that points to | |
7940 | the beginning position of a text containing url. START and END are | |
7941 | the endpoints of a url button before it is extended. The concatenated | |
7942 | url is put as the `gnus-button-url' overlay property on the button." | |
7943 | (let ((opoint (point)) | |
7944 | (points (list start end)) | |
7945 | url delim regexp) | |
7946 | (prog1 | |
7947 | (when (and (progn | |
7948 | (goto-char end) | |
7949 | (not (looking-at "[\t ]*[\">]"))) | |
7950 | (progn | |
7951 | (goto-char start) | |
7952 | (string-match | |
7953 | "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'" | |
7954 | (buffer-substring (point-at-bol) start))) | |
7955 | (progn | |
7956 | (setq url (list (buffer-substring start end)) | |
7957 | delim (if (match-beginning 1) ">" "\"")) | |
7958 | (beginning-of-line) | |
7959 | (setq regexp (concat | |
7960 | (when (and (looking-at | |
7961 | message-cite-prefix-regexp) | |
7962 | (< (match-end 0) start)) | |
7963 | (regexp-quote (match-string 0))) | |
7964 | "\ | |
7965 | \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*" | |
7966 | delim "\\)")) | |
7967 | (while (progn | |
7968 | (forward-line 1) | |
7969 | (and (looking-at regexp) | |
7970 | (prog1 | |
7971 | (match-beginning 1) | |
7972 | (push (or (match-string 2) | |
7973 | (match-string 1)) | |
7974 | url) | |
7975 | (push (setq end (or (match-end 2) | |
7976 | (match-end 1))) | |
7977 | points) | |
7978 | (push (or (match-beginning 2) | |
7979 | (match-beginning 1)) | |
7980 | points))))) | |
7981 | (match-beginning 2))) | |
7982 | (let (gnus-article-mouse-face widget-mouse-face) | |
7983 | (while points | |
7984 | (gnus-article-add-button (pop points) (pop points) | |
dbca79f8 KY |
7985 | 'gnus-button-push |
7986 | (list beg (assq 'gnus-button-url-regexp | |
7987 | gnus-button-alist))))) | |
01c52d31 MB |
7988 | (let ((overlay (gnus-make-overlay start end))) |
7989 | (gnus-overlay-put overlay 'evaporate t) | |
7990 | (gnus-overlay-put overlay 'gnus-button-url | |
7991 | (list (mapconcat 'identity (nreverse url) ""))) | |
7992 | (when gnus-article-mouse-face | |
7993 | (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face))) | |
7994 | t) | |
7995 | (goto-char opoint)))) | |
eec82323 LMI |
7996 | |
7997 | ;; Add buttons to the head of an article. | |
7998 | (defun gnus-article-add-buttons-to-head () | |
7999 | "Add buttons to the head of the article." | |
8000 | (interactive) | |
01c52d31 MB |
8001 | (gnus-with-article-headers |
8002 | (let (beg end) | |
8003 | (dolist (entry gnus-header-button-alist) | |
8004 | ;; Each alist entry. | |
8005 | (goto-char (point-min)) | |
8006 | (while (re-search-forward (car entry) nil t) | |
8007 | ;; Each header matching the entry. | |
8008 | (setq beg (match-beginning 0)) | |
8009 | (setq end (or (and (re-search-forward "^[^ \t]" nil t) | |
8010 | (match-beginning 0)) | |
8011 | (point-max))) | |
8012 | (goto-char beg) | |
8013 | (while (re-search-forward (eval (nth 1 entry)) end t) | |
8014 | ;; Each match within a header. | |
8015 | (let* ((entry (cdr entry)) | |
8016 | (start (match-beginning (nth 1 entry))) | |
8017 | (end (match-end (nth 1 entry))) | |
8018 | (form (nth 2 entry))) | |
8019 | (goto-char (match-end 0)) | |
8020 | (when (eval form) | |
8021 | (gnus-article-add-button | |
8022 | start end (nth 3 entry) | |
8023 | (buffer-substring (match-beginning (nth 4 entry)) | |
8024 | (match-end (nth 4 entry))))))) | |
8025 | (goto-char end)))))) | |
eec82323 LMI |
8026 | |
8027 | ;;; External functions: | |
8028 | ||
b1992461 | 8029 | (defun gnus-article-add-button (from to fun &optional data text) |
eec82323 LMI |
8030 | "Create a button between FROM and TO with callback FUN and data DATA." |
8031 | (when gnus-article-button-face | |
01c52d31 | 8032 | (gnus-overlay-put (gnus-make-overlay from to nil t) |
eec82323 LMI |
8033 | 'face gnus-article-button-face)) |
8034 | (gnus-add-text-properties | |
8035 | from to | |
8036 | (nconc (and gnus-article-mouse-face | |
8037 | (list gnus-mouse-face-prop gnus-article-mouse-face)) | |
8038 | (list 'gnus-callback fun) | |
16409b0b GM |
8039 | (and data (list 'gnus-data data)))) |
8040 | (widget-convert-button 'link from to :action 'gnus-widget-press-button | |
b1992461 | 8041 | :help-echo (or text "Follow the link") |
7426b4f7 | 8042 | :keymap gnus-url-button-map |
16409b0b | 8043 | :button-keymap gnus-widget-button-keymap)) |
eec82323 | 8044 | |
7426b4f7 LMI |
8045 | (defun gnus-article-copy-string () |
8046 | "Copy the string in the button to the kill ring." | |
8047 | (interactive) | |
8048 | (gnus-article-check-buffer) | |
10e91ca9 | 8049 | (let ((data (get-text-property (point) 'gnus-string))) |
7426b4f7 LMI |
8050 | (when data |
8051 | (with-temp-buffer | |
8052 | (insert data) | |
c25d60ab LMI |
8053 | (copy-region-as-kill (point-min) (point-max)) |
8054 | (message "Copied %s" data))))) | |
7426b4f7 | 8055 | |
eec82323 LMI |
8056 | ;;; Internal functions: |
8057 | ||
a8151ef7 | 8058 | (defun gnus-article-set-globals () |
01c52d31 | 8059 | (with-current-buffer gnus-summary-buffer |
a8151ef7 LMI |
8060 | (gnus-set-global-variables))) |
8061 | ||
eec82323 | 8062 | (defun gnus-signature-toggle (end) |
01c52d31 MB |
8063 | (gnus-with-article-buffer |
8064 | (let ((inhibit-point-motion-hooks t)) | |
520aa572 | 8065 | (if (text-property-any end (point-max) 'article-type 'signature) |
23f87bed MB |
8066 | (progn |
8067 | (gnus-delete-wash-type 'signature) | |
8068 | (gnus-remove-text-properties-when | |
8069 | 'article-type 'signature end (point-max) | |
8070 | (cons 'article-type (cons 'signature | |
8071 | gnus-hidden-properties)))) | |
8072 | (gnus-add-wash-type 'signature) | |
520aa572 SZ |
8073 | (gnus-add-text-properties-when |
8074 | 'article-type nil end (point-max) | |
8075 | (cons 'article-type (cons 'signature | |
23f87bed MB |
8076 | gnus-hidden-properties))))) |
8077 | (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist)) | |
8078 | (gnus-set-mode-line 'article)))) | |
eec82323 | 8079 | |
672022e7 | 8080 | (defun gnus-button-push (marker-and-entry) |
eec82323 LMI |
8081 | ;; Push button starting at MARKER. |
8082 | (save-excursion | |
672022e7 G |
8083 | (let* ((marker (car marker-and-entry)) |
8084 | (entry (cadr marker-and-entry)) | |
8085 | (regexp (car entry)) | |
8086 | (inhibit-point-motion-hooks t)) | |
8087 | (goto-char marker) | |
8088 | ;; This is obviously true, or something bad is happening :) | |
8089 | ;; But we need it to have the match-data | |
8090 | (when (looking-at (or (if (symbolp regexp) | |
8091 | (symbol-value regexp) | |
8092 | regexp))) | |
8093 | (let ((fun (nth 3 entry)) | |
8094 | (args (or (and (eq (car entry) 'gnus-button-url-regexp) | |
8095 | (get-char-property marker 'gnus-button-url)) | |
8096 | (mapcar (lambda (group) | |
8097 | (let ((string (match-string group))) | |
8098 | (set-text-properties | |
8099 | 0 (length string) nil string) | |
8100 | string)) | |
8101 | (nthcdr 4 entry))))) | |
8102 | ||
8103 | (cond | |
8104 | ((fboundp fun) | |
8105 | (apply fun args)) | |
8106 | ((and (boundp fun) | |
8107 | (fboundp (symbol-value fun))) | |
8108 | (apply (symbol-value fun) args)) | |
8109 | (t | |
8110 | (gnus-message 1 "You must define `%S' to use this button" | |
8111 | (cons fun args))))))))) | |
eec82323 | 8112 | |
23f87bed | 8113 | (defun gnus-parse-news-url (url) |
82a8ad04 | 8114 | (let (scheme server port group message-id articles) |
23f87bed MB |
8115 | (with-temp-buffer |
8116 | (insert url) | |
8117 | (goto-char (point-min)) | |
8118 | (when (looking-at "\\([A-Za-z]+\\):") | |
8119 | (setq scheme (match-string 1)) | |
8120 | (goto-char (match-end 0))) | |
82a8ad04 | 8121 | (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/") |
23f87bed | 8122 | (setq server (match-string 1)) |
82a8ad04 MB |
8123 | (setq port (if (stringp (match-string 3)) |
8124 | (string-to-number (match-string 3)) | |
8125 | (match-string 3))) | |
23f87bed MB |
8126 | (goto-char (match-end 0))) |
8127 | ||
8128 | (cond | |
8129 | ((looking-at "\\(.*@.*\\)") | |
8130 | (setq message-id (match-string 1))) | |
8131 | ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)") | |
8132 | (setq group (match-string 1) | |
8133 | articles (split-string (match-string 2) "-"))) | |
8134 | ((looking-at "\\([^/]+\\)/?") | |
8135 | (setq group (match-string 1))) | |
8136 | (t | |
8137 | (error "Unknown news URL syntax")))) | |
82a8ad04 | 8138 | (list scheme server port group message-id articles))) |
23f87bed MB |
8139 | |
8140 | (defun gnus-button-handle-news (url) | |
8141 | "Fetch a news URL." | |
82a8ad04 | 8142 | (destructuring-bind (scheme server port group message-id articles) |
23f87bed MB |
8143 | (gnus-parse-news-url url) |
8144 | (cond | |
8145 | (message-id | |
80de1778 | 8146 | (with-current-buffer gnus-summary-buffer |
23f87bed | 8147 | (if server |
ff4d3926 MB |
8148 | (let ((gnus-refer-article-method |
8149 | (nconc (list (list 'nntp server)) | |
8150 | gnus-refer-article-method)) | |
82a8ad04 | 8151 | (nntp-port-number (or port "nntp"))) |
ff4d3926 MB |
8152 | (gnus-message 7 "Fetching %s with %s" |
8153 | message-id gnus-refer-article-method) | |
23f87bed MB |
8154 | (gnus-summary-refer-article message-id)) |
8155 | (gnus-summary-refer-article message-id)))) | |
8156 | (group | |
8157 | (gnus-button-fetch-group url))))) | |
8158 | ||
01c52d31 MB |
8159 | (defun gnus-button-patch (library line) |
8160 | "Visit an Emacs Lisp library LIBRARY on line LINE." | |
8161 | (interactive) | |
8162 | (let ((file (locate-library (file-name-nondirectory library)))) | |
8163 | (unless file | |
8164 | (error "Couldn't find library %s" library)) | |
8165 | (find-file file) | |
5dcc825f GM |
8166 | (goto-char (point-min)) |
8167 | (forward-line (1- (string-to-number line))))) | |
01c52d31 | 8168 | |
23f87bed MB |
8169 | (defun gnus-button-handle-man (url) |
8170 | "Fetch a man page." | |
531e5812 MB |
8171 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) |
8172 | (when (eq gnus-button-man-handler 'woman) | |
8173 | (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" ""))) | |
8174 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) | |
23f87bed MB |
8175 | (funcall gnus-button-man-handler url)) |
8176 | ||
8177 | (defun gnus-button-handle-info-url (url) | |
8178 | "Fetch an info URL." | |
8179 | (setq url (mm-subst-char-in-string ?+ ?\ url)) | |
8180 | (cond | |
8181 | ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url) | |
8182 | (gnus-info-find-node | |
8183 | (concat "(" (or (gnus-url-unhex-string (match-string 1 url)) | |
8184 | "Gnus") | |
8185 | ")" (gnus-url-unhex-string (match-string 2 url))))) | |
8186 | ((string-match "([^)\"]+)[^\"]+" url) | |
8187 | (setq url | |
8188 | (gnus-replace-in-string | |
8189 | (gnus-replace-in-string url "[\n\t ]+" " ") "\"" "")) | |
8190 | (gnus-info-find-node url)) | |
8191 | (t (error "Can't parse %s" url)))) | |
8192 | ||
8193 | (defun gnus-button-handle-info-url-gnome (url) | |
8194 | "Fetch GNOME style info URL." | |
8195 | (setq url (mm-subst-char-in-string ?_ ?\ url)) | |
8196 | (if (string-match "\\([^#]+\\)#?\\(.*\\)" url) | |
8197 | (gnus-info-find-node | |
8198 | (concat "(" | |
bf247b6e | 8199 | (gnus-url-unhex-string |
23f87bed MB |
8200 | (match-string 1 url)) |
8201 | ")" | |
bf247b6e | 8202 | (or (gnus-url-unhex-string |
23f87bed MB |
8203 | (match-string 2 url)) |
8204 | "Top"))) | |
8205 | (error "Can't parse %s" url))) | |
8206 | ||
8207 | (defun gnus-button-handle-info-url-kde (url) | |
8208 | "Fetch KDE style info URL." | |
8209 | (gnus-info-find-node (gnus-url-unhex-string url))) | |
8210 | ||
9640c3bc GM |
8211 | ;; (info) will autoload info.el |
8212 | (declare-function Info-menu "info" (menu-item &optional fork)) | |
9b3ebcb6 | 8213 | (declare-function Info-index-next "info" (num)) |
9640c3bc | 8214 | |
23f87bed MB |
8215 | (defun gnus-button-handle-info-keystrokes (url) |
8216 | "Call `info' when pushing the corresponding URL button." | |
9b3ebcb6 MB |
8217 | ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'. |
8218 | (let (node indx comma) | |
8219 | (if (string-match | |
8220 | (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+" | |
8221 | "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" | |
e425f18b | 8222 | "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>" |
9b3ebcb6 MB |
8223 | "\\(?:[ \t\n,]*\\)\\)?") |
8224 | url) | |
8225 | (setq node (match-string 2 url) | |
8226 | indx (match-string 3 url)) | |
8227 | (error "Can't parse %s" url)) | |
8228 | (info) | |
8229 | (Info-directory) | |
8230 | (Info-menu node) | |
8231 | (when (> (length indx) 0) | |
e425f18b | 8232 | (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>" |
9b3ebcb6 MB |
8233 | "\\([ \t\n,]*\\)") |
8234 | indx) | |
8235 | (setq comma (match-string 2 indx)) | |
8236 | (setq indx (match-string 1 indx)) | |
8237 | (Info-index indx) | |
8238 | (when comma | |
8239 | (dotimes (i (with-temp-buffer | |
8240 | (insert comma) | |
8241 | ;; Note: the XEmacs version of `how-many' takes | |
8242 | ;; no optional argument. | |
8243 | (goto-char (point-min)) | |
8244 | (how-many ","))) | |
8245 | (Info-index-next 1))) | |
8246 | nil))) | |
1888e568 | 8247 | |
9d9cfd53 | 8248 | (autoload 'pgg-snarf-keys-region "pgg") |
1888e568 GM |
8249 | ;; Called after pgg-snarf-keys-region, which autoloads pgg.el. |
8250 | (declare-function pgg-display-output-buffer "pgg" (start end status)) | |
23f87bed | 8251 | |
01c52d31 MB |
8252 | (defun gnus-button-openpgp (url) |
8253 | "Retrieve and add an OpenPGP key given URL from an OpenPGP header." | |
8254 | (with-temp-buffer | |
8255 | (mm-url-insert-file-contents-external url) | |
8256 | (pgg-snarf-keys-region (point-min) (point-max)) | |
8257 | (pgg-display-output-buffer nil nil nil))) | |
8258 | ||
eec82323 LMI |
8259 | (defun gnus-button-message-id (message-id) |
8260 | "Fetch MESSAGE-ID." | |
01c52d31 | 8261 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
8262 | (gnus-summary-refer-article message-id))) |
8263 | ||
01c52d31 | 8264 | (defun gnus-button-fetch-group (address &rest ignore) |
eec82323 | 8265 | "Fetch GROUP specified by ADDRESS." |
01c52d31 MB |
8266 | (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'" |
8267 | address) | |
8268 | ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function' | |
8269 | ;; for nntp:// and news:// | |
8270 | (setq address (match-string 3 address))) | |
eec82323 LMI |
8271 | (if (not (string-match "[:/]" address)) |
8272 | ;; This is just a simple group url. | |
8273 | (gnus-group-read-ephemeral-group address gnus-select-method) | |
23f87bed MB |
8274 | (if (not |
8275 | (string-match | |
8276 | "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?" | |
8277 | address)) | |
eec82323 LMI |
8278 | (error "Can't parse %s" address) |
8279 | (gnus-group-read-ephemeral-group | |
8280 | (match-string 4 address) | |
8281 | `(nntp ,(match-string 1 address) | |
8282 | (nntp-address ,(match-string 1 address)) | |
8283 | (nntp-port-number ,(if (match-end 3) | |
8284 | (match-string 3 address) | |
23f87bed MB |
8285 | "nntp"))) |
8286 | nil nil nil | |
e9bd5782 | 8287 | (and (match-end 6) (list (string-to-number (match-string 6 address)))))))) |
eec82323 | 8288 | |
eec82323 LMI |
8289 | (defun gnus-url-parse-query-string (query &optional downcase) |
8290 | (let (retval pairs cur key val) | |
16409b0b | 8291 | (setq pairs (split-string query "&")) |
eec82323 LMI |
8292 | (while pairs |
8293 | (setq cur (car pairs) | |
23f87bed | 8294 | pairs (cdr pairs)) |
eec82323 | 8295 | (if (not (string-match "=" cur)) |
23f87bed MB |
8296 | nil ; Grace |
8297 | (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0))) | |
8298 | val (gnus-url-unhex-string (substring cur (match-end 0) nil) t)) | |
8299 | (if downcase | |
8300 | (setq key (downcase key))) | |
8301 | (setq cur (assoc key retval)) | |
8302 | (if cur | |
8303 | (setcdr cur (cons val (cdr cur))) | |
8304 | (setq retval (cons (list key val) retval))))) | |
eec82323 LMI |
8305 | retval)) |
8306 | ||
eec82323 LMI |
8307 | (defun gnus-url-mailto (url) |
8308 | ;; Send mail to someone | |
1e91d0eb | 8309 | (setq url (replace-regexp-in-string "\n" " " url)) |
eec82323 LMI |
8310 | (when (string-match "mailto:/*\\(.*\\)" url) |
8311 | (setq url (substring url (match-beginning 1) nil))) | |
6748645f | 8312 | (let (to args subject func) |
23f87bed MB |
8313 | (setq args (gnus-url-parse-query-string |
8314 | (if (string-match "^\\?" url) | |
8315 | (substring url 1) | |
8316 | (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url) | |
8317 | (concat "to=" (match-string 1 url) "&" | |
8318 | (match-string 2 url)) | |
440b1345 | 8319 | (concat "to=" url)))) |
23f87bed MB |
8320 | subject (cdr-safe (assoc "subject" args))) |
8321 | (gnus-msg-mail) | |
eec82323 LMI |
8322 | (while args |
8323 | (setq func (intern-soft (concat "message-goto-" (downcase (caar args))))) | |
8324 | (if (fboundp func) | |
23f87bed MB |
8325 | (funcall func) |
8326 | (message-position-on-field (caar args))) | |
8327 | (insert (gnus-replace-in-string | |
8328 | (mapconcat 'identity (reverse (cdar args)) ", ") | |
8329 | "\r\n" "\n" t)) | |
eec82323 LMI |
8330 | (setq args (cdr args))) |
8331 | (if subject | |
23f87bed | 8332 | (message-goto-body) |
eec82323 LMI |
8333 | (message-goto-subject)))) |
8334 | ||
eec82323 | 8335 | (defun gnus-button-embedded-url (address) |
e0bad764 | 8336 | "Activate ADDRESS with `browse-url'." |
1b978bfc | 8337 | (browse-url (gnus-strip-whitespace address))) |
eec82323 LMI |
8338 | |
8339 | ;;; Next/prev buttons in the article buffer. | |
8340 | ||
8341 | (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") | |
8342 | (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") | |
8343 | ||
23f87bed MB |
8344 | (defvar gnus-prev-page-map |
8345 | (let ((map (make-sparse-keymap))) | |
23f87bed MB |
8346 | (define-key map gnus-mouse-2 'gnus-button-prev-page) |
8347 | (define-key map "\r" 'gnus-button-prev-page) | |
8348 | map)) | |
8349 | ||
8350 | (defvar gnus-next-page-map | |
8351 | (let ((map (make-sparse-keymap))) | |
23f87bed MB |
8352 | (define-key map gnus-mouse-2 'gnus-button-next-page) |
8353 | (define-key map "\r" 'gnus-button-next-page) | |
8354 | map)) | |
eec82323 LMI |
8355 | |
8356 | (defun gnus-insert-prev-page-button () | |
01c52d31 | 8357 | (let ((b (point)) e |
23f87bed | 8358 | (inhibit-read-only t)) |
eec82323 LMI |
8359 | (gnus-eval-format |
8360 | gnus-prev-page-line-format nil | |
01c52d31 MB |
8361 | `(keymap ,gnus-prev-page-map |
8362 | gnus-prev t | |
8363 | gnus-callback gnus-article-button-prev-page | |
8364 | article-type annotation)) | |
8365 | (setq e (if (bolp) | |
8366 | ;; Exclude a newline. | |
8367 | (1- (point)) | |
8368 | (point))) | |
8369 | (when gnus-article-button-face | |
8370 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8371 | 'face gnus-article-button-face)) | |
23f87bed | 8372 | (widget-convert-button |
01c52d31 | 8373 | 'link b e |
23f87bed MB |
8374 | :action 'gnus-button-prev-page |
8375 | :button-keymap gnus-prev-page-map))) | |
8376 | ||
8377 | (defun gnus-button-next-page (&optional args more-args) | |
eec82323 LMI |
8378 | "Go to the next page." |
8379 | (interactive) | |
8380 | (let ((win (selected-window))) | |
23f87bed | 8381 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8382 | (gnus-article-next-page) |
8383 | (select-window win))) | |
8384 | ||
23f87bed | 8385 | (defun gnus-button-prev-page (&optional args more-args) |
eec82323 LMI |
8386 | "Go to the prev page." |
8387 | (interactive) | |
8388 | (let ((win (selected-window))) | |
23f87bed | 8389 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8390 | (gnus-article-prev-page) |
8391 | (select-window win))) | |
8392 | ||
8393 | (defun gnus-insert-next-page-button () | |
01c52d31 | 8394 | (let ((b (point)) e |
23f87bed | 8395 | (inhibit-read-only t)) |
eec82323 | 8396 | (gnus-eval-format gnus-next-page-line-format nil |
01c52d31 MB |
8397 | `(keymap ,gnus-next-page-map |
8398 | gnus-next t | |
8399 | gnus-callback gnus-article-button-next-page | |
8400 | article-type annotation)) | |
8401 | (setq e (if (bolp) | |
8402 | ;; Exclude a newline. | |
8403 | (1- (point)) | |
8404 | (point))) | |
8405 | (when gnus-article-button-face | |
8406 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8407 | 'face gnus-article-button-face)) | |
23f87bed | 8408 | (widget-convert-button |
01c52d31 | 8409 | 'link b e |
23f87bed MB |
8410 | :action 'gnus-button-next-page |
8411 | :button-keymap gnus-next-page-map))) | |
eec82323 LMI |
8412 | |
8413 | (defun gnus-article-button-next-page (arg) | |
8414 | "Go to the next page." | |
8415 | (interactive "P") | |
8416 | (let ((win (selected-window))) | |
23f87bed | 8417 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8418 | (gnus-article-next-page) |
8419 | (select-window win))) | |
8420 | ||
8421 | (defun gnus-article-button-prev-page (arg) | |
8422 | "Go to the prev page." | |
8423 | (interactive "P") | |
8424 | (let ((win (selected-window))) | |
23f87bed | 8425 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8426 | (gnus-article-prev-page) |
8427 | (select-window win))) | |
8428 | ||
16409b0b GM |
8429 | (defvar gnus-decode-header-methods |
8430 | '(mail-decode-encoded-word-region) | |
8431 | "List of methods used to decode headers. | |
8432 | ||
8433 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item | |
4e7d0221 | 8434 | is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a |
23f87bed | 8435 | \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups |
16409b0b GM |
8436 | whose names match REGEXP. |
8437 | ||
8438 | For example: | |
8f688cb0 | 8439 | \((\"chinese\" . gnus-decode-encoded-word-region-by-guess) |
16409b0b GM |
8440 | mail-decode-encoded-word-region |
8441 | (\"chinese\" . rfc1843-decode-region)) | |
8442 | ") | |
8443 | ||
8444 | (defvar gnus-decode-header-methods-cache nil) | |
8445 | ||
8446 | (defun gnus-multi-decode-header (start end) | |
8447 | "Apply the functions from `gnus-encoded-word-methods' that match." | |
8448 | (unless (and gnus-decode-header-methods-cache | |
8449 | (eq gnus-newsgroup-name | |
8450 | (car gnus-decode-header-methods-cache))) | |
8451 | (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name)) | |
01c52d31 MB |
8452 | (dolist (x gnus-decode-header-methods) |
8453 | (if (symbolp x) | |
8454 | (nconc gnus-decode-header-methods-cache (list x)) | |
8455 | (if (and gnus-newsgroup-name | |
8456 | (string-match (car x) gnus-newsgroup-name)) | |
8457 | (nconc gnus-decode-header-methods-cache | |
8458 | (list (cdr x))))))) | |
16409b0b GM |
8459 | (let ((xlist gnus-decode-header-methods-cache)) |
8460 | (pop xlist) | |
8461 | (save-restriction | |
8462 | (narrow-to-region start end) | |
8463 | (while xlist | |
8464 | (funcall (pop xlist) (point-min) (point-max)))))) | |
8465 | ||
8466 | ;;; | |
8467 | ;;; Treatment top-level handling. | |
8468 | ;;; | |
8469 | ||
389b76fa G |
8470 | (defvar gnus-inhibit-article-treatments nil) |
8471 | ||
c497474b GM |
8472 | (defun gnus-treat-article (gnus-treat-condition |
8473 | &optional part-number total-parts gnus-treat-type) | |
8474 | (let ((gnus-treat-length (- (point-max) (point-min))) | |
16409b0b GM |
8475 | (alist gnus-treatment-function-alist) |
8476 | (article-goto-body-goes-to-point-min-p t) | |
8477 | (treated-type | |
c497474b | 8478 | (or (not gnus-treat-type) |
16409b0b GM |
8479 | (catch 'found |
8480 | (let ((list gnus-article-treat-types)) | |
8481 | (while list | |
c497474b | 8482 | (when (string-match (pop list) gnus-treat-type) |
16409b0b GM |
8483 | (throw 'found t))))))) |
8484 | (highlightp (gnus-visual-p 'article-highlight 'highlight)) | |
8485 | val elem) | |
8486 | (gnus-run-hooks 'gnus-part-display-hook) | |
23f87bed | 8487 | (dolist (elem alist) |
16409b0b GM |
8488 | (setq val |
8489 | (save-excursion | |
23f87bed MB |
8490 | (when (gnus-buffer-live-p gnus-summary-buffer) |
8491 | (set-buffer gnus-summary-buffer)) | |
16409b0b GM |
8492 | (symbol-value (car elem)))) |
8493 | (when (and (or (consp val) | |
8494 | treated-type) | |
389b76fa | 8495 | (or (not gnus-inhibit-article-treatments) |
c497474b | 8496 | (eq gnus-treat-condition 'head)) |
16409b0b GM |
8497 | (gnus-treat-predicate val) |
8498 | (or (not (get (car elem) 'highlight)) | |
8499 | highlightp)) | |
8500 | (save-restriction | |
8501 | (funcall (cadr elem))))))) | |
8502 | ||
8503 | ;; Dynamic variables. | |
9efa445f DN |
8504 | (defvar part-number) |
8505 | (defvar total-parts) | |
c497474b GM |
8506 | (defvar gnus-treat-type) |
8507 | (defvar gnus-treat-condition) | |
8508 | (defvar gnus-treat-length) | |
e0bad764 | 8509 | |
16409b0b GM |
8510 | (defun gnus-treat-predicate (val) |
8511 | (cond | |
8512 | ((null val) | |
8513 | nil) | |
c497474b GM |
8514 | (gnus-treat-condition |
8515 | (eq gnus-treat-condition val)) | |
16409b0b GM |
8516 | ((and (listp val) |
8517 | (stringp (car val))) | |
8518 | (apply 'gnus-or (mapcar `(lambda (s) | |
8519 | (string-match s ,(or gnus-newsgroup-name ""))) | |
8520 | val))) | |
8521 | ((listp val) | |
8522 | (let ((pred (pop val))) | |
8523 | (cond | |
8524 | ((eq pred 'or) | |
8525 | (apply 'gnus-or (mapcar 'gnus-treat-predicate val))) | |
8526 | ((eq pred 'and) | |
8527 | (apply 'gnus-and (mapcar 'gnus-treat-predicate val))) | |
8528 | ((eq pred 'not) | |
8529 | (not (gnus-treat-predicate (car val)))) | |
8530 | ((eq pred 'typep) | |
c497474b | 8531 | (equal (car val) gnus-treat-type)) |
47cc1156 G |
8532 | ((functionp pred) |
8533 | (funcall pred)) | |
16409b0b GM |
8534 | (t |
8535 | (error "%S is not a valid predicate" pred))))) | |
16409b0b GM |
8536 | ((eq val t) |
8537 | t) | |
8538 | ((eq val 'head) | |
8539 | nil) | |
01c52d31 MB |
8540 | ((eq val 'first) |
8541 | (eq part-number 1)) | |
16409b0b GM |
8542 | ((eq val 'last) |
8543 | (eq part-number total-parts)) | |
8544 | ((numberp val) | |
c497474b | 8545 | (< gnus-treat-length val)) |
16409b0b GM |
8546 | (t |
8547 | (error "%S is not a valid value" val)))) | |
8548 | ||
23f87bed MB |
8549 | (defun gnus-article-encrypt-body (protocol &optional n) |
8550 | "Encrypt the article body." | |
8551 | (interactive | |
8552 | (list | |
8553 | (or gnus-article-encrypt-protocol | |
229b59da G |
8554 | (gnus-completing-read "Encrypt protocol" |
8555 | (mapcar 'car gnus-article-encrypt-protocol-alist) | |
8556 | t)) | |
23f87bed | 8557 | current-prefix-arg)) |
bbbe940b MB |
8558 | ;; User might hit `K E' instead of `K e', so prompt once. |
8559 | (when (and gnus-article-encrypt-protocol | |
8560 | gnus-novice-user) | |
8561 | (unless (gnus-y-or-n-p "Really encrypt article(s)? ") | |
d93ec753 | 8562 | (error "Encrypt aborted"))) |
23f87bed MB |
8563 | (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist)))) |
8564 | (unless func | |
998a5a95 | 8565 | (error "Can't find the encrypt protocol %s" protocol)) |
23f87bed MB |
8566 | (if (member gnus-newsgroup-name '("nndraft:delayed" |
8567 | "nndraft:drafts" | |
8568 | "nndraft:queue")) | |
8569 | (error "Can't encrypt the article in group %s" | |
8570 | gnus-newsgroup-name)) | |
8571 | (gnus-summary-iterate n | |
80de1778 | 8572 | (with-current-buffer gnus-summary-buffer |
23f87bed MB |
8573 | (let ((mail-parse-charset gnus-newsgroup-charset) |
8574 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) | |
8575 | (summary-buffer gnus-summary-buffer) | |
8576 | references point) | |
8577 | (gnus-set-global-variables) | |
8578 | (when (gnus-group-read-only-p) | |
8579 | (error "The current newsgroup does not support article encrypt")) | |
8580 | (gnus-summary-show-article t) | |
8581 | (setq references | |
8582 | (or (mail-header-references gnus-current-headers) "")) | |
8583 | (set-buffer gnus-article-buffer) | |
8584 | (let* ((inhibit-read-only t) | |
8585 | (headers | |
8586 | (mapcar (lambda (field) | |
8587 | (and (save-restriction | |
8588 | (message-narrow-to-head) | |
8589 | (goto-char (point-min)) | |
8590 | (search-forward field nil t)) | |
8591 | (prog2 | |
8592 | (message-narrow-to-field) | |
8593 | (buffer-string) | |
8594 | (delete-region (point-min) (point-max)) | |
8595 | (widen)))) | |
8596 | '("Content-Type:" "Content-Transfer-Encoding:" | |
8597 | "Content-Disposition:")))) | |
8598 | (message-narrow-to-head) | |
8599 | (message-remove-header "MIME-Version") | |
8600 | (goto-char (point-max)) | |
8601 | (setq point (point)) | |
8602 | (insert (apply 'concat headers)) | |
8603 | (widen) | |
8604 | (narrow-to-region point (point-max)) | |
8605 | (let ((message-options message-options)) | |
8606 | (message-options-set 'message-sender user-mail-address) | |
8607 | (message-options-set 'message-recipients user-mail-address) | |
8608 | (message-options-set 'message-sign-encrypt 'not) | |
8609 | (funcall func)) | |
8610 | (goto-char (point-min)) | |
8611 | (insert "MIME-Version: 1.0\n") | |
8612 | (widen) | |
8613 | (gnus-summary-edit-article-done | |
8614 | references nil summary-buffer t)) | |
8615 | (when gnus-keep-backlog | |
8616 | (gnus-backlog-remove-article | |
8617 | (car gnus-article-current) (cdr gnus-article-current))) | |
8ccbef23 | 8618 | (gnus-flush-original-article-buffer) |
23f87bed MB |
8619 | (when gnus-use-cache |
8620 | (gnus-cache-update-article | |
8621 | (car gnus-article-current) (cdr gnus-article-current)))))))) | |
8622 | ||
8623 | (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n" | |
8624 | "The following specs can be used: | |
8625 | %t The security MIME type | |
8626 | %i Additional info | |
8627 | %d Details | |
8628 | %D Details if button is pressed") | |
8629 | ||
8630 | (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n" | |
8631 | "The following specs can be used: | |
8632 | %t The security MIME type | |
8633 | %i Additional info | |
8634 | %d Details | |
8635 | %D Details if button is pressed") | |
8636 | ||
8637 | (defvar gnus-mime-security-button-line-format-alist | |
8638 | '((?t gnus-tmp-type ?s) | |
8639 | (?i gnus-tmp-info ?s) | |
8640 | (?d gnus-tmp-details ?s) | |
8641 | (?D gnus-tmp-pressed-details ?s))) | |
8642 | ||
01c52d31 MB |
8643 | (defvar gnus-mime-security-button-commands |
8644 | '((gnus-article-press-button "\r" "Show Detail") | |
8645 | (undefined "v") | |
8646 | (undefined "t") | |
8647 | (undefined "C") | |
8648 | (gnus-mime-security-save-part "o" "Save...") | |
8649 | (undefined "\C-o") | |
8650 | (undefined "r") | |
8651 | (undefined "d") | |
8652 | (undefined "c") | |
8653 | (undefined "i") | |
8654 | (undefined "E") | |
8655 | (undefined "e") | |
8656 | (undefined "p") | |
8657 | (gnus-mime-security-pipe-part "|" "Pipe To Command...") | |
8658 | (undefined "."))) | |
8659 | ||
23f87bed MB |
8660 | (defvar gnus-mime-security-button-map |
8661 | (let ((map (make-sparse-keymap))) | |
23f87bed | 8662 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
01c52d31 MB |
8663 | (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu) |
8664 | (dolist (c gnus-mime-security-button-commands) | |
8665 | (define-key map (cadr c) (car c))) | |
23f87bed MB |
8666 | map)) |
8667 | ||
01c52d31 MB |
8668 | (easy-menu-define |
8669 | gnus-mime-security-button-menu gnus-mime-security-button-map | |
8670 | "Security button menu." | |
8671 | `("Security Part" | |
8672 | ,@(delq nil | |
8673 | (mapcar (lambda (c) | |
8674 | (unless (eq (car c) 'undefined) | |
8675 | (vector (caddr c) (car c) :active t))) | |
8676 | gnus-mime-security-button-commands)))) | |
8677 | ||
8678 | (defun gnus-mime-security-button-menu (event prefix) | |
8679 | "Construct a context-sensitive menu of security commands." | |
8680 | (interactive "e\nP") | |
8681 | (save-window-excursion | |
8682 | (let ((pos (event-start event))) | |
8683 | (select-window (posn-window pos)) | |
8684 | (goto-char (posn-point pos)) | |
8685 | (gnus-article-check-buffer) | |
8686 | (popup-menu gnus-mime-security-button-menu nil prefix)))) | |
8687 | ||
23f87bed MB |
8688 | (defvar gnus-mime-security-details-buffer nil) |
8689 | ||
8690 | (defvar gnus-mime-security-button-pressed nil) | |
8691 | ||
8692 | (defvar gnus-mime-security-show-details-inline t | |
8693 | "If non-nil, show details in the article buffer.") | |
8694 | ||
8695 | (defun gnus-mime-security-verify-or-decrypt (handle) | |
8696 | (mm-remove-parts (cdr handle)) | |
8697 | (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region)) | |
8698 | point (inhibit-read-only t)) | |
8699 | (if region | |
8700 | (goto-char (car region))) | |
01c52d31 MB |
8701 | (setq point (point)) |
8702 | (with-current-buffer (mm-handle-multipart-original-buffer handle) | |
8703 | (let* ((mm-verify-option 'known) | |
8704 | (mm-decrypt-option 'known) | |
8705 | (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle))) | |
8706 | (unless (eq nparts (cdr handle)) | |
8707 | (mm-destroy-parts (cdr handle)) | |
8708 | (setcdr handle nparts)))) | |
8709 | (gnus-mime-display-security handle) | |
23f87bed MB |
8710 | (when region |
8711 | (delete-region (point) (cdr region)) | |
8712 | (set-marker (car region) nil) | |
8713 | (set-marker (cdr region) nil)) | |
8714 | (goto-char point))) | |
8715 | ||
8716 | (defun gnus-mime-security-show-details (handle) | |
8717 | (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details))) | |
8718 | (if (not details) | |
8719 | (gnus-message 5 "No details.") | |
8720 | (if gnus-mime-security-show-details-inline | |
8721 | (let ((gnus-mime-security-button-pressed | |
8722 | (not (get-text-property (point) 'gnus-mime-details))) | |
8723 | (gnus-mime-security-button-line-format | |
8724 | (get-text-property (point) 'gnus-line-format)) | |
8725 | (inhibit-read-only t)) | |
8726 | (forward-char -1) | |
8727 | (while (eq (get-text-property (point) 'gnus-line-format) | |
8728 | gnus-mime-security-button-line-format) | |
8729 | (forward-char -1)) | |
8730 | (forward-char) | |
8731 | (save-restriction | |
8732 | (narrow-to-region (point) (point)) | |
8733 | (gnus-insert-mime-security-button handle)) | |
8734 | (delete-region (point) | |
8735 | (or (text-property-not-all | |
8736 | (point) (point-max) | |
8737 | 'gnus-line-format | |
8738 | gnus-mime-security-button-line-format) | |
8739 | (point-max)))) | |
8740 | ;; Not inlined. | |
8741 | (if (gnus-buffer-live-p gnus-mime-security-details-buffer) | |
8742 | (with-current-buffer gnus-mime-security-details-buffer | |
8743 | (erase-buffer) | |
8744 | t) | |
8745 | (setq gnus-mime-security-details-buffer | |
8746 | (gnus-get-buffer-create "*MIME Security Details*"))) | |
8747 | (with-current-buffer gnus-mime-security-details-buffer | |
8748 | (insert details) | |
8749 | (goto-char (point-min))) | |
8750 | (pop-to-buffer gnus-mime-security-details-buffer))))) | |
8751 | ||
8752 | (defun gnus-mime-security-press-button (handle) | |
8753 | (save-excursion | |
8754 | (if (mm-handle-multipart-ctl-parameter handle 'gnus-info) | |
8755 | (gnus-mime-security-show-details handle) | |
8756 | (gnus-mime-security-verify-or-decrypt handle)))) | |
8757 | ||
8758 | (defun gnus-insert-mime-security-button (handle &optional displayed) | |
8759 | (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol)) | |
8760 | (gnus-tmp-type | |
8761 | (concat | |
8762 | (or (nth 2 (assoc protocol mm-verify-function-alist)) | |
8763 | (nth 2 (assoc protocol mm-decrypt-function-alist)) | |
8764 | "Unknown") | |
8765 | (if (equal (car handle) "multipart/signed") | |
8766 | " Signed" " Encrypted") | |
8767 | " Part")) | |
8768 | (gnus-tmp-info | |
8769 | (or (mm-handle-multipart-ctl-parameter handle 'gnus-info) | |
8770 | "Undecided")) | |
8771 | (gnus-tmp-details | |
8772 | (mm-handle-multipart-ctl-parameter handle 'gnus-details)) | |
8773 | gnus-tmp-pressed-details | |
8774 | b e) | |
8775 | (setq gnus-tmp-details | |
8776 | (if gnus-tmp-details | |
8777 | (concat "\n" gnus-tmp-details) | |
8778 | "")) | |
8779 | (setq gnus-tmp-pressed-details | |
8780 | (if gnus-mime-security-button-pressed gnus-tmp-details "")) | |
8781 | (unless (bolp) | |
8782 | (insert "\n")) | |
8783 | (setq b (point)) | |
8784 | (gnus-eval-format | |
8785 | gnus-mime-security-button-line-format | |
8786 | gnus-mime-security-button-line-format-alist | |
01c52d31 | 8787 | `(keymap ,gnus-mime-security-button-map |
23f87bed MB |
8788 | gnus-callback gnus-mime-security-press-button |
8789 | gnus-line-format ,gnus-mime-security-button-line-format | |
8790 | gnus-mime-details ,gnus-mime-security-button-pressed | |
8791 | article-type annotation | |
8792 | gnus-data ,handle)) | |
8793 | (setq e (if (bolp) | |
8794 | ;; Exclude a newline. | |
8795 | (1- (point)) | |
8796 | (point))) | |
01c52d31 MB |
8797 | (when gnus-article-button-face |
8798 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8799 | 'face gnus-article-button-face)) | |
23f87bed MB |
8800 | (widget-convert-button |
8801 | 'link b e | |
8802 | :mime-handle handle | |
8803 | :action 'gnus-widget-press-button | |
8804 | :button-keymap gnus-mime-security-button-map | |
8805 | :help-echo | |
5843126b | 8806 | (lambda (widget) |
23f87bed MB |
8807 | ;; Needed to properly clear the message due to a bug in |
8808 | ;; wid-edit (XEmacs only). | |
8809 | (when (boundp 'help-echo-owns-message) | |
8810 | (setq help-echo-owns-message t)) | |
8811 | (format | |
01c52d31 MB |
8812 | "%S: show detail; %S: more options" |
8813 | (aref gnus-mouse-2 0) | |
8814 | (aref gnus-down-mouse-3 0)))))) | |
23f87bed MB |
8815 | |
8816 | (defun gnus-mime-display-security (handle) | |
8817 | (save-restriction | |
8818 | (narrow-to-region (point) (point)) | |
8819 | (unless (gnus-unbuttonized-mime-type-p (car handle)) | |
8820 | (gnus-insert-mime-security-button handle)) | |
01c52d31 | 8821 | (gnus-mime-display-part (cadr handle)) |
23f87bed MB |
8822 | (unless (bolp) |
8823 | (insert "\n")) | |
8824 | (unless (gnus-unbuttonized-mime-type-p (car handle)) | |
8825 | (let ((gnus-mime-security-button-line-format | |
8826 | gnus-mime-security-button-end-line-format)) | |
8827 | (gnus-insert-mime-security-button handle))) | |
8828 | (mm-set-handle-multipart-parameter | |
30818a23 | 8829 | handle 'gnus-region (cons (point-min-marker) (point-max-marker))) |
01c52d31 MB |
8830 | (goto-char (point-max)))) |
8831 | ||
8832 | (defun gnus-mime-security-run-function (function) | |
8833 | "Run FUNCTION with the security part under point." | |
8834 | (gnus-article-check-buffer) | |
8835 | (let ((data (get-text-property (point) 'gnus-data)) | |
8836 | buffer handle) | |
8837 | (when (and (stringp (car-safe data)) | |
8838 | (setq buffer (mm-handle-multipart-original-buffer data)) | |
8839 | (setq handle (cadr data))) | |
8840 | (if (bufferp (mm-handle-buffer handle)) | |
8841 | (progn | |
8842 | (setq handle (cons buffer (copy-sequence (cdr handle)))) | |
8843 | (mm-handle-set-undisplayer handle nil)) | |
8844 | (setq handle (mm-make-handle | |
8845 | buffer | |
8846 | (mm-handle-multipart-ctl-parameter handle 'protocol) | |
8847 | nil nil nil nil nil nil))) | |
8848 | (funcall function handle)))) | |
8849 | ||
8850 | (defun gnus-mime-security-save-part () | |
8851 | "Save the security part under point." | |
8852 | (interactive) | |
8853 | (gnus-mime-security-run-function 'mm-save-part)) | |
8854 | ||
8855 | (defun gnus-mime-security-pipe-part () | |
8856 | "Pipe the security part under point to a process." | |
8857 | (interactive) | |
8858 | (gnus-mime-security-run-function 'mm-pipe-part)) | |
23f87bed | 8859 | |
eec82323 LMI |
8860 | (gnus-ems-redefine) |
8861 | ||
8862 | (provide 'gnus-art) | |
8863 | ||
8864 | (run-hooks 'gnus-art-load-hook) | |
8865 | ||
8866 | ;;; gnus-art.el ends here |