Commit | Line | Data |
---|---|---|
eec82323 | 1 | ;;; gnus-art.el --- article mode commands for Gnus |
e84b4b86 TTN |
2 | |
3 | ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | |
114f9c96 | 4 | ;; 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
eec82323 | 5 | |
6748645f | 6 | ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org> |
eec82323 LMI |
7 | ;; Keywords: news |
8 | ||
9 | ;; This file is part of GNU Emacs. | |
10 | ||
5e809f55 | 11 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
eec82323 | 12 | ;; it under the terms of the GNU General Public License as published by |
5e809f55 GM |
13 | ;; the Free Software Foundation, either version 3 of the License, or |
14 | ;; (at your option) any later version. | |
eec82323 LMI |
15 | |
16 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
2ff9f5b4 | 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
eec82323 LMI |
19 | ;; GNU General Public License for more details. |
20 | ||
21 | ;; You should have received a copy of the GNU General Public License | |
5e809f55 | 22 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
eec82323 LMI |
23 | |
24 | ;;; Commentary: | |
25 | ||
26 | ;;; Code: | |
27 | ||
9640c3bc GM |
28 | ;; For Emacs < 22.2. |
29 | (eval-and-compile | |
30 | (unless (fboundp 'declare-function) (defmacro declare-function (&rest r)))) | |
23f87bed | 31 | (eval-when-compile |
9efa445f DN |
32 | (require 'cl)) |
33 | (defvar tool-bar-map) | |
34 | (defvar w3m-minor-mode-map) | |
5ab7173c | 35 | |
eec82323 | 36 | (require 'gnus) |
01c52d31 MB |
37 | ;; Avoid the "Recursive load suspected" error in Emacs 21.1. |
38 | (eval-and-compile | |
39 | (let ((recursive-load-depth-limit 100)) | |
40 | (require 'gnus-sum))) | |
eec82323 LMI |
41 | (require 'gnus-spec) |
42 | (require 'gnus-int) | |
23f87bed | 43 | (require 'gnus-win) |
16409b0b GM |
44 | (require 'mm-bodies) |
45 | (require 'mail-parse) | |
46 | (require 'mm-decode) | |
47 | (require 'mm-view) | |
48 | (require 'wid-edit) | |
49 | (require 'mm-uu) | |
23f87bed MB |
50 | (require 'message) |
51 | ||
52 | (autoload 'gnus-msg-mail "gnus-msg" nil t) | |
53 | (autoload 'gnus-button-mailto "gnus-msg") | |
54 | (autoload 'gnus-button-reply "gnus-msg" nil t) | |
498063ec | 55 | (autoload 'parse-time-string "parse-time" nil nil) |
01c52d31 MB |
56 | (autoload 'ansi-color-apply-on-region "ansi-color") |
57 | (autoload 'mm-url-insert-file-contents-external "mm-url") | |
531bedc3 | 58 | (autoload 'mm-extern-cache-contents "mm-extern") |
eec82323 LMI |
59 | |
60 | (defgroup gnus-article nil | |
61 | "Article display." | |
23f87bed | 62 | :link '(custom-manual "(gnus)Article Buffer") |
eec82323 LMI |
63 | :group 'gnus) |
64 | ||
16409b0b GM |
65 | (defgroup gnus-article-treat nil |
66 | "Treating article parts." | |
67 | :link '(custom-manual "(gnus)Article Hiding") | |
68 | :group 'gnus-article) | |
69 | ||
eec82323 LMI |
70 | (defgroup gnus-article-hiding nil |
71 | "Hiding article parts." | |
72 | :link '(custom-manual "(gnus)Article Hiding") | |
73 | :group 'gnus-article) | |
74 | ||
75 | (defgroup gnus-article-highlight nil | |
76 | "Article highlighting." | |
77 | :link '(custom-manual "(gnus)Article Highlighting") | |
78 | :group 'gnus-article | |
79 | :group 'gnus-visual) | |
80 | ||
81 | (defgroup gnus-article-signature nil | |
82 | "Article signatures." | |
83 | :link '(custom-manual "(gnus)Article Signature") | |
84 | :group 'gnus-article) | |
85 | ||
86 | (defgroup gnus-article-headers nil | |
87 | "Article headers." | |
88 | :link '(custom-manual "(gnus)Hiding Headers") | |
89 | :group 'gnus-article) | |
90 | ||
91 | (defgroup gnus-article-washing nil | |
92 | "Special commands on articles." | |
93 | :link '(custom-manual "(gnus)Article Washing") | |
94 | :group 'gnus-article) | |
95 | ||
96 | (defgroup gnus-article-emphasis nil | |
97 | "Fontisizing articles." | |
98 | :link '(custom-manual "(gnus)Article Fontisizing") | |
99 | :group 'gnus-article) | |
100 | ||
101 | (defgroup gnus-article-saving nil | |
102 | "Saving articles." | |
103 | :link '(custom-manual "(gnus)Saving Articles") | |
104 | :group 'gnus-article) | |
105 | ||
106 | (defgroup gnus-article-mime nil | |
107 | "Worshiping the MIME wonder." | |
108 | :link '(custom-manual "(gnus)Using MIME") | |
109 | :group 'gnus-article) | |
110 | ||
111 | (defgroup gnus-article-buttons nil | |
112 | "Pushable buttons in the article buffer." | |
113 | :link '(custom-manual "(gnus)Article Buttons") | |
114 | :group 'gnus-article) | |
115 | ||
116 | (defgroup gnus-article-various nil | |
117 | "Other article options." | |
118 | :link '(custom-manual "(gnus)Misc Article") | |
119 | :group 'gnus-article) | |
120 | ||
121 | (defcustom gnus-ignored-headers | |
23f87bed MB |
122 | (mapcar |
123 | (lambda (header) | |
124 | (concat "^" header ":")) | |
125 | '("Path" "Expires" "Date-Received" "References" "Xref" "Lines" | |
126 | "Relay-Version" "Message-ID" "Approved" "Sender" "Received" | |
127 | "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To" | |
128 | "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature" | |
129 | "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop" | |
130 | "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face" | |
131 | "X-Attribution" "X-Originating-IP" "Delivered-To" | |
132 | "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace" | |
133 | "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*" | |
134 | "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date" | |
135 | "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache" | |
136 | "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time" | |
137 | "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List" | |
138 | "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt" | |
139 | "Old-Received" "X-Pgp" "X-Auth" "X-From-Line" | |
140 | "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender" | |
141 | "MBOX-Line" "Priority" "X400-[-A-Za-z]+" | |
142 | "Status" "X-Gnus-Mail-Source" "Cancel-Lock" | |
143 | "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance" | |
144 | "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3" | |
145 | "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT" | |
146 | "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin" | |
147 | "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender" | |
148 | "List-[A-Za-z]+" "X-Listprocessor-Version" | |
149 | "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks" | |
150 | "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway" | |
151 | "X-Received" "Content-length" "X-precedence" | |
152 | "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info" | |
153 | "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup" | |
154 | "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To" | |
155 | "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post" | |
156 | "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive" | |
157 | "X-Content-length" "X-Posting-Agent" "Original-Received" | |
158 | "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom" | |
159 | "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway" | |
160 | "X-Local-Origin" "X-Local-Destination" "X-UserInfo1" | |
161 | "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications" | |
01c52d31 MB |
162 | "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer" |
163 | "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane" | |
164 | "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At" | |
165 | "Envelope-Sender" "Envelope-Recipients")) | |
6748645f | 166 | "*All headers that start with this regexp will be hidden. |
eec82323 LMI |
167 | This variable can also be a list of regexps of headers to be ignored. |
168 | If `gnus-visible-headers' is non-nil, this variable will be ignored." | |
169 | :type '(choice :custom-show nil | |
170 | regexp | |
171 | (repeat regexp)) | |
172 | :group 'gnus-article-hiding) | |
173 | ||
174 | (defcustom gnus-visible-headers | |
23f87bed | 175 | "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:" |
6748645f | 176 | "*All headers that do not match this regexp will be hidden. |
eec82323 LMI |
177 | This variable can also be a list of regexp of headers to remain visible. |
178 | If this variable is non-nil, `gnus-ignored-headers' will be ignored." | |
9b3ebcb6 MB |
179 | :type '(choice |
180 | (repeat :value-to-internal (lambda (widget value) | |
181 | (custom-split-regexp-maybe value)) | |
182 | :match (lambda (widget value) | |
183 | (or (stringp value) | |
184 | (widget-editable-list-match widget value))) | |
185 | regexp) | |
186 | (const :tag "Use gnus-ignored-headers" nil) | |
187 | regexp) | |
eec82323 LMI |
188 | :group 'gnus-article-hiding) |
189 | ||
190 | (defcustom gnus-sorted-header-list | |
191 | '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" | |
192 | "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:") | |
6748645f | 193 | "*This variable is a list of regular expressions. |
eec82323 LMI |
194 | If it is non-nil, headers that match the regular expressions will |
195 | be placed first in the article buffer in the sequence specified by | |
196 | this list." | |
197 | :type '(repeat regexp) | |
198 | :group 'gnus-article-hiding) | |
199 | ||
200 | (defcustom gnus-boring-article-headers '(empty followup-to reply-to) | |
201 | "Headers that are only to be displayed if they have interesting data. | |
23f87bed MB |
202 | Possible values in this list are: |
203 | ||
204 | 'empty Headers with no content. | |
205 | 'newsgroups Newsgroup identical to Gnus group. | |
206 | 'to-address To identical to To-address. | |
207 | 'to-list To identical to To-list. | |
208 | 'cc-list CC identical to To-list. | |
209 | 'followup-to Followup-to identical to Newsgroups. | |
210 | 'reply-to Reply-to identical to From. | |
211 | 'date Date less than four days old. | |
212 | 'long-to To and/or Cc longer than 1024 characters. | |
213 | 'many-to Multiple To and/or Cc." | |
eec82323 | 214 | :type '(set (const :tag "Headers with no content." empty) |
23f87bed MB |
215 | (const :tag "Newsgroups identical to Gnus group." newsgroups) |
216 | (const :tag "To identical to To-address." to-address) | |
217 | (const :tag "To identical to To-list." to-list) | |
218 | (const :tag "CC identical to To-list." cc-list) | |
219 | (const :tag "Followup-to identical to Newsgroups." followup-to) | |
220 | (const :tag "Reply-to identical to From." reply-to) | |
6748645f | 221 | (const :tag "Date less than four days old." date) |
23f87bed | 222 | (const :tag "To and/or Cc longer than 1024 characters." long-to) |
16409b0b | 223 | (const :tag "Multiple To and/or Cc headers." many-to)) |
eec82323 LMI |
224 | :group 'gnus-article-hiding) |
225 | ||
23f87bed MB |
226 | (defcustom gnus-article-skip-boring nil |
227 | "Skip over text that is not worth reading. | |
228 | By default, if you set this t, then Gnus will display citations and | |
229 | signatures, but will never scroll down to show you a page consisting | |
230 | only of boring text. Boring text is controlled by | |
231 | `gnus-article-boring-faces'." | |
bf247b6e | 232 | :version "22.1" |
23f87bed MB |
233 | :type 'boolean |
234 | :group 'gnus-article-hiding) | |
235 | ||
eec82323 LMI |
236 | (defcustom gnus-signature-separator '("^-- $" "^-- *$") |
237 | "Regexp matching signature separator. | |
238 | This can also be a list of regexps. In that case, it will be checked | |
239 | from head to tail looking for a separator. Searches will be done from | |
240 | the end of the buffer." | |
3031d8b0 MB |
241 | :type '(choice :format "%{%t%}: %[Value Menu%]\n%v" |
242 | (regexp) | |
243 | (repeat :tag "List of regexp" regexp)) | |
eec82323 LMI |
244 | :group 'gnus-article-signature) |
245 | ||
246 | (defcustom gnus-signature-limit nil | |
16409b0b | 247 | "Provide a limit to what is considered a signature. |
eec82323 LMI |
248 | If it is a number, no signature may not be longer (in characters) than |
249 | that number. If it is a floating point number, no signature may be | |
250 | longer (in lines) than that number. If it is a function, the function | |
251 | will be called without any parameters, and if it returns nil, there is | |
252 | no signature in the buffer. If it is a string, it will be used as a | |
01c52d31 MB |
253 | regexp. If it matches, the text in question is not a signature. |
254 | ||
255 | This can also be a list of the above values." | |
4a2358e9 MB |
256 | :type '(choice (const nil) |
257 | (integer :value 200) | |
6748645f | 258 | (number :value 4.0) |
b28080e3 | 259 | function |
6748645f | 260 | (regexp :value ".*")) |
eec82323 LMI |
261 | :group 'gnus-article-signature) |
262 | ||
263 | (defcustom gnus-hidden-properties '(invisible t intangible t) | |
264 | "Property list to use for hiding text." | |
265 | :type 'sexp | |
266 | :group 'gnus-article-hiding) | |
267 | ||
23f87bed MB |
268 | ;; Fixme: This isn't the right thing for mixed graphical and non-graphical |
269 | ;; frames in a session. | |
eec82323 | 270 | (defcustom gnus-article-x-face-command |
23f87bed MB |
271 | (if (featurep 'xemacs) |
272 | (if (or (gnus-image-type-available-p 'xface) | |
273 | (gnus-image-type-available-p 'pbm)) | |
274 | 'gnus-display-x-face-in-from | |
275 | "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -") | |
276 | (if (gnus-image-type-available-p 'pbm) | |
277 | 'gnus-display-x-face-in-from | |
e0bad764 DL |
278 | "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \ |
279 | display -")) | |
6748645f | 280 | "*String or function to be executed to display an X-Face header. |
eec82323 | 281 | If it is a string, the command will be executed in a sub-shell |
2ff9f5b4 | 282 | asynchronously. The compressed face will be piped to this command." |
23f87bed MB |
283 | :type `(choice string |
284 | (function-item gnus-display-x-face-in-from) | |
16409b0b | 285 | function) |
b5a206e7 | 286 | :version "21.1" |
23f87bed | 287 | :group 'gnus-picon |
eec82323 LMI |
288 | :group 'gnus-article-washing) |
289 | ||
290 | (defcustom gnus-article-x-face-too-ugly nil | |
291 | "Regexp matching posters whose face shouldn't be shown automatically." | |
4bb6a3a6 | 292 | :type '(choice regexp (const nil)) |
eec82323 LMI |
293 | :group 'gnus-article-washing) |
294 | ||
e0bad764 DL |
295 | (defcustom gnus-article-banner-alist nil |
296 | "Banner alist for stripping. | |
a1506d29 | 297 | For example, |
23f87bed | 298 | ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))" |
fc2c2db8 | 299 | :version "21.1" |
e0bad764 DL |
300 | :type '(repeat (cons symbol regexp)) |
301 | :group 'gnus-article-washing) | |
302 | ||
23f87bed MB |
303 | (gnus-define-group-parameter |
304 | banner | |
305 | :variable-document | |
306 | "Alist of regexps (to match group names) and banner." | |
307 | :variable-group gnus-article-washing | |
308 | :parameter-type | |
309 | '(choice :tag "Banner" | |
310 | :value nil | |
311 | (const :tag "Remove signature" signature) | |
312 | (symbol :tag "Item in `gnus-article-banner-alist'" none) | |
313 | regexp | |
314 | (const :tag "None" nil)) | |
315 | :parameter-document | |
316 | "If non-nil, specify how to remove `banners' from articles. | |
317 | ||
318 | Symbol `signature' means to remove signatures delimited by | |
319 | `gnus-signature-separator'. Any other symbol is used to look up a | |
320 | regular expression to match the banner in `gnus-article-banner-alist'. | |
321 | A string is used as a regular expression to match the banner | |
322 | directly.") | |
323 | ||
324 | (defcustom gnus-article-address-banner-alist nil | |
325 | "Alist of mail addresses and banners. | |
326 | Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp | |
327 | to match a mail address in the From: header, BANNER is one of a symbol | |
328 | `signature', an item in `gnus-article-banner-alist', a regexp and nil. | |
329 | If ADDRESS matches author's mail address, it will remove things like | |
330 | advertisements. For example: | |
331 | ||
332 | \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\")) | |
333 | " | |
334 | :type '(repeat | |
335 | (cons | |
336 | (regexp :tag "Address") | |
337 | (choice :tag "Banner" :value nil | |
338 | (const :tag "Remove signature" signature) | |
339 | (symbol :tag "Item in `gnus-article-banner-alist'" none) | |
340 | regexp | |
341 | (const :tag "None" nil)))) | |
bf247b6e | 342 | :version "22.1" |
23f87bed MB |
343 | :group 'gnus-article-washing) |
344 | ||
ae465fa7 MB |
345 | (defmacro gnus-emphasis-custom-with-format (&rest body) |
346 | `(let ((format "\ | |
347 | \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\ | |
348 | \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")) | |
349 | ,@body)) | |
350 | ||
351 | (defun gnus-emphasis-custom-value-to-external (value) | |
352 | (gnus-emphasis-custom-with-format | |
353 | (if (consp (car value)) | |
354 | (list (format format (car (car value)) (cdr (car value))) | |
355 | 2 | |
356 | (if (nth 1 value) 2 3) | |
357 | (nth 2 value)) | |
358 | value))) | |
359 | ||
360 | (defun gnus-emphasis-custom-value-to-internal (value) | |
361 | (gnus-emphasis-custom-with-format | |
362 | (let ((regexp (concat "\\`" | |
363 | (format (regexp-quote format) | |
364 | "\\([^()]+\\)" "\\([^()]+\\)") | |
365 | "\\'")) | |
366 | pattern) | |
367 | (if (string-match regexp (setq pattern (car value))) | |
368 | (list (cons (match-string 1 pattern) (match-string 2 pattern)) | |
369 | (= (nth 2 value) 2) | |
370 | (nth 3 value)) | |
371 | value)))) | |
372 | ||
eec82323 | 373 | (defcustom gnus-emphasis-alist |
ae465fa7 MB |
374 | (let ((types |
375 | '(("\\*" "\\*" bold nil 2) | |
23f87bed | 376 | ("_" "_" underline) |
eec82323 | 377 | ("/" "/" italic) |
eec82323 LMI |
378 | ("_/" "/_" underline-italic) |
379 | ("_\\*" "\\*_" underline-bold) | |
380 | ("\\*/" "/\\*" bold-italic) | |
381 | ("_\\*/" "/\\*_" underline-bold-italic)))) | |
ae465fa7 MB |
382 | (nconc |
383 | (gnus-emphasis-custom-with-format | |
384 | (mapcar (lambda (spec) | |
385 | (list (format format (car spec) (cadr spec)) | |
386 | (or (nth 3 spec) 2) | |
387 | (or (nth 4 spec) 3) | |
388 | (intern (format "gnus-emphasis-%s" (nth 2 spec))))) | |
389 | types)) | |
95f75c75 SM |
390 | '(;; I've never seen anyone use this strikethru convention whereas I've |
391 | ;; several times seen it triggered by normal text. --Stef | |
392 | ;; Miles suggests that this form is sometimes used but for italics, | |
393 | ;; so maybe we should map it to `italic'. | |
394 | ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)" | |
395 | ;; 2 3 gnus-emphasis-strikethru) | |
ae465fa7 MB |
396 | ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)" |
397 | 2 3 gnus-emphasis-underline)))) | |
6748645f | 398 | "*Alist that says how to fontify certain phrases. |
eec82323 LMI |
399 | Each item looks like this: |
400 | ||
401 | (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline) | |
402 | ||
403 | The first element is a regular expression to be matched. The second | |
404 | is a number that says what regular expression grouping used to find | |
405 | the entire emphasized word. The third is a number that says what | |
406 | regexp grouping should be displayed and highlighted. The fourth | |
407 | is the face used for highlighting." | |
ae465fa7 MB |
408 | :type |
409 | '(repeat | |
410 | (menu-choice | |
411 | :format "%[Customizing Style%]\n%v" | |
412 | :indent 2 | |
413 | (group :tag "Default" | |
414 | :value ("" 0 0 default) | |
415 | :value-create | |
416 | (lambda (widget) | |
417 | (let ((value (widget-get | |
418 | (cadr (widget-get (widget-get widget :parent) | |
419 | :args)) | |
420 | :value))) | |
421 | (if (not (eq (nth 2 value) 'default)) | |
422 | (widget-put | |
423 | widget | |
424 | :value | |
425 | (gnus-emphasis-custom-value-to-external value)))) | |
426 | (widget-group-value-create widget)) | |
ad136a7c MB |
427 | regexp |
428 | (integer :format "Match group: %v") | |
01c52d31 | 429 | (integer :format "Emphasize group: %v") |
ae465fa7 MB |
430 | face) |
431 | (group :tag "Simple" | |
432 | :value (("_" . "_") nil default) | |
433 | (cons :format "%v" | |
ad136a7c MB |
434 | (regexp :format "Start regexp: %v") |
435 | (regexp :format "End regexp: %v")) | |
ae465fa7 MB |
436 | (boolean :format "Show start and end patterns: %[%v%]\n" |
437 | :on " On " :off " Off ") | |
438 | face))) | |
439 | :get (lambda (symbol) | |
440 | (mapcar 'gnus-emphasis-custom-value-to-internal | |
441 | (default-value symbol))) | |
442 | :set (lambda (symbol value) | |
443 | (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external | |
444 | value))) | |
eec82323 LMI |
445 | :group 'gnus-article-emphasis) |
446 | ||
16409b0b GM |
447 | (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n" |
448 | "A regexp to describe whitespace which should not be emphasized. | |
449 | Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\". | |
450 | The former avoids underlining of leading and trailing whitespace, | |
451 | and the latter avoids underlining any whitespace at all." | |
fc2c2db8 | 452 | :version "21.1" |
16409b0b GM |
453 | :group 'gnus-article-emphasis |
454 | :type 'regexp) | |
455 | ||
23f87bed | 456 | (defface gnus-emphasis-bold '((t (:bold t))) |
eec82323 LMI |
457 | "Face used for displaying strong emphasized text (*word*)." |
458 | :group 'gnus-article-emphasis) | |
459 | ||
23f87bed | 460 | (defface gnus-emphasis-italic '((t (:italic t))) |
eec82323 LMI |
461 | "Face used for displaying italic emphasized text (/word/)." |
462 | :group 'gnus-article-emphasis) | |
463 | ||
464 | (defface gnus-emphasis-underline '((t (:underline t))) | |
465 | "Face used for displaying underlined emphasized text (_word_)." | |
466 | :group 'gnus-article-emphasis) | |
467 | ||
23f87bed | 468 | (defface gnus-emphasis-underline-bold '((t (:bold t :underline t))) |
eec82323 LMI |
469 | "Face used for displaying underlined bold emphasized text (_*word*_)." |
470 | :group 'gnus-article-emphasis) | |
471 | ||
23f87bed | 472 | (defface gnus-emphasis-underline-italic '((t (:italic t :underline t))) |
8de38c21 | 473 | "Face used for displaying underlined italic emphasized text (_/word/_)." |
eec82323 LMI |
474 | :group 'gnus-article-emphasis) |
475 | ||
23f87bed | 476 | (defface gnus-emphasis-bold-italic '((t (:bold t :italic t))) |
eec82323 LMI |
477 | "Face used for displaying bold italic emphasized text (/*word*/)." |
478 | :group 'gnus-article-emphasis) | |
479 | ||
480 | (defface gnus-emphasis-underline-bold-italic | |
23f87bed | 481 | '((t (:bold t :italic t :underline t))) |
eec82323 | 482 | "Face used for displaying underlined bold italic emphasized text. |
8f688cb0 | 483 | Example: (_/*word*/_)." |
eec82323 LMI |
484 | :group 'gnus-article-emphasis) |
485 | ||
23f87bed MB |
486 | (defface gnus-emphasis-strikethru (if (featurep 'xemacs) |
487 | '((t (:strikethru t))) | |
488 | '((t (:strike-through t)))) | |
489 | "Face used for displaying strike-through text (-word-)." | |
490 | :group 'gnus-article-emphasis) | |
491 | ||
16409b0b GM |
492 | (defface gnus-emphasis-highlight-words |
493 | '((t (:background "black" :foreground "yellow"))) | |
494 | "Face used for displaying highlighted words." | |
495 | :group 'gnus-article-emphasis) | |
496 | ||
01c52d31 | 497 | (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z" |
eec82323 | 498 | "Format for display of Date headers in article bodies. |
6748645f LMI |
499 | See `format-time-string' for the possible values. |
500 | ||
501 | The variable can also be function, which should return a complete Date | |
502 | header. The function is called with one argument, the time, which can | |
503 | be fed to `format-time-string'." | |
01c52d31 | 504 | :type '(choice string function) |
eec82323 LMI |
505 | :link '(custom-manual "(gnus)Article Date") |
506 | :group 'gnus-article-washing) | |
507 | ||
eec82323 | 508 | (defcustom gnus-save-all-headers t |
26c9afc3 MB |
509 | "*If non-nil, don't remove any headers before saving. |
510 | This will be overridden by the `:headers' property that the symbol of | |
511 | the saver function, which is specified by `gnus-default-article-saver', | |
512 | might have." | |
eec82323 LMI |
513 | :group 'gnus-article-saving |
514 | :type 'boolean) | |
515 | ||
516 | (defcustom gnus-prompt-before-saving 'always | |
517 | "*This variable says how much prompting is to be done when saving articles. | |
518 | If it is nil, no prompting will be done, and the articles will be | |
519 | saved to the default files. If this variable is `always', each and | |
520 | every article that is saved will be preceded by a prompt, even when | |
521 | saving large batches of articles. If this variable is neither nil not | |
522 | `always', there the user will be prompted once for a file name for | |
523 | each invocation of the saving commands." | |
524 | :group 'gnus-article-saving | |
525 | :type '(choice (item always) | |
526 | (item :tag "never" nil) | |
6748645f | 527 | (sexp :tag "once" :format "%t\n" :value t))) |
eec82323 LMI |
528 | |
529 | (defcustom gnus-saved-headers gnus-visible-headers | |
530 | "Headers to keep if `gnus-save-all-headers' is nil. | |
531 | If `gnus-save-all-headers' is non-nil, this variable will be ignored. | |
532 | If that variable is nil, however, all headers that match this regexp | |
26c9afc3 MB |
533 | will be kept while the rest will be deleted before saving. This and |
534 | `gnus-save-all-headers' will be overridden by the `:headers' property | |
535 | that the symbol of the saver function, which is specified by | |
536 | `gnus-default-article-saver', might have." | |
eec82323 | 537 | :group 'gnus-article-saving |
4bb6a3a6 | 538 | :type 'regexp) |
eec82323 | 539 | |
fef8d38e | 540 | ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before. |
eec82323 LMI |
541 | (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail |
542 | "A function to save articles in your favourite format. | |
26c9afc3 MB |
543 | The function will be called by way of the `gnus-summary-save-article' |
544 | command, and friends such as `gnus-summary-save-article-rmail'. | |
eec82323 LMI |
545 | |
546 | Gnus provides the following functions: | |
547 | ||
548 | * gnus-summary-save-in-rmail (Rmail format) | |
549 | * gnus-summary-save-in-mail (Unix mail format) | |
550 | * gnus-summary-save-in-folder (MH folder) | |
551 | * gnus-summary-save-in-file (article format) | |
23f87bed | 552 | * gnus-summary-save-body-in-file (article body) |
eec82323 | 553 | * gnus-summary-save-in-vm (use VM's folder format) |
26c9afc3 MB |
554 | * gnus-summary-write-to-file (article format -- overwrite) |
555 | * gnus-summary-write-body-to-file (article body -- overwrite) | |
89167438 | 556 | * gnus-summary-save-in-pipe (article format) |
26c9afc3 MB |
557 | |
558 | The symbol of each function may have the following properties: | |
559 | ||
560 | * :decode | |
561 | The value non-nil means save decoded articles. This is meaningful | |
562 | only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file', | |
89167438 MB |
563 | `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and |
564 | `gnus-summary-save-in-pipe'. | |
26c9afc3 MB |
565 | |
566 | * :function | |
567 | The value specifies an alternative function which appends, not | |
568 | overwrites, articles to a file. This implies that when saving many | |
569 | articles at a time, `gnus-prompt-before-saving' is bound to t and all | |
570 | articles are saved in a single file. This is meaningful only with | |
571 | `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'. | |
572 | ||
573 | * :headers | |
574 | The value specifies the symbol of a variable of which the value | |
575 | specifies headers to be saved. If it is omitted, | |
576 | `gnus-save-all-headers' and `gnus-saved-headers' control what | |
577 | headers should be saved." | |
eec82323 LMI |
578 | :group 'gnus-article-saving |
579 | :type '(radio (function-item gnus-summary-save-in-rmail) | |
580 | (function-item gnus-summary-save-in-mail) | |
581 | (function-item gnus-summary-save-in-folder) | |
582 | (function-item gnus-summary-save-in-file) | |
23f87bed | 583 | (function-item gnus-summary-save-body-in-file) |
eec82323 | 584 | (function-item gnus-summary-save-in-vm) |
58090a8d | 585 | (function-item gnus-summary-write-to-file) |
26c9afc3 | 586 | (function-item gnus-summary-write-body-to-file) |
89167438 | 587 | (function-item gnus-summary-save-in-pipe) |
58090a8d | 588 | (function))) |
eec82323 | 589 | |
26c9afc3 MB |
590 | (defcustom gnus-article-save-coding-system |
591 | (or (and (mm-coding-system-p 'utf-8) 'utf-8) | |
592 | (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit) | |
593 | (and (mm-coding-system-p 'emacs-mule) 'emacs-mule) | |
594 | (and (mm-coding-system-p 'escape-quoted) 'escape-quoted)) | |
595 | "Coding system used to save decoded articles to a file. | |
596 | ||
597 | The recommended coding systems are `utf-8', `iso-2022-7bit' and so on, | |
598 | which can safely encode any characters in text. This is used by the | |
599 | commands including: | |
600 | ||
601 | * gnus-summary-save-article-file | |
602 | * gnus-summary-save-article-body-file | |
603 | * gnus-summary-write-article-file | |
604 | * gnus-summary-write-article-body-file | |
605 | ||
606 | and the functions to which you may set `gnus-default-article-saver': | |
607 | ||
608 | * gnus-summary-save-in-file | |
609 | * gnus-summary-save-body-in-file | |
610 | * gnus-summary-write-to-file | |
611 | * gnus-summary-write-body-to-file | |
612 | ||
613 | Those commands and functions save just text displayed in the article | |
614 | buffer to a file if the value of this variable is non-nil. Note that | |
615 | buttonized MIME parts will be lost in a saved file in that case. | |
616 | Otherwise, raw articles will be saved." | |
617 | :group 'gnus-article-saving | |
618 | :type `(choice | |
619 | :format "%{%t%}:\n %[Value Menu%] %v" | |
620 | (const :tag "Save raw articles" nil) | |
621 | ,@(delq nil | |
622 | (mapcar | |
623 | (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg)) | |
624 | '((const :tag "UTF-8" utf-8) | |
625 | (const :tag "iso-2022-7bit" iso-2022-7bit) | |
626 | (const :tag "Emacs internal" emacs-mule) | |
627 | (const :tag "escape-quoted" escape-quoted)))) | |
628 | (symbol :tag "Coding system"))) | |
629 | ||
eec82323 LMI |
630 | (defcustom gnus-rmail-save-name 'gnus-plain-save-name |
631 | "A function generating a file name to save articles in Rmail format. | |
632 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
633 | :group 'gnus-article-saving | |
634 | :type 'function) | |
635 | ||
636 | (defcustom gnus-mail-save-name 'gnus-plain-save-name | |
637 | "A function generating a file name to save articles in Unix mail format. | |
638 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
639 | :group 'gnus-article-saving | |
640 | :type 'function) | |
641 | ||
642 | (defcustom gnus-folder-save-name 'gnus-folder-save-name | |
643 | "A function generating a file name to save articles in MH folder. | |
644 | The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER." | |
645 | :group 'gnus-article-saving | |
646 | :type 'function) | |
647 | ||
648 | (defcustom gnus-file-save-name 'gnus-numeric-save-name | |
649 | "A function generating a file name to save articles in article format. | |
650 | The function is called with NEWSGROUP, HEADERS, and optional | |
651 | LAST-FILE." | |
652 | :group 'gnus-article-saving | |
653 | :type 'function) | |
654 | ||
655 | (defcustom gnus-split-methods | |
656 | '((gnus-article-archive-name) | |
657 | (gnus-article-nndoc-name)) | |
6748645f | 658 | "*Variable used to suggest where articles are to be saved. |
eec82323 LMI |
659 | For instance, if you would like to save articles related to Gnus in |
660 | the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
661 | you could set this variable to something like: | |
662 | ||
663 | '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
664 | (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
665 | ||
01c52d31 MB |
666 | This variable is an alist where the key is the match and the |
667 | value is a list of possible files to save in if the match is | |
668 | non-nil. | |
eec82323 LMI |
669 | |
670 | If the match is a string, it is used as a regexp match on the | |
671 | article. If the match is a symbol, that symbol will be funcalled | |
672 | from the buffer of the article to be saved with the newsgroup as the | |
01c52d31 | 673 | parameter. If it is a list, it will be evaled in the same buffer. |
eec82323 | 674 | |
01c52d31 MB |
675 | If this form or function returns a string, this string will be used as a |
676 | possible file name; and if it returns a non-nil list, that list will be | |
677 | used as possible file names." | |
eec82323 | 678 | :group 'gnus-article-saving |
6748645f LMI |
679 | :type '(repeat (choice (list :value (fun) function) |
680 | (cons :value ("" "") regexp (repeat string)) | |
681 | (sexp :value nil)))) | |
eec82323 | 682 | |
eec82323 LMI |
683 | (defcustom gnus-page-delimiter "^\^L" |
684 | "*Regexp describing what to use as article page delimiters. | |
685 | The default value is \"^\^L\", which is a form linefeed at the | |
686 | beginning of a line." | |
687 | :type 'regexp | |
688 | :group 'gnus-article-various) | |
689 | ||
16409b0b | 690 | (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m" |
eec82323 | 691 | "*The format specification for the article mode line. |
16409b0b GM |
692 | See `gnus-summary-mode-line-format' for a closer description. |
693 | ||
694 | The following additional specs are available: | |
695 | ||
696 | %w The article washing status. | |
697 | %m The number of MIME parts in the article." | |
eec82323 LMI |
698 | :type 'string |
699 | :group 'gnus-article-various) | |
700 | ||
701 | (defcustom gnus-article-mode-hook nil | |
702 | "*A hook for Gnus article mode." | |
703 | :type 'hook | |
704 | :group 'gnus-article-various) | |
705 | ||
23f87bed MB |
706 | (when (featurep 'xemacs) |
707 | ;; Extracted from gnus-xmas-define in order to preserve user settings | |
708 | (when (fboundp 'turn-off-scroll-in-place) | |
709 | (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place)) | |
710 | ;; Extracted from gnus-xmas-redefine in order to preserve user settings | |
711 | (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add)) | |
712 | ||
eec82323 LMI |
713 | (defcustom gnus-article-menu-hook nil |
714 | "*Hook run after the creation of the article mode menu." | |
715 | :type 'hook | |
716 | :group 'gnus-article-various) | |
717 | ||
718 | (defcustom gnus-article-prepare-hook nil | |
16409b0b | 719 | "*A hook called after an article has been prepared in the article buffer." |
eec82323 LMI |
720 | :type 'hook |
721 | :group 'gnus-article-various) | |
722 | ||
01c52d31 MB |
723 | (defcustom gnus-copy-article-ignored-headers nil |
724 | "List of headers to be removed when copying an article. | |
725 | Each element is a regular expression." | |
330f707b | 726 | :version "23.1" ;; No Gnus |
01c52d31 MB |
727 | :type '(repeat regexp) |
728 | :group 'gnus-article-various) | |
729 | ||
265ac10b SM |
730 | (make-obsolete-variable 'gnus-article-hide-pgp-hook nil |
731 | "Gnus 5.10 (Emacs-22.1)") | |
a8151ef7 | 732 | |
01c52d31 MB |
733 | (defface gnus-button |
734 | '((t (:weight bold))) | |
735 | "Face used for highlighting a button in the article buffer." | |
736 | :group 'gnus-article-buttons) | |
737 | ||
738 | (defcustom gnus-article-button-face 'gnus-button | |
eec82323 LMI |
739 | "Face used for highlighting buttons in the article buffer. |
740 | ||
741 | An article button is a piece of text that you can activate by pressing | |
742 | `RET' or `mouse-2' above it." | |
743 | :type 'face | |
744 | :group 'gnus-article-buttons) | |
745 | ||
746 | (defcustom gnus-article-mouse-face 'highlight | |
747 | "Face used for mouse highlighting in the article buffer. | |
748 | ||
749 | Article buttons will be displayed in this face when the cursor is | |
750 | above them." | |
751 | :type 'face | |
752 | :group 'gnus-article-buttons) | |
753 | ||
0f49874b | 754 | (defcustom gnus-signature-face 'gnus-signature |
a8151ef7 | 755 | "Face used for highlighting a signature in the article buffer. |
0f49874b | 756 | Obsolete; use the face `gnus-signature' for customizations instead." |
eec82323 LMI |
757 | :type 'face |
758 | :group 'gnus-article-highlight | |
759 | :group 'gnus-article-signature) | |
760 | ||
0f49874b | 761 | (defface gnus-signature |
f59a3415 | 762 | '((t |
23f87bed | 763 | (:italic t))) |
a8151ef7 LMI |
764 | "Face used for highlighting a signature in the article buffer." |
765 | :group 'gnus-article-highlight | |
766 | :group 'gnus-article-signature) | |
0f49874b MB |
767 | ;; backward-compatibility alias |
768 | (put 'gnus-signature-face 'face-alias 'gnus-signature) | |
3d493bef | 769 | (put 'gnus-signature-face 'obsolete-face "22.1") |
a8151ef7 | 770 | |
0f49874b | 771 | (defface gnus-header-from |
eec82323 LMI |
772 | '((((class color) |
773 | (background dark)) | |
01c52d31 | 774 | (:foreground "PaleGreen1")) |
eec82323 LMI |
775 | (((class color) |
776 | (background light)) | |
6748645f | 777 | (:foreground "red3")) |
eec82323 | 778 | (t |
23f87bed | 779 | (:italic t))) |
eec82323 LMI |
780 | "Face used for displaying from headers." |
781 | :group 'gnus-article-headers | |
782 | :group 'gnus-article-highlight) | |
0f49874b MB |
783 | ;; backward-compatibility alias |
784 | (put 'gnus-header-from-face 'face-alias 'gnus-header-from) | |
3d493bef | 785 | (put 'gnus-header-from-face 'obsolete-face "22.1") |
eec82323 | 786 | |
0f49874b | 787 | (defface gnus-header-subject |
eec82323 LMI |
788 | '((((class color) |
789 | (background dark)) | |
01c52d31 | 790 | (:foreground "SeaGreen1")) |
eec82323 LMI |
791 | (((class color) |
792 | (background light)) | |
6748645f | 793 | (:foreground "red4")) |
eec82323 | 794 | (t |
23f87bed | 795 | (:bold t :italic t))) |
eec82323 LMI |
796 | "Face used for displaying subject headers." |
797 | :group 'gnus-article-headers | |
798 | :group 'gnus-article-highlight) | |
0f49874b MB |
799 | ;; backward-compatibility alias |
800 | (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject) | |
3d493bef | 801 | (put 'gnus-header-subject-face 'obsolete-face "22.1") |
eec82323 | 802 | |
0f49874b | 803 | (defface gnus-header-newsgroups |
eec82323 LMI |
804 | '((((class color) |
805 | (background dark)) | |
23f87bed | 806 | (:foreground "yellow" :italic t)) |
eec82323 LMI |
807 | (((class color) |
808 | (background light)) | |
23f87bed | 809 | (:foreground "MidnightBlue" :italic t)) |
eec82323 | 810 | (t |
23f87bed MB |
811 | (:italic t))) |
812 | "Face used for displaying newsgroups headers. | |
813 | In the default setup this face is only used for crossposted | |
814 | articles." | |
eec82323 LMI |
815 | :group 'gnus-article-headers |
816 | :group 'gnus-article-highlight) | |
0f49874b MB |
817 | ;; backward-compatibility alias |
818 | (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups) | |
3d493bef | 819 | (put 'gnus-header-newsgroups-face 'obsolete-face "22.1") |
eec82323 | 820 | |
0f49874b | 821 | (defface gnus-header-name |
eec82323 LMI |
822 | '((((class color) |
823 | (background dark)) | |
01c52d31 | 824 | (:foreground "SpringGreen2")) |
eec82323 LMI |
825 | (((class color) |
826 | (background light)) | |
827 | (:foreground "maroon")) | |
828 | (t | |
23f87bed | 829 | (:bold t))) |
eec82323 LMI |
830 | "Face used for displaying header names." |
831 | :group 'gnus-article-headers | |
832 | :group 'gnus-article-highlight) | |
0f49874b MB |
833 | ;; backward-compatibility alias |
834 | (put 'gnus-header-name-face 'face-alias 'gnus-header-name) | |
3d493bef | 835 | (put 'gnus-header-name-face 'obsolete-face "22.1") |
eec82323 | 836 | |
0f49874b | 837 | (defface gnus-header-content |
eec82323 LMI |
838 | '((((class color) |
839 | (background dark)) | |
01c52d31 | 840 | (:foreground "SpringGreen1" :italic t)) |
eec82323 LMI |
841 | (((class color) |
842 | (background light)) | |
23f87bed | 843 | (:foreground "indianred4" :italic t)) |
eec82323 | 844 | (t |
23f87bed | 845 | (:italic t))) "Face used for displaying header content." |
eec82323 LMI |
846 | :group 'gnus-article-headers |
847 | :group 'gnus-article-highlight) | |
0f49874b MB |
848 | ;; backward-compatibility alias |
849 | (put 'gnus-header-content-face 'face-alias 'gnus-header-content) | |
3d493bef | 850 | (put 'gnus-header-content-face 'obsolete-face "22.1") |
eec82323 LMI |
851 | |
852 | (defcustom gnus-header-face-alist | |
0f49874b MB |
853 | '(("From" nil gnus-header-from) |
854 | ("Subject" nil gnus-header-subject) | |
855 | ("Newsgroups:.*," nil gnus-header-newsgroups) | |
856 | ("" gnus-header-name gnus-header-content)) | |
23f87bed | 857 | "*Controls highlighting of article headers. |
eec82323 LMI |
858 | |
859 | An alist of the form (HEADER NAME CONTENT). | |
860 | ||
23f87bed MB |
861 | HEADER is a regular expression which should match the name of a |
862 | header and NAME and CONTENT are either face names or nil. | |
eec82323 LMI |
863 | |
864 | The name of each header field will be displayed using the face | |
23f87bed MB |
865 | specified by the first element in the list where HEADER matches |
866 | the header name and NAME is non-nil. Similarly, the content will | |
867 | be displayed by the first non-nil matching CONTENT face." | |
eec82323 LMI |
868 | :group 'gnus-article-headers |
869 | :group 'gnus-article-highlight | |
870 | :type '(repeat (list (regexp :tag "Header") | |
871 | (choice :tag "Name" | |
872 | (item :tag "skip" nil) | |
873 | (face :value default)) | |
874 | (choice :tag "Content" | |
875 | (item :tag "skip" nil) | |
876 | (face :value default))))) | |
877 | ||
01c52d31 MB |
878 | (defcustom gnus-face-properties-alist (if (featurep 'xemacs) |
879 | '((xface . (:face gnus-x-face))) | |
880 | '((pbm . (:face gnus-x-face)) | |
881 | (png . nil))) | |
882 | "Alist of image types and properties applied to Face and X-Face images. | |
883 | Here are examples: | |
884 | ||
885 | ;; Specify the altitude of Face images in the From header. | |
886 | \(setq gnus-face-properties-alist | |
887 | '((pbm . (:face gnus-x-face :ascent 80)) | |
888 | (png . (:ascent 80)))) | |
889 | ||
890 | ;; Show Face images as pressed buttons. | |
891 | \(setq gnus-face-properties-alist | |
892 | '((pbm . (:face gnus-x-face :relief -2)) | |
893 | (png . (:relief -2)))) | |
894 | ||
895 | See the manual for the valid properties for various image types. | |
896 | Currently, `pbm' is used for X-Face images and `png' is used for Face | |
897 | images in Emacs. Only the `:face' property is effective on the `xface' | |
898 | image type in XEmacs if it is built with the libcompface library." | |
330f707b | 899 | :version "23.1" ;; No Gnus |
01c52d31 MB |
900 | :group 'gnus-article-headers |
901 | :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist))) | |
902 | ||
16409b0b | 903 | (defcustom gnus-article-decode-hook |
23f87bed MB |
904 | '(article-decode-charset article-decode-encoded-words |
905 | article-decode-group-name article-decode-idna-rhs) | |
16409b0b GM |
906 | "*Hook run to decode charsets in articles." |
907 | :group 'gnus-article-headers | |
908 | :type 'hook) | |
909 | ||
910 | (defcustom gnus-display-mime-function 'gnus-display-mime | |
911 | "Function to display MIME articles." | |
912 | :group 'gnus-article-mime | |
913 | :type 'function) | |
914 | ||
915 | (defvar gnus-decode-header-function 'mail-decode-encoded-word-region | |
916 | "Function used to decode headers.") | |
917 | ||
343d6628 MB |
918 | (defvar gnus-decode-address-function 'mail-decode-encoded-address-region |
919 | "Function used to decode addresses.") | |
920 | ||
16409b0b | 921 | (defvar gnus-article-dumbquotes-map |
23f87bed MB |
922 | '(("\200" "EUR") |
923 | ("\202" ",") | |
16409b0b GM |
924 | ("\203" "f") |
925 | ("\204" ",,") | |
926 | ("\205" "...") | |
927 | ("\213" "<") | |
928 | ("\214" "OE") | |
929 | ("\221" "`") | |
930 | ("\222" "'") | |
931 | ("\223" "``") | |
932 | ("\224" "\"") | |
933 | ("\225" "*") | |
e0bad764 DL |
934 | ("\226" "-") |
935 | ("\227" "--") | |
23f87bed | 936 | ("\230" "~") |
16409b0b GM |
937 | ("\231" "(TM)") |
938 | ("\233" ">") | |
939 | ("\234" "oe") | |
940 | ("\264" "'")) | |
941 | "Table for MS-to-Latin1 translation.") | |
942 | ||
943 | (defcustom gnus-ignored-mime-types nil | |
944 | "List of MIME types that should be ignored by Gnus." | |
fc2c2db8 | 945 | :version "21.1" |
16409b0b GM |
946 | :group 'gnus-article-mime |
947 | :type '(repeat regexp)) | |
948 | ||
949 | (defcustom gnus-unbuttonized-mime-types '(".*/.*") | |
23f87bed MB |
950 | "List of MIME types that should not be given buttons when rendered inline. |
951 | See also `gnus-buttonized-mime-types' which may override this variable. | |
952 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." | |
953 | :version "21.1" | |
954 | :group 'gnus-article-mime | |
955 | :type '(repeat regexp)) | |
956 | ||
957 | (defcustom gnus-buttonized-mime-types nil | |
958 | "List of MIME types that should be given buttons when rendered inline. | |
959 | If set, this variable overrides `gnus-unbuttonized-mime-types'. | |
960 | To see e.g. security buttons you could set this to | |
3031d8b0 MB |
961 | `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to |
962 | this list to display radio buttons that allow you to choose one of two | |
963 | media types those mails include. See also `mm-discouraged-alternatives'. | |
23f87bed | 964 | This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil." |
bf247b6e | 965 | :version "22.1" |
16409b0b GM |
966 | :group 'gnus-article-mime |
967 | :type '(repeat regexp)) | |
968 | ||
23f87bed MB |
969 | (defcustom gnus-inhibit-mime-unbuttonizing nil |
970 | "If non-nil, all MIME parts get buttons. | |
971 | When nil (the default value), then some MIME parts do not get buttons, | |
972 | as described by the variables `gnus-buttonized-mime-types' and | |
973 | `gnus-unbuttonized-mime-types'." | |
bf247b6e | 974 | :version "22.1" |
d0859c9a | 975 | :group 'gnus-article-mime |
23f87bed MB |
976 | :type 'boolean) |
977 | ||
978 | (defcustom gnus-body-boundary-delimiter "_" | |
979 | "String used to delimit header and body. | |
980 | This variable is used by `gnus-article-treat-body-boundary' which can | |
981 | be controlled by `gnus-treat-body-boundary'." | |
bf247b6e | 982 | :version "22.1" |
23f87bed MB |
983 | :group 'gnus-article-various |
984 | :type '(choice (item :tag "None" :value nil) | |
985 | string)) | |
986 | ||
97f78c9b MB |
987 | (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces" |
988 | "/usr/share/picons") | |
23f87bed MB |
989 | "Defines the location of the faces database. |
990 | For information on obtaining this database of pretty pictures, please | |
991 | see http://www.cs.indiana.edu/picons/ftp/index.html" | |
bf247b6e | 992 | :version "22.1" |
23f87bed MB |
993 | :type '(repeat directory) |
994 | :link '(url-link :tag "download" | |
995 | "http://www.cs.indiana.edu/picons/ftp/index.html") | |
996 | :link '(custom-manual "(gnus)Picons") | |
997 | :group 'gnus-picon) | |
998 | ||
999 | (defun gnus-picons-installed-p () | |
1000 | "Say whether picons are installed on your machine." | |
1001 | (let ((installed nil)) | |
1002 | (dolist (database gnus-picon-databases) | |
1003 | (when (file-exists-p database) | |
1004 | (setq installed t))) | |
1005 | installed)) | |
1006 | ||
16409b0b GM |
1007 | (defcustom gnus-article-mime-part-function nil |
1008 | "Function called with a MIME handle as the argument. | |
1009 | This is meant for people who want to do something automatic based | |
1010 | on parts -- for instance, adding Vcard info to a database." | |
1011 | :group 'gnus-article-mime | |
4a2358e9 MB |
1012 | :type '(choice (const nil) |
1013 | function)) | |
16409b0b GM |
1014 | |
1015 | (defcustom gnus-mime-multipart-functions nil | |
fc2c2db8 DL |
1016 | "An alist of MIME types to functions to display them." |
1017 | :version "21.1" | |
1018 | :group 'gnus-article-mime | |
01c52d31 | 1019 | :type '(repeat (cons :format "%v" (string :tag "MIME type") function))) |
16409b0b GM |
1020 | |
1021 | (defcustom gnus-article-date-lapsed-new-header nil | |
1022 | "Whether the X-Sent and Date headers can coexist. | |
1023 | When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will | |
1024 | either replace the old \"Date:\" header (if this variable is nil), or | |
1025 | be added below it (otherwise)." | |
fc2c2db8 | 1026 | :version "21.1" |
16409b0b GM |
1027 | :group 'gnus-article-headers |
1028 | :type 'boolean) | |
1029 | ||
1030 | (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative | |
1031 | "Function called with a MIME handle as the argument. | |
1032 | This is meant for people who want to view first matched part. | |
a1506d29 JB |
1033 | For `undisplayed-alternative' (default), the first undisplayed |
1034 | part or alternative part is used. For `undisplayed', the first | |
1035 | undisplayed part is used. For a function, the first part which | |
f20b2f5c | 1036 | the function return t is used. For nil, the first part is |
16409b0b | 1037 | used." |
fc2c2db8 | 1038 | :version "21.1" |
16409b0b | 1039 | :group 'gnus-article-mime |
a1506d29 | 1040 | :type '(choice |
16409b0b GM |
1041 | (item :tag "first" :value nil) |
1042 | (item :tag "undisplayed" :value undisplayed) | |
a1506d29 | 1043 | (item :tag "undisplayed or alternative" |
16409b0b GM |
1044 | :value undisplayed-alternative) |
1045 | (function))) | |
1046 | ||
e0bad764 DL |
1047 | (defcustom gnus-mime-action-alist |
1048 | '(("save to file" . gnus-mime-save-part) | |
23f87bed | 1049 | ("save and strip" . gnus-mime-save-part-and-strip) |
01c52d31 | 1050 | ("replace with file" . gnus-mime-replace-part) |
23f87bed | 1051 | ("delete part" . gnus-mime-delete-part) |
e0bad764 DL |
1052 | ("display as text" . gnus-mime-inline-part) |
1053 | ("view the part" . gnus-mime-view-part) | |
1054 | ("pipe to command" . gnus-mime-pipe-part) | |
1055 | ("toggle display" . gnus-article-press-button) | |
23f87bed | 1056 | ("toggle display" . gnus-article-view-part-as-charset) |
e0bad764 | 1057 | ("view as type" . gnus-mime-view-part-as-type) |
23f87bed MB |
1058 | ("view internally" . gnus-mime-view-part-internally) |
1059 | ("view externally" . gnus-mime-view-part-externally)) | |
e0bad764 DL |
1060 | "An alist of actions that run on the MIME attachment." |
1061 | :group 'gnus-article-mime | |
1062 | :type '(repeat (cons (string :tag "name") | |
1063 | (function)))) | |
1064 | ||
01c52d31 MB |
1065 | (defcustom gnus-auto-select-part 1 |
1066 | "Advance to next MIME part when deleting or stripping parts. | |
1067 | ||
1068 | When 0, point will be placed on the same part as before. When | |
1069 | positive (negative), move point forward (backwards) this many | |
1070 | parts. When nil, redisplay article." | |
330f707b | 1071 | :version "23.1" ;; No Gnus |
01c52d31 MB |
1072 | :group 'gnus-article-mime |
1073 | :type '(choice (const nil :tag "Redisplay article.") | |
1074 | (const 1 :tag "Next part.") | |
1075 | (const 0 :tag "Current part.") | |
1076 | integer)) | |
1077 | ||
16409b0b GM |
1078 | ;;; |
1079 | ;;; The treatment variables | |
1080 | ;;; | |
1081 | ||
1082 | (defvar gnus-part-display-hook nil | |
1083 | "Hook called on parts that are to receive treatment.") | |
1084 | ||
1085 | (defvar gnus-article-treat-custom | |
1086 | '(choice (const :tag "Off" nil) | |
1087 | (const :tag "On" t) | |
1088 | (const :tag "Header" head) | |
01c52d31 | 1089 | (const :tag "First" first) |
16409b0b GM |
1090 | (const :tag "Last" last) |
1091 | (integer :tag "Less") | |
1092 | (repeat :tag "Groups" regexp) | |
1093 | (sexp :tag "Predicate"))) | |
1094 | ||
1095 | (defvar gnus-article-treat-head-custom | |
1096 | '(choice (const :tag "Off" nil) | |
1097 | (const :tag "Header" head))) | |
1098 | ||
01c52d31 MB |
1099 | (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim" |
1100 | "text/x-patch") | |
16409b0b GM |
1101 | "Parts to treat.") |
1102 | ||
1103 | (defvar gnus-inhibit-treatment nil | |
1104 | "Whether to inhibit treatment.") | |
1105 | ||
23f87bed | 1106 | (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard")) |
16409b0b | 1107 | "Highlight the signature. |
01c52d31 MB |
1108 | Valid values are nil, t, `head', `first', `last', an integer or a |
1109 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1110 | :group 'gnus-article-treat |
23f87bed | 1111 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1112 | :type gnus-article-treat-custom) |
1113 | (put 'gnus-treat-highlight-signature 'highlight t) | |
1114 | ||
1115 | (defcustom gnus-treat-buttonize 100000 | |
1116 | "Add buttons. | |
01c52d31 MB |
1117 | Valid values are nil, t, `head', `first', `last', an integer or a |
1118 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1119 | :group 'gnus-article-treat |
23f87bed | 1120 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1121 | :type gnus-article-treat-custom) |
1122 | (put 'gnus-treat-buttonize 'highlight t) | |
1123 | ||
1124 | (defcustom gnus-treat-buttonize-head 'head | |
1125 | "Add buttons to the head. | |
01c52d31 MB |
1126 | Valid values are nil, t, `head', `first', `last', an integer or a |
1127 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1128 | :group 'gnus-article-treat |
23f87bed | 1129 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1130 | :type gnus-article-treat-head-custom) |
1131 | (put 'gnus-treat-buttonize-head 'highlight t) | |
1132 | ||
437ce4be | 1133 | (defcustom gnus-treat-emphasize 50000 |
16409b0b | 1134 | "Emphasize text. |
01c52d31 MB |
1135 | Valid values are nil, t, `head', `first', `last', an integer or a |
1136 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1137 | :group 'gnus-article-treat |
23f87bed | 1138 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1139 | :type gnus-article-treat-custom) |
1140 | (put 'gnus-treat-emphasize 'highlight t) | |
1141 | ||
1142 | (defcustom gnus-treat-strip-cr nil | |
1143 | "Remove carriage returns. | |
01c52d31 MB |
1144 | Valid values are nil, t, `head', `first', `last', an integer or a |
1145 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1146 | :version "22.1" |
16409b0b | 1147 | :group 'gnus-article-treat |
23f87bed MB |
1148 | :link '(custom-manual "(gnus)Customizing Articles") |
1149 | :type gnus-article-treat-custom) | |
1150 | ||
1151 | (defcustom gnus-treat-unsplit-urls nil | |
1152 | "Remove newlines from within URLs. | |
01c52d31 MB |
1153 | Valid values are nil, t, `head', `first', `last', an integer or a |
1154 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1155 | :version "22.1" |
23f87bed MB |
1156 | :group 'gnus-article-treat |
1157 | :link '(custom-manual "(gnus)Customizing Articles") | |
1158 | :type gnus-article-treat-custom) | |
1159 | ||
1160 | (defcustom gnus-treat-leading-whitespace nil | |
1161 | "Remove leading whitespace in headers. | |
01c52d31 MB |
1162 | Valid values are nil, t, `head', `first', `last', an integer or a |
1163 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1164 | :version "22.1" |
23f87bed MB |
1165 | :group 'gnus-article-treat |
1166 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1167 | :type gnus-article-treat-custom) |
1168 | ||
1169 | (defcustom gnus-treat-hide-headers 'head | |
1170 | "Hide headers. | |
01c52d31 MB |
1171 | Valid values are nil, t, `head', `first', `last', an integer or a |
1172 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1173 | :group 'gnus-article-treat |
23f87bed | 1174 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1175 | :type gnus-article-treat-head-custom) |
1176 | ||
1177 | (defcustom gnus-treat-hide-boring-headers nil | |
1178 | "Hide boring headers. | |
01c52d31 MB |
1179 | Valid values are nil, t, `head', `first', `last', an integer or a |
1180 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1181 | :group 'gnus-article-treat |
23f87bed | 1182 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1183 | :type gnus-article-treat-head-custom) |
1184 | ||
1185 | (defcustom gnus-treat-hide-signature nil | |
1186 | "Hide the signature. | |
01c52d31 MB |
1187 | Valid values are nil, t, `head', `first', `last', an integer or a |
1188 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1189 | :group 'gnus-article-treat |
23f87bed | 1190 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1191 | :type gnus-article-treat-custom) |
1192 | ||
1193 | (defcustom gnus-treat-fill-article nil | |
1194 | "Fill the article. | |
01c52d31 MB |
1195 | Valid values are nil, t, `head', `first', `last', an integer or a |
1196 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1197 | :group 'gnus-article-treat |
23f87bed | 1198 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1199 | :type gnus-article-treat-custom) |
1200 | ||
1201 | (defcustom gnus-treat-hide-citation nil | |
1202 | "Hide cited text. | |
01c52d31 MB |
1203 | Valid values are nil, t, `head', `first', `last', an integer or a |
1204 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1205 | :group 'gnus-article-treat |
23f87bed | 1206 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1207 | :type gnus-article-treat-custom) |
1208 | ||
e0bad764 DL |
1209 | (defcustom gnus-treat-hide-citation-maybe nil |
1210 | "Hide cited text. | |
01c52d31 MB |
1211 | Valid values are nil, t, `head', `first', `last', an integer or a |
1212 | predicate. See Info node `(gnus)Customizing Articles'." | |
e0bad764 | 1213 | :group 'gnus-article-treat |
23f87bed | 1214 | :link '(custom-manual "(gnus)Customizing Articles") |
e0bad764 DL |
1215 | :type gnus-article-treat-custom) |
1216 | ||
16409b0b GM |
1217 | (defcustom gnus-treat-strip-list-identifiers 'head |
1218 | "Strip list identifiers from `gnus-list-identifiers`. | |
01c52d31 MB |
1219 | Valid values are nil, t, `head', `first', `last', an integer or a |
1220 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1221 | :version "21.1" |
16409b0b | 1222 | :group 'gnus-article-treat |
23f87bed | 1223 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1224 | :type gnus-article-treat-custom) |
1225 | ||
265ac10b SM |
1226 | (make-obsolete-variable 'gnus-treat-strip-pgp nil |
1227 | "Gnus 5.10 (Emacs 22.1)") | |
16409b0b GM |
1228 | |
1229 | (defcustom gnus-treat-strip-pem nil | |
1230 | "Strip PEM signatures. | |
01c52d31 MB |
1231 | Valid values are nil, t, `head', `first', `last', an integer or a |
1232 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1233 | :group 'gnus-article-treat |
23f87bed | 1234 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1235 | :type gnus-article-treat-custom) |
1236 | ||
1237 | (defcustom gnus-treat-strip-banner t | |
1238 | "Strip banners from articles. | |
1239 | The banner to be stripped is specified in the `banner' group parameter. | |
01c52d31 MB |
1240 | Valid values are nil, t, `head', `first', `last', an integer or a |
1241 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1242 | :group 'gnus-article-treat |
23f87bed | 1243 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1244 | :type gnus-article-treat-custom) |
1245 | ||
1246 | (defcustom gnus-treat-highlight-headers 'head | |
1247 | "Highlight the headers. | |
01c52d31 MB |
1248 | Valid values are nil, t, `head', `first', `last', an integer or a |
1249 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1250 | :group 'gnus-article-treat |
23f87bed | 1251 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1252 | :type gnus-article-treat-head-custom) |
1253 | (put 'gnus-treat-highlight-headers 'highlight t) | |
1254 | ||
1255 | (defcustom gnus-treat-highlight-citation t | |
1256 | "Highlight cited text. | |
01c52d31 MB |
1257 | Valid values are nil, t, `head', `first', `last', an integer or a |
1258 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1259 | :group 'gnus-article-treat |
23f87bed | 1260 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1261 | :type gnus-article-treat-custom) |
1262 | (put 'gnus-treat-highlight-citation 'highlight t) | |
1263 | ||
1264 | (defcustom gnus-treat-date-ut nil | |
1265 | "Display the Date in UT (GMT). | |
01c52d31 MB |
1266 | Valid values are nil, t, `head', `first', `last', an integer or a |
1267 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1268 | :group 'gnus-article-treat |
23f87bed | 1269 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1270 | :type gnus-article-treat-head-custom) |
1271 | ||
1272 | (defcustom gnus-treat-date-local nil | |
1273 | "Display the Date in the local timezone. | |
01c52d31 MB |
1274 | Valid values are nil, t, `head', `first', `last', an integer or a |
1275 | predicate. See Info node `(gnus)Customizing Articles'." | |
23f87bed MB |
1276 | :group 'gnus-article-treat |
1277 | :link '(custom-manual "(gnus)Customizing Articles") | |
1278 | :type gnus-article-treat-head-custom) | |
1279 | ||
1280 | (defcustom gnus-treat-date-english nil | |
1281 | "Display the Date in a format that can be read aloud in English. | |
01c52d31 MB |
1282 | Valid values are nil, t, `head', `first', `last', an integer or a |
1283 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1284 | :version "22.1" |
16409b0b | 1285 | :group 'gnus-article-treat |
23f87bed | 1286 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1287 | :type gnus-article-treat-head-custom) |
1288 | ||
1289 | (defcustom gnus-treat-date-lapsed nil | |
1290 | "Display the Date header in a way that says how much time has elapsed. | |
01c52d31 MB |
1291 | Valid values are nil, t, `head', `first', `last', an integer or a |
1292 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1293 | :group 'gnus-article-treat |
23f87bed | 1294 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1295 | :type gnus-article-treat-head-custom) |
1296 | ||
1297 | (defcustom gnus-treat-date-original nil | |
1298 | "Display the date in the original timezone. | |
01c52d31 MB |
1299 | Valid values are nil, t, `head', `first', `last', an integer or a |
1300 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1301 | :group 'gnus-article-treat |
23f87bed | 1302 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1303 | :type gnus-article-treat-head-custom) |
1304 | ||
1305 | (defcustom gnus-treat-date-iso8601 nil | |
1306 | "Display the date in the ISO8601 format. | |
01c52d31 MB |
1307 | Valid values are nil, t, `head', `first', `last', an integer or a |
1308 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1309 | :version "21.1" |
16409b0b | 1310 | :group 'gnus-article-treat |
23f87bed | 1311 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1312 | :type gnus-article-treat-head-custom) |
1313 | ||
1314 | (defcustom gnus-treat-date-user-defined nil | |
1315 | "Display the date in a user-defined format. | |
1316 | The format is defined by the `gnus-article-time-format' variable. | |
01c52d31 MB |
1317 | Valid values are nil, t, `head', `first', `last', an integer or a |
1318 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1319 | :group 'gnus-article-treat |
23f87bed | 1320 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1321 | :type gnus-article-treat-head-custom) |
1322 | ||
1323 | (defcustom gnus-treat-strip-headers-in-body t | |
1324 | "Strip the X-No-Archive header line from the beginning of the body. | |
01c52d31 MB |
1325 | Valid values are nil, t, `head', `first', `last', an integer or a |
1326 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1327 | :version "21.1" |
16409b0b | 1328 | :group 'gnus-article-treat |
23f87bed | 1329 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1330 | :type gnus-article-treat-custom) |
1331 | ||
1332 | (defcustom gnus-treat-strip-trailing-blank-lines nil | |
1333 | "Strip trailing blank lines. | |
01c52d31 MB |
1334 | Valid values are nil, t, `head', `first', `last', an integer or a |
1335 | predicate. See Info node `(gnus)Customizing Articles'. | |
292f71fe MB |
1336 | |
1337 | When set to t, it also strips trailing blanks in all MIME parts. | |
1338 | Consider to use `last' instead." | |
16409b0b | 1339 | :group 'gnus-article-treat |
23f87bed | 1340 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1341 | :type gnus-article-treat-custom) |
1342 | ||
1343 | (defcustom gnus-treat-strip-leading-blank-lines nil | |
1344 | "Strip leading blank lines. | |
01c52d31 MB |
1345 | Valid values are nil, t, `head', `first', `last', an integer or a |
1346 | predicate. See Info node `(gnus)Customizing Articles'. | |
292f71fe MB |
1347 | |
1348 | When set to t, it also strips trailing blanks in all MIME parts." | |
16409b0b | 1349 | :group 'gnus-article-treat |
23f87bed | 1350 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1351 | :type gnus-article-treat-custom) |
1352 | ||
1353 | (defcustom gnus-treat-strip-multiple-blank-lines nil | |
1354 | "Strip multiple blank lines. | |
01c52d31 MB |
1355 | Valid values are nil, t, `head', `first', `last', an integer or a |
1356 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1357 | :group 'gnus-article-treat |
23f87bed MB |
1358 | :link '(custom-manual "(gnus)Customizing Articles") |
1359 | :type gnus-article-treat-custom) | |
1360 | ||
1361 | (defcustom gnus-treat-unfold-headers 'head | |
1362 | "Unfold folded header lines. | |
01c52d31 MB |
1363 | Valid values are nil, t, `head', `first', `last', an integer or a |
1364 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1365 | :version "22.1" |
23f87bed MB |
1366 | :group 'gnus-article-treat |
1367 | :link '(custom-manual "(gnus)Customizing Articles") | |
1368 | :type gnus-article-treat-custom) | |
1369 | ||
01c52d31 MB |
1370 | (defcustom gnus-article-unfold-long-headers nil |
1371 | "If non-nil, allow unfolding headers even if the header is long. | |
1372 | If it is a regexp, only long headers matching this regexp are unfolded. | |
1373 | If it is t, all long headers are unfolded. | |
1374 | ||
1375 | This variable has no effect if `gnus-treat-unfold-headers' is nil." | |
330f707b | 1376 | :version "23.1" ;; No Gnus |
01c52d31 MB |
1377 | :group 'gnus-article-treat |
1378 | :type '(choice (const nil) | |
1379 | (const :tag "all" t) | |
1380 | (regexp))) | |
1381 | ||
23f87bed MB |
1382 | (defcustom gnus-treat-fold-headers nil |
1383 | "Fold headers. | |
01c52d31 MB |
1384 | Valid values are nil, t, `head', `first', `last', an integer or a |
1385 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1386 | :version "22.1" |
23f87bed MB |
1387 | :group 'gnus-article-treat |
1388 | :link '(custom-manual "(gnus)Customizing Articles") | |
1389 | :type gnus-article-treat-custom) | |
1390 | ||
1391 | (defcustom gnus-treat-fold-newsgroups 'head | |
1392 | "Fold the Newsgroups and Followup-To headers. | |
01c52d31 MB |
1393 | Valid values are nil, t, `head', `first', `last', an integer or a |
1394 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1395 | :version "22.1" |
23f87bed MB |
1396 | :group 'gnus-article-treat |
1397 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1398 | :type gnus-article-treat-custom) |
1399 | ||
1400 | (defcustom gnus-treat-overstrike t | |
1401 | "Treat overstrike highlighting. | |
01c52d31 MB |
1402 | Valid values are nil, t, `head', `first', `last', an integer or a |
1403 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1404 | :group 'gnus-article-treat |
23f87bed | 1405 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1406 | :type gnus-article-treat-custom) |
1407 | (put 'gnus-treat-overstrike 'highlight t) | |
1408 | ||
01c52d31 MB |
1409 | (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t) |
1410 | "Treat ANSI SGR control sequences. | |
1411 | Valid values are nil, t, `head', `first', `last', an integer or a | |
1412 | predicate. See Info node `(gnus)Customizing Articles'." | |
1413 | :group 'gnus-article-treat | |
1414 | :link '(custom-manual "(gnus)Customizing Articles") | |
1415 | :type gnus-article-treat-custom) | |
1416 | ||
23f87bed | 1417 | (make-obsolete-variable 'gnus-treat-display-xface |
265ac10b | 1418 | 'gnus-treat-display-x-face "22.1") |
23f87bed MB |
1419 | |
1420 | (defcustom gnus-treat-display-x-face | |
1421 | (and (not noninteractive) | |
11e95b02 MB |
1422 | (gnus-image-type-available-p 'xbm) |
1423 | (if (featurep 'xemacs) | |
1424 | (featurep 'xface) | |
1425 | (and (string-match "^0x" (shell-command-to-string "uncompface")) | |
1426 | (executable-find "icontopbm"))) | |
8b93df01 | 1427 | 'head) |
16409b0b | 1428 | "Display X-Face headers. |
87ba2830 | 1429 | Valid values are nil and `head'. |
23f87bed MB |
1430 | See Info node `(gnus)Customizing Articles' and Info node |
1431 | `(gnus)X-Face' for details." | |
1432 | :group 'gnus-article-treat | |
1433 | :version "21.1" | |
1434 | :link '(custom-manual "(gnus)Customizing Articles") | |
1435 | :link '(custom-manual "(gnus)X-Face") | |
1436 | :type gnus-article-treat-head-custom | |
1437 | :set (lambda (symbol value) | |
1438 | (set-default | |
1439 | symbol | |
1440 | (cond ((or (boundp symbol) (get symbol 'saved-value)) | |
1441 | value) | |
1442 | ((boundp 'gnus-treat-display-xface) | |
1443 | (message "\ | |
1444 | ** gnus-treat-display-xface is an obsolete variable;\ | |
1445 | use gnus-treat-display-x-face instead") | |
1446 | (default-value 'gnus-treat-display-xface)) | |
1447 | ((get 'gnus-treat-display-xface 'saved-value) | |
1448 | (message "\ | |
1449 | ** gnus-treat-display-xface is an obsolete variable;\ | |
1450 | use gnus-treat-display-x-face instead") | |
1451 | (eval (car (get 'gnus-treat-display-xface 'saved-value)))) | |
1452 | (t | |
1453 | value))))) | |
1454 | (put 'gnus-treat-display-x-face 'highlight t) | |
1455 | ||
1456 | (defcustom gnus-treat-display-face | |
1457 | (and (not noninteractive) | |
11e95b02 | 1458 | (gnus-image-type-available-p 'png) |
23f87bed MB |
1459 | 'head) |
1460 | "Display Face headers. | |
01c52d31 MB |
1461 | Valid values are nil, t, `head', `first', `last', an integer or a |
1462 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
41ec3f54 | 1463 | node `(gnus)Face' for details." |
16409b0b | 1464 | :group 'gnus-article-treat |
bf247b6e | 1465 | :version "22.1" |
23f87bed MB |
1466 | :link '(custom-manual "(gnus)Customizing Articles") |
1467 | :link '(custom-manual "(gnus)X-Face") | |
16409b0b | 1468 | :type gnus-article-treat-head-custom) |
23f87bed | 1469 | (put 'gnus-treat-display-face 'highlight t) |
16409b0b | 1470 | |
11e95b02 | 1471 | (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm) |
16409b0b | 1472 | "Display smileys. |
01c52d31 MB |
1473 | Valid values are nil, t, `head', `first', `last', an integer or a |
1474 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1475 | node `(gnus)Smileys' for details." | |
16409b0b | 1476 | :group 'gnus-article-treat |
b5a206e7 | 1477 | :version "21.1" |
23f87bed MB |
1478 | :link '(custom-manual "(gnus)Customizing Articles") |
1479 | :link '(custom-manual "(gnus)Smileys") | |
16409b0b GM |
1480 | :type gnus-article-treat-custom) |
1481 | (put 'gnus-treat-display-smileys 'highlight t) | |
1482 | ||
23f87bed MB |
1483 | (defcustom gnus-treat-from-picon |
1484 | (if (and (gnus-image-type-available-p 'xpm) | |
1485 | (gnus-picons-installed-p)) | |
1486 | 'head nil) | |
1487 | "Display picons in the From header. | |
01c52d31 MB |
1488 | Valid values are nil, t, `head', `first', `last', an integer or a |
1489 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1490 | node `(gnus)Picons' for details." | |
bf247b6e | 1491 | :version "22.1" |
16409b0b | 1492 | :group 'gnus-article-treat |
23f87bed MB |
1493 | :group 'gnus-picon |
1494 | :link '(custom-manual "(gnus)Customizing Articles") | |
1495 | :link '(custom-manual "(gnus)Picons") | |
1496 | :type gnus-article-treat-head-custom) | |
1497 | (put 'gnus-treat-from-picon 'highlight t) | |
1498 | ||
1499 | (defcustom gnus-treat-mail-picon | |
1500 | (if (and (gnus-image-type-available-p 'xpm) | |
1501 | (gnus-picons-installed-p)) | |
1502 | 'head nil) | |
1503 | "Display picons in To and Cc headers. | |
01c52d31 MB |
1504 | Valid values are nil, t, `head', `first', `last', an integer or a |
1505 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1506 | node `(gnus)Picons' for details." | |
bf247b6e | 1507 | :version "22.1" |
23f87bed MB |
1508 | :group 'gnus-article-treat |
1509 | :group 'gnus-picon | |
1510 | :link '(custom-manual "(gnus)Customizing Articles") | |
1511 | :link '(custom-manual "(gnus)Picons") | |
1512 | :type gnus-article-treat-head-custom) | |
1513 | (put 'gnus-treat-mail-picon 'highlight t) | |
1514 | ||
1515 | (defcustom gnus-treat-newsgroups-picon | |
1516 | (if (and (gnus-image-type-available-p 'xpm) | |
1517 | (gnus-picons-installed-p)) | |
1518 | 'head nil) | |
1519 | "Display picons in the Newsgroups and Followup-To headers. | |
01c52d31 MB |
1520 | Valid values are nil, t, `head', `first', `last', an integer or a |
1521 | predicate. See Info node `(gnus)Customizing Articles' and Info | |
1522 | node `(gnus)Picons' for details." | |
bf247b6e | 1523 | :version "22.1" |
23f87bed MB |
1524 | :group 'gnus-article-treat |
1525 | :group 'gnus-picon | |
1526 | :link '(custom-manual "(gnus)Customizing Articles") | |
1527 | :link '(custom-manual "(gnus)Picons") | |
1528 | :type gnus-article-treat-head-custom) | |
1529 | (put 'gnus-treat-newsgroups-picon 'highlight t) | |
1530 | ||
1531 | (defcustom gnus-treat-body-boundary | |
437ce4be MB |
1532 | (if (or gnus-treat-newsgroups-picon |
1533 | gnus-treat-mail-picon | |
1534 | gnus-treat-from-picon) | |
1535 | ;; If there's much decoration, the user might prefer a boundery. | |
1536 | 'head | |
1537 | nil) | |
23f87bed MB |
1538 | "Draw a boundary at the end of the headers. |
1539 | Valid values are nil and `head'. | |
1540 | See Info node `(gnus)Customizing Articles' for details." | |
bf247b6e | 1541 | :version "22.1" |
23f87bed MB |
1542 | :group 'gnus-article-treat |
1543 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b | 1544 | :type gnus-article-treat-head-custom) |
16409b0b GM |
1545 | |
1546 | (defcustom gnus-treat-capitalize-sentences nil | |
1547 | "Capitalize sentence-starting words. | |
01c52d31 MB |
1548 | Valid values are nil, t, `head', `first', `last', an integer or a |
1549 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1550 | :version "21.1" |
16409b0b | 1551 | :group 'gnus-article-treat |
23f87bed MB |
1552 | :link '(custom-manual "(gnus)Customizing Articles") |
1553 | :type gnus-article-treat-custom) | |
1554 | ||
1555 | (defcustom gnus-treat-wash-html nil | |
1556 | "Format as HTML. | |
01c52d31 MB |
1557 | Valid values are nil, t, `head', `first', `last', an integer or a |
1558 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1559 | :version "22.1" |
23f87bed MB |
1560 | :group 'gnus-article-treat |
1561 | :link '(custom-manual "(gnus)Customizing Articles") | |
16409b0b GM |
1562 | :type gnus-article-treat-custom) |
1563 | ||
1564 | (defcustom gnus-treat-fill-long-lines nil | |
1565 | "Fill long lines. | |
01c52d31 MB |
1566 | Valid values are nil, t, `head', `first', `last', an integer or a |
1567 | predicate. See Info node `(gnus)Customizing Articles'." | |
16409b0b | 1568 | :group 'gnus-article-treat |
23f87bed | 1569 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1570 | :type gnus-article-treat-custom) |
1571 | ||
1572 | (defcustom gnus-treat-play-sounds nil | |
1573 | "Play sounds. | |
01c52d31 MB |
1574 | Valid values are nil, t, `head', `first', `last', an integer or a |
1575 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1576 | :version "21.1" |
16409b0b | 1577 | :group 'gnus-article-treat |
23f87bed | 1578 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1579 | :type gnus-article-treat-custom) |
1580 | ||
1581 | (defcustom gnus-treat-translate nil | |
1582 | "Translate articles from one language to another. | |
01c52d31 MB |
1583 | Valid values are nil, t, `head', `first', `last', an integer or a |
1584 | predicate. See Info node `(gnus)Customizing Articles'." | |
fc2c2db8 | 1585 | :version "21.1" |
16409b0b | 1586 | :group 'gnus-article-treat |
23f87bed | 1587 | :link '(custom-manual "(gnus)Customizing Articles") |
16409b0b GM |
1588 | :type gnus-article-treat-custom) |
1589 | ||
23f87bed MB |
1590 | (defcustom gnus-treat-x-pgp-sig nil |
1591 | "Verify X-PGP-Sig. | |
1592 | To automatically treat X-PGP-Sig, set it to head. | |
01c52d31 MB |
1593 | Valid values are nil, t, `head', `first', `last', an integer or a |
1594 | predicate. See Info node `(gnus)Customizing Articles'." | |
bf247b6e | 1595 | :version "22.1" |
23f87bed MB |
1596 | :group 'gnus-article-treat |
1597 | :group 'mime-security | |
1598 | :link '(custom-manual "(gnus)Customizing Articles") | |
1599 | :type gnus-article-treat-custom) | |
1600 | ||
1601 | (defvar gnus-article-encrypt-protocol-alist | |
1602 | '(("PGP" . mml2015-self-encrypt))) | |
1603 | ||
1604 | ;; Set to nil if more than one protocol added to | |
1605 | ;; gnus-article-encrypt-protocol-alist. | |
1606 | (defcustom gnus-article-encrypt-protocol "PGP" | |
1607 | "The protocol used for encrypt articles. | |
1608 | It is a string, such as \"PGP\". If nil, ask user." | |
bf247b6e | 1609 | :version "22.1" |
23f87bed MB |
1610 | :type 'string |
1611 | :group 'mime-security) | |
1612 | ||
1613 | (defvar gnus-article-wash-function nil | |
1614 | "Function used for converting HTML into text.") | |
1615 | ||
1616 | (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error)) | |
1617 | (mm-coding-system-p 'utf-8) | |
1618 | (executable-find idna-program)) | |
1619 | "Whether IDNA decoding of headers is used when viewing messages. | |
1620 | This requires GNU Libidn, and by default only enabled if it is found." | |
bf247b6e | 1621 | :version "22.1" |
23f87bed MB |
1622 | :group 'gnus-article-headers |
1623 | :type 'boolean) | |
1624 | ||
1625 | (defcustom gnus-article-over-scroll nil | |
1626 | "If non-nil, allow scrolling the article buffer even when there no more text." | |
bf247b6e | 1627 | :version "22.1" |
23f87bed MB |
1628 | :group 'gnus-article |
1629 | :type 'boolean) | |
1630 | ||
eec82323 LMI |
1631 | ;;; Internal variables |
1632 | ||
23f87bed MB |
1633 | (defvar gnus-english-month-names |
1634 | '("January" "February" "March" "April" "May" "June" "July" "August" | |
1635 | "September" "October" "November" "December")) | |
1636 | ||
16409b0b GM |
1637 | (defvar article-goto-body-goes-to-point-min-p nil) |
1638 | (defvar gnus-article-wash-types nil) | |
1639 | (defvar gnus-article-emphasis-alist nil) | |
23f87bed | 1640 | (defvar gnus-article-image-alist nil) |
16409b0b GM |
1641 | |
1642 | (defvar gnus-article-mime-handle-alist-1 nil) | |
1643 | (defvar gnus-treatment-function-alist | |
23f87bed MB |
1644 | '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig) |
1645 | (gnus-treat-strip-banner gnus-article-strip-banner) | |
16409b0b GM |
1646 | (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body) |
1647 | (gnus-treat-highlight-signature gnus-article-highlight-signature) | |
1648 | (gnus-treat-buttonize gnus-article-add-buttons) | |
1649 | (gnus-treat-fill-article gnus-article-fill-cited-article) | |
1650 | (gnus-treat-fill-long-lines gnus-article-fill-long-lines) | |
1651 | (gnus-treat-strip-cr gnus-article-remove-cr) | |
23f87bed MB |
1652 | (gnus-treat-unsplit-urls gnus-article-unsplit-urls) |
1653 | (gnus-treat-date-ut gnus-article-date-ut) | |
1654 | (gnus-treat-date-local gnus-article-date-local) | |
1655 | (gnus-treat-date-english gnus-article-date-english) | |
23f87bed MB |
1656 | (gnus-treat-date-original gnus-article-date-original) |
1657 | (gnus-treat-date-user-defined gnus-article-date-user) | |
1658 | (gnus-treat-date-iso8601 gnus-article-date-iso8601) | |
f3f01d5d | 1659 | (gnus-treat-date-lapsed gnus-article-date-lapsed) |
23f87bed MB |
1660 | (gnus-treat-display-x-face gnus-article-display-x-face) |
1661 | (gnus-treat-display-face gnus-article-display-face) | |
16409b0b GM |
1662 | (gnus-treat-hide-headers gnus-article-maybe-hide-headers) |
1663 | (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers) | |
1664 | (gnus-treat-hide-signature gnus-article-hide-signature) | |
16409b0b | 1665 | (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers) |
23f87bed | 1666 | (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace) |
16409b0b | 1667 | (gnus-treat-strip-pem gnus-article-hide-pem) |
23f87bed MB |
1668 | (gnus-treat-from-picon gnus-treat-from-picon) |
1669 | (gnus-treat-mail-picon gnus-treat-mail-picon) | |
1670 | (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon) | |
16409b0b | 1671 | (gnus-treat-highlight-headers gnus-article-highlight-headers) |
16409b0b | 1672 | (gnus-treat-highlight-signature gnus-article-highlight-signature) |
16409b0b GM |
1673 | (gnus-treat-strip-trailing-blank-lines |
1674 | gnus-article-remove-trailing-blank-lines) | |
1675 | (gnus-treat-strip-leading-blank-lines | |
1676 | gnus-article-strip-leading-blank-lines) | |
1677 | (gnus-treat-strip-multiple-blank-lines | |
1678 | gnus-article-strip-multiple-blank-lines) | |
1679 | (gnus-treat-overstrike gnus-article-treat-overstrike) | |
01c52d31 | 1680 | (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences) |
23f87bed | 1681 | (gnus-treat-unfold-headers gnus-article-treat-unfold-headers) |
23f87bed | 1682 | (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups) |
01c52d31 | 1683 | (gnus-treat-fold-headers gnus-article-treat-fold-headers) |
16409b0b | 1684 | (gnus-treat-buttonize-head gnus-article-add-buttons-to-head) |
23f87bed | 1685 | (gnus-treat-display-smileys gnus-treat-smiley) |
16409b0b | 1686 | (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences) |
23f87bed MB |
1687 | (gnus-treat-wash-html gnus-article-wash-html) |
1688 | (gnus-treat-emphasize gnus-article-emphasize) | |
1689 | (gnus-treat-hide-citation gnus-article-hide-citation) | |
1690 | (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe) | |
1691 | (gnus-treat-highlight-citation gnus-article-highlight-citation) | |
1692 | (gnus-treat-body-boundary gnus-article-treat-body-boundary) | |
16409b0b GM |
1693 | (gnus-treat-play-sounds gnus-earcon-display))) |
1694 | ||
1695 | (defvar gnus-article-mime-handle-alist nil) | |
6748645f LMI |
1696 | (defvar article-lapsed-timer nil) |
1697 | (defvar gnus-article-current-summary nil) | |
1698 | ||
eec82323 LMI |
1699 | (defvar gnus-article-mode-syntax-table |
1700 | (let ((table (copy-syntax-table text-mode-syntax-table))) | |
23f87bed MB |
1701 | ;; This causes the citation match run O(2^n). |
1702 | ;; (modify-syntax-entry ?- "w" table) | |
1703 | (modify-syntax-entry ?> ")<" table) | |
1704 | (modify-syntax-entry ?< "(>" table) | |
1705 | ;; make M-. in article buffers work for `foo' strings | |
1706 | (modify-syntax-entry ?' " " table) | |
1707 | (modify-syntax-entry ?` " " table) | |
eec82323 LMI |
1708 | table) |
1709 | "Syntax table used in article mode buffers. | |
1710 | Initialized from `text-mode-syntax-table.") | |
1711 | ||
1712 | (defvar gnus-save-article-buffer nil) | |
1713 | ||
eec82323 LMI |
1714 | (defvar gnus-number-of-articles-to-be-saved nil) |
1715 | ||
1716 | (defvar gnus-inhibit-hiding nil) | |
1717 | ||
c1d7d285 MB |
1718 | (defvar gnus-article-edit-mode nil) |
1719 | ||
23f87bed MB |
1720 | ;;; Macros for dealing with the article buffer. |
1721 | ||
1722 | (defmacro gnus-with-article-headers (&rest forms) | |
80de1778 | 1723 | `(with-current-buffer gnus-article-buffer |
23f87bed MB |
1724 | (save-restriction |
1725 | (let ((inhibit-read-only t) | |
1726 | (inhibit-point-motion-hooks t) | |
1727 | (case-fold-search t)) | |
1728 | (article-narrow-to-head) | |
1729 | ,@forms)))) | |
1730 | ||
1731 | (put 'gnus-with-article-headers 'lisp-indent-function 0) | |
1732 | (put 'gnus-with-article-headers 'edebug-form-spec '(body)) | |
1733 | ||
1734 | (defmacro gnus-with-article-buffer (&rest forms) | |
80de1778 | 1735 | `(with-current-buffer gnus-article-buffer |
23f87bed MB |
1736 | (let ((inhibit-read-only t)) |
1737 | ,@forms))) | |
1738 | ||
1739 | (put 'gnus-with-article-buffer 'lisp-indent-function 0) | |
1740 | (put 'gnus-with-article-buffer 'edebug-form-spec '(body)) | |
1741 | ||
1742 | (defun gnus-article-goto-header (header) | |
1743 | "Go to HEADER, which is a regular expression." | |
1744 | (re-search-forward (concat "^\\(" header "\\):") nil t)) | |
1745 | ||
eec82323 LMI |
1746 | (defsubst gnus-article-hide-text (b e props) |
1747 | "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
520aa572 | 1748 | (gnus-add-text-properties-when 'article-type nil b e props) |
eec82323 LMI |
1749 | (when (memq 'intangible props) |
1750 | (put-text-property | |
1751 | (max (1- b) (point-min)) | |
1752 | b 'intangible (cddr (memq 'intangible props))))) | |
520aa572 | 1753 | |
eec82323 LMI |
1754 | (defsubst gnus-article-unhide-text (b e) |
1755 | "Remove hidden text properties from region between B and E." | |
1756 | (remove-text-properties b e gnus-hidden-properties) | |
1757 | (when (memq 'intangible gnus-hidden-properties) | |
1758 | (put-text-property (max (1- b) (point-min)) | |
1759 | b 'intangible nil))) | |
1760 | ||
1761 | (defun gnus-article-hide-text-type (b e type) | |
1762 | "Hide text of TYPE between B and E." | |
23f87bed | 1763 | (gnus-add-wash-type type) |
eec82323 LMI |
1764 | (gnus-article-hide-text |
1765 | b e (cons 'article-type (cons type gnus-hidden-properties)))) | |
1766 | ||
1767 | (defun gnus-article-unhide-text-type (b e type) | |
6748645f | 1768 | "Unhide text of TYPE between B and E." |
23f87bed | 1769 | (gnus-delete-wash-type type) |
eec82323 LMI |
1770 | (remove-text-properties |
1771 | b e (cons 'article-type (cons type gnus-hidden-properties))) | |
1772 | (when (memq 'intangible gnus-hidden-properties) | |
1773 | (put-text-property (max (1- b) (point-min)) | |
1774 | b 'intangible nil))) | |
1775 | ||
1776 | (defun gnus-article-hide-text-of-type (type) | |
1777 | "Hide text of TYPE in the current buffer." | |
1778 | (save-excursion | |
1779 | (let ((b (point-min)) | |
1780 | (e (point-max))) | |
1781 | (while (setq b (text-property-any b e 'article-type type)) | |
1782 | (add-text-properties b (incf b) gnus-hidden-properties))))) | |
1783 | ||
1784 | (defun gnus-article-delete-text-of-type (type) | |
1785 | "Delete text of TYPE in the current buffer." | |
1786 | (save-excursion | |
a8151ef7 | 1787 | (let ((b (point-min))) |
7dafe00b MB |
1788 | (if (eq type 'multipart) |
1789 | ;; Remove MIME buttons associated with multipart/alternative parts. | |
1790 | (progn | |
1791 | (goto-char b) | |
1792 | (while (if (get-text-property (point) 'gnus-part) | |
1793 | (setq b (point)) | |
1794 | (when (setq b (next-single-property-change (point) | |
1795 | 'gnus-part)) | |
1796 | (goto-char b) | |
1797 | t)) | |
1798 | (end-of-line) | |
1799 | (skip-chars-forward "\n") | |
1800 | (when (eq (get-text-property b 'article-type) 'multipart) | |
1801 | (delete-region b (point))))) | |
1802 | (while (setq b (text-property-any b (point-max) 'article-type type)) | |
1803 | (delete-region | |
1804 | b (or (text-property-not-all b (point-max) 'article-type type) | |
1805 | (point-max)))))))) | |
eec82323 LMI |
1806 | |
1807 | (defun gnus-article-delete-invisible-text () | |
1808 | "Delete all invisible text in the current buffer." | |
1809 | (save-excursion | |
a8151ef7 LMI |
1810 | (let ((b (point-min))) |
1811 | (while (setq b (text-property-any b (point-max) 'invisible t)) | |
1812 | (delete-region | |
1813 | b (or (text-property-not-all b (point-max) 'invisible t) | |
1814 | (point-max))))))) | |
eec82323 LMI |
1815 | |
1816 | (defun gnus-article-text-type-exists-p (type) | |
1817 | "Say whether any text of type TYPE exists in the buffer." | |
1818 | (text-property-any (point-min) (point-max) 'article-type type)) | |
1819 | ||
1820 | (defsubst gnus-article-header-rank () | |
1821 | "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
1822 | (let ((list gnus-sorted-header-list) | |
23f87bed | 1823 | (i 1)) |
eec82323 | 1824 | (while list |
23f87bed MB |
1825 | (if (looking-at (car list)) |
1826 | (setq list nil) | |
1827 | (setq list (cdr list)) | |
1828 | (incf i))) | |
1829 | i)) | |
eec82323 LMI |
1830 | |
1831 | (defun article-hide-headers (&optional arg delete) | |
16409b0b GM |
1832 | "Hide unwanted headers and possibly sort them as well." |
1833 | (interactive) | |
1834 | ;; This function might be inhibited. | |
1835 | (unless gnus-inhibit-hiding | |
37cc095b | 1836 | (let ((inhibit-read-only t) |
23f87bed MB |
1837 | (case-fold-search t) |
1838 | (max (1+ (length gnus-sorted-header-list))) | |
1839 | (inhibit-point-motion-hooks t) | |
1840 | (cur (current-buffer)) | |
1841 | ignored visible beg) | |
1842 | (save-excursion | |
1843 | ;; `gnus-ignored-headers' and `gnus-visible-headers' may be | |
1844 | ;; group parameters, so we should go to the summary buffer. | |
1845 | (when (prog1 | |
1846 | (condition-case nil | |
1847 | (progn (set-buffer gnus-summary-buffer) t) | |
1848 | (error nil)) | |
1849 | (setq ignored (when (not gnus-visible-headers) | |
1850 | (cond ((stringp gnus-ignored-headers) | |
1851 | gnus-ignored-headers) | |
1852 | ((listp gnus-ignored-headers) | |
1853 | (mapconcat 'identity | |
1854 | gnus-ignored-headers | |
1855 | "\\|")))) | |
1856 | visible (cond ((stringp gnus-visible-headers) | |
1857 | gnus-visible-headers) | |
1858 | ((and gnus-visible-headers | |
1859 | (listp gnus-visible-headers)) | |
1860 | (mapconcat 'identity | |
1861 | gnus-visible-headers | |
1862 | "\\|"))))) | |
1863 | (set-buffer cur)) | |
1864 | (save-restriction | |
16409b0b GM |
1865 | ;; First we narrow to just the headers. |
1866 | (article-narrow-to-head) | |
1867 | ;; Hide any "From " lines at the beginning of (mail) articles. | |
1868 | (while (looking-at "From ") | |
1869 | (forward-line 1)) | |
1870 | (unless (bobp) | |
1871 | (delete-region (point-min) (point))) | |
1872 | ;; Then treat the rest of the header lines. | |
1873 | ;; Then we use the two regular expressions | |
1874 | ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
1875 | ;; select which header lines is to remain visible in the | |
1876 | ;; article buffer. | |
23f87bed | 1877 | (while (re-search-forward "^[^ \t:]*:" nil t) |
16409b0b GM |
1878 | (beginning-of-line) |
1879 | ;; Mark the rank of the header. | |
1880 | (put-text-property | |
1881 | (point) (1+ (point)) 'message-rank | |
1882 | (if (or (and visible (looking-at visible)) | |
1883 | (and ignored | |
1884 | (not (looking-at ignored)))) | |
1885 | (gnus-article-header-rank) | |
1886 | (+ 2 max))) | |
1887 | (forward-line 1)) | |
1888 | (message-sort-headers-1) | |
1889 | (when (setq beg (text-property-any | |
1890 | (point-min) (point-max) 'message-rank (+ 2 max))) | |
1891 | ;; We delete the unwanted headers. | |
23f87bed | 1892 | (gnus-add-wash-type 'headers) |
16409b0b GM |
1893 | (add-text-properties (point-min) (+ 5 (point-min)) |
1894 | '(article-type headers dummy-invisible t)) | |
1895 | (delete-region beg (point-max)))))))) | |
eec82323 LMI |
1896 | |
1897 | (defun article-hide-boring-headers (&optional arg) | |
1898 | "Toggle hiding of headers that aren't very interesting. | |
1899 | If given a negative prefix, always show; if given a positive prefix, | |
1900 | always hide." | |
1901 | (interactive (gnus-article-hidden-arg)) | |
1902 | (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) | |
1903 | (not gnus-show-all-headers)) | |
1904 | (save-excursion | |
1905 | (save-restriction | |
4e7d0221 | 1906 | (let ((inhibit-read-only t) |
01c52d31 | 1907 | (inhibit-point-motion-hooks t)) |
16409b0b | 1908 | (article-narrow-to-head) |
01c52d31 | 1909 | (dolist (elem gnus-boring-article-headers) |
eec82323 LMI |
1910 | (goto-char (point-min)) |
1911 | (cond | |
1912 | ;; Hide empty headers. | |
1913 | ((eq elem 'empty) | |
16409b0b | 1914 | (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t) |
eec82323 LMI |
1915 | (forward-line -1) |
1916 | (gnus-article-hide-text-type | |
01c52d31 | 1917 | (point-at-bol) |
eec82323 LMI |
1918 | (progn |
1919 | (end-of-line) | |
1920 | (if (re-search-forward "^[^ \t]" nil t) | |
1921 | (match-beginning 0) | |
1922 | (point-max))) | |
1923 | 'boring-headers))) | |
1924 | ;; Hide boring Newsgroups header. | |
1925 | ((eq elem 'newsgroups) | |
23f87bed MB |
1926 | (when (gnus-string-equal |
1927 | (gnus-fetch-field "newsgroups") | |
1928 | (gnus-group-real-name | |
1929 | (if (boundp 'gnus-newsgroup-name) | |
1930 | gnus-newsgroup-name | |
1931 | ""))) | |
eec82323 | 1932 | (gnus-article-hide-header "newsgroups"))) |
23f87bed MB |
1933 | ((eq elem 'to-address) |
1934 | (let ((to (message-fetch-field "to")) | |
1935 | (to-address | |
1936 | (gnus-parameter-to-address | |
1937 | (if (boundp 'gnus-newsgroup-name) | |
1938 | gnus-newsgroup-name "")))) | |
1939 | (when (and to to-address | |
1940 | (ignore-errors | |
1941 | (gnus-string-equal | |
1942 | ;; only one address in To | |
1943 | (nth 1 (mail-extract-address-components to)) | |
1944 | to-address))) | |
1945 | (gnus-article-hide-header "to")))) | |
1946 | ((eq elem 'to-list) | |
1947 | (let ((to (message-fetch-field "to")) | |
1948 | (to-list | |
1949 | (gnus-parameter-to-list | |
1950 | (if (boundp 'gnus-newsgroup-name) | |
1951 | gnus-newsgroup-name "")))) | |
1952 | (when (and to to-list | |
1953 | (ignore-errors | |
1954 | (gnus-string-equal | |
1955 | ;; only one address in To | |
1956 | (nth 1 (mail-extract-address-components to)) | |
1957 | to-list))) | |
1958 | (gnus-article-hide-header "to")))) | |
1959 | ((eq elem 'cc-list) | |
1960 | (let ((cc (message-fetch-field "cc")) | |
1961 | (to-list | |
1962 | (gnus-parameter-to-list | |
1963 | (if (boundp 'gnus-newsgroup-name) | |
1964 | gnus-newsgroup-name "")))) | |
1965 | (when (and cc to-list | |
1966 | (ignore-errors | |
1967 | (gnus-string-equal | |
1968 | ;; only one address in CC | |
1969 | (nth 1 (mail-extract-address-components cc)) | |
1970 | to-list))) | |
1971 | (gnus-article-hide-header "cc")))) | |
eec82323 | 1972 | ((eq elem 'followup-to) |
23f87bed MB |
1973 | (when (gnus-string-equal |
1974 | (message-fetch-field "followup-to") | |
1975 | (message-fetch-field "newsgroups")) | |
eec82323 LMI |
1976 | (gnus-article-hide-header "followup-to"))) |
1977 | ((eq elem 'reply-to) | |
23f87bed MB |
1978 | (if (gnus-group-find-parameter |
1979 | gnus-newsgroup-name 'broken-reply-to) | |
1980 | (gnus-article-hide-header "reply-to") | |
1981 | (let ((from (message-fetch-field "from")) | |
1982 | (reply-to (message-fetch-field "reply-to"))) | |
1983 | (when | |
1984 | (and | |
eec82323 LMI |
1985 | from reply-to |
1986 | (ignore-errors | |
1987 | (equal | |
23f87bed MB |
1988 | (sort (mapcar |
1989 | (lambda (x) (downcase (cadr x))) | |
1990 | (mail-extract-address-components from t)) | |
1991 | 'string<) | |
1992 | (sort (mapcar | |
1993 | (lambda (x) (downcase (cadr x))) | |
1994 | (mail-extract-address-components reply-to t)) | |
1995 | 'string<)))) | |
1996 | (gnus-article-hide-header "reply-to"))))) | |
eec82323 | 1997 | ((eq elem 'date) |
b193caa3 MB |
1998 | (let ((date (with-current-buffer gnus-original-article-buffer |
1999 | ;; If date in `gnus-article-buffer' is localized | |
2000 | ;; (`gnus-treat-date-user-defined'), | |
2001 | ;; `days-between' might fail. | |
2002 | (message-fetch-field "date")))) | |
eec82323 | 2003 | (when (and date |
16409b0b | 2004 | (< (days-between (current-time-string) date) |
eec82323 | 2005 | 4)) |
6748645f LMI |
2006 | (gnus-article-hide-header "date")))) |
2007 | ((eq elem 'long-to) | |
16409b0b GM |
2008 | (let ((to (message-fetch-field "to")) |
2009 | (cc (message-fetch-field "cc"))) | |
6748645f | 2010 | (when (> (length to) 1024) |
16409b0b GM |
2011 | (gnus-article-hide-header "to")) |
2012 | (when (> (length cc) 1024) | |
2013 | (gnus-article-hide-header "cc")))) | |
6748645f | 2014 | ((eq elem 'many-to) |
16409b0b GM |
2015 | (let ((to-count 0) |
2016 | (cc-count 0)) | |
6748645f LMI |
2017 | (goto-char (point-min)) |
2018 | (while (re-search-forward "^to:" nil t) | |
2019 | (setq to-count (1+ to-count))) | |
2020 | (when (> to-count 1) | |
2021 | (while (> to-count 0) | |
2022 | (goto-char (point-min)) | |
2023 | (save-restriction | |
2024 | (re-search-forward "^to:" nil nil to-count) | |
2025 | (forward-line -1) | |
2026 | (narrow-to-region (point) (point-max)) | |
2027 | (gnus-article-hide-header "to")) | |
16409b0b GM |
2028 | (setq to-count (1- to-count)))) |
2029 | (goto-char (point-min)) | |
2030 | (while (re-search-forward "^cc:" nil t) | |
2031 | (setq cc-count (1+ cc-count))) | |
2032 | (when (> cc-count 1) | |
2033 | (while (> cc-count 0) | |
2034 | (goto-char (point-min)) | |
2035 | (save-restriction | |
2036 | (re-search-forward "^cc:" nil nil cc-count) | |
2037 | (forward-line -1) | |
2038 | (narrow-to-region (point) (point-max)) | |
2039 | (gnus-article-hide-header "cc")) | |
2040 | (setq cc-count (1- cc-count))))))))))))) | |
eec82323 LMI |
2041 | |
2042 | (defun gnus-article-hide-header (header) | |
2043 | (save-excursion | |
2044 | (goto-char (point-min)) | |
2045 | (when (re-search-forward (concat "^" header ":") nil t) | |
2046 | (gnus-article-hide-text-type | |
01c52d31 | 2047 | (point-at-bol) |
eec82323 LMI |
2048 | (progn |
2049 | (end-of-line) | |
2050 | (if (re-search-forward "^[^ \t]" nil t) | |
2051 | (match-beginning 0) | |
2052 | (point-max))) | |
2053 | 'boring-headers)))) | |
2054 | ||
16409b0b GM |
2055 | (defvar gnus-article-normalized-header-length 40 |
2056 | "Length of normalized headers.") | |
2057 | ||
2058 | (defun article-normalize-headers () | |
2059 | "Make all header lines 40 characters long." | |
2060 | (interactive) | |
4e7d0221 | 2061 | (let ((inhibit-read-only t) |
16409b0b GM |
2062 | column) |
2063 | (save-excursion | |
2064 | (save-restriction | |
2065 | (article-narrow-to-head) | |
2066 | (while (not (eobp)) | |
2067 | (cond | |
01c52d31 | 2068 | ((< (setq column (- (point-at-eol) (point))) |
16409b0b GM |
2069 | gnus-article-normalized-header-length) |
2070 | (end-of-line) | |
2071 | (insert (make-string | |
2072 | (- gnus-article-normalized-header-length column) | |
2073 | ? ))) | |
2074 | ((> column gnus-article-normalized-header-length) | |
2075 | (gnus-put-text-property | |
2076 | (progn | |
2077 | (forward-char gnus-article-normalized-header-length) | |
2078 | (point)) | |
01c52d31 | 2079 | (point-at-eol) |
16409b0b GM |
2080 | 'invisible t)) |
2081 | (t | |
2082 | ;; Do nothing. | |
2083 | )) | |
2084 | (forward-line 1)))))) | |
2085 | ||
6748645f | 2086 | (defun article-treat-dumbquotes () |
23f87bed | 2087 | "Translate M****s*** sm*rtq**t*s and other symbols into proper text. |
16409b0b | 2088 | Note that this function guesses whether a character is a sm*rtq**t* or |
74dd1b0d SZ |
2089 | not, so it should only be used interactively. |
2090 | ||
23f87bed MB |
2091 | Sm*rtq**t*s are M****s***'s unilateral extension to the |
2092 | iso-8859-1 character map in an attempt to provide more quoting | |
2093 | characters. If you see something like \\222 or \\264 where | |
2094 | you're expecting some kind of apostrophe or quotation mark, then | |
2095 | try this wash." | |
6748645f | 2096 | (interactive) |
16409b0b | 2097 | (article-translate-strings gnus-article-dumbquotes-map)) |
6748645f LMI |
2098 | |
2099 | (defun article-translate-characters (from to) | |
2100 | "Translate all characters in the body of the article according to FROM and TO. | |
2101 | FROM is a string of characters to translate from; to is a string of | |
2102 | characters to translate to." | |
2103 | (save-excursion | |
16409b0b | 2104 | (when (article-goto-body) |
4e7d0221 | 2105 | (let ((inhibit-read-only t) |
6748645f LMI |
2106 | (x (make-string 225 ?x)) |
2107 | (i -1)) | |
2108 | (while (< (incf i) (length x)) | |
2109 | (aset x i i)) | |
2110 | (setq i 0) | |
2111 | (while (< i (length from)) | |
2112 | (aset x (aref from i) (aref to i)) | |
2113 | (incf i)) | |
2114 | (translate-region (point) (point-max) x))))) | |
2115 | ||
16409b0b GM |
2116 | (defun article-translate-strings (map) |
2117 | "Translate all string in the body of the article according to MAP. | |
2118 | MAP is an alist where the elements are on the form (\"from\" \"to\")." | |
2119 | (save-excursion | |
2120 | (when (article-goto-body) | |
01c52d31 MB |
2121 | (let ((inhibit-read-only t)) |
2122 | (dolist (elem map) | |
16409b0b GM |
2123 | (save-excursion |
2124 | (while (search-forward (car elem) nil t) | |
2125 | (replace-match (cadr elem))))))))) | |
2126 | ||
eec82323 LMI |
2127 | (defun article-treat-overstrike () |
2128 | "Translate overstrikes into bold text." | |
2129 | (interactive) | |
2130 | (save-excursion | |
16409b0b | 2131 | (when (article-goto-body) |
4e7d0221 | 2132 | (let ((inhibit-read-only t)) |
eec82323 | 2133 | (while (search-forward "\b" nil t) |
16409b0b | 2134 | (let ((next (char-after)) |
eec82323 LMI |
2135 | (previous (char-after (- (point) 2)))) |
2136 | ;; We do the boldification/underlining by hiding the | |
2137 | ;; overstrikes and putting the proper text property | |
2138 | ;; on the letters. | |
2139 | (cond | |
2140 | ((eq next previous) | |
2141 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
2142 | (put-text-property (point) (1+ (point)) 'face 'bold)) | |
2143 | ((eq next ?_) | |
2144 | (gnus-article-hide-text-type | |
2145 | (1- (point)) (1+ (point)) 'overstrike) | |
2146 | (put-text-property | |
2147 | (- (point) 2) (1- (point)) 'face 'underline)) | |
2148 | ((eq previous ?_) | |
2149 | (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
2150 | (put-text-property | |
2151 | (point) (1+ (point)) 'face 'underline))))))))) | |
2152 | ||
01c52d31 MB |
2153 | (defun article-treat-ansi-sequences () |
2154 | "Translate ANSI SGR control sequences into overlays or extents." | |
2155 | (interactive) | |
2156 | (save-excursion | |
2157 | (when (article-goto-body) | |
2158 | (let ((inhibit-read-only t)) | |
2159 | (ansi-color-apply-on-region (point) (point-max)))))) | |
2160 | ||
23f87bed MB |
2161 | (defun gnus-article-treat-unfold-headers () |
2162 | "Unfold folded message headers. | |
2163 | Only the headers that fit into the current window width will be | |
2164 | unfolded." | |
2165 | (interactive) | |
2166 | (gnus-with-article-headers | |
2167 | (let (length) | |
2168 | (while (not (eobp)) | |
2169 | (save-restriction | |
2170 | (mail-header-narrow-to-field) | |
01c52d31 MB |
2171 | (let* ((header (buffer-string)) |
2172 | (unfoldable | |
2173 | (or (equal gnus-article-unfold-long-headers t) | |
2174 | (and (stringp gnus-article-unfold-long-headers) | |
2175 | (string-match gnus-article-unfold-long-headers header))))) | |
23f87bed MB |
2176 | (with-temp-buffer |
2177 | (insert header) | |
2178 | (goto-char (point-min)) | |
2179 | (while (re-search-forward "\n[\t ]" nil t) | |
2180 | (replace-match " " t t))) | |
01c52d31 MB |
2181 | (setq length (- (point-max) (point-min) 1)) |
2182 | (when (or unfoldable | |
2183 | (< length (window-width))) | |
2184 | (while (re-search-forward "\n[\t ]" nil t) | |
2185 | (replace-match " " t t)))) | |
23f87bed MB |
2186 | (goto-char (point-max))))))) |
2187 | ||
2188 | (defun gnus-article-treat-fold-headers () | |
2189 | "Fold message headers." | |
2190 | (interactive) | |
2191 | (gnus-with-article-headers | |
2192 | (while (not (eobp)) | |
2193 | (save-restriction | |
2194 | (mail-header-narrow-to-field) | |
2195 | (mail-header-fold-field) | |
2196 | (goto-char (point-max)))))) | |
2197 | ||
2198 | (defun gnus-treat-smiley () | |
2199 | "Toggle display of textual emoticons (\"smileys\") as small graphical icons." | |
2200 | (interactive) | |
2201 | (gnus-with-article-buffer | |
2202 | (if (memq 'smiley gnus-article-wash-types) | |
2203 | (gnus-delete-images 'smiley) | |
2204 | (article-goto-body) | |
2205 | (let ((images (smiley-region (point) (point-max)))) | |
2206 | (when images | |
2207 | (gnus-add-wash-type 'smiley) | |
2208 | (dolist (image images) | |
2209 | (gnus-add-image 'smiley image))))))) | |
2210 | ||
2211 | (defun gnus-article-remove-images () | |
2212 | "Remove all images from the article buffer." | |
2213 | (interactive) | |
2214 | (gnus-with-article-buffer | |
2215 | (dolist (elem gnus-article-image-alist) | |
2216 | (gnus-delete-images (car elem))))) | |
2217 | ||
2218 | (defun gnus-article-treat-fold-newsgroups () | |
2219 | "Unfold folded message headers. | |
2220 | Only the headers that fit into the current window width will be | |
2221 | unfolded." | |
2222 | (interactive) | |
2223 | (gnus-with-article-headers | |
2224 | (while (gnus-article-goto-header "newsgroups\\|followup-to") | |
2225 | (save-restriction | |
2226 | (mail-header-narrow-to-field) | |
2227 | (while (re-search-forward ", *" nil t) | |
2228 | (replace-match ", " t t)) | |
2229 | (mail-header-fold-field) | |
2230 | (goto-char (point-max)))))) | |
2231 | ||
b7b80032 | 2232 | (defcustom gnus-article-truncate-lines (default-value 'truncate-lines) |
01c52d31 MB |
2233 | "Value of `truncate-lines' in Gnus Article buffer. |
2234 | Valid values are nil, t, `head', `first', `last', an integer or a | |
2235 | predicate. See Info node `(gnus)Customizing Articles'." | |
330f707b | 2236 | :version "23.1" ;; No Gnus |
01c52d31 MB |
2237 | :group 'gnus-article |
2238 | ;; :link '(custom-manual "(gnus)Customizing Articles") | |
2239 | :type 'boolean) | |
2240 | ||
2241 | (defun gnus-article-toggle-truncate-lines (&optional arg) | |
2242 | "Toggle whether to fold or truncate long lines in article the buffer. | |
2243 | If ARG is non-nil and not a number, toggle | |
2244 | `gnus-article-truncate-lines' too. If ARG is a number, truncate | |
5229211e | 2245 | long lines if and only if arg is positive." |
01c52d31 MB |
2246 | (interactive "P") |
2247 | (cond | |
2248 | ((and (numberp arg) (> arg 0)) | |
2249 | (setq gnus-article-truncate-lines t)) | |
2250 | ((numberp arg) | |
2251 | (setq gnus-article-truncate-lines nil)) | |
2252 | (arg | |
2253 | (setq gnus-article-truncate-lines | |
2254 | (not gnus-article-truncate-lines)))) | |
2255 | (gnus-with-article-buffer | |
2256 | (cond | |
2257 | ((and (numberp arg) (> arg 0)) | |
2258 | (setq truncate-lines nil)) | |
2259 | ((numberp arg) | |
2260 | (setq truncate-lines t))) | |
2261 | ;; In versions of Emacs 22 (CVS) before 2006-05-26, | |
2262 | ;; `toggle-truncate-lines' needs an argument. | |
2263 | (toggle-truncate-lines))) | |
2264 | ||
23f87bed MB |
2265 | (defun gnus-article-treat-body-boundary () |
2266 | "Place a boundary line at the end of the headers." | |
2267 | (interactive) | |
2268 | (when (and gnus-body-boundary-delimiter | |
2269 | (> (length gnus-body-boundary-delimiter) 0)) | |
2270 | (gnus-with-article-headers | |
2271 | (goto-char (point-max)) | |
2272 | (let ((start (point))) | |
2273 | (insert "X-Boundary: ") | |
2274 | (gnus-add-text-properties start (point) '(invisible t intangible t)) | |
2275 | (insert (let (str) | |
2276 | (while (>= (1- (window-width)) (length str)) | |
2277 | (setq str (concat str gnus-body-boundary-delimiter))) | |
2278 | (substring str 0 (1- (window-width)))) | |
2279 | "\n") | |
2280 | (gnus-put-text-property start (point) 'gnus-decoration 'header))))) | |
2281 | ||
16409b0b GM |
2282 | (defun article-fill-long-lines () |
2283 | "Fill lines that are wider than the window width." | |
eec82323 LMI |
2284 | (interactive) |
2285 | (save-excursion | |
4e7d0221 | 2286 | (let ((inhibit-read-only t) |
16409b0b GM |
2287 | (width (window-width (get-buffer-window (current-buffer))))) |
2288 | (save-restriction | |
2289 | (article-goto-body) | |
80b47379 | 2290 | (let ((adaptive-fill-mode nil)) ;Why? -sm |
16409b0b GM |
2291 | (while (not (eobp)) |
2292 | (end-of-line) | |
2293 | (when (>= (current-column) (min fill-column width)) | |
23f87bed | 2294 | (narrow-to-region (min (1+ (point)) (point-max)) |
01c52d31 | 2295 | (point-at-bol)) |
23f87bed MB |
2296 | (let ((goback (point-marker))) |
2297 | (fill-paragraph nil) | |
2298 | (goto-char (marker-position goback))) | |
16409b0b GM |
2299 | (widen)) |
2300 | (forward-line 1))))))) | |
2301 | ||
2302 | (defun article-capitalize-sentences () | |
2303 | "Capitalize the first word in each sentence." | |
2304 | (interactive) | |
2305 | (save-excursion | |
4e7d0221 | 2306 | (let ((inhibit-read-only t) |
16409b0b GM |
2307 | (paragraph-start "^[\n\^L]")) |
2308 | (article-goto-body) | |
2309 | (while (not (eobp)) | |
2310 | (capitalize-word 1) | |
2311 | (forward-sentence))))) | |
eec82323 LMI |
2312 | |
2313 | (defun article-remove-cr () | |
16409b0b | 2314 | "Remove trailing CRs and then translate remaining CRs into LFs." |
eec82323 LMI |
2315 | (interactive) |
2316 | (save-excursion | |
4e7d0221 | 2317 | (let ((inhibit-read-only t)) |
eec82323 | 2318 | (goto-char (point-min)) |
16409b0b GM |
2319 | (while (re-search-forward "\r+$" nil t) |
2320 | (replace-match "" t t)) | |
2321 | (goto-char (point-min)) | |
eec82323 | 2322 | (while (search-forward "\r" nil t) |
16409b0b | 2323 | (replace-match "\n" t t))))) |
eec82323 LMI |
2324 | |
2325 | (defun article-remove-trailing-blank-lines () | |
2326 | "Remove all trailing blank lines from the article." | |
2327 | (interactive) | |
2328 | (save-excursion | |
4e7d0221 | 2329 | (let ((inhibit-read-only t)) |
eec82323 LMI |
2330 | (goto-char (point-max)) |
2331 | (delete-region | |
2332 | (point) | |
2333 | (progn | |
2334 | (while (and (not (bobp)) | |
16409b0b GM |
2335 | (looking-at "^[ \t]*$") |
2336 | (not (gnus-annotation-in-region-p | |
01c52d31 | 2337 | (point) (point-at-eol)))) |
eec82323 LMI |
2338 | (forward-line -1)) |
2339 | (forward-line 1) | |
2340 | (point)))))) | |
2341 | ||
9efa445f | 2342 | (defvar gnus-face-properties-alist) |
01c52d31 | 2343 | |
b890d447 | 2344 | (defun article-display-face (&optional force) |
23f87bed | 2345 | "Display any Face headers in the header." |
b890d447 | 2346 | (interactive (list 'force)) |
23f87bed MB |
2347 | (let ((wash-face-p buffer-read-only)) |
2348 | (gnus-with-article-headers | |
2349 | ;; When displaying parts, this function can be called several times on | |
2350 | ;; the same article, without any intended toggle semantic (as typing `W | |
2351 | ;; D d' would have). So face deletion must occur only when we come from | |
2352 | ;; an interactive command, that is when the *Article* buffer is | |
2353 | ;; read-only. | |
2354 | (if (and wash-face-p (memq 'face gnus-article-wash-types)) | |
2355 | (gnus-delete-images 'face) | |
b890d447 MB |
2356 | (let ((from (message-fetch-field "from")) |
2357 | face faces) | |
7d0c69be | 2358 | (save-current-buffer |
23f87bed | 2359 | (when (and wash-face-p |
7d0c69be MB |
2360 | (gnus-buffer-live-p gnus-original-article-buffer) |
2361 | (not (re-search-forward "^Face:[\t ]*" nil t))) | |
23f87bed MB |
2362 | (set-buffer gnus-original-article-buffer)) |
2363 | (save-restriction | |
2364 | (mail-narrow-to-head) | |
b890d447 MB |
2365 | (when (or force |
2366 | ;; Check whether this face is censored. | |
2367 | (not (and gnus-article-x-face-too-ugly | |
2368 | (or from | |
2369 | (setq from (message-fetch-field "from"))) | |
2370 | (string-match gnus-article-x-face-too-ugly | |
2371 | from)))) | |
2372 | (while (gnus-article-goto-header "Face") | |
2373 | (push (mail-header-field-value) faces))))) | |
d6697c02 | 2374 | (when faces |
7d0c69be | 2375 | (goto-char (point-min)) |
b890d447 MB |
2376 | (let (png image) |
2377 | (unless (setq from (gnus-article-goto-header "from")) | |
7d0c69be MB |
2378 | (insert "From:") |
2379 | (setq from (point)) | |
b890d447 | 2380 | (insert " [no `from' set]\n")) |
7d0c69be MB |
2381 | (while faces |
2382 | (when (setq png (gnus-convert-face-to-png (pop faces))) | |
01c52d31 MB |
2383 | (setq image |
2384 | (apply 'gnus-create-image png 'png t | |
2385 | (cdr (assq 'png gnus-face-properties-alist)))) | |
d6697c02 MB |
2386 | (goto-char from) |
2387 | (gnus-add-wash-type 'face) | |
2388 | (gnus-add-image 'face image) | |
2389 | (gnus-put-image image nil 'face)))))))))) | |
23f87bed | 2390 | |
eec82323 LMI |
2391 | (defun article-display-x-face (&optional force) |
2392 | "Look for an X-Face header and display it if present." | |
2393 | (interactive (list 'force)) | |
23f87bed MB |
2394 | (let ((wash-face-p buffer-read-only)) ;; When type `W f' |
2395 | (gnus-with-article-headers | |
2396 | ;; Delete the old process, if any. | |
2397 | (when (process-status "article-x-face") | |
2398 | (delete-process "article-x-face")) | |
2399 | ;; See the comment in `article-display-face'. | |
2400 | (if (and wash-face-p (memq 'xface gnus-article-wash-types)) | |
2401 | ;; We have already displayed X-Faces, so we remove them | |
2402 | ;; instead. | |
2403 | (gnus-delete-images 'xface) | |
2404 | ;; Display X-Faces. | |
b890d447 MB |
2405 | (let ((from (message-fetch-field "from")) |
2406 | x-faces face) | |
7d0c69be | 2407 | (save-current-buffer |
23f87bed | 2408 | (when (and wash-face-p |
7d0c69be MB |
2409 | (gnus-buffer-live-p gnus-original-article-buffer) |
2410 | (not (re-search-forward "^X-Face:[\t ]*" nil t))) | |
23f87bed MB |
2411 | ;; If type `W f', use gnus-original-article-buffer, |
2412 | ;; otherwise use the current buffer because displaying | |
2413 | ;; RFC822 parts calls this function too. | |
2414 | (set-buffer gnus-original-article-buffer)) | |
2415 | (save-restriction | |
2416 | (mail-narrow-to-head) | |
b890d447 MB |
2417 | (and gnus-article-x-face-command |
2418 | (or force | |
2419 | ;; Check whether this face is censored. | |
2420 | (not (and gnus-article-x-face-too-ugly | |
2421 | (or from | |
2422 | (setq from (message-fetch-field "from"))) | |
2423 | (string-match gnus-article-x-face-too-ugly | |
2424 | from)))) | |
2425 | (while (gnus-article-goto-header "X-Face") | |
2426 | (push (mail-header-field-value) x-faces))))) | |
2427 | (when x-faces | |
2428 | ;; We display the face. | |
2429 | (cond ((functionp gnus-article-x-face-command) | |
2430 | ;; The command is a lisp function, so we call it. | |
2431 | (mapc gnus-article-x-face-command x-faces)) | |
2432 | ((stringp gnus-article-x-face-command) | |
2433 | ;; The command is a string, so we interpret the command | |
2434 | ;; as a, well, command, and fork it off. | |
2435 | (let ((process-connection-type nil)) | |
2436 | (gnus-set-process-query-on-exit-flag | |
2437 | (start-process | |
2438 | "article-x-face" nil shell-file-name | |
2439 | shell-command-switch gnus-article-x-face-command) | |
2440 | nil) | |
2441 | ;; Sending multiple EOFs to xv doesn't work, | |
2442 | ;; so we only do a single external face. | |
2443 | (with-temp-buffer | |
2444 | (insert (car x-faces)) | |
2445 | (process-send-region "article-x-face" | |
2446 | (point-min) (point-max))) | |
2447 | (process-send-eof "article-x-face"))) | |
2448 | (t | |
2449 | (error "`%s' set to `%s' is not a function" | |
2450 | gnus-article-x-face-command | |
2451 | 'gnus-article-x-face-command))))))))) | |
a8151ef7 | 2452 | |
16409b0b GM |
2453 | (defun article-decode-mime-words () |
2454 | "Decode all MIME-encoded words in the article." | |
2455 | (interactive) | |
01c52d31 | 2456 | (gnus-with-article-buffer |
16409b0b | 2457 | (let ((inhibit-point-motion-hooks t) |
16409b0b | 2458 | (mail-parse-charset gnus-newsgroup-charset) |
a1506d29 | 2459 | (mail-parse-ignored-charsets |
01c52d31 MB |
2460 | (with-current-buffer gnus-summary-buffer |
2461 | gnus-newsgroup-ignored-charsets))) | |
16409b0b GM |
2462 | (mail-decode-encoded-word-region (point-min) (point-max))))) |
2463 | ||
2464 | (defun article-decode-charset (&optional prompt) | |
2465 | "Decode charset-encoded text in the article. | |
2466 | If PROMPT (the prefix), prompt for a coding system to use." | |
2467 | (interactive "P") | |
2468 | (let ((inhibit-point-motion-hooks t) (case-fold-search t) | |
23f87bed | 2469 | (inhibit-read-only t) |
16409b0b | 2470 | (mail-parse-charset gnus-newsgroup-charset) |
a1506d29 | 2471 | (mail-parse-ignored-charsets |
16409b0b GM |
2472 | (save-excursion (condition-case nil |
2473 | (set-buffer gnus-summary-buffer) | |
2474 | (error)) | |
2475 | gnus-newsgroup-ignored-charsets)) | |
2476 | ct cte ctl charset format) | |
c96ec15a MB |
2477 | (save-excursion |
2478 | (save-restriction | |
2479 | (article-narrow-to-head) | |
2480 | (setq ct (message-fetch-field "Content-Type" t) | |
2481 | cte (message-fetch-field "Content-Transfer-Encoding" t) | |
2482 | ctl (and ct (mail-header-parse-content-type ct)) | |
2483 | charset (cond | |
2484 | (prompt | |
2485 | (mm-read-coding-system "Charset to decode: ")) | |
2486 | (ctl | |
2487 | (mail-content-type-get ctl 'charset))) | |
2488 | format (and ctl (mail-content-type-get ctl 'format))) | |
2489 | (when cte | |
2490 | (setq cte (mail-header-strip cte))) | |
2491 | (if (and ctl (not (string-match "/" (car ctl)))) | |
2492 | (setq ctl nil)) | |
2493 | (goto-char (point-max))) | |
2494 | (forward-line 1) | |
2495 | (save-restriction | |
2496 | (narrow-to-region (point) (point-max)) | |
2497 | (when (and (eq mail-parse-charset 'gnus-decoded) | |
2498 | (eq (mm-body-7-or-8) '8bit)) | |
2499 | ;; The text code could have been decoded. | |
2500 | (setq charset mail-parse-charset)) | |
2501 | (when (and (or (not ctl) | |
2502 | (equal (car ctl) "text/plain")) | |
2503 | (not format)) ;; article with format will decode later. | |
2504 | (mm-decode-body | |
2505 | charset (and cte (intern (downcase | |
2506 | (gnus-strip-whitespace cte)))) | |
2507 | (car ctl))))))) | |
16409b0b GM |
2508 | |
2509 | (defun article-decode-encoded-words () | |
2510 | "Remove encoded-word encoding from headers." | |
2511 | (let ((inhibit-point-motion-hooks t) | |
2512 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 2513 | (mail-parse-ignored-charsets |
16409b0b GM |
2514 | (save-excursion (condition-case nil |
2515 | (set-buffer gnus-summary-buffer) | |
2516 | (error)) | |
2517 | gnus-newsgroup-ignored-charsets)) | |
343d6628 | 2518 | (inhibit-read-only t) |
8fbdffe5 MB |
2519 | end start) |
2520 | (goto-char (point-min)) | |
2521 | (when (search-forward "\n\n" nil 'move) | |
2522 | (forward-line -1)) | |
2523 | (setq end (point)) | |
2524 | (while (not (bobp)) | |
2525 | (while (progn | |
2526 | (forward-line -1) | |
2527 | (and (not (bobp)) | |
2528 | (memq (char-after) '(?\t ? ))))) | |
2529 | (setq start (point)) | |
2530 | (if (looking-at "\ | |
343d6628 MB |
2531 | \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\ |
2532 | \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):") | |
8fbdffe5 MB |
2533 | (funcall gnus-decode-address-function start end) |
2534 | (funcall gnus-decode-header-function start end)) | |
2535 | (goto-char (setq end start))))) | |
eec82323 | 2536 | |
23f87bed | 2537 | (defun article-decode-group-name () |
01c52d31 | 2538 | "Decode group names in Newsgroups, Followup-To and Xref headers." |
23f87bed MB |
2539 | (let ((inhibit-point-motion-hooks t) |
2540 | (inhibit-read-only t) | |
01c52d31 MB |
2541 | (method (gnus-find-method-for-group gnus-newsgroup-name)) |
2542 | regexp) | |
23f87bed MB |
2543 | (when (and (or gnus-group-name-charset-method-alist |
2544 | gnus-group-name-charset-group-alist) | |
2545 | (gnus-buffer-live-p gnus-original-article-buffer)) | |
2546 | (save-restriction | |
2547 | (article-narrow-to-head) | |
01c52d31 MB |
2548 | (dolist (header '("Newsgroups" "Followup-To" "Xref")) |
2549 | (with-current-buffer gnus-original-article-buffer | |
2550 | (goto-char (point-min))) | |
2551 | (setq regexp (concat "^" header | |
2552 | ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n")) | |
2553 | (while (re-search-forward regexp nil t) | |
2554 | (replace-match (save-match-data | |
2555 | (gnus-decode-newsgroups | |
2556 | ;; XXX how to use data in article buffer? | |
2557 | (with-current-buffer gnus-original-article-buffer | |
2558 | (re-search-forward regexp nil t) | |
2559 | (match-string 1)) | |
2560 | gnus-newsgroup-name method)) | |
2561 | t t nil 1)) | |
2562 | (goto-char (point-min))))))) | |
23f87bed MB |
2563 | |
2564 | (autoload 'idna-to-unicode "idna") | |
2565 | ||
2566 | (defun article-decode-idna-rhs () | |
53cfefc8 MB |
2567 | "Decode IDNA strings in RHS in various headers in current buffer. |
2568 | The following headers are decoded: From:, To:, Cc:, Reply-To:, | |
2569 | Mail-Reply-To: and Mail-Followup-To:." | |
23f87bed MB |
2570 | (when gnus-use-idna |
2571 | (save-restriction | |
2572 | (let ((inhibit-point-motion-hooks t) | |
2573 | (inhibit-read-only t)) | |
2574 | (article-narrow-to-head) | |
2575 | (goto-char (point-min)) | |
53cfefc8 | 2576 | (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t) |
23f87bed MB |
2577 | (let (ace unicode) |
2578 | (when (save-match-data | |
2579 | (and (setq ace (match-string 1)) | |
2580 | (save-excursion | |
2581 | (and (re-search-backward "^[^ \t]" nil t) | |
53cfefc8 | 2582 | (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To"))) |
23f87bed MB |
2583 | (setq unicode (idna-to-unicode ace)))) |
2584 | (unless (string= ace unicode) | |
2585 | (replace-match unicode nil nil nil 1))))))))) | |
2586 | ||
2587 | (defun article-de-quoted-unreadable (&optional force read-charset) | |
16409b0b | 2588 | "Translate a quoted-printable-encoded article. |
eec82323 | 2589 | If FORCE, decode the article whether it is marked as quoted-printable |
23f87bed MB |
2590 | or not. |
2591 | If READ-CHARSET, ask for a coding system." | |
2592 | (interactive (list 'force current-prefix-arg)) | |
eec82323 | 2593 | (save-excursion |
4e7d0221 | 2594 | (let ((inhibit-read-only t) type charset) |
8b93df01 DL |
2595 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
2596 | (with-current-buffer gnus-original-article-buffer | |
2597 | (setq type | |
2598 | (gnus-fetch-field "content-transfer-encoding")) | |
2599 | (let* ((ct (gnus-fetch-field "content-type")) | |
c96ec15a | 2600 | (ctl (and ct (mail-header-parse-content-type ct)))) |
8b93df01 DL |
2601 | (setq charset (and ctl |
2602 | (mail-content-type-get ctl 'charset))) | |
2603 | (if (stringp charset) | |
2604 | (setq charset (intern (downcase charset))))))) | |
23f87bed MB |
2605 | (if read-charset |
2606 | (setq charset (mm-read-coding-system "Charset: " charset))) | |
a1506d29 | 2607 | (unless charset |
8b93df01 | 2608 | (setq charset gnus-newsgroup-charset)) |
eec82323 | 2609 | (when (or force |
eb806ef3 DL |
2610 | (and type (let ((case-fold-search t)) |
2611 | (string-match "quoted-printable" type)))) | |
16409b0b | 2612 | (article-goto-body) |
eb806ef3 DL |
2613 | (quoted-printable-decode-region |
2614 | (point) (point-max) (mm-charset-to-coding-system charset)))))) | |
16409b0b | 2615 | |
23f87bed | 2616 | (defun article-de-base64-unreadable (&optional force read-charset) |
16409b0b | 2617 | "Translate a base64 article. |
23f87bed MB |
2618 | If FORCE, decode the article whether it is marked as base64 not. |
2619 | If READ-CHARSET, ask for a coding system." | |
2620 | (interactive (list 'force current-prefix-arg)) | |
16409b0b | 2621 | (save-excursion |
4e7d0221 | 2622 | (let ((inhibit-read-only t) type charset) |
8b93df01 DL |
2623 | (if (gnus-buffer-live-p gnus-original-article-buffer) |
2624 | (with-current-buffer gnus-original-article-buffer | |
2625 | (setq type | |
2626 | (gnus-fetch-field "content-transfer-encoding")) | |
2627 | (let* ((ct (gnus-fetch-field "content-type")) | |
c96ec15a | 2628 | (ctl (and ct (mail-header-parse-content-type ct)))) |
8b93df01 DL |
2629 | (setq charset (and ctl |
2630 | (mail-content-type-get ctl 'charset))) | |
2631 | (if (stringp charset) | |
2632 | (setq charset (intern (downcase charset))))))) | |
23f87bed MB |
2633 | (if read-charset |
2634 | (setq charset (mm-read-coding-system "Charset: " charset))) | |
a1506d29 | 2635 | (unless charset |
8b93df01 | 2636 | (setq charset gnus-newsgroup-charset)) |
16409b0b | 2637 | (when (or force |
eb806ef3 DL |
2638 | (and type (let ((case-fold-search t)) |
2639 | (string-match "base64" type)))) | |
16409b0b GM |
2640 | (article-goto-body) |
2641 | (save-restriction | |
2642 | (narrow-to-region (point) (point-max)) | |
2643 | (base64-decode-region (point-min) (point-max)) | |
eb806ef3 DL |
2644 | (mm-decode-coding-region |
2645 | (point-min) (point-max) (mm-charset-to-coding-system charset))))))) | |
16409b0b GM |
2646 | |
2647 | (eval-when-compile | |
2648 | (require 'rfc1843)) | |
2649 | ||
2650 | (defun article-decode-HZ () | |
2651 | "Translate a HZ-encoded article." | |
2652 | (interactive) | |
2653 | (require 'rfc1843) | |
2654 | (save-excursion | |
4e7d0221 | 2655 | (let ((inhibit-read-only t)) |
16409b0b GM |
2656 | (rfc1843-decode-region (point-min) (point-max))))) |
2657 | ||
23f87bed MB |
2658 | (defun article-unsplit-urls () |
2659 | "Remove the newlines that some other mailers insert into URLs." | |
16409b0b | 2660 | (interactive) |
23f87bed MB |
2661 | (save-excursion |
2662 | (let ((inhibit-read-only t)) | |
2663 | (goto-char (point-min)) | |
2664 | (while (re-search-forward | |
97f78c9b | 2665 | "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t) |
23f87bed MB |
2666 | (replace-match "\\1\\3" t))) |
2667 | (when (interactive-p) | |
2668 | (gnus-treat-article nil)))) | |
2669 | ||
2670 | ||
2671 | (defun article-wash-html (&optional read-charset) | |
2672 | "Format an HTML article. | |
73043f7d MB |
2673 | If READ-CHARSET, ask for a coding system. If it is a number, the |
2674 | charset defined in `gnus-summary-show-article-charset-alist' is used." | |
23f87bed | 2675 | (interactive "P") |
16409b0b | 2676 | (save-excursion |
4e7d0221 | 2677 | (let ((inhibit-read-only t) |
8b93df01 | 2678 | charset) |
73043f7d MB |
2679 | (if read-charset |
2680 | (if (or (and (numberp read-charset) | |
2681 | (setq charset | |
2682 | (cdr | |
2683 | (assq read-charset | |
2684 | gnus-summary-show-article-charset-alist)))) | |
2685 | (setq charset (mm-read-coding-system "Charset: "))) | |
2686 | (let ((gnus-summary-show-article-charset-alist | |
2687 | (list (cons 1 charset)))) | |
2688 | (with-current-buffer gnus-summary-buffer | |
2689 | (gnus-summary-show-article 1))) | |
2690 | (error "No charset is given")) | |
2691 | (when (gnus-buffer-live-p gnus-original-article-buffer) | |
2692 | (with-current-buffer gnus-original-article-buffer | |
2693 | (let* ((ct (gnus-fetch-field "content-type")) | |
c96ec15a | 2694 | (ctl (and ct (mail-header-parse-content-type ct)))) |
73043f7d MB |
2695 | (setq charset (and ctl |
2696 | (mail-content-type-get ctl 'charset))) | |
2697 | (when (stringp charset) | |
2698 | (setq charset (intern (downcase charset))))))) | |
2699 | (unless charset | |
2700 | (setq charset gnus-newsgroup-charset))) | |
16409b0b GM |
2701 | (article-goto-body) |
2702 | (save-window-excursion | |
2703 | (save-restriction | |
2704 | (narrow-to-region (point) (point-max)) | |
23f87bed MB |
2705 | (let* ((func (or gnus-article-wash-function mm-text-html-renderer)) |
2706 | (entry (assq func mm-text-html-washer-alist))) | |
2707 | (when entry | |
2708 | (setq func (cdr entry))) | |
2709 | (cond | |
2710 | ((functionp func) | |
2711 | (funcall func)) | |
2712 | (t | |
2713 | (apply (car func) (cdr func)))))))))) | |
2714 | ||
9640c3bc GM |
2715 | ;; External. |
2716 | (declare-function w3-region "ext:w3-display" (st nd)) | |
2717 | ||
23f87bed MB |
2718 | (defun gnus-article-wash-html-with-w3 () |
2719 | "Wash the current buffer with w3." | |
2720 | (mm-setup-w3) | |
2721 | (let ((w3-strict-width (window-width)) | |
2722 | (url-standalone-mode t) | |
2723 | (url-gateway-unplugged t) | |
2724 | (w3-honor-stylesheets nil)) | |
2725 | (condition-case () | |
2726 | (w3-region (point-min) (point-max)) | |
2727 | (error)))) | |
2728 | ||
9640c3bc GM |
2729 | ;; External. |
2730 | (declare-function w3m-region "ext:w3m" (start end &optional url charset)) | |
2731 | ||
23f87bed MB |
2732 | (defun gnus-article-wash-html-with-w3m () |
2733 | "Wash the current buffer with emacs-w3m." | |
2734 | (mm-setup-w3m) | |
7dafe00b MB |
2735 | (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp) |
2736 | w3m-force-redisplay) | |
2737 | (w3m-region (point-min) (point-max))) | |
1250af7b KY |
2738 | ;; Put the mark meaning this part was rendered by emacs-w3m. |
2739 | (put-text-property (point-min) (point-max) 'mm-inline-text-html-with-w3m t) | |
7dafe00b MB |
2740 | (when (and mm-inline-text-html-with-w3m-keymap |
2741 | (boundp 'w3m-minor-mode-map) | |
2742 | w3m-minor-mode-map) | |
886367d8 KY |
2743 | (if (and (boundp 'w3m-link-map) |
2744 | w3m-link-map) | |
1250af7b KY |
2745 | (let* ((start (point-min)) |
2746 | (end (point-max)) | |
2747 | (on (get-text-property start 'w3m-href-anchor)) | |
2748 | (map (copy-keymap w3m-link-map)) | |
2749 | next) | |
886367d8 | 2750 | (set-keymap-parent map w3m-minor-mode-map) |
1250af7b KY |
2751 | (while (< start end) |
2752 | (if on | |
2753 | (progn | |
2754 | (setq next (or (text-property-any start end | |
2755 | 'w3m-href-anchor nil) | |
2756 | end)) | |
2757 | (put-text-property start next 'keymap map)) | |
2758 | (setq next (or (text-property-not-all start end | |
2759 | 'w3m-href-anchor nil) | |
2760 | end)) | |
2761 | (put-text-property start next 'keymap w3m-minor-mode-map)) | |
2762 | (setq start next | |
2763 | on (not on)))) | |
2764 | (put-text-property (point-min) (point-max) 'keymap w3m-minor-mode-map)))) | |
16409b0b | 2765 | |
9efa445f | 2766 | (defvar charset) ;; Bound by `article-wash-html'. |
73043f7d MB |
2767 | |
2768 | (defun gnus-article-wash-html-with-w3m-standalone () | |
2769 | "Wash the current buffer with w3m." | |
7347faa8 MB |
2770 | (if (mm-w3m-standalone-supports-m17n-p) |
2771 | (progn | |
2772 | (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'. | |
2773 | ;; The default. | |
2774 | (setq charset 'iso-8859-1)) | |
2775 | (let ((coding-system-for-write charset) | |
2776 | (coding-system-for-read charset)) | |
2777 | (call-process-region | |
2778 | (point-min) (point-max) | |
2779 | "w3m" t t nil "-dump" "-T" "text/html" | |
2780 | "-I" (symbol-name charset) "-O" (symbol-name charset)))) | |
2781 | (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html"))) | |
73043f7d | 2782 | |
01c52d31 MB |
2783 | (defvar gnus-article-browse-html-temp-list nil |
2784 | "List of temporary files created by `gnus-article-browse-html-parts'. | |
2785 | Internal variable.") | |
2786 | ||
2787 | (defcustom gnus-article-browse-delete-temp 'ask | |
2788 | "What to do with temporary files from `gnus-article-browse-html-parts'. | |
2789 | If nil, don't delete temporary files. If it is t, delete them on | |
2790 | exit from the summary buffer. If it is the symbol `file', query | |
2791 | on each file, if it is `ask' ask once when exiting from the | |
2792 | summary buffer." | |
2793 | :group 'gnus-article | |
330f707b | 2794 | :version "23.1" ;; No Gnus |
01c52d31 MB |
2795 | :type '(choice (const :tag "Don't delete" nil) |
2796 | (const :tag "Don't ask" t) | |
2797 | (const :tag "Ask" ask) | |
2798 | (const :tag "Ask for each file" file))) | |
2799 | ||
2800 | ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list. | |
2801 | ||
2802 | (defun gnus-article-browse-delete-temp-files (&optional how) | |
2803 | "Delete temp-files created by `gnus-article-browse-html-parts'." | |
2804 | (when (and gnus-article-browse-html-temp-list | |
2805 | (or how | |
2806 | (setq how gnus-article-browse-delete-temp))) | |
2807 | (when (and (eq how 'ask) | |
bbbe940b MB |
2808 | (gnus-y-or-n-p (format |
2809 | "Delete all %s temporary HTML file(s)? " | |
2810 | (length gnus-article-browse-html-temp-list))) | |
01c52d31 MB |
2811 | (setq how t))) |
2812 | (dolist (file gnus-article-browse-html-temp-list) | |
2813 | (when (and (file-exists-p file) | |
2814 | (or (eq how t) | |
2815 | ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'): | |
2816 | (gnus-y-or-n-p | |
2817 | (format "Delete temporary HTML file `%s'? " file)))) | |
2818 | (delete-file file))) | |
2819 | ;; Also remove file from the list when not deleted or if file doesn't | |
2820 | ;; exist anymore. | |
2821 | (setq gnus-article-browse-html-temp-list nil)) | |
2822 | gnus-article-browse-html-temp-list) | |
2823 | ||
87035689 | 2824 | (defun gnus-article-browse-html-parts (list &optional header) |
01c52d31 | 2825 | "View all \"text/html\" parts from LIST. |
87035689 MB |
2826 | Recurse into multiparts. The optional HEADER that should be a decoded |
2827 | message header will be added to the bodies of the \"text/html\" parts." | |
01c52d31 | 2828 | ;; Internal function used by `gnus-article-browse-html-article'. |
bbbe940b | 2829 | (let (type file charset tmp-file showed) |
01c52d31 MB |
2830 | ;; Find and show the html-parts. |
2831 | (dolist (handle list) | |
2832 | ;; If HTML, show it: | |
bbbe940b MB |
2833 | (cond ((not (listp handle))) |
2834 | ((or (equal (car (setq type (mm-handle-type handle))) "text/html") | |
2835 | (and (equal (car type) "message/external-body") | |
87035689 MB |
2836 | (or header |
2837 | (setq file (or (mail-content-type-get type 'name) | |
2838 | (mail-content-type-get | |
2839 | (mm-handle-disposition handle) | |
2840 | 'filename)))) | |
bbbe940b MB |
2841 | (or (mm-handle-cache handle) |
2842 | (condition-case code | |
2843 | (progn (mm-extern-cache-contents handle) t) | |
2844 | (error | |
2845 | (gnus-message 3 "%s" (error-message-string code)) | |
2846 | (when (>= gnus-verbose 3) (sit-for 2)) | |
2847 | nil))) | |
2848 | (progn | |
2849 | (setq handle (mm-handle-cache handle) | |
2850 | type (mm-handle-type handle)) | |
2851 | (equal (car type) "text/html")))) | |
2852 | (when (or (setq charset (mail-content-type-get type 'charset)) | |
87035689 | 2853 | header |
bbbe940b MB |
2854 | (not file)) |
2855 | (setq tmp-file (mm-make-temp-file | |
2856 | ;; Do we need to care for 8.3 filenames? | |
2857 | "mm-" nil ".html"))) | |
87035689 MB |
2858 | ;; Add a meta html tag to specify charset and a header. |
2859 | (cond | |
2860 | (header | |
2861 | (let (title eheader body hcharset coding) | |
2862 | (with-temp-buffer | |
2863 | (mm-enable-multibyte) | |
2864 | (setq case-fold-search t) | |
2865 | (insert header "\n") | |
2866 | (setq title (message-fetch-field "subject")) | |
2867 | (goto-char (point-min)) | |
2868 | (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t) | |
2869 | (replace-match (cond ((match-beginning 1) "<") | |
2870 | ((match-beginning 2) ">") | |
2871 | (t "&")))) | |
2872 | (goto-char (point-min)) | |
2873 | (insert "<pre>\n") | |
2874 | (goto-char (point-max)) | |
2875 | (insert "</pre>\n<hr>\n") | |
2876 | ;; We have to examine charset one by one since | |
2877 | ;; charset specified in parts might be different. | |
2878 | (if (eq charset 'gnus-decoded) | |
2879 | (setq charset 'utf-8 | |
2880 | eheader (mm-encode-coding-string (buffer-string) | |
2881 | charset) | |
2882 | title (when title | |
2883 | (mm-encode-coding-string title charset)) | |
2884 | body (mm-encode-coding-string (mm-get-part handle) | |
2885 | charset)) | |
2886 | (setq hcharset (mm-find-mime-charset-region (point-min) | |
2887 | (point-max))) | |
2888 | (cond ((= (length hcharset) 1) | |
2889 | (setq hcharset (car hcharset) | |
2890 | coding (mm-charset-to-coding-system | |
2891 | hcharset))) | |
2892 | ((> (length hcharset) 1) | |
2893 | (setq hcharset 'utf-8 | |
2894 | coding hcharset))) | |
2895 | (if coding | |
2896 | (if charset | |
2897 | (progn | |
2898 | (setq body | |
2899 | (mm-charset-to-coding-system charset)) | |
2900 | (if (eq coding body) | |
2901 | (setq eheader (mm-encode-coding-string | |
2902 | (buffer-string) coding) | |
2903 | title (when title | |
2904 | (mm-encode-coding-string | |
2905 | title coding)) | |
2906 | body (mm-get-part handle)) | |
2907 | (setq charset 'utf-8 | |
2908 | eheader (mm-encode-coding-string | |
2909 | (buffer-string) charset) | |
2910 | title (when title | |
2911 | (mm-encode-coding-string | |
2912 | title charset)) | |
2913 | body (mm-encode-coding-string | |
2914 | (mm-decode-coding-string | |
2915 | (mm-get-part handle) body) | |
2916 | charset)))) | |
2917 | (setq charset hcharset | |
2918 | eheader (mm-encode-coding-string | |
2919 | (buffer-string) coding) | |
2920 | title (when title | |
2921 | (mm-encode-coding-string | |
2922 | title coding)) | |
2923 | body (mm-get-part handle))) | |
2924 | (setq eheader (mm-string-as-unibyte (buffer-string)) | |
2925 | body (mm-get-part handle)))) | |
2926 | (erase-buffer) | |
2927 | (mm-disable-multibyte) | |
2928 | (insert body) | |
2929 | (when charset | |
2930 | (mm-add-meta-html-tag handle charset)) | |
2931 | (when title | |
2932 | (goto-char (point-min)) | |
2933 | (unless (search-forward "<title>" nil t) | |
2934 | (re-search-forward "<head>\\s-*" nil t) | |
2935 | (insert "<title>" title "</title>\n"))) | |
2936 | (goto-char (point-min)) | |
2937 | (or (re-search-forward | |
2938 | "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t) | |
2939 | (re-search-forward | |
2940 | "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)) | |
2941 | (insert eheader) | |
2942 | (mm-write-region (point-min) (point-max) | |
2943 | tmp-file nil nil nil 'binary t)))) | |
2944 | (charset | |
2945 | (mm-with-unibyte-buffer | |
2946 | (insert (if (eq charset 'gnus-decoded) | |
2947 | (mm-encode-coding-string | |
2948 | (mm-get-part handle) | |
2949 | (setq charset 'utf-8)) | |
2950 | (mm-get-part handle))) | |
2951 | (if (or (mm-add-meta-html-tag handle charset) | |
2952 | (not file)) | |
2953 | (mm-write-region (point-min) (point-max) | |
2954 | tmp-file nil nil nil 'binary t) | |
2955 | (setq tmp-file nil)))) | |
2956 | (tmp-file | |
2957 | (mm-save-part-to-file handle tmp-file))) | |
bbbe940b MB |
2958 | (when tmp-file |
2959 | (add-to-list 'gnus-article-browse-html-temp-list tmp-file)) | |
2960 | (add-hook 'gnus-summary-prepare-exit-hook | |
2961 | 'gnus-article-browse-delete-temp-files) | |
2962 | (add-hook 'gnus-exit-gnus-hook | |
2963 | (lambda () | |
2964 | (gnus-article-browse-delete-temp-files t))) | |
2965 | ;; FIXME: Warn if there's an <img> tag? | |
2966 | (browse-url-of-file (or tmp-file (expand-file-name file))) | |
2967 | (setq showed t)) | |
2968 | ;; If multipart, recurse | |
87035689 MB |
2969 | ((equal (mm-handle-media-supertype handle) "multipart") |
2970 | (when (gnus-article-browse-html-parts handle header) | |
2971 | (setq showed t))) | |
2972 | ((equal (mm-handle-media-type handle) "message/rfc822") | |
2973 | (mm-with-multibyte-buffer | |
2974 | (mm-insert-part handle) | |
2975 | (setq handle (mm-dissect-buffer t t)) | |
2976 | (when (and (bufferp (car handle)) | |
2977 | (stringp (car (mm-handle-type handle)))) | |
2978 | (setq handle (list handle))) | |
2979 | (when header | |
2980 | (article-decode-encoded-words) | |
2981 | (let ((gnus-visible-headers | |
2982 | (or (get 'gnus-visible-headers 'standard-value) | |
2983 | gnus-visible-headers))) | |
2984 | (article-hide-headers)) | |
2985 | (goto-char (point-min)) | |
2986 | (search-forward "\n\n" nil 'move) | |
2987 | (skip-chars-backward "\t\n ") | |
2988 | (setq header (buffer-substring (point-min) (point))))) | |
2989 | (when (prog1 | |
2990 | (gnus-article-browse-html-parts handle header) | |
2991 | (mm-destroy-parts handle)) | |
2992 | (setq showed t))))) | |
01c52d31 MB |
2993 | showed)) |
2994 | ||
87035689 | 2995 | (defun gnus-article-browse-html-article (&optional arg) |
01c52d31 | 2996 | "View \"text/html\" parts of the current article with a WWW browser. |
87035689 MB |
2997 | The message header is added to the beginning of every html part unless |
2998 | the prefix argument ARG is given. | |
01c52d31 MB |
2999 | |
3000 | Warning: Spammers use links to images in HTML articles to verify | |
3001 | whether you have read the message. As | |
9b3ebcb6 MB |
3002 | `gnus-article-browse-html-article' passes the HTML content to the |
3003 | browser without eliminating these \"web bugs\" you should only | |
3004 | use it for mails from trusted senders. | |
b890d447 | 3005 | |
9b3ebcb6 | 3006 | If you always want to display HTML parts in the browser, set |
b890d447 | 3007 | `mm-text-html-renderer' to nil." |
01c52d31 | 3008 | ;; Cf. `mm-w3m-safe-url-regexp' |
87035689 MB |
3009 | (interactive "P") |
3010 | (if arg | |
3011 | (gnus-summary-show-article) | |
3012 | (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value) | |
9b3ebcb6 MB |
3013 | gnus-visible-headers)) |
3014 | ;; As we insert a <hr>, there's no need for the body boundary. | |
3015 | (gnus-treat-body-boundary nil)) | |
87035689 MB |
3016 | (gnus-summary-show-article))) |
3017 | (with-current-buffer gnus-article-buffer | |
3018 | (let ((header (unless arg | |
3019 | (save-restriction | |
3020 | (widen) | |
3021 | (buffer-substring-no-properties | |
3022 | (goto-char (point-min)) | |
3023 | (if (search-forward "\n\n" nil t) | |
3024 | (match-beginning 0) | |
3025 | (goto-char (point-max)) | |
3026 | (skip-chars-backward "\t\n ") | |
3027 | (point)))))) | |
3028 | parts) | |
3029 | (set-buffer gnus-original-article-buffer) | |
3030 | (setq parts (mm-dissect-buffer t t)) | |
01c52d31 MB |
3031 | ;; If singlepart, enforce a list. |
3032 | (when (and (bufferp (car parts)) | |
3033 | (stringp (car (mm-handle-type parts)))) | |
3034 | (setq parts (list parts))) | |
3035 | ;; Process the list | |
87035689 | 3036 | (unless (gnus-article-browse-html-parts parts header) |
01c52d31 | 3037 | (gnus-error 3 "Mail doesn't contain a \"text/html\" part!")) |
87035689 MB |
3038 | (mm-destroy-parts parts) |
3039 | (unless arg | |
3040 | (gnus-summary-show-article))))) | |
01c52d31 | 3041 | |
16409b0b GM |
3042 | (defun article-hide-list-identifiers () |
3043 | "Remove list identifies from the Subject header. | |
3044 | The `gnus-list-identifiers' variable specifies what to do." | |
3045 | (interactive) | |
23f87bed MB |
3046 | (let ((inhibit-point-motion-hooks t) |
3047 | (regexp (if (consp gnus-list-identifiers) | |
3048 | (mapconcat 'identity gnus-list-identifiers " *\\|") | |
3049 | gnus-list-identifiers)) | |
3050 | (inhibit-read-only t)) | |
3051 | (when regexp | |
3052 | (save-excursion | |
3053 | (save-restriction | |
3054 | (article-narrow-to-head) | |
3055 | (goto-char (point-min)) | |
3056 | (while (re-search-forward | |
3057 | (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)") | |
3058 | nil t) | |
3059 | (delete-region (match-beginning 2) (match-end 0)) | |
3060 | (beginning-of-line)) | |
3061 | (when (re-search-forward | |
3062 | "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t) | |
3063 | (delete-region (match-beginning 1) (match-end 1)))))))) | |
eec82323 LMI |
3064 | |
3065 | (defun article-hide-pem (&optional arg) | |
3066 | "Toggle hiding of any PEM headers and signatures in the current article. | |
3067 | If given a negative prefix, always show; if given a positive prefix, | |
3068 | always hide." | |
3069 | (interactive (gnus-article-hidden-arg)) | |
3070 | (unless (gnus-article-check-hidden-text 'pem arg) | |
3071 | (save-excursion | |
23f87bed | 3072 | (let ((inhibit-read-only t) end) |
eec82323 | 3073 | (goto-char (point-min)) |
16409b0b GM |
3074 | ;; Hide the horrendously ugly "header". |
3075 | (when (and (search-forward | |
3076 | "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | |
3077 | nil t) | |
3078 | (setq end (1+ (match-beginning 0)))) | |
23f87bed | 3079 | (gnus-add-wash-type 'pem) |
16409b0b GM |
3080 | (gnus-article-hide-text-type |
3081 | end | |
3082 | (if (search-forward "\n\n" nil t) | |
3083 | (match-end 0) | |
3084 | (point-max)) | |
3085 | 'pem) | |
3086 | ;; Hide the trailer as well | |
3087 | (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | |
3088 | nil t) | |
3089 | (gnus-article-hide-text-type | |
3090 | (match-beginning 0) (match-end 0) 'pem))))))) | |
3091 | ||
3092 | (defun article-strip-banner () | |
23f87bed MB |
3093 | "Strip the banners specified by the `banner' group parameter and by |
3094 | `gnus-article-address-banner-alist'." | |
16409b0b | 3095 | (interactive) |
23f87bed MB |
3096 | (save-excursion |
3097 | (save-restriction | |
3098 | (let ((inhibit-point-motion-hooks t)) | |
3099 | (when (gnus-parameter-banner gnus-newsgroup-name) | |
3100 | (article-really-strip-banner | |
3101 | (gnus-parameter-banner gnus-newsgroup-name))) | |
3102 | (when gnus-article-address-banner-alist | |
cf5a5c38 MB |
3103 | ;; Note that the From header is decoded here, so it is |
3104 | ;; required that the *-extract-address-components function | |
3105 | ;; supports non-ASCII text. | |
d71c0855 MB |
3106 | (let ((from (save-restriction |
3107 | (widen) | |
3108 | (article-narrow-to-head) | |
3109 | (mail-fetch-field "from")))) | |
3110 | (when (and from | |
3111 | (setq from | |
3112 | (cadr (funcall gnus-extract-address-components | |
3113 | from)))) | |
3114 | (catch 'found | |
3115 | (dolist (pair gnus-article-address-banner-alist) | |
3116 | (when (string-match (car pair) from) | |
3117 | (throw 'found | |
3118 | (article-really-strip-banner (cdr pair))))))))))))) | |
23f87bed MB |
3119 | |
3120 | (defun article-really-strip-banner (banner) | |
3121 | "Strip the banner specified by the argument." | |
16409b0b GM |
3122 | (save-excursion |
3123 | (save-restriction | |
3124 | (let ((inhibit-point-motion-hooks t) | |
16409b0b | 3125 | (gnus-signature-limit nil) |
23f87bed MB |
3126 | (inhibit-read-only t)) |
3127 | (article-goto-body) | |
3128 | (cond | |
3129 | ((eq banner 'signature) | |
3130 | (when (gnus-article-narrow-to-signature) | |
3131 | (widen) | |
3132 | (forward-line -1) | |
3133 | (delete-region (point) (point-max)))) | |
3134 | ((symbolp banner) | |
3135 | (if (setq banner (cdr (assq banner gnus-article-banner-alist))) | |
3136 | (while (re-search-forward banner nil t) | |
3137 | (delete-region (match-beginning 0) (match-end 0))))) | |
3138 | ((stringp banner) | |
3139 | (while (re-search-forward banner nil t) | |
3140 | (delete-region (match-beginning 0) (match-end 0))))))))) | |
16409b0b GM |
3141 | |
3142 | (defun article-babel () | |
3143 | "Translate article using an online translation service." | |
3144 | (interactive) | |
3145 | (require 'babel) | |
01c52d31 | 3146 | (gnus-with-article-buffer |
16409b0b | 3147 | (when (article-goto-body) |
01c52d31 | 3148 | (let* ((start (point)) |
16409b0b GM |
3149 | (end (point-max)) |
3150 | (orig (buffer-substring start end)) | |
23f87bed | 3151 | (trans (babel-as-string orig))) |
16409b0b GM |
3152 | (save-restriction |
3153 | (narrow-to-region start end) | |
3154 | (delete-region start end) | |
23f87bed | 3155 | (insert trans)))))) |
eec82323 LMI |
3156 | |
3157 | (defun article-hide-signature (&optional arg) | |
3158 | "Hide the signature in the current article. | |
3159 | If given a negative prefix, always show; if given a positive prefix, | |
3160 | always hide." | |
3161 | (interactive (gnus-article-hidden-arg)) | |
3162 | (unless (gnus-article-check-hidden-text 'signature arg) | |
3163 | (save-excursion | |
3164 | (save-restriction | |
4e7d0221 | 3165 | (let ((inhibit-read-only t)) |
eec82323 LMI |
3166 | (when (gnus-article-narrow-to-signature) |
3167 | (gnus-article-hide-text-type | |
23f87bed MB |
3168 | (point-min) (point-max) 'signature)))))) |
3169 | (gnus-set-mode-line 'article)) | |
eec82323 | 3170 | |
16409b0b GM |
3171 | (defun article-strip-headers-in-body () |
3172 | "Strip offensive headers from bodies." | |
3173 | (interactive) | |
3174 | (save-excursion | |
3175 | (article-goto-body) | |
3176 | (let ((case-fold-search t)) | |
3177 | (when (looking-at "x-no-archive:") | |
3178 | (gnus-delete-line))))) | |
3179 | ||
eec82323 LMI |
3180 | (defun article-strip-leading-blank-lines () |
3181 | "Remove all blank lines from the beginning of the article." | |
3182 | (interactive) | |
3183 | (save-excursion | |
3184 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3185 | (inhibit-read-only t)) |
16409b0b | 3186 | (when (article-goto-body) |
eec82323 LMI |
3187 | (while (and (not (eobp)) |
3188 | (looking-at "[ \t]*$")) | |
3189 | (gnus-delete-line)))))) | |
3190 | ||
16409b0b GM |
3191 | (defun article-narrow-to-head () |
3192 | "Narrow the buffer to the head of the message. | |
3193 | Point is left at the beginning of the narrowed-to region." | |
3194 | (narrow-to-region | |
3195 | (goto-char (point-min)) | |
3196 | (if (search-forward "\n\n" nil 1) | |
3197 | (1- (point)) | |
3198 | (point-max))) | |
3199 | (goto-char (point-min))) | |
3200 | ||
3201 | (defun article-goto-body () | |
3202 | "Place point at the start of the body." | |
3203 | (goto-char (point-min)) | |
3204 | (cond | |
3205 | ;; This variable is only bound when dealing with separate | |
3206 | ;; MIME body parts. | |
3207 | (article-goto-body-goes-to-point-min-p | |
3208 | t) | |
3209 | ((search-forward "\n\n" nil t) | |
3210 | t) | |
3211 | (t | |
3212 | (goto-char (point-max)) | |
3213 | nil))) | |
3214 | ||
eec82323 LMI |
3215 | (defun article-strip-multiple-blank-lines () |
3216 | "Replace consecutive blank lines with one empty line." | |
3217 | (interactive) | |
3218 | (save-excursion | |
3219 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3220 | (inhibit-read-only t)) |
eec82323 | 3221 | ;; First make all blank lines empty. |
16409b0b | 3222 | (article-goto-body) |
eec82323 | 3223 | (while (re-search-forward "^[ \t]+$" nil t) |
16409b0b GM |
3224 | (unless (gnus-annotation-in-region-p |
3225 | (match-beginning 0) (match-end 0)) | |
3226 | (replace-match "" nil t))) | |
eec82323 | 3227 | ;; Then replace multiple empty lines with a single empty line. |
16409b0b | 3228 | (article-goto-body) |
23f87bed | 3229 | (while (re-search-forward "\n\n\\(\n+\\)" nil t) |
16409b0b GM |
3230 | (unless (gnus-annotation-in-region-p |
3231 | (match-beginning 0) (match-end 0)) | |
23f87bed | 3232 | (delete-region (match-beginning 1) (match-end 1))))))) |
eec82323 LMI |
3233 | |
3234 | (defun article-strip-leading-space () | |
3235 | "Remove all white space from the beginning of the lines in the article." | |
3236 | (interactive) | |
3237 | (save-excursion | |
3238 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3239 | (inhibit-read-only t)) |
16409b0b | 3240 | (article-goto-body) |
eec82323 LMI |
3241 | (while (re-search-forward "^[ \t]+" nil t) |
3242 | (replace-match "" t t))))) | |
3243 | ||
16409b0b GM |
3244 | (defun article-strip-trailing-space () |
3245 | "Remove all white space from the end of the lines in the article." | |
3246 | (interactive) | |
3247 | (save-excursion | |
3248 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3249 | (inhibit-read-only t)) |
16409b0b GM |
3250 | (article-goto-body) |
3251 | (while (re-search-forward "[ \t]+$" nil t) | |
3252 | (replace-match "" t t))))) | |
3253 | ||
eec82323 LMI |
3254 | (defun article-strip-blank-lines () |
3255 | "Strip leading, trailing and multiple blank lines." | |
3256 | (interactive) | |
3257 | (article-strip-leading-blank-lines) | |
3258 | (article-remove-trailing-blank-lines) | |
3259 | (article-strip-multiple-blank-lines)) | |
3260 | ||
6748645f LMI |
3261 | (defun article-strip-all-blank-lines () |
3262 | "Strip all blank lines." | |
3263 | (interactive) | |
3264 | (save-excursion | |
3265 | (let ((inhibit-point-motion-hooks t) | |
23f87bed | 3266 | (inhibit-read-only t)) |
16409b0b | 3267 | (article-goto-body) |
6748645f LMI |
3268 | (while (re-search-forward "^[ \t]*\n" nil t) |
3269 | (replace-match "" t t))))) | |
3270 | ||
eec82323 LMI |
3271 | (defun gnus-article-narrow-to-signature () |
3272 | "Narrow to the signature; return t if a signature is found, else nil." | |
6748645f | 3273 | (let ((inhibit-point-motion-hooks t)) |
6748645f LMI |
3274 | (when (gnus-article-search-signature) |
3275 | (forward-line 1) | |
3276 | ;; Check whether we have some limits to what we consider | |
3277 | ;; to be a signature. | |
3278 | (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit | |
3279 | (list gnus-signature-limit))) | |
3280 | limit limited) | |
3281 | (while (setq limit (pop limits)) | |
3282 | (if (or (and (integerp limit) | |
3283 | (< (- (point-max) (point)) limit)) | |
3284 | (and (floatp limit) | |
3285 | (< (count-lines (point) (point-max)) limit)) | |
23f87bed | 3286 | (and (functionp limit) |
6748645f LMI |
3287 | (funcall limit)) |
3288 | (and (stringp limit) | |
3289 | (not (re-search-forward limit nil t)))) | |
3290 | () ; This limit did not succeed. | |
3291 | (setq limited t | |
3292 | limits nil))) | |
3293 | (unless limited | |
3294 | (narrow-to-region (point) (point-max)) | |
3295 | t))))) | |
eec82323 LMI |
3296 | |
3297 | (defun gnus-article-search-signature () | |
3298 | "Search the current buffer for the signature separator. | |
3299 | Put point at the beginning of the signature separator." | |
3300 | (let ((cur (point))) | |
3301 | (goto-char (point-max)) | |
3302 | (if (if (stringp gnus-signature-separator) | |
3303 | (re-search-backward gnus-signature-separator nil t) | |
3304 | (let ((seps gnus-signature-separator)) | |
3305 | (while (and seps | |
3306 | (not (re-search-backward (car seps) nil t))) | |
3307 | (pop seps)) | |
3308 | seps)) | |
3309 | t | |
3310 | (goto-char cur) | |
3311 | nil))) | |
3312 | ||
eec82323 LMI |
3313 | (defun gnus-article-hidden-arg () |
3314 | "Return the current prefix arg as a number, or 0 if no prefix." | |
3315 | (list (if current-prefix-arg | |
3316 | (prefix-numeric-value current-prefix-arg) | |
3317 | 0))) | |
3318 | ||
3319 | (defun gnus-article-check-hidden-text (type arg) | |
3320 | "Return nil if hiding is necessary. | |
f0529b5b | 3321 | Arg can be nil or a number. nil and positive means hide, negative |
eec82323 LMI |
3322 | means show, 0 means toggle." |
3323 | (save-excursion | |
3324 | (save-restriction | |
eec82323 LMI |
3325 | (let ((hide (gnus-article-hidden-text-p type))) |
3326 | (cond | |
3327 | ((or (null arg) | |
3328 | (> arg 0)) | |
3329 | nil) | |
3330 | ((< arg 0) | |
4481aa98 SZ |
3331 | (gnus-article-show-hidden-text type) |
3332 | t) | |
eec82323 LMI |
3333 | (t |
3334 | (if (eq hide 'hidden) | |
4481aa98 SZ |
3335 | (progn |
3336 | (gnus-article-show-hidden-text type) | |
3337 | t) | |
eec82323 LMI |
3338 | nil))))))) |
3339 | ||
3340 | (defun gnus-article-hidden-text-p (type) | |
3341 | "Say whether the current buffer contains hidden text of type TYPE." | |
6748645f | 3342 | (let ((pos (text-property-any (point-min) (point-max) 'article-type type))) |
eec82323 | 3343 | (while (and pos |
16409b0b GM |
3344 | (not (get-text-property pos 'invisible)) |
3345 | (not (get-text-property pos 'dummy-invisible))) | |
eec82323 LMI |
3346 | (setq pos |
3347 | (text-property-any (1+ pos) (point-max) 'article-type type))) | |
3348 | (if pos | |
3349 | 'hidden | |
16409b0b | 3350 | nil))) |
eec82323 | 3351 | |
520aa572 | 3352 | (defun gnus-article-show-hidden-text (type &optional dummy) |
eec82323 | 3353 | "Show all hidden text of type TYPE. |
520aa572 | 3354 | Originally it is hide instead of DUMMY." |
4e7d0221 | 3355 | (let ((inhibit-read-only t) |
520aa572 | 3356 | (inhibit-point-motion-hooks t)) |
a1506d29 | 3357 | (gnus-remove-text-properties-when |
520aa572 | 3358 | 'article-type type |
a1506d29 | 3359 | (point-min) (point-max) |
520aa572 | 3360 | (cons 'article-type (cons type |
23f87bed MB |
3361 | gnus-hidden-properties))) |
3362 | (gnus-delete-wash-type type))) | |
eec82323 LMI |
3363 | |
3364 | (defconst article-time-units | |
3365 | `((year . ,(* 365.25 24 60 60)) | |
3366 | (week . ,(* 7 24 60 60)) | |
3367 | (day . ,(* 24 60 60)) | |
3368 | (hour . ,(* 60 60)) | |
3369 | (minute . 60) | |
3370 | (second . 1)) | |
3371 | "Mapping from time units to seconds.") | |
3372 | ||
23f87bed MB |
3373 | (defun gnus-article-forward-header () |
3374 | "Move point to the start of the next header. | |
3375 | If the current header is a continuation header, this can be several | |
3376 | lines forward." | |
3377 | (let ((ended nil)) | |
3378 | (while (not ended) | |
3379 | (forward-line 1) | |
3380 | (if (looking-at "[ \t]+[^ \t]") | |
3381 | (forward-line 1) | |
3382 | (setq ended t))))) | |
3383 | ||
31640842 | 3384 | (defun article-date-ut (&optional type highlight) |
eec82323 LMI |
3385 | "Convert DATE date to universal time in the current article. |
3386 | If TYPE is `local', convert to local time; if it is `lapsed', output | |
16409b0b GM |
3387 | how much time has lapsed since DATE. For `lapsed', the value of |
3388 | `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header | |
3389 | should replace the \"Date:\" one, or should be added below it." | |
eec82323 | 3390 | (interactive (list 'ut t)) |
31640842 MB |
3391 | (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") |
3392 | (date-regexp (cond ((not gnus-article-date-lapsed-new-header) | |
3393 | tdate-regexp) | |
3394 | ((eq type 'lapsed) | |
3395 | "^X-Sent:[ \t]") | |
3396 | (article-lapsed-timer | |
3397 | "^Date:[ \t]") | |
3398 | (t | |
3399 | tdate-regexp))) | |
3400 | (case-fold-search t) | |
3401 | (inhibit-read-only t) | |
eec82323 | 3402 | (inhibit-point-motion-hooks t) |
31640842 | 3403 | pos date bface eface) |
16409b0b GM |
3404 | (save-excursion |
3405 | (save-restriction | |
31640842 MB |
3406 | (widen) |
3407 | (goto-char (point-min)) | |
3408 | (while (or (setq date (get-text-property (setq pos (point)) | |
3409 | 'original-date)) | |
3410 | (when (setq pos (next-single-property-change | |
3411 | (point) 'original-date)) | |
3412 | (setq date (get-text-property pos 'original-date)) | |
3413 | t)) | |
548f737d MB |
3414 | (narrow-to-region |
3415 | pos (if (setq pos (text-property-any pos (point-max) | |
3416 | 'original-date nil)) | |
3417 | (progn | |
3418 | (goto-char pos) | |
3419 | (if (or (bolp) (eobp)) | |
3420 | (point) | |
3421 | (1+ (point)))) | |
3422 | (point-max))) | |
16409b0b | 3423 | (goto-char (point-min)) |
31640842 | 3424 | (when (re-search-forward tdate-regexp nil t) |
01c52d31 MB |
3425 | (setq bface (get-text-property (point-at-bol) 'face) |
3426 | eface (get-text-property (1- (point-at-eol)) 'face))) | |
31640842 MB |
3427 | (goto-char (point-min)) |
3428 | (setq pos nil) | |
3429 | ;; Delete any old Date headers. | |
3430 | (while (re-search-forward date-regexp nil t) | |
3431 | (if pos | |
01c52d31 MB |
3432 | (delete-region (point-at-bol) (progn |
3433 | (gnus-article-forward-header) | |
3434 | (point))) | |
3435 | (delete-region (point-at-bol) (progn | |
3436 | (gnus-article-forward-header) | |
3437 | (forward-char -1) | |
3438 | (point))) | |
31640842 MB |
3439 | (setq pos (point)))) |
3440 | (when (and (not pos) | |
3441 | (re-search-forward tdate-regexp nil t)) | |
3442 | (forward-line 1)) | |
3443 | (gnus-goto-char pos) | |
3444 | (insert (article-make-date-line date (or type 'ut))) | |
3445 | (unless pos | |
3446 | (insert "\n") | |
3447 | (forward-line -1)) | |
3448 | ;; Do highlighting. | |
3449 | (beginning-of-line) | |
3450 | (when (looking-at "\\([^:]+\\): *\\(.*\\)$") | |
3451 | (put-text-property (match-beginning 1) (1+ (match-end 1)) | |
3452 | 'face bface) | |
3453 | (put-text-property (match-beginning 2) (match-end 2) | |
3454 | 'face eface)) | |
3455 | (put-text-property (point-min) (1- (point-max)) 'original-date date) | |
3456 | (goto-char (point-max)) | |
3457 | (widen)))))) | |
eec82323 LMI |
3458 | |
3459 | (defun article-make-date-line (date type) | |
3460 | "Return a DATE line of TYPE." | |
23f87bed MB |
3461 | (unless (memq type '(local ut original user iso8601 lapsed english)) |
3462 | (error "Unknown conversion type: %s" type)) | |
3463 | (condition-case () | |
3464 | (let ((time (date-to-time date))) | |
16409b0b | 3465 | (cond |
23f87bed MB |
3466 | ;; Convert to the local timezone. |
3467 | ((eq type 'local) | |
01c52d31 | 3468 | (concat "Date: " (message-make-date time))) |
23f87bed MB |
3469 | ;; Convert to Universal Time. |
3470 | ((eq type 'ut) | |
3471 | (concat "Date: " | |
01c52d31 MB |
3472 | (substring |
3473 | (message-make-date | |
3474 | (let* ((e (parse-time-string date)) | |
3475 | (tm (apply 'encode-time e)) | |
3476 | (ms (car tm)) | |
3477 | (ls (- (cadr tm) (car (current-time-zone time))))) | |
3478 | (cond ((< ls 0) (list (1- ms) (+ ls 65536))) | |
3479 | ((> ls 65535) (list (1+ ms) (- ls 65536))) | |
3480 | (t (list ms ls))))) | |
3481 | 0 -5) | |
3482 | "UT")) | |
23f87bed MB |
3483 | ;; Get the original date from the article. |
3484 | ((eq type 'original) | |
3485 | (concat "Date: " (if (string-match "\n+$" date) | |
3486 | (substring date 0 (match-beginning 0)) | |
3487 | date))) | |
3488 | ;; Let the user define the format. | |
3489 | ((eq type 'user) | |
3490 | (let ((format (or (condition-case nil | |
3491 | (with-current-buffer gnus-summary-buffer | |
3492 | gnus-article-time-format) | |
3493 | (error nil)) | |
3494 | gnus-article-time-format))) | |
3495 | (if (functionp format) | |
3496 | (funcall format time) | |
3497 | (concat "Date: " (format-time-string format time))))) | |
3498 | ;; ISO 8601. | |
3499 | ((eq type 'iso8601) | |
3500 | (let ((tz (car (current-time-zone time)))) | |
3501 | (concat | |
3502 | "Date: " | |
3503 | (format-time-string "%Y%m%dT%H%M%S" time) | |
3504 | (format "%s%02d%02d" | |
3505 | (if (> tz 0) "+" "-") (/ (abs tz) 3600) | |
3506 | (/ (% (abs tz) 3600) 60))))) | |
3507 | ;; Do an X-Sent lapsed format. | |
3508 | ((eq type 'lapsed) | |
3509 | ;; If the date is seriously mangled, the timezone functions are | |
3510 | ;; liable to bug out, so we ignore all errors. | |
3511 | (let* ((now (current-time)) | |
3512 | (real-time (subtract-time now time)) | |
3513 | (real-sec (and real-time | |
3514 | (+ (* (float (car real-time)) 65536) | |
3515 | (cadr real-time)))) | |
3516 | (sec (and real-time (abs real-sec))) | |
3517 | num prev) | |
3518 | (cond | |
3519 | ((null real-time) | |
3520 | "X-Sent: Unknown") | |
3521 | ((zerop sec) | |
3522 | "X-Sent: Now") | |
3523 | (t | |
3524 | (concat | |
3525 | "X-Sent: " | |
3526 | ;; This is a bit convoluted, but basically we go | |
3527 | ;; through the time units for years, weeks, etc, | |
3528 | ;; and divide things to see whether that results | |
3529 | ;; in positive answers. | |
3530 | (mapconcat | |
3531 | (lambda (unit) | |
3532 | (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
3533 | ;; The (remaining) seconds are too few to | |
3534 | ;; be divided into this time unit. | |
3535 | "" | |
3536 | ;; It's big enough, so we output it. | |
3537 | (setq sec (- sec (* num (cdr unit)))) | |
3538 | (prog1 | |
3539 | (concat (if prev ", " "") (int-to-string | |
3540 | (floor num)) | |
3541 | " " (symbol-name (car unit)) | |
3542 | (if (> num 1) "s" "")) | |
3543 | (setq prev t)))) | |
3544 | article-time-units "") | |
3545 | ;; If dates are odd, then it might appear like the | |
3546 | ;; article was sent in the future. | |
3547 | (if (> real-sec 0) | |
3548 | " ago" | |
3549 | " in the future")))))) | |
3550 | ;; Display the date in proper English | |
3551 | ((eq type 'english) | |
3552 | (let ((dtime (decode-time time))) | |
3553 | (concat | |
3554 | "Date: the " | |
3555 | (number-to-string (nth 3 dtime)) | |
3556 | (let ((digit (% (nth 3 dtime) 10))) | |
3557 | (cond | |
3558 | ((memq (nth 3 dtime) '(11 12 13)) "th") | |
3559 | ((= digit 1) "st") | |
3560 | ((= digit 2) "nd") | |
3561 | ((= digit 3) "rd") | |
3562 | (t "th"))) | |
3563 | " of " | |
3564 | (nth (1- (nth 4 dtime)) gnus-english-month-names) | |
3565 | " " | |
3566 | (number-to-string (nth 5 dtime)) | |
3567 | " at " | |
3568 | (format "%02d" (nth 2 dtime)) | |
3569 | ":" | |
3570 | (format "%02d" (nth 1 dtime))))))) | |
3571 | (error | |
a601fb74 | 3572 | (format "Date: %s (from Gnus)" date)))) |
eec82323 LMI |
3573 | |
3574 | (defun article-date-local (&optional highlight) | |
3575 | "Convert the current article date to the local timezone." | |
3576 | (interactive (list t)) | |
3577 | (article-date-ut 'local highlight)) | |
3578 | ||
23f87bed MB |
3579 | (defun article-date-english (&optional highlight) |
3580 | "Convert the current article date to something that is proper English." | |
3581 | (interactive (list t)) | |
3582 | (article-date-ut 'english highlight)) | |
3583 | ||
eec82323 LMI |
3584 | (defun article-date-original (&optional highlight) |
3585 | "Convert the current article date to what it was originally. | |
3586 | This is only useful if you have used some other date conversion | |
3587 | function and want to see what the date was before converting." | |
3588 | (interactive (list t)) | |
3589 | (article-date-ut 'original highlight)) | |
3590 | ||
3591 | (defun article-date-lapsed (&optional highlight) | |
3592 | "Convert the current article date to time lapsed since it was sent." | |
3593 | (interactive (list t)) | |
3594 | (article-date-ut 'lapsed highlight)) | |
3595 | ||
6748645f LMI |
3596 | (defun article-update-date-lapsed () |
3597 | "Function to be run from a timer to update the lapsed time line." | |
e0a8aa09 LT |
3598 | (save-match-data |
3599 | (let (deactivate-mark) | |
3600 | (save-excursion | |
3601 | (ignore-errors | |
3602 | (walk-windows | |
3603 | (lambda (w) | |
3604 | (set-buffer (window-buffer w)) | |
3605 | (when (eq major-mode 'gnus-article-mode) | |
3606 | (let ((mark (point-marker))) | |
3607 | (goto-char (point-min)) | |
3608 | (when (re-search-forward "^X-Sent:" nil t) | |
3609 | (article-date-lapsed t)) | |
3610 | (goto-char (marker-position mark)) | |
3611 | (move-marker mark nil)))) | |
3612 | nil 'visible)))))) | |
6748645f LMI |
3613 | |
3614 | (defun gnus-start-date-timer (&optional n) | |
3615 | "Start a timer to update the X-Sent header in the article buffers. | |
3616 | The numerical prefix says how frequently (in seconds) the function | |
3617 | is to run." | |
3618 | (interactive "p") | |
3619 | (unless n | |
3620 | (setq n 1)) | |
3621 | (gnus-stop-date-timer) | |
3622 | (setq article-lapsed-timer | |
01c52d31 | 3623 | (run-at-time 1 n 'article-update-date-lapsed))) |
6748645f LMI |
3624 | |
3625 | (defun gnus-stop-date-timer () | |
3626 | "Stop the X-Sent timer." | |
3627 | (interactive) | |
3628 | (when article-lapsed-timer | |
3629 | (nnheader-cancel-timer article-lapsed-timer) | |
3630 | (setq article-lapsed-timer nil))) | |
3631 | ||
eec82323 LMI |
3632 | (defun article-date-user (&optional highlight) |
3633 | "Convert the current article date to the user-defined format. | |
3634 | This format is defined by the `gnus-article-time-format' variable." | |
3635 | (interactive (list t)) | |
3636 | (article-date-ut 'user highlight)) | |
3637 | ||
6748645f LMI |
3638 | (defun article-date-iso8601 (&optional highlight) |
3639 | "Convert the current article date to ISO8601." | |
3640 | (interactive (list t)) | |
3641 | (article-date-ut 'iso8601 highlight)) | |
3642 | ||
31640842 MB |
3643 | (defmacro gnus-article-save-original-date (&rest forms) |
3644 | "Save the original date as a text property and evaluate FORMS." | |
3645 | `(let* ((case-fold-search t) | |
3646 | (start (progn | |
3647 | (goto-char (point-min)) | |
3648 | (when (and (re-search-forward "^date:[\t\n ]+" nil t) | |
3649 | (not (bolp))) | |
3650 | (match-end 0)))) | |
3651 | (date (when (and start | |
01c52d31 | 3652 | (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)" |
31640842 MB |
3653 | nil t)) |
3654 | (buffer-substring-no-properties start | |
3655 | (match-beginning 0))))) | |
3656 | (goto-char (point-max)) | |
3657 | (skip-chars-backward "\n") | |
3658 | (put-text-property (point-min) (point) 'original-date date) | |
3659 | ,@forms | |
3660 | (goto-char (point-max)) | |
3661 | (skip-chars-backward "\n") | |
3662 | (put-text-property (point-min) (point) 'original-date date))) | |
3663 | ||
23f87bed MB |
3664 | ;; (defun article-show-all () |
3665 | ;; "Show all hidden text in the article buffer." | |
3666 | ;; (interactive) | |
3667 | ;; (save-excursion | |
3668 | ;; (let ((inhibit-read-only t)) | |
3669 | ;; (gnus-article-unhide-text (point-min) (point-max))))) | |
3670 | ||
3671 | (defun article-remove-leading-whitespace () | |
3672 | "Remove excessive whitespace from all headers." | |
eec82323 LMI |
3673 | (interactive) |
3674 | (save-excursion | |
23f87bed MB |
3675 | (save-restriction |
3676 | (let ((inhibit-read-only t)) | |
3677 | (article-narrow-to-head) | |
3678 | (goto-char (point-min)) | |
3679 | (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t) | |
3680 | (delete-region (match-beginning 1) (match-end 1))))))) | |
eec82323 LMI |
3681 | |
3682 | (defun article-emphasize (&optional arg) | |
3683 | "Emphasize text according to `gnus-emphasis-alist'." | |
3684 | (interactive (gnus-article-hidden-arg)) | |
3685 | (unless (gnus-article-check-hidden-text 'emphasis arg) | |
3686 | (save-excursion | |
a1506d29 | 3687 | (let ((alist (or |
16409b0b | 3688 | (condition-case nil |
a1506d29 JB |
3689 | (with-current-buffer gnus-summary-buffer |
3690 | gnus-article-emphasis-alist) | |
16409b0b GM |
3691 | (error)) |
3692 | gnus-emphasis-alist)) | |
4e7d0221 | 3693 | (inhibit-read-only t) |
eec82323 LMI |
3694 | (props (append '(article-type emphasis) |
3695 | gnus-hidden-properties)) | |
3696 | regexp elem beg invisible visible face) | |
16409b0b | 3697 | (article-goto-body) |
eec82323 LMI |
3698 | (setq beg (point)) |
3699 | (while (setq elem (pop alist)) | |
3700 | (goto-char beg) | |
3701 | (setq regexp (car elem) | |
3702 | invisible (nth 1 elem) | |
3703 | visible (nth 2 elem) | |
3704 | face (nth 3 elem)) | |
3705 | (while (re-search-forward regexp nil t) | |
23f87bed MB |
3706 | (when (and (match-beginning visible) (match-beginning invisible)) |
3707 | (gnus-article-hide-text | |
3708 | (match-beginning invisible) (match-end invisible) props) | |
3709 | (gnus-article-unhide-text-type | |
3710 | (match-beginning visible) (match-end visible) 'emphasis) | |
3711 | (gnus-put-overlay-excluding-newlines | |
3712 | (match-beginning visible) (match-end visible) 'face face) | |
3713 | (gnus-add-wash-type 'emphasis) | |
3714 | (goto-char (match-end invisible))))))))) | |
eec82323 | 3715 | |
16409b0b GM |
3716 | (defun gnus-article-setup-highlight-words (&optional highlight-words) |
3717 | "Setup newsgroup emphasis alist." | |
3718 | (unless gnus-article-emphasis-alist | |
3719 | (let ((name (and gnus-newsgroup-name | |
3720 | (gnus-group-real-name gnus-newsgroup-name)))) | |
3721 | (make-local-variable 'gnus-article-emphasis-alist) | |
a1506d29 JB |
3722 | (setq gnus-article-emphasis-alist |
3723 | (nconc | |
16409b0b GM |
3724 | (let ((alist gnus-group-highlight-words-alist) elem highlight) |
3725 | (while (setq elem (pop alist)) | |
3726 | (when (and name (string-match (car elem) name)) | |
3727 | (setq alist nil | |
3728 | highlight (copy-sequence (cdr elem))))) | |
3729 | highlight) | |
3730 | (copy-sequence highlight-words) | |
3731 | (if gnus-newsgroup-name | |
a1506d29 | 3732 | (copy-sequence (gnus-group-find-parameter |
16409b0b GM |
3733 | gnus-newsgroup-name 'highlight-words t))) |
3734 | gnus-emphasis-alist))))) | |
3735 | ||
9efa445f DN |
3736 | (defvar gnus-summary-article-menu) |
3737 | (defvar gnus-summary-post-menu) | |
eec82323 LMI |
3738 | |
3739 | ;;; Saving functions. | |
3740 | ||
3741 | (defun gnus-article-save (save-buffer file &optional num) | |
3742 | "Save the currently selected article." | |
26c9afc3 MB |
3743 | (when (or (get gnus-default-article-saver :headers) |
3744 | (not gnus-save-all-headers)) | |
3745 | ;; Remove headers according to `gnus-saved-headers' or the value | |
3746 | ;; of the `:headers' property that the saver function might have. | |
eec82323 | 3747 | (let ((gnus-visible-headers |
26c9afc3 MB |
3748 | (or (symbol-value (get gnus-default-article-saver :headers)) |
3749 | gnus-saved-headers gnus-visible-headers)) | |
16c85f26 MB |
3750 | ;; Ignore group parameter. See `article-hide-headers'. |
3751 | (gnus-summary-buffer nil)) | |
80de1778 | 3752 | (with-current-buffer save-buffer |
6748645f | 3753 | (article-hide-headers 1 t)))) |
eec82323 LMI |
3754 | (save-window-excursion |
3755 | (if (not gnus-default-article-saver) | |
a8151ef7 | 3756 | (error "No default saver is defined") |
eec82323 | 3757 | ;; !!! Magic! The saving functions all save |
16409b0b | 3758 | ;; `gnus-save-article-buffer' (or so they think), but we |
eec82323 LMI |
3759 | ;; bind that variable to our save-buffer. |
3760 | (set-buffer gnus-article-buffer) | |
3761 | (let* ((gnus-save-article-buffer save-buffer) | |
3762 | (filename | |
3763 | (cond | |
3764 | ((not gnus-prompt-before-saving) 'default) | |
3765 | ((eq gnus-prompt-before-saving 'always) nil) | |
3766 | (t file))) | |
3767 | (gnus-number-of-articles-to-be-saved | |
3768 | (when (eq gnus-prompt-before-saving t) | |
3769 | num))) ; Magic | |
6748645f | 3770 | (set-buffer gnus-article-current-summary) |
eec82323 LMI |
3771 | (funcall gnus-default-article-saver filename))))) |
3772 | ||
3773 | (defun gnus-read-save-file-name (prompt &optional filename | |
26c9afc3 MB |
3774 | function group headers variable |
3775 | dir-var) | |
eec82323 LMI |
3776 | (let ((default-name |
3777 | (funcall function group headers (symbol-value variable))) | |
3778 | result) | |
4325195c | 3779 | (setq result |
a1506d29 | 3780 | (expand-file-name |
4325195c DL |
3781 | (cond |
3782 | ((eq filename 'default) | |
3783 | default-name) | |
3784 | ((eq filename t) | |
3785 | default-name) | |
3786 | (filename filename) | |
3787 | (t | |
26c9afc3 MB |
3788 | (when (symbol-value dir-var) |
3789 | (setq default-name (expand-file-name | |
3790 | (file-name-nondirectory default-name) | |
3791 | (symbol-value dir-var)))) | |
4325195c DL |
3792 | (let* ((split-name (gnus-get-split-value gnus-split-methods)) |
3793 | (prompt | |
3794 | (format prompt | |
3795 | (if (and gnus-number-of-articles-to-be-saved | |
3796 | (> gnus-number-of-articles-to-be-saved 1)) | |
3797 | (format "these %d articles" | |
3798 | gnus-number-of-articles-to-be-saved) | |
3799 | "this article"))) | |
3800 | (file | |
3801 | ;; Let the split methods have their say. | |
3802 | (cond | |
3803 | ;; No split name was found. | |
3804 | ((null split-name) | |
3805 | (read-file-name | |
3806 | (concat prompt " (default " | |
81df110a | 3807 | (file-name-nondirectory default-name) "): ") |
4325195c DL |
3808 | (file-name-directory default-name) |
3809 | default-name)) | |
3810 | ;; A single group name is returned. | |
3811 | ((stringp split-name) | |
3812 | (setq default-name | |
3813 | (funcall function split-name headers | |
3814 | (symbol-value variable))) | |
3815 | (read-file-name | |
3816 | (concat prompt " (default " | |
81df110a | 3817 | (file-name-nondirectory default-name) "): ") |
4325195c DL |
3818 | (file-name-directory default-name) |
3819 | default-name)) | |
3820 | ;; A single split name was found | |
3821 | ((= 1 (length split-name)) | |
3822 | (let* ((name (expand-file-name | |
23f87bed MB |
3823 | (car split-name) |
3824 | gnus-article-save-directory)) | |
4325195c DL |
3825 | (dir (cond ((file-directory-p name) |
3826 | (file-name-as-directory name)) | |
3827 | ((file-exists-p name) name) | |
3828 | (t gnus-article-save-directory)))) | |
3829 | (read-file-name | |
81df110a | 3830 | (concat prompt " (default " name "): ") |
4325195c DL |
3831 | dir name))) |
3832 | ;; A list of splits was found. | |
3833 | (t | |
3834 | (setq split-name (nreverse split-name)) | |
3835 | (let (result) | |
3836 | (let ((file-name-history | |
3837 | (nconc split-name file-name-history))) | |
3838 | (setq result | |
3839 | (expand-file-name | |
3840 | (read-file-name | |
81df110a | 3841 | (concat prompt " (`M-p' for defaults): ") |
4325195c DL |
3842 | gnus-article-save-directory |
3843 | (car split-name)) | |
3844 | gnus-article-save-directory))) | |
3845 | (car (push result file-name-history))))))) | |
3846 | ;; Create the directory. | |
3847 | (gnus-make-directory (file-name-directory file)) | |
23f87bed | 3848 | ;; If we have read a directory, we append the default file name. |
4325195c | 3849 | (when (file-directory-p file) |
23f87bed MB |
3850 | (setq file (expand-file-name (file-name-nondirectory |
3851 | default-name) | |
4325195c DL |
3852 | (file-name-as-directory file)))) |
3853 | ;; Possibly translate some characters. | |
3854 | (nnheader-translate-file-chars file)))))) | |
eec82323 | 3855 | (gnus-make-directory (file-name-directory result)) |
26c9afc3 MB |
3856 | (when variable |
3857 | (set variable result)) | |
3858 | (when dir-var | |
3859 | (set dir-var (file-name-directory result))) | |
3860 | result)) | |
eec82323 LMI |
3861 | |
3862 | (defun gnus-article-archive-name (group) | |
3863 | "Return the first instance of an \"Archive-name\" in the current buffer." | |
3864 | (let ((case-fold-search t)) | |
3865 | (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
3866 | (nnheader-concat gnus-article-save-directory | |
3867 | (match-string 1))))) | |
3868 | ||
3869 | (defun gnus-article-nndoc-name (group) | |
3870 | "If GROUP is an nndoc group, return the name of the parent group." | |
3871 | (when (eq (car (gnus-find-method-for-group group)) 'nndoc) | |
3872 | (gnus-group-get-parameter group 'save-article-group))) | |
3873 | ||
3874 | (defun gnus-summary-save-in-rmail (&optional filename) | |
3875 | "Append this article to Rmail file. | |
3876 | Optional argument FILENAME specifies file name. | |
3877 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 3878 | (setq filename (gnus-read-save-file-name |
81df110a | 3879 | "Save %s in rmail file" filename |
eec82323 LMI |
3880 | gnus-rmail-save-name gnus-newsgroup-name |
3881 | gnus-current-headers 'gnus-newsgroup-last-rmail)) | |
3882 | (gnus-eval-in-buffer-window gnus-save-article-buffer | |
3883 | (save-excursion | |
3884 | (save-restriction | |
3885 | (widen) | |
fef8d38e GM |
3886 | ;; Note that unlike gnus-summary-save-in-mail, there is no |
3887 | ;; check to see if filename is Babyl. Rmail in Emacs 23 does | |
3888 | ;; not use Babyl. | |
6748645f LMI |
3889 | (gnus-output-to-rmail filename)))) |
3890 | filename) | |
eec82323 LMI |
3891 | |
3892 | (defun gnus-summary-save-in-mail (&optional filename) | |
3893 | "Append this article to Unix mail file. | |
3894 | Optional argument FILENAME specifies file name. | |
3895 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 3896 | (setq filename (gnus-read-save-file-name |
81df110a | 3897 | "Save %s in Unix mail file" filename |
eec82323 LMI |
3898 | gnus-mail-save-name gnus-newsgroup-name |
3899 | gnus-current-headers 'gnus-newsgroup-last-mail)) | |
3900 | (gnus-eval-in-buffer-window gnus-save-article-buffer | |
3901 | (save-excursion | |
3902 | (save-restriction | |
3903 | (widen) | |
3904 | (if (and (file-readable-p filename) | |
23f87bed | 3905 | (file-regular-p filename) |
eec82323 | 3906 | (mail-file-babyl-p filename)) |
fef8d38e | 3907 | (gnus-output-to-rmail filename) |
6748645f LMI |
3908 | (gnus-output-to-mail filename))))) |
3909 | filename) | |
eec82323 | 3910 | |
26c9afc3 MB |
3911 | (put 'gnus-summary-save-in-file :decode t) |
3912 | (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers) | |
eec82323 LMI |
3913 | (defun gnus-summary-save-in-file (&optional filename overwrite) |
3914 | "Append this article to file. | |
3915 | Optional argument FILENAME specifies file name. | |
3916 | Directory to save to is default to `gnus-article-save-directory'." | |
eec82323 | 3917 | (setq filename (gnus-read-save-file-name |
81df110a | 3918 | "Save %s in file" filename |
eec82323 LMI |
3919 | gnus-file-save-name gnus-newsgroup-name |
3920 | gnus-current-headers 'gnus-newsgroup-last-file)) | |
3921 | (gnus-eval-in-buffer-window gnus-save-article-buffer | |
3922 | (save-excursion | |
3923 | (save-restriction | |
3924 | (widen) | |
3925 | (when (and overwrite | |
3926 | (file-exists-p filename)) | |
3927 | (delete-file filename)) | |
6748645f LMI |
3928 | (gnus-output-to-file filename)))) |
3929 | filename) | |
eec82323 | 3930 | |
26c9afc3 MB |
3931 | (put 'gnus-summary-write-to-file :decode t) |
3932 | (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file) | |
3933 | (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers) | |
eec82323 | 3934 | (defun gnus-summary-write-to-file (&optional filename) |
23f87bed | 3935 | "Write this article to a file, overwriting it if the file exists. |
eec82323 LMI |
3936 | Optional argument FILENAME specifies file name. |
3937 | The directory to save in defaults to `gnus-article-save-directory'." | |
26c9afc3 MB |
3938 | (setq filename (gnus-read-save-file-name |
3939 | "Save %s in file" filename | |
3940 | gnus-file-save-name gnus-newsgroup-name | |
3941 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) | |
3942 | (gnus-summary-save-in-file filename t)) | |
eec82323 | 3943 | |
26c9afc3 MB |
3944 | (put 'gnus-summary-save-body-in-file :decode t) |
3945 | (defun gnus-summary-save-body-in-file (&optional filename overwrite) | |
eec82323 LMI |
3946 | "Append this article body to a file. |
3947 | Optional argument FILENAME specifies file name. | |
3948 | The directory to save in defaults to `gnus-article-save-directory'." | |
eec82323 | 3949 | (setq filename (gnus-read-save-file-name |
81df110a | 3950 | "Save %s body in file" filename |
eec82323 LMI |
3951 | gnus-file-save-name gnus-newsgroup-name |
3952 | gnus-current-headers 'gnus-newsgroup-last-file)) | |
3953 | (gnus-eval-in-buffer-window gnus-save-article-buffer | |
3954 | (save-excursion | |
3955 | (save-restriction | |
3956 | (widen) | |
16409b0b | 3957 | (when (article-goto-body) |
eec82323 | 3958 | (narrow-to-region (point) (point-max))) |
26c9afc3 MB |
3959 | (when (and overwrite |
3960 | (file-exists-p filename)) | |
3961 | (delete-file filename)) | |
6748645f LMI |
3962 | (gnus-output-to-file filename)))) |
3963 | filename) | |
eec82323 | 3964 | |
26c9afc3 MB |
3965 | (put 'gnus-summary-write-body-to-file :decode t) |
3966 | (put 'gnus-summary-write-body-to-file | |
3967 | :function 'gnus-summary-save-body-in-file) | |
3968 | (defun gnus-summary-write-body-to-file (&optional filename) | |
3969 | "Write this article body to a file, overwriting it if the file exists. | |
3970 | Optional argument FILENAME specifies file name. | |
3971 | The directory to save in defaults to `gnus-article-save-directory'." | |
3972 | (setq filename (gnus-read-save-file-name | |
3973 | "Save %s body in file" filename | |
3974 | gnus-file-save-name gnus-newsgroup-name | |
3975 | gnus-current-headers nil 'gnus-newsgroup-last-directory)) | |
3976 | (gnus-summary-save-body-in-file filename t)) | |
3977 | ||
89167438 MB |
3978 | (put 'gnus-summary-save-in-pipe :decode t) |
3979 | (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers) | |
d62672f3 MB |
3980 | (defun gnus-summary-save-in-pipe (&optional command raw) |
3981 | "Pipe this article to subprocess COMMAND. | |
3982 | Valid values for COMMAND include: | |
3983 | a string | |
3984 | The executable command name and possibly arguments. | |
3985 | nil | |
3986 | You will be prompted for the command in the minibuffer. | |
3987 | the symbol `default' | |
3988 | It will be replaced with the command which the variable | |
3989 | `gnus-summary-pipe-output-default-command' holds or the command | |
3990 | last used for saving. | |
3991 | Non-nil value for RAW overrides `:decode' and `:headers' properties | |
3992 | and the raw article including all headers will be piped." | |
6ecfe5c2 MB |
3993 | (let ((article (gnus-summary-article-number)) |
3994 | (decode (unless raw | |
3995 | (get 'gnus-summary-save-in-pipe :decode))) | |
3996 | save-buffer default) | |
3997 | (if article | |
3998 | (if (vectorp (gnus-summary-article-header article)) | |
3999 | (save-current-buffer | |
4000 | (gnus-summary-select-article decode decode nil article) | |
4001 | (insert-buffer-substring | |
4002 | (prog1 | |
4003 | (if decode | |
4004 | gnus-article-buffer | |
4005 | gnus-original-article-buffer) | |
4006 | (setq save-buffer | |
4007 | (nnheader-set-temp-buffer " *Gnus Save*")))) | |
4008 | ;; Remove unwanted headers. | |
4009 | (when (and (not raw) | |
4010 | (or (get 'gnus-summary-save-in-pipe :headers) | |
4011 | (not gnus-save-all-headers))) | |
4012 | (let ((gnus-visible-headers | |
4013 | (or (symbol-value (get 'gnus-summary-save-in-pipe | |
4014 | :headers)) | |
4015 | gnus-saved-headers gnus-visible-headers)) | |
4016 | (gnus-summary-buffer nil)) | |
4017 | (article-hide-headers 1 t)))) | |
4018 | (error "%d is not a real article" article)) | |
4019 | (error "No article to pipe")) | |
4020 | (setq default (or gnus-summary-pipe-output-default-command | |
4021 | gnus-last-shell-command)) | |
89167438 MB |
4022 | (unless (stringp command) |
4023 | (setq command | |
4024 | (if (and (eq command 'default) default) | |
4025 | default | |
6ecfe5c2 MB |
4026 | (gnus-read-shell-command "Shell command on this article: " |
4027 | default)))) | |
89167438 MB |
4028 | (when (string-equal command "") |
4029 | (if default | |
4030 | (setq command default) | |
16c85f26 MB |
4031 | (error "A command is required"))) |
4032 | (gnus-eval-in-buffer-window save-buffer | |
4033 | (save-restriction | |
4034 | (widen) | |
4035 | (shell-command-on-region (point-min) (point-max) command nil))) | |
4036 | (gnus-kill-buffer save-buffer)) | |
89167438 | 4037 | (setq gnus-summary-pipe-output-default-command command)) |
eec82323 | 4038 | |
23f87bed MB |
4039 | (defun gnus-summary-pipe-to-muttprint (&optional command) |
4040 | "Pipe this article to muttprint." | |
16c85f26 MB |
4041 | (unless (stringp command) |
4042 | (setq command (read-string | |
4043 | "Print using command: " gnus-summary-muttprint-program | |
4044 | nil gnus-summary-muttprint-program))) | |
4045 | (let ((gnus-summary-pipe-output-default-command | |
4046 | gnus-summary-pipe-output-default-command)) | |
4047 | (gnus-summary-save-in-pipe command)) | |
4048 | (setq gnus-summary-muttprint-program command)) | |
23f87bed | 4049 | |
eec82323 LMI |
4050 | ;;; Article file names when saving. |
4051 | ||
4052 | (defun gnus-capitalize-newsgroup (newsgroup) | |
4053 | "Capitalize NEWSGROUP name." | |
4054 | (when (not (zerop (length newsgroup))) | |
4055 | (concat (char-to-string (upcase (aref newsgroup 0))) | |
4056 | (substring newsgroup 1)))) | |
4057 | ||
4058 | (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
4059 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4060 | If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num. | |
4061 | Otherwise, it is like ~/News/news/group/num." | |
4062 | (let ((default | |
4063 | (expand-file-name | |
4064 | (concat (if (gnus-use-long-file-name 'not-save) | |
4065 | (gnus-capitalize-newsgroup newsgroup) | |
4066 | (gnus-newsgroup-directory-form newsgroup)) | |
4067 | "/" (int-to-string (mail-header-number headers))) | |
4068 | gnus-article-save-directory))) | |
4069 | (if (and last-file | |
4070 | (string-equal (file-name-directory default) | |
4071 | (file-name-directory last-file)) | |
4072 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4073 | default | |
4074 | (or last-file default)))) | |
4075 | ||
4076 | (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
4077 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4078 | If variable `gnus-use-long-file-name' is non-nil, it is | |
2ff9f5b4 | 4079 | ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." |
eec82323 LMI |
4080 | (let ((default |
4081 | (expand-file-name | |
4082 | (concat (if (gnus-use-long-file-name 'not-save) | |
4083 | newsgroup | |
4084 | (gnus-newsgroup-directory-form newsgroup)) | |
4085 | "/" (int-to-string (mail-header-number headers))) | |
4086 | gnus-article-save-directory))) | |
4087 | (if (and last-file | |
4088 | (string-equal (file-name-directory default) | |
4089 | (file-name-directory last-file)) | |
4090 | (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
4091 | default | |
4092 | (or last-file default)))) | |
4093 | ||
eec82323 LMI |
4094 | (defun gnus-plain-save-name (newsgroup headers &optional last-file) |
4095 | "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
4096 | If variable `gnus-use-long-file-name' is non-nil, it is | |
4097 | ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
4098 | (or last-file | |
4099 | (expand-file-name | |
4100 | (if (gnus-use-long-file-name 'not-save) | |
4101 | newsgroup | |
23f87bed MB |
4102 | (file-relative-name |
4103 | (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)) | |
4104 | default-directory)) | |
eec82323 LMI |
4105 | gnus-article-save-directory))) |
4106 | ||
23f87bed MB |
4107 | (defun gnus-sender-save-name (newsgroup headers &optional last-file) |
4108 | "Generate file name from sender." | |
4109 | (let ((from (mail-header-from headers))) | |
4110 | (expand-file-name | |
4111 | (if (and from (string-match "\\([^ <]+\\)@" from)) | |
4112 | (match-string 1 from) | |
4113 | "nobody") | |
4114 | gnus-article-save-directory))) | |
4115 | ||
4116 | (defun article-verify-x-pgp-sig () | |
4117 | "Verify X-PGP-Sig." | |
bbbe940b | 4118 | ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT> |
23f87bed MB |
4119 | (interactive) |
4120 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
4121 | (let ((sig (with-current-buffer gnus-original-article-buffer | |
4122 | (gnus-fetch-field "X-PGP-Sig"))) | |
4123 | items info headers) | |
4124 | (when (and sig | |
4125 | mml2015-use | |
4126 | (mml2015-clear-verify-function)) | |
4127 | (with-temp-buffer | |
4128 | (insert-buffer-substring gnus-original-article-buffer) | |
4129 | (setq items (split-string sig)) | |
4130 | (message-narrow-to-head) | |
4131 | (let ((inhibit-point-motion-hooks t) | |
4132 | (case-fold-search t)) | |
4133 | ;; Don't verify multiple headers. | |
4134 | (setq headers (mapconcat (lambda (header) | |
4135 | (concat header ": " | |
4136 | (mail-fetch-field header) | |
4137 | "\n")) | |
4138 | (split-string (nth 1 items) ",") ""))) | |
4139 | (delete-region (point-min) (point-max)) | |
4140 | (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n") | |
4141 | (insert "X-Signed-Headers: " (nth 1 items) "\n") | |
4142 | (insert headers) | |
4143 | (widen) | |
4144 | (forward-line) | |
4145 | (while (not (eobp)) | |
4146 | (if (looking-at "^-") | |
4147 | (insert "- ")) | |
4148 | (forward-line)) | |
4149 | (insert "\n-----BEGIN PGP SIGNATURE-----\n") | |
4150 | (insert "Version: " (car items) "\n\n") | |
4151 | (insert (mapconcat 'identity (cddr items) "\n")) | |
4152 | (insert "\n-----END PGP SIGNATURE-----\n") | |
4153 | (let ((mm-security-handle (list (format "multipart/signed")))) | |
4154 | (mml2015-clean-buffer) | |
4155 | (let ((coding-system-for-write (or gnus-newsgroup-charset | |
4156 | 'iso-8859-1))) | |
4157 | (funcall (mml2015-clear-verify-function))) | |
4158 | (setq info | |
4159 | (or (mm-handle-multipart-ctl-parameter | |
4160 | mm-security-handle 'gnus-details) | |
4161 | (mm-handle-multipart-ctl-parameter | |
4162 | mm-security-handle 'gnus-info))))) | |
4163 | (when info | |
4164 | (let ((inhibit-read-only t) bface eface) | |
4165 | (save-restriction | |
4166 | (message-narrow-to-head) | |
4167 | (goto-char (point-max)) | |
4168 | (forward-line -1) | |
01c52d31 MB |
4169 | (setq bface (get-text-property (point-at-bol) 'face) |
4170 | eface (get-text-property (1- (point-at-eol)) 'face)) | |
23f87bed MB |
4171 | (message-remove-header "X-Gnus-PGP-Verify") |
4172 | (if (re-search-forward "^X-PGP-Sig:" nil t) | |
4173 | (forward-line) | |
4174 | (goto-char (point-max))) | |
4175 | (narrow-to-region (point) (point)) | |
4176 | (insert "X-Gnus-PGP-Verify: " info "\n") | |
4177 | (goto-char (point-min)) | |
4178 | (forward-line) | |
4179 | (while (not (eobp)) | |
4180 | (if (not (looking-at "^[ \t]")) | |
4181 | (insert " ")) | |
4182 | (forward-line)) | |
4183 | ;; Do highlighting. | |
4184 | (goto-char (point-min)) | |
4185 | (when (looking-at "\\([^:]+\\): *") | |
4186 | (put-text-property (match-beginning 1) (1+ (match-end 1)) | |
4187 | 'face bface) | |
4188 | (put-text-property (match-end 0) (point-max) | |
4189 | 'face eface))))))))) | |
4190 | ||
4191 | (defun article-verify-cancel-lock () | |
4192 | "Verify Cancel-Lock header." | |
4193 | (interactive) | |
4194 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
4195 | (canlock-verify gnus-original-article-buffer))) | |
4196 | ||
eec82323 | 4197 | (eval-and-compile |
01c52d31 | 4198 | (mapc |
eec82323 LMI |
4199 | (lambda (func) |
4200 | (let (afunc gfunc) | |
4201 | (if (consp func) | |
4202 | (setq afunc (car func) | |
4203 | gfunc (cdr func)) | |
4204 | (setq afunc func | |
4205 | gfunc (intern (format "gnus-%s" func)))) | |
16409b0b | 4206 | (defalias gfunc |
23f87bed | 4207 | (when (fboundp afunc) |
16409b0b GM |
4208 | `(lambda (&optional interactive &rest args) |
4209 | ,(documentation afunc t) | |
4210 | (interactive (list t)) | |
80de1778 | 4211 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
4212 | (if interactive |
4213 | (call-interactively ',afunc) | |
4214 | (apply ',afunc args)))))))) | |
eec82323 | 4215 | '(article-hide-headers |
23f87bed MB |
4216 | article-verify-x-pgp-sig |
4217 | article-verify-cancel-lock | |
eec82323 LMI |
4218 | article-hide-boring-headers |
4219 | article-treat-overstrike | |
01c52d31 | 4220 | article-treat-ansi-sequences |
16409b0b GM |
4221 | article-fill-long-lines |
4222 | article-capitalize-sentences | |
eec82323 | 4223 | article-remove-cr |
23f87bed | 4224 | article-remove-leading-whitespace |
eec82323 | 4225 | article-display-x-face |
23f87bed | 4226 | article-display-face |
eec82323 | 4227 | article-de-quoted-unreadable |
16409b0b GM |
4228 | article-de-base64-unreadable |
4229 | article-decode-HZ | |
4230 | article-wash-html | |
23f87bed | 4231 | article-unsplit-urls |
16409b0b | 4232 | article-hide-list-identifiers |
16409b0b GM |
4233 | article-strip-banner |
4234 | article-babel | |
eec82323 LMI |
4235 | article-hide-pem |
4236 | article-hide-signature | |
16409b0b | 4237 | article-strip-headers-in-body |
eec82323 LMI |
4238 | article-remove-trailing-blank-lines |
4239 | article-strip-leading-blank-lines | |
4240 | article-strip-multiple-blank-lines | |
4241 | article-strip-leading-space | |
16409b0b | 4242 | article-strip-trailing-space |
eec82323 | 4243 | article-strip-blank-lines |
6748645f | 4244 | article-strip-all-blank-lines |
eec82323 | 4245 | article-date-local |
23f87bed | 4246 | article-date-english |
6748645f | 4247 | article-date-iso8601 |
eec82323 LMI |
4248 | article-date-original |
4249 | article-date-ut | |
16409b0b GM |
4250 | article-decode-mime-words |
4251 | article-decode-charset | |
4252 | article-decode-encoded-words | |
eec82323 LMI |
4253 | article-date-user |
4254 | article-date-lapsed | |
4255 | article-emphasize | |
6748645f | 4256 | article-treat-dumbquotes |
16409b0b | 4257 | article-normalize-headers |
01c52d31 | 4258 | ;;(article-show-all . gnus-article-show-all-headers) |
23f87bed | 4259 | ))) |
eec82323 LMI |
4260 | \f |
4261 | ;;; | |
4262 | ;;; Gnus article mode | |
4263 | ;;; | |
4264 | ||
4265 | (put 'gnus-article-mode 'mode-class 'special) | |
4266 | ||
16409b0b GM |
4267 | (set-keymap-parent gnus-article-mode-map widget-keymap) |
4268 | ||
a8151ef7 LMI |
4269 | (gnus-define-keys gnus-article-mode-map |
4270 | " " gnus-article-goto-next-page | |
4271 | "\177" gnus-article-goto-prev-page | |
4272 | [delete] gnus-article-goto-prev-page | |
16409b0b | 4273 | [backspace] gnus-article-goto-prev-page |
a8151ef7 LMI |
4274 | "\C-c^" gnus-article-refer-article |
4275 | "h" gnus-article-show-summary | |
4276 | "s" gnus-article-show-summary | |
4277 | "\C-c\C-m" gnus-article-mail | |
4278 | "?" gnus-article-describe-briefly | |
a8151ef7 LMI |
4279 | "<" beginning-of-buffer |
4280 | ">" end-of-buffer | |
4281 | "\C-c\C-i" gnus-info-find-node | |
4282 | "\C-c\C-b" gnus-bug | |
23f87bed MB |
4283 | "R" gnus-article-reply-with-original |
4284 | "F" gnus-article-followup-with-original | |
520aa572 SZ |
4285 | "\C-hk" gnus-article-describe-key |
4286 | "\C-hc" gnus-article-describe-key-briefly | |
0b6799c3 | 4287 | "\C-hb" gnus-article-describe-bindings |
a8151ef7 | 4288 | |
6ab2c7a8 | 4289 | "e" gnus-article-read-summary-keys |
a8151ef7 LMI |
4290 | "\C-d" gnus-article-read-summary-keys |
4291 | "\M-*" gnus-article-read-summary-keys | |
4292 | "\M-#" gnus-article-read-summary-keys | |
4293 | "\M-^" gnus-article-read-summary-keys | |
4294 | "\M-g" gnus-article-read-summary-keys) | |
4295 | ||
4296 | (substitute-key-definition | |
4297 | 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map) | |
eec82323 | 4298 | |
95838435 MB |
4299 | (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map) |
4300 | "W" gnus-article-wide-reply-with-original) | |
4301 | (if (featurep 'xemacs) | |
4302 | (set-keymap-default-binding gnus-article-send-map | |
4303 | 'gnus-article-read-summary-send-keys) | |
4304 | (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys)) | |
4305 | ||
eec82323 | 4306 | (defun gnus-article-make-menu-bar () |
23f87bed MB |
4307 | (unless (boundp 'gnus-article-commands-menu) |
4308 | (gnus-summary-make-menu-bar)) | |
eec82323 LMI |
4309 | (gnus-turn-off-edit-menu 'article) |
4310 | (unless (boundp 'gnus-article-article-menu) | |
4311 | (easy-menu-define | |
4312 | gnus-article-article-menu gnus-article-mode-map "" | |
4313 | '("Article" | |
4314 | ["Scroll forwards" gnus-article-goto-next-page t] | |
4315 | ["Scroll backwards" gnus-article-goto-prev-page t] | |
4316 | ["Show summary" gnus-article-show-summary t] | |
4317 | ["Fetch Message-ID at point" gnus-article-refer-article t] | |
6748645f LMI |
4318 | ["Mail to address at point" gnus-article-mail t] |
4319 | ["Send a bug report" gnus-bug t])) | |
eec82323 LMI |
4320 | |
4321 | (easy-menu-define | |
4322 | gnus-article-treatment-menu gnus-article-mode-map "" | |
bb367cba | 4323 | ;; Fixme: this should use :active (and maybe :visible). |
eec82323 LMI |
4324 | '("Treatment" |
4325 | ["Hide headers" gnus-article-hide-headers t] | |
4326 | ["Hide signature" gnus-article-hide-signature t] | |
4327 | ["Hide citation" gnus-article-hide-citation t] | |
4328 | ["Treat overstrike" gnus-article-treat-overstrike t] | |
01c52d31 | 4329 | ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t] |
eec82323 | 4330 | ["Remove carriage return" gnus-article-remove-cr t] |
23f87bed | 4331 | ["Remove leading whitespace" gnus-article-remove-leading-whitespace t] |
16409b0b GM |
4332 | ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t] |
4333 | ["Remove base64" gnus-article-de-base64-unreadable t] | |
4334 | ["Treat html" gnus-article-wash-html t] | |
23f87bed | 4335 | ["Remove newlines from within URLs" gnus-article-unsplit-urls t] |
16409b0b | 4336 | ["Decode HZ" gnus-article-decode-HZ t])) |
eec82323 | 4337 | |
6748645f | 4338 | ;; Note "Commands" menu is defined in gnus-sum.el for consistency |
eec82323 | 4339 | |
23f87bed | 4340 | ;; Note "Post" menu is defined in gnus-sum.el for consistency |
eec82323 | 4341 | |
6748645f | 4342 | (gnus-run-hooks 'gnus-article-menu-hook))) |
eec82323 LMI |
4343 | |
4344 | (defun gnus-article-mode () | |
4345 | "Major mode for displaying an article. | |
4346 | ||
4347 | All normal editing commands are switched off. | |
4348 | ||
4349 | The following commands are available in addition to all summary mode | |
4350 | commands: | |
4351 | \\<gnus-article-mode-map> | |
4352 | \\[gnus-article-next-page]\t Scroll the article one page forwards | |
4353 | \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
4354 | \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
4355 | \\[gnus-article-show-summary]\t Display the summary buffer | |
4356 | \\[gnus-article-mail]\t Send a reply to the address near point | |
4357 | \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
4358 | \\[gnus-info-find-node]\t Go to the Gnus info node" | |
4359 | (interactive) | |
0eb586fc | 4360 | (kill-all-local-variables) |
eec82323 LMI |
4361 | (gnus-simplify-mode-line) |
4362 | (setq mode-name "Article") | |
4363 | (setq major-mode 'gnus-article-mode) | |
4364 | (make-local-variable 'minor-mode-alist) | |
eec82323 | 4365 | (use-local-map gnus-article-mode-map) |
1653df0f | 4366 | (when (gnus-visual-p 'article-menu 'menu) |
23f87bed MB |
4367 | (gnus-article-make-menu-bar) |
4368 | (when gnus-summary-tool-bar-map | |
4369 | (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map))) | |
eec82323 LMI |
4370 | (gnus-update-format-specifications nil 'article-mode) |
4371 | (set (make-local-variable 'page-delimiter) gnus-page-delimiter) | |
23f87bed | 4372 | (set (make-local-variable 'gnus-page-broken) nil) |
6748645f LMI |
4373 | (make-local-variable 'gnus-button-marker-list) |
4374 | (make-local-variable 'gnus-article-current-summary) | |
16409b0b GM |
4375 | (make-local-variable 'gnus-article-mime-handles) |
4376 | (make-local-variable 'gnus-article-decoded-p) | |
4377 | (make-local-variable 'gnus-article-mime-handle-alist) | |
4378 | (make-local-variable 'gnus-article-wash-types) | |
23f87bed MB |
4379 | (make-local-variable 'gnus-article-image-alist) |
4380 | (make-local-variable 'gnus-article-charset) | |
4381 | (make-local-variable 'gnus-article-ignored-charsets) | |
524705ae MB |
4382 | ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space' |
4383 | ;; face. | |
fc1c32c1 | 4384 | (set (make-local-variable 'nobreak-char-display) nil) |
e4a89ccf | 4385 | (setq cursor-in-non-selected-windows nil) |
01c52d31 | 4386 | (setq truncate-lines gnus-article-truncate-lines) |
eec82323 | 4387 | (gnus-set-default-directory) |
16409b0b | 4388 | (buffer-disable-undo) |
01c52d31 MB |
4389 | (setq buffer-read-only t |
4390 | show-trailing-whitespace nil) | |
eec82323 | 4391 | (set-syntax-table gnus-article-mode-syntax-table) |
16409b0b | 4392 | (mm-enable-multibyte) |
cfcd5c91 | 4393 | (gnus-run-mode-hooks 'gnus-article-mode-hook)) |
eec82323 | 4394 | |
676c1893 | 4395 | (defvar gnus-button-marker-list nil |
01c52d31 MB |
4396 | "Regexp matching any of the regexps from `gnus-button-alist'. |
4397 | Internal variable.") | |
676c1893 | 4398 | |
eec82323 LMI |
4399 | (defun gnus-article-setup-buffer () |
4400 | "Initialize the article buffer." | |
4401 | (let* ((name (if gnus-single-article-buffer "*Article*" | |
4402 | (concat "*Article " gnus-newsgroup-name "*"))) | |
4403 | (original | |
4404 | (progn (string-match "\\*Article" name) | |
4405 | (concat " *Original Article" | |
4406 | (substring name (match-end 0)))))) | |
4407 | (setq gnus-article-buffer name) | |
4408 | (setq gnus-original-article-buffer original) | |
16409b0b | 4409 | (setq gnus-article-mime-handle-alist nil) |
01c52d31 MB |
4410 | (with-current-buffer gnus-summary-buffer |
4411 | ;; This might be a variable local to the summary buffer. | |
4412 | (unless gnus-single-article-buffer | |
eec82323 LMI |
4413 | (setq gnus-article-buffer name) |
4414 | (setq gnus-original-article-buffer original) | |
4415 | (gnus-set-global-variables))) | |
16409b0b | 4416 | (gnus-article-setup-highlight-words) |
eec82323 | 4417 | ;; Init original article buffer. |
80de1778 | 4418 | (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer) |
16409b0b | 4419 | (mm-enable-multibyte) |
eec82323 | 4420 | (setq major-mode 'gnus-original-article-mode) |
eec82323 | 4421 | (make-local-variable 'gnus-original-article)) |
aba1948a MB |
4422 | (if (and (get-buffer name) |
4423 | (with-current-buffer name | |
4424 | (if gnus-article-edit-mode | |
4425 | (if (y-or-n-p "Article mode edit in progress; discard? ") | |
4426 | (progn | |
4427 | (set-buffer-modified-p nil) | |
4428 | (gnus-kill-buffer name) | |
4429 | (message "") | |
4430 | nil) | |
4431 | (error "Action aborted")) | |
4432 | t))) | |
80de1778 | 4433 | (with-current-buffer name |
23f87bed | 4434 | (set (make-local-variable 'gnus-article-edit-mode) nil) |
16409b0b GM |
4435 | (when gnus-article-mime-handles |
4436 | (mm-destroy-parts gnus-article-mime-handles) | |
4437 | (setq gnus-article-mime-handles nil)) | |
4438 | ;; Set it to nil in article-buffer! | |
a1506d29 | 4439 | (setq gnus-article-mime-handle-alist nil) |
16409b0b | 4440 | (buffer-disable-undo) |
eec82323 | 4441 | (setq buffer-read-only t) |
23f87bed MB |
4442 | ;; This list just keeps growing if we don't reset it. |
4443 | (setq gnus-button-marker-list nil) | |
eec82323 LMI |
4444 | (unless (eq major-mode 'gnus-article-mode) |
4445 | (gnus-article-mode)) | |
4446 | (current-buffer)) | |
80de1778 | 4447 | (with-current-buffer (gnus-get-buffer-create name) |
eec82323 LMI |
4448 | (gnus-article-mode) |
4449 | (make-local-variable 'gnus-summary-buffer) | |
01c52d31 MB |
4450 | (setq gnus-summary-buffer |
4451 | (gnus-summary-buffer-name gnus-newsgroup-name)) | |
16409b0b | 4452 | (gnus-summary-set-local-parameters gnus-newsgroup-name) |
eec82323 LMI |
4453 | (current-buffer))))) |
4454 | ||
4455 | ;; Set article window start at LINE, where LINE is the number of lines | |
4456 | ;; from the head of the article. | |
4457 | (defun gnus-article-set-window-start (&optional line) | |
01c52d31 MB |
4458 | (let ((article-window (gnus-get-buffer-window gnus-article-buffer t))) |
4459 | (when article-window | |
4460 | (set-window-start | |
4461 | article-window | |
80de1778 | 4462 | (with-current-buffer gnus-article-buffer |
01c52d31 MB |
4463 | (goto-char (point-min)) |
4464 | (if (not line) | |
4465 | (point-min) | |
4466 | (gnus-message 6 "Moved to bookmark") | |
4467 | (search-forward "\n\n" nil t) | |
4468 | (forward-line line) | |
4469 | (point))))))) | |
eec82323 LMI |
4470 | |
4471 | (defun gnus-article-prepare (article &optional all-headers header) | |
4472 | "Prepare ARTICLE in article mode buffer. | |
4473 | ARTICLE should either be an article number or a Message-ID. | |
4474 | If ARTICLE is an id, HEADER should be the article headers. | |
4475 | If ALL-HEADERS is non-nil, no headers are hidden." | |
4476 | (save-excursion | |
4477 | ;; Make sure we start in a summary buffer. | |
4478 | (unless (eq major-mode 'gnus-summary-mode) | |
4479 | (set-buffer gnus-summary-buffer)) | |
4480 | (setq gnus-summary-buffer (current-buffer)) | |
eec82323 LMI |
4481 | (let* ((gnus-article (if header (mail-header-number header) article)) |
4482 | (summary-buffer (current-buffer)) | |
6748645f | 4483 | (gnus-tmp-internal-hook gnus-article-internal-prepare-hook) |
eec82323 LMI |
4484 | (group gnus-newsgroup-name) |
4485 | result) | |
4486 | (save-excursion | |
4487 | (gnus-article-setup-buffer) | |
4488 | (set-buffer gnus-article-buffer) | |
4489 | ;; Deactivate active regions. | |
4490 | (when (and (boundp 'transient-mark-mode) | |
4491 | transient-mark-mode) | |
4492 | (setq mark-active nil)) | |
4e7d0221 | 4493 | (if (not (setq result (let ((inhibit-read-only t)) |
eec82323 LMI |
4494 | (gnus-request-article-this-buffer |
4495 | article group)))) | |
4496 | ;; There is no such article. | |
4497 | (save-excursion | |
4498 | (when (and (numberp article) | |
4499 | (not (memq article gnus-newsgroup-sparse))) | |
4500 | (setq gnus-article-current | |
4501 | (cons gnus-newsgroup-name article)) | |
4502 | (set-buffer gnus-summary-buffer) | |
4503 | (setq gnus-current-article article) | |
23f87bed MB |
4504 | (if (and (memq article gnus-newsgroup-undownloaded) |
4505 | (not (gnus-online (gnus-find-method-for-group | |
4506 | gnus-newsgroup-name)))) | |
6748645f LMI |
4507 | (progn |
4508 | (gnus-summary-set-agent-mark article) | |
4509 | (message "Message marked for downloading")) | |
4510 | (gnus-summary-mark-article article gnus-canceled-mark) | |
4511 | (unless (memq article gnus-newsgroup-sparse) | |
16409b0b | 4512 | (gnus-error 1 "No such article (may have expired or been canceled)"))))) |
6748645f LMI |
4513 | (if (or (eq result 'pseudo) |
4514 | (eq result 'nneething)) | |
eec82323 | 4515 | (progn |
80de1778 | 4516 | (with-current-buffer summary-buffer |
6748645f | 4517 | (push article gnus-newsgroup-history) |
eec82323 | 4518 | (setq gnus-last-article gnus-current-article |
eec82323 LMI |
4519 | gnus-current-article 0 |
4520 | gnus-current-headers nil | |
4521 | gnus-article-current nil) | |
4522 | (if (eq result 'nneething) | |
4523 | (gnus-configure-windows 'summary) | |
4524 | (gnus-configure-windows 'article)) | |
4525 | (gnus-set-global-variables)) | |
16409b0b GM |
4526 | (let ((gnus-article-mime-handle-alist-1 |
4527 | gnus-article-mime-handle-alist)) | |
4528 | (gnus-set-mode-line 'article))) | |
eec82323 LMI |
4529 | ;; The result from the `request' was an actual article - |
4530 | ;; or at least some text that is now displayed in the | |
4531 | ;; article buffer. | |
4532 | (when (and (numberp article) | |
4533 | (not (eq article gnus-current-article))) | |
4534 | ;; Seems like a new article has been selected. | |
4535 | ;; `gnus-current-article' must be an article number. | |
80de1778 | 4536 | (with-current-buffer summary-buffer |
6748645f | 4537 | (push article gnus-newsgroup-history) |
eec82323 | 4538 | (setq gnus-last-article gnus-current-article |
eec82323 LMI |
4539 | gnus-current-article article |
4540 | gnus-current-headers | |
4541 | (gnus-summary-article-header gnus-current-article) | |
4542 | gnus-article-current | |
4543 | (cons gnus-newsgroup-name gnus-current-article)) | |
4544 | (unless (vectorp gnus-current-headers) | |
4545 | (setq gnus-current-headers nil)) | |
6748645f LMI |
4546 | (gnus-summary-goto-subject gnus-current-article) |
4547 | (when (gnus-summary-show-thread) | |
4548 | ;; If the summary buffer really was folded, the | |
4549 | ;; previous goto may not actually have gone to | |
4550 | ;; the right article, but the thread root instead. | |
4551 | ;; So we go again. | |
4552 | (gnus-summary-goto-subject gnus-current-article)) | |
4553 | (gnus-run-hooks 'gnus-mark-article-hook) | |
eec82323 LMI |
4554 | (gnus-set-mode-line 'summary) |
4555 | (when (gnus-visual-p 'article-highlight 'highlight) | |
6748645f | 4556 | (gnus-run-hooks 'gnus-visual-mark-article-hook)) |
eec82323 | 4557 | ;; Set the global newsgroup variables here. |
eec82323 LMI |
4558 | (gnus-set-global-variables) |
4559 | (setq gnus-have-all-headers | |
6748645f | 4560 | (or all-headers gnus-show-all-headers)))) |
e0bad764 DL |
4561 | (save-excursion |
4562 | (gnus-configure-windows 'article)) | |
eec82323 LMI |
4563 | (when (or (numberp article) |
4564 | (stringp article)) | |
16409b0b | 4565 | (gnus-article-prepare-display) |
eec82323 LMI |
4566 | ;; Do page break. |
4567 | (goto-char (point-min)) | |
23f87bed MB |
4568 | (when gnus-break-pages |
4569 | (gnus-narrow-to-page))) | |
16409b0b GM |
4570 | (let ((gnus-article-mime-handle-alist-1 |
4571 | gnus-article-mime-handle-alist)) | |
4572 | (gnus-set-mode-line 'article)) | |
4573 | (article-goto-body) | |
23f87bed MB |
4574 | (unless (bobp) |
4575 | (forward-line -1)) | |
6748645f | 4576 | (set-window-point (get-buffer-window (current-buffer)) (point)) |
16409b0b | 4577 | (gnus-configure-windows 'article) |
eec82323 LMI |
4578 | t)))))) |
4579 | ||
16409b0b GM |
4580 | ;;;###autoload |
4581 | (defun gnus-article-prepare-display () | |
4582 | "Make the current buffer look like a nice article." | |
4583 | ;; Hooks for getting information from the article. | |
4584 | ;; This hook must be called before being narrowed. | |
4585 | (let ((gnus-article-buffer (current-buffer)) | |
23f87bed MB |
4586 | buffer-read-only |
4587 | (inhibit-read-only t)) | |
16409b0b GM |
4588 | (unless (eq major-mode 'gnus-article-mode) |
4589 | (gnus-article-mode)) | |
4590 | (setq buffer-read-only nil | |
23f87bed MB |
4591 | gnus-article-wash-types nil |
4592 | gnus-article-image-alist nil) | |
16409b0b GM |
4593 | (gnus-run-hooks 'gnus-tmp-internal-hook) |
4594 | (when gnus-display-mime-function | |
4595 | (funcall gnus-display-mime-function)) | |
4596 | (gnus-run-hooks 'gnus-article-prepare-hook))) | |
4597 | ||
01c52d31 MB |
4598 | ;;; |
4599 | ;;; Gnus Sticky Article Mode | |
4600 | ;;; | |
4601 | ||
4602 | (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle" | |
4603 | "Mode for sticky articles." | |
4604 | ;; Release bindings that won't work. | |
4605 | (substitute-key-definition 'gnus-article-read-summary-keys 'undefined | |
4606 | gnus-sticky-article-mode-map) | |
4607 | (substitute-key-definition 'gnus-article-refer-article 'undefined | |
4608 | gnus-sticky-article-mode-map) | |
4609 | (dolist (k '("e" "h" "s" "F" "R")) | |
4610 | (define-key gnus-sticky-article-mode-map k nil)) | |
4611 | (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer) | |
4612 | (define-key gnus-sticky-article-mode-map "q" 'bury-buffer) | |
4613 | (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly) | |
4614 | (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key)) | |
4615 | ||
4616 | (defun gnus-sticky-article (arg) | |
4617 | "Make the current article sticky. | |
4618 | If a prefix ARG is given, ask for a name for this sticky article buffer." | |
4619 | (interactive "P") | |
4620 | (gnus-summary-show-thread) | |
4621 | (gnus-summary-select-article nil nil 'pseudo) | |
4622 | (let (new-art-buf-name) | |
4623 | (gnus-eval-in-buffer-window gnus-article-buffer | |
4624 | (setq new-art-buf-name | |
4625 | (concat | |
4626 | "*Sticky Article: " | |
4627 | (if arg | |
4628 | (read-from-minibuffer "Sticky article buffer name: ") | |
4629 | (gnus-with-article-headers | |
4630 | (gnus-article-goto-header "subject") | |
4631 | (setq new-art-buf-name | |
4632 | (buffer-substring-no-properties | |
4633 | (line-beginning-position) (line-end-position))) | |
4634 | (goto-char (point-min)) | |
4635 | (gnus-article-goto-header "from") | |
4636 | (setq new-art-buf-name | |
4637 | (concat | |
4638 | new-art-buf-name ", " | |
4639 | (buffer-substring-no-properties | |
4640 | (line-beginning-position) (line-end-position)))) | |
4641 | (goto-char (point-min)) | |
4642 | (gnus-article-goto-header "date") | |
4643 | (setq new-art-buf-name | |
4644 | (concat | |
4645 | new-art-buf-name ", " | |
4646 | (buffer-substring-no-properties | |
4647 | (line-beginning-position) (line-end-position)))))) | |
4648 | "*")) | |
4649 | (if (and (gnus-buffer-live-p new-art-buf-name) | |
4650 | (with-current-buffer new-art-buf-name | |
4651 | (eq major-mode 'gnus-sticky-article-mode))) | |
4652 | (switch-to-buffer new-art-buf-name) | |
4653 | (setq new-art-buf-name (rename-buffer new-art-buf-name t))) | |
4654 | (gnus-sticky-article-mode)) | |
4655 | (setq gnus-article-buffer new-art-buf-name)) | |
4656 | (gnus-summary-recenter) | |
4657 | (gnus-summary-position-point)) | |
4658 | ||
4659 | (defun gnus-kill-sticky-article-buffer (&optional buffer) | |
4660 | "Kill the given sticky article BUFFER. | |
4661 | If none is given, assume the current buffer and kill it if it has | |
4662 | `gnus-sticky-article-mode'." | |
4663 | (interactive) | |
4664 | (unless buffer | |
4665 | (setq buffer (current-buffer))) | |
4666 | (with-current-buffer buffer | |
4667 | (when (eq major-mode 'gnus-sticky-article-mode) | |
4668 | (gnus-kill-buffer buffer)))) | |
4669 | ||
4670 | (defun gnus-kill-sticky-article-buffers (arg) | |
4671 | "Kill all sticky article buffers. | |
4672 | If a prefix ARG is given, ask for confirmation." | |
4673 | (interactive "P") | |
4674 | (dolist (buf (gnus-buffers)) | |
4675 | (with-current-buffer buf | |
4676 | (when (eq major-mode 'gnus-sticky-article-mode) | |
4677 | (if (not arg) | |
4678 | (gnus-kill-buffer buf) | |
4679 | (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? ")) | |
4680 | (gnus-kill-buffer buf))))))) | |
4681 | ||
16409b0b GM |
4682 | ;;; |
4683 | ;;; Gnus MIME viewing functions | |
4684 | ;;; | |
4685 | ||
4686 | (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n" | |
23f87bed MB |
4687 | "Format of the MIME buttons. |
4688 | ||
4689 | Valid specifiers include: | |
16409b0b GM |
4690 | %t The MIME type |
4691 | %T MIME type, along with additional info | |
4692 | %n The `name' parameter | |
4693 | %d The description, if any | |
4694 | %l The length of the encoded part | |
4695 | %p The part identifier number | |
23f87bed MB |
4696 | %e Dots if the part isn't displayed |
4697 | ||
4698 | General format specifiers can also be used. See Info node | |
4699 | `(gnus)Formatting Variables'.") | |
16409b0b GM |
4700 | |
4701 | (defvar gnus-mime-button-line-format-alist | |
4702 | '((?t gnus-tmp-type ?s) | |
4703 | (?T gnus-tmp-type-long ?s) | |
4704 | (?n gnus-tmp-name ?s) | |
4705 | (?d gnus-tmp-description ?s) | |
4706 | (?p gnus-tmp-id ?s) | |
4707 | (?l gnus-tmp-length ?d) | |
4708 | (?e gnus-tmp-dots ?s))) | |
4709 | ||
4710 | (defvar gnus-mime-button-commands | |
4711 | '((gnus-article-press-button "\r" "Toggle Display") | |
4712 | (gnus-mime-view-part "v" "View Interactively...") | |
4713 | (gnus-mime-view-part-as-type "t" "View As Type...") | |
23f87bed | 4714 | (gnus-mime-view-part-as-charset "C" "View As charset...") |
16409b0b | 4715 | (gnus-mime-save-part "o" "Save...") |
23f87bed | 4716 | (gnus-mime-save-part-and-strip "\C-o" "Save and Strip") |
01c52d31 | 4717 | (gnus-mime-replace-part "r" "Replace part") |
23f87bed | 4718 | (gnus-mime-delete-part "d" "Delete part") |
16409b0b GM |
4719 | (gnus-mime-copy-part "c" "View As Text, In Other Buffer") |
4720 | (gnus-mime-inline-part "i" "View As Text, In This Buffer") | |
01c52d31 | 4721 | (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'? |
23f87bed MB |
4722 | (gnus-mime-view-part-externally "e" "View Externally") |
4723 | (gnus-mime-print-part "p" "Print") | |
e0bad764 | 4724 | (gnus-mime-pipe-part "|" "Pipe To Command...") |
23f87bed | 4725 | (gnus-mime-action-on-part "." "Take action on the part..."))) |
16409b0b GM |
4726 | |
4727 | (defun gnus-article-mime-part-status () | |
4728 | (if gnus-article-mime-handle-alist-1 | |
23f87bed MB |
4729 | (if (eq 1 (length gnus-article-mime-handle-alist-1)) |
4730 | " (1 part)" | |
4731 | (format " (%d parts)" (length gnus-article-mime-handle-alist-1))) | |
16409b0b GM |
4732 | "")) |
4733 | ||
4734 | (defvar gnus-mime-button-map | |
4735 | (let ((map (make-sparse-keymap))) | |
16409b0b GM |
4736 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
4737 | (define-key map gnus-down-mouse-3 'gnus-mime-button-menu) | |
4738 | (dolist (c gnus-mime-button-commands) | |
4739 | (define-key map (cadr c) (car c))) | |
4740 | map)) | |
4741 | ||
23f87bed MB |
4742 | (easy-menu-define |
4743 | gnus-mime-button-menu gnus-mime-button-map "MIME button menu." | |
4744 | `("MIME Part" | |
4745 | ,@(mapcar (lambda (c) | |
01c52d31 | 4746 | (vector (caddr c) (car c) :active t)) |
23f87bed MB |
4747 | gnus-mime-button-commands))) |
4748 | ||
b0b63450 MB |
4749 | (defmacro gnus-bind-safe-url-regexp (&rest body) |
4750 | "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'." | |
4751 | `(let ((mm-w3m-safe-url-regexp | |
4752 | (let ((group (if (and (eq major-mode 'gnus-article-mode) | |
4753 | (gnus-buffer-live-p | |
4754 | gnus-article-current-summary)) | |
4755 | (with-current-buffer gnus-article-current-summary | |
4756 | gnus-newsgroup-name) | |
4757 | gnus-newsgroup-name))) | |
4758 | (if (cond ((stringp gnus-safe-html-newsgroups) | |
4759 | (string-match gnus-safe-html-newsgroups group)) | |
4760 | ((consp gnus-safe-html-newsgroups) | |
4761 | (member group gnus-safe-html-newsgroups))) | |
4762 | nil | |
4763 | mm-w3m-safe-url-regexp)))) | |
4764 | ,@body)) | |
4765 | ||
23f87bed MB |
4766 | (defun gnus-mime-button-menu (event prefix) |
4767 | "Construct a context-sensitive menu of MIME commands." | |
4768 | (interactive "e\nP") | |
4769 | (save-window-excursion | |
4770 | (let ((pos (event-start event))) | |
4771 | (select-window (posn-window pos)) | |
4772 | (goto-char (posn-point pos)) | |
4773 | (gnus-article-check-buffer) | |
4774 | (popup-menu gnus-mime-button-menu nil prefix)))) | |
16409b0b GM |
4775 | |
4776 | (defun gnus-mime-view-all-parts (&optional handles) | |
4777 | "View all the MIME parts." | |
4778 | (interactive) | |
01c52d31 | 4779 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
4780 | (let ((handles (or handles gnus-article-mime-handles)) |
4781 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 4782 | (mail-parse-ignored-charsets |
23f87bed MB |
4783 | (with-current-buffer gnus-summary-buffer |
4784 | gnus-newsgroup-ignored-charsets))) | |
4785 | (when handles | |
4786 | (mm-remove-parts handles) | |
4787 | (goto-char (point-min)) | |
4788 | (or (search-forward "\n\n") (goto-char (point-max))) | |
4789 | (let ((inhibit-read-only t)) | |
4790 | (delete-region (point) (point-max)) | |
b0b63450 | 4791 | (gnus-bind-safe-url-regexp (mm-display-parts handles))))))) |
23f87bed | 4792 | |
01c52d31 MB |
4793 | (defun gnus-article-jump-to-part (n) |
4794 | "Jump to MIME part N." | |
4795 | (interactive "P") | |
4796 | (pop-to-buffer gnus-article-buffer) | |
4797 | ;; FIXME: why is it necessary? | |
4798 | (sit-for 0) | |
4799 | (let ((parts (length gnus-article-mime-handle-alist))) | |
4800 | (or n (setq n | |
4801 | (string-to-number | |
4802 | (read-string ;; Emacs 21 doesn't have `read-number'. | |
4803 | (format "Jump to part (2..%s): " parts))))) | |
4804 | (unless (and (integerp n) (<= n parts) (>= n 1)) | |
4805 | (setq n | |
4806 | (progn | |
4807 | (gnus-message 7 "Invalid part `%s', using %s instead." | |
4808 | n parts) | |
4809 | parts))) | |
4810 | (gnus-message 9 "Jumping to part %s." n) | |
4811 | (cond ((>= gnus-auto-select-part 1) | |
4812 | (while (and (<= n parts) | |
4813 | (not (gnus-article-goto-part n))) | |
4814 | (setq n (1+ n)))) | |
4815 | ((< gnus-auto-select-part 0) | |
4816 | (while (and (>= n 1) | |
4817 | (not (gnus-article-goto-part n))) | |
4818 | (setq n (1- n)))) | |
4819 | (t | |
4820 | (gnus-article-goto-part n))))) | |
4821 | ||
4822 | (eval-when-compile | |
4823 | (defsubst gnus-article-edit-part (handles &optional current-id) | |
4824 | "Edit an article in order to delete a mime part. | |
4825 | This function is exclusively used by `gnus-mime-save-part-and-strip' | |
4826 | and `gnus-mime-delete-part', and not provided at run-time normally." | |
4827 | (gnus-article-edit-article | |
4828 | `(lambda () | |
4829 | (buffer-disable-undo) | |
4830 | (erase-buffer) | |
4831 | (let ((mail-parse-charset (or gnus-article-charset | |
4832 | ',gnus-newsgroup-charset)) | |
4833 | (mail-parse-ignored-charsets | |
4834 | (or gnus-article-ignored-charsets | |
4835 | ',gnus-newsgroup-ignored-charsets)) | |
4836 | (mbl mml-buffer-list)) | |
4837 | (setq mml-buffer-list nil) | |
4838 | (insert-buffer-substring gnus-original-article-buffer) | |
4839 | (mime-to-mml ',handles) | |
4840 | (setq gnus-article-mime-handles nil) | |
4841 | (let ((mbl1 mml-buffer-list)) | |
4842 | (setq mml-buffer-list mbl) | |
4843 | (set (make-local-variable 'mml-buffer-list) mbl1)) | |
4844 | (gnus-make-local-hook 'kill-buffer-hook) | |
4845 | (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t))) | |
4846 | `(lambda (no-highlight) | |
4847 | (let ((mail-parse-charset (or gnus-article-charset | |
4848 | ',gnus-newsgroup-charset)) | |
4849 | (message-options message-options) | |
4850 | (message-options-set-recipient) | |
4851 | (mail-parse-ignored-charsets | |
4852 | (or gnus-article-ignored-charsets | |
4853 | ',gnus-newsgroup-ignored-charsets))) | |
4854 | (mml-to-mime) | |
4855 | (mml-destroy-buffers) | |
4856 | (remove-hook 'kill-buffer-hook | |
4857 | 'mml-destroy-buffers t) | |
4858 | (kill-local-variable 'mml-buffer-list)) | |
4859 | (gnus-summary-edit-article-done | |
4860 | ,(or (mail-header-references gnus-current-headers) "") | |
4861 | ,(gnus-group-read-only-p) | |
4862 | ,gnus-summary-buffer no-highlight)) | |
4863 | t) | |
4864 | (gnus-article-edit-done) | |
54c72c31 | 4865 | (gnus-configure-windows 'article) |
01c52d31 | 4866 | (when (and current-id (integerp gnus-auto-select-part)) |
54c72c31 | 4867 | (gnus-article-jump-to-part (+ current-id gnus-auto-select-part))))) |
01c52d31 MB |
4868 | |
4869 | (defun gnus-mime-replace-part (file) | |
4870 | "Replace MIME part under point with an external body." | |
4871 | ;; Useful if file has already been saved to disk | |
4872 | (interactive | |
4873 | (list | |
75eda25b SM |
4874 | (read-file-name "Replace MIME part with file: " |
4875 | (or mm-default-directory default-directory) | |
4876 | nil nil))) | |
01c52d31 MB |
4877 | (gnus-mime-save-part-and-strip file)) |
4878 | ||
4879 | (defun gnus-mime-save-part-and-strip (&optional file) | |
4880 | "Save the MIME part under point then replace it with an external body. | |
4881 | If FILE is given, use it for the external part." | |
23f87bed MB |
4882 | (interactive) |
4883 | (gnus-article-check-buffer) | |
4884 | (when (gnus-group-read-only-p) | |
4885 | (error "The current group does not support deleting of parts")) | |
4886 | (when (mm-complicated-handles gnus-article-mime-handles) | |
4887 | (error "\ | |
4888 | The current article has a complicated MIME structure, giving up...")) | |
01c52d31 MB |
4889 | (let* ((data (get-text-property (point) 'gnus-data)) |
4890 | (id (get-text-property (point) 'gnus-part)) | |
4891 | param | |
4892 | (handles gnus-article-mime-handles)) | |
4893 | (unless file | |
4894 | (setq file | |
4895 | (and data (mm-save-part data "Delete MIME part and save to: ")))) | |
4896 | (when file | |
4897 | (with-current-buffer (mm-handle-buffer data) | |
4898 | (erase-buffer) | |
4899 | (insert "Content-Type: " (mm-handle-media-type data)) | |
4900 | (mml-insert-parameter-string (cdr (mm-handle-type data)) | |
4901 | '(charset)) | |
4902 | ;; Add a filename for the sake of saving the part again. | |
4903 | (mml-insert-parameter | |
4904 | (mail-header-encode-parameter "name" (file-name-nondirectory file))) | |
4905 | (insert "\n") | |
4906 | (insert "Content-ID: " (message-make-message-id) "\n") | |
4907 | (insert "Content-Transfer-Encoding: binary\n") | |
4908 | (insert "\n")) | |
4909 | (setcdr data | |
4910 | (cdr (mm-make-handle nil | |
4911 | `("message/external-body" | |
4912 | (access-type . "LOCAL-FILE") | |
4913 | (name . ,file))))) | |
4914 | ;; (set-buffer gnus-summary-buffer) | |
4915 | (gnus-article-edit-part handles id)))) | |
4916 | ||
4917 | ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all | |
4918 | ;; parts...>') but with stripping would be nice. | |
23f87bed MB |
4919 | |
4920 | (defun gnus-mime-delete-part () | |
4921 | "Delete the MIME part under point. | |
4922 | Replace it with some information about the removed part." | |
4923 | (interactive) | |
4924 | (gnus-article-check-buffer) | |
4925 | (when (gnus-group-read-only-p) | |
4926 | (error "The current group does not support deleting of parts")) | |
4927 | (when (mm-complicated-handles gnus-article-mime-handles) | |
4928 | (error "\ | |
4929 | The current article has a complicated MIME structure, giving up...")) | |
01c52d31 MB |
4930 | (when (or gnus-expert-user |
4931 | (gnus-yes-or-no-p "\ | |
4932 | Deleting parts may malfunction or destroy the article; continue? ")) | |
23f87bed | 4933 | (let* ((data (get-text-property (point) 'gnus-data)) |
01c52d31 | 4934 | (id (get-text-property (point) 'gnus-part)) |
23f87bed MB |
4935 | (handles gnus-article-mime-handles) |
4936 | (none "(none)") | |
4937 | (description | |
bbbe940b MB |
4938 | (let ((desc (mm-handle-description data))) |
4939 | (when desc | |
4940 | (mail-decode-encoded-word-string desc)))) | |
23f87bed MB |
4941 | (filename |
4942 | (or (mail-content-type-get (mm-handle-disposition data) 'filename) | |
4943 | none)) | |
4944 | (type (mm-handle-media-type data))) | |
4945 | (unless data | |
4946 | (error "No MIME part under point")) | |
4947 | (with-current-buffer (mm-handle-buffer data) | |
4948 | (let ((bsize (format "%s" (buffer-size)))) | |
4949 | (erase-buffer) | |
4950 | (insert | |
4951 | (concat | |
4952 | ",----\n" | |
4953 | "| The following attachment has been deleted:\n" | |
4954 | "|\n" | |
4955 | "| Type: " type "\n" | |
4956 | "| Filename: " filename "\n" | |
4957 | "| Size (encoded): " bsize " Byte\n" | |
bbbe940b MB |
4958 | (when description |
4959 | (concat "| Description: " description "\n")) | |
23f87bed MB |
4960 | "`----\n")) |
4961 | (setcdr data | |
4962 | (cdr (mm-make-handle | |
0cf681b6 | 4963 | nil `("text/plain" (charset . gnus-decoded)) nil nil |
23f87bed MB |
4964 | (list "attachment") |
4965 | (format "Deleted attachment (%s bytes)" bsize)))))) | |
01c52d31 MB |
4966 | ;; (set-buffer gnus-summary-buffer) |
4967 | (gnus-article-edit-part handles id)))) | |
16409b0b GM |
4968 | |
4969 | (defun gnus-mime-save-part () | |
4970 | "Save the MIME part under point." | |
4971 | (interactive) | |
4972 | (gnus-article-check-buffer) | |
4973 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed MB |
4974 | (when data |
4975 | (mm-save-part data)))) | |
16409b0b GM |
4976 | |
4977 | (defun gnus-mime-pipe-part () | |
4978 | "Pipe the MIME part under point to a process." | |
4979 | (interactive) | |
4980 | (gnus-article-check-buffer) | |
4981 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed MB |
4982 | (when data |
4983 | (mm-pipe-part data)))) | |
16409b0b GM |
4984 | |
4985 | (defun gnus-mime-view-part () | |
4986 | "Interactively choose a viewing method for the MIME part under point." | |
4987 | (interactive) | |
4988 | (gnus-article-check-buffer) | |
4989 | (let ((data (get-text-property (point) 'gnus-data))) | |
23f87bed MB |
4990 | (when data |
4991 | (setq gnus-article-mime-handles | |
4992 | (mm-merge-handles | |
4993 | gnus-article-mime-handles (setq data (copy-sequence data)))) | |
4994 | (mm-interactively-view-part data)))) | |
16409b0b GM |
4995 | |
4996 | (defun gnus-mime-view-part-as-type-internal () | |
4997 | (gnus-article-check-buffer) | |
54e573e6 MB |
4998 | (let* ((handle (get-text-property (point) 'gnus-data)) |
4999 | (name (or | |
5000 | ;; Content-Type: foo/bar; name=... | |
5001 | (mail-content-type-get (mm-handle-type handle) 'name) | |
5002 | ;; Content-Disposition: attachment; filename=... | |
5003 | (cdr (assq 'filename (cdr (mm-handle-disposition handle)))))) | |
16409b0b | 5004 | (def-type (and name (mm-default-file-encoding name)))) |
01c52d31 MB |
5005 | (or (and def-type (cons def-type 0)) |
5006 | (and handle | |
5007 | (equal (mm-handle-media-supertype handle) "text") | |
5008 | '("text/plain" . 0)) | |
5009 | '("application/octet-stream" . 0)))) | |
16409b0b | 5010 | |
54e573e6 MB |
5011 | (defun gnus-mime-view-part-as-type (&optional mime-type pred) |
5012 | "Choose a MIME media type, and view the part as such. | |
5013 | If non-nil, PRED is a predicate to use during completion to limit the | |
5014 | available media-types." | |
23f87bed MB |
5015 | (interactive) |
5016 | (unless mime-type | |
54e573e6 MB |
5017 | (setq mime-type |
5018 | (let ((default (gnus-mime-view-part-as-type-internal))) | |
5019 | (completing-read | |
5020 | (format "View as MIME type (default %s): " | |
5021 | (car default)) | |
5022 | (mapcar #'list (mailcap-mime-types)) | |
5023 | pred nil nil nil | |
5024 | (car default))))) | |
16409b0b GM |
5025 | (gnus-article-check-buffer) |
5026 | (let ((handle (get-text-property (point) 'gnus-data))) | |
23f87bed | 5027 | (when handle |
531bedc3 MB |
5028 | (when (equal (mm-handle-media-type handle) "message/external-body") |
5029 | (unless (mm-handle-cache handle) | |
5030 | (mm-extern-cache-contents handle)) | |
5031 | (setq handle (mm-handle-cache handle))) | |
23f87bed MB |
5032 | (setq handle |
5033 | (mm-make-handle (mm-handle-buffer handle) | |
5034 | (cons mime-type (cdr (mm-handle-type handle))) | |
5035 | (mm-handle-encoding handle) | |
5036 | (mm-handle-undisplayer handle) | |
5037 | (mm-handle-disposition handle) | |
5038 | (mm-handle-description handle) | |
5039 | nil | |
5040 | (mm-handle-id handle))) | |
5041 | (setq gnus-article-mime-handles | |
5042 | (mm-merge-handles gnus-article-mime-handles handle)) | |
01c52d31 MB |
5043 | (when (mm-handle-displayed-p handle) |
5044 | (mm-remove-part handle)) | |
23f87bed MB |
5045 | (gnus-mm-display-part handle)))) |
5046 | ||
01c52d31 | 5047 | (defun gnus-mime-copy-part (&optional handle arg) |
23f87bed MB |
5048 | "Put the MIME part under point into a new buffer. |
5049 | If `auto-compression-mode' is enabled, compressed files like .gz and .bz2 | |
5050 | are decompressed." | |
01c52d31 | 5051 | (interactive (list nil current-prefix-arg)) |
16409b0b | 5052 | (gnus-article-check-buffer) |
01c52d31 MB |
5053 | (unless handle |
5054 | (setq handle (get-text-property (point) 'gnus-data))) | |
5055 | (when handle | |
5056 | (let ((filename (or (mail-content-type-get (mm-handle-type handle) | |
5057 | 'name) | |
5058 | (mail-content-type-get (mm-handle-disposition handle) | |
5059 | 'filename))) | |
5060 | contents dont-decode charset coding-system) | |
5061 | (mm-with-unibyte-buffer | |
5062 | (mm-insert-part handle) | |
5063 | (setq contents (or (condition-case nil | |
5064 | (mm-decompress-buffer filename nil 'sig) | |
5065 | (error | |
5066 | (setq dont-decode t) | |
5067 | nil)) | |
5068 | (buffer-string)))) | |
5069 | (setq filename (cond (filename (file-name-nondirectory filename)) | |
5070 | (dont-decode "*raw data*") | |
5071 | (t "*decoded*"))) | |
5072 | (cond | |
5073 | (dont-decode) | |
5074 | ((not arg) | |
5075 | (unless (setq charset (mail-content-type-get | |
5076 | (mm-handle-type handle) 'charset)) | |
5077 | (unless (setq coding-system (mm-with-unibyte-buffer | |
5078 | (insert contents) | |
5079 | (mm-find-buffer-file-coding-system))) | |
5080 | (setq charset gnus-newsgroup-charset)))) | |
5081 | ((numberp arg) | |
5082 | (setq charset (or (cdr (assq arg | |
5083 | gnus-summary-show-article-charset-alist)) | |
5084 | (mm-read-coding-system "Charset: "))))) | |
5085 | (switch-to-buffer (generate-new-buffer filename)) | |
5086 | (if (or coding-system | |
5087 | (and charset | |
5088 | (setq coding-system (mm-charset-to-coding-system charset)) | |
5089 | (not (eq charset 'ascii)))) | |
5090 | (progn | |
5091 | (mm-enable-multibyte) | |
5092 | (insert (mm-decode-coding-string contents coding-system)) | |
5093 | (setq buffer-file-coding-system | |
5094 | (if (boundp 'last-coding-system-used) | |
5095 | (symbol-value 'last-coding-system-used) | |
5096 | coding-system))) | |
5097 | (mm-disable-multibyte) | |
5098 | (insert contents) | |
5099 | (setq buffer-file-coding-system mm-binary-coding-system)) | |
23f87bed MB |
5100 | ;; We do it this way to make `normal-mode' set the appropriate mode. |
5101 | (unwind-protect | |
5102 | (progn | |
01c52d31 | 5103 | (setq buffer-file-name (expand-file-name filename)) |
23f87bed MB |
5104 | (normal-mode)) |
5105 | (setq buffer-file-name nil)) | |
5106 | (goto-char (point-min))))) | |
5107 | ||
5108 | (defun gnus-mime-print-part (&optional handle filename) | |
5109 | "Print the MIME part under point." | |
5110 | (interactive (list nil (ps-print-preprint current-prefix-arg))) | |
5111 | (gnus-article-check-buffer) | |
5112 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5113 | (contents (and handle (mm-get-part handle))) | |
5114 | (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory))) | |
5115 | (printer (mailcap-mime-info (mm-handle-media-type handle) "print"))) | |
5116 | (when contents | |
5117 | (if printer | |
5118 | (unwind-protect | |
5119 | (progn | |
5120 | (mm-save-part-to-file handle file) | |
5121 | (call-process shell-file-name nil | |
5122 | (generate-new-buffer " *mm*") | |
5123 | nil | |
5124 | shell-command-switch | |
5125 | (mm-mailcap-command | |
5126 | printer file (mm-handle-type handle)))) | |
5127 | (delete-file file)) | |
5128 | (with-temp-buffer | |
5129 | (insert contents) | |
5130 | (gnus-print-buffer)) | |
5131 | (ps-despool filename))))) | |
16409b0b | 5132 | |
e0bad764 | 5133 | (defun gnus-mime-inline-part (&optional handle arg) |
01c52d31 MB |
5134 | "Insert the MIME part under point into the current buffer. |
5135 | Compressed files like .gz and .bz2 are decompressed." | |
e0bad764 | 5136 | (interactive (list nil current-prefix-arg)) |
16409b0b | 5137 | (gnus-article-check-buffer) |
01c52d31 MB |
5138 | (unless handle |
5139 | (setq handle (get-text-property (point) 'gnus-data))) | |
5140 | (when handle | |
5141 | (let ((b (point)) | |
5142 | (inhibit-read-only t) | |
5143 | contents charset coding-system) | |
23f87bed MB |
5144 | (if (and (not arg) (mm-handle-undisplayer handle)) |
5145 | (mm-remove-part handle) | |
01c52d31 MB |
5146 | (mm-with-unibyte-buffer |
5147 | (mm-insert-part handle) | |
5148 | (setq contents | |
5149 | (or (mm-decompress-buffer | |
5150 | (or (mail-content-type-get (mm-handle-type handle) | |
5151 | 'name) | |
5152 | (mail-content-type-get (mm-handle-disposition handle) | |
5153 | 'filename)) | |
5154 | nil t) | |
5155 | (buffer-string)))) | |
23f87bed MB |
5156 | (cond |
5157 | ((not arg) | |
01c52d31 MB |
5158 | (unless (setq charset (mail-content-type-get |
5159 | (mm-handle-type handle) 'charset)) | |
5160 | (unless (setq coding-system | |
5161 | (mm-with-unibyte-buffer | |
5162 | (insert contents) | |
5163 | (mm-find-buffer-file-coding-system))) | |
5164 | (setq charset gnus-newsgroup-charset)))) | |
23f87bed MB |
5165 | ((numberp arg) |
5166 | (if (mm-handle-undisplayer handle) | |
5167 | (mm-remove-part handle)) | |
5168 | (setq charset | |
5169 | (or (cdr (assq arg | |
5170 | gnus-summary-show-article-charset-alist)) | |
56c30d72 MB |
5171 | (mm-read-coding-system "Charset: ")))) |
5172 | (t | |
5173 | (if (mm-handle-undisplayer handle) | |
850c333d | 5174 | (mm-remove-part handle)))) |
23f87bed | 5175 | (forward-line 2) |
850c333d MB |
5176 | (mm-insert-inline |
5177 | handle | |
01c52d31 MB |
5178 | (if (or coding-system |
5179 | (and charset | |
5180 | (setq coding-system | |
5181 | (mm-charset-to-coding-system charset)) | |
5182 | (not (eq coding-system 'ascii)))) | |
5183 | (mm-decode-coding-string contents coding-system) | |
850c333d | 5184 | (mm-string-to-multibyte contents))) |
23f87bed MB |
5185 | (goto-char b))))) |
5186 | ||
c0ccb0d6 KY |
5187 | (defun gnus-mime-set-charset-parameters (handle charset) |
5188 | "Set CHARSET to parameters in HANDLE. | |
5189 | CHARSET may either be a string or a symbol." | |
5190 | (unless (stringp charset) | |
5191 | (setq charset (symbol-name charset))) | |
6b554e88 | 5192 | (if (stringp (car handle)) |
c0ccb0d6 KY |
5193 | (dolist (h (cdr handle)) |
5194 | (gnus-mime-set-charset-parameters h charset)) | |
6b554e88 MB |
5195 | (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle) |
5196 | "message/external-body") | |
5197 | (progn | |
5198 | (unless (mm-handle-cache handle) | |
5199 | (mm-extern-cache-contents handle)) | |
5200 | (mm-handle-cache handle)) | |
5201 | handle))) | |
c0ccb0d6 KY |
5202 | (param (assq 'charset (cdr type)))) |
5203 | (if param | |
5204 | (setcdr param charset) | |
5205 | (setcdr type (cons (cons 'charset charset) (cdr type))))))) | |
6b554e88 | 5206 | |
23f87bed MB |
5207 | (defun gnus-mime-view-part-as-charset (&optional handle arg) |
5208 | "Insert the MIME part under point into the current buffer using the | |
5209 | specified charset." | |
5210 | (interactive (list nil current-prefix-arg)) | |
5211 | (gnus-article-check-buffer) | |
163cb72d MB |
5212 | (let ((handle (or handle (get-text-property (point) 'gnus-data))) |
5213 | (fun (get-text-property (point) 'gnus-callback)) | |
5214 | (gnus-newsgroup-ignored-charsets 'gnus-all) | |
c0ccb0d6 | 5215 | charset form preferred parts) |
23f87bed | 5216 | (when handle |
01c52d31 MB |
5217 | (when (prog1 |
5218 | (and fun | |
c0ccb0d6 | 5219 | (setq charset |
01c52d31 MB |
5220 | (or (cdr (assq |
5221 | arg | |
5222 | gnus-summary-show-article-charset-alist)) | |
5223 | (mm-read-coding-system "Charset: ")))) | |
5224 | (if (mm-handle-undisplayer handle) | |
5225 | (mm-remove-part handle))) | |
c0ccb0d6 | 5226 | (gnus-mime-set-charset-parameters handle charset) |
6b554e88 MB |
5227 | (when (and (consp (setq form (cdr-safe fun))) |
5228 | (setq form (ignore-errors | |
5229 | (assq 'gnus-mime-display-alternative form))) | |
5230 | (setq preferred (caddr form)) | |
5231 | (progn | |
5232 | (when (eq (car preferred) 'quote) | |
5233 | (setq preferred (cadr preferred))) | |
5234 | (not (equal preferred | |
5235 | (get-text-property (point) 'gnus-data)))) | |
5236 | (setq parts (get-text-property (point) 'gnus-part)) | |
5237 | (setq parts (cdr (assq parts | |
5238 | gnus-article-mime-handle-alist))) | |
5239 | (equal (mm-handle-media-type parts) "multipart/alternative") | |
5240 | (setq parts (reverse (cdr parts)))) | |
5241 | (setcar (cddr form) | |
5242 | (list 'quote (or (cadr (member preferred parts)) | |
5243 | (car parts))))) | |
163cb72d | 5244 | (funcall fun handle))))) |
23f87bed MB |
5245 | |
5246 | (defun gnus-mime-view-part-externally (&optional handle) | |
16409b0b GM |
5247 | "View the MIME part under point with an external viewer." |
5248 | (interactive) | |
5249 | (gnus-article-check-buffer) | |
5250 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5251 | (mm-user-display-methods nil) | |
5252 | (mm-inlined-types nil) | |
5253 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5254 | (mail-parse-ignored-charsets |
54e573e6 MB |
5255 | (with-current-buffer gnus-summary-buffer |
5256 | gnus-newsgroup-ignored-charsets)) | |
5257 | (type (mm-handle-media-type handle)) | |
5258 | (method (mailcap-mime-info type)) | |
5259 | (mm-enable-external t)) | |
5260 | (if (not (stringp method)) | |
5261 | (gnus-mime-view-part-as-type | |
524705ae | 5262 | nil (lambda (types) (stringp (mailcap-mime-info (car types))))) |
54e573e6 MB |
5263 | (when handle |
5264 | (if (mm-handle-undisplayer handle) | |
5265 | (mm-remove-part handle) | |
5266 | (mm-display-part handle)))))) | |
16409b0b | 5267 | |
23f87bed | 5268 | (defun gnus-mime-view-part-internally (&optional handle) |
16409b0b | 5269 | "View the MIME part under point with an internal viewer. |
23f87bed | 5270 | If no internal viewer is available, use an external viewer." |
16409b0b GM |
5271 | (interactive) |
5272 | (gnus-article-check-buffer) | |
5273 | (let* ((handle (or handle (get-text-property (point) 'gnus-data))) | |
5274 | (mm-inlined-types '(".*")) | |
5275 | (mm-inline-large-images t) | |
5276 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5277 | (mail-parse-ignored-charsets |
54e573e6 MB |
5278 | (with-current-buffer gnus-summary-buffer |
5279 | gnus-newsgroup-ignored-charsets)) | |
23f87bed | 5280 | (inhibit-read-only t)) |
54e573e6 MB |
5281 | (if (not (mm-inlinable-p handle)) |
5282 | (gnus-mime-view-part-as-type | |
524705ae | 5283 | nil (lambda (types) (mm-inlinable-p handle (car types)))) |
54e573e6 MB |
5284 | (when handle |
5285 | (if (mm-handle-undisplayer handle) | |
5286 | (mm-remove-part handle) | |
b0b63450 | 5287 | (gnus-bind-safe-url-regexp (mm-display-part handle))))))) |
16409b0b | 5288 | |
e0bad764 DL |
5289 | (defun gnus-mime-action-on-part (&optional action) |
5290 | "Do something with the MIME attachment at \(point\)." | |
5291 | (interactive | |
23f87bed | 5292 | (list (completing-read "Action: " gnus-mime-action-alist nil t))) |
e0bad764 DL |
5293 | (gnus-article-check-buffer) |
5294 | (let ((action-pair (assoc action gnus-mime-action-alist))) | |
5295 | (if action-pair | |
5296 | (funcall (cdr action-pair))))) | |
5297 | ||
01c52d31 MB |
5298 | (defun gnus-article-part-wrapper (n function &optional no-handle interactive) |
5299 | "Call FUNCTION on MIME part N. | |
5300 | Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument. | |
5301 | If INTERACTIVE, call FUNCTION interactivly." | |
5302 | (let (window frame) | |
5303 | ;; Check whether the article is displayed. | |
5304 | (unless (and (gnus-buffer-live-p gnus-article-buffer) | |
5305 | (setq window (get-buffer-window gnus-article-buffer t)) | |
5306 | (frame-visible-p (setq frame (window-frame window)))) | |
5307 | (error "No article is displayed")) | |
5308 | (with-current-buffer gnus-article-buffer | |
5309 | ;; Check whether the article displays the right contents. | |
5310 | (unless (with-current-buffer gnus-summary-buffer | |
5311 | (eq gnus-current-article (gnus-summary-article-number))) | |
5312 | (error "You should select the right article first")) | |
5313 | (if n | |
5314 | (setq n (prefix-numeric-value n)) | |
5315 | (let ((pt (point))) | |
5316 | (setq n (or (get-text-property pt 'gnus-part) | |
5317 | (and (not (bobp)) | |
5318 | (get-text-property (1- pt) 'gnus-part)) | |
5319 | (get-text-property (prog2 | |
5320 | (forward-line 1) | |
5321 | (point) | |
5322 | (goto-char pt)) | |
5323 | 'gnus-part) | |
5324 | (get-text-property | |
5325 | (or (and (setq pt (previous-single-property-change | |
5326 | pt 'gnus-part)) | |
5327 | (1- pt)) | |
5328 | (next-single-property-change (point) 'gnus-part) | |
5329 | (point)) | |
5330 | 'gnus-part) | |
5331 | 1)))) | |
5332 | ;; Check whether the specified part exists. | |
5333 | (when (> n (length gnus-article-mime-handle-alist)) | |
5334 | (error "No such part"))) | |
5335 | (unless | |
5336 | (progn | |
5337 | ;; To select the window is needed so that the cursor | |
5338 | ;; might be visible on the MIME button. | |
5339 | (select-window (prog1 | |
5340 | window | |
5341 | (setq window (selected-window)) | |
5342 | ;; Article may be displayed in the other frame. | |
5343 | (gnus-select-frame-set-input-focus | |
5344 | (prog1 | |
5345 | frame | |
5346 | (setq frame (selected-frame)))))) | |
5347 | (when (gnus-article-goto-part n) | |
5348 | ;; We point the cursor and the arrow at the MIME button | |
5349 | ;; when the `function' prompt the user for something. | |
5350 | (let ((cursor-in-non-selected-windows t) | |
5351 | (overlay-arrow-string "=>") | |
5352 | (overlay-arrow-position (point-marker))) | |
5353 | (unwind-protect | |
5354 | (cond | |
5355 | ((and no-handle interactive) | |
5356 | (call-interactively function)) | |
5357 | (no-handle | |
5358 | (funcall function)) | |
5359 | (interactive | |
5360 | (call-interactively | |
5361 | function | |
5362 | (cdr (assq n gnus-article-mime-handle-alist)))) | |
5363 | (t | |
5364 | (funcall function | |
5365 | (cdr (assq n gnus-article-mime-handle-alist))))) | |
5366 | (set-marker overlay-arrow-position nil) | |
5367 | (unless gnus-auto-select-part | |
5368 | (gnus-select-frame-set-input-focus frame) | |
5369 | (select-window window)))) | |
5370 | t)) | |
5371 | (if gnus-inhibit-mime-unbuttonizing | |
5372 | ;; This is the default though the program shouldn't reach here. | |
5373 | (error "No such part") | |
5374 | ;; The part which doesn't have the MIME button is selected. | |
5375 | ;; So, we display all the buttons and redo it. | |
5376 | (let ((gnus-inhibit-mime-unbuttonizing t)) | |
5377 | (gnus-summary-show-article) | |
5378 | (gnus-article-part-wrapper n function no-handle)))))) | |
16409b0b GM |
5379 | |
5380 | (defun gnus-article-pipe-part (n) | |
5381 | "Pipe MIME part N, which is the numerical prefix." | |
01c52d31 | 5382 | (interactive "P") |
16409b0b GM |
5383 | (gnus-article-part-wrapper n 'mm-pipe-part)) |
5384 | ||
5385 | (defun gnus-article-save-part (n) | |
5386 | "Save MIME part N, which is the numerical prefix." | |
01c52d31 | 5387 | (interactive "P") |
16409b0b GM |
5388 | (gnus-article-part-wrapper n 'mm-save-part)) |
5389 | ||
5390 | (defun gnus-article-interactively-view-part (n) | |
5391 | "View MIME part N interactively, which is the numerical prefix." | |
01c52d31 | 5392 | (interactive "P") |
16409b0b GM |
5393 | (gnus-article-part-wrapper n 'mm-interactively-view-part)) |
5394 | ||
5395 | (defun gnus-article-copy-part (n) | |
5396 | "Copy MIME part N, which is the numerical prefix." | |
01c52d31 | 5397 | (interactive "P") |
16409b0b GM |
5398 | (gnus-article-part-wrapper n 'gnus-mime-copy-part)) |
5399 | ||
23f87bed MB |
5400 | (defun gnus-article-view-part-as-charset (n) |
5401 | "View MIME part N using a specified charset. | |
5402 | N is the numerical prefix." | |
01c52d31 | 5403 | (interactive "P") |
23f87bed MB |
5404 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset)) |
5405 | ||
5406 | (defun gnus-article-view-part-externally (n) | |
16409b0b | 5407 | "View MIME part N externally, which is the numerical prefix." |
01c52d31 | 5408 | (interactive "P") |
23f87bed | 5409 | (gnus-article-part-wrapper n 'gnus-mime-view-part-externally)) |
16409b0b GM |
5410 | |
5411 | (defun gnus-article-inline-part (n) | |
5412 | "Inline MIME part N, which is the numerical prefix." | |
01c52d31 | 5413 | (interactive "P") |
16409b0b GM |
5414 | (gnus-article-part-wrapper n 'gnus-mime-inline-part)) |
5415 | ||
01c52d31 MB |
5416 | (defun gnus-article-save-part-and-strip (n) |
5417 | "Save MIME part N and replace it with an external body. | |
5418 | N is the numerical prefix." | |
5419 | (interactive "P") | |
5420 | (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t)) | |
5421 | ||
5422 | (defun gnus-article-replace-part (n) | |
5423 | "Replace MIME part N with an external body. | |
5424 | N is the numerical prefix." | |
5425 | (interactive "P") | |
5426 | (gnus-article-part-wrapper n 'gnus-mime-replace-part t t)) | |
5427 | ||
5428 | (defun gnus-article-delete-part (n) | |
5429 | "Delete MIME part N and add some information about the removed part. | |
5430 | N is the numerical prefix." | |
5431 | (interactive "P") | |
5432 | (gnus-article-part-wrapper n 'gnus-mime-delete-part t)) | |
5433 | ||
5434 | (defun gnus-article-view-part-as-type (n) | |
5435 | "Choose a MIME media type, and view part N as such. | |
5436 | N is the numerical prefix." | |
5437 | (interactive "P") | |
5438 | (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t)) | |
5439 | ||
16409b0b GM |
5440 | (defun gnus-article-mime-match-handle-first (condition) |
5441 | (if condition | |
01c52d31 MB |
5442 | (let (n) |
5443 | (dolist (ihandle gnus-article-mime-handle-alist) | |
a1506d29 | 5444 | (if (and (cond |
16409b0b GM |
5445 | ((functionp condition) |
5446 | (funcall condition (cdr ihandle))) | |
a1506d29 | 5447 | ((eq condition 'undisplayed) |
16409b0b GM |
5448 | (not (or (mm-handle-undisplayer (cdr ihandle)) |
5449 | (equal (mm-handle-media-type (cdr ihandle)) | |
5450 | "multipart/alternative")))) | |
5451 | ((eq condition 'undisplayed-alternative) | |
5452 | (not (mm-handle-undisplayer (cdr ihandle)))) | |
5453 | (t t)) | |
5454 | (gnus-article-goto-part (car ihandle)) | |
5455 | (or (not n) (< (car ihandle) n))) | |
5456 | (setq n (car ihandle)))) | |
5457 | (or n 1)) | |
5458 | 1)) | |
5459 | ||
5460 | (defun gnus-article-view-part (&optional n) | |
5461 | "View MIME part N, which is the numerical prefix." | |
5462 | (interactive "P") | |
01c52d31 | 5463 | (with-current-buffer gnus-article-buffer |
a1506d29 | 5464 | (or (numberp n) (setq n (gnus-article-mime-match-handle-first |
16409b0b GM |
5465 | gnus-article-mime-match-handle-function))) |
5466 | (when (> n (length gnus-article-mime-handle-alist)) | |
5467 | (error "No such part")) | |
5468 | (let ((handle (cdr (assq n gnus-article-mime-handle-alist)))) | |
5469 | (when (gnus-article-goto-part n) | |
5470 | (if (equal (car handle) "multipart/alternative") | |
5471 | (gnus-article-press-button) | |
5472 | (when (eq (gnus-mm-display-part handle) 'internal) | |
5473 | (gnus-set-window-start))))))) | |
5474 | ||
e0bad764 DL |
5475 | (defsubst gnus-article-mime-total-parts () |
5476 | (if (bufferp (car gnus-article-mime-handles)) | |
5477 | 1 ;; single part | |
5478 | (1- (length gnus-article-mime-handles)))) | |
5479 | ||
16409b0b GM |
5480 | (defun gnus-mm-display-part (handle) |
5481 | "Display HANDLE and fix MIME button." | |
5482 | (let ((id (get-text-property (point) 'gnus-part)) | |
5483 | (point (point)) | |
23f87bed | 5484 | (inhibit-read-only t)) |
16409b0b GM |
5485 | (forward-line 1) |
5486 | (prog1 | |
5487 | (let ((window (selected-window)) | |
5488 | (mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5489 | (mail-parse-ignored-charsets |
23f87bed | 5490 | (if (gnus-buffer-live-p gnus-summary-buffer) |
01c52d31 | 5491 | (with-current-buffer gnus-summary-buffer |
23f87bed MB |
5492 | gnus-newsgroup-ignored-charsets) |
5493 | nil))) | |
16409b0b GM |
5494 | (save-excursion |
5495 | (unwind-protect | |
23f87bed | 5496 | (let ((win (gnus-get-buffer-window (current-buffer) t)) |
16409b0b GM |
5497 | (beg (point))) |
5498 | (when win | |
5499 | (select-window win)) | |
5500 | (goto-char point) | |
5501 | (forward-line) | |
5502 | (if (mm-handle-displayed-p handle) | |
5503 | ;; This will remove the part. | |
5504 | (mm-display-part handle) | |
5505 | (save-restriction | |
23f87bed MB |
5506 | (narrow-to-region (point) |
5507 | (if (eobp) (point) (1+ (point)))) | |
b0b63450 | 5508 | (gnus-bind-safe-url-regexp (mm-display-part handle)) |
16409b0b GM |
5509 | ;; We narrow to the part itself and |
5510 | ;; then call the treatment functions. | |
5511 | (goto-char (point-min)) | |
5512 | (forward-line 1) | |
5513 | (narrow-to-region (point) (point-max)) | |
5514 | (gnus-treat-article | |
5515 | nil id | |
e0bad764 | 5516 | (gnus-article-mime-total-parts) |
16409b0b | 5517 | (mm-handle-media-type handle))))) |
23f87bed MB |
5518 | (if (window-live-p window) |
5519 | (select-window window))))) | |
16409b0b | 5520 | (goto-char point) |
23f87bed | 5521 | (gnus-delete-line) |
16409b0b GM |
5522 | (gnus-insert-mime-button |
5523 | handle id (list (mm-handle-displayed-p handle))) | |
5524 | (goto-char point)))) | |
5525 | ||
5526 | (defun gnus-article-goto-part (n) | |
5527 | "Go to MIME part N." | |
23f87bed | 5528 | (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n))) |
16409b0b GM |
5529 | |
5530 | (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) | |
5531 | (let ((gnus-tmp-name | |
23f87bed MB |
5532 | (or (mail-content-type-get (mm-handle-type handle) 'name) |
5533 | (mail-content-type-get (mm-handle-disposition handle) 'filename) | |
5534 | (mail-content-type-get (mm-handle-type handle) 'url) | |
16409b0b GM |
5535 | "")) |
5536 | (gnus-tmp-type (mm-handle-media-type handle)) | |
4599d0ec | 5537 | (gnus-tmp-description (or (mm-handle-description handle) "")) |
16409b0b GM |
5538 | (gnus-tmp-dots |
5539 | (if (if displayed (car displayed) | |
5540 | (mm-handle-displayed-p handle)) | |
5541 | "" "...")) | |
5542 | (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle) | |
5543 | (buffer-size))) | |
5544 | gnus-tmp-type-long b e) | |
5545 | (when (string-match ".*/" gnus-tmp-name) | |
5546 | (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name))) | |
5547 | (setq gnus-tmp-type-long (concat gnus-tmp-type | |
5548 | (and (not (equal gnus-tmp-name "")) | |
5549 | (concat "; " gnus-tmp-name)))) | |
23f87bed MB |
5550 | (unless (equal gnus-tmp-description "") |
5551 | (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long))) | |
16409b0b GM |
5552 | (unless (bolp) |
5553 | (insert "\n")) | |
5554 | (setq b (point)) | |
5555 | (gnus-eval-format | |
5556 | gnus-mime-button-line-format gnus-mime-button-line-format-alist | |
01c52d31 MB |
5557 | `(keymap ,gnus-mime-button-map |
5558 | gnus-callback gnus-mm-display-part | |
5559 | gnus-part ,gnus-tmp-id | |
5560 | article-type annotation | |
5561 | gnus-data ,handle)) | |
23f87bed MB |
5562 | (setq e (if (bolp) |
5563 | ;; Exclude a newline. | |
5564 | (1- (point)) | |
5565 | (point))) | |
01c52d31 MB |
5566 | (when gnus-article-button-face |
5567 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
5568 | 'face gnus-article-button-face)) | |
16409b0b GM |
5569 | (widget-convert-button |
5570 | 'link b e | |
5571 | :mime-handle handle | |
5572 | :action 'gnus-widget-press-button | |
5573 | :button-keymap gnus-mime-button-map | |
5574 | :help-echo | |
5575 | (lambda (widget/window &optional overlay pos) | |
5576 | ;; Needed to properly clear the message due to a bug in | |
5577 | ;; wid-edit (XEmacs only). | |
5578 | (if (boundp 'help-echo-owns-message) | |
5579 | (setq help-echo-owns-message t)) | |
5580 | (format | |
5581 | "%S: %s the MIME part; %S: more options" | |
5582 | (aref gnus-mouse-2 0) | |
5583 | ;; XEmacs will get a single widget arg; Emacs 21 will get | |
5584 | ;; window, overlay, position. | |
5585 | (if (mm-handle-displayed-p | |
5586 | (if overlay | |
e0bad764 DL |
5587 | (with-current-buffer (gnus-overlay-buffer overlay) |
5588 | (widget-get (widget-at (gnus-overlay-start overlay)) | |
16409b0b GM |
5589 | :mime-handle)) |
5590 | (widget-get widget/window :mime-handle))) | |
5591 | "hide" "show") | |
5592 | (aref gnus-down-mouse-3 0)))))) | |
5593 | ||
5594 | (defun gnus-widget-press-button (elems el) | |
5595 | (goto-char (widget-get elems :from)) | |
5596 | (gnus-article-press-button)) | |
5597 | ||
5598 | (defvar gnus-displaying-mime nil) | |
5599 | ||
5600 | (defun gnus-display-mime (&optional ihandles) | |
5601 | "Display the MIME parts." | |
5602 | (save-excursion | |
5603 | (save-selected-window | |
5604 | (let ((window (get-buffer-window gnus-article-buffer)) | |
5605 | (point (point))) | |
5606 | (when window | |
5607 | (select-window window) | |
5608 | ;; We have to do this since selecting the window | |
5609 | ;; may change the point. So we set the window point. | |
5610 | (set-window-point window point))) | |
73043f7d MB |
5611 | (let ((handles ihandles) |
5612 | (inhibit-read-only t) | |
5613 | handle) | |
5614 | (cond (handles) | |
5615 | ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime)) | |
5616 | (when gnus-article-emulate-mime | |
5617 | (mm-uu-dissect-text-parts handles))) | |
5618 | (gnus-article-emulate-mime | |
5619 | (setq handles (mm-uu-dissect)))) | |
16409b0b GM |
5620 | (when (and (not ihandles) |
5621 | (not gnus-displaying-mime)) | |
5622 | ;; Top-level call; we clean up. | |
5623 | (when gnus-article-mime-handles | |
5624 | (mm-destroy-parts gnus-article-mime-handles) | |
5625 | (setq gnus-article-mime-handle-alist nil));; A trick. | |
5626 | (setq gnus-article-mime-handles handles) | |
5627 | ;; We allow users to glean info from the handles. | |
5628 | (when gnus-article-mime-part-function | |
5629 | (gnus-mime-part-function handles))) | |
5630 | (if (and handles | |
5631 | (or (not (stringp (car handles))) | |
5632 | (cdr handles))) | |
5633 | (progn | |
5634 | (when (and (not ihandles) | |
5635 | (not gnus-displaying-mime)) | |
5636 | ;; Clean up for mime parts. | |
5637 | (article-goto-body) | |
5638 | (delete-region (point) (point-max))) | |
5639 | (let ((gnus-displaying-mime t)) | |
5640 | (gnus-mime-display-part handles))) | |
5641 | (save-restriction | |
5642 | (article-goto-body) | |
5643 | (narrow-to-region (point) (point-max)) | |
5644 | (gnus-treat-article nil 1 1) | |
5645 | (widen))) | |
5646 | (unless ihandles | |
5647 | ;; Highlight the headers. | |
5648 | (save-excursion | |
5649 | (save-restriction | |
5650 | (article-goto-body) | |
5651 | (narrow-to-region (point-min) (point)) | |
31640842 | 5652 | (gnus-article-save-original-date |
f362b760 MB |
5653 | (gnus-treat-article 'head))))))) |
5654 | ;; Cope with broken MIME messages. | |
5655 | (goto-char (point-max)) | |
5656 | (unless (bolp) | |
5657 | (insert "\n")))) | |
16409b0b | 5658 | |
23f87bed MB |
5659 | (defcustom gnus-mime-display-multipart-as-mixed nil |
5660 | "Display \"multipart\" parts as \"multipart/mixed\". | |
5661 | ||
5662 | If t, it overrides nil values of | |
5663 | `gnus-mime-display-multipart-alternative-as-mixed' and | |
5664 | `gnus-mime-display-multipart-related-as-mixed'." | |
5665 | :group 'gnus-article-mime | |
5666 | :type 'boolean) | |
5667 | ||
5668 | (defcustom gnus-mime-display-multipart-alternative-as-mixed nil | |
5669 | "Display \"multipart/alternative\" parts as \"multipart/mixed\"." | |
bf247b6e | 5670 | :version "22.1" |
23f87bed MB |
5671 | :group 'gnus-article-mime |
5672 | :type 'boolean) | |
5673 | ||
5674 | (defcustom gnus-mime-display-multipart-related-as-mixed nil | |
5675 | "Display \"multipart/related\" parts as \"multipart/mixed\". | |
5676 | ||
5677 | If displaying \"text/html\" is discouraged \(see | |
5678 | `mm-discouraged-alternatives'\) images or other material inside a | |
5679 | \"multipart/related\" part might be overlooked when this variable is nil." | |
bf247b6e | 5680 | :version "22.1" |
23f87bed MB |
5681 | :group 'gnus-article-mime |
5682 | :type 'boolean) | |
16409b0b GM |
5683 | |
5684 | (defun gnus-mime-display-part (handle) | |
5685 | (cond | |
430d3ed7 MB |
5686 | ;; Maybe a broken MIME message. |
5687 | ((null handle)) | |
16409b0b GM |
5688 | ;; Single part. |
5689 | ((not (stringp (car handle))) | |
5690 | (gnus-mime-display-single handle)) | |
5691 | ;; User-defined multipart | |
5692 | ((cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
5693 | (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions)) | |
5694 | handle)) | |
5695 | ;; multipart/alternative | |
5696 | ((and (equal (car handle) "multipart/alternative") | |
23f87bed MB |
5697 | (not (or gnus-mime-display-multipart-as-mixed |
5698 | gnus-mime-display-multipart-alternative-as-mixed))) | |
16409b0b GM |
5699 | (let ((id (1+ (length gnus-article-mime-handle-alist)))) |
5700 | (push (cons id handle) gnus-article-mime-handle-alist) | |
5701 | (gnus-mime-display-alternative (cdr handle) nil nil id))) | |
5702 | ;; multipart/related | |
5703 | ((and (equal (car handle) "multipart/related") | |
23f87bed MB |
5704 | (not (or gnus-mime-display-multipart-as-mixed |
5705 | gnus-mime-display-multipart-related-as-mixed))) | |
16409b0b GM |
5706 | ;;;!!!We should find the start part, but we just default |
5707 | ;;;!!!to the first part. | |
23f87bed MB |
5708 | ;;(gnus-mime-display-part (cadr handle)) |
5709 | ;;;!!! Most multipart/related is an HTML message plus images. | |
5710 | ;;;!!! Unfortunately we are unable to let W3 display those | |
5711 | ;;;!!! included images, so we just display it as a mixed multipart. | |
5712 | ;;(gnus-mime-display-mixed (cdr handle)) | |
5713 | ;;;!!! No, w3 can display everything just fine. | |
16409b0b | 5714 | (gnus-mime-display-part (cadr handle))) |
23f87bed MB |
5715 | ((equal (car handle) "multipart/signed") |
5716 | (gnus-add-wash-type 'signed) | |
5717 | (gnus-mime-display-security handle)) | |
5718 | ((equal (car handle) "multipart/encrypted") | |
5719 | (gnus-add-wash-type 'encrypted) | |
5720 | (gnus-mime-display-security handle)) | |
16409b0b GM |
5721 | ;; Other multiparts are handled like multipart/mixed. |
5722 | (t | |
5723 | (gnus-mime-display-mixed (cdr handle))))) | |
5724 | ||
5725 | (defun gnus-mime-part-function (handles) | |
5726 | (if (stringp (car handles)) | |
5727 | (mapcar 'gnus-mime-part-function (cdr handles)) | |
5728 | (funcall gnus-article-mime-part-function handles))) | |
5729 | ||
5730 | (defun gnus-mime-display-mixed (handles) | |
5731 | (mapcar 'gnus-mime-display-part handles)) | |
5732 | ||
5733 | (defun gnus-mime-display-single (handle) | |
5734 | (let ((type (mm-handle-media-type handle)) | |
5735 | (ignored gnus-ignored-mime-types) | |
5736 | (not-attachment t) | |
5737 | (move nil) | |
5738 | display text) | |
5739 | (catch 'ignored | |
5740 | (progn | |
5741 | (while ignored | |
5742 | (when (string-match (pop ignored) type) | |
5743 | (throw 'ignored nil))) | |
5744 | (if (and (setq not-attachment | |
5745 | (and (not (mm-inline-override-p handle)) | |
5746 | (or (not (mm-handle-disposition handle)) | |
5747 | (equal (car (mm-handle-disposition handle)) | |
5748 | "inline") | |
5749 | (mm-attachment-override-p handle)))) | |
5750 | (mm-automatic-display-p handle) | |
23f87bed MB |
5751 | (or (and |
5752 | (mm-inlinable-p handle) | |
5753 | (mm-inlined-p handle)) | |
16409b0b GM |
5754 | (mm-automatic-external-display-p type))) |
5755 | (setq display t) | |
5756 | (when (equal (mm-handle-media-supertype handle) "text") | |
5757 | (setq text t))) | |
e0bad764 DL |
5758 | (let ((id (1+ (length gnus-article-mime-handle-alist))) |
5759 | beg) | |
16409b0b | 5760 | (push (cons id handle) gnus-article-mime-handle-alist) |
531bedc3 MB |
5761 | (when (and display |
5762 | (equal (mm-handle-media-supertype handle) "message")) | |
5763 | (insert-char | |
5764 | ?\n | |
5765 | (cond ((not (bolp)) 2) | |
5766 | ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0) | |
5767 | (t 1)))) | |
16409b0b GM |
5768 | (when (or (not display) |
5769 | (not (gnus-unbuttonized-mime-type-p type))) | |
16409b0b GM |
5770 | (gnus-insert-mime-button |
5771 | handle id (list (or display (and not-attachment text)))) | |
5772 | (gnus-article-insert-newline) | |
23f87bed | 5773 | ;; Remember modify the number of forward lines. |
e0bad764 DL |
5774 | (setq move t)) |
5775 | (setq beg (point)) | |
16409b0b GM |
5776 | (cond |
5777 | (display | |
5778 | (when move | |
23f87bed | 5779 | (forward-line -1) |
16409b0b GM |
5780 | (setq beg (point))) |
5781 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5782 | (mail-parse-ignored-charsets |
16409b0b GM |
5783 | (save-excursion (condition-case () |
5784 | (set-buffer gnus-summary-buffer) | |
5785 | (error)) | |
5786 | gnus-newsgroup-ignored-charsets))) | |
b0b63450 | 5787 | (gnus-bind-safe-url-regexp (mm-display-part handle t))) |
16409b0b GM |
5788 | (goto-char (point-max))) |
5789 | ((and text not-attachment) | |
5790 | (when move | |
23f87bed | 5791 | (forward-line -1) |
16409b0b GM |
5792 | (setq beg (point))) |
5793 | (gnus-article-insert-newline) | |
53cfefc8 MB |
5794 | (mm-insert-inline |
5795 | handle | |
01c52d31 MB |
5796 | (let ((charset (or (mail-content-type-get (mm-handle-type handle) |
5797 | 'charset) | |
5798 | (and (equal type "text/calendar") 'utf-8)))) | |
53cfefc8 MB |
5799 | (cond ((not charset) |
5800 | (mm-string-as-multibyte (mm-get-part handle))) | |
5801 | ((eq charset 'gnus-decoded) | |
5802 | (with-current-buffer (mm-handle-buffer handle) | |
5803 | (buffer-string))) | |
5804 | (t | |
5805 | (mm-decode-string (mm-get-part handle) charset))))) | |
16409b0b GM |
5806 | (goto-char (point-max)))) |
5807 | ;; Do highlighting. | |
5808 | (save-excursion | |
5809 | (save-restriction | |
5810 | (narrow-to-region beg (point)) | |
01c52d31 MB |
5811 | (if (eq handle gnus-article-mime-handles) |
5812 | ;; The format=flowed case. | |
5813 | (gnus-treat-article nil 1 1 (mm-handle-media-type handle)) | |
5814 | ;; Don't count signature parts that are never displayed. | |
5815 | ;; The part number should be re-calculated supposing this | |
5816 | ;; might be a message/rfc822 part. | |
5817 | (let (handles) | |
5818 | (dolist (part gnus-article-mime-handles) | |
5819 | (unless (or (stringp part) | |
5820 | (equal (car (mm-handle-type part)) | |
5821 | "application/pgp-signature")) | |
5822 | (push part handles))) | |
5823 | (gnus-treat-article | |
5824 | nil (length (memq handle handles)) (length handles) | |
5825 | (mm-handle-media-type handle))))))))))) | |
16409b0b GM |
5826 | |
5827 | (defun gnus-unbuttonized-mime-type-p (type) | |
5828 | "Say whether TYPE is to be unbuttonized." | |
5829 | (unless gnus-inhibit-mime-unbuttonizing | |
23f87bed MB |
5830 | (when (catch 'found |
5831 | (let ((types gnus-unbuttonized-mime-types)) | |
5832 | (while types | |
5833 | (when (string-match (pop types) type) | |
5834 | (throw 'found t))))) | |
5835 | (not (catch 'found | |
5836 | (let ((types gnus-buttonized-mime-types)) | |
5837 | (while types | |
5838 | (when (string-match (pop types) type) | |
5839 | (throw 'found t))))))))) | |
16409b0b GM |
5840 | |
5841 | (defun gnus-article-insert-newline () | |
5842 | "Insert a newline, but mark it as undeletable." | |
5843 | (gnus-put-text-property | |
5844 | (point) (progn (insert "\n") (point)) 'gnus-undeletable t)) | |
5845 | ||
5846 | (defun gnus-mime-display-alternative (handles &optional preferred ibegend id) | |
5847 | (let* ((preferred (or preferred (mm-preferred-alternative handles))) | |
5848 | (ihandles handles) | |
5849 | (point (point)) | |
23f87bed | 5850 | handle (inhibit-read-only t) from props begend not-pref) |
16409b0b GM |
5851 | (save-window-excursion |
5852 | (save-restriction | |
5853 | (when ibegend | |
5854 | (narrow-to-region (car ibegend) | |
5855 | (or (cdr ibegend) | |
5856 | (progn | |
5857 | (goto-char (car ibegend)) | |
5858 | (forward-line 2) | |
5859 | (point)))) | |
5860 | (delete-region (point-min) (point-max)) | |
5861 | (mm-remove-parts handles)) | |
5862 | (setq begend (list (point-marker))) | |
5863 | ;; Do the toggle. | |
5864 | (unless (setq not-pref (cadr (member preferred ihandles))) | |
5865 | (setq not-pref (car ihandles))) | |
5866 | (when (or ibegend | |
23f87bed | 5867 | (not preferred) |
16409b0b GM |
5868 | (not (gnus-unbuttonized-mime-type-p |
5869 | "multipart/alternative"))) | |
5870 | (gnus-add-text-properties | |
5871 | (setq from (point)) | |
5872 | (progn | |
5873 | (insert (format "%d. " id)) | |
5874 | (point)) | |
5875 | `(gnus-callback | |
5876 | (lambda (handles) | |
5877 | (unless ,(not ibegend) | |
5878 | (setq gnus-article-mime-handle-alist | |
5879 | ',gnus-article-mime-handle-alist)) | |
5880 | (gnus-mime-display-alternative | |
5881 | ',ihandles ',not-pref ',begend ,id)) | |
01c52d31 | 5882 | keymap ,gnus-mime-button-map |
16409b0b GM |
5883 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
5884 | face ,gnus-article-button-face | |
16409b0b | 5885 | gnus-part ,id |
7dafe00b | 5886 | article-type multipart)) |
16409b0b GM |
5887 | (widget-convert-button 'link from (point) |
5888 | :action 'gnus-widget-press-button | |
5889 | :button-keymap gnus-widget-button-keymap) | |
5890 | ;; Do the handles | |
5891 | (while (setq handle (pop handles)) | |
5892 | (gnus-add-text-properties | |
5893 | (setq from (point)) | |
5894 | (progn | |
5895 | (insert (format "(%c) %-18s" | |
5896 | (if (equal handle preferred) ?* ? ) | |
5897 | (mm-handle-media-type handle))) | |
5898 | (point)) | |
5899 | `(gnus-callback | |
5900 | (lambda (handles) | |
5901 | (unless ,(not ibegend) | |
5902 | (setq gnus-article-mime-handle-alist | |
5903 | ',gnus-article-mime-handle-alist)) | |
5904 | (gnus-mime-display-alternative | |
5905 | ',ihandles ',handle ',begend ,id)) | |
01c52d31 | 5906 | keymap ,gnus-mime-button-map |
16409b0b GM |
5907 | ,gnus-mouse-face-prop ,gnus-article-mouse-face |
5908 | face ,gnus-article-button-face | |
16409b0b GM |
5909 | gnus-part ,id |
5910 | gnus-data ,handle)) | |
5911 | (widget-convert-button 'link from (point) | |
5912 | :action 'gnus-widget-press-button | |
5913 | :button-keymap gnus-widget-button-keymap) | |
5914 | (insert " ")) | |
5915 | (insert "\n\n")) | |
5916 | (when preferred | |
5917 | (if (stringp (car preferred)) | |
5918 | (gnus-display-mime preferred) | |
5919 | (let ((mail-parse-charset gnus-newsgroup-charset) | |
a1506d29 | 5920 | (mail-parse-ignored-charsets |
01c52d31 MB |
5921 | (with-current-buffer gnus-summary-buffer |
5922 | gnus-newsgroup-ignored-charsets))) | |
b0b63450 | 5923 | (gnus-bind-safe-url-regexp (mm-display-part preferred)) |
16409b0b GM |
5924 | ;; Do highlighting. |
5925 | (save-excursion | |
5926 | (save-restriction | |
5927 | (narrow-to-region (car begend) (point-max)) | |
5928 | (gnus-treat-article | |
5929 | nil (length gnus-article-mime-handle-alist) | |
e0bad764 | 5930 | (gnus-article-mime-total-parts) |
16409b0b GM |
5931 | (mm-handle-media-type handle)))))) |
5932 | (goto-char (point-max)) | |
5933 | (setcdr begend (point-marker))))) | |
5934 | (when ibegend | |
5935 | (goto-char point)))) | |
5936 | ||
23f87bed MB |
5937 | (defconst gnus-article-wash-status-strings |
5938 | (let ((alist '((cite "c" "Possible hidden citation text" | |
5939 | " " "All citation text visible") | |
5940 | (headers "h" "Hidden headers" | |
5941 | " " "All headers visible.") | |
5942 | (pgp "p" "Encrypted or signed message status hidden" | |
5943 | " " "No hidden encryption nor digital signature status") | |
5944 | (signature "s" "Signature has been hidden" | |
5945 | " " "Signature is visible") | |
5946 | (overstrike "o" "Overstrike (^H) characters applied" | |
5947 | " " "No overstrike characters applied") | |
5948 | (emphasis "e" "/*_Emphasis_*/ characters applied" | |
5949 | " " "No /*_emphasis_*/ characters applied"))) | |
5950 | result) | |
5951 | (dolist (entry alist result) | |
5952 | (let ((key (nth 0 entry)) | |
5953 | (on (copy-sequence (nth 1 entry))) | |
5954 | (on-help (nth 2 entry)) | |
5955 | (off (copy-sequence (nth 3 entry))) | |
5956 | (off-help (nth 4 entry))) | |
5957 | (put-text-property 0 1 'help-echo on-help on) | |
5958 | (put-text-property 0 1 'help-echo off-help off) | |
5959 | (push (list key on off) result)))) | |
5960 | "Alist of strings describing wash status in the mode line. | |
5961 | Each entry has the form (KEY ON OF), where the KEY is a symbol | |
5962 | representing the particular washing function, ON is the string to use | |
5963 | in the article mode line when the washing function is active, and OFF | |
5964 | is the string to use when it is inactive.") | |
5965 | ||
5966 | (defun gnus-article-wash-status-entry (key value) | |
5967 | (let ((entry (assoc key gnus-article-wash-status-strings))) | |
5968 | (if value (nth 1 entry) (nth 2 entry)))) | |
5969 | ||
eec82323 LMI |
5970 | (defun gnus-article-wash-status () |
5971 | "Return a string which display status of article washing." | |
01c52d31 | 5972 | (with-current-buffer gnus-article-buffer |
16409b0b GM |
5973 | (let ((cite (memq 'cite gnus-article-wash-types)) |
5974 | (headers (memq 'headers gnus-article-wash-types)) | |
5975 | (boring (memq 'boring-headers gnus-article-wash-types)) | |
5976 | (pgp (memq 'pgp gnus-article-wash-types)) | |
5977 | (pem (memq 'pem gnus-article-wash-types)) | |
23f87bed MB |
5978 | (signed (memq 'signed gnus-article-wash-types)) |
5979 | (encrypted (memq 'encrypted gnus-article-wash-types)) | |
16409b0b GM |
5980 | (signature (memq 'signature gnus-article-wash-types)) |
5981 | (overstrike (memq 'overstrike gnus-article-wash-types)) | |
5982 | (emphasis (memq 'emphasis gnus-article-wash-types))) | |
23f87bed MB |
5983 | (concat |
5984 | (gnus-article-wash-status-entry 'cite cite) | |
5985 | (gnus-article-wash-status-entry 'headers (or headers boring)) | |
5986 | (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted)) | |
5987 | (gnus-article-wash-status-entry 'signature signature) | |
5988 | (gnus-article-wash-status-entry 'overstrike overstrike) | |
5989 | (gnus-article-wash-status-entry 'emphasis emphasis))))) | |
5990 | ||
5991 | (defun gnus-add-wash-type (type) | |
5992 | "Add a washing of TYPE to the current status." | |
5993 | (add-to-list 'gnus-article-wash-types type)) | |
5994 | ||
5995 | (defun gnus-delete-wash-type (type) | |
5996 | "Add a washing of TYPE to the current status." | |
5997 | (setq gnus-article-wash-types (delq type gnus-article-wash-types))) | |
5998 | ||
5999 | (defun gnus-add-image (category image) | |
6000 | "Add IMAGE of CATEGORY to the list of displayed images." | |
6001 | (let ((entry (assq category gnus-article-image-alist))) | |
6002 | (unless entry | |
6003 | (setq entry (list category)) | |
6004 | (push entry gnus-article-image-alist)) | |
6005 | (nconc entry (list image)))) | |
6006 | ||
6007 | (defun gnus-delete-images (category) | |
6008 | "Delete all images in CATEGORY." | |
6009 | (let ((entry (assq category gnus-article-image-alist))) | |
6010 | (dolist (image (cdr entry)) | |
6011 | (gnus-remove-image image category)) | |
6012 | (setq gnus-article-image-alist (delq entry gnus-article-image-alist)) | |
6013 | (gnus-delete-wash-type category))) | |
eec82323 | 6014 | |
16409b0b | 6015 | (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers) |
6748645f LMI |
6016 | |
6017 | (defun gnus-article-maybe-hide-headers () | |
eec82323 LMI |
6018 | "Hide unwanted headers if `gnus-have-all-headers' is nil. |
6019 | Provided for backwards compatibility." | |
16409b0b | 6020 | (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer)) |
01c52d31 MB |
6021 | (not (with-current-buffer gnus-summary-buffer |
6022 | gnus-have-all-headers))) | |
16409b0b GM |
6023 | (not gnus-inhibit-hiding)) |
6024 | (gnus-article-hide-headers))) | |
eec82323 LMI |
6025 | |
6026 | ;;; Article savers. | |
6027 | ||
6028 | (defun gnus-output-to-file (file-name) | |
26c9afc3 MB |
6029 | "Append the current article to a file named FILE-NAME. |
6030 | If `gnus-article-save-coding-system' is non-nil, it is used to encode | |
6031 | text and used as the value of the coding cookie which is added to the | |
6032 | top of a file. Otherwise, this function saves a raw article without | |
6033 | the coding cookie." | |
6034 | (let* ((artbuf (current-buffer)) | |
6035 | (file-name-coding-system nnmail-pathname-coding-system) | |
6036 | (coding gnus-article-save-coding-system) | |
6037 | (coding-system-for-read (if coding | |
6038 | nil ;; Rely on the coding cookie. | |
6039 | mm-text-coding-system)) | |
6040 | (coding-system-for-write (or coding | |
6041 | mm-text-coding-system-for-write | |
6042 | mm-text-coding-system)) | |
6043 | (exists (file-exists-p file-name))) | |
16409b0b | 6044 | (with-temp-buffer |
26c9afc3 MB |
6045 | (when exists |
6046 | (insert-file-contents file-name) | |
6047 | (goto-char (point-min)) | |
6048 | ;; Remove the existing coding cookie. | |
6049 | (when (looking-at "X-Gnus-Coding-System: .+\n\n") | |
6050 | (delete-region (match-beginning 0) (match-end 0)))) | |
6051 | (goto-char (point-max)) | |
eec82323 LMI |
6052 | (insert-buffer-substring artbuf) |
6053 | ;; Append newline at end of the buffer as separator, and then | |
6054 | ;; save it to file. | |
6055 | (goto-char (point-max)) | |
6056 | (insert "\n") | |
26c9afc3 MB |
6057 | (when coding |
6058 | ;; If the coding system is not suitable to encode the text, | |
6059 | ;; ask a user for a proper one. | |
6060 | (when (fboundp 'select-safe-coding-system) | |
6061 | (setq coding (coding-system-base | |
6062 | (save-window-excursion | |
6063 | (select-safe-coding-system (point-min) (point-max) | |
6064 | coding)))) | |
6065 | (setq coding-system-for-write | |
6066 | (or (cdr (assq coding '((mule-utf-8 . utf-8)))) | |
6067 | coding))) | |
6068 | (goto-char (point-min)) | |
6069 | ;; Add the coding cookie. | |
6070 | (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n" | |
6071 | coding-system-for-write))) | |
6072 | (if exists | |
6073 | (progn | |
6074 | (write-region (point-min) (point-max) file-name nil 'no-message) | |
6075 | (message "Appended to %s" file-name)) | |
6076 | (write-region (point-min) (point-max) file-name)))) | |
6077 | t) | |
eec82323 LMI |
6078 | |
6079 | (defun gnus-narrow-to-page (&optional arg) | |
6080 | "Narrow the article buffer to a page. | |
6081 | If given a numerical ARG, move forward ARG pages." | |
6082 | (interactive "P") | |
6083 | (setq arg (if arg (prefix-numeric-value arg) 0)) | |
80de1778 | 6084 | (with-current-buffer gnus-article-buffer |
eec82323 LMI |
6085 | (widen) |
6086 | ;; Remove any old next/prev buttons. | |
6087 | (when (gnus-visual-p 'page-marker) | |
4e7d0221 | 6088 | (let ((inhibit-read-only t)) |
eec82323 LMI |
6089 | (gnus-remove-text-with-property 'gnus-prev) |
6090 | (gnus-remove-text-with-property 'gnus-next))) | |
8f7abae3 MB |
6091 | (let (st nd pt) |
6092 | (when (save-excursion | |
6093 | (cond ((< arg 0) | |
6094 | (if (re-search-backward page-delimiter nil 'move (abs arg)) | |
6095 | (prog1 | |
6096 | (setq nd (match-beginning 0) | |
6097 | pt nd) | |
6098 | (when (re-search-backward page-delimiter nil t) | |
6099 | (setq st (match-end 0)))) | |
6100 | (when (re-search-forward page-delimiter nil t) | |
6101 | (setq nd (match-beginning 0) | |
6102 | pt (point-min))))) | |
6103 | ((> arg 0) | |
6104 | (if (re-search-forward page-delimiter nil 'move arg) | |
6105 | (prog1 | |
6106 | (setq st (match-end 0) | |
6107 | pt st) | |
6108 | (when (re-search-forward page-delimiter nil t) | |
6109 | (setq nd (match-beginning 0)))) | |
6110 | (when (re-search-backward page-delimiter nil t) | |
6111 | (setq st (match-end 0) | |
6112 | pt (point-max))))) | |
6113 | (t | |
6114 | (when (re-search-backward page-delimiter nil t) | |
6115 | (goto-char (setq st (match-end 0)))) | |
6116 | (when (re-search-forward page-delimiter nil t) | |
6117 | (setq nd (match-beginning 0))) | |
6118 | (or st nd)))) | |
6119 | (setq gnus-page-broken t) | |
6120 | (when pt (goto-char pt)) | |
6121 | (narrow-to-region (or st (point-min)) (or nd (point-max))) | |
6122 | (when (gnus-visual-p 'page-marker) | |
6123 | (save-excursion | |
6124 | (when nd | |
6125 | (goto-char nd) | |
6126 | (gnus-insert-next-page-button)) | |
6127 | (when st | |
6128 | (goto-char st) | |
6129 | (gnus-insert-prev-page-button)))))))) | |
eec82323 LMI |
6130 | |
6131 | ;; Article mode commands | |
6132 | ||
6133 | (defun gnus-article-goto-next-page () | |
6134 | "Show the next page of the article." | |
6135 | (interactive) | |
6136 | (when (gnus-article-next-page) | |
6137 | (goto-char (point-min)) | |
6138 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
6139 | ||
23f87bed | 6140 | |
eec82323 | 6141 | (defun gnus-article-goto-prev-page () |
23f87bed | 6142 | "Show the previous page of the article." |
eec82323 | 6143 | (interactive) |
8f7abae3 | 6144 | (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer? |
23f87bed | 6145 | (gnus-article-read-summary-keys nil (gnus-character-to-event ?p)) |
eec82323 LMI |
6146 | (gnus-article-prev-page nil))) |
6147 | ||
23f87bed MB |
6148 | ;; This is cleaner but currently breaks `gnus-pick-mode': |
6149 | ;; | |
6150 | ;; (defun gnus-article-goto-next-page () | |
6151 | ;; "Show the next page of the article." | |
6152 | ;; (interactive) | |
6153 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer | |
6154 | ;; (gnus-summary-next-page))) | |
6155 | ;; | |
6156 | ;; (defun gnus-article-goto-prev-page () | |
6157 | ;; "Show the next page of the article." | |
6158 | ;; (interactive) | |
6159 | ;; (gnus-eval-in-buffer-window gnus-summary-buffer | |
6160 | ;; (gnus-summary-prev-page))) | |
6161 | ||
eec82323 LMI |
6162 | (defun gnus-article-next-page (&optional lines) |
6163 | "Show the next page of the current article. | |
6164 | If end of article, return non-nil. Otherwise return nil. | |
6165 | Argument LINES specifies lines to be scrolled up." | |
6166 | (interactive "p") | |
9153f10d | 6167 | (move-to-window-line (if (featurep 'xemacs) -1 (- -1 scroll-margin))) |
60ece9b0 MB |
6168 | (if (and (not (and gnus-article-over-scroll |
6169 | (> (count-lines (window-start) (point-max)) | |
9153f10d MB |
6170 | (if (featurep 'xemacs) |
6171 | (or lines (1- (window-height))) | |
6172 | (+ (or lines (1- (window-height))) scroll-margin))))) | |
60ece9b0 MB |
6173 | (save-excursion |
6174 | (end-of-line) | |
6175 | (and (pos-visible-in-window-p) ;Not continuation line. | |
6176 | (>= (1+ (point)) (point-max))))) ;Allow for trailing newline. | |
eec82323 LMI |
6177 | ;; Nothing in this page. |
6178 | (if (or (not gnus-page-broken) | |
6179 | (save-excursion | |
6180 | (save-restriction | |
23f87bed MB |
6181 | (widen) |
6182 | (forward-line) | |
6183 | (eobp)))) ;Real end-of-buffer? | |
6184 | (progn | |
6185 | (when gnus-article-over-scroll | |
6186 | (gnus-article-next-page-1 lines)) | |
6187 | t) ;Nothing more. | |
eec82323 LMI |
6188 | (gnus-narrow-to-page 1) ;Go to next page. |
6189 | nil) | |
6190 | ;; More in this page. | |
23f87bed | 6191 | (gnus-article-next-page-1 lines) |
eec82323 LMI |
6192 | nil)) |
6193 | ||
d8a88581 MB |
6194 | (defmacro gnus-article-beginning-of-window () |
6195 | "Move point to the beginning of the window. | |
6196 | In Emacs, the point is placed at the line number which `scroll-margin' | |
6197 | specifies." | |
6198 | (if (featurep 'xemacs) | |
6199 | '(move-to-window-line 0) | |
6200 | '(move-to-window-line | |
6201 | (min (max 0 scroll-margin) | |
6202 | (max 1 (- (window-height) | |
6203 | (if mode-line-format 1 0) | |
9153f10d MB |
6204 | (if header-line-format 1 0) |
6205 | 2)))))) | |
d8a88581 | 6206 | |
23f87bed | 6207 | (defun gnus-article-next-page-1 (lines) |
9153f10d | 6208 | (unless (featurep 'xemacs) |
4b91459a MB |
6209 | ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for |
6210 | ;; too many number of lines if `scroll-margin' is set as two or greater. | |
9153f10d MB |
6211 | (when (and (numberp lines) |
6212 | (> lines 0) | |
6213 | (> scroll-margin 0)) | |
6214 | (setq lines (min lines | |
6215 | (max 0 (- (count-lines (window-start) (point-max)) | |
6216 | scroll-margin)))))) | |
4b91459a MB |
6217 | (condition-case () |
6218 | (let ((scroll-in-place nil)) | |
6219 | (scroll-up lines)) | |
6220 | (end-of-buffer | |
6221 | ;; Long lines may cause an end-of-buffer error. | |
6222 | (goto-char (point-max)))) | |
6223 | (gnus-article-beginning-of-window)) | |
23f87bed | 6224 | |
eec82323 LMI |
6225 | (defun gnus-article-prev-page (&optional lines) |
6226 | "Show previous page of current article. | |
6227 | Argument LINES specifies lines to be scrolled down." | |
6228 | (interactive "p") | |
d8a88581 | 6229 | (move-to-window-line 0) |
eec82323 LMI |
6230 | (if (and gnus-page-broken |
6231 | (bobp) | |
6232 | (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
6233 | (progn | |
6234 | (gnus-narrow-to-page -1) ;Go to previous page. | |
6235 | (goto-char (point-max)) | |
60ece9b0 MB |
6236 | (recenter (if gnus-article-over-scroll |
6237 | (if lines | |
9153f10d MB |
6238 | (max (if (featurep 'xemacs) |
6239 | lines | |
6240 | (+ lines scroll-margin)) | |
60ece9b0 MB |
6241 | 3) |
6242 | (- (window-height) 2)) | |
6243 | -1))) | |
c03ac728 MB |
6244 | (prog1 |
6245 | (condition-case () | |
6246 | (let ((scroll-in-place nil)) | |
6247 | (scroll-down lines)) | |
6248 | (beginning-of-buffer | |
6249 | (goto-char (point-min)))) | |
6250 | (gnus-article-beginning-of-window)))) | |
eec82323 | 6251 | |
23f87bed MB |
6252 | (defun gnus-article-only-boring-p () |
6253 | "Decide whether there is only boring text remaining in the article. | |
6254 | Something \"interesting\" is a word of at least two letters that does | |
6255 | not have a face in `gnus-article-boring-faces'." | |
6256 | (when (and gnus-article-skip-boring | |
6257 | (boundp 'gnus-article-boring-faces) | |
6258 | (symbol-value 'gnus-article-boring-faces)) | |
6259 | (save-excursion | |
531bedc3 MB |
6260 | (let ((inhibit-point-motion-hooks t)) |
6261 | (catch 'only-boring | |
6262 | (while (re-search-forward "\\b\\w\\w" nil t) | |
6263 | (forward-char -1) | |
6264 | (when (not (gnus-intersection | |
6265 | (gnus-faces-at (point)) | |
6266 | (symbol-value 'gnus-article-boring-faces))) | |
6267 | (throw 'only-boring nil))) | |
6268 | (throw 'only-boring t)))))) | |
23f87bed | 6269 | |
eec82323 LMI |
6270 | (defun gnus-article-refer-article () |
6271 | "Read article specified by message-id around point." | |
6272 | (interactive) | |
23f87bed | 6273 | (save-excursion |
01c52d31 MB |
6274 | (re-search-backward "[ \t]\\|^" (point-at-bol) t) |
6275 | (re-search-forward "<?news:<?\\|<" (point-at-eol) t) | |
6276 | (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t) | |
23f87bed | 6277 | (let ((msg-id (concat "<" (match-string 0) ">"))) |
eec82323 | 6278 | (set-buffer gnus-summary-buffer) |
23f87bed | 6279 | (gnus-summary-refer-article msg-id)) |
eec82323 LMI |
6280 | (error "No references around point")))) |
6281 | ||
6282 | (defun gnus-article-show-summary () | |
6283 | "Reconfigure windows to show summary buffer." | |
6284 | (interactive) | |
6285 | (if (not (gnus-buffer-live-p gnus-summary-buffer)) | |
6286 | (error "There is no summary buffer for this article buffer") | |
a8151ef7 | 6287 | (gnus-article-set-globals) |
eec82323 | 6288 | (gnus-configure-windows 'article) |
6748645f LMI |
6289 | (gnus-summary-goto-subject gnus-current-article) |
6290 | (gnus-summary-position-point))) | |
eec82323 LMI |
6291 | |
6292 | (defun gnus-article-describe-briefly () | |
6293 | "Describe article mode commands briefly." | |
6294 | (interactive) | |
16409b0b | 6295 | (gnus-message 6 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help"))) |
eec82323 | 6296 | |
16409b0b GM |
6297 | (defun gnus-article-check-buffer () |
6298 | "Beep if not in an article buffer." | |
6299 | (unless (equal major-mode 'gnus-article-mode) | |
6300 | (error "Command invoked outside of a Gnus article buffer"))) | |
6301 | ||
eec82323 LMI |
6302 | (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) |
6303 | "Read a summary buffer key sequence and execute it from the article buffer." | |
6304 | (interactive "P") | |
16409b0b | 6305 | (gnus-article-check-buffer) |
eec82323 | 6306 | (let ((nosaves |
23f87bed MB |
6307 | '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f" |
6308 | "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
6309 | "=" "^" "\M-^" "|")) | |
6310 | (nosave-but-article | |
0b6799c3 MB |
6311 | '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae" |
6312 | "An" "Ap" [?A (meta return)] [?A delete])) | |
23f87bed | 6313 | (nosave-in-article |
0b6799c3 | 6314 | '("AS" "\C-d")) |
23f87bed MB |
6315 | (up-to-top |
6316 | '("n" "Gn" "p" "Gp")) | |
6317 | keys new-sum-point) | |
80de1778 | 6318 | (with-current-buffer gnus-article-current-summary |
eec82323 | 6319 | (let (gnus-pick-mode) |
95838435 MB |
6320 | (setq unread-command-events (nconc unread-command-events |
6321 | (list (or key last-command-event))) | |
6322 | keys (if (featurep 'xemacs) | |
6323 | (events-to-keys (read-key-sequence nil t)) | |
6324 | (read-key-sequence nil t))))) | |
a1506d29 | 6325 | |
eec82323 LMI |
6326 | (message "") |
6327 | ||
01c52d31 MB |
6328 | (cond |
6329 | ((eq (aref keys (1- (length keys))) ?\C-h) | |
0b6799c3 | 6330 | (gnus-article-describe-bindings (substring keys 0 -1))) |
01c52d31 MB |
6331 | ((or (member keys nosaves) |
6332 | (member keys nosave-but-article) | |
6333 | (member keys nosave-in-article)) | |
6334 | (let (func) | |
6335 | (save-window-excursion | |
6336 | (pop-to-buffer gnus-article-current-summary) | |
6337 | ;; We disable the pick minor mode commands. | |
6338 | (let (gnus-pick-mode) | |
6ab2c7a8 | 6339 | (setq func (key-binding keys t)))) |
01c52d31 MB |
6340 | (if (or (not func) |
6341 | (numberp func)) | |
6342 | (ding) | |
6343 | (unless (member keys nosave-in-article) | |
6344 | (set-buffer gnus-article-current-summary)) | |
6345 | (call-interactively func) | |
6346 | (setq new-sum-point (point))) | |
6347 | (when (member keys nosave-but-article) | |
6348 | (pop-to-buffer gnus-article-buffer)))) | |
6349 | (t | |
eec82323 LMI |
6350 | ;; These commands should restore window configuration. |
6351 | (let ((obuf (current-buffer)) | |
23f87bed | 6352 | (owin (current-window-configuration)) |
01c52d31 | 6353 | win func in-buffer selected new-sum-start new-sum-hscroll err) |
23f87bed | 6354 | (cond (not-restore-window |
01c52d31 MB |
6355 | (pop-to-buffer gnus-article-current-summary) |
6356 | (setq win (selected-window))) | |
23f87bed MB |
6357 | ((setq win (get-buffer-window gnus-article-current-summary)) |
6358 | (select-window win)) | |
6359 | (t | |
01c52d31 MB |
6360 | (let ((summary-buffer gnus-article-current-summary)) |
6361 | (gnus-configure-windows 'article) | |
6362 | (unless (setq win (get-buffer-window summary-buffer 'visible)) | |
6363 | (let ((gnus-buffer-configuration | |
de0bdfe7 KY |
6364 | '((article ((vertical 1.0 |
6365 | (summary 0.25 point) | |
6366 | (article 1.0))))))) | |
01c52d31 MB |
6367 | (gnus-configure-windows 'article)) |
6368 | (setq win (get-buffer-window summary-buffer 'visible))) | |
6369 | (gnus-select-frame-set-input-focus (window-frame win)) | |
6370 | (select-window win)))) | |
23f87bed MB |
6371 | (setq in-buffer (current-buffer)) |
6372 | ;; We disable the pick minor mode commands. | |
6373 | (if (and (setq func (let (gnus-pick-mode) | |
6ab2c7a8 | 6374 | (key-binding keys t))) |
01c52d31 MB |
6375 | (functionp func) |
6376 | (condition-case code | |
6377 | (progn | |
6378 | (call-interactively func) | |
6379 | t) | |
6380 | (error | |
6381 | (setq err code) | |
6382 | nil))) | |
23f87bed | 6383 | (progn |
23f87bed MB |
6384 | (when (eq win (selected-window)) |
6385 | (setq new-sum-point (point) | |
6386 | new-sum-start (window-start win) | |
9a89f5b0 | 6387 | new-sum-hscroll (window-hscroll win))) |
01c52d31 MB |
6388 | (when (or (eq in-buffer (current-buffer)) |
6389 | (when (eq obuf (current-buffer)) | |
6390 | (set-buffer in-buffer) | |
6391 | t)) | |
520aa572 SZ |
6392 | (setq selected (gnus-summary-select-article)) |
6393 | (set-buffer obuf) | |
6394 | (unless not-restore-window | |
6395 | (set-window-configuration owin)) | |
01c52d31 MB |
6396 | (when (and (eq selected 'old) |
6397 | new-sum-point) | |
520aa572 SZ |
6398 | (set-window-start (get-buffer-window (current-buffer)) |
6399 | 1) | |
6400 | (set-window-point (get-buffer-window (current-buffer)) | |
01c52d31 MB |
6401 | (if (article-goto-body) |
6402 | (1- (point)) | |
6403 | (point)))) | |
23f87bed | 6404 | (when (and (not not-restore-window) |
01c52d31 | 6405 | new-sum-point |
4520e527 | 6406 | (window-live-p win) |
01c52d31 MB |
6407 | (with-current-buffer (window-buffer win) |
6408 | (eq major-mode 'gnus-summary-mode))) | |
23f87bed MB |
6409 | (set-window-point win new-sum-point) |
6410 | (set-window-start win new-sum-start) | |
9a89f5b0 | 6411 | (set-window-hscroll win new-sum-hscroll)))) |
23f87bed | 6412 | (set-window-configuration owin) |
01c52d31 MB |
6413 | (if err |
6414 | (signal (car err) (cdr err)) | |
6415 | (ding)))))))) | |
520aa572 | 6416 | |
95838435 MB |
6417 | (defun gnus-article-read-summary-send-keys () |
6418 | (interactive) | |
0b6799c3 | 6419 | (let ((unread-command-events (list (gnus-character-to-event ?S)))) |
95838435 MB |
6420 | (gnus-article-read-summary-keys))) |
6421 | ||
520aa572 | 6422 | (defun gnus-article-describe-key (key) |
95838435 MB |
6423 | "Display documentation of the function invoked by KEY. |
6424 | KEY is a string or a vector." | |
6425 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. | |
6426 | (read-key-sequence "Describe key: ")))) | |
520aa572 | 6427 | (gnus-article-check-buffer) |
95838435 MB |
6428 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
6429 | gnus-article-read-summary-send-keys)) | |
80de1778 | 6430 | (with-current-buffer gnus-article-current-summary |
95838435 MB |
6431 | (setq unread-command-events |
6432 | (if (featurep 'xemacs) | |
6433 | (append key nil) | |
6434 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) | |
6435 | (list 'meta (- x 128)) | |
6436 | x)) | |
6437 | key))) | |
6438 | (let ((cursor-in-echo-area t) | |
6439 | gnus-pick-mode) | |
6440 | (describe-key (read-key-sequence nil t)))) | |
520aa572 SZ |
6441 | (describe-key key))) |
6442 | ||
6443 | (defun gnus-article-describe-key-briefly (key &optional insert) | |
95838435 MB |
6444 | "Display documentation of the function invoked by KEY. |
6445 | KEY is a string or a vector." | |
6446 | (interactive (list (let ((cursor-in-echo-area t)) ;; better for XEmacs. | |
6447 | (read-key-sequence "Describe key: ")) | |
6448 | current-prefix-arg)) | |
520aa572 | 6449 | (gnus-article-check-buffer) |
95838435 MB |
6450 | (if (memq (key-binding key t) '(gnus-article-read-summary-keys |
6451 | gnus-article-read-summary-send-keys)) | |
80de1778 | 6452 | (with-current-buffer gnus-article-current-summary |
95838435 MB |
6453 | (setq unread-command-events |
6454 | (if (featurep 'xemacs) | |
6455 | (append key nil) | |
6456 | (mapcar (lambda (x) (if (and (integerp x) (>= x 128)) | |
6457 | (list 'meta (- x 128)) | |
6458 | x)) | |
6459 | key))) | |
6460 | (let ((cursor-in-echo-area t) | |
6461 | gnus-pick-mode) | |
6462 | (describe-key-briefly (read-key-sequence nil t) insert))) | |
520aa572 | 6463 | (describe-key-briefly key insert))) |
eec82323 | 6464 | |
0b6799c3 MB |
6465 | ;;`gnus-agent-mode' in gnus-agent.el will define it. |
6466 | (defvar gnus-agent-summary-mode) | |
e9198520 | 6467 | (defvar gnus-draft-mode) |
12ea3d65 GM |
6468 | ;; Calling help-buffer will autoload help-mode. |
6469 | (defvar help-xref-stack-item) | |
0b6799c3 MB |
6470 | |
6471 | (defun gnus-article-describe-bindings (&optional prefix) | |
6472 | "Show a list of all defined keys, and their definitions. | |
6473 | The optional argument PREFIX, if non-nil, should be a key sequence; | |
6474 | then we display only bindings that start with that prefix." | |
6475 | (interactive) | |
6476 | (gnus-article-check-buffer) | |
6477 | (let ((keymap (copy-keymap gnus-article-mode-map)) | |
6478 | (map (copy-keymap gnus-article-send-map)) | |
6479 | (sumkeys (where-is-internal 'gnus-article-read-summary-keys)) | |
8a908224 | 6480 | parent agent draft) |
0b6799c3 MB |
6481 | (define-key keymap "S" map) |
6482 | (define-key map [t] nil) | |
6483 | (with-current-buffer gnus-article-current-summary | |
8a908224 KY |
6484 | (set-keymap-parent |
6485 | keymap | |
6486 | (if (setq parent (keymap-parent gnus-article-mode-map)) | |
6487 | (prog1 | |
6488 | (setq parent (copy-keymap parent)) | |
6489 | (set-keymap-parent parent (current-local-map))) | |
6490 | (current-local-map))) | |
0b6799c3 | 6491 | (set-keymap-parent map (key-binding "S")) |
8f7abae3 MB |
6492 | (let (key def gnus-pick-mode) |
6493 | (while sumkeys | |
6494 | (setq key (pop sumkeys)) | |
6495 | (cond ((and (vectorp key) (= (length key) 1) | |
6496 | (consp (setq def (aref key 0))) | |
6497 | (numberp (car def)) (numberp (cdr def))) | |
6498 | (when (< (max (car def) (cdr def)) 128) | |
6499 | (setq sumkeys | |
6500 | (append (mapcar | |
6501 | #'vector | |
6502 | (nreverse (gnus-uncompress-range def))) | |
6503 | sumkeys)))) | |
6504 | ((setq def (key-binding key)) | |
6505 | (unless (eq def 'undefined) | |
6506 | (define-key keymap key def)))))) | |
0b6799c3 | 6507 | (when (boundp 'gnus-agent-summary-mode) |
e9198520 MB |
6508 | (setq agent gnus-agent-summary-mode)) |
6509 | (when (boundp 'gnus-draft-mode) | |
6510 | (setq draft gnus-draft-mode))) | |
0b6799c3 MB |
6511 | (with-temp-buffer |
6512 | (use-local-map keymap) | |
6513 | (set (make-local-variable 'gnus-agent-summary-mode) agent) | |
e9198520 | 6514 | (set (make-local-variable 'gnus-draft-mode) draft) |
0b6799c3 MB |
6515 | (describe-bindings prefix)) |
6516 | (let ((item `((lambda (prefix) | |
80de1778 | 6517 | (with-current-buffer ,(current-buffer) |
0b6799c3 MB |
6518 | (gnus-article-describe-bindings prefix))) |
6519 | ,prefix))) | |
6520 | (with-current-buffer (if (fboundp 'help-buffer) | |
6521 | (let (help-xref-following) (help-buffer)) | |
6522 | "*Help*") ;; Emacs 21 | |
6523 | (setq help-xref-stack-item item))))) | |
6524 | ||
23f87bed MB |
6525 | (defun gnus-article-reply-with-original (&optional wide) |
6526 | "Start composing a reply mail to the current message. | |
6527 | The text in the region will be yanked. If the region isn't active, | |
6528 | the entire article will be yanked." | |
95838435 | 6529 | (interactive) |
23f87bed MB |
6530 | (let ((article (cdr gnus-article-current)) |
6531 | contents) | |
1d0df8af | 6532 | (if (not (gnus-region-active-p)) |
23f87bed MB |
6533 | (with-current-buffer gnus-summary-buffer |
6534 | (gnus-summary-reply (list (list article)) wide)) | |
6535 | (setq contents (buffer-substring (point) (mark t))) | |
6536 | ;; Deactivate active regions. | |
6537 | (when (and (boundp 'transient-mark-mode) | |
6538 | transient-mark-mode) | |
6539 | (setq mark-active nil)) | |
6540 | (with-current-buffer gnus-summary-buffer | |
6541 | (gnus-summary-reply | |
6542 | (list (list article contents)) wide))))) | |
6543 | ||
95838435 MB |
6544 | (defun gnus-article-wide-reply-with-original () |
6545 | "Start composing a wide reply mail to the current message. | |
6546 | The text in the region will be yanked. If the region isn't active, | |
6547 | the entire article will be yanked." | |
6548 | (interactive) | |
6549 | (gnus-article-reply-with-original t)) | |
6550 | ||
23f87bed MB |
6551 | (defun gnus-article-followup-with-original () |
6552 | "Compose a followup to the current article. | |
6553 | The text in the region will be yanked. If the region isn't active, | |
6554 | the entire article will be yanked." | |
6555 | (interactive) | |
6556 | (let ((article (cdr gnus-article-current)) | |
6557 | contents) | |
1d0df8af | 6558 | (if (not (gnus-region-active-p)) |
23f87bed MB |
6559 | (with-current-buffer gnus-summary-buffer |
6560 | (gnus-summary-followup (list (list article)))) | |
6561 | (setq contents (buffer-substring (point) (mark t))) | |
6562 | ;; Deactivate active regions. | |
6563 | (when (and (boundp 'transient-mark-mode) | |
6564 | transient-mark-mode) | |
6565 | (setq mark-active nil)) | |
6566 | (with-current-buffer gnus-summary-buffer | |
6567 | (gnus-summary-followup | |
6568 | (list (list article contents))))))) | |
6569 | ||
eec82323 LMI |
6570 | (defun gnus-article-hide (&optional arg force) |
6571 | "Hide all the gruft in the current article. | |
23f87bed MB |
6572 | This means that signatures, cited text and (some) headers will be |
6573 | hidden. | |
eec82323 | 6574 | If given a prefix, show the hidden text instead." |
6748645f | 6575 | (interactive (append (gnus-article-hidden-arg) (list 'force))) |
eec82323 | 6576 | (gnus-article-hide-headers arg) |
16409b0b | 6577 | (gnus-article-hide-list-identifiers arg) |
eec82323 LMI |
6578 | (gnus-article-hide-citation-maybe arg force) |
6579 | (gnus-article-hide-signature arg)) | |
6580 | ||
6581 | (defun gnus-article-maybe-highlight () | |
6748645f | 6582 | "Do some article highlighting if article highlighting is requested." |
eec82323 LMI |
6583 | (when (gnus-visual-p 'article-highlight 'highlight) |
6584 | (gnus-article-highlight-some))) | |
6585 | ||
6748645f LMI |
6586 | (defun gnus-check-group-server () |
6587 | ;; Make sure the connection to the server is alive. | |
6588 | (unless (gnus-server-opened | |
6589 | (gnus-find-method-for-group gnus-newsgroup-name)) | |
6590 | (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
6591 | (gnus-request-group gnus-newsgroup-name t))) | |
6592 | ||
23f87bed MB |
6593 | (eval-when-compile |
6594 | (autoload 'nneething-get-file-name "nneething")) | |
6595 | ||
eec82323 LMI |
6596 | (defun gnus-request-article-this-buffer (article group) |
6597 | "Get an article and insert it into this buffer." | |
6748645f | 6598 | (let (do-update-line sparse-header) |
eec82323 LMI |
6599 | (prog1 |
6600 | (save-excursion | |
6601 | (erase-buffer) | |
6602 | (gnus-kill-all-overlays) | |
6603 | (setq group (or group gnus-newsgroup-name)) | |
6604 | ||
eec82323 LMI |
6605 | ;; Using `gnus-request-article' directly will insert the article into |
6606 | ;; `nntp-server-buffer' - so we'll save some time by not having to | |
6607 | ;; copy it from the server buffer into the article buffer. | |
6608 | ||
6609 | ;; We only request an article by message-id when we do not have the | |
6610 | ;; headers for it, so we'll have to get those. | |
6611 | (when (stringp article) | |
16409b0b | 6612 | (gnus-read-header article)) |
eec82323 LMI |
6613 | |
6614 | ;; If the article number is negative, that means that this article | |
6615 | ;; doesn't belong in this newsgroup (possibly), so we find its | |
6616 | ;; message-id and request it by id instead of number. | |
6617 | (when (and (numberp article) | |
6618 | gnus-summary-buffer | |
6619 | (get-buffer gnus-summary-buffer) | |
6748645f | 6620 | (gnus-buffer-exists-p gnus-summary-buffer)) |
80de1778 | 6621 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
6622 | (let ((header (gnus-summary-article-header article))) |
6623 | (when (< article 0) | |
6624 | (cond | |
6625 | ((memq article gnus-newsgroup-sparse) | |
6626 | ;; This is a sparse gap article. | |
6627 | (setq do-update-line article) | |
6628 | (setq article (mail-header-id header)) | |
16409b0b | 6629 | (setq sparse-header (gnus-read-header article)) |
eec82323 LMI |
6630 | (setq gnus-newsgroup-sparse |
6631 | (delq article gnus-newsgroup-sparse))) | |
6632 | ((vectorp header) | |
6633 | ;; It's a real article. | |
6634 | (setq article (mail-header-id header))) | |
6635 | (t | |
6636 | ;; It is an extracted pseudo-article. | |
6637 | (setq article 'pseudo) | |
6638 | (gnus-request-pseudo-article header)))) | |
6639 | ||
6640 | (let ((method (gnus-find-method-for-group | |
6641 | gnus-newsgroup-name))) | |
6748645f LMI |
6642 | (when (and (eq (car method) 'nneething) |
6643 | (vectorp header)) | |
23f87bed MB |
6644 | (let ((dir (nneething-get-file-name |
6645 | (mail-header-id header)))) | |
6646 | (when (and (stringp dir) | |
6647 | (file-directory-p dir)) | |
eec82323 LMI |
6648 | (setq article 'nneething) |
6649 | (gnus-group-enter-directory dir)))))))) | |
6650 | ||
6651 | (cond | |
6652 | ;; Refuse to select canceled articles. | |
6653 | ((and (numberp article) | |
6654 | gnus-summary-buffer | |
6655 | (get-buffer gnus-summary-buffer) | |
6748645f | 6656 | (gnus-buffer-exists-p gnus-summary-buffer) |
01c52d31 | 6657 | (eq (cdr (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
6658 | (assq article gnus-newsgroup-reads))) |
6659 | gnus-canceled-mark)) | |
6660 | nil) | |
6661 | ;; We first check `gnus-original-article-buffer'. | |
6662 | ((and (get-buffer gnus-original-article-buffer) | |
6663 | (numberp article) | |
01c52d31 | 6664 | (with-current-buffer gnus-original-article-buffer |
eec82323 LMI |
6665 | (and (equal (car gnus-original-article) group) |
6666 | (eq (cdr gnus-original-article) article)))) | |
75eda25b SM |
6667 | ;; `insert-buffer-substring' would incorrectly use the |
6668 | ;; equivalent of string-make-multibyte which amount to decoding | |
6669 | ;; with locale-coding-system, causing failure of | |
6670 | ;; subsequent decoding. | |
6671 | (insert (mm-string-to-multibyte | |
6672 | (with-current-buffer gnus-original-article-buffer | |
6673 | (buffer-substring (point-min) (point-max))))) | |
eec82323 LMI |
6674 | 'article) |
6675 | ;; Check the backlog. | |
6676 | ((and gnus-keep-backlog | |
6677 | (gnus-backlog-request-article group article (current-buffer))) | |
6678 | 'article) | |
6679 | ;; Check asynchronous pre-fetch. | |
6680 | ((gnus-async-request-fetched-article group article (current-buffer)) | |
6681 | (gnus-async-prefetch-next group article gnus-summary-buffer) | |
6748645f LMI |
6682 | (when (and (numberp article) gnus-keep-backlog) |
6683 | (gnus-backlog-enter-article group article (current-buffer))) | |
eec82323 LMI |
6684 | 'article) |
6685 | ;; Check the cache. | |
6686 | ((and gnus-use-cache | |
6687 | (numberp article) | |
6688 | (gnus-cache-request-article article group)) | |
6689 | 'article) | |
23f87bed MB |
6690 | ;; Check the agent cache. |
6691 | ((gnus-agent-request-article article group) | |
6692 | 'article) | |
eec82323 | 6693 | ;; Get the article and put into the article buffer. |
16409b0b GM |
6694 | ((or (stringp article) |
6695 | (numberp article)) | |
6696 | (let ((gnus-override-method gnus-override-method) | |
a1506d29 | 6697 | (methods (and (stringp article) |
16409b0b | 6698 | gnus-refer-article-method)) |
23f87bed MB |
6699 | (backend (car (gnus-find-method-for-group |
6700 | gnus-newsgroup-name))) | |
16409b0b | 6701 | result |
4e7d0221 | 6702 | (inhibit-read-only t)) |
e0bad764 DL |
6703 | (if (or (not (listp methods)) |
6704 | (and (symbolp (car methods)) | |
6705 | (assq (car methods) nnoo-definition-alist))) | |
6706 | (setq methods (list methods))) | |
16409b0b GM |
6707 | (when (and (null gnus-override-method) |
6708 | methods) | |
6709 | (setq gnus-override-method (pop methods))) | |
6710 | (while (not result) | |
6711 | (when (eq gnus-override-method 'current) | |
c55f89a5 GM |
6712 | (setq gnus-override-method |
6713 | (with-current-buffer gnus-summary-buffer | |
6714 | gnus-current-select-method))) | |
16409b0b GM |
6715 | (erase-buffer) |
6716 | (gnus-kill-all-overlays) | |
6717 | (let ((gnus-newsgroup-name group)) | |
6718 | (gnus-check-group-server)) | |
23f87bed MB |
6719 | (cond |
6720 | ((gnus-request-article article group (current-buffer)) | |
16409b0b | 6721 | (when (numberp article) |
a1506d29 | 6722 | (gnus-async-prefetch-next group article |
16409b0b GM |
6723 | gnus-summary-buffer) |
6724 | (when gnus-keep-backlog | |
6725 | (gnus-backlog-enter-article | |
6726 | group article (current-buffer)))) | |
6727 | (setq result 'article)) | |
23f87bed MB |
6728 | (methods |
6729 | (setq gnus-override-method (pop methods))) | |
6730 | ((not (string-match "^400 " | |
6731 | (nnheader-get-report backend))) | |
6732 | ;; If we get 400 server disconnect, reconnect and | |
6733 | ;; retry; otherwise, assume the article has expired. | |
6734 | (setq result 'done)))) | |
16409b0b | 6735 | (and (eq result 'article) 'article))) |
eec82323 LMI |
6736 | ;; It was a pseudo. |
6737 | (t article))) | |
6738 | ||
6748645f LMI |
6739 | ;; Associate this article with the current summary buffer. |
6740 | (setq gnus-article-current-summary gnus-summary-buffer) | |
6741 | ||
eec82323 LMI |
6742 | ;; Take the article from the original article buffer |
6743 | ;; and place it in the buffer it's supposed to be in. | |
6744 | (when (and (get-buffer gnus-article-buffer) | |
eec82323 LMI |
6745 | (equal (buffer-name (current-buffer)) |
6746 | (buffer-name (get-buffer gnus-article-buffer)))) | |
6747 | (save-excursion | |
6748 | (if (get-buffer gnus-original-article-buffer) | |
6748645f LMI |
6749 | (set-buffer gnus-original-article-buffer) |
6750 | (set-buffer (gnus-get-buffer-create gnus-original-article-buffer)) | |
16409b0b | 6751 | (buffer-disable-undo) |
eec82323 | 6752 | (setq major-mode 'gnus-original-article-mode) |
6748645f | 6753 | (setq buffer-read-only t)) |
23f87bed | 6754 | (let ((inhibit-read-only t)) |
eec82323 LMI |
6755 | (erase-buffer) |
6756 | (insert-buffer-substring gnus-article-buffer)) | |
16409b0b GM |
6757 | (setq gnus-original-article (cons group article))) |
6758 | ||
6759 | ;; Decode charsets. | |
6760 | (run-hooks 'gnus-article-decode-hook) | |
6761 | ;; Mark article as decoded or not. | |
6762 | (setq gnus-article-decoded-p gnus-article-decode-hook)) | |
eec82323 LMI |
6763 | |
6764 | ;; Update sparse articles. | |
6765 | (when (and do-update-line | |
6766 | (or (numberp article) | |
6767 | (stringp article))) | |
6768 | (let ((buf (current-buffer))) | |
6769 | (set-buffer gnus-summary-buffer) | |
6748645f | 6770 | (gnus-summary-update-article do-update-line sparse-header) |
eec82323 | 6771 | (gnus-summary-goto-subject do-update-line nil t) |
23f87bed | 6772 | (set-window-point (gnus-get-buffer-window (current-buffer) t) |
eec82323 LMI |
6773 | (point)) |
6774 | (set-buffer buf)))))) | |
6775 | ||
6776 | ;;; | |
6777 | ;;; Article editing | |
6778 | ;;; | |
6779 | ||
6780 | (defcustom gnus-article-edit-mode-hook nil | |
6781 | "Hook run in article edit mode buffers." | |
6782 | :group 'gnus-article-various | |
6783 | :type 'hook) | |
6784 | ||
6785 | (defvar gnus-article-edit-done-function nil) | |
6786 | ||
6787 | (defvar gnus-article-edit-mode-map nil) | |
6788 | ||
16409b0b | 6789 | ;; Should we be using derived.el for this? |
eec82323 | 6790 | (unless gnus-article-edit-mode-map |
23f87bed | 6791 | (setq gnus-article-edit-mode-map (make-keymap)) |
16409b0b | 6792 | (set-keymap-parent gnus-article-edit-mode-map text-mode-map) |
eec82323 LMI |
6793 | |
6794 | (gnus-define-keys gnus-article-edit-mode-map | |
23f87bed | 6795 | "\C-c?" describe-mode |
eec82323 | 6796 | "\C-c\C-c" gnus-article-edit-done |
23f87bed MB |
6797 | "\C-c\C-k" gnus-article-edit-exit |
6798 | "\C-c\C-f\C-t" message-goto-to | |
6799 | "\C-c\C-f\C-o" message-goto-from | |
6800 | "\C-c\C-f\C-b" message-goto-bcc | |
6801 | ;;"\C-c\C-f\C-w" message-goto-fcc | |
6802 | "\C-c\C-f\C-c" message-goto-cc | |
6803 | "\C-c\C-f\C-s" message-goto-subject | |
6804 | "\C-c\C-f\C-r" message-goto-reply-to | |
6805 | "\C-c\C-f\C-n" message-goto-newsgroups | |
6806 | "\C-c\C-f\C-d" message-goto-distribution | |
6807 | "\C-c\C-f\C-f" message-goto-followup-to | |
6808 | "\C-c\C-f\C-m" message-goto-mail-followup-to | |
6809 | "\C-c\C-f\C-k" message-goto-keywords | |
6810 | "\C-c\C-f\C-u" message-goto-summary | |
6811 | "\C-c\C-f\C-i" message-insert-or-toggle-importance | |
6812 | "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to | |
6813 | "\C-c\C-b" message-goto-body | |
6814 | "\C-c\C-i" message-goto-signature | |
6815 | ||
6816 | "\C-c\C-t" message-insert-to | |
6817 | "\C-c\C-n" message-insert-newsgroups | |
6818 | "\C-c\C-o" message-sort-headers | |
6819 | "\C-c\C-e" message-elide-region | |
6820 | "\C-c\C-v" message-delete-not-region | |
6821 | "\C-c\C-z" message-kill-to-signature | |
6822 | "\M-\r" message-newline-and-reformat | |
6823 | "\C-c\C-a" mml-attach-file | |
6824 | "\C-a" message-beginning-of-line | |
6825 | "\t" message-tab | |
6826 | "\M-;" comment-region) | |
eec82323 LMI |
6827 | |
6828 | (gnus-define-keys (gnus-article-edit-wash-map | |
6829 | "\C-c\C-w" gnus-article-edit-mode-map) | |
6830 | "f" gnus-article-edit-full-stops)) | |
6831 | ||
23f87bed MB |
6832 | (easy-menu-define |
6833 | gnus-article-edit-mode-field-menu gnus-article-edit-mode-map "" | |
6834 | '("Field" | |
6835 | ["Fetch To" message-insert-to t] | |
6836 | ["Fetch Newsgroups" message-insert-newsgroups t] | |
6837 | "----" | |
6838 | ["To" message-goto-to t] | |
6839 | ["From" message-goto-from t] | |
6840 | ["Subject" message-goto-subject t] | |
6841 | ["Cc" message-goto-cc t] | |
6842 | ["Reply-To" message-goto-reply-to t] | |
6843 | ["Summary" message-goto-summary t] | |
6844 | ["Keywords" message-goto-keywords t] | |
6845 | ["Newsgroups" message-goto-newsgroups t] | |
6846 | ["Followup-To" message-goto-followup-to t] | |
6847 | ["Mail-Followup-To" message-goto-mail-followup-to t] | |
6848 | ["Distribution" message-goto-distribution t] | |
6849 | ["Body" message-goto-body t] | |
6850 | ["Signature" message-goto-signature t])) | |
6851 | ||
4e7d0221 | 6852 | (define-derived-mode gnus-article-edit-mode message-mode "Article Edit" |
eec82323 LMI |
6853 | "Major mode for editing articles. |
6854 | This is an extended text-mode. | |
6855 | ||
6856 | \\{gnus-article-edit-mode-map}" | |
eec82323 LMI |
6857 | (make-local-variable 'gnus-article-edit-done-function) |
6858 | (make-local-variable 'gnus-prev-winconf) | |
80b47379 SZ |
6859 | (set (make-local-variable 'font-lock-defaults) |
6860 | '(message-font-lock-keywords t)) | |
23f87bed MB |
6861 | (set (make-local-variable 'mail-header-separator) "") |
6862 | (set (make-local-variable 'gnus-article-edit-mode) t) | |
6863 | (easy-menu-add message-mode-field-menu message-mode-map) | |
6864 | (mml-mode) | |
eec82323 LMI |
6865 | (setq buffer-read-only nil) |
6866 | (buffer-enable-undo) | |
80b47379 | 6867 | (widen)) |
eec82323 LMI |
6868 | |
6869 | (defun gnus-article-edit (&optional force) | |
6870 | "Edit the current article. | |
6871 | This will have permanent effect only in mail groups. | |
6872 | If FORCE is non-nil, allow editing of articles even in read-only | |
6873 | groups." | |
6874 | (interactive "P") | |
6875 | (when (and (not force) | |
6876 | (gnus-group-read-only-p)) | |
a8151ef7 | 6877 | (error "The current newsgroup does not support article editing")) |
6748645f | 6878 | (gnus-article-date-original) |
eec82323 | 6879 | (gnus-article-edit-article |
16409b0b | 6880 | 'ignore |
6748645f | 6881 | `(lambda (no-highlight) |
16409b0b | 6882 | 'ignore |
eec82323 LMI |
6883 | (gnus-summary-edit-article-done |
6884 | ,(or (mail-header-references gnus-current-headers) "") | |
6748645f | 6885 | ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight)))) |
eec82323 | 6886 | |
01c52d31 | 6887 | (defun gnus-article-edit-article (start-func exit-func &optional quiet) |
eec82323 LMI |
6888 | "Start editing the contents of the current article buffer." |
6889 | (let ((winconf (current-window-configuration))) | |
6890 | (set-buffer gnus-article-buffer) | |
0683d241 MB |
6891 | (let ((message-auto-save-directory |
6892 | ;; Don't associate the article buffer with a draft file. | |
6893 | nil)) | |
6894 | (gnus-article-edit-mode)) | |
16409b0b | 6895 | (funcall start-func) |
23f87bed | 6896 | (set-buffer-modified-p nil) |
eec82323 LMI |
6897 | (gnus-configure-windows 'edit-article) |
6898 | (setq gnus-article-edit-done-function exit-func) | |
6899 | (setq gnus-prev-winconf winconf) | |
01c52d31 MB |
6900 | (unless quiet |
6901 | (gnus-message 6 "C-c C-c to end edits")))) | |
eec82323 | 6902 | |
6748645f | 6903 | (defun gnus-article-edit-done (&optional arg) |
eec82323 | 6904 | "Update the article edits and exit." |
6748645f | 6905 | (interactive "P") |
eec82323 LMI |
6906 | (let ((func gnus-article-edit-done-function) |
6907 | (buf (current-buffer)) | |
23f87bed MB |
6908 | (start (window-start)) |
6909 | (p (point)) | |
6910 | (winconf gnus-prev-winconf)) | |
6911 | (widen) ;; Widen it in case that users narrowed the buffer. | |
6912 | (funcall func arg) | |
6913 | (set-buffer buf) | |
6914 | ;; The cache and backlog have to be flushed somewhat. | |
6915 | (when gnus-keep-backlog | |
6916 | (gnus-backlog-remove-article | |
6917 | (car gnus-article-current) (cdr gnus-article-current))) | |
6918 | ;; Flush original article as well. | |
80de1778 SM |
6919 | (when (get-buffer gnus-original-article-buffer) |
6920 | (with-current-buffer gnus-original-article-buffer | |
23f87bed MB |
6921 | (setq gnus-original-article nil))) |
6922 | (when gnus-use-cache | |
6923 | (gnus-cache-update-article | |
6924 | (car gnus-article-current) (cdr gnus-article-current))) | |
6925 | ;; We remove all text props from the article buffer. | |
6926 | (kill-all-local-variables) | |
01c52d31 | 6927 | (set-text-properties (point-min) (point-max) nil) |
23f87bed MB |
6928 | (gnus-article-mode) |
6929 | (set-window-configuration winconf) | |
eec82323 LMI |
6930 | (set-buffer buf) |
6931 | (set-window-start (get-buffer-window buf) start) | |
23f87bed MB |
6932 | (set-window-point (get-buffer-window buf) (point))) |
6933 | (gnus-summary-show-article)) | |
eec82323 LMI |
6934 | |
6935 | (defun gnus-article-edit-exit () | |
6936 | "Exit the article editing without updating." | |
6937 | (interactive) | |
23f87bed MB |
6938 | (when (or (not (buffer-modified-p)) |
6939 | (yes-or-no-p "Article modified; kill anyway? ")) | |
6940 | (let ((curbuf (current-buffer)) | |
6941 | (p (point)) | |
6942 | (window-start (window-start))) | |
6943 | (erase-buffer) | |
6944 | (if (gnus-buffer-live-p gnus-original-article-buffer) | |
d8a88581 | 6945 | (insert-buffer-substring gnus-original-article-buffer)) |
23f87bed MB |
6946 | (let ((winconf gnus-prev-winconf)) |
6947 | (kill-all-local-variables) | |
6948 | (gnus-article-mode) | |
6949 | (set-window-configuration winconf) | |
6950 | ;; Tippy-toe some to make sure that point remains where it was. | |
6951 | (save-current-buffer | |
6952 | (set-buffer curbuf) | |
6953 | (set-window-start (get-buffer-window (current-buffer)) window-start) | |
6954 | (goto-char p)))) | |
6955 | (gnus-summary-show-article))) | |
eec82323 LMI |
6956 | |
6957 | (defun gnus-article-edit-full-stops () | |
6958 | "Interactively repair spacing at end of sentences." | |
6959 | (interactive) | |
6960 | (save-excursion | |
6961 | (goto-char (point-min)) | |
6962 | (search-forward-regexp "^$" nil t) | |
6963 | (let ((case-fold-search nil)) | |
6964 | (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2")))) | |
6965 | ||
6966 | ;;; | |
6967 | ;;; Article highlights | |
6968 | ;;; | |
6969 | ||
6970 | ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. | |
6971 | ||
6972 | ;;; Internal Variables: | |
6973 | ||
a1506d29 | 6974 | (defcustom gnus-button-url-regexp |
01c52d31 MB |
6975 | (concat |
6976 | "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|" | |
6977 | "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)" | |
6978 | "\\(//[-a-z0-9_.]+:[0-9]*\\)?" | |
6979 | (if (string-match "[[:digit:]]" "1") ;; Support POSIX? | |
6980 | (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]") | |
6981 | (punct "!?:;.,")) | |
6982 | (concat | |
6983 | "\\(?:" | |
6984 | ;; Match paired parentheses, e.g. in Wikipedia URLs: | |
9b3ebcb6 MB |
6985 | ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com |
6986 | "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]*" | |
01c52d31 MB |
6987 | "\\|" |
6988 | "[" chars punct "]+" "[" chars "]" | |
6989 | "\\)")) | |
6990 | (concat ;; XEmacs 21.4 doesn't support POSIX. | |
6991 | "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+" | |
6992 | "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)")) | |
6993 | "\\)") | |
eec82323 LMI |
6994 | "Regular expression that matches URLs." |
6995 | :group 'gnus-article-buttons | |
6996 | :type 'regexp) | |
6997 | ||
23f87bed MB |
6998 | (defcustom gnus-button-valid-fqdn-regexp |
6999 | message-valid-fqdn-regexp | |
7000 | "Regular expression that matches a valid FQDN." | |
bf247b6e | 7001 | :version "22.1" |
23f87bed MB |
7002 | :group 'gnus-article-buttons |
7003 | :type 'regexp) | |
7004 | ||
97f78c9b MB |
7005 | ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de> |
7006 | (defcustom gnus-button-valid-localpart-regexp | |
14e6dc54 | 7007 | "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*" |
97f78c9b MB |
7008 | "Regular expression that matches a localpart of mail addresses or MIDs." |
7009 | :version "22.1" | |
7010 | :group 'gnus-article-buttons | |
7011 | :type 'regexp) | |
7012 | ||
23f87bed MB |
7013 | (defcustom gnus-button-man-handler 'manual-entry |
7014 | "Function to use for displaying man pages. | |
7015 | The function must take at least one argument with a string naming the | |
7016 | man page." | |
bf247b6e | 7017 | :version "22.1" |
23f87bed MB |
7018 | :type '(choice (function-item :tag "Man" manual-entry) |
7019 | (function-item :tag "Woman" woman) | |
7020 | (function :tag "Other")) | |
7021 | :group 'gnus-article-buttons) | |
7022 | ||
7023 | (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/" | |
7024 | "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive. | |
7025 | If the default site is too slow, try to find a CTAN mirror, see | |
7026 | <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also | |
7027 | the variable `gnus-button-handle-ctan'." | |
bf247b6e | 7028 | :version "22.1" |
23f87bed MB |
7029 | :group 'gnus-article-buttons |
7030 | :link '(custom-manual "(gnus)Group Parameters") | |
7031 | :type '(choice (const "http://www.tex.ac.uk/tex-archive/") | |
7032 | (const "http://tug.ctan.org/tex-archive/") | |
7033 | (const "http://www.dante.de/CTAN/") | |
7034 | (string :tag "Other"))) | |
7035 | ||
7036 | (defcustom gnus-button-ctan-handler 'browse-url | |
7037 | "Function to use for displaying CTAN links. | |
7038 | The function must take one argument, the string naming the URL." | |
bf247b6e | 7039 | :version "22.1" |
23f87bed MB |
7040 | :type '(choice (function-item :tag "Browse Url" browse-url) |
7041 | (function :tag "Other")) | |
7042 | :group 'gnus-article-buttons) | |
7043 | ||
7044 | (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/" | |
7045 | "Bogus strings removed from CTAN URLs." | |
bf247b6e | 7046 | :version "22.1" |
23f87bed MB |
7047 | :group 'gnus-article-buttons |
7048 | :type '(choice (const "^/?tex-archive/\\|/") | |
7049 | (regexp :tag "Other"))) | |
7050 | ||
7051 | (defcustom gnus-button-ctan-directory-regexp | |
97f78c9b MB |
7052 | (regexp-opt |
7053 | (list "archive-tools" "biblio" "bibliography" "digests" "documentation" | |
7054 | "dviware" "fonts" "graphics" "help" "indexing" "info" "language" | |
7055 | "languages" "macros" "nonfree" "obsolete" "support" "systems" | |
7056 | "tds" "tools" "usergrps" "web") t) | |
23f87bed MB |
7057 | "Regular expression for ctan directories. |
7058 | It should match all directories in the top level of `gnus-ctan-url'." | |
bf247b6e | 7059 | :version "22.1" |
23f87bed MB |
7060 | :group 'gnus-article-buttons |
7061 | :type 'regexp) | |
7062 | ||
7063 | (defcustom gnus-button-mid-or-mail-regexp | |
97f78c9b | 7064 | (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@" |
23f87bed MB |
7065 | gnus-button-valid-fqdn-regexp |
7066 | ">?\\)\\b") | |
7067 | "Regular expression that matches a message ID or a mail address." | |
bf247b6e | 7068 | :version "22.1" |
23f87bed MB |
7069 | :group 'gnus-article-buttons |
7070 | :type 'regexp) | |
7071 | ||
7072 | (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic | |
7073 | "What to do when the button on a string as \"foo123@bar.invalid\" is pushed. | |
7074 | Strings like this can be either a message ID or a mail address. If it is one | |
7075 | of the symbols `mid' or `mail', Gnus will always assume that the string is a | |
7076 | message ID or a mail address, respectively. If this variable is set to the | |
7077 | symbol `ask', always query the user what do do. If it is a function, this | |
aa819354 | 7078 | function will be called with the string as its only argument. The function |
23f87bed | 7079 | must return `mid', `mail', `invalid' or `ask'." |
bf247b6e | 7080 | :version "22.1" |
23f87bed MB |
7081 | :group 'gnus-article-buttons |
7082 | :type '(choice (function-item :tag "Heuristic function" | |
7083 | gnus-button-mid-or-mail-heuristic) | |
7084 | (const ask) | |
7085 | (const mid) | |
7086 | (const mail))) | |
7087 | ||
7088 | (defcustom gnus-button-mid-or-mail-heuristic-alist | |
7089 | '((-10.0 . ".+\\$.+@") | |
7090 | (-10.0 . "#") | |
7091 | (-10.0 . "\\*") | |
7092 | (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs | |
7093 | (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i | |
7094 | (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i; | |
7095 | (-1.0 . "^[^a-z]+@") | |
7096 | ;; | |
7097 | (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@" | |
7098 | (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@" | |
7099 | (-3.0 . "[A-Z][A-Z][a-z][a-z].*@") | |
7100 | (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@") | |
7101 | ;; | |
7102 | (-2.0 . "^[0-9]") | |
7103 | (-1.0 . "^[0-9][0-9]") | |
7104 | ;; | |
7105 | ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/; | |
7106 | (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") | |
7107 | ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/; | |
7108 | (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]") | |
7109 | ;; | |
7110 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@" | |
7111 | (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@") | |
7112 | ;; "[0-9]{8,}.*\@" | |
7113 | (-3.0 | |
7114 | . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@") | |
7115 | ;; "[0-9]{12,}.*\@" | |
7116 | ;; compensation for TDMA dated mail addresses: | |
7117 | (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@") | |
7118 | ;; | |
7119 | (-20.0 . "\\.fsf@") ;; Gnus | |
7120 | (-20.0 . "^slrn") | |
7121 | (-20.0 . "^Pine") | |
437ce4be | 7122 | (-20.0 . "^alpine\\.") |
23f87bed MB |
7123 | (-20.0 . "_-_") ;; Subject change in thread |
7124 | ;; | |
7125 | (-20.0 . "\\.ln@") ;; leafnode | |
7126 | (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de") | |
7127 | (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent | |
7128 | ;; | |
7129 | ;; (5.0 . "") ;; $local_part_len <= 7 | |
7130 | (10.0 . "^[^0-9]+@") | |
7131 | (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@") | |
7132 | ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part | |
7133 | (3.0 . "\@stud") | |
7134 | ;; | |
7135 | (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@") | |
7136 | ;; | |
7137 | (0.5 . "^[A-Z][a-z]") | |
7138 | (0.5 . "^[A-Z][a-z][a-z]") | |
7139 | (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3} | |
7140 | (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4} | |
7141 | "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'. | |
7142 | ||
7143 | A negative RATE indicates a message IDs, whereas a positive indicates a mail | |
7144 | address. The REGEXP is processed with `case-fold-search' set to nil." | |
bf247b6e | 7145 | :version "22.1" |
23f87bed MB |
7146 | :group 'gnus-article-buttons |
7147 | :type '(repeat (cons (number :tag "Rate") | |
7148 | (regexp :tag "Regexp")))) | |
7149 | ||
7150 | (defun gnus-button-mid-or-mail-heuristic (mid-or-mail) | |
7151 | "Guess whether MID-OR-MAIL is a message ID or a mail address. | |
7152 | Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail | |
7153 | address, `ask' if unsure and `invalid' if the string is invalid." | |
7154 | (let ((case-fold-search nil) | |
7155 | (list gnus-button-mid-or-mail-heuristic-alist) | |
7156 | (result 0) rate regexp lpartlen elem) | |
7157 | (setq lpartlen | |
7158 | (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1"))) | |
7159 | (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen) | |
7160 | ;; Certain special cases... | |
7161 | (when (string-match | |
7162 | (concat | |
7163 | "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|" | |
7164 | "^[0-9]+\\.[0-9]+@compuserve\\|" | |
7165 | "@public\\.gmane\\.org") | |
7166 | mid-or-mail) | |
7167 | (gnus-message 8 "`%s' is a known mail address." mid-or-mail) | |
7168 | (setq result 'mail)) | |
7169 | (when (string-match "@.*@\\| " mid-or-mail) | |
7170 | (gnus-message 8 "`%s' is invalid." mid-or-mail) | |
7171 | (setq result 'invalid)) | |
7172 | ;; Nothing more to do, if result is not a number here... | |
7173 | (when (numberp result) | |
7174 | (while list | |
7175 | (setq elem (car list) | |
7176 | rate (car elem) | |
7177 | regexp (cdr elem) | |
7178 | list (cdr list)) | |
7179 | (when (string-match regexp mid-or-mail) | |
7180 | (setq result (+ result rate)) | |
7181 | (gnus-message | |
7182 | 9 "`%s' matched `%s', rate `%s', result `%s'." | |
7183 | mid-or-mail regexp rate result))) | |
7184 | (when (<= lpartlen 7) | |
7185 | (setq result (+ result 5.0)) | |
7186 | (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'." | |
7187 | mid-or-mail result)) | |
7188 | (when (>= lpartlen 12) | |
7189 | (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail) | |
7190 | (cond | |
7191 | ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail) | |
7192 | ;; Long local part should contain realname if e-mail address, | |
7193 | ;; too many digits: message-id. | |
7194 | ;; $score -= 5.0 + 0.1 * $local_part_len; | |
7195 | (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen)))) | |
7196 | (setq result (+ result rate)) | |
7197 | (gnus-message | |
7198 | 9 "Many digits in `%s', rate `%s', result `%s'." | |
7199 | mid-or-mail rate result)) | |
7200 | ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@" | |
7201 | mid-or-mail) | |
7202 | ;; Too few vowels [^aeiouy]{4,}.*\@ | |
7203 | (setq result (+ result -5.0)) | |
7204 | (gnus-message | |
7205 | 9 "Few vowels in `%s', rate `%s', result `%s'." | |
7206 | mid-or-mail -5.0 result)) | |
7207 | (t | |
7208 | (setq result (+ result 5.0)) | |
7209 | (gnus-message | |
7210 | 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result))))) | |
7211 | (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result) | |
7212 | ;; Maybe we should make this a customizable alist: (condition . 'result) | |
7213 | (cond | |
7214 | ((symbolp result) result) | |
7215 | ;; Now convert number into proper results: | |
7216 | ((< result -10.0) 'mid) | |
7217 | ((> result 10.0) 'mail) | |
7218 | (t 'ask)))) | |
7219 | ||
7220 | (defun gnus-button-handle-mid-or-mail (mid-or-mail) | |
7221 | (let* ((pref gnus-button-prefer-mid-or-mail) guessed | |
7222 | (url-mid (concat "news" ":" mid-or-mail)) | |
7223 | (url-mailto (concat "mailto" ":" mid-or-mail))) | |
7224 | (gnus-message 9 "mid-or-mail=%s" mid-or-mail) | |
7225 | (when (fboundp pref) | |
7226 | (setq guessed | |
7227 | ;; get rid of surrounding angles... | |
7228 | (funcall pref | |
7229 | (gnus-replace-in-string mid-or-mail "^<\\|>$" ""))) | |
7230 | (if (or (eq 'mid guessed) (eq 'mail guessed)) | |
7231 | (setq pref guessed) | |
7232 | (setq pref 'ask))) | |
7233 | (if (eq pref 'ask) | |
7234 | (save-window-excursion | |
7235 | (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? ")) | |
7236 | (setq pref 'mail) | |
7237 | (setq pref 'mid)))) | |
7238 | (cond ((eq pref 'mid) | |
7239 | (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid) | |
7240 | (gnus-button-handle-news url-mid)) | |
7241 | ((eq pref 'mail) | |
7242 | (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto) | |
7243 | (gnus-url-mailto url-mailto)) | |
7244 | (t (gnus-message 3 "Invalid string."))))) | |
7245 | ||
01c52d31 MB |
7246 | (defun gnus-button-handle-custom (fun arg) |
7247 | "Call function FUN on argument ARG. | |
7248 | Both FUN and ARG are supposed to be strings. ARG will be passed | |
7249 | as a symbol to FUN." | |
7250 | (funcall (intern fun) | |
7251 | (if (string-match "^customize-apropos" fun) | |
7252 | arg | |
7253 | (intern arg)))) | |
23f87bed MB |
7254 | |
7255 | (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)") | |
7256 | ||
7257 | ;; FIXME: Maybe we should merge some of the functions that do quite similar | |
7258 | ;; stuff? | |
7259 | ||
7260 | (defun gnus-button-handle-describe-function (url) | |
7261 | "Call `describe-function' when pushing the corresponding URL button." | |
7262 | (describe-function | |
7263 | (intern | |
7264 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) | |
7265 | ||
7266 | (defun gnus-button-handle-describe-variable (url) | |
7267 | "Call `describe-variable' when pushing the corresponding URL button." | |
7268 | (describe-variable | |
7269 | (intern | |
7270 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))) | |
7271 | ||
7272 | (defun gnus-button-handle-symbol (url) | |
7273 | "Display help on variable or function. | |
7274 | Calls `describe-variable' or `describe-function'." | |
7275 | (let ((sym (intern url))) | |
7276 | (cond | |
7277 | ((fboundp sym) (describe-function sym)) | |
7278 | ((boundp sym) (describe-variable sym)) | |
7279 | (t (gnus-message 3 "`%s' is not a known function of variable." url))))) | |
7280 | ||
7281 | (defun gnus-button-handle-describe-key (url) | |
7282 | "Call `describe-key' when pushing the corresponding URL button." | |
7283 | (let* ((key-string | |
7284 | (gnus-replace-in-string url gnus-button-handle-describe-prefix "")) | |
7285 | (keys (ignore-errors (eval `(kbd ,key-string))))) | |
7286 | (if keys | |
7287 | (describe-key keys) | |
7288 | (gnus-message 3 "Invalid key sequence in button: %s" key-string)))) | |
7289 | ||
7290 | (defun gnus-button-handle-apropos (url) | |
7291 | "Call `apropos' when pushing the corresponding URL button." | |
7292 | (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7293 | ||
7294 | (defun gnus-button-handle-apropos-command (url) | |
7295 | "Call `apropos' when pushing the corresponding URL button." | |
7296 | (apropos-command | |
7297 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7298 | ||
7299 | (defun gnus-button-handle-apropos-variable (url) | |
7300 | "Call `apropos' when pushing the corresponding URL button." | |
7301 | (funcall | |
7302 | (if (fboundp 'apropos-variable) 'apropos-variable 'apropos) | |
7303 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7304 | ||
7305 | (defun gnus-button-handle-apropos-documentation (url) | |
7306 | "Call `apropos' when pushing the corresponding URL button." | |
7307 | (funcall | |
7308 | (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos) | |
7309 | (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))) | |
7310 | ||
7311 | (defun gnus-button-handle-library (url) | |
7312 | "Call `locate-library' when pushing the corresponding URL button." | |
7313 | (gnus-message 9 "url=`%s'" url) | |
7314 | (let* ((lib (locate-library url)) | |
7315 | (file (gnus-replace-in-string (or lib "") "\.elc" ".el"))) | |
7316 | (if (not lib) | |
7317 | (gnus-message 1 "Cannot locale library `%s'." url) | |
7318 | (find-file-read-only file)))) | |
7319 | ||
7320 | (defun gnus-button-handle-ctan (url) | |
7321 | "Call `browse-url' when pushing a CTAN URL button." | |
7322 | (funcall | |
7323 | gnus-button-ctan-handler | |
7324 | (concat | |
7325 | gnus-ctan-url | |
7326 | (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp "")))) | |
7327 | ||
7328 | (defcustom gnus-button-tex-level 5 | |
7329 | "*Integer that says how many TeX-related buttons Gnus will show. | |
7330 | The higher the number, the more buttons will appear and the more false | |
7331 | positives are possible. Note that you can set this variable local to | |
7332 | specific groups. Setting it higher in TeX groups is probably a good idea. | |
7333 | See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on | |
7334 | how to set variables in specific groups." | |
bf247b6e | 7335 | :version "22.1" |
23f87bed MB |
7336 | :group 'gnus-article-buttons |
7337 | :link '(custom-manual "(gnus)Group Parameters") | |
7338 | :type 'integer) | |
7339 | ||
7340 | (defcustom gnus-button-man-level 5 | |
7341 | "*Integer that says how many man-related buttons Gnus will show. | |
7342 | The higher the number, the more buttons will appear and the more false | |
7343 | positives are possible. Note that you can set this variable local to | |
7344 | specific groups. Setting it higher in Unix groups is probably a good idea. | |
7345 | See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on | |
7346 | how to set variables in specific groups." | |
bf247b6e | 7347 | :version "22.1" |
23f87bed MB |
7348 | :group 'gnus-article-buttons |
7349 | :link '(custom-manual "(gnus)Group Parameters") | |
7350 | :type 'integer) | |
7351 | ||
7352 | (defcustom gnus-button-emacs-level 5 | |
7353 | "*Integer that says how many emacs-related buttons Gnus will show. | |
7354 | The higher the number, the more buttons will appear and the more false | |
7355 | positives are possible. Note that you can set this variable local to | |
7356 | specific groups. Setting it higher in Emacs or Gnus related groups is | |
7357 | probably a good idea. See Info node `(gnus)Group Parameters' and the variable | |
7358 | `gnus-parameters' on how to set variables in specific groups." | |
bf247b6e | 7359 | :version "22.1" |
23f87bed MB |
7360 | :group 'gnus-article-buttons |
7361 | :link '(custom-manual "(gnus)Group Parameters") | |
7362 | :type 'integer) | |
7363 | ||
7364 | (defcustom gnus-button-message-level 5 | |
7365 | "*Integer that says how many buttons for news or mail messages will appear. | |
7366 | The higher the number, the more buttons will appear and the more false | |
7367 | positives are possible." | |
7368 | ;; mail addresses, MIDs, URLs for news, ... | |
bf247b6e | 7369 | :version "22.1" |
23f87bed MB |
7370 | :group 'gnus-article-buttons |
7371 | :type 'integer) | |
7372 | ||
7373 | (defcustom gnus-button-browse-level 5 | |
7374 | "*Integer that says how many buttons for browsing will appear. | |
7375 | The higher the number, the more buttons will appear and the more false | |
7376 | positives are possible." | |
7377 | ;; stuff handled by `browse-url' or `gnus-button-embedded-url' | |
bf247b6e | 7378 | :version "22.1" |
23f87bed MB |
7379 | :group 'gnus-article-buttons |
7380 | :type 'integer) | |
7381 | ||
eec82323 | 7382 | (defcustom gnus-button-alist |
23f87bed MB |
7383 | '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" |
7384 | 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3) | |
97f78c9b MB |
7385 | ((concat "\\b\\(nntp\\|news\\):\\(" |
7386 | gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)") | |
7387 | 0 t gnus-button-handle-news 2) | |
23f87bed MB |
7388 | ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)" |
7389 | 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5) | |
7390 | ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)" | |
7391 | 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3) | |
7392 | ;; RFC 2392 (Don't allow `/' in domain part --> CID) | |
7393 | ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)" | |
7394 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 2) | |
7395 | ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" | |
7396 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) | |
01c52d31 MB |
7397 | ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" |
7398 | 2 (>= gnus-button-message-level 0) gnus-button-message-id 3) | |
23f87bed MB |
7399 | ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" |
7400 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 2) | |
7401 | ;; RFC 2368 (The mailto URL scheme) | |
531e5812 | 7402 | ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
23f87bed MB |
7403 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
7404 | ("\\bmailto:\\([^ \n\t]+\\)" | |
7405 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) | |
7406 | ;; CTAN | |
7407 | ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\(" | |
7408 | gnus-button-ctan-directory-regexp | |
7409 | "[^][>)!;:,'\n\t ]+\\)") | |
7410 | 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1) | |
7411 | ((concat "\\btex-archive/\\(" | |
7412 | gnus-button-ctan-directory-regexp | |
7413 | "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)") | |
7414 | 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1) | |
7415 | ((concat | |
7416 | "\\b\\(" | |
7417 | gnus-button-ctan-directory-regexp | |
7418 | "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)") | |
7419 | 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1) | |
9eb59592 MB |
7420 | ;; Info Konqueror style <info:/foo/bar baz>. |
7421 | ;; Must come before " Gnus home-grown style". | |
7422 | ("\\binfo://?\\([^'\">\n\t]+\\)" | |
7423 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) | |
7424 | ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz> | |
23f87bed MB |
7425 | ("\\binfo://\\([^'\">\n\t ]+\\)" |
7426 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1) | |
7427 | ;; Info GNOME style <info:foo#bar_baz> | |
7428 | ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)" | |
7429 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1) | |
7430 | ;; Info KDE style <info:(foo)bar baz> | |
7431 | ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>" | |
7432 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2) | |
7433 | ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0 | |
7434 | (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2) | |
9b3ebcb6 MB |
7435 | ("\\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,]*\\)\\)?" |
7436 | ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET' | |
7437 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0) | |
23f87bed | 7438 | ;; This is custom |
01c52d31 MB |
7439 | ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0 |
7440 | (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2) | |
23f87bed MB |
7441 | ;; Emacs help commands |
7442 | ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7443 | ;; regexp doesn't match arguments containing ` '. | |
7444 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1) | |
7445 | ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7446 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1) | |
7447 | ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7448 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1) | |
7449 | ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7450 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1) | |
7451 | ;; The following entries may lead to many false positives so don't enable | |
531e5812 MB |
7452 | ;; them by default (use a high button level). |
7453 | ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]" | |
7454 | ;; Exclude [.?] for URLs in gmane.emacs.cvs | |
23f87bed MB |
7455 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) |
7456 | ("`\\([a-z][-a-z0-9]+\\.el\\)'" | |
7457 | 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1) | |
01c52d31 | 7458 | ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'" |
23f87bed MB |
7459 | 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1) |
7460 | ("`\\([a-z][a-z0-9]+-[a-z]+\\)'" | |
7461 | 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1) | |
7462 | ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)" | |
7463 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1) | |
7464 | ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7465 | 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1) | |
7466 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7467 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2) | |
7468 | ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET" | |
7469 | 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2) | |
87ba2830 | 7470 | ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" |
23f87bed MB |
7471 | ;; Unlike the other regexps we really have to require quoting |
7472 | ;; here to determine where it ends. | |
7473 | 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3) | |
7474 | ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)... | |
01c52d31 | 7475 | ("<URL: *\\([^\n<>]*\\)>" |
23f87bed MB |
7476 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
7477 | ;; RFC 2396 (2.4.3., delims) ... | |
01c52d31 | 7478 | ("\"URL: *\\([^\n\"]*\\)\"" |
23f87bed | 7479 | 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1) |
eec82323 | 7480 | ;; Raw URLs. |
23f87bed MB |
7481 | (gnus-button-url-regexp |
7482 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7483 | ;; man pages | |
531e5812 | 7484 | ("\\b\\([a-z][a-z]+([1-9])\\)\\W" |
23f87bed MB |
7485 | 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3)) |
7486 | gnus-button-handle-man 1) | |
7487 | ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x) | |
531e5812 | 7488 | ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W" |
23f87bed MB |
7489 | 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5)) |
7490 | gnus-button-handle-man 1) | |
7491 | ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm), | |
7492 | ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7) | |
531e5812 | 7493 | ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W" |
23f87bed | 7494 | 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1) |
01c52d31 MB |
7495 | ;; Recognizing patches to .el files. This is somewhat obscure, |
7496 | ;; but considering the percentage of Gnus users who hack Emacs | |
7497 | ;; Lisp files... | |
7498 | ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1 | |
7499 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) | |
7500 | ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1 | |
7501 | (>= gnus-button-message-level 4) gnus-button-patch 1 2) | |
23f87bed MB |
7502 | ;; MID or mail: To avoid too many false positives we don't try to catch |
7503 | ;; all kind of allowed MIDs or mail addresses. Domain part must contain | |
7504 | ;; at least one dot. TLD must contain two or three chars or be a know TLD | |
7505 | ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist' | |
7506 | ;; so that non-ambiguous entries (see above) match first. | |
7507 | (gnus-button-mid-or-mail-regexp | |
7508 | 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1)) | |
6748645f | 7509 | "*Alist of regexps matching buttons in article bodies. |
eec82323 LMI |
7510 | |
7511 | Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where | |
23f87bed MB |
7512 | REGEXP: is the string (case insensitive) matching text around the button (can |
7513 | also be Lisp expression evaluating to a string), | |
eec82323 | 7514 | BUTTON: is the number of the regexp grouping actually matching the button, |
4e7d0221 | 7515 | FORM: is a Lisp expression which must eval to true for the button to |
eec82323 LMI |
7516 | be added, |
7517 | CALLBACK: is the function to call when the user push this button, and each | |
7518 | PAR: is a number of a regexp grouping whose text will be passed to CALLBACK. | |
7519 | ||
7520 | CALLBACK can also be a variable, in that case the value of that | |
7521 | variable it the real callback function." | |
7522 | :group 'gnus-article-buttons | |
23f87bed | 7523 | :type '(repeat (list (choice regexp variable sexp) |
eec82323 LMI |
7524 | (integer :tag "Button") |
7525 | (sexp :tag "Form") | |
7526 | (function :tag "Callback") | |
7527 | (repeat :tag "Par" | |
7528 | :inline t | |
7529 | (integer :tag "Regexp group"))))) | |
60ece9b0 | 7530 | (put 'gnus-button-alist 'risky-local-variable t) |
eec82323 LMI |
7531 | |
7532 | (defcustom gnus-header-button-alist | |
23f87bed MB |
7533 | '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>" |
7534 | 0 (>= gnus-button-message-level 0) gnus-button-message-id 0) | |
7535 | ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" | |
7536 | 1 (>= gnus-button-message-level 0) gnus-button-reply 1) | |
eec82323 | 7537 | ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" |
fa9a04e1 | 7538 | 0 (>= gnus-button-message-level 0) gnus-msg-mail 0) |
23f87bed MB |
7539 | ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp |
7540 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7541 | ("^Subject:" gnus-button-url-regexp | |
7542 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
7543 | ("^[^:]+:" gnus-button-url-regexp | |
7544 | 0 (>= gnus-button-browse-level 0) browse-url 0) | |
01c52d31 MB |
7545 | ("^OpenPGP:.*url=" gnus-button-url-regexp |
7546 | 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0) | |
531e5812 | 7547 | ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)" |
23f87bed MB |
7548 | 0 (>= gnus-button-message-level 0) gnus-url-mailto 1) |
7549 | ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)" | |
7550 | 1 (>= gnus-button-message-level 0) gnus-button-message-id 4)) | |
6748645f | 7551 | "*Alist of headers and regexps to match buttons in article heads. |
eec82323 LMI |
7552 | |
7553 | This alist is very similar to `gnus-button-alist', except that each | |
7554 | alist has an additional HEADER element first in each entry: | |
7555 | ||
7556 | \(HEADER REGEXP BUTTON FORM CALLBACK PAR) | |
7557 | ||
7558 | HEADER is a regexp to match a header. For a fuller explanation, see | |
7559 | `gnus-button-alist'." | |
7560 | :group 'gnus-article-buttons | |
7561 | :group 'gnus-article-headers | |
7562 | :type '(repeat (list (regexp :tag "Header") | |
23f87bed | 7563 | (choice regexp variable) |
eec82323 LMI |
7564 | (integer :tag "Button") |
7565 | (sexp :tag "Form") | |
7566 | (function :tag "Callback") | |
7567 | (repeat :tag "Par" | |
7568 | :inline t | |
7569 | (integer :tag "Regexp group"))))) | |
60ece9b0 | 7570 | (put 'gnus-header-button-alist 'risky-local-variable t) |
eec82323 | 7571 | |
eec82323 LMI |
7572 | ;;; Commands: |
7573 | ||
7574 | (defun gnus-article-push-button (event) | |
7575 | "Check text under the mouse pointer for a callback function. | |
7576 | If the text under the mouse pointer has a `gnus-callback' property, | |
7577 | call it with the value of the `gnus-data' text property." | |
7578 | (interactive "e") | |
7579 | (set-buffer (window-buffer (posn-window (event-start event)))) | |
7580 | (let* ((pos (posn-point (event-start event))) | |
23f87bed | 7581 | (data (get-text-property pos 'gnus-data)) |
eec82323 | 7582 | (fun (get-text-property pos 'gnus-callback))) |
6748645f | 7583 | (goto-char pos) |
eec82323 LMI |
7584 | (when fun |
7585 | (funcall fun data)))) | |
7586 | ||
7587 | (defun gnus-article-press-button () | |
7588 | "Check text at point for a callback function. | |
7589 | If the text at point has a `gnus-callback' property, | |
7590 | call it with the value of the `gnus-data' text property." | |
7591 | (interactive) | |
23f87bed MB |
7592 | (let ((data (get-text-property (point) 'gnus-data)) |
7593 | (fun (get-text-property (point) 'gnus-callback))) | |
eec82323 LMI |
7594 | (when fun |
7595 | (funcall fun data)))) | |
7596 | ||
eec82323 LMI |
7597 | (defun gnus-article-highlight (&optional force) |
7598 | "Highlight current article. | |
7599 | This function calls `gnus-article-highlight-headers', | |
7600 | `gnus-article-highlight-citation', | |
7601 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
7602 | do the highlighting. See the documentation for those functions." | |
7603 | (interactive (list 'force)) | |
7604 | (gnus-article-highlight-headers) | |
7605 | (gnus-article-highlight-citation force) | |
7606 | (gnus-article-highlight-signature) | |
7607 | (gnus-article-add-buttons force) | |
7608 | (gnus-article-add-buttons-to-head)) | |
7609 | ||
7610 | (defun gnus-article-highlight-some (&optional force) | |
7611 | "Highlight current article. | |
7612 | This function calls `gnus-article-highlight-headers', | |
7613 | `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
7614 | do the highlighting. See the documentation for those functions." | |
7615 | (interactive (list 'force)) | |
7616 | (gnus-article-highlight-headers) | |
7617 | (gnus-article-highlight-signature) | |
7618 | (gnus-article-add-buttons)) | |
7619 | ||
7620 | (defun gnus-article-highlight-headers () | |
7621 | "Highlight article headers as specified by `gnus-header-face-alist'." | |
7622 | (interactive) | |
01c52d31 MB |
7623 | (gnus-with-article-headers |
7624 | (let (regexp header-face field-face from hpoints fpoints) | |
7625 | (dolist (entry gnus-header-face-alist) | |
7626 | (goto-char (point-min)) | |
7627 | (setq regexp (concat "^\\(" | |
7628 | (if (string-equal "" (nth 0 entry)) | |
7629 | "[^\t ]" | |
7630 | (nth 0 entry)) | |
7631 | "\\)") | |
7632 | header-face (nth 1 entry) | |
7633 | field-face (nth 2 entry)) | |
7634 | (while (and (re-search-forward regexp nil t) | |
7635 | (not (eobp))) | |
7636 | (beginning-of-line) | |
7637 | (setq from (point)) | |
7638 | (unless (search-forward ":" nil t) | |
7639 | (forward-char 1)) | |
7640 | (when (and header-face | |
7641 | (not (memq (point) hpoints))) | |
7642 | (push (point) hpoints) | |
7643 | (gnus-put-text-property from (point) 'face header-face)) | |
7644 | (when (and field-face | |
7645 | (not (memq (setq from (point)) fpoints))) | |
7646 | (push from fpoints) | |
7647 | (if (re-search-forward "^[^ \t]" nil t) | |
7648 | (forward-char -2) | |
7649 | (goto-char (point-max))) | |
7650 | (gnus-put-text-property from (point) 'face field-face))))))) | |
eec82323 LMI |
7651 | |
7652 | (defun gnus-article-highlight-signature () | |
7653 | "Highlight the signature in an article. | |
7654 | It does this by highlighting everything after | |
0f49874b | 7655 | `gnus-signature-separator' using the face `gnus-signature'." |
eec82323 | 7656 | (interactive) |
01c52d31 MB |
7657 | (gnus-with-article-buffer |
7658 | (let ((inhibit-point-motion-hooks t)) | |
eec82323 LMI |
7659 | (save-restriction |
7660 | (when (and gnus-signature-face | |
7661 | (gnus-article-narrow-to-signature)) | |
01c52d31 | 7662 | (gnus-overlay-put (gnus-make-overlay (point-min) (point-max) nil t) |
eec82323 LMI |
7663 | 'face gnus-signature-face) |
7664 | (widen) | |
7665 | (gnus-article-search-signature) | |
7666 | (let ((start (match-beginning 0)) | |
7667 | (end (set-marker (make-marker) (1+ (match-end 0))))) | |
7668 | (gnus-article-add-button start (1- end) 'gnus-signature-toggle | |
7669 | end))))))) | |
7670 | ||
7671 | (defun gnus-button-in-region-p (b e prop) | |
7672 | "Say whether PROP exists in the region." | |
7673 | (text-property-not-all b e prop nil)) | |
7674 | ||
7675 | (defun gnus-article-add-buttons (&optional force) | |
7676 | "Find external references in the article and make buttons of them. | |
7677 | \"External references\" are things like Message-IDs and URLs, as | |
7678 | specified by `gnus-button-alist'." | |
7679 | (interactive (list 'force)) | |
01c52d31 MB |
7680 | (gnus-with-article-buffer |
7681 | (let ((inhibit-point-motion-hooks t) | |
eec82323 LMI |
7682 | (case-fold-search t) |
7683 | (alist gnus-button-alist) | |
7684 | beg entry regexp) | |
7685 | ;; Remove all old markers. | |
16409b0b | 7686 | (let (marker entry new-list) |
eec82323 | 7687 | (while (setq marker (pop gnus-button-marker-list)) |
16409b0b GM |
7688 | (if (or (< marker (point-min)) (>= marker (point-max))) |
7689 | (push marker new-list) | |
7690 | (goto-char marker) | |
7691 | (when (setq entry (gnus-button-entry)) | |
7692 | (put-text-property (match-beginning (nth 1 entry)) | |
7693 | (match-end (nth 1 entry)) | |
7694 | 'gnus-callback nil)) | |
7695 | (set-marker marker nil))) | |
7696 | (setq gnus-button-marker-list new-list)) | |
eec82323 | 7697 | ;; We skip the headers. |
16409b0b | 7698 | (article-goto-body) |
eec82323 LMI |
7699 | (setq beg (point)) |
7700 | (while (setq entry (pop alist)) | |
23f87bed | 7701 | (setq regexp (eval (car entry))) |
eec82323 LMI |
7702 | (goto-char beg) |
7703 | (while (re-search-forward regexp nil t) | |
01c52d31 MB |
7704 | (let ((start (match-beginning (nth 1 entry))) |
7705 | (end (match-end (nth 1 entry))) | |
7706 | (from (match-beginning 0))) | |
eec82323 LMI |
7707 | (when (and (or (eq t (nth 2 entry)) |
7708 | (eval (nth 2 entry))) | |
7709 | (not (gnus-button-in-region-p | |
7710 | start end 'gnus-callback))) | |
7711 | ;; That optional form returned non-nil, so we add the | |
7712 | ;; button. | |
01c52d31 MB |
7713 | (setq from (set-marker (make-marker) from)) |
7714 | (push from gnus-button-marker-list) | |
7715 | (unless (and (eq (car entry) 'gnus-button-url-regexp) | |
7716 | (gnus-article-extend-url-button from start end)) | |
7717 | (gnus-article-add-button start end | |
7718 | 'gnus-button-push from))))))))) | |
7719 | ||
7720 | (defun gnus-article-extend-url-button (beg start end) | |
7721 | "Extend url button if url is folded into two or more lines. | |
7722 | Return non-nil if button is extended. BEG is a marker that points to | |
7723 | the beginning position of a text containing url. START and END are | |
7724 | the endpoints of a url button before it is extended. The concatenated | |
7725 | url is put as the `gnus-button-url' overlay property on the button." | |
7726 | (let ((opoint (point)) | |
7727 | (points (list start end)) | |
7728 | url delim regexp) | |
7729 | (prog1 | |
7730 | (when (and (progn | |
7731 | (goto-char end) | |
7732 | (not (looking-at "[\t ]*[\">]"))) | |
7733 | (progn | |
7734 | (goto-char start) | |
7735 | (string-match | |
7736 | "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'" | |
7737 | (buffer-substring (point-at-bol) start))) | |
7738 | (progn | |
7739 | (setq url (list (buffer-substring start end)) | |
7740 | delim (if (match-beginning 1) ">" "\"")) | |
7741 | (beginning-of-line) | |
7742 | (setq regexp (concat | |
7743 | (when (and (looking-at | |
7744 | message-cite-prefix-regexp) | |
7745 | (< (match-end 0) start)) | |
7746 | (regexp-quote (match-string 0))) | |
7747 | "\ | |
7748 | \[\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*" | |
7749 | delim "\\)")) | |
7750 | (while (progn | |
7751 | (forward-line 1) | |
7752 | (and (looking-at regexp) | |
7753 | (prog1 | |
7754 | (match-beginning 1) | |
7755 | (push (or (match-string 2) | |
7756 | (match-string 1)) | |
7757 | url) | |
7758 | (push (setq end (or (match-end 2) | |
7759 | (match-end 1))) | |
7760 | points) | |
7761 | (push (or (match-beginning 2) | |
7762 | (match-beginning 1)) | |
7763 | points))))) | |
7764 | (match-beginning 2))) | |
7765 | (let (gnus-article-mouse-face widget-mouse-face) | |
7766 | (while points | |
7767 | (gnus-article-add-button (pop points) (pop points) | |
7768 | 'gnus-button-push beg))) | |
7769 | (let ((overlay (gnus-make-overlay start end))) | |
7770 | (gnus-overlay-put overlay 'evaporate t) | |
7771 | (gnus-overlay-put overlay 'gnus-button-url | |
7772 | (list (mapconcat 'identity (nreverse url) ""))) | |
7773 | (when gnus-article-mouse-face | |
7774 | (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face))) | |
7775 | t) | |
7776 | (goto-char opoint)))) | |
eec82323 LMI |
7777 | |
7778 | ;; Add buttons to the head of an article. | |
7779 | (defun gnus-article-add-buttons-to-head () | |
7780 | "Add buttons to the head of the article." | |
7781 | (interactive) | |
01c52d31 MB |
7782 | (gnus-with-article-headers |
7783 | (let (beg end) | |
7784 | (dolist (entry gnus-header-button-alist) | |
7785 | ;; Each alist entry. | |
7786 | (goto-char (point-min)) | |
7787 | (while (re-search-forward (car entry) nil t) | |
7788 | ;; Each header matching the entry. | |
7789 | (setq beg (match-beginning 0)) | |
7790 | (setq end (or (and (re-search-forward "^[^ \t]" nil t) | |
7791 | (match-beginning 0)) | |
7792 | (point-max))) | |
7793 | (goto-char beg) | |
7794 | (while (re-search-forward (eval (nth 1 entry)) end t) | |
7795 | ;; Each match within a header. | |
7796 | (let* ((entry (cdr entry)) | |
7797 | (start (match-beginning (nth 1 entry))) | |
7798 | (end (match-end (nth 1 entry))) | |
7799 | (form (nth 2 entry))) | |
7800 | (goto-char (match-end 0)) | |
7801 | (when (eval form) | |
7802 | (gnus-article-add-button | |
7803 | start end (nth 3 entry) | |
7804 | (buffer-substring (match-beginning (nth 4 entry)) | |
7805 | (match-end (nth 4 entry))))))) | |
7806 | (goto-char end)))))) | |
eec82323 LMI |
7807 | |
7808 | ;;; External functions: | |
7809 | ||
7810 | (defun gnus-article-add-button (from to fun &optional data) | |
7811 | "Create a button between FROM and TO with callback FUN and data DATA." | |
7812 | (when gnus-article-button-face | |
01c52d31 | 7813 | (gnus-overlay-put (gnus-make-overlay from to nil t) |
eec82323 LMI |
7814 | 'face gnus-article-button-face)) |
7815 | (gnus-add-text-properties | |
7816 | from to | |
7817 | (nconc (and gnus-article-mouse-face | |
7818 | (list gnus-mouse-face-prop gnus-article-mouse-face)) | |
7819 | (list 'gnus-callback fun) | |
16409b0b GM |
7820 | (and data (list 'gnus-data data)))) |
7821 | (widget-convert-button 'link from to :action 'gnus-widget-press-button | |
7822 | :button-keymap gnus-widget-button-keymap)) | |
eec82323 LMI |
7823 | |
7824 | ;;; Internal functions: | |
7825 | ||
a8151ef7 | 7826 | (defun gnus-article-set-globals () |
01c52d31 | 7827 | (with-current-buffer gnus-summary-buffer |
a8151ef7 LMI |
7828 | (gnus-set-global-variables))) |
7829 | ||
eec82323 | 7830 | (defun gnus-signature-toggle (end) |
01c52d31 MB |
7831 | (gnus-with-article-buffer |
7832 | (let ((inhibit-point-motion-hooks t)) | |
520aa572 | 7833 | (if (text-property-any end (point-max) 'article-type 'signature) |
23f87bed MB |
7834 | (progn |
7835 | (gnus-delete-wash-type 'signature) | |
7836 | (gnus-remove-text-properties-when | |
7837 | 'article-type 'signature end (point-max) | |
7838 | (cons 'article-type (cons 'signature | |
7839 | gnus-hidden-properties)))) | |
7840 | (gnus-add-wash-type 'signature) | |
520aa572 SZ |
7841 | (gnus-add-text-properties-when |
7842 | 'article-type nil end (point-max) | |
7843 | (cons 'article-type (cons 'signature | |
23f87bed MB |
7844 | gnus-hidden-properties))))) |
7845 | (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist)) | |
7846 | (gnus-set-mode-line 'article)))) | |
eec82323 LMI |
7847 | |
7848 | (defun gnus-button-entry () | |
7849 | ;; Return the first entry in `gnus-button-alist' matching this place. | |
7850 | (let ((alist gnus-button-alist) | |
7851 | (entry nil)) | |
7852 | (while alist | |
7853 | (setq entry (pop alist)) | |
23f87bed | 7854 | (if (looking-at (eval (car entry))) |
eec82323 LMI |
7855 | (setq alist nil) |
7856 | (setq entry nil))) | |
7857 | entry)) | |
7858 | ||
7859 | (defun gnus-button-push (marker) | |
7860 | ;; Push button starting at MARKER. | |
7861 | (save-excursion | |
eec82323 LMI |
7862 | (goto-char marker) |
7863 | (let* ((entry (gnus-button-entry)) | |
7864 | (inhibit-point-motion-hooks t) | |
7865 | (fun (nth 3 entry)) | |
01c52d31 MB |
7866 | (args (or (and (eq (car entry) 'gnus-button-url-regexp) |
7867 | (get-char-property marker 'gnus-button-url)) | |
7868 | (mapcar (lambda (group) | |
7869 | (let ((string (match-string group))) | |
7870 | (set-text-properties | |
7871 | 0 (length string) nil string) | |
7872 | string)) | |
7873 | (nthcdr 4 entry))))) | |
eec82323 LMI |
7874 | (cond |
7875 | ((fboundp fun) | |
7876 | (apply fun args)) | |
7877 | ((and (boundp fun) | |
7878 | (fboundp (symbol-value fun))) | |
7879 | (apply (symbol-value fun) args)) | |
7880 | (t | |
7881 | (gnus-message 1 "You must define `%S' to use this button" | |
7882 | (cons fun args))))))) | |
7883 | ||
23f87bed | 7884 | (defun gnus-parse-news-url (url) |
82a8ad04 | 7885 | (let (scheme server port group message-id articles) |
23f87bed MB |
7886 | (with-temp-buffer |
7887 | (insert url) | |
7888 | (goto-char (point-min)) | |
7889 | (when (looking-at "\\([A-Za-z]+\\):") | |
7890 | (setq scheme (match-string 1)) | |
7891 | (goto-char (match-end 0))) | |
82a8ad04 | 7892 | (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/") |
23f87bed | 7893 | (setq server (match-string 1)) |
82a8ad04 MB |
7894 | (setq port (if (stringp (match-string 3)) |
7895 | (string-to-number (match-string 3)) | |
7896 | (match-string 3))) | |
23f87bed MB |
7897 | (goto-char (match-end 0))) |
7898 | ||
7899 | (cond | |
7900 | ((looking-at "\\(.*@.*\\)") | |
7901 | (setq message-id (match-string 1))) | |
7902 | ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)") | |
7903 | (setq group (match-string 1) | |
7904 | articles (split-string (match-string 2) "-"))) | |
7905 | ((looking-at "\\([^/]+\\)/?") | |
7906 | (setq group (match-string 1))) | |
7907 | (t | |
7908 | (error "Unknown news URL syntax")))) | |
82a8ad04 | 7909 | (list scheme server port group message-id articles))) |
23f87bed MB |
7910 | |
7911 | (defun gnus-button-handle-news (url) | |
7912 | "Fetch a news URL." | |
82a8ad04 | 7913 | (destructuring-bind (scheme server port group message-id articles) |
23f87bed MB |
7914 | (gnus-parse-news-url url) |
7915 | (cond | |
7916 | (message-id | |
80de1778 | 7917 | (with-current-buffer gnus-summary-buffer |
23f87bed | 7918 | (if server |
ff4d3926 MB |
7919 | (let ((gnus-refer-article-method |
7920 | (nconc (list (list 'nntp server)) | |
7921 | gnus-refer-article-method)) | |
82a8ad04 | 7922 | (nntp-port-number (or port "nntp"))) |
ff4d3926 MB |
7923 | (gnus-message 7 "Fetching %s with %s" |
7924 | message-id gnus-refer-article-method) | |
23f87bed MB |
7925 | (gnus-summary-refer-article message-id)) |
7926 | (gnus-summary-refer-article message-id)))) | |
7927 | (group | |
7928 | (gnus-button-fetch-group url))))) | |
7929 | ||
01c52d31 MB |
7930 | (defun gnus-button-patch (library line) |
7931 | "Visit an Emacs Lisp library LIBRARY on line LINE." | |
7932 | (interactive) | |
7933 | (let ((file (locate-library (file-name-nondirectory library)))) | |
7934 | (unless file | |
7935 | (error "Couldn't find library %s" library)) | |
7936 | (find-file file) | |
5dcc825f GM |
7937 | (goto-char (point-min)) |
7938 | (forward-line (1- (string-to-number line))))) | |
01c52d31 | 7939 | |
23f87bed MB |
7940 | (defun gnus-button-handle-man (url) |
7941 | "Fetch a man page." | |
531e5812 MB |
7942 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) |
7943 | (when (eq gnus-button-man-handler 'woman) | |
7944 | (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" ""))) | |
7945 | (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url) | |
23f87bed MB |
7946 | (funcall gnus-button-man-handler url)) |
7947 | ||
7948 | (defun gnus-button-handle-info-url (url) | |
7949 | "Fetch an info URL." | |
7950 | (setq url (mm-subst-char-in-string ?+ ?\ url)) | |
7951 | (cond | |
7952 | ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url) | |
7953 | (gnus-info-find-node | |
7954 | (concat "(" (or (gnus-url-unhex-string (match-string 1 url)) | |
7955 | "Gnus") | |
7956 | ")" (gnus-url-unhex-string (match-string 2 url))))) | |
7957 | ((string-match "([^)\"]+)[^\"]+" url) | |
7958 | (setq url | |
7959 | (gnus-replace-in-string | |
7960 | (gnus-replace-in-string url "[\n\t ]+" " ") "\"" "")) | |
7961 | (gnus-info-find-node url)) | |
7962 | (t (error "Can't parse %s" url)))) | |
7963 | ||
7964 | (defun gnus-button-handle-info-url-gnome (url) | |
7965 | "Fetch GNOME style info URL." | |
7966 | (setq url (mm-subst-char-in-string ?_ ?\ url)) | |
7967 | (if (string-match "\\([^#]+\\)#?\\(.*\\)" url) | |
7968 | (gnus-info-find-node | |
7969 | (concat "(" | |
bf247b6e | 7970 | (gnus-url-unhex-string |
23f87bed MB |
7971 | (match-string 1 url)) |
7972 | ")" | |
bf247b6e | 7973 | (or (gnus-url-unhex-string |
23f87bed MB |
7974 | (match-string 2 url)) |
7975 | "Top"))) | |
7976 | (error "Can't parse %s" url))) | |
7977 | ||
7978 | (defun gnus-button-handle-info-url-kde (url) | |
7979 | "Fetch KDE style info URL." | |
7980 | (gnus-info-find-node (gnus-url-unhex-string url))) | |
7981 | ||
9640c3bc GM |
7982 | ;; (info) will autoload info.el |
7983 | (declare-function Info-menu "info" (menu-item &optional fork)) | |
9b3ebcb6 | 7984 | (declare-function Info-index-next "info" (num)) |
9640c3bc | 7985 | |
23f87bed MB |
7986 | (defun gnus-button-handle-info-keystrokes (url) |
7987 | "Call `info' when pushing the corresponding URL button." | |
9b3ebcb6 MB |
7988 | ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'. |
7989 | (let (node indx comma) | |
7990 | (if (string-match | |
7991 | (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+" | |
7992 | "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" | |
7993 | "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET" | |
7994 | "\\(?:[ \t\n,]*\\)\\)?") | |
7995 | url) | |
7996 | (setq node (match-string 2 url) | |
7997 | indx (match-string 3 url)) | |
7998 | (error "Can't parse %s" url)) | |
7999 | (info) | |
8000 | (Info-directory) | |
8001 | (Info-menu node) | |
8002 | (when (> (length indx) 0) | |
8003 | (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET" | |
8004 | "\\([ \t\n,]*\\)") | |
8005 | indx) | |
8006 | (setq comma (match-string 2 indx)) | |
8007 | (setq indx (match-string 1 indx)) | |
8008 | (Info-index indx) | |
8009 | (when comma | |
8010 | (dotimes (i (with-temp-buffer | |
8011 | (insert comma) | |
8012 | ;; Note: the XEmacs version of `how-many' takes | |
8013 | ;; no optional argument. | |
8014 | (goto-char (point-min)) | |
8015 | (how-many ","))) | |
8016 | (Info-index-next 1))) | |
8017 | nil))) | |
1888e568 GM |
8018 | |
8019 | ;; Called after pgg-snarf-keys-region, which autoloads pgg.el. | |
8020 | (declare-function pgg-display-output-buffer "pgg" (start end status)) | |
23f87bed | 8021 | |
01c52d31 MB |
8022 | (defun gnus-button-openpgp (url) |
8023 | "Retrieve and add an OpenPGP key given URL from an OpenPGP header." | |
8024 | (with-temp-buffer | |
8025 | (mm-url-insert-file-contents-external url) | |
8026 | (pgg-snarf-keys-region (point-min) (point-max)) | |
8027 | (pgg-display-output-buffer nil nil nil))) | |
8028 | ||
eec82323 LMI |
8029 | (defun gnus-button-message-id (message-id) |
8030 | "Fetch MESSAGE-ID." | |
01c52d31 | 8031 | (with-current-buffer gnus-summary-buffer |
eec82323 LMI |
8032 | (gnus-summary-refer-article message-id))) |
8033 | ||
01c52d31 | 8034 | (defun gnus-button-fetch-group (address &rest ignore) |
eec82323 | 8035 | "Fetch GROUP specified by ADDRESS." |
01c52d31 MB |
8036 | (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'" |
8037 | address) | |
8038 | ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function' | |
8039 | ;; for nntp:// and news:// | |
8040 | (setq address (match-string 3 address))) | |
eec82323 LMI |
8041 | (if (not (string-match "[:/]" address)) |
8042 | ;; This is just a simple group url. | |
8043 | (gnus-group-read-ephemeral-group address gnus-select-method) | |
23f87bed MB |
8044 | (if (not |
8045 | (string-match | |
8046 | "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?" | |
8047 | address)) | |
eec82323 LMI |
8048 | (error "Can't parse %s" address) |
8049 | (gnus-group-read-ephemeral-group | |
8050 | (match-string 4 address) | |
8051 | `(nntp ,(match-string 1 address) | |
8052 | (nntp-address ,(match-string 1 address)) | |
8053 | (nntp-port-number ,(if (match-end 3) | |
8054 | (match-string 3 address) | |
23f87bed MB |
8055 | "nntp"))) |
8056 | nil nil nil | |
e9bd5782 | 8057 | (and (match-end 6) (list (string-to-number (match-string 6 address)))))))) |
eec82323 | 8058 | |
eec82323 LMI |
8059 | (defun gnus-url-parse-query-string (query &optional downcase) |
8060 | (let (retval pairs cur key val) | |
16409b0b | 8061 | (setq pairs (split-string query "&")) |
eec82323 LMI |
8062 | (while pairs |
8063 | (setq cur (car pairs) | |
23f87bed | 8064 | pairs (cdr pairs)) |
eec82323 | 8065 | (if (not (string-match "=" cur)) |
23f87bed MB |
8066 | nil ; Grace |
8067 | (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0))) | |
8068 | val (gnus-url-unhex-string (substring cur (match-end 0) nil) t)) | |
8069 | (if downcase | |
8070 | (setq key (downcase key))) | |
8071 | (setq cur (assoc key retval)) | |
8072 | (if cur | |
8073 | (setcdr cur (cons val (cdr cur))) | |
8074 | (setq retval (cons (list key val) retval))))) | |
eec82323 LMI |
8075 | retval)) |
8076 | ||
eec82323 LMI |
8077 | (defun gnus-url-mailto (url) |
8078 | ;; Send mail to someone | |
8079 | (when (string-match "mailto:/*\\(.*\\)" url) | |
8080 | (setq url (substring url (match-beginning 1) nil))) | |
6748645f | 8081 | (let (to args subject func) |
23f87bed MB |
8082 | (setq args (gnus-url-parse-query-string |
8083 | (if (string-match "^\\?" url) | |
8084 | (substring url 1) | |
8085 | (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url) | |
8086 | (concat "to=" (match-string 1 url) "&" | |
8087 | (match-string 2 url)) | |
8088 | (concat "to=" url))) | |
8089 | t) | |
8090 | subject (cdr-safe (assoc "subject" args))) | |
8091 | (gnus-msg-mail) | |
eec82323 LMI |
8092 | (while args |
8093 | (setq func (intern-soft (concat "message-goto-" (downcase (caar args))))) | |
8094 | (if (fboundp func) | |
23f87bed MB |
8095 | (funcall func) |
8096 | (message-position-on-field (caar args))) | |
8097 | (insert (gnus-replace-in-string | |
8098 | (mapconcat 'identity (reverse (cdar args)) ", ") | |
8099 | "\r\n" "\n" t)) | |
eec82323 LMI |
8100 | (setq args (cdr args))) |
8101 | (if subject | |
23f87bed | 8102 | (message-goto-body) |
eec82323 LMI |
8103 | (message-goto-subject)))) |
8104 | ||
eec82323 | 8105 | (defun gnus-button-embedded-url (address) |
e0bad764 | 8106 | "Activate ADDRESS with `browse-url'." |
1b978bfc | 8107 | (browse-url (gnus-strip-whitespace address))) |
eec82323 LMI |
8108 | |
8109 | ;;; Next/prev buttons in the article buffer. | |
8110 | ||
8111 | (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") | |
8112 | (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") | |
8113 | ||
23f87bed MB |
8114 | (defvar gnus-prev-page-map |
8115 | (let ((map (make-sparse-keymap))) | |
23f87bed MB |
8116 | (define-key map gnus-mouse-2 'gnus-button-prev-page) |
8117 | (define-key map "\r" 'gnus-button-prev-page) | |
8118 | map)) | |
8119 | ||
8120 | (defvar gnus-next-page-map | |
8121 | (let ((map (make-sparse-keymap))) | |
8122 | (unless (>= emacs-major-version 21) | |
8123 | ;; XEmacs doesn't care. | |
8124 | (set-keymap-parent map gnus-article-mode-map)) | |
8125 | (define-key map gnus-mouse-2 'gnus-button-next-page) | |
8126 | (define-key map "\r" 'gnus-button-next-page) | |
8127 | map)) | |
eec82323 LMI |
8128 | |
8129 | (defun gnus-insert-prev-page-button () | |
01c52d31 | 8130 | (let ((b (point)) e |
23f87bed | 8131 | (inhibit-read-only t)) |
eec82323 LMI |
8132 | (gnus-eval-format |
8133 | gnus-prev-page-line-format nil | |
01c52d31 MB |
8134 | `(keymap ,gnus-prev-page-map |
8135 | gnus-prev t | |
8136 | gnus-callback gnus-article-button-prev-page | |
8137 | article-type annotation)) | |
8138 | (setq e (if (bolp) | |
8139 | ;; Exclude a newline. | |
8140 | (1- (point)) | |
8141 | (point))) | |
8142 | (when gnus-article-button-face | |
8143 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8144 | 'face gnus-article-button-face)) | |
23f87bed | 8145 | (widget-convert-button |
01c52d31 | 8146 | 'link b e |
23f87bed MB |
8147 | :action 'gnus-button-prev-page |
8148 | :button-keymap gnus-prev-page-map))) | |
8149 | ||
8150 | (defun gnus-button-next-page (&optional args more-args) | |
eec82323 LMI |
8151 | "Go to the next page." |
8152 | (interactive) | |
8153 | (let ((win (selected-window))) | |
23f87bed | 8154 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8155 | (gnus-article-next-page) |
8156 | (select-window win))) | |
8157 | ||
23f87bed | 8158 | (defun gnus-button-prev-page (&optional args more-args) |
eec82323 LMI |
8159 | "Go to the prev page." |
8160 | (interactive) | |
8161 | (let ((win (selected-window))) | |
23f87bed | 8162 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8163 | (gnus-article-prev-page) |
8164 | (select-window win))) | |
8165 | ||
8166 | (defun gnus-insert-next-page-button () | |
01c52d31 | 8167 | (let ((b (point)) e |
23f87bed | 8168 | (inhibit-read-only t)) |
eec82323 | 8169 | (gnus-eval-format gnus-next-page-line-format nil |
01c52d31 MB |
8170 | `(keymap ,gnus-next-page-map |
8171 | gnus-next t | |
8172 | gnus-callback gnus-article-button-next-page | |
8173 | article-type annotation)) | |
8174 | (setq e (if (bolp) | |
8175 | ;; Exclude a newline. | |
8176 | (1- (point)) | |
8177 | (point))) | |
8178 | (when gnus-article-button-face | |
8179 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8180 | 'face gnus-article-button-face)) | |
23f87bed | 8181 | (widget-convert-button |
01c52d31 | 8182 | 'link b e |
23f87bed MB |
8183 | :action 'gnus-button-next-page |
8184 | :button-keymap gnus-next-page-map))) | |
eec82323 LMI |
8185 | |
8186 | (defun gnus-article-button-next-page (arg) | |
8187 | "Go to the next page." | |
8188 | (interactive "P") | |
8189 | (let ((win (selected-window))) | |
23f87bed | 8190 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8191 | (gnus-article-next-page) |
8192 | (select-window win))) | |
8193 | ||
8194 | (defun gnus-article-button-prev-page (arg) | |
8195 | "Go to the prev page." | |
8196 | (interactive "P") | |
8197 | (let ((win (selected-window))) | |
23f87bed | 8198 | (select-window (gnus-get-buffer-window gnus-article-buffer t)) |
eec82323 LMI |
8199 | (gnus-article-prev-page) |
8200 | (select-window win))) | |
8201 | ||
16409b0b GM |
8202 | (defvar gnus-decode-header-methods |
8203 | '(mail-decode-encoded-word-region) | |
8204 | "List of methods used to decode headers. | |
8205 | ||
8206 | This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item | |
4e7d0221 | 8207 | is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a |
23f87bed | 8208 | \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups |
16409b0b GM |
8209 | whose names match REGEXP. |
8210 | ||
8211 | For example: | |
8f688cb0 | 8212 | \((\"chinese\" . gnus-decode-encoded-word-region-by-guess) |
16409b0b GM |
8213 | mail-decode-encoded-word-region |
8214 | (\"chinese\" . rfc1843-decode-region)) | |
8215 | ") | |
8216 | ||
8217 | (defvar gnus-decode-header-methods-cache nil) | |
8218 | ||
8219 | (defun gnus-multi-decode-header (start end) | |
8220 | "Apply the functions from `gnus-encoded-word-methods' that match." | |
8221 | (unless (and gnus-decode-header-methods-cache | |
8222 | (eq gnus-newsgroup-name | |
8223 | (car gnus-decode-header-methods-cache))) | |
8224 | (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name)) | |
01c52d31 MB |
8225 | (dolist (x gnus-decode-header-methods) |
8226 | (if (symbolp x) | |
8227 | (nconc gnus-decode-header-methods-cache (list x)) | |
8228 | (if (and gnus-newsgroup-name | |
8229 | (string-match (car x) gnus-newsgroup-name)) | |
8230 | (nconc gnus-decode-header-methods-cache | |
8231 | (list (cdr x))))))) | |
16409b0b GM |
8232 | (let ((xlist gnus-decode-header-methods-cache)) |
8233 | (pop xlist) | |
8234 | (save-restriction | |
8235 | (narrow-to-region start end) | |
8236 | (while xlist | |
8237 | (funcall (pop xlist) (point-min) (point-max)))))) | |
8238 | ||
8239 | ;;; | |
8240 | ;;; Treatment top-level handling. | |
8241 | ;;; | |
8242 | ||
8243 | (defun gnus-treat-article (condition &optional part-number total-parts type) | |
8244 | (let ((length (- (point-max) (point-min))) | |
8245 | (alist gnus-treatment-function-alist) | |
8246 | (article-goto-body-goes-to-point-min-p t) | |
8247 | (treated-type | |
8248 | (or (not type) | |
8249 | (catch 'found | |
8250 | (let ((list gnus-article-treat-types)) | |
8251 | (while list | |
8252 | (when (string-match (pop list) type) | |
8253 | (throw 'found t))))))) | |
8254 | (highlightp (gnus-visual-p 'article-highlight 'highlight)) | |
8255 | val elem) | |
8256 | (gnus-run-hooks 'gnus-part-display-hook) | |
23f87bed | 8257 | (dolist (elem alist) |
16409b0b GM |
8258 | (setq val |
8259 | (save-excursion | |
23f87bed MB |
8260 | (when (gnus-buffer-live-p gnus-summary-buffer) |
8261 | (set-buffer gnus-summary-buffer)) | |
16409b0b GM |
8262 | (symbol-value (car elem)))) |
8263 | (when (and (or (consp val) | |
8264 | treated-type) | |
8265 | (gnus-treat-predicate val) | |
8266 | (or (not (get (car elem) 'highlight)) | |
8267 | highlightp)) | |
8268 | (save-restriction | |
8269 | (funcall (cadr elem))))))) | |
8270 | ||
8271 | ;; Dynamic variables. | |
9efa445f DN |
8272 | (defvar part-number) |
8273 | (defvar total-parts) | |
8274 | (defvar type) | |
8275 | (defvar condition) | |
8276 | (defvar length) | |
e0bad764 | 8277 | |
16409b0b GM |
8278 | (defun gnus-treat-predicate (val) |
8279 | (cond | |
8280 | ((null val) | |
8281 | nil) | |
23f87bed MB |
8282 | (condition |
8283 | (eq condition val)) | |
16409b0b GM |
8284 | ((and (listp val) |
8285 | (stringp (car val))) | |
8286 | (apply 'gnus-or (mapcar `(lambda (s) | |
8287 | (string-match s ,(or gnus-newsgroup-name ""))) | |
8288 | val))) | |
8289 | ((listp val) | |
8290 | (let ((pred (pop val))) | |
8291 | (cond | |
8292 | ((eq pred 'or) | |
8293 | (apply 'gnus-or (mapcar 'gnus-treat-predicate val))) | |
8294 | ((eq pred 'and) | |
8295 | (apply 'gnus-and (mapcar 'gnus-treat-predicate val))) | |
8296 | ((eq pred 'not) | |
8297 | (not (gnus-treat-predicate (car val)))) | |
8298 | ((eq pred 'typep) | |
8299 | (equal (car val) type)) | |
8300 | (t | |
8301 | (error "%S is not a valid predicate" pred))))) | |
16409b0b GM |
8302 | ((eq val t) |
8303 | t) | |
8304 | ((eq val 'head) | |
8305 | nil) | |
01c52d31 MB |
8306 | ((eq val 'first) |
8307 | (eq part-number 1)) | |
16409b0b GM |
8308 | ((eq val 'last) |
8309 | (eq part-number total-parts)) | |
8310 | ((numberp val) | |
8311 | (< length val)) | |
8312 | (t | |
8313 | (error "%S is not a valid value" val)))) | |
8314 | ||
23f87bed MB |
8315 | (defun gnus-article-encrypt-body (protocol &optional n) |
8316 | "Encrypt the article body." | |
8317 | (interactive | |
8318 | (list | |
8319 | (or gnus-article-encrypt-protocol | |
8320 | (completing-read "Encrypt protocol: " | |
8321 | gnus-article-encrypt-protocol-alist | |
8322 | nil t)) | |
8323 | current-prefix-arg)) | |
bbbe940b MB |
8324 | ;; User might hit `K E' instead of `K e', so prompt once. |
8325 | (when (and gnus-article-encrypt-protocol | |
8326 | gnus-novice-user) | |
8327 | (unless (gnus-y-or-n-p "Really encrypt article(s)? ") | |
d93ec753 | 8328 | (error "Encrypt aborted"))) |
23f87bed MB |
8329 | (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist)))) |
8330 | (unless func | |
998a5a95 | 8331 | (error "Can't find the encrypt protocol %s" protocol)) |
23f87bed MB |
8332 | (if (member gnus-newsgroup-name '("nndraft:delayed" |
8333 | "nndraft:drafts" | |
8334 | "nndraft:queue")) | |
8335 | (error "Can't encrypt the article in group %s" | |
8336 | gnus-newsgroup-name)) | |
8337 | (gnus-summary-iterate n | |
80de1778 | 8338 | (with-current-buffer gnus-summary-buffer |
23f87bed MB |
8339 | (let ((mail-parse-charset gnus-newsgroup-charset) |
8340 | (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets) | |
8341 | (summary-buffer gnus-summary-buffer) | |
8342 | references point) | |
8343 | (gnus-set-global-variables) | |
8344 | (when (gnus-group-read-only-p) | |
8345 | (error "The current newsgroup does not support article encrypt")) | |
8346 | (gnus-summary-show-article t) | |
8347 | (setq references | |
8348 | (or (mail-header-references gnus-current-headers) "")) | |
8349 | (set-buffer gnus-article-buffer) | |
8350 | (let* ((inhibit-read-only t) | |
8351 | (headers | |
8352 | (mapcar (lambda (field) | |
8353 | (and (save-restriction | |
8354 | (message-narrow-to-head) | |
8355 | (goto-char (point-min)) | |
8356 | (search-forward field nil t)) | |
8357 | (prog2 | |
8358 | (message-narrow-to-field) | |
8359 | (buffer-string) | |
8360 | (delete-region (point-min) (point-max)) | |
8361 | (widen)))) | |
8362 | '("Content-Type:" "Content-Transfer-Encoding:" | |
8363 | "Content-Disposition:")))) | |
8364 | (message-narrow-to-head) | |
8365 | (message-remove-header "MIME-Version") | |
8366 | (goto-char (point-max)) | |
8367 | (setq point (point)) | |
8368 | (insert (apply 'concat headers)) | |
8369 | (widen) | |
8370 | (narrow-to-region point (point-max)) | |
8371 | (let ((message-options message-options)) | |
8372 | (message-options-set 'message-sender user-mail-address) | |
8373 | (message-options-set 'message-recipients user-mail-address) | |
8374 | (message-options-set 'message-sign-encrypt 'not) | |
8375 | (funcall func)) | |
8376 | (goto-char (point-min)) | |
8377 | (insert "MIME-Version: 1.0\n") | |
8378 | (widen) | |
8379 | (gnus-summary-edit-article-done | |
8380 | references nil summary-buffer t)) | |
8381 | (when gnus-keep-backlog | |
8382 | (gnus-backlog-remove-article | |
8383 | (car gnus-article-current) (cdr gnus-article-current))) | |
80de1778 SM |
8384 | (when (get-buffer gnus-original-article-buffer) |
8385 | (with-current-buffer gnus-original-article-buffer | |
23f87bed MB |
8386 | (setq gnus-original-article nil))) |
8387 | (when gnus-use-cache | |
8388 | (gnus-cache-update-article | |
8389 | (car gnus-article-current) (cdr gnus-article-current)))))))) | |
8390 | ||
8391 | (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n" | |
8392 | "The following specs can be used: | |
8393 | %t The security MIME type | |
8394 | %i Additional info | |
8395 | %d Details | |
8396 | %D Details if button is pressed") | |
8397 | ||
8398 | (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n" | |
8399 | "The following specs can be used: | |
8400 | %t The security MIME type | |
8401 | %i Additional info | |
8402 | %d Details | |
8403 | %D Details if button is pressed") | |
8404 | ||
8405 | (defvar gnus-mime-security-button-line-format-alist | |
8406 | '((?t gnus-tmp-type ?s) | |
8407 | (?i gnus-tmp-info ?s) | |
8408 | (?d gnus-tmp-details ?s) | |
8409 | (?D gnus-tmp-pressed-details ?s))) | |
8410 | ||
01c52d31 MB |
8411 | (defvar gnus-mime-security-button-commands |
8412 | '((gnus-article-press-button "\r" "Show Detail") | |
8413 | (undefined "v") | |
8414 | (undefined "t") | |
8415 | (undefined "C") | |
8416 | (gnus-mime-security-save-part "o" "Save...") | |
8417 | (undefined "\C-o") | |
8418 | (undefined "r") | |
8419 | (undefined "d") | |
8420 | (undefined "c") | |
8421 | (undefined "i") | |
8422 | (undefined "E") | |
8423 | (undefined "e") | |
8424 | (undefined "p") | |
8425 | (gnus-mime-security-pipe-part "|" "Pipe To Command...") | |
8426 | (undefined "."))) | |
8427 | ||
23f87bed MB |
8428 | (defvar gnus-mime-security-button-map |
8429 | (let ((map (make-sparse-keymap))) | |
23f87bed | 8430 | (define-key map gnus-mouse-2 'gnus-article-push-button) |
01c52d31 MB |
8431 | (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu) |
8432 | (dolist (c gnus-mime-security-button-commands) | |
8433 | (define-key map (cadr c) (car c))) | |
23f87bed MB |
8434 | map)) |
8435 | ||
01c52d31 MB |
8436 | (easy-menu-define |
8437 | gnus-mime-security-button-menu gnus-mime-security-button-map | |
8438 | "Security button menu." | |
8439 | `("Security Part" | |
8440 | ,@(delq nil | |
8441 | (mapcar (lambda (c) | |
8442 | (unless (eq (car c) 'undefined) | |
8443 | (vector (caddr c) (car c) :active t))) | |
8444 | gnus-mime-security-button-commands)))) | |
8445 | ||
8446 | (defun gnus-mime-security-button-menu (event prefix) | |
8447 | "Construct a context-sensitive menu of security commands." | |
8448 | (interactive "e\nP") | |
8449 | (save-window-excursion | |
8450 | (let ((pos (event-start event))) | |
8451 | (select-window (posn-window pos)) | |
8452 | (goto-char (posn-point pos)) | |
8453 | (gnus-article-check-buffer) | |
8454 | (popup-menu gnus-mime-security-button-menu nil prefix)))) | |
8455 | ||
23f87bed MB |
8456 | (defvar gnus-mime-security-details-buffer nil) |
8457 | ||
8458 | (defvar gnus-mime-security-button-pressed nil) | |
8459 | ||
8460 | (defvar gnus-mime-security-show-details-inline t | |
8461 | "If non-nil, show details in the article buffer.") | |
8462 | ||
8463 | (defun gnus-mime-security-verify-or-decrypt (handle) | |
8464 | (mm-remove-parts (cdr handle)) | |
8465 | (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region)) | |
8466 | point (inhibit-read-only t)) | |
8467 | (if region | |
8468 | (goto-char (car region))) | |
01c52d31 MB |
8469 | (setq point (point)) |
8470 | (with-current-buffer (mm-handle-multipart-original-buffer handle) | |
8471 | (let* ((mm-verify-option 'known) | |
8472 | (mm-decrypt-option 'known) | |
8473 | (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle))) | |
8474 | (unless (eq nparts (cdr handle)) | |
8475 | (mm-destroy-parts (cdr handle)) | |
8476 | (setcdr handle nparts)))) | |
8477 | (gnus-mime-display-security handle) | |
23f87bed MB |
8478 | (when region |
8479 | (delete-region (point) (cdr region)) | |
8480 | (set-marker (car region) nil) | |
8481 | (set-marker (cdr region) nil)) | |
8482 | (goto-char point))) | |
8483 | ||
8484 | (defun gnus-mime-security-show-details (handle) | |
8485 | (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details))) | |
8486 | (if (not details) | |
8487 | (gnus-message 5 "No details.") | |
8488 | (if gnus-mime-security-show-details-inline | |
8489 | (let ((gnus-mime-security-button-pressed | |
8490 | (not (get-text-property (point) 'gnus-mime-details))) | |
8491 | (gnus-mime-security-button-line-format | |
8492 | (get-text-property (point) 'gnus-line-format)) | |
8493 | (inhibit-read-only t)) | |
8494 | (forward-char -1) | |
8495 | (while (eq (get-text-property (point) 'gnus-line-format) | |
8496 | gnus-mime-security-button-line-format) | |
8497 | (forward-char -1)) | |
8498 | (forward-char) | |
8499 | (save-restriction | |
8500 | (narrow-to-region (point) (point)) | |
8501 | (gnus-insert-mime-security-button handle)) | |
8502 | (delete-region (point) | |
8503 | (or (text-property-not-all | |
8504 | (point) (point-max) | |
8505 | 'gnus-line-format | |
8506 | gnus-mime-security-button-line-format) | |
8507 | (point-max)))) | |
8508 | ;; Not inlined. | |
8509 | (if (gnus-buffer-live-p gnus-mime-security-details-buffer) | |
8510 | (with-current-buffer gnus-mime-security-details-buffer | |
8511 | (erase-buffer) | |
8512 | t) | |
8513 | (setq gnus-mime-security-details-buffer | |
8514 | (gnus-get-buffer-create "*MIME Security Details*"))) | |
8515 | (with-current-buffer gnus-mime-security-details-buffer | |
8516 | (insert details) | |
8517 | (goto-char (point-min))) | |
8518 | (pop-to-buffer gnus-mime-security-details-buffer))))) | |
8519 | ||
8520 | (defun gnus-mime-security-press-button (handle) | |
8521 | (save-excursion | |
8522 | (if (mm-handle-multipart-ctl-parameter handle 'gnus-info) | |
8523 | (gnus-mime-security-show-details handle) | |
8524 | (gnus-mime-security-verify-or-decrypt handle)))) | |
8525 | ||
8526 | (defun gnus-insert-mime-security-button (handle &optional displayed) | |
8527 | (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol)) | |
8528 | (gnus-tmp-type | |
8529 | (concat | |
8530 | (or (nth 2 (assoc protocol mm-verify-function-alist)) | |
8531 | (nth 2 (assoc protocol mm-decrypt-function-alist)) | |
8532 | "Unknown") | |
8533 | (if (equal (car handle) "multipart/signed") | |
8534 | " Signed" " Encrypted") | |
8535 | " Part")) | |
8536 | (gnus-tmp-info | |
8537 | (or (mm-handle-multipart-ctl-parameter handle 'gnus-info) | |
8538 | "Undecided")) | |
8539 | (gnus-tmp-details | |
8540 | (mm-handle-multipart-ctl-parameter handle 'gnus-details)) | |
8541 | gnus-tmp-pressed-details | |
8542 | b e) | |
8543 | (setq gnus-tmp-details | |
8544 | (if gnus-tmp-details | |
8545 | (concat "\n" gnus-tmp-details) | |
8546 | "")) | |
8547 | (setq gnus-tmp-pressed-details | |
8548 | (if gnus-mime-security-button-pressed gnus-tmp-details "")) | |
8549 | (unless (bolp) | |
8550 | (insert "\n")) | |
8551 | (setq b (point)) | |
8552 | (gnus-eval-format | |
8553 | gnus-mime-security-button-line-format | |
8554 | gnus-mime-security-button-line-format-alist | |
01c52d31 | 8555 | `(keymap ,gnus-mime-security-button-map |
23f87bed MB |
8556 | gnus-callback gnus-mime-security-press-button |
8557 | gnus-line-format ,gnus-mime-security-button-line-format | |
8558 | gnus-mime-details ,gnus-mime-security-button-pressed | |
8559 | article-type annotation | |
8560 | gnus-data ,handle)) | |
8561 | (setq e (if (bolp) | |
8562 | ;; Exclude a newline. | |
8563 | (1- (point)) | |
8564 | (point))) | |
01c52d31 MB |
8565 | (when gnus-article-button-face |
8566 | (gnus-overlay-put (gnus-make-overlay b e nil t) | |
8567 | 'face gnus-article-button-face)) | |
23f87bed MB |
8568 | (widget-convert-button |
8569 | 'link b e | |
8570 | :mime-handle handle | |
8571 | :action 'gnus-widget-press-button | |
8572 | :button-keymap gnus-mime-security-button-map | |
8573 | :help-echo | |
8574 | (lambda (widget/window &optional overlay pos) | |
8575 | ;; Needed to properly clear the message due to a bug in | |
8576 | ;; wid-edit (XEmacs only). | |
8577 | (when (boundp 'help-echo-owns-message) | |
8578 | (setq help-echo-owns-message t)) | |
8579 | (format | |
01c52d31 MB |
8580 | "%S: show detail; %S: more options" |
8581 | (aref gnus-mouse-2 0) | |
8582 | (aref gnus-down-mouse-3 0)))))) | |
23f87bed MB |
8583 | |
8584 | (defun gnus-mime-display-security (handle) | |
8585 | (save-restriction | |
8586 | (narrow-to-region (point) (point)) | |
8587 | (unless (gnus-unbuttonized-mime-type-p (car handle)) | |
8588 | (gnus-insert-mime-security-button handle)) | |
01c52d31 | 8589 | (gnus-mime-display-part (cadr handle)) |
23f87bed MB |
8590 | (unless (bolp) |
8591 | (insert "\n")) | |
8592 | (unless (gnus-unbuttonized-mime-type-p (car handle)) | |
8593 | (let ((gnus-mime-security-button-line-format | |
8594 | gnus-mime-security-button-end-line-format)) | |
8595 | (gnus-insert-mime-security-button handle))) | |
8596 | (mm-set-handle-multipart-parameter | |
8597 | handle 'gnus-region | |
8598 | (cons (set-marker (make-marker) (point-min)) | |
01c52d31 MB |
8599 | (set-marker (make-marker) (point-max)))) |
8600 | (goto-char (point-max)))) | |
8601 | ||
8602 | (defun gnus-mime-security-run-function (function) | |
8603 | "Run FUNCTION with the security part under point." | |
8604 | (gnus-article-check-buffer) | |
8605 | (let ((data (get-text-property (point) 'gnus-data)) | |
8606 | buffer handle) | |
8607 | (when (and (stringp (car-safe data)) | |
8608 | (setq buffer (mm-handle-multipart-original-buffer data)) | |
8609 | (setq handle (cadr data))) | |
8610 | (if (bufferp (mm-handle-buffer handle)) | |
8611 | (progn | |
8612 | (setq handle (cons buffer (copy-sequence (cdr handle)))) | |
8613 | (mm-handle-set-undisplayer handle nil)) | |
8614 | (setq handle (mm-make-handle | |
8615 | buffer | |
8616 | (mm-handle-multipart-ctl-parameter handle 'protocol) | |
8617 | nil nil nil nil nil nil))) | |
8618 | (funcall function handle)))) | |
8619 | ||
8620 | (defun gnus-mime-security-save-part () | |
8621 | "Save the security part under point." | |
8622 | (interactive) | |
8623 | (gnus-mime-security-run-function 'mm-save-part)) | |
8624 | ||
8625 | (defun gnus-mime-security-pipe-part () | |
8626 | "Pipe the security part under point to a process." | |
8627 | (interactive) | |
8628 | (gnus-mime-security-run-function 'mm-pipe-part)) | |
23f87bed | 8629 | |
eec82323 LMI |
8630 | (gnus-ems-redefine) |
8631 | ||
8632 | (provide 'gnus-art) | |
8633 | ||
8634 | (run-hooks 'gnus-art-load-hook) | |
8635 | ||
80de1778 | 8636 | ;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33 |
eec82323 | 8637 | ;;; gnus-art.el ends here |