1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2017 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (defvar w3m-minor-mode-map
)
46 (autoload 'gnus-msg-mail
"gnus-msg" nil t
)
47 (autoload 'gnus-button-mailto
"gnus-msg")
48 (autoload 'gnus-button-reply
"gnus-msg" nil t
)
49 (autoload 'parse-time-string
"parse-time" nil nil
)
50 (autoload 'ansi-color-apply-on-region
"ansi-color")
51 (autoload 'mm-url-insert-file-contents-external
"mm-url")
52 (autoload 'mm-extern-cache-contents
"mm-extern")
53 (autoload 'url-expand-file-name
"url-expand")
55 (defgroup gnus-article nil
57 :link
'(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link
'(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link
'(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link
'(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link
'(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link
'(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link
'(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link
'(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link
'(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link
'(custom-manual "(gnus)Using MIME")
104 :group
'gnus-article
)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link
'(custom-manual "(gnus)Article Buttons")
109 :group
'gnus-article
)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link
'(custom-manual "(gnus)Misc Article")
114 :group
'gnus-article
)
116 (defcustom gnus-ignored-headers
119 (concat "^" header
":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
158 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
159 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
160 "Envelope-Sender" "Envelope-Recipients"))
161 "All headers that start with this regexp will be hidden.
162 This variable can also be a list of regexps of headers to be ignored.
163 If `gnus-visible-headers' is non-nil, this variable will be ignored."
164 :type
'(choice regexp
166 :group
'gnus-article-hiding
)
168 (defcustom gnus-visible-headers
169 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
170 "All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
174 (repeat :value-to-internal
(lambda (widget value
)
175 (custom-split-regexp-maybe value
))
176 :match
(lambda (widget value
)
178 (widget-editable-list-match widget value
)))
180 (const :tag
"Use gnus-ignored-headers" nil
)
182 :group
'gnus-article-hiding
)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type
'(repeat regexp
)
192 :group
'gnus-article-hiding
)
194 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 `empty' Headers with no content.
199 `newsgroups' Newsgroup identical to Gnus group.
200 `to-address' To identical to To-address.
201 `to-list' To identical to To-list.
202 `cc-list' CC identical to To-list.
203 `followup-to' Followup-to identical to Newsgroups.
204 `reply-to' Reply-to identical to From.
205 `date' Date less than four days old.
206 `long-to' To and/or Cc longer than 1024 characters.
207 `many-to' Multiple To and/or Cc."
208 :type
'(set (const :tag
"Headers with no content." empty
)
209 (const :tag
"Newsgroups identical to Gnus group." newsgroups
)
210 (const :tag
"To identical to To-address." to-address
)
211 (const :tag
"To identical to To-list." to-list
)
212 (const :tag
"CC identical to To-list." cc-list
)
213 (const :tag
"Followup-to identical to Newsgroups." followup-to
)
214 (const :tag
"Reply-to identical to From." reply-to
)
215 (const :tag
"Date less than four days old." date
)
216 (const :tag
"To and/or Cc longer than 1024 characters." long-to
)
217 (const :tag
"Multiple To and/or Cc headers." many-to
))
218 :group
'gnus-article-hiding
)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
228 :group
'gnus-article-hiding
)
230 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
231 "Regexp matching signature separator.
232 This can also be a list of regexps. In that case, it will be checked
233 from head to tail looking for a separator. Searches will be done from
234 the end of the buffer."
235 :type
'(choice :format
"%{%t%}: %[Value Menu%]\n%v"
237 (repeat :tag
"List of regexp" regexp
))
238 :group
'gnus-article-signature
)
240 (defcustom gnus-signature-limit nil
241 "Provide a limit to what is considered a signature.
242 If it is a number, no signature may not be longer (in characters) than
243 that number. If it is a floating point number, no signature may be
244 longer (in lines) than that number. If it is a function, the function
245 will be called without any parameters, and if it returns nil, there is
246 no signature in the buffer. If it is a string, it will be used as a
247 regexp. If it matches, the text in question is not a signature.
249 This can also be a list of the above values."
250 :type
'(choice (const nil
)
255 (repeat (choice (const nil
)
259 (regexp :value
".*"))))
260 :group
'gnus-article-signature
)
262 (defcustom gnus-hidden-properties
263 ;; We use to have `intangible' here as well, but Emacs's command loop moves
264 ;; point out of invisible text anyway, so `intangible' is clearly not
265 ;; needed there. And XEmacs doesn't handle `intangible' anyway.
267 "Property list to use for hiding text."
269 :group
'gnus-article-hiding
)
271 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
272 ;; frames in a session.
273 (defcustom gnus-article-x-face-command
274 (if (gnus-image-type-available-p 'pbm
)
275 'gnus-display-x-face-in-from
277 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
278 ; uncompface; } | icontopbm | display -")
279 "String or function to be executed to display an X-Face header.
280 If it is a string, the command will be executed in a sub-shell
281 asynchronously. The compressed face will be piped to this command."
282 :type
`(choice string
283 (function-item gnus-display-x-face-in-from
)
287 :group
'gnus-article-washing
)
289 (defcustom gnus-article-x-face-too-ugly nil
290 "Regexp matching posters whose face shouldn't be shown automatically."
291 :type
'(choice regexp
(const nil
))
292 :group
'gnus-article-washing
)
294 (defcustom gnus-article-banner-alist nil
295 "Banner alist for stripping.
297 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
299 :type
'(repeat (cons symbol regexp
))
300 :group
'gnus-article-washing
)
302 (gnus-define-group-parameter
305 "Alist of regexps (to match group names) and banner."
306 :variable-group gnus-article-washing
308 '(choice :tag
"Banner"
310 (const :tag
"Remove signature" signature
)
311 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
313 (const :tag
"None" nil
))
315 "If non-nil, specify how to remove `banners' from articles.
317 Symbol `signature' means to remove signatures delimited by
318 `gnus-signature-separator'. Any other symbol is used to look up a
319 regular expression to match the banner in `gnus-article-banner-alist'.
320 A string is used as a regular expression to match the banner
323 (defcustom gnus-article-address-banner-alist nil
324 "Alist of mail addresses and banners.
325 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
326 to match a mail address in the From: header, BANNER is one of a symbol
327 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
328 If ADDRESS matches author's mail address, it will remove things like
329 advertisements. For example:
331 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\\\='\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
335 (regexp :tag
"Address")
336 (choice :tag
"Banner" :value nil
337 (const :tag
"Remove signature" signature
)
338 (symbol :tag
"Item in `gnus-article-banner-alist'" none
)
340 (const :tag
"None" nil
))))
342 :group
'gnus-article-washing
)
344 (defmacro gnus-emphasis-custom-with-format
(&rest body
)
346 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
347 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
350 (defun gnus-emphasis-custom-value-to-external (value)
351 (gnus-emphasis-custom-with-format
352 (if (consp (car value
))
353 (list (format format
(car (car value
)) (cdr (car value
)))
355 (if (nth 1 value
) 2 3)
359 (defun gnus-emphasis-custom-value-to-internal (value)
360 (gnus-emphasis-custom-with-format
361 (let ((regexp (concat "\\`"
362 (format (regexp-quote format
)
363 "\\([^()]+\\)" "\\([^()]+\\)")
366 (if (string-match regexp
(setq pattern
(car value
)))
367 (list (cons (match-string 1 pattern
) (match-string 2 pattern
))
372 (defcustom gnus-emphasis-alist
374 '(("\\*" "\\*" bold nil
2)
377 ("_/" "/_" underline-italic
)
378 ("_\\*" "\\*_" underline-bold
)
379 ("\\*/" "/\\*" bold-italic
)
380 ("_\\*/" "/\\*_" underline-bold-italic
))))
382 (gnus-emphasis-custom-with-format
383 (mapcar (lambda (spec)
384 (list (format format
(car spec
) (cadr spec
))
387 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
389 '(;; I've never seen anyone use this strikethru convention whereas I've
390 ;; several times seen it triggered by normal text. --Stef
391 ;; Miles suggests that this form is sometimes used but for italics,
392 ;; so maybe we should map it to `italic'.
393 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
394 ;; 2 3 gnus-emphasis-strikethru)
395 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
396 2 3 gnus-emphasis-underline
))))
397 "Alist that says how to fontify certain phrases.
398 Each item looks like this:
400 (\"_\\\\(\\\\w+\\\\)_\" 0 1 \\='underline)
402 The first element is a regular expression to be matched. The second
403 is a number that says what regular expression grouping used to find
404 the entire emphasized word. The third is a number that says what
405 regexp grouping should be displayed and highlighted. The fourth
406 is the face used for highlighting."
410 :format
"%[Customizing Style%]\n%v"
412 (group :tag
"Default"
413 :value
("" 0 0 default
)
416 (let ((value (widget-get
417 (cadr (widget-get (widget-get widget
:parent
)
420 (if (not (eq (nth 2 value
) 'default
))
424 (gnus-emphasis-custom-value-to-external value
))))
425 (widget-group-value-create widget
))
427 (integer :format
"Match group: %v")
428 (integer :format
"Emphasize group: %v")
431 :value
(("_" .
"_") nil default
)
433 (regexp :format
"Start regexp: %v")
434 (regexp :format
"End regexp: %v"))
435 (boolean :format
"Show start and end patterns: %[%v%]\n"
436 :on
" On " :off
" Off ")
438 :get
(lambda (symbol)
439 (mapcar 'gnus-emphasis-custom-value-to-internal
440 (default-value symbol
)))
441 :set
(lambda (symbol value
)
442 (set-default symbol
(mapcar 'gnus-emphasis-custom-value-to-external
444 :group
'gnus-article-emphasis
)
446 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
447 "A regexp to describe whitespace which should not be emphasized.
448 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
449 The former avoids underlining of leading and trailing whitespace,
450 and the latter avoids underlining any whitespace at all."
452 :group
'gnus-article-emphasis
455 (defface gnus-emphasis-bold
'((t (:bold t
)))
456 "Face used for displaying strong emphasized text (*word*)."
457 :group
'gnus-article-emphasis
)
459 (defface gnus-emphasis-italic
'((t (:italic t
)))
460 "Face used for displaying italic emphasized text (/word/)."
461 :group
'gnus-article-emphasis
)
463 (defface gnus-emphasis-underline
'((t (:underline t
)))
464 "Face used for displaying underlined emphasized text (_word_)."
465 :group
'gnus-article-emphasis
)
467 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
468 "Face used for displaying underlined bold emphasized text (_*word*_)."
469 :group
'gnus-article-emphasis
)
471 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
472 "Face used for displaying underlined italic emphasized text (_/word/_)."
473 :group
'gnus-article-emphasis
)
475 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
476 "Face used for displaying bold italic emphasized text (/*word*/)."
477 :group
'gnus-article-emphasis
)
479 (defface gnus-emphasis-underline-bold-italic
480 '((t (:bold t
:italic t
:underline t
)))
481 "Face used for displaying underlined bold italic emphasized text.
482 Example: (_/*word*/_)."
483 :group
'gnus-article-emphasis
)
485 (defface gnus-emphasis-strikethru
'((t (:strike-through t
)))
486 "Face used for displaying strike-through text (-word-)."
487 :group
'gnus-article-emphasis
)
489 (defface gnus-emphasis-highlight-words
490 '((t (:background
"black" :foreground
"yellow")))
491 "Face used for displaying highlighted words."
492 :group
'gnus-article-emphasis
)
494 (defcustom gnus-article-time-format
"%a, %d %b %Y %T %Z"
495 "Format for display of Date headers in article bodies.
496 See `format-time-string' for the possible values.
498 The variable can also be function, which should return a complete Date
499 header. The function is called with one argument, the time, which can
500 be fed to `format-time-string'."
501 :type
'(choice string function
)
502 :link
'(custom-manual "(gnus)Article Date")
503 :group
'gnus-article-washing
)
505 (defcustom gnus-save-all-headers t
506 "If non-nil, don't remove any headers before saving.
507 This will be overridden by the `:headers' property that the symbol of
508 the saver function, which is specified by `gnus-default-article-saver',
510 :group
'gnus-article-saving
513 (defcustom gnus-prompt-before-saving
'always
514 "This variable says how much prompting is to be done when saving articles.
515 If it is nil, no prompting will be done, and the articles will be
516 saved to the default files. If this variable is `always', each and
517 every article that is saved will be preceded by a prompt, even when
518 saving large batches of articles. If this variable is neither nil not
519 `always', there the user will be prompted once for a file name for
520 each invocation of the saving commands."
521 :group
'gnus-article-saving
522 :type
'(choice (item always
)
523 (item :tag
"never" nil
)
524 (sexp :tag
"once" :format
"%t\n" :value t
)))
526 (defcustom gnus-article-show-cursor nil
527 "If non-nil, show the cursor in the Article buffer even when not selected."
532 (defcustom gnus-saved-headers gnus-visible-headers
533 "Headers to keep if `gnus-save-all-headers' is nil.
534 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
535 If that variable is nil, however, all headers that match this regexp
536 will be kept while the rest will be deleted before saving. This and
537 `gnus-save-all-headers' will be overridden by the `:headers' property
538 that the symbol of the saver function, which is specified by
539 `gnus-default-article-saver', might have."
540 :group
'gnus-article-saving
543 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
544 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
545 "A function to save articles in your favorite format.
546 The function will be called by way of the `gnus-summary-save-article'
547 command, and friends such as `gnus-summary-save-article-rmail'.
549 Gnus provides the following functions:
551 * gnus-summary-save-in-rmail (Rmail format)
552 * gnus-summary-save-in-mail (Unix mail format)
553 * gnus-summary-save-in-folder (MH folder)
554 * gnus-summary-save-in-file (article format)
555 * gnus-summary-save-body-in-file (article body)
556 * gnus-summary-save-in-vm (use VM's folder format)
557 * gnus-summary-write-to-file (article format -- overwrite)
558 * gnus-summary-write-body-to-file (article body -- overwrite)
559 * gnus-summary-save-in-pipe (article format)
561 The symbol of each function may have the following properties:
564 The value non-nil means save decoded articles. This is meaningful
565 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
566 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
567 `gnus-summary-save-in-pipe'.
570 The value specifies an alternative function which appends, not
571 overwrites, articles to a file. This implies that when saving many
572 articles at a time, `gnus-prompt-before-saving' is bound to t and all
573 articles are saved in a single file. This is meaningful only with
574 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
577 The value specifies the symbol of a variable of which the value
578 specifies headers to be saved. If it is omitted,
579 `gnus-save-all-headers' and `gnus-saved-headers' control what
580 headers should be saved."
581 :group
'gnus-article-saving
582 :type
'(radio (function-item gnus-summary-save-in-rmail
)
583 (function-item gnus-summary-save-in-mail
)
584 (function-item gnus-summary-save-in-folder
)
585 (function-item gnus-summary-save-in-file
)
586 (function-item gnus-summary-save-body-in-file
)
587 (function-item gnus-summary-save-in-vm
)
588 (function-item gnus-summary-write-to-file
)
589 (function-item gnus-summary-write-body-to-file
)
590 (function-item gnus-summary-save-in-pipe
)
593 (defcustom gnus-article-save-coding-system
594 (or (and (mm-coding-system-p 'utf-8
) 'utf-8
)
595 (and (mm-coding-system-p 'iso-2022-7bit
) 'iso-2022-7bit
)
596 (and (mm-coding-system-p 'emacs-mule
) 'emacs-mule
)
597 (and (mm-coding-system-p 'escape-quoted
) 'escape-quoted
))
598 "Coding system used to save decoded articles to a file.
600 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
601 which can safely encode any characters in text. This is used by the
604 * gnus-summary-save-article-file
605 * gnus-summary-save-article-body-file
606 * gnus-summary-write-article-file
607 * gnus-summary-write-article-body-file
609 and the functions to which you may set `gnus-default-article-saver':
611 * gnus-summary-save-in-file
612 * gnus-summary-save-body-in-file
613 * gnus-summary-write-to-file
614 * gnus-summary-write-body-to-file
616 Those commands and functions save just text displayed in the article
617 buffer to a file if the value of this variable is non-nil. Note that
618 buttonized MIME parts will be lost in a saved file in that case.
619 Otherwise, raw articles will be saved."
620 :group
'gnus-article-saving
622 :format
"%{%t%}:\n %[Value Menu%] %v"
623 (const :tag
"Save raw articles" nil
)
626 (lambda (arg) (if (mm-coding-system-p (nth 3 arg
)) arg
))
627 '((const :tag
"UTF-8" utf-8
)
628 (const :tag
"iso-2022-7bit" iso-2022-7bit
)
629 (const :tag
"Emacs internal" emacs-mule
)
630 (const :tag
"escape-quoted" escape-quoted
))))
631 (symbol :tag
"Coding system")))
633 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
634 "A function generating a file name to save articles in Rmail format.
635 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
636 :group
'gnus-article-saving
639 (defcustom gnus-mail-save-name
'gnus-plain-save-name
640 "A function generating a file name to save articles in Unix mail format.
641 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
642 :group
'gnus-article-saving
645 (defcustom gnus-folder-save-name
'gnus-folder-save-name
646 "A function generating a file name to save articles in MH folder.
647 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
648 :group
'gnus-article-saving
651 (defcustom gnus-file-save-name
'gnus-numeric-save-name
652 "A function generating a file name to save articles in article format.
653 The function is called with NEWSGROUP, HEADERS, and optional
655 :group
'gnus-article-saving
658 (defcustom gnus-split-methods
659 '((gnus-article-archive-name)
660 (gnus-article-nndoc-name))
661 "Variable used to suggest where articles are to be saved.
662 For instance, if you would like to save articles related to Gnus in
663 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
664 you could set this variable to something like:
666 ((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
667 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
669 This variable is an alist where the key is the match and the
670 value is a list of possible files to save in if the match is
673 If the match is a string, it is used as a regexp match on the
674 article. If the match is a symbol, that symbol will be funcalled
675 from the buffer of the article to be saved with the newsgroup as the
676 parameter. If it is a list, it will be evalled in the same buffer.
678 If this form or function returns a string, this string will be used as a
679 possible file name; and if it returns a non-nil list, that list will be
680 used as possible file names."
681 :group
'gnus-article-saving
682 :type
'(repeat (choice (list :value
(fun) function
)
683 (cons :value
("" "") regexp
(repeat string
))
686 (defcustom gnus-page-delimiter
"^\^L"
687 "Regexp describing what to use as article page delimiters.
688 The default value is \"^\^L\", which is a form linefeed at the
689 beginning of a line."
691 :group
'gnus-article-various
)
693 (defcustom gnus-article-mode-line-format
"Gnus: %g %S%m"
694 "The format specification for the article mode line.
695 See `gnus-summary-mode-line-format' for a closer description.
697 The following additional specs are available:
699 %w The article washing status.
700 %m The number of MIME parts in the article."
703 :group
'gnus-article-various
)
705 (defcustom gnus-article-mode-hook nil
706 "A hook for Gnus article mode."
708 :group
'gnus-article-various
)
710 (defcustom gnus-article-menu-hook nil
711 "Hook run after the creation of the article mode menu."
713 :group
'gnus-article-various
)
715 (defcustom gnus-article-prepare-hook nil
716 "A hook called after an article has been prepared in the article buffer."
718 :group
'gnus-article-various
)
720 (defcustom gnus-copy-article-ignored-headers nil
721 "List of headers to be removed when copying an article.
722 Each element is a regular expression."
723 :version
"23.1" ;; No Gnus
724 :type
'(repeat regexp
)
725 :group
'gnus-article-various
)
727 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
728 "Gnus 5.10 (Emacs 22.1)")
731 '((t (:weight bold
)))
732 "Face used for highlighting a button in the article buffer."
733 :group
'gnus-article-buttons
)
735 (defcustom gnus-article-button-face
'gnus-button
736 "Face used for highlighting buttons in the article buffer.
738 An article button is a piece of text that you can activate by pressing
739 `RET' or `mouse-2' above it."
741 :group
'gnus-article-buttons
)
743 (defcustom gnus-article-mouse-face
'highlight
744 "Face used for mouse highlighting in the article buffer.
746 Article buttons will be displayed in this face when the cursor is
749 :group
'gnus-article-buttons
)
751 (defcustom gnus-signature-face
'gnus-signature
752 "Face used for highlighting a signature in the article buffer.
753 Obsolete; use the face `gnus-signature' for customizations instead."
755 :group
'gnus-article-highlight
756 :group
'gnus-article-signature
)
758 (defface gnus-signature
761 "Face used for highlighting a signature in the article buffer."
762 :group
'gnus-article-highlight
763 :group
'gnus-article-signature
)
764 ;; backward-compatibility alias
765 (put 'gnus-signature-face
'face-alias
'gnus-signature
)
766 (put 'gnus-signature-face
'obsolete-face
"22.1")
768 (defface gnus-header-from
771 (:foreground
"PaleGreen1"))
774 (:foreground
"red3"))
777 "Face used for displaying from headers."
778 :group
'gnus-article-headers
779 :group
'gnus-article-highlight
)
780 ;; backward-compatibility alias
781 (put 'gnus-header-from-face
'face-alias
'gnus-header-from
)
782 (put 'gnus-header-from-face
'obsolete-face
"22.1")
784 (defface gnus-header-subject
787 (:foreground
"SeaGreen1"))
790 (:foreground
"red4"))
792 (:bold t
:italic t
)))
793 "Face used for displaying subject headers."
794 :group
'gnus-article-headers
795 :group
'gnus-article-highlight
)
796 ;; backward-compatibility alias
797 (put 'gnus-header-subject-face
'face-alias
'gnus-header-subject
)
798 (put 'gnus-header-subject-face
'obsolete-face
"22.1")
800 (defface gnus-header-newsgroups
803 (:foreground
"yellow" :italic t
))
806 (:foreground
"MidnightBlue" :italic t
))
809 "Face used for displaying newsgroups headers.
810 In the default setup this face is only used for crossposted
812 :group
'gnus-article-headers
813 :group
'gnus-article-highlight
)
814 ;; backward-compatibility alias
815 (put 'gnus-header-newsgroups-face
'face-alias
'gnus-header-newsgroups
)
816 (put 'gnus-header-newsgroups-face
'obsolete-face
"22.1")
818 (defface gnus-header-name
821 (:foreground
"SpringGreen2"))
824 (:foreground
"maroon"))
827 "Face used for displaying header names."
828 :group
'gnus-article-headers
829 :group
'gnus-article-highlight
)
830 ;; backward-compatibility alias
831 (put 'gnus-header-name-face
'face-alias
'gnus-header-name
)
832 (put 'gnus-header-name-face
'obsolete-face
"22.1")
834 (defface gnus-header-content
837 (:foreground
"SpringGreen1" :italic t
))
840 (:foreground
"indianred4" :italic t
))
842 (:italic t
))) "Face used for displaying header content."
843 :group
'gnus-article-headers
844 :group
'gnus-article-highlight
)
845 ;; backward-compatibility alias
846 (put 'gnus-header-content-face
'face-alias
'gnus-header-content
)
847 (put 'gnus-header-content-face
'obsolete-face
"22.1")
849 (defcustom gnus-header-face-alist
850 '(("From" nil gnus-header-from
)
851 ("Subject" nil gnus-header-subject
)
852 ("Newsgroups:.*," nil gnus-header-newsgroups
)
853 ("" gnus-header-name gnus-header-content
))
854 "Controls highlighting of article headers.
856 An alist of the form (HEADER NAME CONTENT).
858 HEADER is a regular expression which should match the name of a
859 header and NAME and CONTENT are either face names or nil.
861 The name of each header field will be displayed using the face
862 specified by the first element in the list where HEADER matches
863 the header name and NAME is non-nil. Similarly, the content will
864 be displayed by the first non-nil matching CONTENT face."
865 :group
'gnus-article-headers
866 :group
'gnus-article-highlight
867 :type
'(repeat (list (regexp :tag
"Header")
869 (item :tag
"skip" nil
)
870 (face :value default
))
871 (choice :tag
"Content"
872 (item :tag
"skip" nil
)
873 (face :value default
)))))
875 (defcustom gnus-face-properties-alist
'((pbm .
(:face gnus-x-face
))
877 "Alist of image types and properties applied to Face and X-Face images.
880 ;; Specify the altitude of Face images in the From header.
881 \(setq gnus-face-properties-alist
882 \\='((pbm . (:face gnus-x-face :ascent 80))
883 (png . (:ascent 80))))
885 ;; Show Face images as pressed buttons.
886 \(setq gnus-face-properties-alist
887 \\='((pbm . (:face gnus-x-face :relief -2))
888 (png . (:relief -2))))
890 See the manual for the valid properties for various image types.
891 Currently, `pbm' is used for X-Face images and `png' is used for Face
893 :version
"23.1" ;; No Gnus
894 :group
'gnus-article-headers
895 :type
'(repeat (cons :format
"%v" (symbol :tag
"Image type") plist
)))
897 (defcustom gnus-article-decode-hook
898 '(article-decode-charset article-decode-encoded-words
899 article-decode-group-name article-decode-idna-rhs
)
900 "Hook run to decode charsets in articles."
901 :group
'gnus-article-headers
904 (defcustom gnus-display-mime-function
'gnus-display-mime
905 "Function to display MIME articles."
906 :group
'gnus-article-mime
909 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
910 "Function used to decode headers.")
912 (defvar gnus-decode-address-function
'mail-decode-encoded-address-region
913 "Function used to decode addresses.")
915 (defvar gnus-article-dumbquotes-map
935 "Table for MS-to-Latin1 translation.")
937 (defcustom gnus-ignored-mime-types nil
938 "List of MIME types that should be ignored by Gnus."
940 :group
'gnus-article-mime
941 :type
'(repeat regexp
))
943 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
944 "List of MIME types that should not be given buttons when rendered inline.
945 See also `gnus-buttonized-mime-types' which may override this variable.
946 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
948 :group
'gnus-article-mime
949 :type
'(repeat regexp
))
951 (defcustom gnus-buttonized-mime-types nil
952 "List of MIME types that should be given buttons when rendered inline.
953 If set, this variable overrides `gnus-unbuttonized-mime-types'.
954 To see e.g. security buttons you could set this to
955 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
956 this list to display radio buttons that allow you to choose one of two
957 media types those mails include. See also `mm-discouraged-alternatives'.
958 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
960 :group
'gnus-article-mime
961 :type
'(repeat regexp
))
963 (defcustom gnus-inhibit-mime-unbuttonizing nil
964 "If non-nil, all MIME parts get buttons.
965 When nil (the default value), then some MIME parts do not get buttons,
966 as described by the variables `gnus-buttonized-mime-types' and
967 `gnus-unbuttonized-mime-types'."
969 :group
'gnus-article-mime
972 (defcustom gnus-body-boundary-delimiter
"_"
973 "String used to delimit header and body.
974 This variable is used by `gnus-article-treat-body-boundary' which can
975 be controlled by `gnus-treat-body-boundary'."
977 :group
'gnus-article-various
978 :type
'(choice (item :tag
"None" :value nil
)
981 (defcustom gnus-picon-databases
'("/usr/lib/picon" "/usr/local/faces"
983 "Defines the location of the faces database.
984 For information on obtaining this database of pretty pictures, please
985 see http://www.cs.indiana.edu/picons/ftp/index.html"
987 :type
'(repeat directory
)
988 :link
'(url-link :tag
"download"
989 "http://www.cs.indiana.edu/picons/ftp/index.html")
990 :link
'(custom-manual "(gnus)Picons")
993 (defun gnus-picons-installed-p ()
994 "Say whether picons are installed on your machine."
995 (let ((installed nil
))
996 (dolist (database gnus-picon-databases
)
997 (when (file-exists-p database
)
1001 (defcustom gnus-article-mime-part-function nil
1002 "Function called with a MIME handle as the argument.
1003 This is meant for people who want to do something automatic based
1004 on parts -- for instance, adding Vcard info to a database."
1005 :group
'gnus-article-mime
1006 :type
'(choice (const nil
)
1009 (defcustom gnus-mime-multipart-functions nil
1010 "An alist of MIME types to functions to display them."
1012 :group
'gnus-article-mime
1013 :type
'(repeat (cons :format
"%v" (string :tag
"MIME type") function
)))
1015 (defcustom gnus-article-date-headers
'(combined-lapsed)
1016 "A list of Date header formats to display.
1017 Valid formats are `ut' (Universal Time), `local' (local time
1018 zone), `english' (readable English), `lapsed' (elapsed time),
1019 `combined-lapsed' (both the original date and the elapsed time),
1020 `original' (the original date header), `iso8601' (ISO8601
1021 format), and `user-defined' (a user-defined format defined by the
1022 `gnus-article-time-format' variable).
1024 You have as many date headers as you want in the article buffer.
1025 Some of these headers are updated automatically. See
1026 `gnus-article-update-date-headers' for details."
1028 :group
'gnus-article-headers
1030 (const :tag
"Universal time (UT)" ut
)
1031 (const :tag
"Local time zone" local
)
1032 (const :tag
"Readable English" english
)
1033 (const :tag
"Elapsed time" lapsed
)
1034 (const :tag
"Original and elapsed time" combined-lapsed
)
1035 (const :tag
"Original date header" original
)
1036 (const :tag
"ISO8601 format" iso8601
)
1037 (const :tag
"User-defined" user-defined
)))
1039 (defcustom gnus-article-update-date-headers nil
1040 "A number that says how often to update the date header (in seconds).
1041 If nil, don't update it at all."
1043 :group
'gnus-article-headers
1045 (item :tag
"Don't update" :value nil
)
1048 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
1049 "Function called with a MIME handle as the argument.
1050 This is meant for people who want to view first matched part.
1051 For `undisplayed-alternative' (default), the first undisplayed
1052 part or alternative part is used. For `undisplayed', the first
1053 undisplayed part is used. For a function, the first part which
1054 the function return t is used. For nil, the first part is
1057 :group
'gnus-article-mime
1059 (item :tag
"first" :value nil
)
1060 (item :tag
"undisplayed" :value undisplayed
)
1061 (item :tag
"undisplayed or alternative"
1062 :value undisplayed-alternative
)
1065 (defcustom gnus-mime-action-alist
1066 '(("save to file" . gnus-mime-save-part
)
1067 ("save and strip" . gnus-mime-save-part-and-strip
)
1068 ("replace with file" . gnus-mime-replace-part
)
1069 ("delete part" . gnus-mime-delete-part
)
1070 ("display as text" . gnus-mime-inline-part
)
1071 ("view the part" . gnus-mime-view-part
)
1072 ("pipe to command" . gnus-mime-pipe-part
)
1073 ("toggle display" . gnus-article-press-button
)
1074 ("toggle display" . gnus-article-view-part-as-charset
)
1075 ("view as type" . gnus-mime-view-part-as-type
)
1076 ("view internally" . gnus-mime-view-part-internally
)
1077 ("view externally" . gnus-mime-view-part-externally
))
1078 "An alist of actions that run on the MIME attachment."
1079 :group
'gnus-article-mime
1080 :type
'(repeat (cons (string :tag
"name")
1083 (defcustom gnus-auto-select-part
1
1084 "Advance to next MIME part when deleting or stripping parts.
1086 When 0, point will be placed on the same part as before. When
1087 positive (negative), move point forward (backwards) this many
1088 parts. When nil, redisplay article."
1089 :version
"23.1" ;; No Gnus
1090 :group
'gnus-article-mime
1091 :type
'(choice (const nil
:tag
"Redisplay article.")
1092 (const 1 :tag
"Next part.")
1093 (const 0 :tag
"Current part.")
1097 ;;; The treatment variables
1100 (defvar gnus-part-display-hook nil
1101 "Hook called on parts that are to receive treatment.")
1103 (defvar gnus-article-treat-custom
1104 '(choice (const :tag
"Off" nil
)
1106 (const :tag
"Header" head
)
1107 (const :tag
"First" first
)
1108 (const :tag
"Last" last
)
1109 (integer :tag
"Less")
1110 (repeat :tag
"Groups" regexp
)
1111 (sexp :tag
"Predicate")))
1113 (defvar gnus-article-treat-head-custom
1114 '(choice (const :tag
"Off" nil
)
1115 (const :tag
"Header" head
)))
1117 (defvar gnus-article-treat-types
'("text/plain" "text/x-verbatim"
1118 "text/x-patch" "text/html")
1119 "Part types eligible for treatment.")
1121 (defvar gnus-inhibit-treatment nil
1122 "Whether to inhibit treatment.")
1124 (defcustom gnus-treat-highlight-signature
'(or t
(typep "text/x-vcard"))
1125 "Highlight the signature.
1126 Valid values are nil, t, `head', `first', `last', an integer or a
1127 predicate. See Info node `(gnus)Customizing Articles'."
1128 :group
'gnus-article-treat
1129 :link
'(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-custom
)
1131 (put 'gnus-treat-highlight-signature
'highlight t
)
1133 (defcustom gnus-treat-buttonize
'(and 100000 (typep "text/plain"))
1135 Valid values are nil, t, `head', `first', `last', an integer or a
1136 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group
'gnus-article-treat
1138 :link
'(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom
)
1140 (put 'gnus-treat-buttonize
'highlight t
)
1142 (defcustom gnus-treat-buttonize-head
'head
1143 "Add buttons to the head.
1144 Valid values are nil, t, `head', `first', `last', an integer or a
1145 predicate. See Info node `(gnus)Customizing Articles'."
1146 :group
'gnus-article-treat
1147 :link
'(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-head-custom
)
1149 (put 'gnus-treat-buttonize-head
'highlight t
)
1151 (defcustom gnus-treat-date
'head
1152 "Display dates according to the `gnus-article-date-headers' variable.
1153 Valid values are nil, t, `head', `first', `last', an integer or a
1154 predicate. See Info node `(gnus)Customizing Articles'."
1156 :group
'gnus-article-treat
1157 :link
'(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-head-custom
)
1160 (defcustom gnus-treat-emphasize
50000
1162 Valid values are nil, t, `head', `first', `last', an integer or a
1163 predicate. See Info node `(gnus)Customizing Articles'."
1164 :group
'gnus-article-treat
1165 :link
'(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom
)
1167 (put 'gnus-treat-emphasize
'highlight t
)
1169 (defcustom gnus-treat-strip-cr nil
1170 "Remove carriage returns.
1171 Valid values are nil, t, `head', `first', `last', an integer or a
1172 predicate. See Info node `(gnus)Customizing Articles'."
1174 :group
'gnus-article-treat
1175 :link
'(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom
)
1178 (defcustom gnus-treat-unsplit-urls nil
1179 "Remove newlines from within URLs.
1180 Valid values are nil, t, `head', `first', `last', an integer or a
1181 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group
'gnus-article-treat
1184 :link
'(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom
)
1187 (defcustom gnus-treat-leading-whitespace nil
1188 "Remove leading whitespace in headers.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1192 :group
'gnus-article-treat
1193 :link
'(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-custom
)
1196 (defcustom gnus-treat-hide-headers
'head
1198 Valid values are nil, t, `head', `first', `last', an integer or a
1199 predicate. See Info node `(gnus)Customizing Articles'."
1200 :group
'gnus-article-treat
1201 :link
'(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-head-custom
)
1204 (defcustom gnus-treat-hide-boring-headers nil
1205 "Hide boring headers.
1206 Valid values are nil, t, `head', `first', `last', an integer or a
1207 predicate. See Info node `(gnus)Customizing Articles'."
1208 :group
'gnus-article-treat
1209 :link
'(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-head-custom
)
1212 (defcustom gnus-treat-hide-signature nil
1213 "Hide the signature.
1214 Valid values are nil, t, `head', `first', `last', an integer or a
1215 predicate. See Info node `(gnus)Customizing Articles'."
1216 :group
'gnus-article-treat
1217 :link
'(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-custom
)
1220 (defcustom gnus-treat-fill-article nil
1222 Valid values are nil, t, `head', `first', `last', an integer or a
1223 predicate. See Info node `(gnus)Customizing Articles'."
1224 :group
'gnus-article-treat
1225 :link
'(custom-manual "(gnus)Customizing Articles")
1226 :type gnus-article-treat-custom
)
1228 (defcustom gnus-treat-hide-citation nil
1230 Valid values are nil, t, `head', `first', `last', an integer or a
1231 predicate. See Info node `(gnus)Customizing Articles'.
1233 See `gnus-article-highlight-citation' for variables used to
1234 control what it hides."
1235 :group
'gnus-article-treat
1236 :link
'(custom-manual "(gnus)Customizing Articles")
1237 :type gnus-article-treat-custom
)
1239 (defcustom gnus-treat-hide-citation-maybe nil
1240 "Hide cited text according to certain conditions.
1241 Valid values are nil, t, `head', `first', `last', an integer or a
1242 predicate. See Info node `(gnus)Customizing Articles'.
1244 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1245 how to control what it hides."
1246 :group
'gnus-article-treat
1247 :link
'(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom
)
1250 (defcustom gnus-treat-strip-list-identifiers
'head
1251 "Strip list identifiers from `gnus-list-identifiers'.
1252 Valid values are nil, t, `head', `first', `last', an integer or a
1253 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group
'gnus-article-treat
1256 :link
'(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom
)
1259 (gnus-define-group-parameter
1262 "Alist of regexps and correspondent identifiers."
1263 :variable-group gnus-article-washing
1265 '(choice :tag
"Identifier"
1267 (symbol :tag
"Item in `gnus-list-identifiers'" none
)
1269 (const :tag
"None" nil
))
1271 "If non-nil, specify how to remove `identifiers' from articles' subject.
1273 Any symbol is used to look up a regular expression to match the
1274 banner in `gnus-list-identifiers'. A string is used as a regular
1275 expression to match the identifier directly.")
1277 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1278 "Gnus 5.10 (Emacs 22.1)")
1280 (defcustom gnus-treat-strip-pem nil
1281 "Strip PEM signatures.
1282 Valid values are nil, t, `head', `first', `last', an integer or a
1283 predicate. See Info node `(gnus)Customizing Articles'."
1284 :group
'gnus-article-treat
1285 :link
'(custom-manual "(gnus)Customizing Articles")
1286 :type gnus-article-treat-custom
)
1288 (defcustom gnus-treat-strip-banner t
1289 "Strip banners from articles.
1290 The banner to be stripped is specified in the `banner' group parameter.
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1293 :group
'gnus-article-treat
1294 :link
'(custom-manual "(gnus)Customizing Articles")
1295 :type gnus-article-treat-custom
)
1297 (defcustom gnus-treat-highlight-headers
'head
1298 "Highlight the headers.
1299 Valid values are nil, t, `head', `first', `last', an integer or a
1300 predicate. See Info node `(gnus)Customizing Articles'."
1301 :group
'gnus-article-treat
1302 :link
'(custom-manual "(gnus)Customizing Articles")
1303 :type gnus-article-treat-head-custom
)
1304 (put 'gnus-treat-highlight-headers
'highlight t
)
1306 (defcustom gnus-treat-highlight-citation t
1307 "Highlight cited text.
1308 Valid values are nil, t, `head', `first', `last', an integer or a
1309 predicate. See Info node `(gnus)Customizing Articles'."
1310 :group
'gnus-article-treat
1311 :link
'(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-custom
)
1313 (put 'gnus-treat-highlight-citation
'highlight t
)
1315 (defcustom gnus-treat-strip-headers-in-body t
1316 "Strip the X-No-Archive header line from the beginning of the body.
1317 Valid values are nil, t, `head', `first', `last', an integer or a
1318 predicate. See Info node `(gnus)Customizing Articles'."
1320 :group
'gnus-article-treat
1321 :link
'(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom
)
1324 (defcustom gnus-treat-strip-trailing-blank-lines nil
1325 "Strip trailing blank lines.
1326 Valid values are nil, t, `head', `first', `last', an integer or a
1327 predicate. See Info node `(gnus)Customizing Articles'.
1329 When set to t, it also strips trailing blanks in all MIME parts.
1330 Consider to use `last' instead."
1331 :group
'gnus-article-treat
1332 :link
'(custom-manual "(gnus)Customizing Articles")
1333 :type gnus-article-treat-custom
)
1335 (defcustom gnus-treat-strip-leading-blank-lines nil
1336 "Strip leading blank lines.
1337 Valid values are nil, t, `head', `first', `last', an integer or a
1338 predicate. See Info node `(gnus)Customizing Articles'.
1340 When set to t, it also strips trailing blanks in all MIME parts."
1341 :group
'gnus-article-treat
1342 :link
'(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom
)
1345 (defcustom gnus-treat-strip-multiple-blank-lines nil
1346 "Strip multiple blank lines.
1347 Valid values are nil, t, `head', `first', `last', an integer or a
1348 predicate. See Info node `(gnus)Customizing Articles'."
1349 :group
'gnus-article-treat
1350 :link
'(custom-manual "(gnus)Customizing Articles")
1351 :type gnus-article-treat-custom
)
1353 (defcustom gnus-treat-unfold-headers
'head
1354 "Unfold folded header lines.
1355 Valid values are nil, t, `head', `first', `last', an integer or a
1356 predicate. See Info node `(gnus)Customizing Articles'."
1358 :group
'gnus-article-treat
1359 :link
'(custom-manual "(gnus)Customizing Articles")
1360 :type gnus-article-treat-custom
)
1362 (defcustom gnus-article-unfold-long-headers nil
1363 "If non-nil, allow unfolding headers even if the header is long.
1364 If it is a regexp, only long headers matching this regexp are unfolded.
1365 If it is t, all long headers are unfolded.
1367 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1368 :version
"23.1" ;; No Gnus
1369 :group
'gnus-article-treat
1370 :type
'(choice (const nil
)
1371 (const :tag
"all" t
)
1374 (defcustom gnus-treat-fold-headers nil
1376 Valid values are nil, t, `head', `first', `last', an integer or a
1377 predicate. See Info node `(gnus)Customizing Articles'."
1379 :group
'gnus-article-treat
1380 :link
'(custom-manual "(gnus)Customizing Articles")
1381 :type gnus-article-treat-custom
)
1383 (defcustom gnus-treat-fold-newsgroups
'head
1384 "Fold the Newsgroups and Followup-To headers.
1385 Valid values are nil, t, `head', `first', `last', an integer or a
1386 predicate. See Info node `(gnus)Customizing Articles'."
1388 :group
'gnus-article-treat
1389 :link
'(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom
)
1392 (defcustom gnus-treat-overstrike t
1393 "Treat overstrike highlighting.
1394 Valid values are nil, t, `head', `first', `last', an integer or a
1395 predicate. See Info node `(gnus)Customizing Articles'."
1396 :group
'gnus-article-treat
1397 :link
'(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom
)
1399 (put 'gnus-treat-overstrike
'highlight t
)
1401 (defcustom gnus-treat-ansi-sequences t
1402 "Treat ANSI SGR control sequences.
1403 Valid values are nil, t, `head', `first', `last', an integer or a
1404 predicate. See Info node `(gnus)Customizing Articles'."
1405 :group
'gnus-article-treat
1406 :link
'(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom
)
1409 (make-obsolete-variable 'gnus-treat-display-xface
1410 'gnus-treat-display-x-face
"Emacs 22.1")
1412 (defcustom gnus-treat-display-x-face
1413 (and (not noninteractive
)
1414 (gnus-image-type-available-p 'xbm
)
1416 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1417 (executable-find "icontopbm"))
1418 ;; shell-command-to-string may signal an error, e.g. if
1419 ;; shell-file-name is not found.
1422 "Display X-Face headers.
1423 Valid values are nil and `head'.
1424 See Info node `(gnus)Customizing Articles' and Info node
1425 `(gnus)X-Face' for details."
1426 :group
'gnus-article-treat
1428 :link
'(custom-manual "(gnus)Customizing Articles")
1429 :link
'(custom-manual "(gnus)X-Face")
1430 :type gnus-article-treat-head-custom
1431 :set
(lambda (symbol value
)
1434 (cond ((or (boundp symbol
) (get symbol
'saved-value
))
1436 ((boundp 'gnus-treat-display-xface
)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (default-value 'gnus-treat-display-xface
))
1441 ((get 'gnus-treat-display-xface
'saved-value
)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (eval (car (get 'gnus-treat-display-xface
'saved-value
))))
1448 (put 'gnus-treat-display-x-face
'highlight t
)
1450 (defcustom gnus-treat-display-face
1451 (and (not noninteractive
)
1452 (gnus-image-type-available-p 'png
)
1454 "Display Face headers.
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles' and Info
1457 node `(gnus)Face' for details."
1458 :group
'gnus-article-treat
1460 :link
'(custom-manual "(gnus)Customizing Articles")
1461 :link
'(custom-manual "(gnus)X-Face")
1462 :type gnus-article-treat-head-custom
)
1463 (put 'gnus-treat-display-face
'highlight t
)
1465 (defcustom gnus-treat-display-smileys
(gnus-image-type-available-p 'xpm
)
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Smileys' for details."
1470 :group
'gnus-article-treat
1472 :link
'(custom-manual "(gnus)Customizing Articles")
1473 :link
'(custom-manual "(gnus)Smileys")
1474 :type gnus-article-treat-custom
)
1475 (put 'gnus-treat-display-smileys
'highlight t
)
1477 (defcustom gnus-treat-from-picon
1478 (if (and (gnus-image-type-available-p 'xpm
)
1479 (gnus-picons-installed-p))
1481 "Display picons in the From header.
1482 Valid values are nil, t, `head', `first', `last', an integer or a
1483 predicate. See Info node `(gnus)Customizing Articles' and Info
1484 node `(gnus)Picons' for details."
1486 :group
'gnus-article-treat
1488 :link
'(custom-manual "(gnus)Customizing Articles")
1489 :link
'(custom-manual "(gnus)Picons")
1490 :type gnus-article-treat-head-custom
)
1491 (put 'gnus-treat-from-picon
'highlight t
)
1493 (defcustom gnus-treat-mail-picon
1494 (if (and (gnus-image-type-available-p 'xpm
)
1495 (gnus-picons-installed-p))
1497 "Display picons in To and Cc headers.
1498 Valid values are nil, t, `head', `first', `last', an integer or a
1499 predicate. See Info node `(gnus)Customizing Articles' and Info
1500 node `(gnus)Picons' for details."
1502 :group
'gnus-article-treat
1504 :link
'(custom-manual "(gnus)Customizing Articles")
1505 :link
'(custom-manual "(gnus)Picons")
1506 :type gnus-article-treat-head-custom
)
1507 (put 'gnus-treat-mail-picon
'highlight t
)
1509 (defcustom gnus-treat-newsgroups-picon
1510 (if (and (gnus-image-type-available-p 'xpm
)
1511 (gnus-picons-installed-p))
1513 "Display picons in the Newsgroups and Followup-To headers.
1514 Valid values are nil, t, `head', `first', `last', an integer or a
1515 predicate. See Info node `(gnus)Customizing Articles' and Info
1516 node `(gnus)Picons' for details."
1518 :group
'gnus-article-treat
1520 :link
'(custom-manual "(gnus)Customizing Articles")
1521 :link
'(custom-manual "(gnus)Picons")
1522 :type gnus-article-treat-head-custom
)
1523 (put 'gnus-treat-newsgroups-picon
'highlight t
)
1525 (defcustom gnus-treat-from-gravatar nil
1526 "Display gravatars in the From header.
1527 Valid values are nil, t, `head', `first', `last', an integer or a
1528 predicate. See Info node `(gnus)Customizing Articles' and Info
1529 node `(gnus)Gravatars' for details."
1531 :group
'gnus-article-treat
1532 :group
'gnus-gravatar
1533 :link
'(custom-manual "(gnus)Customizing Articles")
1534 :link
'(custom-manual "(gnus)Gravatars")
1535 :type gnus-article-treat-head-custom
)
1536 (put 'gnus-treat-from-gravatar
'highlight t
)
1538 (defcustom gnus-treat-mail-gravatar nil
1539 "Display gravatars in To and Cc headers.
1540 Valid values are nil, t, `head', `first', `last', an integer or a
1541 predicate. See Info node `(gnus)Customizing Articles' and Info
1542 node `(gnus)Gravatars' for details."
1544 :group
'gnus-article-treat
1545 :group
'gnus-gravatar
1546 :link
'(custom-manual "(gnus)Customizing Articles")
1547 :link
'(custom-manual "(gnus)Gravatars")
1548 :type gnus-article-treat-head-custom
)
1549 (put 'gnus-treat-mail-gravatar
'highlight t
)
1551 (defcustom gnus-treat-body-boundary
1552 (if (or gnus-treat-newsgroups-picon
1553 gnus-treat-mail-picon
1554 gnus-treat-from-picon
1555 gnus-treat-from-gravatar
1556 gnus-treat-mail-gravatar
)
1557 ;; If there's much decoration, the user might prefer a boundary.
1560 "Draw a boundary at the end of the headers.
1561 Valid values are nil and `head'.
1562 See Info node `(gnus)Customizing Articles' for details."
1564 :group
'gnus-article-treat
1565 :link
'(custom-manual "(gnus)Customizing Articles")
1566 :type gnus-article-treat-head-custom
)
1568 (defcustom gnus-treat-capitalize-sentences nil
1569 "Capitalize sentence-starting words.
1570 Valid values are nil, t, `head', `first', `last', an integer or a
1571 predicate. See Info node `(gnus)Customizing Articles'."
1573 :group
'gnus-article-treat
1574 :link
'(custom-manual "(gnus)Customizing Articles")
1575 :type gnus-article-treat-custom
)
1577 (defcustom gnus-treat-wash-html nil
1579 Valid values are nil, t, `head', `first', `last', an integer or a
1580 predicate. See Info node `(gnus)Customizing Articles'."
1582 :group
'gnus-article-treat
1583 :link
'(custom-manual "(gnus)Customizing Articles")
1584 :type gnus-article-treat-custom
)
1586 (defcustom gnus-treat-fill-long-lines
'(typep "text/plain")
1588 Valid values are nil, t, `head', `first', `last', an integer or a
1589 predicate. See Info node `(gnus)Customizing Articles'."
1591 :group
'gnus-article-treat
1592 :link
'(custom-manual "(gnus)Customizing Articles")
1593 :type gnus-article-treat-custom
)
1595 (defcustom gnus-treat-x-pgp-sig nil
1597 To automatically treat X-PGP-Sig, set it to head.
1598 Valid values are nil, t, `head', `first', `last', an integer or a
1599 predicate. See Info node `(gnus)Customizing Articles'."
1601 :group
'gnus-article-treat
1602 :group
'mime-security
1603 :link
'(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom
)
1606 (defvar gnus-article-encrypt-protocol-alist
1607 '(("PGP" . mml2015-self-encrypt
)))
1609 ;; Set to nil if more than one protocol added to
1610 ;; gnus-article-encrypt-protocol-alist.
1611 (defcustom gnus-article-encrypt-protocol
"PGP"
1612 "The protocol used for encrypt articles.
1613 It is a string, such as \"PGP\". If nil, ask user."
1616 :group
'mime-security
)
1618 (defcustom gnus-use-idna t
1619 "Whether IDNA decoding of headers is used when viewing messages."
1621 :group
'gnus-article-headers
1624 (defcustom gnus-article-over-scroll nil
1625 "If non-nil, allow scrolling the article buffer even when there no more text."
1627 :group
'gnus-article
1630 (defcustom gnus-inhibit-images nil
1631 "Non-nil means inhibit displaying of images inline in the article body."
1633 :group
'gnus-article
1636 (defcustom gnus-blocked-images
'gnus-block-private-groups
1637 "Images that have URLs matching this regexp will be blocked.
1638 This can also be a function to be evaluated. If so, it will be
1639 called with the group name as the parameter, and should return a
1643 :type
'(choice (const :tag
"Allow all" nil
)
1644 (regexp :tag
"Regular expression")
1645 (function :tag
"Use a function")))
1647 ;;; Internal variables
1649 (defvar gnus-english-month-names
1650 '("January" "February" "March" "April" "May" "June" "July" "August"
1651 "September" "October" "November" "December"))
1653 (defvar article-goto-body-goes-to-point-min-p nil
)
1654 (defvar gnus-article-wash-types nil
)
1655 (defvar gnus-article-emphasis-alist nil
)
1656 (defvar gnus-article-image-alist nil
)
1658 (defvar gnus-article-mime-handle-alist-1 nil
)
1659 (defvar gnus-treatment-function-alist
1660 '((gnus-treat-strip-cr gnus-article-remove-cr
)
1661 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig
)
1662 (gnus-treat-strip-banner gnus-article-strip-banner
)
1663 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1664 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1665 (gnus-treat-buttonize gnus-article-add-buttons
)
1666 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1667 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines
)
1668 (gnus-treat-unsplit-urls gnus-article-unsplit-urls
)
1669 (gnus-treat-display-x-face gnus-article-display-x-face
)
1670 (gnus-treat-display-face gnus-article-display-face
)
1671 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1672 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1673 (gnus-treat-hide-signature gnus-article-hide-signature
)
1674 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1675 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace
)
1676 (gnus-treat-from-picon gnus-treat-from-picon
)
1677 (gnus-treat-mail-picon gnus-treat-mail-picon
)
1678 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon
)
1679 (gnus-treat-strip-pem gnus-article-hide-pem
)
1680 (gnus-treat-date gnus-article-treat-date
)
1681 (gnus-treat-from-gravatar gnus-treat-from-gravatar
)
1682 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar
)
1683 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1684 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1685 (gnus-treat-strip-trailing-blank-lines
1686 gnus-article-remove-trailing-blank-lines
)
1687 (gnus-treat-strip-leading-blank-lines
1688 gnus-article-strip-leading-blank-lines
)
1689 (gnus-treat-strip-multiple-blank-lines
1690 gnus-article-strip-multiple-blank-lines
)
1691 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1692 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences
)
1693 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers
)
1694 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups
)
1695 (gnus-treat-fold-headers gnus-article-treat-fold-headers
)
1696 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1697 (gnus-treat-display-smileys gnus-treat-smiley
)
1698 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1699 (gnus-treat-wash-html gnus-article-wash-html
)
1700 (gnus-treat-emphasize gnus-article-emphasize
)
1701 (gnus-treat-hide-citation gnus-article-hide-citation
)
1702 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1703 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1704 (gnus-treat-body-boundary gnus-article-treat-body-boundary
)))
1706 (defvar gnus-article-mime-handle-alist nil
)
1707 (defvar article-lapsed-timer nil
)
1708 (defvar gnus-article-current-summary nil
)
1710 (defvar gnus-article-mode-syntax-table
1711 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1712 ;; This causes the citation match run O(2^n).
1713 ;; (modify-syntax-entry ?- "w" table)
1714 (modify-syntax-entry ?
> ")<" table
)
1715 (modify-syntax-entry ?
< "(>" table
)
1716 ;; make M-. in article buffers work for `foo' strings
1717 (modify-syntax-entry ?
' " " table
)
1718 (modify-syntax-entry ?
` " " table
)
1720 "Syntax table used in article mode buffers.
1721 Initialized from `text-mode-syntax-table'.")
1723 (defvar gnus-save-article-buffer nil
)
1725 (defvar gnus-number-of-articles-to-be-saved nil
)
1727 (defvar gnus-inhibit-hiding nil
)
1729 (defvar gnus-article-edit-mode nil
)
1731 ;;; Macros for dealing with the article buffer.
1733 (defmacro gnus-with-article-headers
(&rest forms
)
1734 `(with-current-buffer gnus-article-buffer
1736 (let ((inhibit-read-only t
)
1737 (inhibit-point-motion-hooks t
)
1738 (case-fold-search t
))
1739 (article-narrow-to-head)
1742 (put 'gnus-with-article-headers
'lisp-indent-function
0)
1743 (put 'gnus-with-article-headers
'edebug-form-spec
'(body))
1745 (defmacro gnus-with-article-buffer
(&rest forms
)
1746 `(when (buffer-live-p (get-buffer gnus-article-buffer
))
1747 (with-current-buffer gnus-article-buffer
1748 (let ((inhibit-read-only t
))
1751 (put 'gnus-with-article-buffer
'lisp-indent-function
0)
1752 (put 'gnus-with-article-buffer
'edebug-form-spec
'(body))
1754 (defun gnus-article-goto-header (header)
1755 "Go to HEADER, which is a regular expression."
1756 (re-search-forward (concat "^\\(" header
"\\):") nil t
))
1758 (defsubst gnus-article-hide-text
(b e props
)
1759 "Set text PROPS on the B to E region."
1760 (gnus-add-text-properties-when 'article-type nil b e props
))
1762 (defsubst gnus-article-unhide-text
(b e
)
1763 "Remove hidden text properties from region between B and E."
1764 (remove-text-properties b e gnus-hidden-properties
))
1766 (defun gnus-article-hide-text-type (b e type
)
1767 "Hide text of TYPE between B and E."
1768 (gnus-add-wash-type type
)
1769 (gnus-article-hide-text
1770 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1772 (defun gnus-article-unhide-text-type (b e type
)
1773 "Unhide text of TYPE between B and E."
1774 (gnus-delete-wash-type type
)
1775 (remove-text-properties
1776 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1778 (defun gnus-article-delete-text-of-type (type)
1779 "Delete text of TYPE in the current buffer."
1781 (let ((b (point-min)))
1782 (if (eq type
'multipart
)
1783 ;; Remove MIME buttons associated with multipart/alternative parts.
1786 (while (if (get-text-property (point) 'gnus-part
)
1788 (when (setq b
(next-single-property-change (point)
1793 (skip-chars-forward "\n")
1794 (when (eq (get-text-property b
'article-type
) 'multipart
)
1795 (delete-region b
(point)))))
1796 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1798 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1801 (defun gnus-article-delete-invisible-text ()
1802 "Delete all invisible text in the current buffer."
1804 (let ((b (point-min)))
1805 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1807 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1810 (defsubst gnus-article-header-rank
()
1811 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1812 (let ((list gnus-sorted-header-list
)
1815 (if (looking-at (car list
))
1817 (setq list
(cdr list
))
1821 (defun article-hide-headers (&optional _arg _delete
)
1822 "Hide unwanted headers and possibly sort them as well."
1824 ;; This function might be inhibited.
1825 (unless gnus-inhibit-hiding
1826 (let ((inhibit-read-only t
)
1827 (case-fold-search t
)
1828 (max (1+ (length gnus-sorted-header-list
)))
1829 (inhibit-point-motion-hooks t
)
1830 (cur (current-buffer))
1831 ignored visible beg
)
1833 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1834 ;; group parameters, so we should go to the summary buffer.
1837 (progn (set-buffer gnus-summary-buffer
) t
)
1839 (setq ignored
(when (not gnus-visible-headers
)
1840 (cond ((stringp gnus-ignored-headers
)
1841 gnus-ignored-headers
)
1842 ((listp gnus-ignored-headers
)
1843 (mapconcat 'identity
1844 gnus-ignored-headers
1846 visible
(cond ((stringp gnus-visible-headers
)
1847 gnus-visible-headers
)
1848 ((and gnus-visible-headers
1849 (listp gnus-visible-headers
))
1850 (mapconcat 'identity
1851 gnus-visible-headers
1855 ;; First we narrow to just the headers.
1856 (article-narrow-to-head)
1857 ;; Hide any "From " lines at the beginning of (mail) articles.
1858 (while (looking-at "From ")
1861 (delete-region (point-min) (point)))
1862 ;; Then treat the rest of the header lines.
1863 ;; Then we use the two regular expressions
1864 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1865 ;; select which header lines is to remain visible in the
1867 (while (re-search-forward "^[^ \t:]*:" nil t
)
1869 ;; Mark the rank of the header.
1871 (point) (1+ (point)) 'message-rank
1872 (if (or (and visible
(looking-at visible
))
1874 (not (looking-at ignored
))))
1875 (gnus-article-header-rank)
1878 (message-sort-headers-1)
1879 (when (setq beg
(text-property-any
1880 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1881 ;; We delete the unwanted headers.
1882 (gnus-add-wash-type 'headers
)
1883 (add-text-properties (point-min) (+ 5 (point-min))
1884 '(article-type headers dummy-invisible t
))
1885 (delete-region beg
(point-max))))))))
1887 (defun article-hide-boring-headers (&optional arg
)
1888 "Toggle hiding of headers that aren't very interesting.
1889 If given a negative prefix, always show; if given a positive prefix,
1891 (interactive (gnus-article-hidden-arg))
1892 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1893 (not gnus-show-all-headers
))
1896 (let ((inhibit-read-only t
)
1897 (inhibit-point-motion-hooks t
))
1898 (article-narrow-to-head)
1899 (dolist (elem gnus-boring-article-headers
)
1900 (goto-char (point-min))
1902 ;; Hide empty headers.
1904 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1906 (gnus-article-hide-text-type
1910 (if (re-search-forward "^[^ \t]" nil t
)
1914 ;; Hide boring Newsgroups header.
1915 ((eq elem
'newsgroups
)
1916 (when (gnus-string-equal
1917 (gnus-fetch-field "newsgroups")
1918 (gnus-group-real-name
1919 (if (boundp 'gnus-newsgroup-name
)
1922 (gnus-article-hide-header "newsgroups")))
1923 ((eq elem
'to-address
)
1924 (let ((to (message-fetch-field "to"))
1926 (gnus-parameter-to-address
1927 (if (boundp 'gnus-newsgroup-name
)
1928 gnus-newsgroup-name
""))))
1929 (when (and to to-address
1932 ;; only one address in To
1933 (nth 1 (mail-extract-address-components to
))
1935 (gnus-article-hide-header "to"))))
1937 (let ((to (message-fetch-field "to"))
1939 (gnus-parameter-to-list
1940 (if (boundp 'gnus-newsgroup-name
)
1941 gnus-newsgroup-name
""))))
1942 (when (and to to-list
1945 ;; only one address in To
1946 (nth 1 (mail-extract-address-components to
))
1948 (gnus-article-hide-header "to"))))
1950 (let ((cc (message-fetch-field "cc"))
1952 (gnus-parameter-to-list
1953 (if (boundp 'gnus-newsgroup-name
)
1954 gnus-newsgroup-name
""))))
1955 (when (and cc to-list
1958 ;; only one address in CC
1959 (nth 1 (mail-extract-address-components cc
))
1961 (gnus-article-hide-header "cc"))))
1962 ((eq elem
'followup-to
)
1963 (when (gnus-string-equal
1964 (message-fetch-field "followup-to")
1965 (message-fetch-field "newsgroups"))
1966 (gnus-article-hide-header "followup-to")))
1967 ((eq elem
'reply-to
)
1968 (if (gnus-group-find-parameter
1969 gnus-newsgroup-name
'broken-reply-to
)
1970 (gnus-article-hide-header "reply-to")
1971 (let ((from (message-fetch-field "from"))
1972 (reply-to (message-fetch-field "reply-to")))
1979 (lambda (x) (downcase (cadr x
)))
1980 (mail-extract-address-components from t
))
1983 (lambda (x) (downcase (cadr x
)))
1984 (mail-extract-address-components reply-to t
))
1986 (gnus-article-hide-header "reply-to")))))
1988 (let ((date (with-current-buffer gnus-original-article-buffer
1989 ;; If date in `gnus-article-buffer' is localized
1990 ;; (`gnus-treat-date-user-defined'),
1991 ;; `days-between' might fail.
1992 (message-fetch-field "date"))))
1994 (< (days-between (current-time-string) date
)
1996 (gnus-article-hide-header "date"))))
1998 (let ((to (message-fetch-field "to"))
1999 (cc (message-fetch-field "cc")))
2000 (when (> (length to
) 1024)
2001 (gnus-article-hide-header "to"))
2002 (when (> (length cc
) 1024)
2003 (gnus-article-hide-header "cc"))))
2007 (goto-char (point-min))
2008 (while (re-search-forward "^to:" nil t
)
2009 (setq to-count
(1+ to-count
)))
2010 (when (> to-count
1)
2011 (while (> to-count
0)
2012 (goto-char (point-min))
2014 (re-search-forward "^to:" nil nil to-count
)
2016 (narrow-to-region (point) (point-max))
2017 (gnus-article-hide-header "to"))
2018 (setq to-count
(1- to-count
))))
2019 (goto-char (point-min))
2020 (while (re-search-forward "^cc:" nil t
)
2021 (setq cc-count
(1+ cc-count
)))
2022 (when (> cc-count
1)
2023 (while (> cc-count
0)
2024 (goto-char (point-min))
2026 (re-search-forward "^cc:" nil nil cc-count
)
2028 (narrow-to-region (point) (point-max))
2029 (gnus-article-hide-header "cc"))
2030 (setq cc-count
(1- cc-count
)))))))))))))
2032 (defun gnus-article-hide-header (header)
2034 (goto-char (point-min))
2035 (when (re-search-forward (concat "^" header
":") nil t
)
2036 (gnus-article-hide-text-type
2040 (if (re-search-forward "^[^ \t]" nil t
)
2045 (defvar gnus-article-normalized-header-length
40
2046 "Length of normalized headers.")
2048 (defun article-normalize-headers ()
2049 "Make all header lines 40 characters long."
2051 (let ((inhibit-read-only t
)
2055 (article-narrow-to-head)
2058 ((< (setq column
(- (point-at-eol) (point)))
2059 gnus-article-normalized-header-length
)
2061 (insert (make-string
2062 (- gnus-article-normalized-header-length column
)
2064 ((> column gnus-article-normalized-header-length
)
2067 (forward-char gnus-article-normalized-header-length
)
2074 (forward-line 1))))))
2076 (defun article-treat-dumbquotes ()
2077 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2078 Note that this function guesses whether a character is a sm*rtq**t* or
2079 not, so it should only be used interactively.
2081 Sm*rtq**t*s are M****s***'s unilateral extension to the
2082 iso-8859-1 character map in an attempt to provide more quoting
2083 characters. If you see something like \\222 or \\264 where
2084 you're expecting some kind of apostrophe or quotation mark, then
2087 (article-translate-strings gnus-article-dumbquotes-map
))
2089 (defvar org-entities
)
2091 (defun article-treat-non-ascii ()
2092 "Translate many Unicode characters into their ASCII equivalents."
2094 (require 'org-entities
)
2095 (let ((table (make-char-table nil
)))
2096 (dolist (elem org-entities
)
2097 (when (and (listp elem
)
2098 (= (length (nth 6 elem
)) 1))
2099 (set-char-table-range table
(aref (nth 6 elem
) 0) (nth 4 elem
))))
2101 (when (article-goto-body)
2102 (let ((inhibit-read-only t
)
2105 (if (not (setq replace
(aref table
(following-char))))
2108 (setq props
(text-properties-at (point)))
2110 (add-text-properties (point) (progn (insert replace
) (point))
2112 (insert replace
)))))))))
2114 (defun article-translate-strings (map)
2115 "Translate all string in the body of the article according to MAP.
2116 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2118 (when (article-goto-body)
2119 (let ((inhibit-read-only t
))
2121 (let ((from (car elem
))
2125 (while (search-forward from nil t
)
2128 (if (eq (following-char) from
)
2132 (forward-char 1)))))))))))
2134 (defun article-treat-overstrike ()
2135 "Translate overstrikes into bold text."
2138 (when (article-goto-body)
2139 (let ((inhibit-read-only t
))
2140 (while (search-forward "\b" nil t
)
2141 (let ((next (char-after))
2142 (previous (char-after (- (point) 2))))
2143 ;; We do the boldification/underlining by hiding the
2144 ;; overstrikes and putting the proper text property
2148 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2149 (put-text-property (point) (1+ (point)) 'face
'bold
))
2151 (gnus-article-hide-text-type
2152 (1- (point)) (1+ (point)) 'overstrike
)
2154 (- (point) 2) (1- (point)) 'face
'underline
))
2156 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
2158 (point) (1+ (point)) 'face
'underline
)))))))))
2160 (defun article-treat-ansi-sequences ()
2161 "Translate ANSI SGR control sequences into overlays or extents."
2164 (when (article-goto-body)
2165 (let ((inhibit-read-only t
))
2166 (ansi-color-apply-on-region (point) (point-max))))))
2168 (defun gnus-article-treat-unfold-headers ()
2169 "Unfold folded message headers.
2170 Only the headers that fit into the current window width will be
2173 (gnus-with-article-headers
2177 (mail-header-narrow-to-field)
2178 (let* ((header (buffer-string))
2180 (or (equal gnus-article-unfold-long-headers t
)
2181 (and (stringp gnus-article-unfold-long-headers
)
2182 (string-match gnus-article-unfold-long-headers
2186 (goto-char (point-min))
2187 (while (re-search-forward "\n[\t ]" nil t
)
2188 (replace-match " " t t
)))
2189 (setq length
(- (point-max) (point-min) 1))
2190 (when (or unfoldable
2191 (< length
(window-width)))
2192 (while (re-search-forward "\n[\t ]" nil t
)
2193 (replace-match " " t t
))))
2194 (goto-char (point-max)))))))
2196 (defun gnus-article-treat-fold-headers ()
2197 "Fold message headers."
2199 (gnus-with-article-headers
2202 (mail-header-narrow-to-field)
2203 (mail-header-fold-field)
2204 (goto-char (point-max))))))
2206 (defun gnus-treat-smiley ()
2207 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2209 (gnus-with-article-buffer
2210 (if (memq 'smiley gnus-article-wash-types
)
2211 (gnus-delete-images 'smiley
)
2213 (let ((images (smiley-region (point) (point-max))))
2215 (gnus-add-wash-type 'smiley
)
2216 (dolist (image images
)
2217 (gnus-add-image 'smiley image
)))))))
2219 (defun gnus-article-remove-images ()
2220 "Remove all images from the article buffer."
2222 (gnus-with-article-buffer
2225 (dolist (elem gnus-article-image-alist
)
2226 (gnus-delete-images (car elem
))))))
2228 (autoload 'w3m-toggle-inline-images
"w3m")
2230 (defun gnus-article-show-images ()
2231 "Show any images that are in the HTML-rendered article buffer.
2232 This only works if the article in question is HTML."
2234 (gnus-with-article-buffer
2237 (if (eq mm-text-html-renderer
'w3m
)
2238 (w3m-toggle-inline-images)
2239 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2241 (destructuring-bind (start end function
) region
2242 (funcall function
(get-text-property start
'image-url
)
2245 (defun gnus-article-treat-fold-newsgroups ()
2246 "Unfold folded message headers.
2247 Only the headers that fit into the current window width will be
2250 (gnus-with-article-headers
2251 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2253 (mail-header-narrow-to-field)
2254 (while (re-search-forward ", *" nil t
)
2255 (replace-match ", " t t
))
2256 (mail-header-fold-field)
2257 (goto-char (point-max))))))
2259 (defcustom gnus-article-truncate-lines
(default-value 'truncate-lines
)
2260 "Value of `truncate-lines' in Gnus Article buffer.
2261 Valid values are nil, t, `head', `first', `last', an integer or a
2262 predicate. See Info node `(gnus)Customizing Articles'."
2263 :version
"23.1" ;; No Gnus
2264 :group
'gnus-article
2265 ;; :link '(custom-manual "(gnus)Customizing Articles")
2268 (defun gnus-article-toggle-truncate-lines (&optional arg
)
2269 "Toggle whether to fold or truncate long lines in article the buffer.
2270 If ARG is non-nil and not a number, toggle
2271 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2272 long lines if and only if arg is positive."
2275 ((and (numberp arg
) (> arg
0))
2276 (setq gnus-article-truncate-lines t
))
2278 (setq gnus-article-truncate-lines nil
))
2280 (setq gnus-article-truncate-lines
2281 (not gnus-article-truncate-lines
))))
2282 (gnus-with-article-buffer
2284 ((and (numberp arg
) (> arg
0))
2285 (setq truncate-lines nil
))
2287 (setq truncate-lines t
)))
2288 (toggle-truncate-lines)))
2290 (defun gnus-article-treat-body-boundary ()
2291 "Place a boundary line at the end of the headers."
2293 (when (and gnus-body-boundary-delimiter
2294 (> (length gnus-body-boundary-delimiter
) 0))
2295 (gnus-with-article-headers
2296 (goto-char (point-max))
2297 (let ((start (point)))
2298 (insert "X-Boundary: ")
2299 (add-text-properties start
(point) gnus-hidden-properties
)
2300 (insert (let (str (max (window-width)))
2301 (while (>= max
(length str
))
2302 (setq str
(concat str gnus-body-boundary-delimiter
)))
2303 (substring str
0 max
))
2305 (put-text-property start
(point) 'gnus-decoration
'header
)))))
2307 (defun article-fill-long-lines ()
2308 "Fill lines that are wider than the window width."
2311 (let ((inhibit-read-only t
)
2312 (width (window-width (get-buffer-window (current-buffer)))))
2315 (let ((adaptive-fill-mode nil
)) ;Why? -sm
2318 (when (>= (current-column) (min fill-column width
))
2319 (narrow-to-region (min (1+ (point)) (point-max))
2321 (let ((goback (point-marker)))
2322 (fill-paragraph nil
)
2323 (goto-char (marker-position goback
)))
2325 (forward-line 1)))))))
2327 (defun article-capitalize-sentences ()
2328 "Capitalize the first word in each sentence."
2331 (let ((inhibit-read-only t
)
2332 (paragraph-start "^[\n\^L]"))
2336 (forward-sentence)))))
2338 (defun article-remove-cr ()
2339 "Remove trailing CRs and then translate remaining CRs into LFs."
2342 (let ((inhibit-read-only t
))
2343 (goto-char (point-min))
2344 (while (re-search-forward "\r+$" nil t
)
2345 (replace-match "" t t
))
2346 (goto-char (point-min))
2347 (while (search-forward "\r" nil t
)
2348 (replace-match "\n" t t
)))))
2350 (defun article-remove-trailing-blank-lines ()
2351 "Remove all trailing blank lines from the article."
2354 (let ((inhibit-read-only t
))
2355 (goto-char (point-max))
2359 (while (and (not (bobp))
2360 (looking-at "^[ \t]*$")
2361 (not (gnus-annotation-in-region-p
2362 (point) (point-at-eol))))
2367 (defvar gnus-face-properties-alist
)
2369 (defun article-display-face (&optional force
)
2370 "Display any Face headers in the header."
2371 (interactive (list 'force
))
2372 (let ((wash-face-p buffer-read-only
))
2373 (gnus-with-article-headers
2374 ;; When displaying parts, this function can be called several times on
2375 ;; the same article, without any intended toggle semantic (as typing `W
2376 ;; D d' would have). So face deletion must occur only when we come from
2377 ;; an interactive command, that is when the *Article* buffer is
2379 (if (and wash-face-p
(memq 'face gnus-article-wash-types
))
2380 (gnus-delete-images 'face
)
2381 (let ((from (message-fetch-field "from"))
2383 (save-current-buffer
2384 (when (and wash-face-p
2385 (gnus-buffer-live-p gnus-original-article-buffer
)
2386 (not (re-search-forward "^Face:[\t ]*" nil t
)))
2387 (set-buffer gnus-original-article-buffer
))
2389 (mail-narrow-to-head)
2391 ;; Check whether this face is censored.
2392 (not (and gnus-article-x-face-too-ugly
2394 (setq from
(message-fetch-field "from")))
2395 (string-match gnus-article-x-face-too-ugly
2397 (while (gnus-article-goto-header "Face")
2398 (push (mail-header-field-value) faces
)))))
2400 (goto-char (point-min))
2402 (unless (setq from
(gnus-article-goto-header "from"))
2405 (insert " [no 'from' set]\n"))
2407 (when (setq png
(gnus-convert-face-to-png (pop faces
)))
2409 (apply 'gnus-create-image png
'png t
2410 (cdr (assq 'png gnus-face-properties-alist
))))
2413 (gnus-add-wash-type 'face
)
2414 (gnus-add-image 'face image
)
2415 (gnus-put-image image nil
'face
)))))))))))
2417 (defun article-display-x-face (&optional force
)
2418 "Look for an X-Face header and display it if present."
2419 (interactive (list 'force
))
2420 (let ((wash-face-p buffer-read-only
)) ;; When type `W f'
2421 (gnus-with-article-headers
2422 ;; Delete the old process, if any.
2423 (when (process-status "article-x-face")
2424 (delete-process "article-x-face"))
2425 ;; See the comment in `article-display-face'.
2426 (if (and wash-face-p
(memq 'xface gnus-article-wash-types
))
2427 ;; We have already displayed X-Faces, so we remove them
2429 (gnus-delete-images 'xface
)
2431 (let ((from (message-fetch-field "from"))
2433 (save-current-buffer
2434 (when (and wash-face-p
2435 (gnus-buffer-live-p gnus-original-article-buffer
)
2436 (not (re-search-forward "^X-Face:[\t ]*" nil t
)))
2437 ;; If type `W f', use gnus-original-article-buffer,
2438 ;; otherwise use the current buffer because displaying
2439 ;; RFC822 parts calls this function too.
2440 (set-buffer gnus-original-article-buffer
))
2442 (mail-narrow-to-head)
2443 (and gnus-article-x-face-command
2445 ;; Check whether this face is censored.
2446 (not (and gnus-article-x-face-too-ugly
2448 (setq from
(message-fetch-field "from")))
2449 (string-match gnus-article-x-face-too-ugly
2451 (while (gnus-article-goto-header "X-Face")
2452 (push (mail-header-field-value) x-faces
)))))
2454 ;; We display the face.
2455 (cond ((functionp gnus-article-x-face-command
)
2456 ;; The command is a lisp function, so we call it.
2457 (mapc gnus-article-x-face-command x-faces
))
2458 ((stringp gnus-article-x-face-command
)
2459 ;; The command is a string, so we interpret the command
2460 ;; as a, well, command, and fork it off.
2461 (let ((process-connection-type nil
))
2462 (set-process-query-on-exit-flag
2464 "article-x-face" nil shell-file-name
2465 shell-command-switch gnus-article-x-face-command
)
2467 ;; Sending multiple EOFs to xv doesn't work,
2468 ;; so we only do a single external face.
2470 (insert (car x-faces
))
2471 (process-send-region "article-x-face"
2472 (point-min) (point-max)))
2473 (process-send-eof "article-x-face")))
2475 (error "`%s' set to `%s' is not a function"
2476 gnus-article-x-face-command
2477 'gnus-article-x-face-command
)))))))))
2479 (defun article-decode-mime-words ()
2480 "Decode all MIME-encoded words in the article."
2482 (gnus-with-article-buffer
2483 (let ((inhibit-point-motion-hooks t
)
2484 (mail-parse-charset gnus-newsgroup-charset
)
2485 (mail-parse-ignored-charsets
2486 (with-current-buffer gnus-summary-buffer
2487 gnus-newsgroup-ignored-charsets
)))
2488 (mail-decode-encoded-word-region (point-min) (point-max)))))
2490 (defun article-decode-charset (&optional prompt
)
2491 "Decode charset-encoded text in the article.
2492 If PROMPT (the prefix), prompt for a coding system to use."
2494 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
2495 (inhibit-read-only t
)
2496 (mail-parse-charset gnus-newsgroup-charset
)
2497 (mail-parse-ignored-charsets
2498 (save-excursion (condition-case nil
2499 (set-buffer gnus-summary-buffer
)
2501 gnus-newsgroup-ignored-charsets
))
2502 ct cte ctl charset format
)
2505 (article-narrow-to-head)
2506 (setq ct
(message-fetch-field "Content-Type" t
)
2507 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
2508 ctl
(and ct
(mail-header-parse-content-type ct
))
2511 (read-coding-system "Charset to decode: "))
2513 (mail-content-type-get ctl
'charset
)))
2514 format
(and ctl
(mail-content-type-get ctl
'format
)))
2516 (setq cte
(mail-header-strip-cte cte
)))
2517 (if (and ctl
(not (string-match "/" (car ctl
))))
2519 (goto-char (point-max)))
2522 (narrow-to-region (point) (point-max))
2523 (when (and (eq mail-parse-charset
'gnus-decoded
)
2524 (eq (mm-body-7-or-8) '8bit
))
2525 ;; The text code could have been decoded.
2526 (setq charset mail-parse-charset
))
2527 (when (and (or (not ctl
)
2528 (equal (car ctl
) "text/plain"))
2529 (not format
)) ;; article with format will decode later.
2531 charset
(and cte
(intern (downcase cte
)))
2534 (defun article-decode-encoded-words ()
2535 "Remove encoded-word encoding from headers."
2536 (let ((inhibit-point-motion-hooks t
)
2537 (mail-parse-charset gnus-newsgroup-charset
)
2538 (mail-parse-ignored-charsets
2539 (save-excursion (condition-case nil
2540 (set-buffer gnus-summary-buffer
)
2542 gnus-newsgroup-ignored-charsets
))
2543 (inhibit-read-only t
)
2545 (goto-char (point-min))
2546 (when (search-forward "\n\n" nil
'move
)
2553 (memq (char-after) '(?
\t ?
)))))
2554 (setq start
(point))
2556 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2557 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2558 (funcall gnus-decode-address-function start end
)
2559 (funcall gnus-decode-header-function start end
))
2560 (goto-char (setq end start
)))))
2562 (defun article-decode-group-name ()
2563 "Decode group names in Newsgroups, Followup-To and Xref headers."
2564 (let ((inhibit-point-motion-hooks t
)
2565 (inhibit-read-only t
)
2566 (method (gnus-find-method-for-group gnus-newsgroup-name
))
2568 (when (and (or gnus-group-name-charset-method-alist
2569 gnus-group-name-charset-group-alist
)
2570 (gnus-buffer-live-p gnus-original-article-buffer
))
2572 (article-narrow-to-head)
2573 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2574 (with-current-buffer gnus-original-article-buffer
2575 (goto-char (point-min)))
2576 (setq regexp
(concat "^" header
2577 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2578 (while (re-search-forward regexp nil t
)
2579 (replace-match (save-match-data
2580 (gnus-decode-newsgroups
2581 ;; XXX how to use data in article buffer?
2582 (with-current-buffer gnus-original-article-buffer
2583 (re-search-forward regexp nil t
)
2585 gnus-newsgroup-name method
))
2587 (goto-char (point-min)))))))
2589 (defun article-decode-idna-rhs ()
2590 "Decode IDNA strings in RHS in various headers in current buffer.
2591 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2592 Mail-Reply-To: and Mail-Followup-To:."
2595 (let ((inhibit-point-motion-hooks t
)
2596 (inhibit-read-only t
))
2597 (article-narrow-to-head)
2598 (goto-char (point-min))
2599 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t
)
2601 (when (save-match-data
2602 (and (setq ace
(match-string 1))
2604 (and (re-search-backward "^[^ \t]" nil t
)
2605 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2606 (setq unicode
(puny-decode-domain ace
))))
2607 (unless (string= ace unicode
)
2608 (replace-match unicode nil nil nil
1)))))))))
2610 (defun article-de-quoted-unreadable (&optional force read-charset
)
2611 "Translate a quoted-printable-encoded article.
2612 If FORCE, decode the article whether it is marked as quoted-printable
2614 If READ-CHARSET, ask for a coding system."
2615 (interactive (list 'force current-prefix-arg
))
2617 (let ((inhibit-read-only t
) type charset
)
2618 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2619 (with-current-buffer gnus-original-article-buffer
2621 (gnus-fetch-field "content-transfer-encoding"))
2622 (let* ((ct (gnus-fetch-field "content-type"))
2623 (ctl (and ct
(mail-header-parse-content-type ct
))))
2624 (setq charset
(and ctl
2625 (mail-content-type-get ctl
'charset
)))
2626 (if (stringp charset
)
2627 (setq charset
(intern (downcase charset
)))))))
2629 (setq charset
(read-coding-system "Charset: " charset
)))
2631 (setq charset gnus-newsgroup-charset
))
2633 (and type
(let ((case-fold-search t
))
2634 (string-match "quoted-printable" type
))))
2636 (quoted-printable-decode-region
2637 (point) (point-max) (mm-charset-to-coding-system charset nil t
))))))
2639 (defun article-de-base64-unreadable (&optional force read-charset
)
2640 "Translate a base64 article.
2641 If FORCE, decode the article whether it is marked as base64 not.
2642 If READ-CHARSET, ask for a coding system."
2643 (interactive (list 'force current-prefix-arg
))
2645 (let ((inhibit-read-only t
) type charset
)
2646 (if (gnus-buffer-live-p gnus-original-article-buffer
)
2647 (with-current-buffer gnus-original-article-buffer
2649 (gnus-fetch-field "content-transfer-encoding"))
2650 (let* ((ct (gnus-fetch-field "content-type"))
2651 (ctl (and ct
(mail-header-parse-content-type ct
))))
2652 (setq charset
(and ctl
2653 (mail-content-type-get ctl
'charset
)))
2654 (if (stringp charset
)
2655 (setq charset
(intern (downcase charset
)))))))
2657 (setq charset
(read-coding-system "Charset: " charset
)))
2659 (setq charset gnus-newsgroup-charset
))
2661 (and type
(let ((case-fold-search t
))
2662 (string-match "base64" type
))))
2665 (narrow-to-region (point) (point-max))
2666 (base64-decode-region (point-min) (point-max))
2667 (decode-coding-region
2668 (point-min) (point-max)
2669 (mm-charset-to-coding-system charset nil t
)))))))
2671 (declare-function rfc1843-decode-region
"rfc1843" (from to
))
2673 (defun article-decode-HZ ()
2674 "Translate a HZ-encoded article."
2678 (let ((inhibit-read-only t
))
2679 (rfc1843-decode-region (point-min) (point-max)))))
2681 (defun article-unsplit-urls ()
2682 "Remove the newlines that some other mailers insert into URLs."
2685 (let ((inhibit-read-only t
))
2686 (goto-char (point-min))
2687 (while (re-search-forward
2688 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t
)
2689 (replace-match "\\1\\3" t
)))
2690 (when (called-interactively-p 'any
)
2691 (gnus-treat-article nil
))))
2693 (defun article-wash-html ()
2694 "Format an HTML article."
2697 (buffer-read-only nil
))
2698 (when (gnus-buffer-live-p gnus-original-article-buffer
)
2699 (with-current-buffer gnus-original-article-buffer
2700 (setq handles
(mm-dissect-buffer t t
))))
2702 (delete-region (point) (point-max))
2703 (mm-enable-multibyte)
2704 (mm-inline-text-html handles
)))
2706 (defvar gnus-article-browse-html-temp-list nil
2707 "List of temporary files created by `gnus-article-browse-html-parts'.
2708 Internal variable.")
2710 (defcustom gnus-article-browse-delete-temp
'ask
2711 "What to do with temporary files from `gnus-article-browse-html-parts'.
2712 If nil, don't delete temporary files. If it is t, delete them on
2713 exit from the summary buffer. If it is the symbol `file', query
2714 on each file, if it is `ask' ask once when exiting from the
2716 :group
'gnus-article
2717 :version
"23.1" ;; No Gnus
2718 :type
'(choice (const :tag
"Don't delete" nil
)
2719 (const :tag
"Don't ask" t
)
2720 (const :tag
"Ask" ask
)
2721 (const :tag
"Ask for each file" file
)))
2723 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2725 (defun gnus-article-browse-delete-temp-files (&optional how
)
2726 "Delete temp-files created by `gnus-article-browse-html-parts'."
2727 (when (and gnus-article-browse-html-temp-list
2729 (or how
(setq how gnus-article-browse-delete-temp
))
2731 (let ((files (length gnus-article-browse-html-temp-list
)))
2734 "Delete the temporary HTML file? "
2735 (format "Delete all %s temporary HTML files? "
2737 (setq gnus-article-browse-html-temp-list nil
)))
2739 (dolist (file gnus-article-browse-html-temp-list
)
2740 (cond ((file-directory-p file
)
2741 (when (or (not (eq how
'file
))
2744 "Delete temporary HTML file(s) in directory `%s'? "
2745 (file-name-as-directory file
))))
2746 (gnus-delete-directory file
)))
2747 ((file-exists-p file
)
2748 (when (or (not (eq how
'file
))
2750 (format "Delete temporary HTML file `%s'? " file
)))
2751 (delete-file file
)))))
2752 ;; Also remove file from the list when not deleted or if file doesn't
2754 (setq gnus-article-browse-html-temp-list nil
))
2755 gnus-article-browse-html-temp-list
)
2757 (defun gnus-article-browse-html-save-cid-content (cid handles directory
)
2758 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2759 Return file name relative to the parent of DIRECTORY."
2763 (dolist (handle handles
)
2765 ((not (listp handle
)))
2766 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2768 ((not (or (bufferp (car handle
)) (stringp (car handle
)))))
2769 ((equal (mm-handle-media-supertype handle
) "multipart")
2770 (when (setq file
(gnus-article-browse-html-save-cid-content
2771 cid handle directory
))
2772 (throw 'found file
)))
2773 ((equal (concat "<" cid
">") (mm-handle-id handle
))
2774 (setq file
(or (mm-handle-filename handle
)
2776 (make-temp-name "cid")
2777 (car (rassoc (car (mm-handle-type handle
))
2778 mailcap-mime-extensions
))))
2779 afile
(expand-file-name file directory
))
2780 (mm-save-part-to-file handle afile
)
2781 (throw 'found
(concat (file-name-nondirectory
2782 (directory-file-name directory
))
2785 (defun gnus-article-browse-html-parts (list &optional header
)
2786 "View all \"text/html\" parts from LIST.
2787 Recurse into multiparts. The optional HEADER that should be a decoded
2788 message header will be added to the bodies of the \"text/html\" parts."
2789 ;; Internal function used by `gnus-article-browse-html-article'.
2790 (let (type file charset content cid-dir tmp-file showed
)
2791 ;; Find and show the html-parts.
2792 (dolist (handle list
)
2793 ;; If HTML, show it:
2794 (cond ((not (listp handle
)))
2795 ((or (equal (car (setq type
(mm-handle-type handle
))) "text/html")
2796 (and (equal (car type
) "message/external-body")
2798 (setq file
(mm-handle-filename handle
)))
2799 (or (mm-handle-cache handle
)
2800 (condition-case code
2801 (progn (mm-extern-cache-contents handle
) t
)
2803 (gnus-message 3 "%s" (error-message-string code
))
2804 (when (>= gnus-verbose
3) (sit-for 2))
2807 (setq handle
(mm-handle-cache handle
)
2808 type
(mm-handle-type handle
))
2809 (equal (car type
) "text/html"))))
2810 (setq charset
(mail-content-type-get type
'charset
)
2811 content
(mm-get-part handle
))
2813 (if (eq charset
'gnus-decoded
)
2814 (mm-enable-multibyte)
2815 (mm-disable-multibyte))
2817 ;; resolve cid contents
2818 (let ((case-fold-search t
)
2819 st base regexp cid-file
)
2820 (goto-char (point-min))
2821 (when (and (re-search-forward "<head[\t\n >]" nil t
)
2823 (setq st
(match-end 0))
2824 (re-search-forward "</head[\t\n >]" nil t
))
2825 (re-search-backward "<base\
2826 \\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+href=\"\\([^\"]+\\)\"[^>]*>" st t
))
2827 (setq base
(match-string 1))
2828 (replace-match "<!--\\&-->")
2830 (dolist (tag '(("a" .
"href") ("form" .
"action")
2832 (setq regexp
(concat "<" (car tag
)
2833 "\\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+"
2834 (cdr tag
) "=\"\\([^\"]+\\)"))
2835 (while (re-search-forward regexp nil t
)
2839 (url-expand-file-name (match-string 1)
2841 (error (match-string 1)))
2842 (delete-region (match-beginning 1)
2845 (while (re-search-forward "\
2846 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2849 (setq cid-dir
(make-temp-file "cid" t
))
2850 (add-to-list 'gnus-article-browse-html-temp-list cid-dir
))
2853 (when (setq cid-file
2854 (gnus-article-browse-html-save-cid-content
2856 (with-current-buffer gnus-article-buffer
2857 gnus-article-mime-handles
)
2859 (replace-match cid-file nil nil nil
1))))
2860 (unless content
(setq content
(buffer-string))))
2861 (when (or charset header
(not file
))
2862 (setq tmp-file
(make-temp-file
2863 ;; Do we need to care for 8.3 filenames?
2864 "mm-" nil
".html")))
2865 ;; Add a meta html tag to specify charset and a header.
2868 (let (title eheader body hcharset coding
)
2870 (mm-enable-multibyte)
2871 (setq case-fold-search t
)
2872 (insert header
"\n")
2873 (setq title
(message-fetch-field "subject"))
2874 (goto-char (point-min))
2875 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2877 (replace-match (cond ((match-beginning 1) "<")
2878 ((match-beginning 2) ">")
2879 ((match-beginning 3) "&")
2881 (goto-char (point-min))
2882 (while (re-search-forward "^[\t ]+" nil t
)
2885 (delete-region (match-beginning 0)
2888 (goto-char (point-min))
2889 (insert "<div align=\"left\">\n")
2890 (goto-char (point-max))
2891 (insert "</div>\n<hr>\n")
2892 ;; We have to examine charset one by one since
2893 ;; charset specified in parts might be different.
2894 (if (eq charset
'gnus-decoded
)
2895 (setq charset
'utf-8
2896 eheader
(encode-coding-string (buffer-string)
2899 (encode-coding-string title charset
))
2900 body
(encode-coding-string content charset
))
2901 (setq hcharset
(mm-find-mime-charset-region (point-min)
2903 (cond ((= (length hcharset
) 1)
2904 (setq hcharset
(car hcharset
)
2905 coding
(mm-charset-to-coding-system
2907 ((> (length hcharset
) 1)
2908 (setq hcharset
'utf-8
2914 (mm-charset-to-coding-system charset
2916 (if (eq coding body
)
2917 (setq eheader
(encode-coding-string
2918 (buffer-string) coding
)
2920 (encode-coding-string
2923 (setq charset
'utf-8
2924 eheader
(encode-coding-string
2925 (buffer-string) charset
)
2927 (encode-coding-string
2929 body
(encode-coding-string
2930 (decode-coding-string
2933 (setq charset hcharset
2934 eheader
(encode-coding-string
2935 (buffer-string) coding
)
2937 (encode-coding-string
2940 (setq eheader
(string-as-unibyte (buffer-string))
2943 (mm-disable-multibyte)
2946 (mm-add-meta-html-tag handle charset t
))
2948 (goto-char (point-min))
2949 (unless (search-forward "<title>" nil t
)
2950 (re-search-forward "<head>\\s-*" nil t
)
2951 (insert "<title>" title
"</title>\n")))
2952 (goto-char (point-min))
2953 (or (re-search-forward
2954 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
)
2956 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t
))
2958 (mm-write-region (point-min) (point-max)
2959 tmp-file nil nil nil
'binary t
))))
2961 (mm-with-unibyte-buffer
2962 (insert (if (eq charset
'gnus-decoded
)
2963 (encode-coding-string content
2964 (setq charset
'utf-8
))
2966 (if (or (mm-add-meta-html-tag handle charset
)
2968 (mm-write-region (point-min) (point-max)
2969 tmp-file nil nil nil
'binary t
)
2970 (setq tmp-file nil
))))
2972 (mm-save-part-to-file handle tmp-file
)))
2974 (add-to-list 'gnus-article-browse-html-temp-list tmp-file
))
2975 (add-hook 'gnus-summary-prepare-exit-hook
2976 'gnus-article-browse-delete-temp-files
)
2977 (add-hook 'gnus-exit-gnus-hook
2979 (gnus-article-browse-delete-temp-files t
)))
2980 ;; FIXME: Warn if there's an <img> tag?
2981 (browse-url-of-file (or tmp-file
(expand-file-name file
)))
2983 ;; If multipart, recurse
2984 ((equal (mm-handle-media-supertype handle
) "multipart")
2985 (when (gnus-article-browse-html-parts handle header
)
2987 ((equal (mm-handle-media-type handle
) "message/rfc822")
2988 (mm-with-multibyte-buffer
2989 (mm-insert-part handle
)
2990 (setq handle
(mm-dissect-buffer t t
))
2991 (when (and (bufferp (car handle
))
2992 (stringp (car (mm-handle-type handle
))))
2993 (setq handle
(list handle
)))
2995 (article-decode-encoded-words)
2996 (let ((gnus-visible-headers
2997 (or (get 'gnus-visible-headers
'standard-value
)
2998 gnus-visible-headers
)))
2999 (article-hide-headers))
3000 (goto-char (point-min))
3001 (search-forward "\n\n" nil
'move
)
3002 (skip-chars-backward "\t\n ")
3003 (setq header
(buffer-substring (point-min) (point)))))
3005 (gnus-article-browse-html-parts handle header
)
3006 (mm-destroy-parts handle
))
3010 (defun gnus-article-browse-html-article (&optional arg
)
3011 "View \"text/html\" parts of the current article with a WWW browser.
3012 Inline images embedded in a message using the cid scheme, as they are
3013 generally considered to be safe, will be processed properly.
3014 The message header is added to the beginning of every html part unless
3015 the prefix argument ARG is given.
3017 Warning: Spammers use links to images (using the http scheme) in HTML
3018 articles to verify whether you have read the message. As
3019 `gnus-article-browse-html-article' passes the HTML content to the
3020 browser without eliminating these \"web bugs\" you should only
3021 use it for mails from trusted senders.
3023 If you always want to display HTML parts in the browser, set
3024 `mm-text-html-renderer' to nil.
3026 This command creates temporary files to pass HTML contents including
3027 images if any to the browser, and deletes them when exiting the group
3029 ;; Cf. `mm-w3m-safe-url-regexp'
3032 (gnus-summary-show-article)
3033 (let ((gnus-visible-headers (or (get 'gnus-visible-headers
'standard-value
)
3034 gnus-visible-headers
))
3035 ;; As we insert a <hr>, there's no need for the body boundary.
3036 (gnus-treat-body-boundary nil
))
3037 (gnus-summary-show-article)))
3038 (with-current-buffer gnus-article-buffer
3039 (let ((header (unless arg
3042 (buffer-substring-no-properties
3043 (goto-char (point-min))
3044 (if (search-forward "\n\n" nil t
)
3046 (goto-char (point-max))
3047 (skip-chars-backward "\t\n ")
3050 (set-buffer gnus-original-article-buffer
)
3051 (setq parts
(mm-dissect-buffer t t
))
3052 ;; If singlepart, enforce a list.
3053 (when (and (bufferp (car parts
))
3054 (stringp (car (mm-handle-type parts
))))
3055 (setq parts
(list parts
)))
3057 (unless (gnus-article-browse-html-parts parts header
)
3058 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3059 (mm-destroy-parts parts
)
3061 (gnus-summary-show-article)))))
3063 (defun article-hide-list-identifiers ()
3064 "Remove list identifiers from the Subject header.
3065 The `gnus-list-identifiers' variable specifies what to do."
3067 (let ((inhibit-point-motion-hooks t
)
3068 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name
))
3069 (inhibit-read-only t
))
3073 (article-narrow-to-head)
3074 (goto-char (point-min))
3075 (while (re-search-forward
3076 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp
" *\\)")
3078 (delete-region (match-beginning 2) (match-end 0))
3079 (beginning-of-line))
3080 (when (re-search-forward
3081 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t
)
3082 (delete-region (match-beginning 1) (match-end 1))))))))
3084 (defun article-hide-pem (&optional arg
)
3085 "Toggle hiding of any PEM headers and signatures in the current article.
3086 If given a negative prefix, always show; if given a positive prefix,
3088 (interactive (gnus-article-hidden-arg))
3089 (unless (gnus-article-check-hidden-text 'pem arg
)
3091 (let ((inhibit-read-only t
) end
)
3092 (goto-char (point-min))
3093 ;; Hide the horrendously ugly "header".
3094 (when (and (search-forward
3095 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3097 (setq end
(1+ (match-beginning 0))))
3098 (gnus-add-wash-type 'pem
)
3099 (gnus-article-hide-text-type
3101 (if (search-forward "\n\n" nil t
)
3105 ;; Hide the trailer as well
3106 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3108 (gnus-article-hide-text-type
3109 (match-beginning 0) (match-end 0) 'pem
)))))))
3111 (defun article-strip-banner ()
3112 "Strip the banners specified by the `banner' group parameter and by
3113 `gnus-article-address-banner-alist'."
3117 (let ((inhibit-point-motion-hooks t
))
3118 (when (gnus-parameter-banner gnus-newsgroup-name
)
3119 (article-really-strip-banner
3120 (gnus-parameter-banner gnus-newsgroup-name
)))
3121 (when gnus-article-address-banner-alist
3122 ;; Note that the From header is decoded here, so it is
3123 ;; required that the *-extract-address-components function
3124 ;; supports non-ASCII text.
3125 (let ((from (save-restriction
3127 (article-narrow-to-head)
3128 (mail-fetch-field "from"))))
3131 (cadr (funcall gnus-extract-address-components
3134 (dolist (pair gnus-article-address-banner-alist
)
3135 (when (string-match (car pair
) from
)
3137 (article-really-strip-banner (cdr pair
)))))))))))))
3139 (defun article-really-strip-banner (banner)
3140 "Strip the banner specified by the argument."
3143 (let ((inhibit-point-motion-hooks t
)
3144 (gnus-signature-limit nil
)
3145 (inhibit-read-only t
))
3148 ((eq banner
'signature
)
3149 (when (gnus-article-narrow-to-signature)
3152 (delete-region (point) (point-max))))
3154 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
3155 (while (re-search-forward banner nil t
)
3156 (delete-region (match-beginning 0) (match-end 0)))))
3158 (while (re-search-forward banner nil t
)
3159 (delete-region (match-beginning 0) (match-end 0)))))))))
3161 (defun article-babel ()
3162 "Translate article using an online translation service."
3165 (gnus-with-article-buffer
3166 (when (article-goto-body)
3167 (let* ((start (point))
3169 (orig (buffer-substring start end
))
3170 (trans (babel-as-string orig
)))
3172 (narrow-to-region start end
)
3173 (delete-region start end
)
3176 (defun article-hide-signature (&optional arg
)
3177 "Hide the signature in the current article.
3178 If given a negative prefix, always show; if given a positive prefix,
3180 (interactive (gnus-article-hidden-arg))
3181 (unless (gnus-article-check-hidden-text 'signature arg
)
3184 (let ((inhibit-read-only t
))
3185 (when (gnus-article-narrow-to-signature)
3186 (gnus-article-hide-text-type
3187 (point-min) (point-max) 'signature
))))))
3188 (gnus-set-mode-line 'article
))
3190 (defun article-strip-headers-in-body ()
3191 "Strip offensive headers from bodies."
3195 (let ((case-fold-search t
))
3196 (when (looking-at "x-no-archive:")
3197 (gnus-delete-line)))))
3199 (defun article-strip-leading-blank-lines ()
3200 "Remove all blank lines from the beginning of the article."
3203 (let ((inhibit-point-motion-hooks t
)
3204 (inhibit-read-only t
))
3205 (when (article-goto-body)
3206 (while (and (not (eobp))
3207 (looking-at "[ \t]*$"))
3208 (gnus-delete-line))))))
3210 (defun article-narrow-to-head ()
3211 "Narrow the buffer to the head of the message.
3212 Point is left at the beginning of the narrowed-to region."
3214 (goto-char (point-min))
3216 ;; Absolutely no headers displayed.
3220 ((search-forward "\n\n" nil
1)
3222 ;; Nothing but headers.
3225 (goto-char (point-min)))
3227 (defun article-goto-body ()
3228 "Place point at the start of the body."
3229 (goto-char (point-min))
3231 ;; This variable is only bound when dealing with separate
3233 (article-goto-body-goes-to-point-min-p
3235 ((search-forward "\n\n" nil t
)
3238 (goto-char (point-max))
3241 (defun article-strip-multiple-blank-lines ()
3242 "Replace consecutive blank lines with one empty line."
3245 (let ((inhibit-point-motion-hooks t
)
3246 (inhibit-read-only t
))
3247 ;; First make all blank lines empty.
3249 (while (re-search-forward "^[ \t]+$" nil t
)
3250 (unless (gnus-annotation-in-region-p
3251 (match-beginning 0) (match-end 0))
3252 (replace-match "" nil t
)))
3253 ;; Then replace multiple empty lines with a single empty line.
3255 (while (re-search-forward "\n\n\\(\n+\\)" nil t
)
3256 (unless (gnus-annotation-in-region-p
3257 (match-beginning 0) (match-end 0))
3258 (delete-region (match-beginning 1) (match-end 1)))))))
3260 (defun article-strip-leading-space ()
3261 "Remove all white space from the beginning of the lines in the article."
3264 (let ((inhibit-point-motion-hooks t
)
3265 (inhibit-read-only t
))
3267 (while (re-search-forward "^[ \t]+" nil t
)
3268 (replace-match "" t t
)))))
3270 (defun article-strip-trailing-space ()
3271 "Remove all white space from the end of the lines in the article."
3274 (let ((inhibit-point-motion-hooks t
)
3275 (inhibit-read-only t
))
3277 (while (re-search-forward "[ \t]+$" nil t
)
3278 (replace-match "" t t
)))))
3280 (defun article-strip-blank-lines ()
3281 "Strip leading, trailing and multiple blank lines."
3283 (article-strip-leading-blank-lines)
3284 (article-remove-trailing-blank-lines)
3285 (article-strip-multiple-blank-lines))
3287 (defun article-strip-all-blank-lines ()
3288 "Strip all blank lines."
3291 (let ((inhibit-point-motion-hooks t
)
3292 (inhibit-read-only t
))
3294 (while (re-search-forward "^[ \t]*\n" nil t
)
3295 (replace-match "" t t
)))))
3297 (defun gnus-article-narrow-to-signature ()
3298 "Narrow to the signature; return t if a signature is found, else nil."
3299 (let ((inhibit-point-motion-hooks t
))
3300 (when (gnus-article-search-signature)
3302 ;; Check whether we have some limits to what we consider
3303 ;; to be a signature.
3304 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
3305 (list gnus-signature-limit
)))
3307 (while (setq limit
(pop limits
))
3308 (if (or (and (integerp limit
)
3309 (< (- (point-max) (point)) limit
))
3311 (< (count-lines (point) (point-max)) limit
))
3312 (and (functionp limit
)
3314 (and (stringp limit
)
3315 (not (re-search-forward limit nil t
))))
3316 () ; This limit did not succeed.
3320 (narrow-to-region (point) (point-max))
3323 (defun gnus-article-search-signature ()
3324 "Search the current buffer for the signature separator.
3325 Put point at the beginning of the signature separator."
3326 (let ((cur (point)))
3327 (goto-char (point-max))
3328 (if (if (stringp gnus-signature-separator
)
3329 (re-search-backward gnus-signature-separator nil t
)
3330 (let ((seps gnus-signature-separator
))
3332 (not (re-search-backward (car seps
) nil t
)))
3339 (defun gnus-article-hidden-arg ()
3340 "Return the current prefix arg as a number, or 0 if no prefix."
3341 (list (if current-prefix-arg
3342 (prefix-numeric-value current-prefix-arg
)
3345 (defun gnus-article-check-hidden-text (type arg
)
3346 "Return nil if hiding is necessary.
3347 Arg can be nil or a number. nil and positive means hide, negative
3348 means show, 0 means toggle."
3351 (let ((hide (gnus-article-hidden-text-p type
)))
3357 (gnus-article-show-hidden-text type
)
3360 (if (eq hide
'hidden
)
3362 (gnus-article-show-hidden-text type
)
3366 (defun gnus-article-hidden-text-p (type)
3367 "Say whether the current buffer contains hidden text of type TYPE."
3368 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
3370 (not (get-text-property pos
'invisible
))
3371 (not (get-text-property pos
'dummy-invisible
)))
3373 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
3378 (defun gnus-article-show-hidden-text (type &optional _dummy
)
3379 "Show all hidden text of type TYPE.
3380 Originally it is hide instead of DUMMY."
3381 (let ((inhibit-read-only t
)
3382 (inhibit-point-motion-hooks t
))
3383 (gnus-remove-text-properties-when
3385 (point-min) (point-max)
3386 (cons 'article-type
(cons type
3387 gnus-hidden-properties
)))
3388 (gnus-delete-wash-type type
)))
3390 (defconst article-time-units
3391 `((year .
,(* 365.25 24 60 60))
3392 (week .
,(* 7 24 60 60))
3393 (day .
,(* 24 60 60))
3397 "Mapping from time units to seconds.")
3399 (defun gnus-article-forward-header ()
3400 "Move point to the start of the next header.
3401 If the current header is a continuation header, this can be several
3406 (if (looking-at "[ \t]+[^ \t]")
3410 (defun article-treat-date ()
3411 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer
)
3412 (with-current-buffer gnus-summary-buffer
3413 gnus-article-date-headers
)
3414 gnus-article-date-headers
)
3417 (defun article-date-ut (&optional type _highlight date-position
)
3418 "Convert DATE date to TYPE in the current article.
3419 The default type is `ut'. See `gnus-article-date-headers' for
3421 (interactive (list 'ut t
))
3422 (let* ((case-fold-search t
)
3423 (inhibit-read-only t
)
3424 (inhibit-point-motion-hooks t
)
3425 (visible-date (mail-fetch-field "Date"))
3426 pos date bface eface
)
3430 (goto-char date-position
)
3431 (setq date
(get-text-property (point) 'original-date
))
3432 (when (looking-at "[^:]+:[\t ]*")
3433 (setq bface
(get-text-property (match-beginning 0) 'face
)
3434 eface
(get-text-property (match-end 0) 'face
)))
3435 (delete-region (point)
3437 (gnus-article-forward-header)
3439 (article-transform-date date type bface eface
))
3442 (goto-char (point-min))
3443 (while (or (get-text-property (setq pos
(point)) 'original-date
)
3444 (and (setq pos
(next-single-property-change
3445 (point) 'original-date
))
3447 (narrow-to-region pos
(if (search-forward "\n\n" nil t
)
3448 (1+ (match-beginning 0))
3450 (while (setq pos
(text-property-not-all pos
(point-max)
3451 'gnus-date-type nil
))
3452 (setq date
(get-text-property pos
'original-date
))
3454 (when (looking-at "[^:]+:[\t ]*")
3455 (setq bface
(get-text-property (match-beginning 0) 'face
)
3456 eface
(get-text-property (match-end 0) 'face
)))
3457 (delete-region pos
(or (text-property-any pos
(point-max)
3458 'gnus-date-type nil
)
3460 (unless date
;; the 1st time
3461 (goto-char (point-min))
3462 (while (re-search-forward "^Date:[\t ]*" nil t
)
3463 (setq date
(get-text-property (match-beginning 0)
3465 bface
(get-text-property (match-beginning 0) 'face
)
3466 eface
(get-text-property (match-end 0) 'face
))
3467 (delete-region (point-at-bol) (progn
3468 (gnus-article-forward-header)
3470 (when (and (not date
)
3472 (setq date visible-date
))
3474 (article-transform-date date type bface eface
))
3475 (goto-char (point-max))
3478 (defun article-transform-date (date type bface eface
)
3479 (dolist (this-type (cond
3489 (add-text-properties
3492 (insert (article-make-date-line date
(or this-type
'ut
)) "\n")
3494 (list 'original-date date
'gnus-date-type this-type
))))
3497 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3498 (put-text-property (match-beginning 1) (match-end 1) 'face bface
)
3499 (when (match-beginning 2)
3500 (put-text-property (match-beginning 2) (match-end 2) 'face eface
))
3501 (while (and (zerop (forward-line 1))
3502 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3503 (when (match-beginning 1)
3504 (put-text-property (match-beginning 1) (match-end 1) 'face eface
))))))
3506 (defun article-make-date-line (date type
)
3507 "Return a DATE line of TYPE."
3508 (unless (memq type
'(local ut original user-defined iso8601 lapsed english
3510 (error "Unknown conversion type: %s" type
))
3512 (let ((time (ignore-errors (date-to-time date
))))
3514 ;; Convert to the local timezone.
3516 (concat "Date: " (message-make-date time
)))
3517 ;; Convert to Universal Time.
3522 (let* ((e (parse-time-string date
))
3523 (tm (apply 'encode-time e
))
3525 (ls (- (cadr tm
) (car (current-time-zone time
)))))
3526 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
3527 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
3531 ;; Get the original date from the article.
3532 ((eq type
'original
)
3533 (concat "Date: " (if (string-match "\n+$" date
)
3534 (substring date
0 (match-beginning 0))
3536 ;; Let the user define the format.
3537 ((eq type
'user-defined
)
3538 (let ((format (or (condition-case nil
3539 (with-current-buffer gnus-summary-buffer
3540 gnus-article-time-format
)
3542 gnus-article-time-format
)))
3543 (if (functionp format
)
3544 (funcall format time
)
3545 (concat "Date: " (format-time-string format time
)))))
3548 (let ((tz (car (current-time-zone time
))))
3551 (format-time-string "%Y%m%dT%H%M%S" time
)
3552 (format "%s%02d%02d"
3553 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
3554 (/ (%
(abs tz
) 3600) 60)))))
3555 ;; Do a lapsed format.
3557 (concat "Date: " (article-lapsed-string time
)))
3558 ;; A combined date/lapsed format.
3559 ((eq type
'combined-lapsed
)
3560 (let ((date-string (article-make-date-line date
'original
))
3566 (concat " (" (article-lapsed-string time segments
) ")"))
3567 (> (+ (length date-string
)
3568 (length lapsed-string
))
3571 (setq segments
(1- segments
)))
3573 (concat date-string lapsed-string
)
3575 ;; Display the date in proper English
3577 (let ((dtime (decode-time time
)))
3580 (number-to-string (nth 3 dtime
))
3581 (let ((digit (%
(nth 3 dtime
) 10)))
3583 ((memq (nth 3 dtime
) '(11 12 13)) "th")
3589 (nth (1- (nth 4 dtime
)) gnus-english-month-names
)
3591 (number-to-string (nth 5 dtime
))
3593 (format "%02d" (nth 2 dtime
))
3595 (format "%02d" (nth 1 dtime
)))))))
3597 (format "Date: %s (from Gnus)" date
))))
3599 (defun article-lapsed-string (time &optional max-segments
)
3600 ;; If the date is seriously mangled, the timezone functions are
3601 ;; liable to bug out, so we ignore all errors.
3602 (let* ((now (current-time))
3603 (real-time (time-subtract now time
))
3604 (real-sec (and real-time
3605 (+ (* (float (car real-time
)) 65536)
3607 (sec (and real-time
(abs real-sec
)))
3610 (unless max-segments
3611 (setq max-segments
(length article-time-units
)))
3619 ;; This is a bit convoluted, but basically we go
3620 ;; through the time units for years, weeks, etc,
3621 ;; and divide things to see whether that results
3622 ;; in positive answers.
3625 (if (or (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
3626 (>= segments max-segments
))
3627 ;; The (remaining) seconds are too few to
3628 ;; be divided into this time unit.
3630 ;; It's big enough, so we output it.
3631 (setq sec
(- sec
(* num
(cdr unit
))))
3633 (concat (if prev
", " "") (int-to-string
3635 " " (symbol-name (car unit
))
3636 (if (> num
1) "s" ""))
3638 segments
(1+ segments
)))))
3639 article-time-units
"")
3640 ;; If dates are odd, then it might appear like the
3641 ;; article was sent in the future.
3644 " in the future"))))))
3646 (defun article-date-local (&optional highlight
)
3647 "Convert the current article date to the local timezone."
3648 (interactive (list t
))
3649 (article-date-ut 'local highlight
))
3651 (defun article-date-english (&optional highlight
)
3652 "Convert the current article date to something that is proper English."
3653 (interactive (list t
))
3654 (article-date-ut 'english highlight
))
3656 (defun article-date-original (&optional highlight
)
3657 "Convert the current article date to what it was originally.
3658 This is only useful if you have used some other date conversion
3659 function and want to see what the date was before converting."
3660 (interactive (list t
))
3661 (article-date-ut 'original highlight
))
3663 (defun article-date-lapsed (&optional highlight
)
3664 "Convert the current article date to time lapsed since it was sent."
3665 (interactive (list t
))
3666 (article-date-ut 'lapsed highlight
))
3668 (defun article-date-combined-lapsed (&optional highlight
)
3669 "Convert the current article date to time lapsed since it was sent."
3670 (interactive (list t
))
3671 (article-date-ut 'combined-lapsed highlight
))
3673 (defun article-update-date-lapsed ()
3674 "Function to be run from a timer to update the lapsed time line."
3676 (let ((buffer (current-buffer)))
3680 (set-buffer (window-buffer w
))
3681 (when (derived-mode-p 'gnus-article-mode
)
3682 (let ((old-line (count-lines (point-min) (point)))
3683 (old-column (- (point) (line-beginning-position)))
3684 (window-start (window-start w
))
3687 (while (setq pos
(text-property-not-all pos
(point-max)
3688 'gnus-date-type nil
))
3689 (setq next
(or (next-single-property-change pos
3692 (setq type
(get-text-property pos
'gnus-date-type
))
3693 (when (memq type
'(lapsed combined-lapsed user-defined
))
3694 (article-date-ut type t pos
)
3695 (setq end
(or (next-single-property-change pos
3699 (if (/= window-start next
)
3700 (setq window-start nil
)
3701 (set-window-start w end
)))
3704 (goto-char (point-min))
3705 (when (> old-column
0)
3706 (setq old-line
(1- old-line
)))
3707 (forward-line old-line
)
3709 (when (> (current-column) old-column
)
3711 (forward-char old-column
)))))
3713 (set-buffer buffer
))))
3715 (defun gnus-start-date-timer (&optional n
)
3716 "Start a timer to update the Date headers in the article buffers.
3717 The numerical prefix says how frequently (in seconds) the function
3722 (gnus-stop-date-timer)
3723 (setq article-lapsed-timer
3724 (run-at-time 1 n
'article-update-date-lapsed
)))
3726 (defun gnus-stop-date-timer ()
3727 "Stop the Date timer."
3729 (when article-lapsed-timer
3730 (nnheader-cancel-timer article-lapsed-timer
)
3731 (setq article-lapsed-timer nil
)))
3733 (defun article-date-user (&optional highlight
)
3734 "Convert the current article date to the user-defined format.
3735 This format is defined by the `gnus-article-time-format' variable."
3736 (interactive (list t
))
3737 (article-date-ut 'user highlight
))
3739 (defun article-date-iso8601 (&optional highlight
)
3740 "Convert the current article date to ISO8601."
3741 (interactive (list t
))
3742 (article-date-ut 'iso8601 highlight
))
3744 (defmacro gnus-article-save-original-date
(&rest forms
)
3745 "Save the original date as a text property and evaluate FORMS."
3746 `(let* ((case-fold-search t
)
3748 (goto-char (point-min))
3749 (when (and (re-search-forward "^date:[\t\n ]+" nil t
)
3752 (date (when (and start
3753 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3755 (buffer-substring-no-properties start
3756 (match-beginning 0)))))
3757 (goto-char (point-max))
3758 (skip-chars-backward "\n")
3759 (put-text-property (point-min) (point) 'original-date date
)
3761 (goto-char (point-max))
3762 (skip-chars-backward "\n")
3763 (put-text-property (point-min) (point) 'original-date date
)))
3765 ;; (defun article-show-all ()
3766 ;; "Show all hidden text in the article buffer."
3769 ;; (let ((inhibit-read-only t))
3770 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3772 (defun article-remove-leading-whitespace ()
3773 "Remove excessive whitespace from all headers."
3777 (let ((inhibit-read-only t
))
3778 (article-narrow-to-head)
3779 (goto-char (point-min))
3780 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t
)
3781 (delete-region (match-beginning 1) (match-end 1)))))))
3783 (defun article-emphasize (&optional arg
)
3784 "Emphasize text according to `gnus-emphasis-alist'."
3785 (interactive (gnus-article-hidden-arg))
3786 (unless (gnus-article-check-hidden-text 'emphasis arg
)
3790 (with-current-buffer gnus-summary-buffer
3791 gnus-article-emphasis-alist
)
3793 gnus-emphasis-alist
))
3794 (inhibit-read-only t
)
3795 (props (append '(article-type emphasis
)
3796 gnus-hidden-properties
))
3797 regexp elem beg invisible visible face
)
3800 (while (setq elem
(pop alist
))
3802 (setq regexp
(car elem
)
3803 invisible
(nth 1 elem
)
3804 visible
(nth 2 elem
)
3806 (while (re-search-forward regexp nil t
)
3807 (when (and (match-beginning visible
) (match-beginning invisible
))
3808 (gnus-article-hide-text
3809 (match-beginning invisible
) (match-end invisible
) props
)
3810 (gnus-article-unhide-text-type
3811 (match-beginning visible
) (match-end visible
) 'emphasis
)
3812 (gnus-put-overlay-excluding-newlines
3813 (match-beginning visible
) (match-end visible
) 'face face
)
3814 (gnus-add-wash-type 'emphasis
)
3815 (goto-char (match-end invisible
)))))))))
3817 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
3818 "Setup newsgroup emphasis alist."
3819 (unless gnus-article-emphasis-alist
3820 (let ((name (and gnus-newsgroup-name
3821 (gnus-group-real-name gnus-newsgroup-name
))))
3822 (make-local-variable 'gnus-article-emphasis-alist
)
3823 (setq gnus-article-emphasis-alist
3825 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
3826 (while (setq elem
(pop alist
))
3827 (when (and name
(string-match (car elem
) name
))
3829 highlight
(copy-sequence (cdr elem
)))))
3831 (copy-sequence highlight-words
)
3832 (if gnus-newsgroup-name
3833 (copy-sequence (gnus-group-find-parameter
3834 gnus-newsgroup-name
'highlight-words t
)))
3835 gnus-emphasis-alist
)))))
3837 (defvar gnus-summary-article-menu
)
3838 (defvar gnus-summary-post-menu
)
3840 ;;; Saving functions.
3842 (defun gnus-article-save (save-buffer file
&optional num
)
3843 "Save the currently selected article."
3844 (when (or (get gnus-default-article-saver
:headers
)
3845 (not gnus-save-all-headers
))
3846 ;; Remove headers according to `gnus-saved-headers' or the value
3847 ;; of the `:headers' property that the saver function might have.
3848 (let ((gnus-visible-headers
3849 (or (symbol-value (get gnus-default-article-saver
:headers
))
3850 gnus-saved-headers gnus-visible-headers
))
3851 ;; Ignore group parameter. See `article-hide-headers'.
3852 (gnus-summary-buffer nil
))
3853 (with-current-buffer save-buffer
3854 (article-hide-headers 1 t
))))
3855 (save-window-excursion
3856 (if (not gnus-default-article-saver
)
3857 (error "No default saver is defined")
3858 ;; !!! Magic! The saving functions all save
3859 ;; `gnus-save-article-buffer' (or so they think), but we
3860 ;; bind that variable to our save-buffer.
3861 (set-buffer gnus-article-buffer
)
3862 (let* ((gnus-save-article-buffer save-buffer
)
3865 ((not gnus-prompt-before-saving
) 'default
)
3866 ((eq gnus-prompt-before-saving
'always
) nil
)
3868 (gnus-number-of-articles-to-be-saved
3869 (when (eq gnus-prompt-before-saving t
)
3871 (set-buffer gnus-article-current-summary
)
3872 (funcall gnus-default-article-saver filename
)))))
3874 (defun gnus-read-save-file-name (prompt &optional filename
3875 function group headers variable
3878 (funcall function group headers
(symbol-value variable
)))
3883 ((eq filename
'default
)
3889 (when (symbol-value dir-var
)
3890 (setq default-name
(expand-file-name
3891 (file-name-nondirectory default-name
)
3892 (symbol-value dir-var
))))
3893 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
3896 (if (and gnus-number-of-articles-to-be-saved
3897 (> gnus-number-of-articles-to-be-saved
1))
3898 (format "these %d articles"
3899 gnus-number-of-articles-to-be-saved
)
3902 ;; Let the split methods have their say.
3904 ;; No split name was found.
3907 (concat prompt
" (default "
3908 (file-name-nondirectory default-name
) "): ")
3909 (file-name-directory default-name
)
3911 ;; A single group name is returned.
3912 ((stringp split-name
)
3914 (funcall function split-name headers
3915 (symbol-value variable
)))
3917 (concat prompt
" (default "
3918 (file-name-nondirectory default-name
) "): ")
3919 (file-name-directory default-name
)
3921 ;; A single split name was found
3922 ((= 1 (length split-name
))
3923 (let* ((name (expand-file-name
3925 gnus-article-save-directory
))
3926 (dir (cond ((file-directory-p name
)
3927 (file-name-as-directory name
))
3928 ((file-exists-p name
) name
)
3929 (t gnus-article-save-directory
))))
3931 (concat prompt
" (default " name
"): ")
3933 ;; A list of splits was found.
3935 (setq split-name
(nreverse split-name
))
3937 (let ((file-name-history
3938 (nconc split-name file-name-history
)))
3942 (concat prompt
" (`M-p' for defaults): ")
3943 gnus-article-save-directory
3945 gnus-article-save-directory
)))
3946 (car (push result file-name-history
)))))))
3947 ;; Create the directory.
3948 (gnus-make-directory (file-name-directory file
))
3949 ;; If we have read a directory, we append the default file name.
3950 (when (file-directory-p file
)
3951 (setq file
(expand-file-name (file-name-nondirectory
3953 (file-name-as-directory file
))))
3954 ;; Possibly translate some characters.
3955 (nnheader-translate-file-chars file
))))))
3956 (gnus-make-directory (file-name-directory result
))
3958 (set variable result
))
3960 (set dir-var
(file-name-directory result
)))
3963 (defun gnus-article-archive-name (_group)
3964 "Return the first instance of an \"Archive-name\" in the current buffer."
3965 (let ((case-fold-search t
))
3966 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
3967 (nnheader-concat gnus-article-save-directory
3968 (match-string 1)))))
3970 (defun gnus-article-nndoc-name (group)
3971 "If GROUP is an nndoc group, return the name of the parent group."
3972 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
3973 (gnus-group-get-parameter group
'save-article-group
)))
3975 (defun gnus-summary-save-in-rmail (&optional filename
)
3976 "Append this article to Rmail file.
3977 Optional argument FILENAME specifies file name.
3978 Directory to save to is default to `gnus-article-save-directory'."
3979 (setq filename
(gnus-read-save-file-name
3980 "Save %s in rmail file" filename
3981 gnus-rmail-save-name gnus-newsgroup-name
3982 gnus-current-headers
'gnus-newsgroup-last-rmail
))
3983 (with-current-buffer gnus-save-article-buffer
3987 ;; Note that unlike gnus-summary-save-in-mail, there is no
3988 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3990 (gnus-output-to-rmail filename
))))
3993 (defun gnus-summary-save-in-mail (&optional filename
)
3994 "Append this article to Unix mail file.
3995 Optional argument FILENAME specifies file name.
3996 Directory to save to is default to `gnus-article-save-directory'."
3997 (setq filename
(gnus-read-save-file-name
3998 "Save %s in Unix mail file" filename
3999 gnus-mail-save-name gnus-newsgroup-name
4000 gnus-current-headers
'gnus-newsgroup-last-mail
))
4001 (with-current-buffer gnus-save-article-buffer
4005 (if (and (file-readable-p filename
)
4006 (file-regular-p filename
)
4007 (mail-file-babyl-p filename
))
4008 (gnus-output-to-rmail filename
)
4009 (gnus-output-to-mail filename
)))))
4012 (put 'gnus-summary-save-in-file
:decode t
)
4013 (put 'gnus-summary-save-in-file
:headers
'gnus-saved-headers
)
4014 (defun gnus-summary-save-in-file (&optional filename overwrite
)
4015 "Append this article to file.
4016 Optional argument FILENAME specifies file name.
4017 Directory to save to is default to `gnus-article-save-directory'."
4018 (setq filename
(gnus-read-save-file-name
4019 "Save %s in file" filename
4020 gnus-file-save-name gnus-newsgroup-name
4021 gnus-current-headers
'gnus-newsgroup-last-file
))
4022 (with-current-buffer gnus-save-article-buffer
4026 (when (and overwrite
4027 (file-exists-p filename
))
4028 (delete-file filename
))
4029 (gnus-output-to-file filename
))))
4032 (put 'gnus-summary-write-to-file
:decode t
)
4033 (put 'gnus-summary-write-to-file
:function
'gnus-summary-save-in-file
)
4034 (put 'gnus-summary-write-to-file
:headers
'gnus-saved-headers
)
4035 (defun gnus-summary-write-to-file (&optional filename
)
4036 "Write this article to a file, overwriting it if the file exists.
4037 Optional argument FILENAME specifies file name.
4038 The directory to save in defaults to `gnus-article-save-directory'."
4039 (setq filename
(gnus-read-save-file-name
4040 "Save %s in file" filename
4041 gnus-file-save-name gnus-newsgroup-name
4042 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4043 (gnus-summary-save-in-file filename t
))
4045 (put 'gnus-summary-save-body-in-file
:decode t
)
4046 (defun gnus-summary-save-body-in-file (&optional filename overwrite
)
4047 "Append this article body to a file.
4048 Optional argument FILENAME specifies file name.
4049 The directory to save in defaults to `gnus-article-save-directory'."
4050 (setq filename
(gnus-read-save-file-name
4051 "Save %s body in file" filename
4052 gnus-file-save-name gnus-newsgroup-name
4053 gnus-current-headers
'gnus-newsgroup-last-file
))
4054 (with-current-buffer gnus-save-article-buffer
4058 (when (article-goto-body)
4059 (narrow-to-region (point) (point-max)))
4060 (when (and overwrite
4061 (file-exists-p filename
))
4062 (delete-file filename
))
4063 (gnus-output-to-file filename
))))
4066 (put 'gnus-summary-write-body-to-file
:decode t
)
4067 (put 'gnus-summary-write-body-to-file
4068 :function
'gnus-summary-save-body-in-file
)
4069 (defun gnus-summary-write-body-to-file (&optional filename
)
4070 "Write this article body to a file, overwriting it if the file exists.
4071 Optional argument FILENAME specifies file name.
4072 The directory to save in defaults to `gnus-article-save-directory'."
4073 (setq filename
(gnus-read-save-file-name
4074 "Save %s body in file" filename
4075 gnus-file-save-name gnus-newsgroup-name
4076 gnus-current-headers nil
'gnus-newsgroup-last-directory
))
4077 (gnus-summary-save-body-in-file filename t
))
4079 (put 'gnus-summary-save-in-pipe
:decode t
)
4080 (put 'gnus-summary-save-in-pipe
:headers
'gnus-saved-headers
)
4081 (defun gnus-summary-save-in-pipe (&optional command raw
)
4082 "Pipe this article to subprocess COMMAND.
4083 Valid values for COMMAND include:
4085 The executable command name and possibly arguments.
4087 You will be prompted for the command in the minibuffer.
4088 the symbol `default'
4089 It will be replaced with the command which the variable
4090 `gnus-summary-pipe-output-default-command' holds or the command
4091 last used for saving.
4092 Non-nil value for RAW overrides `:decode' and `:headers' properties
4093 and the raw article including all headers will be piped."
4094 (let ((article (gnus-summary-article-number))
4096 (get 'gnus-summary-save-in-pipe
:decode
)))
4097 save-buffer default
)
4099 (if (vectorp (gnus-summary-article-header article
))
4100 (save-current-buffer
4101 (gnus-summary-select-article decode decode nil article
)
4102 (insert-buffer-substring
4106 gnus-original-article-buffer
)
4108 (nnheader-set-temp-buffer " *Gnus Save*"))))
4109 ;; Remove unwanted headers.
4110 (when (and (not raw
)
4111 (or (get 'gnus-summary-save-in-pipe
:headers
)
4112 (not gnus-save-all-headers
)))
4113 (let ((gnus-visible-headers
4114 (or (symbol-value (get 'gnus-summary-save-in-pipe
4116 gnus-saved-headers gnus-visible-headers
))
4117 (gnus-summary-buffer nil
))
4118 (article-hide-headers 1 t
))))
4119 (error "%d is not a real article" article
))
4120 (error "No article to pipe"))
4121 (setq default
(or gnus-summary-pipe-output-default-command
4122 gnus-last-shell-command
))
4123 (unless (stringp command
)
4125 (if (and (eq command
'default
) default
)
4127 (read-shell-command "Shell command on this article: " default
))))
4128 (when (string-equal command
"")
4130 (setq command default
)
4131 (error "A command is required")))
4132 (with-current-buffer save-buffer
4135 (shell-command-on-region (point-min) (point-max) command nil
)))
4136 (gnus-kill-buffer save-buffer
))
4137 (setq gnus-summary-pipe-output-default-command command
))
4139 (defun gnus-summary-pipe-to-muttprint (&optional command
)
4140 "Pipe this article to muttprint."
4141 (unless (stringp command
)
4142 (setq command
(read-string
4143 "Print using command: " gnus-summary-muttprint-program
4144 nil gnus-summary-muttprint-program
)))
4145 (let ((gnus-summary-pipe-output-default-command
4146 gnus-summary-pipe-output-default-command
))
4147 (gnus-summary-save-in-pipe command
))
4148 (setq gnus-summary-muttprint-program command
))
4150 ;;; Article file names when saving.
4152 (defun gnus-capitalize-newsgroup (newsgroup)
4153 "Capitalize NEWSGROUP name."
4154 (when (not (zerop (length newsgroup
)))
4155 (concat (char-to-string (upcase (aref newsgroup
0)))
4156 (substring newsgroup
1))))
4158 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
4159 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4160 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4161 Otherwise, it is like ~/News/news/group/num."
4164 (concat (if (gnus-use-long-file-name 'not-save
)
4165 (gnus-capitalize-newsgroup newsgroup
)
4166 (gnus-newsgroup-directory-form newsgroup
))
4167 "/" (int-to-string (mail-header-number headers
)))
4168 gnus-article-save-directory
)))
4170 (string-equal (file-name-directory default
)
4171 (file-name-directory last-file
))
4172 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4174 (or last-file default
))))
4176 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
4177 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4178 If variable `gnus-use-long-file-name' is non-nil, it is
4179 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4182 (concat (if (gnus-use-long-file-name 'not-save
)
4184 (gnus-newsgroup-directory-form newsgroup
))
4185 "/" (int-to-string (mail-header-number headers
)))
4186 gnus-article-save-directory
)))
4188 (string-equal (file-name-directory default
)
4189 (file-name-directory last-file
))
4190 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
4192 (or last-file default
))))
4194 (defun gnus-plain-save-name (newsgroup _headers
&optional last-file
)
4195 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4196 If variable `gnus-use-long-file-name' is non-nil, it is
4197 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4200 (if (gnus-use-long-file-name 'not-save
)
4203 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
))
4205 gnus-article-save-directory
)))
4207 (defun gnus-sender-save-name (_newsgroup headers
&optional _last-file
)
4208 "Generate file name from sender."
4209 (let ((from (mail-header-from headers
)))
4211 (if (and from
(string-match "\\([^ <]+\\)@" from
))
4212 (match-string 1 from
)
4214 gnus-article-save-directory
)))
4216 (defun article-verify-x-pgp-sig ()
4218 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4220 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4221 (let ((sig (with-current-buffer gnus-original-article-buffer
4222 (gnus-fetch-field "X-PGP-Sig")))
4226 (mml2015-clear-verify-function))
4228 (insert-buffer-substring gnus-original-article-buffer
)
4229 (setq items
(split-string sig
))
4230 (message-narrow-to-head)
4231 (let ((inhibit-point-motion-hooks t
)
4232 (case-fold-search t
))
4233 ;; Don't verify multiple headers.
4234 (setq headers
(mapconcat (lambda (header)
4236 (mail-fetch-field header
)
4238 (split-string (nth 1 items
) ",") "")))
4239 (delete-region (point-min) (point-max))
4240 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4241 (insert "X-Signed-Headers: " (nth 1 items
) "\n")
4246 (if (looking-at "^-")
4249 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4250 (insert "Version: " (car items
) "\n\n")
4251 (insert (mapconcat 'identity
(cddr items
) "\n"))
4252 (insert "\n-----END PGP SIGNATURE-----\n")
4253 (let ((mm-security-handle (list (format "multipart/signed"))))
4254 (mml2015-clean-buffer)
4255 (let ((coding-system-for-write (or gnus-newsgroup-charset
4257 (funcall (mml2015-clear-verify-function)))
4259 (or (mm-handle-multipart-ctl-parameter
4260 mm-security-handle
'gnus-details
)
4261 (mm-handle-multipart-ctl-parameter
4262 mm-security-handle
'gnus-info
)))))
4264 (let ((inhibit-read-only t
) bface eface
)
4266 (message-narrow-to-head)
4267 (goto-char (point-max))
4269 (setq bface
(get-text-property (point-at-bol) 'face
)
4270 eface
(get-text-property (1- (point-at-eol)) 'face
))
4271 (message-remove-header "X-Gnus-PGP-Verify")
4272 (if (re-search-forward "^X-PGP-Sig:" nil t
)
4274 (goto-char (point-max)))
4275 (narrow-to-region (point) (point))
4276 (insert "X-Gnus-PGP-Verify: " info
"\n")
4277 (goto-char (point-min))
4280 (if (not (looking-at "^[ \t]"))
4284 (goto-char (point-min))
4285 (when (looking-at "\\([^:]+\\): *")
4286 (put-text-property (match-beginning 1) (1+ (match-end 1))
4288 (put-text-property (match-end 0) (point-max)
4289 'face eface
)))))))))
4291 (defun article-verify-cancel-lock ()
4292 "Verify Cancel-Lock header."
4294 (if (gnus-buffer-live-p gnus-original-article-buffer
)
4295 (canlock-verify gnus-original-article-buffer
)))
4302 (setq afunc
(car func
)
4305 gfunc
(intern (format "gnus-%s" func
))))
4307 (when (fboundp afunc
)
4308 `(lambda (&optional interactive
&rest args
)
4309 ,(documentation afunc t
)
4310 (interactive (list t
))
4311 (with-current-buffer gnus-article-buffer
4313 (call-interactively ',afunc
)
4314 (apply ',afunc args
))))))))
4315 '(article-hide-headers
4316 article-verify-x-pgp-sig
4317 article-verify-cancel-lock
4318 article-hide-boring-headers
4319 article-treat-overstrike
4320 article-treat-ansi-sequences
4321 article-fill-long-lines
4322 article-capitalize-sentences
4324 article-remove-leading-whitespace
4325 article-display-x-face
4326 article-display-face
4327 article-de-quoted-unreadable
4328 article-de-base64-unreadable
4331 article-unsplit-urls
4332 article-hide-list-identifiers
4333 article-strip-banner
4336 article-hide-signature
4337 article-strip-headers-in-body
4338 article-remove-trailing-blank-lines
4339 article-strip-leading-blank-lines
4340 article-strip-multiple-blank-lines
4341 article-strip-leading-space
4342 article-strip-trailing-space
4343 article-strip-blank-lines
4344 article-strip-all-blank-lines
4346 article-date-english
4347 article-date-iso8601
4348 article-date-original
4351 article-decode-mime-words
4352 article-decode-charset
4353 article-decode-encoded-words
4356 article-date-combined-lapsed
4358 article-treat-dumbquotes
4359 article-treat-non-ascii
4360 article-normalize-headers
4361 ;;(article-show-all . gnus-article-show-all-headers)
4365 ;;; Gnus article mode
4368 (put 'gnus-article-mode
'mode-class
'special
)
4370 (set-keymap-parent gnus-article-mode-map widget-keymap
)
4372 (gnus-define-keys gnus-article-mode-map
4373 " " gnus-article-goto-next-page
4374 [?\S-\
] gnus-article-goto-prev-page
4375 "\177" gnus-article-goto-prev-page
4376 [delete] gnus-article-goto-prev-page
4377 "\C-c^" gnus-article-refer-article
4378 "h" gnus-article-show-summary
4379 "s" gnus-article-show-summary
4380 "\C-c\C-m" gnus-article-mail
4381 "?" gnus-article-describe-briefly
4382 "<" beginning-of-buffer
4384 "\C-c\C-i" gnus-info-find-node
4386 "R" gnus-article-reply-with-original
4387 "F" gnus-article-followup-with-original
4388 "\C-hk" gnus-article-describe-key
4389 "\C-hc" gnus-article-describe-key-briefly
4390 "\C-hb" gnus-article-describe-bindings
4392 "e" gnus-article-read-summary-keys
4393 "\C-d" gnus-article-read-summary-keys
4394 "\M-*" gnus-article-read-summary-keys
4395 "\M-#" gnus-article-read-summary-keys
4396 "\M-^" gnus-article-read-summary-keys
4397 "\M-g" gnus-article-read-summary-keys)
4399 (substitute-key-definition
4400 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4402 (defvar gnus-article-send-map)
4403 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4404 "W" gnus-article-wide-reply-with-original
4405 [t] gnus-article-read-summary-send-keys)
4407 (defun gnus-article-make-menu-bar ()
4408 (unless (boundp 'gnus-article-commands-menu)
4409 (gnus-summary-make-menu-bar))
4410 (unless (boundp 'gnus-article-article-menu)
4412 gnus-article-article-menu gnus-article-mode-map ""
4414 ["Scroll forwards" gnus-article-goto-next-page t]
4415 ["Scroll backwards" gnus-article-goto-prev-page t]
4416 ["Show summary" gnus-article-show-summary t]
4417 ["Fetch Message-ID at point" gnus-article-refer-article t]
4418 ["Mail to address at point" gnus-article-mail t]
4419 ["Send a bug report" gnus-bug t]))
4422 gnus-article-treatment-menu gnus-article-mode-map ""
4423 ;; Fixme: this should use :active (and maybe :visible).
4425 ["Hide headers" gnus-article-hide-headers t]
4426 ["Hide signature" gnus-article-hide-signature t]
4427 ["Hide citation" gnus-article-hide-citation t]
4428 ["Treat overstrike" gnus-article-treat-overstrike t]
4429 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4430 ["Remove carriage return" gnus-article-remove-cr t]
4431 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4432 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4433 ["Remove base64" gnus-article-de-base64-unreadable t]
4434 ["Treat html" gnus-article-wash-html t]
4435 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4436 ["Decode HZ" gnus-article-decode-HZ t]))
4438 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4440 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4442 (gnus-run-hooks 'gnus-article-menu-hook)))
4444 (defvar bookmark-make-record-function)
4445 (defvar shr-put-image-function)
4447 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4448 "Major mode for displaying an article.
4450 All normal editing commands are switched off.
4452 The following commands are available in addition to all summary mode
4454 \\<gnus-article-mode-map>
4455 \\[gnus-article-next-page]\t Scroll the article one page forwards
4456 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4457 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4458 \\[gnus-article-show-summary]\t Display the summary buffer
4459 \\[gnus-article-mail]\t Send a reply to the address near point
4460 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4461 \\[gnus-info-find-node]\t Go to the Gnus info node"
4462 (gnus-simplify-mode-line)
4463 (make-local-variable 'minor-mode-alist)
4464 (when (gnus-visual-p 'article-menu 'menu)
4465 (gnus-article-make-menu-bar)
4466 (when gnus-summary-tool-bar-map
4467 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4468 (gnus-update-format-specifications nil 'article-mode)
4469 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4470 (set (make-local-variable 'gnus-page-broken) nil)
4471 (make-local-variable 'gnus-article-current-summary)
4472 (make-local-variable 'gnus-article-mime-handles)
4473 (make-local-variable 'gnus-article-decoded-p)
4474 (make-local-variable 'gnus-article-mime-handle-alist)
4475 (make-local-variable 'gnus-article-wash-types)
4476 (make-local-variable 'gnus-article-image-alist)
4477 (make-local-variable 'gnus-article-charset)
4478 (make-local-variable 'gnus-article-ignored-charsets)
4479 (set (make-local-variable 'bookmark-make-record-function)
4480 'gnus-summary-bookmark-make-record)
4481 ;; Prevent Emacs from displaying non-break space with
4482 ;; `nobreak-space' face.
4483 (set (make-local-variable 'nobreak-char-display) nil)
4484 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4485 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4486 (unless gnus-article-show-cursor
4487 (setq cursor-in-non-selected-windows nil))
4488 (gnus-set-default-directory)
4489 (buffer-disable-undo)
4490 (setq buffer-read-only t
4491 show-trailing-whitespace nil)
4492 (mm-enable-multibyte))
4494 (defun gnus-article-setup-buffer ()
4495 "Initialize the article buffer."
4496 (let* ((name (if gnus-single-article-buffer "*Article*"
4498 (gnus-group-decoded-name gnus-newsgroup-name)
4501 (progn (string-match "\\*Article" name)
4502 (concat " *Original Article"
4503 (substring name (match-end 0))))))
4504 (setq gnus-article-buffer name)
4505 (setq gnus-original-article-buffer original)
4506 (setq gnus-article-mime-handle-alist nil)
4507 (with-current-buffer gnus-summary-buffer
4508 ;; This might be a variable local to the summary buffer.
4509 (unless gnus-single-article-buffer
4510 (setq gnus-article-buffer name)
4511 (setq gnus-original-article-buffer original)
4512 (gnus-set-global-variables)))
4513 (gnus-article-setup-highlight-words)
4514 ;; Init original article buffer.
4515 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4516 (mm-enable-multibyte)
4517 (setq major-mode 'gnus-original-article-mode)
4518 (make-local-variable 'gnus-original-article))
4519 (if (and (get-buffer name)
4520 (with-current-buffer name
4521 (if gnus-article-edit-mode
4522 (if (y-or-n-p "Article mode edit in progress; discard? ")
4524 (set-buffer-modified-p nil)
4525 (gnus-kill-buffer name)
4528 (error "Action aborted"))
4530 (let ((summary gnus-summary-buffer))
4531 (with-current-buffer name
4532 (set (make-local-variable 'gnus-article-edit-mode) nil)
4533 (gnus-article-stop-animations)
4534 (when gnus-article-mime-handles
4535 (mm-destroy-parts gnus-article-mime-handles)
4536 (setq gnus-article-mime-handles nil))
4537 ;; Set it to nil in article-buffer!
4538 (setq gnus-article-mime-handle-alist nil)
4539 (buffer-disable-undo)
4540 (setq buffer-read-only t)
4541 (unless (derived-mode-p 'gnus-article-mode)
4542 (gnus-article-mode))
4543 (set (make-local-variable 'gnus-summary-buffer) summary)
4544 (setq truncate-lines gnus-article-truncate-lines)
4546 (let ((summary gnus-summary-buffer))
4547 (with-current-buffer (gnus-get-buffer-create name)
4549 (setq truncate-lines gnus-article-truncate-lines)
4550 (set (make-local-variable 'gnus-summary-buffer) summary)
4551 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4552 (when article-lapsed-timer
4553 (gnus-stop-date-timer))
4554 (when gnus-article-update-date-headers
4555 (gnus-start-date-timer gnus-article-update-date-headers))
4556 (current-buffer))))))
4558 (defun gnus-article-stop-animations ()
4559 (dolist (timer (and (boundp 'timer-list)
4561 (when (eq (timer--function timer) 'image-animate-timeout)
4562 (cancel-timer timer))))
4564 (defun gnus-stop-downloads ()
4565 (when (boundp 'url-queue)
4566 (set (intern "url-queue" obarray) nil)))
4568 ;; Set article window start at LINE, where LINE is the number of lines
4569 ;; from the head of the article.
4570 (defun gnus-article-set-window-start (&optional line)
4571 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4572 (when article-window
4575 (with-current-buffer gnus-article-buffer
4576 (goto-char (point-min))
4579 (gnus-message 6 "Moved to bookmark")
4580 (search-forward "\n\n" nil t)
4584 (defvar gnus-tmp-internal-hook)
4586 (defun gnus-article-prepare (article &optional all-headers _header)
4587 "Prepare ARTICLE in article mode buffer.
4588 ARTICLE should either be an article number or a Message-ID.
4589 If ARTICLE is an id, HEADER should be the article headers.
4590 If ALL-HEADERS is non-nil, no headers are hidden."
4591 (save-excursion ;FIXME: Shouldn't that be save-current-buffer?
4592 ;; Make sure we start in a summary buffer.
4593 (unless (derived-mode-p 'gnus-summary-mode)
4594 (set-buffer gnus-summary-buffer))
4595 (setq gnus-summary-buffer (current-buffer))
4596 (let* ((summary-buffer (current-buffer))
4597 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4598 (group gnus-newsgroup-name)
4601 (gnus-article-setup-buffer)
4602 (set-buffer gnus-article-buffer)
4603 ;; Deactivate active regions.
4604 (when transient-mark-mode
4605 (setq mark-active nil))
4606 (if (not (setq result (let ((inhibit-read-only t))
4607 (gnus-request-article-this-buffer
4609 ;; There is no such article.
4611 (when (and (numberp article)
4612 (not (memq article gnus-newsgroup-sparse)))
4613 (setq gnus-article-current
4614 (cons gnus-newsgroup-name article))
4615 (set-buffer gnus-summary-buffer)
4616 (setq gnus-current-article article)
4617 (if (and (memq article gnus-newsgroup-undownloaded)
4618 (not (gnus-online (gnus-find-method-for-group
4619 gnus-newsgroup-name))))
4621 (gnus-summary-set-agent-mark article)
4622 (message "Message marked for downloading"))
4623 (gnus-summary-mark-article article gnus-canceled-mark)
4624 (unless (memq article gnus-newsgroup-sparse)
4625 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4626 (if (or (eq result 'pseudo)
4627 (eq result 'nneething))
4629 (with-current-buffer summary-buffer
4630 (push article gnus-newsgroup-history)
4631 (setq gnus-last-article gnus-current-article
4632 gnus-current-article 0
4633 gnus-current-headers nil
4634 gnus-article-current nil)
4635 (if (eq result 'nneething)
4636 (gnus-configure-windows 'summary)
4637 (gnus-configure-windows 'article))
4638 (gnus-set-global-variables))
4639 (let ((gnus-article-mime-handle-alist-1
4640 gnus-article-mime-handle-alist))
4641 (gnus-set-mode-line 'article)))
4642 ;; The result from the `request' was an actual article -
4643 ;; or at least some text that is now displayed in the
4645 (when (and (numberp article)
4646 (not (eq article gnus-current-article)))
4647 ;; Seems like a new article has been selected.
4648 ;; `gnus-current-article' must be an article number.
4649 (with-current-buffer summary-buffer
4650 (push article gnus-newsgroup-history)
4651 (setq gnus-last-article gnus-current-article
4652 gnus-current-article article
4653 gnus-current-headers
4654 (gnus-summary-article-header gnus-current-article)
4655 gnus-article-current
4656 (cons gnus-newsgroup-name gnus-current-article))
4657 (unless (vectorp gnus-current-headers)
4658 (setq gnus-current-headers nil))
4659 (gnus-summary-goto-subject gnus-current-article)
4660 (when (gnus-summary-show-thread)
4661 ;; If the summary buffer really was folded, the
4662 ;; previous goto may not actually have gone to
4663 ;; the right article, but the thread root instead.
4665 (gnus-summary-goto-subject gnus-current-article))
4666 (gnus-run-hooks 'gnus-mark-article-hook)
4667 (gnus-set-mode-line 'summary)
4668 (when (gnus-visual-p 'article-highlight 'highlight)
4669 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4670 ;; Set the global newsgroup variables here.
4671 (gnus-set-global-variables)
4672 (setq gnus-have-all-headers
4673 (or all-headers gnus-show-all-headers))))
4675 (gnus-configure-windows 'article))
4676 (when (or (numberp article)
4678 (gnus-article-prepare-display)
4680 (goto-char (point-min))
4681 (when gnus-break-pages
4682 (gnus-narrow-to-page)))
4683 (let ((gnus-article-mime-handle-alist-1
4684 gnus-article-mime-handle-alist))
4685 (gnus-set-mode-line 'article))
4689 (set-window-point (get-buffer-window (current-buffer)) (point))
4690 (gnus-configure-windows 'article)
4691 (gnus-run-hooks 'gnus-article-prepare-hook)
4694 (defvar gnus-mime-display-attachment-buttons-in-header)
4697 (defun gnus-article-prepare-display ()
4698 "Make the current buffer look like a nice article."
4699 ;; Hooks for getting information from the article.
4700 ;; This hook must be called before being narrowed.
4701 (let ((gnus-article-buffer (current-buffer))
4703 (inhibit-read-only t))
4704 (unless (derived-mode-p 'gnus-article-mode)
4705 (gnus-article-mode))
4706 (setq buffer-read-only nil
4707 gnus-article-wash-types nil
4708 gnus-article-image-alist nil)
4709 (gnus-run-hooks 'gnus-tmp-internal-hook)
4710 (when gnus-display-mime-function
4711 (funcall gnus-display-mime-function))
4712 ;; Add attachment buttons to the header.
4713 (when gnus-mime-display-attachment-buttons-in-header
4714 (gnus-mime-buttonize-attachments-in-header))))
4717 ;;; Gnus Sticky Article Mode
4720 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4721 "Mode for sticky articles."
4722 ;; Release bindings that won't work.
4723 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4724 gnus-sticky-article-mode-map)
4725 (substitute-key-definition 'gnus-article-refer-article 'undefined
4726 gnus-sticky-article-mode-map)
4727 (dolist (k '("e" "h" "s" "F" "R"))
4728 (define-key gnus-sticky-article-mode-map k nil))
4729 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4730 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4731 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4732 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4734 (defun gnus-sticky-article (arg)
4735 "Make the current article sticky.
4736 If a prefix ARG is given, ask for a name for this sticky article buffer."
4738 (gnus-summary-show-thread)
4739 (gnus-summary-select-article nil nil 'pseudo)
4740 (let (new-art-buf-name)
4741 (gnus-eval-in-buffer-window gnus-article-buffer
4742 (setq new-art-buf-name
4746 (read-from-minibuffer "Sticky article buffer name: ")
4747 (gnus-with-article-headers
4748 (gnus-article-goto-header "subject")
4749 (setq new-art-buf-name
4750 (buffer-substring-no-properties
4751 (line-beginning-position) (line-end-position)))
4752 (goto-char (point-min))
4753 (gnus-article-goto-header "from")
4754 (setq new-art-buf-name
4756 new-art-buf-name ", "
4757 (buffer-substring-no-properties
4758 (line-beginning-position) (line-end-position))))
4759 (goto-char (point-min))
4760 (gnus-article-goto-header "date")
4761 (setq new-art-buf-name
4763 new-art-buf-name ", "
4764 (buffer-substring-no-properties
4765 (line-beginning-position) (line-end-position))))))
4767 (if (and (gnus-buffer-live-p new-art-buf-name)
4768 (with-current-buffer new-art-buf-name
4769 (derived-mode-p 'gnus-sticky-article-mode)))
4770 (switch-to-buffer new-art-buf-name)
4771 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4772 (gnus-sticky-article-mode))
4773 (setq gnus-article-buffer new-art-buf-name))
4774 (gnus-summary-recenter)
4775 (gnus-summary-position-point))
4777 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4778 "Kill the given sticky article BUFFER.
4779 If none is given, assume the current buffer and kill it if it has
4780 `gnus-sticky-article-mode'."
4783 (setq buffer (current-buffer)))
4784 (with-current-buffer buffer
4785 (when (derived-mode-p 'gnus-sticky-article-mode)
4786 (gnus-kill-buffer buffer))))
4788 (defun gnus-kill-sticky-article-buffers (arg)
4789 "Kill all sticky article buffers.
4790 If a prefix ARG is given, ask for confirmation."
4792 (dolist (buf (gnus-buffers))
4793 (with-current-buffer buf
4794 (when (derived-mode-p 'gnus-sticky-article-mode)
4796 (gnus-kill-buffer buf)
4797 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4798 (gnus-kill-buffer buf)))))))
4801 ;;; Gnus MIME viewing functions
4804 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4805 "Format of the MIME buttons.
4807 Valid specifiers include:
4809 %T MIME type, along with additional info
4810 %n The `name' parameter
4811 %d The description, if any
4812 %l The length of the encoded part
4813 %p The part identifier number
4814 %e Dots if the part isn't displayed
4816 General format specifiers can also be used. See Info node
4817 `(gnus)Formatting Variables'.")
4819 (defvar gnus-tmp-type)
4820 (defvar gnus-tmp-type-long)
4821 (defvar gnus-tmp-name)
4822 (defvar gnus-tmp-description)
4823 (defvar gnus-tmp-id)
4824 (defvar gnus-tmp-length)
4825 (defvar gnus-tmp-dots)
4826 (defvar gnus-tmp-info)
4827 (defvar gnus-tmp-pressed-details)
4829 (defvar gnus-mime-button-line-format-alist
4830 '((?t gnus-tmp-type ?s)
4831 (?T gnus-tmp-type-long ?s)
4832 (?n gnus-tmp-name ?s)
4833 (?d gnus-tmp-description ?s)
4835 (?l gnus-tmp-length ?d)
4836 (?e gnus-tmp-dots ?s)))
4838 (defvar gnus-mime-button-commands
4839 '((gnus-article-press-button "\r" "Toggle Display")
4840 (gnus-mime-view-part "v" "View Interactively...")
4841 (gnus-mime-view-part-as-type "t" "View As Type...")
4842 (gnus-mime-view-part-as-charset "C" "View As charset...")
4843 (gnus-mime-save-part "o" "Save...")
4844 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4845 (gnus-mime-replace-part "r" "Replace part")
4846 (gnus-mime-delete-part "d" "Delete part")
4847 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4848 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4849 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4850 (gnus-mime-view-part-externally "e" "View Externally")
4851 (gnus-mime-print-part "p" "Print")
4852 (gnus-mime-pipe-part "|" "Pipe To Command...")
4853 (gnus-mime-action-on-part "." "Take action on the part...")))
4855 (defun gnus-article-mime-part-status ()
4856 (if gnus-article-mime-handle-alist-1
4857 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4859 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4862 (defvar gnus-mime-button-map
4863 (let ((map (make-sparse-keymap)))
4864 (define-key map [mouse-2] 'gnus-article-push-button)
4865 (define-key map [down-mouse-3] 'gnus-mime-button-menu)
4866 (dolist (c gnus-mime-button-commands)
4867 (define-key map (cadr c) (car c)))
4871 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4873 ,@(mapcar (lambda (c)
4874 (vector (caddr c) (car c) :active t))
4875 gnus-mime-button-commands)))
4877 (defvar gnus-url-button-commands
4878 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4880 (defvar gnus-url-button-map
4881 (let ((map (make-sparse-keymap)))
4882 (dolist (c gnus-url-button-commands)
4883 (define-key map (cadr c) (car c)))
4887 gnus-url-button-menu gnus-url-button-map "URL button menu."
4889 ,@(mapcar (lambda (c)
4890 (vector (caddr c) (car c) :active t))
4891 gnus-url-button-commands)))
4893 (defmacro gnus-bind-mm-vars (&rest body)
4894 "Bind some mm-* variables and execute BODY."
4895 `(let (mm-html-inhibit-images
4896 mm-html-blocked-images
4897 (mm-w3m-safe-url-regexp mm-w3m-safe-url-regexp))
4898 (with-current-buffer
4899 (cond ((derived-mode-p 'gnus-article-mode)
4900 (if (gnus-buffer-live-p gnus-article-current-summary)
4901 gnus-article-current-summary
4902 ;; Maybe we're in a mml-preview buffer
4903 ;; and no group is selected.
4905 ((gnus-buffer-live-p gnus-summary-buffer)
4906 gnus-summary-buffer)
4907 (t (current-buffer)))
4908 (setq mm-html-inhibit-images gnus-inhibit-images
4909 mm-html-blocked-images (gnus-blocked-images))
4910 (when (or (not gnus-newsgroup-name)
4911 (and (stringp gnus-safe-html-newsgroups)
4912 (string-match gnus-safe-html-newsgroups
4913 gnus-newsgroup-name))
4914 (and (consp gnus-safe-html-newsgroups)
4915 (member gnus-newsgroup-name gnus-safe-html-newsgroups)))
4916 (setq mm-w3m-safe-url-regexp nil)))
4919 (defun gnus-mime-button-menu (event prefix)
4920 "Construct a context-sensitive menu of MIME commands."
4921 (interactive "e\nP")
4922 (save-window-excursion
4923 (let ((pos (event-start event)))
4924 (select-window (posn-window pos))
4925 (goto-char (posn-point pos))
4926 (gnus-article-check-buffer)
4927 (popup-menu gnus-mime-button-menu nil prefix))))
4929 (defun gnus-mime-view-all-parts (&optional handles)
4930 "View all the MIME parts."
4932 (with-current-buffer gnus-article-buffer
4933 (let ((handles (or handles gnus-article-mime-handles))
4934 (mail-parse-charset gnus-newsgroup-charset)
4935 (mail-parse-ignored-charsets
4936 (with-current-buffer gnus-summary-buffer
4937 gnus-newsgroup-ignored-charsets)))
4939 (mm-remove-parts handles)
4940 (goto-char (point-min))
4941 (or (search-forward "\n\n") (goto-char (point-max)))
4942 (let ((inhibit-read-only t))
4943 (delete-region (point) (point-max))
4944 (gnus-bind-mm-vars (mm-display-parts handles)))))))
4946 (defun gnus-article-jump-to-part (n)
4947 "Jump to MIME part N."
4949 (let ((parts (with-current-buffer gnus-article-buffer
4950 (length gnus-article-mime-handle-alist))))
4952 (error "No such part"))
4953 (pop-to-buffer gnus-article-buffer)
4955 (setq n (if (= parts 1)
4957 (read-number (format "Jump to part (1..%s): " parts)))))
4958 (unless (and (integerp n) (<= n parts) (>= n 1))
4961 (gnus-message 7 "Invalid part `%s', using %s instead."
4964 (gnus-message 9 "Jumping to part %s." n)
4965 (cond ((>= gnus-auto-select-part 1)
4966 (while (and (<= n parts)
4967 (not (gnus-article-goto-part n)))
4969 ((< gnus-auto-select-part 0)
4970 (while (and (>= n 1)
4971 (not (gnus-article-goto-part n)))
4974 (gnus-article-goto-part n)))))
4976 (defvar gnus-mime-buttonized-part-id nil
4977 "ID of a mime part that should be buttonized.
4978 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
4981 (defsubst gnus-article-edit-part (handles &optional current-id)
4982 "Edit an article in order to delete a mime part.
4983 This function is exclusively used by `gnus-mime-save-part-and-strip'
4984 and `gnus-mime-delete-part', and not provided at run-time normally."
4985 (gnus-article-edit-article
4987 (buffer-disable-undo)
4988 (let ((mail-parse-charset (or gnus-article-charset
4989 ',gnus-newsgroup-charset))
4990 (mail-parse-ignored-charsets
4991 (or gnus-article-ignored-charsets
4992 ',gnus-newsgroup-ignored-charsets))
4993 (mbl mml-buffer-list))
4994 (setq mml-buffer-list nil)
4995 ;; A new text must be inserted before deleting existing ones
4996 ;; at the end so as not to move existing markers of which
4997 ;; the insertion type is t.
5001 (goto-char (point-max))
5002 (insert-buffer-substring gnus-original-article-buffer)))
5003 (mime-to-mml ',handles)
5004 (setq gnus-article-mime-handles nil)
5005 (let ((mbl1 mml-buffer-list))
5006 (setq mml-buffer-list mbl)
5007 (set (make-local-variable 'mml-buffer-list) mbl1))
5008 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5009 `(lambda (no-highlight)
5010 (let ((mail-parse-charset (or gnus-article-charset
5011 ',gnus-newsgroup-charset))
5012 (message-options message-options)
5013 (message-options-set-recipient)
5014 (mail-parse-ignored-charsets
5015 (or gnus-article-ignored-charsets
5016 ',gnus-newsgroup-ignored-charsets)))
5018 (mml-destroy-buffers)
5019 (remove-hook 'kill-buffer-hook
5020 'mml-destroy-buffers t)
5021 (kill-local-variable 'mml-buffer-list))
5022 (gnus-summary-edit-article-done
5023 ,(or (mail-header-references gnus-current-headers) "")
5024 ,(gnus-group-read-only-p)
5025 ,gnus-summary-buffer no-highlight))
5027 ;; Force buttonizing this part.
5028 (let ((gnus-mime-buttonized-part-id current-id))
5029 (gnus-article-edit-done))
5030 (gnus-configure-windows 'article)
5032 (when (and current-id (integerp gnus-auto-select-part))
5033 (gnus-article-jump-to-part
5034 (min (max (+ current-id gnus-auto-select-part) 1)
5035 (with-current-buffer gnus-article-buffer
5036 (length gnus-article-mime-handle-alist)))))))
5038 (defun gnus-mime-replace-part (file)
5039 "Replace MIME part under point with an external body."
5040 ;; Useful if file has already been saved to disk
5043 (read-file-name "Replace MIME part with file: "
5044 (or mm-default-directory default-directory)
5046 (gnus-mime-save-part-and-strip file))
5048 (defun gnus-mime-save-part-and-strip (&optional file)
5049 "Save the MIME part under point then replace it with an external body.
5050 If FILE is given, use it for the external part."
5052 (gnus-article-check-buffer)
5053 (when (gnus-group-read-only-p)
5054 (error "The current group does not support deleting of parts"))
5055 (when (mm-complicated-handles gnus-article-mime-handles)
5057 The current article has a complicated MIME structure, giving up..."))
5058 (let* ((data (get-text-property (point) 'gnus-data))
5059 (id (get-text-property (point) 'gnus-part))
5060 (handles gnus-article-mime-handles))
5063 (and data (mm-save-part data "Delete MIME part and save to: "))))
5065 (with-current-buffer (mm-handle-buffer data)
5067 (insert "Content-Type: " (mm-handle-media-type data))
5068 (mml-insert-parameter-string (cdr (mm-handle-type data))
5070 ;; Add a filename for the sake of saving the part again.
5071 (mml-insert-parameter
5072 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5074 (insert "Content-ID: " (message-make-message-id) "\n")
5075 (insert "Content-Transfer-Encoding: binary\n")
5078 (cdr (mm-make-handle nil
5079 `("message/external-body"
5080 (access-type . "LOCAL-FILE")
5082 ;; (set-buffer gnus-summary-buffer)
5083 (gnus-article-edit-part handles id))))
5085 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5086 ;; parts...>') but with stripping would be nice.
5088 (defun gnus-mime-delete-part ()
5089 "Delete the MIME part under point.
5090 Replace it with some information about the removed part."
5092 (gnus-article-check-buffer)
5093 (when (gnus-group-read-only-p)
5094 (error "The current group does not support deleting of parts"))
5095 (when (mm-complicated-handles gnus-article-mime-handles)
5097 The current article has a complicated MIME structure, giving up..."))
5098 (when (or gnus-expert-user
5099 (gnus-yes-or-no-p "\
5100 Deleting parts may malfunction or destroy the article; continue? "))
5101 (let* ((data (get-text-property (point) 'gnus-data))
5102 (id (get-text-property (point) 'gnus-part))
5103 (handles gnus-article-mime-handles)
5105 (let ((desc (mm-handle-description data)))
5107 (mail-decode-encoded-word-string desc))))
5108 (filename (or (mm-handle-filename data) "(none)"))
5109 (type (mm-handle-media-type data)))
5111 (error "No MIME part under point"))
5112 (with-current-buffer (mm-handle-buffer data)
5113 (let ((bsize (buffer-size)))
5118 "| The following attachment has been deleted:\n"
5120 "| Type: " type "\n"
5121 "| Filename: " filename "\n"
5122 "| Size (encoded): " (format "%s byte%s\n"
5123 bsize (if (= bsize 1)
5127 (concat "| Description: " description "\n"))
5130 (cdr (mm-make-handle
5131 nil `("text/plain" (charset . gnus-decoded)) nil nil
5133 (format "Deleted attachment (%s bytes)" bsize))))))
5134 ;; (set-buffer gnus-summary-buffer)
5135 (gnus-article-edit-part handles id))))
5137 (defun gnus-mime-save-part ()
5138 "Save the MIME part under point."
5140 (gnus-article-check-buffer)
5141 (let ((data (get-text-property (point) 'gnus-data)))
5143 (mm-save-part data))))
5145 (defun gnus-mime-pipe-part (&optional cmd)
5146 "Pipe the MIME part under point to a process.
5147 Use CMD as the process."
5149 (gnus-article-check-buffer)
5150 (let ((data (get-text-property (point) 'gnus-data)))
5152 (mm-pipe-part data cmd))))
5154 (defun gnus-mime-view-part ()
5155 "Interactively choose a viewing method for the MIME part under point."
5157 (gnus-article-check-buffer)
5158 (let ((data (get-text-property (point) 'gnus-data)))
5160 (setq gnus-article-mime-handles
5162 gnus-article-mime-handles (setq data (copy-sequence data))))
5163 (mm-interactively-view-part data))))
5165 (defun gnus-mime-view-part-as-type-internal ()
5166 (gnus-article-check-buffer)
5167 (let* ((handle (get-text-property (point) 'gnus-data))
5169 ;; Content-Type: foo/bar; name=...
5170 (mail-content-type-get (mm-handle-type handle) 'name)
5171 ;; Content-Disposition: attachment; filename=...
5172 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5173 (def-type (and name (mm-default-file-encoding name))))
5174 (or (and def-type (cons def-type 0))
5176 (equal (mm-handle-media-supertype handle) "text")
5177 '("text/plain" . 0))
5178 '("application/octet-stream" . 0))))
5180 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5181 "Choose a MIME media type, and view the part as such.
5182 If non-nil, PRED is a predicate to use during completion to limit the
5183 available media-types."
5187 (let ((default (gnus-mime-view-part-as-type-internal)))
5188 (gnus-completing-read
5191 (gnus-remove-if-not pred (mailcap-mime-types))
5192 (mailcap-mime-types))
5195 (gnus-article-check-buffer)
5196 (let ((handle (get-text-property (point) 'gnus-data)))
5198 (when (equal (mm-handle-media-type handle) "message/external-body")
5199 (unless (mm-handle-cache handle)
5200 (mm-extern-cache-contents handle))
5201 (setq handle (mm-handle-cache handle)))
5203 (mm-make-handle (mm-handle-buffer handle)
5204 (cons mime-type (cdr (mm-handle-type handle)))
5205 (mm-handle-encoding handle)
5206 (mm-handle-undisplayer handle)
5207 (mm-handle-disposition handle)
5208 (mm-handle-description handle)
5210 (mm-handle-id handle)))
5211 (setq gnus-article-mime-handles
5212 (mm-merge-handles gnus-article-mime-handles handle))
5213 (when (mm-handle-displayed-p handle)
5214 (mm-remove-part handle))
5215 (gnus-mm-display-part handle))))
5217 (defun gnus-mime-copy-part (&optional handle arg)
5218 "Put the MIME part under point into a new buffer.
5219 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5221 (interactive (list nil current-prefix-arg))
5222 (gnus-article-check-buffer)
5224 (setq handle (get-text-property (point) 'gnus-data)))
5226 (let ((filename (mm-handle-filename handle))
5227 contents dont-decode charset coding-system)
5228 (mm-with-unibyte-buffer
5229 (mm-insert-part handle)
5230 (setq contents (or (condition-case nil
5231 (mm-decompress-buffer filename nil 'sig)
5233 (setq dont-decode t)
5236 (setq filename (cond (filename (file-name-nondirectory filename))
5237 (dont-decode "*raw data*")
5242 (unless (setq charset (mail-content-type-get
5243 (mm-handle-type handle) 'charset))
5244 (unless (setq coding-system (mm-with-unibyte-buffer
5246 (mm-find-buffer-file-coding-system)))
5247 (setq charset gnus-newsgroup-charset))))
5249 (setq charset (or (cdr (assq arg
5250 gnus-summary-show-article-charset-alist))
5251 (read-coding-system "Charset: ")))))
5252 (switch-to-buffer (generate-new-buffer filename))
5253 (if (or coding-system
5255 (setq coding-system (mm-charset-to-coding-system
5257 (not (eq coding-system 'ascii))))
5259 (mm-enable-multibyte)
5260 (insert (decode-coding-string contents coding-system))
5261 (setq buffer-file-coding-system last-coding-system-used))
5262 (mm-disable-multibyte)
5264 (setq buffer-file-coding-system mm-binary-coding-system))
5265 ;; We do it this way to make `normal-mode' set the appropriate mode.
5268 (setq buffer-file-name (expand-file-name filename))
5270 (setq buffer-file-name nil))
5271 (goto-char (point-min)))))
5273 (defun gnus-mime-print-part (&optional handle filename)
5274 "Print the MIME part under point."
5275 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5276 (gnus-article-check-buffer)
5277 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5278 (contents (and handle (mm-get-part handle)))
5279 (file (make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5280 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5285 (mm-save-part-to-file handle file)
5286 (call-process shell-file-name nil
5287 (generate-new-buffer " *mm*")
5289 shell-command-switch
5291 printer file (mm-handle-type handle))))
5295 (gnus-print-buffer))
5296 (ps-despool filename)))))
5298 (defun gnus-mime-inline-part (&optional handle arg)
5299 "Insert the MIME part under point into the current buffer.
5300 Compressed files like .gz and .bz2 are decompressed."
5301 (interactive (list nil current-prefix-arg))
5302 (gnus-article-check-buffer)
5303 (let* ((inhibit-read-only t)
5305 (btn ;; position where the MIME button exists
5307 (if (eq handle (get-text-property b 'gnus-data))
5310 (or (text-property-any (point) (point-max) 'gnus-data handle)
5311 (text-property-any (point-min) (point) 'gnus-data handle)))
5312 (setq handle (get-text-property b 'gnus-data))
5318 (setq start (next-single-property-change btn 'gnus-data
5320 btn (previous-single-property-change start
5323 (if (and (not arg) (mm-handle-undisplayer handle))
5325 (setq b (copy-marker b)
5326 btn (copy-marker btn))
5327 (mm-remove-part handle))
5331 (if (mm-handle-undisplayer handle)
5332 (mm-remove-part handle)))
5333 ((mm-handle-undisplayer handle)
5334 (mm-remove-part handle)))
5337 ;; This is a header button.
5339 (mm-display-inline handle))
5340 ;; Toggle the button appearance between `[button]...' and `[button]'.
5342 (setq btn (prog1 (marker-position btn)
5343 (set-marker btn nil))))
5345 (let ((displayed-p (mm-handle-displayed-p handle)))
5346 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5350 (next-single-property-change (point) 'gnus-data nil (point-max)))
5351 (setq start (point))
5352 (if (search-backward "\n\n" nil t)
5355 (unless (or displayed-p (eolp))
5356 ;; Add extra newline.
5357 (insert (propertize (buffer-substring (1- start) start)
5358 'gnus-undeletable t))))
5359 ;; We're in the article header.
5361 (dolist (ovl (overlays-in btn (point)))
5362 (overlay-put ovl 'gnus-button-attachment-extra t)
5363 (overlay-put ovl 'face nil))
5365 (message-narrow-to-field)
5366 (let ((gnus-treatment-function-alist
5367 '((gnus-treat-highlight-headers
5368 gnus-article-highlight-headers))))
5369 (gnus-treat-article 'head)))))
5371 (setq b (prog1 (marker-position b)
5372 (set-marker b nil))))
5375 (defun gnus-mime-set-charset-parameters (handle charset)
5376 "Set CHARSET to parameters in HANDLE.
5377 CHARSET may either be a string or a symbol."
5378 (unless (stringp charset)
5379 (setq charset (symbol-name charset)))
5380 (if (stringp (car handle))
5381 (dolist (h (cdr handle))
5382 (gnus-mime-set-charset-parameters h charset))
5383 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5384 "message/external-body")
5386 (unless (mm-handle-cache handle)
5387 (mm-extern-cache-contents handle))
5388 (mm-handle-cache handle))
5390 (param (assq 'charset (cdr type))))
5392 (setcdr param charset)
5393 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5395 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5396 "Insert the MIME part under point into the current buffer using the
5398 (interactive (list nil current-prefix-arg))
5399 (gnus-article-check-buffer)
5400 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5401 (fun (get-text-property (point) 'gnus-callback))
5402 (gnus-newsgroup-ignored-charsets 'gnus-all)
5403 charset form preferred parts)
5410 gnus-summary-show-article-charset-alist))
5411 (read-coding-system "Charset: "))))
5412 (if (mm-handle-undisplayer handle)
5413 (mm-remove-part handle)))
5414 (gnus-mime-set-charset-parameters handle charset)
5415 (when (and (consp (setq form (cdr-safe fun)))
5416 (setq form (ignore-errors
5417 (assq 'gnus-mime-display-alternative form)))
5418 (setq preferred (caddr form))
5420 (when (eq (car preferred) 'quote)
5421 (setq preferred (cadr preferred)))
5422 (not (equal preferred
5423 (get-text-property (point) 'gnus-data))))
5424 (setq parts (get-text-property (point) 'gnus-part))
5425 (setq parts (cdr (assq parts
5426 gnus-article-mime-handle-alist)))
5427 (equal (mm-handle-media-type parts) "multipart/alternative")
5428 (setq parts (reverse (cdr parts))))
5430 (list 'quote (or (cadr (member preferred parts))
5432 (funcall fun handle)))))
5434 (defun gnus-mime-view-part-externally (&optional handle)
5435 "View the MIME part under point with an external viewer."
5437 (gnus-article-check-buffer)
5438 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5439 (mm-inlined-types nil)
5440 (mail-parse-charset gnus-newsgroup-charset)
5441 (mail-parse-ignored-charsets
5442 (with-current-buffer gnus-summary-buffer
5443 gnus-newsgroup-ignored-charsets))
5444 (type (mm-handle-media-type handle))
5445 (method (mailcap-mime-info type))
5446 (mm-enable-external t))
5447 (if (not (stringp method))
5448 (gnus-mime-view-part-as-type
5449 nil (lambda (type) (stringp (mailcap-mime-info type))))
5451 (mm-display-part handle nil t)))))
5453 (defun gnus-mime-view-part-internally (&optional handle)
5454 "View the MIME part under point with an internal viewer.
5455 If no internal viewer is available, use an external viewer."
5457 (gnus-article-check-buffer)
5458 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5459 (mm-inlined-types '(".*"))
5460 (mm-inline-large-images t)
5461 (mail-parse-charset gnus-newsgroup-charset)
5462 (mail-parse-ignored-charsets
5463 (with-current-buffer gnus-summary-buffer
5464 gnus-newsgroup-ignored-charsets))
5465 (inhibit-read-only t))
5466 (if (not (mm-inlinable-p handle))
5467 (gnus-mime-view-part-as-type
5468 nil (lambda (type) (mm-inlinable-p handle type)))
5470 (gnus-bind-mm-vars (mm-display-part handle nil t))))))
5472 (defun gnus-mime-action-on-part (&optional action)
5473 "Do something with the MIME attachment at (point)."
5475 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5476 (gnus-article-check-buffer)
5477 (let ((action-pair (assoc action gnus-mime-action-alist)))
5479 (funcall (cdr action-pair)))))
5481 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5482 "Call FUNCTION on MIME part N.
5483 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5484 If INTERACTIVE, call FUNCTION interactively."
5486 ;; Check whether the article is displayed.
5487 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5488 (setq window (get-buffer-window gnus-article-buffer t))
5489 (frame-visible-p (setq frame (window-frame window))))
5490 (error "No article is displayed"))
5491 (with-current-buffer gnus-article-buffer
5492 ;; Check whether the article displays the right contents.
5493 (unless (with-current-buffer gnus-summary-buffer
5494 (eq gnus-current-article (gnus-summary-article-number)))
5495 (error "You should select the right article first"))
5497 (setq n (prefix-numeric-value n))
5499 (setq n (or (get-text-property pt 'gnus-part)
5501 (get-text-property (1- pt) 'gnus-part))
5502 (get-text-property (prog2
5508 (or (and (setq pt (previous-single-property-change
5511 (next-single-property-change (point) 'gnus-part)
5515 ;; Check whether the specified part exists.
5516 (when (> n (length gnus-article-mime-handle-alist))
5517 (error "No such part")))
5520 ;; To select the window is needed so that the cursor
5521 ;; might be visible on the MIME button.
5522 (select-window (prog1
5524 (setq window (selected-window))
5525 ;; Article may be displayed in the other frame.
5526 (select-frame-set-input-focus
5529 (setq frame (selected-frame))))))
5530 (when (gnus-article-goto-part n)
5531 ;; We point the cursor and the arrow at the MIME button
5532 ;; when the `function' prompt the user for something.
5533 (unless (and (pos-visible-in-window-p)
5534 (> (count-lines (point) (window-end))
5535 (/ (1- (window-height)) 3)))
5536 (recenter (/ (1- (window-height)) 3)))
5537 (let ((cursor-in-non-selected-windows t)
5538 (overlay-arrow-string "=>")
5539 (overlay-arrow-position (point-marker)))
5542 ((and no-handle interactive)
5543 (call-interactively function))
5548 function (get-text-property (point) 'gnus-data)))
5551 (get-text-property (point) 'gnus-data))))
5552 (set-marker overlay-arrow-position nil)
5553 (unless gnus-auto-select-part
5554 (select-frame-set-input-focus frame)
5555 (select-window window))))
5557 (if gnus-inhibit-mime-unbuttonizing
5558 ;; This is the default though the program shouldn't reach here.
5559 (error "No such part")
5560 ;; The part which doesn't have the MIME button is selected.
5561 ;; So, we display all the buttons and redo it.
5562 (let ((gnus-inhibit-mime-unbuttonizing t))
5563 (gnus-summary-show-article)
5564 (gnus-article-part-wrapper n function no-handle))))))
5566 (defun gnus-article-pipe-part (n)
5567 "Pipe MIME part N, which is the numerical prefix."
5569 (gnus-article-part-wrapper n 'mm-pipe-part))
5571 (defun gnus-article-save-part (n)
5572 "Save MIME part N, which is the numerical prefix."
5574 (gnus-article-part-wrapper n 'mm-save-part))
5576 (defun gnus-article-interactively-view-part (n)
5577 "View MIME part N interactively, which is the numerical prefix."
5579 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5581 (defun gnus-article-copy-part (n)
5582 "Copy MIME part N, which is the numerical prefix."
5584 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5586 (defun gnus-article-view-part-as-charset (n)
5587 "View MIME part N using a specified charset.
5588 N is the numerical prefix."
5590 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5592 (defun gnus-article-view-part-externally (n)
5593 "View MIME part N externally, which is the numerical prefix."
5595 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5597 (defun gnus-article-inline-part (n)
5598 "Inline MIME part N, which is the numerical prefix."
5600 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5602 (defun gnus-article-save-part-and-strip (n)
5603 "Save MIME part N and replace it with an external body.
5604 N is the numerical prefix."
5606 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5608 (defun gnus-article-replace-part (n)
5609 "Replace MIME part N with an external body.
5610 N is the numerical prefix."
5612 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5614 (defun gnus-article-delete-part (n)
5615 "Delete MIME part N and add some information about the removed part.
5616 N is the numerical prefix."
5618 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5620 (defun gnus-article-view-part-as-type (n)
5621 "Choose a MIME media type, and view part N as such.
5622 N is the numerical prefix."
5624 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5626 (defun gnus-article-mime-match-handle-first (condition)
5629 (dolist (ihandle gnus-article-mime-handle-alist)
5631 ((functionp condition)
5632 (funcall condition (cdr ihandle)))
5633 ((eq condition 'undisplayed)
5634 (not (or (mm-handle-undisplayer (cdr ihandle))
5635 (equal (mm-handle-media-type (cdr ihandle))
5636 "multipart/alternative"))))
5637 ((eq condition 'undisplayed-alternative)
5638 (not (mm-handle-undisplayer (cdr ihandle))))
5640 (gnus-article-goto-part (car ihandle))
5641 (or (not n) (< (car ihandle) n)))
5642 (setq n (car ihandle))))
5646 (defun gnus-article-view-part (&optional n)
5647 "View MIME part N, which is the numerical prefix.
5648 If the part is already shown, hide the part. If N is nil, view
5651 (with-current-buffer gnus-article-buffer
5652 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5653 gnus-article-mime-match-handle-function)))
5654 (when (> n (length gnus-article-mime-handle-alist))
5655 (error "No such part"))
5656 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5657 (when (gnus-article-goto-part n)
5658 (if (equal (car handle) "multipart/alternative")
5660 (beginning-of-line) ;; Make it toggle subparts
5661 (gnus-article-press-button))
5662 (when (eq (gnus-mm-display-part handle) 'internal)
5663 (gnus-set-window-start)))))))
5665 (defsubst gnus-article-mime-total-parts ()
5666 (if (bufferp (car gnus-article-mime-handles))
5668 (1- (length gnus-article-mime-handles))))
5670 (defun gnus-mm-display-part (handle)
5671 "Display HANDLE and fix MIME button."
5672 (let ((id (get-text-property (point) 'gnus-part))
5674 (inhibit-read-only t)
5675 (window (selected-window))
5676 (mail-parse-charset gnus-newsgroup-charset)
5677 (mail-parse-ignored-charsets
5678 (if (gnus-buffer-live-p gnus-summary-buffer)
5679 (with-current-buffer gnus-summary-buffer
5680 gnus-newsgroup-ignored-charsets)
5685 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5689 (setq start (next-single-property-change point 'gnus-data
5691 point (previous-single-property-change start 'gnus-data))
5692 (if (mm-handle-displayed-p handle)
5693 ;; This will remove the part.
5694 (setq point (copy-marker point)
5695 retval (mm-display-part handle))
5696 (let ((part (or (and (mm-inlinable-p handle)
5697 (mm-inlined-p handle)
5701 (setq retval (mm-display-part handle)))
5702 (unless (zerop (buffer-size))
5703 (buffer-string))))))
5706 ;; This is a header button.
5708 (cond ((stringp part)
5710 (narrow-to-region (point)
5713 (unless (bolp) (insert "\n"))
5715 (gnus-treat-article nil id
5716 (gnus-article-mime-total-parts)
5717 (mm-handle-media-type handle))
5718 (mm-handle-set-undisplayer
5721 (let ((inhibit-read-only t))
5722 (delete-region ,(copy-marker (point-min) t)
5723 ,(point-max-marker)))))))
5725 (mm-display-inline handle))))))
5726 (when (markerp point)
5727 (setq point (prog1 (marker-position point)
5728 (set-marker point nil))))
5730 ;; Toggle the button appearance between `[button]...' and `[button]'.
5731 (let ((displayed-p (mm-handle-displayed-p handle)))
5732 (gnus-insert-mime-button handle id (list displayed-p))
5735 (next-single-property-change (point) 'gnus-data nil (point-max)))
5736 (setq start (point))
5737 (if (search-backward "\n\n" nil t)
5740 (unless (or displayed-p (eolp))
5741 ;; Add extra newline.
5742 (insert (propertize (buffer-substring (1- start) start)
5743 'gnus-undeletable t))))
5744 ;; We're in the article header.
5746 (dolist (ovl (overlays-in point (point)))
5747 (overlay-put ovl 'gnus-button-attachment-extra t)
5748 (overlay-put ovl 'face nil))
5750 (message-narrow-to-field)
5751 (let ((gnus-treatment-function-alist
5752 '((gnus-treat-highlight-headers
5753 gnus-article-highlight-headers))))
5754 (gnus-treat-article 'head)))))
5756 (if (window-live-p window)
5757 (select-window window)))
5760 (defun gnus-article-goto-part (n)
5761 "Go to MIME part N."
5762 (when gnus-break-pages
5766 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5767 ;; There may be header buttons.
5768 (text-property-any (point-min) (point) 'gnus-part n)))
5769 part handle end next handles)
5772 (if (setq handle (get-text-property start 'gnus-data))
5774 ;; Go to the displayed subpart, assuming this is
5775 ;; multipart/alternative.
5778 (while (and (not handle)
5781 (setq next (text-property-not-all part end
5784 handle (get-text-property part 'gnus-data))
5785 (push (cons handle part) handles)
5786 (unless (mm-handle-displayed-p handle)
5788 part (text-property-any part end 'gnus-data nil))))
5790 ;; No subpart is displayed, so we find preferred one.
5792 (cdr (assq (mm-preferred-alternative
5793 (nreverse (mapcar 'car handles)))
5796 (goto-char (1+ part))
5798 (when gnus-break-pages
5799 (gnus-narrow-to-page))))
5801 (defun gnus-insert-mime-button (handle id &optional displayed)
5802 (let ((gnus-tmp-name
5803 (or (mm-handle-filename handle)
5804 (mail-content-type-get (mm-handle-type handle) 'url)
5807 (gnus-tmp-type (mm-handle-media-type handle))
5808 (gnus-tmp-description (or (mm-handle-description handle) ""))
5810 (if (if displayed (car displayed)
5811 (mm-handle-displayed-p handle))
5813 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5815 gnus-tmp-type-long b e)
5816 (when (string-match ".*/" gnus-tmp-name)
5817 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5818 (setq gnus-tmp-type-long (concat gnus-tmp-type
5819 (and (not (equal gnus-tmp-name ""))
5820 (concat "; " gnus-tmp-name))))
5821 (unless (equal gnus-tmp-description "")
5822 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5825 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5826 `(keymap ,gnus-mime-button-map
5827 gnus-callback gnus-mm-display-part
5828 gnus-part ,gnus-tmp-id
5829 article-type annotation
5833 ;; Exclude a newline.
5836 (when gnus-article-button-face
5837 (overlay-put (make-overlay b e nil t)
5838 'face gnus-article-button-face))
5839 (widget-convert-button
5842 :action 'gnus-widget-press-button
5843 :button-keymap gnus-mime-button-map
5847 "%S: %s the MIME part; %S: more options"
5849 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5853 (defun gnus-widget-press-button (elems _el)
5854 (goto-char (widget-get elems :from))
5855 (gnus-article-press-button))
5857 (defvar gnus-displaying-mime nil)
5859 (defun gnus-display-mime (&optional ihandles)
5860 "Display the MIME parts."
5862 (save-selected-window
5863 (let ((window (get-buffer-window gnus-article-buffer))
5866 (select-window window)
5867 ;; We have to do this since selecting the window
5868 ;; may change the point. So we set the window point.
5869 (set-window-point window point)))
5870 (let ((handles ihandles)
5871 (inhibit-read-only t))
5873 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5874 (when gnus-article-emulate-mime
5875 (mm-uu-dissect-text-parts handles)))
5876 (gnus-article-emulate-mime
5877 (setq handles (mm-uu-dissect))))
5878 (when (and (not ihandles)
5879 (not gnus-displaying-mime))
5880 ;; Top-level call; we clean up.
5881 (when gnus-article-mime-handles
5882 (mm-destroy-parts gnus-article-mime-handles)
5883 (setq gnus-article-mime-handle-alist nil));; A trick.
5884 (setq gnus-article-mime-handles handles)
5885 ;; We allow users to glean info from the handles.
5886 (when gnus-article-mime-part-function
5887 (gnus-mime-part-function handles)))
5889 (or (not (stringp (car handles)))
5892 (when (and (not ihandles)
5893 (not gnus-displaying-mime))
5894 ;; Clean up for mime parts.
5896 (delete-region (point) (point-max)))
5897 (let ((gnus-displaying-mime t))
5898 (gnus-mime-display-part handles)))
5901 (narrow-to-region (point) (point-max))
5902 (gnus-treat-article nil 1 1 "text/plain")
5905 ;; Highlight the headers.
5909 (narrow-to-region (point-min) (point))
5910 (gnus-article-save-original-date
5911 (gnus-treat-article 'head)))))))
5912 ;; Cope with broken MIME messages.
5913 (goto-char (point-max))
5917 (defcustom gnus-mime-display-multipart-as-mixed nil
5918 "Display \"multipart\" parts as \"multipart/mixed\".
5920 If t, it overrides nil values of
5921 `gnus-mime-display-multipart-alternative-as-mixed' and
5922 `gnus-mime-display-multipart-related-as-mixed'."
5923 :group 'gnus-article-mime
5926 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5927 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5929 :group 'gnus-article-mime
5932 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5933 "Display \"multipart/related\" parts as \"multipart/mixed\".
5935 If displaying \"text/html\" is discouraged \(see
5936 `mm-discouraged-alternatives') images or other material inside a
5937 \"multipart/related\" part might be overlooked when this variable is nil."
5939 :group 'gnus-article-mime
5942 (defcustom gnus-mime-display-attachment-buttons-in-header t
5943 "Add attachment buttons in the end of the header of an article.
5944 Since MIME attachments tend to be put at the end of an article, we may
5945 overlook them if there is a huge body. This option offers you a copy
5946 of all non-inlinable MIME parts as buttons shown in front of an article.
5947 If nil, don't show those extra buttons."
5949 :group 'gnus-article-mime
5952 (defun gnus-mime-display-part (handle)
5954 ;; Maybe a broken MIME message.
5957 ((not (stringp (car handle)))
5958 (gnus-mime-display-single handle))
5959 ;; User-defined multipart
5960 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5961 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5963 ;; multipart/alternative
5964 ((and (equal (car handle) "multipart/alternative")
5965 (not (or gnus-mime-display-multipart-as-mixed
5966 gnus-mime-display-multipart-alternative-as-mixed)))
5967 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5968 (push (cons id handle) gnus-article-mime-handle-alist)
5969 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5970 ;; multipart/related
5971 ((and (equal (car handle) "multipart/related")
5972 (not (or gnus-mime-display-multipart-as-mixed
5973 gnus-mime-display-multipart-related-as-mixed)))
5974 (gnus-mime-display-part (cadr handle)))
5975 ((equal (car handle) "multipart/signed")
5976 (gnus-add-wash-type 'signed)
5977 (gnus-mime-display-security handle))
5978 ((equal (car handle) "multipart/encrypted")
5979 (gnus-add-wash-type 'encrypted)
5980 (gnus-mime-display-security handle))
5981 ;; Other multiparts are handled like multipart/mixed.
5983 (gnus-mime-display-mixed (cdr handle)))))
5985 (defun gnus-mime-part-function (handles)
5986 (if (stringp (car handles))
5987 (mapcar 'gnus-mime-part-function (cdr handles))
5988 (funcall gnus-article-mime-part-function handles)))
5990 (defun gnus-mime-display-mixed (handles)
5991 (mapcar 'gnus-mime-display-part handles))
5993 (defun gnus-mime-display-single (handle)
5994 (let ((type (mm-handle-media-type handle))
5995 (ignored gnus-ignored-mime-types)
6001 (when (string-match (pop ignored) type)
6002 (throw 'ignored nil)))
6003 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6004 (with-current-buffer gnus-summary-buffer
6005 gnus-inhibit-images)
6006 gnus-inhibit-images)
6007 (string-match "\\`image/" type)))
6008 (setq not-attachment
6009 (and (not (mm-inline-override-p handle))
6010 (or (not (mm-handle-disposition handle))
6011 (equal (car (mm-handle-disposition handle))
6013 (mm-attachment-override-p handle))))
6014 (mm-automatic-display-p handle)
6016 (mm-inlinable-p handle)
6017 (mm-inlined-p handle))
6018 (mm-automatic-external-display-p type)))
6020 (when (equal (mm-handle-media-supertype handle) "text")
6022 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6025 (setq id (1+ (length gnus-article-mime-handle-alist)))
6026 (push (cons id handle) gnus-article-mime-handle-alist))
6028 (equal (mm-handle-media-supertype handle) "message"))
6031 (cond ((not (bolp)) 2)
6032 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6034 (when (or (not display)
6035 (not (gnus-unbuttonized-mime-type-p type))
6036 (eq id gnus-mime-buttonized-part-id))
6037 (gnus-insert-mime-button
6038 handle id (list (or display (and not-attachment text)))))
6042 (let ((mail-parse-charset gnus-newsgroup-charset)
6043 (mail-parse-ignored-charsets
6044 (save-excursion (condition-case ()
6045 (set-buffer gnus-summary-buffer)
6047 gnus-newsgroup-ignored-charsets)))
6048 (gnus-bind-mm-vars (mm-display-part handle t))))
6049 ((and text not-attachment)
6050 (mm-display-inline handle)))
6051 (goto-char (point-max))
6052 (if (string-match "\\`image/" type)
6053 (gnus-article-insert-newline)
6055 (= (skip-chars-backward "\n") -1)
6056 (unless (eobp) (forward-char 1)))
6057 (gnus-article-insert-newline)
6058 (put-text-property (point) (point-max) 'gnus-undeletable t))
6059 (goto-char (point-max)))
6063 (narrow-to-region beg (point))
6064 (if (eq handle gnus-article-mime-handles)
6065 ;; The format=flowed case.
6066 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6067 ;; Don't count signature parts that are never displayed.
6068 ;; The part number should be re-calculated supposing this
6069 ;; might be a message/rfc822 part.
6071 (dolist (part gnus-article-mime-handles)
6072 (unless (or (stringp part)
6073 (equal (car (mm-handle-type part))
6074 "application/pgp-signature"))
6075 (push part handles)))
6077 nil (length (memq handle handles)) (length handles)
6078 (mm-handle-media-type handle)))))))))))
6080 (defun gnus-unbuttonized-mime-type-p (type)
6081 "Say whether TYPE is to be unbuttonized."
6082 (unless gnus-inhibit-mime-unbuttonizing
6084 (let ((types gnus-unbuttonized-mime-types))
6086 (when (string-match (pop types) type)
6087 (throw 'found t)))))
6089 (let ((types gnus-buttonized-mime-types))
6091 (when (string-match (pop types) type)
6092 (throw 'found t)))))))))
6094 (defun gnus-article-insert-newline ()
6095 "Insert a newline, but mark it as undeletable."
6096 (put-text-property (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
6098 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
6099 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
6102 handle (inhibit-read-only t) from begend not-pref)
6103 (save-window-excursion
6106 (narrow-to-region (car ibegend)
6109 (goto-char (car ibegend))
6112 (delete-region (point-min) (point-max))
6113 (mm-remove-parts handles))
6114 (setq begend (list (point-marker)))
6116 (unless (setq not-pref (cadr (member preferred ihandles)))
6117 (setq not-pref (car ihandles)))
6120 (not (gnus-unbuttonized-mime-type-p
6121 "multipart/alternative")))
6122 (add-text-properties
6125 (insert (format "%d. " id))
6129 (unless ,(not ibegend)
6130 (setq gnus-article-mime-handle-alist
6131 ',gnus-article-mime-handle-alist))
6132 (gnus-mime-display-alternative
6133 ',ihandles ',not-pref ',begend ,id))
6134 keymap ,gnus-mime-button-map
6135 mouse-face ,gnus-article-mouse-face
6136 face ,gnus-article-button-face
6138 article-type multipart
6140 (widget-convert-button 'link from (point)
6141 :action 'gnus-widget-press-button)
6143 (while (setq handle (pop handles))
6144 (add-text-properties
6147 (insert (format "(%c) %-18s"
6148 (if (equal handle preferred) ?* ? )
6149 (mm-handle-media-type handle)))
6153 (unless ,(not ibegend)
6154 (setq gnus-article-mime-handle-alist
6155 ',gnus-article-mime-handle-alist))
6156 (gnus-mime-display-alternative
6157 ',ihandles ',handle ',begend ,id))
6158 keymap ,gnus-mime-button-map
6159 mouse-face ,gnus-article-mouse-face
6160 face ,gnus-article-button-face
6164 (widget-convert-button 'link from (point)
6165 :action 'gnus-widget-press-button)
6169 (if (stringp (car preferred))
6170 (gnus-display-mime preferred)
6171 (let ((mail-parse-charset gnus-newsgroup-charset)
6172 (mail-parse-ignored-charsets
6173 (with-current-buffer gnus-summary-buffer
6174 gnus-newsgroup-ignored-charsets)))
6175 (gnus-bind-mm-vars (mm-display-part preferred))
6179 (narrow-to-region (car begend) (point-max))
6181 nil (length gnus-article-mime-handle-alist)
6182 (gnus-article-mime-total-parts)
6183 (mm-handle-media-type preferred))))))
6184 (goto-char (point-max))
6185 (setcdr begend (point-marker)))))
6188 ;; Redraw attachment buttons in the header.
6189 (when gnus-mime-display-attachment-buttons-in-header
6190 (gnus-mime-buttonize-attachments-in-header)))
6192 (defconst gnus-article-wash-status-strings
6193 (let ((alist '((cite "c" "Possible hidden citation text"
6194 " " "All citation text visible")
6195 (headers "h" "Hidden headers"
6196 " " "All headers visible.")
6197 (pgp "p" "Encrypted or signed message status hidden"
6198 " " "No hidden encryption nor digital signature status")
6199 (signature "s" "Signature has been hidden"
6200 " " "Signature is visible")
6201 (overstrike "o" "Overstrike (^H) characters applied"
6202 " " "No overstrike characters applied")
6203 (emphasis "e" "/*_Emphasis_*/ characters applied"
6204 " " "No /*_emphasis_*/ characters applied")))
6206 (dolist (entry alist result)
6207 (let ((key (nth 0 entry))
6208 (on (copy-sequence (nth 1 entry)))
6209 (on-help (nth 2 entry))
6210 (off (copy-sequence (nth 3 entry)))
6211 (off-help (nth 4 entry)))
6212 (put-text-property 0 1 'help-echo on-help on)
6213 (put-text-property 0 1 'help-echo off-help off)
6214 (push (list key on off) result))))
6215 "Alist of strings describing wash status in the mode line.
6216 Each entry has the form (KEY ON OF), where the KEY is a symbol
6217 representing the particular washing function, ON is the string to use
6218 in the article mode line when the washing function is active, and OFF
6219 is the string to use when it is inactive.")
6221 (defun gnus-article-wash-status-entry (key value)
6222 (let ((entry (assoc key gnus-article-wash-status-strings)))
6223 (if value (nth 1 entry) (nth 2 entry))))
6225 (defun gnus-article-wash-status ()
6226 "Return a string which display status of article washing."
6227 (with-current-buffer gnus-article-buffer
6228 (let ((cite (memq 'cite gnus-article-wash-types))
6229 (headers (memq 'headers gnus-article-wash-types))
6230 (boring (memq 'boring-headers gnus-article-wash-types))
6231 (pgp (memq 'pgp gnus-article-wash-types))
6232 (pem (memq 'pem gnus-article-wash-types))
6233 (signed (memq 'signed gnus-article-wash-types))
6234 (encrypted (memq 'encrypted gnus-article-wash-types))
6235 (signature (memq 'signature gnus-article-wash-types))
6236 (overstrike (memq 'overstrike gnus-article-wash-types))
6237 (emphasis (memq 'emphasis gnus-article-wash-types)))
6239 (gnus-article-wash-status-entry 'cite cite)
6240 (gnus-article-wash-status-entry 'headers (or headers boring))
6241 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
6242 (gnus-article-wash-status-entry 'signature signature)
6243 (gnus-article-wash-status-entry 'overstrike overstrike)
6244 (gnus-article-wash-status-entry 'emphasis emphasis)))))
6246 (defun gnus-add-wash-type (type)
6247 "Add a washing of TYPE to the current status."
6248 (add-to-list 'gnus-article-wash-types type))
6250 (defun gnus-delete-wash-type (type)
6251 "Add a washing of TYPE to the current status."
6252 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
6254 (defun gnus-add-image (category image)
6255 "Add IMAGE of CATEGORY to the list of displayed images."
6256 (let ((entry (assq category gnus-article-image-alist)))
6258 (setq entry (list category))
6259 (push entry gnus-article-image-alist))
6260 (nconc entry (list image))))
6262 (defun gnus-delete-images (category)
6263 "Delete all images in CATEGORY."
6264 (let ((entry (assq category gnus-article-image-alist)))
6265 (dolist (image (cdr entry))
6266 (gnus-remove-image image category))
6267 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
6268 (gnus-delete-wash-type category)))
6270 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
6272 (defun gnus-article-maybe-hide-headers ()
6273 "Hide unwanted headers if `gnus-have-all-headers' is nil.
6274 Provided for backwards compatibility."
6275 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
6276 (not (with-current-buffer gnus-summary-buffer
6277 gnus-have-all-headers)))
6278 (not gnus-inhibit-hiding))
6279 (article-hide-headers)))
6281 (declare-function shr-put-image "shr" (data alt &optional flags))
6283 (defun gnus-shr-put-image (data alt &optional flags)
6284 "Put image DATA with a string ALT. Enable image to be deleted."
6285 (let ((image (if flags
6286 (shr-put-image data (propertize (or alt "*")
6287 'gnus-image-category 'shr)
6289 ;; Old `shr-put-image' doesn't take the optional `flags'
6291 (shr-put-image data (propertize (or alt "*")
6292 'gnus-image-category 'shr)))))
6294 (gnus-add-image 'shr image))))
6296 (defun gnus-article-mime-handles (&optional alist id all)
6298 (let ((i 1) newid flat)
6299 (dolist (handle alist flat)
6300 (setq newid (append id (list i))
6302 (if (stringp (car handle))
6303 (setq flat (nconc flat (gnus-article-mime-handles
6304 (cdr handle) newid all)))
6305 (delq (rassq handle all) all)
6306 (setq flat (nconc flat (list (cons newid handle)))))))
6307 (let ((flat (list nil)))
6308 ;; Assume that elements of `gnus-article-mime-handle-alist'
6309 ;; are in the decreasing order, but unnumbered subsidiaries
6310 ;; in each element are in the increasing order.
6311 (dolist (handle (reverse gnus-article-mime-handle-alist))
6312 (if (stringp (cadr handle))
6313 (setq flat (nconc flat (gnus-article-mime-handles
6314 (cddr handle) (list (car handle)) flat)))
6315 (delq (rassq (cdr handle) flat) flat)
6316 (setq flat (nconc flat (list (cons (list (car handle))
6318 (setq flat (cdr flat))
6319 (mapc (lambda (handle)
6321 ;; This is a hidden (i.e. unnumbered) handle.
6324 (1+ (caar gnus-article-mime-handle-alist)))
6325 (push handle gnus-article-mime-handle-alist))
6326 (setcar handle (caar handle))))
6330 (defun gnus-mime-buttonize-attachments-in-header (&optional interactive)
6331 "Show attachments as buttons in the end of the header of an article.
6332 This function toggles the display when called interactively. Note that
6333 buttons to be added to the header are only the ones that aren't inlined
6334 in the body. Use `gnus-header-face-alist' to highlight buttons."
6335 (interactive (list t))
6336 (gnus-with-article-buffer
6337 (let ((case-fold-search t) buttons handle type st)
6341 (article-narrow-to-head)
6342 ;; Header buttons exist?
6343 (while (and (not buttons)
6344 (re-search-forward "^attachments?:[\n ]+" nil t))
6345 (when (get-char-property (match-end 0)
6346 'gnus-button-attachment-extra)
6347 (setq buttons (match-beginning 0))))
6350 ;; Delete header buttons.
6351 (delete-region buttons (if (re-search-forward "^[^ ]" nil t)
6354 (unless (and interactive buttons)
6357 (dolist (button (gnus-article-mime-handles))
6358 (setq handle (cdr button)
6359 type (mm-handle-media-type handle))
6360 (when (or (and (if (gnus-buffer-live-p gnus-summary-buffer)
6361 (with-current-buffer gnus-summary-buffer
6362 gnus-inhibit-images)
6363 gnus-inhibit-images)
6364 (string-match "\\`image/" type))
6365 (mm-inline-override-p handle)
6366 (and (mm-handle-disposition handle)
6367 (not (equal (car (mm-handle-disposition handle))
6369 (not (mm-attachment-override-p handle)))
6370 (not (mm-automatic-display-p handle))
6371 (not (or (and (mm-inlinable-p handle)
6372 (mm-inlined-p handle))
6373 (mm-automatic-external-display-p type))))
6374 (push button buttons)))
6376 ;; Add header buttons.
6379 (narrow-to-region (point) (point))
6380 (insert "Attachment" (if (cdr buttons) "s" "") ":")
6381 (dolist (button (nreverse buttons))
6384 (mm-handle-set-undisplayer (setq handle (cdr button)) nil)
6385 (gnus-insert-mime-button handle (car button))
6386 (skip-chars-backward "\t\n ")
6387 (delete-region (point) (point-max))
6388 (when (> (current-column) (window-width))
6393 (dolist (ovl (overlays-in (point-min) (point)))
6394 (overlay-put ovl 'gnus-button-attachment-extra t)
6395 (overlay-put ovl 'face nil))
6396 (let ((gnus-treatment-function-alist
6397 '((gnus-treat-highlight-headers
6398 gnus-article-highlight-headers))))
6399 (gnus-treat-article 'head)))))))))
6403 (defun gnus-output-to-file (file-name)
6404 "Append the current article to a file named FILE-NAME.
6405 If `gnus-article-save-coding-system' is non-nil, it is used to encode
6406 text and used as the value of the coding cookie which is added to the
6407 top of a file. Otherwise, this function saves a raw article without
6409 (let* ((artbuf (current-buffer))
6410 (file-name-coding-system nnmail-pathname-coding-system)
6411 (coding gnus-article-save-coding-system)
6412 (coding-system-for-read (if coding
6413 nil ;; Rely on the coding cookie.
6414 mm-text-coding-system))
6415 (coding-system-for-write (or coding
6416 mm-text-coding-system-for-write
6417 mm-text-coding-system))
6418 (exists (file-exists-p file-name)))
6421 (insert-file-contents file-name)
6422 (goto-char (point-min))
6423 ;; Remove the existing coding cookie.
6424 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
6425 (delete-region (match-beginning 0) (match-end 0))))
6426 (goto-char (point-max))
6427 (insert-buffer-substring artbuf)
6428 ;; Append newline at end of the buffer as separator, and then
6430 (goto-char (point-max))
6433 ;; If the coding system is not suitable to encode the text,
6434 ;; ask a user for a proper one.
6435 (setq coding (coding-system-base
6436 (save-window-excursion
6437 (select-safe-coding-system (point-min) (point-max)
6439 (setq coding-system-for-write
6440 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
6442 (goto-char (point-min))
6443 ;; Add the coding cookie.
6444 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
6445 coding-system-for-write)))
6448 (write-region (point-min) (point-max) file-name nil 'no-message)
6449 (message "Appended to %s" file-name))
6450 (write-region (point-min) (point-max) file-name))))
6453 (defun gnus-narrow-to-page (&optional arg)
6454 "Narrow the article buffer to a page.
6455 If given a numerical ARG, move forward ARG pages."
6457 (setq arg (if arg (prefix-numeric-value arg) 0))
6458 (with-current-buffer gnus-article-buffer
6460 ;; Remove any old next/prev buttons.
6461 (when (gnus-visual-p 'page-marker)
6462 (let ((inhibit-read-only t))
6463 (gnus-remove-text-with-property 'gnus-prev)
6464 (gnus-remove-text-with-property 'gnus-next)))
6466 (when (save-excursion
6468 (if (re-search-backward page-delimiter nil 'move (abs arg))
6470 (setq nd (match-beginning 0)
6472 (when (re-search-backward page-delimiter nil t)
6473 (setq st (match-end 0))))
6474 (when (re-search-forward page-delimiter nil t)
6475 (setq nd (match-beginning 0)
6478 (if (re-search-forward page-delimiter nil 'move arg)
6480 (setq st (match-end 0)
6482 (when (re-search-forward page-delimiter nil t)
6483 (setq nd (match-beginning 0))))
6484 (when (re-search-backward page-delimiter nil t)
6485 (setq st (match-end 0)
6488 (when (re-search-backward page-delimiter nil t)
6489 (goto-char (setq st (match-end 0))))
6490 (when (re-search-forward page-delimiter nil t)
6491 (setq nd (match-beginning 0)))
6493 (setq gnus-page-broken t)
6494 (when pt (goto-char pt))
6495 (narrow-to-region (or st (point-min)) (or nd (point-max)))
6496 (when (gnus-visual-p 'page-marker)
6500 (gnus-insert-next-page-button))
6503 (gnus-insert-prev-page-button))))))))
6505 ;; Article mode commands
6507 (defun gnus-article-goto-next-page ()
6508 "Show the next page of the article."
6510 (when (gnus-article-next-page)
6511 (goto-char (point-min))
6512 (gnus-article-read-summary-keys nil ?n)))
6515 (defun gnus-article-goto-prev-page ()
6516 "Show the previous page of the article."
6518 (if (save-restriction (widen) (bobp)) ;; Real beginning-of-buffer?
6519 (gnus-article-read-summary-keys nil ?p)
6520 (gnus-article-prev-page nil)))
6522 ;; This is cleaner but currently breaks `gnus-pick-mode':
6524 ;; (defun gnus-article-goto-next-page ()
6525 ;; "Show the next page of the article."
6527 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6528 ;; (gnus-summary-next-page)))
6530 ;; (defun gnus-article-goto-prev-page ()
6531 ;; "Show the next page of the article."
6533 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
6534 ;; (gnus-summary-prev-page)))
6536 (defun gnus-article-next-page (&optional lines)
6537 "Show the next page of the current article.
6538 If end of article, return non-nil. Otherwise return nil.
6539 Argument LINES specifies lines to be scrolled up."
6541 (move-to-window-line (- -1 scroll-margin))
6542 (if (and (not (and gnus-article-over-scroll
6543 (> (count-lines (window-start) (point-max))
6544 (+ (or lines (1- (window-height))) scroll-margin))))
6547 (and (pos-visible-in-window-p) ;Not continuation line.
6548 (>= (point) (point-max)))))
6549 ;; Nothing in this page.
6550 (if (or (not gnus-page-broken)
6555 (eobp)))) ;Real end-of-buffer?
6557 (when gnus-article-over-scroll
6558 (gnus-article-next-page-1 lines))
6560 (gnus-narrow-to-page 1) ;Go to next page.
6562 ;; More in this page.
6563 (gnus-article-next-page-1 lines)
6566 (defun gnus-article-beginning-of-window ()
6567 "Move point to the beginning of the window.
6568 The point is placed at the line number which `scroll-margin'
6570 ;; There is an obscure bug in Emacs that makes it impossible to
6571 ;; scroll past big pictures in the article buffer. Try to fix
6572 ;; this by adding a sanity check by counting the lines visible.
6573 (when (> (count-lines (window-start) (window-end)) 30)
6574 (move-to-window-line
6575 (min (max 0 scroll-margin)
6576 (max 1 (- (window-height)
6577 (if mode-line-format 1 0)
6578 (if header-line-format 1 0)
6581 (defvar scroll-in-place)
6583 (defun gnus-article-next-page-1 (lines)
6585 (let ((scroll-in-place nil)
6586 (auto-window-vscroll nil))
6589 ;; Long lines may cause an end-of-buffer error.
6590 (goto-char (point-max))))
6591 (gnus-article-beginning-of-window))
6593 (defun gnus-article-prev-page (&optional lines)
6594 "Show previous page of current article.
6595 Argument LINES specifies lines to be scrolled down."
6597 (move-to-window-line 0)
6598 (if (and gnus-page-broken
6600 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
6602 (gnus-narrow-to-page -1) ;Go to previous page.
6603 (goto-char (point-max))
6604 (recenter (if gnus-article-over-scroll
6606 (max (+ lines scroll-margin) 3)
6607 (- (window-height) 2))
6611 (let ((scroll-in-place nil))
6612 (scroll-down lines))
6613 (beginning-of-buffer
6614 (goto-char (point-min))))
6615 (gnus-article-beginning-of-window))))
6617 (defun gnus-article-only-boring-p ()
6618 "Decide whether there is only boring text remaining in the article.
6619 Something \"interesting\" is a word of at least two letters that does
6620 not have a face in `gnus-article-boring-faces'."
6621 (when (and gnus-article-skip-boring
6622 (boundp 'gnus-article-boring-faces)
6623 (symbol-value 'gnus-article-boring-faces))
6625 (let ((inhibit-point-motion-hooks t))
6627 (while (re-search-forward "\\b\\w\\w" nil t)
6629 (when (not (gnus-intersection
6630 (gnus-faces-at (point))
6631 (symbol-value 'gnus-article-boring-faces)))
6632 (throw 'only-boring nil)))
6633 (throw 'only-boring t))))))
6635 (defun gnus-article-refer-article ()
6636 "Read article specified by message-id around point."
6639 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
6640 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
6641 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
6642 (let ((msg-id (concat "<" (match-string 0) ">")))
6643 (set-buffer gnus-summary-buffer)
6644 (gnus-summary-refer-article msg-id))
6645 (error "No references around point"))))
6647 (defun gnus-article-show-summary ()
6648 "Reconfigure windows to show summary buffer."
6650 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6651 (error "There is no summary buffer for this article buffer")
6652 (gnus-article-set-globals)
6653 (gnus-configure-windows 'article)
6654 (gnus-summary-goto-subject gnus-current-article)
6655 (gnus-summary-position-point)))
6657 (defun gnus-article-describe-briefly ()
6658 "Describe article mode commands briefly."
6660 (gnus-message 6 "%s" (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
6662 (defun gnus-article-check-buffer ()
6663 "Beep if not in an article buffer."
6664 (unless (derived-mode-p 'gnus-article-mode)
6665 (error "Command invoked outside of a Gnus article buffer")))
6667 (defvar gnus-pick-mode)
6669 (defun gnus-article-read-summary-keys (&optional _arg key not-restore-window)
6670 "Read a summary buffer key sequence and execute it from the article buffer."
6672 (gnus-article-check-buffer)
6674 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6675 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6676 "=" "^" "\M-^" "|"))
6678 '("A " "A<" "A>" "AM" "AP" "AR" "AT" "A\C-?" "A\M-\r" "A\r" "Ab" "Ae"
6679 "An" "Ap" [?A (meta return)] [?A delete]))
6683 (with-current-buffer gnus-article-current-summary
6684 (let (gnus-pick-mode)
6685 (setq unread-command-events (nconc unread-command-events
6686 (list (or key last-command-event)))
6687 keys (read-key-sequence nil t))))
6692 ((eq (aref keys (1- (length keys))) ?\C-h)
6693 (gnus-article-describe-bindings (substring keys 0 -1)))
6694 ((or (member keys nosaves)
6695 (member keys nosave-but-article)
6696 (member keys nosave-in-article))
6698 (save-window-excursion
6699 (pop-to-buffer gnus-article-current-summary)
6700 ;; We disable the pick minor mode commands.
6701 (let (gnus-pick-mode)
6702 (setq func (key-binding keys t))))
6706 (unless (member keys nosave-in-article)
6707 (set-buffer gnus-article-current-summary))
6708 (when (and (symbolp func)
6709 (get func 'disabled))
6710 (error "Function %s disabled" func))
6711 (call-interactively func)
6712 (setq new-sum-point (point)))
6713 (when (member keys nosave-but-article)
6714 (pop-to-buffer gnus-article-buffer))))
6716 ;; These commands should restore window configuration.
6717 (let ((obuf (current-buffer))
6718 (owin (current-window-configuration))
6719 win func in-buffer selected new-sum-start new-sum-hscroll err)
6720 (cond (not-restore-window
6721 (pop-to-buffer gnus-article-current-summary)
6722 (setq win (selected-window)))
6723 ((setq win (get-buffer-window gnus-article-current-summary))
6724 (select-window win))
6726 (let ((summary-buffer gnus-article-current-summary))
6727 (gnus-configure-windows 'article)
6728 (unless (setq win (get-buffer-window summary-buffer 'visible))
6729 (let ((gnus-buffer-configuration
6730 '((article ((vertical 1.0
6731 (summary 0.25 point)
6733 (gnus-configure-windows 'article))
6734 (setq win (get-buffer-window summary-buffer 'visible)))
6735 (select-frame-set-input-focus (window-frame win))
6736 (select-window win))))
6737 (setq in-buffer (current-buffer))
6738 ;; We disable the pick minor mode commands.
6739 (setq func (let (gnus-pick-mode)
6740 (key-binding keys t)))
6741 (when (get func 'disabled)
6742 (error "Function %s disabled" func))
6745 (condition-case code
6747 (call-interactively func)
6753 (when (eq win (selected-window))
6754 (setq new-sum-point (point)
6755 new-sum-start (window-start win)
6756 new-sum-hscroll (window-hscroll win)))
6757 (when (or (eq in-buffer (current-buffer))
6758 (when (eq obuf (current-buffer))
6759 (set-buffer in-buffer)
6761 (setq selected (ignore-errors (gnus-summary-select-article)))
6763 (unless not-restore-window
6764 (set-window-configuration owin))
6765 (when (and (eq selected 'old)
6767 (set-window-start (get-buffer-window (current-buffer))
6769 (set-window-point (get-buffer-window (current-buffer))
6770 (if (article-goto-body)
6773 (when (and (not not-restore-window)
6776 (with-current-buffer (window-buffer win)
6777 (derived-mode-p 'gnus-summary-mode)))
6778 (set-window-point win new-sum-point)
6779 (set-window-start win new-sum-start)
6780 (set-window-hscroll win new-sum-hscroll))))
6781 (set-window-configuration owin)
6783 (signal (car err) (cdr err))
6786 (defun gnus-article-read-summary-send-keys ()
6788 (let ((unread-command-events (list ?S)))
6789 (gnus-article-read-summary-keys)))
6791 (defun gnus-article-describe-key (key)
6792 "Display documentation of the function invoked by KEY.
6793 KEY is a string or a vector."
6794 (interactive (list (let ((cursor-in-echo-area t))
6795 (read-key-sequence "Describe key: "))))
6796 (gnus-article-check-buffer)
6797 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6798 gnus-article-read-summary-send-keys))
6799 (with-current-buffer gnus-article-current-summary
6800 (setq unread-command-events
6802 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6803 (list 'meta (- x 128))
6806 unread-command-events))
6807 (let ((cursor-in-echo-area t)
6809 (describe-key (read-key-sequence nil t))))
6810 (describe-key key)))
6812 (defun gnus-article-describe-key-briefly (key &optional insert)
6813 "Display documentation of the function invoked by KEY.
6814 KEY is a string or a vector."
6815 (interactive (list (let ((cursor-in-echo-area t))
6816 (read-key-sequence "Describe key: "))
6817 current-prefix-arg))
6818 (gnus-article-check-buffer)
6819 (if (memq (key-binding key t) '(gnus-article-read-summary-keys
6820 gnus-article-read-summary-send-keys))
6821 (with-current-buffer gnus-article-current-summary
6822 (setq unread-command-events
6824 (mapcar (lambda (x) (if (and (integerp x) (>= x 128))
6825 (list 'meta (- x 128))
6828 unread-command-events))
6829 (let ((cursor-in-echo-area t)
6831 (describe-key-briefly (read-key-sequence nil t) insert)))
6832 (describe-key-briefly key insert)))
6834 ;;`gnus-agent-mode' in gnus-agent.el will define it.
6835 (defvar gnus-agent-summary-mode)
6836 (defvar gnus-draft-mode)
6837 (defvar help-xref-stack-item)
6838 (defvar help-xref-following)
6840 (defun gnus-article-describe-bindings (&optional prefix)
6841 "Show a list of all defined keys, and their definitions.
6842 The optional argument PREFIX, if non-nil, should be a key sequence;
6843 then we display only bindings that start with that prefix."
6845 (gnus-article-check-buffer)
6846 (let ((keymap (copy-keymap gnus-article-mode-map))
6847 (map (copy-keymap gnus-article-send-map))
6848 (sumkeys (where-is-internal 'gnus-article-read-summary-keys))
6850 (define-key keymap "S" map)
6851 (define-key map [t] nil)
6852 (with-current-buffer gnus-article-current-summary
6855 (if (setq parent (keymap-parent gnus-article-mode-map))
6857 (setq parent (copy-keymap parent))
6858 (set-keymap-parent parent (current-local-map)))
6859 (current-local-map)))
6860 (set-keymap-parent map (key-binding "S"))
6861 (let (key def gnus-pick-mode)
6863 (setq key (pop sumkeys))
6864 (cond ((and (vectorp key) (= (length key) 1)
6865 (consp (setq def (aref key 0)))
6866 (numberp (car def)) (numberp (cdr def)))
6867 (when (< (max (car def) (cdr def)) 128)
6871 (nreverse (gnus-uncompress-range def)))
6873 ((setq def (key-binding key))
6874 (unless (eq def 'undefined)
6875 (define-key keymap key def))))))
6876 (when (boundp 'gnus-agent-summary-mode)
6877 (setq agent gnus-agent-summary-mode))
6878 (when (boundp 'gnus-draft-mode)
6879 (setq draft gnus-draft-mode)))
6881 (use-local-map keymap)
6882 (set (make-local-variable 'gnus-agent-summary-mode) agent)
6883 (set (make-local-variable 'gnus-draft-mode) draft)
6884 (describe-bindings prefix))
6885 (let ((item `((lambda (prefix)
6886 (with-current-buffer ,(current-buffer)
6887 (gnus-article-describe-bindings prefix)))
6889 ;; Loading `help-mode' here is necessary if `describe-bindings'
6890 ;; is replaced with something, e.g. `helm-descbinds'.
6891 (require 'help-mode)
6892 (with-current-buffer (let (help-xref-following) (help-buffer))
6893 (setq help-xref-stack-item item)))))
6895 (defun gnus-article-reply-with-original (&optional wide)
6896 "Start composing a reply mail to the current message.
6897 The text in the region will be yanked. If the region isn't active,
6898 the entire article will be yanked."
6900 (let ((article (cdr gnus-article-current))
6902 (if (not (and transient-mark-mode mark-active))
6903 (with-current-buffer gnus-summary-buffer
6904 (gnus-summary-reply (list (list article)) wide))
6905 (setq contents (buffer-substring (point) (mark t)))
6906 ;; Deactivate active regions.
6907 (when transient-mark-mode
6908 (setq mark-active nil))
6909 (with-current-buffer gnus-summary-buffer
6911 (list (list article contents)) wide)))))
6913 (defun gnus-article-wide-reply-with-original ()
6914 "Start composing a wide reply mail to the current message.
6915 The text in the region will be yanked. If the region isn't active,
6916 the entire article will be yanked."
6918 (gnus-article-reply-with-original t))
6920 (defun gnus-article-followup-with-original ()
6921 "Compose a followup to the current article.
6922 The text in the region will be yanked. If the region isn't active,
6923 the entire article will be yanked."
6925 (let ((article (cdr gnus-article-current))
6927 (if (not (and transient-mark-mode mark-active))
6928 (with-current-buffer gnus-summary-buffer
6929 (gnus-summary-followup (list (list article))))
6930 (setq contents (buffer-substring (point) (mark t)))
6931 ;; Deactivate active regions.
6932 (when transient-mark-mode
6933 (setq mark-active nil))
6934 (with-current-buffer gnus-summary-buffer
6935 (gnus-summary-followup
6936 (list (list article contents)))))))
6938 (defun gnus-article-hide (&optional arg force)
6939 "Hide all the gruft in the current article.
6940 This means that signatures, cited text and (some) headers will be
6942 If given a prefix, show the hidden text instead."
6943 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6944 (gnus-with-article-buffer
6945 (article-hide-headers arg)
6946 (article-hide-list-identifiers)
6947 (gnus-article-hide-citation-maybe arg force)
6948 (article-hide-signature arg)))
6950 (defun gnus-check-group-server ()
6951 ;; Make sure the connection to the server is alive.
6952 (unless (gnus-server-opened
6953 (gnus-find-method-for-group gnus-newsgroup-name))
6954 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6955 (gnus-request-group gnus-newsgroup-name t)))
6957 (declare-function nneething-get-file-name "nneething" (id))
6959 (defun gnus-request-article-this-buffer (article group)
6960 "Get an article and insert it into this buffer."
6961 (let (do-update-line sparse-header)
6965 (gnus-kill-all-overlays)
6966 (setq group (or group gnus-newsgroup-name))
6968 ;; Using `gnus-request-article' directly will insert the article into
6969 ;; `nntp-server-buffer' - so we'll save some time by not having to
6970 ;; copy it from the server buffer into the article buffer.
6972 ;; We only request an article by message-id when we do not have the
6973 ;; headers for it, so we'll have to get those.
6974 (when (stringp article)
6975 (gnus-read-header article))
6977 ;; If the article number is negative, that means that this article
6978 ;; doesn't belong in this newsgroup (possibly), so we find its
6979 ;; message-id and request it by id instead of number.
6980 (when (and (numberp article)
6982 (get-buffer gnus-summary-buffer)
6983 (gnus-buffer-exists-p gnus-summary-buffer))
6984 (with-current-buffer gnus-summary-buffer
6985 (let ((header (gnus-summary-article-header article)))
6988 ((memq article gnus-newsgroup-sparse)
6989 ;; This is a sparse gap article.
6990 (setq do-update-line article)
6991 (setq article (mail-header-id header))
6992 (setq sparse-header (gnus-read-header article))
6993 (setq gnus-newsgroup-sparse
6994 (delq article gnus-newsgroup-sparse)))
6996 ;; It's a real article.
6997 (setq article (mail-header-id header)))
6999 ;; It is an extracted pseudo-article.
7000 (setq article 'pseudo)
7001 (gnus-request-pseudo-article header))))
7003 (let ((method (gnus-find-method-for-group
7004 gnus-newsgroup-name)))
7005 (when (and (eq (car method) 'nneething)
7007 (let ((dir (nneething-get-file-name
7008 (mail-header-id header))))
7009 (when (and (stringp dir)
7010 (file-directory-p dir))
7011 (setq article 'nneething)
7012 (gnus-group-enter-directory dir))))))))
7015 ;; Refuse to select canceled articles.
7016 ((and (numberp article)
7018 (get-buffer gnus-summary-buffer)
7019 (gnus-buffer-exists-p gnus-summary-buffer)
7020 (eq (cdr (with-current-buffer gnus-summary-buffer
7021 (assq article gnus-newsgroup-reads)))
7022 gnus-canceled-mark))
7024 ;; We first check `gnus-original-article-buffer'.
7025 ((and (get-buffer gnus-original-article-buffer)
7027 (with-current-buffer gnus-original-article-buffer
7028 (and (equal (car gnus-original-article) group)
7029 (eq (cdr gnus-original-article) article))))
7030 ;; `insert-buffer-substring' would incorrectly use the
7031 ;; equivalent of string-make-multibyte which amount to decoding
7032 ;; with locale-coding-system, causing failure of
7033 ;; subsequent decoding.
7034 (insert (string-to-multibyte
7035 (with-current-buffer gnus-original-article-buffer
7036 (buffer-substring (point-min) (point-max)))))
7038 ;; Check the backlog.
7039 ((and gnus-keep-backlog
7040 (gnus-backlog-request-article group article (current-buffer)))
7042 ;; Check asynchronous pre-fetch.
7043 ((gnus-async-request-fetched-article group article (current-buffer))
7044 (gnus-async-prefetch-next group article gnus-summary-buffer)
7045 (when (and (numberp article) gnus-keep-backlog)
7046 (gnus-backlog-enter-article group article (current-buffer)))
7049 ((and gnus-use-cache
7051 (gnus-cache-request-article article group))
7053 ;; Check the agent cache.
7054 ((gnus-agent-request-article article group)
7056 ;; Get the article and put into the article buffer.
7057 ((or (stringp article)
7059 (let ((gnus-override-method gnus-override-method)
7060 (methods (and (stringp article)
7061 (with-current-buffer gnus-summary-buffer
7062 (gnus-refer-article-methods))))
7063 (backend (car (gnus-find-method-for-group
7064 gnus-newsgroup-name)))
7066 (inhibit-read-only t))
7067 (when (and (null gnus-override-method)
7069 (setq gnus-override-method (pop methods)))
7072 (gnus-kill-all-overlays)
7073 (let ((gnus-newsgroup-name group))
7074 (gnus-check-group-server))
7076 ((gnus-request-article article group (current-buffer))
7077 (when (numberp article)
7078 (gnus-async-prefetch-next group article
7079 gnus-summary-buffer)
7080 (when gnus-keep-backlog
7081 (gnus-backlog-enter-article
7082 group article (current-buffer)))
7083 (when (and gnus-agent
7084 (gnus-agent-group-covered-p group))
7085 (gnus-agent-store-article article group)))
7086 (setq result 'article))
7088 (setq gnus-override-method (pop methods)))
7089 ((not (string-match "^400 "
7090 (nnheader-get-report backend)))
7091 ;; If we get 400 server disconnect, reconnect and
7092 ;; retry; otherwise, assume the article has expired.
7093 (setq result 'done))))
7094 (and (eq result 'article) 'article)))
7098 ;; Associate this article with the current summary buffer.
7099 (setq gnus-article-current-summary gnus-summary-buffer)
7101 ;; Take the article from the original article buffer
7102 ;; and place it in the buffer it's supposed to be in.
7103 (when (and (get-buffer gnus-article-buffer)
7104 (equal (buffer-name (current-buffer))
7105 (buffer-name (get-buffer gnus-article-buffer))))
7107 (if (get-buffer gnus-original-article-buffer)
7108 (set-buffer gnus-original-article-buffer)
7109 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
7110 (buffer-disable-undo)
7111 (setq major-mode 'gnus-original-article-mode)
7112 (setq buffer-read-only t))
7113 (let ((inhibit-read-only t))
7115 (insert-buffer-substring gnus-article-buffer))
7116 (setq gnus-original-article (cons group article)))
7119 (run-hooks 'gnus-article-decode-hook)
7120 ;; Mark article as decoded or not.
7121 (setq gnus-article-decoded-p gnus-article-decode-hook))
7123 ;; Update sparse articles.
7124 (when (and do-update-line
7125 (or (numberp article)
7127 (let ((buf (current-buffer)))
7128 (set-buffer gnus-summary-buffer)
7129 (gnus-summary-update-article do-update-line sparse-header)
7130 (gnus-summary-goto-subject do-update-line nil t)
7131 (set-window-point (gnus-get-buffer-window (current-buffer) t)
7133 (set-buffer buf))))))
7135 (defun gnus-block-private-groups (group)
7136 "Allows images in newsgroups to be shown, blocks images in all
7138 (if (or (gnus-news-group-p group)
7139 (gnus-member-of-valid 'global group))
7140 ;; Block nothing in news groups.
7142 ;; Block everything anywhere else.
7145 (defun gnus-blocked-images ()
7146 (if (functionp gnus-blocked-images)
7147 (funcall gnus-blocked-images gnus-newsgroup-name)
7148 gnus-blocked-images))
7154 (defcustom gnus-article-edit-mode-hook nil
7155 "Hook run in article edit mode buffers."
7156 :group 'gnus-article-various
7159 (defvar gnus-article-edit-done-function nil)
7161 (defvar gnus-article-edit-mode-map nil)
7163 ;; Should we be using derived.el for this?
7164 (unless gnus-article-edit-mode-map
7165 (setq gnus-article-edit-mode-map (make-keymap))
7166 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
7168 (gnus-define-keys gnus-article-edit-mode-map
7169 "\C-c?" describe-mode
7170 "\C-c\C-c" gnus-article-edit-done
7171 "\C-c\C-k" gnus-article-edit-exit
7172 "\C-c\C-f\C-t" message-goto-to
7173 "\C-c\C-f\C-o" message-goto-from
7174 "\C-c\C-f\C-b" message-goto-bcc
7175 ;;"\C-c\C-f\C-w" message-goto-fcc
7176 "\C-c\C-f\C-c" message-goto-cc
7177 "\C-c\C-f\C-s" message-goto-subject
7178 "\C-c\C-f\C-r" message-goto-reply-to
7179 "\C-c\C-f\C-n" message-goto-newsgroups
7180 "\C-c\C-f\C-d" message-goto-distribution
7181 "\C-c\C-f\C-f" message-goto-followup-to
7182 "\C-c\C-f\C-m" message-goto-mail-followup-to
7183 "\C-c\C-f\C-k" message-goto-keywords
7184 "\C-c\C-f\C-u" message-goto-summary
7185 "\C-c\C-f\C-i" message-insert-or-toggle-importance
7186 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
7187 "\C-c\C-b" message-goto-body
7188 "\C-c\C-i" message-goto-signature
7190 "\C-c\C-t" message-insert-to
7191 "\C-c\C-n" message-insert-newsgroups
7192 "\C-c\C-o" message-sort-headers
7193 "\C-c\C-e" message-elide-region
7194 "\C-c\C-v" message-delete-not-region
7195 "\C-c\C-z" message-kill-to-signature
7196 "\M-\r" message-newline-and-reformat
7197 "\C-c\C-a" mml-attach-file
7198 "\C-a" message-beginning-of-line
7200 "\M-;" comment-region)
7202 (gnus-define-keys (gnus-article-edit-wash-map
7203 "\C-c\C-w" gnus-article-edit-mode-map)
7204 "f" gnus-article-edit-full-stops))
7207 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
7209 ["Fetch To" message-insert-to t]
7210 ["Fetch Newsgroups" message-insert-newsgroups t]
7212 ["To" message-goto-to t]
7213 ["From" message-goto-from t]
7214 ["Subject" message-goto-subject t]
7215 ["Cc" message-goto-cc t]
7216 ["Reply-To" message-goto-reply-to t]
7217 ["Summary" message-goto-summary t]
7218 ["Keywords" message-goto-keywords t]
7219 ["Newsgroups" message-goto-newsgroups t]
7220 ["Followup-To" message-goto-followup-to t]
7221 ["Mail-Followup-To" message-goto-mail-followup-to t]
7222 ["Distribution" message-goto-distribution t]
7223 ["Body" message-goto-body t]
7224 ["Signature" message-goto-signature t]))
7226 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
7227 "Major mode for editing articles.
7228 This is an extended text-mode.
7230 \\{gnus-article-edit-mode-map}"
7231 (make-local-variable 'gnus-article-edit-done-function)
7232 (make-local-variable 'gnus-prev-winconf)
7233 (set (make-local-variable 'font-lock-defaults)
7234 '(message-font-lock-keywords t))
7235 (set (make-local-variable 'mail-header-separator) "")
7236 (set (make-local-variable 'gnus-article-edit-mode) t)
7237 (easy-menu-add message-mode-field-menu message-mode-map)
7239 (setq buffer-read-only nil)
7240 (buffer-enable-undo)
7243 (defun gnus-article-edit (&optional force)
7244 "Edit the current article.
7245 This will have permanent effect only in mail groups.
7246 If FORCE is non-nil, allow editing of articles even in read-only
7249 (when (and (not force)
7250 (gnus-group-read-only-p))
7251 (error "The current newsgroup does not support article editing"))
7252 (gnus-with-article-buffer
7253 (article-date-original))
7254 (gnus-article-edit-article
7256 `(lambda (no-highlight)
7258 (gnus-summary-edit-article-done
7259 ,(or (mail-header-references gnus-current-headers) "")
7260 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
7262 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
7263 "Start editing the contents of the current article buffer."
7264 (let ((winconf (current-window-configuration)))
7265 (set-buffer gnus-article-buffer)
7266 (let ((message-auto-save-directory
7267 ;; Don't associate the article buffer with a draft file.
7269 (gnus-article-edit-mode))
7270 (funcall start-func)
7271 (set-buffer-modified-p nil)
7272 (gnus-configure-windows 'edit-article)
7273 (setq gnus-article-edit-done-function exit-func)
7274 (setq gnus-prev-winconf winconf)
7276 (gnus-message 6 "C-c C-c to end edits"))))
7278 (defun gnus-article-edit-done (&optional arg)
7279 "Update the article edits and exit."
7281 (let ((func gnus-article-edit-done-function)
7282 (buf (current-buffer))
7283 (start (window-start))
7284 (winconf gnus-prev-winconf))
7285 (widen) ;; Widen it in case that users narrowed the buffer.
7288 ;; The cache and backlog have to be flushed somewhat.
7289 (when gnus-keep-backlog
7290 (gnus-backlog-remove-article
7291 (car gnus-article-current) (cdr gnus-article-current)))
7292 ;; Flush original article as well.
7293 (gnus-flush-original-article-buffer)
7294 (when gnus-use-cache
7295 (gnus-cache-update-article
7296 (car gnus-article-current) (cdr gnus-article-current)))
7297 ;; We remove all text props from the article buffer.
7298 (kill-all-local-variables)
7299 (set-text-properties (point-min) (point-max) nil)
7301 (set-window-configuration winconf)
7303 (set-window-start (get-buffer-window buf) start)
7304 (set-window-point (get-buffer-window buf) (point)))
7305 (gnus-summary-show-article))
7307 (defun gnus-flush-original-article-buffer ()
7308 (when (get-buffer gnus-original-article-buffer)
7309 (with-current-buffer gnus-original-article-buffer
7310 (setq gnus-original-article nil))))
7312 (defun gnus-article-edit-exit ()
7313 "Exit the article editing without updating."
7315 (when (or (not (buffer-modified-p))
7316 (yes-or-no-p "Article modified; kill anyway? "))
7317 (let ((curbuf (current-buffer))
7319 (window-start (window-start)))
7321 (if (gnus-buffer-live-p gnus-original-article-buffer)
7322 (insert-buffer-substring gnus-original-article-buffer))
7323 (let ((winconf gnus-prev-winconf))
7324 (kill-all-local-variables)
7326 (set-window-configuration winconf)
7327 ;; Tippy-toe some to make sure that point remains where it was.
7328 (save-current-buffer
7330 (set-window-start (get-buffer-window (current-buffer)) window-start)
7332 (gnus-summary-show-article)))
7334 (defun gnus-article-edit-full-stops ()
7335 "Interactively repair spacing at end of sentences."
7338 (goto-char (point-min))
7339 (search-forward-regexp "^$" nil t)
7340 (let ((case-fold-search nil))
7341 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
7344 ;;; Article highlights
7347 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
7349 ;;; Internal Variables:
7351 (defcustom gnus-button-url-regexp
7353 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
7354 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
7355 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
7356 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
7360 ;; Match paired parentheses, e.g. in Wikipedia URLs:
7361 ;; http://thread.gmane.org/47B4E3B2.3050402@gmail.com
7362 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)"
7363 "\\(?:" "[" chars punct "]+" "[" chars "]" "\\)?"
7365 "[" chars punct "]+" "[" chars "]"
7368 "Regular expression that matches URLs."
7370 :group 'gnus-article-buttons
7373 (defcustom gnus-button-valid-fqdn-regexp "\\([-A-Za-z0-9]+\\.\\)+[A-Za-z]+"
7374 "Regular expression that matches a valid FQDN."
7376 :group 'gnus-article-buttons
7379 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
7380 (defcustom gnus-button-valid-localpart-regexp
7381 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
7382 "Regular expression that matches a localpart of mail addresses or MIDs."
7384 :group 'gnus-article-buttons
7387 (defcustom gnus-button-man-handler 'manual-entry
7388 "Function to use for displaying man pages.
7389 The function must take at least one argument with a string naming the
7392 :type '(choice (function-item :tag "Man" manual-entry)
7393 (function-item :tag "Woman" woman)
7394 (function :tag "Other"))
7395 :group 'gnus-article-buttons)
7397 (defcustom gnus-button-mid-or-mail-regexp
7398 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
7399 gnus-button-valid-fqdn-regexp
7401 "Regular expression that matches a message ID or a mail address."
7403 :group 'gnus-article-buttons
7406 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
7407 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
7408 Strings like this can be either a message ID or a mail address. If it is one
7409 of the symbols `mid' or `mail', Gnus will always assume that the string is a
7410 message ID or a mail address, respectively. If this variable is set to the
7411 symbol `ask', always query the user what do do. If it is a function, this
7412 function will be called with the string as its only argument. The function
7413 must return `mid', `mail', `invalid' or `ask'."
7415 :group 'gnus-article-buttons
7416 :type '(choice (function-item :tag "Heuristic function"
7417 gnus-button-mid-or-mail-heuristic)
7422 (defcustom gnus-button-mid-or-mail-heuristic-alist
7423 '((-10.0 . ".+\\$.+@")
7426 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
7427 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
7428 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
7429 (-1.0 . "^[^a-z]+@")
7431 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
7432 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
7433 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
7434 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
7437 (-1.0 . "^[0-9][0-9]")
7439 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
7440 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7441 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
7442 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
7444 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
7445 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
7448 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
7450 ;; compensation for TDMA dated mail addresses:
7451 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
7453 (-20.0 . "\\.fsf@") ;; Gnus
7456 (-20.0 . "^alpine\\.")
7457 (-20.0 . "_-_") ;; Subject change in thread
7459 (-20.0 . "\\.ln@") ;; leafnode
7460 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
7461 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
7463 ;; (5.0 . "") ;; $local_part_len <= 7
7464 (10.0 . "^[^0-9]+@")
7465 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
7466 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
7469 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
7471 (0.5 . "^[A-Z][a-z]")
7472 (0.5 . "^[A-Z][a-z][a-z]")
7473 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
7474 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
7475 "An alist of (RATE . REGEXP) pairs for `gnus-button-mid-or-mail-heuristic'.
7477 A negative RATE indicates a message IDs, whereas a positive indicates a mail
7478 address. The REGEXP is processed with `case-fold-search' set to nil."
7480 :group 'gnus-article-buttons
7481 :type '(repeat (cons (number :tag "Rate")
7482 (regexp :tag "Regexp"))))
7484 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
7485 "Guess whether MID-OR-MAIL is a message ID or a mail address.
7486 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
7487 address, `ask' if unsure and `invalid' if the string is invalid."
7488 (let ((case-fold-search nil)
7489 (list gnus-button-mid-or-mail-heuristic-alist)
7490 (result 0) rate regexp lpartlen elem)
7492 (length (replace-regexp-in-string "^\\(.*\\)@.*$" "\\1" mid-or-mail)))
7493 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
7494 ;; Certain special cases...
7497 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
7498 "^[0-9]+\\.[0-9]+@compuserve\\|"
7499 "@public\\.gmane\\.org")
7501 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
7502 (setq result 'mail))
7503 (when (string-match "@.*@\\| " mid-or-mail)
7504 (gnus-message 8 "`%s' is invalid." mid-or-mail)
7505 (setq result 'invalid))
7506 ;; Nothing more to do, if result is not a number here...
7507 (when (numberp result)
7509 (setq elem (car list)
7513 (when (string-match regexp mid-or-mail)
7514 (setq result (+ result rate))
7516 9 "`%s' matched `%s', rate `%s', result `%s'."
7517 mid-or-mail regexp rate result)))
7518 (when (<= lpartlen 7)
7519 (setq result (+ result 5.0))
7520 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
7521 mid-or-mail result))
7522 (when (>= lpartlen 12)
7523 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
7525 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
7526 ;; Long local part should contain realname if e-mail address,
7527 ;; too many digits: message-id.
7528 ;; $score -= 5.0 + 0.1 * $local_part_len;
7529 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
7530 (setq result (+ result rate))
7532 9 "Many digits in `%s', rate `%s', result `%s'."
7533 mid-or-mail rate result))
7534 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*@"
7536 ;; Too few vowels [^aeiouy]{4,}.*@
7537 (setq result (+ result -5.0))
7539 9 "Few vowels in `%s', rate `%s', result `%s'."
7540 mid-or-mail -5.0 result))
7542 (setq result (+ result 5.0))
7544 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
7545 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
7546 ;; Maybe we should make this a customizable alist: (condition . 'result)
7548 ((symbolp result) result)
7549 ;; Now convert number into proper results:
7550 ((< result -10.0) 'mid)
7551 ((> result 10.0) 'mail)
7554 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
7555 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
7556 (url-mid (concat "news" ":" mid-or-mail))
7557 (url-mailto (concat "mailto" ":" mid-or-mail)))
7558 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
7559 (when (fboundp pref)
7561 ;; get rid of surrounding angles...
7563 (replace-regexp-in-string "^<\\|>$" "" mid-or-mail)))
7564 (if (or (eq 'mid guessed) (eq 'mail guessed))
7568 (save-window-excursion
7569 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
7572 (cond ((eq pref 'mid)
7573 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
7574 (gnus-button-handle-news url-mid))
7576 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
7577 (gnus-url-mailto url-mailto))
7578 (t (gnus-message 3 "Invalid string.")))))
7580 (defun gnus-button-handle-custom (fun arg)
7581 "Call function FUN on argument ARG.
7582 Both FUN and ARG are supposed to be strings. ARG will be passed
7583 as a symbol to FUN."
7584 (funcall (intern fun)
7585 (if (string-match "^customize-apropos" fun)
7589 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
7591 (defun gnus-button-handle-describe-function (url)
7592 "Call `describe-function' when pushing the corresponding URL button."
7595 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))))
7597 (defun gnus-button-handle-describe-variable (url)
7598 "Call `describe-variable' when pushing the corresponding URL button."
7601 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))))
7603 (defun gnus-button-handle-symbol (url)
7604 "Display help on variable or function.
7605 Calls `describe-variable' or `describe-function'."
7606 (let ((sym (intern url)))
7608 ((fboundp sym) (describe-function sym))
7609 ((boundp sym) (describe-variable sym))
7610 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
7612 (defun gnus-button-handle-describe-key (url)
7613 "Call `describe-key' when pushing the corresponding URL button."
7615 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url))
7616 (keys (ignore-errors (eval `(kbd ,key-string)))))
7619 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
7621 (defun gnus-button-handle-apropos (url)
7622 "Call `apropos' when pushing the corresponding URL button."
7623 (apropos (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7625 (defun gnus-button-handle-apropos-command (url)
7626 "Call `apropos' when pushing the corresponding URL button."
7628 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7630 (defun gnus-button-handle-apropos-variable (url)
7631 "Call `apropos' when pushing the corresponding URL button."
7633 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7635 (defun gnus-button-handle-apropos-documentation (url)
7636 "Call `apropos' when pushing the corresponding URL button."
7637 (apropos-documentation
7638 (replace-regexp-in-string gnus-button-handle-describe-prefix "" url)))
7640 (defun gnus-button-handle-library (url)
7641 "Call `locate-library' when pushing the corresponding URL button."
7642 (gnus-message 9 "url=`%s'" url)
7643 (let* ((lib (locate-library url))
7644 (file (replace-regexp-in-string "\\.elc" ".el" (or lib ""))))
7646 (gnus-message 1 "Cannot locate library `%s'." url)
7647 (find-file-read-only file))))
7649 (defcustom gnus-button-man-level 5
7650 "Integer that says how many man-related buttons Gnus will show.
7651 The higher the number, the more buttons will appear and the more false
7652 positives are possible. Note that you can set this variable local to
7653 specific groups. Setting it higher in Unix groups is probably a good idea.
7654 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7655 how to set variables in specific groups."
7657 :group 'gnus-article-buttons
7658 :link '(custom-manual "(gnus)Group Parameters")
7661 (defcustom gnus-button-emacs-level 5
7662 "Integer that says how many emacs-related buttons Gnus will show.
7663 The higher the number, the more buttons will appear and the more false
7664 positives are possible. Note that you can set this variable local to
7665 specific groups. Setting it higher in Emacs or Gnus related groups is
7666 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7667 `gnus-parameters' on how to set variables in specific groups."
7669 :group 'gnus-article-buttons
7670 :link '(custom-manual "(gnus)Group Parameters")
7673 (defcustom gnus-button-message-level 5
7674 "Integer that says how many buttons for news or mail messages will appear.
7675 The higher the number, the more buttons will appear and the more false
7676 positives are possible."
7677 ;; mail addresses, MIDs, URLs for news, ...
7679 :group 'gnus-article-buttons
7682 (defcustom gnus-button-browse-level 5
7683 "Integer that says how many buttons for browsing will appear.
7684 The higher the number, the more buttons will appear and the more false
7685 positives are possible."
7686 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7688 :group 'gnus-article-buttons
7691 (defcustom gnus-button-alist
7692 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7693 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7694 ((concat "\\b\\(nntp\\|news\\):\\("
7695 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7696 0 t gnus-button-handle-news 2)
7697 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7698 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7699 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7700 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7701 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7702 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7703 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7704 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7705 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7706 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7707 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7708 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7709 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7710 ;; RFC 2368 (The mailto URL scheme)
7711 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7712 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7713 ("\\bmailto:\\([^ \n\t]+\\)"
7714 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7715 ;; Info Konqueror style <info:/foo/bar baz>.
7716 ;; Must come before " Gnus home-grown style".
7717 ("\\binfo://?\\([^'\">\n\t]+\\)"
7718 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7719 ;; Info, Gnus home-grown style (deprecated) <info://foo/bar+baz>
7720 ("\\binfo://\\([^'\">\n\t ]+\\)"
7721 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7722 ;; Info GNOME style <info:foo#bar_baz>
7723 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7724 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7725 ;; Info KDE style <info:(foo)bar baz>
7726 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7727 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7728 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7729 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7730 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\([ \t\n,]*\\)\\)?"
7731 ;; Info links like `C-h i d m Gnus RET' or `C-h i d m Gnus RET i partial RET'
7732 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 0)
7734 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET\\>" 0
7735 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7736 ;; Emacs help commands
7737 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7738 ;; regexp doesn't match arguments containing ` '.
7739 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7740 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7741 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7742 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7743 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7744 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7745 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7746 ;; The following entries may lead to many false positives so don't enable
7747 ;; them by default (use a high button level).
7748 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7749 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7750 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7751 ("['`‘]\\([a-z][-a-z0-9]+\\.el\\)['’]"
7752 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7753 ("['`‘]\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)['’]"
7754 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7755 ("['`‘]\\([a-z][a-z0-9]+-[a-z]+\\)['’]"
7756 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7757 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7758 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7759 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7760 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7761 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7762 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7763 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET\\>"
7764 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7765 ("['`‘]\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^'’]+\\)\\)['’]"
7766 ;; Unlike the other regexps we really have to require quoting
7767 ;; here to determine where it ends.
7768 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7769 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7770 ("<URL: *\\([^\n<>]*\\)>"
7771 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7772 ;; RFC 2396 (2.4.3., delims) ...
7773 ("\"URL: *\\([^\n\"]*\\)\""
7774 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7776 (gnus-button-url-regexp
7777 0 (>= gnus-button-browse-level 0) browse-url 0)
7779 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7780 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7781 gnus-button-handle-man 1)
7782 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7783 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7784 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7785 gnus-button-handle-man 1)
7786 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7787 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7788 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7789 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7790 ;; Recognizing patches to .el files. This is somewhat obscure,
7791 ;; but considering the percentage of Gnus users who hack Emacs
7793 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7794 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7795 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7796 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7797 ;; MID or mail: To avoid too many false positives we don't try to catch
7798 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7799 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7800 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7801 ;; so that non-ambiguous entries (see above) match first.
7802 (gnus-button-mid-or-mail-regexp
7803 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7804 "Alist of regexps matching buttons in article bodies.
7806 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7807 REGEXP: is the string (case insensitive) matching text around the button (can
7808 also be Lisp expression evaluating to a string),
7809 BUTTON: is the number of the regexp grouping actually matching the button,
7810 FORM: is a Lisp expression which must eval to true for the button to
7812 CALLBACK: is the function to call when the user push this button, and each
7813 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7815 CALLBACK can also be a variable, in that case the value of that
7816 variable it the real callback function."
7817 :group 'gnus-article-buttons
7818 :type '(repeat (list (choice regexp variable sexp)
7819 (integer :tag "Button")
7821 (function :tag "Callback")
7824 (integer :tag "Regexp group")))))
7825 (put 'gnus-button-alist 'risky-local-variable t)
7827 (defcustom gnus-header-button-alist
7828 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7829 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7830 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7831 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7832 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7833 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7834 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7835 0 (>= gnus-button-browse-level 0) browse-url 0)
7836 ("^Subject:" gnus-button-url-regexp
7837 0 (>= gnus-button-browse-level 0) browse-url 0)
7838 ("^[^:]+:" gnus-button-url-regexp
7839 0 (>= gnus-button-browse-level 0) browse-url 0)
7840 ("^OpenPGP:.*url=" gnus-button-url-regexp
7841 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7842 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7843 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7844 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7845 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7846 "Alist of headers and regexps to match buttons in article heads.
7848 This alist is very similar to `gnus-button-alist', except that each
7849 alist has an additional HEADER element first in each entry:
7851 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7853 HEADER is a regexp to match a header. For a fuller explanation, see
7854 `gnus-button-alist'."
7855 :group 'gnus-article-buttons
7856 :group 'gnus-article-headers
7857 :type '(repeat (list (regexp :tag "Header")
7858 (choice regexp variable)
7859 (integer :tag "Button")
7861 (function :tag "Callback")
7864 (integer :tag "Regexp group")))))
7865 (put 'gnus-header-button-alist 'risky-local-variable t)
7869 (defun gnus-article-push-button (event)
7870 "Check text under the mouse pointer for a callback function.
7871 If the text under the mouse pointer has a `gnus-callback' property,
7872 call it with the value of the `gnus-data' text property."
7874 (set-buffer (window-buffer (posn-window (event-start event))))
7875 (let* ((pos (posn-point (event-start event)))
7876 (data (get-text-property pos 'gnus-data))
7877 (fun (get-text-property pos 'gnus-callback)))
7880 (funcall fun data))))
7882 (defun gnus-article-press-button ()
7883 "Check text at point for a callback function.
7884 If the text at point has a `gnus-callback' property,
7885 call it with the value of the `gnus-data' text property."
7887 (let ((data (get-text-property (point) 'gnus-data))
7888 (fun (get-text-property (point) 'gnus-callback)))
7890 (funcall fun data))))
7892 (defun gnus-article-highlight (&optional force)
7893 "Highlight current article.
7894 This function calls `gnus-article-highlight-headers',
7895 `gnus-article-highlight-citation',
7896 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7897 do the highlighting. See the documentation for those functions."
7898 (interactive (list 'force))
7899 (gnus-article-highlight-headers)
7900 (gnus-article-highlight-citation force)
7901 (gnus-article-highlight-signature)
7902 (gnus-article-add-buttons)
7903 (gnus-article-add-buttons-to-head))
7905 (defun gnus-article-highlight-some (&optional _force)
7906 "Highlight current article.
7907 This function calls `gnus-article-highlight-headers',
7908 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7909 do the highlighting. See the documentation for those functions."
7910 (interactive (list 'force))
7911 (gnus-article-highlight-headers)
7912 (gnus-article-highlight-signature)
7913 (gnus-article-add-buttons))
7915 (defun gnus-article-highlight-headers ()
7916 "Highlight article headers as specified by `gnus-header-face-alist'."
7918 (gnus-with-article-headers
7919 (let (regexp header-face field-face from hpoints fpoints)
7920 (dolist (entry gnus-header-face-alist)
7921 (goto-char (point-min))
7922 (setq regexp (concat "^\\("
7923 (if (string-equal "" (nth 0 entry))
7927 header-face (nth 1 entry)
7928 field-face (nth 2 entry))
7929 (while (and (re-search-forward regexp nil t)
7933 (unless (search-forward ":" nil t)
7935 (when (and header-face
7936 (not (memq (point) hpoints)))
7937 (push (point) hpoints)
7938 (put-text-property from (point) 'face header-face))
7939 (when (and field-face
7940 (not (memq (setq from (point)) fpoints)))
7942 (if (re-search-forward "^[^ \t]" nil t)
7944 (goto-char (point-max)))
7945 (put-text-property from (point) 'face field-face)))))))
7947 (defun gnus-article-highlight-signature ()
7948 "Highlight the signature in an article.
7949 It does this by highlighting everything after
7950 `gnus-signature-separator' using the face `gnus-signature'."
7952 (gnus-with-article-buffer
7953 (let ((inhibit-point-motion-hooks t))
7955 (when (and gnus-signature-face
7956 (gnus-article-narrow-to-signature))
7957 (overlay-put (make-overlay (point-min) (point-max) nil t)
7958 'face gnus-signature-face)
7960 (gnus-article-search-signature)
7961 (let ((start (match-beginning 0))
7962 (end (set-marker (make-marker) (1+ (match-end 0)))))
7963 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7966 (defun gnus-button-in-region-p (b e prop)
7967 "Say whether PROP exists in the region."
7968 (text-property-not-all b e prop nil))
7970 (defun gnus-article-add-buttons ()
7971 "Find external references in the article and make buttons of them.
7972 \"External references\" are things like Message-IDs and URLs, as
7973 specified by `gnus-button-alist'."
7975 (gnus-with-article-buffer
7976 (let ((inhibit-point-motion-hooks t)
7977 (case-fold-search t)
7978 (alist gnus-button-alist)
7980 ;; We skip the headers.
7983 (while (setq entry (pop alist))
7984 (setq regexp (eval (car entry)))
7986 (while (re-search-forward regexp nil t)
7987 (let ((start (match-beginning (nth 1 entry)))
7988 (end (match-end (nth 1 entry)))
7989 (from (match-beginning 0)))
7990 (when (and (eval (nth 2 entry))
7991 (not (gnus-button-in-region-p
7992 start end 'gnus-callback)))
7993 ;; That optional form returned non-nil, so we add the
7995 (setq from (set-marker (make-marker) from))
7996 (unless (and (eq (car entry) 'gnus-button-url-regexp)
7997 (gnus-article-extend-url-button from start end))
7998 (gnus-article-add-button start end
7999 'gnus-button-push (list from entry))
8002 'gnus-string (buffer-substring-no-properties
8005 (defun gnus-article-extend-url-button (beg start end)
8006 "Extend url button if url is folded into two or more lines.
8007 Return non-nil if button is extended. BEG is a marker that points to
8008 the beginning position of a text containing url. START and END are
8009 the endpoints of a url button before it is extended. The concatenated
8010 url is put as the `gnus-button-url' overlay property on the button."
8011 (let ((opoint (point))
8012 (points (list start end))
8017 (not (looking-at "[\t ]*[\">]")))
8021 "\\(?:\"\\|\\(<\\)\\)[\t ]*\\(?:url[\t ]*:[\t ]*\\)?\\'"
8022 (buffer-substring (point-at-bol) start)))
8024 (setq url (list (buffer-substring start end))
8025 delim (if (match-beginning 1) ">" "\""))
8027 (setq regexp (concat
8028 (when (and (looking-at
8029 message-cite-prefix-regexp)
8030 (< (match-end 0) start))
8031 (regexp-quote (match-string 0)))
8033 [\t ]*\\(?:\\([^\t\n \">]+\\)[\t ]*$\\|\\([^\t\n \">]*\\)[\t ]*"
8037 (and (looking-at regexp)
8040 (push (or (match-string 2)
8043 (push (setq end (or (match-end 2)
8046 (push (or (match-beginning 2)
8047 (match-beginning 1))
8049 (match-beginning 2)))
8050 (let (gnus-article-mouse-face widget-mouse-face)
8052 (gnus-article-add-button (pop points) (pop points)
8054 (list beg (assq 'gnus-button-url-regexp
8055 gnus-button-alist)))))
8056 (let ((overlay (make-overlay start end)))
8057 (overlay-put overlay 'evaporate t)
8058 (overlay-put overlay 'gnus-button-url
8059 (list (mapconcat 'identity (nreverse url) "")))
8060 (when gnus-article-mouse-face
8061 (overlay-put overlay 'mouse-face gnus-article-mouse-face)))
8063 (goto-char opoint))))
8065 ;; Add buttons to the head of an article.
8066 (defun gnus-article-add-buttons-to-head ()
8067 "Add buttons to the head of the article."
8069 (gnus-with-article-headers
8071 (dolist (entry gnus-header-button-alist)
8072 ;; Each alist entry.
8073 (goto-char (point-min))
8074 (while (re-search-forward (car entry) nil t)
8075 ;; Each header matching the entry.
8076 (setq beg (match-beginning 0))
8077 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
8078 (match-beginning 0))
8081 (while (re-search-forward (eval (nth 1 entry)) end t)
8082 ;; Each match within a header.
8083 (let* ((entry (cdr entry))
8084 (start (match-beginning (nth 1 entry)))
8085 (end (match-end (nth 1 entry)))
8086 (form (nth 2 entry)))
8087 (goto-char (match-end 0))
8089 (gnus-article-add-button
8090 start end (nth 3 entry)
8091 (buffer-substring (match-beginning (nth 4 entry))
8092 (match-end (nth 4 entry)))))))
8093 (goto-char end))))))
8095 ;;; External functions:
8097 (defun gnus-article-add-button (from to fun &optional data text)
8098 "Create a button between FROM and TO with callback FUN and data DATA."
8099 (when gnus-article-button-face
8100 (overlay-put (make-overlay from to nil t)
8101 'face gnus-article-button-face))
8102 (add-text-properties
8104 (nconc (and gnus-article-mouse-face
8105 (list 'mouse-face gnus-article-mouse-face))
8106 (list 'gnus-callback fun)
8107 (and data (list 'gnus-data data))))
8108 (widget-convert-button 'link from to :action 'gnus-widget-press-button
8109 :help-echo (or text "Follow the link")
8110 :keymap gnus-url-button-map))
8112 (defun gnus-article-copy-string ()
8113 "Copy the string in the button to the kill ring."
8115 (gnus-article-check-buffer)
8116 (let ((data (get-text-property (point) 'gnus-string)))
8120 (copy-region-as-kill (point-min) (point-max))
8121 (message "Copied %s" data)))))
8123 ;;; Internal functions:
8125 (defun gnus-article-set-globals ()
8126 (with-current-buffer gnus-summary-buffer
8127 (gnus-set-global-variables)))
8129 (defun gnus-signature-toggle (end)
8130 (gnus-with-article-buffer
8131 (let ((inhibit-point-motion-hooks t))
8132 (if (text-property-any end (point-max) 'article-type 'signature)
8134 (gnus-delete-wash-type 'signature)
8135 (gnus-remove-text-properties-when
8136 'article-type 'signature end (point-max)
8137 (cons 'article-type (cons 'signature
8138 gnus-hidden-properties))))
8139 (gnus-add-wash-type 'signature)
8140 (gnus-add-text-properties-when
8141 'article-type nil end (point-max)
8142 (cons 'article-type (cons 'signature
8143 gnus-hidden-properties)))))
8144 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
8145 (gnus-set-mode-line 'article))))
8147 (defun gnus-button-push (marker-and-entry)
8148 ;; Push button starting at MARKER.
8150 (let* ((marker (car marker-and-entry))
8151 (entry (cadr marker-and-entry))
8152 (regexp (car entry))
8153 (inhibit-point-motion-hooks t))
8155 ;; This is obviously true, or something bad is happening :)
8156 ;; But we need it to have the match-data
8157 (when (looking-at (or (if (symbolp regexp)
8158 (symbol-value regexp)
8160 (let ((fun (nth 3 entry))
8161 (args (or (and (eq (car entry) 'gnus-button-url-regexp)
8162 (get-char-property marker 'gnus-button-url))
8163 (mapcar (lambda (group)
8164 (let ((string (match-string group)))
8165 (set-text-properties
8166 0 (length string) nil string)
8168 (nthcdr 4 entry)))))
8174 (fboundp (symbol-value fun)))
8175 (apply (symbol-value fun) args))
8177 (gnus-message 1 "You must define `%S' to use this button"
8178 (cons fun args)))))))))
8180 (defun gnus-parse-news-url (url)
8181 (let (scheme server port group message-id articles)
8184 (goto-char (point-min))
8185 (when (looking-at "\\([A-Za-z]+\\):")
8186 (setq scheme (match-string 1))
8187 (goto-char (match-end 0)))
8188 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
8189 (setq server (match-string 1))
8190 (setq port (if (stringp (match-string 3))
8191 (string-to-number (match-string 3))
8193 (goto-char (match-end 0)))
8196 ((looking-at "\\(.*@.*\\)")
8197 (setq message-id (match-string 1)))
8198 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
8199 (setq group (match-string 1)
8200 articles (split-string (match-string 2) "-")))
8201 ((looking-at "\\([^/]+\\)/?")
8202 (setq group (match-string 1)))
8204 (error "Unknown news URL syntax"))))
8205 (list scheme server port group message-id articles)))
8207 (defvar nntp-port-number)
8209 (defun gnus-button-handle-news (url)
8211 (destructuring-bind (_scheme server port group message-id _articles)
8212 (gnus-parse-news-url url)
8215 (with-current-buffer gnus-summary-buffer
8217 (let ((gnus-refer-article-method
8218 (nconc (list (list 'nntp server))
8219 gnus-refer-article-method))
8220 (nntp-port-number (or port "nntp")))
8221 (gnus-message 7 "Fetching %s with %s"
8222 message-id gnus-refer-article-method)
8223 (gnus-summary-refer-article message-id))
8224 (gnus-summary-refer-article message-id))))
8226 (gnus-button-fetch-group url)))))
8228 (defun gnus-button-patch (library line)
8229 "Visit an Emacs Lisp library LIBRARY on line LINE."
8231 (let ((file (locate-library (file-name-nondirectory library))))
8233 (error "Couldn't find library %s" library))
8235 (goto-char (point-min))
8236 (forward-line (1- (string-to-number line)))))
8238 (defun gnus-button-handle-man (url)
8240 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8241 (when (eq gnus-button-man-handler 'woman)
8242 (setq url (replace-regexp-in-string "([1-9][X1a-z]*).*\\'" "" url)))
8243 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
8244 (funcall gnus-button-man-handler url))
8246 (defun gnus-button-handle-info-url (url)
8247 "Fetch an info URL."
8248 (setq url (subst-char-in-string ?+ ?\ url))
8250 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
8251 (gnus-info-find-node
8252 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
8254 ")" (gnus-url-unhex-string (match-string 2 url)))))
8255 ((string-match "([^)\"]+)[^\"]+" url)
8257 (replace-regexp-in-string
8258 "\"" "" (replace-regexp-in-string "[\n\t ]+" " " url)))
8259 (gnus-info-find-node url))
8260 (t (error "Can't parse %s" url))))
8262 (defun gnus-button-handle-info-url-gnome (url)
8263 "Fetch GNOME style info URL."
8264 (setq url (subst-char-in-string ?_ ?\ url))
8265 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
8266 (gnus-info-find-node
8268 (gnus-url-unhex-string
8269 (match-string 1 url))
8271 (or (gnus-url-unhex-string
8272 (match-string 2 url))
8274 (error "Can't parse %s" url)))
8276 (defun gnus-button-handle-info-url-kde (url)
8277 "Fetch KDE style info URL."
8278 (gnus-info-find-node (gnus-url-unhex-string url)))
8280 ;; (info) will autoload info.el
8281 (declare-function Info-menu "info" (menu-item &optional fork))
8282 (declare-function Info-index-next "info" (num))
8284 (defun gnus-button-handle-info-keystrokes (url)
8285 "Call `info' when pushing the corresponding URL button."
8286 ;; For links like `C-h i d m gnus RET part RET , ,', `C-h i d m CC Mode RET'.
8287 (let (node indx comma)
8289 (concat "\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+"
8290 "\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
8291 "\\([ \t\n]+i[ \t\n]+[^ ]+ ?[^ ]+[ \t\n]+RET\\>"
8292 "\\(?:[ \t\n,]*\\)\\)?")
8294 (setq node (match-string 2 url)
8295 indx (match-string 3 url))
8296 (error "Can't parse %s" url))
8300 (when (> (length indx) 0)
8301 (string-match (concat "[ \t\n]+i[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET\\>"
8304 (setq comma (match-string 2 indx))
8305 (setq indx (match-string 1 indx))
8308 (dotimes (i (with-temp-buffer
8310 ;; Note: the XEmacs version of `how-many' takes
8311 ;; no optional argument.
8312 (goto-char (point-min))
8314 (Info-index-next 1)))
8317 (autoload 'pgg-snarf-keys-region "pgg")
8318 ;; Called after pgg-snarf-keys-region, which autoloads pgg.el.
8319 (declare-function pgg-display-output-buffer "pgg" (start end status))
8321 (defun gnus-button-openpgp (url)
8322 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
8324 (mm-url-insert-file-contents-external url)
8325 (pgg-snarf-keys-region (point-min) (point-max))
8326 (pgg-display-output-buffer nil nil nil)))
8328 (defun gnus-button-message-id (message-id)
8330 (with-current-buffer gnus-summary-buffer
8331 (gnus-summary-refer-article message-id)))
8333 (defun gnus-button-fetch-group (address &rest _ignore)
8334 "Fetch GROUP specified by ADDRESS."
8335 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
8337 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
8338 ;; for nntp:// and news://
8339 (setq address (match-string 3 address)))
8340 (if (not (string-match "[:/]" address))
8341 ;; This is just a simple group url.
8342 (gnus-group-read-ephemeral-group address gnus-select-method)
8345 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
8347 (error "Can't parse %s" address)
8348 (gnus-group-read-ephemeral-group
8349 (match-string 4 address)
8350 `(nntp ,(match-string 1 address)
8351 (nntp-address ,(match-string 1 address))
8352 (nntp-port-number ,(if (match-end 3)
8353 (match-string 3 address)
8356 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
8358 (defun gnus-url-parse-query-string (query &optional downcase)
8359 (let (retval pairs cur key val)
8360 (setq pairs (split-string query "&"))
8362 (setq cur (car pairs)
8364 (if (not (string-match "=" cur))
8366 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
8367 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
8369 (setq key (downcase key)))
8370 (setq cur (assoc key retval))
8372 (setcdr cur (cons val (cdr cur)))
8373 (setq retval (cons (list key val) retval)))))
8376 (defun gnus-url-mailto (url)
8377 ;; Send mail to someone
8378 (setq url (replace-regexp-in-string "\n" " " url))
8379 (when (string-match "mailto:/*\\(.*\\)" url)
8380 (setq url (substring url (match-beginning 1) nil)))
8381 (let* ((args (gnus-url-parse-query-string
8382 (if (string-match "^\\?" url)
8384 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
8385 (concat "to=" (match-string 1 url) "&"
8386 (match-string 2 url))
8387 (concat "to=" url)))))
8388 (subject (cdr-safe (assoc "subject" args)))
8392 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
8395 (message-position-on-field (caar args)))
8396 (insert (replace-regexp-in-string
8398 (mapconcat 'identity (reverse (cdar args)) ", ") nil t))
8399 (setq args (cdr args)))
8402 (message-goto-subject))))
8404 (defun gnus-button-embedded-url (address)
8405 "Activate ADDRESS with `browse-url'."
8406 (browse-url (gnus-strip-whitespace address)))
8408 ;;; Next/prev buttons in the article buffer.
8410 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
8411 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
8413 (defvar gnus-prev-page-map
8414 (let ((map (make-sparse-keymap)))
8415 (define-key map [mouse-2] 'gnus-button-prev-page)
8416 (define-key map "\r" 'gnus-button-prev-page)
8419 (defvar gnus-next-page-map
8420 (let ((map (make-sparse-keymap)))
8421 (define-key map [mouse-2] 'gnus-button-next-page)
8422 (define-key map "\r" 'gnus-button-next-page)
8425 (defun gnus-insert-prev-page-button ()
8427 (inhibit-read-only t))
8429 gnus-prev-page-line-format nil
8430 `(keymap ,gnus-prev-page-map
8432 gnus-callback gnus-article-button-prev-page
8433 article-type annotation))
8435 ;; Exclude a newline.
8438 (when gnus-article-button-face
8439 (overlay-put (make-overlay b e nil t)
8440 'face gnus-article-button-face))
8441 (widget-convert-button
8443 :action 'gnus-button-prev-page
8444 :button-keymap gnus-prev-page-map)))
8446 (defun gnus-button-next-page (&optional _args _more-args)
8447 "Go to the next page."
8449 (let ((win (selected-window)))
8450 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8451 (gnus-article-next-page)
8452 (select-window win)))
8454 (defun gnus-button-prev-page (&optional _args _more-args)
8455 "Go to the prev page."
8457 (let ((win (selected-window)))
8458 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8459 (gnus-article-prev-page)
8460 (select-window win)))
8462 (defun gnus-insert-next-page-button ()
8464 (inhibit-read-only t))
8465 (gnus-eval-format gnus-next-page-line-format nil
8466 `(keymap ,gnus-next-page-map
8468 gnus-callback gnus-article-button-next-page
8469 article-type annotation))
8471 ;; Exclude a newline.
8474 (when gnus-article-button-face
8475 (overlay-put (make-overlay b e nil t)
8476 'face gnus-article-button-face))
8477 (widget-convert-button
8479 :action 'gnus-button-next-page
8480 :button-keymap gnus-next-page-map)))
8482 (defun gnus-article-button-next-page (_arg)
8483 "Go to the next page."
8485 (let ((win (selected-window)))
8486 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8487 (gnus-article-next-page)
8488 (select-window win)))
8490 (defun gnus-article-button-prev-page (_arg)
8491 "Go to the prev page."
8493 (let ((win (selected-window)))
8494 (select-window (gnus-get-buffer-window gnus-article-buffer t))
8495 (gnus-article-prev-page)
8496 (select-window win)))
8498 (defvar gnus-decode-header-methods
8499 '(mail-decode-encoded-word-region)
8500 "List of methods used to decode headers.
8502 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
8503 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
8504 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
8505 whose names match REGEXP.
8508 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
8509 mail-decode-encoded-word-region
8510 (\"chinese\" . rfc1843-decode-region))
8513 (defvar gnus-decode-header-methods-cache nil)
8515 (defun gnus-multi-decode-header (start end)
8516 "Apply the functions from `gnus-encoded-word-methods' that match."
8517 (unless (and gnus-decode-header-methods-cache
8518 (eq gnus-newsgroup-name
8519 (car gnus-decode-header-methods-cache)))
8520 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
8521 (dolist (x gnus-decode-header-methods)
8523 (nconc gnus-decode-header-methods-cache (list x))
8524 (if (and gnus-newsgroup-name
8525 (string-match (car x) gnus-newsgroup-name))
8526 (nconc gnus-decode-header-methods-cache
8528 (let ((xlist gnus-decode-header-methods-cache))
8531 (narrow-to-region start end)
8533 (funcall (pop xlist) (point-min) (point-max))))))
8536 ;;; Treatment top-level handling.
8539 (defvar gnus-inhibit-article-treatments nil)
8541 ;; Dynamic variables.
8542 (defvar part-number) ;FIXME: Lacks a "gnus-" prefix.
8543 (defvar total-parts) ;FIXME: Lacks a "gnus-" prefix.
8544 (defvar gnus-treat-type)
8545 (defvar gnus-treat-condition)
8546 (defvar gnus-treat-length)
8548 (defun gnus-treat-article (condition
8549 &optional part-num total type)
8550 (let ((gnus-treat-condition condition)
8551 (part-number part-num)
8553 (gnus-treat-type type)
8554 (gnus-treat-length (- (point-max) (point-min)))
8555 (alist gnus-treatment-function-alist)
8556 (article-goto-body-goes-to-point-min-p t)
8560 (let ((list gnus-article-treat-types))
8562 (when (string-match (pop list) type)
8563 (throw 'found t)))))))
8564 (highlightp (gnus-visual-p 'article-highlight 'highlight))
8566 (gnus-run-hooks 'gnus-part-display-hook)
8567 (dolist (elem alist)
8570 (when (gnus-buffer-live-p gnus-summary-buffer)
8571 (set-buffer gnus-summary-buffer))
8572 (symbol-value (car elem))))
8573 (when (and (or (consp val)
8575 (or (not gnus-inhibit-article-treatments)
8576 (eq gnus-treat-condition 'head))
8577 (gnus-treat-predicate val)
8578 (or (not (get (car elem) 'highlight))
8581 (funcall (cadr elem)))))))
8583 (defun gnus-treat-predicate (val)
8587 (gnus-treat-condition
8588 (eq gnus-treat-condition val))
8590 (stringp (car val)))
8591 (apply 'gnus-or (mapcar `(lambda (s)
8592 (string-match s ,(or gnus-newsgroup-name "")))
8595 (let ((pred (pop val)))
8598 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
8600 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
8602 (not (gnus-treat-predicate (car val))))
8604 (equal (car val) gnus-treat-type))
8608 (error "%S is not a valid predicate" pred)))))
8616 (eq part-number total-parts))
8618 (< gnus-treat-length val))
8620 (error "%S is not a valid value" val))))
8622 (defun gnus-article-encrypt-body (protocol &optional n)
8623 "Encrypt the article body."
8626 (or gnus-article-encrypt-protocol
8627 (gnus-completing-read "Encrypt protocol"
8628 (mapcar 'car gnus-article-encrypt-protocol-alist)
8630 current-prefix-arg))
8631 ;; User might hit `K E' instead of `K e', so prompt once.
8632 (when (and gnus-article-encrypt-protocol
8634 (unless (gnus-y-or-n-p "Really encrypt article(s)? ")
8635 (error "Encrypt aborted")))
8636 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
8638 (error "Can't find the encrypt protocol %s" protocol))
8639 (if (member gnus-newsgroup-name '("nndraft:delayed"
8642 (error "Can't encrypt the article in group %s"
8643 gnus-newsgroup-name))
8644 (gnus-summary-iterate n
8645 (with-current-buffer gnus-summary-buffer
8646 (let ((mail-parse-charset gnus-newsgroup-charset)
8647 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
8648 (summary-buffer gnus-summary-buffer)
8650 (gnus-set-global-variables)
8651 (when (gnus-group-read-only-p)
8652 (error "The current newsgroup does not support article encrypt"))
8653 (gnus-summary-show-article t)
8655 (or (mail-header-references gnus-current-headers) ""))
8656 (set-buffer gnus-article-buffer)
8657 (let* ((inhibit-read-only t)
8659 (mapcar (lambda (field)
8660 (and (save-restriction
8661 (message-narrow-to-head)
8662 (goto-char (point-min))
8663 (search-forward field nil t))
8665 (message-narrow-to-field)
8667 (delete-region (point-min) (point-max))
8669 '("Content-Type:" "Content-Transfer-Encoding:"
8670 "Content-Disposition:"))))
8671 (message-narrow-to-head)
8672 (message-remove-header "MIME-Version")
8673 (goto-char (point-max))
8674 (setq point (point))
8675 (insert (apply 'concat headers))
8677 (narrow-to-region point (point-max))
8678 (let ((message-options message-options))
8679 (message-options-set 'message-sender user-mail-address)
8680 (message-options-set 'message-recipients user-mail-address)
8681 (message-options-set 'message-sign-encrypt 'not)
8683 (goto-char (point-min))
8684 (insert "MIME-Version: 1.0\n")
8686 (gnus-summary-edit-article-done
8687 references nil summary-buffer t))
8688 (when gnus-keep-backlog
8689 (gnus-backlog-remove-article
8690 (car gnus-article-current) (cdr gnus-article-current)))
8691 (gnus-flush-original-article-buffer)
8692 (when gnus-use-cache
8693 (gnus-cache-update-article
8694 (car gnus-article-current) (cdr gnus-article-current))))))))
8696 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
8697 "The following specs can be used:
8698 %t The security MIME type
8701 %D Details if button is pressed")
8703 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8704 "The following specs can be used:
8705 %t The security MIME type
8708 %D Details if button is pressed")
8710 (defvar gnus-mime-security-button-line-format-alist
8711 '((?t gnus-tmp-type ?s)
8712 (?i gnus-tmp-info ?s)
8713 (?d gnus-tmp-details ?s)
8714 (?D gnus-tmp-pressed-details ?s)))
8716 (defvar gnus-mime-security-button-commands
8717 '((gnus-article-press-button "\r" "Show Detail")
8721 (gnus-mime-security-save-part "o" "Save...")
8730 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8733 (defvar gnus-mime-security-button-map
8734 (let ((map (make-sparse-keymap)))
8735 (define-key map [mouse-2] 'gnus-article-push-button)
8736 (define-key map [down-mouse-3] 'gnus-mime-security-button-menu)
8737 (dolist (c gnus-mime-security-button-commands)
8738 (define-key map (cadr c) (car c)))
8742 gnus-mime-security-button-menu gnus-mime-security-button-map
8743 "Security button menu."
8747 (unless (eq (car c) 'undefined)
8748 (vector (caddr c) (car c) :active t)))
8749 gnus-mime-security-button-commands))))
8751 (defun gnus-mime-security-button-menu (event prefix)
8752 "Construct a context-sensitive menu of security commands."
8753 (interactive "e\nP")
8754 (save-window-excursion
8755 (let ((pos (event-start event)))
8756 (select-window (posn-window pos))
8757 (goto-char (posn-point pos))
8758 (gnus-article-check-buffer)
8759 (popup-menu gnus-mime-security-button-menu nil prefix))))
8761 (defvar gnus-mime-security-details-buffer nil)
8763 (defvar gnus-mime-security-button-pressed nil)
8765 (defvar gnus-mime-security-show-details-inline t
8766 "If non-nil, show details in the article buffer.")
8768 (defun gnus-mime-security-verify-or-decrypt (handle)
8769 (mm-remove-parts (cdr handle))
8770 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8771 point (inhibit-read-only t))
8773 (goto-char (car region)))
8774 (setq point (point))
8775 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8776 (let* ((mm-verify-option 'known)
8777 (mm-decrypt-option 'known)
8778 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8779 (unless (eq nparts (cdr handle))
8780 (mm-destroy-parts (cdr handle))
8781 (setcdr handle nparts))))
8782 (gnus-mime-display-security handle)
8784 (delete-region (point) (cdr region))
8785 (set-marker (car region) nil)
8786 (set-marker (cdr region) nil))
8789 (defun gnus-mime-security-show-details (handle)
8790 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8792 (gnus-message 5 "No details.")
8793 (if gnus-mime-security-show-details-inline
8794 (let ((gnus-mime-security-button-pressed
8795 (not (get-text-property (point) 'gnus-mime-details)))
8796 (gnus-mime-security-button-line-format
8797 (get-text-property (point) 'gnus-line-format))
8798 (inhibit-read-only t))
8800 (while (eq (get-text-property (point) 'gnus-line-format)
8801 gnus-mime-security-button-line-format)
8805 (narrow-to-region (point) (point))
8806 (gnus-insert-mime-security-button handle))
8807 (delete-region (point)
8808 (or (text-property-not-all
8811 gnus-mime-security-button-line-format)
8814 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8815 (with-current-buffer gnus-mime-security-details-buffer
8818 (setq gnus-mime-security-details-buffer
8819 (gnus-get-buffer-create "*MIME Security Details*")))
8820 (with-current-buffer gnus-mime-security-details-buffer
8822 (goto-char (point-min)))
8823 (pop-to-buffer gnus-mime-security-details-buffer)))))
8825 (defun gnus-mime-security-press-button (handle)
8827 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8828 (gnus-mime-security-show-details handle)
8829 (gnus-mime-security-verify-or-decrypt handle))))
8831 (defun gnus-insert-mime-security-button (handle &optional _displayed)
8832 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8835 (or (nth 2 (assoc protocol mm-verify-function-alist))
8836 (nth 2 (assoc protocol mm-decrypt-function-alist))
8838 (if (equal (car handle) "multipart/signed")
8839 " Signed" " Encrypted")
8842 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8845 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8846 gnus-tmp-pressed-details
8848 (setq gnus-tmp-details
8849 (if gnus-tmp-details
8850 (concat "\n" gnus-tmp-details)
8852 (setq gnus-tmp-pressed-details
8853 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8858 gnus-mime-security-button-line-format
8859 gnus-mime-security-button-line-format-alist
8860 `(keymap ,gnus-mime-security-button-map
8861 gnus-callback gnus-mime-security-press-button
8862 gnus-line-format ,gnus-mime-security-button-line-format
8863 gnus-mime-details ,gnus-mime-security-button-pressed
8864 article-type annotation
8867 ;; Exclude a newline.
8870 (when gnus-article-button-face
8871 (overlay-put (make-overlay b e nil t)
8872 'face gnus-article-button-face))
8873 (widget-convert-button
8876 :action 'gnus-widget-press-button
8877 :button-keymap gnus-mime-security-button-map
8881 "%S: show detail; %S: more options"
8885 (defun gnus-mime-display-security (handle)
8887 (narrow-to-region (point) (point))
8888 (unless (gnus-unbuttonized-mime-type-p (car handle))
8889 (gnus-insert-mime-security-button handle))
8890 (gnus-mime-display-part (cadr handle))
8893 (unless (gnus-unbuttonized-mime-type-p (car handle))
8894 (let ((gnus-mime-security-button-line-format
8895 gnus-mime-security-button-end-line-format))
8896 (gnus-insert-mime-security-button handle)))
8897 (mm-set-handle-multipart-parameter
8898 handle 'gnus-region (cons (point-min-marker) (point-max-marker)))
8899 (goto-char (point-max))))
8901 (defun gnus-mime-security-run-function (function)
8902 "Run FUNCTION with the security part under point."
8903 (gnus-article-check-buffer)
8904 (let ((data (get-text-property (point) 'gnus-data))
8906 (when (and (stringp (car-safe data))
8907 (setq buffer (mm-handle-multipart-original-buffer data))
8908 (setq handle (cadr data)))
8909 (if (bufferp (mm-handle-buffer handle))
8911 (setq handle (cons buffer (copy-sequence (cdr handle))))
8912 (mm-handle-set-undisplayer handle nil))
8913 (setq handle (mm-make-handle
8915 (mm-handle-multipart-ctl-parameter handle 'protocol)
8916 nil nil nil nil nil nil)))
8917 (funcall function handle))))
8919 (defun gnus-mime-security-save-part ()
8920 "Save the security part under point."
8922 (gnus-mime-security-run-function 'mm-save-part))
8924 (defun gnus-mime-security-pipe-part ()
8925 "Pipe the security part under point to a process."
8927 (gnus-mime-security-run-function 'mm-pipe-part))
8931 (run-hooks 'gnus-art-load-hook)
8933 ;;; gnus-art.el ends here