Mercurial > emacs
annotate lisp/gnus/gnus-art.el @ 21400:d2b302f002af
Don't include <string.h> when configuring.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 07 Apr 1998 03:21:19 +0000 |
parents | c62cc873509f |
children | 900aecbf7d38 |
rev | line source |
---|---|
17493 | 1 ;;; gnus-art.el --- article mode commands for Gnus |
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
5 ;; Keywords: news | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 |
17493 | 30 (require 'custom) |
31 (require 'gnus) | |
32 (require 'gnus-sum) | |
33 (require 'gnus-spec) | |
34 (require 'gnus-int) | |
35 (require 'browse-url) | |
36 | |
37 (defgroup gnus-article nil | |
38 "Article display." | |
39 :link '(custom-manual "(gnus)The Article Buffer") | |
40 :group 'gnus) | |
41 | |
42 (defgroup gnus-article-hiding nil | |
43 "Hiding article parts." | |
44 :link '(custom-manual "(gnus)Article Hiding") | |
45 :group 'gnus-article) | |
46 | |
47 (defgroup gnus-article-highlight nil | |
48 "Article highlighting." | |
49 :link '(custom-manual "(gnus)Article Highlighting") | |
50 :group 'gnus-article | |
51 :group 'gnus-visual) | |
52 | |
53 (defgroup gnus-article-signature nil | |
54 "Article signatures." | |
55 :link '(custom-manual "(gnus)Article Signature") | |
56 :group 'gnus-article) | |
57 | |
58 (defgroup gnus-article-headers nil | |
59 "Article headers." | |
60 :link '(custom-manual "(gnus)Hiding Headers") | |
61 :group 'gnus-article) | |
62 | |
63 (defgroup gnus-article-washing nil | |
64 "Special commands on articles." | |
65 :link '(custom-manual "(gnus)Article Washing") | |
66 :group 'gnus-article) | |
67 | |
68 (defgroup gnus-article-emphasis nil | |
69 "Fontisizing articles." | |
70 :link '(custom-manual "(gnus)Article Fontisizing") | |
71 :group 'gnus-article) | |
72 | |
73 (defgroup gnus-article-saving nil | |
74 "Saving articles." | |
75 :link '(custom-manual "(gnus)Saving Articles") | |
76 :group 'gnus-article) | |
77 | |
78 (defgroup gnus-article-mime nil | |
79 "Worshiping the MIME wonder." | |
80 :link '(custom-manual "(gnus)Using MIME") | |
81 :group 'gnus-article) | |
82 | |
83 (defgroup gnus-article-buttons nil | |
84 "Pushable buttons in the article buffer." | |
85 :link '(custom-manual "(gnus)Article Buttons") | |
86 :group 'gnus-article) | |
87 | |
88 (defgroup gnus-article-various nil | |
89 "Other article options." | |
90 :link '(custom-manual "(gnus)Misc Article") | |
91 :group 'gnus-article) | |
92 | |
93 (defcustom gnus-ignored-headers | |
94 '("^Path:" "^Posting-Version:" "^Article-I.D.:" "^Expires:" | |
95 "^Date-Received:" "^References:" "^Control:" "^Xref:" "^Lines:" | |
96 "^Posted:" "^Relay-Version:" "^Message-ID:" "^Nf-ID:" "^Nf-From:" | |
97 "^Approved:" "^Sender:" "^Received:" "^Mail-from:") | |
98 "All headers that match this regexp will be hidden. | |
99 This variable can also be a list of regexps of headers to be ignored. | |
100 If `gnus-visible-headers' is non-nil, this variable will be ignored." | |
101 :type '(choice :custom-show nil | |
102 regexp | |
103 (repeat regexp)) | |
104 :group 'gnus-article-hiding) | |
105 | |
106 (defcustom gnus-visible-headers | |
107 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From" | |
108 "All headers that do not match this regexp will be hidden. | |
109 This variable can also be a list of regexp of headers to remain visible. | |
110 If this variable is non-nil, `gnus-ignored-headers' will be ignored." | |
111 :type '(repeat :value-to-internal (lambda (widget value) | |
112 (custom-split-regexp-maybe value)) | |
113 :match (lambda (widget value) | |
114 (or (stringp value) | |
115 (widget-editable-list-match widget value))) | |
116 regexp) | |
117 :group 'gnus-article-hiding) | |
118 | |
119 (defcustom gnus-sorted-header-list | |
120 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" | |
121 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:") | |
122 "This variable is a list of regular expressions. | |
123 If it is non-nil, headers that match the regular expressions will | |
124 be placed first in the article buffer in the sequence specified by | |
125 this list." | |
126 :type '(repeat regexp) | |
127 :group 'gnus-article-hiding) | |
128 | |
129 (defcustom gnus-boring-article-headers '(empty followup-to reply-to) | |
130 "Headers that are only to be displayed if they have interesting data. | |
131 Possible values in this list are `empty', `newsgroups', `followup-to', | |
132 `reply-to', and `date'." | |
133 :type '(set (const :tag "Headers with no content." empty) | |
134 (const :tag "Newsgroups with only one group." newsgroups) | |
135 (const :tag "Followup-to identical to newsgroups." followup-to) | |
136 (const :tag "Reply-to identical to from." reply-to) | |
137 (const :tag "Date less than four days old." date)) | |
138 :group 'gnus-article-hiding) | |
139 | |
140 (defcustom gnus-signature-separator '("^-- $" "^-- *$") | |
141 "Regexp matching signature separator. | |
142 This can also be a list of regexps. In that case, it will be checked | |
143 from head to tail looking for a separator. Searches will be done from | |
144 the end of the buffer." | |
145 :type '(repeat string) | |
146 :group 'gnus-article-signature) | |
147 | |
148 (defcustom gnus-signature-limit nil | |
149 "Provide a limit to what is considered a signature. | |
150 If it is a number, no signature may not be longer (in characters) than | |
151 that number. If it is a floating point number, no signature may be | |
152 longer (in lines) than that number. If it is a function, the function | |
153 will be called without any parameters, and if it returns nil, there is | |
154 no signature in the buffer. If it is a string, it will be used as a | |
155 regexp. If it matches, the text in question is not a signature." | |
156 :type '(choice integer number function regexp) | |
157 :group 'gnus-article-signature) | |
158 | |
159 (defcustom gnus-hidden-properties '(invisible t intangible t) | |
160 "Property list to use for hiding text." | |
161 :type 'sexp | |
162 :group 'gnus-article-hiding) | |
163 | |
164 (defcustom gnus-article-x-face-command | |
165 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -" | |
166 "String or function to be executed to display an X-Face header. | |
167 If it is a string, the command will be executed in a sub-shell | |
168 asynchronously. The compressed face will be piped to this command." | |
169 :type 'string ;Leave function case to Lisp. | |
170 :group 'gnus-article-washing) | |
171 | |
172 (defcustom gnus-article-x-face-too-ugly nil | |
173 "Regexp matching posters whose face shouldn't be shown automatically." | |
174 :type 'regexp | |
175 :group 'gnus-article-washing) | |
176 | |
177 (defcustom gnus-emphasis-alist | |
178 (let ((format | |
179 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)") | |
180 (types | |
181 '(("_" "_" underline) | |
182 ("/" "/" italic) | |
183 ("\\*" "\\*" bold) | |
184 ("_/" "/_" underline-italic) | |
185 ("_\\*" "\\*_" underline-bold) | |
186 ("\\*/" "/\\*" bold-italic) | |
187 ("_\\*/" "/\\*_" underline-bold-italic)))) | |
188 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)" | |
189 2 3 gnus-emphasis-underline) | |
190 ,@(mapcar | |
191 (lambda (spec) | |
192 (list | |
193 (format format (car spec) (cadr spec)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
194 2 3 (intern (format "gnus-emphasis-%s" (caddr spec))))) |
17493 | 195 types))) |
196 "Alist that says how to fontify certain phrases. | |
197 Each item looks like this: | |
198 | |
199 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline) | |
200 | |
201 The first element is a regular expression to be matched. The second | |
202 is a number that says what regular expression grouping used to find | |
203 the entire emphasized word. The third is a number that says what | |
204 regexp grouping should be displayed and highlighted. The fourth | |
205 is the face used for highlighting." | |
206 :type '(repeat (list :value ("" 0 0 default) | |
207 regexp | |
208 (integer :tag "Match group") | |
209 (integer :tag "Emphasize group") | |
210 face)) | |
211 :group 'gnus-article-emphasis) | |
212 | |
213 (defface gnus-emphasis-bold '((t (:bold t))) | |
214 "Face used for displaying strong emphasized text (*word*)." | |
215 :group 'gnus-article-emphasis) | |
216 | |
217 (defface gnus-emphasis-italic '((t (:italic t))) | |
218 "Face used for displaying italic emphasized text (/word/)." | |
219 :group 'gnus-article-emphasis) | |
220 | |
221 (defface gnus-emphasis-underline '((t (:underline t))) | |
222 "Face used for displaying underlined emphasized text (_word_)." | |
223 :group 'gnus-article-emphasis) | |
224 | |
225 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t))) | |
226 "Face used for displaying underlined bold emphasized text (_*word*_)." | |
227 :group 'gnus-article-emphasis) | |
228 | |
229 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t))) | |
230 "Face used for displaying underlined italic emphasized text (_*word*_)." | |
231 :group 'gnus-article-emphasis) | |
232 | |
233 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t))) | |
234 "Face used for displaying bold italic emphasized text (/*word*/)." | |
235 :group 'gnus-article-emphasis) | |
236 | |
237 (defface gnus-emphasis-underline-bold-italic | |
238 '((t (:bold t :italic t :underline t))) | |
239 "Face used for displaying underlined bold italic emphasized text. | |
240 Esample: (_/*word*/_)." | |
241 :group 'gnus-article-emphasis) | |
242 | |
243 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z" | |
244 "Format for display of Date headers in article bodies. | |
245 See `format-time-zone' for the possible values." | |
246 :type 'string | |
247 :link '(custom-manual "(gnus)Article Date") | |
248 :group 'gnus-article-washing) | |
249 | |
250 (eval-and-compile | |
251 (autoload 'hexl-hex-string-to-integer "hexl") | |
252 (autoload 'timezone-make-date-arpa-standard "timezone") | |
253 (autoload 'mail-extract-address-components "mail-extr")) | |
254 | |
255 (defcustom gnus-save-all-headers t | |
256 "*If non-nil, don't remove any headers before saving." | |
257 :group 'gnus-article-saving | |
258 :type 'boolean) | |
259 | |
260 (defcustom gnus-prompt-before-saving 'always | |
261 "*This variable says how much prompting is to be done when saving articles. | |
262 If it is nil, no prompting will be done, and the articles will be | |
263 saved to the default files. If this variable is `always', each and | |
264 every article that is saved will be preceded by a prompt, even when | |
265 saving large batches of articles. If this variable is neither nil not | |
266 `always', there the user will be prompted once for a file name for | |
267 each invocation of the saving commands." | |
268 :group 'gnus-article-saving | |
269 :type '(choice (item always) | |
270 (item :tag "never" nil) | |
271 (sexp :tag "once" :format "%t"))) | |
272 | |
273 (defcustom gnus-saved-headers gnus-visible-headers | |
274 "Headers to keep if `gnus-save-all-headers' is nil. | |
275 If `gnus-save-all-headers' is non-nil, this variable will be ignored. | |
276 If that variable is nil, however, all headers that match this regexp | |
277 will be kept while the rest will be deleted before saving." | |
278 :group 'gnus-article-saving | |
279 :type '(repeat string)) | |
280 | |
281 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail | |
282 "A function to save articles in your favourite format. | |
283 The function must be interactively callable (in other words, it must | |
284 be an Emacs command). | |
285 | |
286 Gnus provides the following functions: | |
287 | |
288 * gnus-summary-save-in-rmail (Rmail format) | |
289 * gnus-summary-save-in-mail (Unix mail format) | |
290 * gnus-summary-save-in-folder (MH folder) | |
291 * gnus-summary-save-in-file (article format) | |
292 * gnus-summary-save-in-vm (use VM's folder format) | |
293 * gnus-summary-write-to-file (article format -- overwrite)." | |
294 :group 'gnus-article-saving | |
295 :type '(radio (function-item gnus-summary-save-in-rmail) | |
296 (function-item gnus-summary-save-in-mail) | |
297 (function-item gnus-summary-save-in-folder) | |
298 (function-item gnus-summary-save-in-file) | |
299 (function-item gnus-summary-save-in-vm) | |
300 (function-item gnus-summary-write-to-file))) | |
301 | |
302 (defcustom gnus-rmail-save-name 'gnus-plain-save-name | |
303 "A function generating a file name to save articles in Rmail format. | |
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
305 :group 'gnus-article-saving | |
306 :type 'function) | |
307 | |
308 (defcustom gnus-mail-save-name 'gnus-plain-save-name | |
309 "A function generating a file name to save articles in Unix mail format. | |
310 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
311 :group 'gnus-article-saving | |
312 :type 'function) | |
313 | |
314 (defcustom gnus-folder-save-name 'gnus-folder-save-name | |
315 "A function generating a file name to save articles in MH folder. | |
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER." | |
317 :group 'gnus-article-saving | |
318 :type 'function) | |
319 | |
320 (defcustom gnus-file-save-name 'gnus-numeric-save-name | |
321 "A function generating a file name to save articles in article format. | |
322 The function is called with NEWSGROUP, HEADERS, and optional | |
323 LAST-FILE." | |
324 :group 'gnus-article-saving | |
325 :type 'function) | |
326 | |
327 (defcustom gnus-split-methods | |
328 '((gnus-article-archive-name) | |
329 (gnus-article-nndoc-name)) | |
330 "Variable used to suggest where articles are to be saved. | |
331 For instance, if you would like to save articles related to Gnus in | |
332 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
333 you could set this variable to something like: | |
334 | |
335 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
336 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
337 | |
338 This variable is an alist where the where the key is the match and the | |
339 value is a list of possible files to save in if the match is non-nil. | |
340 | |
341 If the match is a string, it is used as a regexp match on the | |
342 article. If the match is a symbol, that symbol will be funcalled | |
343 from the buffer of the article to be saved with the newsgroup as the | |
344 parameter. If it is a list, it will be evaled in the same buffer. | |
345 | |
346 If this form or function returns a string, this string will be used as | |
347 a possible file name; and if it returns a non-nil list, that list will | |
348 be used as possible file names." | |
349 :group 'gnus-article-saving | |
350 :type '(repeat (choice (list function) | |
351 (cons regexp (repeat string)) | |
352 sexp))) | |
353 | |
354 (defcustom gnus-strict-mime t | |
355 "*If nil, MIME-decode even if there is no Mime-Version header." | |
356 :group 'gnus-article-mime | |
357 :type 'boolean) | |
358 | |
359 (defcustom gnus-show-mime-method 'metamail-buffer | |
360 "Function to process a MIME message. | |
361 The function is called from the article buffer." | |
362 :group 'gnus-article-mime | |
363 :type 'function) | |
364 | |
365 (defcustom gnus-decode-encoded-word-method 'gnus-article-de-quoted-unreadable | |
366 "*Function to decode MIME encoded words. | |
367 The function is called from the article buffer." | |
368 :group 'gnus-article-mime | |
369 :type 'function) | |
370 | |
19993
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
371 (defcustom gnus-show-traditional-method |
20119
c62cc873509f
(gnus-show-traditional-method): Call
Kenichi Handa <handa@m17n.org>
parents:
19993
diff
changeset
|
372 (if (and (featurep 'mule) |
c62cc873509f
(gnus-show-traditional-method): Call
Kenichi Handa <handa@m17n.org>
parents:
19993
diff
changeset
|
373 (boundp 'enable-multibyte-characters)) |
c62cc873509f
(gnus-show-traditional-method): Call
Kenichi Handa <handa@m17n.org>
parents:
19993
diff
changeset
|
374 (lambda () |
c62cc873509f
(gnus-show-traditional-method): Call
Kenichi Handa <handa@m17n.org>
parents:
19993
diff
changeset
|
375 (if enable-multibyte-characters (gnus-mule-decode-article))) |
19993
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
376 (lambda ())) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
377 "Function to decode ``localized RFC 822 messages''. |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
378 The function is called from the article buffer." |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
379 :group 'gnus-article-mime |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
380 :type 'function) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
381 |
17493 | 382 (defcustom gnus-page-delimiter "^\^L" |
383 "*Regexp describing what to use as article page delimiters. | |
384 The default value is \"^\^L\", which is a form linefeed at the | |
385 beginning of a line." | |
386 :type 'regexp | |
387 :group 'gnus-article-various) | |
388 | |
389 (defcustom gnus-article-mode-line-format "Gnus: %%b %S" | |
390 "*The format specification for the article mode line. | |
391 See `gnus-summary-mode-line-format' for a closer description." | |
392 :type 'string | |
393 :group 'gnus-article-various) | |
394 | |
395 (defcustom gnus-article-mode-hook nil | |
396 "*A hook for Gnus article mode." | |
397 :type 'hook | |
398 :group 'gnus-article-various) | |
399 | |
400 (defcustom gnus-article-menu-hook nil | |
401 "*Hook run after the creation of the article mode menu." | |
402 :type 'hook | |
403 :group 'gnus-article-various) | |
404 | |
405 (defcustom gnus-article-prepare-hook nil | |
406 "*A hook called after an article has been prepared in the article buffer. | |
407 If you want to run a special decoding program like nkf, use this hook." | |
408 :type 'hook | |
409 :group 'gnus-article-various) | |
410 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
411 (defcustom gnus-article-hide-pgp-hook nil |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
412 "*A hook called after successfully hiding a PGP signature." |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
413 :type 'hook |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
414 :group 'gnus-article-various) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
415 |
17493 | 416 (defcustom gnus-article-button-face 'bold |
417 "Face used for highlighting buttons in the article buffer. | |
418 | |
419 An article button is a piece of text that you can activate by pressing | |
420 `RET' or `mouse-2' above it." | |
421 :type 'face | |
422 :group 'gnus-article-buttons) | |
423 | |
424 (defcustom gnus-article-mouse-face 'highlight | |
425 "Face used for mouse highlighting in the article buffer. | |
426 | |
427 Article buttons will be displayed in this face when the cursor is | |
428 above them." | |
429 :type 'face | |
430 :group 'gnus-article-buttons) | |
431 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
432 (defcustom gnus-signature-face 'gnus-signature-face |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
433 "Face used for highlighting a signature in the article buffer. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
434 Obsolete; use the face `gnus-signature-face' for customizations instead." |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
435 :type 'face |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
436 :group 'gnus-article-highlight |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
437 :group 'gnus-article-signature) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
438 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
439 (defface gnus-signature-face |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
440 '((((type x)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
441 (:italic t))) |
17493 | 442 "Face used for highlighting a signature in the article buffer." |
443 :group 'gnus-article-highlight | |
444 :group 'gnus-article-signature) | |
445 | |
446 (defface gnus-header-from-face | |
447 '((((class color) | |
448 (background dark)) | |
449 (:foreground "spring green" :bold t)) | |
450 (((class color) | |
451 (background light)) | |
452 (:foreground "red3" :bold t)) | |
453 (t | |
454 (:bold t :italic t))) | |
455 "Face used for displaying from headers." | |
456 :group 'gnus-article-headers | |
457 :group 'gnus-article-highlight) | |
458 | |
459 (defface gnus-header-subject-face | |
460 '((((class color) | |
461 (background dark)) | |
462 (:foreground "SeaGreen3" :bold t)) | |
463 (((class color) | |
464 (background light)) | |
465 (:foreground "red4" :bold t)) | |
466 (t | |
467 (:bold t :italic t))) | |
468 "Face used for displaying subject headers." | |
469 :group 'gnus-article-headers | |
470 :group 'gnus-article-highlight) | |
471 | |
472 (defface gnus-header-newsgroups-face | |
473 '((((class color) | |
474 (background dark)) | |
475 (:foreground "yellow" :bold t :italic t)) | |
476 (((class color) | |
477 (background light)) | |
478 (:foreground "MidnightBlue" :bold t :italic t)) | |
479 (t | |
480 (:bold t :italic t))) | |
481 "Face used for displaying newsgroups headers." | |
482 :group 'gnus-article-headers | |
483 :group 'gnus-article-highlight) | |
484 | |
485 (defface gnus-header-name-face | |
486 '((((class color) | |
487 (background dark)) | |
488 (:foreground "SeaGreen")) | |
489 (((class color) | |
490 (background light)) | |
491 (:foreground "maroon")) | |
492 (t | |
493 (:bold t))) | |
494 "Face used for displaying header names." | |
495 :group 'gnus-article-headers | |
496 :group 'gnus-article-highlight) | |
497 | |
498 (defface gnus-header-content-face | |
499 '((((class color) | |
500 (background dark)) | |
501 (:foreground "forest green" :italic t)) | |
502 (((class color) | |
503 (background light)) | |
504 (:foreground "indianred4" :italic t)) | |
505 (t | |
506 (:italic t))) "Face used for displaying header content." | |
507 :group 'gnus-article-headers | |
508 :group 'gnus-article-highlight) | |
509 | |
510 (defcustom gnus-header-face-alist | |
511 '(("From" nil gnus-header-from-face) | |
512 ("Subject" nil gnus-header-subject-face) | |
513 ("Newsgroups:.*," nil gnus-header-newsgroups-face) | |
514 ("" gnus-header-name-face gnus-header-content-face)) | |
515 "Controls highlighting of article header. | |
516 | |
517 An alist of the form (HEADER NAME CONTENT). | |
518 | |
519 HEADER is a regular expression which should match the name of an | |
520 header header and NAME and CONTENT are either face names or nil. | |
521 | |
522 The name of each header field will be displayed using the face | |
523 specified by the first element in the list where HEADER match the | |
524 header name and NAME is non-nil. Similarly, the content will be | |
525 displayed by the first non-nil matching CONTENT face." | |
526 :group 'gnus-article-headers | |
527 :group 'gnus-article-highlight | |
528 :type '(repeat (list (regexp :tag "Header") | |
529 (choice :tag "Name" | |
530 (item :tag "skip" nil) | |
531 (face :value default)) | |
532 (choice :tag "Content" | |
533 (item :tag "skip" nil) | |
534 (face :value default))))) | |
535 | |
536 ;;; Internal variables | |
537 | |
538 (defvar gnus-article-mode-syntax-table | |
539 (let ((table (copy-syntax-table text-mode-syntax-table))) | |
540 (modify-syntax-entry ?- "w" table) | |
541 (modify-syntax-entry ?> ")" table) | |
542 (modify-syntax-entry ?< "(" table) | |
543 table) | |
544 "Syntax table used in article mode buffers. | |
545 Initialized from `text-mode-syntax-table.") | |
546 | |
547 (defvar gnus-save-article-buffer nil) | |
548 | |
549 (defvar gnus-article-mode-line-format-alist | |
550 (nconc '((?w (gnus-article-wash-status) ?s)) | |
551 gnus-summary-mode-line-format-alist)) | |
552 | |
553 (defvar gnus-number-of-articles-to-be-saved nil) | |
554 | |
555 (defvar gnus-inhibit-hiding nil) | |
556 | |
557 (defsubst gnus-article-hide-text (b e props) | |
558 "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
559 (add-text-properties b e props) | |
560 (when (memq 'intangible props) | |
561 (put-text-property | |
562 (max (1- b) (point-min)) | |
563 b 'intangible (cddr (memq 'intangible props))))) | |
564 | |
565 (defsubst gnus-article-unhide-text (b e) | |
566 "Remove hidden text properties from region between B and E." | |
567 (remove-text-properties b e gnus-hidden-properties) | |
568 (when (memq 'intangible gnus-hidden-properties) | |
569 (put-text-property (max (1- b) (point-min)) | |
570 b 'intangible nil))) | |
571 | |
572 (defun gnus-article-hide-text-type (b e type) | |
573 "Hide text of TYPE between B and E." | |
574 (gnus-article-hide-text | |
575 b e (cons 'article-type (cons type gnus-hidden-properties)))) | |
576 | |
577 (defun gnus-article-unhide-text-type (b e type) | |
578 "Hide text of TYPE between B and E." | |
579 (remove-text-properties | |
580 b e (cons 'article-type (cons type gnus-hidden-properties))) | |
581 (when (memq 'intangible gnus-hidden-properties) | |
582 (put-text-property (max (1- b) (point-min)) | |
583 b 'intangible nil))) | |
584 | |
585 (defun gnus-article-hide-text-of-type (type) | |
586 "Hide text of TYPE in the current buffer." | |
587 (save-excursion | |
588 (let ((b (point-min)) | |
589 (e (point-max))) | |
590 (while (setq b (text-property-any b e 'article-type type)) | |
591 (add-text-properties b (incf b) gnus-hidden-properties))))) | |
592 | |
593 (defun gnus-article-delete-text-of-type (type) | |
594 "Delete text of TYPE in the current buffer." | |
595 (save-excursion | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
596 (let ((b (point-min))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
597 (while (setq b (text-property-any b (point-max) 'article-type type)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
598 (delete-region |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
599 b (or (text-property-not-all b (point-max) 'article-type type) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
600 (point-max))))))) |
17493 | 601 |
602 (defun gnus-article-delete-invisible-text () | |
603 "Delete all invisible text in the current buffer." | |
604 (save-excursion | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
605 (let ((b (point-min))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
606 (while (setq b (text-property-any b (point-max) 'invisible t)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
607 (delete-region |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
608 b (or (text-property-not-all b (point-max) 'invisible t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
609 (point-max))))))) |
17493 | 610 |
611 (defun gnus-article-text-type-exists-p (type) | |
612 "Say whether any text of type TYPE exists in the buffer." | |
613 (text-property-any (point-min) (point-max) 'article-type type)) | |
614 | |
615 (defsubst gnus-article-header-rank () | |
616 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
617 (let ((list gnus-sorted-header-list) | |
618 (i 0)) | |
619 (while list | |
620 (when (looking-at (car list)) | |
621 (setq list nil)) | |
622 (setq list (cdr list)) | |
623 (incf i)) | |
624 i)) | |
625 | |
626 (defun article-hide-headers (&optional arg delete) | |
627 "Toggle whether to hide unwanted headers and possibly sort them as well. | |
628 If given a negative prefix, always show; if given a positive prefix, | |
629 always hide." | |
630 (interactive (gnus-article-hidden-arg)) | |
631 (if (gnus-article-check-hidden-text 'headers arg) | |
632 ;; Show boring headers as well. | |
633 (gnus-article-show-hidden-text 'boring-headers) | |
634 ;; This function might be inhibited. | |
635 (unless gnus-inhibit-hiding | |
636 (save-excursion | |
637 (save-restriction | |
638 (let ((buffer-read-only nil) | |
639 (props (nconc (list 'article-type 'headers) | |
640 gnus-hidden-properties)) | |
641 (max (1+ (length gnus-sorted-header-list))) | |
642 (ignored (when (not gnus-visible-headers) | |
643 (cond ((stringp gnus-ignored-headers) | |
644 gnus-ignored-headers) | |
645 ((listp gnus-ignored-headers) | |
646 (mapconcat 'identity gnus-ignored-headers | |
647 "\\|"))))) | |
648 (visible | |
649 (cond ((stringp gnus-visible-headers) | |
650 gnus-visible-headers) | |
651 ((and gnus-visible-headers | |
652 (listp gnus-visible-headers)) | |
653 (mapconcat 'identity gnus-visible-headers "\\|")))) | |
654 (inhibit-point-motion-hooks t) | |
655 want-list beg) | |
656 ;; First we narrow to just the headers. | |
657 (widen) | |
658 (goto-char (point-min)) | |
659 ;; Hide any "From " lines at the beginning of (mail) articles. | |
660 (while (looking-at "From ") | |
661 (forward-line 1)) | |
662 (unless (bobp) | |
663 (if delete | |
664 (delete-region (point-min) (point)) | |
665 (gnus-article-hide-text (point-min) (point) props))) | |
666 ;; Then treat the rest of the header lines. | |
667 (narrow-to-region | |
668 (point) | |
669 (if (search-forward "\n\n" nil t) ; if there's a body | |
670 (progn (forward-line -1) (point)) | |
671 (point-max))) | |
672 ;; Then we use the two regular expressions | |
673 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
674 ;; select which header lines is to remain visible in the | |
675 ;; article buffer. | |
676 (goto-char (point-min)) | |
677 (while (re-search-forward "^[^ \t]*:" nil t) | |
678 (beginning-of-line) | |
679 ;; Mark the rank of the header. | |
680 (put-text-property | |
681 (point) (1+ (point)) 'message-rank | |
682 (if (or (and visible (looking-at visible)) | |
683 (and ignored | |
684 (not (looking-at ignored)))) | |
685 (gnus-article-header-rank) | |
686 (+ 2 max))) | |
687 (forward-line 1)) | |
688 (message-sort-headers-1) | |
689 (when (setq beg (text-property-any | |
690 (point-min) (point-max) 'message-rank (+ 2 max))) | |
691 ;; We make the unwanted headers invisible. | |
692 (if delete | |
693 (delete-region beg (point-max)) | |
694 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
695 (gnus-article-hide-text-type beg (point-max) 'headers)) | |
696 ;; Work around XEmacs lossage. | |
697 (put-text-property (point-min) beg 'invisible nil)))))))) | |
698 | |
699 (defun article-hide-boring-headers (&optional arg) | |
700 "Toggle hiding of headers that aren't very interesting. | |
701 If given a negative prefix, always show; if given a positive prefix, | |
702 always hide." | |
703 (interactive (gnus-article-hidden-arg)) | |
704 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) | |
705 (not gnus-show-all-headers)) | |
706 (save-excursion | |
707 (save-restriction | |
708 (let ((buffer-read-only nil) | |
709 (list gnus-boring-article-headers) | |
710 (inhibit-point-motion-hooks t) | |
711 elem) | |
712 (nnheader-narrow-to-headers) | |
713 (while list | |
714 (setq elem (pop list)) | |
715 (goto-char (point-min)) | |
716 (cond | |
717 ;; Hide empty headers. | |
718 ((eq elem 'empty) | |
719 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t) | |
720 (forward-line -1) | |
721 (gnus-article-hide-text-type | |
722 (progn (beginning-of-line) (point)) | |
723 (progn | |
724 (end-of-line) | |
725 (if (re-search-forward "^[^ \t]" nil t) | |
726 (match-beginning 0) | |
727 (point-max))) | |
728 'boring-headers))) | |
729 ;; Hide boring Newsgroups header. | |
730 ((eq elem 'newsgroups) | |
731 (when (equal (gnus-fetch-field "newsgroups") | |
732 (gnus-group-real-name | |
733 (if (boundp 'gnus-newsgroup-name) | |
734 gnus-newsgroup-name | |
735 ""))) | |
736 (gnus-article-hide-header "newsgroups"))) | |
737 ((eq elem 'followup-to) | |
738 (when (equal (message-fetch-field "followup-to") | |
739 (message-fetch-field "newsgroups")) | |
740 (gnus-article-hide-header "followup-to"))) | |
741 ((eq elem 'reply-to) | |
742 (let ((from (message-fetch-field "from")) | |
743 (reply-to (message-fetch-field "reply-to"))) | |
744 (when (and | |
745 from reply-to | |
746 (ignore-errors | |
747 (equal | |
748 (nth 1 (mail-extract-address-components from)) | |
749 (nth 1 (mail-extract-address-components reply-to))))) | |
750 (gnus-article-hide-header "reply-to")))) | |
751 ((eq elem 'date) | |
752 (let ((date (message-fetch-field "date"))) | |
753 (when (and date | |
754 (< (gnus-days-between (current-time-string) date) | |
755 4)) | |
756 (gnus-article-hide-header "date"))))))))))) | |
757 | |
758 (defun gnus-article-hide-header (header) | |
759 (save-excursion | |
760 (goto-char (point-min)) | |
761 (when (re-search-forward (concat "^" header ":") nil t) | |
762 (gnus-article-hide-text-type | |
763 (progn (beginning-of-line) (point)) | |
764 (progn | |
765 (end-of-line) | |
766 (if (re-search-forward "^[^ \t]" nil t) | |
767 (match-beginning 0) | |
768 (point-max))) | |
769 'boring-headers)))) | |
770 | |
771 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
772 (defun article-treat-overstrike () | |
773 "Translate overstrikes into bold text." | |
774 (interactive) | |
775 (save-excursion | |
776 (goto-char (point-min)) | |
777 (when (search-forward "\n\n" nil t) | |
778 (let ((buffer-read-only nil)) | |
779 (while (search-forward "\b" nil t) | |
780 (let ((next (following-char)) | |
781 (previous (char-after (- (point) 2)))) | |
782 ;; We do the boldification/underlining by hiding the | |
783 ;; overstrikes and putting the proper text property | |
784 ;; on the letters. | |
785 (cond | |
786 ((eq next previous) | |
787 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
788 (put-text-property (point) (1+ (point)) 'face 'bold)) | |
789 ((eq next ?_) | |
790 (gnus-article-hide-text-type | |
791 (1- (point)) (1+ (point)) 'overstrike) | |
792 (put-text-property | |
793 (- (point) 2) (1- (point)) 'face 'underline)) | |
794 ((eq previous ?_) | |
795 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
796 (put-text-property | |
797 (point) (1+ (point)) 'face 'underline))))))))) | |
798 | |
799 (defun article-fill () | |
800 "Format too long lines." | |
801 (interactive) | |
802 (save-excursion | |
803 (let ((buffer-read-only nil)) | |
804 (widen) | |
805 (goto-char (point-min)) | |
806 (search-forward "\n\n" nil t) | |
807 (end-of-line 1) | |
808 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | |
809 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | |
810 (adaptive-fill-mode t)) | |
811 (while (not (eobp)) | |
812 (and (>= (current-column) (min fill-column (window-width))) | |
813 (/= (preceding-char) ?:) | |
814 (fill-paragraph nil)) | |
815 (end-of-line 2)))))) | |
816 | |
817 (defun article-remove-cr () | |
818 "Remove carriage returns from an article." | |
819 (interactive) | |
820 (save-excursion | |
821 (let ((buffer-read-only nil)) | |
822 (goto-char (point-min)) | |
823 (while (search-forward "\r" nil t) | |
824 (replace-match "" t t))))) | |
825 | |
826 (defun article-remove-trailing-blank-lines () | |
827 "Remove all trailing blank lines from the article." | |
828 (interactive) | |
829 (save-excursion | |
830 (let ((buffer-read-only nil)) | |
831 (goto-char (point-max)) | |
832 (delete-region | |
833 (point) | |
834 (progn | |
835 (while (and (not (bobp)) | |
836 (looking-at "^[ \t]*$")) | |
837 (forward-line -1)) | |
838 (forward-line 1) | |
839 (point)))))) | |
840 | |
841 (defun article-display-x-face (&optional force) | |
842 "Look for an X-Face header and display it if present." | |
843 (interactive (list 'force)) | |
844 (save-excursion | |
845 ;; Delete the old process, if any. | |
846 (when (process-status "article-x-face") | |
847 (delete-process "article-x-face")) | |
848 (let ((inhibit-point-motion-hooks t) | |
849 (case-fold-search nil) | |
850 from) | |
851 (save-restriction | |
852 (nnheader-narrow-to-headers) | |
853 (setq from (message-fetch-field "from")) | |
854 (goto-char (point-min)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
855 (while (and gnus-article-x-face-command |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
856 (or force |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
857 ;; Check whether this face is censored. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
858 (not gnus-article-x-face-too-ugly) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
859 (and gnus-article-x-face-too-ugly from |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
860 (not (string-match gnus-article-x-face-too-ugly |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
861 from)))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
862 ;; Has to be present. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
863 (re-search-forward "^X-Face: " nil t)) |
17493 | 864 ;; We now have the area of the buffer where the X-Face is stored. |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
865 (save-excursion |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
866 (let ((beg (point)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
867 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
868 ;; We display the face. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
869 (if (symbolp gnus-article-x-face-command) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
870 ;; The command is a lisp function, so we call it. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
871 (if (gnus-functionp gnus-article-x-face-command) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
872 (funcall gnus-article-x-face-command beg end) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
873 (error "%s is not a function" gnus-article-x-face-command)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
874 ;; The command is a string, so we interpret the command |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
875 ;; as a, well, command, and fork it off. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
876 (let ((process-connection-type nil)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
877 (process-kill-without-query |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
878 (start-process |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
879 "article-x-face" nil shell-file-name shell-command-switch |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
880 gnus-article-x-face-command)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
881 (process-send-region "article-x-face" beg end) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
882 (process-send-eof "article-x-face")))))))))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
883 |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
884 (defun gnus-hack-decode-rfc1522 () |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
885 "Emergency hack function for avoiding problems when decoding." |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
886 (let ((buffer-read-only nil)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
887 (goto-char (point-min)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
888 ;; Remove encoded TABs. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
889 (while (search-forward "=09" nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
890 (replace-match " " t t)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
891 ;; Remove encoded newlines. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
892 (goto-char (point-min)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
893 (while (search-forward "=10" nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
894 (replace-match " " t t)))) |
17493 | 895 |
896 (defalias 'gnus-decode-rfc1522 'article-decode-rfc1522) | |
897 (defalias 'gnus-article-decode-rfc1522 'article-decode-rfc1522) | |
898 (defun article-decode-rfc1522 () | |
899 "Hack to remove QP encoding from headers." | |
900 (let ((case-fold-search t) | |
901 (inhibit-point-motion-hooks t) | |
902 (buffer-read-only nil) | |
903 string) | |
904 (save-restriction | |
905 (narrow-to-region | |
906 (goto-char (point-min)) | |
907 (or (search-forward "\n\n" nil t) (point-max))) | |
908 (goto-char (point-min)) | |
909 (while (re-search-forward | |
910 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t) | |
911 (setq string (match-string 1)) | |
912 (save-restriction | |
913 (narrow-to-region (match-beginning 0) (match-end 0)) | |
914 (delete-region (point-min) (point-max)) | |
915 (insert string) | |
916 (article-mime-decode-quoted-printable | |
917 (goto-char (point-min)) (point-max)) | |
918 (subst-char-in-region (point-min) (point-max) ?_ ? ) | |
919 (goto-char (point-max))) | |
920 (goto-char (point-min)))))) | |
921 | |
922 (defun article-de-quoted-unreadable (&optional force) | |
923 "Do a naive translation of a quoted-printable-encoded article. | |
924 This is in no way, shape or form meant as a replacement for real MIME | |
925 processing, but is simply a stop-gap measure until MIME support is | |
926 written. | |
927 If FORCE, decode the article whether it is marked as quoted-printable | |
928 or not." | |
929 (interactive (list 'force)) | |
930 (save-excursion | |
931 (let ((case-fold-search t) | |
932 (buffer-read-only nil) | |
933 (type (gnus-fetch-field "content-transfer-encoding"))) | |
934 (gnus-article-decode-rfc1522) | |
935 (when (or force | |
936 (and type (string-match "quoted-printable" (downcase type)))) | |
937 (goto-char (point-min)) | |
938 (search-forward "\n\n" nil 'move) | |
939 (article-mime-decode-quoted-printable (point) (point-max)))))) | |
940 | |
941 (defun article-mime-decode-quoted-printable-buffer () | |
942 "Decode Quoted-Printable in the current buffer." | |
943 (article-mime-decode-quoted-printable (point-min) (point-max))) | |
944 | |
945 (defun article-mime-decode-quoted-printable (from to) | |
946 "Decode Quoted-Printable in the region between FROM and TO." | |
947 (interactive "r") | |
948 (goto-char from) | |
949 (while (search-forward "=" to t) | |
950 (cond ((eq (following-char) ?\n) | |
951 (delete-char -1) | |
952 (delete-char 1)) | |
953 ((looking-at "[0-9A-F][0-9A-F]") | |
954 (subst-char-in-region | |
955 (1- (point)) (point) ?= | |
956 (hexl-hex-string-to-integer | |
957 (buffer-substring (point) (+ 2 (point))))) | |
958 (delete-char 2)) | |
959 ((looking-at "=") | |
960 (delete-char 1)) | |
961 ((gnus-message 3 "Malformed MIME quoted-printable message"))))) | |
962 | |
963 (defun article-hide-pgp (&optional arg) | |
964 "Toggle hiding of any PGP headers and signatures in the current article. | |
965 If given a negative prefix, always show; if given a positive prefix, | |
966 always hide." | |
967 (interactive (gnus-article-hidden-arg)) | |
968 (unless (gnus-article-check-hidden-text 'pgp arg) | |
969 (save-excursion | |
970 (let ((inhibit-point-motion-hooks t) | |
971 buffer-read-only beg end) | |
972 (widen) | |
973 (goto-char (point-min)) | |
974 ;; Hide the "header". | |
975 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) | |
976 (gnus-article-hide-text-type (1+ (match-beginning 0)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
977 (match-end 0) 'pgp) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
978 (setq beg (point)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
979 ;; Hide the actual signature. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
980 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
981 (setq end (1+ (match-beginning 0))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
982 (gnus-article-hide-text-type |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
983 end |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
984 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
985 (match-end 0) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
986 ;; Perhaps we shouldn't hide to the end of the buffer |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
987 ;; if there is no end to the signature? |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
988 (point-max)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
989 'pgp)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
990 ;; Hide "- " PGP quotation markers. |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
991 (when (and beg end) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
992 (narrow-to-region beg end) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
993 (goto-char (point-min)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
994 (while (re-search-forward "^- " nil t) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
995 (gnus-article-hide-text-type |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
996 (match-beginning 0) (match-end 0) 'pgp)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
997 (widen)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
998 (run-hooks 'gnus-article-hide-pgp-hook)))))) |
17493 | 999 |
1000 (defun article-hide-pem (&optional arg) | |
1001 "Toggle hiding of any PEM headers and signatures in the current article. | |
1002 If given a negative prefix, always show; if given a positive prefix, | |
1003 always hide." | |
1004 (interactive (gnus-article-hidden-arg)) | |
1005 (unless (gnus-article-check-hidden-text 'pem arg) | |
1006 (save-excursion | |
1007 (let (buffer-read-only end) | |
1008 (widen) | |
1009 (goto-char (point-min)) | |
1010 ;; hide the horrendously ugly "header". | |
1011 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | |
1012 nil | |
1013 t) | |
1014 (setq end (1+ (match-beginning 0))) | |
1015 (gnus-article-hide-text-type | |
1016 end | |
1017 (if (search-forward "\n\n" nil t) | |
1018 (match-end 0) | |
1019 (point-max)) | |
1020 'pem)) | |
1021 ;; hide the trailer as well | |
1022 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | |
1023 nil | |
1024 t) | |
1025 (gnus-article-hide-text-type | |
1026 (match-beginning 0) (match-end 0) 'pem)))))) | |
1027 | |
1028 (defun article-hide-signature (&optional arg) | |
1029 "Hide the signature in the current article. | |
1030 If given a negative prefix, always show; if given a positive prefix, | |
1031 always hide." | |
1032 (interactive (gnus-article-hidden-arg)) | |
1033 (unless (gnus-article-check-hidden-text 'signature arg) | |
1034 (save-excursion | |
1035 (save-restriction | |
1036 (let ((buffer-read-only nil)) | |
1037 (when (gnus-article-narrow-to-signature) | |
1038 (gnus-article-hide-text-type | |
1039 (point-min) (point-max) 'signature))))))) | |
1040 | |
1041 (defun article-strip-leading-blank-lines () | |
1042 "Remove all blank lines from the beginning of the article." | |
1043 (interactive) | |
1044 (save-excursion | |
1045 (let ((inhibit-point-motion-hooks t) | |
1046 buffer-read-only) | |
1047 (goto-char (point-min)) | |
1048 (when (search-forward "\n\n" nil t) | |
1049 (while (and (not (eobp)) | |
1050 (looking-at "[ \t]*$")) | |
1051 (gnus-delete-line)))))) | |
1052 | |
1053 (defun article-strip-multiple-blank-lines () | |
1054 "Replace consecutive blank lines with one empty line." | |
1055 (interactive) | |
1056 (save-excursion | |
1057 (let ((inhibit-point-motion-hooks t) | |
1058 buffer-read-only) | |
1059 ;; First make all blank lines empty. | |
1060 (goto-char (point-min)) | |
1061 (search-forward "\n\n" nil t) | |
1062 (while (re-search-forward "^[ \t]+$" nil t) | |
1063 (replace-match "" nil t)) | |
1064 ;; Then replace multiple empty lines with a single empty line. | |
1065 (goto-char (point-min)) | |
1066 (search-forward "\n\n" nil t) | |
1067 (while (re-search-forward "\n\n\n+" nil t) | |
1068 (replace-match "\n\n" t t))))) | |
1069 | |
1070 (defun article-strip-leading-space () | |
1071 "Remove all white space from the beginning of the lines in the article." | |
1072 (interactive) | |
1073 (save-excursion | |
1074 (let ((inhibit-point-motion-hooks t) | |
1075 buffer-read-only) | |
1076 (goto-char (point-min)) | |
1077 (search-forward "\n\n" nil t) | |
1078 (while (re-search-forward "^[ \t]+" nil t) | |
1079 (replace-match "" t t))))) | |
1080 | |
1081 (defun article-strip-blank-lines () | |
1082 "Strip leading, trailing and multiple blank lines." | |
1083 (interactive) | |
1084 (article-strip-leading-blank-lines) | |
1085 (article-remove-trailing-blank-lines) | |
1086 (article-strip-multiple-blank-lines)) | |
1087 | |
1088 (defvar mime::preview/content-list) | |
1089 (defvar mime::preview-content-info/point-min) | |
1090 (defun gnus-article-narrow-to-signature () | |
1091 "Narrow to the signature; return t if a signature is found, else nil." | |
1092 (widen) | |
1093 (when (and (boundp 'mime::preview/content-list) | |
1094 mime::preview/content-list) | |
1095 ;; We have a MIMEish article, so we use the MIME data to narrow. | |
1096 (let ((pcinfo (car (last mime::preview/content-list)))) | |
1097 (ignore-errors | |
1098 (narrow-to-region | |
1099 (funcall (intern "mime::preview-content-info/point-min") pcinfo) | |
1100 (point-max))))) | |
1101 | |
1102 (when (gnus-article-search-signature) | |
1103 (forward-line 1) | |
1104 ;; Check whether we have some limits to what we consider | |
1105 ;; to be a signature. | |
1106 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit | |
1107 (list gnus-signature-limit))) | |
1108 limit limited) | |
1109 (while (setq limit (pop limits)) | |
1110 (if (or (and (integerp limit) | |
1111 (< (- (point-max) (point)) limit)) | |
1112 (and (floatp limit) | |
1113 (< (count-lines (point) (point-max)) limit)) | |
1114 (and (gnus-functionp limit) | |
1115 (funcall limit)) | |
1116 (and (stringp limit) | |
1117 (not (re-search-forward limit nil t)))) | |
1118 () ; This limit did not succeed. | |
1119 (setq limited t | |
1120 limits nil))) | |
1121 (unless limited | |
1122 (narrow-to-region (point) (point-max)) | |
1123 t)))) | |
1124 | |
1125 (defun gnus-article-search-signature () | |
1126 "Search the current buffer for the signature separator. | |
1127 Put point at the beginning of the signature separator." | |
1128 (let ((cur (point))) | |
1129 (goto-char (point-max)) | |
1130 (if (if (stringp gnus-signature-separator) | |
1131 (re-search-backward gnus-signature-separator nil t) | |
1132 (let ((seps gnus-signature-separator)) | |
1133 (while (and seps | |
1134 (not (re-search-backward (car seps) nil t))) | |
1135 (pop seps)) | |
1136 seps)) | |
1137 t | |
1138 (goto-char cur) | |
1139 nil))) | |
1140 | |
1141 (eval-and-compile | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1142 (autoload 'w3-display "w3-parse") |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1143 (autoload 'w3-do-setup "w3" "" t)) |
17493 | 1144 |
1145 (defun gnus-article-treat-html () | |
1146 "Render HTML." | |
1147 (interactive) | |
1148 (let ((cbuf (current-buffer))) | |
1149 (set-buffer gnus-article-buffer) | |
1150 (let (buf buffer-read-only b e) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1151 (w3-do-setup) |
17493 | 1152 (goto-char (point-min)) |
1153 (narrow-to-region | |
1154 (if (search-forward "\n\n" nil t) | |
1155 (setq b (point)) | |
1156 (point-max)) | |
1157 (setq e (point-max))) | |
1158 (nnheader-temp-write nil | |
1159 (insert-buffer-substring gnus-article-buffer b e) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1160 (require 'url) |
17493 | 1161 (save-window-excursion |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1162 (w3-region (point-min) (point-max)) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1163 (setq buf (buffer-substring-no-properties (point-min) (point-max))))) |
17493 | 1164 (when buf |
1165 (delete-region (point-min) (point-max)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1166 (insert buf)) |
17493 | 1167 (widen) |
1168 (goto-char (point-min)) | |
1169 (set-window-start (get-buffer-window (current-buffer)) (point-min)) | |
1170 (set-buffer cbuf)))) | |
1171 | |
1172 (defun gnus-article-hidden-arg () | |
1173 "Return the current prefix arg as a number, or 0 if no prefix." | |
1174 (list (if current-prefix-arg | |
1175 (prefix-numeric-value current-prefix-arg) | |
1176 0))) | |
1177 | |
1178 (defun gnus-article-check-hidden-text (type arg) | |
1179 "Return nil if hiding is necessary. | |
1180 Arg can be nil or a number. Nil and positive means hide, negative | |
1181 means show, 0 means toggle." | |
1182 (save-excursion | |
1183 (save-restriction | |
1184 (widen) | |
1185 (let ((hide (gnus-article-hidden-text-p type))) | |
1186 (cond | |
1187 ((or (null arg) | |
1188 (> arg 0)) | |
1189 nil) | |
1190 ((< arg 0) | |
1191 (gnus-article-show-hidden-text type)) | |
1192 (t | |
1193 (if (eq hide 'hidden) | |
1194 (gnus-article-show-hidden-text type) | |
1195 nil))))))) | |
1196 | |
1197 (defun gnus-article-hidden-text-p (type) | |
1198 "Say whether the current buffer contains hidden text of type TYPE." | |
1199 (let ((start (point-min)) | |
1200 (pos (text-property-any (point-min) (point-max) 'article-type type))) | |
1201 (while (and pos | |
1202 (not (get-text-property pos 'invisible))) | |
1203 (setq pos | |
1204 (text-property-any (1+ pos) (point-max) 'article-type type))) | |
1205 (if pos | |
1206 'hidden | |
1207 'shown))) | |
1208 | |
1209 (defun gnus-article-show-hidden-text (type &optional hide) | |
1210 "Show all hidden text of type TYPE. | |
1211 If HIDE, hide the text instead." | |
1212 (save-excursion | |
1213 (let ((buffer-read-only nil) | |
1214 (inhibit-point-motion-hooks t) | |
1215 (end (point-min)) | |
1216 beg) | |
1217 (while (setq beg (text-property-any end (point-max) 'article-type type)) | |
1218 (goto-char beg) | |
1219 (setq end (or | |
1220 (text-property-not-all beg (point-max) 'article-type type) | |
1221 (point-max))) | |
1222 (if hide | |
1223 (gnus-article-hide-text beg end gnus-hidden-properties) | |
1224 (gnus-article-unhide-text beg end)) | |
1225 (goto-char end)) | |
1226 t))) | |
1227 | |
1228 (defconst article-time-units | |
1229 `((year . ,(* 365.25 24 60 60)) | |
1230 (week . ,(* 7 24 60 60)) | |
1231 (day . ,(* 24 60 60)) | |
1232 (hour . ,(* 60 60)) | |
1233 (minute . 60) | |
1234 (second . 1)) | |
1235 "Mapping from time units to seconds.") | |
1236 | |
1237 (defun article-date-ut (&optional type highlight header) | |
1238 "Convert DATE date to universal time in the current article. | |
1239 If TYPE is `local', convert to local time; if it is `lapsed', output | |
1240 how much time has lapsed since DATE." | |
1241 (interactive (list 'ut t)) | |
1242 (let* ((header (or header | |
1243 (mail-header-date gnus-current-headers) | |
1244 (message-fetch-field "date") | |
1245 "")) | |
1246 (date (if (vectorp header) (mail-header-date header) | |
1247 header)) | |
1248 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") | |
1249 (inhibit-point-motion-hooks t) | |
1250 bface eface) | |
1251 (when (and date (not (string= date ""))) | |
1252 (save-excursion | |
1253 (save-restriction | |
1254 (nnheader-narrow-to-headers) | |
1255 (let ((buffer-read-only nil)) | |
1256 ;; Delete any old Date headers. | |
1257 (if (re-search-forward date-regexp nil t) | |
1258 (progn | |
1259 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
1260 eface (get-text-property (1- (gnus-point-at-eol)) | |
1261 'face)) | |
1262 (message-remove-header date-regexp t) | |
1263 (beginning-of-line)) | |
1264 (goto-char (point-max))) | |
1265 (insert (article-make-date-line date type)) | |
1266 ;; Do highlighting. | |
1267 (forward-line -1) | |
1268 (when (looking-at "\\([^:]+\\): *\\(.*\\)$") | |
1269 (put-text-property (match-beginning 1) (match-end 1) | |
1270 'face bface) | |
1271 (put-text-property (match-beginning 2) (match-end 2) | |
1272 'face eface)))))))) | |
1273 | |
1274 (defun article-make-date-line (date type) | |
1275 "Return a DATE line of TYPE." | |
1276 (cond | |
1277 ;; Convert to the local timezone. We have to slap a | |
1278 ;; `condition-case' round the calls to the timezone | |
1279 ;; functions since they aren't particularly resistant to | |
1280 ;; buggy dates. | |
1281 ((eq type 'local) | |
1282 (concat "Date: " (condition-case () | |
1283 (timezone-make-date-arpa-standard date) | |
1284 (error date)) | |
1285 "\n")) | |
1286 ;; Convert to Universal Time. | |
1287 ((eq type 'ut) | |
1288 (concat "Date: " | |
1289 (condition-case () | |
1290 (timezone-make-date-arpa-standard date nil "UT") | |
1291 (error date)) | |
1292 "\n")) | |
1293 ;; Get the original date from the article. | |
1294 ((eq type 'original) | |
1295 (concat "Date: " date "\n")) | |
1296 ;; Let the user define the format. | |
1297 ((eq type 'user) | |
1298 (concat | |
1299 "Date: " | |
1300 (format-time-string gnus-article-time-format | |
1301 (ignore-errors | |
1302 (gnus-encode-date | |
1303 (timezone-make-date-arpa-standard | |
1304 date nil "UT")))) | |
1305 "\n")) | |
1306 ;; Do an X-Sent lapsed format. | |
1307 ((eq type 'lapsed) | |
1308 ;; If the date is seriously mangled, the timezone functions are | |
1309 ;; liable to bug out, so we ignore all errors. | |
1310 (let* ((now (current-time)) | |
1311 (real-time | |
1312 (ignore-errors | |
1313 (gnus-time-minus | |
1314 (gnus-encode-date | |
1315 (timezone-make-date-arpa-standard | |
1316 (current-time-string now) | |
1317 (current-time-zone now) "UT")) | |
1318 (gnus-encode-date | |
1319 (timezone-make-date-arpa-standard | |
1320 date nil "UT"))))) | |
1321 (real-sec (and real-time | |
1322 (+ (* (float (car real-time)) 65536) | |
1323 (cadr real-time)))) | |
1324 (sec (and real-time (abs real-sec))) | |
1325 num prev) | |
1326 (cond | |
1327 ((null real-time) | |
1328 "X-Sent: Unknown\n") | |
1329 ((zerop sec) | |
1330 "X-Sent: Now\n") | |
1331 (t | |
1332 (concat | |
1333 "X-Sent: " | |
1334 ;; This is a bit convoluted, but basically we go | |
1335 ;; through the time units for years, weeks, etc, | |
1336 ;; and divide things to see whether that results | |
1337 ;; in positive answers. | |
1338 (mapconcat | |
1339 (lambda (unit) | |
1340 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
1341 ;; The (remaining) seconds are too few to | |
1342 ;; be divided into this time unit. | |
1343 "" | |
1344 ;; It's big enough, so we output it. | |
1345 (setq sec (- sec (* num (cdr unit)))) | |
1346 (prog1 | |
1347 (concat (if prev ", " "") (int-to-string | |
1348 (floor num)) | |
1349 " " (symbol-name (car unit)) | |
1350 (if (> num 1) "s" "")) | |
1351 (setq prev t)))) | |
1352 article-time-units "") | |
1353 ;; If dates are odd, then it might appear like the | |
1354 ;; article was sent in the future. | |
1355 (if (> real-sec 0) | |
1356 " ago\n" | |
1357 " in the future\n")))))) | |
1358 (t | |
1359 (error "Unknown conversion type: %s" type)))) | |
1360 | |
1361 (defun article-date-local (&optional highlight) | |
1362 "Convert the current article date to the local timezone." | |
1363 (interactive (list t)) | |
1364 (article-date-ut 'local highlight)) | |
1365 | |
1366 (defun article-date-original (&optional highlight) | |
1367 "Convert the current article date to what it was originally. | |
1368 This is only useful if you have used some other date conversion | |
1369 function and want to see what the date was before converting." | |
1370 (interactive (list t)) | |
1371 (article-date-ut 'original highlight)) | |
1372 | |
1373 (defun article-date-lapsed (&optional highlight) | |
1374 "Convert the current article date to time lapsed since it was sent." | |
1375 (interactive (list t)) | |
1376 (article-date-ut 'lapsed highlight)) | |
1377 | |
1378 (defun article-date-user (&optional highlight) | |
1379 "Convert the current article date to the user-defined format. | |
1380 This format is defined by the `gnus-article-time-format' variable." | |
1381 (interactive (list t)) | |
1382 (article-date-ut 'user highlight)) | |
1383 | |
1384 (defun article-show-all () | |
1385 "Show all hidden text in the article buffer." | |
1386 (interactive) | |
1387 (save-excursion | |
1388 (let ((buffer-read-only nil)) | |
1389 (gnus-article-unhide-text (point-min) (point-max))))) | |
1390 | |
1391 (defun article-emphasize (&optional arg) | |
1392 "Emphasize text according to `gnus-emphasis-alist'." | |
1393 (interactive (gnus-article-hidden-arg)) | |
1394 (unless (gnus-article-check-hidden-text 'emphasis arg) | |
1395 (save-excursion | |
1396 (let ((alist gnus-emphasis-alist) | |
1397 (buffer-read-only nil) | |
1398 (props (append '(article-type emphasis) | |
1399 gnus-hidden-properties)) | |
1400 regexp elem beg invisible visible face) | |
1401 (goto-char (point-min)) | |
1402 (search-forward "\n\n" nil t) | |
1403 (setq beg (point)) | |
1404 (while (setq elem (pop alist)) | |
1405 (goto-char beg) | |
1406 (setq regexp (car elem) | |
1407 invisible (nth 1 elem) | |
1408 visible (nth 2 elem) | |
1409 face (nth 3 elem)) | |
1410 (while (re-search-forward regexp nil t) | |
1411 (when (and (match-beginning visible) (match-beginning invisible)) | |
1412 (gnus-article-hide-text | |
1413 (match-beginning invisible) (match-end invisible) props) | |
1414 (gnus-article-unhide-text-type | |
1415 (match-beginning visible) (match-end visible) 'emphasis) | |
1416 (gnus-put-text-property-excluding-newlines | |
1417 (match-beginning visible) (match-end visible) 'face face) | |
1418 (goto-char (match-end invisible))))))))) | |
1419 | |
1420 (defvar gnus-summary-article-menu) | |
1421 (defvar gnus-summary-post-menu) | |
1422 | |
1423 ;;; Saving functions. | |
1424 | |
1425 (defun gnus-article-save (save-buffer file &optional num) | |
1426 "Save the currently selected article." | |
1427 (unless gnus-save-all-headers | |
1428 ;; Remove headers according to `gnus-saved-headers'. | |
1429 (let ((gnus-visible-headers | |
1430 (or gnus-saved-headers gnus-visible-headers)) | |
1431 (gnus-article-buffer save-buffer)) | |
1432 (gnus-article-hide-headers 1 t))) | |
1433 (save-window-excursion | |
1434 (if (not gnus-default-article-saver) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1435 (error "No default saver is defined") |
17493 | 1436 ;; !!! Magic! The saving functions all save |
1437 ;; `gnus-original-article-buffer' (or so they think), but we | |
1438 ;; bind that variable to our save-buffer. | |
1439 (set-buffer gnus-article-buffer) | |
1440 (let* ((gnus-save-article-buffer save-buffer) | |
1441 (filename | |
1442 (cond | |
1443 ((not gnus-prompt-before-saving) 'default) | |
1444 ((eq gnus-prompt-before-saving 'always) nil) | |
1445 (t file))) | |
1446 (gnus-number-of-articles-to-be-saved | |
1447 (when (eq gnus-prompt-before-saving t) | |
1448 num))) ; Magic | |
1449 (set-buffer gnus-summary-buffer) | |
1450 (funcall gnus-default-article-saver filename))))) | |
1451 | |
1452 (defun gnus-read-save-file-name (prompt &optional filename | |
1453 function group headers variable) | |
1454 (let ((default-name | |
1455 (funcall function group headers (symbol-value variable))) | |
1456 result) | |
1457 (setq | |
1458 result | |
1459 (cond | |
1460 ((eq filename 'default) | |
1461 default-name) | |
1462 ((eq filename t) | |
1463 default-name) | |
1464 (filename filename) | |
1465 (t | |
1466 (let* ((split-name (gnus-get-split-value gnus-split-methods)) | |
1467 (prompt | |
1468 (format prompt | |
1469 (if (and gnus-number-of-articles-to-be-saved | |
1470 (> gnus-number-of-articles-to-be-saved 1)) | |
1471 (format "these %d articles" | |
1472 gnus-number-of-articles-to-be-saved) | |
1473 "this article"))) | |
1474 (file | |
1475 ;; Let the split methods have their say. | |
1476 (cond | |
1477 ;; No split name was found. | |
1478 ((null split-name) | |
1479 (read-file-name | |
1480 (concat prompt " (default " | |
1481 (file-name-nondirectory default-name) ") ") | |
1482 (file-name-directory default-name) | |
1483 default-name)) | |
1484 ;; A single group name is returned. | |
1485 ((stringp split-name) | |
1486 (setq default-name | |
1487 (funcall function split-name headers | |
1488 (symbol-value variable))) | |
1489 (read-file-name | |
1490 (concat prompt " (default " | |
1491 (file-name-nondirectory default-name) ") ") | |
1492 (file-name-directory default-name) | |
1493 default-name)) | |
1494 ;; A single split name was found | |
1495 ((= 1 (length split-name)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1496 (let* ((name (expand-file-name |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1497 (car split-name) gnus-article-save-directory)) |
17493 | 1498 (dir (cond ((file-directory-p name) |
1499 (file-name-as-directory name)) | |
1500 ((file-exists-p name) name) | |
1501 (t gnus-article-save-directory)))) | |
1502 (read-file-name | |
1503 (concat prompt " (default " name ") ") | |
1504 dir name))) | |
1505 ;; A list of splits was found. | |
1506 (t | |
1507 (setq split-name (nreverse split-name)) | |
1508 (let (result) | |
1509 (let ((file-name-history | |
1510 (nconc split-name file-name-history))) | |
1511 (setq result | |
1512 (expand-file-name | |
1513 (read-file-name | |
1514 (concat prompt " (`M-p' for defaults) ") | |
1515 gnus-article-save-directory | |
1516 (car split-name)) | |
1517 gnus-article-save-directory))) | |
1518 (car (push result file-name-history))))))) | |
1519 ;; Create the directory. | |
1520 (gnus-make-directory (file-name-directory file)) | |
1521 ;; If we have read a directory, we append the default file name. | |
1522 (when (file-directory-p file) | |
1523 (setq file (concat (file-name-as-directory file) | |
1524 (file-name-nondirectory default-name)))) | |
1525 ;; Possibly translate some characters. | |
1526 (nnheader-translate-file-chars file))))) | |
1527 (gnus-make-directory (file-name-directory result)) | |
1528 (set variable result))) | |
1529 | |
1530 (defun gnus-article-archive-name (group) | |
1531 "Return the first instance of an \"Archive-name\" in the current buffer." | |
1532 (let ((case-fold-search t)) | |
1533 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
1534 (nnheader-concat gnus-article-save-directory | |
1535 (match-string 1))))) | |
1536 | |
1537 (defun gnus-article-nndoc-name (group) | |
1538 "If GROUP is an nndoc group, return the name of the parent group." | |
1539 (when (eq (car (gnus-find-method-for-group group)) 'nndoc) | |
1540 (gnus-group-get-parameter group 'save-article-group))) | |
1541 | |
1542 (defun gnus-summary-save-in-rmail (&optional filename) | |
1543 "Append this article to Rmail file. | |
1544 Optional argument FILENAME specifies file name. | |
1545 Directory to save to is default to `gnus-article-save-directory'." | |
1546 (interactive) | |
1547 (gnus-set-global-variables) | |
1548 (setq filename (gnus-read-save-file-name | |
1549 "Save %s in rmail file:" filename | |
1550 gnus-rmail-save-name gnus-newsgroup-name | |
1551 gnus-current-headers 'gnus-newsgroup-last-rmail)) | |
1552 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1553 (save-excursion | |
1554 (save-restriction | |
1555 (widen) | |
1556 (gnus-output-to-rmail filename))))) | |
1557 | |
1558 (defun gnus-summary-save-in-mail (&optional filename) | |
1559 "Append this article to Unix mail file. | |
1560 Optional argument FILENAME specifies file name. | |
1561 Directory to save to is default to `gnus-article-save-directory'." | |
1562 (interactive) | |
1563 (gnus-set-global-variables) | |
1564 (setq filename (gnus-read-save-file-name | |
1565 "Save %s in Unix mail file:" filename | |
1566 gnus-mail-save-name gnus-newsgroup-name | |
1567 gnus-current-headers 'gnus-newsgroup-last-mail)) | |
1568 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1569 (save-excursion | |
1570 (save-restriction | |
1571 (widen) | |
1572 (if (and (file-readable-p filename) | |
1573 (mail-file-babyl-p filename)) | |
1574 (gnus-output-to-rmail filename t) | |
1575 (gnus-output-to-mail filename)))))) | |
1576 | |
1577 (defun gnus-summary-save-in-file (&optional filename overwrite) | |
1578 "Append this article to file. | |
1579 Optional argument FILENAME specifies file name. | |
1580 Directory to save to is default to `gnus-article-save-directory'." | |
1581 (interactive) | |
1582 (gnus-set-global-variables) | |
1583 (setq filename (gnus-read-save-file-name | |
1584 "Save %s in file:" filename | |
1585 gnus-file-save-name gnus-newsgroup-name | |
1586 gnus-current-headers 'gnus-newsgroup-last-file)) | |
1587 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1588 (save-excursion | |
1589 (save-restriction | |
1590 (widen) | |
1591 (when (and overwrite | |
1592 (file-exists-p filename)) | |
1593 (delete-file filename)) | |
1594 (gnus-output-to-file filename))))) | |
1595 | |
1596 (defun gnus-summary-write-to-file (&optional filename) | |
1597 "Write this article to a file. | |
1598 Optional argument FILENAME specifies file name. | |
1599 The directory to save in defaults to `gnus-article-save-directory'." | |
1600 (interactive) | |
1601 (gnus-summary-save-in-file nil t)) | |
1602 | |
1603 (defun gnus-summary-save-body-in-file (&optional filename) | |
1604 "Append this article body to a file. | |
1605 Optional argument FILENAME specifies file name. | |
1606 The directory to save in defaults to `gnus-article-save-directory'." | |
1607 (interactive) | |
1608 (gnus-set-global-variables) | |
1609 (setq filename (gnus-read-save-file-name | |
1610 "Save %s body in file:" filename | |
1611 gnus-file-save-name gnus-newsgroup-name | |
1612 gnus-current-headers 'gnus-newsgroup-last-file)) | |
1613 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1614 (save-excursion | |
1615 (save-restriction | |
1616 (widen) | |
1617 (goto-char (point-min)) | |
1618 (when (search-forward "\n\n" nil t) | |
1619 (narrow-to-region (point) (point-max))) | |
1620 (gnus-output-to-file filename))))) | |
1621 | |
1622 (defun gnus-summary-save-in-pipe (&optional command) | |
1623 "Pipe this article to subprocess." | |
1624 (interactive) | |
1625 (gnus-set-global-variables) | |
1626 (setq command | |
1627 (cond ((eq command 'default) | |
1628 gnus-last-shell-command) | |
1629 (command command) | |
1630 (t (read-string | |
1631 (format | |
1632 "Shell command on %s: " | |
1633 (if (and gnus-number-of-articles-to-be-saved | |
1634 (> gnus-number-of-articles-to-be-saved 1)) | |
1635 (format "these %d articles" | |
1636 gnus-number-of-articles-to-be-saved) | |
1637 "this article")) | |
1638 gnus-last-shell-command)))) | |
1639 (when (string-equal command "") | |
1640 (setq command gnus-last-shell-command)) | |
1641 (gnus-eval-in-buffer-window gnus-article-buffer | |
1642 (save-restriction | |
1643 (widen) | |
1644 (shell-command-on-region (point-min) (point-max) command nil))) | |
1645 (setq gnus-last-shell-command command)) | |
1646 | |
1647 ;;; Article file names when saving. | |
1648 | |
1649 (defun gnus-capitalize-newsgroup (newsgroup) | |
1650 "Capitalize NEWSGROUP name." | |
1651 (when (not (zerop (length newsgroup))) | |
1652 (concat (char-to-string (upcase (aref newsgroup 0))) | |
1653 (substring newsgroup 1)))) | |
1654 | |
1655 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
1656 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1657 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num. | |
1658 Otherwise, it is like ~/News/news/group/num." | |
1659 (let ((default | |
1660 (expand-file-name | |
1661 (concat (if (gnus-use-long-file-name 'not-save) | |
1662 (gnus-capitalize-newsgroup newsgroup) | |
1663 (gnus-newsgroup-directory-form newsgroup)) | |
1664 "/" (int-to-string (mail-header-number headers))) | |
1665 gnus-article-save-directory))) | |
1666 (if (and last-file | |
1667 (string-equal (file-name-directory default) | |
1668 (file-name-directory last-file)) | |
1669 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
1670 default | |
1671 (or last-file default)))) | |
1672 | |
1673 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
1674 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1675 If variable `gnus-use-long-file-name' is non-nil, it is | |
1676 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." | |
1677 (let ((default | |
1678 (expand-file-name | |
1679 (concat (if (gnus-use-long-file-name 'not-save) | |
1680 newsgroup | |
1681 (gnus-newsgroup-directory-form newsgroup)) | |
1682 "/" (int-to-string (mail-header-number headers))) | |
1683 gnus-article-save-directory))) | |
1684 (if (and last-file | |
1685 (string-equal (file-name-directory default) | |
1686 (file-name-directory last-file)) | |
1687 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
1688 default | |
1689 (or last-file default)))) | |
1690 | |
1691 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
1692 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1693 If variable `gnus-use-long-file-name' is non-nil, it is | |
1694 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
1695 (or last-file | |
1696 (expand-file-name | |
1697 (if (gnus-use-long-file-name 'not-save) | |
1698 (gnus-capitalize-newsgroup newsgroup) | |
1699 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
1700 gnus-article-save-directory))) | |
1701 | |
1702 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
1703 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1704 If variable `gnus-use-long-file-name' is non-nil, it is | |
1705 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
1706 (or last-file | |
1707 (expand-file-name | |
1708 (if (gnus-use-long-file-name 'not-save) | |
1709 newsgroup | |
1710 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
1711 gnus-article-save-directory))) | |
1712 | |
1713 (eval-and-compile | |
1714 (mapcar | |
1715 (lambda (func) | |
1716 (let (afunc gfunc) | |
1717 (if (consp func) | |
1718 (setq afunc (car func) | |
1719 gfunc (cdr func)) | |
1720 (setq afunc func | |
1721 gfunc (intern (format "gnus-%s" func)))) | |
1722 (fset gfunc | |
1723 (if (not (fboundp afunc)) | |
1724 nil | |
1725 `(lambda (&optional interactive &rest args) | |
1726 ,(documentation afunc t) | |
1727 (interactive (list t)) | |
1728 (save-excursion | |
1729 (set-buffer gnus-article-buffer) | |
1730 (if interactive | |
1731 (call-interactively ',afunc) | |
1732 (apply ',afunc args)))))))) | |
1733 '(article-hide-headers | |
1734 article-hide-boring-headers | |
1735 article-treat-overstrike | |
1736 (article-fill . gnus-article-word-wrap) | |
1737 article-remove-cr | |
1738 article-display-x-face | |
1739 article-de-quoted-unreadable | |
1740 article-mime-decode-quoted-printable | |
1741 article-hide-pgp | |
1742 article-hide-pem | |
1743 article-hide-signature | |
1744 article-remove-trailing-blank-lines | |
1745 article-strip-leading-blank-lines | |
1746 article-strip-multiple-blank-lines | |
1747 article-strip-leading-space | |
1748 article-strip-blank-lines | |
1749 article-date-local | |
1750 article-date-original | |
1751 article-date-ut | |
1752 article-date-user | |
1753 article-date-lapsed | |
1754 article-emphasize | |
1755 (article-show-all . gnus-article-show-all-headers)))) | |
1756 | |
1757 ;;; | |
1758 ;;; Gnus article mode | |
1759 ;;; | |
1760 | |
1761 (put 'gnus-article-mode 'mode-class 'special) | |
1762 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1763 (gnus-define-keys gnus-article-mode-map |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1764 " " gnus-article-goto-next-page |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1765 "\177" gnus-article-goto-prev-page |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1766 [delete] gnus-article-goto-prev-page |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1767 "\C-c^" gnus-article-refer-article |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1768 "h" gnus-article-show-summary |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1769 "s" gnus-article-show-summary |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1770 "\C-c\C-m" gnus-article-mail |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1771 "?" gnus-article-describe-briefly |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1772 gnus-mouse-2 gnus-article-push-button |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1773 "\r" gnus-article-press-button |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1774 "\t" gnus-article-next-button |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1775 "\M-\t" gnus-article-prev-button |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1776 "e" gnus-article-edit |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1777 "<" beginning-of-buffer |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1778 ">" end-of-buffer |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1779 "\C-c\C-i" gnus-info-find-node |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1780 "\C-c\C-b" gnus-bug |
17493 | 1781 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1782 "\C-d" gnus-article-read-summary-keys |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1783 "\M-*" gnus-article-read-summary-keys |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1784 "\M-#" gnus-article-read-summary-keys |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1785 "\M-^" gnus-article-read-summary-keys |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1786 "\M-g" gnus-article-read-summary-keys) |
17493 | 1787 |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1788 (substitute-key-definition |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
1789 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map) |
17493 | 1790 |
1791 (defun gnus-article-make-menu-bar () | |
1792 (gnus-turn-off-edit-menu 'article) | |
1793 (unless (boundp 'gnus-article-article-menu) | |
1794 (easy-menu-define | |
1795 gnus-article-article-menu gnus-article-mode-map "" | |
1796 '("Article" | |
1797 ["Scroll forwards" gnus-article-goto-next-page t] | |
1798 ["Scroll backwards" gnus-article-goto-prev-page t] | |
1799 ["Show summary" gnus-article-show-summary t] | |
1800 ["Fetch Message-ID at point" gnus-article-refer-article t] | |
1801 ["Mail to address at point" gnus-article-mail t])) | |
1802 | |
1803 (easy-menu-define | |
1804 gnus-article-treatment-menu gnus-article-mode-map "" | |
1805 '("Treatment" | |
1806 ["Hide headers" gnus-article-hide-headers t] | |
1807 ["Hide signature" gnus-article-hide-signature t] | |
1808 ["Hide citation" gnus-article-hide-citation t] | |
1809 ["Treat overstrike" gnus-article-treat-overstrike t] | |
1810 ["Remove carriage return" gnus-article-remove-cr t] | |
1811 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t])) | |
1812 | |
1813 (when nil | |
1814 (when (boundp 'gnus-summary-article-menu) | |
1815 (define-key gnus-article-mode-map [menu-bar commands] | |
1816 (cons "Commands" gnus-summary-article-menu)))) | |
1817 | |
1818 (when (boundp 'gnus-summary-post-menu) | |
1819 (define-key gnus-article-mode-map [menu-bar post] | |
1820 (cons "Post" gnus-summary-post-menu))) | |
1821 | |
1822 (run-hooks 'gnus-article-menu-hook))) | |
1823 | |
1824 (defun gnus-article-mode () | |
1825 "Major mode for displaying an article. | |
1826 | |
1827 All normal editing commands are switched off. | |
1828 | |
1829 The following commands are available in addition to all summary mode | |
1830 commands: | |
1831 \\<gnus-article-mode-map> | |
1832 \\[gnus-article-next-page]\t Scroll the article one page forwards | |
1833 \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
1834 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
1835 \\[gnus-article-show-summary]\t Display the summary buffer | |
1836 \\[gnus-article-mail]\t Send a reply to the address near point | |
1837 \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
1838 \\[gnus-info-find-node]\t Go to the Gnus info node" | |
1839 (interactive) | |
1840 (when (gnus-visual-p 'article-menu 'menu) | |
1841 (gnus-article-make-menu-bar)) | |
1842 (kill-all-local-variables) | |
1843 (gnus-simplify-mode-line) | |
1844 (setq mode-name "Article") | |
1845 (setq major-mode 'gnus-article-mode) | |
1846 (make-local-variable 'minor-mode-alist) | |
1847 (unless (assq 'gnus-show-mime minor-mode-alist) | |
1848 (push (list 'gnus-show-mime " MIME") minor-mode-alist)) | |
1849 (use-local-map gnus-article-mode-map) | |
1850 (gnus-update-format-specifications nil 'article-mode) | |
1851 (set (make-local-variable 'page-delimiter) gnus-page-delimiter) | |
1852 (set (make-local-variable 'gnus-page-broken) nil) | |
1853 (set (make-local-variable 'gnus-button-marker-list) nil) | |
1854 (gnus-set-default-directory) | |
1855 (buffer-disable-undo (current-buffer)) | |
1856 (setq buffer-read-only t) | |
1857 (set-syntax-table gnus-article-mode-syntax-table) | |
1858 (run-hooks 'gnus-article-mode-hook)) | |
1859 | |
1860 (defun gnus-article-setup-buffer () | |
1861 "Initialize the article buffer." | |
1862 (let* ((name (if gnus-single-article-buffer "*Article*" | |
1863 (concat "*Article " gnus-newsgroup-name "*"))) | |
1864 (original | |
1865 (progn (string-match "\\*Article" name) | |
1866 (concat " *Original Article" | |
1867 (substring name (match-end 0)))))) | |
1868 (setq gnus-article-buffer name) | |
1869 (setq gnus-original-article-buffer original) | |
1870 ;; This might be a variable local to the summary buffer. | |
1871 (unless gnus-single-article-buffer | |
1872 (save-excursion | |
1873 (set-buffer gnus-summary-buffer) | |
1874 (setq gnus-article-buffer name) | |
1875 (setq gnus-original-article-buffer original) | |
1876 (gnus-set-global-variables))) | |
1877 ;; Init original article buffer. | |
1878 (save-excursion | |
1879 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
1880 (buffer-disable-undo (current-buffer)) | |
1881 (setq major-mode 'gnus-original-article-mode) | |
1882 (gnus-add-current-to-buffer-list) | |
1883 (make-local-variable 'gnus-original-article)) | |
1884 (if (get-buffer name) | |
1885 (save-excursion | |
1886 (set-buffer name) | |
1887 (buffer-disable-undo (current-buffer)) | |
1888 (setq buffer-read-only t) | |
1889 (gnus-add-current-to-buffer-list) | |
1890 (unless (eq major-mode 'gnus-article-mode) | |
1891 (gnus-article-mode)) | |
1892 (current-buffer)) | |
1893 (save-excursion | |
1894 (set-buffer (get-buffer-create name)) | |
1895 (gnus-add-current-to-buffer-list) | |
1896 (gnus-article-mode) | |
1897 (make-local-variable 'gnus-summary-buffer) | |
1898 (current-buffer))))) | |
1899 | |
1900 ;; Set article window start at LINE, where LINE is the number of lines | |
1901 ;; from the head of the article. | |
1902 (defun gnus-article-set-window-start (&optional line) | |
1903 (set-window-start | |
1904 (get-buffer-window gnus-article-buffer t) | |
1905 (save-excursion | |
1906 (set-buffer gnus-article-buffer) | |
1907 (goto-char (point-min)) | |
1908 (if (not line) | |
1909 (point-min) | |
1910 (gnus-message 6 "Moved to bookmark") | |
1911 (search-forward "\n\n" nil t) | |
1912 (forward-line line) | |
1913 (point))))) | |
1914 | |
1915 (defun gnus-article-prepare (article &optional all-headers header) | |
1916 "Prepare ARTICLE in article mode buffer. | |
1917 ARTICLE should either be an article number or a Message-ID. | |
1918 If ARTICLE is an id, HEADER should be the article headers. | |
1919 If ALL-HEADERS is non-nil, no headers are hidden." | |
1920 (save-excursion | |
1921 ;; Make sure we start in a summary buffer. | |
1922 (unless (eq major-mode 'gnus-summary-mode) | |
1923 (set-buffer gnus-summary-buffer)) | |
1924 (setq gnus-summary-buffer (current-buffer)) | |
1925 ;; Make sure the connection to the server is alive. | |
1926 (unless (gnus-server-opened | |
1927 (gnus-find-method-for-group gnus-newsgroup-name)) | |
1928 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
1929 (gnus-request-group gnus-newsgroup-name t)) | |
1930 (let* ((gnus-article (if header (mail-header-number header) article)) | |
1931 (summary-buffer (current-buffer)) | |
1932 (internal-hook gnus-article-internal-prepare-hook) | |
1933 (group gnus-newsgroup-name) | |
1934 result) | |
1935 (save-excursion | |
1936 (gnus-article-setup-buffer) | |
1937 (set-buffer gnus-article-buffer) | |
1938 ;; Deactivate active regions. | |
1939 (when (and (boundp 'transient-mark-mode) | |
1940 transient-mark-mode) | |
1941 (setq mark-active nil)) | |
1942 (if (not (setq result (let ((buffer-read-only nil)) | |
1943 (gnus-request-article-this-buffer | |
1944 article group)))) | |
1945 ;; There is no such article. | |
1946 (save-excursion | |
1947 (when (and (numberp article) | |
1948 (not (memq article gnus-newsgroup-sparse))) | |
1949 (setq gnus-article-current | |
1950 (cons gnus-newsgroup-name article)) | |
1951 (set-buffer gnus-summary-buffer) | |
1952 (setq gnus-current-article article) | |
1953 (gnus-summary-mark-article article gnus-canceled-mark)) | |
1954 (unless (memq article gnus-newsgroup-sparse) | |
1955 (gnus-error | |
1956 1 "No such article (may have expired or been canceled)"))) | |
1957 (if (or (eq result 'pseudo) (eq result 'nneething)) | |
1958 (progn | |
1959 (save-excursion | |
1960 (set-buffer summary-buffer) | |
1961 (setq gnus-last-article gnus-current-article | |
1962 gnus-newsgroup-history (cons gnus-current-article | |
1963 gnus-newsgroup-history) | |
1964 gnus-current-article 0 | |
1965 gnus-current-headers nil | |
1966 gnus-article-current nil) | |
1967 (if (eq result 'nneething) | |
1968 (gnus-configure-windows 'summary) | |
1969 (gnus-configure-windows 'article)) | |
1970 (gnus-set-global-variables)) | |
1971 (gnus-set-mode-line 'article)) | |
1972 ;; The result from the `request' was an actual article - | |
1973 ;; or at least some text that is now displayed in the | |
1974 ;; article buffer. | |
1975 (when (and (numberp article) | |
1976 (not (eq article gnus-current-article))) | |
1977 ;; Seems like a new article has been selected. | |
1978 ;; `gnus-current-article' must be an article number. | |
1979 (save-excursion | |
1980 (set-buffer summary-buffer) | |
1981 (setq gnus-last-article gnus-current-article | |
1982 gnus-newsgroup-history (cons gnus-current-article | |
1983 gnus-newsgroup-history) | |
1984 gnus-current-article article | |
1985 gnus-current-headers | |
1986 (gnus-summary-article-header gnus-current-article) | |
1987 gnus-article-current | |
1988 (cons gnus-newsgroup-name gnus-current-article)) | |
1989 (unless (vectorp gnus-current-headers) | |
1990 (setq gnus-current-headers nil)) | |
1991 (gnus-summary-show-thread) | |
1992 (run-hooks 'gnus-mark-article-hook) | |
1993 (gnus-set-mode-line 'summary) | |
1994 (when (gnus-visual-p 'article-highlight 'highlight) | |
1995 (run-hooks 'gnus-visual-mark-article-hook)) | |
1996 ;; Set the global newsgroup variables here. | |
1997 ;; Suggested by Jim Sisolak | |
1998 ;; <sisolak@trans4.neep.wisc.edu>. | |
1999 (gnus-set-global-variables) | |
2000 (setq gnus-have-all-headers | |
2001 (or all-headers gnus-show-all-headers)) | |
2002 (and gnus-use-cache | |
2003 (vectorp (gnus-summary-article-header article)) | |
2004 (gnus-cache-possibly-enter-article | |
2005 group article | |
2006 (gnus-summary-article-header article) | |
2007 (memq article gnus-newsgroup-marked) | |
2008 (memq article gnus-newsgroup-dormant) | |
2009 (memq article gnus-newsgroup-unreads))))) | |
2010 (when (or (numberp article) | |
2011 (stringp article)) | |
2012 ;; Hooks for getting information from the article. | |
2013 ;; This hook must be called before being narrowed. | |
2014 (let (buffer-read-only) | |
2015 (run-hooks 'internal-hook) | |
2016 (run-hooks 'gnus-article-prepare-hook) | |
2017 ;; Decode MIME message. | |
19993
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2018 (if gnus-show-mime |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2019 (if (or (not gnus-strict-mime) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2020 (gnus-fetch-field "Mime-Version")) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2021 (funcall gnus-show-mime-method) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2022 (funcall gnus-decode-encoded-word-method)) |
2c30b1fb6409
(gnus-show-traditional-method): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19969
diff
changeset
|
2023 (funcall gnus-show-traditional-method)) |
17493 | 2024 ;; Perform the article display hooks. |
2025 (run-hooks 'gnus-article-display-hook)) | |
2026 ;; Do page break. | |
2027 (goto-char (point-min)) | |
2028 (setq gnus-page-broken | |
2029 (when gnus-break-pages | |
2030 (gnus-narrow-to-page) | |
2031 t))) | |
2032 (gnus-set-mode-line 'article) | |
2033 (gnus-configure-windows 'article) | |
2034 (goto-char (point-min)) | |
2035 t)))))) | |
2036 | |
2037 (defun gnus-article-wash-status () | |
2038 "Return a string which display status of article washing." | |
2039 (save-excursion | |
2040 (set-buffer gnus-article-buffer) | |
2041 (let ((cite (gnus-article-hidden-text-p 'cite)) | |
2042 (headers (gnus-article-hidden-text-p 'headers)) | |
2043 (boring (gnus-article-hidden-text-p 'boring-headers)) | |
2044 (pgp (gnus-article-hidden-text-p 'pgp)) | |
2045 (pem (gnus-article-hidden-text-p 'pem)) | |
2046 (signature (gnus-article-hidden-text-p 'signature)) | |
2047 (overstrike (gnus-article-hidden-text-p 'overstrike)) | |
2048 (emphasis (gnus-article-hidden-text-p 'emphasis)) | |
2049 (mime gnus-show-mime)) | |
2050 (format "%c%c%c%c%c%c%c" | |
2051 (if cite ?c ? ) | |
2052 (if (or headers boring) ?h ? ) | |
2053 (if (or pgp pem) ?p ? ) | |
2054 (if signature ?s ? ) | |
2055 (if overstrike ?o ? ) | |
2056 (if mime ?m ? ) | |
2057 (if emphasis ?e ? ))))) | |
2058 | |
2059 (defun gnus-article-hide-headers-if-wanted () | |
2060 "Hide unwanted headers if `gnus-have-all-headers' is nil. | |
2061 Provided for backwards compatibility." | |
2062 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | |
2063 gnus-inhibit-hiding | |
2064 (gnus-article-hide-headers))) | |
2065 | |
2066 ;;; Article savers. | |
2067 | |
2068 (defun gnus-output-to-file (file-name) | |
2069 "Append the current article to a file named FILE-NAME." | |
2070 (let ((artbuf (current-buffer))) | |
2071 (nnheader-temp-write nil | |
2072 (insert-buffer-substring artbuf) | |
2073 ;; Append newline at end of the buffer as separator, and then | |
2074 ;; save it to file. | |
2075 (goto-char (point-max)) | |
2076 (insert "\n") | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2077 (append-to-file (point-min) (point-max) file-name) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2078 t))) |
17493 | 2079 |
2080 (defun gnus-narrow-to-page (&optional arg) | |
2081 "Narrow the article buffer to a page. | |
2082 If given a numerical ARG, move forward ARG pages." | |
2083 (interactive "P") | |
2084 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
2085 (save-excursion | |
2086 (set-buffer gnus-article-buffer) | |
2087 (goto-char (point-min)) | |
2088 (widen) | |
2089 ;; Remove any old next/prev buttons. | |
2090 (when (gnus-visual-p 'page-marker) | |
2091 (let ((buffer-read-only nil)) | |
2092 (gnus-remove-text-with-property 'gnus-prev) | |
2093 (gnus-remove-text-with-property 'gnus-next))) | |
2094 (when | |
2095 (cond ((< arg 0) | |
2096 (re-search-backward page-delimiter nil 'move (1+ (abs arg)))) | |
2097 ((> arg 0) | |
2098 (re-search-forward page-delimiter nil 'move arg))) | |
2099 (goto-char (match-end 0))) | |
2100 (narrow-to-region | |
2101 (point) | |
2102 (if (re-search-forward page-delimiter nil 'move) | |
2103 (match-beginning 0) | |
2104 (point))) | |
2105 (when (and (gnus-visual-p 'page-marker) | |
2106 (not (= (point-min) 1))) | |
2107 (save-excursion | |
2108 (goto-char (point-min)) | |
2109 (gnus-insert-prev-page-button))) | |
2110 (when (and (gnus-visual-p 'page-marker) | |
2111 (< (+ (point-max) 2) (buffer-size))) | |
2112 (save-excursion | |
2113 (goto-char (point-max)) | |
2114 (gnus-insert-next-page-button))))) | |
2115 | |
2116 ;; Article mode commands | |
2117 | |
2118 (defun gnus-article-goto-next-page () | |
2119 "Show the next page of the article." | |
2120 (interactive) | |
2121 (when (gnus-article-next-page) | |
2122 (goto-char (point-min)) | |
2123 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
2124 | |
2125 (defun gnus-article-goto-prev-page () | |
2126 "Show the next page of the article." | |
2127 (interactive) | |
2128 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p)) | |
2129 (gnus-article-prev-page nil))) | |
2130 | |
2131 (defun gnus-article-next-page (&optional lines) | |
2132 "Show the next page of the current article. | |
2133 If end of article, return non-nil. Otherwise return nil. | |
2134 Argument LINES specifies lines to be scrolled up." | |
2135 (interactive "p") | |
2136 (move-to-window-line -1) | |
2137 (if (save-excursion | |
2138 (end-of-line) | |
2139 (and (pos-visible-in-window-p) ;Not continuation line. | |
2140 (eobp))) | |
2141 ;; Nothing in this page. | |
2142 (if (or (not gnus-page-broken) | |
2143 (save-excursion | |
2144 (save-restriction | |
2145 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
2146 t ;Nothing more. | |
2147 (gnus-narrow-to-page 1) ;Go to next page. | |
2148 nil) | |
2149 ;; More in this page. | |
2150 (let ((scroll-in-place nil)) | |
2151 (condition-case () | |
2152 (scroll-up lines) | |
2153 (end-of-buffer | |
2154 ;; Long lines may cause an end-of-buffer error. | |
2155 (goto-char (point-max))))) | |
2156 (move-to-window-line 0) | |
2157 nil)) | |
2158 | |
2159 (defun gnus-article-prev-page (&optional lines) | |
2160 "Show previous page of current article. | |
2161 Argument LINES specifies lines to be scrolled down." | |
2162 (interactive "p") | |
2163 (move-to-window-line 0) | |
2164 (if (and gnus-page-broken | |
2165 (bobp) | |
2166 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
2167 (progn | |
2168 (gnus-narrow-to-page -1) ;Go to previous page. | |
2169 (goto-char (point-max)) | |
2170 (recenter -1)) | |
2171 (let ((scroll-in-place nil)) | |
2172 (prog1 | |
2173 (condition-case () | |
2174 (scroll-down lines) | |
2175 (beginning-of-buffer | |
2176 (goto-char (point-min)))) | |
2177 (move-to-window-line 0))))) | |
2178 | |
2179 (defun gnus-article-refer-article () | |
2180 "Read article specified by message-id around point." | |
2181 (interactive) | |
2182 (let ((point (point))) | |
2183 (search-forward ">" nil t) ;Move point to end of "<....>". | |
2184 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
2185 (let ((message-id (match-string 1))) | |
2186 (goto-char point) | |
2187 (set-buffer gnus-summary-buffer) | |
2188 (gnus-summary-refer-article message-id)) | |
2189 (goto-char (point)) | |
2190 (error "No references around point")))) | |
2191 | |
2192 (defun gnus-article-show-summary () | |
2193 "Reconfigure windows to show summary buffer." | |
2194 (interactive) | |
2195 (if (not (gnus-buffer-live-p gnus-summary-buffer)) | |
2196 (error "There is no summary buffer for this article buffer") | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2197 (gnus-article-set-globals) |
17493 | 2198 (gnus-configure-windows 'article) |
2199 (gnus-summary-goto-subject gnus-current-article))) | |
2200 | |
2201 (defun gnus-article-describe-briefly () | |
2202 "Describe article mode commands briefly." | |
2203 (interactive) | |
2204 (gnus-message 6 | |
2205 (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"))) | |
2206 | |
2207 (defun gnus-article-summary-command () | |
2208 "Execute the last keystroke in the summary buffer." | |
2209 (interactive) | |
2210 (let ((obuf (current-buffer)) | |
2211 (owin (current-window-configuration)) | |
2212 func) | |
2213 (switch-to-buffer gnus-summary-buffer 'norecord) | |
2214 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
2215 (call-interactively func) | |
2216 (set-buffer obuf) | |
2217 (set-window-configuration owin) | |
2218 (set-window-point (get-buffer-window (current-buffer)) (point)))) | |
2219 | |
2220 (defun gnus-article-summary-command-nosave () | |
2221 "Execute the last keystroke in the summary buffer." | |
2222 (interactive) | |
2223 (let (func) | |
2224 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2225 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
2226 (call-interactively func))) | |
2227 | |
2228 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) | |
2229 "Read a summary buffer key sequence and execute it from the article buffer." | |
2230 (interactive "P") | |
2231 (let ((nosaves | |
2232 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | |
2233 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
2234 "=" "^" "\M-^" "|")) | |
2235 (nosave-but-article | |
2236 '("A\r")) | |
2237 (nosave-in-article | |
2238 '("\C-d")) | |
2239 keys) | |
2240 (save-excursion | |
2241 (set-buffer gnus-summary-buffer) | |
2242 (let (gnus-pick-mode) | |
2243 (push (or key last-command-event) unread-command-events) | |
2244 (setq keys (read-key-sequence nil)))) | |
2245 (message "") | |
2246 | |
2247 (if (or (member keys nosaves) | |
2248 (member keys nosave-but-article) | |
2249 (member keys nosave-in-article)) | |
2250 (let (func) | |
2251 (save-window-excursion | |
2252 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2253 ;; We disable the pick minor mode commands. | |
2254 (let (gnus-pick-mode) | |
2255 (setq func (lookup-key (current-local-map) keys)))) | |
2256 (if (not func) | |
2257 (ding) | |
2258 (unless (member keys nosave-in-article) | |
2259 (set-buffer gnus-summary-buffer)) | |
2260 (call-interactively func)) | |
2261 (when (member keys nosave-but-article) | |
2262 (pop-to-buffer gnus-article-buffer 'norecord))) | |
2263 ;; These commands should restore window configuration. | |
2264 (let ((obuf (current-buffer)) | |
2265 (owin (current-window-configuration)) | |
2266 (opoint (point)) | |
2267 func in-buffer) | |
2268 (if not-restore-window | |
2269 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2270 (switch-to-buffer gnus-summary-buffer 'norecord)) | |
2271 (setq in-buffer (current-buffer)) | |
2272 ;; We disable the pick minor mode commands. | |
2273 (if (setq func (let (gnus-pick-mode) | |
2274 (lookup-key (current-local-map) keys))) | |
2275 (call-interactively func) | |
2276 (ding)) | |
2277 (when (eq in-buffer (current-buffer)) | |
2278 (set-buffer obuf) | |
2279 (unless not-restore-window | |
2280 (set-window-configuration owin)) | |
2281 (set-window-point (get-buffer-window (current-buffer)) opoint)))))) | |
2282 | |
2283 (defun gnus-article-hide (&optional arg force) | |
2284 "Hide all the gruft in the current article. | |
2285 This means that PGP stuff, signatures, cited text and (some) | |
2286 headers will be hidden. | |
2287 If given a prefix, show the hidden text instead." | |
2288 (interactive (list current-prefix-arg 'force)) | |
2289 (gnus-article-hide-headers arg) | |
2290 (gnus-article-hide-pgp arg) | |
2291 (gnus-article-hide-citation-maybe arg force) | |
2292 (gnus-article-hide-signature arg)) | |
2293 | |
2294 (defun gnus-article-maybe-highlight () | |
2295 "Do some article highlighting if `article-visual' is non-nil." | |
2296 (when (gnus-visual-p 'article-highlight 'highlight) | |
2297 (gnus-article-highlight-some))) | |
2298 | |
2299 (defun gnus-request-article-this-buffer (article group) | |
2300 "Get an article and insert it into this buffer." | |
2301 (let (do-update-line) | |
2302 (prog1 | |
2303 (save-excursion | |
2304 (erase-buffer) | |
2305 (gnus-kill-all-overlays) | |
2306 (setq group (or group gnus-newsgroup-name)) | |
2307 | |
2308 ;; Open server if it has closed. | |
2309 (gnus-check-server (gnus-find-method-for-group group)) | |
2310 | |
2311 ;; Using `gnus-request-article' directly will insert the article into | |
2312 ;; `nntp-server-buffer' - so we'll save some time by not having to | |
2313 ;; copy it from the server buffer into the article buffer. | |
2314 | |
2315 ;; We only request an article by message-id when we do not have the | |
2316 ;; headers for it, so we'll have to get those. | |
2317 (when (stringp article) | |
2318 (let ((gnus-override-method gnus-refer-article-method)) | |
2319 (gnus-read-header article))) | |
2320 | |
2321 ;; If the article number is negative, that means that this article | |
2322 ;; doesn't belong in this newsgroup (possibly), so we find its | |
2323 ;; message-id and request it by id instead of number. | |
2324 (when (and (numberp article) | |
2325 gnus-summary-buffer | |
2326 (get-buffer gnus-summary-buffer) | |
2327 (buffer-name (get-buffer gnus-summary-buffer))) | |
2328 (save-excursion | |
2329 (set-buffer gnus-summary-buffer) | |
2330 (let ((header (gnus-summary-article-header article))) | |
2331 (when (< article 0) | |
2332 (cond | |
2333 ((memq article gnus-newsgroup-sparse) | |
2334 ;; This is a sparse gap article. | |
2335 (setq do-update-line article) | |
2336 (setq article (mail-header-id header)) | |
2337 (let ((gnus-override-method gnus-refer-article-method)) | |
2338 (gnus-read-header article)) | |
2339 (setq gnus-newsgroup-sparse | |
2340 (delq article gnus-newsgroup-sparse))) | |
2341 ((vectorp header) | |
2342 ;; It's a real article. | |
2343 (setq article (mail-header-id header))) | |
2344 (t | |
2345 ;; It is an extracted pseudo-article. | |
2346 (setq article 'pseudo) | |
2347 (gnus-request-pseudo-article header)))) | |
2348 | |
2349 (let ((method (gnus-find-method-for-group | |
2350 gnus-newsgroup-name))) | |
2351 (if (not (eq (car method) 'nneething)) | |
2352 () | |
2353 (let ((dir (concat (file-name-as-directory (nth 1 method)) | |
2354 (mail-header-subject header)))) | |
2355 (when (file-directory-p dir) | |
2356 (setq article 'nneething) | |
2357 (gnus-group-enter-directory dir)))))))) | |
2358 | |
2359 (cond | |
2360 ;; Refuse to select canceled articles. | |
2361 ((and (numberp article) | |
2362 gnus-summary-buffer | |
2363 (get-buffer gnus-summary-buffer) | |
2364 (buffer-name (get-buffer gnus-summary-buffer)) | |
2365 (eq (cdr (save-excursion | |
2366 (set-buffer gnus-summary-buffer) | |
2367 (assq article gnus-newsgroup-reads))) | |
2368 gnus-canceled-mark)) | |
2369 nil) | |
2370 ;; We first check `gnus-original-article-buffer'. | |
2371 ((and (get-buffer gnus-original-article-buffer) | |
2372 (numberp article) | |
2373 (save-excursion | |
2374 (set-buffer gnus-original-article-buffer) | |
2375 (and (equal (car gnus-original-article) group) | |
2376 (eq (cdr gnus-original-article) article)))) | |
2377 (insert-buffer-substring gnus-original-article-buffer) | |
2378 'article) | |
2379 ;; Check the backlog. | |
2380 ((and gnus-keep-backlog | |
2381 (gnus-backlog-request-article group article (current-buffer))) | |
2382 'article) | |
2383 ;; Check asynchronous pre-fetch. | |
2384 ((gnus-async-request-fetched-article group article (current-buffer)) | |
2385 (gnus-async-prefetch-next group article gnus-summary-buffer) | |
2386 'article) | |
2387 ;; Check the cache. | |
2388 ((and gnus-use-cache | |
2389 (numberp article) | |
2390 (gnus-cache-request-article article group)) | |
2391 'article) | |
2392 ;; Get the article and put into the article buffer. | |
2393 ((or (stringp article) (numberp article)) | |
2394 (let ((gnus-override-method | |
2395 (and (stringp article) gnus-refer-article-method)) | |
2396 (buffer-read-only nil)) | |
2397 (erase-buffer) | |
2398 (gnus-kill-all-overlays) | |
2399 (when (gnus-request-article article group (current-buffer)) | |
2400 (when (numberp article) | |
2401 (gnus-async-prefetch-next group article gnus-summary-buffer) | |
2402 (when gnus-keep-backlog | |
2403 (gnus-backlog-enter-article | |
2404 group article (current-buffer)))) | |
2405 'article))) | |
2406 ;; It was a pseudo. | |
2407 (t article))) | |
2408 | |
2409 ;; Take the article from the original article buffer | |
2410 ;; and place it in the buffer it's supposed to be in. | |
2411 (when (and (get-buffer gnus-article-buffer) | |
2412 ;;(numberp article) | |
2413 (equal (buffer-name (current-buffer)) | |
2414 (buffer-name (get-buffer gnus-article-buffer)))) | |
2415 (save-excursion | |
2416 (if (get-buffer gnus-original-article-buffer) | |
2417 (set-buffer (get-buffer gnus-original-article-buffer)) | |
2418 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
2419 (buffer-disable-undo (current-buffer)) | |
2420 (setq major-mode 'gnus-original-article-mode) | |
2421 (setq buffer-read-only t) | |
2422 (gnus-add-current-to-buffer-list)) | |
2423 (let (buffer-read-only) | |
2424 (erase-buffer) | |
2425 (insert-buffer-substring gnus-article-buffer)) | |
2426 (setq gnus-original-article (cons group article)))) | |
2427 | |
2428 ;; Update sparse articles. | |
2429 (when (and do-update-line | |
2430 (or (numberp article) | |
2431 (stringp article))) | |
2432 (let ((buf (current-buffer))) | |
2433 (set-buffer gnus-summary-buffer) | |
2434 (gnus-summary-update-article do-update-line) | |
2435 (gnus-summary-goto-subject do-update-line nil t) | |
2436 (set-window-point (get-buffer-window (current-buffer) t) | |
2437 (point)) | |
2438 (set-buffer buf)))))) | |
2439 | |
2440 ;;; | |
2441 ;;; Article editing | |
2442 ;;; | |
2443 | |
2444 (defcustom gnus-article-edit-mode-hook nil | |
2445 "Hook run in article edit mode buffers." | |
2446 :group 'gnus-article-various | |
2447 :type 'hook) | |
2448 | |
2449 (defvar gnus-article-edit-done-function nil) | |
2450 | |
2451 (defvar gnus-article-edit-mode-map nil) | |
2452 | |
2453 (unless gnus-article-edit-mode-map | |
2454 (setq gnus-article-edit-mode-map (copy-keymap text-mode-map)) | |
2455 | |
2456 (gnus-define-keys gnus-article-edit-mode-map | |
2457 "\C-c\C-c" gnus-article-edit-done | |
2458 "\C-c\C-k" gnus-article-edit-exit) | |
2459 | |
2460 (gnus-define-keys (gnus-article-edit-wash-map | |
2461 "\C-c\C-w" gnus-article-edit-mode-map) | |
2462 "f" gnus-article-edit-full-stops)) | |
2463 | |
2464 (defun gnus-article-edit-mode () | |
2465 "Major mode for editing articles. | |
2466 This is an extended text-mode. | |
2467 | |
2468 \\{gnus-article-edit-mode-map}" | |
2469 (interactive) | |
2470 (kill-all-local-variables) | |
2471 (setq major-mode 'gnus-article-edit-mode) | |
2472 (setq mode-name "Article Edit") | |
2473 (use-local-map gnus-article-edit-mode-map) | |
2474 (make-local-variable 'gnus-article-edit-done-function) | |
2475 (make-local-variable 'gnus-prev-winconf) | |
2476 (setq buffer-read-only nil) | |
2477 (buffer-enable-undo) | |
2478 (widen) | |
2479 (run-hooks 'text-mode 'gnus-article-edit-mode-hook)) | |
2480 | |
2481 (defun gnus-article-edit (&optional force) | |
2482 "Edit the current article. | |
2483 This will have permanent effect only in mail groups. | |
2484 If FORCE is non-nil, allow editing of articles even in read-only | |
2485 groups." | |
2486 (interactive "P") | |
2487 (when (and (not force) | |
2488 (gnus-group-read-only-p)) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2489 (error "The current newsgroup does not support article editing")) |
17493 | 2490 (gnus-article-edit-article |
2491 `(lambda () | |
2492 (gnus-summary-edit-article-done | |
2493 ,(or (mail-header-references gnus-current-headers) "") | |
2494 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))) | |
2495 | |
2496 (defun gnus-article-edit-article (exit-func) | |
2497 "Start editing the contents of the current article buffer." | |
2498 (let ((winconf (current-window-configuration))) | |
2499 (set-buffer gnus-article-buffer) | |
2500 (gnus-article-edit-mode) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2501 (gnus-set-text-properties (point-min) (point-max) nil) |
17493 | 2502 (gnus-configure-windows 'edit-article) |
2503 (setq gnus-article-edit-done-function exit-func) | |
2504 (setq gnus-prev-winconf winconf) | |
2505 (gnus-message 6 "C-c C-c to end edits"))) | |
2506 | |
2507 (defun gnus-article-edit-done () | |
2508 "Update the article edits and exit." | |
2509 (interactive) | |
2510 (let ((func gnus-article-edit-done-function) | |
2511 (buf (current-buffer)) | |
2512 (start (window-start))) | |
2513 (gnus-article-edit-exit) | |
2514 (save-excursion | |
2515 (set-buffer buf) | |
2516 (let ((buffer-read-only nil)) | |
2517 (funcall func))) | |
2518 (set-buffer buf) | |
2519 (set-window-start (get-buffer-window buf) start) | |
2520 (set-window-point (get-buffer-window buf) (point)))) | |
2521 | |
2522 (defun gnus-article-edit-exit () | |
2523 "Exit the article editing without updating." | |
2524 (interactive) | |
2525 ;; We remove all text props from the article buffer. | |
2526 (let ((buf (format "%s" (buffer-string))) | |
2527 (curbuf (current-buffer)) | |
2528 (p (point)) | |
2529 (window-start (window-start))) | |
2530 (erase-buffer) | |
2531 (insert buf) | |
2532 (let ((winconf gnus-prev-winconf)) | |
2533 (gnus-article-mode) | |
2534 ;; The cache and backlog have to be flushed somewhat. | |
2535 (when gnus-use-cache | |
2536 (gnus-cache-update-article | |
2537 (car gnus-article-current) (cdr gnus-article-current))) | |
2538 (when gnus-keep-backlog | |
2539 (gnus-backlog-remove-article | |
2540 (car gnus-article-current) (cdr gnus-article-current))) | |
2541 ;; Flush original article as well. | |
2542 (save-excursion | |
2543 (when (get-buffer gnus-original-article-buffer) | |
2544 (set-buffer gnus-original-article-buffer) | |
2545 (setq gnus-original-article nil))) | |
2546 (set-window-configuration winconf) | |
2547 ;; Tippy-toe some to make sure that point remains where it was. | |
2548 (let ((buf (current-buffer))) | |
2549 (set-buffer curbuf) | |
2550 (set-window-start (get-buffer-window (current-buffer)) window-start) | |
2551 (goto-char p) | |
2552 (set-buffer buf))))) | |
2553 | |
2554 (defun gnus-article-edit-full-stops () | |
2555 "Interactively repair spacing at end of sentences." | |
2556 (interactive) | |
2557 (save-excursion | |
2558 (goto-char (point-min)) | |
2559 (search-forward-regexp "^$" nil t) | |
2560 (let ((case-fold-search nil)) | |
2561 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2")))) | |
2562 | |
2563 ;;; | |
2564 ;;; Article highlights | |
2565 ;;; | |
2566 | |
2567 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. | |
2568 | |
2569 ;;; Internal Variables: | |
2570 | |
2571 (defcustom gnus-button-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)" | |
2572 "Regular expression that matches URLs." | |
2573 :group 'gnus-article-buttons | |
2574 :type 'regexp) | |
2575 | |
2576 (defcustom gnus-button-alist | |
2577 `(("<\\(url: ?\\)?news:\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t | |
2578 gnus-button-message-id 2) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2579 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*\\)" 0 t gnus-button-message-id 1) |
17493 | 2580 ("\\(\\b<\\(url: ?\\)?news:\\(//\\)?\\([^>\n\t ]*\\)>\\)" 1 t |
2581 gnus-button-fetch-group 4) | |
2582 ("\\bnews:\\(//\\)?\\([^>\n\t ]+\\)" 0 t gnus-button-fetch-group 2) | |
2583 ("\\bin\\( +article\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2 | |
2584 t gnus-button-message-id 3) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2585 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2586 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1) |
17493 | 2587 ;; This is how URLs _should_ be embedded in text... |
2588 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1) | |
2589 ;; Raw URLs. | |
2590 (,gnus-button-url-regexp 0 t gnus-button-url 0)) | |
2591 "Alist of regexps matching buttons in article bodies. | |
2592 | |
2593 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where | |
2594 REGEXP: is the string matching text around the button, | |
2595 BUTTON: is the number of the regexp grouping actually matching the button, | |
2596 FORM: is a lisp expression which must eval to true for the button to | |
2597 be added, | |
2598 CALLBACK: is the function to call when the user push this button, and each | |
2599 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK. | |
2600 | |
2601 CALLBACK can also be a variable, in that case the value of that | |
2602 variable it the real callback function." | |
2603 :group 'gnus-article-buttons | |
2604 :type '(repeat (list regexp | |
2605 (integer :tag "Button") | |
2606 (sexp :tag "Form") | |
2607 (function :tag "Callback") | |
2608 (repeat :tag "Par" | |
2609 :inline t | |
2610 (integer :tag "Regexp group"))))) | |
2611 | |
2612 (defcustom gnus-header-button-alist | |
2613 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>" | |
2614 0 t gnus-button-message-id 0) | |
2615 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1) | |
2616 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" | |
2617 0 t gnus-button-mailto 0) | |
2618 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2619 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0) |
17493 | 2620 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0) |
2621 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t | |
2622 gnus-button-message-id 3)) | |
2623 "Alist of headers and regexps to match buttons in article heads. | |
2624 | |
2625 This alist is very similar to `gnus-button-alist', except that each | |
2626 alist has an additional HEADER element first in each entry: | |
2627 | |
2628 \(HEADER REGEXP BUTTON FORM CALLBACK PAR) | |
2629 | |
2630 HEADER is a regexp to match a header. For a fuller explanation, see | |
2631 `gnus-button-alist'." | |
2632 :group 'gnus-article-buttons | |
2633 :group 'gnus-article-headers | |
2634 :type '(repeat (list (regexp :tag "Header") | |
2635 regexp | |
2636 (integer :tag "Button") | |
2637 (sexp :tag "Form") | |
2638 (function :tag "Callback") | |
2639 (repeat :tag "Par" | |
2640 :inline t | |
2641 (integer :tag "Regexp group"))))) | |
2642 | |
2643 (defvar gnus-button-regexp nil) | |
2644 (defvar gnus-button-marker-list nil) | |
2645 ;; Regexp matching any of the regexps from `gnus-button-alist'. | |
2646 | |
2647 (defvar gnus-button-last nil) | |
2648 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build. | |
2649 | |
2650 ;;; Commands: | |
2651 | |
2652 (defun gnus-article-push-button (event) | |
2653 "Check text under the mouse pointer for a callback function. | |
2654 If the text under the mouse pointer has a `gnus-callback' property, | |
2655 call it with the value of the `gnus-data' text property." | |
2656 (interactive "e") | |
2657 (set-buffer (window-buffer (posn-window (event-start event)))) | |
2658 (let* ((pos (posn-point (event-start event))) | |
2659 (data (get-text-property pos 'gnus-data)) | |
2660 (fun (get-text-property pos 'gnus-callback))) | |
2661 (when fun | |
2662 (funcall fun data)))) | |
2663 | |
2664 (defun gnus-article-press-button () | |
2665 "Check text at point for a callback function. | |
2666 If the text at point has a `gnus-callback' property, | |
2667 call it with the value of the `gnus-data' text property." | |
2668 (interactive) | |
2669 (let* ((data (get-text-property (point) 'gnus-data)) | |
2670 (fun (get-text-property (point) 'gnus-callback))) | |
2671 (when fun | |
2672 (funcall fun data)))) | |
2673 | |
2674 (defun gnus-article-prev-button (n) | |
2675 "Move point to N buttons backward. | |
2676 If N is negative, move forward instead." | |
2677 (interactive "p") | |
2678 (gnus-article-next-button (- n))) | |
2679 | |
2680 (defun gnus-article-next-button (n) | |
2681 "Move point to N buttons forward. | |
2682 If N is negative, move backward instead." | |
2683 (interactive "p") | |
2684 (let ((function (if (< n 0) 'previous-single-property-change | |
2685 'next-single-property-change)) | |
2686 (inhibit-point-motion-hooks t) | |
2687 (backward (< n 0)) | |
2688 (limit (if (< n 0) (point-min) (point-max)))) | |
2689 (setq n (abs n)) | |
2690 (while (and (not (= limit (point))) | |
2691 (> n 0)) | |
2692 ;; Skip past the current button. | |
2693 (when (get-text-property (point) 'gnus-callback) | |
2694 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2695 ;; Go to the next (or previous) button. | |
2696 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit)) | |
2697 ;; Put point at the start of the button. | |
2698 (when (and backward (not (get-text-property (point) 'gnus-callback))) | |
2699 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2700 ;; Skip past intangible buttons. | |
2701 (when (get-text-property (point) 'intangible) | |
2702 (incf n)) | |
2703 (decf n)) | |
2704 (unless (zerop n) | |
2705 (gnus-message 5 "No more buttons")) | |
2706 n)) | |
2707 | |
2708 (defun gnus-article-highlight (&optional force) | |
2709 "Highlight current article. | |
2710 This function calls `gnus-article-highlight-headers', | |
2711 `gnus-article-highlight-citation', | |
2712 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
2713 do the highlighting. See the documentation for those functions." | |
2714 (interactive (list 'force)) | |
2715 (gnus-article-highlight-headers) | |
2716 (gnus-article-highlight-citation force) | |
2717 (gnus-article-highlight-signature) | |
2718 (gnus-article-add-buttons force) | |
2719 (gnus-article-add-buttons-to-head)) | |
2720 | |
2721 (defun gnus-article-highlight-some (&optional force) | |
2722 "Highlight current article. | |
2723 This function calls `gnus-article-highlight-headers', | |
2724 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
2725 do the highlighting. See the documentation for those functions." | |
2726 (interactive (list 'force)) | |
2727 (gnus-article-highlight-headers) | |
2728 (gnus-article-highlight-signature) | |
2729 (gnus-article-add-buttons)) | |
2730 | |
2731 (defun gnus-article-highlight-headers () | |
2732 "Highlight article headers as specified by `gnus-header-face-alist'." | |
2733 (interactive) | |
2734 (save-excursion | |
2735 (set-buffer gnus-article-buffer) | |
2736 (save-restriction | |
2737 (let ((alist gnus-header-face-alist) | |
2738 (buffer-read-only nil) | |
2739 (case-fold-search t) | |
2740 (inhibit-point-motion-hooks t) | |
2741 entry regexp header-face field-face from hpoints fpoints) | |
2742 (message-narrow-to-head) | |
2743 (while (setq entry (pop alist)) | |
2744 (goto-char (point-min)) | |
2745 (setq regexp (concat "^\\(" | |
2746 (if (string-equal "" (nth 0 entry)) | |
2747 "[^\t ]" | |
2748 (nth 0 entry)) | |
2749 "\\)") | |
2750 header-face (nth 1 entry) | |
2751 field-face (nth 2 entry)) | |
2752 (while (and (re-search-forward regexp nil t) | |
2753 (not (eobp))) | |
2754 (beginning-of-line) | |
2755 (setq from (point)) | |
2756 (unless (search-forward ":" nil t) | |
2757 (forward-char 1)) | |
2758 (when (and header-face | |
2759 (not (memq (point) hpoints))) | |
2760 (push (point) hpoints) | |
2761 (gnus-put-text-property from (point) 'face header-face)) | |
2762 (when (and field-face | |
2763 (not (memq (setq from (point)) fpoints))) | |
2764 (push from fpoints) | |
2765 (if (re-search-forward "^[^ \t]" nil t) | |
2766 (forward-char -2) | |
2767 (goto-char (point-max))) | |
2768 (gnus-put-text-property from (point) 'face field-face)))))))) | |
2769 | |
2770 (defun gnus-article-highlight-signature () | |
2771 "Highlight the signature in an article. | |
2772 It does this by highlighting everything after | |
2773 `gnus-signature-separator' using `gnus-signature-face'." | |
2774 (interactive) | |
2775 (save-excursion | |
2776 (set-buffer gnus-article-buffer) | |
2777 (let ((buffer-read-only nil) | |
2778 (inhibit-point-motion-hooks t)) | |
2779 (save-restriction | |
2780 (when (and gnus-signature-face | |
2781 (gnus-article-narrow-to-signature)) | |
2782 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max)) | |
2783 'face gnus-signature-face) | |
2784 (widen) | |
2785 (gnus-article-search-signature) | |
2786 (let ((start (match-beginning 0)) | |
2787 (end (set-marker (make-marker) (1+ (match-end 0))))) | |
2788 (gnus-article-add-button start (1- end) 'gnus-signature-toggle | |
2789 end))))))) | |
2790 | |
2791 (defun gnus-button-in-region-p (b e prop) | |
2792 "Say whether PROP exists in the region." | |
2793 (text-property-not-all b e prop nil)) | |
2794 | |
2795 (defun gnus-article-add-buttons (&optional force) | |
2796 "Find external references in the article and make buttons of them. | |
2797 \"External references\" are things like Message-IDs and URLs, as | |
2798 specified by `gnus-button-alist'." | |
2799 (interactive (list 'force)) | |
2800 (save-excursion | |
2801 (set-buffer gnus-article-buffer) | |
2802 (let ((buffer-read-only nil) | |
2803 (inhibit-point-motion-hooks t) | |
2804 (case-fold-search t) | |
2805 (alist gnus-button-alist) | |
2806 beg entry regexp) | |
2807 ;; Remove all old markers. | |
2808 (let (marker entry) | |
2809 (while (setq marker (pop gnus-button-marker-list)) | |
2810 (goto-char marker) | |
2811 (when (setq entry (gnus-button-entry)) | |
2812 (put-text-property (match-beginning (nth 1 entry)) | |
2813 (match-end (nth 1 entry)) | |
2814 'gnus-callback nil)) | |
2815 (set-marker marker nil))) | |
2816 ;; We skip the headers. | |
2817 (goto-char (point-min)) | |
2818 (unless (search-forward "\n\n" nil t) | |
2819 (goto-char (point-max))) | |
2820 (setq beg (point)) | |
2821 (while (setq entry (pop alist)) | |
2822 (setq regexp (car entry)) | |
2823 (goto-char beg) | |
2824 (while (re-search-forward regexp nil t) | |
2825 (let* ((start (and entry (match-beginning (nth 1 entry)))) | |
2826 (end (and entry (match-end (nth 1 entry)))) | |
2827 (from (match-beginning 0))) | |
2828 (when (and (or (eq t (nth 2 entry)) | |
2829 (eval (nth 2 entry))) | |
2830 (not (gnus-button-in-region-p | |
2831 start end 'gnus-callback))) | |
2832 ;; That optional form returned non-nil, so we add the | |
2833 ;; button. | |
2834 (gnus-article-add-button | |
2835 start end 'gnus-button-push | |
2836 (car (push (set-marker (make-marker) from) | |
2837 gnus-button-marker-list)))))))))) | |
2838 | |
2839 ;; Add buttons to the head of an article. | |
2840 (defun gnus-article-add-buttons-to-head () | |
2841 "Add buttons to the head of the article." | |
2842 (interactive) | |
2843 (save-excursion | |
2844 (set-buffer gnus-article-buffer) | |
2845 (let ((buffer-read-only nil) | |
2846 (inhibit-point-motion-hooks t) | |
2847 (case-fold-search t) | |
2848 (alist gnus-header-button-alist) | |
2849 entry beg end) | |
2850 (nnheader-narrow-to-headers) | |
2851 (while alist | |
2852 ;; Each alist entry. | |
2853 (setq entry (car alist) | |
2854 alist (cdr alist)) | |
2855 (goto-char (point-min)) | |
2856 (while (re-search-forward (car entry) nil t) | |
2857 ;; Each header matching the entry. | |
2858 (setq beg (match-beginning 0)) | |
2859 (setq end (or (and (re-search-forward "^[^ \t]" nil t) | |
2860 (match-beginning 0)) | |
2861 (point-max))) | |
2862 (goto-char beg) | |
2863 (while (re-search-forward (nth 1 entry) end t) | |
2864 ;; Each match within a header. | |
2865 (let* ((entry (cdr entry)) | |
2866 (start (match-beginning (nth 1 entry))) | |
2867 (end (match-end (nth 1 entry))) | |
2868 (form (nth 2 entry))) | |
2869 (goto-char (match-end 0)) | |
2870 (when (eval form) | |
2871 (gnus-article-add-button | |
2872 start end (nth 3 entry) | |
2873 (buffer-substring (match-beginning (nth 4 entry)) | |
2874 (match-end (nth 4 entry))))))) | |
2875 (goto-char end)))) | |
2876 (widen))) | |
2877 | |
2878 ;;; External functions: | |
2879 | |
2880 (defun gnus-article-add-button (from to fun &optional data) | |
2881 "Create a button between FROM and TO with callback FUN and data DATA." | |
2882 (when gnus-article-button-face | |
2883 (gnus-overlay-put (gnus-make-overlay from to) | |
2884 'face gnus-article-button-face)) | |
2885 (gnus-add-text-properties | |
2886 from to | |
2887 (nconc (and gnus-article-mouse-face | |
2888 (list gnus-mouse-face-prop gnus-article-mouse-face)) | |
2889 (list 'gnus-callback fun) | |
2890 (and data (list 'gnus-data data))))) | |
2891 | |
2892 ;;; Internal functions: | |
2893 | |
19969
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2894 (defun gnus-article-set-globals () |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2895 (save-excursion |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2896 (set-buffer gnus-summary-buffer) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2897 (gnus-set-global-variables))) |
5f1ab3dd344d
*** empty log message ***
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19537
diff
changeset
|
2898 |
17493 | 2899 (defun gnus-signature-toggle (end) |
2900 (save-excursion | |
2901 (set-buffer gnus-article-buffer) | |
2902 (let ((buffer-read-only nil) | |
2903 (inhibit-point-motion-hooks t)) | |
2904 (if (get-text-property end 'invisible) | |
2905 (gnus-article-unhide-text end (point-max)) | |
2906 (gnus-article-hide-text end (point-max) gnus-hidden-properties))))) | |
2907 | |
2908 (defun gnus-button-entry () | |
2909 ;; Return the first entry in `gnus-button-alist' matching this place. | |
2910 (let ((alist gnus-button-alist) | |
2911 (entry nil)) | |
2912 (while alist | |
2913 (setq entry (pop alist)) | |
2914 (if (looking-at (car entry)) | |
2915 (setq alist nil) | |
2916 (setq entry nil))) | |
2917 entry)) | |
2918 | |
2919 (defun gnus-button-push (marker) | |
2920 ;; Push button starting at MARKER. | |
2921 (save-excursion | |
2922 (set-buffer gnus-article-buffer) | |
2923 (goto-char marker) | |
2924 (let* ((entry (gnus-button-entry)) | |
2925 (inhibit-point-motion-hooks t) | |
2926 (fun (nth 3 entry)) | |
2927 (args (mapcar (lambda (group) | |
2928 (let ((string (match-string group))) | |
2929 (gnus-set-text-properties | |
2930 0 (length string) nil string) | |
2931 string)) | |
2932 (nthcdr 4 entry)))) | |
2933 (cond | |
2934 ((fboundp fun) | |
2935 (apply fun args)) | |
2936 ((and (boundp fun) | |
2937 (fboundp (symbol-value fun))) | |
2938 (apply (symbol-value fun) args)) | |
2939 (t | |
2940 (gnus-message 1 "You must define `%S' to use this button" | |
2941 (cons fun args))))))) | |
2942 | |
2943 (defun gnus-button-message-id (message-id) | |
2944 "Fetch MESSAGE-ID." | |
2945 (save-excursion | |
2946 (set-buffer gnus-summary-buffer) | |
2947 (gnus-summary-refer-article message-id))) | |
2948 | |
2949 (defun gnus-button-fetch-group (address) | |
2950 "Fetch GROUP specified by ADDRESS." | |
2951 (if (not (string-match "[:/]" address)) | |
2952 ;; This is just a simple group url. | |
2953 (gnus-group-read-ephemeral-group address gnus-select-method) | |
2954 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$" | |
2955 address)) | |
2956 (error "Can't parse %s" address) | |
2957 (gnus-group-read-ephemeral-group | |
2958 (match-string 4 address) | |
2959 `(nntp ,(match-string 1 address) | |
2960 (nntp-address ,(match-string 1 address)) | |
2961 (nntp-port-number ,(if (match-end 3) | |
2962 (match-string 3 address) | |
2963 "nntp"))))))) | |
2964 | |
2965 (defun gnus-split-string (string pattern) | |
2966 "Return a list of substrings of STRING which are separated by PATTERN." | |
2967 (let (parts (start 0)) | |
2968 (while (string-match pattern string start) | |
2969 (setq parts (cons (substring string start (match-beginning 0)) parts) | |
2970 start (match-end 0))) | |
2971 (nreverse (cons (substring string start) parts)))) | |
2972 | |
2973 (defun gnus-url-parse-query-string (query &optional downcase) | |
2974 (let (retval pairs cur key val) | |
2975 (setq pairs (gnus-split-string query "&")) | |
2976 (while pairs | |
2977 (setq cur (car pairs) | |
2978 pairs (cdr pairs)) | |
2979 (if (not (string-match "=" cur)) | |
2980 nil ; Grace | |
2981 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0))) | |
2982 val (gnus-url-unhex-string (substring cur (match-end 0) nil))) | |
2983 (if downcase | |
2984 (setq key (downcase key))) | |
2985 (setq cur (assoc key retval)) | |
2986 (if cur | |
2987 (setcdr cur (cons val (cdr cur))) | |
2988 (setq retval (cons (list key val) retval))))) | |
2989 retval)) | |
2990 | |
2991 (defun gnus-url-unhex (x) | |
2992 (if (> x ?9) | |
2993 (if (>= x ?a) | |
2994 (+ 10 (- x ?a)) | |
2995 (+ 10 (- x ?A))) | |
2996 (- x ?0))) | |
2997 | |
2998 (defun gnus-url-unhex-string (str &optional allow-newlines) | |
2999 "Remove %XXX embedded spaces, etc in a url. | |
3000 If optional second argument ALLOW-NEWLINES is non-nil, then allow the | |
3001 decoding of carriage returns and line feeds in the string, which is normally | |
3002 forbidden in URL encoding." | |
3003 (setq str (or str "")) | |
3004 (let ((tmp "") | |
3005 (case-fold-search t)) | |
3006 (while (string-match "%[0-9a-f][0-9a-f]" str) | |
3007 (let* ((start (match-beginning 0)) | |
3008 (ch1 (gnus-url-unhex (elt str (+ start 1)))) | |
3009 (code (+ (* 16 ch1) | |
3010 (gnus-url-unhex (elt str (+ start 2)))))) | |
3011 (setq tmp (concat | |
3012 tmp (substring str 0 start) | |
3013 (cond | |
3014 (allow-newlines | |
3015 (char-to-string code)) | |
3016 ((or (= code ?\n) (= code ?\r)) | |
3017 " ") | |
3018 (t (char-to-string code)))) | |
3019 str (substring str (match-end 0))))) | |
3020 (setq tmp (concat tmp str)) | |
3021 tmp)) | |
3022 | |
3023 (defun gnus-url-mailto (url) | |
3024 ;; Send mail to someone | |
3025 (when (string-match "mailto:/*\\(.*\\)" url) | |
3026 (setq url (substring url (match-beginning 1) nil))) | |
3027 (let (to args source-url subject func) | |
3028 (if (string-match (regexp-quote "?") url) | |
3029 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0))) | |
3030 args (gnus-url-parse-query-string | |
3031 (substring url (match-end 0) nil) t)) | |
3032 (setq to (gnus-url-unhex-string url))) | |
3033 (setq args (cons (list "to" to) args) | |
3034 subject (cdr-safe (assoc "subject" args))) | |
3035 (message-mail) | |
3036 (while args | |
3037 (setq func (intern-soft (concat "message-goto-" (downcase (caar args))))) | |
3038 (if (fboundp func) | |
3039 (funcall func) | |
3040 (message-position-on-field (caar args))) | |
3041 (insert (mapconcat 'identity (cdar args) ", ")) | |
3042 (setq args (cdr args))) | |
3043 (if subject | |
3044 (message-goto-body) | |
3045 (message-goto-subject)))) | |
3046 | |
3047 (defun gnus-button-mailto (address) | |
3048 ;; Mail to ADDRESS. | |
3049 (set-buffer (gnus-copy-article-buffer)) | |
3050 (message-reply address)) | |
3051 | |
3052 (defun gnus-button-reply (address) | |
3053 ;; Reply to ADDRESS. | |
3054 (message-reply address)) | |
3055 | |
3056 (defun gnus-button-url (address) | |
3057 "Browse ADDRESS." | |
3058 (funcall browse-url-browser-function address)) | |
3059 | |
3060 (defun gnus-button-embedded-url (address) | |
3061 "Browse ADDRESS." | |
3062 (funcall browse-url-browser-function (gnus-strip-whitespace address))) | |
3063 | |
3064 ;;; Next/prev buttons in the article buffer. | |
3065 | |
3066 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") | |
3067 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") | |
3068 | |
3069 (defvar gnus-prev-page-map nil) | |
3070 (unless gnus-prev-page-map | |
3071 (setq gnus-prev-page-map (make-sparse-keymap)) | |
3072 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page) | |
3073 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page)) | |
3074 | |
3075 (defun gnus-insert-prev-page-button () | |
3076 (let ((buffer-read-only nil)) | |
3077 (gnus-eval-format | |
3078 gnus-prev-page-line-format nil | |
3079 `(gnus-prev t local-map ,gnus-prev-page-map | |
3080 gnus-callback gnus-article-button-prev-page)))) | |
3081 | |
3082 (defvar gnus-next-page-map nil) | |
3083 (unless gnus-next-page-map | |
3084 (setq gnus-next-page-map (make-keymap)) | |
3085 (suppress-keymap gnus-prev-page-map) | |
3086 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page) | |
3087 (define-key gnus-next-page-map "\r" 'gnus-button-next-page)) | |
3088 | |
3089 (defun gnus-button-next-page () | |
3090 "Go to the next page." | |
3091 (interactive) | |
3092 (let ((win (selected-window))) | |
3093 (select-window (get-buffer-window gnus-article-buffer t)) | |
3094 (gnus-article-next-page) | |
3095 (select-window win))) | |
3096 | |
3097 (defun gnus-button-prev-page () | |
3098 "Go to the prev page." | |
3099 (interactive) | |
3100 (let ((win (selected-window))) | |
3101 (select-window (get-buffer-window gnus-article-buffer t)) | |
3102 (gnus-article-prev-page) | |
3103 (select-window win))) | |
3104 | |
3105 (defun gnus-insert-next-page-button () | |
3106 (let ((buffer-read-only nil)) | |
3107 (gnus-eval-format gnus-next-page-line-format nil | |
3108 `(gnus-next t local-map ,gnus-next-page-map | |
3109 gnus-callback | |
3110 gnus-article-button-next-page)))) | |
3111 | |
3112 (defun gnus-article-button-next-page (arg) | |
3113 "Go to the next page." | |
3114 (interactive "P") | |
3115 (let ((win (selected-window))) | |
3116 (select-window (get-buffer-window gnus-article-buffer t)) | |
3117 (gnus-article-next-page) | |
3118 (select-window win))) | |
3119 | |
3120 (defun gnus-article-button-prev-page (arg) | |
3121 "Go to the prev page." | |
3122 (interactive "P") | |
3123 (let ((win (selected-window))) | |
3124 (select-window (get-buffer-window gnus-article-buffer t)) | |
3125 (gnus-article-prev-page) | |
3126 (select-window win))) | |
3127 | |
3128 (gnus-ems-redefine) | |
3129 | |
3130 (provide 'gnus-art) | |
3131 | |
3132 (run-hooks 'gnus-art-load-hook) | |
3133 | |
3134 ;;; gnus-art.el ends here |